@graphrefly/graphrefly 0.41.0 → 0.42.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 (296) hide show
  1. package/dist/{cascading-Cxs1eztH.d.cts → cascading-CH-_VwG9.d.cts} +2 -2
  2. package/dist/{cascading-BNfxffgc.d.ts → cascading-OgKQZjsa.d.ts} +2 -2
  3. package/dist/{chunk-L77I47VU.js → chunk-2K5RXLAH.js} +1 -1
  4. package/dist/chunk-3ERTUW2J.js +45 -0
  5. package/dist/chunk-3K7HA4Y6.js +1 -0
  6. package/dist/chunk-3ZZX7M25.js +1 -0
  7. package/dist/chunk-4QH6VJF4.js +1 -0
  8. package/dist/{chunk-M3FQSXEW.js → chunk-5QRRKBUT.js} +1 -1
  9. package/dist/chunk-5ST42ESJ.js +1 -0
  10. package/dist/{chunk-AK5RHMC5.js → chunk-6YFZMUMR.js} +1 -1
  11. package/dist/{chunk-SC27WTSG.js → chunk-7ARY3Y3T.js} +1 -1
  12. package/dist/chunk-7B7ELAT2.js +1 -0
  13. package/dist/{chunk-F7VUYPP6.js → chunk-7VKFXLZQ.js} +1 -1
  14. package/dist/chunk-ACMJ2ZPS.js +3 -0
  15. package/dist/{chunk-7PQLZMOG.js → chunk-AGNM6RS6.js} +1 -1
  16. package/dist/chunk-AS3TV2TV.js +1 -0
  17. package/dist/{chunk-CGNOWGV6.js → chunk-CISGGAIF.js} +1 -1
  18. package/dist/{chunk-ZAJ7J7TO.js → chunk-DEJTNNQC.js} +1 -1
  19. package/dist/{chunk-AI7QC7J6.js → chunk-FDZAZNRO.js} +1 -1
  20. package/dist/{chunk-OV5AA6HJ.js → chunk-FUZ6S2DY.js} +1 -1
  21. package/dist/{chunk-G3M3IMEV.js → chunk-G5VBJ5K6.js} +1 -1
  22. package/dist/{chunk-KNVCCBIU.js → chunk-HZKW2AAB.js} +1 -1
  23. package/dist/{chunk-CYOSWFT2.js → chunk-IZM3UEH3.js} +3 -3
  24. package/dist/{chunk-UISPDFJ3.js → chunk-KCACBSJH.js} +1 -1
  25. package/dist/{chunk-GI4Q7PNY.js → chunk-KT5DTRBP.js} +1 -1
  26. package/dist/{chunk-33N4TU3X.js → chunk-KY2LMAXU.js} +1 -1
  27. package/dist/{chunk-TT4C7DXW.js → chunk-LDQ3IUIP.js} +1 -1
  28. package/dist/chunk-LPRWATHB.js +61 -0
  29. package/dist/{chunk-X7QKTXXC.js → chunk-NWXQIOIB.js} +3 -3
  30. package/dist/{chunk-VV62MIG4.js → chunk-Q7QQQA3I.js} +1 -1
  31. package/dist/chunk-VE5SIZEM.js +1 -0
  32. package/dist/chunk-VRALOYRD.js +1 -0
  33. package/dist/{chunk-5VEZLQFN.js → chunk-WHMUB5QB.js} +1 -1
  34. package/dist/chunk-XLQPNNIC.js +1 -0
  35. package/dist/{chunk-YQRN4CIV.js → chunk-YGL7FPVQ.js} +1 -1
  36. package/dist/compat/index.cjs +5 -5
  37. package/dist/compat/index.d.cts +16 -16
  38. package/dist/compat/index.d.ts +16 -16
  39. package/dist/compat/index.js +1 -1
  40. package/dist/compat/jotai/index.d.cts +2 -2
  41. package/dist/compat/jotai/index.d.ts +2 -2
  42. package/dist/compat/nanostores/index.d.cts +2 -2
  43. package/dist/compat/nanostores/index.d.ts +2 -2
  44. package/dist/compat/nestjs/index.cjs +5 -5
  45. package/dist/compat/nestjs/index.d.cts +8 -8
  46. package/dist/compat/nestjs/index.d.ts +8 -8
  47. package/dist/compat/nestjs/index.js +1 -1
  48. package/dist/compat/react/index.d.cts +2 -2
  49. package/dist/compat/react/index.d.ts +2 -2
  50. package/dist/compat/solid/index.d.cts +2 -2
  51. package/dist/compat/solid/index.d.ts +2 -2
  52. package/dist/compat/svelte/index.d.cts +2 -2
  53. package/dist/compat/svelte/index.d.ts +2 -2
  54. package/dist/compat/vue/index.d.cts +2 -2
  55. package/dist/compat/vue/index.d.ts +2 -2
  56. package/dist/compat/zustand/index.cjs +3 -3
  57. package/dist/compat/zustand/index.d.cts +4 -4
  58. package/dist/compat/zustand/index.d.ts +4 -4
  59. package/dist/compat/zustand/index.js +1 -1
  60. package/dist/core/index.d.cts +4 -4
  61. package/dist/core/index.d.ts +4 -4
  62. package/dist/{decay-C25AyNAj.d.cts → decay-2ZukgQ4o.d.cts} +2 -2
  63. package/dist/{decay-BnrlbxSv.d.ts → decay-CdEBmDIs.d.ts} +2 -2
  64. package/dist/extra/browser.d.cts +1 -1
  65. package/dist/extra/browser.d.ts +1 -1
  66. package/dist/extra/index.cjs +14 -14
  67. package/dist/extra/index.d.cts +10 -11
  68. package/dist/extra/index.d.ts +10 -11
  69. package/dist/extra/index.js +1 -1
  70. package/dist/extra/node.cjs +2 -2
  71. package/dist/extra/node.d.cts +1 -1
  72. package/dist/extra/node.d.ts +1 -1
  73. package/dist/extra/node.js +1 -1
  74. package/dist/extra/operators.cjs +1 -1
  75. package/dist/extra/operators.d.cts +1 -1
  76. package/dist/extra/operators.d.ts +1 -1
  77. package/dist/extra/operators.js +1 -1
  78. package/dist/extra/reactive.d.cts +3 -3
  79. package/dist/extra/reactive.d.ts +3 -3
  80. package/dist/extra/reactive.js +1 -1
  81. package/dist/extra/render/index.d.cts +3 -3
  82. package/dist/extra/render/index.d.ts +3 -3
  83. package/dist/extra/sources.cjs +3 -1
  84. package/dist/extra/sources.d.cts +1 -1
  85. package/dist/extra/sources.d.ts +1 -1
  86. package/dist/extra/sources.js +1 -1
  87. package/dist/extra/storage-browser.d.cts +1 -1
  88. package/dist/extra/storage-browser.d.ts +1 -1
  89. package/dist/{fallback-CMZl39L5.d.ts → fallback-CqYVLL6X.d.ts} +1 -1
  90. package/dist/{fallback-8JYU8tlT.d.cts → fallback-Ctlj2tMY.d.cts} +1 -1
  91. package/dist/graph/index.cjs +7 -7
  92. package/dist/graph/index.d.cts +5 -5
  93. package/dist/graph/index.d.ts +5 -5
  94. package/dist/graph/index.js +1 -1
  95. package/dist/{graph-BkIkog4h.d.ts → graph-7VguS7a4.d.ts} +3 -3
  96. package/dist/{graph-E6likq7w.d.cts → graph-C4SHb3Ly.d.cts} +3 -3
  97. package/dist/{index-DktLSZOc.d.cts → index-2B7u2pVn.d.cts} +4 -4
  98. package/dist/{index-DGD4_fj6.d.cts → index-3NmAfcH0.d.cts} +8 -5
  99. package/dist/{index-DfOK_oL5.d.ts → index-4Uz-e_fL.d.ts} +372 -17
  100. package/dist/{index-BAQrjuZF.d.ts → index-B-i4_g3k.d.ts} +2 -2
  101. package/dist/{index-DpiGqtrs.d.cts → index-B11anra4.d.cts} +441 -381
  102. package/dist/{index-WSlcjhQF.d.ts → index-B3OTH1dV.d.ts} +124 -13
  103. package/dist/{index-2n8Eai6M.d.ts → index-BG0BN3PB.d.ts} +1 -1
  104. package/dist/{index-z8WFPVI8.d.cts → index-BJX94aud.d.cts} +1 -1
  105. package/dist/{index-DhLyOHYZ.d.ts → index-BP8a88zx.d.ts} +11 -4
  106. package/dist/{index-Cnr1WrlX.d.cts → index-BTQtTb_H.d.cts} +14 -3
  107. package/dist/{index-BaA-xpSw.d.ts → index-BUYXac2c.d.ts} +3 -3
  108. package/dist/{index-DOBLxOti.d.cts → index-BVpm6noz.d.cts} +1 -1
  109. package/dist/{index-DhnsQfa3.d.ts → index-Bbkgpt5t.d.ts} +441 -381
  110. package/dist/{index-Cczxgd2D.d.ts → index-Bc41FuHp.d.cts} +3 -3
  111. package/dist/{index-BiHUBEKq.d.cts → index-BdGtBX-X.d.cts} +3 -3
  112. package/dist/index-BeT2r7sk.d.ts +760 -0
  113. package/dist/{index-da2V5vPy.d.ts → index-Bf7eqeSF.d.ts} +2 -2
  114. package/dist/{index-bXXLSvor.d.ts → index-Bn4zHYLj.d.ts} +4 -4
  115. package/dist/{index-DGTo1yka.d.cts → index-BoLv_OfD.d.cts} +2 -2
  116. package/dist/{index-B72TQQHd.d.cts → index-BsT7F2et.d.ts} +3 -3
  117. package/dist/{index-Bd91Nmf4.d.cts → index-BtAsBp8K.d.cts} +4 -4
  118. package/dist/{index-DgJc8Zgc.d.cts → index-C0-Jv1kP.d.cts} +81 -5
  119. package/dist/{index-C6ZUaos7.d.ts → index-C7O6r5fV.d.ts} +1 -1
  120. package/dist/{index-CL7oilfm.d.cts → index-C9kSENB4.d.cts} +1 -1
  121. package/dist/{index-yLt-aPMp.d.ts → index-CCq87F7t.d.ts} +1 -1
  122. package/dist/{index-DQQCOIt8.d.cts → index-CEMx8n40.d.cts} +10 -5
  123. package/dist/{index-BilOa6AE.d.cts → index-CJIuLu2f.d.cts} +124 -13
  124. package/dist/{index-B2RUoIUz.d.ts → index-CJK1JkYy.d.ts} +1 -1
  125. package/dist/{index-CG33HeBW.d.ts → index-CJQm0g38.d.ts} +8 -5
  126. package/dist/index-CPNSy-U0.d.cts +760 -0
  127. package/dist/{index-A3U3CSve.d.cts → index-CZjOhcBy.d.cts} +2 -2
  128. package/dist/{index-CAP3UGsq.d.ts → index-CZmcDtFn.d.ts} +1 -1
  129. package/dist/{index-DYTBbF8T.d.cts → index-ChOyVLKm.d.cts} +1 -1
  130. package/dist/{index-eaQuGJnv.d.ts → index-CpyNFqkB.d.ts} +3 -3
  131. package/dist/{index-BJSZxSFX.d.ts → index-CvrqGfNS.d.ts} +1 -1
  132. package/dist/{index-DuRsN9ae.d.cts → index-D-Xs74HZ.d.cts} +372 -17
  133. package/dist/{index-C5cQ7Gfx.d.ts → index-D6egPFAL.d.ts} +4 -4
  134. package/dist/{index-CD2dBMet.d.ts → index-D8l8hNXn.d.ts} +10 -5
  135. package/dist/{index-40ZT4MHj.d.ts → index-DBHK8O6H.d.ts} +14 -3
  136. package/dist/{index-DVDapw2k.d.cts → index-DBIqYS43.d.cts} +35 -21
  137. package/dist/{index-3k4Gg6-n.d.ts → index-DBevwHj_.d.ts} +3 -3
  138. package/dist/{index-Ctb7_2sG.d.ts → index-DIOoAZUX.d.ts} +1 -1
  139. package/dist/{index-BQ1fR4li.d.ts → index-DO9XxMzS.d.ts} +35 -21
  140. package/dist/{index-CQtWm7jS.d.ts → index-DQo8xBgd.d.ts} +9 -9
  141. package/dist/{index-DH4fm2Ck.d.ts → index-Dgs8zcj7.d.ts} +2 -2
  142. package/dist/{index-CtFNGe-m.d.cts → index-Dhc7a7Xo.d.cts} +2 -2
  143. package/dist/{index-MxYuWOrf.d.cts → index-DmAgG5CI.d.cts} +3 -3
  144. package/dist/{index-CoM4rzyB.d.ts → index-Dmqp7KjD.d.ts} +1 -1
  145. package/dist/{index-B6iTqKtJ.d.ts → index-Dn-wI9g4.d.ts} +2 -2
  146. package/dist/{index-C-dkXOpB.d.cts → index-Du7u1lSf.d.cts} +11 -4
  147. package/dist/{index-DVAlsmEU.d.cts → index-HoU88d5U.d.cts} +3 -3
  148. package/dist/{index-CRm0YIzC.d.cts → index-LIpQQE9f.d.cts} +9 -9
  149. package/dist/{index-CgnCFhr2.d.cts → index-f5IivDUX.d.cts} +1 -1
  150. package/dist/{index-PgwvGWa1.d.cts → index-hHcaFlJX.d.cts} +1 -1
  151. package/dist/{index-I1cCY3ZI.d.ts → index-pT8sCpOJ.d.ts} +81 -5
  152. package/dist/{index-D4uimgee.d.cts → index-sl4NyzQx.d.cts} +1 -1
  153. package/dist/{index-tV3AA9hI.d.cts → index-tJoTcnHh.d.cts} +2 -2
  154. package/dist/{index-D3ayz3hy.d.cts → index-z96luz5O.d.cts} +1 -1
  155. package/dist/index.cjs +48 -48
  156. package/dist/index.d.cts +45 -50
  157. package/dist/index.d.ts +45 -50
  158. package/dist/index.js +1 -1
  159. package/dist/{meta-D8OyedKp.d.ts → meta-BgVAsg9j.d.ts} +1 -1
  160. package/dist/{meta-Ct9nqQS5.d.cts → meta-vE8bxW1E.d.cts} +1 -1
  161. package/dist/{node-BYInONRr.d.cts → node-ClS5yC-B.d.cts} +1 -1
  162. package/dist/{node-BYInONRr.d.ts → node-ClS5yC-B.d.ts} +1 -1
  163. package/dist/{observable-DO8DDEzv.d.ts → observable-BsBzUrcI.d.ts} +1 -1
  164. package/dist/{observable-DMIlYJV1.d.cts → observable-DLGPPtb8.d.cts} +1 -1
  165. package/dist/patterns/ai/browser.d.cts +4 -4
  166. package/dist/patterns/ai/browser.d.ts +4 -4
  167. package/dist/patterns/ai/browser.js +1 -1
  168. package/dist/patterns/ai/index.cjs +17 -17
  169. package/dist/patterns/ai/index.d.cts +17 -17
  170. package/dist/patterns/ai/index.d.ts +17 -17
  171. package/dist/patterns/ai/index.js +1 -1
  172. package/dist/patterns/ai/node.d.cts +4 -4
  173. package/dist/patterns/ai/node.d.ts +4 -4
  174. package/dist/patterns/ai/node.js +1 -1
  175. package/dist/patterns/cqrs/index.cjs +3 -3
  176. package/dist/patterns/cqrs/index.d.cts +6 -6
  177. package/dist/patterns/cqrs/index.d.ts +6 -6
  178. package/dist/patterns/cqrs/index.js +1 -1
  179. package/dist/patterns/demo-shell/index.cjs +5 -5
  180. package/dist/patterns/demo-shell/index.d.cts +5 -5
  181. package/dist/patterns/demo-shell/index.d.ts +5 -5
  182. package/dist/patterns/demo-shell/index.js +1 -1
  183. package/dist/patterns/domain-templates/index.cjs +3 -3
  184. package/dist/patterns/domain-templates/index.d.cts +4 -4
  185. package/dist/patterns/domain-templates/index.d.ts +4 -4
  186. package/dist/patterns/domain-templates/index.js +1 -1
  187. package/dist/patterns/graphspec/index.cjs +12 -12
  188. package/dist/patterns/graphspec/index.d.cts +5 -5
  189. package/dist/patterns/graphspec/index.d.ts +5 -5
  190. package/dist/patterns/graphspec/index.js +1 -1
  191. package/dist/patterns/harness/index.cjs +10 -8
  192. package/dist/patterns/harness/index.d.cts +11 -12
  193. package/dist/patterns/harness/index.d.ts +11 -12
  194. package/dist/patterns/harness/index.js +1 -1
  195. package/dist/patterns/inspect/index.cjs +3 -0
  196. package/dist/patterns/inspect/index.d.cts +9 -0
  197. package/dist/patterns/inspect/index.d.ts +9 -0
  198. package/dist/patterns/inspect/index.js +1 -0
  199. package/dist/patterns/job-queue/index.cjs +3 -3
  200. package/dist/patterns/job-queue/index.d.cts +6 -6
  201. package/dist/patterns/job-queue/index.d.ts +6 -6
  202. package/dist/patterns/job-queue/index.js +1 -1
  203. package/dist/patterns/memory/index.cjs +3 -3
  204. package/dist/patterns/memory/index.d.cts +6 -6
  205. package/dist/patterns/memory/index.d.ts +6 -6
  206. package/dist/patterns/memory/index.js +1 -1
  207. package/dist/patterns/messaging/index.cjs +3 -3
  208. package/dist/patterns/messaging/index.d.cts +5 -5
  209. package/dist/patterns/messaging/index.d.ts +5 -5
  210. package/dist/patterns/messaging/index.js +1 -1
  211. package/dist/patterns/orchestration/index.cjs +3 -3
  212. package/dist/patterns/orchestration/index.d.cts +7 -7
  213. package/dist/patterns/orchestration/index.d.ts +7 -7
  214. package/dist/patterns/orchestration/index.js +1 -1
  215. package/dist/patterns/process/index.cjs +1 -1
  216. package/dist/patterns/process/index.d.cts +7 -7
  217. package/dist/patterns/process/index.d.ts +7 -7
  218. package/dist/patterns/process/index.js +1 -1
  219. package/dist/patterns/reactive-layout/index.cjs +4 -4
  220. package/dist/patterns/reactive-layout/index.d.cts +5 -5
  221. package/dist/patterns/reactive-layout/index.d.ts +5 -5
  222. package/dist/patterns/reactive-layout/index.js +1 -1
  223. package/dist/patterns/reduction/index.cjs +3 -3
  224. package/dist/patterns/reduction/index.d.cts +4 -4
  225. package/dist/patterns/reduction/index.d.ts +4 -4
  226. package/dist/patterns/reduction/index.js +1 -1
  227. package/dist/patterns/surface/index.cjs +8 -8
  228. package/dist/patterns/surface/index.d.cts +6 -6
  229. package/dist/patterns/surface/index.d.ts +6 -6
  230. package/dist/patterns/surface/index.js +1 -1
  231. package/dist/{pipeline-graph-MWrQZXCq.d.cts → pipeline-graph-WBlobVhU.d.cts} +5 -5
  232. package/dist/{pipeline-graph-CB4La-UW.d.ts → pipeline-graph-v8fMvqNk.d.ts} +5 -5
  233. package/dist/{reactive-layout-BtZfUKuL.d.cts → reactive-layout-Dsvob4zD.d.cts} +2 -2
  234. package/dist/{reactive-layout-KJj4E2dT.d.ts → reactive-layout-v7KPvxoc.d.ts} +2 -2
  235. package/dist/{reactive-log-_zeEnB9H.d.cts → reactive-log-B00laMSQ.d.cts} +1 -1
  236. package/dist/{reactive-log-BlAsPLl2.d.ts → reactive-log-BezYsbA_.d.ts} +1 -1
  237. package/dist/{reactive-map-6P_k3AQM.d.cts → reactive-map-48mnZ-nu.d.cts} +1 -1
  238. package/dist/{reactive-map-CjXByDV-.d.ts → reactive-map-BVVPdvmi.d.ts} +1 -1
  239. package/dist/resilience-445VFFXQ.js +1 -0
  240. package/dist/{sugar-BhfjgetH.d.ts → sugar-CH-2ZY90.d.ts} +1 -1
  241. package/dist/{sugar-DzePN5-g.d.cts → sugar-DStZfUEK.d.cts} +1 -1
  242. package/dist/{topology-tree-mF7Emqzm.d.ts → topology-tree-BNGvuG82.d.ts} +1 -1
  243. package/dist/{topology-tree-3LBKFsUo.d.cts → topology-tree-BSdfSwMi.d.cts} +1 -1
  244. package/dist/{types-1Dhoi7HM.d.cts → types-B1jDWVsM.d.cts} +1 -1
  245. package/dist/{types-39jk0kaV.d.ts → types-DkzUUs0H.d.ts} +1 -1
  246. package/package.json +11 -51
  247. package/dist/budget-gate-CmmVtasH.d.ts +0 -115
  248. package/dist/budget-gate-DiP_nK0n.d.cts +0 -115
  249. package/dist/chunk-2W553JJC.js +0 -1
  250. package/dist/chunk-4MKL6Q3K.js +0 -1
  251. package/dist/chunk-5B3JDG5F.js +0 -1
  252. package/dist/chunk-5QSXEMXG.js +0 -1
  253. package/dist/chunk-5TEFC2ZX.js +0 -1
  254. package/dist/chunk-5TOPVRN6.js +0 -1
  255. package/dist/chunk-EC2WNSZ7.js +0 -1
  256. package/dist/chunk-ELAASRBT.js +0 -3
  257. package/dist/chunk-H5SCWHWP.js +0 -1
  258. package/dist/chunk-OLIKJUKI.js +0 -1
  259. package/dist/chunk-POXANAJ6.js +0 -3
  260. package/dist/chunk-RSMEXK53.js +0 -43
  261. package/dist/chunk-SGS4OJGS.js +0 -1
  262. package/dist/chunk-URJ2VFNC.js +0 -1
  263. package/dist/chunk-VXPLLA4P.js +0 -1
  264. package/dist/chunk-WZYB3JQS.js +0 -1
  265. package/dist/chunk-Z6X7B6A4.js +0 -61
  266. package/dist/index-8s-Qm-gz.d.ts +0 -218
  267. package/dist/index-BgjS2b8N.d.ts +0 -366
  268. package/dist/index-BmSQLAZo.d.cts +0 -244
  269. package/dist/index-CGhMJNHb.d.cts +0 -128
  270. package/dist/index-CUIkE1l9.d.cts +0 -230
  271. package/dist/index-Ck35nA-T.d.ts +0 -244
  272. package/dist/index-CuPUehFa.d.cts +0 -218
  273. package/dist/index-D1Gc7wV5.d.ts +0 -230
  274. package/dist/index-N2MAxt7_.d.ts +0 -128
  275. package/dist/index-t6L2qpHh.d.cts +0 -366
  276. package/dist/patterns/audit/index.cjs +0 -3
  277. package/dist/patterns/audit/index.d.cts +0 -8
  278. package/dist/patterns/audit/index.d.ts +0 -8
  279. package/dist/patterns/audit/index.js +0 -1
  280. package/dist/patterns/guarded-execution/index.cjs +0 -3
  281. package/dist/patterns/guarded-execution/index.d.cts +0 -9
  282. package/dist/patterns/guarded-execution/index.d.ts +0 -9
  283. package/dist/patterns/guarded-execution/index.js +0 -1
  284. package/dist/patterns/lens/index.cjs +0 -3
  285. package/dist/patterns/lens/index.d.cts +0 -7
  286. package/dist/patterns/lens/index.d.ts +0 -7
  287. package/dist/patterns/lens/index.js +0 -1
  288. package/dist/patterns/refine-loop/index.cjs +0 -5
  289. package/dist/patterns/refine-loop/index.d.cts +0 -9
  290. package/dist/patterns/refine-loop/index.d.ts +0 -9
  291. package/dist/patterns/refine-loop/index.js +0 -1
  292. package/dist/patterns/resilient-pipeline/index.cjs +0 -3
  293. package/dist/patterns/resilient-pipeline/index.d.cts +0 -8
  294. package/dist/patterns/resilient-pipeline/index.d.ts +0 -8
  295. package/dist/patterns/resilient-pipeline/index.js +0 -1
  296. package/dist/resilience-JISHQD2F.js +0 -1
