@graphrefly/graphrefly 0.43.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 (279) 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-KVV66NN2.js → chunk-2T7U5EU6.js} +1 -1
  4. package/dist/chunk-5M4CCMMD.js +45 -0
  5. package/dist/{chunk-I7IGYPSL.js → chunk-5XJ6B66J.js} +1 -1
  6. package/dist/{chunk-OFZG3TB3.js → chunk-6X7AFUJV.js} +1 -1
  7. package/dist/{chunk-EBW4V6JN.js → chunk-7K6PWTDQ.js} +1 -1
  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-K2Q24F5T.js → chunk-CB676TKJ.js} +1 -1
  14. package/dist/{chunk-SUWT3ZON.js → chunk-CE6TI2TL.js} +1 -1
  15. package/dist/{chunk-VOPGGIL7.js → chunk-CLVB32RD.js} +1 -1
  16. package/dist/{chunk-V5A7M7RJ.js → chunk-CRVT7D2P.js} +1 -1
  17. package/dist/chunk-D7GPHKFH.js +1 -0
  18. package/dist/{chunk-OCKEEPRJ.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-TPKQW72B.js → chunk-HIDYF36O.js} +1 -1
  23. package/dist/chunk-HITNVN6B.js +3 -0
  24. package/dist/{chunk-P6C4WHZO.js → chunk-HY4DJBA7.js} +1 -1
  25. package/dist/chunk-KZIEYVXN.js +1 -0
  26. package/dist/{chunk-O2BLLH7M.js → chunk-N4MQX6JU.js} +1 -1
  27. package/dist/{chunk-4YAN45KM.js → chunk-N7FHEL4D.js} +1 -1
  28. package/dist/chunk-NTEURFZH.js +1 -0
  29. package/dist/{chunk-OYJKFY7V.js → chunk-OIVP6KFV.js} +1 -1
  30. package/dist/{chunk-Q4U3A3L5.js → chunk-OPHBU3LG.js} +1 -1
  31. package/dist/{chunk-PT7W5FCD.js → chunk-OYQOZP2F.js} +1 -1
  32. package/dist/{chunk-6HOSXQKF.js → chunk-PTZK576G.js} +1 -1
  33. package/dist/{chunk-S3EEIPO7.js → chunk-ST7UXLWR.js} +1 -1
  34. package/dist/chunk-SVY7VUYU.js +1 -0
  35. package/dist/{chunk-QYVXF7GW.js → chunk-TK3NWWD4.js} +1 -1
  36. package/dist/chunk-UNGSTR4X.js +61 -0
  37. package/dist/{chunk-VQ4A6T2A.js → chunk-VV4N5P64.js} +1 -1
  38. package/dist/{chunk-FDQGFWLF.js → chunk-W3I423PS.js} +1 -1
  39. package/dist/{chunk-XG62INFA.js → chunk-WJR24TAG.js} +1 -1
  40. package/dist/{chunk-F3IGTWCQ.js → chunk-XTGKMHSW.js} +1 -1
  41. package/dist/{chunk-JQFH2DV6.js → chunk-YBB7ZGTY.js} +1 -1
  42. package/dist/{chunk-CUNIRONA.js → chunk-Z4NPUARF.js} +1 -1
  43. package/dist/{chunk-KRH66M4O.js → chunk-ZGNQRPDT.js} +1 -1
  44. package/dist/{chunk-JNWRYDJN.js → chunk-ZKPSFFKU.js} +1 -1
  45. package/dist/{chunk-FG4TKHMC.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-O7fucFrU.d.cts → index-5k1T6jl0.d.cts} +9 -9
  119. package/dist/{index-DyR7eU5S.d.cts → index-9770hRuQ.d.cts} +4 -4
  120. package/dist/{index-COD1kVoS.d.cts → index-B-_tFaqV.d.cts} +4 -4
  121. package/dist/{index-CLon-IWF.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-DSZ3ZCHF.d.ts → index-BHskSB8v.d.ts} +28 -17
  126. package/dist/{index-CDXc9zKM.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-K0_0eR8g.d.ts → index-BoJ5JHxI.d.ts} +3 -3
  131. package/dist/{index-JZUPJIJy.d.ts → index-BocU7pqs.d.ts} +4 -4
  132. package/dist/{index-ChOyVLKm.d.cts → index-BrPrLl4e.d.cts} +1 -1
  133. package/dist/{index-BiX1Nkgx.d.cts → index-BxNs2HB9.d.cts} +22 -8
  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-D4Y1cMG0.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-cm1GNcWE.d.ts → index-CBGUK09R.d.ts} +4 -4
  141. package/dist/{index-0rKFCVFp.d.cts → index-CC-AvFTy.d.cts} +3 -3
  142. package/dist/{index-C59mYFKp.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-D-AEQVLo.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-CPT7C_f1.d.ts → index-CZ3r5Rxp.d.ts} +4 -4
  151. package/dist/{index-BojK2fwH.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-wAzD9yVj.d.ts → index-CdTelp1M.d.ts} +8 -4
  154. package/dist/{index-CQG3D1cp.d.ts → index-CeFiHtAg.d.ts} +4 -4
  155. package/dist/{index-RV_yDjOX.d.cts → index-Cj3WohTd.d.cts} +8 -4
  156. package/dist/{index-BAOD98JD.d.cts → index-Climxqsu.d.cts} +4 -4
  157. package/dist/{index-O16yXPK4.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-C9pjcz3l.d.cts → index-D0aciIex.d.cts} +3 -3
  162. package/dist/{index-DwigL4lY.d.ts → index-DHen9Klo.d.ts} +22 -8
  163. package/dist/{index-BwLvVVsy.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-CAC_rNzm.d.ts → index-DisjX8a-.d.ts} +40 -8
  167. package/dist/{index-B5iz82A3.d.cts → index-UPSiS-X7.d.cts} +49 -24
  168. package/dist/{index-CZQXo5tH.d.ts → index-Yq60JP3s.d.ts} +3 -3
  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-Dh_HJ82K.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-DPqKDk59.d.cts → pipeline-graph-CIKhynsF.d.cts} +11 -6
  253. package/dist/{pipeline-graph-loP57TBA.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-DLwvMr3F.d.ts → sugar-DQjFmVqb.d.cts} +178 -2
  262. package/dist/{sugar-DyVGtczU.d.cts → sugar-fhLIE7TT.d.ts} +178 -2
  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-3XDYJRYU.js +0 -1
  269. package/dist/chunk-4I45FVQS.js +0 -1
  270. package/dist/chunk-626TESAC.js +0 -3
  271. package/dist/chunk-INQD2KRQ.js +0 -1
  272. package/dist/chunk-LYCLF26R.js +0 -1
  273. package/dist/chunk-NON4NLIC.js +0 -45
  274. package/dist/chunk-QE4IGY7I.js +0 -61
  275. package/dist/chunk-VNC3TMVY.js +0 -1
  276. package/dist/chunk-Y4NI3X7O.js +0 -84
  277. package/dist/meta-BgVAsg9j.d.ts +0 -102
  278. package/dist/meta-vE8bxW1E.d.cts +0 -102
  279. package/dist/resilience-YIWPK4YC.js +0 -1