@@ -1,5 +1,5 @@
1
- import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-1Dhoi7HM.cjs';
2
- import { b as CircuitBreakerOptions, f as CircuitBreaker } from './index-DGTo1yka.cjs';
1
+ import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-B1jDWVsM.cjs';
2
+ import { b as CircuitBreakerOptions, C as CircuitBreaker } from './index-BoLv_OfD.cjs';
3
3
 
4
4
  /**
5
5
  * OpenAICompatAdapter — default fetch-backed, optional SDK-backed.
@@ -1,5 +1,5 @@
1
- import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-39jk0kaV.js';
2
- import { b as CircuitBreakerOptions, f as CircuitBreaker } from './index-BAQrjuZF.js';
1
+ import { L as LLMAdapter, C as ChatMessage, a as LLMInvokeOptions } from './types-DkzUUs0H.js';
2
+ import { b as CircuitBreakerOptions, C as CircuitBreaker } from './index-B-i4_g3k.js';
3
3
 
4
4
  /**
5
5
  * OpenAICompatAdapter — default fetch-backed, optional SDK-backed.
@@ -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-JISHQD2F.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-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-445VFFXQ.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,45 @@
1
+ import{d as tt,e as rt}from"./chunk-5ST42ESJ.js";import{s as $e,t as Me,v as Ze}from"./chunk-LPRWATHB.js";import{g as Ne,i as Ge}from"./chunk-4QH6VJF4.js";import{c as et}from"./chunk-AGNM6RS6.js";import{b as me}from"./chunk-D27JNOLZ.js";import{b as Xe}from"./chunk-TSOYJ743.js";import{b as Se}from"./chunk-TZQPPQEQ.js";import{a as _e}from"./chunk-3ZZX7M25.js";import{g as ze,j as xe}from"./chunk-ACMJ2ZPS.js";import{b as Re,s as De,t as Ke,x as Ie}from"./chunk-6YFZMUMR.js";import{C as We,m as ke}from"./chunk-2K5RXLAH.js";import{b as Ye}from"./chunk-35JTVPOX.js";import{D as Be,E as S,F as Ee,G as h,H as O,m as fe,o as H}from"./chunk-LYCLF26R.js";import{b as V,i as X,j as Y}from"./chunk-CK2E7BTU.js";import{b as pt}from"./chunk-QYADASLV.js";var Yt={};pt(Yt,{DEFAULT_DECAY_RATE:()=>ee,DEFAULT_EXECUTE_PROMPT:()=>Ve,DEFAULT_QUEUE_CONFIGS:()=>Ae,DEFAULT_SEVERITY_WEIGHTS:()=>Z,DEFAULT_TRIAGE_PROMPT:()=>He,DEFAULT_VERIFY_PROMPT:()=>Le,HarnessGraph:()=>Ce,QUEUE_NAMES:()=>M,actuatorExecutor:()=>nt,affectedTaskFilter:()=>kt,autoSolidify:()=>ht,beforeAfterCompare:()=>It,blindVariation:()=>Pt,codeChangeBridge:()=>St,createIntakeBridge:()=>Et,defaultErrorClassifier:()=>we,defaultLlmExecutor:()=>lt,defaultLlmVerifier:()=>dt,dispatchActuator:()=>vt,effectivenessTracker:()=>wt,errorCritique:()=>Dt,evalIntakeBridge:()=>xt,evalSource:()=>Rt,evalVerifier:()=>at,harnessEvalPair:()=>Ht,harnessLoop:()=>qt,harnessProfile:()=>Jt,harnessTrace:()=>Ut,notifyEffect:()=>Nt,priorityScore:()=>Vt,refineExecutor:()=>Je,refineLoop:()=>je,resolvePromptFn:()=>pe,strategyKey:()=>te,strategyModel:()=>Qe});function yt(e,r){return{outcome:"success",detail:`actuator applied ${r.intervention} for ${Tt(r.summary)}`,artifact:e}}function gt(e,r){let c=e instanceof Error?e.message:String(e);return{outcome:"failure",detail:`actuator threw on ${r.intervention}: ${c}`}}function bt(e){return`actuator skipped ${e.intervention} (shouldApply returned false)`}function Tt(e,r=80){return e.length<=r?e:`${e.slice(0,r-1)}\u2026`}function nt(e){let r=e.name??"actuator-executor",c=e.toOutput??yt,n=e.onError??gt,i=e.skipDetail??bt;return t=>{let o=t.payload.item;return e.shouldApply&&!e.shouldApply(o)?{...t.payload,execution:{item:o,outcome:"failure",detail:i(o)}}:Ee(a=>{let u=new AbortController,s=!1,l=null,m=y=>{s||(s=!0,a.down([[V,{...t.payload,execution:{item:o,...y}}],[X]]),l?.(),l=null)},f;try{let y=e.apply(o,{signal:u.signal});f=ke(y,{signal:u.signal})}catch(y){return m(n(y,o)),()=>{u.abort()}}return l=f.subscribe(y=>{for(let g of y){if(s)return;if(g[0]===V){m(c(g[1],o));return}if(g[0]===Y){m(n(g[1],o));return}if(g[0]===X){m(n(new Error("actuator inner completed without emitting DATA"),o));return}}}),s&&l&&(l(),l=null),()=>{u.abort(),l?.(),l=null}},{name:`${r}/inner`})}}function vt(e){let r=e.name??"dispatch-actuator",c=e.default??null,n=c!=null;return nt({apply:(i,t)=>{let o=Object.hasOwn(e.routes,i.intervention)?e.routes[i.intervention]:c;if(!o)throw new Error(`dispatchActuator: no route for intervention '${i.intervention}'`);return o(i,t)},shouldApply:i=>Object.hasOwn(e.routes,i.intervention)||n,skipDetail:i=>`no route for intervention '${i.intervention}'`,name:r})}function ht(e){let r=e.name??"auto-solidify",c=e.extract??(i=>i.execution.artifact??null),n=e.predicate??(()=>!0);return Ee(i=>{let t=null,o=!1,a=()=>{o||(o=!0,t?.(),t=null)},u=s=>{o||(i.down([[Y,s]]),a())};return t=e.verifyResults.subscribe(s=>{if(!o)for(let l of s){if(o)return;if(l[0]!==V){if(l[0]===X){i.down([[X]]),a();return}continue}let m=l[1];if(m==null||!m.verified)continue;let f;try{f=n(m)}catch(g){u(g);return}if(!f)continue;let y;try{y=c(m)}catch(g){u(g);return}if(y!=null){try{e.write(y,m)}catch(g){u(g);return}i.down([[V,y]])}}}),o&&t&&(t(),t=null),()=>{a()}},{name:r})}function Et(e,r,c,n){return O([e],([i])=>{if(i==null)return;let t=c(i);for(let o of t)r.publish(o)},{name:n?.name??"intake-bridge"})}function xt(e,r,c){let n=c?.defaultSeverity??"medium";return O([e],([i])=>{if(i==null)return;let t=Array.isArray(i)?i:[i];for(let o of t)for(let a of o.tasks)if(!(a.valid&&a.judge_scores?.every(u=>u.pass))){if(!a.valid&&(!a.judge_scores||a.judge_scores.length===0)){r.publish({source:"eval",summary:`Task ${a.task_id} invalid (model: ${o.model})`,evidence:`Run ${o.run_id}: task produced invalid output`,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:n});continue}if(a.judge_scores)for(let u of a.judge_scores)u.pass||r.publish({source:"eval",summary:`${a.task_id}: ${u.claim} (model: ${o.model})`,evidence:u.reasoning,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:n})}},{name:c?.name??"eval-intake-bridge"})}function Rt(e,r){return Ie(e,()=>ke(r()))}function It(e,r){return h([e,r],([c,n])=>{let i=c,t=n,o=new Map(i.tasks.map(f=>[f.task_id,f])),a=new Map(t.tasks.map(f=>[f.task_id,f])),u=new Set([...o.keys(),...a.keys()]),s=[],l=[],m=[];for(let f of u){let y=o.get(f),g=a.get(f),E=y?.valid??!1,N=g?.valid??!1,R=y?.judge_scores?y.judge_scores.filter(_=>_.pass).length:void 0,$=g?.judge_scores?g.judge_scores.filter(_=>_.pass).length:void 0,A=R!==void 0&&$!==void 0?$-R:void 0;s.push({taskId:f,before:E,after:N,scoreDiff:A}),E&&!N&&l.push(f),!E&&N&&m.push(f)}return{newFailures:l,resolved:m,taskDeltas:s,overallImproved:m.length>l.length}},{name:"eval-delta"})}function kt(e,r){let c=r==null?null:Array.isArray(r)?S(r):r,n=[e];return c&&n.push(c),h(n,i=>{let t=i[0],o=c?new Set(i[1]):null,a=new Set;for(let u of t)for(let s of u.affectsEvalTasks??[])(o==null||o.has(s))&&a.add(s);return[...a].sort()},{name:"affected-task-filter"})}function St(e,r,c,n){let i=n?.defaultSeverity??"high";function t(a){let u=[];for(let s of a.lintErrors??[])u.push({source:"code-change",summary:`Lint: ${s.rule} in ${s.file}:${s.line}`,evidence:s.message,affectsAreas:[s.file],severity:i});for(let s of a.testFailures??[])u.push({source:"test",summary:`Test failure: ${s.testId}`,evidence:s.message,affectsAreas:[s.file],affectsEvalTasks:[s.testId],severity:i});return u}let o=c??t;return O([e],([a])=>{if(a!=null)for(let u of o(a))r.publish(u)},{name:n?.name??"code-change-bridge"})}function Nt(e,r,c){return O([e.latest],([n])=>{n!=null&&r(n)},{name:c?.name??"notify-effect"})}var M=["auto-fix","needs-decision","investigation","backlog"],Ae={"auto-fix":{gated:!1},"needs-decision":{gated:!0},investigation:{gated:!0},backlog:{gated:!1}},Z={critical:100,high:70,medium:40,low:10},ee=Math.LN2/(168*3600);function te(e,r){return`${e}\u2192${r}`}var At=/\b(parse|json|config|validation|syntax)\b/i,we=e=>At.test(e.detail)?"self-correctable":"structural",He=`You are a triage classifier for a reactive collaboration harness.
2
+
3
+ Given an intake item, classify it and output JSON:
4
+ {
5
+ "rootCause": "composition" | "missing-fn" | "bad-docs" | "schema-gap" | "regression" | "unknown",
6
+ "intervention": "template" | "catalog-fn" | "docs" | "wrapper" | "schema-change" | "investigate",
7
+ "route": "auto-fix" | "needs-decision" | "investigation" | "backlog",
8
+ "priority": <number 0-100>,
9
+ "triageReasoning": "<one sentence>"
10
+ }
11
+
12
+ Strategy model (past effectiveness):
13
+ {{strategy}}
14
+
15
+ Intake item:
16
+ {{item}}`,Ve=`You are an implementation agent.
17
+
18
+ Given a triaged issue with root cause and intervention type, produce a fix.
19
+
20
+ Issue:
21
+ {{item}}
22
+
23
+ Output JSON:
24
+ {
25
+ "outcome": "success" | "failure" | "partial",
26
+ "detail": "<description of what was done or what failed>"
27
+ }`,Le=`You are a QA reviewer.
28
+
29
+ Given an execution result, verify whether the fix is correct.
30
+
31
+ Execution:
32
+ {{execution}}
33
+
34
+ Original issue:
35
+ {{item}}
36
+
37
+ Output JSON:
38
+ {
39
+ "verified": true/false,
40
+ "findings": ["<finding1>", ...],
41
+ "errorClass": "self-correctable" | "structural" // only if verified=false
42
+ }`;function pe(e,r,c){if(typeof e=="function")return e;let n=e??r;return i=>c(n,i)}function wt(e){let r=Se({name:e?.name??"effectiveness-entries"}),c=h([r.entries],([o])=>new Map(o),{name:`${e?.name??"effectiveness"}-snapshot`,equals:(o,a)=>{let u=o,s=a;if(u.size!==s.size)return!1;for(let[l,m]of u){let f=s.get(l);if(!f||m.attempts!==f.attempts||m.successes!==f.successes)return!1}return!0}});function n(o,a){let u=r.get(o),s=(u?.attempts??0)+1,l=(u?.successes??0)+(a?1:0);r.set(o,{key:o,attempts:s,successes:l,successRate:l/s})}function i(o){return r.get(o)}let t=We(c);return{node:c,record:n,lookup:i,dispose:()=>{t(),r.dispose()}}}function Ct(e){if(typeof e!="object"||e===null)return!1;let r=e;return typeof r.subscribe=="function"&&typeof r.down=="function"&&typeof r.emit=="function"}function ot(e,r){if(e.length===0)return{best:null,bestScore:Number.NEGATIVE_INFINITY};if(e.length===1){let t=qe(r);return{best:e[0],bestScore:t}}if(r.some(t=>typeof t.candidateIndex=="number")){let t=new Array(e.length);for(let u=0;u<e.length;u++)t[u]={sum:0,count:0};for(let u of r){let s=u.candidateIndex;typeof s=="number"&&s>=0&&s<e.length&&(t[s].sum+=u.score,t[s].count+=1)}let o=e[0],a=t[0].count>0?t[0].sum/t[0].count:Number.NEGATIVE_INFINITY;for(let u=1;u<e.length;u++){let s=t[u].count>0?t[u].sum/t[u].count:Number.NEGATIVE_INFINITY;s>a&&(a=s,o=e[u])}return{best:o,bestScore:a}}let n=e[0],i=r[0]?.score??Number.NEGATIVE_INFINITY;for(let t=1;t<e.length;t++){let o=r[t]?.score??Number.NEGATIVE_INFINITY;o>i&&(i=o,n=e[t])}return{best:n,bestScore:i}}function qe(e){if(e.length===0)return Number.NEGATIVE_INFINITY;let r=0;for(let c of e)r+=c.score;return r/e.length}function je(e,r,c,n){let i=n.name??"refine-loop",t=new xe(i,n.graph),o=Ct(n.dataset)?n.dataset:S(n.dataset,{name:"dataset"});t.add(o,{name:"dataset"});let a=S(0,{name:"iteration"});t.add(a,{name:"iteration"});let u=S(c,{name:"strategy",equals:()=>!1});t.add(u,{name:"strategy"});let s=S(null,{name:"lastFeedback"});t.add(s,{name:"lastFeedback"});let l=S([],{name:"prevCandidates"});t.add(l,{name:"prevCandidates"});let m=S(!1,{name:"paused"});t.add(m,{name:"paused"});let f=S("running",{name:"status"});t.add(f,{name:"status"});let y=S([],{name:"history",equals:()=>!1});t.add(y,{name:"history"});let g=S(null,{name:"best"});t.add(g,{name:"best"});let E=S(Number.NEGATIVE_INFINITY,{name:"score"});t.add(E,{name:"score"});let N=S(0,{name:"budget-used"});t.add(N,{name:"budget-used"});let R=Ne("stages");t.mount("stages",R);let $=R.topic("generate"),A=R.topic("evaluate"),_=R.topic("analyze"),ye=R.topic("decide"),L=c,U=null,re=[];t.addDisposer(u.subscribe(b=>{for(let T of b)T[0]===V&&(L=T[1])})),t.addDisposer(s.subscribe(b=>{for(let T of b)T[0]===V&&(U=T[1])})),t.addDisposer(l.subscribe(b=>{for(let T of b)T[0]===V&&(re=T[1])}));let G=Ie(a,b=>{let T=L,C=b===0||U==null;return Be([],(w,P)=>{let v=!1;try{let d=C?T.seed(e):T.generate(U,re);if(d instanceof Promise)return d.then(p=>{v||P.emit(p)},p=>{v||P.down([[Y,p]])}),()=>{v=!0};P.emit(d)}catch(d){v=!0,P.down([[Y,d]])}},{describeKind:"producer"})},{name:"candidates"});t.add(G,{name:"candidates"});let ne=O([G],(b,T,C)=>{let w=C.terminalDeps[0];w!==void 0&&w!==!0&&f.emit("errored")},{name:"error-watcher",errorWhenDepsError:!1});t.add(ne,{name:"error-watcher"}),t.addDisposer(ne.subscribe(()=>{}));let Q=h([G,a],([b,T])=>({iteration:T,candidates:b,timestamp_ns:H()}),{name:"generate-event"});t.add(Q,{name:"generate-event"}),t.addDisposer(Q.subscribe(()=>{}));let B=O([Q],([b])=>{$.publish(b)},{name:"generate-publish"});t.add(B,{name:"generate-publish"}),t.addDisposer(B.subscribe(()=>{}));let oe=O([G],([b])=>{l.emit(b)},{name:"generate-mirror"});t.add(oe,{name:"generate-mirror"}),t.addDisposer(oe.subscribe(()=>{}));let z=r(G,o);t.add(z,{name:"scores"});let ae=h([z,G,a],([b,T,C])=>({iteration:C,candidates:T,scores:b,timestamp_ns:H()}),{name:"evaluate-event"});t.add(ae,{name:"evaluate-event"}),t.addDisposer(ae.subscribe(()=>{}));let ge=O([ae],([b])=>{A.publish(b)},{name:"evaluate-publish"});t.add(ge,{name:"evaluate-publish"}),t.addDisposer(ge.subscribe(()=>{}));let se=h([z,G],([b,T])=>L.analyze(b,T),{name:"feedback"});t.add(se,{name:"feedback"});let q=h([se,G,a],([b,T,C])=>({iteration:C,candidates:T,feedback:b,timestamp_ns:H()}),{name:"analyze-event"});t.add(q,{name:"analyze-event"}),t.addDisposer(q.subscribe(()=>{}));let ie=O([q],([b])=>{_.publish(b)},{name:"analyze-publish"});t.add(ie,{name:"analyze-publish"}),t.addDisposer(ie.subscribe(()=>{}));let ue=h([y],([b])=>{let T=b;if(n.patience==null||T.length<=n.patience)return!1;let C=T.slice(-(n.patience+1)),w=C[0].bestScore;return C.slice(1).every(P=>P.bestScore<=w)},{name:"patience-check"});t.add(ue,{name:"patience-check"});let K=h([E],([b])=>n.minScore!=null&&b>=n.minScore,{name:"min-score-check"});t.add(K,{name:"min-score-check"});let ce=h([y],([b])=>{let T=b;if(n.minDelta==null||T.length<2)return!1;let C=T[T.length-2].bestScore,w=T[T.length-1].bestScore;return Math.abs(w-C)<n.minDelta},{name:"min-delta-check"});t.add(ce,{name:"min-delta-check"});let le=h([N],([b])=>n.maxEvaluations!=null&&b>=n.maxEvaluations,{name:"max-evaluations-check"});t.add(le,{name:"max-evaluations-check"});let W=h([a],([b])=>n.maxIterations!=null&&b>=n.maxIterations,{name:"max-iterations-check"});t.add(W,{name:"max-iterations-check"});let de=h([N],([b])=>n.budget!=null&&b>=n.budget,{name:"budget-exhausted-check"});t.add(de,{name:"budget-exhausted-check"}),t.addDisposer(ue.subscribe(()=>{})),t.addDisposer(K.subscribe(()=>{})),t.addDisposer(ce.subscribe(()=>{})),t.addDisposer(le.subscribe(()=>{})),t.addDisposer(W.subscribe(()=>{})),t.addDisposer(de.subscribe(()=>{}));let be=h([ue,K,ce,le,W],([b,T,C,w,P])=>b?{converged:!0,reason:"patience"}:T?{converged:!0,reason:"min-score"}:C?{converged:!0,reason:"min-delta"}:w?{converged:!0,reason:"max-evaluations"}:P?{converged:!0,reason:"max-iterations"}:{converged:!1},{name:"converged"});t.add(be,{name:"converged"}),t.addDisposer(be.subscribe(()=>{}));let Te=-1,ve=O([se,z,G],([b,T,C])=>{let w=a.cache,P=b,v=C,d=T;if(w<=Te)return;Te=w;let{best:p,bestScore:x}=ot(v,d),I=y.cache,j={n:w,candidates:v,scores:d,feedback:P,best:p,bestScore:x,timestamp_ns:H()},F=[...I,j],J=N.cache+v.length,k="continue",D,Pe=n.budget!=null&&J>=n.budget,Fe=m.cache;if(Pe)k="budget",D="budget";else if(n.minScore!=null&&P.score>=n.minScore)k="converged",D="min-score";else if(n.maxIterations!=null&&w>=n.maxIterations)k="converged",D="max-iterations";else if(n.maxEvaluations!=null&&J>=n.maxEvaluations)k="converged",D="max-evaluations";else if(n.minDelta!=null&&F.length>=2){let he=F[F.length-2].bestScore,Oe=F[F.length-1].bestScore;Math.abs(Oe-he)<n.minDelta&&(k="converged",D="min-delta")}else if(n.patience!=null&&F.length>n.patience){let he=F.slice(-(n.patience+1)),Oe=he[0].bestScore;he.slice(1).every(mt=>mt.bestScore<=Oe)&&(k="converged",D="patience")}k==="continue"&&Fe&&(k="paused"),fe(()=>{g.emit(p),E.emit(P.score),y.emit(F),N.emit(J),s.emit(P),ye.publish({iteration:w,decision:k,reason:D,timestamp_ns:H()}),k==="continue"?a.emit(w+1):f.emit(k==="converged"?"converged":k==="budget"?"budget":"paused")})},{name:"decide-bridge"});return t.add(ve,{name:"decide-bridge"}),t.addDisposer(ve.subscribe(()=>{})),Object.assign(t,{best:g,score:E,status:f,history:y,strategy:u,iteration:a,generate:$,evaluate:A,analyze:_,decide:ye,setStrategy(b){u.emit(b)},pause(){m.emit(!0)},resume(){f.cache==="paused"&&fe(()=>{m.emit(!1),f.emit("running"),a.emit(a.cache+1)})}})}function Pt(e){let r=e.width??4;return{name:e.name??"blindVariation",seed(n){return[n]},analyze(n,i){let t=qe(n),o=null;for(let a of n)(!o||a.score<o.score)&&(o=a);return{summary:`blindVariation iteration: mean=${t.toFixed(3)}, n=${n.length}`,score:t,weakTasks:o?[o.taskId]:[]}},async generate(n,i){if(i.length===0)throw new Error("blindVariation.generate: empty candidate batch \u2014 cannot derive prior for teacher");let t=i[i.length-1],o=0,u={prior:t,reportCost:s=>{o+=s}};try{if(e.parallel!==!1)return await Promise.all(Array.from({length:r},()=>e.teacher(u)));let s=[];for(let l=0;l<r;l++)s.push(await e.teacher(u));return s}finally{if(e.tokens!=null&&o>0){let s=e.tokens.cache??0;e.tokens.emit(s+o)}}}}}function Ft(e){return typeof e=="object"&&e!==null&&e.kind==="errorCritique"}function Ot(e,r){return e.length===0?`No task scored below the batch mean (${r.score.toFixed(3)}). Reinforce the current direction.`:`Failures below threshold:
43
+ ${e.map(n=>{let i=n.error!=null?` | error: ${n.error}`:"";return`- ${n.taskId} (score=${n.score.toFixed(3)})${i}`}).join(`
44
+ `)}`}function Dt(e){let r=e.width??4,c=e.name??"errorCritique",n=e.maxFailureSamples??5,i=e.formatCritique??Ot;return{name:c,seed(t){return[t]},analyze(t,o){let a=qe(t),u=typeof e.failureThreshold=="function"?e.failureThreshold(t):e.failureThreshold,s=u===void 0&&!Number.isFinite(a),l=u??a,m=s?[...t].sort((A,_)=>A.score-_.score):t.filter(A=>A.score<l).slice().sort((A,_)=>A.score-_.score),f=m.slice(0,n),{best:y,bestScore:g}=ot(o,t),E={summary:"",score:a,weakTasks:f.map(A=>A.taskId)},N=i(f,E),R={kind:"errorCritique",best:y,failures:f,critiqueText:N},$=m.length>f.length?` (top ${f.length} retained)`:"";return{summary:`errorCritique iteration: mean=${a.toFixed(3)}, failures=${m.length}${$}/${t.length}, bestScore=${g.toFixed(3)}`,critique:R,weakTasks:f.map(A=>A.taskId),score:a}},async generate(t,o){if(o.length===0)throw new Error("errorCritique.generate: empty candidate batch \u2014 cannot derive prior for teacher");let a=Ft(t.critique)?t.critique:void 0,u=a!==void 0?a.best:o[o.length-1],s=a?.critiqueText??t.summary,l=a?.failures??[],m=0,y={prior:u,critique:s,failures:l,reportCost:g=>{m+=g}};try{if(e.parallel!==!1)return await Promise.all(Array.from({length:r},()=>e.teacher(y)));let g=[];for(let E=0;E<r;E++)g.push(await e.teacher(y));return g}finally{if(e.tokens!=null&&m>0){let g=e.tokens.cache??0;e.tokens.emit(g+m)}}}}}function _t(e){let{best:r,score:c,status:n}=e,i=Number.isFinite(c)?c.toFixed(3):String(c),t=r??void 0;return n==="converged"?{outcome:"success",detail:`refineLoop converged at score ${i}`,artifact:t}:n==="budget"?{outcome:"partial",detail:`refineLoop hit budget at score ${i}`,artifact:t}:{outcome:"failure",detail:`refineLoop errored (status=${n})`,artifact:t}}function Je(e){let r=e.name??"refine-executor",c=e.toOutput??_t;return n=>{let i=n.payload.item,t=je(e.seedFrom(i),e.evaluator,e.strategy,{...e.refine,dataset:e.datasetFor(i),name:`${r}/inner`}),o=h([t.status,t.best,t.score],([a,u,s])=>{let l=a;if(l!=="converged"&&l!=="budget"&&l!=="errored")return null;let m=c({best:u,score:s,status:l});return{...n.payload,execution:{item:i,...m}}},{name:`${r}/output`});return Re(o,a=>a!=null,{name:`${r}/gate-out`})}}function $t(e){if(e.length===0)return Number.NEGATIVE_INFINITY;let r=0;for(let c of e)r+=c.score;return r/e.length}function Mt(e){let{passCount:r,total:c,meanScore:n,threshold:i,missingArtifact:t}=e,o=Number.isFinite(n)?n.toFixed(3):String(n),a=!t&&c>0&&n>=i,u=t?["EXECUTE stage did not emit an artifact; cannot verify reactively"]:a?[`${r}/${c} eval tasks passed; mean score ${o} \u2265 ${i}`]:c===0?["No eval tasks were selected for this item \u2014 cannot verify"]:[`${r}/${c} eval tasks passed; mean score ${o} < threshold ${i}`];return a?{verified:!0,findings:u}:{verified:!1,findings:u,errorClass:"structural"}}function Gt(e){return e.artifact??null}function at(e){let r=e.name??"eval-verifier",c=e.threshold??.5,n=e.toOutput??Mt,i=e.extractArtifact??Gt;return t=>{let{item:o,execution:a}=t.payload;if(a==null)return{...t.payload,verify:{verified:!1,findings:["evalVerifier: prior execute stage produced no execution"],errorClass:"structural"}};let u=i(a,o);if(u==null)return{...t.payload,verify:n({scores:[],meanScore:Number.NEGATIVE_INFINITY,passCount:0,total:0,threshold:c,missingArtifact:!0})};let s=S([u],{name:`${r}/candidates`}),l=S(e.datasetFor(o),{name:`${r}/dataset`}),m;fe(()=>{m=e.evaluator(s,l)});let f=h([m],([y])=>{let g=y;if(g==null)return null;let E=$t(g),N=g.filter(R=>R.score>=c).length;return{...t.payload,verify:n({scores:g,meanScore:E,passCount:N,total:g.length,threshold:c})}},{name:`${r}/output`});return Re(f,y=>y!=null,{name:`${r}/gate-out`})}}function Ht(e){let r=e.name??"harness-pair",c=Je({name:`${r}-exec`,seedFrom:e.seedFrom,evaluator:e.evaluator,strategy:e.strategy,datasetFor:e.datasetFor,refine:e.refine}),n=at({name:`${r}-verify`,evaluator:e.evaluator,datasetFor:e.datasetFor,threshold:e.threshold});return{executor:c,verifier:n}}function Qe(){let e=Se({name:"strategy-entries"}),r=h([e.entries],([o])=>{let a=o;return new Map(a)},{name:"strategy-model",equals:(o,a)=>{let u=o,s=a;if(u.size!==s.size)return!1;for(let[l,m]of u){let f=s.get(l);if(!f||m.attempts!==f.attempts||m.successes!==f.successes)return!1}return!0}});function c(o,a,u){let s=te(o,a),l=e.get(s),m=(l?.attempts??0)+1,f=(l?.successes??0)+(u?1:0);e.set(s,{rootCause:o,intervention:a,attempts:m,successes:f,successRate:f/m})}function n(o,a){return e.get(te(o,a))}let i=r.subscribe(()=>{});function t(){i()}return{node:r,record:c,lookup:n,dispose:t}}function Vt(e,r,c,n,i){let t={...Z,...i?.severityWeights},o=i?.decayRate??ee,a=i?.effectivenessThreshold??.7,u=i?.effectivenessBoost??15,s=[e,r,c];return n&&s.push(n),h(s,l=>{let m=l[0],f=l[1],y=l[2],g=n?l[3]:0,E=t[m.severity??"medium"],N=(H()-y)/1e9,R=Xe(E,N,o,0),$=te(m.rootCause,m.intervention),A=f.get($);return A&&A.successRate>=a&&(R+=u),R+=g*20,R},{name:"priority-score"})}var st="intake",Lt="triage-output",it="retry",ut="verify-results",ct="__unrouted";function lt(e,r){let c=pe(r,Ve,(n,i)=>n.replace("{{item}}",JSON.stringify(i)));return n=>{let i=n.payload.item,t=[{role:"user",content:c(i)}],o=u=>({...n.payload,execution:{item:i,outcome:"failure",detail:u}}),a=u=>u instanceof Error?u.message:String(u);return Me(e,t,{onSuccess:u=>{let s;try{s=JSON.parse($e(String(u.content)))}catch(m){return o(`execute parse error: ${a(m)}`)}if(s==null||typeof s!="object"||Array.isArray(s))return o(`execute parse error: non-object response: ${JSON.stringify(s)}`);let l=s;return{...n.payload,execution:{item:i,outcome:l.outcome??"failure",detail:l.detail??"unknown",artifact:l.artifact}}},onFailure:(u,s)=>o(u==="complete"?"adapter completed without emitting DATA":`executor failed: ${a(s)}`)})}}function dt(e,r){let c=pe(r,Le,(n,i)=>{let[t,o]=i;return n.replace("{{execution}}",JSON.stringify(t)).replace("{{item}}",JSON.stringify(o))});return n=>{let{item:i,execution:t}=n.payload;if(t==null)return{...n.payload,verify:{verified:!1,findings:["verifier: prior execute stage produced no execution"],errorClass:"structural"}};let o=[{role:"user",content:c([t,i])}],a=s=>({...n.payload,verify:{verified:!1,findings:[s],errorClass:"self-correctable"}}),u=s=>s instanceof Error?s.message:String(s);return Me(e,o,{onSuccess:s=>{let l;try{l=JSON.parse($e(String(s.content)))}catch(f){return a(`verify parse error: ${u(f)}`)}if(l==null||typeof l!="object"||Array.isArray(l))return a(`verify parse error: non-object response: ${JSON.stringify(l)}`);let m=l;return{...n.payload,verify:{verified:m.verified===!0,findings:m.findings??[],errorClass:m.errorClass}}},onFailure:(s,l)=>a(s==="complete"?"verifier completed without emitting DATA":`verifier failed: ${u(l)}`)})}}var Ce=class extends xe{queues;executeFlow;jobs;gates;queueTopics;strategy;totalRetries;totalReingestions;priorityScores;constructor(r,c,n,i,t,o,a,u,s,l){super(r),this.queues=c,this.executeFlow=n,this.queueTopics=i,this.jobs=t,this.gates=o,this.strategy=a,this.totalRetries=u,this.totalReingestions=s,this.priorityScores=l}get intake(){return this.queues.topic(st)}get verifyResults(){return this.queues.topic(ut)}get retry(){return this.queues.topic(it)}get unrouted(){return this.queues.topic(ct)}stageNodes(){let r=this.queues,c=o=>r.has(o)?`queues::${o}::latest`:null,n=o=>o==null?[]:[o],i=M.flatMap(o=>n(c(o))),t=[];for(let[o]of this.gates)t.push(`gates::${o}/gate`);return[{label:"INTAKE",paths:n(c("intake"))},{label:"TRIAGE",paths:["triage"]},{label:"QUEUE",paths:i},{label:"GATE",paths:t},{label:"EXECUTE",paths:["executeFlow::execute::events"]},{label:"VERIFY",paths:["executeFlow::verify::events"]},{label:"REFLECT",paths:["reflect"]},{label:"STRATEGY",paths:["strategy"]}]}};function qt(e,r){let c=r.adapter,n=r.maxRetries??2,i=r.retainedLimit??1e3,t=r.errorClassifier??we,o=new Map;for(let d of M)o.set(d,{...Ae[d],...r.queues?.[d]});let a=Ne(`${e}/queues`,{defaultTopicOptions:{retainedLimit:i}}),u=a.topic(st),s=a.topic(Lt),l=a.topic(it),m=a.topic(ut),f=new Map;for(let d of M)f.set(d,a.topic(d));let y=a.topic(ct),g=Qe(),E=De(u.latest,g.node),N=pe(r.triagePrompt,He,(d,p)=>{let[x,I]=p;return d.replace("{{strategy}}",JSON.stringify(Array.from(I.entries()))).replace("{{item}}",JSON.stringify(x))}),R=Ze(c,[E],d=>{let p=d;return!p||!p[0]?"":N(p)},{name:"triage",format:"json"}),$=De(R,E),_=O([$],([d])=>{if(d==null)return;let[p,x]=d;if(!p?.route)return;let I=x?.[0],j={...p,...I};s.publish(j)}).subscribe(()=>{}),ye=new Set(M);for(let d of M)Ge(`bridge/${d}`,s,f.get(d),{map:p=>p.route===d?p:void 0});Ge("bridge/__unrouted",s,y,{map:d=>ye.has(d.route)?void 0:d});let L=new Map,U=new Map;for(let d of M)L.set(d,tt(`jobs/${d}`));let re=[];for(let d of M){let p=f.get(d),x=L.get(d),I=new WeakSet,j=O([p.events],([F])=>{let J=F??[];for(let k of J){if(I.has(k))continue;I.add(k);let D=x.enqueue(k);U.set(me(k),{route:d,id:D})}},{name:`jobs/${d}-mirror`});re.push(j.subscribe(()=>{}))}function G(d){let p=me(d),x=U.get(p);x&&(L.get(x.route)?.removeById(x.id),U.delete(p))}let ne=et("gates"),Q=new Map;for(let d of M){let p=o.get(d);if(!p.gated)continue;let x=f.get(d),I=ne.approvalGate(`${d}/gate`,x.latest,{maxPending:p.maxPending,startOpen:p.startOpen});Q.set(d,I)}let B=[];for(let d of M)o.get(d).gated&&Q.has(d)?B.push(Q.get(d).node):B.push(f.get(d).latest);B.push(l.latest);let oe=Ke(...B),z=r.executor??lt(c,r.executePrompt),ae=r.verifier??dt(c,r.verifyPrompt),ge=r.executeMaxPerPump??Number.MAX_SAFE_INTEGER,se=r.verifyMaxPerPump??Number.MAX_SAFE_INTEGER,q=rt(`${e}/executeFlow`,{stages:[{name:"execute",work:d=>z(d),maxPerPump:ge},{name:"verify",work:d=>ae(d),maxPerPump:se}]}),ie=O([oe],([d])=>{d!=null&&q.enqueue({item:d})},{name:"execute-enqueue"}),ue=ie.subscribe(()=>{}),K=r.maxReingestions??1,ce=Math.min(r.maxTotalRetries??n*10,100),le=Math.min(r.maxTotalReingestions??K*10,100),W=S(0),de=S(0);function be(d,p,x){return{item:x,execution:d,verified:p.verified,findings:p.findings??[],errorClass:p.errorClass}}function Te(d,p){g.record(p.rootCause,p.intervention,!0),m.publish(d),G(p)}function ve(d,p){let x=me(p),I=p.$retries??0,j={...p,$retries:I+1,summary:`[RETRY ${I+1}/${n}] ${x} \u2014 Previous attempt failed: ${d.findings.join("; ")}`,relatedTo:[x]};l.publish(j)}function Ue(d,p){g.record(p.rootCause,p.intervention,!1),m.publish(d),G(p);let x=me(p),I=p.$reingestions??0;I<K&&_e(de,le)&&u.publish({source:p.source,summary:`Verification failed for: ${x}`,evidence:d.findings.join(`
45
+ `),affectsAreas:p.affectsAreas,affectsEvalTasks:p.affectsEvalTasks,severity:p.severity??"high",relatedTo:[x],$reingestions:I+1})}let b=0,T=O([q.completed],([d])=>{let p=d??[];b>p.length&&(b=p.length);let x=b;b=p.length;for(let I=x;I<p.length;I++){let j=p[I],{item:F,execution:J,verify:k}=j.payload;if(J==null||k==null){G(F);continue}let D=be(J,k,F);if(D.verified){Te(D,F);continue}let Pe=D.errorClass??t({item:F,outcome:J.outcome,detail:D.findings.join("; ")}),Fe=F.$retries??0;Pe==="self-correctable"&&Fe<n&&_e(W,ce)?ve(D,F):Ue(D,F)}},{name:"verify-dispatch"}),C=T.subscribe(()=>{}),w=h([q.completed],()=>null,{name:"reflect",equals:()=>!1}),P;r.priority&&(P=jt(f,g,r));let v=new Ce(e,a,q,f,L,Q,g,W,de,P);v.addDisposer(_),v.addDisposer(ue),v.addDisposer(C),v.addDisposer(g.dispose);for(let d of re)v.addDisposer(d);if(v.add(E,{name:"triage-input"}),v.add(R,{name:"triage"}),v.add($,{name:"router-input"}),v.add(oe,{name:"execute-input"}),v.add(ie,{name:"execute-enqueue"}),v.add(T,{name:"verify-dispatch"}),v.add(w,{name:"reflect"}),v.add(g.node,{name:"strategy"}),v.addDisposer(w.subscribe(()=>{})),P)for(let[d,p]of P)v.add(p,{name:`priority/${d}`}),v.addDisposer(p.subscribe(()=>{}));v.mount("queues",a),v.mount("gates",ne),v.mount("executeFlow",q);for(let[d,p]of L)v.mount(`jobs/${d}`,p);return v.tagFactory("harnessLoop",Ye(r)),v}function jt(e,r,c){if(!c.lastInteractionNs)throw new Error("harnessLoop: `opts.priority` requires `opts.lastInteractionNs` \u2014 pass a Node<number> (e.g. `fromTimer(60_000)` or a `state(monotonicNs())` you bump on human interaction). Priority scores only decay when this node settles; an internal default would freeze age at construction time.");let n=c.lastInteractionNs,i=c.priority??{},t={...Z,...i.severityWeights},o=i.decayRate??ee,a=i.effectivenessThreshold??.7,u=i.effectivenessBoost??15,s=new Map;for(let[l,m]of e){let f=h([m.latest,r.node,n],y=>{let g=y[0];if(g==null)return 0;let E=t[g.severity??"medium"]??40,N=(H()-y[2])/1e9,R=E*Math.exp(-o*Math.max(0,N)),$=`${g.rootCause}\u2192${g.intervention}`,_=y[1]?.get($);return _&&_.successRate>=a&&(R+=u),R},{name:`priority/${l}`});s.set(l,f)}return s}function Jt(e,r){let c=ze(e,r),n={};for(let i of M){let t=e.queues.has(i)?e.queues.topic(i):null;n[i]=t?.retained().length??0}return{...c,queueDepths:n,strategyEntries:e.strategy.node.cache?.size??0,totalRetries:e.totalRetries.cache??0,totalReingestions:e.totalReingestions.cache??0}}function Qt(e){let r={};for(let{label:c,paths:n}of e.stageNodes())for(let i of n)r[i]=c;return r}function Ut(e,r){let c=r?.logger===null?null:r?.logger??console.log,n=r?.detail??"summary",i=H(),t=[],o=[],a=Qt(e);function u(){return(H()-i)/1e9}function s(l,m,f){let y={elapsed:u(),stage:l,type:m};n!=="summary"&&(y.summary=Bt(f)),n==="full"&&(y.data=f),o.push(y)}for(let[l,m]of Object.entries(a))try{let f=e.observe(l,{format:"stage-log",stageLabels:a,logger:c?y=>c(y):()=>{},includeTypes:["data","error","complete"]});f.onEvent(y=>{y.type==="data"?s(m,"data",y.data):y.type==="error"?s(m,"error",y.data):y.type==="complete"&&s(m,"complete",void 0)}),t.push(f)}catch(f){let y=f instanceof Error?f.message:String(f);s(m,"error",`observe-unavailable: ${l} \u2014 ${y}`),c&&c(`[${u().toFixed(3)}s] ${m.padEnd(9)} \u2717 observe-unavailable: ${y}`)}return{get events(){return o},dispose(){for(let l of t)l.dispose();t.length=0}}}function Bt(e){if(e==null)return"null";if(typeof e=="string")return ft(e,80);if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);try{let r=JSON.stringify(e);return ft(r,120)}catch{return String(e)}}function ft(e,r){return e.length>r?`${e.slice(0,r-1)}\u2026`:e}export{nt as a,vt as b,ht as c,Et as d,xt as e,Rt as f,It as g,kt as h,St as i,Nt as j,M as k,Ae as l,Z as m,ee as n,te as o,we as p,He as q,Ve as r,Le as s,pe as t,wt as u,je as v,Pt as w,Dt as x,Je as y,at as z,Ht as A,Qe as B,Vt as C,lt as D,dt as E,Ce as F,qt as G,Jt as H,Ut as I,Yt as J};
@@ -0,0 +1 @@
1
+ import{c as O,f as V,h as j}from"./chunk-3ZZX7M25.js";import{f as B,m as K}from"./chunk-2K5RXLAH.js";import{p as N}from"./chunk-LYCLF26R.js";import{b as M,i as L,j as $}from"./chunk-CK2E7BTU.js";import{b as J}from"./chunk-QYADASLV.js";var G={};J(G,{processInstanceKeyOf:()=>X,processManager:()=>Z});var X=i=>i.correlationId;function D(i){if(i==null)return Promise.resolve(void 0);let p=K(i);return new Promise((s,v)=>{let c=!1,m,r=()=>{m&&m()};m=p.subscribe(a=>{if(!c)for(let o of a){if(o[0]===M){c=!0,Promise.resolve().then(r),s(o[1]);return}if(o[0]===$){c=!0,Promise.resolve().then(r),v(o[1]);return}if(o[0]===L){c=!0,Promise.resolve().then(r),s(void 0);return}}})})}async function Y(i,p,s,v,c){let m;for(let r=0;r<=v;r++){if(r>0){let a=c[Math.min(r-1,c.length-1)]??0;a>0&&await new Promise(o=>setTimeout(o,a))}try{return await D(i(p,s))}catch(a){m=a}}return{outcome:"failure",error:m}}function Z(i,p,s){let v=s.retryMax??0,c=s.backoffMs??[0],m=1024,r=new Map,a=new Set,o=new Map,b=`${p}_process_instances`,C=`${p}_process_seq`;if(i.tryResolve(b)!==void 0||i.tryResolve(C)!==void 0)throw new Error(`processManager: name "${p}" is already in use on this CQRS graph (collides on "${b}" / "${C}"). Pick a different name or destroy the previous CQRS graph before re-creating the manager.`);let R=O({name:b,retainedLimit:m,graph:i}),Q=j(i,C,0),y=V(()=>{},{audit:R,seq:Q,freeze:!0,...s.handlerVersion!==void 0?{handlerVersion:s.handlerVersion}:{},onSuccess:([e,t,n,d],g,{t_ns:u,seq:f})=>({correlationId:e,state:t,status:n,startedAt:o.get(e)??u,updatedAt:u,t_ns:u,seq:f??0,...d!==void 0?{reason:d}:{}})}),_=`_process_${p}_started`;i.event(_),s.persistence?.eventStorage&&i.attachEventStorage(s.persistence.eventStorage);async function k(e,t,n,d){if(a.delete(e),r.delete(e),o.delete(e),s.compensate)try{await D(s.compensate(t,n)),y(e,t,"compensated",d)}catch{y(e,t,"errored",void 0)}else y(e,t,"errored",void 0)}async function z(e,t){if(a.has(e)){if(t.outcome==="failure"){let n=r.get(e)??s.initial;await k(e,n,t.error);return}if(t.outcome==="success"){if(r.set(e,t.state),t.emit)for(let n of t.emit)try{i._appendEvent(n.type,n.payload,{correlationId:e,aggregateId:e})}catch{}if(y(e,t.state,"running",void 0),s.isTerminal?.(t.state)){a.delete(e),r.delete(e),o.delete(e),y(e,t.state,"terminated",void 0);return}if(t.schedule){let{afterMs:n,eventType:d}=t.schedule,g,u=B(n),f=l=>{for(let T of l)if(T[0]===M){if(g?g():queueMicrotask(()=>g?.()),!a.has(e))return;let h=r.get(e);if(h===void 0)return;let S=s.steps[d];if(!S)return;let w={type:d,payload:null,timestampNs:N(),seq:Number.NaN,correlationId:e,aggregateId:e};q(e,S,h,w)}};g=u.subscribe(f)}return}if(t.outcome==="terminate"){if(r.set(e,t.state),t.emit)for(let n of t.emit)try{i._appendEvent(n.type,n.payload,{correlationId:e,aggregateId:e})}catch{}a.delete(e),r.delete(e),o.delete(e),y(e,t.state,"terminated",void 0)}}}let E=new Map;function q(e,t,n,d){let u=(E.get(e)??Promise.resolve()).then(async()=>{let f=r.get(e);if(f===void 0||!a.has(e))return;let l;try{l=await Y(t,f,d,v,c)}catch(T){await k(e,r.get(e)??s.initial,T);return}await z(e,l)});E.set(e,u),u.finally(()=>{E.get(e)===u&&E.delete(e)})}let P=!1,x=[];for(let e of s.watching){let t=i.event(e),n=0;n=(t.cache??[]).length;let g=t.subscribe(u=>{for(let f of u){if(f[0]!==M)continue;let l=f[1];if(l.length<=n)continue;let T=l.slice(n);n=l.length;for(let h of T){let S=h.correlationId;if(S===void 0||!a.has(S))continue;let w=s.steps[e];if(!w)continue;let A=r.get(S);A!==void 0&&q(S,w,A,h)}}});x.push(g)}function F(e,t){if(P||a.has(e))return;let n=N();o.set(e,n),r.set(e,s.initial),a.add(e);try{i._appendEvent(_,t??null,{correlationId:e,aggregateId:e})}catch{}y(e,s.initial,"running",void 0)}function U(e,t){if(P||!a.has(e))return;let n=r.get(e)??s.initial;k(e,n,new Error(`cancelled: ${t??"no reason given"}`),t)}function W(e){return r.get(e)}function H(){if(!P){P=!0;for(let e of x)try{e()}catch{}x.length=0}}return{instances:R,audit:R,start:F,cancel:U,getState:W,dispose:H}}export{X as a,Z as b,G as c};
@@ -0,0 +1 @@
1
+ import{b as y}from"./chunk-LDQ3IUIP.js";import{j as x}from"./chunk-ACMJ2ZPS.js";import{E as f,m as A,p as T,t as b}from"./chunk-LYCLF26R.js";import{b as R,c as m}from"./chunk-CK2E7BTU.js";function S(r,e){let t=r.cache??0;return t>=e?!1:(r.down([[m],[R,t+1]]),!0)}var M=b((r,e)=>{r("observe"),r("signal"),e("write")});function q(r){let e=y([],{name:r.name,maxSize:r.retainedLimit??1024,guard:r.guard??M,...r.versioning!=null?{versioning:r.versioning}:{}});return e.withLatest(),r.graph&&r.graph.add(e.entries,{name:r.name}),e}function p(r){if(r===null||typeof r!="object"||Object.isFrozen(r))return r;for(let e of Object.keys(r))p(r[e]);return Object.freeze(r)}function w(r){let e=r.cache,o=(typeof e=="number"&&Number.isFinite(e)?e:0)+1;return r.down([[m],[R,o]]),o}function g(r,e,t,o,a,s){let u=e(t,o,a);if(u===void 0)return;let i=s!=null?{...u,handlerVersion:s}:u;r.append(i)}function z(r,e){let t=e.freeze??!0;return function(...a){let s=t?a.map(p):a,u=T(),i=e.seq?w(e.seq):void 0;try{let n=r(...s);return e.audit&&e.onSuccess&&g(e.audit,e.onSuccess,s,n,{t_ns:u,seq:i},e.handlerVersion),n}catch(n){if(e.audit&&e.onFailure){let d=n instanceof Error?n.name:typeof n;g(e.audit,e.onFailure,s,n,{t_ns:u,seq:i,errorType:d},e.handlerVersion)}throw n}}}function G(r,e){let t=e.freeze??!0;return function(...a){let s=t?a.map(p):a,u=T(),i,n,d=!1,l;try{A(()=>{e.seq&&(l=w(e.seq));try{i=r(...s),e.audit&&e.onSuccess&&g(e.audit,e.onSuccess,s,i,{t_ns:u,seq:l},e.handlerVersion)}catch(c){throw n=c,d=!0,c}})}catch(c){if(d&&e.audit&&e.onFailure){let h=n instanceof Error?n.name:typeof n;g(e.audit,e.onFailure,s,n,{t_ns:u,seq:l,errorType:h},e.handlerVersion)}throw d?n:c}return i}}function V(r,e,t=0){let o=f(t,{name:e,describeKind:"state"});return r.add(o,{name:e}),o}function _(r,e,t,o=0){let a={},s=new x(e);for(let u of t){let i=f(o,{name:u,describeKind:"state"});s.add(i,{name:u}),a[u]=i}return r.mount(e,s),a}export{S as a,M as b,q as c,w as d,g as e,z as f,G as g,V as h,_ as i};
@@ -0,0 +1 @@
1
+ import{f as b}from"./chunk-3ZZX7M25.js";import{a as S}from"./chunk-L6NSJVJZ.js";import{b as D}from"./chunk-LDQ3IUIP.js";import{j as T}from"./chunk-ACMJ2ZPS.js";import{C as d}from"./chunk-2K5RXLAH.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 +1 @@
1
- import{b as v}from"./chunk-KRH66M4O.js";import{i as y}from"./chunk-CLD3F4R5.js";import{G as x}from"./chunk-X7QKTXXC.js";import{d as S}from"./chunk-VJLMUKOI.js";import{d as O}from"./chunk-VIMF6LGM.js";import{d as k}from"./chunk-6QZNQS5B.js";import{d as A}from"./chunk-GPW2V3RE.js";import{b as N}from"./chunk-CGNOWGV6.js";import{E as b,J as g,m as _}from"./chunk-LYCLF26R.js";import{b as a,c as p,i as h,j as m}from"./chunk-CK2E7BTU.js";import{b as f}from"./chunk-QYADASLV.js";var j={};f(j,{jotai:()=>v,nanostores:()=>y,nestjs:()=>x,react:()=>S,signals:()=>T,solid:()=>O,svelte:()=>k,vue:()=>A,zustand:()=>N});var T={};f(T,{Signal:()=>q});var s=[];function i(n){let e=n.cache;return n.subscribe(o=>{for(let[d,r]of o)d===a&&(e=r)})(),e}var u=class{_node;_equals;constructor(e,t){this._equals=t?.equals??Object.is,this._node=b(e,{...t,resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}set(e){this._equals(this.get(),e)||_(()=>{this._node.down([[p],[a,e]])})}},l=class{_node;constructor(e,t){this._node=g(o=>{s.push(o);try{return e()}finally{s.pop()}},{...t,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}},q={State:u,Computed:l,sub:(n,e)=>{let t=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,o=!0;return n._node.subscribe(d=>{for(let[r,c]of d){if(r===a){if(o){o=!1;continue}t.data?.(c)}r===m&&t.error?.(c),r===h&&t.complete?.()}})}};export{T as a,j as b};
1
+ import{b as v}from"./chunk-KRH66M4O.js";import{i as y}from"./chunk-CLD3F4R5.js";import{G as x}from"./chunk-NWXQIOIB.js";import{d as S}from"./chunk-VJLMUKOI.js";import{d as O}from"./chunk-VIMF6LGM.js";import{d as k}from"./chunk-6QZNQS5B.js";import{d as A}from"./chunk-GPW2V3RE.js";import{b as N}from"./chunk-CISGGAIF.js";import{E as b,J as g,m as _}from"./chunk-LYCLF26R.js";import{b as a,c as p,i as h,j as m}from"./chunk-CK2E7BTU.js";import{b as f}from"./chunk-QYADASLV.js";var j={};f(j,{jotai:()=>v,nanostores:()=>y,nestjs:()=>x,react:()=>S,signals:()=>T,solid:()=>O,svelte:()=>k,vue:()=>A,zustand:()=>N});var T={};f(T,{Signal:()=>q});var s=[];function i(n){let e=n.cache;return n.subscribe(o=>{for(let[d,r]of o)d===a&&(e=r)})(),e}var u=class{_node;_equals;constructor(e,t){this._equals=t?.equals??Object.is,this._node=b(e,{...t,resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}set(e){this._equals(this.get(),e)||_(()=>{this._node.down([[p],[a,e]])})}},l=class{_node;constructor(e,t){this._node=g(o=>{s.push(o);try{return e()}finally{s.pop()}},{...t,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}},q={State:u,Computed:l,sub:(n,e)=>{let t=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,o=!0;return n._node.subscribe(d=>{for(let[r,c]of d){if(r===a){if(o){o=!1;continue}t.data?.(c)}r===m&&t.error?.(c),r===h&&t.complete?.()}})}};export{T as a,j as b};
@@ -0,0 +1 @@
1
+ import{b as U}from"./chunk-KGKJCHEK.js";import{b as K}from"./chunk-TZQPPQEQ.js";import{c as B,d as G,f as v,h as W}from"./chunk-3ZZX7M25.js";import{a as L}from"./chunk-L6NSJVJZ.js";import{b as Q}from"./chunk-LDQ3IUIP.js";import{j as I}from"./chunk-ACMJ2ZPS.js";import{C as _,m as z}from"./chunk-2K5RXLAH.js";import{b as D}from"./chunk-35JTVPOX.js";import{D as P,G as N,m as f,p as $}from"./chunk-LYCLF26R.js";import{b as x,j as S}from"./chunk-CK2E7BTU.js";import{b as ee}from"./chunk-QYADASLV.js";var re={};ee(re,{JobFlowGraph:()=>w,JobQueueGraph:()=>y,jobEventKeyOf:()=>oe,jobFlow:()=>se,jobQueue:()=>V});var te=256,ne=1024;function F(p,e){if(!Number.isFinite(p)||!Number.isInteger(p)||p<0)throw new Error(`${e} must be a non-negative integer`);return p}function T(p,e){return L("job_queue",p,e)}var oe=p=>p.action,y=class extends I{_pending;_jobs;_seqCursor;pending;jobs;depth;events;audit;_enqueueImpl;_ackImpl;_nackImpl;_removeByIdImpl;constructor(e,n={}){super(e,n.graph),this._pending=U([],{name:"pending"}),this._jobs=K({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=N([this.pending],([t])=>t.length,{name:"depth",describeKind:"derived",meta:T("queue_depth"),initial:0}),this.add(this.depth,{name:"depth"}),this.addDisposer(_(this.depth)),this.events=B({name:"events",retainedLimit:1024,graph:this}),this.audit=this.events,this._seqCursor=W(this,"seq",0),this._enqueueImpl=v((t,o)=>{let a=this._seqCursor.cache,s=o.id??`${this.name}-${a}`;if(this._jobs.get(s)!==void 0)throw new Error(`jobQueue("${this.name}"): duplicate job id "${s}"`);let u={id:s,payload:t,attempts:0,metadata:Object.freeze({...o.metadata??{}}),state:"queued"};return this._jobs.set(s,u),this._pending.append(s),s},{audit:this.events,seq:this._seqCursor,freeze:!1,onSuccess:([t],o,{t_ns:a,seq:s})=>({action:"enqueue",id:o,payload:t,t_ns:a,seq:s??0})}),this._ackImpl=v((t,o)=>{this._jobs.delete(t)},{audit:this.events,seq:this._seqCursor,freeze:!1,onSuccess:([t,o],a,{t_ns:s,seq:u})=>({action:"ack",id:t,attempts:o.attempts,t_ns:s,seq:u??0})}),this._nackImpl=v((t,o,a)=>{a?(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],a,{t_ns:s,seq:u})=>({action:"nack",id:t,attempts:o.attempts,t_ns:s,seq:u??0})}),this._removeByIdImpl=v((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],a,{t_ns:s,seq:u})=>({action:"remove",id:t,attempts:o.attempts,t_ns:s,seq:u??0})})}attachEventStorage(e){return this.events.attachStorage(e)}enqueue(e,n={}){return this._enqueueImpl(e,n)}claim(e=1){let n=F(e,"job queue claim limit");if(n===0)return[];let t=[];for(;t.length<n&&this.pending.cache.length!==0;){let a=this._pending.pop(0),s=this._jobs.get(a);if(!s||s.state!=="queued")continue;let u={...s,state:"inflight",attempts:s.attempts+1};this._jobs.set(a,u),t.push(u),this.events.append({action:"claim",id:a,attempts:u.attempts,t_ns:$(),seq:G(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]!==x)continue;let a=o[1];this.enqueue(a,n?{metadata:n.metadata}:void 0)}})}},w=class extends I{_stageNames;_stageWorkFns;_queues=new Map;_completed;completed;completedCount;constructor(e,n={}){super(e,n.graph);let t=n.stages??["incoming","processing","done"],o=[],a=new Map,s=new Map;for(let r of t){let i=typeof r=="string"?r.trim():r.name.trim();typeof r!="string"&&r.work&&a.set(i,r.work),typeof r!="string"&&r.maxPerPump!=null&&s.set(i,Math.max(1,F(r.maxPerPump,`job flow stage "${i}" maxPerPump`))),o.push(i)}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=a;for(let r of this._stageNames){let i=V(`${e}-${r}`);this._queues.set(r,i),this.mount(r,i)}this._completed=Q([],{name:"completed",maxSize:ne}),this.completed=this._completed.entries,this.add(this.completed,{name:"completed"}),this.completedCount=N([this.completed],([r])=>r.length,{name:"completedCount",describeKind:"derived",meta:T("job_flow_completed_count"),initial:0}),this.add(this.completedCount,{name:"completedCount"}),this.addDisposer(_(this.completedCount));let X=Math.max(1,F(n.maxPerPump??te,"job flow maxPerPump"));for(let r=0;r<this._stageNames.length;r+=1){let i=this._stageNames[r],l=this.queue(i),j=r+1<this._stageNames.length?this.queue(this._stageNames[r+1]):null,R=this._stageWorkFns.get(i),C=s.get(i)??X,M=j===null;if(R){let h=P([l.pending],()=>{let c=0;for(;c<C;){let g=l.claim(1);if(g.length===0)break;let d=g[0];if(!d)break;let q=[...d.metadata.job_flow_path??[],i],b;try{b=R(d)}catch{l.nack(d.id,{requeue:!1}),c+=1;continue}let k=z(b),E=!1,m;m=k.subscribe(Y=>{if(!E){for(let J of Y)if(J[0]===x){E=!0,m?m():Promise.resolve().then(()=>m?.());let A=J[1],O={...d.metadata,job_flow_path:q};if(M){let Z={...d,payload:A,metadata:Object.freeze(O)};f(()=>{l.ack(d.id),this._completed.append(Z)})}else f(()=>{l.ack(d.id),j.enqueue(A,{metadata:O})});return}else if(J[0]===S){E=!0,m?m():Promise.resolve().then(()=>m?.()),l.nack(d.id,{requeue:!1});return}}}),c+=1}},{name:`pump_${i}`,describeKind:"effect",meta:T("job_flow_pump",{stage:i,has_work:!0})});this.add(h,{name:`pump_${i}`}),this.addDisposer(_(h))}else{let h=P([l.pending],()=>{let c=0;for(;c<C;){let g=l.claim(1);if(g.length===0)break;let d=g[0];if(!d)break;let q=[...d.metadata.job_flow_path??[],i],b={...d.metadata,job_flow_path:q};if(M){let k={...d,metadata:Object.freeze(b)};f(()=>{l.ack(d.id),this._completed.append(k)})}else f(()=>{l.ack(d.id),j.enqueue(d.payload,{metadata:b})});c+=1}},{name:`pump_${i}`,describeKind:"effect",meta:T("job_flow_pump",{stage:i,has_work:!1})});this.add(h,{name:`pump_${i}`}),this.addDisposer(_(h))}}}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 V(p,e){return new y(p,e)}function se(p,e){let n=new w(p,e),{factory:t,factoryArgs:o,...a}=e??{};return n.tagFactory("jobFlow",D(a)),n}export{oe as a,y as b,w as c,V as d,se as e,re as f};
@@ -1 +1 @@
1
- import{a as B}from"./chunk-4VVTGLXJ.js";import{m as k}from"./chunk-L77I47VU.js";import{c as h}from"./chunk-35JTVPOX.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{m as k}from"./chunk-2K5RXLAH.js";import{c as h}from"./chunk-35JTVPOX.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,4 +1,4 @@
1
- import{f as F,g as j,h as A}from"./chunk-F7VUYPP6.js";import{h as b,i as x}from"./chunk-POXANAJ6.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-7VKFXLZQ.js";import{i as b,j as x}from"./chunk-ACMJ2ZPS.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:
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{b as E}from"./chunk-TZQPPQEQ.js";import{t as I,x as w}from"./chunk-6YFZMUMR.js";import{m as f,s as M}from"./chunk-2K5RXLAH.js";import{c as O}from"./chunk-35JTVPOX.js";import{E as R,G as V,m as h}from"./chunk-LYCLF26R.js";import{b as v}from"./chunk-CK2E7BTU.js";function C(n){return typeof n=="object"&&n!==null&&"cache"in n&&typeof n.subscribe=="function"}function H(n,u,e){let i=f(n),o=i.v!=null,p=R(e?.initialVerified??null,{meta:{...O("verifiable"),...o?{sourceVersion:null}:{}}}),x=e?.trigger!==void 0&&e.trigger!==null,c=null;if(x&&e?.autoVerify?c=I(f(e.trigger),i):x?c=f(e.trigger):e?.autoVerify&&(c=i),c!==null){let y;if(c===i)y=w(i,l=>u(l));else{let l=i.cache;i.subscribe(m=>{for(let N of m)N[0]===v&&(l=N[1])}),y=w(c,()=>u(l))}M(y,l=>{h(()=>{if(p.down([[v,l]]),o){let m=i.v;m!=null&&p.meta.sourceVersion.down([[v,{id:m.id,version:m.version}]])}})})}return{node:i,verified:p,trigger:c}}function B(n){n.subscribe(()=>{})}function k(n){return n instanceof Map?n:new Map}function S(n,u){if(!Array.isArray(u.upsert))throw new TypeError("distill extraction requires upsert: Array<{ key, value }>");h(()=>{for(let{key:e,value:i}of u.upsert)n.set(e,i);for(let e of u.remove??[])n.delete(e)})}function J(n,u,e){let i=f(n),o=E(e.mapOptions??{}),p=e.budget??2e3,c=e.context!==void 0&&e.context!==null?f(e.context):R(null),y=k(o.entries.cache);o.entries.subscribe(t=>{for(let d of t)d[0]===v&&(y=k(d[1]))});let l=f(u(i,o.entries));if(M(l,t=>{S(o,t)}),e.evict){let t=new Map,d=V([o.entries],([g])=>{let T=[],b=k(g);for(let r of t.keys())b.has(r)||(t.get(r)(),t.delete(r));for(let[r,s]of b){let a=e.evict(r,s);if(C(a)){if(!t.has(r)){let D=M(a,z=>{z===!0&&o.has(r)&&o.delete(r)});t.set(r,D)}continue}if(typeof a=="boolean"){a&&T.push(r);continue}throw new TypeError("distill evict() must return boolean or Node<boolean>")}return T});M(d,g=>{for(let T of g)o.delete(T)})}let m=e.consolidateTrigger!==void 0&&e.consolidateTrigger!==null;if(e.consolidate&&m){let t=f(e.consolidateTrigger),d=w(t,()=>e.consolidate(y));M(d,g=>{S(o,g)})}let N=V([o.entries,c],([t,d])=>{let T=[...k(t).entries()].map(([s,a])=>({key:s,value:a,score:e.score(a,d),cost:e.cost(a)}));T.sort((s,a)=>a.score-s.score);let b=[],r=p;for(let s of T)s.cost<=r&&(b.push({key:s.key,value:s.value,score:s.score}),r-=s.cost);return b},{meta:{...O("distill",{budget:p})}}),A=V([o.entries],([t])=>k(t).size);return B(N),B(A),{store:o,compact:N,size:A}}export{H as a,J as b};
@@ -1,4 +1,4 @@
1
- import{b as X}from"./chunk-G3M3IMEV.js";import{g as Q,i as U}from"./chunk-POXANAJ6.js";import{E as z,F as W,G as Y,H as V}from"./chunk-LYCLF26R.js";import{b as ie}from"./chunk-QYADASLV.js";var he={};ie(he,{compileSpec:()=>ue,decompileSpec:()=>me,extractFnFactory:()=>te,extractSourceFactory:()=>ne,generateCatalogPrompt:()=>oe,isRichFnEntry:()=>T,isRichSourceEntry:()=>I,llmCompose:()=>ye,llmRefine:()=>ae,specDiff:()=>ge,validateSpec:()=>q,validateSpecAgainstCatalog:()=>K});function M(n){let e=n.meta?.factory;return typeof e=="string"?e:void 0}function C(n){let e=n.meta?.factoryArgs;return e!=null&&typeof e=="object"?e:{}}function Z(n){let e=C(n);return"initial"in e?e.initial:n.value}function T(n){return typeof n=="object"&&n!==null&&"factory"in n}function I(n){return typeof n=="object"&&n!==null&&"factory"in n}function te(n){return T(n)?n.factory:n}function ne(n){return I(n)?n.factory:n}function oe(n){let e=[];if(n.fns){let o=new Map;for(let[s,f]of Object.entries(n.fns)){let p=T(f)?f.tags?.[0]??"Other":"Other";o.has(p)||o.set(p,[]),o.get(p).push(ce(s,f))}for(let[s,f]of o)e.push(`${s}:
1
+ import{b as X}from"./chunk-G5VBJ5K6.js";import{h as Q,j as U}from"./chunk-ACMJ2ZPS.js";import{E as z,F as W,G as Y,H as V}from"./chunk-LYCLF26R.js";import{b as ie}from"./chunk-QYADASLV.js";var he={};ie(he,{compileSpec:()=>ue,decompileSpec:()=>me,extractFnFactory:()=>te,extractSourceFactory:()=>ne,generateCatalogPrompt:()=>oe,isRichFnEntry:()=>T,isRichSourceEntry:()=>I,llmCompose:()=>ye,llmRefine:()=>ae,specDiff:()=>ge,validateSpec:()=>q,validateSpecAgainstCatalog:()=>K});function M(n){let e=n.meta?.factory;return typeof e=="string"?e:void 0}function C(n){let e=n.meta?.factoryArgs;return e!=null&&typeof e=="object"?e:{}}function Z(n){let e=C(n);return"initial"in e?e.initial:n.value}function T(n){return typeof n=="object"&&n!==null&&"factory"in n}function I(n){return typeof n=="object"&&n!==null&&"factory"in n}function te(n){return T(n)?n.factory:n}function ne(n){return I(n)?n.factory:n}function oe(n){let e=[];if(n.fns){let o=new Map;for(let[s,f]of Object.entries(n.fns)){let p=T(f)?f.tags?.[0]??"Other":"Other";o.has(p)||o.set(p,[]),o.get(p).push(ce(s,f))}for(let[s,f]of o)e.push(`${s}:
2
2
  ${f.join(`
3
3
  `)}`)}if(n.sources){let o=[];for(let[s,f]of Object.entries(n.sources))o.push(pe(s,f));o.length>0&&e.push(`Sources:
4
4
  ${o.join(`
@@ -0,0 +1,3 @@
1
+ import{a as Me}from"./chunk-ESMPEKEV.js";import{C as re}from"./chunk-2K5RXLAH.js";import{a as ye,d as we}from"./chunk-35JTVPOX.js";import{A as me,C as M,E as Z,F as be,G as ve,e as xe,f as $e,i as Q,k as Ae,l as ne,m as Te,o as L,p as Pe,s as U}from"./chunk-LYCLF26R.js";import{b as q,c as pe,d as fe,e as te,f as he,g as ge,h as B,i as H,j as W}from"./chunk-CK2E7BTU.js";var A={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},Xe=Symbol.for("sizeof");function je(o){let e=new WeakSet,t=new WeakSet,n=[o],s=0;for(;n.length>0;){let r=n.pop();s+=et(r,e,t,n)}return s}function et(o,e,t,n){if(o==null)return 0;switch(typeof o){case"number":return A.number;case"boolean":return A.boolean;case"string":return A.string+o.length*2;case"bigint":return A.bigint+tt(o);case"symbol":return A.symbol;case"function":return e.has(o)?0:(e.add(o),A.function);case"undefined":return 0}let r=o;if(e.has(r))return 0;e.add(r);let i=r[Xe];if(typeof i=="function")try{let a=i.call(r);if(typeof a=="number"&&Number.isFinite(a))return a}catch{}if(r instanceof Date)return A.date;if(r instanceof RegExp)return A.regexp+r.source.length*2;if(r instanceof Error){let a=r.message?r.message.length*2:0,p=r.stack?r.stack.length*2:0;return A.error+a+p}if(typeof URL<"u"&&r instanceof URL)return A.url+r.href.length*2;if(typeof Promise<"u"&&r instanceof Promise)return A.promise;if(r instanceof WeakMap)return A.weakmap;if(r instanceof WeakSet)return A.weakset;if(r instanceof Map){let a=A.map;for(let[p,g]of r)a+=A.mapEntry,n.push(p),n.push(g);return a}if(r instanceof Set){let a=A.set;for(let p of r)a+=A.setEntry,n.push(p);return a}if(Array.isArray(r)){let a=A.array+r.length*8;for(let p of r)n.push(p);return a}if(r instanceof ArrayBuffer)return t.has(r)?0:(t.add(r),r.byteLength);if(ArrayBuffer.isView(r)){let a=r;return t.has(a.buffer)?48:(t.add(a.buffer),a.buffer.byteLength+48)}let c=A.object,d=Object.keys(r);for(let a of d){c+=A.string+a.length*2;try{n.push(r[a])}catch{}}return c}function tt(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 Fe(o,e,t,n={}){let s=e in o.nodes,r=t in o.nodes;if(!s)return se(e,t,"no-such-from");if(!r)return se(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 a=nt(o,e,n);if(a!=null)return a}let d=oe(e,o.nodes[e],0,n);return ie(e,t,[d])}if(i===0)return se(e,t,"no-path");let c=Ie(o,e,t,i);return c.found?ie(e,t,ze(o,c.pathOrder,n)):se(e,t,c.truncated?"max-depth-exceeded":"no-path")}function Ie(o,e,t,n){let s=new Map,r=[{path:t,depth:0}],i=new Set([t]),c=0,d=!1;for(;c<r.length;){let g=r[c++];if(g.path===e)break;if(n!=null&&g.depth>=n){let y=o.nodes[g.path];y?.deps&&y.deps.length>0&&(d=!0);continue}let h=o.nodes[g.path];if(h==null)continue;let f=h.deps??[],u=new Map;for(let y=0;y<f.length;y++){let l=f[y];if(!l)continue;let O=u.get(l);O==null&&(O=[],u.set(l,O)),O.push(y)}for(let[y,l]of u)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:d};let a=[{path:e}],p=e;for(;p!==t;){let g=s.get(p);if(g==null)return{found:!1,pathOrder:[],truncated:!1};a[a.length-1].depIndices=g.depIndices,a.push({path:g.from}),p=g.from}return{found:!0,pathOrder:a,truncated:!1}}function nt(o,e,t){let n=o.nodes[e];if(n==null)return null;let s=n.deps??[],r=[];for(let c=0;c<s.length;c++)s[c]===e&&r.push(c);if(r.length>0){let c=oe(e,n,0,t);c.dep_index=r[0];let d=oe(e,n,1,t);return ie(e,e,[c,d])}let i=null;for(let c=0;c<s.length;c++){let d=s[c];if(!d||d===e)continue;let a=Ie(o,d,e,t.maxDepth);a.found&&(i==null||a.pathOrder.length<i.pathOrder.length)&&(i=a,i={found:!0,pathOrder:[{path:e,depIndices:[c]},...a.pathOrder],truncated:!1})}return i==null?null:ie(e,e,ze(o,i.pathOrder,t))}function ze(o,e,t){return e.map((n,s)=>{let r=o.nodes[n.path],i=oe(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 oe(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 ie(o,e,t){return Be(o,e,!0,"ok",t)}function se(o,e,t){return Be(o,e,!1,t,[])}function Be(o,e,t,n,s){let r=rt(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 rt(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 d=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(r.push(d),"value"in i&&r.push(` value: ${st(i.value)}`),i.annotation!=null&&r.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let a=i.lastMutation.actor;r.push(` actor: ${a.type}${a.id?`:${a.id}`:""}`)}}return r.join(`
2
+ `)}function st(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 Oe(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(!Oe(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)||!Oe(o[r],e[r]))return!1;return!0}function Le(o,e){return`${o}\0${e}`}function _e(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)),c=new Set(Object.keys(e.nodes)),d=[];for(let l of c)i.has(l)||d.push(l);d.sort();for(let l of d)t.push({type:"node-added",path:l,node:{...e.nodes[l]}});let a=[];for(let l of c){if(!i.has(l))continue;let O=o.nodes[l]?.meta,m=e.nodes[l]?.meta;O==null&&m==null||Oe(O??{},m??{})||a.push(l)}a.sort();for(let l of a)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(Le(l.from,l.to),l);let g=new Map;for(let l of e.edges)g.set(Le(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 u=[];for(let l of i)c.has(l)||u.push(l);u.sort();for(let l of u)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 Ve(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 c=[];for(let[h,f]of Object.entries(n.nodes)){let u=i.get(h),y=u instanceof M?u:null,l=y?je(y.cache):0,O=y?y._sinkCount:0,m=f.deps?.length??0,b=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;c.push({path:h,type:f.type,status:f.status??"unknown",valueSizeBytes:l,subscriberCount:O,depCount:m,isOrphanEffect:b,orphanKind:v})}let d=c.reduce((h,f)=>h+f.valueSizeBytes,0),a=(h,f)=>[...c].sort(f??((u,y)=>y[h]-u[h])).slice(0,t),p=c.filter(h=>h.orphanKind!=null),g=c.filter(h=>h.isOrphanEffect);return{nodeCount:c.length,edgeCount:n.edges.length,subgraphCount:n.subgraphs.length,nodes:c,totalValueSizeBytes:d,hotspots:{byValueSize:a("valueSizeBytes"),bySubscriberCount:a("subscriberCount"),byDepCount:a("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 x="::",z="__meta__",J=1;function qe(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 Ye(o){return o!=null&&typeof o=="object"&&"cache"in o&&typeof o.subscribe=="function"&&typeof o.down=="function"}function ot(o){if(o!=null)return Ye(o)?o.cache:o}function K(o){return o!=null&&typeof o=="object"&&"cache"in o&&typeof o.subscribe=="function"&&typeof o.down=="function"}function V(o){return K(o)?o.cache??"":o}function Ke(o){return K(o)?o.cache??0:o}function He(o){return K(o)?o.cache??!1:o}function it(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 We(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 at(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 c=s.constructor,d=r.constructor;if(c!==d)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,u]of s)if(!h.has(f)||!n(u,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 u=!1;for(let y of h)if(n(f,y)){u=!0;break}if(!u)return!1}return!0}if(ArrayBuffer.isView(s)){let h=s,f=r;if(h.length!==f.length)return!1;for(let u=0;u<h.length;u++)if(h[u]!==f[u])return!1;return!0}let a=Object.keys(s),p=Object.keys(r);if(a.length!==p.length)return!1;let g=new Set(p);for(let h of a)if(!g.has(h)||!n(s[h],r[h]))return!1;return!0};return n(o,e)}function ut(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ae(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+=ut(n)}return e+="$",new RegExp(e)}var ct={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"},dt={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function Ee(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 lt(o){return o==="none"?dt:o==="ansi"||o==null?ct:{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 Ue(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 pt(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 ke(o,e,t){if(o==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(o.includes(x))throw new Error(`Graph "${e}": ${t} "${o}" must not contain '${x}' (path separator)`);if(o===z)throw new Error(`Graph "${e}": ${t} name "${z}" is reserved for meta companion paths`);pt(o,e,t)}function ft(o,e){if(o==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=o.split(x);for(let n of t)if(n==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function ht(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 Qe(o){for(let e of o._mounts.values())Qe(e);for(let e of o._nodes.values())try{e.down([[B]],{internal:!0})}catch{}}var Se=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(x))throw new Error(`Graph name must not contain '${x}' (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??me,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=be(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(ke(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 c=this._nodeToName.get(e);if(c!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${c}"`);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){ke(e,this.name,"remove");let t=this._mounts.get(e);if(t){let r={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[c,d]of i)c.includes(`${x}${z}${x}`)||r.nodes.push(c);return r.nodes.sort(),r.mounts.push(e),r.mounts.push(...t._collectSubgraphs(`${e}${x}`)),this._mounts.delete(e),t._parent=void 0,Qe(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=ae(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(x))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([[q,t]],{actor:n?.actor,internal:s,delivery:"write"})}setAll(e,t){let n=Symbol.iterator in e?e:Object.entries(e);Te(()=>{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([[W,t]],{actor:n?.actor,internal:s,delivery:"write"})}complete(e,t){let n=t?.internal===!0;this.node(e).down([[H]],{actor:t?.actor,internal:n,delivery:"write"})}edges(e){let t=e?.recursive===!0,n=new Map;if(!t){for(let[d,a]of this._nodes)n.set(a,d);let c=[];for(let[d,a]of this._nodes)if(a instanceof M)for(let p of a._deps){let g=n.get(p.node);g!=null&&c.push([g,d])}return c.sort((d,a)=>d[0]<a[0]?-1:d[0]>a[0]?1:d[1]<a[1]?-1:d[1]>a[1]?1:0),c}let s=[];this._collectObserveTargets("",s);let r=new Map;for(let[c,d]of s)r.set(d,c);let i=[];for(let[c,d]of s)if(d instanceof M)for(let a of d._deps){let p=r.get(a.node);p!=null&&i.push([p,c])}return i.sort((c,d)=>c[0]<d[0]?-1:c[0]>d[0]?1:c[1]<d[1]?-1:c[1]>d[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(ke(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=ft(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 c=this._nodes.get(n);if(c)return c;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(x));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(x)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${n}"`);return i.resolve(s.join(x))}_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 c=i[r+1],d=s.meta[c];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${c}" in path "${n}"`);s=d,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 d of this._mounts.values())d._signalDeliver(e,t,n,s);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},c=ht(e,this.config);for(let d of[...this._nodes.keys()].sort()){let a=this._nodes.get(d);if(!n.has(a)){n.add(a);try{a.down(e,i)}catch(p){if(p instanceof U)throw p;s.push(p)}c.length!==0&&this._signalMetaSubtree(a,c,n,i,s)}}}_signalMetaSubtree(e,t,n,s,r){for(let i of Object.keys(e.meta).sort()){let c=e.meta[i];if(!n.has(c)){n.add(c);try{c.down(t,s)}catch(d){if(d instanceof U)throw d;r.push(d)}this._signalMetaSubtree(c,t,n,s,r)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=ot(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=ye(e?.detail,e?.fields),r=e?.detail==="spec",i=s,c=[];this._collectObserveTargets("",c);let d=new Map;for(let[v,w]of c)d.set(w,v);let a=[];{let v=c.map(([,S])=>S),w=new Set(d.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(d.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++}`;d.set(G,k),w.add(k),a.push([k,G]),v.push(G)}}}let p=[...c,...a],g={};for(let[v,w]of p){if(t!=null&&!w.allowsObserve(t))continue;let E=we(w,i,r),S=w instanceof M?w._deps.map(k=>d.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,T]of Object.entries(n)){let $=I==="deps_includes"?"depsIncludes":I==="meta_has"?"metaHas":I;if($==="depsIncludes"){if(!D.deps.includes(String(T))){k=!1;break}continue}if($==="metaHas"){if(!Object.hasOwn(D.meta??{},String(T))){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=d.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 u=f.map(([v,w])=>({from:v,to:w}));(t!=null||n!=null)&&(u=u.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}${x}`;return[...h].some(E=>E===v||E.startsWith(w))}):y,O=this,m=e;return{name:this.name,nodes:g,edges:u,subgraphs:l,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(v){let w={...m};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}${x}`))}return t}resourceProfile(e){return Ve(this,e)}reachable(e,t,n={}){return n.withDetail===!0?Je(this.describe(),e,t,{...n,withDetail:!0}):Je(this.describe(),e,t,n)}explain(e,t,n){return n?.reactive===!0?this._explainReactive(e,t,n):this._explainStatic(V(e),V(t),{...n?.maxDepth!==void 0?{maxDepth:Ke(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:He(n.findCycle)}:{}})}_explainStatic(e,t,n){let s=this.describe({detail:"full"}),r=new Map(this._annotations),i=new Map;for(let[c,d]of Object.entries(s.nodes))d.lastMutation!=null&&i.set(c,d.lastMutation);return Fe(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}),c=!1,d=!1,a=()=>{c||d||(c=!0,ne(()=>{c=!1,!d&&(s+=1,r.emit(s))}))},p=i.onEvent(m=>{let b=m.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||a()}),g=[],h=new WeakSet,f=m=>{if(h.has(m)||d)return;h.add(m);let b=m.topology.subscribe(v=>{for(let w of v){if(w[0]!==q)continue;let E=w[1];if(a(),E.kind==="added"&&E.nodeKind==="mount"){let S=m._mounts.get(E.name);S!=null&&f(S)}}});g.push(b);for(let v of m._mounts.keys()){let w=m._mounts.get(v);w!=null&&f(w)}};f(this);let u,y=e.actor;Ye(y)&&(u=y.subscribe(m=>{let b=!1,v=!1;for(let w of m){let E=w[0];E===q?b=!0:(E===H||E===W||E===B)&&(v=!0)}b&&a(),v&&(u?.(),u=void 0,a())}));let l;try{l=ve([r],()=>this.describe(t),{name:n,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(m,b)=>m===b})}catch(m){p(),u?.();for(let b of g)b();throw i.dispose(),m}let O=re(l);return{node:l,dispose(){d=!0,p(),u?.();for(let m of g)m();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=_e(s,r),c=Z(i,{name:n,meta:{domain:"audit",kind:"describe-diff"},equals:(h,f)=>h===f}),d=this._describeReactive({...e,reactiveName:void 0}),a=!1,p=d.node.subscribe(h=>{if(!a)for(let f of h){if(f[0]!==q)continue;let u=f[1],y=_e(r,u);r=u,y.events.length!==0&&c.emit(y)}}),g=re(c);return{node:c,dispose(){a=!0,p(),d.dispose(),c.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}),c=!1,d=!1,a=()=>{c||d||(c=!0,ne(()=>{c=!1,!d&&(s+=1,r.emit(s))}))},p=i.onEvent(m=>{let b=m.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||a()}),g=[];e!=null&&K(e)&&g.push(e),t!=null&&K(t)&&g.push(t),n?.maxDepth!=null&&K(n.maxDepth)&&g.push(n.maxDepth),n?.findCycle!=null&&K(n.findCycle)&&g.push(n.findCycle);let h=()=>{for(let m of g)if(m.cache===void 0)return!1;return!0},f=()=>{let m=V(e),b=V(t);return{from:m,to:b,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:m,to:b,found:!1,reason:"pending",steps:[]})}},u;try{u=ve([r],()=>{if(!h())return f();let m=V(e),b=V(t),v={...n?.maxDepth!==void 0?{maxDepth:Ke(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:He(n.findCycle)}:{}};return this._explainStatic(m,b,v)},{name:n?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:V(e),to:V(t)},equals:(m,b)=>m.found===b.found&&m.reason===b.reason&&m.steps.length===b.steps.length&&mt(m.steps,b.steps)})}catch(m){throw p(),i.dispose(),m}let y=re(u),l=[],O=m=>{let b;return b=m.subscribe(v=>{let w=!1,E=!1;for(let S of v){let R=S[0];R===q?w=!0:(R===H||R===W||R===B)&&(E=!0)}(w||E)&&a(),E&&b&&(b(),b=void 0)}),()=>{b&&(b(),b=void 0)}};for(let m of g)l.push(O(m));return{node:u,dispose(){d=!0,p();for(let m of l)m?.();l.length=0,i.dispose(),y()}}}_pathsMatching(e){let t=ae(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}${x}${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}${x}${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}${x}${z}${x}${s}`;n.push([i,r]),this._appendMetaObserveTargets(i,r,n)}}observe(e,t){let n=typeof e=="string",r=Ue(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,c=r.actor;if(n){let p=e,g=this.resolve(p);if(c!=null&&!g.allowsObserve(c))throw new U({actor:c,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 d=[];this._collectObserveTargets("",d),d.sort((p,g)=>p[0]<g[0]?-1:p[0]>g[0]?1:0);let a=c==null?d:d.filter(([,p])=>p.allowsObserve(c));return i?this._buildStructuredObserver(a,r,"all"):{subscribe:p=>{let g=a.map(([h,f])=>f.subscribe(u=>{p(h,u)}));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 be(i=>{let c=[],d=!1,a=!1,p=()=>{if(c.length===0||a)return;let y={events:c.slice(),flushedAt_ns:L()};c.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=>{a||(c.push(y),!d&&(d=!0,ne(()=>{d=!1,p()})))};for(let y of h.events)f(y);let u=h.onEvent(f);return()=>{a=!0,u(),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 c=[];this._collectObserveTargets("",c),c.sort((p,g)=>p[0]<g[0]?-1:p[0]>g[0]?1:0);let d=i.actor,a=d==null?c:c.filter(([,p])=>p.allowsObserve(d));return this._buildStructuredObserver(a,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,c=t.detail==="minimal",d=this.config.inspectorEnabled,a=(r||i)&&d,p=t.maxEvents,g=p!=null&&p>0?new X(p):null,h=[],f=new Set,u=t.tiers!=null?new Set(t.tiers):null,y={},l=new Set,O=0,m=0,b=0,v=0,w=0,E=0,S=!1,R=!1,G=0,D=new Map,k=new Map,I=new Map,T=_=>{if(!(u!=null&&!u.has(_.type))){g?g.push(_):h.push(_);for(let C of f)C(_)}},$=_=>u==null||u.has(_),Re=()=>s?{timestamp_ns:L(),in_batch:Ae(),batch_id:G}:{},Ze=(_,C)=>{if(!(!a||!(_ 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&&T({type:"derived",path:C,dep_values:Y,dep_batches:F,...Re()})}})},Ne=_=>{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}:{}}},Ge=[],De=[];for(let[_,C]of e){let j=Ze(C,_);j&&Ge.push(j),De.push(C.subscribe(Y=>{G++;for(let F of Y){let N=F[0],P=Re();if(N===q){y[_]=F[1];let le=C instanceof M?C.lastMutation?.actor??Q:Q;T({type:"data",path:_,data:F[1],actor:le,...P,...Ne(C)})}else if(c)N===pe?$("dirty")&&O++:N===fe?$("resolved")&&m++:N===te?$("invalidate")&&b++:N===he?$("pause")&&v++:N===ge?$("resume")&&w++:N===B?$("teardown")&&E++:N===H&&!l.has(_)?$("complete")&&(S=!0):N===W&&$("error")&&(R=!0,l.add(_));else if(N===pe)$("dirty")&&O++,T({type:"dirty",path:_,...P});else if(N===fe)$("resolved")&&m++,T({type:"resolved",path:_,...P,...Ne(C)});else if(N===te)$("invalidate")&&b++,T({type:"invalidate",path:_,...P});else if(N===he)$("pause")&&v++,T({type:"pause",path:_,lockId:F[1],...P});else if(N===ge)$("resume")&&w++,T({type:"resume",path:_,lockId:F[1],...P});else if(N===H)$("complete")&&!l.has(_)&&(S=!0),T({type:"complete",path:_,...P});else if(N===W){$("error")&&(R=!0,l.add(_));let le=C instanceof M?C.lastMutation?.actor??Q:Q;T({type:"error",path:_,data:F[1],actor:le,...P})}else N===B&&($("teardown")&&E++,T({type:"teardown",path:_,...P}))}}))}let ue=!1,ce=()=>{if(!ue){ue=!0;for(let _ of De)_();for(let _ of Ge)_();for(let _ of ee)_({value:void 0,done:!0});ee.length=0}},de=[],ee=[];f.add(_=>{let C=ee.shift();C?C({value:_,done:!1}):de.push(_)});let Ce={get values(){return y},get dirtyCount(){return O},get resolvedCount(){return m},get invalidateCount(){return b},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:ce,expand(_){ce();let C={...t};return typeof _=="string"?C.detail=_:Object.assign(C,_),n(Ue(C))},[Symbol.asyncIterator](){return{next(){return de.length>0?Promise.resolve({value:de.shift(),done:!1}):ue?Promise.resolve({value:void 0,done:!0}):new Promise(_=>ee.push(_))},return(){return ce(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(Ce,t),Ce}_attachFormatLogger(e,t){let n=t.format;if(n==null)return;let s=t.logger??(u=>console.log(u)),r=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,c=r==null&&i==null?()=>!0:u=>(r==null||r.has(u))&&(i==null||!i.has(u)),d=lt(t.theme),a=n==="stage-log"?L():0,p=u=>u==null?"":t.stageLabels?.[u]??u,g=(u,y)=>u.length>y?`${u.slice(0,y-1)}\u2026`:u,h=u=>u.type==="data"||u.type==="error"?g(Ee(u.data),120):"",f=u=>{if(n==="stage-log"){let S=(L()-a)/1e9,R=p(u.path).padEnd(9);if(u.type==="data"){let G=h(u);return`[${S.toFixed(3)}s] ${R} \u2190${G?` ${G}`:""}`}if(u.type==="error"){let G=h(u);return`[${S.toFixed(3)}s] ${R} \u2717${G?` ${G}`:""}`}return u.type==="complete"?`[${S.toFixed(3)}s] ${R} \u25A0 complete`:`[${S.toFixed(3)}s] ${R} ${u.type}`}if(n==="json")try{return JSON.stringify(u)}catch{return JSON.stringify({type:u.type,path:u.path,data:"[unserializable]"})}let y=d[u.type]??"",l=u.path?`${d.path}${u.path}${d.reset} `:"",O=u.type==="data"||u.type==="error",m=u.type==="pause"||u.type==="resume",b=O?` ${Ee(u.data)}`:m?` ${Ee(u.lockId)}`:"",v=u.type==="data"||u.type==="resolved"||u.type==="derived"?u:void 0,w=v?.trigger_dep_name!=null?` <- ${v.trigger_dep_name}`:v?.trigger_dep_index!=null?` <- #${v.trigger_dep_index}`:"",E=u.in_batch?" [batch]":"";return`${l}${y}${u.type.toUpperCase()}${d.reset}${b}${w}${E}`};e.onEvent(u=>{c(u.type)&&s(f(u),u)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){qe(this._disposers,this.name),this.signal([[B]],{internal:!0}),qe(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:t,...n}=this.describe({detail:"full"}),s={};for(let c of Object.keys(n.nodes).sort()){let{lastMutation:d,guard:a,...p}=n.nodes[c];s[c]=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 c=this.config.lookupCodec(e.codec);if(c==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return xe(c,c.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let n=t?.config??me,{codec:s,codecVersion:r,payload:i}=$e(e,n);return s.decode(i,r)}restore(e,t){if(We(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=>ae(r)),s=t?.includeProducers===!0;for(let r of Object.keys(e.nodes).sort()){if(n!==null&&!n.some(c=>c.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 d=this.tryResolve(r)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(r,i.value)}catch(c){t?.onError?.(r,c)}}}}}static fromSnapshot(e,t){We(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((u,y)=>{let l=u.split(x).length,O=y.split(x).length;return l!==O?l-O:u<y?-1:u>y?1:0})){let u=f.split(x),y=r;for(let l of u)y._mounts.has(l)||y.mount(l,new o(l)),y=y._mounts.get(l)}let i=s?Object.entries(s).map(([f,u])=>({re:ae(f),factory:u})):[],c=f=>{for(let u of i)if(u.re.test(f))return u.factory},d=f=>{let u=f.split(x),y=u.pop();if(y==null||y.length===0)throw new Error(`invalid snapshot path "${f}"`);let l=r;for(let O of u){let m=l._mounts.get(O);if(!m)throw new Error(`unknown mount "${O}" in path "${f}"`);l=m}return[l,y]},a=Object.entries(e.nodes).filter(([f])=>!f.includes(`${x}${z}${x}`)).sort((f,u)=>f[0]<u[0]?-1:f[0]>u[0]?1:0),p=new Map(a),g=new Map,h=!0;for(;p.size>0&&h;){h=!1;for(let[f,u]of[...p.entries()]){let y=u?.deps??[];if(!y.every(w=>g.has(w)))continue;let[l,O]=d(f),m={...u?.meta??{}},b=c(f),v;if(u?.type==="state")v=Z(u.value,{meta:m});else{if(b==null)continue;v=b(O,{path:f,type:u.type,value:u.value,meta:m,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(a=>({tier:a,debounceMs:Math.max(0,a.debounceMs??0),compactEvery:Math.max(1,a.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=(a,p)=>{if(a.disposed)return;let g=it(p.nodes);if(a.lastSnapshot!=null&&g!==""&&g===a.lastFingerprint)return;let h=a.seq+1,f=Pe(),l=a.lastSnapshot==null||h%a.compactEvery===0?{name:this.name,mode:"full",snapshot:p,seq:h,timestamp_ns:f,format_version:J}:{name:this.name,mode:"diff",diff:gt(a.lastSnapshot,p),seq:h,timestamp_ns:f,format_version:J};if(a.tier.filter&&!a.tier.filter(l))return;let O;try{O=a.tier.save(l)}catch(m){t.onError?.(m,a.tier);return}if(O&&typeof O.then=="function"){let v=(a.savePending??Promise.resolve()).then(()=>O,()=>O).then(()=>{a.disposed||(a.seq=h,a.lastSnapshot=p,a.lastFingerprint=g)},w=>{t.onError?.(w,a.tier)});a.savePending=v.finally(()=>{a.savePending===v&&(a.savePending=void 0)})}else a.seq=h,a.lastSnapshot=p,a.lastFingerprint=g},r=(a,p)=>{try{s(a,p)}catch(g){t.onError?.(g,a.tier)}},i=(a,p)=>{if(!p.some(u=>{let y=this.config.messageTier(u[0]);return y>=3&&y<5}))return;if(t.filter){let u=this.tryResolve(a);if(u==null)return;let y=we(u,ye("standard"));if(!t.filter(a,y))return}let h,f=()=>(h==null&&(h=this.snapshot()),h);for(let u of n)u.disposed||(u.debounceMs===0?r(u,f()):(u.timer==null&&(u.timer=new Me),u.timer.start(u.debounceMs,()=>{u.disposed||r(u,this.snapshot())})))},c;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))});c=()=>{for(let g of p)g()}}else c=this.observe().subscribe((a,p)=>i(a,p));let d=()=>{c();for(let a of n)a.disposed=!0,a.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}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(d){n?.onError?.(d,s);continue}if(r==null||typeof r!="object"||Array.isArray(r))continue;let i=r,c=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===J&&i.nodes!=null?i:void 0;if(c!=null)try{return o.fromSnapshot(c,n)}catch(d){n?.onError?.(d,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(m=>!n.has(m)).sort(),i=[...n].filter(m=>!s.has(m)).sort(),c=[],d=[];for(let m of n){if(!s.has(m))continue;let b=e.nodes[m],v=t.nodes[m],w=b.v,E=v.v;w!=null&&E!=null&&w.id===E.id&&w.version!==E.version&&d.push({path:m,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=b[R],D=v[R];G!==D&&c.push({path:m,field:R,from:G,to:D})}if(!S)for(let R of["value","meta"]){let G=b[R],D=v[R];at(G,D)||c.push({path:m,field:R,from:G,to:D})}}let a=m=>`${m.from} ${m.to}`,p=new Set(e.edges.map(a)),g=new Set(t.edges.map(a)),h=t.edges.filter(m=>!p.has(a(m))),f=e.edges.filter(m=>!g.has(a(m))),u=new Set(e.subgraphs),y=new Set(t.subgraphs),l=[...y].filter(m=>!u.has(m)).sort(),O=[...u].filter(m=>!y.has(m)).sort();return{nodesAdded:r,nodesRemoved:i,nodesChanged:c,versionChanges:d,edgesAdded:h,edgesRemoved:f,subgraphsAdded:l,subgraphsRemoved:O}}};function gt(o,e){let t=Se.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 Je(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,c=new Map,d=new Map,a=new Map,p=new Set;for(let[b,v]of Object.entries(o.nodes)){if(!b)continue;p.add(b);let w=v.deps??[];i.set(b,w);for(let E of w)E&&(p.add(E),c.has(E)||c.set(E,new Set),c.get(E).add(b))}for(let b of o.edges){if(b==null||typeof b!="object")continue;let v=typeof b.from=="string"?b.from:"",w=typeof b.to=="string"?b.to:"";!v||!w||(p.add(v),p.add(w),a.has(v)||a.set(v,new Set),a.get(v).add(w),d.has(w)||d.set(w,new Set),d.get(w).add(v))}if(!p.has(e))return n.withDetail?s:[];let g=n.both===!0,h=b=>{if(g){let S=i.get(b)??[],R=d.get(b),G=c.get(b),D=a.get(b),k=[...S];return R&&k.push(...R),G&&k.push(...G),D&&k.push(...D),k}if(t==="upstream"){let S=i.get(b)??[],R=d.get(b);return R?[...S,...R]:S}let v=c.get(b),w=a.get(b),E=v?[...v]:[];return w&&E.push(...w),E},f=new Set([e]),u=new Map,y=[{path:e,depth:0}],l=0,O=!1;for(;l<y.length;){let b=y[l++];if(r!=null&&b.depth>=r){h(b.path).length>0&&(O=!0);continue}for(let v of h(b.path))!v||f.has(v)||(f.add(v),u.set(v,b.depth+1),y.push({path:v,depth:b.depth+1}))}let m=[...u.keys()].sort((b,v)=>b<v?-1:b>v?1:0);return n.withDetail?{paths:m,depths:u,truncated:O}:m}function mt(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{A as a,Xe as b,je as c,Fe as d,_e as e,X as f,Ve as g,z as h,J as i,Se as j,gt as k,Je as l};
@@ -1 +1 @@
1
- import{c as $,g as _}from"./chunk-VXPLLA4P.js";import{a as L}from"./chunk-L6NSJVJZ.js";import{i as F}from"./chunk-POXANAJ6.js";import{b as z}from"./chunk-35JTVPOX.js";import{D as j,E as G,G as D,m as E,p as B}from"./chunk-LYCLF26R.js";import{b as P,d as S,i as I,j as K}from"./chunk-CK2E7BTU.js";import{b as ie}from"./chunk-QYADASLV.js";var se={};ie(se,{PipelineGraph:()=>x,decisionKeyOf:()=>q,pipelineGraph:()=>W});function N(y,t){return L("orchestration",y,t)}var q=y=>y.action,x=class extends F{constructor(t,i){super(t,i)}task(t,i,e={}){let a=(e.deps??[]).map(c=>this._resolveStep(c)),p=D(a,i,{name:t,describeKind:"derived",meta:N("task",e.meta)});return this.add(p,{name:t}),p}classify(t,i,e,a={}){let p=this._resolveStep(i),c=D([p],([d])=>{try{return{tag:e(d),value:d}}catch(f){return{tag:"error",value:d,error:f}}},{name:t,describeKind:"derived",meta:N("classify",a.meta)});return this.add(c,{name:t}),c}combine(t,i,e={}){let a=Object.keys(i),p=a.map(d=>this._resolveStep(i[d])),c=D(p,d=>{let f={};for(let s=0;s<a.length;s++)f[a[s]]=d[s];return f},{name:t,describeKind:"derived",meta:N("combine",e.meta)});return this.add(c,{name:t}),c}approvalGate(t,i,e={}){let a=e.maxPending??1e3;if(a<1&&a!==Number.POSITIVE_INFINITY)throw new RangeError("approvalGate: maxPending must be >= 1");let p=e.startOpen??!1;typeof i!="string"&&this.nameOf(i)===void 0&&this.add(i,{name:`${t}/source`});let c=this._resolveStep(i),d=new F(`${t}_state`),f=G([],{name:"pending",equals:()=>!1}),s=G(p,{name:"isOpen"}),R=D([f],([n])=>n.length,{name:"count"}),T=G(0,{name:"droppedCount"}),u=$({name:"decisions",retainedLimit:1024,graph:d});d.add(f,{name:"pending"}),d.add(s,{name:"isOpen"}),d.add(R,{name:"count"}),d.add(T,{name:"droppedCount"}),this.mount(`${t}_state`,d);let l=[],v=!1,k=!1,w=p,M=s.subscribe(n=>{for(let o of n)o[0]===P&&(w=o[1])});this.addDisposer(M);function A(){f.emit([...l])}function C(n,o,r){u.append({action:n,t_ns:B(),...o!==void 0?{items:o,count:o.length}:{},...r!==void 0?{unflushed:r}:{},...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}function U(n){if(l.push(n),l.length>a){let o=l.shift();T.emit(T.cache+1),C("drop",[o])}A()}function O(n){let o=l.splice(0,n);return A(),o}let b=j([c],(n,o,r)=>{let h=r.terminalDeps[0];if(h!==void 0){v=!0;let g=l.length;l=[],A(),C("teardown",void 0,g),o.down(h===!0?[[I]]:[[K,h]]);return}let m=n[0];if(m==null||m.length===0){o.down([[S]]);return}for(let g of m)w?o.emit(g):(U(g),o.down([[S]]))},{name:t,describeKind:"derived",meta:N("approval_gate",e.meta)});if(this.add(b,{name:t}),e.approver!=null){e.approver.cache&&(s.emit(!0),w=!0,e.onceOnly&&(k=!0));let o=e.approver.subscribe(r=>{for(let h of r){if(h[0]!==P)continue;let m=!!h[1];if(m&&!w){if(e.onceOnly){if(k)continue;k=!0}E(()=>{s.emit(!0);let g=O(l.length);C("open",g);for(let te of g){if(v)break;b.emit(te)}})}else if(!m&&w){if(e.onceOnly&&k)continue;E(()=>{s.emit(!1),C("close")})}}});this.addDisposer(o)}let V=n=>{if(v)throw new Error(`approvalGate: ${n}() called after the gate was torn down`)},Y=(n=1)=>{V("approve");let o=O(n);for(let r of o){if(v)break;b.emit(r)}},H=(n=1)=>{V("reject"),O(n)},J=(n,o=1)=>{V("modify");let r=[...l],h=O(o);for(let m=0;m<h.length&&!v;m++)b.emit(n(h[m],m,r))},Q=()=>{V("open"),s.emit(!0);let n=O(l.length);for(let o of n){if(v)break;b.emit(o)}},X=()=>{V("close"),!(e.onceOnly&&k)&&s.emit(!1)},Z=_(Y,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"approve",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ee=_(H,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"reject",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ne=_(J,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"modify",count:n[1]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),re=_(Q,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"open",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),oe=_(X,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"close",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})});return this.addDisposer(R.subscribe(()=>{})),{node:b,pending:f,count:R,isOpen:s,droppedCount:T,decisions:u,audit:u,approve:Z,reject:ee,modify:ne,open:re,close:oe}}approval(t,i,e,a={}){return this.approvalGate(t,i,{...a,approver:e,maxPending:1})}catch(t,i,e,a={}){let p=this._resolveStep(i),c=a.on??"errored",d=j([p],(f,s,R)=>{let T=R.terminalDeps[0];if(T!==void 0){let l=T===!0?{kind:"completed"}:{kind:"errored",error:T};if(c==="terminal"||c===l.kind){s.emit(e(l,s));return}s.down(l.kind==="completed"?[[I]]:[[K,l.error]]);return}let u=f[0];if(u==null||u.length===0){s.down([[S]]);return}for(let l of u)s.emit(l)},{name:t,describeKind:"derived",completeWhenDepsComplete:a.completeWhenDepsComplete??!(c==="completed"||c==="terminal"),errorWhenDepsError:!(c==="errored"||c==="terminal"),meta:N("catch",a.meta)});return this.add(d,{name:t}),d}_resolveStep(t){if(typeof t=="string")return this.resolve(t);if(this.nameOf(t)===void 0)throw new Error(`PipelineGraph "${this.name}": Node dep is not registered. Pass a string path or call graph.add(node) first.`);return t}};function W(y,t){let i=new x(y,t),{factory:e,factoryArgs:a,...p}=t??{};return i.tagFactory("pipelineGraph",z(p)),i}export{q as a,x as b,W as c,se as d};
1
+ import{c as $,g as _}from"./chunk-3ZZX7M25.js";import{a as L}from"./chunk-L6NSJVJZ.js";import{j as F}from"./chunk-ACMJ2ZPS.js";import{b as z}from"./chunk-35JTVPOX.js";import{D as j,E as G,G as D,m as E,p as B}from"./chunk-LYCLF26R.js";import{b as P,d as S,i as I,j as K}from"./chunk-CK2E7BTU.js";import{b as ie}from"./chunk-QYADASLV.js";var se={};ie(se,{PipelineGraph:()=>x,decisionKeyOf:()=>q,pipelineGraph:()=>W});function N(y,t){return L("orchestration",y,t)}var q=y=>y.action,x=class extends F{constructor(t,i){super(t,i)}task(t,i,e={}){let a=(e.deps??[]).map(c=>this._resolveStep(c)),p=D(a,i,{name:t,describeKind:"derived",meta:N("task",e.meta)});return this.add(p,{name:t}),p}classify(t,i,e,a={}){let p=this._resolveStep(i),c=D([p],([d])=>{try{return{tag:e(d),value:d}}catch(f){return{tag:"error",value:d,error:f}}},{name:t,describeKind:"derived",meta:N("classify",a.meta)});return this.add(c,{name:t}),c}combine(t,i,e={}){let a=Object.keys(i),p=a.map(d=>this._resolveStep(i[d])),c=D(p,d=>{let f={};for(let s=0;s<a.length;s++)f[a[s]]=d[s];return f},{name:t,describeKind:"derived",meta:N("combine",e.meta)});return this.add(c,{name:t}),c}approvalGate(t,i,e={}){let a=e.maxPending??1e3;if(a<1&&a!==Number.POSITIVE_INFINITY)throw new RangeError("approvalGate: maxPending must be >= 1");let p=e.startOpen??!1;typeof i!="string"&&this.nameOf(i)===void 0&&this.add(i,{name:`${t}/source`});let c=this._resolveStep(i),d=new F(`${t}_state`),f=G([],{name:"pending",equals:()=>!1}),s=G(p,{name:"isOpen"}),R=D([f],([n])=>n.length,{name:"count"}),T=G(0,{name:"droppedCount"}),u=$({name:"decisions",retainedLimit:1024,graph:d});d.add(f,{name:"pending"}),d.add(s,{name:"isOpen"}),d.add(R,{name:"count"}),d.add(T,{name:"droppedCount"}),this.mount(`${t}_state`,d);let l=[],v=!1,k=!1,w=p,M=s.subscribe(n=>{for(let o of n)o[0]===P&&(w=o[1])});this.addDisposer(M);function A(){f.emit([...l])}function C(n,o,r){u.append({action:n,t_ns:B(),...o!==void 0?{items:o,count:o.length}:{},...r!==void 0?{unflushed:r}:{},...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}function U(n){if(l.push(n),l.length>a){let o=l.shift();T.emit(T.cache+1),C("drop",[o])}A()}function O(n){let o=l.splice(0,n);return A(),o}let b=j([c],(n,o,r)=>{let h=r.terminalDeps[0];if(h!==void 0){v=!0;let g=l.length;l=[],A(),C("teardown",void 0,g),o.down(h===!0?[[I]]:[[K,h]]);return}let m=n[0];if(m==null||m.length===0){o.down([[S]]);return}for(let g of m)w?o.emit(g):(U(g),o.down([[S]]))},{name:t,describeKind:"derived",meta:N("approval_gate",e.meta)});if(this.add(b,{name:t}),e.approver!=null){e.approver.cache&&(s.emit(!0),w=!0,e.onceOnly&&(k=!0));let o=e.approver.subscribe(r=>{for(let h of r){if(h[0]!==P)continue;let m=!!h[1];if(m&&!w){if(e.onceOnly){if(k)continue;k=!0}E(()=>{s.emit(!0);let g=O(l.length);C("open",g);for(let te of g){if(v)break;b.emit(te)}})}else if(!m&&w){if(e.onceOnly&&k)continue;E(()=>{s.emit(!1),C("close")})}}});this.addDisposer(o)}let V=n=>{if(v)throw new Error(`approvalGate: ${n}() called after the gate was torn down`)},Y=(n=1)=>{V("approve");let o=O(n);for(let r of o){if(v)break;b.emit(r)}},H=(n=1)=>{V("reject"),O(n)},J=(n,o=1)=>{V("modify");let r=[...l],h=O(o);for(let m=0;m<h.length&&!v;m++)b.emit(n(h[m],m,r))},Q=()=>{V("open"),s.emit(!0);let n=O(l.length);for(let o of n){if(v)break;b.emit(o)}},X=()=>{V("close"),!(e.onceOnly&&k)&&s.emit(!1)},Z=_(Y,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"approve",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ee=_(H,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"reject",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ne=_(J,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"modify",count:n[1]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),re=_(Q,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"open",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),oe=_(X,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"close",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})});return this.addDisposer(R.subscribe(()=>{})),{node:b,pending:f,count:R,isOpen:s,droppedCount:T,decisions:u,audit:u,approve:Z,reject:ee,modify:ne,open:re,close:oe}}approval(t,i,e,a={}){return this.approvalGate(t,i,{...a,approver:e,maxPending:1})}catch(t,i,e,a={}){let p=this._resolveStep(i),c=a.on??"errored",d=j([p],(f,s,R)=>{let T=R.terminalDeps[0];if(T!==void 0){let l=T===!0?{kind:"completed"}:{kind:"errored",error:T};if(c==="terminal"||c===l.kind){s.emit(e(l,s));return}s.down(l.kind==="completed"?[[I]]:[[K,l.error]]);return}let u=f[0];if(u==null||u.length===0){s.down([[S]]);return}for(let l of u)s.emit(l)},{name:t,describeKind:"derived",completeWhenDepsComplete:a.completeWhenDepsComplete??!(c==="completed"||c==="terminal"),errorWhenDepsError:!(c==="errored"||c==="terminal"),meta:N("catch",a.meta)});return this.add(d,{name:t}),d}_resolveStep(t){if(typeof t=="string")return this.resolve(t);if(this.nameOf(t)===void 0)throw new Error(`PipelineGraph "${this.name}": Node dep is not registered. Pass a string path or call graph.add(node) first.`);return t}};function W(y,t){let i=new x(y,t),{factory:e,factoryArgs:a,...p}=t??{};return i.tagFactory("pipelineGraph",z(p)),i}export{q as a,x as b,W as c,se as d};
@@ -0,0 +1 @@
1
+ import{a as N}from"./chunk-L6NSJVJZ.js";import{f as ue,j as ae}from"./chunk-ACMJ2ZPS.js";import{a as V}from"./chunk-ESMPEKEV.js";import{x as L}from"./chunk-6YFZMUMR.js";import{a as S,b as P,i as se}from"./chunk-4VVTGLXJ.js";import{m as de}from"./chunk-2K5RXLAH.js";import{b as oe,c as R}from"./chunk-35JTVPOX.js";import{D as F,F as C,m as K,o as Y}from"./chunk-LYCLF26R.js";import{b as y,c as k,d as w,f as U,g as q,h as _,i as T,j as g}from"./chunk-CK2E7BTU.js";var $=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 W(e,t,n){if(t.length===0)throw new RangeError("budgetGate requires at least one constraint");let r=t.map(c=>c.node),i=[e,...r],l=new $,u=!1,s=!1,o=Symbol("budget-gate"),d=new Array(t.length);function f(){return t.every((c,b)=>c.check(d[b]))}function a(c){for(;l.size>0&&f();){let b=l.shift();c.emit(b)}l.size===0&&s&&(s=!1,c.down([[w]]))}return F([],(c,b)=>{for(let m=0;m<t.length;m++)d[m]=t[m].node.cache;let h=[];for(let m=0;m<i.length;m++){let O=i[m];h.push(O.subscribe(E=>{for(let M of E)p(M,m,b)}))}return()=>{for(let m of h)m()}},{...n,describeKind:"derived",meta:N("resilience","budget_gate",n?.meta)});function p(c,b,h){let m=c[0];if(b===0){if(m===y)return f()&&l.size===0?h.emit(c[1]):(l.push(c[1]),u||(u=!0,h.up([[U,o]]))),!0;if(m===k)return h.down([[k]]),!0;if(m===w)return l.size===0?h.down([[w]]):s=!0,!0;if(m===T||m===g){for(;l.size>0;)h.emit(l.shift());return s=!1,u&&(u=!1,h.up([[q,o]])),h.down([c]),!0}return!1}if(m===y&&(d[b-1]=c[1]),m===y||m===w){let O=f();return O&&l.size>0?(a(h),l.size===0&&u&&(u=!1,h.up([[q,o]]))):!O&&!u&&l.size>0&&(u=!0,h.up([[U,o]])),!0}return m===k?!0:m===g?(h.down([c]),!0):m===T}}function z(e){return typeof e=="object"&&e!==null&&"subscribe"in e&&"down"in e}function fe(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 D=class extends ae{output;status;lastError;breakerState;droppedCount;rateLimitState;constructor(t,n={}){super(n.name??"resilient_pipeline",n.graph);let r=t,i,l,u;if(n.rateLimit!=null)if(z(n.rateLimit)){let o=r,d=n.rateLimit;r=L(d,f=>{let a={...f,maxBuffer:f.maxBuffer??1/0,meta:N("resilient","rate-limit")};return Z(o,a).node}),this.add(r,{name:"rateLimited"})}else{let o={...n.rateLimit,maxBuffer:n.rateLimit.maxBuffer??1/0,meta:N("resilient","rate-limit")},d=Z(r,o);r=d.node,i=d.droppedCount,l=d.rateLimitState,this.add(r,{name:"rateLimited"}),this.add(i,{name:"droppedCount"}),this.add(l,{name:"rateLimitState"})}if(n.budget!=null)if(z(n.budget)){let o=r,d=n.budget;r=L(d,f=>f.length>0?W(o,f,{meta:N("resilient","budget")}):o),this.add(r,{name:"budgetGated"})}else n.budget.length>0&&(r=W(r,n.budget,{meta:N("resilient","budget")}),this.add(r,{name:"budgetGated"}));if(n.breaker!=null)if(z(n.breaker)){let o=r,d=n.breaker,f=n.breakerOnOpen??"skip";r=L(d,a=>{let p=J(a);return X(p,{onOpen:f,meta:N("resilient","breaker")})(o).node}),this.add(r,{name:"breakerWrapped"})}else{let o=J(n.breaker),d=n.breakerOnOpen??"skip",f=X(o,{onOpen:d,meta:N("resilient","breaker")})(r);r=f.node,u=f.breakerState,this.add(r,{name:"breakerWrapped"}),this.add(u,{name:"breakerState"})}if(n.timeoutMs!=null)if(z(n.timeoutMs)){let o=r,d=n.timeoutMs;r=L(d,f=>(fe(f),H(o,f*1e6,{meta:N("resilient","timeout")}))),this.add(r,{name:"timeoutWrapped"})}else fe(n.timeoutMs),r=H(r,n.timeoutMs*1e6,{meta:N("resilient","timeout")}),this.add(r,{name:"timeoutWrapped"});if(n.retry!=null)if(z(n.retry)){let o=r,d=n.retry;r=L(d,f=>Q(o,{...f,meta:N("resilient","retry")})),this.add(r,{name:"retryWrapped"})}else r=Q(r,{...n.retry,meta:N("resilient","retry")}),this.add(r,{name:"retryWrapped"});n.fallback!==void 0&&(r=ce(r,n.fallback,{meta:N("resilient","fallback")}),this.add(r,{name:"fallbackWrapped"}));let s=le(r,{initialStatus:n.initialStatus??"pending",meta:N("resilient","status")});this.output=s.node,this.status=s.status,this.lastError=s.error,this.breakerState=u,this.droppedCount=i,this.rateLimitState=l,this.add(this.output,{name:"output"}),this.add(this.status,{name:"status"}),this.add(this.lastError,{name:"lastError"})}};function ye(e,t={}){let n=new D(e,t);return n.tagFactory("resilientPipeline",oe(t)),n}function v(e){return{describeKind:"derived",...e}}function we(e){return e<0?0:e}function re(e){return e[1]}function Te(e){if(typeof e!="number"||!Number.isFinite(e))throw new TypeError("backoff strategy must return a finite number");return e<0?0:e}function me(e){let t=e?.count,n=e?.backoff;if(n!==void 0&&t===void 0)throw new RangeError("retry({ backoff }) requires explicit count to prevent unbounded retries; pass { count: <n>, backoff: ... }");let r=t!==void 0?t:0;if(r<0)throw new RangeError("retry count must be >= 0");let i=n===void 0?null:typeof n=="string"?se(n):n;return{maxRetries:r,strategy:i}}function pe(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 be(e,t,n){let r=0,i=!1,l=null,u,s=new V;function o(){u?.(),u=void 0}function d(a){if(i)return;if(r>=e.maxRetries){o(),n.down([[g,a]]);return}let p=e.strategy===null?0:e.strategy(r,a,l);if(p==null){o(),n.down([[g,a]]);return}let c;try{c=Te(p)}catch{o(),n.down([[g,a]]);return}l=c,r+=1,o();let b=c>0?c/1e6:1;s.start(b,()=>{i||f()})}function f(){s.cancel(),o();let a;try{a=t()}catch(p){d(p);return}u=a.subscribe(p=>{if(!i)for(let c of p){let b=c[0];if(b===k)n.down([[k]]);else if(b===y)r=0,l=null,n.emit(c[1]);else if(b===w)n.down([[w]]);else if(b===T)o(),n.down([[T]]);else if(b===g){d(re(c));return}else n.down([c])}})}return f(),()=>{i=!0,s.cancel(),o()}}function Q(e,t){return typeof e=="function"?ge(e,t):ke(e,t)}function ke(e,t){let n=me(t);return C(r=>be(n,()=>e,r),{...v(),initial:e.cache,meta:{...t?.meta??{},...R("retry",pe(t))}})}function ge(e,t){let n=me(t);return C(r=>be(n,e,r),{...v(),initial:t?.initial,meta:{...t?.meta??{},...R("retry",pe(t))}})}var ee=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};function J(e){let t=Math.max(1,e?.failureThreshold??5),n=we(e?.cooldownNs??30*1e9),r=e?.cooldown??null,i=Math.max(1,e?.halfOpenMax??1),l=e?.now??Y,u="closed",s=0,o=0,d=0,f=n,a=0;function p(){if(!r)return n;let h=r(o);return h!==null?h:n}function c(){u="open",f=p(),d=l(),a=0}return{canExecute(){return u==="closed"?!0:u==="open"?l()-d>=f?(u="half-open",a=1,!0):!1:a<i?(a++,!0):!1},recordSuccess(){u==="half-open"?(u="closed",s=0,o=0):u==="closed"&&(s=0)},recordFailure(h){if(u==="half-open"){o++,c();return}u==="closed"&&(s++,s>=t&&c())},get state(){return u},get failureCount(){return s},reset(){u="closed",s=0,o=0,a=0}}}function X(e,t){let n=t?.onOpen??"skip",r=t?.meta;return i=>{let l=F([],(u,s)=>{function o(){l.meta.breakerState.down([[y,e.state]])}let d=i.subscribe(f=>{for(let a of f){let p=a[0];p===k?s.down([[k]]):p===y?e.canExecute()?(o(),s.emit(a[1])):(o(),n==="error"?s.down([[g,new ee]]):s.down([[w]])):p===w?s.down([[w]]):p===T?(e.recordSuccess(),o(),s.down([[T]])):p===g?(e.recordFailure(re(a)),o(),s.down([a])):s.down([a])}});return o(),d},{...v(),meta:{...r??{},breakerState:e.state,...R("withBreaker",{onOpen:n})},completeWhenDepsComplete:!1,initial:i.cache});return{node:l,breakerState:l.meta.breakerState}}}function Ne(e,t,n){if(e<=0)throw new RangeError("capacity must be > 0");if(t<0)throw new RangeError("refillPerSecond must be >= 0");let r=n?.clock??Y,i=e,l=r();function u(s){if(t>0){let o=s-l;i=Math.min(e,i+o/1e9*t)}l=s}return{available(){return u(r()),i},tryConsume(s=1){if(s<=0)return!0;let o=r();return u(o),i>=s?(i-=s,!0):!1},putBack(s=1){s<=0||(u(r()),i=Math.min(e,i+s))}}}var te=class extends Error{name="RateLimiterOverflowError";constructor(t){super(`rateLimiter buffer overflow (maxBuffer=${t})`)}};function Re(e,t){return e.droppedCount===t.droppedCount&&e.pendingCount===t.pendingCount&&e.paused===t.paused}var G=Object.freeze({droppedCount:0,pendingCount:0,paused:!1});function Z(e,t){let{maxEvents:n,windowNs:r}=t;if(n<=0)throw new RangeError("maxEvents must be > 0");if(r<=0)throw new RangeError("windowNs must be > 0");let i=t.maxBuffer;if(i===void 0)throw new RangeError("rateLimiter requires explicit maxBuffer (use Infinity to opt in to unbounded)");let l=i===1/0;if(!l&&(!Number.isInteger(i)||i<1))throw new RangeError("maxBuffer must be a positive integer (or Infinity for unbounded)");let u=t.onOverflow??"drop-newest",s=n*1e9/r,o=C(d=>{let f=Ne(n,s),a=l?Se():Oe(i),p=new V,c=!1,b=0,h=1e9/s,m=o.meta.droppedCount,O=o.meta.rateLimitState,E=G;function M(){m.emit(b);let A={droppedCount:b,pendingCount:a.size,paused:a.size>0};Re(E,A)||(E=A,O.emit(A))}E=G,m.emit(0),O.emit(G);function ie(){for(;a.size>0;)if(f.tryConsume(1))d.emit(a.shift()),M();else{p.start(Math.max(1,h/1e6),ie);return}}function j(){b+=1,M()}function I(){for(c=!0,p.cancel();a.size>0;)a.shift();b=0}let he=e.subscribe(A=>{for(let x of A){if(c)return;let B=x[0];if(B===k)d.down([[k]]);else if(B===y){if(!l&&a.size>=i)if(u==="drop-newest")j();else if(u==="drop-oldest")a.shift(),a.push(x[1]),j();else{j(),I(),d.down([[g,new te(i)]]);return}else a.push(x[1]),M();ie()}else if(B===w)d.down([[w]]);else if(B===T)I(),d.down([[T]]);else if(B===g)I(),d.down([x]);else if(B===_){I(),d.down([x]);return}else d.down([x])}});return()=>{c=!0,p.cancel(),he()}},{...v(),initial:e.cache,meta:{...t.meta??{},droppedCount:0,rateLimitState:G,...R("rateLimiter",t)}});return{node:o,droppedCount:o.meta.droppedCount,rateLimitState:o.meta.rateLimitState}}function Oe(e){let t=new ue(e);return{push:n=>t.push(n),shift:()=>t.shift(),get size(){return t.size}}}function Se(){let e=[];return{push:t=>{e.push(t)},shift:()=>e.shift(),get size(){return e.length}}}function le(e,t){let n=t?.initialStatus??"pending",r=t?.meta,i=F([],(l,u)=>{let s=n;return i.meta.status.down([[y,n]]),i.meta.error.down([[y,null]]),e.subscribe(d=>{for(let f of d){let a=f[0];if(a===k)u.down([[k]]);else if(a===y)s==="errored"?K(()=>{i.meta.error.down([[y,null]]),i.meta.status.down([[y,"running"]])}):i.meta.status.down([[y,"running"]]),s="running",u.emit(f[1]);else if(a===w)u.down([[w]]);else if(a===T)i.meta.status.down([[y,"completed"]]),s="completed",u.down([[T]]);else if(a===g){let p=re(f);K(()=>{i.meta.error.down([[y,p]]),i.meta.status.down([[y,"errored"]])}),s="errored",u.down([f])}else u.down([f])}})},{...v(),meta:{...r??{},status:n,error:null,...R("withStatus",{initialStatus:n})},completeWhenDepsComplete:!1,resubscribable:!0,initial:e.cache});return{node:i,status:i.meta.status,error:i.meta.error}}var ne=class extends Error{name="TimeoutError";constructor(t){super(`Timed out after ${t/1e6}ms`)}};function ve(e){return e!=null&&typeof e=="object"&&"cache"in e&&typeof e.subscribe=="function"}function xe(e){return e!=null&&typeof e.then=="function"}function Be(e){return e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function"}function ce(e,t,n){let r=n?.meta;return C(i=>{let l,u;function s(){u?.(),u=void 0,ve(t)||xe(t)||Be(t)?l=de(t).subscribe(d=>{i.down(d);for(let f of d){let a=f[0];if(a===T||a===g||a===_){l=void 0;return}}}):(i.emit(t),i.down([[T]]))}return u=e.subscribe(o=>{for(let d of o){let f=d[0];if(f===k)i.down([[k]]);else if(f===y)i.emit(d[1]);else if(f===w)i.down([[w]]);else if(f===T)i.down([[T]]);else if(f===g){s();return}else if(f===_){l?.(),i.down([d]);return}else i.down([d])}}),()=>{u?.(),l?.()}},{...v(),initial:e.cache,meta:{...r??{},...R("fallback")}})}function H(e,t,n){if(t<=0)throw new RangeError("timeoutNs must be > 0");let r=n?.meta;return C(i=>{let l=!1,u=new V;function s(){let d=t/1e6;u.start(d,()=>{l||(l=!0,o(),i.down([[g,new ne(t)]]))})}let o=e.subscribe(d=>{for(let f of d){if(l)return;let a=f[0];if(a===k)i.down([[k]]);else if(a===y)s(),i.emit(f[1]);else if(a===w)i.down([[w]]);else if(a===T){u.cancel(),l=!0,i.down([[T]]);return}else if(a===g){u.cancel(),l=!0,i.down([f]);return}else if(a===_){u.cancel(),l=!0,i.down([f]);return}else i.down([f])}});return s(),()=>{l=!0,u.cancel(),o()}},{...v(),initial:e.cache,meta:{...r??{},...R("timeout",{timeoutNs:t})}})}export{W as a,D as b,ye as c,Q as d,ee as e,J as f,X as g,Ne as h,te as i,Z as j,le as k,ne as l,ce as m,H as n};
@@ -1 +1 @@
1
- import{i as f}from"./chunk-POXANAJ6.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-ACMJ2ZPS.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};