@@ -1 +1 @@
1
- import{a as B}from"./chunk-4VVTGLXJ.js";import{c as h}from"./chunk-35JTVPOX.js";import{m as k}from"./chunk-V5A7M7RJ.js";import{D as N,F as w,G as P,o as U}from"./chunk-LYCLF26R.js";import{a as A,b as p,c as W,d as m,i as a,j as b}from"./chunk-CK2E7BTU.js";function c(d){return{describeKind:"derived",...d}}function S(d){return{describeKind:"derived",partial:!0,...d}}function Z(d,i,s){return N([d],(t,e)=>{let n=t[0];if(n==null||n.length===0){e.down([[m]]);return}for(let o of n)e.emit(i(o))},{...c(s),meta:{...h("map"),...s?.meta??{}}})}function V(d,i,s){return N([d],(t,e)=>{let n=t[0];if(n==null||n.length===0){e.down([[m]]);return}let o=!1;for(let r of n)i(r)&&(e.emit(r),o=!0);o||e.down([[m]])},{...c(s),meta:{...h("filter"),...s?.meta??{}}})}function $(d,i,s,t){return N([d],(e,n,o)=>{"acc"in o.store||(o.store.acc=s);let r=e[0];if(r==null||r.length===0){n.down([[m]]);return}for(let u of r)o.store.acc=i(o.store.acc,u),n.emit(o.store.acc)},{...c(t),initial:s,resetOnTeardown:!0,meta:{...h("scan",{initial:s}),...t?.meta??{}}})}function ee(d,i,s,t){return N([d],(e,n,o)=>{if("acc"in o.store||(o.store.acc=s),o.terminalDeps[0]===!0){n.emit(o.store.acc),n.down([[a]]);return}let r=e[0];if(r==null||r.length===0){n.down([[m]]);return}for(let u of r)o.store.acc=i(o.store.acc,u)},{...c(t),completeWhenDepsComplete:!1,meta:{...h("reduce",{initial:s}),...t?.meta??{}}})}function C(d,i,s){return i<=0?N([d],(t,e,n)=>{n.store.completed||(n.store.completed=!0,e.down([[a]]))},{...c(s),completeWhenDepsComplete:!1,meta:{...h("take",{count:i}),...s?.meta??{}}}):N([d],(t,e,n)=>{if("taken"in n.store||(n.store.taken=0),n.store.done){e.down([[m]]);return}if(n.terminalDeps[0]===!0){n.store.done=!0,e.down([[a]]);return}let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}for(let r of o)if(n.store.taken++,e.emit(r),n.store.taken>=i){n.store.done=!0,e.down([[a]]);return}},{...c(s),completeWhenDepsComplete:!1,meta:{...h("take",{count:i}),...s?.meta??{}}})}function K(d,i,s){return N([d],(t,e,n)=>{"skipped"in n.store||(n.store.skipped=0);let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}let r=!1;for(let u of o)n.store.skipped++,n.store.skipped<=i||(e.emit(u),r=!0);r||e.down([[m]])},c(s))}function ne(d,i,s){return N([d],(t,e,n)=>{if(n.store.done){e.down([[m]]);return}let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}for(let r of o){if(!i(r)){n.store.done=!0,e.down([[a]]);return}e.emit(r)}},{...c(s),completeWhenDepsComplete:!1})}function te(d,i,s){let t=s?.predicate??(o=>o[0]===p),{predicate:e,...n}=s??{};return w(o=>{let r=!1,u=d.subscribe(l=>{if(!r)for(let T of l){if(r)return;T[0]===p?o.emit(T[1]):(T[0]===a||T[0]===b)&&(r=!0,o.down([T]))}}),f=i.subscribe(l=>{if(!r)for(let T of l){if(r)return;if(t(T)){r=!0,o.down([[a]]);return}}});return()=>{u(),f()}},c(n))}function oe(d,i){return C(d,1,i)}function re(d,i){let{defaultValue:s,...t}=i??{},e=i!=null&&Object.hasOwn(i,"defaultValue");return N([d],(n,o,r)=>{if(r.terminalDeps[0]===!0){r.store.has?o.emit(r.store.latest):e&&o.emit(s),o.down([[a]]);return}let u=n[0];if(u==null||u.length===0){o.down([[m]]);return}r.store.latest=u.at(-1),r.store.has=!0},{...c(t),completeWhenDepsComplete:!1})}function se(d,i,s){return C(V(d,i,s),1,s)}function ie(d,i,s){return C(K(d,i,s),1,s)}function ue(d,i,s){if(typeof i=="function")return N([d],(e,n)=>{let o=e[0];if(o==null||o.length===0){n.down([[m]]);return}for(let r of o)i(r),n.emit(r)},{...c(s),meta:{...h("tap"),...s?.meta??{}}});let t=i;return N([d],(e,n,o)=>{if(o.terminalDeps[0]!==void 0){o.terminalDeps[0]===!0?(t.complete?.(),n.down([[a]])):(t.error?.(o.terminalDeps[0]),n.down([[b,o.terminalDeps[0]]]));return}let r=e[0];if(r==null||r.length===0){n.down([[m]]);return}for(let u of r)t.data?.(u),n.emit(u)},{...c(s),completeWhenDepsComplete:!1,meta:{...h("tap"),...s?.meta??{}}})}function q(d,i,s){let t=s?.where??(n=>n!=null),e=!1;return N([d],(n,o)=>{let r=n[0];if(r==null||r.length===0){o.down([[m]]);return}for(let u of r)!e&&t(u)&&(e=!0,i(u)),o.emit(u)},c(s))}var fe=q;function de(d,i=Object.is,s){return N([d],(t,e,n)=>{let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}let r=!1;for(let u of o)n.store.hasPrev&&i(n.store.prev,u)||(n.store.prev=u,n.store.hasPrev=!0,e.emit(u),r=!0);r||e.down([[m]])},{...c(s),meta:{...h("distinctUntilChanged"),...s?.meta??{}}})}function le(d,i){return N([d],(s,t,e)=>{let n=s[0];if(n==null||n.length===0){t.down([[m]]);return}let o=!1;for(let r of n)if(!e.store.hasPrev)e.store.prev=r,e.store.hasPrev=!0;else{let u=[e.store.prev,r];e.store.prev=r,t.emit(u),o=!0}o||t.down([[m]])},c(i))}function F(...d){let i=[...d];return P(i,s=>s,{...c(),equals:(s,t)=>{if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(!Object.is(s[e],t[e]))return!1;return!0}})}function ae(d,i,s){return N([d,i],(t,e,n)=>{let o=t[0],r=t[1],u=r!=null&&r.length>0?r.at(-1):n.prevData[1];if(o!=null&&o.length>0){if(!(r!=null&&r.length>0)&&n.prevData[1]===void 0){e.down([[m]]);return}for(let f of o)e.emit([f,u])}else e.down([[m]])},{...S(s),meta:{...h("withLatestFrom"),...s?.meta??{}}})}function ce(...d){return d.length===0?w(i=>{i.down([[a]])},{...c(),meta:{...h("merge")}}):w(i=>{let s=d.length,t=0,e=[];for(let n of d){let o=n.subscribe(r=>{for(let u of r)u[0]===p?i.emit(u[1]):u[0]===a?(t+=1,t>=s&&i.down([[a]])):u[0]===b&&i.down([u])});e.push(o)}return()=>{for(let n of e)n()}},{...c(),meta:{...h("merge")}})}function Te(...d){let i=d.length;return i===0?w(s=>{s.emit([]),s.down([[a]])},c()):w(s=>{let t=Array.from({length:i},()=>[]),e=i;function n(){for(;t.every(r=>r.length>0);){let r=t.map(u=>u.shift());s.emit(r)}}let o=[];for(let r=0;r<i;r++){let u=r,f=d[r].subscribe(l=>{for(let T of l)T[0]===p?(t[u].push(T[1]),n()):T[0]===a?(e-=1,(e===0||t[u].length===0)&&s.down([[a]])):T[0]===b&&s.down([T])});o.push(f)}return()=>{for(let r of o)r()}},c())}function pe(d,i,s){return w(t=>{let e=0,n=[],o,r;return r=i.subscribe(u=>{for(let f of u)e===0?f[0]===p?n.push(f[1]):f[0]===b&&t.down([f]):f[0]===p?t.emit(f[1]):(f[0]===a||f[0]===b)&&t.down([f])}),o=d.subscribe(u=>{for(let f of u)if(e===0)if(f[0]===p)t.emit(f[1]);else if(f[0]===a){e=1;for(let l of n)t.emit(l);n.length=0}else f[0]===b&&t.down([f])}),()=>{o?.(),r?.()}},c(s))}function me(...d){return d.length===0?w(i=>{i.down([[a]])},c()):d.length===1?N([d[0]],(i,s)=>{let t=i[0];if(t==null||t.length===0){s.down([[m]]);return}for(let e of t)s.emit(e)},c()):w(i=>{let s=null,t=[];for(let e=0;e<d.length;e++){let n=e,o=d[e].subscribe(r=>{for(let u of r){if(s!==null&&n!==s)return;u[0]===p?(s===null&&(s=n),i.emit(u[1])):(u[0]===a||u[0]===b)&&(s===null||n===s)&&i.down([u])}});t.push(o)}return()=>{for(let e of t)e()}},c())}function I(d,i,s){let t,e=!1,n=()=>{e||(e=!0,s())};return t=d.subscribe(o=>{let r=!1,u=!1;for(let f of o)f[0]!==A&&(f[0]===p?i.emit(f[1]):f[0]===a?r=!0:f[0]===b?(u=!0,i.down([f])):(f[0]===W||f[0]===m)&&i.down([f]));u?(t?.(),t=void 0,n()):r&&n()}),()=>{t?.(),t=void 0}}function be(d,i,s){let t,e=!1;function n(){t?.(),t=void 0}return N([d],(o,r,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){n();return}if(u.terminalDeps[0]===!0){e=!0,t||r.down([[a]]);return}let f=o[0];if(!(f==null||f.length===0))return n(),t=I(k(i(f[f.length-1])),r,()=>{n(),e&&r.down([[a]])}),{deactivate:()=>{n(),e=!1}}},{...c(s),completeWhenDepsComplete:!1,meta:{...h("switchMap"),...s?.meta??{}}})}function we(d,i,s){let t,e=!1;function n(){t?.(),t=void 0}return N([d],(o,r,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){n();return}if(u.terminalDeps[0]===!0){e=!0,t||r.down([[a]]);return}let f=o[0];if(!(f==null||f.length===0))return t===void 0?t=I(k(i(f[0])),r,()=>{n(),e&&r.down([[a]])}):r.down([[m]]),{deactivate:()=>{n(),e=!1}}},{...c(s),completeWhenDepsComplete:!1})}function Ne(d,i,s){let{maxBuffer:t,...e}=s??{},n=[],o,r=!1,u;function f(){o?.(),o=void 0}function l(){if(!u||o!==void 0)return;if(n.length===0){r&&u.down([[a]]);return}let v=n.shift();o=I(k(i(v)),u,()=>{f(),l()})}function T(v){t&&t>0&&n.length>=t&&n.shift(),n.push(v),l()}return N([d],(v,x,E)=>{if(u=x,E.terminalDeps[0]!=null&&E.terminalDeps[0]!==!0){f(),n.length=0;return}if(E.terminalDeps[0]===!0){r=!0,l();return}let R=v[0];if(!(R==null||R.length===0)){for(let g of R)T(g);return{deactivate:()=>{f(),n.length=0,r=!1}}}},{...c(e),completeWhenDepsComplete:!1})}function L(d,i,s){let{concurrent:t,...e}=s??{},n=t!=null&&t>0?t:Number.POSITIVE_INFINITY,o=0,r=!1,u=new Set,f=[],l;function T(){r&&o===0&&f.length===0&&l&&l.down([[a]])}function v(g){if(!l)return;o++;let O;O=I(k(i(g)),l,()=>{O&&u.delete(O),o--,x(),T()}),u.add(O)}function x(){for(;f.length>0&&o<n;)v(f.shift())}function E(g){o<n?v(g):f.push(g)}function R(){for(let g of u)g();u.clear(),o=0,f.length=0}return N([d],(g,O,y)=>{if(l=O,y.terminalDeps[0]!=null&&y.terminalDeps[0]!==!0){R();return}if(y.terminalDeps[0]===!0){r=!0,T();return}let D=g[0];if(!(D==null||D.length===0)){for(let M of D)E(M);return{deactivate:()=>{R(),r=!1}}}},{...c(e),completeWhenDepsComplete:!1})}var he=L;function ve(d,i,s){return w(t=>{let e=new Set;function n(){for(let r of e)clearTimeout(r);e.clear()}let o=d.subscribe(r=>{for(let u of r)if(u[0]===p){let f=setTimeout(()=>{e.delete(f),t.emit(u[1])},i);e.add(f)}else if(u[0]===a){let f=setTimeout(()=>{e.delete(f),t.down([[a]])},i);e.add(f)}else u[0]===b&&(n(),t.down([u]))});return()=>{o(),n()}},c(s))}function _(d,i,s){return w(t=>{let e,n;function o(){e!==void 0&&(clearTimeout(e),e=void 0)}let r=d.subscribe(u=>{for(let f of u)f[0]===p?(o(),n=f[1],e=setTimeout(()=>{e=void 0,t.emit(n)},i)):f[0]===a?(e!==void 0&&(o(),t.emit(n)),t.down([[a]])):f[0]===b&&(o(),t.down([f]))});return()=>{r(),o()}},{...c(s),meta:{...h("debounce",{ms:i}),...s?.meta??{}}})}function j(d,i,s){let{leading:t,trailing:e,...n}=s??{},o=t!==!1,r=e===!0,u=i*1e6;return w(f=>{let l,T=-1/0,v,x=!1;function E(){l!==void 0&&(clearTimeout(l),l=void 0)}let R=d.subscribe(g=>{for(let O of g)if(O[0]===p){let y=O[1],D=U();if(o&&D-T>=u)T=D,f.emit(y),E(),r&&(l=setTimeout(()=>{l=void 0,x&&(T=U(),f.emit(v),x=!1)},i));else if(r&&(v=y,x=!0,l===void 0)){let M=(D-T)/1e6;l=setTimeout(()=>{l=void 0,x&&(T=U(),f.emit(v),x=!1)},Math.max(0,i-M))}}else(O[0]===a||O[0]===b)&&(E(),f.down([O]))});return()=>{R(),E()}},{...c(n),meta:{...h("throttle",{ms:i,leading:o,trailing:r}),...n.meta??{}}})}function ge(d,i,s){return w(t=>{let e,n=!1,o=!1,r=d.subscribe(f=>{if(!n)for(let l of f){if(n)return;l[0]===p?e={v:l[1]}:l[0]===b?(n=!0,t.down([l])):l[0]===a&&(o=!0,e=void 0)}}),u=i.subscribe(f=>{if(!n)for(let l of f){if(n)return;l[0]===p?e!==void 0&&!o&&t.emit(e.v):l[0]===b?(n=!0,t.down([l])):l[0]===a&&(n=!0,t.down([[a]]))}});return()=>{r(),u()}},c(s))}function Oe(d,i,s){return w(t=>{let e,n,o=!1;function r(){e!==void 0&&(clearTimeout(e),e=void 0)}let u=d.subscribe(f=>{for(let l of f)l[0]===p?(n=l[1],o=!0,r(),e=setTimeout(()=>{e=void 0,o&&(o=!1,t.emit(n))},i)):(l[0]===a||l[0]===b)&&(r(),t.down([l]))});return()=>{u(),r()}},c(s))}function xe(d,i,s){let{with:t,...e}=s??{},n=t??new Error("timeout");return w(o=>{let r;function u(){clearTimeout(r),r=setTimeout(()=>{r=void 0,o.down([[b,n]])},i)}u();let f=d.subscribe(l=>{for(let T of l)T[0]===p?(u(),o.emit(T[1])):(T[0]===a||T[0]===b)&&(clearTimeout(r),o.down([T]))});return()=>{f(),clearTimeout(r)}},c(e))}function Ee(d,i,s){return w(t=>{let e=[],n=d.subscribe(r=>{for(let u of r)u[0]===p?e.push(u[1]):u[0]===a?(e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):u[0]===b&&t.down([u])}),o=i.subscribe(r=>{for(let u of r)u[0]===p?e.length>0&&(t.emit([...e]),e.length=0):u[0]===a?t.down([[a]]):u[0]===b&&t.down([u])});return()=>{n(),o(),e.length=0}},c(s))}function Re(d,i,s){if(i<=0)throw new RangeError("bufferCount expects count > 0");return w(t=>{let e=[],n=d.subscribe(o=>{for(let r of o)r[0]===p?(e.push(r[1]),e.length>=i&&t.emit(e.splice(0,e.length))):r[0]===a?(e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):r[0]===b&&t.down([r])});return()=>{n(),e.length=0}},c(s))}function De(d,i,s){if(i<=0)throw new RangeError("windowCount expects count > 0");return w(t=>{let e,n=0;function o(){let u=w(f=>(e=f.down.bind(f),()=>{e=void 0}),c());n=0,t.emit(u)}let r=d.subscribe(u=>{for(let f of u)f[0]===p?(e||o(),e?.([[p,f[1]]]),n+=1,n>=i&&(e?.([[a]]),e=void 0)):f[0]===a?(e?.([[a]]),e=void 0,t.down([[a]])):f[0]===b&&(e?.([f]),e=void 0,t.down([f]))});return()=>{r(),e?.([[a]]),e=void 0}},c(s))}function ye(d,i,s){return w(t=>{let e=[],n=setInterval(()=>{e.length>0&&(t.emit([...e]),e.length=0)},i),o=d.subscribe(r=>{for(let u of r)u[0]===p?e.push(u[1]):u[0]===a?(clearInterval(n),e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):u[0]===b&&(clearInterval(n),t.down([u]))});return()=>{o(),clearInterval(n),e.length=0}},{...c(s),meta:{...h("bufferTime",{ms:i}),...s?.meta??{}}})}function ke(d,i,s){return w(t=>{let e;function n(){e?.([[a]]),e=void 0}function o(){let f=w(l=>(e=l.down.bind(l),()=>{e=void 0}),c());t.emit(f)}o();let r=setInterval(()=>{n(),o()},i),u=d.subscribe(f=>{for(let l of f)l[0]===p?e?.([[p,l[1]]]):l[0]===a?(clearInterval(r),n(),t.down([[a]])):l[0]===b&&(clearInterval(r),e?.([l]),n(),t.down([l]))});return()=>{u(),clearInterval(r),n()}},c(s))}function Ue(d,i,s){return w(t=>{let e;function n(){e?.([[a]]),e=void 0}function o(){let f=w(l=>(e=l.down.bind(l),()=>{e=void 0}),c());t.emit(f)}let r=d.subscribe(f=>{for(let l of f)l[0]===p?(e||o(),e?.([[p,l[1]]])):l[0]===a?(n(),t.down([[a]])):l[0]===b&&(e?.([l]),e=void 0,t.down([l]))}),u=i.subscribe(f=>{for(let l of f)l[0]===p&&(n(),o())});return()=>{r(),u(),n()}},c(s))}function Ie(d,i){return w((s,t)=>{"n"in t.store||(t.store.n=0);let e=setInterval(()=>{s.emit(t.store.n),t.store.n=t.store.n+1},d);return()=>clearInterval(e)},c(i))}function Me(d,i,s){if(i<=0)throw new RangeError("repeat expects count > 0");return w(t=>{let e=i,n,o=()=>{n?.(),n=d.subscribe(r=>{let u=!1,f=[];for(let l of r)l[0]===a?u=!0:f.push(l);f.length>0&&t.down(f),u&&(n?.(),n=void 0,e-=1,e>0?o():t.down([[a]]))})};return o(),()=>{n?.()}},c(s))}function Ce(d,i){return N([d],(s,t)=>{let e=s[0];if(e==null||e.length===0){t.down([[m]]);return}for(let n of e)t.emit(n)},c(i))}function Y(d,i,s){return w(t=>{let e=d.subscribe(n=>{for(let o of n)if(o[0]===p)t.emit(o[1]);else if(o[0]===b)try{t.emit(i(o[1]))}catch(r){t.down([[b,r]])}else o[0]===a&&t.down([[a]])});return()=>{e()}},c(s))}function Ae(d,i,s){return N([d,i],(t,e,n)=>{let o=t[1];if(!(o!=null&&o.length>0?o.at(-1):n.prevData[1])){e.down([[m]]);return}let u=t[0];if(u!=null&&u.length>0){for(let f of u)e.emit(f);return}if(o!=null&&o.length>0&&n.prevData[0]!==void 0){e.emit(n.prevData[0]);return}e.down([[m]])},S(s))}var We=F,Pe=_,Be=j,Se=Y;export{Z as a,V as b,$ as c,ee as d,C as e,K as f,ne as g,te as h,oe as i,re as j,se as k,ie as l,ue as m,q as n,fe as o,de as p,le as q,F as r,ae as s,ce as t,Te as u,pe as v,me as w,be as x,we as y,Ne as z,L as A,he as B,ve as C,_ as D,j as E,ge as F,Oe as G,xe as H,Ee as I,Re as J,De as K,ye as L,ke as M,Ue as N,Ie as O,Me as P,Ce as Q,Y as R,Ae as S,We as T,Pe as U,Be as V,Se as W};
1
+ import{a as B}from"./chunk-4VVTGLXJ.js";import{c as h}from"./chunk-GHBWHMRZ.js";import{m as k}from"./chunk-CRVT7D2P.js";import{D as N,F as w,G as P,o as U}from"./chunk-NTEURFZH.js";import{a as A,b as p,c as W,d as m,i as a,j as b}from"./chunk-CK2E7BTU.js";function c(d){return{describeKind:"derived",...d}}function S(d){return{describeKind:"derived",partial:!0,...d}}function Z(d,i,s){return N([d],(t,e)=>{let n=t[0];if(n==null||n.length===0){e.down([[m]]);return}for(let o of n)e.emit(i(o))},{...c(s),meta:{...h("map"),...s?.meta??{}}})}function V(d,i,s){return N([d],(t,e)=>{let n=t[0];if(n==null||n.length===0){e.down([[m]]);return}let o=!1;for(let r of n)i(r)&&(e.emit(r),o=!0);o||e.down([[m]])},{...c(s),meta:{...h("filter"),...s?.meta??{}}})}function $(d,i,s,t){return N([d],(e,n,o)=>{"acc"in o.store||(o.store.acc=s);let r=e[0];if(r==null||r.length===0){n.down([[m]]);return}for(let u of r)o.store.acc=i(o.store.acc,u),n.emit(o.store.acc)},{...c(t),initial:s,resetOnTeardown:!0,meta:{...h("scan",{initial:s}),...t?.meta??{}}})}function ee(d,i,s,t){return N([d],(e,n,o)=>{if("acc"in o.store||(o.store.acc=s),o.terminalDeps[0]===!0){n.emit(o.store.acc),n.down([[a]]);return}let r=e[0];if(r==null||r.length===0){n.down([[m]]);return}for(let u of r)o.store.acc=i(o.store.acc,u)},{...c(t),completeWhenDepsComplete:!1,meta:{...h("reduce",{initial:s}),...t?.meta??{}}})}function C(d,i,s){return i<=0?N([d],(t,e,n)=>{n.store.completed||(n.store.completed=!0,e.down([[a]]))},{...c(s),completeWhenDepsComplete:!1,meta:{...h("take",{count:i}),...s?.meta??{}}}):N([d],(t,e,n)=>{if("taken"in n.store||(n.store.taken=0),n.store.done){e.down([[m]]);return}if(n.terminalDeps[0]===!0){n.store.done=!0,e.down([[a]]);return}let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}for(let r of o)if(n.store.taken++,e.emit(r),n.store.taken>=i){n.store.done=!0,e.down([[a]]);return}},{...c(s),completeWhenDepsComplete:!1,meta:{...h("take",{count:i}),...s?.meta??{}}})}function K(d,i,s){return N([d],(t,e,n)=>{"skipped"in n.store||(n.store.skipped=0);let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}let r=!1;for(let u of o)n.store.skipped++,n.store.skipped<=i||(e.emit(u),r=!0);r||e.down([[m]])},c(s))}function ne(d,i,s){return N([d],(t,e,n)=>{if(n.store.done){e.down([[m]]);return}let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}for(let r of o){if(!i(r)){n.store.done=!0,e.down([[a]]);return}e.emit(r)}},{...c(s),completeWhenDepsComplete:!1})}function te(d,i,s){let t=s?.predicate??(o=>o[0]===p),{predicate:e,...n}=s??{};return w(o=>{let r=!1,u=d.subscribe(l=>{if(!r)for(let T of l){if(r)return;T[0]===p?o.emit(T[1]):(T[0]===a||T[0]===b)&&(r=!0,o.down([T]))}}),f=i.subscribe(l=>{if(!r)for(let T of l){if(r)return;if(t(T)){r=!0,o.down([[a]]);return}}});return()=>{u(),f()}},c(n))}function oe(d,i){return C(d,1,i)}function re(d,i){let{defaultValue:s,...t}=i??{},e=i!=null&&Object.hasOwn(i,"defaultValue");return N([d],(n,o,r)=>{if(r.terminalDeps[0]===!0){r.store.has?o.emit(r.store.latest):e&&o.emit(s),o.down([[a]]);return}let u=n[0];if(u==null||u.length===0){o.down([[m]]);return}r.store.latest=u.at(-1),r.store.has=!0},{...c(t),completeWhenDepsComplete:!1})}function se(d,i,s){return C(V(d,i,s),1,s)}function ie(d,i,s){return C(K(d,i,s),1,s)}function ue(d,i,s){if(typeof i=="function")return N([d],(e,n)=>{let o=e[0];if(o==null||o.length===0){n.down([[m]]);return}for(let r of o)i(r),n.emit(r)},{...c(s),meta:{...h("tap"),...s?.meta??{}}});let t=i;return N([d],(e,n,o)=>{if(o.terminalDeps[0]!==void 0){o.terminalDeps[0]===!0?(t.complete?.(),n.down([[a]])):(t.error?.(o.terminalDeps[0]),n.down([[b,o.terminalDeps[0]]]));return}let r=e[0];if(r==null||r.length===0){n.down([[m]]);return}for(let u of r)t.data?.(u),n.emit(u)},{...c(s),completeWhenDepsComplete:!1,meta:{...h("tap"),...s?.meta??{}}})}function q(d,i,s){let t=s?.where??(n=>n!=null),e=!1;return N([d],(n,o)=>{let r=n[0];if(r==null||r.length===0){o.down([[m]]);return}for(let u of r)!e&&t(u)&&(e=!0,i(u)),o.emit(u)},c(s))}var fe=q;function de(d,i=Object.is,s){return N([d],(t,e,n)=>{let o=t[0];if(o==null||o.length===0){e.down([[m]]);return}let r=!1;for(let u of o)n.store.hasPrev&&i(n.store.prev,u)||(n.store.prev=u,n.store.hasPrev=!0,e.emit(u),r=!0);r||e.down([[m]])},{...c(s),meta:{...h("distinctUntilChanged"),...s?.meta??{}}})}function le(d,i){return N([d],(s,t,e)=>{let n=s[0];if(n==null||n.length===0){t.down([[m]]);return}let o=!1;for(let r of n)if(!e.store.hasPrev)e.store.prev=r,e.store.hasPrev=!0;else{let u=[e.store.prev,r];e.store.prev=r,t.emit(u),o=!0}o||t.down([[m]])},c(i))}function F(...d){let i=[...d];return P(i,s=>s,{...c(),equals:(s,t)=>{if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(!Object.is(s[e],t[e]))return!1;return!0}})}function ae(d,i,s){return N([d,i],(t,e,n)=>{let o=t[0],r=t[1],u=r!=null&&r.length>0?r.at(-1):n.prevData[1];if(o!=null&&o.length>0){if(!(r!=null&&r.length>0)&&n.prevData[1]===void 0){e.down([[m]]);return}for(let f of o)e.emit([f,u])}else e.down([[m]])},{...S(s),meta:{...h("withLatestFrom"),...s?.meta??{}}})}function ce(...d){return d.length===0?w(i=>{i.down([[a]])},{...c(),meta:{...h("merge")}}):w(i=>{let s=d.length,t=0,e=[];for(let n of d){let o=n.subscribe(r=>{for(let u of r)u[0]===p?i.emit(u[1]):u[0]===a?(t+=1,t>=s&&i.down([[a]])):u[0]===b&&i.down([u])});e.push(o)}return()=>{for(let n of e)n()}},{...c(),meta:{...h("merge")}})}function Te(...d){let i=d.length;return i===0?w(s=>{s.emit([]),s.down([[a]])},c()):w(s=>{let t=Array.from({length:i},()=>[]),e=i;function n(){for(;t.every(r=>r.length>0);){let r=t.map(u=>u.shift());s.emit(r)}}let o=[];for(let r=0;r<i;r++){let u=r,f=d[r].subscribe(l=>{for(let T of l)T[0]===p?(t[u].push(T[1]),n()):T[0]===a?(e-=1,(e===0||t[u].length===0)&&s.down([[a]])):T[0]===b&&s.down([T])});o.push(f)}return()=>{for(let r of o)r()}},c())}function pe(d,i,s){return w(t=>{let e=0,n=[],o,r;return r=i.subscribe(u=>{for(let f of u)e===0?f[0]===p?n.push(f[1]):f[0]===b&&t.down([f]):f[0]===p?t.emit(f[1]):(f[0]===a||f[0]===b)&&t.down([f])}),o=d.subscribe(u=>{for(let f of u)if(e===0)if(f[0]===p)t.emit(f[1]);else if(f[0]===a){e=1;for(let l of n)t.emit(l);n.length=0}else f[0]===b&&t.down([f])}),()=>{o?.(),r?.()}},c(s))}function me(...d){return d.length===0?w(i=>{i.down([[a]])},c()):d.length===1?N([d[0]],(i,s)=>{let t=i[0];if(t==null||t.length===0){s.down([[m]]);return}for(let e of t)s.emit(e)},c()):w(i=>{let s=null,t=[];for(let e=0;e<d.length;e++){let n=e,o=d[e].subscribe(r=>{for(let u of r){if(s!==null&&n!==s)return;u[0]===p?(s===null&&(s=n),i.emit(u[1])):(u[0]===a||u[0]===b)&&(s===null||n===s)&&i.down([u])}});t.push(o)}return()=>{for(let e of t)e()}},c())}function I(d,i,s){let t,e=!1,n=()=>{e||(e=!0,s())};return t=d.subscribe(o=>{let r=!1,u=!1;for(let f of o)f[0]!==A&&(f[0]===p?i.emit(f[1]):f[0]===a?r=!0:f[0]===b?(u=!0,i.down([f])):(f[0]===W||f[0]===m)&&i.down([f]));u?(t?.(),t=void 0,n()):r&&n()}),()=>{t?.(),t=void 0}}function be(d,i,s){let t,e=!1;function n(){t?.(),t=void 0}return N([d],(o,r,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){n();return}if(u.terminalDeps[0]===!0){e=!0,t||r.down([[a]]);return}let f=o[0];if(!(f==null||f.length===0))return n(),t=I(k(i(f[f.length-1])),r,()=>{n(),e&&r.down([[a]])}),{deactivate:()=>{n(),e=!1}}},{...c(s),completeWhenDepsComplete:!1,meta:{...h("switchMap"),...s?.meta??{}}})}function we(d,i,s){let t,e=!1;function n(){t?.(),t=void 0}return N([d],(o,r,u)=>{if(u.terminalDeps[0]!=null&&u.terminalDeps[0]!==!0){n();return}if(u.terminalDeps[0]===!0){e=!0,t||r.down([[a]]);return}let f=o[0];if(!(f==null||f.length===0))return t===void 0?t=I(k(i(f[0])),r,()=>{n(),e&&r.down([[a]])}):r.down([[m]]),{deactivate:()=>{n(),e=!1}}},{...c(s),completeWhenDepsComplete:!1})}function Ne(d,i,s){let{maxBuffer:t,...e}=s??{},n=[],o,r=!1,u;function f(){o?.(),o=void 0}function l(){if(!u||o!==void 0)return;if(n.length===0){r&&u.down([[a]]);return}let v=n.shift();o=I(k(i(v)),u,()=>{f(),l()})}function T(v){t&&t>0&&n.length>=t&&n.shift(),n.push(v),l()}return N([d],(v,x,E)=>{if(u=x,E.terminalDeps[0]!=null&&E.terminalDeps[0]!==!0){f(),n.length=0;return}if(E.terminalDeps[0]===!0){r=!0,l();return}let R=v[0];if(!(R==null||R.length===0)){for(let g of R)T(g);return{deactivate:()=>{f(),n.length=0,r=!1}}}},{...c(e),completeWhenDepsComplete:!1})}function L(d,i,s){let{concurrent:t,...e}=s??{},n=t!=null&&t>0?t:Number.POSITIVE_INFINITY,o=0,r=!1,u=new Set,f=[],l;function T(){r&&o===0&&f.length===0&&l&&l.down([[a]])}function v(g){if(!l)return;o++;let O;O=I(k(i(g)),l,()=>{O&&u.delete(O),o--,x(),T()}),u.add(O)}function x(){for(;f.length>0&&o<n;)v(f.shift())}function E(g){o<n?v(g):f.push(g)}function R(){for(let g of u)g();u.clear(),o=0,f.length=0}return N([d],(g,O,y)=>{if(l=O,y.terminalDeps[0]!=null&&y.terminalDeps[0]!==!0){R();return}if(y.terminalDeps[0]===!0){r=!0,T();return}let D=g[0];if(!(D==null||D.length===0)){for(let M of D)E(M);return{deactivate:()=>{R(),r=!1}}}},{...c(e),completeWhenDepsComplete:!1})}var he=L;function ve(d,i,s){return w(t=>{let e=new Set;function n(){for(let r of e)clearTimeout(r);e.clear()}let o=d.subscribe(r=>{for(let u of r)if(u[0]===p){let f=setTimeout(()=>{e.delete(f),t.emit(u[1])},i);e.add(f)}else if(u[0]===a){let f=setTimeout(()=>{e.delete(f),t.down([[a]])},i);e.add(f)}else u[0]===b&&(n(),t.down([u]))});return()=>{o(),n()}},c(s))}function _(d,i,s){return w(t=>{let e,n;function o(){e!==void 0&&(clearTimeout(e),e=void 0)}let r=d.subscribe(u=>{for(let f of u)f[0]===p?(o(),n=f[1],e=setTimeout(()=>{e=void 0,t.emit(n)},i)):f[0]===a?(e!==void 0&&(o(),t.emit(n)),t.down([[a]])):f[0]===b&&(o(),t.down([f]))});return()=>{r(),o()}},{...c(s),meta:{...h("debounce",{ms:i}),...s?.meta??{}}})}function j(d,i,s){let{leading:t,trailing:e,...n}=s??{},o=t!==!1,r=e===!0,u=i*1e6;return w(f=>{let l,T=-1/0,v,x=!1;function E(){l!==void 0&&(clearTimeout(l),l=void 0)}let R=d.subscribe(g=>{for(let O of g)if(O[0]===p){let y=O[1],D=U();if(o&&D-T>=u)T=D,f.emit(y),E(),r&&(l=setTimeout(()=>{l=void 0,x&&(T=U(),f.emit(v),x=!1)},i));else if(r&&(v=y,x=!0,l===void 0)){let M=(D-T)/1e6;l=setTimeout(()=>{l=void 0,x&&(T=U(),f.emit(v),x=!1)},Math.max(0,i-M))}}else(O[0]===a||O[0]===b)&&(E(),f.down([O]))});return()=>{R(),E()}},{...c(n),meta:{...h("throttle",{ms:i,leading:o,trailing:r}),...n.meta??{}}})}function ge(d,i,s){return w(t=>{let e,n=!1,o=!1,r=d.subscribe(f=>{if(!n)for(let l of f){if(n)return;l[0]===p?e={v:l[1]}:l[0]===b?(n=!0,t.down([l])):l[0]===a&&(o=!0,e=void 0)}}),u=i.subscribe(f=>{if(!n)for(let l of f){if(n)return;l[0]===p?e!==void 0&&!o&&t.emit(e.v):l[0]===b?(n=!0,t.down([l])):l[0]===a&&(n=!0,t.down([[a]]))}});return()=>{r(),u()}},c(s))}function Oe(d,i,s){return w(t=>{let e,n,o=!1;function r(){e!==void 0&&(clearTimeout(e),e=void 0)}let u=d.subscribe(f=>{for(let l of f)l[0]===p?(n=l[1],o=!0,r(),e=setTimeout(()=>{e=void 0,o&&(o=!1,t.emit(n))},i)):(l[0]===a||l[0]===b)&&(r(),t.down([l]))});return()=>{u(),r()}},c(s))}function xe(d,i,s){let{with:t,...e}=s??{},n=t??new Error("timeout");return w(o=>{let r;function u(){clearTimeout(r),r=setTimeout(()=>{r=void 0,o.down([[b,n]])},i)}u();let f=d.subscribe(l=>{for(let T of l)T[0]===p?(u(),o.emit(T[1])):(T[0]===a||T[0]===b)&&(clearTimeout(r),o.down([T]))});return()=>{f(),clearTimeout(r)}},c(e))}function Ee(d,i,s){return w(t=>{let e=[],n=d.subscribe(r=>{for(let u of r)u[0]===p?e.push(u[1]):u[0]===a?(e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):u[0]===b&&t.down([u])}),o=i.subscribe(r=>{for(let u of r)u[0]===p?e.length>0&&(t.emit([...e]),e.length=0):u[0]===a?t.down([[a]]):u[0]===b&&t.down([u])});return()=>{n(),o(),e.length=0}},c(s))}function Re(d,i,s){if(i<=0)throw new RangeError("bufferCount expects count > 0");return w(t=>{let e=[],n=d.subscribe(o=>{for(let r of o)r[0]===p?(e.push(r[1]),e.length>=i&&t.emit(e.splice(0,e.length))):r[0]===a?(e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):r[0]===b&&t.down([r])});return()=>{n(),e.length=0}},c(s))}function De(d,i,s){if(i<=0)throw new RangeError("windowCount expects count > 0");return w(t=>{let e,n=0;function o(){let u=w(f=>(e=f.down.bind(f),()=>{e=void 0}),c());n=0,t.emit(u)}let r=d.subscribe(u=>{for(let f of u)f[0]===p?(e||o(),e?.([[p,f[1]]]),n+=1,n>=i&&(e?.([[a]]),e=void 0)):f[0]===a?(e?.([[a]]),e=void 0,t.down([[a]])):f[0]===b&&(e?.([f]),e=void 0,t.down([f]))});return()=>{r(),e?.([[a]]),e=void 0}},c(s))}function ye(d,i,s){return w(t=>{let e=[],n=setInterval(()=>{e.length>0&&(t.emit([...e]),e.length=0)},i),o=d.subscribe(r=>{for(let u of r)u[0]===p?e.push(u[1]):u[0]===a?(clearInterval(n),e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):u[0]===b&&(clearInterval(n),t.down([u]))});return()=>{o(),clearInterval(n),e.length=0}},{...c(s),meta:{...h("bufferTime",{ms:i}),...s?.meta??{}}})}function ke(d,i,s){return w(t=>{let e;function n(){e?.([[a]]),e=void 0}function o(){let f=w(l=>(e=l.down.bind(l),()=>{e=void 0}),c());t.emit(f)}o();let r=setInterval(()=>{n(),o()},i),u=d.subscribe(f=>{for(let l of f)l[0]===p?e?.([[p,l[1]]]):l[0]===a?(clearInterval(r),n(),t.down([[a]])):l[0]===b&&(clearInterval(r),e?.([l]),n(),t.down([l]))});return()=>{u(),clearInterval(r),n()}},c(s))}function Ue(d,i,s){return w(t=>{let e;function n(){e?.([[a]]),e=void 0}function o(){let f=w(l=>(e=l.down.bind(l),()=>{e=void 0}),c());t.emit(f)}let r=d.subscribe(f=>{for(let l of f)l[0]===p?(e||o(),e?.([[p,l[1]]])):l[0]===a?(n(),t.down([[a]])):l[0]===b&&(e?.([l]),e=void 0,t.down([l]))}),u=i.subscribe(f=>{for(let l of f)l[0]===p&&(n(),o())});return()=>{r(),u(),n()}},c(s))}function Ie(d,i){return w((s,t)=>{"n"in t.store||(t.store.n=0);let e=setInterval(()=>{s.emit(t.store.n),t.store.n=t.store.n+1},d);return()=>clearInterval(e)},c(i))}function Me(d,i,s){if(i<=0)throw new RangeError("repeat expects count > 0");return w(t=>{let e=i,n,o=()=>{n?.(),n=d.subscribe(r=>{let u=!1,f=[];for(let l of r)l[0]===a?u=!0:f.push(l);f.length>0&&t.down(f),u&&(n?.(),n=void 0,e-=1,e>0?o():t.down([[a]]))})};return o(),()=>{n?.()}},c(s))}function Ce(d,i){return N([d],(s,t)=>{let e=s[0];if(e==null||e.length===0){t.down([[m]]);return}for(let n of e)t.emit(n)},c(i))}function Y(d,i,s){return w(t=>{let e=d.subscribe(n=>{for(let o of n)if(o[0]===p)t.emit(o[1]);else if(o[0]===b)try{t.emit(i(o[1]))}catch(r){t.down([[b,r]])}else o[0]===a&&t.down([[a]])});return()=>{e()}},c(s))}function Ae(d,i,s){return N([d,i],(t,e,n)=>{let o=t[1];if(!(o!=null&&o.length>0?o.at(-1):n.prevData[1])){e.down([[m]]);return}let u=t[0];if(u!=null&&u.length>0){for(let f of u)e.emit(f);return}if(o!=null&&o.length>0&&n.prevData[0]!==void 0){e.emit(n.prevData[0]);return}e.down([[m]])},S(s))}var We=F,Pe=_,Be=j,Se=Y;export{Z as a,V as b,$ as c,ee as d,C as e,K as f,ne as g,te as h,oe as i,re as j,se as k,ie as l,ue as m,q as n,fe as o,de as p,le as q,F as r,ae as s,ce as t,Te as u,pe as v,me as w,be as x,we as y,Ne as z,L as A,he as B,ve as C,_ as D,j as E,ge as F,Oe as G,xe as H,Ee as I,Re as J,De as K,ye as L,ke as M,Ue as N,Ie as O,Me as P,Ce as Q,Y as R,Ae as S,We as T,Pe as U,Be as V,Se as W};
@@ -1 +1 @@
1
- import{D as w,E as I,F as b,p as C}from"./chunk-LYCLF26R.js";import{a as S,b as h,c as A,d as x,i as T,j as p}from"./chunk-CK2E7BTU.js";function y(e,n,t){let u=new Set;for(let o of e.split(",")){let[r,i]=o.split("/"),s=i?Number.parseInt(i,10):1;if(Number.isNaN(s)||s<1)throw new Error(`Invalid cron step: ${o}`);let a,d;if(r==="*")a=n,d=t;else if(r.includes("-")){let[f,c]=r.split("-");a=Number.parseInt(f,10),d=Number.parseInt(c,10)}else a=Number.parseInt(r,10),d=a;if(Number.isNaN(a)||Number.isNaN(d))throw new Error(`Invalid cron field: ${e}`);if(a<n||d>t)throw new Error(`Cron field out of range: ${e} (${n}-${t})`);if(a>d)throw new Error(`Invalid cron range: ${a}-${d} in ${e}`);for(let f=a;f<=d;f+=s)u.add(f)}return u}function L(e){let n=e.trim().split(/\s+/);if(n.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${n.length}`);return{minutes:y(n[0],0,59),hours:y(n[1],0,23),daysOfMonth:y(n[2],1,31),months:y(n[3],1,12),daysOfWeek:y(n[4],0,6)}}function P(e,n){return e.minutes.has(n.getMinutes())&&e.hours.has(n.getHours())&&e.daysOfMonth.has(n.getDate())&&e.months.has(n.getMonth()+1)&&e.daysOfWeek.has(n.getDay())}function m(e){return{describeKind:"producer",...e}}function $(e){return/[\\^$+?.()|[\]{}]/.test(e)?`\\${e}`:e}function X(e){let n="^";for(let t=0;t<e.length;t+=1){let u=e[t];if(u==="*"){e[t+1]==="*"?(n+=".*",t+=1):n+="[^/]*";continue}n+=$(u)}return n+="$",new RegExp(n)}function Z(e,n){for(let t of n)if(t.test(e))return!0;return!1}function K(e,n){let t=w([e],(o,r)=>{let i=o[0];if(i==null||i.length===0){r.down([[x]]);return}for(let s of i)r.emit(s)},{describeKind:"derived",initial:e.cache}),u=t.subscribe.bind(t);return t.subscribe=(o,r)=>(n(o),u(o,r)),t}function ee(e,n){let{signal:t,period:u,...o}=n??{};return b(r=>{let i=!1,s=0,a,d,f=()=>{i=!0,a!==void 0&&clearTimeout(a),d!==void 0&&clearInterval(d),t?.removeEventListener("abort",l)},c=()=>{i||(u!=null?(r.emit(s++),d=setInterval(()=>{i||r.emit(s++)},u)):(i=!0,t?.removeEventListener("abort",l),r.emit(s++),r.down([[T]])))},l=()=>{i||(f(),r.down([[p,t.reason]]))};if(t?.aborted){l();return}return a=setTimeout(c,e),t?.addEventListener("abort",l,{once:!0}),f},m(o))}function ne(e){let{signal:n,...t}=e??{};return b(u=>{let o=!1,r,i,s=!1,a=!1,d=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,f=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,c=typeof document<"u"?document:void 0,l=()=>{r!==void 0&&f&&f(r),i!==void 0&&clearTimeout(i),r=void 0,i=void 0},v=()=>{o=!0,l(),s&&(n?.removeEventListener("abort",N),s=!1),a&&c&&(c.removeEventListener("visibilitychange",k),a=!1)},N=()=>{o||(v(),u.down([[p,n.reason]]))},O=_=>{o||(u.emit(_),g())},g=()=>{o||(d&&(!c||c.visibilityState!=="hidden")?r=d(O):i=setTimeout(()=>O(performance.now()),16))},k=()=>{o||(l(),g())};return n?.aborted?(N(),v):(n?.addEventListener("abort",N,{once:!0}),s=n!==void 0,c&&d&&(c.addEventListener("visibilitychange",k),a=!0),g(),v)},m(t))}function te(e,n){let t=L(e),{tickMs:u,output:o,...r}=n??{},i=u??6e4,s=o==="date";return b(a=>{let d=-1,f=()=>{let l=new Date,v=l.getFullYear()*1e8+(l.getMonth()+1)*1e6+l.getDate()*1e4+l.getHours()*100+l.getMinutes();v!==d&&P(t,l)&&(d=v,a.emit(s?l:C()))};f();let c=setInterval(f,i);return()=>clearInterval(c)},{...m(r),name:r.name??`cron:${e}`})}function re(e,n,t){let{capture:u,passive:o,once:r,...i}=t??{};return b(s=>{let a=f=>{s.emit(f)},d={capture:u,passive:o,once:r};return e.addEventListener(n,a,d),()=>e.removeEventListener(n,a,d)},m(i))}function D(e,n){return b(t=>{let u=!1;try{for(let o of e){if(u)return;t.emit(o)}u||t.down([[T]])}catch(o){u||t.down([[p,o]])}return()=>{u=!0}},m(n))}function W(e){return e!=null&&typeof e.then=="function"}function q(e,n){let{signal:t,...u}=n??{};return b(o=>{let r=!1,i=()=>{r||(r=!0,o.down([[p,t.reason]]))};if(t?.aborted){i();return}return t?.addEventListener("abort",i,{once:!0}),Promise.resolve(e).then(s=>{r||(r=!0,t?.removeEventListener("abort",i),o.emit(s),o.down([[T]]))},s=>{r||(r=!0,t?.removeEventListener("abort",i),o.down([[p,s]]))}),()=>{r=!0,t?.removeEventListener("abort",i)}},m(u))}function H(e,n){let{signal:t,...u}=n??{};return b(o=>{let r=new AbortController,i=()=>r.abort(t?.reason);t?.aborted?r.abort(t.reason):t?.addEventListener("abort",i,{once:!0});let s=t??r.signal,a=!1,d=e[Symbol.asyncIterator](),f=()=>{a||s.aborted||Promise.resolve(d.next()).then(c=>{if(!(a||s.aborted)){if(c.done){o.down([[T]]);return}o.emit(c.value),f()}},c=>{!a&&!s.aborted&&o.down([[p,c]])})};return f(),()=>{a=!0,t?.removeEventListener("abort",i),r.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},m(u))}function U(e){return e!=null&&typeof e=="object"&&"cache"in e&&typeof e.subscribe=="function"}function V(e,n){if(U(e))return e;if(W(e))return q(e,n);if(e!=null){let t=e;if(typeof t[Symbol.asyncIterator]=="function")return H(e,n);if(typeof t[Symbol.iterator]=="function")return D(e,n)}return B(e)}function B(...e){return D(e,void 0)}function oe(e){return b(n=>{n.down([[T]])},m(e))}function ie(e){return b(()=>{},m(e))}function se(e,n){return b(t=>{t.down([[p,e]])},m(n))}function ue(e,n){let{signal:t,...u}=n??{},o=m(u),r=o.resubscribable===void 0?{...o,resubscribable:!0}:o;return b(i=>{let s,a=!1;try{let d=e();s=V(d,n).subscribe(c=>{if(!a)for(let l of c){let v=l[0];if(v!==S)if(v===h)i.emit(l[1]);else if(v===T){a=!0,i.down([[T]]);break}else if(v===p){a=!0,i.down([[p,l[1]]]);break}else i.down([l])}})}catch(d){let f=d===void 0?new Error("defer: thunk threw undefined"):d;i.down([[p,f]])}return()=>{a=!0,s?.()}},r)}function ae(e,n,t){return w([e],(o,r)=>{let i=o[0];if(i!=null&&i.length>0)for(let s of i)n(s)},{describeKind:"effect",...t}).subscribe(()=>{})}function de(e,n){return w([e],(t,u,o)=>{o.store.buf||(o.store.buf=[]);let r=o.store.buf,i=t[0];if(i!=null&&i.length>0)for(let s of i)r.push(s);if(o.terminalDeps[0]===!0){u.emit([...r]),u.down([[T]]);return}(i==null||i.length===0)&&u.down([[x]])},{describeKind:"derived",completeWhenDepsComplete:!1,...n})}function fe(e,n){return b(t=>e.subscribe(u=>{t.down(u)}),{...m(n),initial:e.cache})}function F(e,n,t){if(n<1)throw new RangeError("replay expects bufferSize >= 1");let u=[],o=b(r=>e.subscribe(i=>{for(let s of i)s[0]===h&&(u.push(s[1]),u.length>n&&u.shift());r.down(i)}),{...m(t),initial:e.cache});return K(o,r=>{for(let i of u)r([[h,i]])})}function ce(e,n){return F(e,1,n)}function le(e){return new Promise((n,t)=>{let u=!1,o=!1,r;r=e.subscribe(i=>{for(let s of i){if(u)return;if(s[0]===h){u=!0,n(s[1]),r?(r(),r=void 0):o=!0;return}if(s[0]===p){u=!0,t(s[1]),r?(r(),r=void 0):o=!0;return}if(s[0]===T){u=!0,t(new Error("completed without DATA")),r?(r(),r=void 0):o=!0;return}}}),o&&(r?.(),r=void 0)})}function R(e,n,t){return new Promise((u,o)=>{let r=!1,i=!1,s,a=t?.skipCurrent===!0;s=e.subscribe(d=>{for(let f of d){if(r)return;if(!(a&&f[0]===h)){if(f[0]===h){let c=f[1];if(n(c)){r=!0,u(c),s?(s(),s=void 0):i=!0;return}}if(f[0]===p){r=!0,o(f[1]),s?(s(),s=void 0):i=!0;return}if(f[0]===T){r=!0,o(new Error("completed without matching value")),s?(s(),s=void 0):i=!0;return}}}}),a=!1,i&&(s?.(),s=void 0)})}var E,M;async function pe(e,n){let t=n?.predicate??(r=>r!=null),u=n?.skipCurrent;if(n?.timeoutMs==null||n.timeoutMs<=0)return await R(e,t,{skipCurrent:u});if(E===void 0){let[r,i]=await Promise.all([import("./resilience-YIWPK4YC.js"),import("./backoff-HPZMEZNF.js")]);E=r.timeout,M=i.NS_PER_MS}let o=E(e,n.timeoutMs*M);return await R(o,t,{skipCurrent:u})}function be(e,n){let t=new AbortController,u=n?.reason??new Error("cancelled via nodeSignal"),o,r=!1,i=()=>{o?(o(),o=void 0):r=!0};return o=e.subscribe(s=>{if(!t.signal.aborted)for(let a of s){if(a[0]===h&&a[1]===!0){t.abort(u),i();return}if(a[0]===p){t.abort(a[1]),i();return}if(a[0]===T){i();return}}}),r&&(o?.(),o=void 0),{signal:t.signal,dispose:()=>{o&&(o(),o=void 0)}}}var me=F;function Te(e){return e.subscribe(()=>{})}function ve(e){let n=I(0);return{node:n,increment(){let t=n.cache??0;return t>=e?!1:(n.down([[A],[h,t+1]]),!0)},get(){return n.cache??0},atCap(){return(n.cache??0)>=e}}}export{L as a,P as b,$ as c,X as d,Z as e,ee as f,ne as g,te as h,re as i,D as j,q as k,H as l,V as m,B as n,oe as o,ie as p,se as q,ue as r,ae as s,de as t,fe as u,F as v,ce as w,le as x,R as y,pe as z,be as A,me as B,Te as C,ve as D};
1
+ import{D as w,E as I,F as b,p as C}from"./chunk-NTEURFZH.js";import{a as S,b as h,c as A,d as x,i as T,j as p}from"./chunk-CK2E7BTU.js";function y(e,n,t){let u=new Set;for(let o of e.split(",")){let[r,i]=o.split("/"),s=i?Number.parseInt(i,10):1;if(Number.isNaN(s)||s<1)throw new Error(`Invalid cron step: ${o}`);let a,d;if(r==="*")a=n,d=t;else if(r.includes("-")){let[f,c]=r.split("-");a=Number.parseInt(f,10),d=Number.parseInt(c,10)}else a=Number.parseInt(r,10),d=a;if(Number.isNaN(a)||Number.isNaN(d))throw new Error(`Invalid cron field: ${e}`);if(a<n||d>t)throw new Error(`Cron field out of range: ${e} (${n}-${t})`);if(a>d)throw new Error(`Invalid cron range: ${a}-${d} in ${e}`);for(let f=a;f<=d;f+=s)u.add(f)}return u}function L(e){let n=e.trim().split(/\s+/);if(n.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${n.length}`);return{minutes:y(n[0],0,59),hours:y(n[1],0,23),daysOfMonth:y(n[2],1,31),months:y(n[3],1,12),daysOfWeek:y(n[4],0,6)}}function P(e,n){return e.minutes.has(n.getMinutes())&&e.hours.has(n.getHours())&&e.daysOfMonth.has(n.getDate())&&e.months.has(n.getMonth()+1)&&e.daysOfWeek.has(n.getDay())}function m(e){return{describeKind:"producer",...e}}function $(e){return/[\\^$+?.()|[\]{}]/.test(e)?`\\${e}`:e}function X(e){let n="^";for(let t=0;t<e.length;t+=1){let u=e[t];if(u==="*"){e[t+1]==="*"?(n+=".*",t+=1):n+="[^/]*";continue}n+=$(u)}return n+="$",new RegExp(n)}function Z(e,n){for(let t of n)if(t.test(e))return!0;return!1}function K(e,n){let t=w([e],(o,r)=>{let i=o[0];if(i==null||i.length===0){r.down([[x]]);return}for(let s of i)r.emit(s)},{describeKind:"derived",initial:e.cache}),u=t.subscribe.bind(t);return t.subscribe=(o,r)=>(n(o),u(o,r)),t}function ee(e,n){let{signal:t,period:u,...o}=n??{};return b(r=>{let i=!1,s=0,a,d,f=()=>{i=!0,a!==void 0&&clearTimeout(a),d!==void 0&&clearInterval(d),t?.removeEventListener("abort",l)},c=()=>{i||(u!=null?(r.emit(s++),d=setInterval(()=>{i||r.emit(s++)},u)):(i=!0,t?.removeEventListener("abort",l),r.emit(s++),r.down([[T]])))},l=()=>{i||(f(),r.down([[p,t.reason]]))};if(t?.aborted){l();return}return a=setTimeout(c,e),t?.addEventListener("abort",l,{once:!0}),f},m(o))}function ne(e){let{signal:n,...t}=e??{};return b(u=>{let o=!1,r,i,s=!1,a=!1,d=typeof requestAnimationFrame=="function"?requestAnimationFrame:void 0,f=typeof cancelAnimationFrame=="function"?cancelAnimationFrame:void 0,c=typeof document<"u"?document:void 0,l=()=>{r!==void 0&&f&&f(r),i!==void 0&&clearTimeout(i),r=void 0,i=void 0},v=()=>{o=!0,l(),s&&(n?.removeEventListener("abort",N),s=!1),a&&c&&(c.removeEventListener("visibilitychange",k),a=!1)},N=()=>{o||(v(),u.down([[p,n.reason]]))},O=_=>{o||(u.emit(_),g())},g=()=>{o||(d&&(!c||c.visibilityState!=="hidden")?r=d(O):i=setTimeout(()=>O(performance.now()),16))},k=()=>{o||(l(),g())};return n?.aborted?(N(),v):(n?.addEventListener("abort",N,{once:!0}),s=n!==void 0,c&&d&&(c.addEventListener("visibilitychange",k),a=!0),g(),v)},m(t))}function te(e,n){let t=L(e),{tickMs:u,output:o,...r}=n??{},i=u??6e4,s=o==="date";return b(a=>{let d=-1,f=()=>{let l=new Date,v=l.getFullYear()*1e8+(l.getMonth()+1)*1e6+l.getDate()*1e4+l.getHours()*100+l.getMinutes();v!==d&&P(t,l)&&(d=v,a.emit(s?l:C()))};f();let c=setInterval(f,i);return()=>clearInterval(c)},{...m(r),name:r.name??`cron:${e}`})}function re(e,n,t){let{capture:u,passive:o,once:r,...i}=t??{};return b(s=>{let a=f=>{s.emit(f)},d={capture:u,passive:o,once:r};return e.addEventListener(n,a,d),()=>e.removeEventListener(n,a,d)},m(i))}function D(e,n){return b(t=>{let u=!1;try{for(let o of e){if(u)return;t.emit(o)}u||t.down([[T]])}catch(o){u||t.down([[p,o]])}return()=>{u=!0}},m(n))}function W(e){return e!=null&&typeof e.then=="function"}function q(e,n){let{signal:t,...u}=n??{};return b(o=>{let r=!1,i=()=>{r||(r=!0,o.down([[p,t.reason]]))};if(t?.aborted){i();return}return t?.addEventListener("abort",i,{once:!0}),Promise.resolve(e).then(s=>{r||(r=!0,t?.removeEventListener("abort",i),o.emit(s),o.down([[T]]))},s=>{r||(r=!0,t?.removeEventListener("abort",i),o.down([[p,s]]))}),()=>{r=!0,t?.removeEventListener("abort",i)}},m(u))}function H(e,n){let{signal:t,...u}=n??{};return b(o=>{let r=new AbortController,i=()=>r.abort(t?.reason);t?.aborted?r.abort(t.reason):t?.addEventListener("abort",i,{once:!0});let s=t??r.signal,a=!1,d=e[Symbol.asyncIterator](),f=()=>{a||s.aborted||Promise.resolve(d.next()).then(c=>{if(!(a||s.aborted)){if(c.done){o.down([[T]]);return}o.emit(c.value),f()}},c=>{!a&&!s.aborted&&o.down([[p,c]])})};return f(),()=>{a=!0,t?.removeEventListener("abort",i),r.abort(),Promise.resolve(d.return?.()).catch(()=>{})}},m(u))}function U(e){return e!=null&&typeof e=="object"&&"cache"in e&&typeof e.subscribe=="function"}function V(e,n){if(U(e))return e;if(W(e))return q(e,n);if(e!=null){let t=e;if(typeof t[Symbol.asyncIterator]=="function")return H(e,n);if(typeof t[Symbol.iterator]=="function")return D(e,n)}return B(e)}function B(...e){return D(e,void 0)}function oe(e){return b(n=>{n.down([[T]])},m(e))}function ie(e){return b(()=>{},m(e))}function se(e,n){return b(t=>{t.down([[p,e]])},m(n))}function ue(e,n){let{signal:t,...u}=n??{},o=m(u),r=o.resubscribable===void 0?{...o,resubscribable:!0}:o;return b(i=>{let s,a=!1;try{let d=e();s=V(d,n).subscribe(c=>{if(!a)for(let l of c){let v=l[0];if(v!==S)if(v===h)i.emit(l[1]);else if(v===T){a=!0,i.down([[T]]);break}else if(v===p){a=!0,i.down([[p,l[1]]]);break}else i.down([l])}})}catch(d){let f=d===void 0?new Error("defer: thunk threw undefined"):d;i.down([[p,f]])}return()=>{a=!0,s?.()}},r)}function ae(e,n,t){return w([e],(o,r)=>{let i=o[0];if(i!=null&&i.length>0)for(let s of i)n(s)},{describeKind:"effect",...t}).subscribe(()=>{})}function de(e,n){return w([e],(t,u,o)=>{o.store.buf||(o.store.buf=[]);let r=o.store.buf,i=t[0];if(i!=null&&i.length>0)for(let s of i)r.push(s);if(o.terminalDeps[0]===!0){u.emit([...r]),u.down([[T]]);return}(i==null||i.length===0)&&u.down([[x]])},{describeKind:"derived",completeWhenDepsComplete:!1,...n})}function fe(e,n){return b(t=>e.subscribe(u=>{t.down(u)}),{...m(n),initial:e.cache})}function F(e,n,t){if(n<1)throw new RangeError("replay expects bufferSize >= 1");let u=[],o=b(r=>e.subscribe(i=>{for(let s of i)s[0]===h&&(u.push(s[1]),u.length>n&&u.shift());r.down(i)}),{...m(t),initial:e.cache});return K(o,r=>{for(let i of u)r([[h,i]])})}function ce(e,n){return F(e,1,n)}function le(e){return new Promise((n,t)=>{let u=!1,o=!1,r;r=e.subscribe(i=>{for(let s of i){if(u)return;if(s[0]===h){u=!0,n(s[1]),r?(r(),r=void 0):o=!0;return}if(s[0]===p){u=!0,t(s[1]),r?(r(),r=void 0):o=!0;return}if(s[0]===T){u=!0,t(new Error("completed without DATA")),r?(r(),r=void 0):o=!0;return}}}),o&&(r?.(),r=void 0)})}function R(e,n,t){return new Promise((u,o)=>{let r=!1,i=!1,s,a=t?.skipCurrent===!0;s=e.subscribe(d=>{for(let f of d){if(r)return;if(!(a&&f[0]===h)){if(f[0]===h){let c=f[1];if(n(c)){r=!0,u(c),s?(s(),s=void 0):i=!0;return}}if(f[0]===p){r=!0,o(f[1]),s?(s(),s=void 0):i=!0;return}if(f[0]===T){r=!0,o(new Error("completed without matching value")),s?(s(),s=void 0):i=!0;return}}}}),a=!1,i&&(s?.(),s=void 0)})}var E,M;async function pe(e,n){let t=n?.predicate??(r=>r!=null),u=n?.skipCurrent;if(n?.timeoutMs==null||n.timeoutMs<=0)return await R(e,t,{skipCurrent:u});if(E===void 0){let[r,i]=await Promise.all([import("./resilience-6LYQJAC5.js"),import("./backoff-HPZMEZNF.js")]);E=r.timeout,M=i.NS_PER_MS}let o=E(e,n.timeoutMs*M);return await R(o,t,{skipCurrent:u})}function be(e,n){let t=new AbortController,u=n?.reason??new Error("cancelled via nodeSignal"),o,r=!1,i=()=>{o?(o(),o=void 0):r=!0};return o=e.subscribe(s=>{if(!t.signal.aborted)for(let a of s){if(a[0]===h&&a[1]===!0){t.abort(u),i();return}if(a[0]===p){t.abort(a[1]),i();return}if(a[0]===T){i();return}}}),r&&(o?.(),o=void 0),{signal:t.signal,dispose:()=>{o&&(o(),o=void 0)}}}var me=F;function Te(e){return e.subscribe(()=>{})}function ve(e){let n=I(0);return{node:n,increment(){let t=n.cache??0;return t>=e?!1:(n.down([[A],[h,t+1]]),!0)},get(){return n.cache??0},atCap(){return(n.cache??0)>=e}}}export{L as a,P as b,$ as c,X as d,Z as e,ee as f,ne as g,te as h,re as i,D as j,q as k,H as l,V as m,B as n,oe as o,ie as p,se as q,ue as r,ae as s,de as t,fe as u,F as v,ce as w,le as x,R as y,pe as z,be as A,me as B,Te as C,ve as D};
@@ -0,0 +1 @@
1
+ import{a as N}from"./chunk-L6NSJVJZ.js";import{f as ce,j as me}from"./chunk-HITNVN6B.js";import{a as j}from"./chunk-ESMPEKEV.js";import{x as _}from"./chunk-CLVB32RD.js";import{a as E,b as x,i as pe}from"./chunk-4VVTGLXJ.js";import{b as le,c as C}from"./chunk-GHBWHMRZ.js";import{m as be}from"./chunk-CRVT7D2P.js";import{D as F,F as V,m as Z,o as G}from"./chunk-NTEURFZH.js";import{b as w,c as O,d as T,f as J,g as X,h as A,i as k,j as g}from"./chunk-CK2E7BTU.js";var H=class{buf=[];head=0;get size(){return this.buf.length-this.head}push(t){this.buf.push(t)}shift(){if(this.head>=this.buf.length)return;let t=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),t}clear(){this.buf=[],this.head=0}};function U(e,t,r){if(t.length===0)throw new RangeError("budgetGate requires at least one constraint");let n=t.map(m=>m.node),o=[e,...n],a=new H,u=!1,i=!1,s=Symbol("budget-gate"),f=new Array(t.length);function d(){return t.every((m,b)=>m.check(f[b]))}function c(m){for(;a.size>0&&d();){let b=a.shift();m.emit(b)}a.size===0&&i&&(i=!1,m.down([[T]]))}return F([],(m,b)=>{for(let h=0;h<t.length;h++)f[h]=t[h].node.cache;let p=[];for(let h=0;h<o.length;h++){let y=o[h];p.push(y.subscribe(L=>{for(let P of L)l(P,h,b)}))}return()=>{for(let h of p)h()}},{...r,describeKind:"derived",meta:N("resilience","budget_gate",r?.meta)});function l(m,b,p){let h=m[0];if(b===0){if(h===w)return d()&&a.size===0?p.emit(m[1]):(a.push(m[1]),u||(u=!0,p.up([[J,s]]))),!0;if(h===O)return p.down([[O]]),!0;if(h===T)return a.size===0?p.down([[T]]):i=!0,!0;if(h===k||h===g){for(;a.size>0;)p.emit(a.shift());return i=!1,u&&(u=!1,p.up([[X,s]])),p.down([m]),!0}return!1}if(h===w&&(f[b-1]=m[1]),h===w||h===T){let y=d();return y&&a.size>0?(c(p),a.size===0&&u&&(u=!1,p.up([[X,s]]))):!y&&!u&&a.size>0&&(u=!0,p.up([[J,s]])),!0}return h===O?!0:h===g?(p.down([m]),!0):h===k}}function I(e){return typeof e=="object"&&e!==null&&"subscribe"in e&&"down"in e}function he(e){if(e<=0)throw new RangeError("timeoutMs must be > 0");if(e>9e6)throw new RangeError("timeoutMs must be <= 9_000_000 (\u22482.5h) to stay within safe ns arithmetic")}var q=class extends me{output;status;lastError;breakerState;droppedCount;rateLimitState;constructor(t,r={}){super(r.name??"resilient_pipeline",r.graph);let n=t,o,a,u;if(r.rateLimit!=null)if(I(r.rateLimit)){let s=n,f=r.rateLimit;n=_(f,d=>{let c={...d,maxBuffer:d.maxBuffer??1/0,meta:N("resilient","rate-limit")};return ne(s,c).node}),this.add(n,{name:"rateLimited"})}else{let s={...r.rateLimit,maxBuffer:r.rateLimit.maxBuffer??1/0,meta:N("resilient","rate-limit")},f=ne(n,s);n=f.node,o=f.droppedCount,a=f.rateLimitState,this.add(n,{name:"rateLimited"}),this.add(o,{name:"droppedCount"}),this.add(a,{name:"rateLimitState"})}if(r.budget!=null)if(I(r.budget)){let s=n,f=r.budget;n=_(f,d=>d.length>0?U(s,d,{meta:N("resilient","budget")}):s),this.add(n,{name:"budgetGated"})}else r.budget.length>0&&(n=U(n,r.budget,{meta:N("resilient","budget")}),this.add(n,{name:"budgetGated"}));if(r.breaker!=null)if(I(r.breaker)){let s=n,f=r.breaker,d=r.breakerOnOpen??"skip";n=_(f,c=>{let l=te(c);return re(l,{onOpen:d,meta:N("resilient","breaker")})(s).node}),this.add(n,{name:"breakerWrapped"})}else{let s=te(r.breaker),f=r.breakerOnOpen??"skip",d=re(s,{onOpen:f,meta:N("resilient","breaker")})(n);n=d.node,u=d.breakerState,this.add(n,{name:"breakerWrapped"}),this.add(u,{name:"breakerState"})}if(r.timeoutMs!=null)if(I(r.timeoutMs)){let s=n,f=r.timeoutMs;n=_(f,d=>(he(d),ie(s,d*1e6,{meta:N("resilient","timeout")}))),this.add(n,{name:"timeoutWrapped"})}else he(r.timeoutMs),n=ie(n,r.timeoutMs*1e6,{meta:N("resilient","timeout")}),this.add(n,{name:"timeoutWrapped"});if(r.retry!=null)if(I(r.retry)){let s=n,f=r.retry;n=_(f,d=>ee(s,{...d,meta:N("resilient","retry")})),this.add(n,{name:"retryWrapped"})}else n=ee(n,{...r.retry,meta:N("resilient","retry")}),this.add(n,{name:"retryWrapped"});r.fallback!==void 0&&(n=we(n,r.fallback,{meta:N("resilient","fallback")}),this.add(n,{name:"fallbackWrapped"}));let i=ye(n,{initialStatus:r.initialStatus??"pending",meta:N("resilient","status")});this.output=i.node,this.status=i.status,this.lastError=i.error,this.breakerState=u,this.droppedCount=o,this.rateLimitState=a,this.add(this.output,{name:"output"}),this.add(this.status,{name:"status"}),this.add(this.lastError,{name:"lastError"})}};function ve(e,t={}){let r=new q(e,t);return r.tagFactory("resilientPipeline",le(t)),r}function M(e){return{describeKind:"derived",...e}}function Se(e){return e<0?0:e}function ae(e){return e[1]}function Be(e){if(typeof e!="number"||!Number.isFinite(e))throw new TypeError("backoff strategy must return a finite number");return e<0?0:e}function $(e){let t=e?.count,r=e?.backoff;if(r!==void 0&&t===void 0)throw new RangeError("retry({ backoff }) requires explicit count to prevent unbounded retries; pass { count: <n>, backoff: ... }");let n=t!==void 0?t:0;if(n<0)throw new RangeError("retry count must be >= 0");let o=r===void 0?null:typeof r=="string"?pe(r):r;return{maxRetries:n,strategy:o}}function Oe(e){let t={};return e?.count!==void 0&&(t.count=e.count),typeof e?.backoff=="string"&&(t.backoff=e.backoff),Object.keys(t).length>0?t:void 0}function ge(e,t,r){let n=0,o=!1,a=null,u,i=new j;function s(){u?.(),u=void 0}function f(c){if(o)return;let l=e();if(n>=l.maxRetries){s(),r.down([[g,c]]);return}let m=l.strategy===null?0:l.strategy(n,c,a);if(m==null){s(),r.down([[g,c]]);return}let b;try{b=Be(m)}catch{s(),r.down([[g,c]]);return}a=b,n+=1,s();let p=b>0?b/1e6:1;i.start(p,()=>{o||d()})}function d(){i.cancel(),s();let c;try{c=t()}catch(l){f(l);return}u=c.subscribe(l=>{if(!o)for(let m of l){let b=m[0];if(b===O)r.down([[O]]);else if(b===w)n=0,a=null,r.emit(m[1]);else if(b===T)r.down([[T]]);else if(b===k)o=!0,s(),r.down([[k]]);else if(b===g){f(ae(m));return}else r.down([m])}})}return d(),()=>{o=!0,i.cancel(),s()}}function ee(e,t){return typeof e=="function"?Ce(e,t):xe(e,t)}var Te=new WeakSet;function xe(e,t){e._resubscribable===!1&&!Te.has(e)&&(Te.add(e),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 n=B(t)?void 0:t;return B(t)||$(n),V(o=>{let a=z(t),i=ge(()=>$(a.current()),()=>e,o);return()=>{i(),a.unsub()}},{...M(),initial:e.cache,meta:{...n?.meta??{},...C("retry",B(t)?{reactiveOpts:!0}:Oe(n))}})}function Ce(e,t){let r=B(t)?void 0:t;return B(t)||$(r),V(n=>{let o=z(t),u=ge(()=>$(o.current()),e,n);return()=>{u(),o.unsub()}},{...M(),initial:r?.initial,meta:{...r?.meta??{},...C("retry",B(t)?{reactiveOpts:!0}:Oe(r))}})}var oe=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};function te(e){let t=5,r=30*1e9,n=null,o=1,a=G;function u(y){t=Math.max(1,y?.failureThreshold??5),r=Se(y?.cooldownNs??30*1e9),n=y?.cooldown??null,o=Math.max(1,y?.halfOpenMax??1),a=y?.now??G}let i="closed",s=0,f=0,d=0,c=r,l=0,m=z(e,y=>{u(y),i="closed",s=0,f=0,l=0,c=r});u(m.current()),c=r;function b(){if(!n)return r;let y=n(f);return y!==null?y:r}function p(){i="open",c=b(),d=a(),l=0}return{canExecute(){return i==="closed"?!0:i==="open"?a()-d>=c?(i="half-open",l=1,!0):!1:l<o?(l++,!0):!1},recordSuccess(){i==="half-open"?(i="closed",s=0,f=0):i==="closed"&&(s=0)},recordFailure(y){if(i==="half-open"){f++,p();return}i==="closed"&&(s++,s>=t&&p())},get state(){return i},get failureCount(){return s},reset(){i="closed",s=0,f=0,l=0},dispose(){m.unsub()}}}function re(e,t){let r=t?.onOpen??"skip",n=t?.meta;return o=>{let a=F([],(u,i)=>{function s(){a.meta.breakerState.down([[w,e.state]])}let f=o.subscribe(d=>{for(let c of d){let l=c[0];l===O?i.down([[O]]):l===w?e.canExecute()?(s(),i.emit(c[1])):(s(),r==="error"?i.down([[g,new oe]]):i.down([[T]])):l===T?i.down([[T]]):l===k?(e.recordSuccess(),s(),i.down([[k]])):l===g?(e.recordFailure(ae(c)),s(),i.down([c])):i.down([c])}});return s(),f},{...M(),meta:{...n??{},breakerState:e.state,...C("withBreaker",{onOpen:r})},completeWhenDepsComplete:!1,initial:o.cache});return{node:a,breakerState:a.meta.breakerState}}}function ke(e,t,r){if(e<=0)throw new RangeError("capacity must be > 0");if(t<0)throw new RangeError("refillPerSecond must be >= 0");let n=r?.clock??G,o=e,a=n();function u(i){if(t>0){let s=i-a;o=Math.min(e,o+s/1e9*t)}a=i}return{available(){return u(n()),o},tryConsume(i=1){if(i<=0)return!0;let s=n();return u(s),o>=i?(o-=i,!0):!1},putBack(i=1){i<=0||(u(n()),o=Math.min(e,o+i))}}}var se=class extends Error{name="RateLimiterOverflowError";constructor(t){super(`rateLimiter buffer overflow (maxBuffer=${t})`)}};function Le(e,t){return e.droppedCount===t.droppedCount&&e.pendingCount===t.pendingCount&&e.paused===t.paused}var K=Object.freeze({droppedCount:0,pendingCount:0,paused:!1});function ne(e,t){let r=B(t);if(!r){let i=t;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 n=r?t.cache:t,o=n?.maxBuffer,a=o===1/0,u=V(i=>{let s=n?.maxEvents??1,f=n?.windowNs??1e9,d=o??1,c=n?.onOverflow??"drop-newest",l=s*1e9/f,m=1e9/l,b=ke(s,l),p=a?Me():Ee(Math.max(1,d)),h=new j,y=!1,L=0,P=u.meta.droppedCount,de=u.meta.rateLimitState,Y=K;function W(){P.emit(L);let v={droppedCount:L,pendingCount:p.size,paused:p.size>0};Le(Y,v)||(Y=v,de.emit(v))}Y=K,P.emit(0),de.emit(K);let Ne=z(t,v=>{if(y||v==null||!(v.maxEvents>0)||!(v.windowNs>0))return;let R=v.maxBuffer;if(R===void 0)return;let S=R===1/0;if(S===a&&!(!S&&(!Number.isInteger(R)||R<1))){if(!S&&R>d){console.warn(`rateLimiter: reactive maxBuffer grow (${d} \u2192 ${R}) 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(s=v.maxEvents,f=v.windowNs,d=R,c=v.onOverflow??"drop-newest",l=s*1e9/f,m=1e9/l,b=ke(s,l),!S)for(;p.size>d;)p.shift(),L+=1;W()}});function fe(){for(;p.size>0;)if(b.tryConsume(1))i.emit(p.shift()),W();else{h.start(Math.max(1,m/1e6),fe);return}}function Q(){L+=1,W()}function D(){for(y=!0,h.cancel();p.size>0;)p.shift();L=0}let Re=e.subscribe(v=>{for(let R of v){if(y)return;let S=R[0];if(S===O)i.down([[O]]);else if(S===w){if(!a&&p.size>=d)if(c==="drop-newest")Q();else if(c==="drop-oldest")p.shift(),p.push(R[1]),Q();else{Q(),D(),i.down([[g,new se(d)]]);return}else p.push(R[1]),W();fe()}else if(S===T)i.down([[T]]);else if(S===k)D(),i.down([[k]]);else if(S===g)D(),i.down([R]);else if(S===A){D(),i.down([R]);return}else i.down([R])}});return()=>{y=!0,h.cancel(),Re(),Ne.unsub()}},{...M(),initial:e.cache,meta:{...r?{}:t.meta??{},droppedCount:0,rateLimitState:K,...C("rateLimiter",r?{reactiveOpts:!0}:t)}});return{node:u,droppedCount:u.meta.droppedCount,rateLimitState:u.meta.rateLimitState}}function Ee(e){let t=new ce(e);return{push:r=>t.push(r),shift:()=>t.shift(),get size(){return t.size}}}function Me(){let e=[];return{push:t=>{e.push(t)},shift:()=>e.shift(),get size(){return e.length}}}function ye(e,t){let r=t?.initialStatus??"pending",n=t?.meta,o=F([],(a,u)=>{let i=r;return o.meta.status.down([[w,r]]),o.meta.error.down([[w,null]]),e.subscribe(f=>{for(let d of f){let c=d[0];if(c===O)u.down([[O]]);else if(c===w)i==="errored"?Z(()=>{o.meta.error.down([[w,null]]),o.meta.status.down([[w,"running"]])}):o.meta.status.down([[w,"running"]]),i="running",u.emit(d[1]);else if(c===T)u.down([[T]]);else if(c===k)o.meta.status.down([[w,"completed"]]),i="completed",u.down([[k]]);else if(c===g){let l=ae(d);Z(()=>{o.meta.error.down([[w,l]]),o.meta.status.down([[w,"errored"]])}),i="errored",u.down([d])}else u.down([d])}})},{...M(),meta:{...n??{},status:r,error:null,...C("withStatus",{initialStatus:r})},completeWhenDepsComplete:!1,resubscribable:!0,initial:e.cache});return{node:o,status:o.meta.status,error:o.meta.error}}var ue=class extends Error{name="TimeoutError";constructor(t){super(`Timed out after ${t/1e6}ms`)}};function B(e){return e!=null&&typeof e=="object"&&"cache"in e&&typeof e.subscribe=="function"}function z(e,t){if(!B(e))return{current:()=>e,unsub:()=>{}};let r=e,n=r.cache,o=r.subscribe(a=>{for(let u of a)u[0]===w&&(n=u[1],t&&t(n))});return{current:()=>n,unsub:o}}function Ve(e){return e!=null&&typeof e.then=="function"}function _e(e){return e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function"}function we(e,t,r){let n=r?.meta;return V(o=>{let a,u;function i(){u?.(),u=void 0,B(t)||Ve(t)||_e(t)?a=be(t).subscribe(f=>{o.down(f);for(let d of f){let c=d[0];if(c===k||c===g||c===A){a=void 0;return}}}):(o.emit(t),o.down([[k]]))}return u=e.subscribe(s=>{for(let f of s){let d=f[0];if(d===O)o.down([[O]]);else if(d===w)o.emit(f[1]);else if(d===T)o.down([[T]]);else if(d===k)o.down([[k]]);else if(d===g){i();return}else if(d===A){a?.(),o.down([f]);return}else o.down([f])}}),()=>{u?.(),a?.()}},{...M(),initial:e.cache,meta:{...n??{},...C("fallback")}})}function ie(e,t,r){if(!B(t)&&t<=0)throw new RangeError("timeoutNs must be > 0");let n=r?.meta,o=B(t)?{timeoutNs:"Node<number>"}:{timeoutNs:t};return V(a=>{let u=!1,i=new j,s=z(t),f=()=>{let l=s.current();return typeof l=="number"&&l>0?l:0};function d(){let l=f();if(l<=0)return;let m=l/1e6;i.start(m,()=>{u||(u=!0,c(),a.down([[g,new ue(l)]]))})}let c=e.subscribe(l=>{for(let m of l){if(u)return;let b=m[0];if(b===O)a.down([[O]]);else if(b===w)d(),a.emit(m[1]);else if(b===T)a.down([[T]]);else if(b===k){i.cancel(),u=!0,a.down([[k]]);return}else if(b===g){i.cancel(),u=!0,a.down([m]);return}else if(b===A){i.cancel(),u=!0,a.down([m]);return}else a.down([m])}});return d(),()=>{u=!0,i.cancel(),c(),s.unsub()}},{...M(),initial:e.cache,meta:{...n??{},...C("timeout",o)}})}export{U as a,q as b,ve as c,ee as d,oe as e,te as f,re as g,ke as h,se as i,ne as j,ye as k,ue as l,we as m,ie as n};
@@ -1,2 +1,2 @@
1
- import{a as G}from"./chunk-D27JNOLZ.js";import{j as z}from"./chunk-626TESAC.js";import{D as H,E as M,G as N,o as R}from"./chunk-LYCLF26R.js";function q(t){for(let c of t){let m=c.codePointAt(0);if(m>=19968&&m<=40959||m>=13312&&m<=19903||m>=12288&&m<=12351||m>=12352&&m<=12447||m>=12448&&m<=12543||m>=44032&&m<=55215||m>=65280&&m<=65519)return!0}return!1}var E=new Set(["\uFF0C","\uFF0E","\uFF01","\uFF1A","\uFF1B","\uFF1F","\u3001","\u3002","\u30FB","\uFF09","\u3015","\u3009","\u300B","\u300D","\u300F","\u3011"]),F=new Set([".",",","!","?",":",";",")","]","}","%",'"',"\u201D","\u2019","\xBB","\u203A","\u2026"]);function D(t){return t.replace(/[\t\n\r\f ]+/g," ").replace(/^ | $/g,"")}function O(t){let c=new Intl.Segmenter(void 0,{granularity:"word"}),m=[];for(let f of c.segment(t)){let h=f.segment,w=f.isWordLike??!1,u=[],s=[],r=[],p="",n=null;for(let i of h){let S;i===" "?S="space":i==="\u200B"?S="zero-width-break":i==="\xAD"?S="soft-hyphen":i===`
1
+ import{a as G}from"./chunk-7LIAPXJB.js";import{j as z}from"./chunk-HITNVN6B.js";import{D as H,E as M,G as N,o as R}from"./chunk-NTEURFZH.js";function q(t){for(let c of t){let m=c.codePointAt(0);if(m>=19968&&m<=40959||m>=13312&&m<=19903||m>=12288&&m<=12351||m>=12352&&m<=12447||m>=12448&&m<=12543||m>=44032&&m<=55215||m>=65280&&m<=65519)return!0}return!1}var E=new Set(["\uFF0C","\uFF0E","\uFF01","\uFF1A","\uFF1B","\uFF1F","\u3001","\u3002","\u30FB","\uFF09","\u3015","\u3009","\u300B","\u300D","\u300F","\u3011"]),F=new Set([".",",","!","?",":",";",")","]","}","%",'"',"\u201D","\u2019","\xBB","\u203A","\u2026"]);function D(t){return t.replace(/[\t\n\r\f ]+/g," ").replace(/^ | $/g,"")}function O(t){let c=new Intl.Segmenter(void 0,{granularity:"word"}),m=[];for(let f of c.segment(t)){let h=f.segment,w=f.isWordLike??!1,u=[],s=[],r=[],p="",n=null;for(let i of h){let S;i===" "?S="space":i==="\u200B"?S="zero-width-break":i==="\xAD"?S="soft-hyphen":i===`
2
2
  `?S="hard-break":S="text",n!==null&&S===n?p+=i:(n!==null&&(u.push(p),s.push(n==="text"&&w),r.push(n)),p=i,n=S)}n!==null&&(u.push(p),s.push(n==="text"&&w),r.push(n)),m.push({texts:u,isWordLike:s,kinds:r})}return m}function V(t,c,m,f,h){let w=D(t);if(w.length===0)return[];let u=O(w),s=new Intl.Segmenter(void 0,{granularity:"grapheme"}),r=[],p=[],n=[];for(let g of u)for(let o=0;o<g.texts.length;o++)r.push(g.texts[o]),p.push(g.kinds[o]),n.push(g.isWordLike[o]);let i=[],S=[],B=[];for(let g=0;g<r.length;g++){let o=r[g],y=p[g],I=n[g];if(y==="text"&&!I&&i.length>0&&S[S.length-1]==="text"&&o.length===1&&(F.has(o)||E.has(o))){i[i.length-1]+=o;continue}if(o==="-"&&i.length>0&&S[S.length-1]==="text"&&B[B.length-1]){i[i.length-1]+=o;continue}i.push(o),S.push(y),B.push(I)}let l=f.get(c);l||(l=new Map,f.set(c,l));function b(g){let o=l.get(g);if(o===void 0){h&&(h.misses+=1);let y=m.measureSegment(g,c).width;o=Number.isFinite(y)&&y>=0?y:0,l.set(g,o)}else h&&(h.hits+=1);return o}let d=[];for(let g=0;g<i.length;g++){let o=i[g],y=S[g];if(y!=="text"){d.push({text:o,width:y==="space"?b(" ")*o.length:0,kind:y,graphemeWidths:null});continue}if(q(o)){let a="";for(let x of s.segment(o)){let k=x.segment;if(a.length>0&&E.has(k)){a+=k;continue}if(a.length>0){let L=b(a);d.push({text:a,width:L,kind:"text",graphemeWidths:null})}a=k}if(a.length>0){let x=b(a);d.push({text:a,width:x,kind:"text",graphemeWidths:null})}continue}let I=b(o),e=null;if(B[g]&&o.length>1){let a=[];for(let x of s.segment(o))a.push(b(x.segment));a.length>1&&(e=a)}d.push({text:o,width:I,kind:"text",graphemeWidths:e})}return d}function J(t,c,m,f,h){if(t.length===0)return{lines:[],lineCount:0};let w=[],u=0,s=!1,r=0,p=0,n=0,i=0,S=-1,B=0,l=h.get(f);l||(l=new Map,h.set(f,l));let b=l.get("-");b===void 0&&(b=m.measureSegment("-",f).width,l.set("-",b));function d(e=n,a=i,x=u){let k="";for(let L=r;L<e;L++){let W=t[L];if(!(W.kind==="soft-hyphen"||W.kind==="hard-break"))if(L===r&&p>0&&W.graphemeWidths){let P=[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(W.text)].map(K=>K.segment);k+=P.slice(p).join("")}else k+=W.text}if(a>0&&e<t.length){let L=t[e],v=[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(L.text)].map(K=>K.segment),P=r===e?p:0;k+=v.slice(P,a).join("")}e>0&&t[e-1]?.kind==="soft-hyphen"&&!(r===e&&p>0)&&(k+="-"),w.push({text:k,width:x,startSegment:r,startGrapheme:p,endSegment:e,endGrapheme:a}),u=0,s=!1,S=-1,B=0}function g(e){return e==="space"||e==="zero-width-break"||e==="soft-hyphen"}function o(e,a,x){s=!0,r=e,p=a,n=e+1,i=0,u=x}function y(e,a,x){s=!0,r=e,p=a,n=e,i=a+1,u=x}for(let e=0;e<t.length;e++){let a=t[e];if(a.kind==="hard-break"){s?d():w.push({text:"",width:0,startSegment:e,startGrapheme:0,endSegment:e,endGrapheme:0}),r=e+1,p=0;continue}let x=a.width;if(!s){x>c&&a.graphemeWidths?I(e,0,a.graphemeWidths):o(e,0,x),g(a.kind)&&(S=e+1,B=a.kind==="space"?u-x:u);continue}let k=u+x;if(k>c+.005){if(g(a.kind)){u+=x,n=e+1,i=0,d(e+1,0,a.kind==="space"?u-x:u);continue}if(S>=0){d(S,0,B),e--;continue}if(x>c&&a.graphemeWidths){d(),I(e,0,a.graphemeWidths);continue}d(),e--;continue}u=k,n=e+1,i=0,g(a.kind)&&(S=e+1,B=a.kind==="space"?u-x:u)}return s&&d(),{lines:w,lineCount:w.length};function I(e,a,x){for(let k=a;k<x.length;k++){let L=x[k];if(!s){y(e,k,L);continue}u+L>c+.005?(d(),y(e,k,L)):(u+=L,n=e,i=k+1)}s&&n===e&&i===x.length&&(n=e+1,i=0)}}function A(t){return t==="space"||t==="zero-width-break"||t==="soft-hyphen"}var T=null;function _(){return T===null&&(T=new Intl.Segmenter(void 0,{granularity:"grapheme"})),T}function j(t,c,m){if(c===0&&m<0)return t.text;let f=[..._().segment(t.text)].map(w=>w.segment),h=m<0?f.length:m;return f.slice(c,h).join("")}function C(t,c,m,f,h,w){let u="";for(let s=c;s<f;s++){let r=t[s];r.kind==="soft-hyphen"||r.kind==="hard-break"||(s===c&&m>0?u+=j(r,m,-1):u+=r.text)}if(h>0&&f<t.length){let s=t[f];u+=j(s,c===f?m:0,h)}return w&&(u+="-"),u}function $(t){if(!t?.adapter||!t.font)return 0;let c=t.cache;if(c){let m=c.get(t.font);m||(m=new Map,c.set(t.font,m));let f=m.get("-");return f===void 0&&(f=t.adapter.measureSegment("-",t.font).width,m.set("-",f)),f}return t.adapter.measureSegment("-",t.font).width}function te(t,c,m,f){let h=c.segmentIndex,w=c.graphemeIndex;if(h>=t.length)return null;if(w===0){for(;h<t.length;){let e=t[h];if(e.kind==="hard-break")return{text:"",width:0,start:{segmentIndex:c.segmentIndex,graphemeIndex:0},end:{segmentIndex:h+1,graphemeIndex:0}};if(e.kind==="space"||e.kind==="zero-width-break"||e.kind==="soft-hyphen"){h+=1;continue}break}if(h>=t.length)return null}let u=$(f),s=h,r=h===c.segmentIndex?w:0,p=0,n=s,i=0,S=!1,B=-1,l=0,b=0,d=!1,g=(e,a,x,k)=>{B=e,l=a,b=x,d=k==="soft-hyphen"},o=(e,a,x)=>{for(let k=a;k<x.length;k++){let L=x[k];if(!S){p=L,n=e,i=k+1,S=!0;continue}if(p+L>m+.005)return!0;p+=L,n=e,i=k+1}return n===e&&i===x.length&&(n=e+1,i=0),!1};if(r>0&&s<t.length){let e=t[s];if(e.graphemeWidths){if(o(s,r,e.graphemeWidths))return{text:C(t,s,r,n,i,!1),width:p,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}};h=n}}for(;h<t.length;){let e=t[h];if(e.kind==="hard-break"){if(S){let k=n>0&&t[n-1]?.kind==="soft-hyphen";return{text:C(t,s,r,n,i,k),width:p+(k?u:0),start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}}}return{text:"",width:0,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:h+1,graphemeIndex:0}}}let a=e.width;if(!S){if(a>m&&e.graphemeWidths){if(o(h,0,e.graphemeWidths))return{text:C(t,s,r,n,i,!1),width:p,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}};h=n;continue}p=a,n=h+1,i=0,S=!0,A(e.kind)&&g(h+1,0,e.kind==="space"?p-a:p,e.kind),h+=1;continue}let x=p+a;if(x>m+.005){if(A(e.kind)){n=h+1,i=0;let L=e.kind==="soft-hyphen",W=e.kind==="space"?p:p+(L?u:0);return{text:C(t,s,r,n,i,L),width:W,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}}}return B>=0?{text:C(t,s,r,B,l,d),width:b+(d?u:0),start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:B,graphemeIndex:l}}:a>m&&e.graphemeWidths?{text:C(t,s,r,n,i,!1),width:p,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}}:{text:C(t,s,r,n,i,!1),width:p,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}}}p=x,n=h+1,i=0,A(e.kind)&&g(h+1,0,e.kind==="space"?p-a:p,e.kind),h+=1}if(!S)return null;let y=n>0&&t[n-1]?.kind==="soft-hyphen";return{text:C(t,s,r,n,i,y),width:p+(y?u:0),start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}}}function ne(t,c,m=0){let f=[t];for(let h=0;h<c.length;h++){let w=c[h],u=[];for(let s=0;s<f.length;s++){let r=f[s];if(w.right<=r.left||w.left>=r.right){u.push(r);continue}w.left>r.left&&u.push({left:r.left,right:w.left}),w.right<r.right&&u.push({left:w.right,right:r.right})}f=u}return m>0?f.filter(h=>h.right-h.left>=m):f}function Q(t,c,m){let f=[],h=new Intl.Segmenter(void 0,{granularity:"grapheme"});for(let w=0;w<t.lines.length;w++){let u=t.lines[w],s=w*m,r=0;for(let p=u.startSegment;p<c.length;p++){let n=c[p];if(n.kind==="soft-hyphen"||n.kind==="hard-break"){if(p>=u.endSegment&&u.endGrapheme===0)break;continue}let i=[...h.segment(n.text)].map(l=>l.segment);if(i.length===0)continue;let S=p===u.startSegment?u.startGrapheme:0,B;if(p<u.endSegment)B=i.length;else if(p===u.endSegment&&u.endGrapheme>0)B=u.endGrapheme;else break;for(let l=S;l<B;l++){let b=n.graphemeWidths?n.graphemeWidths[l]:n.width/i.length;f.push({x:r,y:s,width:b,height:m,line:w}),r+=b}}}return f}function re(t){let{adapter:c,name:m="reactive-layout"}=t,f=new z(m),h=new Map,w=M(t.text??"",{name:"text"}),u=M(t.font??"16px sans-serif",{name:"font"}),s=M(t.lineHeight??20,{name:"line-height"}),r=M(Math.max(0,t.maxWidth??800),{name:"max-width"});function p(l,b){if(l===null||b===null)return l===b;if(l.length!==b.length)return!1;for(let d=0;d<l.length;d++)if(l[d]!==b[d])return!1;return!0}let n=H([w,u],(l,b,d)=>{let g=l[0],o=g!=null&&g.length>0?g.at(-1):d.prevData[0],y=l[1],I=y!=null&&y.length>0?y.at(-1):d.prevData[1],e=R(),a={hits:0,misses:0},x=V(o,I,c,h,a),k=R()-e,L=a.hits+a.misses,W=L===0?1:a.hits/L,v=n.meta;v&&(G(v["cache-hit-rate"],W),G(v["segment-count"],x.length),G(v["layout-time-ns"],k)),b.emit(x);let P=()=>{h.clear(),c.clearCache?.()};return{deactivate:P,invalidate:P}},{name:"segments",describeKind:"derived",meta:{"cache-hit-rate":0,"segment-count":0,"layout-time-ns":0},equals:(l,b)=>{let d=l,g=b;if(d==null||g==null)return d===g;if(d.length!==g.length)return!1;for(let o=0;o<d.length;o++){let y=d[o],I=g[o];if(y.text!==I.text||y.width!==I.width||y.kind!==I.kind||!p(y.graphemeWidths??null,I.graphemeWidths??null))return!1}return!0}}),i=N([n,r,u],([l,b,d])=>J(l,b,c,d,h),{name:"line-breaks",equals:(l,b)=>{let d=l,g=b;if(d==null||g==null)return d===g;if(d.lineCount!==g.lineCount)return!1;for(let o=0;o<d.lines.length;o++){let y=d.lines[o],I=g.lines[o];if(y.text!==I.text||y.width!==I.width||y.startSegment!==I.startSegment||y.startGrapheme!==I.startGrapheme||y.endSegment!==I.endSegment||y.endGrapheme!==I.endGrapheme)return!1}return!0}}),S=N([i,s],([l,b])=>l.lineCount*b,{name:"height"}),B=N([i,n,s],([l,b,d])=>Q(l,b,d),{name:"char-positions",equals:(l,b)=>{let d=l,g=b;if(d==null||g==null)return d===g;if(d.length!==g.length)return!1;for(let o=0;o<d.length;o++)if(d[o].x!==g[o].x||d[o].y!==g[o].y||d[o].width!==g[o].width)return!1;return!0}});return f.add(w,{name:"text"}),f.add(u,{name:"font"}),f.add(s,{name:"line-height"}),f.add(r,{name:"max-width"}),f.add(n,{name:"segments"}),f.add(i,{name:"line-breaks"}),f.add(S,{name:"height"}),f.add(B,{name:"char-positions"}),{graph:f,setText:l=>f.set("text",l),setFont:l=>f.set("font",l),setLineHeight:l=>f.set("line-height",l),setMaxWidth:l=>f.set("max-width",Math.max(0,l)),segments:n,lineBreaks:i,height:S,charPositions:B}}export{V as a,J as b,te as c,ne as d,Q as e,re as f};
@@ -0,0 +1 @@
1
+ import{c as ee,d as te,f as w,h as ne}from"./chunk-W3I423PS.js";import{a as X}from"./chunk-L6NSJVJZ.js";import{j as $}from"./chunk-HITNVN6B.js";import{b as H}from"./chunk-GHBWHMRZ.js";import{b as se}from"./chunk-GLERH466.js";import{b as oe}from"./chunk-BEZWM2SY.js";import{b as Z}from"./chunk-YBB7ZGTY.js";import{C as T,m as Y}from"./chunk-CRVT7D2P.js";import{D as R,E as V,G as A,m as y,p as U}from"./chunk-NTEURFZH.js";import{b as F,j as K}from"./chunk-CK2E7BTU.js";import{b as le}from"./chunk-QYADASLV.js";var be={};le(be,{JobFlowGraph:()=>I,JobQueueGraph:()=>x,jobEventKeyOf:()=>ge,jobFlow:()=>he,jobQueue:()=>ie});var me=256,ce=1024;function E(d,e){if(!Number.isFinite(d)||!Number.isInteger(d)||d<0)throw new Error(`${e} must be a non-negative integer`);return d}function J(d,e){return X("job_queue",d,e)}var ge=d=>d.action,x=class extends ${_pending;_jobs;_seqCursor;pending;jobs;depth;events;audit;_enqueueImpl;_ackImpl;_nackImpl;_removeByIdImpl;constructor(e,n={}){super(e,n.graph),this._pending=se([],{name:"pending"}),this._jobs=oe({name:"jobs"}),this.pending=this._pending.items,this.jobs=this._jobs.entries,this.add(this.pending,{name:"pending"}),this.add(this.jobs,{name:"jobs"}),this.depth=A([this.pending],([t])=>t.length,{name:"depth",describeKind:"derived",meta:J("queue_depth"),initial:0}),this.add(this.depth,{name:"depth"}),this.addDisposer(T(this.depth)),this.events=ee({name:"events",retainedLimit:1024,graph:this}),this.audit=this.events,this._seqCursor=ne(this,"seq",0),this._enqueueImpl=w((t,o)=>{let r=this._seqCursor.cache,s=o.id??`${this.name}-${r}`;if(this._jobs.get(s)!==void 0)throw new Error(`jobQueue("${this.name}"): duplicate job id "${s}"`);let p={id:s,payload:t,attempts:0,metadata:Object.freeze({...o.metadata??{}}),state:"queued"};return this._jobs.set(s,p),this._pending.append(s),s},{audit:this.events,seq:this._seqCursor,freeze:!1,onSuccess:([t],o,{t_ns:r,seq:s})=>({action:"enqueue",id:o,payload:t,t_ns:r,seq:s??0})}),this._ackImpl=w((t,o)=>{this._jobs.delete(t)},{audit:this.events,seq:this._seqCursor,freeze:!1,onSuccess:([t,o],r,{t_ns:s,seq:p})=>({action:"ack",id:t,attempts:o.attempts,t_ns:s,seq:p??0})}),this._nackImpl=w((t,o,r)=>{r?(this._jobs.set(t,{...o,state:"queued"}),this._pending.append(t)):this._jobs.delete(t)},{audit:this.events,seq:this._seqCursor,freeze:!1,onSuccess:([t,o],r,{t_ns:s,seq:p})=>({action:"nack",id:t,attempts:o.attempts,t_ns:s,seq:p??0})}),this._removeByIdImpl=w((t,o)=>{if(o.state==="queued"){let s=this.pending.cache.indexOf(t);s>=0&&this._pending.pop(s)}this._jobs.delete(t)},{audit:this.events,seq:this._seqCursor,freeze:!1,onSuccess:([t,o],r,{t_ns:s,seq:p})=>({action:"remove",id:t,attempts:o.attempts,t_ns:s,seq:p??0})})}attachEventStorage(e){return this.events.attachStorage(e)}enqueue(e,n={}){return this._enqueueImpl(e,n)}claim(e=1){let n=E(e,"job queue claim limit");if(n===0)return[];let t=[];for(;t.length<n&&this.pending.cache.length!==0;){let r=this._pending.pop(0),s=this._jobs.get(r);if(!s||s.state!=="queued")continue;let p={...s,state:"inflight",attempts:s.attempts+1};this._jobs.set(r,p),t.push(p),this.events.append({action:"claim",id:r,attempts:p.attempts,t_ns:U(),seq:te(this._seqCursor)})}return t}ack(e){let n=this._jobs.get(e);return!n||n.state!=="inflight"?!1:(this._ackImpl(e,n),!0)}nack(e,n={}){let t=this._jobs.get(e);return!t||t.state!=="inflight"?!1:(this._nackImpl(e,t,n.requeue??!0),!0)}removeById(e){let n=this._jobs.get(e);return n?(this._removeByIdImpl(e,n),!0):!1}consumeFrom(e,n){return e.subscribe(t=>{for(let o of t){if(o[0]!==F)continue;let r=o[1];this.enqueue(r,n?{metadata:n.metadata}:void 0)}})}},I=class extends ${_stageNames;_stageWorkFns;_queues=new Map;_completed;completed;completedCount;constructor(e,n={}){super(e,n.graph);let t=n.stages??["incoming","processing","done"],o=[],r=new Map,s=new Map,p=new Map;for(let i of t){let a=typeof i=="string"?i.trim():i.name.trim();typeof i!="string"&&i.work&&r.set(a,i.work),typeof i!="string"&&i.maxPerPump!=null&&s.set(a,Math.max(1,E(i.maxPerPump,`job flow stage "${a}" maxPerPump`))),typeof i!="string"&&i.maxInflight!=null&&p.set(a,Math.max(1,E(i.maxInflight,`job flow stage "${a}" maxInflight`))),o.push(a)}if(o.length<2)throw new Error(`jobFlow("${e}"): requires at least 2 stages`);if(new Set(o).size!==o.length)throw new Error(`jobFlow("${e}"): stage names must be unique`);this._stageNames=Object.freeze([...o]),this._stageWorkFns=r;for(let i of this._stageNames){let a=ie(`${e}-${i}`);this._queues.set(i,a),this.mount(i,a)}this._completed=Z([],{name:"completed",maxSize:ce}),this.completed=this._completed.entries,this.add(this.completed,{name:"completed"}),this.completedCount=A([this.completed],([i])=>i.length,{name:"completedCount",describeKind:"derived",meta:J("job_flow_completed_count"),initial:0}),this.add(this.completedCount,{name:"completedCount"}),this.addDisposer(T(this.completedCount));let ae=Math.max(1,E(n.maxPerPump??me,"job flow maxPerPump"));for(let i=0;i<this._stageNames.length;i+=1){let a=this._stageNames[i],l=this.queue(a),P=i+1<this._stageNames.length?this.queue(this._stageNames[i+1]):null,O=this._stageWorkFns.get(a),z=s.get(a)??ae,N=p.get(a),g=N!==void 0?V(0,{name:`__inflight__/${a}`}):null;g&&this.add(g,{name:`__inflight__/${a}`});let D=P===null;if(O){let j=g!=null?[l.pending,g]:[l.pending],h=R(j,(S,c,q)=>{"inflight"in q.store||(q.store.inflight={entries:new Set,terminated:!1});let b=q.store.inflight,u=b.entries,f=0;for(;f<z&&!(N!==void 0&&u.size>=N);){let _=l.claim(1);if(_.length===0)break;let m=_[0];if(!m)break;let re=[...m.metadata.job_flow_path??[],a],L=new AbortController,k={unsub:()=>{},ac:L};u.add(k),g?.emit(u.size);let Q;try{Q=O(m,{signal:L.signal})}catch{u.delete(k),g?.emit(u.size),l.nack(m.id,{requeue:!1}),f+=1;continue}let de=Y(Q),C=!1,v,B=()=>{v?v():Promise.resolve().then(()=>v?.()),u.delete(k),b.terminated||g?.emit(u.size)};v=de.subscribe(pe=>{if(!C){for(let M of pe)if(M[0]===F){C=!0,B();let G=M[1],W={...m.metadata,job_flow_path:re};if(D){let ue={...m,payload:G,metadata:Object.freeze(W)};y(()=>{l.ack(m.id),this._completed.append(ue)})}else y(()=>{l.ack(m.id),P.enqueue(G,{metadata:W})});return}else if(M[0]===K){C=!0,B(),l.nack(m.id,{requeue:!1});return}}}),k.unsub=()=>v?.(),f+=1}return{deactivate:()=>{b.terminated=!0;for(let _ of u){try{_.ac.abort()}catch{}try{_.unsub()}catch{}}u.clear()}}},{name:`pump_${a}`,describeKind:"effect",meta:J("job_flow_pump",{stage:a,has_work:!0})});this.add(h,{name:`pump_${a}`}),this.addDisposer(T(h))}else{let j=R([l.pending],()=>{let h=0;for(;h<z;){let S=l.claim(1);if(S.length===0)break;let c=S[0];if(!c)break;let b=[...c.metadata.job_flow_path??[],a],u={...c.metadata,job_flow_path:b};if(D){let f={...c,metadata:Object.freeze(u)};y(()=>{l.ack(c.id),this._completed.append(f)})}else y(()=>{l.ack(c.id),P.enqueue(c.payload,{metadata:u})});h+=1}},{name:`pump_${a}`,describeKind:"effect",meta:J("job_flow_pump",{stage:a,has_work:!1})});this.add(j,{name:`pump_${a}`}),this.addDisposer(T(j))}}}stages(){return this._stageNames}queue(e){let n=this._queues.get(e);if(!n)throw new Error(`jobFlow("${this.name}"): unknown stage "${e}"`);return n}enqueue(e,n={}){return this.queue(this._stageNames[0]).enqueue(e,n)}retainedCompleted(){return this.completed.cache}};function ie(d,e){return new x(d,e)}function he(d,e){let n=new I(d,e),{factory:t,factoryArgs:o,...r}=e??{};return n.tagFactory("jobFlow",H(r)),n}export{ge as a,x as b,I as c,ie as d,he as e,be as f};
@@ -1 +1 @@
1
- import{C as p,v as f}from"./chunk-LYCLF26R.js";function v(t,n){if(n!=null&&n.length>0)return new Set(n);switch(t){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 b(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function D(t){let n=new WeakSet,r={};for(let[e,a]of m(t))r[e]=d(a,n);return r}function d(t,n){if(t==null)return t;let r=typeof t;if(r==="boolean"||r==="number"||r==="string")return t;if(r==="function")return"<function>";if(Array.isArray(t))return n.has(t)?"<cycle>":(n.add(t),t.map(e=>d(e,n)));if(r==="object"){let e=t;if(n.has(e))return"<cycle>";n.add(e);try{if(typeof e.subscribe=="function"&&"cache"in e)return"<Node>"}catch{return"<unserializable>"}let a={};for(let[c,i]of m(e))a[c]=d(i,n);return a}return"<unserializable>"}function m(t){let n=[],r;try{r=Object.keys(t)}catch{return n}for(let e of r)try{n.push([e,t[e]])}catch{n.push([e,"<unserializable>"])}return n}function N(t,n){let r={factory:t};return n!==void 0&&(r.factoryArgs=n),r}function h(t){let n={};for(let[r,e]of Object.entries(t.meta))try{n[r]=e.cache}catch{}return n}function R(t,n,r){let e=n==null,a=!e&&n!=null?[...n].filter(s=>s.startsWith("meta.")).map(s=>s.slice(5)):null,c=e||n.has("meta")||a!=null&&a.length>0,i="state",g=[];t instanceof p&&(i=b(t),g=t._deps.map(s=>s.node.name??""));let o={type:i,deps:g};(e||n.has("status"))&&(o.status=t.status);let u=t instanceof p?t._guard:void 0;if(c){let s={...h(t)};if(u!=null&&s.access===void 0&&(s.access=f(u)),a!=null&&a.length>0&&!n.has("meta")){let y={};for(let l of a)l in s&&(y[l]=s[l]);o.meta=y}else o.meta=s}if(t.name!=null&&(o.name=t.name),(e||n.has("value"))&&(!r||i==="state")){t.status==="sentinel"&&(o.sentinel=!0);try{o.value=t.cache}catch{}}if((e||n.has("v"))&&t.v!=null){let s={id:t.v.id,version:t.v.version};"cid"in t.v&&(s.cid=t.v.cid,s.prev=t.v.prev),o.v=s}return(e||n.has("guard"))&&u!=null&&(o.guard=f(u)),(e||n.has("lastMutation"))&&t.lastMutation!=null&&(o.lastMutation=t.lastMutation),o}export{v as a,D as b,N as c,R as d};
1
+ import{C as p,v as f}from"./chunk-NTEURFZH.js";function v(t,n){if(n!=null&&n.length>0)return new Set(n);switch(t){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 b(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function D(t){let n=new WeakSet,r={};for(let[e,a]of m(t))r[e]=d(a,n);return r}function d(t,n){if(t==null)return t;let r=typeof t;if(r==="boolean"||r==="number"||r==="string")return t;if(r==="function")return"<function>";if(Array.isArray(t))return n.has(t)?"<cycle>":(n.add(t),t.map(e=>d(e,n)));if(r==="object"){let e=t;if(n.has(e))return"<cycle>";n.add(e);try{if(typeof e.subscribe=="function"&&"cache"in e)return"<Node>"}catch{return"<unserializable>"}let a={};for(let[c,i]of m(e))a[c]=d(i,n);return a}return"<unserializable>"}function m(t){let n=[],r;try{r=Object.keys(t)}catch{return n}for(let e of r)try{n.push([e,t[e]])}catch{n.push([e,"<unserializable>"])}return n}function N(t,n){let r={factory:t};return n!==void 0&&(r.factoryArgs=n),r}function h(t){let n={};for(let[r,e]of Object.entries(t.meta))try{n[r]=e.cache}catch{}return n}function R(t,n,r){let e=n==null,a=!e&&n!=null?[...n].filter(s=>s.startsWith("meta.")).map(s=>s.slice(5)):null,c=e||n.has("meta")||a!=null&&a.length>0,i="state",g=[];t instanceof p&&(i=b(t),g=t._deps.map(s=>s.node.name??""));let o={type:i,deps:g};(e||n.has("status"))&&(o.status=t.status);let u=t instanceof p?t._guard:void 0;if(c){let s={...h(t)};if(u!=null&&s.access===void 0&&(s.access=f(u)),a!=null&&a.length>0&&!n.has("meta")){let y={};for(let l of a)l in s&&(y[l]=s[l]);o.meta=y}else o.meta=s}if(t.name!=null&&(o.name=t.name),(e||n.has("value"))&&(!r||i==="state")){t.status==="sentinel"&&(o.sentinel=!0);try{o.value=t.cache}catch{}}if((e||n.has("v"))&&t.v!=null){let s={id:t.v.id,version:t.v.version};"cid"in t.v&&(s.cid=t.v.cid,s.prev=t.v.prev),o.v=s}return(e||n.has("guard"))&&u!=null&&(o.guard=f(u)),(e||n.has("lastMutation"))&&t.lastMutation!=null&&(o.lastMutation=t.lastMutation),o}export{v as a,D as b,N as c,R as d};
@@ -1 +1 @@
1
- import{E as b,m as h}from"./chunk-LYCLF26R.js";import{b as p,c as l}from"./chunk-CK2E7BTU.js";var u=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 n=e>=0?e:this._buf.length+e;if(!(n<0||n>=this._buf.length))return this._buf[n]}append(e){this._buf.push(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._buf.length;this._buf.length=n+e.length;for(let i=0;i<e.length;i++)this._buf[n+i]=e[i];this._version+=1}insert(e,n){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,n),this._version+=1}insertMany(e,n){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insertMany: index ${e} out of range [0, ${this._buf.length}]`);n.length!==0&&(this._buf.splice(e,0,...n),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 n=e>=0?e:this._buf.length+e;if(n<0||n>=this._buf.length)throw new RangeError(`pop: index ${e} out of range`);let[i]=this._buf.splice(n,1);return this._version+=1,i}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._version+=1,e)}toArray(){return[...this._buf]}};function y(d,e={}){let{name:n,versioning:i,backend:f}=e,t=f??new u(d),a=b(t.toArray(),{name:n,describeKind:"state",equals:(r,o)=>r===o,...i!=null?{versioning:i}:{}});function v(){let r=t.toArray();h(()=>{a.down([[l]]),a.down([[p,r]])})}function s(r){let o=t.version;try{return r()}finally{t.version!==o&&v()}}return{items:a,get size(){return t.size},at(r){return t.at(r)},append(r){s(()=>t.append(r))},appendMany(r){s(()=>t.appendMany(r))},insert(r,o){s(()=>t.insert(r,o))},insertMany(r,o){s(()=>t.insertMany(r,o))},pop(r=-1){return s(()=>t.pop(r))},clear(){s(()=>t.clear())},dispose(){}}}export{u as a,y as b};
1
+ import{E as b,m as h}from"./chunk-NTEURFZH.js";import{b as p,c as l}from"./chunk-CK2E7BTU.js";var u=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 n=e>=0?e:this._buf.length+e;if(!(n<0||n>=this._buf.length))return this._buf[n]}append(e){this._buf.push(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._buf.length;this._buf.length=n+e.length;for(let i=0;i<e.length;i++)this._buf[n+i]=e[i];this._version+=1}insert(e,n){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,n),this._version+=1}insertMany(e,n){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insertMany: index ${e} out of range [0, ${this._buf.length}]`);n.length!==0&&(this._buf.splice(e,0,...n),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 n=e>=0?e:this._buf.length+e;if(n<0||n>=this._buf.length)throw new RangeError(`pop: index ${e} out of range`);let[i]=this._buf.splice(n,1);return this._version+=1,i}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._version+=1,e)}toArray(){return[...this._buf]}};function y(d,e={}){let{name:n,versioning:i,backend:f}=e,t=f??new u(d),a=b(t.toArray(),{name:n,describeKind:"state",equals:(r,o)=>r===o,...i!=null?{versioning:i}:{}});function v(){let r=t.toArray();h(()=>{a.down([[l]]),a.down([[p,r]])})}function s(r){let o=t.version;try{return r()}finally{t.version!==o&&v()}}return{items:a,get size(){return t.size},at(r){return t.at(r)},append(r){s(()=>t.append(r))},appendMany(r){s(()=>t.appendMany(r))},insert(r,o){s(()=>t.insert(r,o))},insertMany(r,o){s(()=>t.insertMany(r,o))},pop(r=-1){return s(()=>t.pop(r))},clear(){s(()=>t.clear())},dispose(){}}}export{u as a,y as b};
@@ -1 +1 @@
1
- import{j as f}from"./chunk-626TESAC.js";import{E as d}from"./chunk-LYCLF26R.js";import{b as S}from"./chunk-CK2E7BTU.js";import{b}from"./chunk-QYADASLV.js";var g={};b(g,{create:()=>v});var m=()=>!1;function v(l){let o=new f("zustand"),t=d(void 0,{name:"state",equals:m});o.add(t,{name:"state"});let r=()=>t.cache,n=(e,s)=>{let a=t.cache,i=typeof e=="function"?e(a):e;t.emit(s?i:{...a,...i})},c={getState:r,setState:n,getInitialState:()=>T,subscribe:e=>{let s=!0,a=t.cache;return t.subscribe(i=>{for(let[u,p]of i)if(u===S){if(s){s=!1;continue}e(p,a),a=p}})},destroy:o.destroy.bind(o)},T=l(n,r,c);return t.emit(T),Object.assign(o,c)}export{v as a,g as b};
1
+ import{j as f}from"./chunk-HITNVN6B.js";import{E as d}from"./chunk-NTEURFZH.js";import{b as S}from"./chunk-CK2E7BTU.js";import{b}from"./chunk-QYADASLV.js";var g={};b(g,{create:()=>v});var m=()=>!1;function v(l){let o=new f("zustand"),t=d(void 0,{name:"state",equals:m});o.add(t,{name:"state"});let r=()=>t.cache,n=(e,s)=>{let a=t.cache,i=typeof e=="function"?e(a):e;t.emit(s?i:{...a,...i})},c={getState:r,setState:n,getInitialState:()=>T,subscribe:e=>{let s=!0,a=t.cache;return t.subscribe(i=>{for(let[u,p]of i)if(u===S){if(s){s=!1;continue}e(p,a),a=p}})},destroy:o.destroy.bind(o)},T=l(n,r,c);return t.emit(T),Object.assign(o,c)}export{v as a,g as b};
@@ -0,0 +1,3 @@
1
+ import{a as Fe}from"./chunk-ESMPEKEV.js";import{a as Oe,d as _e}from"./chunk-GHBWHMRZ.js";import{C as se,m as Ie}from"./chunk-CRVT7D2P.js";import{A as ye,C as M,E as Z,F as we,G as re,J as je,e as xe,f as $e,i as Q,k as Pe,l as ne,m as ve,o as L,p as Me,s as U}from"./chunk-NTEURFZH.js";import{b as K,c as he,d as ge,e as te,f as be,g as me,h as B,i as V,j as H}from"./chunk-CK2E7BTU.js";var x={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},tt=Symbol.for("sizeof");function ze(o){let e=new WeakSet,t=new WeakSet,n=[o],s=0;for(;n.length>0;){let r=n.pop();s+=nt(r,e,t,n)}return s}function nt(o,e,t,n){if(o==null)return 0;switch(typeof o){case"number":return x.number;case"boolean":return x.boolean;case"string":return x.string+o.length*2;case"bigint":return x.bigint+rt(o);case"symbol":return x.symbol;case"function":return e.has(o)?0:(e.add(o),x.function);case"undefined":return 0}let r=o;if(e.has(r))return 0;e.add(r);let i=r[tt];if(typeof i=="function")try{let u=i.call(r);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(r instanceof Date)return x.date;if(r instanceof RegExp)return x.regexp+r.source.length*2;if(r instanceof Error){let u=r.message?r.message.length*2:0,p=r.stack?r.stack.length*2:0;return x.error+u+p}if(typeof URL<"u"&&r instanceof URL)return x.url+r.href.length*2;if(typeof Promise<"u"&&r instanceof Promise)return x.promise;if(r instanceof WeakMap)return x.weakmap;if(r instanceof WeakSet)return x.weakset;if(r instanceof Map){let u=x.map;for(let[p,g]of r)u+=x.mapEntry,n.push(p),n.push(g);return u}if(r instanceof Set){let u=x.set;for(let p of r)u+=x.setEntry,n.push(p);return u}if(Array.isArray(r)){let u=x.array+r.length*8;for(let p of r)n.push(p);return u}if(r instanceof ArrayBuffer)return t.has(r)?0:(t.add(r),r.byteLength);if(ArrayBuffer.isView(r)){let u=r;return t.has(u.buffer)?48:(t.add(u.buffer),u.buffer.byteLength+48)}let a=x.object,c=Object.keys(r);for(let u of c){a+=x.string+u.length*2;try{n.push(r[u])}catch{}}return a}function rt(o){let e=o<0n?-o:o;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}function Be(o,e,t,n={}){let s=e in o.nodes,r=t in o.nodes;if(!s)return oe(e,t,"no-such-from");if(!r)return oe(e,t,"no-such-to");let i=n.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(n.findCycle===!0){let u=st(o,e,n);if(u!=null)return u}let c=ie(e,o.nodes[e],0,n);return ae(e,t,[c])}if(i===0)return oe(e,t,"no-path");let a=Le(o,e,t,i);return a.found?ae(e,t,qe(o,a.pathOrder,n)):oe(e,t,a.truncated?"max-depth-exceeded":"no-path")}function Le(o,e,t,n){let s=new Map,r=[{path:t,depth:0}],i=new Set([t]),a=0,c=!1;for(;a<r.length;){let g=r[a++];if(g.path===e)break;if(n!=null&&g.depth>=n){let y=o.nodes[g.path];y?.deps&&y.deps.length>0&&(c=!0);continue}let h=o.nodes[g.path];if(h==null)continue;let f=h.deps??[],d=new Map;for(let y=0;y<f.length;y++){let l=f[y];if(!l)continue;let O=d.get(l);O==null&&(O=[],d.set(l,O)),O.push(y)}for(let[y,l]of d)i.has(y)||(i.add(y),s.set(y,{from:g.path,depIndices:l}),r.push({path:y,depth:g.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:c};let u=[{path:e}],p=e;for(;p!==t;){let g=s.get(p);if(g==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=g.depIndices,u.push({path:g.from}),p=g.from}return{found:!0,pathOrder:u,truncated:!1}}function st(o,e,t){let n=o.nodes[e];if(n==null)return null;let s=n.deps??[],r=[];for(let a=0;a<s.length;a++)s[a]===e&&r.push(a);if(r.length>0){let a=ie(e,n,0,t);a.dep_index=r[0];let c=ie(e,n,1,t);return ae(e,e,[a,c])}let i=null;for(let a=0;a<s.length;a++){let c=s[a];if(!c||c===e)continue;let u=Le(o,c,e,t.maxDepth);u.found&&(i==null||u.pathOrder.length<i.pathOrder.length)&&(i=u,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...u.pathOrder],truncated:!1})}return i==null?null:ae(e,e,qe(o,i.pathOrder,t))}function qe(o,e,t){return e.map((n,s)=>{let r=o.nodes[n.path],i=ie(n.path,r,s,t);return n.depIndices!=null&&n.depIndices.length>0&&(i.dep_index=n.depIndices[0],n.depIndices.length>1&&(i.dep_indices=[...n.depIndices])),i})}function ie(o,e,t,n){let s={path:o,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 r=n.annotations?.get(o)??e.annotation;r!=null&&(s.annotation=r);let i=n.lastMutations?.get(o)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function ae(o,e,t){return Ke(o,e,!0,"ok",t)}function oe(o,e,t){return Ke(o,e,!1,t,[])}function Ke(o,e,t,n,s){let r=ot(o,e,t,n,s);return{from:o,to:e,found:t,reason:n,steps:s,text:r,toJSON(){return{from:o,to:e,found:t,reason:n,steps:s}}}}function ot(o,e,t,n,s){if(!t)switch(n){case"no-such-from":return`explainPath: no node named "${o}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${o}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${o}" to "${e}"`}let r=[`Causal path: ${o} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let c=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(r.push(c),"value"in i&&r.push(` value: ${it(i.value)}`),i.annotation!=null&&r.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;r.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return r.join(`
2
+ `)}function it(o){if(o===void 0)return"<sentinel>";if(o===null)return"null";if(typeof o=="string")return JSON.stringify(o);if(typeof o=="number"||typeof o=="boolean"||typeof o=="bigint")return String(o);try{let e=JSON.stringify(o);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(o)}}function Ee(o,e){if(Object.is(o,e))return!0;if(o==null||e==null||typeof o!="object"||typeof e!="object")return!1;if(Array.isArray(o)){if(!Array.isArray(e)||o.length!==e.length)return!1;for(let r=0;r<o.length;r++)if(!Ee(o[r],e[r]))return!1;return!0}if(Array.isArray(e))return!1;let t=Object.keys(o),n=Object.keys(e);if(t.length!==n.length)return!1;let s=new Set(n);for(let r of t)if(!s.has(r)||!Ee(o[r],e[r]))return!1;return!0}function Ve(o,e){return`${o}\0${e}`}function ke(o,e){let t=[],n=new Set(o.subgraphs),s=new Set(e.subgraphs),r=[];for(let l of s)n.has(l)||r.push(l);r.sort();for(let l of r)t.push({type:"subgraph-mounted",path:l});let i=new Set(Object.keys(o.nodes)),a=new Set(Object.keys(e.nodes)),c=[];for(let l of a)i.has(l)||c.push(l);c.sort();for(let l of c)t.push({type:"node-added",path:l,node:{...e.nodes[l]}});let u=[];for(let l of a){if(!i.has(l))continue;let O=o.nodes[l]?.meta,b=e.nodes[l]?.meta;O==null&&b==null||Ee(O??{},b??{})||u.push(l)}u.sort();for(let l of u)t.push({type:"node-meta-changed",path:l,prevMeta:o.nodes[l]?.meta??{},nextMeta:e.nodes[l]?.meta??{}});let p=new Map;for(let l of o.edges)p.set(Ve(l.from,l.to),l);let g=new Map;for(let l of e.edges)g.set(Ve(l.from,l.to),l);let h=[];for(let[l,O]of g)p.has(l)||h.push(O);h.sort((l,O)=>l.from<O.from?-1:l.from>O.from?1:l.to<O.to?-1:l.to>O.to?1:0);for(let l of h)t.push({type:"edge-added",from:l.from,to:l.to});let f=[];for(let[l,O]of p)g.has(l)||f.push(O);f.sort((l,O)=>l.from<O.from?-1:l.from>O.from?1:l.to<O.to?-1:l.to>O.to?1:0);for(let l of f)t.push({type:"edge-removed",from:l.from,to:l.to});let d=[];for(let l of i)a.has(l)||d.push(l);d.sort();for(let l of d)t.push({type:"node-removed",path:l});let y=[];for(let l of n)s.has(l)||y.push(l);y.sort();for(let l of y)t.push({type:"subgraph-unmounted",path:l});return{events:t,flushedAt_ns:L()}}function He(o,e){let t=e?.topN??10,n=o.describe({detail:"standard"}),s=[],r=o._collectObserveTargets;typeof r=="function"&&r.call(o,"",s);let i=new Map;for(let[h,f]of s)i.set(h,f);let a=[];for(let[h,f]of Object.entries(n.nodes)){let d=i.get(h),y=d instanceof M?d:null,l=y?ze(y.cache):0,O=y?y._sinkCount:0,b=f.deps?.length??0,m=f.type==="effect"&&O===0,v=O===0?f.type==="effect"?"orphan-effect":f.type==="derived"?"idle-derived":f.type==="producer"?"idle-producer":null:null;a.push({path:h,type:f.type,status:f.status??"unknown",valueSizeBytes:l,subscriberCount:O,depCount:b,isOrphanEffect:m,orphanKind:v})}let c=a.reduce((h,f)=>h+f.valueSizeBytes,0),u=(h,f)=>[...a].sort(f??((d,y)=>y[h]-d[h])).slice(0,t),p=a.filter(h=>h.orphanKind!=null),g=a.filter(h=>h.isOrphanEffect);return{nodeCount:a.length,edgeCount:n.edges.length,subgraphCount:n.subgraphs.length,nodes:a,totalValueSizeBytes:c,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:p,orphanEffects:g}}var X=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}};var A="::",z="__meta__",J=1;function ue(o,e){let t=Math.max(16,o.size*4),n=0;for(;o.size>0;){if(n++>=t){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${t}); ${o.size} disposer(s) discarded`),o.clear();return}let s=o.values().next();if(s.done)return;let r=s.value;o.delete(r);try{r()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function Ze(o){return o!=null&&typeof o=="object"&&"cache"in o&&typeof o.subscribe=="function"&&typeof o.down=="function"}function at(o){if(o!=null)return Ze(o)?o.cache:o}function W(o){return o!=null&&typeof o=="object"&&"cache"in o&&typeof o.subscribe=="function"&&typeof o.down=="function"}function q(o){return W(o)?o.cache??"":o}function We(o){return W(o)?o.cache??0:o}function Ue(o){return W(o)?o.cache??!1:o}function ut(o){let e=[];for(let t of Object.keys(o).sort()){let n=o[t].v;n!=null&&e.push(`${t} ${n.id} ${n.version}`)}return e.join(`
3
+ `)}function Je(o){if(o.version!==J)throw new Error(`unsupported snapshot version ${String(o.version)} (expected ${J})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in o))throw new Error(`snapshot missing required key "${e}"`);if(typeof o.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof o.nodes!="object"||o.nodes===null||Array.isArray(o.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(o.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(o.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function dt(o,e){let t=new WeakMap,n=(s,r)=>{if(Object.is(s,r))return!0;if(s==null||r==null||typeof s!="object"||typeof r!="object")return!1;let i=t.get(s);if(i==null&&(i=new WeakSet,t.set(s,i)),i.has(r))return!0;i.add(r);let a=s.constructor,c=r.constructor;if(a!==c)return!1;if(s instanceof Date)return s.getTime()===r.getTime();if(s instanceof RegExp)return s.source===r.source&&s.flags===r.flags;if(Array.isArray(s)){let h=r;if(s.length!==h.length)return!1;for(let f=0;f<s.length;f++)if(!n(s[f],h[f]))return!1;return!0}if(s instanceof Map){let h=r;if(s.size!==h.size)return!1;for(let[f,d]of s)if(!h.has(f)||!n(d,h.get(f)))return!1;return!0}if(s instanceof Set){let h=r;if(s.size!==h.size)return!1;for(let f of s){let d=!1;for(let y of h)if(n(f,y)){d=!0;break}if(!d)return!1}return!0}if(ArrayBuffer.isView(s)){let h=s,f=r;if(h.length!==f.length)return!1;for(let d=0;d<h.length;d++)if(h[d]!==f[d])return!1;return!0}let u=Object.keys(s),p=Object.keys(r);if(u.length!==p.length)return!1;let g=new Set(p);for(let h of u)if(!g.has(h)||!n(s[h],r[h]))return!1;return!0};return n(o,e)}function ct(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function de(o){let e="^";for(let t=0;t<o.length;t+=1){let n=o[t];if(n==="*"){e+=".*";continue}if(n==="?"){e+=".";continue}if(n==="["){let s=o.indexOf("]",t+1);if(s<=t+1){e+="\\[";continue}let r=o.slice(t+1,s);r.startsWith("!")&&(r=`^${r.slice(1)}`),r=r.replace(/\\/g,"\\\\"),e+=`[${r}]`,t=s;continue}e+=ct(n)}return e+="$",new RegExp(e)}var lt={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"},pt={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function Se(o){if(typeof o=="string")return JSON.stringify(o);if(typeof o=="number"||typeof o=="boolean"||o==null)return String(o);try{return JSON.stringify(o)}catch{return"[unserializable]"}}function ft(o){return o==="none"?pt:o==="ansi"||o==null?lt:{data:o.data??"",dirty:o.dirty??"",resolved:o.resolved??"",invalidate:o.invalidate??"",pause:o.pause??"",resume:o.resume??"",complete:o.complete??"",error:o.error??"",teardown:o.teardown??"",derived:o.derived??"",path:o.path??"",reset:o.reset??""}}function Ye(o){if(o==null)return{};let e=o.detail;return e==="full"?{...o,structured:o.structured??!0,timeline:o.timeline??!0,causal:o.causal??!0,derived:o.derived??!0}:e==="minimal"?{...o,structured:o.structured??!0}:o.format==="stage-log"?{...o,structured:o.structured??!0,timeline:o.timeline??!0}:o}function ht(o,e,t){for(let n=0;n<o.length;n++){let s=o.charCodeAt(n);if(s<32||s===127)throw new Error(`Graph "${e}": ${t} "${o}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${n})`)}}function Re(o,e,t){if(o==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(o.includes(A))throw new Error(`Graph "${e}": ${t} "${o}" must not contain '${A}' (path separator)`);if(o===z)throw new Error(`Graph "${e}": ${t} name "${z}" is reserved for meta companion paths`);ht(o,e,t)}function gt(o,e){if(o==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=o.split(A);for(let n of t)if(n==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function bt(o,e){let t=!1;for(let s of o)if(!e.isMetaPassthrough(s[0])){t=!0;break}return t?o.filter(s=>e.isMetaPassthrough(s[0])):o}function Xe(o){for(let e of o._mounts.values())Xe(e);for(let e of o._nodes.values())try{e.down([[B]],{internal:!0})}catch{}}var Ne=class o{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(A))throw new Error(`Graph name must not contain '${A}' (got "${e}")`);if(e===z)throw new Error(`Graph name "${z}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??ye,this._traceRing=new X(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=[],n=e?this:this._parent;for(;n!=null;)t.push(n),n=n._parent;return t}get topology(){return this._topology==null&&(this._topology=we(e=>{let t=n=>{e.emit(n)};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 n=e.name,s=t?.name??n;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 r=s,i=t?.annotation;if(Re(r,this.name,"add"),this._mounts.has(r))throw new Error(`Graph "${this.name}": name "${r}" is already a mount point`);if(this._nodes.has(r))throw new Error(`Graph "${this.name}": node "${r}" 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(r,e),this._nodeToName.set(e,r),this._emitTopology({kind:"added",name:r,nodeKind:"node"}),i!=null&&(this._annotations.set(r,i),this.config.inspectorEnabled&&this._traceRing.push({path:r,annotation:i,timestamp_ns:L()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof M&&t._applyVersioning(e)}remove(e){Re(e,this.name,"remove");let t=this._mounts.get(e);if(t){let r={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[a,c]of i)a.includes(`${A}${z}${A}`)||r.nodes.push(a);return r.nodes.sort(),r.mounts.push(e),r.mounts.push(...t._collectSubgraphs(`${e}${A}`)),this._mounts.delete(e),t._parent=void 0,Xe(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:r}),r}let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(n),n.down([[B]],{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 r=de(e);return i=>r.test(i)})(),n={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(r=>t(r));for(let r of s){let i=this.remove(r);n.nodes.push(...i.nodes),n.mounts.push(...i.mounts)}return n.nodes.sort(),n.mounts.sort(),n}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,n=0;return{[Symbol.iterator](){return this},next(){if(n>=e.length)return{value:void 0,done:!0};let s=e[n++];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(A))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,n){let s=n?.internal===!0;this.node(e).down([[K,t]],{actor:n?.actor,internal:s,delivery:"write"})}setAll(e,t){let n=Symbol.iterator in e?e:Object.entries(e);ve(()=>{for(let[s,r]of n)this.set(s,r,t)})}invalidate(e,t){let n=t?.internal===!0;this.node(e).down([[te]],{actor:t?.actor,internal:n,delivery:"write"})}error(e,t,n){let s=n?.internal===!0;this.node(e).down([[H,t]],{actor:n?.actor,internal:s,delivery:"write"})}complete(e,t){let n=t?.internal===!0;this.node(e).down([[V]],{actor:t?.actor,internal:n,delivery:"write"})}_registerSelfPruningKeepalive(e){let t,n,s=()=>{t?.(),t=void 0,n?.(),n=void 0};t=e.subscribe(r=>{for(let i of r){let a=i[0];if(a===B||a===V||a===H){s();return}}}),n=this.addDisposer(s)}_wireSignalToRemove(e,t){if(t==null)return;let n=()=>{try{this.remove(e)}catch{}};if(t.aborted){n();return}t.addEventListener("abort",n,{once:!0}),this.addDisposer(()=>t.removeEventListener("abort",n))}derived(e,t,n,s){let r=t.map(f=>this.resolve(f)),{keepAlive:i,annotation:a,equals:c,initial:u,meta:p,signal:g}=s??{},h=re(r,n,{name:e,...c!=null?{equals:c}:{},...u!==void 0?{initial:u}:{},...p!=null?{meta:p}:{}});return this.add(h,{name:e,...a!=null?{annotation:a}:{}}),i===!0&&this._registerSelfPruningKeepalive(h),this._wireSignalToRemove(e,g),h}effect(e,t,n,s){let r=t.map(p=>this.resolve(p)),{annotation:i,meta:a,signal:c}=s??{},u=je(r,n,{name:e,...a!=null?{meta:a}:{}});return this.add(u,{name:e,...i!=null?{annotation:i}:{}}),this._wireSignalToRemove(e,c),u}produce(e,t,n){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:r,equals:i,signal:a}=n??{},c=Ie(t,{name:e,...r!=null?{meta:r}:{},...i!=null?{equals:i}:{},...a!=null?{signal:a}:{}});return this.add(c,{name:e,...s!=null?{annotation:s}:{}}),this._wireSignalToRemove(e,a),c}batch(e){ve(e)}edges(e){let t=e?.recursive===!0,n=new Map;if(!t){for(let[c,u]of this._nodes)n.set(u,c);let a=[];for(let[c,u]of this._nodes)if(u instanceof M)for(let p of u._deps){let g=n.get(p.node);g!=null&&a.push([g,c])}return a.sort((c,u)=>c[0]<u[0]?-1:c[0]>u[0]?1:c[1]<u[1]?-1:c[1]>u[1]?1:0),a}let s=[];this._collectObserveTargets("",s);let r=new Map;for(let[a,c]of s)r.set(c,a);let i=[];for(let[a,c]of s)if(c instanceof M)for(let u of c._deps){let p=r.get(u.node);p!=null&&i.push([p,a])}return i.sort((a,c)=>a[0]<c[0]?-1:a[0]>c[0]?1:a[1]<c[1]?-1:a[1]>c[1]?1:0),i}mount(e,t){if(t===void 0){let s=new o(e);return this.mount(e,s)}if(typeof t=="function"){let s=new o(e);return t(s),this.mount(e,s)}let n=t;if(Re(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(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let s=this;s!=null;s=s._parent)if(s===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let t=gt(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 n=t[0],s=t.slice(1);if(s.length===0){let a=this._nodes.get(n);if(a)return a;throw this._mounts.has(n)?new Error(`Graph "${this.name}": path ends at subgraph "${n}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${n}"`)}let r=this._nodes.get(n);if(r&&s.length>0&&s[0]===z)return this._resolveMetaChainFromNode(r,s,t.join(A));let i=this._mounts.get(n);if(!i)throw this._nodes.has(n)?new Error(`Graph "${this.name}": "${n}" is a node; trailing path "${s.join(A)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${n}"`);return i.resolve(s.join(A))}_resolveMetaChainFromNode(e,t,n){let s=e,r=0,i=[...t];for(;r<i.length;){if(i[r]!==z)throw new Error(`Graph "${this.name}": expected ${z} segment in meta path "${n}"`);if(r+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${z} in "${n}"`);let a=i[r+1],c=s.meta[a];if(!c)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${n}"`);s=c,r+=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 n=[];if(this._signalDeliver(e,t??{},new Set,n),n.length>0)throw n[0]}_signalDeliver(e,t,n,s){for(let c of this._mounts.values())c._signalDeliver(e,t,n,s);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},a=bt(e,this.config);for(let c of[...this._nodes.keys()].sort()){let u=this._nodes.get(c);if(!n.has(u)){n.add(u);try{u.down(e,i)}catch(p){if(p instanceof U)throw p;s.push(p)}a.length!==0&&this._signalMetaSubtree(u,a,n,i,s)}}}_signalMetaSubtree(e,t,n,s,r){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!n.has(a)){n.add(a);try{a.down(t,s)}catch(c){if(c instanceof U)throw c;r.push(c)}this._signalMetaSubtree(a,t,n,s,r)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=at(e?.actor),n=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=Oe(e?.detail,e?.fields),r=e?.detail==="spec",i=s,a=[];this._collectObserveTargets("",a);let c=new Map;for(let[v,w]of a)c.set(w,v);let u=[];{let v=a.map(([,S])=>S),w=new Set(c.values()),E=0;for(;v.length>0;){let S=v.shift();if(S instanceof M)for(let R of S._deps){let G=R.node;if(c.has(G))continue;let D=G.name??"",k=D;if(!k||w.has(k))if(D){let I=2;for(;w.has(`${D}#${I}`);)I++;k=`${D}#${I}`}else for(k=`__internal__/${E++}`;w.has(k);)k=`__internal__/${E++}`;c.set(G,k),w.add(k),u.push([k,G]),v.push(G)}}}let p=[...a,...u],g={};for(let[v,w]of p){if(t!=null&&!w.allowsObserve(t))continue;let E=_e(w,i,r),S=w instanceof M?w._deps.map(k=>c.get(k.node)??k.node.name??""):[],{name:R,...G}=E,D={...G,deps:S};if(!r){let k=this._annotations.get(v);k!=null&&(D.annotation=k)}if(n!=null)if(typeof n=="function"){let k=n;if(!(k.length>=2?k(v,D):k(D)))continue}else{let k=!0;for(let[I,$]of Object.entries(n)){let T=I==="deps_includes"?"depsIncludes":I==="meta_has"?"metaHas":I;if(T==="depsIncludes"){if(!D.deps.includes(String($))){k=!1;break}continue}if(T==="metaHas"){if(!Object.hasOwn(D.meta??{},String($))){k=!1;break}continue}if(D[T]!==$){k=!1;break}}if(!k)continue}g[v]=D}let h=new Set(Object.keys(g)),f=[];for(let[v,w]of p)if(w instanceof M)for(let E of w._deps){let S=c.get(E.node);S!=null&&f.push([S,v])}f.sort((v,w)=>v[0]<w[0]?-1:v[0]>w[0]?1:v[1]<w[1]?-1:v[1]>w[1]?1:0);let d=f.map(([v,w])=>({from:v,to:w}));(t!=null||n!=null)&&(d=d.filter(v=>h.has(v.from)&&h.has(v.to)));let y=this._collectSubgraphs(""),l=t!=null||n!=null?y.filter(v=>{let w=`${v}${A}`;return[...h].some(E=>E===v||E.startsWith(w))}):y,O=this,b=e;return{name:this.name,nodes:g,edges:d,subgraphs:l,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(v){let w={...b};return Array.isArray(v)?(w.fields=v,w.detail=void 0):(w.detail=v,w.fields=void 0),O.describe(w)}}}_collectSubgraphs(e){let t=[];for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${n}`;t.push(s),t.push(...this._mounts.get(n)._collectSubgraphs(`${s}${A}`))}return t}resourceProfile(e){return He(this,e)}reachable(e,t,n={}){return n.withDetail===!0?Qe(this.describe(),e,t,{...n,withDetail:!0}):Qe(this.describe(),e,t,n)}explain(e,t,n){return n?.reactive===!0?this._explainReactive(e,t,n):this._explainStatic(q(e),q(t),{...n?.maxDepth!==void 0?{maxDepth:We(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:Ue(n.findCycle)}:{}})}_explainStatic(e,t,n){let s=this.describe({detail:"full"}),r=new Map(this._annotations),i=new Map;for(let[a,c]of Object.entries(s.nodes))c.lastMutation!=null&&i.set(a,c.lastMutation);return Be(s,e,t,{...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{},annotations:r,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},n=e.reactiveName??"describe",s=0,r=Z(s,{name:`${n}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,c=!1,u=()=>{a||c||(a=!0,ne(()=>{a=!1,!c&&(s+=1,r.emit(s))}))},p=i.onEvent(b=>{let m=b.type;m!=="data"&&m!=="error"&&m!=="complete"&&m!=="teardown"||u()}),g=[],h=new WeakSet,f=b=>{if(h.has(b)||c)return;h.add(b);let m=b.topology.subscribe(v=>{for(let w of v){if(w[0]!==K)continue;let E=w[1];if(u(),E.kind==="added"&&E.nodeKind==="mount"){let S=b._mounts.get(E.name);S!=null&&f(S)}}});g.push(m);for(let v of b._mounts.keys()){let w=b._mounts.get(v);w!=null&&f(w)}};f(this);let d,y=e.actor;Ze(y)&&(d=y.subscribe(b=>{let m=!1,v=!1;for(let w of b){let E=w[0];E===K?m=!0:(E===V||E===H||E===B)&&(v=!0)}m&&u(),v&&(d?.(),d=void 0,u())}));let l;try{l=re([r],()=>this.describe(t),{name:n,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(b,m)=>b===m})}catch(b){p(),d?.();for(let m of g)m();throw i.dispose(),b}let O=se(l);return{node:l,dispose(){c=!0,p(),d?.();for(let b of g)b();g.length=0,i.dispose(),O()}}}_describeReactiveDiff(e){let t={...e,reactive:!1},n=e.reactiveName??"describe-diff",s={name:this.name,nodes:{},edges:[],subgraphs:[]},r=this.describe(t),i=ke(s,r),a=Z(i,{name:n,meta:{domain:"audit",kind:"describe-diff"},equals:(h,f)=>h===f}),c=this._describeReactive({...e,reactiveName:void 0}),u=!1,p=c.node.subscribe(h=>{if(!u)for(let f of h){if(f[0]!==K)continue;let d=f[1],y=ke(r,d);r=d,y.events.length!==0&&a.emit(y)}}),g=se(a);return{node:a,dispose(){u=!0,p(),c.dispose(),a.down([[B,"describe-diff disposed"]]),g()}}}_explainReactive(e,t,n){let s=0,r=Z(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,c=!1,u=()=>{a||c||(a=!0,ne(()=>{a=!1,!c&&(s+=1,r.emit(s))}))},p=i.onEvent(b=>{let m=b.type;m!=="data"&&m!=="error"&&m!=="complete"&&m!=="teardown"||u()}),g=[];e!=null&&W(e)&&g.push(e),t!=null&&W(t)&&g.push(t),n?.maxDepth!=null&&W(n.maxDepth)&&g.push(n.maxDepth),n?.findCycle!=null&&W(n.findCycle)&&g.push(n.findCycle);let h=()=>{for(let b of g)if(b.cache===void 0)return!1;return!0},f=()=>{let b=q(e),m=q(t);return{from:b,to:m,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:b,to:m,found:!1,reason:"pending",steps:[]})}},d;try{d=re([r],()=>{if(!h())return f();let b=q(e),m=q(t),v={...n?.maxDepth!==void 0?{maxDepth:We(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:Ue(n.findCycle)}:{}};return this._explainStatic(b,m,v)},{name:n?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:q(e),to:q(t)},equals:(b,m)=>b.found===m.found&&b.reason===m.reason&&b.steps.length===m.steps.length&&vt(b.steps,m.steps)})}catch(b){throw p(),i.dispose(),b}let y=se(d),l=[],O=b=>{let m;return m=b.subscribe(v=>{let w=!1,E=!1;for(let S of v){let R=S[0];R===K?w=!0:(R===V||R===H||R===B)&&(E=!0)}(w||E)&&u(),E&&m&&(m(),m=void 0)}),()=>{m&&(m(),m=void 0)}};for(let b of g)l.push(O(b));return{node:d,dispose(){c=!0,p();for(let b of l)b?.();l.length=0,i.dispose(),y()}}}_pathsMatching(e){let t=de(e),n=[];return this._collectObserveTargets("",n),n.map(([s])=>s).filter(s=>t.test(s))}_collectObserveTargets(e,t){for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${A}${n}`;this._mounts.get(n)._collectObserveTargets(s,t)}for(let n of[...this._nodes.keys()].sort()){let s=this._nodes.get(n),r=e===""?n:`${e}${A}${n}`;t.push([r,s]),this._appendMetaObserveTargets(r,s,t)}}_appendMetaObserveTargets(e,t,n){for(let s of Object.keys(t.meta).sort()){let r=t.meta[s],i=`${e}${A}${z}${A}${s}`;n.push([i,r]),this._appendMetaObserveTargets(i,r,n)}}observe(e,t){let n=typeof e=="string",r=Ye(n?t:e);if(r.reactive===!0)return this._observeReactive(n?e:void 0,r);let i=r.structured===!0||r.timeline===!0||r.causal===!0||r.derived===!0||r.detail==="minimal"||r.detail==="full"||r.format!=null,a=r.actor;if(n){let p=e,g=this.resolve(p);if(a!=null&&!g.allowsObserve(a))throw new U({actor:a,action:"observe",nodeName:p});return i?this._buildStructuredObserver([[p,g]],r,"one"):{subscribe(h){return g.subscribe(h)},up(h){try{g.up?.(h)}catch(f){if(f instanceof U)return;throw f}}}}let c=[];this._collectObserveTargets("",c),c.sort((p,g)=>p[0]<g[0]?-1:p[0]>g[0]?1:0);let u=a==null?c:c.filter(([,p])=>p.allowsObserve(a));return i?this._buildStructuredObserver(u,r,"all"):{subscribe:p=>{let g=u.map(([h,f])=>f.subscribe(d=>{p(h,d)}));return()=>{for(let h of g)h()}},up:(p,g)=>{try{this.resolve(p).up?.(g)}catch(h){if(h instanceof U)return;throw h}}}}_observeReactive(e,t){let n=t.tiers,s=n!=null?new Set(n):null,r=t.reactiveName??"observe";return we(i=>{let a=[],c=!1,u=!1,p=()=>{if(a.length===0||u)return;let y={events:a.slice(),flushedAt_ns:L()};a.length=0,i.emit(y)},g={...t,reactive:!1,structured:!0,timeline:!0},h=e!=null?this.observe(e,g):this.observe(g),f=y=>{u||(a.push(y),!c&&(c=!0,ne(()=>{c=!1,p()})))};for(let y of h.events)f(y);let d=h.onEvent(f);return()=>{u=!0,d(),h.dispose()}},{name:r,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,t,n){let s=n==="one"?e[0]?.[0]:void 0,r=i=>{if(n==="one"&&s!=null){let p=this.resolve(s);return this._buildStructuredObserver([[s,p]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((p,g)=>p[0]<g[0]?-1:p[0]>g[0]?1:0);let c=i.actor,u=c==null?a:a.filter(([,p])=>p.allowsObserve(c));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,t,r)}_createObserveResult(e,t,n){let s=t.timeline===!0,r=t.causal===!0,i=t.derived===!0,a=t.detail==="minimal",c=this.config.inspectorEnabled,u=(r||i)&&c,p=t.maxEvents,g=p!=null&&p>0?new X(p):null,h=[],f=new Set,d=t.tiers!=null?new Set(t.tiers):null,y={},l=new Set,O=0,b=0,m=0,v=0,w=0,E=0,S=!1,R=!1,G=0,D=new Map,k=new Map,I=new Map,$=_=>{if(!(d!=null&&!d.has(_.type))){g?g.push(_):h.push(_);for(let C of f)C(_)}},T=_=>d==null||d.has(_),Ge=()=>s?{timestamp_ns:L(),in_batch:Pe(),batch_id:G}:{},et=(_,C)=>{if(!(!u||!(_ instanceof M)))return _._setInspectorHook(j=>{if(j.kind==="dep_message")D.set(_,j.depIndex);else if(j.kind==="run"){let Y=j.batchData.map((N,P)=>N!=null&&N.length>0?N.at(-1):j.prevData[P]);k.set(_,Y);let F=j.batchData.map(N=>N!=null?[...N]:void 0);I.set(_,F),i&&$({type:"derived",path:C,dep_values:Y,dep_batches:F,...Ge()})}})},De=_=>{let C=D.get(_),j=k.get(_);if(!r||j==null)return{};let F=(C!=null&&C>=0&&_ instanceof M?_._deps[C]:void 0)?.node,N=F?.v,P=I.get(_);return{trigger_dep_index:C,trigger_dep_name:F?.name,...N!=null?{trigger_version:{id:N.id,version:N.version}}:{},dep_values:[...j],...P!=null?{dep_batches:P}:{}}},Ce=[],Ae=[];for(let[_,C]of e){let j=et(C,_);j&&Ce.push(j),Ae.push(C.subscribe(Y=>{G++;for(let F of Y){let N=F[0],P=Ge();if(N===K){y[_]=F[1];let fe=C instanceof M?C.lastMutation?.actor??Q:Q;$({type:"data",path:_,data:F[1],actor:fe,...P,...De(C)})}else if(a)N===he?T("dirty")&&O++:N===ge?T("resolved")&&b++:N===te?T("invalidate")&&m++:N===be?T("pause")&&v++:N===me?T("resume")&&w++:N===B?T("teardown")&&E++:N===V&&!l.has(_)?T("complete")&&(S=!0):N===H&&T("error")&&(R=!0,l.add(_));else if(N===he)T("dirty")&&O++,$({type:"dirty",path:_,...P});else if(N===ge)T("resolved")&&b++,$({type:"resolved",path:_,...P,...De(C)});else if(N===te)T("invalidate")&&m++,$({type:"invalidate",path:_,...P});else if(N===be)T("pause")&&v++,$({type:"pause",path:_,lockId:F[1],...P});else if(N===me)T("resume")&&w++,$({type:"resume",path:_,lockId:F[1],...P});else if(N===V)T("complete")&&!l.has(_)&&(S=!0),$({type:"complete",path:_,...P});else if(N===H){T("error")&&(R=!0,l.add(_));let fe=C instanceof M?C.lastMutation?.actor??Q:Q;$({type:"error",path:_,data:F[1],actor:fe,...P})}else N===B&&(T("teardown")&&E++,$({type:"teardown",path:_,...P}))}}))}let ce=!1,le=()=>{if(!ce){ce=!0;for(let _ of Ae)_();for(let _ of Ce)_();for(let _ of ee)_({value:void 0,done:!0});ee.length=0}},pe=[],ee=[];f.add(_=>{let C=ee.shift();C?C({value:_,done:!1}):pe.push(_)});let Te={get values(){return y},get dirtyCount(){return O},get resolvedCount(){return b},get invalidateCount(){return m},get pauseCount(){return v},get resumeCount(){return w},get teardownCount(){return E},get events(){return g?g.toArray():[...h]},get anyCompletedCleanly(){return S},get anyErrored(){return R},get completedWithoutErrors(){return S&&!R},onEvent(_){return f.add(_),()=>f.delete(_)},dispose:le,expand(_){le();let C={...t};return typeof _=="string"?C.detail=_:Object.assign(C,_),n(Ye(C))},[Symbol.asyncIterator](){return{next(){return pe.length>0?Promise.resolve({value:pe.shift(),done:!1}):ce?Promise.resolve({value:void 0,done:!0}):new Promise(_=>ee.push(_))},return(){return le(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(Te,t),Te}_attachFormatLogger(e,t){let n=t.format;if(n==null)return;let s=t.logger??(d=>console.log(d)),r=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,a=r==null&&i==null?()=>!0:d=>(r==null||r.has(d))&&(i==null||!i.has(d)),c=ft(t.theme),u=n==="stage-log"?L():0,p=d=>d==null?"":t.stageLabels?.[d]??d,g=(d,y)=>d.length>y?`${d.slice(0,y-1)}\u2026`:d,h=d=>d.type==="data"||d.type==="error"?g(Se(d.data),120):"",f=d=>{if(n==="stage-log"){let S=(L()-u)/1e9,R=p(d.path).padEnd(9);if(d.type==="data"){let G=h(d);return`[${S.toFixed(3)}s] ${R} \u2190${G?` ${G}`:""}`}if(d.type==="error"){let G=h(d);return`[${S.toFixed(3)}s] ${R} \u2717${G?` ${G}`:""}`}return d.type==="complete"?`[${S.toFixed(3)}s] ${R} \u25A0 complete`:`[${S.toFixed(3)}s] ${R} ${d.type}`}if(n==="json")try{return JSON.stringify(d)}catch{return JSON.stringify({type:d.type,path:d.path,data:"[unserializable]"})}let y=c[d.type]??"",l=d.path?`${c.path}${d.path}${c.reset} `:"",O=d.type==="data"||d.type==="error",b=d.type==="pause"||d.type==="resume",m=O?` ${Se(d.data)}`:b?` ${Se(d.lockId)}`:"",v=d.type==="data"||d.type==="resolved"||d.type==="derived"?d:void 0,w=v?.trigger_dep_name!=null?` <- ${v.trigger_dep_name}`:v?.trigger_dep_index!=null?` <- #${v.trigger_dep_index}`:"",E=d.in_batch?" [batch]":"";return`${l}${y}${d.type.toUpperCase()}${c.reset}${m}${w}${E}`};e.onEvent(d=>{a(d.type)&&s(f(d),d)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){ue(this._disposers,this.name),this.signal([[B]],{internal:!0}),ue(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(){ue(this._disposers,this.name),ue(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,...n}=this.describe({detail:"full"}),s={};for(let a of Object.keys(n.nodes).sort()){let{lastMutation:c,guard:u,...p}=n.nodes[a];s[a]=p}let r=[...n.subgraphs].sort(),i={...n,version:1,nodes:s,subgraphs:r};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 xe(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let n=t?.config??ye,{codec:s,codecVersion:r,payload:i}=$e(e,n);return s.decode(i,r)}restore(e,t){if(Je(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let n=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(r=>de(r)),s=t?.includeProducers===!0;for(let r of Object.keys(e.nodes).sort()){if(n!==null&&!n.some(a=>a.test(r)))continue;let i=e.nodes[r];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&t?.onError?.(r,new Error(`restore: slice.value is undefined for "${r}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let c=this.tryResolve(r)?.v;if(c!=null&&c.id===i.v.id&&c.version===i.v.version)continue}try{this.set(r,i.value)}catch(a){t?.onError?.(r,a)}}}}}static fromSnapshot(e,t){Je(e);let n=typeof t=="function"?t:t?.build,s=typeof t=="function"?void 0:t?.factories,r=new o(e.name);if(n)return n(r),r.restore(e),r;for(let f of[...e.subgraphs].sort((d,y)=>{let l=d.split(A).length,O=y.split(A).length;return l!==O?l-O:d<y?-1:d>y?1:0})){let d=f.split(A),y=r;for(let l of d)y._mounts.has(l)||y.mount(l,new o(l)),y=y._mounts.get(l)}let i=s?Object.entries(s).map(([f,d])=>({re:de(f),factory:d})):[],a=f=>{for(let d of i)if(d.re.test(f))return d.factory},c=f=>{let d=f.split(A),y=d.pop();if(y==null||y.length===0)throw new Error(`invalid snapshot path "${f}"`);let l=r;for(let O of d){let b=l._mounts.get(O);if(!b)throw new Error(`unknown mount "${O}" in path "${f}"`);l=b}return[l,y]},u=Object.entries(e.nodes).filter(([f])=>!f.includes(`${A}${z}${A}`)).sort((f,d)=>f[0]<d[0]?-1:f[0]>d[0]?1:0),p=new Map(u),g=new Map,h=!0;for(;p.size>0&&h;){h=!1;for(let[f,d]of[...p.entries()]){let y=d?.deps??[];if(!y.every(w=>g.has(w)))continue;let[l,O]=c(f),b={...d?.meta??{}},m=a(f),v;if(d?.type==="state")v=Z(d.value,{meta:b});else{if(m==null)continue;v=m(O,{path:f,type:d.type,value:d.value,meta:b,deps:y,resolvedDeps:y.map(w=>g.get(w))})}l.add(v,{name:O}),g.set(f,v),p.delete(f),h=!0}}if(p.size>0){let f=[...p.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${f}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return r.restore(e),r}toJSON(){return this.snapshot()}attachSnapshotStorage(e,t={}){let n=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.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=(u,p)=>{if(u.disposed)return;let g=ut(p.nodes);if(u.lastSnapshot!=null&&g!==""&&g===u.lastFingerprint)return;let h=u.seq+1,f=Me(),l=u.lastSnapshot==null||h%u.compactEvery===0?{name:this.name,mode:"full",snapshot:p,seq:h,timestamp_ns:f,format_version:J}:{name:this.name,mode:"diff",diff:mt(u.lastSnapshot,p),seq:h,timestamp_ns:f,format_version:J};if(u.tier.filter&&!u.tier.filter(l))return;let O;try{O=u.tier.save(l)}catch(b){t.onError?.(b,u.tier);return}if(O&&typeof O.then=="function"){let v=(u.savePending??Promise.resolve()).then(()=>O,()=>O).then(()=>{u.disposed||(u.seq=h,u.lastSnapshot=p,u.lastFingerprint=g)},w=>{t.onError?.(w,u.tier)});u.savePending=v.finally(()=>{u.savePending===v&&(u.savePending=void 0)})}else u.seq=h,u.lastSnapshot=p,u.lastFingerprint=g},r=(u,p)=>{try{s(u,p)}catch(g){t.onError?.(g,u.tier)}},i=(u,p)=>{if(!p.some(d=>{let y=this.config.messageTier(d[0]);return y>=3&&y<5}))return;if(t.filter){let d=this.tryResolve(u);if(d==null)return;let y=_e(d,Oe("standard"));if(!t.filter(u,y))return}let h,f=()=>(h==null&&(h=this.snapshot()),h);for(let d of n)d.disposed||(d.debounceMs===0?r(d,f()):(d.timer==null&&(d.timer=new Fe),d.timer.start(d.debounceMs,()=>{d.disposed||r(d,this.snapshot())})))},a;if(t.paths!=null){let p=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(g=>{let h=this.tryResolve(g);return h==null?()=>{}:h.subscribe(f=>i(g,f))});a=()=>{for(let g of p)g()}}else a=this.observe().subscribe((u,p)=>i(u,p));let c=()=>{a();for(let u of n)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(c)};return this._storageDisposers.add(c),{dispose:c}}async _cascadeRestore(e,t){for(let n of e){let s;try{s=await n.load?.()}catch(i){t?.(i,n);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let r=s;try{if(r.mode==="full"&&r.snapshot!=null)return this.restore(r.snapshot),!0;if(r.version===J&&r.nodes!=null)return this.restore(r),!0}catch(i){t?.(i,n)}}return!1}static async fromStorage(e,t,n){for(let s of t){let r;try{r=await s.load?.()}catch(c){n?.onError?.(c,s);continue}if(r==null||typeof r!="object"||Array.isArray(r))continue;let i=r,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===J&&i.nodes!=null?i:void 0;if(a!=null)try{return o.fromSnapshot(a,n)}catch(c){n?.onError?.(c,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,n){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:L(),...n?.actor!=null?{actor:n.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)),n=this._traceRing.size-t.length;this._traceRing.clear();for(let s of t)this._traceRing.push(s);return n}static diff(e,t){let n=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(t.nodes)),r=[...s].filter(b=>!n.has(b)).sort(),i=[...n].filter(b=>!s.has(b)).sort(),a=[],c=[];for(let b of n){if(!s.has(b))continue;let m=e.nodes[b],v=t.nodes[b],w=m.v,E=v.v;w!=null&&E!=null&&w.id===E.id&&w.version!==E.version&&c.push({path:b,id:w.id,from:w.version,to:E.version});let S=w!=null&&E!=null&&w.id===E.id&&w.version===E.version;for(let R of["type","status","sentinel"]){let G=m[R],D=v[R];G!==D&&a.push({path:b,field:R,from:G,to:D})}if(!S)for(let R of["value","meta"]){let G=m[R],D=v[R];dt(G,D)||a.push({path:b,field:R,from:G,to:D})}}let u=b=>`${b.from} ${b.to}`,p=new Set(e.edges.map(u)),g=new Set(t.edges.map(u)),h=t.edges.filter(b=>!p.has(u(b))),f=e.edges.filter(b=>!g.has(u(b))),d=new Set(e.subgraphs),y=new Set(t.subgraphs),l=[...y].filter(b=>!d.has(b)).sort(),O=[...d].filter(b=>!y.has(b)).sort();return{nodesAdded:r,nodesRemoved:i,nodesChanged:a,versionChanges:c,edgesAdded:h,edgesRemoved:f,subgraphsAdded:l,subgraphsRemoved:O}}};function mt(o,e){let t=Ne.diff(o,e),n={};for(let s of t.nodesAdded){let r=e.nodes[s];r!=null&&(n[s]=r)}return{...t,nodesAddedFull:n}}function Qe(o,e,t,n={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return n.withDetail?s:[];if(!n.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let r=n.maxDepth;if(r!=null&&(!Number.isInteger(r)||r<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(r===0)return n.withDetail?s:[];let i=new Map,a=new Map,c=new Map,u=new Map,p=new Set;for(let[m,v]of Object.entries(o.nodes)){if(!m)continue;p.add(m);let w=v.deps??[];i.set(m,w);for(let E of w)E&&(p.add(E),a.has(E)||a.set(E,new Set),a.get(E).add(m))}for(let m of o.edges){if(m==null||typeof m!="object")continue;let v=typeof m.from=="string"?m.from:"",w=typeof m.to=="string"?m.to:"";!v||!w||(p.add(v),p.add(w),u.has(v)||u.set(v,new Set),u.get(v).add(w),c.has(w)||c.set(w,new Set),c.get(w).add(v))}if(!p.has(e))return n.withDetail?s:[];let g=n.both===!0,h=m=>{if(g){let S=i.get(m)??[],R=c.get(m),G=a.get(m),D=u.get(m),k=[...S];return R&&k.push(...R),G&&k.push(...G),D&&k.push(...D),k}if(t==="upstream"){let S=i.get(m)??[],R=c.get(m);return R?[...S,...R]:S}let v=a.get(m),w=u.get(m),E=v?[...v]:[];return w&&E.push(...w),E},f=new Set([e]),d=new Map,y=[{path:e,depth:0}],l=0,O=!1;for(;l<y.length;){let m=y[l++];if(r!=null&&m.depth>=r){h(m.path).length>0&&(O=!0);continue}for(let v of h(m.path))!v||f.has(v)||(f.add(v),d.set(v,m.depth+1),y.push({path:v,depth:m.depth+1}))}let b=[...d.keys()].sort((m,v)=>m<v?-1:m>v?1:0);return n.withDetail?{paths:b,depths:d,truncated:O}:b}function vt(o,e){if(o.length!==e.length)return!1;for(let t=0;t<o.length;t++){let n=o[t],s=e[t];if(n.path!==s.path||n.type!==s.type||n.status!==s.status||n.hop!==s.hop||n.dep_index!==s.dep_index||n.annotation!==s.annotation||n.value!==s.value||n.lastMutation!==s.lastMutation)return!1;let r=n.v,i=s.v;if(r!==i&&(r==null||i==null||r.id!==i.id||r.version!==i.version))return!1}return!0}export{x as a,tt as b,ze as c,Be as d,ke as e,X as f,He as g,z as h,J as i,Ne as j,mt as k,Qe as l};
@@ -1,4 +1,4 @@
1
- import{f as F,g as j,h as A}from"./chunk-Y4NI3X7O.js";import{i as b,j as x}from"./chunk-626TESAC.js";import{p as _}from"./chunk-LYCLF26R.js";import{b as C,d as $,i as T,j as N}from"./chunk-CK2E7BTU.js";import{b as J}from"./chunk-QYADASLV.js";var Y={};J(Y,{SNAPSHOT_WIRE_VERSION:()=>v,SurfaceError:()=>o,asSurfaceError:()=>K,createGraph:()=>R,deleteSnapshot:()=>L,diffSnapshots:()=>V,listSnapshots:()=>W,restoreSnapshot:()=>U,runReduction:()=>D,saveSnapshot:()=>M});var o=class extends Error{code;details;constructor(t,r,n){super(r),this.name="SurfaceError",this.code=t,n!==void 0&&(this.details=n)}toJSON(){let t={code:this.code,message:this.message};if(this.details!==void 0){let r=q(this.details);r!==void 0&&(t.details=r)}return t}};function q(e){try{return JSON.parse(JSON.stringify(e))}catch{return}}function K(e,t="internal-error"){if(e instanceof o)return e;let r=e instanceof Error?e.message:String(e);return new o(t,r)}function R(e,t){let r=j(e);if(!r.valid)throw new o("invalid-spec",`GraphSpec validation failed:
1
+ import{f as F,g as j,h as A}from"./chunk-APPIWSGD.js";import{i as b,j as x}from"./chunk-HITNVN6B.js";import{p as _}from"./chunk-NTEURFZH.js";import{b as C,d as $,i as T,j as N}from"./chunk-CK2E7BTU.js";import{b as J}from"./chunk-QYADASLV.js";var Y={};J(Y,{SNAPSHOT_WIRE_VERSION:()=>v,SurfaceError:()=>o,asSurfaceError:()=>K,createGraph:()=>R,deleteSnapshot:()=>L,diffSnapshots:()=>V,listSnapshots:()=>W,restoreSnapshot:()=>U,runReduction:()=>D,saveSnapshot:()=>M});var o=class extends Error{code;details;constructor(t,r,n){super(r),this.name="SurfaceError",this.code=t,n!==void 0&&(this.details=n)}toJSON(){let t={code:this.code,message:this.message};if(this.details!==void 0){let r=q(this.details);r!==void 0&&(t.details=r)}return t}};function q(e){try{return JSON.parse(JSON.stringify(e))}catch{return}}function K(e,t="internal-error"){if(e instanceof o)return e;let r=e instanceof Error?e.message:String(e);return new o(t,r)}function R(e,t){let r=j(e);if(!r.valid)throw new o("invalid-spec",`GraphSpec validation failed:
2
2
  ${r.errors.join(`
3
3
  `)}`,{errors:r.errors});let n=t?.catalog??{},s=F(e,n);if(!s.valid)throw new o("catalog-error",`Catalog validation failed:
4
4
  ${s.errors.join(`
@@ -0,0 +1 @@
1
+ import{a as K,b as j,c as q}from"./chunk-GHBWHMRZ.js";import{A as F,B as b,C as H,D as v,E as G,F as h,G as k,H as B,I as Y,J as P,K as W,L as w,M as U,i as J,j as Q,k as g,m as S,n as u,o as C,p as I,q as M,r as _,s as X,t as Z,u as $,v as ee,w as L,x as V,y as m,z as x}from"./chunk-NTEURFZH.js";import{a as e,b as t,c as o,d as p,e as r,f as n,g as s,h as y,i,j as a,k as d,l as c,m as T,n as N,o as E,p as f,q as l,r as D,s as O,t as A,u as R}from"./chunk-CK2E7BTU.js";import{b as z}from"./chunk-QYADASLV.js";var te={};z(te,{COMPLETE:()=>i,COMPLETE_MSG:()=>E,COMPLETE_ONLY_BATCH:()=>A,DATA:()=>t,DEFAULT_ACTOR:()=>J,DIRTY:()=>o,DIRTY_MSG:()=>d,DIRTY_ONLY_BATCH:()=>l,ERROR:()=>a,GraphReFlyConfig:()=>M,GuardDenied:()=>X,INVALIDATE:()=>r,INVALIDATE_MSG:()=>T,INVALIDATE_ONLY_BATCH:()=>O,NodeImpl:()=>H,PAUSE:()=>n,RESOLVED:()=>p,RESOLVED_MSG:()=>c,RESOLVED_ONLY_BATCH:()=>D,RESUME:()=>s,START:()=>e,START_MSG:()=>N,TEARDOWN:()=>y,TEARDOWN_MSG:()=>f,TEARDOWN_ONLY_BATCH:()=>R,accessHintForGuard:()=>ee,advanceVersion:()=>m,autoTrackNode:()=>w,batch:()=>S,configure:()=>b,createVersioning:()=>V,defaultConfig:()=>F,defaultHash:()=>L,derived:()=>k,derivedT:()=>B,downWithBatch:()=>u,dynamicNode:()=>W,effect:()=>P,effectT:()=>Y,factoryTag:()=>q,isBatching:()=>g,isV1:()=>x,monotonicNs:()=>C,node:()=>v,normalizeActor:()=>Q,pipe:()=>U,placeholderArgs:()=>j,policy:()=>Z,policyFromRules:()=>$,producer:()=>h,registerBuiltins:()=>_,resolveDescribeFields:()=>K,state:()=>G,wallClockNs:()=>I});export{te as a};
@@ -1,4 +1,4 @@
1
- import{d as Re,k as Pe}from"./chunk-VNC3TMVY.js";import{f as Oe}from"./chunk-626TESAC.js";import{x as pe}from"./chunk-VOPGGIL7.js";import{a as Z,b as le,i as Ne}from"./chunk-4VVTGLXJ.js";import{f as fe}from"./chunk-V5A7M7RJ.js";import{A as ee,D as be,E as U,F as B,m as J,p as D}from"./chunk-LYCLF26R.js";import{b as E,c as ye,d as ke,h as de,i as P,j as x}from"./chunk-CK2E7BTU.js";function Ce(r){return{describeKind:"producer",...r}}function oe(r,n){return B(i=>{let s=!0,u={emit(t){s&&i.emit(t)},error(t){s&&(s=!1,i.down([[x,t]]))},complete(){s&&(s=!1,i.down([[P]]))}},o;try{let t=r(u);o=typeof t=="function"?t:void 0}catch(t){return u.error(t),()=>{s=!1}}return()=>{s=!1;try{o?.()}catch{}}},Ce(n))}function Me(r,n,i){let s=!0,u,o=0,t=0,e={},a=[],c=()=>{let l=u;u=void 0;try{l?.()}catch{}};for(let l of n){let m=i?.name?`${i.name}::${l}`:l,g=i?.channelOpts?.[l],y=B(T=>(o++,()=>{t++,o>0&&t>=o&&t>=n.length&&c()}),Ce({...g,name:m}));e[l]=y,a.push(y)}let f={};for(let l of n)f[l]=m=>{s&&e[l].down([[E,m]])};f.error=l=>{s&&(s=!1,J(()=>{for(let m of a)m.down([[x,l]])}),c())},f.complete=()=>{s&&(s=!1,J(()=>{for(let l of a)l.down([[P]])}),c())};let p=r(f);return u=typeof p=="function"?p:void 0,Object.assign(e,{dispose:()=>{s&&(s=!1,J(()=>{for(let l of a)try{l.down([[P]])}catch{}}),c())}})}var he=class{ring;arr;constructor(n){n===Number.POSITIVE_INFINITY||n<=0?(this.arr=[],this.ring=null):(this.ring=new Oe(n),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(n){this.ring!=null?this.ring.push(n):this.arr.push(n)}shift(){return this.ring!=null?this.ring.shift():this.arr.shift()}drain(){if(this.ring!=null){let i=this.ring.toArray();return this.ring.clear(),i}let n=this.arr;return this.arr=[],n}};function se(r){return r instanceof Error?r:new Error(String(r))}function De(r){return r===void 0?null:typeof r=="string"?Ne(r):r}function z(r,n){let{name:i,onTransportError:s,retry:u,backpressure:o,batchSize:t=Number.POSITIVE_INFINITY,flushIntervalMs:e=0,serialize:a,stopOn:c,onUpstreamMessage:f,onDispose:p,send:d,sendBatch:l,ctx:m}=n;if(!d&&!l)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let g=m,y=Math.max(1,u?.maxAttempts??1),T=De(u?.backoff??(y>1?"exponential":void 0)),h=u?.shouldRetry??(()=>!0),b=l!==void 0||t<Number.POSITIVE_INFINITY||e>0,w=k=>i?`${i}::${k}`:void 0,v=U(void 0,{equals:()=>!1,name:w("sent")}),S=U(null,{name:w("failed")}),L=U(0,{name:w("inFlight")}),F=U(null,{name:w("errors")}),K=b?U(0,{name:w("buffered")}):void 0,Y=o?U(!1,{name:w("paused")}):void 0,ie=0,Q=k=>{ie+=k,L.down([[E,ie]])},O=k=>{try{s?.(k)}catch{}try{F.down([[E,k]])}catch{}},q=new Set,V=k=>{q.add(k);let N=()=>q.delete(k);k.then(N,N)},I=(k,N,C)=>{let A=T?T(N-1,C,null):0,H=A==null?0:typeof A=="number"&&A>0?A:0,j=Math.max(1,Math.ceil(H/1e6));return new Promise(M=>{setTimeout(()=>M(k()),j)})},$=k=>k!=null&&typeof k=="object"&&typeof k.then=="function",_=k=>{let N;try{N=a?a(k):k}catch(M){let R=se(M);return O({stage:"serialize",error:R,value:k}),S.down([[E,{value:k,error:R,attempts:0}]]),Promise.resolve()}let C=0,A=M=>{Q(-1);let R=se(M);if(O({stage:"send",error:R,value:k,attempt:C}),!(C<y&&h(R,C))){S.down([[E,{value:k,error:R,attempts:C}]]);return}return I(j,C,R)},H=()=>{Q(-1),v.down([[E,k]])};function j(){C+=1,Q(1);let M;try{M=d(N,g)}catch(R){return A(R)??Promise.resolve()}return $(M)?M.then(H,R=>A(R)):(H(),Promise.resolve())}return j()},te=o?.maxBuffer??Number.POSITIVE_INFINITY,X=new he(te),G,ae=!1,me=()=>{K?.down([[E,X.length]])},ue=k=>{Y&&Y.down([[E,k]])},we=o?.strategy??"drop-oldest",Be=(k,N)=>{let C={value:k,payload:N};if(X.length<te)return X.push(C),me(),!0;if(we==="drop-oldest"){let H=X.shift();return X.push(C),me(),ue(!0),S.down([[E,{value:H.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(we==="drop-newest")return ue(!0),S.down([[E,{value:k,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let A=new Error("backpressure: buffer overflow");return O({stage:"send",error:A,value:k}),S.down([[E,{value:k,error:A,attempts:0}]]),ue(!0),!1},Fe=k=>{let N=0,C=k.map(M=>M.payload),A=M=>{Q(-1);let R=se(M);if(O({stage:"send",error:R,value:k.map(ge=>ge.value),attempt:N}),!(N<y&&h(R,N))){for(let{value:ge}of k)S.down([[E,{value:ge,error:R,attempts:N}]]);return}return I(j,N,R)},H=()=>{Q(-1);for(let{value:M}of k)v.down([[E,M]])};function j(){N+=1,Q(1);let M;try{M=l(C,g)}catch(R){return A(R)??Promise.resolve()}return $(M)?M.then(H,R=>A(R)):(H(),Promise.resolve())}return j()},He=async k=>{for(let N of k)await ze(N.value,N.payload)},ze=(k,N)=>{let C=0,A=M=>{Q(-1);let R=se(M);if(O({stage:"send",error:R,value:k,attempt:C}),!(C<y&&h(R,C))){S.down([[E,{value:k,error:R,attempts:C}]]);return}return I(j,C,R)},H=()=>{Q(-1),v.down([[E,k]])};function j(){C+=1,Q(1);let M;try{M=d(N,g)}catch(R){return A(R)??Promise.resolve()}return $(M)?M.then(H,R=>A(R)):(H(),Promise.resolve())}return j()},ne=()=>{if(ae||X.length===0)return Promise.resolve();let k=X.drain();if(me(),ue(!1),l!==void 0){let C=Fe(k);return V(C),C}let N=He(k);return V(N),N},qe=()=>{G!==void 0||ae||e<=0||(G=setTimeout(()=>{G=void 0,ne()},e))},Ue=r.subscribe(k=>{for(let N of k){let C=N[0];if(C!==E)try{f?.(N)}catch{}if(C===E){let A=N[1];if(b){let H;if(a)try{H=a(A)}catch(M){let R=se(M);O({stage:"serialize",error:R,value:A}),S.down([[E,{value:A,error:R,attempts:0}]]);continue}else H=A;if(!Be(A,H))continue;X.length>=t?ne():qe()}else{let H=_(A);V(H)}}else ee.messageTier(C)>=3&&b&&(G!==void 0&&(clearTimeout(G),G=void 0),ne())}}),Se;if(c){let k=!1;Se=c.subscribe(N=>{if(!k){k=!0;return}N.length>0&&!Te&&Ee()})}let Te=!1,Ee=()=>{if(Te)return;Te=!0,G!==void 0&&(clearTimeout(G),G=void 0),b&&ne(),ae=!0,Se?.(),Ue();let k=N=>{try{N.down([[de]])}catch{}};k(F),k(S),k(v),k(L),K&&k(K),Y&&k(Y);try{p?.()}catch{}},ce={dispose:Ee,sent:v,failed:S,inFlight:L,errors:F};return b&&(ce.buffered=K,ce.flush=async()=>{ae||(await ne(),await Promise.all(q))}),Y&&(ce.paused=Y),ce}function W(r){return{describeKind:"producer",...r}}function Ke(r,n){let{parse:i,closeOnTeardown:s=!1,...u}=n??{};return B(o=>{let t=!0,e,a=()=>{let T=e;e=void 0,T?.()},c=T=>{t&&(t=!1,o.down([T]),a())},f=(T,h=T)=>{if(t)try{let b=T!==null&&typeof T=="object"&&"data"in T?T.data:T,w=i?i(b,h):b;o.emit(w)}catch(b){c([x,b])}},p=T=>{c([x,T])},d=()=>{c([P])};if(typeof r=="function"){try{if(e=r(f,p,d),typeof e!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(T){c([x,T])}return()=>{t=!1,a()}}let l=r,m=T=>f(T,T),g=T=>p(T),y=()=>d();return l.addEventListener("message",m),l.addEventListener("error",g),l.addEventListener("close",y),e=()=>{l.removeEventListener("message",m),l.removeEventListener("error",g),l.removeEventListener("close",y),s&&l.close()},()=>{t=!1,a()}},W(u))}function Tr(r,n){return oe(r,n)}function $e(r,n){let{method:i="GET",headers:s,body:u,transform:o=b=>b.json(),timeoutNs:t=30*1e9,signal:e,completeAfterFetch:a=!1,refetchOnSubscribe:c=!1,...f}=n??{},p=U(0,{name:`${f.name??"http"}/fetchCount`}),d=U(0,{name:`${f.name??"http"}/lastUpdated`}),l=U(!1,{name:`${f.name??"http"}/fetched`}),m=0,g=u!==void 0?typeof u=="string"?u:JSON.stringify(u):void 0,y=b=>{let w=new AbortController,v=!0;if(e?.aborted)return v=!1,b.down([[x,e.reason??new Error("Aborted")]]),()=>{};e?.addEventListener("abort",()=>w.abort(e.reason),{once:!0});let S=setTimeout(()=>w.abort(new Error("Request timeout")),Math.ceil(t/1e6));return fetch(r,{method:i,headers:s,body:g,signal:w.signal}).then(async L=>{if(clearTimeout(S),!v)return;if(!L.ok)throw new Error(`HTTP ${L.status}: ${L.statusText}`);let F=await o(L);v&&(J(()=>{m+=1,p.down([[E,m]]),d.down([[E,D()]]),l.down([[E,!0]]),b.emit(F)}),a&&b.down([[P]]))}).catch(L=>{clearTimeout(S),v&&(L&&L.name==="AbortError"||b.down([[x,L]]))}),()=>{v=!1,w.abort()}},T=B(b=>y({emit:w=>b.emit(w),down:w=>b.down(w)}),{...W(f),resubscribable:c});return{...Pe(T),fetchCount:p,lastUpdated:d,fetched:l}}function gr(r,n,i){let{method:s="POST",headers:u={"Content-Type":"application/json"},serialize:o=m=>JSON.stringify(m),timeoutNs:t,batchFormat:e="json-array",batchSize:a,flushIntervalMs:c,retry:f,onTransportError:p}=i??{},d=async m=>{let g=t!==void 0?new AbortController:void 0,y;g&&t!==void 0&&(y=setTimeout(()=>g.abort(new Error("Request timeout")),Math.ceil(t/1e6)));try{let T=await fetch(n,{method:s,headers:u,body:m,signal:g?.signal}),h=async()=>{try{await T.arrayBuffer?.()}catch{}};if(!T.ok)throw await h(),new Error(`HTTP ${T.status}: ${T.statusText}`);await h()}finally{y!==void 0&&clearTimeout(y)}};return a!==void 0||c!==void 0?z(r,{onTransportError:p,retry:f,batchSize:a,flushIntervalMs:c,sendBatch:async m=>{let g;e==="ndjson"?g=m.map(y=>{let T=o(y);return typeof T=="string"?T:new TextDecoder().decode(T)}).join(`
1
+ import{d as Re,k as Pe}from"./chunk-D7GPHKFH.js";import{f as Oe}from"./chunk-HITNVN6B.js";import{x as pe}from"./chunk-CLVB32RD.js";import{a as Z,b as le,i as Ne}from"./chunk-4VVTGLXJ.js";import{f as fe}from"./chunk-CRVT7D2P.js";import{A as ee,D as be,E as U,F as B,m as J,p as D}from"./chunk-NTEURFZH.js";import{b as E,c as ye,d as ke,h as de,i as P,j as x}from"./chunk-CK2E7BTU.js";function Ce(r){return{describeKind:"producer",...r}}function oe(r,n){return B(i=>{let s=!0,u={emit(t){s&&i.emit(t)},error(t){s&&(s=!1,i.down([[x,t]]))},complete(){s&&(s=!1,i.down([[P]]))}},o;try{let t=r(u);o=typeof t=="function"?t:void 0}catch(t){return u.error(t),()=>{s=!1}}return()=>{s=!1;try{o?.()}catch{}}},Ce(n))}function Me(r,n,i){let s=!0,u,o=0,t=0,e={},a=[],c=()=>{let l=u;u=void 0;try{l?.()}catch{}};for(let l of n){let m=i?.name?`${i.name}::${l}`:l,g=i?.channelOpts?.[l],y=B(T=>(o++,()=>{t++,o>0&&t>=o&&t>=n.length&&c()}),Ce({...g,name:m}));e[l]=y,a.push(y)}let f={};for(let l of n)f[l]=m=>{s&&e[l].down([[E,m]])};f.error=l=>{s&&(s=!1,J(()=>{for(let m of a)m.down([[x,l]])}),c())},f.complete=()=>{s&&(s=!1,J(()=>{for(let l of a)l.down([[P]])}),c())};let p=r(f);return u=typeof p=="function"?p:void 0,Object.assign(e,{dispose:()=>{s&&(s=!1,J(()=>{for(let l of a)try{l.down([[P]])}catch{}}),c())}})}var he=class{ring;arr;constructor(n){n===Number.POSITIVE_INFINITY||n<=0?(this.arr=[],this.ring=null):(this.ring=new Oe(n),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(n){this.ring!=null?this.ring.push(n):this.arr.push(n)}shift(){return this.ring!=null?this.ring.shift():this.arr.shift()}drain(){if(this.ring!=null){let i=this.ring.toArray();return this.ring.clear(),i}let n=this.arr;return this.arr=[],n}};function se(r){return r instanceof Error?r:new Error(String(r))}function De(r){return r===void 0?null:typeof r=="string"?Ne(r):r}function z(r,n){let{name:i,onTransportError:s,retry:u,backpressure:o,batchSize:t=Number.POSITIVE_INFINITY,flushIntervalMs:e=0,serialize:a,stopOn:c,onUpstreamMessage:f,onDispose:p,send:d,sendBatch:l,ctx:m}=n;if(!d&&!l)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let g=m,y=Math.max(1,u?.maxAttempts??1),T=De(u?.backoff??(y>1?"exponential":void 0)),h=u?.shouldRetry??(()=>!0),b=l!==void 0||t<Number.POSITIVE_INFINITY||e>0,w=k=>i?`${i}::${k}`:void 0,v=U(void 0,{equals:()=>!1,name:w("sent")}),S=U(null,{name:w("failed")}),L=U(0,{name:w("inFlight")}),F=U(null,{name:w("errors")}),K=b?U(0,{name:w("buffered")}):void 0,Y=o?U(!1,{name:w("paused")}):void 0,ie=0,Q=k=>{ie+=k,L.down([[E,ie]])},O=k=>{try{s?.(k)}catch{}try{F.down([[E,k]])}catch{}},q=new Set,V=k=>{q.add(k);let N=()=>q.delete(k);k.then(N,N)},I=(k,N,C)=>{let A=T?T(N-1,C,null):0,H=A==null?0:typeof A=="number"&&A>0?A:0,j=Math.max(1,Math.ceil(H/1e6));return new Promise(M=>{setTimeout(()=>M(k()),j)})},$=k=>k!=null&&typeof k=="object"&&typeof k.then=="function",_=k=>{let N;try{N=a?a(k):k}catch(M){let R=se(M);return O({stage:"serialize",error:R,value:k}),S.down([[E,{value:k,error:R,attempts:0}]]),Promise.resolve()}let C=0,A=M=>{Q(-1);let R=se(M);if(O({stage:"send",error:R,value:k,attempt:C}),!(C<y&&h(R,C))){S.down([[E,{value:k,error:R,attempts:C}]]);return}return I(j,C,R)},H=()=>{Q(-1),v.down([[E,k]])};function j(){C+=1,Q(1);let M;try{M=d(N,g)}catch(R){return A(R)??Promise.resolve()}return $(M)?M.then(H,R=>A(R)):(H(),Promise.resolve())}return j()},te=o?.maxBuffer??Number.POSITIVE_INFINITY,X=new he(te),G,ae=!1,me=()=>{K?.down([[E,X.length]])},ue=k=>{Y&&Y.down([[E,k]])},we=o?.strategy??"drop-oldest",Be=(k,N)=>{let C={value:k,payload:N};if(X.length<te)return X.push(C),me(),!0;if(we==="drop-oldest"){let H=X.shift();return X.push(C),me(),ue(!0),S.down([[E,{value:H.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(we==="drop-newest")return ue(!0),S.down([[E,{value:k,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let A=new Error("backpressure: buffer overflow");return O({stage:"send",error:A,value:k}),S.down([[E,{value:k,error:A,attempts:0}]]),ue(!0),!1},Fe=k=>{let N=0,C=k.map(M=>M.payload),A=M=>{Q(-1);let R=se(M);if(O({stage:"send",error:R,value:k.map(ge=>ge.value),attempt:N}),!(N<y&&h(R,N))){for(let{value:ge}of k)S.down([[E,{value:ge,error:R,attempts:N}]]);return}return I(j,N,R)},H=()=>{Q(-1);for(let{value:M}of k)v.down([[E,M]])};function j(){N+=1,Q(1);let M;try{M=l(C,g)}catch(R){return A(R)??Promise.resolve()}return $(M)?M.then(H,R=>A(R)):(H(),Promise.resolve())}return j()},He=async k=>{for(let N of k)await ze(N.value,N.payload)},ze=(k,N)=>{let C=0,A=M=>{Q(-1);let R=se(M);if(O({stage:"send",error:R,value:k,attempt:C}),!(C<y&&h(R,C))){S.down([[E,{value:k,error:R,attempts:C}]]);return}return I(j,C,R)},H=()=>{Q(-1),v.down([[E,k]])};function j(){C+=1,Q(1);let M;try{M=d(N,g)}catch(R){return A(R)??Promise.resolve()}return $(M)?M.then(H,R=>A(R)):(H(),Promise.resolve())}return j()},ne=()=>{if(ae||X.length===0)return Promise.resolve();let k=X.drain();if(me(),ue(!1),l!==void 0){let C=Fe(k);return V(C),C}let N=He(k);return V(N),N},qe=()=>{G!==void 0||ae||e<=0||(G=setTimeout(()=>{G=void 0,ne()},e))},Ue=r.subscribe(k=>{for(let N of k){let C=N[0];if(C!==E)try{f?.(N)}catch{}if(C===E){let A=N[1];if(b){let H;if(a)try{H=a(A)}catch(M){let R=se(M);O({stage:"serialize",error:R,value:A}),S.down([[E,{value:A,error:R,attempts:0}]]);continue}else H=A;if(!Be(A,H))continue;X.length>=t?ne():qe()}else{let H=_(A);V(H)}}else ee.messageTier(C)>=3&&b&&(G!==void 0&&(clearTimeout(G),G=void 0),ne())}}),Se;if(c){let k=!1;Se=c.subscribe(N=>{if(!k){k=!0;return}N.length>0&&!Te&&Ee()})}let Te=!1,Ee=()=>{if(Te)return;Te=!0,G!==void 0&&(clearTimeout(G),G=void 0),b&&ne(),ae=!0,Se?.(),Ue();let k=N=>{try{N.down([[de]])}catch{}};k(F),k(S),k(v),k(L),K&&k(K),Y&&k(Y);try{p?.()}catch{}},ce={dispose:Ee,sent:v,failed:S,inFlight:L,errors:F};return b&&(ce.buffered=K,ce.flush=async()=>{ae||(await ne(),await Promise.all(q))}),Y&&(ce.paused=Y),ce}function W(r){return{describeKind:"producer",...r}}function Ke(r,n){let{parse:i,closeOnTeardown:s=!1,...u}=n??{};return B(o=>{let t=!0,e,a=()=>{let T=e;e=void 0,T?.()},c=T=>{t&&(t=!1,o.down([T]),a())},f=(T,h=T)=>{if(t)try{let b=T!==null&&typeof T=="object"&&"data"in T?T.data:T,w=i?i(b,h):b;o.emit(w)}catch(b){c([x,b])}},p=T=>{c([x,T])},d=()=>{c([P])};if(typeof r=="function"){try{if(e=r(f,p,d),typeof e!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(T){c([x,T])}return()=>{t=!1,a()}}let l=r,m=T=>f(T,T),g=T=>p(T),y=()=>d();return l.addEventListener("message",m),l.addEventListener("error",g),l.addEventListener("close",y),e=()=>{l.removeEventListener("message",m),l.removeEventListener("error",g),l.removeEventListener("close",y),s&&l.close()},()=>{t=!1,a()}},W(u))}function Tr(r,n){return oe(r,n)}function $e(r,n){let{method:i="GET",headers:s,body:u,transform:o=b=>b.json(),timeoutNs:t=30*1e9,signal:e,completeAfterFetch:a=!1,refetchOnSubscribe:c=!1,...f}=n??{},p=U(0,{name:`${f.name??"http"}/fetchCount`}),d=U(0,{name:`${f.name??"http"}/lastUpdated`}),l=U(!1,{name:`${f.name??"http"}/fetched`}),m=0,g=u!==void 0?typeof u=="string"?u:JSON.stringify(u):void 0,y=b=>{let w=new AbortController,v=!0;if(e?.aborted)return v=!1,b.down([[x,e.reason??new Error("Aborted")]]),()=>{};e?.addEventListener("abort",()=>w.abort(e.reason),{once:!0});let S=setTimeout(()=>w.abort(new Error("Request timeout")),Math.ceil(t/1e6));return fetch(r,{method:i,headers:s,body:g,signal:w.signal}).then(async L=>{if(clearTimeout(S),!v)return;if(!L.ok)throw new Error(`HTTP ${L.status}: ${L.statusText}`);let F=await o(L);v&&(J(()=>{m+=1,p.down([[E,m]]),d.down([[E,D()]]),l.down([[E,!0]]),b.emit(F)}),a&&b.down([[P]]))}).catch(L=>{clearTimeout(S),v&&(L&&L.name==="AbortError"||b.down([[x,L]]))}),()=>{v=!1,w.abort()}},T=B(b=>y({emit:w=>b.emit(w),down:w=>b.down(w)}),{...W(f),resubscribable:c});return{...Pe(T),fetchCount:p,lastUpdated:d,fetched:l}}function gr(r,n,i){let{method:s="POST",headers:u={"Content-Type":"application/json"},serialize:o=m=>JSON.stringify(m),timeoutNs:t,batchFormat:e="json-array",batchSize:a,flushIntervalMs:c,retry:f,onTransportError:p}=i??{},d=async m=>{let g=t!==void 0?new AbortController:void 0,y;g&&t!==void 0&&(y=setTimeout(()=>g.abort(new Error("Request timeout")),Math.ceil(t/1e6)));try{let T=await fetch(n,{method:s,headers:u,body:m,signal:g?.signal}),h=async()=>{try{await T.arrayBuffer?.()}catch{}};if(!T.ok)throw await h(),new Error(`HTTP ${T.status}: ${T.statusText}`);await h()}finally{y!==void 0&&clearTimeout(y)}};return a!==void 0||c!==void 0?z(r,{onTransportError:p,retry:f,batchSize:a,flushIntervalMs:c,sendBatch:async m=>{let g;e==="ndjson"?g=m.map(y=>{let T=o(y);return typeof T=="string"?T:new TextDecoder().decode(T)}).join(`
2
2
  `):g=JSON.stringify(m),await d(g)}}):z(r,{onTransportError:p,retry:f,serialize:o,send:async m=>{await d(m)}})}function Ae(r){return Symbol.keyFor(r)??r.description??"message"}function re(r,n){return typeof r=="string"?r:n(r)}function Le(r,n){let i=`event: ${r}
3
3
  `;if(n!==void 0){let s=n.split(/\r?\n/);for(let u of s)i+=`data: ${u}
4
4
  `}return`${i}
@@ -1 +1 @@
1
- import{j as _}from"./chunk-626TESAC.js";import{D as g,E as k}from"./chunk-LYCLF26R.js";import{b as R,c as T,d,h as A,i as O,j as D}from"./chunk-CK2E7BTU.js";function L(c,y,l,a){let s=new _(c,a);s.add(y,{name:"source"});let n=k(l,{meta:{kind:"stratify_rules"}});s.add(n,{name:"rules"});for(let f of l)E(s,y,n,f);return s}function E(c,y,l,a){let s=`branch/${a.name}`,n=Symbol("noValue"),f=!1,m=!1,p=!1,N=n,r=!1,h=l.cache??[];function v(o){if(p){p=!1;let t=N;if(N=n,t!==n){let i=h.find(u=>u.name===a.name),e=!1;try{e=i?.classify(t)??!1}catch{e=!1}e?(r=!1,o.emit(t)):r&&(r=!1,o.down([[T],[d]]))}else r?(r=!1,o.down([[T],[d]])):o.down([[d]])}}let S=g([],(o,t)=>{let i=y.subscribe(u=>{for(let b of u)w(b,0,t)}),e=l.subscribe(u=>{for(let b of u)w(b,1,t)});return()=>{i(),e()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:a.name},completeWhenDepsComplete:!1});function w(o,t,i){let e=o[0];return e===T?(t===0?(f=!0,r=!0):m=!0,!0):e===R||e===d?(t===0?(f=!1,p=!0,N=e===R?o[1]:n):(e===R&&(h=o[1]),m=!1),f||m||v(i),!0):e===O||e===D||e===A?(f=!1,m=!1,p=!1,N=n,r=!1,t===0&&i.down([o]),!0):t===1}if(c.add(S,{name:s}),a.ops){let o=a.ops(S),t=`branch/${a.name}/out`;c.add(o,{name:t})}}export{L as a};
1
+ import{j as _}from"./chunk-HITNVN6B.js";import{D as g,E as k}from"./chunk-NTEURFZH.js";import{b as R,c as T,d,h as A,i as O,j as D}from"./chunk-CK2E7BTU.js";function L(c,y,l,a){let s=new _(c,a);s.add(y,{name:"source"});let n=k(l,{meta:{kind:"stratify_rules"}});s.add(n,{name:"rules"});for(let f of l)E(s,y,n,f);return s}function E(c,y,l,a){let s=`branch/${a.name}`,n=Symbol("noValue"),f=!1,m=!1,p=!1,N=n,r=!1,h=l.cache??[];function v(o){if(p){p=!1;let t=N;if(N=n,t!==n){let i=h.find(u=>u.name===a.name),e=!1;try{e=i?.classify(t)??!1}catch{e=!1}e?(r=!1,o.emit(t)):r&&(r=!1,o.down([[T],[d]]))}else r?(r=!1,o.down([[T],[d]])):o.down([[d]])}}let S=g([],(o,t)=>{let i=y.subscribe(u=>{for(let b of u)w(b,0,t)}),e=l.subscribe(u=>{for(let b of u)w(b,1,t)});return()=>{i(),e()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:a.name},completeWhenDepsComplete:!1});function w(o,t,i){let e=o[0];return e===T?(t===0?(f=!0,r=!0):m=!0,!0):e===R||e===d?(t===0?(f=!1,p=!0,N=e===R?o[1]:n):(e===R&&(h=o[1]),m=!1),f||m||v(i),!0):e===O||e===D||e===A?(f=!1,m=!1,p=!1,N=n,r=!1,t===0&&i.down([o]),!0):t===1}if(c.add(S,{name:s}),a.ops){let o=a.ops(S),t=`branch/${a.name}/out`;c.add(o,{name:t})}}export{L as a};
@@ -0,0 +1 @@
1
+ import{a as Y,b,c as M,d as D,e as C,f as N,g as L,h as k,i as S,j as _,k as P,l as he,n as se,q as re,r as fe,s as pe,t as _e,u as ie}from"./chunk-CK2E7BTU.js";var Re={name:"json",version:1,contentType:"application/json",encode(t){let e=JSON.stringify(t);return new TextEncoder().encode(e)},decode(t,e){let n=new TextDecoder().decode(t);return JSON.parse(n)}};function je(t){return{name:"dag-cbor",version:1,contentType:"application/dag-cbor",encode:e=>t.encode(e),decode:(e,n)=>t.decode(e)}}function ze(t,e){return{name:"dag-cbor-zstd",version:1,contentType:"application/dag-cbor+zstd",encode:n=>e.compressSync(t.encode(n)),decode:(n,s)=>t.decode(e.decompressSync(n))}}var oe=1,ge=4;function qe(t,e){let n=new TextEncoder().encode(t.name);if(n.length===0||n.length>255)throw new Error(`encodeEnvelope: codec name "${t.name}" encodes to ${n.length} bytes (must be 1\u2013255)`);let s=t.version;if(!Number.isInteger(s)||s<0||s>65535)throw new Error(`encodeEnvelope: codec.version ${s} out of u16 range (expected integer 0\u201365535)`);let r=2+n.length+2+e.length;if(r>4294967295)throw new Error(`encodeEnvelope: total envelope size ${r} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let i=new Uint8Array(r),a=0;return i[a++]=oe,i[a++]=n.length,i.set(n,a),a+=n.length,i[a++]=s>>>8&255,i[a++]=s&255,i.set(e,a),i}function Ke(t,e){if(t.length<ge)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${ge})`);let n=0,s=t[n++];if(s!==oe)throw new Error(`decodeEnvelope: unsupported envelope version ${s} (expected ${oe})`);let r=t[n++];if(r===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(n+r+2>t.length)throw new Error(`decodeEnvelope: envelope truncated (need ${n+r+2} bytes, have ${t.length})`);let i=new TextDecoder().decode(t.subarray(n,n+r));n+=r;let a=(t[n]<<8|t[n+1])>>>0;n+=2;let o=t.subarray(n),d=e.lookupCodec(i);if(d==null)throw new Error(`decodeEnvelope: codec "${i}" not registered (envelope codec_v=${a})`);return{codec:d,codecVersion:a,payload:o}}function ye(t){t.registerCodec(Re)}function Ye(t){if(t.length===0)throw new Error("WAL is empty \u2014 need at least one full snapshot");let e=t[0];if(e.mode!=="full")throw new Error("WAL must start with a full record carrying a baseline snapshot");let n=JSON.parse(JSON.stringify(e.snapshot)),s=e.seq;for(let r=1;r<t.length;r++){let i=t[r];if(i.seq<=s)throw new Error(`WAL chain broken at index ${r}: seq=${i.seq} must exceed prev seq=${s}`);if(i.mode==="full"){n=JSON.parse(JSON.stringify(i.snapshot)),s=i.seq;continue}let a=i.diff;for(let d of a.nodesRemoved)delete n.nodes[d];let o=a.nodesAddedFull;if(o!=null)for(let[d,l]of Object.entries(o))n.nodes[d]=JSON.parse(JSON.stringify(l));for(let d of a.nodesChanged){let l=n.nodes[d.path];l!=null&&(l[d.field]=d.to)}s=i.seq}return n}var Oe={type:"system",id:""};function J(t){if(t==null)return Oe;let{type:e,id:n,...s}=t;return{type:e??"system",id:n??"",...s}}var R=0,U=!1,A=[],E=[],O=[],W=[];function me(){return R>0||U}function be(){return R>0}function ve(t){R>0?W.push(t):t()}function Ze(t){R+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(R-=1,R===0)if(e){if(!U){let n=W.splice(0);for(let s of n)try{s()}catch{}A.length=0,E.length=0,O.length=0}}else Fe()}}function Fe(){let t=!U;t&&(U=!0);let e=[],n=0;try{for(;A.length>0||E.length>0||O.length>0||t&&W.length>0;){if(t&&W.length>0){let i=W.splice(0);for(let a of i)try{a()}catch(o){e.push(o)}continue}if(n+=1,n>1e3)throw A.length=0,E.length=0,O.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let r=(A.length>0?A:E.length>0?E:O).splice(0);for(let i of r)try{i()}catch(a){e.push(a)}}}finally{t&&(U=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function X(t,e,n){if(e.length===0)return;if(e.length===1){let l=n(e[0][0]);if(l<3||!me()){t(e);return}(l>=5?O:l===4?E:A).push(()=>t(e));return}let s=e.length,r=s,i=s,a=s,o=0;for(;o<s&&n(e[o][0])<3;)o++;for(r=o;o<s&&n(e[o][0])===3;)o++;for(i=o;o<s&&n(e[o][0])===4;)o++;a=o;let d=me();if(r>0){let l=e.slice(0,r);t(l)}if(i>r){let l=e.slice(r,i);d?A.push(()=>t(l)):t(l)}if(a>i){let l=e.slice(i,a);d?E.push(()=>t(l)):t(l)}if(s>a){let l=e.slice(a,s);d?O.push(()=>t(l)):t(l)}}function en(){return Math.trunc(performance.now()*1e6)}function we(){return Date.now()*1e6}var Z=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=n=>{let s=this._messageTypes.get(n);return s!=null?s.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=e}registerMessageType(e,n){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:n.tier,wireCrossing:n.wireCrossing??n.tier>=3,metaPassthrough:n.metaPassthrough??!0}),this}messageTier(e){let n=this._messageTypes.get(e);return n!=null?n.tier:1}isWireCrossing(e){let n=this._messageTypes.get(e);return n!=null?n.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let n=this._messageTypes.get(e);return n!=null?n.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}};function xe(t){t.registerMessageType(Y,{tier:0,wireCrossing:!1}),t.registerMessageType(M,{tier:1,wireCrossing:!1}),t.registerMessageType(C,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(N,{tier:2,wireCrossing:!1}),t.registerMessageType(L,{tier:2,wireCrossing:!1}),t.registerMessageType(b,{tier:3,wireCrossing:!0}),t.registerMessageType(D,{tier:3,wireCrossing:!0}),t.registerMessageType(S,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(_,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(k,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var F=class extends Error{actor;action;nodeName;constructor(e,n){super(n??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}};function Te(t){return Array.isArray(t)?[...t]:[t]}function Ge(t,e){return t.has(e)||t.has("*")}function Ie(t){let e=[];return t((r,i)=>{e.push({kind:"allow",actions:new Set(Te(r)),where:i?.where??(()=>!0)})},(r,i)=>{e.push({kind:"deny",actions:new Set(Te(r)),where:i?.where??(()=>!0)})}),(r,i)=>{let a=!1,o=!1;for(let d of e)Ge(d.actions,i)&&d.where(r)&&(d.kind==="deny"?a=!0:o=!0);return a?!1:o}}function rn(t){return Ie((e,n)=>{for(let s of t){let r=s.actorType==null?null:new Set(Array.isArray(s.actorType)?s.actorType:[s.actorType]),i=s.actorId==null?null:new Set(Array.isArray(s.actorId)?s.actorId:[s.actorId]),a=Object.entries(s.claims??{}),o=d=>{if(r!==null&&!r.has(String(d.type))||i!==null&&!i.has(String(d.id??"")))return!1;for(let[l,c]of a)if(d[l]!==c)return!1;return!0};s.effect==="deny"?n(s.action,{where:o}):e(s.action,{where:o})}})}var He=["human","llm","wallet","system"];function on(t){let e=He.filter(n=>t({type:n,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(n=>n==="human"||n==="llm"||n==="system")?"both":e.length===1?e[0]:e.join("+")}function ae(t){if(t===void 0)return null;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Cannot hash non-finite number: ${t}`);if(Number.isInteger(t)&&!Number.isSafeInteger(t))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${t}. Cross-language cid parity is not guaranteed for unsafe integers.`);return t}if(typeof t=="string"||typeof t=="boolean"||t===null)return t;if(Array.isArray(t))return t.map(ae);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=ae(t[n]);return e}return null}var Ve=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]),Le=new TextEncoder;function Pe(t){let e=Le.encode(t),n=e.length,s=n*8,r=n+9+63&-64,i=new Uint8Array(r);i.set(e),i[n]=128;let a=new DataView(i.buffer);a.setUint32(r-4,s>>>0,!1),a.setUint32(r-8,Math.floor(s/4294967296)>>>0,!1);let o=1779033703,d=3144134277,l=1013904242,c=2773480762,h=1359893119,p=2600822924,u=528734635,g=1541459225,T=new Uint32Array(64),m=(w,y)=>w>>>y|w<<32-y;for(let w=0;w<r;w+=64){for(let f=0;f<16;f++)T[f]=a.getUint32(w+f*4,!1);for(let f=16;f<64;f++){let H=T[f-15],V=T[f-2],K=m(H,7)^m(H,18)^H>>>3,te=m(V,17)^m(V,19)^V>>>10;T[f]=T[f-16]+K+T[f-7]+te>>>0}let y=o,G=d,I=l,ee=c,x=h,z=p,q=u,ne=g;for(let f=0;f<64;f++){let H=m(x,6)^m(x,11)^m(x,25),V=x&z^~x&q,K=ne+H+V+Ve[f]+T[f]>>>0,te=m(y,2)^m(y,13)^m(y,22),Ce=y&G^y&I^G&I,Se=te+Ce>>>0;ne=q,q=z,z=x,x=ee+K>>>0,ee=I,I=G,G=y,y=K+Se>>>0}o=o+y>>>0,d=d+G>>>0,l=l+I>>>0,c=c+ee>>>0,h=h+x>>>0,p=p+z>>>0,u=u+q>>>0,g=g+ne>>>0}let v=w=>w.toString(16).padStart(8,"0");return v(o)+v(d)+v(l)+v(c)+v(h)+v(p)+v(u)+v(g)}function de(t){let e=ae(t??null),n=JSON.stringify(e);return Pe(n).slice(0,16)}function Ue(){let t=globalThis.crypto;if(t?.randomUUID)return t.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),n=e()+e()+e()+e();return`${n.slice(0,8)}-${n.slice(8,12)}-4${n.slice(13,16)}-${(parseInt(n.slice(16,17),16)&3|8).toString(16)}${n.slice(17,20)}-${n.slice(20,32)}`}function le(t,e,n){let s=n?.id??Ue();if(t===0)return{id:s,version:0};let i=(n?.hash??de)(e);return{id:s,version:0,cid:i,prev:null}}function Ne(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}function dn(t){return"cid"in t}var ke=()=>{},Ae=100;function Ee(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function ce(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function Q(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}var We=(t,e,n,s)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},Be=(t,e,n,s)=>{let r=t;if(r._status==="completed"||r._status==="errored")return;let i=r._cached,a=i===void 0?[se]:[se,[b,i]];r._status==="dirty"&&a.push(P),X(e,a,r._config.tierOf)},B=new Z({onMessage:We,onSubscribe:Be});xe(B);ye(B);function mn(t){if(B._isFrozen())throw new Error("configure() called after a node was created \u2014 the default GraphReFlyConfig is frozen. Call configure(...) at application startup, before any node factories run.");t(B)}var $=class t{_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,n,s){this._config=s.config??B,this._config.onMessage,this._optsName=s.name,this._describeKind=s.describeKind,this._equals=s.equals??Object.is,this._resubscribable=s.resubscribable??!1,this._resetOnTeardown=s.resetOnTeardown??!1,this._autoComplete=s.completeWhenDepsComplete??!0,this._autoError=s.errorWhenDepsError??!0,this._pausable=s.pausable??!0,this._guard=s.guard,this._fn=n,this._partial=s.partial??!1,this._cached=s.initial!==void 0?s.initial:void 0,this._status=e.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=s.versioningHash??this._config.defaultHashFn??de;let r=s.versioning??this._config.defaultVersioning;this._versioningLevel=r,this._versioning=r!=null?le(r,this._cached===void 0?void 0:this._cached,{id:s.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Ee);let i={};for(let[o,d]of Object.entries(s.meta??{})){let l={initial:d,name:`${s.name??"node"}:meta:${o}`,describeKind:"state",config:this._config};s.guard!=null&&(l.guard=s.guard),s.resubscribable===!0&&(l.resubscribable=!0),i[o]=new t([],void 0,l)}Object.freeze(i),this.meta=i,this._hasMeta=Object.keys(i).length>0;let a=this;this._actions={emit(o){a._emit([[b,o]])},down(o){a._emit(Q(o))},up(o){a._emitUp(Q(o))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let s=this._versioningLevel;if(s!=null&&e<=s)return;let r=n?.hash??this._hashFn;r!==this._hashFn&&(this._hashFn=r);let i=this._cached===void 0?void 0:this._cached,a=this._versioning,o=a?.id??n?.id,d=a?.version??0,l=le(e,i,{id:o,hash:r});l.version=d,this._versioning=l,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=J(e);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let s of this._extraGuards)if(!s(n,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let n=this._guard!=null||this._extraGuards!=null,s=e?.actor!=null;if(!n&&!s)return;let r=J(e?.actor),i=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(r,i))throw new F({actor:r,action:i,nodeName:this.name});if(this._extraGuards!=null){for(let a of this._extraGuards)if(!a(r,i))throw new F({actor:r,action:i,nodeName:this.name})}this._lastMutation={actor:r,timestamp_ns:we()}}down(e,n){let s=Q(e);s.length!==0&&(this._checkGuard(n),this._emit(s))}emit(e,n){this._checkGuard(n),this._emit([[b,e]])}up(e,n){if(this._deps.length===0)return;let s=Q(e);if(s.length===0)return;this._checkGuard(n);let r=n??{internal:!0};this._validateUpTiers(s);for(let i of this._deps)i.node.up?.(s,r)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let n of this._deps)n.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let n=this._config.tierOf;for(let s of e){let r=n(s[0]);if(r===3||r===4)throw new Error(`Node "${this.name}": tier-${r} 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,n){if(n!=null&&this._guard!=null){let d=J(n);if(!this._guard(d,"observe"))throw new F({actor:d,action:"observe",nodeName:this.name})}let r=this._isTerminal&&this._resubscribable;if(r){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)ce(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let i;try{i=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:r},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let a=this._isTerminal;if(this._sinkCount===1&&!a)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof i=="function")try{i()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let o=!1;return()=>{o||(o=!0,this._sinkCount-=1,this._removeSink(e),typeof i=="function"&&i(),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[n]=this._sinks;this._sinks=n}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,n=0;try{for(let s=0;s<e;s++){let r=s,i=this._deps[s];i.unsub=ke,i.unsub=i.node.subscribe(a=>{if(i.unsub===null)return;let o=this._config.tierOf,d=!1;for(let l of a)o(l[0])>=3&&(d=!0),this._config.onMessage(this,l,{direction:"down-in",depIndex:r},this._actions);d&&this._maybeRunFnOnSettlement()}),n++}}catch(s){this._deps[n].unsub=null;for(let r=0;r<n;r++){let i=this._deps[r];if(i.unsub!=null){let a=i.unsub;i.unsub=null;try{a()}catch{}ce(i)}}throw this._dirtyDepCount=0,s}}_addDep(e){for(let r=0;r<this._deps.length;r++)if(this._deps[r].node===e)return r;let n=this._deps.length,s=Ee(e);if(this._deps.push(s),this._sinks==null)return n;s.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(re),s.unsub=ke;try{s.unsub=e.subscribe(r=>{if(s.unsub===null)return;let i=this._config.tierOf,a=!1;for(let o of r)i(o[0])>=3&&(a=!0),this._config.onMessage(this,o,{direction:"down-in",depIndex:n},this._actions);a&&this._maybeRunFnOnSettlement()})}catch(r){throw s.unsub=null,this._deps.pop(),this._dirtyDepCount--,r}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(s){this._emit([[_,this._wrapFnError("cleanup threw",s)]])}else if(n!=null&&typeof n=="object"){let s=n.deactivate;if(typeof s=="function")try{s()}catch(r){this._emit([[_,this._wrapFnError("cleanup.deactivate threw",r)]])}}for(let s of this._deps){if(s.unsub!=null){let r=s.unsub;s.unsub=null;try{r()}catch{}}ce(s)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,n){let s=this._deps[e],r=n[0];if(this._inspectorHooks!=null){let i={kind:"dep_message",depIndex:e,message:n};for(let a of this._inspectorHooks)a(i)}if(r!==Y){if(r===M){this._depDirtied(s);return}if(r===C){if(this._depInvalidated(s),this._cached===void 0)return;this._emit(pe);return}if(r===N||r===L){this._emit([n]);return}if(r===k){this._emit(ie);return}if(r===b)this._depSettledAsData(s,n[1]);else if(r===D)this._depSettledAsResolved(s);else if(r===S)this._depSettledAsTerminal(s,!0);else if(r===_)this._depSettledAsTerminal(s,n[1]);else{this._emit([n]);return}if(!this._fn){(r===b||r===D)&&this._emit([n]),(r===S||r===_)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(re))}_depSettledAsData(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=n,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 n=this._deps[e];if(n.dataBatch.length===0&&n.prevData===void 0&&n.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(fe),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(e!=null){this._autoError&&this._emit([[_,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(_e)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(a){this._emit([[_,this._wrapFnError("cleanup threw",a)]]);return}}else if(e!=null&&typeof e=="object"){let a=e.beforeRun;if(typeof a=="function"){e.beforeRun=void 0;try{a()}catch(o){this._emit([[_,this._wrapFnError("cleanup.beforeRun threw",o)]]);return}}}let n=this._deps.map(a=>a.involvedThisWave?a.dataBatch.length>0?[...a.dataBatch]:[]:void 0),s=this._deps.map(a=>a.prevData);for(let a=0;a<this._deps.length;a++){let o=n[a];o!=null&&o.length>0&&(this._deps[a].prevData=o[o.length-1])}let r=this._deps.map(a=>a.terminal),i={prevData:s,terminalDeps:r,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let a={kind:"run",batchData:n,prevData:s};for(let o of this._inspectorHooks)o(a)}this._isExecutingFn=!0;try{let a=this._fn(n,this._actions,i);if(typeof a=="function")this._cleanup=a;else if(a!=null&&typeof a=="object"){let o=a;(typeof o.beforeRun=="function"||typeof o.deactivate=="function"||typeof o.invalidate=="function")&&(this._cleanup=a)}}catch(a){this._emit([[_,this._wrapFnError("fn threw",a)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Ae?(this._rerunDepth=0,this._emit([[_,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Ae} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,n){let s=n instanceof Error?n.message:String(n);return new Error(`Node "${this.name}": ${e}: ${s}`,{cause:n})}_frameBatch(e){let n=this._config.tierOf;if(e.length===1)return n(e[0][0])===3&&this._status!=="dirty"?[P,e[0]]:e;let s=!0,r=!1,i=!1,a=-1;for(let d of e){let l=n(d[0]);l<a&&(s=!1),l===3&&(r=!0),d[0]===M&&(i=!0),a=l}let o=e;if(!s){let d=e.map((l,c)=>({m:l,i:c,tier:n(l[0])}));d.sort((l,c)=>l.tier-c.tier||l.i-c.i),o=d.map(l=>l.m)}if(r&&!i&&this._status!=="dirty"){let d=0;for(;d<o.length&&n(o[d][0])===0;)d++;return d===0?[P,...o]:[...o.slice(0,d),P,...o.slice(d)]}return o}_emit(e){if(e.length===0)return;for(let o=0;o<e.length;o++){let d=e[o];if(d[0]===_&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let n=e;if(this._isTerminal&&!this._resubscribable){let o=e.filter(d=>d[0]===k||d[0]===C);if(o.length===0)return;n=o}n=this._frameBatch(n);let r=null;for(let o=0;o<n.length;o++){let d=n[o],l=d[0];if(l!==N&&l!==L){r?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${l===N?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let h=d[1];if(l===N)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(h),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(h))c=!1;else if(this._pauseLocks.delete(h),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?r?.push(d):r==null&&(r=n.slice(0,o))}if(r!=null){if(r.length===0)return;n=r}if(this._hasMeta&&n.some(o=>o[0]===k))for(let o of Object.keys(this.meta))try{this.meta[o]._emit(ie)}catch{}let{finalMessages:i,equalsError:a}=this._updateState(n);if(i.length>0&&this._config.inspectorEnabled){let o=this._config.globalInspector;if(o!=null)try{o({kind:"emit",node:this,messages:i})}catch{}}if(i.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let o=this._config.tierOf,d=[];for(let l of i)o(l[0])===3?this._pauseBuffer.push(l):d.push(l);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(i);a!=null&&this._emit([[_,a]])}_updateState(e){let n=this._config.tierOf,s,r,i=-1,a=0;for(let c of e)n(c[0])===3&&a++;let o=a<=1,d=-1;if(this._versioning!=null&&a>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===b){d=c;break}}for(let c=0;c<e.length;c++){let h=e[c],p=h[0];if(p===b){if(h.length>=2){let u=!1;if(o&&this._cached!==void 0)try{u=this._equals(this._cached,h[1])}catch(g){r=this._wrapFnError("equals threw",g),i=c;break}if(u){s==null&&(s=e.slice(0,c)),s.push(he),this._status="resolved";continue}this._cached=h[1],this._versioning!=null&&(d<0||c===d)&&Ne(this._versioning,h[1],this._hashFn)}this._status="settled",s?.push(h)}else if(s?.push(h),p===M)this._status="dirty";else if(p===D)this._status="resolved";else if(p===S){this._status="completed";{let u=this._config.rigorRecorder;if(u!=null)try{u.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===_){this._status="errored";{let u=this._config.rigorRecorder;if(u!=null)try{u.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===C){if(this._cached!==void 0){let g=this._config.rigorRecorder;if(g!=null)try{g.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let u=this._cleanup;if(typeof u=="function"){this._cleanup=void 0;try{u()}catch{}}else if(u!=null&&typeof u=="object"){let g=u.invalidate;if(typeof g=="function")try{g()}catch{}}}else p===k&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let l=i>=0?s??e.slice(0,i):s??e;return r!=null?{finalMessages:l,equalsError:r}:{finalMessages:l}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let n=[...this._sinks];for(let s of n)s(e)};_dispatchOrAccumulate(e){if(be()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],ve(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}X(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let n=this._frameBatch(e);X(this._deliverToSinks,n,this._config.tierOf)}},Me=t=>Array.isArray(t),ue=t=>typeof t=="object"&&t!=null&&!Array.isArray(t);function j(t,e,n){let s=Me(t)?t:[],r=typeof t=="function"?t:typeof e=="function"?e:void 0,i={};return Me(t)?i=(ue(e)?e:n)??{}:ue(t)?i=t:i=(ue(e)?e:n)??{},new $(s,r,i)}function wn(t,e){return j([],{...e,initial:t})}function xn(t,e){return j((s,r,i)=>t(r,i)??void 0,{describeKind:"producer",...e})}function De(t,e,n){return j(t,(r,i,a)=>{let o=r.map((d,l)=>d!=null&&d.length>0?d.at(-1):a.prevData[l]);i.emit(e(o,a))},{describeKind:"derived",...n})}function Tn(t,e,n){return De(t,e,n)}function Nn(t,e,n){return $e(t,e,n)}function $e(t,e,n){return j(t,(r,i,a)=>{let o=r.map((d,l)=>d!=null&&d.length>0?d.at(-1):a.prevData[l]);return e(o,i,a)??void 0},{describeKind:"effect",...n})}function kn(t,e,n){let s=new Map;return t.forEach((r,i)=>{s.set(r,i)}),De(t,(r,i)=>e(o=>{let d=s.get(o);if(d==null)throw new Error(`dynamicNode: untracked dep "${o.name??"<unnamed>"}"`);return r[d]},i),n)}function An(t,e){let n,s=new Map,r=(i,a,o)=>{let d=!1,l=c=>{let h=s.get(c);if(h!==void 0){if(h<i.length){let u=i[h];return u!=null&&u.length>0?u.at(-1):o.prevData[h]}return c.cache}d=!0;let p=n._addDep(c);return s.set(c,p),c.cache};try{let c=t(l,o);d||(a.emit(c),o.store.__autoTrackLastDiscoveryError!=null&&delete o.store.__autoTrackLastDiscoveryError)}catch(c){if(!d)throw c;o.store.__autoTrackLastDiscoveryError=c}};return n=new $([],r,{describeKind:"derived",...e}),n}function En(t,...e){let n=t;for(let s of e)n=s(n);return n}export{Re as a,je as b,ze as c,oe as d,qe as e,Ke as f,ye as g,Ye as h,Oe as i,J as j,me as k,ve as l,Ze as m,X as n,en as o,we as p,Z as q,xe as r,F as s,Ie as t,rn as u,on as v,de as w,le as x,Ne as y,dn as z,B as A,mn as B,$ as C,j as D,wn as E,xn as F,De as G,Tn as H,Nn as I,$e as J,kn as K,An as L,En as M};
@@ -1 +1 @@
1
- import{f as b}from"./chunk-FDQGFWLF.js";import{a as S}from"./chunk-L6NSJVJZ.js";import{j as T}from"./chunk-626TESAC.js";import{b as D}from"./chunk-JQFH2DV6.js";import{C as d}from"./chunk-V5A7M7RJ.js";import{D as N,E as _,G as y,m as P}from"./chunk-LYCLF26R.js";import{b as M,i as A}from"./chunk-CK2E7BTU.js";import{b as C}from"./chunk-QYADASLV.js";var $={};C($,{MessagingHubGraph:()=>k,SubscriptionGraph:()=>f,TopicBridgeGraph:()=>O,TopicGraph:()=>g,TopicRegistry:()=>I,messagingHub:()=>F,subscription:()=>R,topic:()=>H,topicBridge:()=>U});var z=256;function l(r,e){if(!Number.isFinite(r)||!Number.isInteger(r)||r<0)throw new Error(`${e} must be a non-negative integer`);return r}function p(r,e){return S("messaging",r,e)}var B=1024,g=class extends T{_log;_publishImpl;events;latest;hasLatest;constructor(e,n={}){super(e,n.graph),this._log=D([],{name:"events",maxSize:n.retainedLimit??B}),this._log.withLatest(),this.events=this._log.entries,this.add(this.events,{name:"events"}),this.latest=y([this.events],([t])=>{let i=t;return i.length===0?null:i[i.length-1]},{name:"latest",describeKind:"derived",meta:p("topic_latest")}),this.add(this.latest,{name:"latest"}),this.addDisposer(d(this.latest)),this.hasLatest=y([this.events],([t])=>t.length>0,{name:"hasLatest",describeKind:"derived",meta:p("topic_has_latest")}),this.add(this.hasLatest,{name:"hasLatest"}),this.addDisposer(d(this.hasLatest)),this.addDisposer(()=>{this.events.down([[A]])}),this.addDisposer(()=>this._log.disposeAllViews()),this._publishImpl=b(t=>{this._log.append(t)},{freeze:!1})}publish(e){if(e===void 0)throw new TypeError(`TopicGraph "${this.name}": publish(undefined) is not allowed (spec \xA75.12 SENTINEL).`);this._publishImpl(e)}attachEventStorage(e){return this._log.attachStorage(e)}retained(){return this.events.cache}get _logBundle(){return this._log}},f=class extends T{cursor;available;topic;_disposed=!1;_ackImpl;_pullAndAckImpl;constructor(e,n,t={}){super(e,t.graph),this.topic=n;let i;if(t.from!==void 0?t.from==="retained"?i=0:t.from==="now"?i=n.events.cache.length:i=l(t.from,"subscription from"):i=l(t.cursor??0,"subscription cursor"),this.cursor=_(i,{name:"cursor",describeKind:"state",meta:p("subscription_cursor")}),this.add(this.cursor,{name:"cursor"}),this.available=n._logBundle.view({kind:"fromCursor",cursor:this.cursor}),this.add(this.available,{name:"available"}),this.addDisposer(d(this.available)),t.advanceOn!==void 0){let s=t.advanceOn,a=!1,c=N([s],()=>{if(!a){a=!0;return}if(this._disposed)return;let o=this.available.cache;if(o.length===0)return;let u=this.cursor.cache+o.length;this.cursor.emit(u)},{name:"advancePump",describeKind:"effect",meta:p("subscription_advance_pump")});this.add(c,{name:"advancePump"}),this.addDisposer(d(c))}this._ackImpl=b(s=>{let a=this.available.cache,c=s===void 0?a.length:l(s,"subscription ack count"),o=Math.min(c,a.length);if(o<=0)return this.cursor.cache;let u=this.cursor.cache+o;return this.cursor.emit(u),u},{freeze:!1}),this._pullAndAckImpl=b(s=>{let a=this.available.cache,c=s===void 0?a.length:l(s,"subscription pullAndAck limit"),o=a.slice(0,c);if(o.length===0)return{items:o,cursor:this.cursor.cache};let u=this.cursor.cache+o.length;return this.cursor.emit(u),{items:o,cursor:u}},{freeze:!1})}ack(e){return this._disposed?this.cursor.cache:this._ackImpl(e)}pull(e){if(this._disposed)return[];let n=this.available.cache,t=e===void 0?n.length:l(e,"subscription pull limit");return n.slice(0,t)}pullAndAck(e){return this._disposed?{items:[],cursor:this.cursor.cache}:this._pullAndAckImpl(e)}dispose(){this._disposed||(this._disposed=!0,this.cursor.down([[A]]),this.destroy())}},O=class extends T{_sourceSub;bridgedCount;output;constructor(e,n,t,i={}){super(e,i.graph),this._sourceSub=R(`${e}-subscription`,n,{cursor:i.cursor}),this.mount("subscription",this._sourceSub);let s=Math.max(1,l(i.maxPerPump??z,"topic bridge maxPerPump")),a=i.map??(h=>h);this.output=y([this._sourceSub.available],([h])=>{let v=h,m=[],w=Math.min(v.length,s);for(let x=0;x<w;x++){let L=a(v[x]);L!==void 0&&m.push(L)}return m},{name:"output",describeKind:"derived",meta:p("topic_bridge_output",{targetRef:t.name}),initial:[]}),this.add(this.output,{name:"output"}),this.addDisposer(d(this.output)),this.bridgedCount=_(0,{name:"bridgedCount",describeKind:"state",meta:p("topic_bridge_count")}),this.add(this.bridgedCount,{name:"bridgedCount"}),this.addDisposer(d(this.bridgedCount));let c=this.output,o=this._sourceSub,u=this.bridgedCount,G=N([c],()=>{let h=c.cache;if(h.length===0)return;let v=o.available.cache.length,m=Math.min(v,s);if(m>0){o.ack(m);let w=u.cache??0;u.emit(w+h.length)}},{name:"ackPump",describeKind:"effect",meta:p("topic_bridge_ack_pump")});this.add(G,{name:"ackPump"}),this.addDisposer(d(G));let E=K(this.output,t);this.addDisposer(E)}};function K(r,e){return r.subscribe(n=>{for(let t of n){if(t[0]!==M)continue;let i=t[1];i.length!==0&&P(()=>{for(let s of i)e.publish(s)})}})}var I=class{_map=new Map;version;constructor(e){this.version=e}get size(){return this._map.size}has(e){return this._map.has(e)}get(e){return this._map.get(e)}set(e,n){this._map.set(e,n)}delete(e){return this._map.delete(e)}keys(){return this._map.keys()}},k=class extends T{_registry;version;_defaultTopicOptions;_removeTopicImpl;constructor(e,n={}){super(e,n.graph);let t=_(0,{name:"version",describeKind:"state",meta:p("hub_version")});this.add(t,{name:"version"}),this.version=t,this._registry=new I(t),this._defaultTopicOptions={...n.defaultTopicOptions??{}},this._removeTopicImpl=b(i=>{try{this.remove(i)}finally{this._registry.delete(i);let s=this.version.cache??0;this.version.emit(s+1)}},{freeze:!1})}get size(){return this._registry.size}has(e){return this._registry.has(e)}topicNames(){return this._registry.keys()}topic(e,n){let t=this._registry.get(e);if(t===void 0){let i={...this._defaultTopicOptions,...n??{}};t=new g(e,i),this._registry.set(e,t),this.mount(e,t);let s=this.version.cache??0;this.version.emit(s+1)}return t}publish(e,n){this.topic(e).publish(n)}publishMany(e){P(()=>{for(let[n,t]of e)this.topic(n).publish(t)})}subscribe(e,n,t){let i=this.topic(n);return new f(e,i,t)}removeTopic(e){return this._registry.has(e)?(this._removeTopicImpl(e),!0):!1}};function H(r,e){return new g(r,e)}function F(r,e){return new k(r,e)}function R(r,e,n){return new f(r,e,n)}function U(r,e,n,t){return new O(r,e,n,t)}export{g as a,f as b,O as c,I as d,k as e,H as f,F as g,R as h,U as i,$ as j};
1
+ import{f as b}from"./chunk-W3I423PS.js";import{a as S}from"./chunk-L6NSJVJZ.js";import{j as T}from"./chunk-HITNVN6B.js";import{b as D}from"./chunk-YBB7ZGTY.js";import{C as d}from"./chunk-CRVT7D2P.js";import{D as N,E as _,G as y,m as P}from"./chunk-NTEURFZH.js";import{b as M,i as A}from"./chunk-CK2E7BTU.js";import{b as C}from"./chunk-QYADASLV.js";var $={};C($,{MessagingHubGraph:()=>k,SubscriptionGraph:()=>f,TopicBridgeGraph:()=>O,TopicGraph:()=>g,TopicRegistry:()=>I,messagingHub:()=>F,subscription:()=>R,topic:()=>H,topicBridge:()=>U});var z=256;function l(r,e){if(!Number.isFinite(r)||!Number.isInteger(r)||r<0)throw new Error(`${e} must be a non-negative integer`);return r}function p(r,e){return S("messaging",r,e)}var B=1024,g=class extends T{_log;_publishImpl;events;latest;hasLatest;constructor(e,n={}){super(e,n.graph),this._log=D([],{name:"events",maxSize:n.retainedLimit??B}),this._log.withLatest(),this.events=this._log.entries,this.add(this.events,{name:"events"}),this.latest=y([this.events],([t])=>{let i=t;return i.length===0?null:i[i.length-1]},{name:"latest",describeKind:"derived",meta:p("topic_latest")}),this.add(this.latest,{name:"latest"}),this.addDisposer(d(this.latest)),this.hasLatest=y([this.events],([t])=>t.length>0,{name:"hasLatest",describeKind:"derived",meta:p("topic_has_latest")}),this.add(this.hasLatest,{name:"hasLatest"}),this.addDisposer(d(this.hasLatest)),this.addDisposer(()=>{this.events.down([[A]])}),this.addDisposer(()=>this._log.disposeAllViews()),this._publishImpl=b(t=>{this._log.append(t)},{freeze:!1})}publish(e){if(e===void 0)throw new TypeError(`TopicGraph "${this.name}": publish(undefined) is not allowed (spec \xA75.12 SENTINEL).`);this._publishImpl(e)}attachEventStorage(e){return this._log.attachStorage(e)}retained(){return this.events.cache}get _logBundle(){return this._log}},f=class extends T{cursor;available;topic;_disposed=!1;_ackImpl;_pullAndAckImpl;constructor(e,n,t={}){super(e,t.graph),this.topic=n;let i;if(t.from!==void 0?t.from==="retained"?i=0:t.from==="now"?i=n.events.cache.length:i=l(t.from,"subscription from"):i=l(t.cursor??0,"subscription cursor"),this.cursor=_(i,{name:"cursor",describeKind:"state",meta:p("subscription_cursor")}),this.add(this.cursor,{name:"cursor"}),this.available=n._logBundle.view({kind:"fromCursor",cursor:this.cursor}),this.add(this.available,{name:"available"}),this.addDisposer(d(this.available)),t.advanceOn!==void 0){let s=t.advanceOn,a=!1,c=N([s],()=>{if(!a){a=!0;return}if(this._disposed)return;let o=this.available.cache;if(o.length===0)return;let u=this.cursor.cache+o.length;this.cursor.emit(u)},{name:"advancePump",describeKind:"effect",meta:p("subscription_advance_pump")});this.add(c,{name:"advancePump"}),this.addDisposer(d(c))}this._ackImpl=b(s=>{let a=this.available.cache,c=s===void 0?a.length:l(s,"subscription ack count"),o=Math.min(c,a.length);if(o<=0)return this.cursor.cache;let u=this.cursor.cache+o;return this.cursor.emit(u),u},{freeze:!1}),this._pullAndAckImpl=b(s=>{let a=this.available.cache,c=s===void 0?a.length:l(s,"subscription pullAndAck limit"),o=a.slice(0,c);if(o.length===0)return{items:o,cursor:this.cursor.cache};let u=this.cursor.cache+o.length;return this.cursor.emit(u),{items:o,cursor:u}},{freeze:!1})}ack(e){return this._disposed?this.cursor.cache:this._ackImpl(e)}pull(e){if(this._disposed)return[];let n=this.available.cache,t=e===void 0?n.length:l(e,"subscription pull limit");return n.slice(0,t)}pullAndAck(e){return this._disposed?{items:[],cursor:this.cursor.cache}:this._pullAndAckImpl(e)}dispose(){this._disposed||(this._disposed=!0,this.cursor.down([[A]]),this.destroy())}},O=class extends T{_sourceSub;bridgedCount;output;constructor(e,n,t,i={}){super(e,i.graph),this._sourceSub=R(`${e}-subscription`,n,{cursor:i.cursor}),this.mount("subscription",this._sourceSub);let s=Math.max(1,l(i.maxPerPump??z,"topic bridge maxPerPump")),a=i.map??(h=>h);this.output=y([this._sourceSub.available],([h])=>{let v=h,m=[],w=Math.min(v.length,s);for(let x=0;x<w;x++){let L=a(v[x]);L!==void 0&&m.push(L)}return m},{name:"output",describeKind:"derived",meta:p("topic_bridge_output",{targetRef:t.name}),initial:[]}),this.add(this.output,{name:"output"}),this.addDisposer(d(this.output)),this.bridgedCount=_(0,{name:"bridgedCount",describeKind:"state",meta:p("topic_bridge_count")}),this.add(this.bridgedCount,{name:"bridgedCount"}),this.addDisposer(d(this.bridgedCount));let c=this.output,o=this._sourceSub,u=this.bridgedCount,G=N([c],()=>{let h=c.cache;if(h.length===0)return;let v=o.available.cache.length,m=Math.min(v,s);if(m>0){o.ack(m);let w=u.cache??0;u.emit(w+h.length)}},{name:"ackPump",describeKind:"effect",meta:p("topic_bridge_ack_pump")});this.add(G,{name:"ackPump"}),this.addDisposer(d(G));let E=K(this.output,t);this.addDisposer(E)}};function K(r,e){return r.subscribe(n=>{for(let t of n){if(t[0]!==M)continue;let i=t[1];i.length!==0&&P(()=>{for(let s of i)e.publish(s)})}})}var I=class{_map=new Map;version;constructor(e){this.version=e}get size(){return this._map.size}has(e){return this._map.has(e)}get(e){return this._map.get(e)}set(e,n){this._map.set(e,n)}delete(e){return this._map.delete(e)}keys(){return this._map.keys()}},k=class extends T{_registry;version;_defaultTopicOptions;_removeTopicImpl;constructor(e,n={}){super(e,n.graph);let t=_(0,{name:"version",describeKind:"state",meta:p("hub_version")});this.add(t,{name:"version"}),this.version=t,this._registry=new I(t),this._defaultTopicOptions={...n.defaultTopicOptions??{}},this._removeTopicImpl=b(i=>{try{this.remove(i)}finally{this._registry.delete(i);let s=this.version.cache??0;this.version.emit(s+1)}},{freeze:!1})}get size(){return this._registry.size}has(e){return this._registry.has(e)}topicNames(){return this._registry.keys()}topic(e,n){let t=this._registry.get(e);if(t===void 0){let i={...this._defaultTopicOptions,...n??{}};t=new g(e,i),this._registry.set(e,t),this.mount(e,t);let s=this.version.cache??0;this.version.emit(s+1)}return t}publish(e,n){this.topic(e).publish(n)}publishMany(e){P(()=>{for(let[n,t]of e)this.topic(n).publish(t)})}subscribe(e,n,t){let i=this.topic(n);return new f(e,i,t)}removeTopic(e){return this._registry.has(e)?(this._removeTopicImpl(e),!0):!1}};function H(r,e){return new g(r,e)}function F(r,e){return new k(r,e)}function R(r,e,n){return new f(r,e,n)}function U(r,e,n,t){return new O(r,e,n,t)}export{g as a,f as b,O as c,I as d,k as e,H as f,F as g,R as h,U as i,$ as j};