@graphrefly/graphrefly 0.34.0 → 0.36.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 (333) hide show
  1. package/dist/{cascading-DKIb6Pk8.d.cts → cascading-B25wxpRa.d.cts} +3 -3
  2. package/dist/{cascading-Bg0a4VSf.d.ts → cascading-BsJ4GbnS.d.ts} +3 -3
  3. package/dist/chunk-3U7IIQB2.js +1 -0
  4. package/dist/{chunk-YDWTVO4E.js → chunk-44QWWUA3.js} +1 -1
  5. package/dist/chunk-5CPPC75H.js +1 -0
  6. package/dist/chunk-5CZ3KIRJ.js +1 -0
  7. package/dist/chunk-5KPIYVCC.js +7 -0
  8. package/dist/{chunk-WBWBY6LI.js → chunk-5RTZ6DXG.js} +1 -1
  9. package/dist/{chunk-IPNJDNE7.js → chunk-5Z3AFBN7.js} +1 -1
  10. package/dist/{chunk-C5DINHNP.js → chunk-6G5YD37E.js} +1 -1
  11. package/dist/{chunk-TONEKQM3.js → chunk-7LYIKMW5.js} +1 -1
  12. package/dist/chunk-A5HZZYRK.js +1 -0
  13. package/dist/{chunk-CJMFZXIZ.js → chunk-AACJX2L7.js} +1 -1
  14. package/dist/chunk-AQC53OWG.js +1 -0
  15. package/dist/chunk-CE72X3WO.js +1 -0
  16. package/dist/chunk-CGA5RXO6.js +1 -0
  17. package/dist/chunk-D5RFJOZ2.js +1 -0
  18. package/dist/chunk-DBPFMCVH.js +1 -0
  19. package/dist/chunk-F36TA3ET.js +1 -0
  20. package/dist/chunk-F3IGTWCQ.js +1 -0
  21. package/dist/chunk-F672GV32.js +1 -0
  22. package/dist/{chunk-GCUYSIM4.js → chunk-GWOKTENT.js} +1 -1
  23. package/dist/{chunk-GAOX6OPT.js → chunk-I57VSGRB.js} +1 -1
  24. package/dist/{chunk-4NYSEUKV.js → chunk-J6TGRQUP.js} +1 -1
  25. package/dist/{chunk-4F564IPP.js → chunk-JJTF75VS.js} +1 -1
  26. package/dist/{chunk-BY4WKPKM.js → chunk-JUJEPZOI.js} +1 -1
  27. package/dist/chunk-K5ZXJPWU.js +5 -0
  28. package/dist/{chunk-TZLEMGAK.js → chunk-KCE6WWJE.js} +2 -2
  29. package/dist/chunk-KL7CILPL.js +1 -0
  30. package/dist/chunk-KUVDFOJH.js +1 -0
  31. package/dist/{chunk-PBN426RU.js → chunk-LO3LO2TO.js} +1 -1
  32. package/dist/chunk-MQZWA3DF.js +1 -0
  33. package/dist/chunk-MYFR67PY.js +18 -0
  34. package/dist/{chunk-65WWQ5CB.js → chunk-N2GCKKKH.js} +5 -5
  35. package/dist/{chunk-KN2UMFT6.js → chunk-PCD2MU7X.js} +1 -1
  36. package/dist/{chunk-SFIM774L.js → chunk-PYEIPRSZ.js} +1 -1
  37. package/dist/chunk-Q7EUZ6NN.js +1 -0
  38. package/dist/{chunk-U2T2XWDA.js → chunk-QKUWS7CO.js} +1 -1
  39. package/dist/{chunk-Q46YJCQH.js → chunk-T6RPUERH.js} +1 -1
  40. package/dist/chunk-TQSTS3BY.js +1 -0
  41. package/dist/chunk-VN6RDSK2.js +1 -0
  42. package/dist/{chunk-UF746BQ4.js → chunk-XINLP35X.js} +1 -1
  43. package/dist/{chunk-A3GDELMY.js → chunk-YBA5N4XY.js} +7 -7
  44. package/dist/{chunk-INXDSJRC.js → chunk-YOUAVGHJ.js} +1 -1
  45. package/dist/compat/index.cjs +10 -10
  46. package/dist/compat/index.d.cts +17 -14
  47. package/dist/compat/index.d.ts +17 -14
  48. package/dist/compat/index.js +1 -1
  49. package/dist/compat/jotai/index.d.cts +2 -2
  50. package/dist/compat/jotai/index.d.ts +2 -2
  51. package/dist/compat/nanostores/index.d.cts +2 -2
  52. package/dist/compat/nanostores/index.d.ts +2 -2
  53. package/dist/compat/nestjs/index.cjs +12 -12
  54. package/dist/compat/nestjs/index.d.cts +9 -6
  55. package/dist/compat/nestjs/index.d.ts +9 -6
  56. package/dist/compat/nestjs/index.js +1 -1
  57. package/dist/compat/react/index.d.cts +2 -2
  58. package/dist/compat/react/index.d.ts +2 -2
  59. package/dist/compat/solid/index.d.cts +2 -2
  60. package/dist/compat/solid/index.d.ts +2 -2
  61. package/dist/compat/svelte/index.d.cts +2 -2
  62. package/dist/compat/svelte/index.d.ts +2 -2
  63. package/dist/compat/vue/index.d.cts +2 -2
  64. package/dist/compat/vue/index.d.ts +2 -2
  65. package/dist/compat/zustand/index.cjs +7 -7
  66. package/dist/compat/zustand/index.d.cts +5 -4
  67. package/dist/compat/zustand/index.d.ts +5 -4
  68. package/dist/compat/zustand/index.js +1 -1
  69. package/dist/{composite-BPDU_XV1.d.ts → composite-CT_mApQD.d.ts} +2 -2
  70. package/dist/{composite-CmvdhTJe.d.cts → composite-_XckYx2e.d.cts} +2 -2
  71. package/dist/{content-addressed-storage-DqIWCmZG.d.cts → content-addressed-storage-4-ST1tYk.d.cts} +5 -5
  72. package/dist/{content-addressed-storage-BUiREIuj.d.ts → content-addressed-storage-DuYMjV7o.d.ts} +5 -5
  73. package/dist/core/index.d.cts +4 -4
  74. package/dist/core/index.d.ts +4 -4
  75. package/dist/extra/browser.cjs +1 -1
  76. package/dist/extra/browser.d.cts +4 -3
  77. package/dist/extra/browser.d.ts +4 -3
  78. package/dist/extra/browser.js +1 -1
  79. package/dist/extra/index.cjs +18 -18
  80. package/dist/extra/index.d.cts +13 -12
  81. package/dist/extra/index.d.ts +13 -12
  82. package/dist/extra/index.js +1 -1
  83. package/dist/extra/node.cjs +2 -3
  84. package/dist/extra/node.d.cts +3 -3
  85. package/dist/extra/node.d.ts +3 -3
  86. package/dist/extra/node.js +2 -2
  87. package/dist/extra/operators.cjs +1 -1
  88. package/dist/extra/operators.d.cts +1 -1
  89. package/dist/extra/operators.d.ts +1 -1
  90. package/dist/extra/operators.js +1 -1
  91. package/dist/extra/reactive.cjs +1 -1
  92. package/dist/extra/reactive.d.cts +4 -3
  93. package/dist/extra/reactive.d.ts +4 -3
  94. package/dist/extra/reactive.js +1 -1
  95. package/dist/extra/sources.cjs +1 -1
  96. package/dist/extra/sources.d.cts +57 -2
  97. package/dist/extra/sources.d.ts +57 -2
  98. package/dist/extra/sources.js +1 -1
  99. package/dist/extra/storage-browser.cjs +1 -1
  100. package/dist/extra/storage-browser.d.cts +8 -42
  101. package/dist/extra/storage-browser.d.ts +8 -42
  102. package/dist/extra/storage-browser.js +1 -1
  103. package/dist/extra/storage-core.cjs +1 -1
  104. package/dist/extra/storage-core.d.cts +13 -83
  105. package/dist/extra/storage-core.d.ts +13 -83
  106. package/dist/extra/storage-core.js +1 -1
  107. package/dist/extra/storage-node.cjs +1 -2
  108. package/dist/extra/storage-node.d.cts +1 -59
  109. package/dist/extra/storage-node.d.ts +1 -59
  110. package/dist/extra/storage-node.js +0 -1
  111. package/dist/extra/storage-tiers-browser.cjs +1 -0
  112. package/dist/extra/storage-tiers-browser.d.cts +49 -0
  113. package/dist/extra/storage-tiers-browser.d.ts +49 -0
  114. package/dist/extra/storage-tiers-browser.js +1 -0
  115. package/dist/extra/storage-tiers-node.cjs +1 -0
  116. package/dist/extra/storage-tiers-node.d.cts +86 -0
  117. package/dist/extra/storage-tiers-node.d.ts +86 -0
  118. package/dist/extra/storage-tiers-node.js +1 -0
  119. package/dist/extra/storage-tiers.cjs +1 -0
  120. package/dist/extra/storage-tiers.d.cts +284 -0
  121. package/dist/extra/storage-tiers.d.ts +284 -0
  122. package/dist/extra/storage-tiers.js +1 -0
  123. package/dist/{fallback-mYSd8vQo.d.ts → fallback-DuEXfA4F.d.ts} +14 -14
  124. package/dist/{fallback-9YznPvPP.d.cts → fallback-axI2cXwt.d.cts} +14 -14
  125. package/dist/graph/index.cjs +3 -3
  126. package/dist/graph/index.d.cts +6 -5
  127. package/dist/graph/index.d.ts +6 -5
  128. package/dist/graph/index.js +1 -1
  129. package/dist/{graph-BROUZPG9.d.ts → graph-Cv-8x0ZI.d.ts} +28 -16
  130. package/dist/{graph-DaoydJ_u.d.cts → graph-kTltt95s.d.cts} +28 -16
  131. package/dist/imperative-audit-ahAE65a9.d.cts +28 -0
  132. package/dist/imperative-audit-ahAE65a9.d.ts +28 -0
  133. package/dist/index-2URa-V4S.d.cts +461 -0
  134. package/dist/{index-Ccv_61jG.d.cts → index-33mF4XyU.d.cts} +110 -27
  135. package/dist/{index-CI5fULSz.d.ts → index-8OxXae3g.d.ts} +1 -1
  136. package/dist/{index-CQ1gt4rn.d.cts → index-9xhIaM-w.d.cts} +1 -1
  137. package/dist/{index-DhWrMTI6.d.cts → index-B3D_z0Z6.d.cts} +1 -1
  138. package/dist/{index-Dia4yc2y.d.ts → index-B4s70vYf.d.ts} +4 -4
  139. package/dist/{index-Db21wuaD.d.ts → index-B5UR87KG.d.ts} +3 -3
  140. package/dist/{index-DuvQAU02.d.ts → index-BBdwz2BW.d.ts} +2 -2
  141. package/dist/{index-CQtnGFrZ.d.cts → index-BC-xjOrd.d.cts} +7 -7
  142. package/dist/{index-ClKm7CFB.d.cts → index-BFuVcqL8.d.cts} +1 -1
  143. package/dist/index-BTJxM-wZ.d.ts +292 -0
  144. package/dist/{index-Jgl7ev9I.d.cts → index-BVNGEX7d.d.cts} +9 -9
  145. package/dist/{index-BkfL5MXh.d.cts → index-BWH17rK_.d.cts} +3 -3
  146. package/dist/{index-CD7qmvSf.d.ts → index-BZ1V5GzX.d.ts} +3 -3
  147. package/dist/{index-BDEhWLF4.d.cts → index-BhkPzu-Z.d.cts} +4 -4
  148. package/dist/{index-zA1uVtk0.d.ts → index-BiomL7AW.d.ts} +1 -1
  149. package/dist/{index-BWiX5foT.d.ts → index-BjWZARLy.d.ts} +1 -1
  150. package/dist/{index-RJX4snyi.d.cts → index-BlRVj-7Q.d.cts} +21 -21
  151. package/dist/{index-Ds3Rz9m9.d.cts → index-BsZlbHM5.d.cts} +3 -3
  152. package/dist/{index-BsxqmV6u.d.ts → index-BuMzxRO2.d.ts} +2 -2
  153. package/dist/{index-C5uMGVJw.d.ts → index-BwYGLgmI.d.ts} +4 -4
  154. package/dist/{index-p0bkNfby.d.cts → index-C4ig7whw.d.cts} +3 -3
  155. package/dist/{index-BRisOxlx.d.ts → index-CDvC1m5p.d.ts} +1 -1
  156. package/dist/{index-ygRFoyrN.d.ts → index-CI_yjtua.d.ts} +2 -2
  157. package/dist/{index-DxEcY7Om.d.ts → index-CIcu6fIR.d.ts} +1 -1
  158. package/dist/{index-Ced0dphF.d.ts → index-CVhBdCMf.d.ts} +9 -9
  159. package/dist/{index-b4a6Sg0R.d.ts → index-CZAixNU3.d.ts} +4 -4
  160. package/dist/index-Cjrpx2Mg.d.cts +171 -0
  161. package/dist/{index-Bd2AjMQY.d.ts → index-Cot94_82.d.ts} +21 -21
  162. package/dist/{index-B1hFhK1K.d.cts → index-CpZKtdMw.d.cts} +1 -1
  163. package/dist/{index-BO6t0HjV.d.cts → index-CqSJ25A9.d.cts} +1 -1
  164. package/dist/{index-BUtCR0k6.d.ts → index-CsD0fqnO.d.ts} +7 -7
  165. package/dist/{index-ChZvMC4M.d.cts → index-CvUrRb4m.d.cts} +7 -7
  166. package/dist/{index-Cp91Sxbo.d.cts → index-D8IyqHvT.d.cts} +3 -3
  167. package/dist/{index-iKsmdnq6.d.cts → index-D9qoEOj_.d.cts} +2 -2
  168. package/dist/{index-nP13Qe6T.d.ts → index-DFe2Pk2u.d.ts} +1 -1
  169. package/dist/{index-IxinNgAH.d.cts → index-DHv2M7s8.d.cts} +16 -15
  170. package/dist/{index-Cn3taOmp.d.cts → index-DKp1CIbG.d.cts} +2 -2
  171. package/dist/{index-CoR-tOZA.d.cts → index-DLyQC5Ww.d.ts} +8 -7
  172. package/dist/{index-CNxdDb2e.d.ts → index-DSSsxS7B.d.ts} +3 -3
  173. package/dist/{index-DheNs40A.d.ts → index-DXSLMoma.d.ts} +2 -2
  174. package/dist/{index-BVTjuKeP.d.cts → index-D_QQ_dTD.d.cts} +1 -1
  175. package/dist/{index-Chi9IiHJ.d.ts → index-DlccEIi3.d.ts} +3 -3
  176. package/dist/{index-DR3XqZlV.d.cts → index-DmtWMP0X.d.cts} +1 -1
  177. package/dist/{index-B5eS17Bz.d.ts → index-DtSVSKnd.d.ts} +47 -32
  178. package/dist/{index-Bi4ZP6Hc.d.ts → index-DxxvGTXp.d.ts} +110 -27
  179. package/dist/index-DzCQt2FJ.d.cts +292 -0
  180. package/dist/{index-D80nGRb9.d.ts → index-DzYTXMBz.d.ts} +3 -3
  181. package/dist/index-EfPb77rT.d.cts +26 -0
  182. package/dist/{index-B-KCkW4M.d.cts → index-GaW6Welt.d.cts} +4 -4
  183. package/dist/{index-D23g00HE.d.cts → index-HCp5ua_i.d.cts} +4 -4
  184. package/dist/{index-DupIl9wI.d.ts → index-JYtN9uqM.d.ts} +1 -1
  185. package/dist/index-KeBhbNg3.d.ts +461 -0
  186. package/dist/{index-BpjQanLs.d.cts → index-PluovH45.d.cts} +2 -2
  187. package/dist/{index-CbCNoogR.d.ts → index-Pu1Wa7en.d.ts} +16 -15
  188. package/dist/{index-ZIQaKIdY.d.cts → index-RJIY7QVW.d.cts} +47 -32
  189. package/dist/{index-yJY9thRY.d.cts → index-XxSeddWP.d.cts} +2 -2
  190. package/dist/{index-C8_bnDBZ.d.cts → index-ZhKyR8co.d.cts} +3 -3
  191. package/dist/{index-3L3RC3VJ.d.ts → index-isdlyeeO.d.ts} +7 -7
  192. package/dist/index-jA_OwwNg.d.ts +26 -0
  193. package/dist/{index-BFHpNSsV.d.ts → index-k67aNfqC.d.cts} +8 -7
  194. package/dist/index-kBUQj-rT.d.ts +171 -0
  195. package/dist/index.cjs +59 -59
  196. package/dist/index.d.cts +53 -49
  197. package/dist/index.d.ts +53 -49
  198. package/dist/index.js +1 -1
  199. package/dist/{meta-BdjSt8ky.d.cts → meta-BGO6C7K9.d.cts} +1 -1
  200. package/dist/{meta-CtDjj7cU.d.ts → meta-CC6EPdpK.d.ts} +1 -1
  201. package/dist/{node-8qx0kgYt.d.cts → node-fSc-hCv8.d.cts} +1 -1
  202. package/dist/{node-8qx0kgYt.d.ts → node-fSc-hCv8.d.ts} +1 -1
  203. package/dist/{observable-B6Ba-TTI.d.cts → observable-Cqty11jG.d.cts} +1 -1
  204. package/dist/{observable-DOniYM2B.d.ts → observable-EAV_rNfM.d.ts} +1 -1
  205. package/dist/patterns/ai/browser.cjs +5 -5
  206. package/dist/patterns/ai/browser.d.cts +4 -4
  207. package/dist/patterns/ai/browser.d.ts +4 -4
  208. package/dist/patterns/ai/browser.js +1 -1
  209. package/dist/patterns/ai/index.cjs +19 -19
  210. package/dist/patterns/ai/index.d.cts +19 -17
  211. package/dist/patterns/ai/index.d.ts +19 -17
  212. package/dist/patterns/ai/index.js +1 -1
  213. package/dist/patterns/ai/node.cjs +1 -2
  214. package/dist/patterns/ai/node.d.cts +9 -9
  215. package/dist/patterns/ai/node.d.ts +9 -9
  216. package/dist/patterns/ai/node.js +1 -1
  217. package/dist/patterns/audit/index.cjs +6 -6
  218. package/dist/patterns/audit/index.d.cts +7 -5
  219. package/dist/patterns/audit/index.d.ts +7 -5
  220. package/dist/patterns/audit/index.js +1 -1
  221. package/dist/patterns/cqrs/index.cjs +7 -7
  222. package/dist/patterns/cqrs/index.d.cts +7 -4
  223. package/dist/patterns/cqrs/index.d.ts +7 -4
  224. package/dist/patterns/cqrs/index.js +1 -1
  225. package/dist/patterns/demo-shell/index.cjs +8 -8
  226. package/dist/patterns/demo-shell/index.d.cts +6 -5
  227. package/dist/patterns/demo-shell/index.d.ts +6 -5
  228. package/dist/patterns/demo-shell/index.js +1 -1
  229. package/dist/patterns/domain-templates/index.cjs +5 -5
  230. package/dist/patterns/domain-templates/index.d.cts +5 -4
  231. package/dist/patterns/domain-templates/index.d.ts +5 -4
  232. package/dist/patterns/domain-templates/index.js +1 -1
  233. package/dist/patterns/graphspec/index.cjs +20 -20
  234. package/dist/patterns/graphspec/index.d.cts +6 -5
  235. package/dist/patterns/graphspec/index.d.ts +6 -5
  236. package/dist/patterns/graphspec/index.js +1 -1
  237. package/dist/patterns/guarded-execution/index.cjs +7 -7
  238. package/dist/patterns/guarded-execution/index.d.cts +8 -6
  239. package/dist/patterns/guarded-execution/index.d.ts +8 -6
  240. package/dist/patterns/guarded-execution/index.js +1 -1
  241. package/dist/patterns/harness/index.cjs +12 -12
  242. package/dist/patterns/harness/index.d.cts +13 -10
  243. package/dist/patterns/harness/index.d.ts +13 -10
  244. package/dist/patterns/harness/index.js +1 -1
  245. package/dist/patterns/job-queue/index.cjs +7 -7
  246. package/dist/patterns/job-queue/index.d.cts +8 -4
  247. package/dist/patterns/job-queue/index.d.ts +8 -4
  248. package/dist/patterns/job-queue/index.js +1 -1
  249. package/dist/patterns/lens/index.cjs +4 -4
  250. package/dist/patterns/lens/index.d.cts +7 -6
  251. package/dist/patterns/lens/index.d.ts +7 -6
  252. package/dist/patterns/lens/index.js +1 -1
  253. package/dist/patterns/memory/index.cjs +1 -1
  254. package/dist/patterns/memory/index.d.cts +5 -4
  255. package/dist/patterns/memory/index.d.ts +5 -4
  256. package/dist/patterns/memory/index.js +1 -1
  257. package/dist/patterns/messaging/index.cjs +7 -7
  258. package/dist/patterns/messaging/index.d.cts +6 -4
  259. package/dist/patterns/messaging/index.d.ts +6 -4
  260. package/dist/patterns/messaging/index.js +1 -1
  261. package/dist/patterns/orchestration/index.cjs +7 -7
  262. package/dist/patterns/orchestration/index.d.cts +8 -5
  263. package/dist/patterns/orchestration/index.d.ts +8 -5
  264. package/dist/patterns/orchestration/index.js +1 -1
  265. package/dist/patterns/process/index.cjs +1 -0
  266. package/dist/patterns/process/index.d.cts +10 -0
  267. package/dist/patterns/process/index.d.ts +10 -0
  268. package/dist/patterns/process/index.js +1 -0
  269. package/dist/patterns/reactive-layout/index.cjs +5 -5
  270. package/dist/patterns/reactive-layout/index.d.cts +6 -5
  271. package/dist/patterns/reactive-layout/index.d.ts +6 -5
  272. package/dist/patterns/reactive-layout/index.js +1 -1
  273. package/dist/patterns/reduction/index.cjs +1 -1
  274. package/dist/patterns/reduction/index.d.cts +5 -4
  275. package/dist/patterns/reduction/index.d.ts +5 -4
  276. package/dist/patterns/reduction/index.js +1 -1
  277. package/dist/patterns/refine-loop/index.cjs +8 -8
  278. package/dist/patterns/refine-loop/index.d.cts +7 -5
  279. package/dist/patterns/refine-loop/index.d.ts +7 -5
  280. package/dist/patterns/refine-loop/index.js +1 -1
  281. package/dist/patterns/resilient-pipeline/index.cjs +1 -1
  282. package/dist/patterns/resilient-pipeline/index.d.cts +7 -6
  283. package/dist/patterns/resilient-pipeline/index.d.ts +7 -6
  284. package/dist/patterns/resilient-pipeline/index.js +1 -1
  285. package/dist/patterns/surface/index.cjs +11 -11
  286. package/dist/patterns/surface/index.d.cts +7 -6
  287. package/dist/patterns/surface/index.d.ts +7 -6
  288. package/dist/patterns/surface/index.js +1 -1
  289. package/dist/pipeline-graph-BlLBWSZ2.d.cts +120 -0
  290. package/dist/pipeline-graph-DdBoRu37.d.ts +120 -0
  291. package/dist/{reactive-layout-DBJ3Vz-m.d.ts → reactive-layout-Btv0-efV.d.ts} +2 -2
  292. package/dist/{reactive-layout-Dk9AOQb_.d.cts → reactive-layout-D9zqqaqK.d.cts} +2 -2
  293. package/dist/reactive-log-ScpWyqny.d.cts +196 -0
  294. package/dist/reactive-log-jirQsxMY.d.ts +196 -0
  295. package/dist/{reactive-map-LjwjcFaW.d.ts → reactive-map-CHyeCf4D.d.ts} +1 -1
  296. package/dist/{reactive-map-Cm89Hk0c.d.cts → reactive-map-DmgeADH8.d.cts} +1 -1
  297. package/dist/{resilience-RjDIHZNZ.d.ts → resilience-BWP2c7Af.d.cts} +27 -45
  298. package/dist/{resilience-N_VtLf7W.d.cts → resilience-Bys63Cpd.d.ts} +27 -45
  299. package/dist/resilience-OBU472D2.js +1 -0
  300. package/dist/{sugar-CQkn_rxB.d.ts → sugar-D13E2M_z.d.ts} +1 -1
  301. package/dist/{sugar-DVEYhR7a.d.cts → sugar-DgaGJcI6.d.cts} +1 -1
  302. package/dist/{topology-tree-BB6oJxMz.d.cts → topology-tree-C50l9ARE.d.cts} +1 -1
  303. package/dist/{topology-tree-CAFOG5S5.d.ts → topology-tree-CJsT24DP.d.ts} +1 -1
  304. package/dist/{types-Cp_4coR_.d.cts → types-BMSGPlpO.d.cts} +1 -1
  305. package/dist/{types-B2LfBvNc.d.ts → types-CidcBDuk.d.ts} +1 -1
  306. package/package.json +41 -1
  307. package/dist/chunk-2JO6LXFT.js +0 -7
  308. package/dist/chunk-2LZ6DL45.js +0 -1
  309. package/dist/chunk-3JXNEPCD.js +0 -2
  310. package/dist/chunk-3Y4BXFFR.js +0 -1
  311. package/dist/chunk-55T3K37W.js +0 -1
  312. package/dist/chunk-6HQ6HVTF.js +0 -1
  313. package/dist/chunk-7Q2WPFQ7.js +0 -1
  314. package/dist/chunk-FKRPIRE6.js +0 -1
  315. package/dist/chunk-HTBOCKVD.js +0 -1
  316. package/dist/chunk-I6VIH3VA.js +0 -1
  317. package/dist/chunk-IB64M7VP.js +0 -1
  318. package/dist/chunk-IJFSR4NU.js +0 -1
  319. package/dist/chunk-LOF5HSD3.js +0 -18
  320. package/dist/chunk-T2TB37TW.js +0 -1
  321. package/dist/chunk-T7EQPKOP.js +0 -1
  322. package/dist/chunk-Y63GWRHO.js +0 -5
  323. package/dist/chunk-YUBV7EEE.js +0 -1
  324. package/dist/index-C2Dey3L-.d.cts +0 -152
  325. package/dist/index-ClJUZAOr.d.cts +0 -101
  326. package/dist/index-Cq7Uqgu4.d.ts +0 -192
  327. package/dist/index-Dtpr2FIB.d.ts +0 -101
  328. package/dist/index-HvJ90_tX.d.ts +0 -152
  329. package/dist/index-wcfc7W-f.d.cts +0 -192
  330. package/dist/reactive-log-CWC7jO4J.d.cts +0 -190
  331. package/dist/reactive-log-CqaBg8nf.d.ts +0 -190
  332. package/dist/resilience-7UZHSSGC.js +0 -1
  333. /package/dist/{chunk-L3KUKDZC.js → chunk-O32GJOUJ.js} +0 -0
@@ -1 +1 @@
1
- import{a as O,b as H,c as j,d as E,e as W,f as ne}from"./chunk-INXDSJRC.js";import{a as N}from"./chunk-L3KUKDZC.js";import{a as X,j as T}from"./chunk-2JO6LXFT.js";import{D as I,E as y,G as L,o as S}from"./chunk-LYCLF26R.js";import{b as te}from"./chunk-QYADASLV.js";var ie={};te(ie,{CanvasMeasureAdapter:()=>$,CliMeasureAdapter:()=>D,ImageSizeAdapter:()=>J,NodeCanvasMeasureAdapter:()=>q,PrecomputedAdapter:()=>V,SvgBoundsAdapter:()=>z,analyzeAndMeasure:()=>O,carveTextLineSlots:()=>E,circleIntervalForBand:()=>Q,computeBlockFlow:()=>_,computeCharPositions:()=>W,computeFlowLines:()=>ee,computeLineBreaks:()=>H,computeTotalHeight:()=>U,layoutNextLine:()=>j,measureBlock:()=>Y,measureBlocks:()=>K,reactiveBlockLayout:()=>re,reactiveFlowLayout:()=>se,reactiveLayout:()=>ne,rectIntervalForBand:()=>Z});var D=class{cellPx;constructor(t){this.cellPx=t?.cellPx??8}measureSegment(t,n){return{width:X(t)*this.cellPx}}},G=class extends Error{name="KeyError"},V=class{metrics;fallback;constructor(t){this.metrics=t.metrics;let n=t.fallback??"per-char";if(n!=="per-char"&&n!=="error")throw new Error(`fallback must be 'per-char' or 'error', got ${JSON.stringify(t.fallback)}`);this.fallback=n}measureSegment(t,n){let i=this.metrics[n];if(i){let o=i[t];if(o!==void 0)return{width:o}}if(this.fallback==="error")throw new G(`PrecomputedAdapter: no metrics for segment ${JSON.stringify(t)} in font ${JSON.stringify(n)}`);let r=0;if(i)for(let o of t){let l=i[o];l!==void 0&&(r+=l)}return{width:r}}},$=class{ctx=null;currentFont="";emojiCorrection;constructor(t){this.emojiCorrection=t?.emojiCorrection??1}getContext(){if(!this.ctx){if(typeof OffscreenCanvas>"u")throw new Error("CanvasMeasureAdapter requires a browser environment with OffscreenCanvas support. Use CliMeasureAdapter or NodeCanvasMeasureAdapter for Node.js.");let n=new OffscreenCanvas(0,0).getContext("2d");if(!n)throw new Error("CanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(t,n){let i=this.getContext();n!==this.currentFont&&(i.font=n,this.currentFont=n);let r=i.measureText(t).width;return this.emojiCorrection!==1&&new RegExp("\\p{Emoji_Presentation}","u").test(t)&&(r*=this.emojiCorrection),{width:r}}clearCache(){this.currentFont=""}},q=class{ctx=null;currentFont="";canvasModule;constructor(t){this.canvasModule=t}getContext(){if(!this.ctx){let n=this.canvasModule.createCanvas(0,0).getContext("2d");if(!n)throw new Error("NodeCanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(t,n){let i=this.getContext();return n!==this.currentFont&&(i.font=n,this.currentFont=n),{width:i.measureText(t).width}}clearCache(){this.currentFont=""}},z=class{measureSvg(t){let n=t.match(/viewBox\s*=\s*["']([^"']+)["']/);if(n){let o=n[1].trim().split(/[\s,]+/);if(o.length>=4){let l=Number.parseFloat(o[2]),a=Number.parseFloat(o[3]);if(Number.isFinite(l)&&Number.isFinite(a)&&l>0&&a>0)return{width:l,height:a};throw new Error("SvgBoundsAdapter: viewBox width/height are missing, non-finite, or not positive")}}let i=t.match(/<svg[^>]*\bwidth\s*=\s*["']?([\d.]+)/),r=t.match(/<svg[^>]*\bheight\s*=\s*["']?([\d.]+)/);if(i&&r){let o=Number.parseFloat(i[1]),l=Number.parseFloat(r[1]);if(Number.isFinite(o)&&Number.isFinite(l)&&o>0&&l>0)return{width:o,height:l};throw new Error("SvgBoundsAdapter: svg width/height attributes are non-finite or not positive")}throw new Error("SvgBoundsAdapter: cannot determine dimensions \u2014 SVG has no viewBox or width/height attributes")}},J=class{sizes;constructor(t){this.sizes=new Map(Object.entries(t))}measureImage(t){let n=this.sizes.get(t);if(!n)throw new Error(`ImageSizeAdapter: no dimensions registered for ${JSON.stringify(t)}`);return{width:n.width,height:n.height}}};function Y(e,t,n,i,r,o,l){switch(e.type){case"text":{let a=e.font??r,m=e.lineHeight??o,d=O(e.text,a,n.text,i),w=H(d,t,n.text,a,i),v=W(w,d,m),B=w.lineCount*m,c=0;for(let x of w.lines)x.width>c&&(c=x.width);return{index:l,type:"text",width:Math.min(c,t),height:B,textSegments:d,textLineBreaks:w,textCharPositions:v}}case"image":{let a,m;if(e.naturalWidth!=null&&e.naturalHeight!=null)a=e.naturalWidth,m=e.naturalHeight;else if(n.image){let d=n.image.measureImage(e.src);a=d.width,m=d.height}else throw new Error(`Image block at index ${l} has no naturalWidth/naturalHeight and no ImageMeasurer adapter`);return a>t&&(m=m*t/a,a=t),{index:l,type:"image",width:a,height:m}}case"svg":{let a,m;if(e.viewBox)a=e.viewBox.width,m=e.viewBox.height;else if(n.svg){let d=n.svg.measureSvg(e.content);a=d.width,m=d.height}else throw new Error(`SVG block at index ${l} has no viewBox and no SvgMeasurer adapter`);return a>t&&(m=m*t/a,a=t),{index:l,type:"svg",width:a,height:m}}}}function K(e,t,n,i,r,o){return e.map((l,a)=>Y(l,t,n,i,r,o,a))}function _(e,t){let n=[],i=0;for(let r=0;r<e.length;r++){let o=e[r];n.push({...o,x:0,y:i}),i+=o.height+(r<e.length-1?t:0)}return n}function U(e){if(e.length===0)return 0;let t=e[e.length-1];return t.y+t.height}function re(e){let{adapters:t,name:n="reactive-block-layout",defaultFont:i="16px sans-serif",defaultLineHeight:r=20}=e,o=new T(n),l=new Map,a=y(e.blocks??[],{name:"blocks"}),m=y(Math.max(0,e.maxWidth??800),{name:"max-width"}),d=y(e.gap??0,{name:"gap"}),w=I([a,m],(c,x,s)=>{let p=c[0]!=null&&c[0].length>0?c[0].at(-1):s.prevData[0],h=c[1]!=null&&c[1].length>0?c[1].at(-1):s.prevData[1],g=S(),u=K(p,h,t,l,i,r),f=S()-g,b=w.meta;b&&(N(b["block-count"],u.length),N(b["layout-time-ns"],f)),x.emit(u);let C=()=>{l.clear(),t.text.clearCache?.()};return{deactivate:C,invalidate:C}},{name:"measured-blocks",describeKind:"derived",meta:{"block-count":0,"layout-time-ns":0},equals:(c,x)=>{let s=c,p=x;if(s==null||p==null)return s===p;if(s.length!==p.length)return!1;for(let h=0;h<s.length;h++){let g=s[h],u=p[h];if(g.type!==u.type||g.width!==u.width||g.height!==u.height||g.index!==u.index)return!1}return!0}}),v=L([w,d],([c,x])=>_(c,x),{name:"block-flow",equals:(c,x)=>{let s=c,p=x;if(s==null||p==null)return s===p;if(s.length!==p.length)return!1;for(let h=0;h<s.length;h++){let g=s[h],u=p[h];if(g.x!==u.x||g.y!==u.y||g.width!==u.width||g.height!==u.height)return!1}return!0}}),B=L([v],([c])=>U(c),{name:"total-height"});return o.add(a,{name:"blocks"}),o.add(m,{name:"max-width"}),o.add(d,{name:"gap"}),o.add(w,{name:"measured-blocks"}),o.add(v,{name:"block-flow"}),o.add(B,{name:"total-height"}),{graph:o,setBlocks:c=>o.set("blocks",c),setMaxWidth:c=>o.set("max-width",Math.max(0,c)),setGap:c=>o.set("gap",c),measuredBlocks:w,blockFlow:v,totalHeight:B}}function Q(e,t,n){let i=e.hPad??0,r=e.vPad??0,o=t-r,l=n+r;if(o>=e.cy+e.r||l<=e.cy-e.r)return null;let a=e.cy>=o&&e.cy<=l?0:e.cy<o?o-e.cy:e.cy-l;if(a>=e.r)return null;let m=Math.sqrt(e.r*e.r-a*a);return{left:e.cx-m-i,right:e.cx+m+i}}function Z(e,t,n){let i=e.hPad??0,r=e.vPad??0;return n<=e.y-r||t>=e.y+e.h+r?null:{left:e.x-i,right:e.x+e.w+i}}function oe(e,t,n){return e.kind==="circle"?Q(e,t,n):Z(e,t,n)}function ee(e,t,n,i,r,o,l){let a=l?.paragraphSpacing??r,m=[],d={segmentIndex:0,graphemeIndex:0};if(e.length===0||n.count<=0||r<=0)return{lines:m,cursor:d};let w=t.paddingX??0,v=t.paddingY??0,B=Math.max(0,t.width-w*2),c=Math.max(0,t.height-v*2),x=n.gap*Math.max(0,n.count-1),s=Math.max(0,(B-x)/n.count);if(s<=0)return{lines:m,cursor:d};e:for(let p=0;p<n.count;p++){let h=w+p*(s+n.gap),g=h+s,u=v;for(;u+r<=v+c;){let f=u+r,b=[];for(let k=0;k<i.length;k++){let M=oe(i[k],u,f);M!==null&&b.push(M)}let C=E({left:h,right:g},b,o);if(C.length===0){u+=r;continue}let P=!1;for(let k=0;k<C.length;k++){let M=C[k],R=M.right-M.left,F=j(e,d,R);if(F===null)return{lines:m,cursor:d};if(F.text.length===0&&F.width===0){d=F.end,P=!0;break}m.push({x:M.left,y:u,width:F.width,slotWidth:R,text:F.text,columnIndex:p,flushToRight:M.right<g-.5}),d=F.end}if(P){u+=a;continue}if(u+=r,d.segmentIndex>=e.length)break e}if(d.segmentIndex>=e.length)break}return{lines:m,cursor:d}}function se(e){let{adapter:t,name:n="reactive-flow-layout",minSlotWidth:i=20}=e,r=new T(n),o=new Map,l=y(e.text??"",{name:"text"}),a=y(e.font??"16px sans-serif",{name:"font"}),m=y(e.lineHeight??20,{name:"line-height"}),d=y(e.container??{width:800,height:600,paddingX:0,paddingY:0},{name:"container"}),w=y(e.columns??{count:1,gap:0},{name:"columns"}),v=y(e.obstacles??[],{name:"obstacles"}),B=y(e.paragraphSpacing??null,{name:"paragraph-spacing"}),c=I([l,a],(s,p,h)=>{let g=s[0],u=g!=null&&g.length>0?g.at(-1):h.prevData[0],f=s[1],b=f!=null&&f.length>0?f.at(-1):h.prevData[1],C=O(u,b,t,o);p.emit(C);let P=()=>{o.clear(),t.clearCache?.()};return{deactivate:P,invalidate:P}},{name:"segments",describeKind:"derived"}),x=L([c,d,w,v,m,B],([s,p,h,g,u,f])=>{let b=s,C=S(),P=f??u,{lines:k,cursor:M}=ee(b,p,h,g,u,i,{paragraphSpacing:P}),R=S()-C,F=Math.max(0,b.length-M.segmentIndex),A=x.meta;return A&&(N(A["line-count"],k.length),N(A["layout-time-ns"],R),N(A["overflow-segments"],F)),k},{name:"flow-lines",meta:{"line-count":0,"layout-time-ns":0,"overflow-segments":0},equals:(s,p)=>{let h=s,g=p;if(h.length!==g.length)return!1;for(let u=0;u<h.length;u++){let f=h[u],b=g[u];if(f.x!==b.x||f.y!==b.y||f.width!==b.width||f.slotWidth!==b.slotWidth||f.text!==b.text||f.columnIndex!==b.columnIndex||f.flushToRight!==b.flushToRight)return!1}return!0}});return r.add(l,{name:"text"}),r.add(a,{name:"font"}),r.add(m,{name:"line-height"}),r.add(d,{name:"container"}),r.add(w,{name:"columns"}),r.add(v,{name:"obstacles"}),r.add(B,{name:"paragraph-spacing"}),r.add(c,{name:"segments"}),r.add(x,{name:"flow-lines"}),{graph:r,setText:s=>r.set("text",s),setFont:s=>r.set("font",s),setLineHeight:s=>r.set("line-height",s),setContainer:s=>r.set("container",s),setColumns:s=>r.set("columns",s),setObstacles:s=>r.set("obstacles",s),setParagraphSpacing:s=>r.set("paragraph-spacing",s),segments:c,flowLines:x}}export{D as a,V as b,$ as c,q as d,z as e,J as f,Y as g,K as h,_ as i,U as j,re as k,Q as l,Z as m,ee as n,se as o,ie as p};
1
+ import{a as O,b as H,c as j,d as E,e as W,f as ne}from"./chunk-YOUAVGHJ.js";import{a as N}from"./chunk-O32GJOUJ.js";import{a as X,j as T}from"./chunk-5KPIYVCC.js";import{D as I,E as y,G as L,o as S}from"./chunk-LYCLF26R.js";import{b as te}from"./chunk-QYADASLV.js";var ie={};te(ie,{CanvasMeasureAdapter:()=>$,CliMeasureAdapter:()=>D,ImageSizeAdapter:()=>J,NodeCanvasMeasureAdapter:()=>q,PrecomputedAdapter:()=>V,SvgBoundsAdapter:()=>z,analyzeAndMeasure:()=>O,carveTextLineSlots:()=>E,circleIntervalForBand:()=>Q,computeBlockFlow:()=>_,computeCharPositions:()=>W,computeFlowLines:()=>ee,computeLineBreaks:()=>H,computeTotalHeight:()=>U,layoutNextLine:()=>j,measureBlock:()=>Y,measureBlocks:()=>K,reactiveBlockLayout:()=>re,reactiveFlowLayout:()=>se,reactiveLayout:()=>ne,rectIntervalForBand:()=>Z});var D=class{cellPx;constructor(t){this.cellPx=t?.cellPx??8}measureSegment(t,n){return{width:X(t)*this.cellPx}}},G=class extends Error{name="KeyError"},V=class{metrics;fallback;constructor(t){this.metrics=t.metrics;let n=t.fallback??"per-char";if(n!=="per-char"&&n!=="error")throw new Error(`fallback must be 'per-char' or 'error', got ${JSON.stringify(t.fallback)}`);this.fallback=n}measureSegment(t,n){let i=this.metrics[n];if(i){let o=i[t];if(o!==void 0)return{width:o}}if(this.fallback==="error")throw new G(`PrecomputedAdapter: no metrics for segment ${JSON.stringify(t)} in font ${JSON.stringify(n)}`);let r=0;if(i)for(let o of t){let l=i[o];l!==void 0&&(r+=l)}return{width:r}}},$=class{ctx=null;currentFont="";emojiCorrection;constructor(t){this.emojiCorrection=t?.emojiCorrection??1}getContext(){if(!this.ctx){if(typeof OffscreenCanvas>"u")throw new Error("CanvasMeasureAdapter requires a browser environment with OffscreenCanvas support. Use CliMeasureAdapter or NodeCanvasMeasureAdapter for Node.js.");let n=new OffscreenCanvas(0,0).getContext("2d");if(!n)throw new Error("CanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(t,n){let i=this.getContext();n!==this.currentFont&&(i.font=n,this.currentFont=n);let r=i.measureText(t).width;return this.emojiCorrection!==1&&new RegExp("\\p{Emoji_Presentation}","u").test(t)&&(r*=this.emojiCorrection),{width:r}}clearCache(){this.currentFont=""}},q=class{ctx=null;currentFont="";canvasModule;constructor(t){this.canvasModule=t}getContext(){if(!this.ctx){let n=this.canvasModule.createCanvas(0,0).getContext("2d");if(!n)throw new Error("NodeCanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(t,n){let i=this.getContext();return n!==this.currentFont&&(i.font=n,this.currentFont=n),{width:i.measureText(t).width}}clearCache(){this.currentFont=""}},z=class{measureSvg(t){let n=t.match(/viewBox\s*=\s*["']([^"']+)["']/);if(n){let o=n[1].trim().split(/[\s,]+/);if(o.length>=4){let l=Number.parseFloat(o[2]),a=Number.parseFloat(o[3]);if(Number.isFinite(l)&&Number.isFinite(a)&&l>0&&a>0)return{width:l,height:a};throw new Error("SvgBoundsAdapter: viewBox width/height are missing, non-finite, or not positive")}}let i=t.match(/<svg[^>]*\bwidth\s*=\s*["']?([\d.]+)/),r=t.match(/<svg[^>]*\bheight\s*=\s*["']?([\d.]+)/);if(i&&r){let o=Number.parseFloat(i[1]),l=Number.parseFloat(r[1]);if(Number.isFinite(o)&&Number.isFinite(l)&&o>0&&l>0)return{width:o,height:l};throw new Error("SvgBoundsAdapter: svg width/height attributes are non-finite or not positive")}throw new Error("SvgBoundsAdapter: cannot determine dimensions \u2014 SVG has no viewBox or width/height attributes")}},J=class{sizes;constructor(t){this.sizes=new Map(Object.entries(t))}measureImage(t){let n=this.sizes.get(t);if(!n)throw new Error(`ImageSizeAdapter: no dimensions registered for ${JSON.stringify(t)}`);return{width:n.width,height:n.height}}};function Y(e,t,n,i,r,o,l){switch(e.type){case"text":{let a=e.font??r,m=e.lineHeight??o,d=O(e.text,a,n.text,i),w=H(d,t,n.text,a,i),v=W(w,d,m),B=w.lineCount*m,c=0;for(let x of w.lines)x.width>c&&(c=x.width);return{index:l,type:"text",width:Math.min(c,t),height:B,textSegments:d,textLineBreaks:w,textCharPositions:v}}case"image":{let a,m;if(e.naturalWidth!=null&&e.naturalHeight!=null)a=e.naturalWidth,m=e.naturalHeight;else if(n.image){let d=n.image.measureImage(e.src);a=d.width,m=d.height}else throw new Error(`Image block at index ${l} has no naturalWidth/naturalHeight and no ImageMeasurer adapter`);return a>t&&(m=m*t/a,a=t),{index:l,type:"image",width:a,height:m}}case"svg":{let a,m;if(e.viewBox)a=e.viewBox.width,m=e.viewBox.height;else if(n.svg){let d=n.svg.measureSvg(e.content);a=d.width,m=d.height}else throw new Error(`SVG block at index ${l} has no viewBox and no SvgMeasurer adapter`);return a>t&&(m=m*t/a,a=t),{index:l,type:"svg",width:a,height:m}}}}function K(e,t,n,i,r,o){return e.map((l,a)=>Y(l,t,n,i,r,o,a))}function _(e,t){let n=[],i=0;for(let r=0;r<e.length;r++){let o=e[r];n.push({...o,x:0,y:i}),i+=o.height+(r<e.length-1?t:0)}return n}function U(e){if(e.length===0)return 0;let t=e[e.length-1];return t.y+t.height}function re(e){let{adapters:t,name:n="reactive-block-layout",defaultFont:i="16px sans-serif",defaultLineHeight:r=20}=e,o=new T(n),l=new Map,a=y(e.blocks??[],{name:"blocks"}),m=y(Math.max(0,e.maxWidth??800),{name:"max-width"}),d=y(e.gap??0,{name:"gap"}),w=I([a,m],(c,x,s)=>{let p=c[0]!=null&&c[0].length>0?c[0].at(-1):s.prevData[0],h=c[1]!=null&&c[1].length>0?c[1].at(-1):s.prevData[1],g=S(),u=K(p,h,t,l,i,r),f=S()-g,b=w.meta;b&&(N(b["block-count"],u.length),N(b["layout-time-ns"],f)),x.emit(u);let C=()=>{l.clear(),t.text.clearCache?.()};return{deactivate:C,invalidate:C}},{name:"measured-blocks",describeKind:"derived",meta:{"block-count":0,"layout-time-ns":0},equals:(c,x)=>{let s=c,p=x;if(s==null||p==null)return s===p;if(s.length!==p.length)return!1;for(let h=0;h<s.length;h++){let g=s[h],u=p[h];if(g.type!==u.type||g.width!==u.width||g.height!==u.height||g.index!==u.index)return!1}return!0}}),v=L([w,d],([c,x])=>_(c,x),{name:"block-flow",equals:(c,x)=>{let s=c,p=x;if(s==null||p==null)return s===p;if(s.length!==p.length)return!1;for(let h=0;h<s.length;h++){let g=s[h],u=p[h];if(g.x!==u.x||g.y!==u.y||g.width!==u.width||g.height!==u.height)return!1}return!0}}),B=L([v],([c])=>U(c),{name:"total-height"});return o.add(a,{name:"blocks"}),o.add(m,{name:"max-width"}),o.add(d,{name:"gap"}),o.add(w,{name:"measured-blocks"}),o.add(v,{name:"block-flow"}),o.add(B,{name:"total-height"}),{graph:o,setBlocks:c=>o.set("blocks",c),setMaxWidth:c=>o.set("max-width",Math.max(0,c)),setGap:c=>o.set("gap",c),measuredBlocks:w,blockFlow:v,totalHeight:B}}function Q(e,t,n){let i=e.hPad??0,r=e.vPad??0,o=t-r,l=n+r;if(o>=e.cy+e.r||l<=e.cy-e.r)return null;let a=e.cy>=o&&e.cy<=l?0:e.cy<o?o-e.cy:e.cy-l;if(a>=e.r)return null;let m=Math.sqrt(e.r*e.r-a*a);return{left:e.cx-m-i,right:e.cx+m+i}}function Z(e,t,n){let i=e.hPad??0,r=e.vPad??0;return n<=e.y-r||t>=e.y+e.h+r?null:{left:e.x-i,right:e.x+e.w+i}}function oe(e,t,n){return e.kind==="circle"?Q(e,t,n):Z(e,t,n)}function ee(e,t,n,i,r,o,l){let a=l?.paragraphSpacing??r,m=[],d={segmentIndex:0,graphemeIndex:0};if(e.length===0||n.count<=0||r<=0)return{lines:m,cursor:d};let w=t.paddingX??0,v=t.paddingY??0,B=Math.max(0,t.width-w*2),c=Math.max(0,t.height-v*2),x=n.gap*Math.max(0,n.count-1),s=Math.max(0,(B-x)/n.count);if(s<=0)return{lines:m,cursor:d};e:for(let p=0;p<n.count;p++){let h=w+p*(s+n.gap),g=h+s,u=v;for(;u+r<=v+c;){let f=u+r,b=[];for(let k=0;k<i.length;k++){let M=oe(i[k],u,f);M!==null&&b.push(M)}let C=E({left:h,right:g},b,o);if(C.length===0){u+=r;continue}let P=!1;for(let k=0;k<C.length;k++){let M=C[k],R=M.right-M.left,F=j(e,d,R);if(F===null)return{lines:m,cursor:d};if(F.text.length===0&&F.width===0){d=F.end,P=!0;break}m.push({x:M.left,y:u,width:F.width,slotWidth:R,text:F.text,columnIndex:p,flushToRight:M.right<g-.5}),d=F.end}if(P){u+=a;continue}if(u+=r,d.segmentIndex>=e.length)break e}if(d.segmentIndex>=e.length)break}return{lines:m,cursor:d}}function se(e){let{adapter:t,name:n="reactive-flow-layout",minSlotWidth:i=20}=e,r=new T(n),o=new Map,l=y(e.text??"",{name:"text"}),a=y(e.font??"16px sans-serif",{name:"font"}),m=y(e.lineHeight??20,{name:"line-height"}),d=y(e.container??{width:800,height:600,paddingX:0,paddingY:0},{name:"container"}),w=y(e.columns??{count:1,gap:0},{name:"columns"}),v=y(e.obstacles??[],{name:"obstacles"}),B=y(e.paragraphSpacing??null,{name:"paragraph-spacing"}),c=I([l,a],(s,p,h)=>{let g=s[0],u=g!=null&&g.length>0?g.at(-1):h.prevData[0],f=s[1],b=f!=null&&f.length>0?f.at(-1):h.prevData[1],C=O(u,b,t,o);p.emit(C);let P=()=>{o.clear(),t.clearCache?.()};return{deactivate:P,invalidate:P}},{name:"segments",describeKind:"derived"}),x=L([c,d,w,v,m,B],([s,p,h,g,u,f])=>{let b=s,C=S(),P=f??u,{lines:k,cursor:M}=ee(b,p,h,g,u,i,{paragraphSpacing:P}),R=S()-C,F=Math.max(0,b.length-M.segmentIndex),A=x.meta;return A&&(N(A["line-count"],k.length),N(A["layout-time-ns"],R),N(A["overflow-segments"],F)),k},{name:"flow-lines",meta:{"line-count":0,"layout-time-ns":0,"overflow-segments":0},equals:(s,p)=>{let h=s,g=p;if(h.length!==g.length)return!1;for(let u=0;u<h.length;u++){let f=h[u],b=g[u];if(f.x!==b.x||f.y!==b.y||f.width!==b.width||f.slotWidth!==b.slotWidth||f.text!==b.text||f.columnIndex!==b.columnIndex||f.flushToRight!==b.flushToRight)return!1}return!0}});return r.add(l,{name:"text"}),r.add(a,{name:"font"}),r.add(m,{name:"line-height"}),r.add(d,{name:"container"}),r.add(w,{name:"columns"}),r.add(v,{name:"obstacles"}),r.add(B,{name:"paragraph-spacing"}),r.add(c,{name:"segments"}),r.add(x,{name:"flow-lines"}),{graph:r,setText:s=>r.set("text",s),setFont:s=>r.set("font",s),setLineHeight:s=>r.set("line-height",s),setContainer:s=>r.set("container",s),setColumns:s=>r.set("columns",s),setObstacles:s=>r.set("obstacles",s),setParagraphSpacing:s=>r.set("paragraph-spacing",s),segments:c,flowLines:x}}export{D as a,V as b,$ as c,q as d,z as e,J as f,Y as g,K as h,_ as i,U as j,re as k,Q as l,Z as m,ee as n,se as o,ie as p};
@@ -1 +1 @@
1
- import{a as P}from"./chunk-4VVTGLXJ.js";import{m as y}from"./chunk-T7EQPKOP.js";import{D as N,F as w,G as W,o as k}from"./chunk-LYCLF26R.js";import{a as C,b as p,c as A,d as m,i as a,j as b}from"./chunk-CK2E7BTU.js";function c(d){return{describeKind:"derived",...d}}function B(d){return{describeKind:"derived",partial:!0,...d}}function Q(d,i,u){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(u))}function S(d,i,u){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(u))}function X(d,i,u,t){return N([d],(e,n,o)=>{"acc"in o.store||(o.store.acc=u);let r=e[0];if(r==null||r.length===0){n.down([[m]]);return}for(let s of r)o.store.acc=i(o.store.acc,s),n.emit(o.store.acc)},{...c(t),initial:u,resetOnTeardown:!0})}function Z(d,i,u,t){return N([d],(e,n,o)=>{if("acc"in o.store||(o.store.acc=u),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 s of r)o.store.acc=i(o.store.acc,s)},{...c(t),completeWhenDepsComplete:!1})}function M(d,i,u){return i<=0?N([d],(t,e,n)=>{n.store.completed||(n.store.completed=!0,e.down([[a]]))},{...c(u),completeWhenDepsComplete:!1}):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(u),completeWhenDepsComplete:!1})}function V(d,i,u){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 s of o)n.store.skipped++,n.store.skipped<=i||(e.emit(s),r=!0);r||e.down([[m]])},c(u))}function $(d,i,u){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(u),completeWhenDepsComplete:!1})}function ee(d,i,u){let t=u?.predicate??(o=>o[0]===p),{predicate:e,...n}=u??{};return w(o=>{let r=!1,s=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()=>{s(),f()}},c(n))}function ne(d,i){return M(d,1,i)}function te(d,i){let{defaultValue:u,...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(u),o.down([[a]]);return}let s=n[0];if(s==null||s.length===0){o.down([[m]]);return}r.store.latest=s.at(-1),r.store.has=!0},{...c(t),completeWhenDepsComplete:!1})}function oe(d,i,u){return M(S(d,i,u),1,u)}function re(d,i,u){return M(V(d,i,u),1,u)}function se(d,i,u){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(u));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 s of r)t.data?.(s),n.emit(s)},{...c(u),completeWhenDepsComplete:!1})}function K(d,i,u){let t=u?.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 s of r)!e&&t(s)&&(e=!0,i(s)),o.emit(s)},c(u))}var ie=K;function ue(d,i=Object.is,u){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 s of o)n.store.hasPrev&&i(n.store.prev,s)||(n.store.prev=s,n.store.hasPrev=!0,e.emit(s),r=!0);r||e.down([[m]])},c(u))}function fe(d,i){return N([d],(u,t,e)=>{let n=u[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 s=[e.store.prev,r];e.store.prev=r,t.emit(s),o=!0}o||t.down([[m]])},c(i))}function q(...d){let i=[...d];return W(i,u=>u,{...c(),equals:(u,t)=>{if(u.length!==t.length)return!1;for(let e=0;e<u.length;e++)if(!Object.is(u[e],t[e]))return!1;return!0}})}function de(d,i,u){return N([d,i],(t,e,n)=>{let o=t[0],r=t[1],s=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,s])}else e.down([[m]])},B(u))}function le(...d){return d.length===0?w(i=>{i.down([[a]])},c()):w(i=>{let u=d.length,t=0,e=[];for(let n of d){let o=n.subscribe(r=>{for(let s of r)s[0]===p?i.emit(s[1]):s[0]===a?(t+=1,t>=u&&i.down([[a]])):s[0]===b&&i.down([s])});e.push(o)}return()=>{for(let n of e)n()}},c())}function ae(...d){let i=d.length;return i===0?w(u=>{u.emit([]),u.down([[a]])},c()):w(u=>{let t=Array.from({length:i},()=>[]),e=i;function n(){for(;t.every(r=>r.length>0);){let r=t.map(s=>s.shift());u.emit(r)}}let o=[];for(let r=0;r<i;r++){let s=r,f=d[r].subscribe(l=>{for(let T of l)T[0]===p?(t[s].push(T[1]),n()):T[0]===a?(e-=1,(e===0||t[s].length===0)&&u.down([[a]])):T[0]===b&&u.down([T])});o.push(f)}return()=>{for(let r of o)r()}},c())}function ce(d,i,u){return w(t=>{let e=0,n=[],o,r;return r=i.subscribe(s=>{for(let f of s)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(s=>{for(let f of s)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(u))}function Te(...d){return d.length===0?w(i=>{i.down([[a]])},c()):d.length===1?N([d[0]],(i,u)=>{let t=i[0];if(t==null||t.length===0){u.down([[m]]);return}for(let e of t)u.emit(e)},c()):w(i=>{let u=null,t=[];for(let e=0;e<d.length;e++){let n=e,o=d[e].subscribe(r=>{for(let s of r){if(u!==null&&n!==u)return;s[0]===p?(u===null&&(u=n),i.emit(s[1])):(s[0]===a||s[0]===b)&&(u===null||n===u)&&i.down([s])}});t.push(o)}return()=>{for(let e of t)e()}},c())}function I(d,i,u){let t,e=!1,n=()=>{e||(e=!0,u())};return t=d.subscribe(o=>{let r=!1,s=!1;for(let f of o)f[0]!==C&&(f[0]===p?i.emit(f[1]):f[0]===a?r=!0:f[0]===b?(s=!0,i.down([f])):(f[0]===A||f[0]===m)&&i.down([f]));s?(t?.(),t=void 0,n()):r&&n()}),()=>{t?.(),t=void 0}}function pe(d,i,u){let t,e=!1;function n(){t?.(),t=void 0}return N([d],(o,r,s)=>{if(s.terminalDeps[0]!=null&&s.terminalDeps[0]!==!0){n();return}if(s.terminalDeps[0]===!0){e=!0,t||r.down([[a]]);return}let f=o[0];if(!(f==null||f.length===0))return n(),t=I(y(i(f[f.length-1])),r,()=>{n(),e&&r.down([[a]])}),{deactivate:()=>{n(),e=!1}}},{...c(u),completeWhenDepsComplete:!1})}function me(d,i,u){let t,e=!1;function n(){t?.(),t=void 0}return N([d],(o,r,s)=>{if(s.terminalDeps[0]!=null&&s.terminalDeps[0]!==!0){n();return}if(s.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(y(i(f[0])),r,()=>{n(),e&&r.down([[a]])}):r.down([[m]]),{deactivate:()=>{n(),e=!1}}},{...c(u),completeWhenDepsComplete:!1})}function be(d,i,u){let{maxBuffer:t,...e}=u??{},n=[],o,r=!1,s;function f(){o?.(),o=void 0}function l(){if(!s||o!==void 0)return;if(n.length===0){r&&s.down([[a]]);return}let h=n.shift();o=I(y(i(h)),s,()=>{f(),l()})}function T(h){t&&t>0&&n.length>=t&&n.shift(),n.push(h),l()}return N([d],(h,O,x)=>{if(s=O,x.terminalDeps[0]!=null&&x.terminalDeps[0]!==!0){f(),n.length=0;return}if(x.terminalDeps[0]===!0){r=!0,l();return}let E=h[0];if(!(E==null||E.length===0)){for(let v of E)T(v);return{deactivate:()=>{f(),n.length=0,r=!1}}}},{...c(e),completeWhenDepsComplete:!1})}function _(d,i,u){let{concurrent:t,...e}=u??{},n=t!=null&&t>0?t:Number.POSITIVE_INFINITY,o=0,r=!1,s=new Set,f=[],l;function T(){r&&o===0&&f.length===0&&l&&l.down([[a]])}function h(v){if(!l)return;o++;let g;g=I(y(i(v)),l,()=>{g&&s.delete(g),o--,O(),T()}),s.add(g)}function O(){for(;f.length>0&&o<n;)h(f.shift())}function x(v){o<n?h(v):f.push(v)}function E(){for(let v of s)v();s.clear(),o=0,f.length=0}return N([d],(v,g,D)=>{if(l=g,D.terminalDeps[0]!=null&&D.terminalDeps[0]!==!0){E();return}if(D.terminalDeps[0]===!0){r=!0,T();return}let R=v[0];if(!(R==null||R.length===0)){for(let U of R)x(U);return{deactivate:()=>{E(),r=!1}}}},{...c(e),completeWhenDepsComplete:!1})}var we=_;function Ne(d,i,u){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 s of r)if(s[0]===p){let f=setTimeout(()=>{e.delete(f),t.emit(s[1])},i);e.add(f)}else if(s[0]===a){let f=setTimeout(()=>{e.delete(f),t.down([[a]])},i);e.add(f)}else s[0]===b&&(n(),t.down([s]))});return()=>{o(),n()}},c(u))}function j(d,i,u){return w(t=>{let e,n;function o(){e!==void 0&&(clearTimeout(e),e=void 0)}let r=d.subscribe(s=>{for(let f of s)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(u))}function F(d,i,u){let{leading:t,trailing:e,...n}=u??{},o=t!==!1,r=e===!0,s=i*1e6;return w(f=>{let l,T=-1/0,h,O=!1;function x(){l!==void 0&&(clearTimeout(l),l=void 0)}let E=d.subscribe(v=>{for(let g of v)if(g[0]===p){let D=g[1],R=k();if(o&&R-T>=s)T=R,f.emit(D),x(),r&&(l=setTimeout(()=>{l=void 0,O&&(T=k(),f.emit(h),O=!1)},i));else if(r&&(h=D,O=!0,l===void 0)){let U=(R-T)/1e6;l=setTimeout(()=>{l=void 0,O&&(T=k(),f.emit(h),O=!1)},Math.max(0,i-U))}}else(g[0]===a||g[0]===b)&&(x(),f.down([g]))});return()=>{E(),x()}},c(n))}function he(d,i,u){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)}}),s=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(),s()}},c(u))}function ve(d,i,u){return w(t=>{let e,n,o=!1;function r(){e!==void 0&&(clearTimeout(e),e=void 0)}let s=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()=>{s(),r()}},c(u))}function ge(d,i,u){let{with:t,...e}=u??{},n=t??new Error("timeout");return w(o=>{let r;function s(){clearTimeout(r),r=setTimeout(()=>{r=void 0,o.down([[b,n]])},i)}s();let f=d.subscribe(l=>{for(let T of l)T[0]===p?(s(),o.emit(T[1])):(T[0]===a||T[0]===b)&&(clearTimeout(r),o.down([T]))});return()=>{f(),clearTimeout(r)}},c(e))}function Oe(d,i,u){return w(t=>{let e=[],n=d.subscribe(r=>{for(let s of r)s[0]===p?e.push(s[1]):s[0]===a?(e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):s[0]===b&&t.down([s])}),o=i.subscribe(r=>{for(let s of r)s[0]===p?e.length>0&&(t.emit([...e]),e.length=0):s[0]===a?t.down([[a]]):s[0]===b&&t.down([s])});return()=>{n(),o(),e.length=0}},c(u))}function xe(d,i,u){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(u))}function Ee(d,i,u){if(i<=0)throw new RangeError("windowCount expects count > 0");return w(t=>{let e,n=0;function o(){let s=w(f=>(e=f.down.bind(f),()=>{e=void 0}),c());n=0,t.emit(s)}let r=d.subscribe(s=>{for(let f of s)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(u))}function Re(d,i,u){return w(t=>{let e=[],n=setInterval(()=>{e.length>0&&(t.emit([...e]),e.length=0)},i),o=d.subscribe(r=>{for(let s of r)s[0]===p?e.push(s[1]):s[0]===a?(clearInterval(n),e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):s[0]===b&&(clearInterval(n),t.down([s]))});return()=>{o(),clearInterval(n),e.length=0}},c(u))}function De(d,i,u){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),s=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()=>{s(),clearInterval(r),n()}},c(u))}function ye(d,i,u){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]))}),s=i.subscribe(f=>{for(let l of f)l[0]===p&&(n(),o())});return()=>{r(),s(),n()}},c(u))}function ke(d,i){return w((u,t)=>{"n"in t.store||(t.store.n=0);let e=setInterval(()=>{u.emit(t.store.n),t.store.n=t.store.n+1},d);return()=>clearInterval(e)},c(i))}function Ie(d,i,u){if(i<=0)throw new RangeError("repeat expects count > 0");return w(t=>{let e=i,n,o=()=>{n?.(),n=d.subscribe(r=>{let s=!1,f=[];for(let l of r)l[0]===a?s=!0:f.push(l);f.length>0&&t.down(f),s&&(n?.(),n=void 0,e-=1,e>0?o():t.down([[a]]))})};return o(),()=>{n?.()}},c(u))}function Ue(d,i){return N([d],(u,t)=>{let e=u[0];if(e==null||e.length===0){t.down([[m]]);return}for(let n of e)t.emit(n)},c(i))}function L(d,i,u){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(u))}function Me(d,i,u){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 s=t[0];if(s!=null&&s.length>0){for(let f of s)e.emit(f);return}if(o!=null&&o.length>0&&n.prevData[0]!==void 0){e.emit(n.prevData[0]);return}e.down([[m]])},B(u))}var Ce=q,Ae=j,We=F,Pe=L;export{Q as a,S as b,X as c,Z as d,M as e,V as f,$ as g,ee as h,ne as i,te as j,oe as k,re as l,se as m,K as n,ie as o,ue as p,fe as q,q as r,de as s,le as t,ae as u,ce as v,Te as w,pe as x,me as y,be as z,_ as A,we as B,Ne as C,j as D,F as E,he as F,ve as G,ge as H,Oe as I,xe as J,Ee as K,Re as L,De as M,ye as N,ke as O,Ie as P,Ue as Q,L as R,Me as S,Ce as T,Ae as U,We as V,Pe as W};
1
+ import{a as P}from"./chunk-4VVTGLXJ.js";import{m as y}from"./chunk-MQZWA3DF.js";import{D as N,F as w,G as W,o as k}from"./chunk-LYCLF26R.js";import{a as C,b as p,c as A,d as m,i as a,j as b}from"./chunk-CK2E7BTU.js";function c(d){return{describeKind:"derived",...d}}function B(d){return{describeKind:"derived",partial:!0,...d}}function Q(d,i,u){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(u))}function S(d,i,u){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(u))}function X(d,i,u,t){return N([d],(e,n,o)=>{"acc"in o.store||(o.store.acc=u);let r=e[0];if(r==null||r.length===0){n.down([[m]]);return}for(let s of r)o.store.acc=i(o.store.acc,s),n.emit(o.store.acc)},{...c(t),initial:u,resetOnTeardown:!0})}function Z(d,i,u,t){return N([d],(e,n,o)=>{if("acc"in o.store||(o.store.acc=u),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 s of r)o.store.acc=i(o.store.acc,s)},{...c(t),completeWhenDepsComplete:!1})}function M(d,i,u){return i<=0?N([d],(t,e,n)=>{n.store.completed||(n.store.completed=!0,e.down([[a]]))},{...c(u),completeWhenDepsComplete:!1}):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(u),completeWhenDepsComplete:!1})}function V(d,i,u){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 s of o)n.store.skipped++,n.store.skipped<=i||(e.emit(s),r=!0);r||e.down([[m]])},c(u))}function $(d,i,u){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(u),completeWhenDepsComplete:!1})}function ee(d,i,u){let t=u?.predicate??(o=>o[0]===p),{predicate:e,...n}=u??{};return w(o=>{let r=!1,s=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()=>{s(),f()}},c(n))}function ne(d,i){return M(d,1,i)}function te(d,i){let{defaultValue:u,...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(u),o.down([[a]]);return}let s=n[0];if(s==null||s.length===0){o.down([[m]]);return}r.store.latest=s.at(-1),r.store.has=!0},{...c(t),completeWhenDepsComplete:!1})}function oe(d,i,u){return M(S(d,i,u),1,u)}function re(d,i,u){return M(V(d,i,u),1,u)}function se(d,i,u){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(u));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 s of r)t.data?.(s),n.emit(s)},{...c(u),completeWhenDepsComplete:!1})}function K(d,i,u){let t=u?.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 s of r)!e&&t(s)&&(e=!0,i(s)),o.emit(s)},c(u))}var ie=K;function ue(d,i=Object.is,u){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 s of o)n.store.hasPrev&&i(n.store.prev,s)||(n.store.prev=s,n.store.hasPrev=!0,e.emit(s),r=!0);r||e.down([[m]])},c(u))}function fe(d,i){return N([d],(u,t,e)=>{let n=u[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 s=[e.store.prev,r];e.store.prev=r,t.emit(s),o=!0}o||t.down([[m]])},c(i))}function q(...d){let i=[...d];return W(i,u=>u,{...c(),equals:(u,t)=>{if(u.length!==t.length)return!1;for(let e=0;e<u.length;e++)if(!Object.is(u[e],t[e]))return!1;return!0}})}function de(d,i,u){return N([d,i],(t,e,n)=>{let o=t[0],r=t[1],s=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,s])}else e.down([[m]])},B(u))}function le(...d){return d.length===0?w(i=>{i.down([[a]])},c()):w(i=>{let u=d.length,t=0,e=[];for(let n of d){let o=n.subscribe(r=>{for(let s of r)s[0]===p?i.emit(s[1]):s[0]===a?(t+=1,t>=u&&i.down([[a]])):s[0]===b&&i.down([s])});e.push(o)}return()=>{for(let n of e)n()}},c())}function ae(...d){let i=d.length;return i===0?w(u=>{u.emit([]),u.down([[a]])},c()):w(u=>{let t=Array.from({length:i},()=>[]),e=i;function n(){for(;t.every(r=>r.length>0);){let r=t.map(s=>s.shift());u.emit(r)}}let o=[];for(let r=0;r<i;r++){let s=r,f=d[r].subscribe(l=>{for(let T of l)T[0]===p?(t[s].push(T[1]),n()):T[0]===a?(e-=1,(e===0||t[s].length===0)&&u.down([[a]])):T[0]===b&&u.down([T])});o.push(f)}return()=>{for(let r of o)r()}},c())}function ce(d,i,u){return w(t=>{let e=0,n=[],o,r;return r=i.subscribe(s=>{for(let f of s)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(s=>{for(let f of s)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(u))}function Te(...d){return d.length===0?w(i=>{i.down([[a]])},c()):d.length===1?N([d[0]],(i,u)=>{let t=i[0];if(t==null||t.length===0){u.down([[m]]);return}for(let e of t)u.emit(e)},c()):w(i=>{let u=null,t=[];for(let e=0;e<d.length;e++){let n=e,o=d[e].subscribe(r=>{for(let s of r){if(u!==null&&n!==u)return;s[0]===p?(u===null&&(u=n),i.emit(s[1])):(s[0]===a||s[0]===b)&&(u===null||n===u)&&i.down([s])}});t.push(o)}return()=>{for(let e of t)e()}},c())}function I(d,i,u){let t,e=!1,n=()=>{e||(e=!0,u())};return t=d.subscribe(o=>{let r=!1,s=!1;for(let f of o)f[0]!==C&&(f[0]===p?i.emit(f[1]):f[0]===a?r=!0:f[0]===b?(s=!0,i.down([f])):(f[0]===A||f[0]===m)&&i.down([f]));s?(t?.(),t=void 0,n()):r&&n()}),()=>{t?.(),t=void 0}}function pe(d,i,u){let t,e=!1;function n(){t?.(),t=void 0}return N([d],(o,r,s)=>{if(s.terminalDeps[0]!=null&&s.terminalDeps[0]!==!0){n();return}if(s.terminalDeps[0]===!0){e=!0,t||r.down([[a]]);return}let f=o[0];if(!(f==null||f.length===0))return n(),t=I(y(i(f[f.length-1])),r,()=>{n(),e&&r.down([[a]])}),{deactivate:()=>{n(),e=!1}}},{...c(u),completeWhenDepsComplete:!1})}function me(d,i,u){let t,e=!1;function n(){t?.(),t=void 0}return N([d],(o,r,s)=>{if(s.terminalDeps[0]!=null&&s.terminalDeps[0]!==!0){n();return}if(s.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(y(i(f[0])),r,()=>{n(),e&&r.down([[a]])}):r.down([[m]]),{deactivate:()=>{n(),e=!1}}},{...c(u),completeWhenDepsComplete:!1})}function be(d,i,u){let{maxBuffer:t,...e}=u??{},n=[],o,r=!1,s;function f(){o?.(),o=void 0}function l(){if(!s||o!==void 0)return;if(n.length===0){r&&s.down([[a]]);return}let h=n.shift();o=I(y(i(h)),s,()=>{f(),l()})}function T(h){t&&t>0&&n.length>=t&&n.shift(),n.push(h),l()}return N([d],(h,O,x)=>{if(s=O,x.terminalDeps[0]!=null&&x.terminalDeps[0]!==!0){f(),n.length=0;return}if(x.terminalDeps[0]===!0){r=!0,l();return}let E=h[0];if(!(E==null||E.length===0)){for(let v of E)T(v);return{deactivate:()=>{f(),n.length=0,r=!1}}}},{...c(e),completeWhenDepsComplete:!1})}function _(d,i,u){let{concurrent:t,...e}=u??{},n=t!=null&&t>0?t:Number.POSITIVE_INFINITY,o=0,r=!1,s=new Set,f=[],l;function T(){r&&o===0&&f.length===0&&l&&l.down([[a]])}function h(v){if(!l)return;o++;let g;g=I(y(i(v)),l,()=>{g&&s.delete(g),o--,O(),T()}),s.add(g)}function O(){for(;f.length>0&&o<n;)h(f.shift())}function x(v){o<n?h(v):f.push(v)}function E(){for(let v of s)v();s.clear(),o=0,f.length=0}return N([d],(v,g,D)=>{if(l=g,D.terminalDeps[0]!=null&&D.terminalDeps[0]!==!0){E();return}if(D.terminalDeps[0]===!0){r=!0,T();return}let R=v[0];if(!(R==null||R.length===0)){for(let U of R)x(U);return{deactivate:()=>{E(),r=!1}}}},{...c(e),completeWhenDepsComplete:!1})}var we=_;function Ne(d,i,u){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 s of r)if(s[0]===p){let f=setTimeout(()=>{e.delete(f),t.emit(s[1])},i);e.add(f)}else if(s[0]===a){let f=setTimeout(()=>{e.delete(f),t.down([[a]])},i);e.add(f)}else s[0]===b&&(n(),t.down([s]))});return()=>{o(),n()}},c(u))}function j(d,i,u){return w(t=>{let e,n;function o(){e!==void 0&&(clearTimeout(e),e=void 0)}let r=d.subscribe(s=>{for(let f of s)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(u))}function F(d,i,u){let{leading:t,trailing:e,...n}=u??{},o=t!==!1,r=e===!0,s=i*1e6;return w(f=>{let l,T=-1/0,h,O=!1;function x(){l!==void 0&&(clearTimeout(l),l=void 0)}let E=d.subscribe(v=>{for(let g of v)if(g[0]===p){let D=g[1],R=k();if(o&&R-T>=s)T=R,f.emit(D),x(),r&&(l=setTimeout(()=>{l=void 0,O&&(T=k(),f.emit(h),O=!1)},i));else if(r&&(h=D,O=!0,l===void 0)){let U=(R-T)/1e6;l=setTimeout(()=>{l=void 0,O&&(T=k(),f.emit(h),O=!1)},Math.max(0,i-U))}}else(g[0]===a||g[0]===b)&&(x(),f.down([g]))});return()=>{E(),x()}},c(n))}function he(d,i,u){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)}}),s=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(),s()}},c(u))}function ve(d,i,u){return w(t=>{let e,n,o=!1;function r(){e!==void 0&&(clearTimeout(e),e=void 0)}let s=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()=>{s(),r()}},c(u))}function ge(d,i,u){let{with:t,...e}=u??{},n=t??new Error("timeout");return w(o=>{let r;function s(){clearTimeout(r),r=setTimeout(()=>{r=void 0,o.down([[b,n]])},i)}s();let f=d.subscribe(l=>{for(let T of l)T[0]===p?(s(),o.emit(T[1])):(T[0]===a||T[0]===b)&&(clearTimeout(r),o.down([T]))});return()=>{f(),clearTimeout(r)}},c(e))}function Oe(d,i,u){return w(t=>{let e=[],n=d.subscribe(r=>{for(let s of r)s[0]===p?e.push(s[1]):s[0]===a?(e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):s[0]===b&&t.down([s])}),o=i.subscribe(r=>{for(let s of r)s[0]===p?e.length>0&&(t.emit([...e]),e.length=0):s[0]===a?t.down([[a]]):s[0]===b&&t.down([s])});return()=>{n(),o(),e.length=0}},c(u))}function xe(d,i,u){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(u))}function Ee(d,i,u){if(i<=0)throw new RangeError("windowCount expects count > 0");return w(t=>{let e,n=0;function o(){let s=w(f=>(e=f.down.bind(f),()=>{e=void 0}),c());n=0,t.emit(s)}let r=d.subscribe(s=>{for(let f of s)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(u))}function Re(d,i,u){return w(t=>{let e=[],n=setInterval(()=>{e.length>0&&(t.emit([...e]),e.length=0)},i),o=d.subscribe(r=>{for(let s of r)s[0]===p?e.push(s[1]):s[0]===a?(clearInterval(n),e.length>0&&t.emit([...e]),e.length=0,t.down([[a]])):s[0]===b&&(clearInterval(n),t.down([s]))});return()=>{o(),clearInterval(n),e.length=0}},c(u))}function De(d,i,u){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),s=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()=>{s(),clearInterval(r),n()}},c(u))}function ye(d,i,u){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]))}),s=i.subscribe(f=>{for(let l of f)l[0]===p&&(n(),o())});return()=>{r(),s(),n()}},c(u))}function ke(d,i){return w((u,t)=>{"n"in t.store||(t.store.n=0);let e=setInterval(()=>{u.emit(t.store.n),t.store.n=t.store.n+1},d);return()=>clearInterval(e)},c(i))}function Ie(d,i,u){if(i<=0)throw new RangeError("repeat expects count > 0");return w(t=>{let e=i,n,o=()=>{n?.(),n=d.subscribe(r=>{let s=!1,f=[];for(let l of r)l[0]===a?s=!0:f.push(l);f.length>0&&t.down(f),s&&(n?.(),n=void 0,e-=1,e>0?o():t.down([[a]]))})};return o(),()=>{n?.()}},c(u))}function Ue(d,i){return N([d],(u,t)=>{let e=u[0];if(e==null||e.length===0){t.down([[m]]);return}for(let n of e)t.emit(n)},c(i))}function L(d,i,u){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(u))}function Me(d,i,u){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 s=t[0];if(s!=null&&s.length>0){for(let f of s)e.emit(f);return}if(o!=null&&o.length>0&&n.prevData[0]!==void 0){e.emit(n.prevData[0]);return}e.down([[m]])},B(u))}var Ce=q,Ae=j,We=F,Pe=L;export{Q as a,S as b,X as c,Z as d,M as e,V as f,$ as g,ee as h,ne as i,te as j,oe as k,re as l,se as m,K as n,ie as o,ue as p,fe as q,q as r,de as s,le as t,ae as u,ce as v,Te as w,pe as x,me as y,be as z,_ as A,we as B,Ne as C,j as D,F as E,he as F,ve as G,ge as H,Oe as I,xe as J,Ee as K,Re as L,De as M,ye as N,ke as O,Ie as P,Ue as Q,L as R,Me as S,Ce as T,Ae as U,We as V,Pe as W};
@@ -1 +1 @@
1
- import{j as _}from"./chunk-2JO6LXFT.js";import{D as g,E as k}from"./chunk-LYCLF26R.js";import{b as R,c as T,d,h as A,i as O,j as D}from"./chunk-CK2E7BTU.js";function L(c,y,l,a){let s=new _(c,a);s.add(y,{name:"source"});let n=k(l,{meta:{kind:"stratify_rules"}});s.add(n,{name:"rules"});for(let f of l)E(s,y,n,f);return s}function E(c,y,l,a){let s=`branch/${a.name}`,n=Symbol("noValue"),f=!1,m=!1,p=!1,N=n,r=!1,h=l.cache??[];function v(o){if(p){p=!1;let t=N;if(N=n,t!==n){let i=h.find(u=>u.name===a.name),e=!1;try{e=i?.classify(t)??!1}catch{e=!1}e?(r=!1,o.emit(t)):r&&(r=!1,o.down([[T],[d]]))}else r?(r=!1,o.down([[T],[d]])):o.down([[d]])}}let S=g([],(o,t)=>{let i=y.subscribe(u=>{for(let b of u)w(b,0,t)}),e=l.subscribe(u=>{for(let b of u)w(b,1,t)});return()=>{i(),e()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:a.name},completeWhenDepsComplete:!1});function w(o,t,i){let e=o[0];return e===T?(t===0?(f=!0,r=!0):m=!0,!0):e===R||e===d?(t===0?(f=!1,p=!0,N=e===R?o[1]:n):(e===R&&(h=o[1]),m=!1),f||m||v(i),!0):e===O||e===D||e===A?(f=!1,m=!1,p=!1,N=n,r=!1,t===0&&i.down([o]),!0):t===1}if(c.add(S,{name:s}),a.ops){let o=a.ops(S),t=`branch/${a.name}/out`;c.add(o,{name:t})}}export{L as a};
1
+ import{j as _}from"./chunk-5KPIYVCC.js";import{D as g,E as k}from"./chunk-LYCLF26R.js";import{b as R,c as T,d,h as A,i as O,j as D}from"./chunk-CK2E7BTU.js";function L(c,y,l,a){let s=new _(c,a);s.add(y,{name:"source"});let n=k(l,{meta:{kind:"stratify_rules"}});s.add(n,{name:"rules"});for(let f of l)E(s,y,n,f);return s}function E(c,y,l,a){let s=`branch/${a.name}`,n=Symbol("noValue"),f=!1,m=!1,p=!1,N=n,r=!1,h=l.cache??[];function v(o){if(p){p=!1;let t=N;if(N=n,t!==n){let i=h.find(u=>u.name===a.name),e=!1;try{e=i?.classify(t)??!1}catch{e=!1}e?(r=!1,o.emit(t)):r&&(r=!1,o.down([[T],[d]]))}else r?(r=!1,o.down([[T],[d]])):o.down([[d]])}}let S=g([],(o,t)=>{let i=y.subscribe(u=>{for(let b of u)w(b,0,t)}),e=l.subscribe(u=>{for(let b of u)w(b,1,t)});return()=>{i(),e()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:a.name},completeWhenDepsComplete:!1});function w(o,t,i){let e=o[0];return e===T?(t===0?(f=!0,r=!0):m=!0,!0):e===R||e===d?(t===0?(f=!1,p=!0,N=e===R?o[1]:n):(e===R&&(h=o[1]),m=!1),f||m||v(i),!0):e===O||e===D||e===A?(f=!1,m=!1,p=!1,N=n,r=!1,t===0&&i.down([o]),!0):t===1}if(c.add(S,{name:s}),a.ops){let o=a.ops(S),t=`branch/${a.name}/out`;c.add(o,{name:t})}}export{L as a};
@@ -0,0 +1,5 @@
1
+ import{f as F,g as j,h as A}from"./chunk-QKUWS7CO.js";import{h as b,j as x}from"./chunk-5KPIYVCC.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
+ ${r.errors.join(`
3
+ `)}`,{errors:r.errors});let n=t?.catalog??{},s=F(e,n);if(!s.valid)throw new o("catalog-error",`Catalog validation failed:
4
+ ${s.errors.join(`
5
+ `)}`,{errors:s.errors});try{return A(e,t)}catch(a){let i=a instanceof Error?a.message:String(a);throw new o("catalog-error",i)}}var z=3e4;async function D(e,t,r){let n=r?.inputPath??"input",s=r?.outputPath??"output",a=r?.timeoutMs??z,i=R(e,{catalog:r?.catalog}),u;try{u=i.resolve(s)}catch{throw i.destroy(),new o("node-not-found",`reduce: output path "${s}" is not registered`,{path:s})}try{i.resolve(n)}catch{throw i.destroy(),new o("node-not-found",`reduce: input path "${n}" is not registered`,{path:n})}try{return await new Promise((g,d)=>{let l=!1,y=!1,E,h,k=!1,m=p=>{y||(y=!0,E!==void 0&&clearTimeout(E),h!==void 0?(h(),h=void 0):k=!0,p())};h=u.subscribe(p=>{for(let f of p){if(y)return;if(l){if(f[0]===C){m(()=>g(f[1]));return}if(f[0]===$){let c=u.cache;m(()=>g(c));return}if(f[0]===N){let c=f[1],H=c instanceof Error?c.message:String(c),O=c instanceof Error?c:void 0;m(()=>d(new o("internal-error",`reduce: output emitted ERROR: ${H}`,O!=null?{cause:O}:void 0)));return}if(f[0]===T){m(()=>d(new o("internal-error","reduce: output COMPLETEd without a post-push DATA")));return}}}}),k&&(h?.(),h=void 0),l=!0;try{i.set(n,t)}catch(p){let f=p instanceof Error?p.message:String(p),c=p instanceof Error?p:void 0;m(()=>d(new o("internal-error",`reduce: failed to set input on "${n}": ${f}`,c!=null?{path:n,cause:c}:{path:n})));return}!y&&Number.isFinite(a)&&a>0&&(E=setTimeout(()=>{m(()=>d(new o("reduce-timeout",`reduce: no output emitted within ${a}ms`,{timeoutMs:a,outputPath:s})))},a),E.unref?.())})}finally{i.destroy()}}var v=b,S="snapshot:";function w(e){if(e.startsWith(S))throw new o("snapshot-failed",`snapshot id must not start with "${S}" (reserved); got "${e}"`,{snapshotId:e})}function G(e){return`${S}${e}`}function X(e){return e.startsWith(S)?e.slice(S.length):void 0}function P(e,t){if(e==null||typeof e!="object")throw new o("snapshot-not-found",`snapshot "${t}" not found in tier`,{snapshotId:t});let r=e;if("mode"in r){if(r.mode==="full"&&"snapshot"in r)return r.snapshot;throw r.mode==="diff"?new o("restore-failed",`snapshot "${t}" is a diff record; restore the baseline and replay WAL instead`,{snapshotId:t,mode:"diff"}):new o("restore-failed",`snapshot "${t}" has unknown mode "${String(r.mode)}"`,{snapshotId:t,mode:String(r.mode)})}if("nodes"in r&&"edges"in r&&"subgraphs"in r&&"name"in r)return r;throw new o("restore-failed",`snapshot "${t}" payload is not a GraphCheckpointRecord or GraphPersistSnapshot`,{snapshotId:t})}async function M(e,t,r){w(t);let n;try{n=e.snapshot()}catch(a){let i=a instanceof Error?a.message:String(a);throw new o("snapshot-failed",`snapshot "${t}" serialization failed: ${i}`,{snapshotId:t})}let s={name:e.name,mode:"full",seq:0,timestamp_ns:_(),format_version:v,snapshot:n};try{await r.save(G(t),s)}catch(a){let i=a instanceof Error?a.message:String(a);throw new o("snapshot-failed",`snapshot "${t}" save failed: ${i}`,{snapshotId:t})}return{snapshotId:t,timestamp_ns:s.timestamp_ns}}async function U(e,t,r){w(e);let n=G(e),s=await t.load(n);s===void 0&&(s=await t.load(e));let a=P(s,e);try{return x.fromSnapshot(a,r?.factories?{factories:r.factories}:void 0)}catch(i){let u=i instanceof Error?i.message:String(i);throw new o("restore-failed",`snapshot "${e}" restore failed: ${u}`,{snapshotId:e})}}async function V(e,t,r){w(e),w(t);let n=async g=>{let d=G(g),l=await r.load(d);return l===void 0&&(l=await r.load(g)),l},[s,a]=await Promise.all([n(e),n(t)]),i=P(s,e),u=P(a,t);return x.diff(i,u)}async function W(e,t){if(typeof e.list!="function")throw new o("tier-no-list","KvStorageTier does not implement list(); wrap the tier with an enumerator or use a different backend");let r=await e.list(),n=[],s=t?.includeUnprefixed===!0;for(let a of r){let i=X(a);i!==void 0?n.push(i):s&&n.push(a)}return n}async function L(e,t){if(w(e),typeof t.delete!="function")throw new o("snapshot-failed",`KvStorageTier is append-only (no delete()); cannot delete "${e}"`,{snapshotId:e});try{await t.delete(G(e))}catch(r){let n=r instanceof Error?r.message:String(r);throw new o("snapshot-failed",`snapshot "${e}" delete failed: ${n}`,{snapshotId:e})}}export{o as a,K as b,R as c,D as d,v as e,M as f,U as g,V as h,W as i,L as j,Y as k};
@@ -1,4 +1,4 @@
1
- import{c as ce}from"./chunk-YUBV7EEE.js";import{a as se,b as P}from"./chunk-5QDBSZBV.js";import{j as L}from"./chunk-2JO6LXFT.js";import{f as ae,h as ie}from"./chunk-T7EQPKOP.js";import{i as ne,j as U}from"./chunk-LYCLF26R.js";import{b,h as _,i as T,j as W}from"./chunk-CK2E7BTU.js";import{b as Oe,c as re,d as te,e as oe}from"./chunk-QYADASLV.js";var ke={};Oe(ke,{ACTOR_KEY:()=>F,COMMAND_HANDLERS:()=>A,CQRS_EVENT_HANDLERS:()=>S,CRON_HANDLERS:()=>D,CommandHandler:()=>me,EVENT_HANDLERS:()=>G,EventHandler:()=>ve,GRAPHREFLY_REQUEST_GRAPH:()=>R,GRAPHREFLY_ROOT_GRAPH:()=>v,GraphCron:()=>fe,GraphInterval:()=>he,GraphReflyEventExplorer:()=>x,GraphReflyGuard:()=>Re,GraphReflyGuardImpl:()=>I,GraphReflyModule:()=>Q,INTERVAL_HANDLERS:()=>O,InjectCqrsGraph:()=>de,InjectGraph:()=>ue,InjectNode:()=>pe,ObserveGateway:()=>B,OnGraphEvent:()=>le,QUERY_HANDLERS:()=>H,QueryHandler:()=>ye,SAGA_HANDLERS:()=>N,SagaHandler:()=>ge,fromHeader:()=>Ee,fromJwtPayload:()=>V,getActor:()=>we,getGraphToken:()=>m,getNodeToken:()=>y,observeSSE:()=>Me,observeSubscription:()=>Ce,toObservable:()=>se});import{Inject as j}from"@nestjs/common";var v=Symbol.for("graphrefly:root-graph");var R=Symbol.for("graphrefly:request-graph");function m(s){return Symbol.for(`graphrefly:graph:${s}`)}function y(s){return Symbol.for(`graphrefly:node:${s}`)}var G=new Map,O=new Map,D=new Map,A=new Map,S=new Map,H=new Map,N=new Map;function ue(s){return s==="request"?j(R):j(s?m(s):v)}function de(s){return j(m(s))}function pe(s){return j(y(s))}function le(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=G.get(o)??[];n.push({nodeName:s,methodKey:t}),G.set(o,n)})}}function he(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=O.get(o)??[];n.push({ms:s,methodKey:t}),O.set(o,n)})}}function fe(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=D.get(o)??[];n.push({expr:s,methodKey:t}),D.set(o,n)})}}function me(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=A.get(n)??[];a.push({cqrsName:s,commandName:e,methodKey:o}),A.set(n,a)})}}function ve(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=S.get(n)??[];a.push({cqrsName:s,eventName:e,methodKey:o}),S.set(n,a)})}}function ye(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=H.get(n)??[];a.push({cqrsName:s,projectionName:e,methodKey:o}),H.set(n,a)})}}function ge(s,e,r){return(t,o)=>{let n=o.name;o.addInitializer(function(){let a=this.constructor,c=N.get(a)??[];c.push({cqrsName:s,eventNames:r,sagaName:e,methodKey:n}),N.set(a,c)})}}var be=0,x=class{constructor(e,r){this.graph=e;this.moduleRef=r}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,r]of G){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireEventHandler(t,o)}}wireEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),a=this.observeNode(r.nodeName).subscribe(c=>{for(let l of c)l[0]===b&&o(l[1])});this.disposers.push(a)}wireIntervals(){for(let[e,r]of O){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireIntervalHandler(t,e,o)}}wireIntervalHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ae(t.ms,{period:t.ms,name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCrons(){for(let[e,r]of D){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCronHandler(t,e,o)}}wireCronHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ie(t.expr,{name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCqrsCommands(){for(let[e,r]of A){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsCommand(t,o)}}wireCqrsCommand(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.command(r.commandName,o)}wireCqrsEvents(){for(let[e,r]of S){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsEventHandler(t,o)}}wireCqrsEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;n.event(r.eventName);let c=n.resolve(r.eventName).cache,l=c&&c.length>0?c[c.length-1].seq:0,p=this.observeNodeOn(n,r.eventName).subscribe(u=>{for(let d of u)if(d[0]===b){let g=d[1];for(let i of g)i.seq>l&&(o(i),l=i.seq)}});this.disposers.push(p)}wireCqrsQueries(){for(let[e,r]of H){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsQuery(t,o)}}wireCqrsQuery(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;let c=this.observeNodeOn(n,r.projectionName).subscribe(l=>{for(let f of l)f[0]===b&&o(f[1])});this.disposers.push(c)}wireCqrsSagas(){for(let[e,r]of N){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsSaga(t,o)}}wireCqrsSaga(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.saga(r.sagaName,r.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,r){return e.observe(r)}resolveCqrsGraph(e){try{return this.moduleRef.get(m(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};function Me(s,e,r){let{actor:t,serialize:o=De,keepAliveMs:n,signal:a}=r??{},c=new TextEncoder,l,f=r?.highWaterMark!=null,p,u,d=[],g=!1;return new ReadableStream({start(i){let h,w=()=>{},M=()=>{if(!g){g=!0,h!==void 0&&clearInterval(h),a?.removeEventListener("abort",K),w(),p?.dispose(),u?.(),u=void 0;for(let k of d)i.enqueue(k.frame);d.length=0,i.close()}};l=M;let K=()=>M(),ee=s.observe(e,{actor:t});f&&(p=P(k=>ee.up(k),{highWaterMark:r.highWaterMark,lowWaterMark:r.lowWaterMark??Math.floor(r.highWaterMark/2)})),w=ee.subscribe(k=>{for(let $ of k){if(g)return;let q=$[0];if(q===b){let C=c.encode(Y("data",o($[1])));f?(d.push({frame:C,counted:!0}),p.onEnqueue(),u?.(),u=void 0):i.enqueue(C)}else if(q===W){let C=c.encode(Y("error",o($[1])));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C),M();return}else if(q===T||q===_){if(q===T){let C=c.encode(Y("complete"));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C)}M();return}}}),n!==void 0&&n>0&&(h=setInterval(()=>{g||(f?(d.push({frame:c.encode(`: keepalive
1
+ import{e as ce}from"./chunk-3U7IIQB2.js";import{a as se,b as P}from"./chunk-5QDBSZBV.js";import{j as L}from"./chunk-5KPIYVCC.js";import{f as ae,h as ie}from"./chunk-MQZWA3DF.js";import{i as ne,j as U}from"./chunk-LYCLF26R.js";import{b,h as _,i as T,j as W}from"./chunk-CK2E7BTU.js";import{b as Oe,c as re,d as te,e as oe}from"./chunk-QYADASLV.js";var ke={};Oe(ke,{ACTOR_KEY:()=>F,COMMAND_HANDLERS:()=>A,CQRS_EVENT_HANDLERS:()=>S,CRON_HANDLERS:()=>D,CommandHandler:()=>me,EVENT_HANDLERS:()=>G,EventHandler:()=>ve,GRAPHREFLY_REQUEST_GRAPH:()=>R,GRAPHREFLY_ROOT_GRAPH:()=>v,GraphCron:()=>fe,GraphInterval:()=>he,GraphReflyEventExplorer:()=>x,GraphReflyGuard:()=>Re,GraphReflyGuardImpl:()=>I,GraphReflyModule:()=>Q,INTERVAL_HANDLERS:()=>O,InjectCqrsGraph:()=>de,InjectGraph:()=>ue,InjectNode:()=>pe,ObserveGateway:()=>B,OnGraphEvent:()=>le,QUERY_HANDLERS:()=>H,QueryHandler:()=>ye,SAGA_HANDLERS:()=>N,SagaHandler:()=>ge,fromHeader:()=>Ee,fromJwtPayload:()=>V,getActor:()=>we,getGraphToken:()=>m,getNodeToken:()=>y,observeSSE:()=>Me,observeSubscription:()=>Ce,toObservable:()=>se});import{Inject as j}from"@nestjs/common";var v=Symbol.for("graphrefly:root-graph");var R=Symbol.for("graphrefly:request-graph");function m(s){return Symbol.for(`graphrefly:graph:${s}`)}function y(s){return Symbol.for(`graphrefly:node:${s}`)}var G=new Map,O=new Map,D=new Map,A=new Map,S=new Map,H=new Map,N=new Map;function ue(s){return s==="request"?j(R):j(s?m(s):v)}function de(s){return j(m(s))}function pe(s){return j(y(s))}function le(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=G.get(o)??[];n.push({nodeName:s,methodKey:t}),G.set(o,n)})}}function he(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=O.get(o)??[];n.push({ms:s,methodKey:t}),O.set(o,n)})}}function fe(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=D.get(o)??[];n.push({expr:s,methodKey:t}),D.set(o,n)})}}function me(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=A.get(n)??[];a.push({cqrsName:s,commandName:e,methodKey:o}),A.set(n,a)})}}function ve(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=S.get(n)??[];a.push({cqrsName:s,eventName:e,methodKey:o}),S.set(n,a)})}}function ye(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=H.get(n)??[];a.push({cqrsName:s,projectionName:e,methodKey:o}),H.set(n,a)})}}function ge(s,e,r){return(t,o)=>{let n=o.name;o.addInitializer(function(){let a=this.constructor,c=N.get(a)??[];c.push({cqrsName:s,eventNames:r,sagaName:e,methodKey:n}),N.set(a,c)})}}var be=0,x=class{constructor(e,r){this.graph=e;this.moduleRef=r}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,r]of G){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireEventHandler(t,o)}}wireEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),a=this.observeNode(r.nodeName).subscribe(c=>{for(let l of c)l[0]===b&&o(l[1])});this.disposers.push(a)}wireIntervals(){for(let[e,r]of O){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireIntervalHandler(t,e,o)}}wireIntervalHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ae(t.ms,{period:t.ms,name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCrons(){for(let[e,r]of D){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCronHandler(t,e,o)}}wireCronHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ie(t.expr,{name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCqrsCommands(){for(let[e,r]of A){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsCommand(t,o)}}wireCqrsCommand(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.command(r.commandName,o)}wireCqrsEvents(){for(let[e,r]of S){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsEventHandler(t,o)}}wireCqrsEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;n.event(r.eventName);let c=n.resolve(r.eventName).cache,l=c&&c.length>0?c[c.length-1].seq:0,p=this.observeNodeOn(n,r.eventName).subscribe(u=>{for(let d of u)if(d[0]===b){let g=d[1];for(let i of g)i.seq>l&&(o(i),l=i.seq)}});this.disposers.push(p)}wireCqrsQueries(){for(let[e,r]of H){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsQuery(t,o)}}wireCqrsQuery(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;let c=this.observeNodeOn(n,r.projectionName).subscribe(l=>{for(let f of l)f[0]===b&&o(f[1])});this.disposers.push(c)}wireCqrsSagas(){for(let[e,r]of N){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsSaga(t,o)}}wireCqrsSaga(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.saga(r.sagaName,r.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,r){return e.observe(r)}resolveCqrsGraph(e){try{return this.moduleRef.get(m(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};function Me(s,e,r){let{actor:t,serialize:o=De,keepAliveMs:n,signal:a}=r??{},c=new TextEncoder,l,f=r?.highWaterMark!=null,p,u,d=[],g=!1;return new ReadableStream({start(i){let h,w=()=>{},M=()=>{if(!g){g=!0,h!==void 0&&clearInterval(h),a?.removeEventListener("abort",K),w(),p?.dispose(),u?.(),u=void 0;for(let k of d)i.enqueue(k.frame);d.length=0,i.close()}};l=M;let K=()=>M(),ee=s.observe(e,{actor:t});f&&(p=P(k=>ee.up(k),{highWaterMark:r.highWaterMark,lowWaterMark:r.lowWaterMark??Math.floor(r.highWaterMark/2)})),w=ee.subscribe(k=>{for(let $ of k){if(g)return;let q=$[0];if(q===b){let C=c.encode(Y("data",o($[1])));f?(d.push({frame:C,counted:!0}),p.onEnqueue(),u?.(),u=void 0):i.enqueue(C)}else if(q===W){let C=c.encode(Y("error",o($[1])));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C),M();return}else if(q===T||q===_){if(q===T){let C=c.encode(Y("complete"));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C)}M();return}}}),n!==void 0&&n>0&&(h=setInterval(()=>{g||(f?(d.push({frame:c.encode(`: keepalive
2
2
 
3
3
  `),counted:!1}),u?.(),u=void 0):i.enqueue(c.encode(`: keepalive
4
4
 
@@ -6,4 +6,4 @@ import{c as ce}from"./chunk-YUBV7EEE.js";import{a as se,b as P}from"./chunk-5QDB
6
6
  `;if(e!==void 0)for(let t of e.split(`
7
7
  `))r+=`data: ${t}
8
8
  `;return r+=`
9
- `,r}function Ae(s){return JSON.parse(s)}function Se(s,e){try{s.send(JSON.stringify(e))}catch{}}function z(s,e){try{s(e)}catch{}}var F="graphReflyActor";function V(s){return e=>{let t=e.switchToHttp().getRequest()?.user;if(t!=null)return s?s(t):t}}function Ee(s="x-graphrefly-actor"){return e=>{let t=e.switchToHttp().getRequest()?.headers?.[s.toLowerCase()];if(!(typeof t!="string"||t.length===0))try{return JSON.parse(t)}catch{return}}}function we(s){let e=s?.[F];return e!=null?U(e):ne}var I=class{constructor(e){this.extractor=e}canActivate(e){let r=U(this.extractor(e)),t=e.switchToHttp().getRequest();return t!=null&&(t[F]=r),!0}};function Re(s){return new I(s??V())}import{Module as He,Scope as xe}from"@nestjs/common";import{ModuleRef as Ne}from"@nestjs/core";var X=class{constructor(e){this.graph=e}onModuleDestroy(){this.graph.destroy()}},Z=class{graph=new L("request");onModuleDestroy(){this.graph.destroy()}},Ge,J;Ge=[He({})];var E=class E{static forRoot(e){let r=e??{},t=r.name??"root",o=[{provide:v,useFactory:()=>{let n=new L(t);return r.build&&r.build(n),r.snapshot&&n.restore(r.snapshot),n}},{provide:Symbol.for("graphrefly:root-lifecycle"),useFactory:n=>new X(n),inject:[v]},{provide:x,useFactory:(n,a)=>new x(n,a),inject:[v,Ne]}];if(r.nodes)for(let n of r.nodes)o.push({provide:y(n),useFactory:a=>a.resolve(n),inject:[v]});return r.requestScope&&o.push({provide:Symbol.for("graphrefly:request-lifecycle"),useFactory:()=>new Z,scope:xe.REQUEST},{provide:R,useFactory:n=>n.graph,inject:[Symbol.for("graphrefly:request-lifecycle")],scope:xe.REQUEST}),{module:E,global:!0,providers:o,exports:[v,...(r.nodes??[]).map(y),...r.requestScope?[R]:[]]}}static forFeature(e){let r=[{provide:m(e.name),useFactory:t=>{let o=new L(e.name);return e.build&&e.build(o),e.snapshot&&o.restore(e.snapshot),t.mount(e.name,o),o},inject:[v]}];if(e.nodes)for(let t of e.nodes)r.push({provide:y(`${e.name}::${t}`),useFactory:o=>o.resolve(t),inject:[m(e.name)]});return{module:E,providers:r,exports:[m(e.name),...(e.nodes??[]).map(t=>y(`${e.name}::${t}`))]}}static forCqrs(e){let r=[{provide:m(e.name),useFactory:t=>{let o=ce(e.name,e.cqrs);return e.eventStore&&o.useEventStore(e.eventStore),e.build&&e.build(o),t.mount(e.name,o),o},inject:[v]}];if(e.nodes)for(let t of e.nodes)r.push({provide:y(`${e.name}::${t}`),useFactory:o=>o.resolve(t),inject:[m(e.name)]});return{module:E,providers:r,exports:[m(e.name),...(e.nodes??[]).map(t=>y(`${e.name}::${t}`))]}}};J=re(null),E=oe(J,0,"GraphReflyModule",Ge,E),te(J,1,E);var Q=E;export{v as a,R as b,m as c,y as d,G as e,O as f,D as g,A as h,S as i,H as j,N as k,ue as l,de as m,pe as n,le as o,he as p,fe as q,me as r,ve as s,ye as t,ge as u,x as v,Me as w,Ce as x,B as y,F as z,V as A,Ee as B,we as C,I as D,Re as E,Q as F,ke as G};
9
+ `,r}function Ae(s){return JSON.parse(s)}function Se(s,e){try{s.send(JSON.stringify(e))}catch{}}function z(s,e){try{s(e)}catch{}}var F="graphReflyActor";function V(s){return e=>{let t=e.switchToHttp().getRequest()?.user;if(t!=null)return s?s(t):t}}function Ee(s="x-graphrefly-actor"){return e=>{let t=e.switchToHttp().getRequest()?.headers?.[s.toLowerCase()];if(!(typeof t!="string"||t.length===0))try{return JSON.parse(t)}catch{return}}}function we(s){let e=s?.[F];return e!=null?U(e):ne}var I=class{constructor(e){this.extractor=e}canActivate(e){let r=U(this.extractor(e)),t=e.switchToHttp().getRequest();return t!=null&&(t[F]=r),!0}};function Re(s){return new I(s??V())}import{Module as He,Scope as xe}from"@nestjs/common";import{ModuleRef as Ne}from"@nestjs/core";var X=class{constructor(e){this.graph=e}onModuleDestroy(){this.graph.destroy()}},Z=class{graph=new L("request");onModuleDestroy(){this.graph.destroy()}},Ge,J;Ge=[He({})];var E=class E{static forRoot(e){let r=e??{},t=r.name??"root",o=[{provide:v,useFactory:()=>{let n=new L(t);return r.build&&r.build(n),r.snapshot&&n.restore(r.snapshot),n}},{provide:Symbol.for("graphrefly:root-lifecycle"),useFactory:n=>new X(n),inject:[v]},{provide:x,useFactory:(n,a)=>new x(n,a),inject:[v,Ne]}];if(r.nodes)for(let n of r.nodes)o.push({provide:y(n),useFactory:a=>a.resolve(n),inject:[v]});return r.requestScope&&o.push({provide:Symbol.for("graphrefly:request-lifecycle"),useFactory:()=>new Z,scope:xe.REQUEST},{provide:R,useFactory:n=>n.graph,inject:[Symbol.for("graphrefly:request-lifecycle")],scope:xe.REQUEST}),{module:E,global:!0,providers:o,exports:[v,...(r.nodes??[]).map(y),...r.requestScope?[R]:[]]}}static forFeature(e){let r=[{provide:m(e.name),useFactory:t=>{let o=new L(e.name);return e.build&&e.build(o),e.snapshot&&o.restore(e.snapshot),t.mount(e.name,o),o},inject:[v]}];if(e.nodes)for(let t of e.nodes)r.push({provide:y(`${e.name}::${t}`),useFactory:o=>o.resolve(t),inject:[m(e.name)]});return{module:E,providers:r,exports:[m(e.name),...(e.nodes??[]).map(t=>y(`${e.name}::${t}`))]}}static forCqrs(e){let r=[{provide:m(e.name),useFactory:t=>{let o=ce(e.name,e.cqrs);return e.eventStorage&&o.attachEventStorage(e.eventStorage),e.build&&e.build(o),t.mount(e.name,o),o},inject:[v]}];if(e.nodes)for(let t of e.nodes)r.push({provide:y(`${e.name}::${t}`),useFactory:o=>o.resolve(t),inject:[m(e.name)]});return{module:E,providers:r,exports:[m(e.name),...(e.nodes??[]).map(t=>y(`${e.name}::${t}`))]}}};J=re(null),E=oe(J,0,"GraphReflyModule",Ge,E),te(J,1,E);var Q=E;export{v as a,R as b,m as c,y as d,G as e,O as f,D as g,A as h,S as i,H as j,N as k,ue as l,de as m,pe as n,le as o,he as p,fe as q,me as r,ve as s,ye as t,ge as u,x as v,Me as w,Ce as x,B as y,F as z,V as A,Ee as B,we as C,I as D,Re as E,Q as F,ke as G};
@@ -0,0 +1 @@
1
+ import{a as L,c as D}from"./chunk-CGA5RXO6.js";import{c as Q}from"./chunk-O32GJOUJ.js";import{b as G}from"./chunk-KGKJCHEK.js";import{b as I}from"./chunk-TZQPPQEQ.js";import{b as M}from"./chunk-KUVDFOJH.js";import{j as F}from"./chunk-5KPIYVCC.js";import{C as v,m as C}from"./chunk-MQZWA3DF.js";import{D as x,G as P,m as _,p as m}from"./chunk-LYCLF26R.js";import{b as N,j as A}from"./chunk-CK2E7BTU.js";import{b as V}from"./chunk-QYADASLV.js";var ee={};V(ee,{JobFlowGraph:()=>w,JobQueueGraph:()=>y,jobEventKeyOf:()=>Y,jobFlow:()=>Z,jobQueue:()=>z});var X=256,H=1024;function W(i,e){if(!Number.isFinite(i)||!Number.isInteger(i)||i<0)throw new Error(`${e} must be a non-negative integer`);return i}function T(i,e){return Q("job_queue",i,e)}var Y=i=>i.action,y=class extends F{_pending;_jobs;_seqCursor;pending;jobs;depth;events;audit;constructor(e,t={}){super(e,t.graph),this._pending=G([],{name:"pending"}),this._jobs=I({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=P([this.pending],([o])=>o.length,{name:"depth",describeKind:"derived",meta:T("queue_depth"),initial:0}),this.add(this.depth,{name:"depth"}),this.addDisposer(v(this.depth)),this.events=L({name:"events",retainedLimit:1024,graph:this}),this.audit=this.events,this._seqCursor=D(this,"seq",0)}_bumpSeq(){let t=(this._seqCursor.cache??0)+1;return this._seqCursor.emit(t),t}attachEventStorage(e){return this.events.attachStorage(e)}enqueue(e,t={}){let o=this._bumpSeq(),n=t.id??`${this.name}-${o}`;if(this._jobs.get(n)!==void 0)throw new Error(`jobQueue("${this.name}"): duplicate job id "${n}"`);let p={id:n,payload:e,attempts:0,metadata:Object.freeze({...t.metadata??{}}),state:"queued"};return this._jobs.set(n,p),this._pending.append(n),this.events.append({action:"enqueue",id:n,payload:e,t_ns:m(),seq:o}),n}claim(e=1){let t=W(e,"job queue claim limit");if(t===0)return[];let o=[];for(;o.length<t&&this.pending.cache.length!==0;){let p=this._pending.pop(0),h=this._jobs.get(p);if(!h||h.state!=="queued")continue;let l={...h,state:"inflight",attempts:h.attempts+1};this._jobs.set(p,l),o.push(l),this.events.append({action:"claim",id:p,attempts:l.attempts,t_ns:m(),seq:this._bumpSeq()})}return o}ack(e){let t=this._jobs.get(e);return!t||t.state!=="inflight"?!1:(this._jobs.delete(e),this.events.append({action:"ack",id:e,attempts:t.attempts,t_ns:m(),seq:this._bumpSeq()}),!0)}nack(e,t={}){let o=this._jobs.get(e);return!o||o.state!=="inflight"?!1:t.requeue??!0?(this._jobs.set(e,{...o,state:"queued"}),this._pending.append(e),this.events.append({action:"nack",id:e,attempts:o.attempts,t_ns:m(),seq:this._bumpSeq()}),!0):(this._jobs.delete(e),this.events.append({action:"nack",id:e,attempts:o.attempts,t_ns:m(),seq:this._bumpSeq()}),!0)}removeById(e){let t=this._jobs.get(e);if(!t)return!1;if(t.state==="queued"){let n=this.pending.cache.indexOf(e);n>=0&&this._pending.pop(n)}return this._jobs.delete(e),this.events.append({action:"remove",id:e,attempts:t.attempts,t_ns:m(),seq:this._bumpSeq()}),!0}consumeFrom(e,t){return e.subscribe(o=>{for(let n of o){if(n[0]!==N)continue;let p=n[1];this.enqueue(p,t?{metadata:t.metadata}:void 0)}})}},w=class extends F{_stageNames;_stageWorkFns;_queues=new Map;_completed;completed;completedCount;constructor(e,t={}){super(e,t.graph);let o=t.stages??["incoming","processing","done"],n=[],p=new Map;for(let s of o){let r=typeof s=="string"?s.trim():s.name.trim();typeof s!="string"&&s.work&&p.set(r,s.work),n.push(r)}if(n.length<2)throw new Error(`jobFlow("${e}"): requires at least 2 stages`);if(new Set(n).size!==n.length)throw new Error(`jobFlow("${e}"): stage names must be unique`);this._stageNames=Object.freeze([...n]),this._stageWorkFns=p;for(let s of this._stageNames){let r=z(`${e}-${s}`);this._queues.set(s,r),this.mount(s,r)}this._completed=M([],{name:"completed",maxSize:H}),this.completed=this._completed.entries,this.add(this.completed,{name:"completed"}),this.completedCount=P([this.completed],([s])=>s.length,{name:"completedCount",describeKind:"derived",meta:T("job_flow_completed_count"),initial:0}),this.add(this.completedCount,{name:"completedCount"}),this.addDisposer(v(this.completedCount));let l=Math.max(1,W(t.maxPerPump??X,"job flow maxPerPump"));for(let s=0;s<this._stageNames.length;s+=1){let r=this._stageNames[s],d=this.queue(r),q=s+1<this._stageNames.length?this.queue(this._stageNames[s+1]):null,R=this._stageWorkFns.get(r),S=q===null;if(R){let g=x([d.pending],()=>{let c=0;for(;c<l;){let b=d.claim(1);if(b.length===0)break;let a=b[0];if(!a)break;let j=[...a.metadata.job_flow_path??[],r],f;try{f=R(a)}catch{d.nack(a.id,{requeue:!1}),c+=1;continue}let k=C(f),E=!1,u;u=k.subscribe(K=>{if(!E){for(let J of K)if(J[0]===N){E=!0,u?u():Promise.resolve().then(()=>u?.());let O=J[1],$={...a.metadata,job_flow_path:j};if(S){let U={...a,payload:O,metadata:Object.freeze($)};_(()=>{d.ack(a.id),this._completed.append(U)})}else _(()=>{d.ack(a.id),q.enqueue(O,{metadata:$})});return}else if(J[0]===A){E=!0,u?u():Promise.resolve().then(()=>u?.()),d.nack(a.id,{requeue:!1});return}}}),c+=1}},{name:`pump_${r}`,describeKind:"effect",meta:T("job_flow_pump",{stage:r,has_work:!0})});this.add(g,{name:`pump_${r}`}),this.addDisposer(v(g))}else{let g=x([d.pending],()=>{let c=0;for(;c<l;){let b=d.claim(1);if(b.length===0)break;let a=b[0];if(!a)break;let j=[...a.metadata.job_flow_path??[],r],f={...a.metadata,job_flow_path:j};if(S){let k={...a,metadata:Object.freeze(f)};_(()=>{d.ack(a.id),this._completed.append(k)})}else _(()=>{d.ack(a.id),q.enqueue(a.payload,{metadata:f})});c+=1}},{name:`pump_${r}`,describeKind:"effect",meta:T("job_flow_pump",{stage:r,has_work:!1})});this.add(g,{name:`pump_${r}`}),this.addDisposer(v(g))}}}stages(){return this._stageNames}queue(e){let t=this._queues.get(e);if(!t)throw new Error(`jobFlow("${this.name}"): unknown stage "${e}"`);return t}enqueue(e,t={}){return this.queue(this._stageNames[0]).enqueue(e,t)}retainedCompleted(){return this.completed.cache}};function z(i,e){return new y(i,e)}function Z(i,e){return new w(i,e)}export{Y as a,y as b,w as c,z as d,Z as e,ee as f};
@@ -0,0 +1 @@
1
+ import{C as O}from"./chunk-MQZWA3DF.js";import{D as H,E as A,G as k,m as D}from"./chunk-LYCLF26R.js";import{b as N,c as $,d as K,i as B,j as E}from"./chunk-CK2E7BTU.js";var C=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(n,t){if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=t,t!==void 0){if(this._buf=new Array(t),n&&n.length>0){let s=Math.min(n.length,t),h=n.length-s;for(let o=0;o<s;o++)this._buf[o]=n[h+o];this._size=s}}else this._buf=n?[...n]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(n){if(!Number.isInteger(n))return;let t=n>=0?n:this._size+n;if(!(t<0||t>=this._size))return this._maxSize!==void 0?this._buf[(this._head+t)%this._maxSize]:this._buf[t]}append(n){this._rawAppend(n),this._version+=1}appendMany(n){if(n.length===0)return;let t=this._maxSize!==void 0&&n.length>this._maxSize?n.length-this._maxSize:0;for(let s=t;s<n.length;s++)this._rawAppend(n[s]);this._version+=1}clear(){if(this._size===0)return 0;let n=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let t=0;t<n;t++)this._buf[(this._head+t)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,n}trimHead(n){if(!Number.isInteger(n)||n<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${n})`);if(n===0||this._size===0)return 0;let t=Math.min(n,this._size);if(this._maxSize===void 0)this._buf.splice(0,t);else{for(let s=0;s<t;s++)this._buf[(this._head+s)%this._maxSize]=void 0;this._head=(this._head+t)%this._maxSize}return this._size-=t,this._version+=1,t}slice(n,t){if(!Number.isInteger(n)||n<0)throw new RangeError(`slice: start must be a non-negative integer (got ${n})`);if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${t})`);let s=t===void 0?this._size:Math.min(Math.max(t,0),this._size),h=Math.min(n,this._size);if(h>=s)return[];let o=s-h;if(this._maxSize===void 0)return this._buf.slice(h,s);let b=new Array(o);for(let r=0;r<o;r++)b[r]=this._buf[(this._head+h+r)%this._maxSize];return b}tail(n){if(!Number.isInteger(n)||n<0)throw new RangeError(`tail: n must be a non-negative integer (got ${n})`);if(n===0||this._size===0)return[];let t=Math.min(n,this._size);return this.slice(this._size-t,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let n=new Array(this._size);for(let t=0;t<this._size;t++)n[t]=this._buf[(this._head+t)%this._maxSize];return n}snapshot(){return this.toArray()}restore(n){if(this._maxSize===void 0){this._buf.length=0;for(let t=0;t<n.length;t++)this._buf.push(n[t]);this._size=this._buf.length}else{let t=this._maxSize;for(let o=0;o<t;o++)this._buf[o]=void 0;this._head=0;let s=Math.min(n.length,t),h=n.length-s;for(let o=0;o<s;o++)this._buf[o]=n[h+o];this._size=s}this._version+=1}_rawAppend(n){if(this._maxSize===void 0){this._buf.push(n),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=n,this._size+=1):(this._buf[this._head]=n,this._head=(this._head+1)%this._maxSize)}};function x(g){return g.subscribe(()=>{})}var G=64;function Q(g,n={}){let{name:t,maxSize:s,versioning:h,guard:o,backend:b}=n,r=b??new C(g,s),m=A(r.toArray(),{name:t,describeKind:"state",equals:(e,i)=>e===i,...h!=null?{versioning:h}:{},...o!=null?{guard:o}:{}});function w(){let e=r.toArray();D(()=>{m.down([[$]],{internal:!0}),m.down([[N,e]],{internal:!0})})}let u=new Map,l=new Map,_=new Map;function M(e,i){return`${e}:${i===void 0?"END":i}`}function y(e){if(e.size<G)return;let i=e.keys().next();if(i.done)return;let d=e.get(i.value);d!==void 0&&d.dispose(),e.delete(i.value)}function v(e){let i=r.version;try{return e()}finally{r.version!==i&&w()}}function P(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);let i=u.get(e);if(i!==void 0)return u.delete(e),u.set(e,i),i.node;y(u);let d=k([m],([f])=>{let c=f;return e===0||c.length===0?[]:c.slice(Math.max(0,c.length-e))},{initial:r.tail(e),describeKind:"derived"}),a=x(d);return u.set(e,{node:d,dispose:a}),d}function j(e,i){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(i!==void 0&&(!Number.isInteger(i)||i<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${i})`);let d=M(e,i),a=l.get(d);if(a!==void 0)return l.delete(d),l.set(d,a),a.node;y(l);let f=k([m],([p])=>{let T=p;return i===void 0?T.slice(e):T.slice(e,i)},{initial:r.slice(e,i),describeKind:"derived"}),c=x(f);return l.set(d,{node:f,dispose:c}),f}function q(e){let i=_.get(e);if(i!==void 0)return i.node;let d=k([m,e],([f,c])=>{let p=f,T=Math.max(0,Math.trunc(c??0));return p.slice(T)},{initial:[],describeKind:"derived"}),a=x(d);return _.set(e,{node:d,dispose:a}),d}let L,S;function R(){L===void 0&&(L=H([m],(e,i,d)=>{let a=e[0],c=a!=null&&a.length>0?a.at(-1):d.prevData[0];if(c==null||c.length===0){i.down([[K]]);return}i.emit(c[c.length-1])},{name:t!=null?`${t}::lastValue`:"lastValue",describeKind:"derived",initial:r.size===0?void 0:r.at(r.size-1)}),S=k([m],([e])=>e.length>0,{name:t!=null?`${t}::hasLatest`:"hasLatest",describeKind:"derived",initial:r.size>0}),x(L),x(S))}let I={entries:m,get size(){return r.size},at(e){return r.at(e)},append(e){v(()=>r.append(e))},appendMany(e){e.length!==0&&v(()=>r.appendMany(e))},clear(){v(()=>r.clear())},trimHead(e){v(()=>r.trimHead(e))},withLatest(){return R(),m},get lastValue(){return R(),L},get hasLatest(){return R(),S},view(e){switch(e.kind){case"tail":return P(e.n);case"slice":return j(e.start,e.stop);case"fromCursor":return q(e.cursor)}},attach(e){let i=e.subscribe(d=>{for(let a of d)a[0]===N&&I.append(a[1])});return()=>i()},attachStorage(e){if(e.length===0)return()=>{};let i=new Map;for(let a of e)i.set(a,r.size);(async()=>{for(let a of e)if(typeof a.loadEntries=="function")try{let f=await Promise.resolve(a.loadEntries());f.entries.length>0&&r.size===0&&(r.restore(f.entries),i.set(a,f.entries.length),w());break}catch{}})();let d=m.subscribe(a=>{for(let f of a){if(f[0]!==N)continue;let c=f[1];for(let p of e){let T=i.get(p)??0;if(c.length<T){try{let z=p.appendEntries(c);z instanceof Promise&&z.catch(()=>{})}catch{}i.set(p,c.length);continue}if(c.length===T)continue;let F=c.slice(T);i.set(p,c.length);try{let z=p.appendEntries(F);z instanceof Promise&&z.catch(()=>{})}catch{}}}});return()=>d()},disposeAllViews(){for(let e of u.values())e.dispose();u.clear();for(let e of l.values())e.dispose();l.clear();for(let e of _.values())e.dispose();_.clear()},dispose(){for(let e of u.values())e.dispose();u.clear();for(let e of l.values())e.dispose();l.clear();for(let e of _.values())e.dispose();_.clear()}};return I}var V=new WeakMap;function Z(g){let n=V.get(g);if(n)return n;let t=g.map(u=>u.cache??[]),s=t.flat(),h=A(s,{name:"mergeReactiveLogs",describeKind:"state",equals:(u,l)=>u===l}),o=g.map((u,l)=>[...t[l]??[]]),b=[];for(let u=0;u<g.length;u++){let l=u,_=g[l].subscribe(M=>{for(let y of M)if(y[0]===N)o[l]=[...y[1]],h.emit(o.flat());else if(y[0]===B){o[l]=[];let v=b[l];v!==void 0&&(b[l]=void 0,v())}else y[0]===E&&h.down([[E,y[1]]])});b.push(_)}let r=O(h),m=!1,w={node:h,dispose(){if(!m){m=!0;for(let u of b)u?.();b.length=0,r(),V.delete(g)}}};return V.set(g,w),w}export{C as a,Q as b,Z as c};
@@ -1 +1 @@
1
- import{b as F,c as G}from"./chunk-L3KUKDZC.js";import{b as $}from"./chunk-TZQPPQEQ.js";import{j as _}from"./chunk-2JO6LXFT.js";import{t as B}from"./chunk-4F564IPP.js";import{B as N}from"./chunk-T7EQPKOP.js";import{D as x,E as I,G as S,H as M,m as A}from"./chunk-LYCLF26R.js";import{b as k,c as v,d as y,f as T,g as O,i as E,j as w}from"./chunk-CK2E7BTU.js";import{b as K}from"./chunk-QYADASLV.js";var U={};K(U,{budgetGate:()=>C,effectivenessTracker:()=>L,feedback:()=>V,funnel:()=>P,scorer:()=>z});function R(u,t){return G("reduction",u,t)}function P(u,t,i,b){if(t.length===0)throw new RangeError("funnel requires at least one source");if(i.length===0)throw new RangeError("funnel requires at least one stage");let d=new _(u,b),s=t.length===1?t[0]:B(...t);d.add(s,{name:"merged"});let e="merged";for(let f=0;f<i.length;f++){let o=i[f],c=new _(o.name);o.build(c);try{c.resolve("input")}catch{throw new Error(`funnel stage "${o.name}" must define an "input" node`)}try{c.resolve("output")}catch{throw new Error(`funnel stage "${o.name}" must define an "output" node`)}d.mount(o.name,c);let l=d.resolve(e),m=`${o.name}::input`,g=d.resolve(m),a=`__bridge_${e}\u2192${o.name}_input`,p=M([l],([r])=>{g.emit(r)},{name:a});d.add(p,{name:a}),d.addDisposer(N(p)),e=`${o.name}::output`}return d}function V(u,t,i,b){let d=b?.maxIterations??10,s=`__feedback_${t}`,e=I(0,{meta:R("feedback_counter",{maxIterations:d,feedbackFrom:t,feedbackTo:i})});u.add(e,{name:s});let f=u.resolve(t),o=u.resolve(i),c=`__feedback_effect_${t}`,l=x([],(m,g)=>{let a=f.subscribe(p=>{for(let r of p){let n=r[0];if(n===k){let h=r[1];if(h==null)return;A(()=>{F(e,d)&&o.emit(h)})}else if(n===E||n===w){let h=n===w&&r.length>1?[w,r[1]]:[n];e.down([h])}}});return()=>a()},{name:c,describeKind:"effect",meta:{...R("feedback_effect",{feedbackFrom:t,feedbackTo:i}),_internal:!0}});return u.add(l,{name:c}),u.addDisposer(N(l)),u}function C(u,t,i){if(t.length===0)throw new RangeError("budgetGate requires at least one constraint");let b=t.map(a=>a.node),d=[u,...b],s=[],e=!1,f=!1,o=Symbol("budget-gate"),c=new Array(t.length);function l(){return t.every((a,p)=>a.check(c[p]))}function m(a){for(;s.length>0&&l();){let p=s[0];s=s.slice(1),a.emit(p)}s.length===0&&f&&(f=!1,a.down([[y]]))}return x([],(a,p)=>{for(let n=0;n<t.length;n++)c[n]=t[n].node.cache;let r=[];for(let n=0;n<d.length;n++){let h=d[n];r.push(h.subscribe(q=>{for(let D of q)g(D,n,p)}))}return()=>{for(let n of r)n()}},{...i,describeKind:"derived",meta:R("budget_gate",i?.meta)});function g(a,p,r){let n=a[0];if(p===0){if(n===k)return l()&&s.length===0?r.emit(a[1]):(s.push(a[1]),e||(e=!0,r.up([[T,o]]))),!0;if(n===v)return r.down([[v]]),!0;if(n===y)return s.length===0?r.down([[y]]):f=!0,!0;if(n===E||n===w){for(let h of s)r.emit(h);return s=[],f=!1,e&&(e=!1,r.up([[O,o]])),r.down([a]),!0}return!1}return n===k&&(c[p-1]=a[1]),n===k||n===y?(l()&&s.length>0?(m(r),s.length===0&&e&&(e=!1,r.up([[O,o]]))):!l()&&!e&&s.length>0&&(e=!0,r.up([[T,o]])),!0):n===v?!0:n===w?(r.down([a]),!0):n===E}}function z(u,t,i){if(u.length===0)throw new RangeError("scorer requires at least one source");if(u.length!==t.length)throw new RangeError("scorer requires the same number of sources and weights");let b=[...u,...t],d=u.length,s=i?.scoreFns;return S(b,e=>{let f=e.slice(0,d),o=e.slice(d),c=[],l=0;for(let m=0;m<d;m++){let g=f[m]??0,a=o[m]??0,r=(s?.[m]?s[m](g):g)*a;c.push(r),l+=r}return{value:f,score:l,breakdown:c}},{...i?{equals:i.equals,resubscribable:i.resubscribable,resetOnTeardown:i.resetOnTeardown}:{},describeKind:"derived",meta:R("scorer",i?.meta)})}function L(u){let t=$({name:u?.name??"effectiveness-entries"}),i=S([t.entries],([e])=>new Map(e),{name:`${u?.name??"effectiveness"}-snapshot`,equals:(e,f)=>{let o=e,c=f;if(o.size!==c.size)return!1;for(let[l,m]of o){let g=c.get(l);if(!g||m.attempts!==g.attempts||m.successes!==g.successes)return!1}return!0}});function b(e,f){let o=t.get(e),c=(o?.attempts??0)+1,l=(o?.successes??0)+(f?1:0);t.set(e,{key:e,attempts:c,successes:l,successRate:l/c})}function d(e){return t.get(e)}let s=N(i);return{node:i,record:b,lookup:d,dispose:()=>s()}}export{P as a,V as b,C as c,z as d,L as e,U as f};
1
+ import{b as F,c as G}from"./chunk-O32GJOUJ.js";import{b as $}from"./chunk-TZQPPQEQ.js";import{j as _}from"./chunk-5KPIYVCC.js";import{t as B}from"./chunk-JJTF75VS.js";import{C as N}from"./chunk-MQZWA3DF.js";import{D as x,E as I,G as S,H as M,m as A}from"./chunk-LYCLF26R.js";import{b as k,c as v,d as y,f as T,g as O,i as E,j as w}from"./chunk-CK2E7BTU.js";import{b as K}from"./chunk-QYADASLV.js";var U={};K(U,{budgetGate:()=>C,effectivenessTracker:()=>L,feedback:()=>V,funnel:()=>P,scorer:()=>z});function R(u,t){return G("reduction",u,t)}function P(u,t,i,b){if(t.length===0)throw new RangeError("funnel requires at least one source");if(i.length===0)throw new RangeError("funnel requires at least one stage");let d=new _(u,b),s=t.length===1?t[0]:B(...t);d.add(s,{name:"merged"});let e="merged";for(let f=0;f<i.length;f++){let o=i[f],c=new _(o.name);o.build(c);try{c.resolve("input")}catch{throw new Error(`funnel stage "${o.name}" must define an "input" node`)}try{c.resolve("output")}catch{throw new Error(`funnel stage "${o.name}" must define an "output" node`)}d.mount(o.name,c);let l=d.resolve(e),m=`${o.name}::input`,g=d.resolve(m),a=`__bridge_${e}\u2192${o.name}_input`,p=M([l],([r])=>{g.emit(r)},{name:a});d.add(p,{name:a}),d.addDisposer(N(p)),e=`${o.name}::output`}return d}function V(u,t,i,b){let d=b?.maxIterations??10,s=`__feedback_${t}`,e=I(0,{meta:R("feedback_counter",{maxIterations:d,feedbackFrom:t,feedbackTo:i})});u.add(e,{name:s});let f=u.resolve(t),o=u.resolve(i),c=`__feedback_effect_${t}`,l=x([],(m,g)=>{let a=f.subscribe(p=>{for(let r of p){let n=r[0];if(n===k){let h=r[1];if(h==null)return;A(()=>{F(e,d)&&o.emit(h)})}else if(n===E||n===w){let h=n===w&&r.length>1?[w,r[1]]:[n];e.down([h])}}});return()=>a()},{name:c,describeKind:"effect",meta:{...R("feedback_effect",{feedbackFrom:t,feedbackTo:i}),_internal:!0}});return u.add(l,{name:c}),u.addDisposer(N(l)),u}function C(u,t,i){if(t.length===0)throw new RangeError("budgetGate requires at least one constraint");let b=t.map(a=>a.node),d=[u,...b],s=[],e=!1,f=!1,o=Symbol("budget-gate"),c=new Array(t.length);function l(){return t.every((a,p)=>a.check(c[p]))}function m(a){for(;s.length>0&&l();){let p=s[0];s=s.slice(1),a.emit(p)}s.length===0&&f&&(f=!1,a.down([[y]]))}return x([],(a,p)=>{for(let n=0;n<t.length;n++)c[n]=t[n].node.cache;let r=[];for(let n=0;n<d.length;n++){let h=d[n];r.push(h.subscribe(q=>{for(let D of q)g(D,n,p)}))}return()=>{for(let n of r)n()}},{...i,describeKind:"derived",meta:R("budget_gate",i?.meta)});function g(a,p,r){let n=a[0];if(p===0){if(n===k)return l()&&s.length===0?r.emit(a[1]):(s.push(a[1]),e||(e=!0,r.up([[T,o]]))),!0;if(n===v)return r.down([[v]]),!0;if(n===y)return s.length===0?r.down([[y]]):f=!0,!0;if(n===E||n===w){for(let h of s)r.emit(h);return s=[],f=!1,e&&(e=!1,r.up([[O,o]])),r.down([a]),!0}return!1}return n===k&&(c[p-1]=a[1]),n===k||n===y?(l()&&s.length>0?(m(r),s.length===0&&e&&(e=!1,r.up([[O,o]]))):!l()&&!e&&s.length>0&&(e=!0,r.up([[T,o]])),!0):n===v?!0:n===w?(r.down([a]),!0):n===E}}function z(u,t,i){if(u.length===0)throw new RangeError("scorer requires at least one source");if(u.length!==t.length)throw new RangeError("scorer requires the same number of sources and weights");let b=[...u,...t],d=u.length,s=i?.scoreFns;return S(b,e=>{let f=e.slice(0,d),o=e.slice(d),c=[],l=0;for(let m=0;m<d;m++){let g=f[m]??0,a=o[m]??0,r=(s?.[m]?s[m](g):g)*a;c.push(r),l+=r}return{value:f,score:l,breakdown:c}},{...i?{equals:i.equals,resubscribable:i.resubscribable,resetOnTeardown:i.resetOnTeardown}:{},describeKind:"derived",meta:R("scorer",i?.meta)})}function L(u){let t=$({name:u?.name??"effectiveness-entries"}),i=S([t.entries],([e])=>new Map(e),{name:`${u?.name??"effectiveness"}-snapshot`,equals:(e,f)=>{let o=e,c=f;if(o.size!==c.size)return!1;for(let[l,m]of o){let g=c.get(l);if(!g||m.attempts!==g.attempts||m.successes!==g.successes)return!1}return!0}});function b(e,f){let o=t.get(e),c=(o?.attempts??0)+1,l=(o?.successes??0)+(f?1:0);t.set(e,{key:e,attempts:c,successes:l,successRate:l/c})}function d(e){return t.get(e)}let s=N(i);return{node:i,record:b,lookup:d,dispose:()=>s()}}export{P as a,V as b,C as c,z as d,L as e,U as f};
@@ -0,0 +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-OBU472D2.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,18 @@
1
+ import{a as Ne,h as Re}from"./chunk-A5HZZYRK.js";import{a as Pe}from"./chunk-SGS4OJGS.js";import{x as fe}from"./chunk-JJTF75VS.js";import{a as Z,b as le,i as Oe}from"./chunk-4VVTGLXJ.js";import{f as pe}from"./chunk-MQZWA3DF.js";import{A as ee,D as be,E as U,F as B,m as J,p as D}from"./chunk-LYCLF26R.js";import{b as E,c as ye,d as ke,h as de,i as P,j as x}from"./chunk-CK2E7BTU.js";function Ce(r){return{describeKind:"producer",...r}}function oe(r,n){return B(i=>{let s=!0,u={emit(t){s&&i.emit(t)},error(t){s&&(s=!1,i.down([[x,t]]))},complete(){s&&(s=!1,i.down([[P]]))}},o;try{let t=r(u);o=typeof t=="function"?t:void 0}catch(t){return u.error(t),()=>{s=!1}}return()=>{s=!1;try{o?.()}catch{}}},Ce(n))}function Me(r,n,i){let s=!0,u,o=0,t=0,e={},a=[],c=()=>{let l=u;u=void 0;try{l?.()}catch{}};for(let l of n){let m=i?.name?`${i.name}::${l}`:l,g=i?.channelOpts?.[l],y=B(T=>(o++,()=>{t++,o>0&&t>=o&&t>=n.length&&c()}),Ce({...g,name:m}));e[l]=y,a.push(y)}let f={};for(let l of n)f[l]=m=>{s&&e[l].down([[E,m]])};f.error=l=>{s&&(s=!1,J(()=>{for(let m of a)m.down([[x,l]])}),c())},f.complete=()=>{s&&(s=!1,J(()=>{for(let l of a)l.down([[P]])}),c())};let p=r(f);return u=typeof p=="function"?p:void 0,Object.assign(e,{dispose:()=>{s&&(s=!1,J(()=>{for(let l of a)try{l.down([[P]])}catch{}}),c())}})}var he=class{ring;arr;constructor(n){n===Number.POSITIVE_INFINITY||n<=0?(this.arr=[],this.ring=null):(this.ring=new Pe(n),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(n){this.ring!=null?this.ring.push(n):this.arr.push(n)}shift(){return this.ring!=null?this.ring.shift():this.arr.shift()}drain(){if(this.ring!=null){let i=this.ring.toArray();return this.ring.clear(),i}let n=this.arr;return this.arr=[],n}};function se(r){return r instanceof Error?r:new Error(String(r))}function De(r){return r===void 0?null:typeof r=="string"?Oe(r):r}function z(r,n){let{name:i,onTransportError:s,retry:u,backpressure:o,batchSize:t=Number.POSITIVE_INFINITY,flushIntervalMs:e=0,serialize:a,stopOn:c,onUpstreamMessage:f,onDispose:p,send:d,sendBatch:l,ctx:m}=n;if(!d&&!l)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let g=m,y=Math.max(1,u?.maxAttempts??1),T=De(u?.backoff??(y>1?"exponential":void 0)),h=u?.shouldRetry??(()=>!0),b=l!==void 0||t<Number.POSITIVE_INFINITY||e>0,w=k=>i?`${i}::${k}`:void 0,v=U(void 0,{equals:()=>!1,name:w("sent")}),S=U(null,{name:w("failed")}),L=U(0,{name:w("inFlight")}),F=U(null,{name:w("errors")}),K=b?U(0,{name:w("buffered")}):void 0,Y=o?U(!1,{name:w("paused")}):void 0,ie=0,Q=k=>{ie+=k,L.down([[E,ie]])},O=k=>{try{s?.(k)}catch{}try{F.down([[E,k]])}catch{}},q=new Set,V=k=>{q.add(k);let N=()=>q.delete(k);k.then(N,N)},I=(k,N,C)=>{let A=T?T(N-1,C,null):0,H=A==null?0:typeof A=="number"&&A>0?A:0,j=Math.max(1,Math.ceil(H/1e6));return new Promise(M=>{setTimeout(()=>M(k()),j)})},$=k=>k!=null&&typeof k=="object"&&typeof k.then=="function",_=k=>{let N;try{N=a?a(k):k}catch(M){let R=se(M);return O({stage:"serialize",error:R,value:k}),S.down([[E,{value:k,error:R,attempts:0}]]),Promise.resolve()}let C=0,A=M=>{Q(-1);let R=se(M);if(O({stage:"send",error:R,value:k,attempt:C}),!(C<y&&h(R,C))){S.down([[E,{value:k,error:R,attempts:C}]]);return}return I(j,C,R)},H=()=>{Q(-1),v.down([[E,k]])};function j(){C+=1,Q(1);let M;try{M=d(N,g)}catch(R){return A(R)??Promise.resolve()}return $(M)?M.then(H,R=>A(R)):(H(),Promise.resolve())}return j()},te=o?.maxBuffer??Number.POSITIVE_INFINITY,X=new he(te),G,ae=!1,me=()=>{K?.down([[E,X.length]])},ue=k=>{Y&&Y.down([[E,k]])},we=o?.strategy??"drop-oldest",Be=(k,N)=>{let C={value:k,payload:N};if(X.length<te)return X.push(C),me(),!0;if(we==="drop-oldest"){let H=X.shift();return X.push(C),me(),ue(!0),S.down([[E,{value:H.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(we==="drop-newest")return ue(!0),S.down([[E,{value:k,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let A=new Error("backpressure: buffer overflow");return O({stage:"send",error:A,value:k}),S.down([[E,{value:k,error:A,attempts:0}]]),ue(!0),!1},Fe=k=>{let N=0,C=k.map(M=>M.payload),A=M=>{Q(-1);let R=se(M);if(O({stage:"send",error:R,value:k.map(ge=>ge.value),attempt:N}),!(N<y&&h(R,N))){for(let{value:ge}of k)S.down([[E,{value:ge,error:R,attempts:N}]]);return}return I(j,N,R)},H=()=>{Q(-1);for(let{value:M}of k)v.down([[E,M]])};function j(){N+=1,Q(1);let M;try{M=l(C,g)}catch(R){return A(R)??Promise.resolve()}return $(M)?M.then(H,R=>A(R)):(H(),Promise.resolve())}return j()},He=async k=>{for(let N of k)await ze(N.value,N.payload)},ze=(k,N)=>{let C=0,A=M=>{Q(-1);let R=se(M);if(O({stage:"send",error:R,value:k,attempt:C}),!(C<y&&h(R,C))){S.down([[E,{value:k,error:R,attempts:C}]]);return}return I(j,C,R)},H=()=>{Q(-1),v.down([[E,k]])};function j(){C+=1,Q(1);let M;try{M=d(N,g)}catch(R){return A(R)??Promise.resolve()}return $(M)?M.then(H,R=>A(R)):(H(),Promise.resolve())}return j()},ne=()=>{if(ae||X.length===0)return Promise.resolve();let k=X.drain();if(me(),ue(!1),l!==void 0){let C=Fe(k);return V(C),C}let N=He(k);return V(N),N},qe=()=>{G!==void 0||ae||e<=0||(G=setTimeout(()=>{G=void 0,ne()},e))},Ue=r.subscribe(k=>{for(let N of k){let C=N[0];if(C!==E)try{f?.(N)}catch{}if(C===E){let A=N[1];if(b){let H;if(a)try{H=a(A)}catch(M){let R=se(M);O({stage:"serialize",error:R,value:A}),S.down([[E,{value:A,error:R,attempts:0}]]);continue}else H=A;if(!Be(A,H))continue;X.length>=t?ne():qe()}else{let H=_(A);V(H)}}else ee.messageTier(C)>=3&&b&&(G!==void 0&&(clearTimeout(G),G=void 0),ne())}}),Se;if(c){let k=!1;Se=c.subscribe(N=>{if(!k){k=!0;return}N.length>0&&!Te&&Ee()})}let Te=!1,Ee=()=>{if(Te)return;Te=!0,G!==void 0&&(clearTimeout(G),G=void 0),b&&ne(),ae=!0,Se?.(),Ue();let k=N=>{try{N.down([[de]])}catch{}};k(F),k(S),k(v),k(L),K&&k(K),Y&&k(Y);try{p?.()}catch{}},ce={dispose:Ee,sent:v,failed:S,inFlight:L,errors:F};return b&&(ce.buffered=K,ce.flush=async()=>{ae||(await ne(),await Promise.all(q))}),Y&&(ce.paused=Y),ce}function W(r){return{describeKind:"producer",...r}}function Ke(r,n){let{parse:i,closeOnTeardown:s=!1,...u}=n??{};return B(o=>{let t=!0,e,a=()=>{let T=e;e=void 0,T?.()},c=T=>{t&&(t=!1,o.down([T]),a())},f=(T,h=T)=>{if(t)try{let b=T!==null&&typeof T=="object"&&"data"in T?T.data:T,w=i?i(b,h):b;o.emit(w)}catch(b){c([x,b])}},p=T=>{c([x,T])},d=()=>{c([P])};if(typeof r=="function"){try{if(e=r(f,p,d),typeof e!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(T){c([x,T])}return()=>{t=!1,a()}}let l=r,m=T=>f(T,T),g=T=>p(T),y=()=>d();return l.addEventListener("message",m),l.addEventListener("error",g),l.addEventListener("close",y),e=()=>{l.removeEventListener("message",m),l.removeEventListener("error",g),l.removeEventListener("close",y),s&&l.close()},()=>{t=!1,a()}},W(u))}function Tr(r,n){return oe(r,n)}function $e(r,n){let{method:i="GET",headers:s,body:u,transform:o=b=>b.json(),timeoutNs:t=30*1e9,signal:e,completeAfterFetch:a=!1,refetchOnSubscribe:c=!1,...f}=n??{},p=U(0,{name:`${f.name??"http"}/fetchCount`}),d=U(0,{name:`${f.name??"http"}/lastUpdated`}),l=U(!1,{name:`${f.name??"http"}/fetched`}),m=0,g=u!==void 0?typeof u=="string"?u:JSON.stringify(u):void 0,y=b=>{let w=new AbortController,v=!0;if(e?.aborted)return v=!1,b.down([[x,e.reason??new Error("Aborted")]]),()=>{};e?.addEventListener("abort",()=>w.abort(e.reason),{once:!0});let S=setTimeout(()=>w.abort(new Error("Request timeout")),Math.ceil(t/1e6));return fetch(r,{method:i,headers:s,body:g,signal:w.signal}).then(async L=>{if(clearTimeout(S),!v)return;if(!L.ok)throw new Error(`HTTP ${L.status}: ${L.statusText}`);let F=await o(L);v&&(J(()=>{m+=1,p.down([[E,m]]),d.down([[E,D()]]),l.down([[E,!0]]),b.emit(F)}),a&&b.down([[P]]))}).catch(L=>{clearTimeout(S),v&&(L&&L.name==="AbortError"||b.down([[x,L]]))}),()=>{v=!1,w.abort()}},T=B(b=>y({emit:w=>b.emit(w),down:w=>b.down(w)}),{...W(f),resubscribable:c});return{...Re(T),fetchCount:p,lastUpdated:d,fetched:l}}function gr(r,n,i){let{method:s="POST",headers:u={"Content-Type":"application/json"},serialize:o=m=>JSON.stringify(m),timeoutNs:t,batchFormat:e="json-array",batchSize:a,flushIntervalMs:c,retry:f,onTransportError:p}=i??{},d=async m=>{let g=t!==void 0?new AbortController:void 0,y;g&&t!==void 0&&(y=setTimeout(()=>g.abort(new Error("Request timeout")),Math.ceil(t/1e6)));try{let T=await fetch(n,{method:s,headers:u,body:m,signal:g?.signal}),h=async()=>{try{await T.arrayBuffer?.()}catch{}};if(!T.ok)throw await h(),new Error(`HTTP ${T.status}: ${T.statusText}`);await h()}finally{y!==void 0&&clearTimeout(y)}};return a!==void 0||c!==void 0?z(r,{onTransportError:p,retry:f,batchSize:a,flushIntervalMs:c,sendBatch:async m=>{let g;e==="ndjson"?g=m.map(y=>{let T=o(y);return typeof T=="string"?T:new TextDecoder().decode(T)}).join(`
2
+ `):g=JSON.stringify(m),await d(g)}}):z(r,{onTransportError:p,retry:f,serialize:o,send:async m=>{await d(m)}})}function Ae(r){return Symbol.keyFor(r)??r.description??"message"}function re(r,n){return typeof r=="string"?r:n(r)}function Le(r,n){let i=`event: ${r}
3
+ `;if(n!==void 0){let s=n.split(/\r?\n/);for(let u of s)i+=`data: ${u}
4
+ `}return`${i}
5
+ `}function yr(r,n){let{serialize:i=l=>{if(l instanceof Error)return l.message;try{return JSON.stringify(l)}catch{return String(l)}},dataEvent:s="data",errorEvent:u="error",completeEvent:o="complete",includeResolved:t=!1,includeDirty:e=!1,keepAliveMs:a,signal:c,eventNameResolver:f=Ae}=n??{},p=new TextEncoder,d;return new ReadableStream({start(l){let m=!1,g,y=()=>{},T=()=>{m||(m=!0,g!==void 0&&clearInterval(g),c?.removeEventListener("abort",b),y(),l.close())};d=T;let h=(w,v)=>{m||l.enqueue(p.encode(Le(w,v)))},b=()=>{m||T()};y=r.subscribe(w=>{for(let v of w){let S=v[0];if(!(ee.isLocalOnly(S)&&!(S===ye&&e))){if(S===E){h(s,re(v[1],i));continue}if(S===x){h(u,re(v[1],i)),T();return}if(S===P){h(o),T();return}!t&&S===ke||h(f(S),v.length>1?re(v[1],i):void 0)}}}),a!==void 0&&a>0&&(g=setInterval(()=>{m||l.enqueue(p.encode(`: keepalive
6
+
7
+ `))},a)),c?.aborted?b():c?.addEventListener("abort",b,{once:!0})},cancel(){d?.()}})}function kr(r,n){let{serialize:i=d=>{if(d instanceof Error)return d.message;try{return JSON.stringify(d)}catch{return String(d)}},dataEvent:s="data",errorEvent:u="error",completeEvent:o="complete",includeResolved:t=!1,includeDirty:e=!1,keepAliveMs:a,signal:c,eventNameResolver:f=Ae}=n??{},p=new TextEncoder;return B(d=>{let l=!0,m,g=(h,b)=>{l&&d.emit(p.encode(Le(h,b)))},y=()=>{l&&(l=!1,d.down([[P]]))},T=r.subscribe(h=>{if(l)for(let b of h){let w=b[0];if(!(ee.isLocalOnly(w)&&!(w===ye&&e))){if(w===E){g(s,re(b[1],i));continue}if(w===x){g(u,re(b[1],i)),l=!1,d.down([[P]]);return}if(w===P){g(o),l=!1,d.down([[P]]);return}!t&&w===ke||g(f(w),b.length>1?re(b[1],i):void 0)}}});return a!==void 0&&a>0&&(m=setInterval(()=>{l&&d.emit(p.encode(`: keepalive
8
+
9
+ `))},a)),c?.aborted?y():c?.addEventListener("abort",y,{once:!0}),()=>{l=!1,m!==void 0&&clearInterval(m),c?.removeEventListener("abort",y),T()}})}function br(r){let n,i=!1;return new ReadableStream({start(s){n=r.subscribe(u=>{for(let o of u){let t=o[0];if(i)return;if(t===E)try{s.enqueue(o[1])}catch{i=!0,n?.()}else if(t===x){i=!0;try{s.error(o[1])}catch{}return}else if(t===P){i=!0;try{s.close()}catch{}return}}})},cancel(){i=!0,n?.()}})}async function*je(r,n){let i=n?.parse??(v=>v),s=n?.signal,u=new TextDecoder,o="",t="message",e=[],a,c,f=[],p=()=>{if(e.length===0&&t==="message"&&a===void 0){e=[];return}let v=e.join(`
10
+ `);f.push({event:t,data:i(v),id:a,retry:c}),t="message",e=[],a=void 0,c=void 0},d=v=>{if(v===""){p();return}if(v.startsWith(":"))return;let S=v.indexOf(":"),L=S<0?v:v.slice(0,S),F=S<0?"":v.slice(S+1);switch(F.startsWith(" ")&&(F=F.slice(1)),L){case"event":t=F;break;case"data":e.push(F);break;case"id":F.includes("\0")||(a=F);break;case"retry":{let K=Number(F);Number.isFinite(K)&&(c=K);break}}},l=(v,S)=>{o+=u.decode(v,{stream:!S});let L=o.split(/\r?\n/);o=L.pop()??"";for(let F of L)d(F)},m=r,g=r instanceof ReadableStream?r:m&&typeof m=="object"&&m.body instanceof ReadableStream?m.body:null,y,T,h=!1,b=()=>{h||(h=!0,y&&y.cancel().catch(()=>{}),T&&typeof T.return=="function"&&Promise.resolve(T.return()).catch(()=>{}))},w=()=>{b()};if(s){if(s.aborted)return;s.addEventListener("abort",w,{once:!0})}try{if(g){for(y=g.getReader();!s?.aborted;){let{value:v,done:S}=await y.read();if(S)break;for(l(v,!1);f.length>0;)yield f.shift()}l(new Uint8Array,!0)}else{for(T=r[Symbol.asyncIterator]();!s?.aborted;){let S=await T.next();if(S.done)break;for(l(S.value,!1);f.length>0;)yield f.shift()}l(new Uint8Array,!0)}if(o.trim()){for(let v of o.split(/\r?\n/))d(v);p()}for(;f.length>0;)yield f.shift()}finally{s&&s.removeEventListener("abort",w),b()}}function hr(r,n){let{parse:i,...s}=n??{};return B(u=>{let o=!0,t=new AbortController;return(async()=>{try{for await(let a of je(r,{parse:i,signal:t.signal})){if(!o)return;u.emit(a)}o&&u.down([[P]])}catch(a){o&&u.down([[x,a]])}})(),()=>{o=!1,t.abort()}},W(s))}function vr(r,n){let{method:i="GET",headers:s,body:u,signal:o,...t}=n??{};return B(e=>{let a=!0,c=new AbortController;if(o?.aborted)return e.down([[x,o.reason??new Error("Aborted")]]),()=>{};o?.addEventListener("abort",()=>c.abort(o.reason),{once:!0});let f=u!==void 0?typeof u=="string"?u:JSON.stringify(u):void 0;return(async()=>{try{let d=await fetch(r,{method:i,headers:s,body:f,signal:c.signal});if(!a)return;if(!d.ok)throw new Error(`HTTP ${d.status}: ${d.statusText}`);if(!d.body)throw new Error("HTTP response has no body");let l=d.body.getReader();for(;a;){let{value:m,done:g}=await l.read();if(g)break;m&&e.emit(m)}a&&e.down([[P]])}catch(d){if(!a||d&&d.name==="AbortError")return;e.down([[x,d]])}})(),()=>{a=!1,c.abort()}},W(t))}function wr(r,n){let{intervalMs:i=5e3,...s}=n??{};return fe(pe(i,{period:i}),()=>$e(r,{...s,completeAfterFetch:!0}).node)}function Sr(r,n,i){let{serialize:s=T=>{if(typeof T=="string"||T instanceof Blob||T instanceof ArrayBuffer||ArrayBuffer.isView(T))return T;try{return JSON.stringify(T)}catch{return String(T)}},closeOnComplete:u=!0,closeOnError:o=!0,closeCode:t,closeReason:e,onTransportError:a,retry:c,backpressure:f,stopOn:p}=i??{},d=!1,l=T=>{if(!d){d=!0;try{n.close(t,e)}catch(h){let b=h instanceof Error?h:new Error(String(h));try{a?.({stage:"close",error:b,value:void 0,message:T})}catch{}}}},m=null,y=z(r,{onTransportError:a,serialize:T=>{let h=s(T);if(h===void 0)throw new Error("serialize returned undefined");return h},retry:c,backpressure:f,stopOn:p,onDispose:()=>{if(m){try{n.removeEventListener("close",m)}catch{}m=null}},send:T=>{n.send(T)},onUpstreamMessage:T=>{(T[0]===P&&u||T[0]===x&&o)&&l(T)}});return m=()=>{d=!0,y.dispose()},n.addEventListener("close",m),y}function Er(r,n){let{parse:i,maxRetries:s,backoff:u="exponential",closeOnTeardown:o=!0,...t}=n??{};return Ne(()=>Ke(r(),{parse:i,closeOnTeardown:o,...t}),{count:s,backoff:u})}function xr(r,n){let{method:i="notifications/message",onDisconnect:s,...u}=n??{};return oe(({emit:o,error:t})=>(r.setNotificationHandler(i,e=>o(e)),s?.(e=>t(e??new Error("MCP client disconnected"))),()=>r.setNotificationHandler(i,()=>{})),u)}function Or(r,n){return Me(({traces:s,metrics:u,logs:o,error:t})=>r({onTraces:e=>{J(()=>{for(let a of e)s(a)})},onMetrics:e=>{J(()=>{for(let a of e)u(a)})},onLogs:e=>{J(()=>{for(let a of e)o(a)})},onError:t})??void 0,["traces","metrics","logs"],n?.name?{name:n.name}:void 0)}function Nr(r,n){return oe(r,n)}function Rr(r){let n=r.match(/^<(\d{1,3})>\d?\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*(.*)/s);if(!n){let s=D();return{facility:1,severity:6,timestamp:new Date(Math.floor(s/1e6)).toISOString(),hostname:"-",appName:"-",procId:"-",msgId:"-",message:r.trim(),timestampNs:s}}let i=Number(n[1]);return{facility:i>>3,severity:i&7,timestamp:n[2],hostname:n[3],appName:n[4],procId:n[5],msgId:n[6],message:(n[7]??"").trim(),timestampNs:D()}}function Pr(r,n){return oe(r,n)}var We={c:"counter",g:"gauge",ms:"timer",h:"histogram",s:"set",d:"distribution"};function Cr(r){let n=r.split("|"),[i,s]=(n[0]??"").split(":");if(!i||s===void 0)throw new Error(`Invalid StatsD line: ${r}`);let u=n[1]?.trim()??"c",o=We[u]??"counter",t=o==="set"?0:Number(s),e,a={};for(let c=2;c<n.length;c++){let f=n[c].trim();if(f.startsWith("@"))e=Number(f.slice(1));else if(f.startsWith("#"))for(let p of f.slice(1).split(",")){let[d,l]=p.split(":");d&&(a[d]=l??"")}}return{name:i.trim(),value:t,type:o,sampleRate:e,tags:a,timestampNs:D()}}function Mr(r,n){let{intervalNs:i=15*1e9,headers:s,timeoutNs:u=10*1e9,signal:o,maxConsecutiveErrors:t=1}=n??{},e=Math.ceil(i/1e6),a=0;return fe(pe(0,{period:e,signal:o}),()=>B(c=>{let f=!0,p=new AbortController,d=setTimeout(()=>p.abort(new Error("Scrape timeout")),Math.ceil(u/1e6));return(async()=>{try{let m=await fetch(r,{headers:{Accept:"text/plain",...s},signal:p.signal});if(clearTimeout(d),!f)return;if(!m.ok)throw new Error(`Prometheus scrape ${m.status}: ${m.statusText}`);let g=await m.text();if(!f)return;let y=Qe(g);for(let T of y)c.emit(T);a=0,c.down([[P]])}catch(m){if(clearTimeout(d),!f||m instanceof Error&&m.name==="AbortError")return;a+=1,a>=t&&c.down([[x,m]])}})(),()=>{f=!1,clearTimeout(d),p.abort()}}))}function Qe(r){let n=[],i=new Map,s=new Map;for(let u of r.split(`
11
+ `)){let o=u.trim();if(!o)continue;if(o.startsWith("# TYPE ")){let d=o.slice(7),l=d.indexOf(" ");l>0&&i.set(d.slice(0,l),d.slice(l+1).trim());continue}if(o.startsWith("# HELP ")){let d=o.slice(7),l=d.indexOf(" ");l>0&&s.set(d.slice(0,l),d.slice(l+1).trim());continue}if(o.startsWith("#"))continue;let t,e={},a,c,f=o.indexOf("{");if(f>=0){t=o.slice(0,f);let d=o.indexOf("}",f);if(d<0)continue;let l=o.slice(f+1,d);e=Je(l);let m=o.slice(d+1).trim().split(/\s+/);a=m[0]??"",c=m[1]}else{let d=o.split(/\s+/);t=d[0]??"",a=d[1]??"",c=d[2]}if(!t||!a)continue;let p=t.replace(/(_total|_count|_sum|_bucket|_created|_info)$/,"");n.push({name:t,labels:e,value:Number(a),timestampMs:c?Number(c):void 0,type:i.get(p)??i.get(t),help:s.get(p)??s.get(t),timestampNs:D()})}return n}function Je(r){let n={},i=/(\w+)="((?:[^"\\]|\\.)*)"/g,s=i.exec(r);for(;s!==null;)n[s[1]]=s[2].replace(/\\(.)/g,"$1"),s=i.exec(r);return n}function Ar(r,n,i){let{fromBeginning:s=!1,deserialize:u=t=>{if(t===null)return null;try{return JSON.parse(t.toString())}catch{return t.toString()}},...o}=i??{};return B(t=>{let e=!0;return(async()=>{try{await r.subscribe({topic:n,fromBeginning:s}),await r.run({eachMessage:async({topic:c,partition:f,message:p})=>{if(!e)return;let d={};if(p.headers)for(let[l,m]of Object.entries(p.headers))m!==void 0&&(d[l]=typeof m=="string"?m:m.toString());t.emit({topic:c,partition:f,key:p.key?.toString()??null,value:u(p.value),headers:d,offset:p.offset,timestamp:p.timestamp,timestampNs:D()})}})}catch(c){e&&t.down([[x,c]])}})(),()=>{e=!1}},W(o))}function Lr(r,n,i,s){let{serialize:u=e=>JSON.stringify(e),keyExtractor:o,onTransportError:t}=s??{};return z(r,{onTransportError:t,send:async e=>{let a=o?.(e)??null,c=u(e);await n.send({topic:i,messages:[{key:a,value:Buffer.from(c)}]})}})}function Ir(r,n,i){let{blockMs:s=5e3,startId:u="$",parse:o=e=>{for(let c=0;c<e.length;c+=2)if(e[c]==="data")try{return JSON.parse(e[c+1])}catch{return e[c+1]}let a={};for(let c=0;c<e.length;c+=2)a[e[c]]=e[c+1];return a},...t}=i??{};return B(e=>{let a=!0,c=u;return(async()=>{for(;a;)try{let p=await r.xread("BLOCK",s,"STREAMS",n,c);if(!a)return;if(p)for(let[d,l]of p)for(let[m,g]of l)c=m,e.emit({id:m,key:n,data:o(g),timestampNs:D()})}catch(p){if(!a)return;e.down([[x,p]]);return}})(),()=>{a=!1}},W(t))}function Br(r,n,i,s){let{serialize:u=e=>["data",JSON.stringify(e)],maxLen:o,onTransportError:t}=s??{};return z(r,{onTransportError:t,send:async e=>{let a=u(e);await(o!==void 0?n.xadd(i,"MAXLEN","~",String(o),"*",...a):n.xadd(i,"*",...a))}})}function Fr(r,n){let{delimiter:i=",",hasHeader:s=!0,columns:u,parseLine:o,...t}=n??{},e=o??(a=>Ie(a,i));return B(a=>{let c=!1;return(async()=>{try{let p=u,d="";for await(let l of r){if(c)return;d+=l;let m=d.split(/\r?\n/);d=m.pop()??"";for(let g of m){if(c)return;if(!g.trim())continue;let y=e(g);if(!p&&s){p=y;continue}p||(p=y.map((h,b)=>`col${b}`));let T={};for(let h=0;h<p.length;h++)T[p[h]]=y[h]??"";a.emit(T)}}if(!c&&d.trim()){let l=e(d);if(p){let m={};for(let g=0;g<p.length;g++)m[p[g]]=l[g]??"";a.emit(m)}}c||a.down([[P]])}catch(p){c||a.down([[x,p]])}})(),()=>{c=!0}},W(t))}function Hr(r,n){let{delimiter:i=",",hasHeader:s=!0,columns:u,parseLine:o,...t}=n??{},e=o??(a=>Ie(a,i));return be([r],(a,c,f)=>{let p=a[0];if(p==null||p.length===0)return;let d=f.store;typeof d.buffer!="string"&&(d.buffer=""),d.headers===void 0&&u&&(d.headers=u.slice());for(let l of p){d.buffer=d.buffer+l;let m=d.buffer.split(/\r?\n/);d.buffer=m.pop()??"";for(let g of m){if(!g.trim())continue;let y=e(g);if(!d.headers&&s){d.headers=y;continue}d.headers||(d.headers=y.map((h,b)=>`col${b}`));let T={};for(let h=0;h<d.headers.length;h++)T[d.headers[h]]=y[h]??"";c.emit(T)}}},{describeKind:"derived",...t})}function zr(r,n){return be([r],(i,s,u)=>{let o=i[0];if(o==null||o.length===0)return;let t=u.store;typeof t.buffer!="string"&&(t.buffer="");for(let e of o){t.buffer=t.buffer+e;let a=t.buffer.split(/\r?\n/);t.buffer=a.pop()??"";for(let c of a)if(c.trim())try{s.emit(JSON.parse(c))}catch(f){s.down([[x,f]]);return}}},{describeKind:"derived",...n??{}})}function Ie(r,n){let i=[],s="",u=!1;for(let o=0;o<r.length;o++){let t=r[o];u?t==='"'?r[o+1]==='"'?(s+='"',o++):u=!1:s+=t:t==='"'?u=!0:t===n?(i.push(s),s=""):s+=t}return i.push(s),i}function qr(r,n){return B(i=>{let s=!1;return(async()=>{try{let o="";for await(let t of r){if(s)return;o+=t;let e=o.split(/\r?\n/);o=e.pop()??"";for(let a of e){if(s)return;let c=a.trim();c&&i.emit(JSON.parse(c))}}!s&&o.trim()&&i.emit(JSON.parse(o.trim())),s||i.down([[P]])}catch(o){s||i.down([[x,o]])}})(),()=>{s=!0}},W(n))}function Ur(r,n,i){let{intervalNs:s=5*1e9,format:u="JSONEachRow",signal:o,maxConsecutiveErrors:t=1}=i??{},e=Math.ceil(s/1e6),a=0;return fe(pe(0,{period:e,signal:o}),()=>B(c=>{let f=!0;return(async()=>{try{let d=await r.query({query:n,format:u});if(!f)return;let l=await d.json();if(!f)return;for(let m of l)c.emit(m);a=0,c.down([[P]])}catch(d){if(!f)return;a+=1,a>=t&&c.down([[x,d]])}})(),()=>{f=!1}}))}function Dr(r,n){let{autoAck:i=!0,deserialize:s=e=>{try{return JSON.parse(e.toString())}catch{return e.toString()}},onAckError:u,...o}=n??{},t=e=>{if(u)try{u(e instanceof Error?e:new Error(String(e)))}catch{}};return B(e=>{let a=!0;return(async()=>{for(;a;)try{let f=await r.receive();if(!a)return;let p={topic:f.getTopicName(),messageId:f.getMessageId().toString(),key:f.getPartitionKey(),value:s(f.getData()),properties:f.getProperties(),publishTime:f.getPublishTimestamp(),eventTime:f.getEventTimestamp(),timestampNs:D()};if(i)e.emit(p),r.acknowledge(f).catch(t);else{let d=!1,l={value:p,ack(){d||(d=!0,r.acknowledge(f).catch(t))},nack(m){if(d)return;d=!0;let g=r;try{let y=g.negativeAcknowledge?.(f);y&&typeof y.then=="function"&&y.catch(t)}catch(y){t(y)}}};e.emit(l)}}catch(f){a&&e.down([[x,f]]);return}})(),()=>{a=!1}},W(o))}function Kr(r,n,i){let{serialize:s=e=>Buffer.from(JSON.stringify(e)),keyExtractor:u,propertiesExtractor:o,onTransportError:t}=i??{};return z(r,{onTransportError:t,send:async e=>{await n.send({data:s(e),partitionKey:u?.(e),properties:o?.(e)})}})}function $r(r,n,i){let s=new TextDecoder,{queue:u,deserialize:o=e=>{let a=s.decode(e);try{return JSON.parse(a)}catch{return a}},...t}=i??{};return B(e=>{let a=!0,c=r.subscribe(n,u?{queue:u}:void 0);return(async()=>{try{for await(let p of c){if(!a)return;let d={};if(p.headers)for(let l of p.headers.keys())d[l]=p.headers.get(l);e.emit({subject:p.subject,data:o(p.data),headers:d,reply:p.reply,sid:p.sid,timestampNs:D()})}a&&e.down([[P]])}catch(p){a&&e.down([[x,p]])}})(),()=>{a=!1}},W(t))}function jr(r,n,i,s){let u=new TextEncoder,{serialize:o=e=>u.encode(JSON.stringify(e)),onTransportError:t}=s??{};return z(r,{onTransportError:t,send:e=>{n.publish(i,o(e))}})}function Wr(r,n,i){let{autoAck:s=!0,deserialize:u=a=>{try{return JSON.parse(a.toString())}catch{return a.toString()}},onAckError:o,...t}=i??{},e=a=>{if(o)try{o(a instanceof Error?a:new Error(String(a)))}catch{}};return B(a=>{let c=!0,f;return(async()=>{try{f=(await r.consume(n,l=>{if(!c)return;if(l===null){c&&a.down([[x,new Error("Consumer cancelled by broker")]]);return}let m={queue:n,routingKey:l.fields.routingKey,exchange:l.fields.exchange,content:u(l.content),properties:l.properties,deliveryTag:l.fields.deliveryTag,redelivered:l.fields.redelivered,timestampNs:D()};if(s){a.emit(m);try{r.ack(l)}catch(g){e(g)}}else{let g=!1,y=r,T={value:m,ack(){if(!g){g=!0;try{r.ack(l)}catch(h){e(h)}}},nack(h){if(g)return;g=!0;let b=h?.requeue;if(!y.nack){e(new Error("RabbitMQ channel does not expose `nack`; cannot negative-ack"));return}try{y.nack(l,!1,b)}catch(w){e(w)}}};a.emit(T)}},{noAck:!1})).consumerTag}catch(d){c&&a.down([[x,d]])}})(),()=>{c=!1,f!==void 0&&r.cancel(f)}},W(t))}function Qr(r,n,i,s){let{serialize:u=e=>Buffer.from(JSON.stringify(e)),routingKeyExtractor:o=()=>"",onTransportError:t}=s??{};return z(r,{onTransportError:t,send:e=>{let a=o(e),c=u(e);n.publish(i,a,c)}})}function Ve(r,n,i){let{serialize:s=p=>`${JSON.stringify(p)}
12
+ `,flushIntervalMs:u=0,batchSize:o=Number.POSITIVE_INFINITY,onTransportError:t,mode:e}=i??{},c=u>0||o<Number.POSITIVE_INFINITY?z(r,{onTransportError:t,batchSize:o,flushIntervalMs:u,serialize:s,sendBatch:p=>{n.write(p.join(""))}}):z(r,{onTransportError:t,serialize:s,send:p=>{n.write(p)}}),f=c.dispose;return c.dispose=()=>{f();try{n.end()}catch{}},c}function ve(r,n){return r.includes(n)||r.includes('"')||r.includes(`
13
+ `)?`"${r.replace(/"/g,'""')}"`:r}function Jr(r,n,i){let{columns:s,delimiter:u=",",writeHeader:o=!0,cellExtractor:t=(l,m)=>String(l[m]??""),flushIntervalMs:e=0,batchSize:a=Number.POSITIVE_INFINITY,onTransportError:c,...f}=i,p=!1;return Ve(r,n,{serialize:l=>{if(!p&&o){p=!0;let m=s.map(y=>ve(y,u)).join(u),g=s.map(y=>ve(t(l,y),u)).join(u);return`${m}
14
+ ${g}
15
+ `}return`${s.map(m=>ve(t(l,m),u)).join(u)}
16
+ `},flushIntervalMs:e,batchSize:a,onTransportError:c,...f})}function Vr(r,n,i,s){let{batchSize:u=1e3,flushIntervalMs:o=5e3,format:t="JSONEachRow",transform:e=c=>c,onTransportError:a}=s??{};return z(r,{onTransportError:a,batchSize:u,flushIntervalMs:o,serialize:e,sendBatch:async c=>{await n.insert({table:i,values:c,format:t})}})}function _r(r,n,i,s){let{format:u="ndjson",keyGenerator:o=(d,l)=>{let m=Math.floor(l/1e6);return`data/${new Date(m).toISOString().replace(/[:.]/g,"-")}-${d}.${u==="ndjson"?"ndjson":"json"}`},batchSize:t=1e3,flushIntervalMs:e=1e4,transform:a=d=>d,onTransportError:c}=s??{},f=u==="ndjson"?"application/x-ndjson":"application/json",p=0;return z(r,{onTransportError:c,batchSize:t,flushIntervalMs:e,serialize:a,sendBatch:async d=>{p+=1;let l=u==="ndjson"?`${d.map(g=>JSON.stringify(g)).join(`
17
+ `)}
18
+ `:JSON.stringify(d),m=o(p,D());await n.putObject({Bucket:i,Key:m,Body:l,ContentType:f})}})}function Gr(r,n,i,s){let{toSQL:u=(t,e)=>({sql:`INSERT INTO "${e.replace(/"/g,'""')}" (data) VALUES ($1)`,params:[JSON.stringify(t)]}),onTransportError:o}=s??{};return z(r,{onTransportError:o,serialize:t=>u(t,i),send:async t=>{let e=t;await n.query(e.sql,e.params)}})}function Yr(r,n,i){let{toDocument:s=o=>o,onTransportError:u}=i??{};return z(r,{onTransportError:u,serialize:s,send:async o=>{await n.insertOne(o)}})}function Xr(r,n,i){let{labels:s={},toLine:u=e=>JSON.stringify(e),toLabels:o,onTransportError:t}=i??{};return z(r,{onTransportError:t,serialize:e=>({line:u(e),labels:o?{...s,...o(e)}:s}),send:async e=>{let{line:a,labels:c}=e,f=`${D()}`;await n.push({streams:[{stream:c,values:[[f,a]]}]})}})}function Zr(r,n,i){let{toResourceSpans:s=o=>[o],onTransportError:u}=i??{};return z(r,{onTransportError:u,serialize:s,send:async o=>{await n.push({resourceSpans:o})}})}function et(r,n,i,s){let{prefix:u="checkpoints/",debounceMs:o=500,compactEvery:t=10,onError:e}=s??{},a={name:`s3:${i}`,debounceMs:o,compactEvery:t,save(c){let f=Math.floor(D()/1e6),p=`${u}${r.name}/checkpoint-${f}.json`,d;try{d=JSON.stringify(c)}catch(l){e?.(l);return}n.putObject({Bucket:i,Key:p,Body:d,ContentType:"application/json"}).catch(l=>e?.(l))}};return r.attachSnapshotStorage([a],{onError:c=>e?.(c)})}function rt(r,n,i){let{prefix:s="graphrefly:checkpoint:",debounceMs:u=500,compactEvery:o=10,onError:t}=i??{},e=`${s}${r.name}`,a={name:`redis:${e}`,debounceMs:u,compactEvery:o,save(c){let f;try{f=JSON.stringify(c)}catch(p){t?.(p);return}n.set(e,f).catch(p=>t?.(p))},async load(){let c=await n.get(e);if(c!=null)try{return JSON.parse(c)}catch{return}}};return r.attachSnapshotStorage([a],{onError:c=>t?.(c)})}function tt(r,n,i){let{mapRow:s=t=>t,params:u,...o}=i??{};return B(t=>{try{let a=r.query(n,u).map(s);t.emit(a),t.down([[P]])}catch(e){t.down([[x,e instanceof Error?e:new Error(String(e))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function nt(r,n,i){let{mapRow:s=t=>t,params:u,...o}=i??{};return B(t=>{try{let e=r.iterate(n,u);J(()=>{for(let a of e)t.emit(s(a));t.down([[P]])})}catch(e){t.down([[x,e instanceof Error?e:new Error(String(e))]])}},{describeKind:"producer",completeWhenDepsComplete:!1,...o})}function ot(r,n,i,s){if(i.includes("\0")||i.length===0)throw new Error(`toSqlite: invalid table name: ${JSON.stringify(i)}`);let{toSQL:u=(O,q)=>({sql:`INSERT INTO "${q.replace(/"/g,'""')}" (data) VALUES (?)`,params:[JSON.stringify(O)]}),onTransportError:o,batchInsert:t=!1,maxBatchSize:e=1e3,flushIntervalMs:a=0}=s??{},c=O=>u(O,i);if(!t)return z(r,{onTransportError:o,serialize:c,send:O=>{let q=O;n.query(q.sql,q.params)}});let f=U(null),p=U(void 0,{equals:()=>!1}),d=U(null),l=U(0),m=U(0),g=O=>{try{o?.(O)}catch{}try{f.down([[E,O]])}catch{}},y=[],T=!1,h,b=!1,w=()=>m.down([[E,y.length]]),v=O=>{b||p.down([[E,O]])},S=O=>{b||d.down([[E,O]])},L=O=>{b||l.down([[E,O]])},F=O=>{b||g(O)},K=()=>{if(y.length===0||T)return;T=!0,L(1);try{n.query("BEGIN",[])}catch(I){T=!1,L(0),F({stage:"send",error:I instanceof Error?I:new Error(String(I)),value:void 0});return}let O=y;y=[],w();let q,V=0;for(let I of O)try{n.query(I.query.sql,I.query.params),V+=1}catch($){q=$ instanceof Error?$:new Error(String($));break}if(q){try{n.query("ROLLBACK",[])}catch{}F({stage:"send",error:q,value:void 0});for(let I of O)S({value:I.value,error:q,attempts:1})}else try{n.query("COMMIT",[]);for(let I of O)v(I.value)}catch(I){let $=I instanceof Error?I:new Error(String(I));F({stage:"send",error:$,value:void 0});for(let _=0;_<V;_++)S({value:O[_].value,error:$,attempts:1})}T=!1,L(0)},Y=()=>{a>0&&h===void 0&&!b&&(h=setTimeout(()=>{h=void 0,K()},a))},ie=r.subscribe(O=>{for(let q of O){let V=q[0];if(V===E){let I=q[1],$;try{$=c(I)}catch(_){let te=_ instanceof Error?_:new Error(String(_));g({stage:"serialize",error:te,value:I}),d.down([[E,{value:I,error:te,attempts:0}]]);continue}y.push({value:I,query:$}),w(),y.length>=e?K():Y()}else ee.messageTier(V)>=3&&K()}});return{dispose:()=>{if(!b){h!==void 0&&(clearTimeout(h),h=void 0),K(),b=!0,ie();for(let O of[f,p,d,l,m])try{O.down([[de]])}catch{}}},sent:p,failed:d,inFlight:l,errors:f,buffered:m,flush:async()=>{b||K()}}}function st(r,n){let{args:i,mapRow:s=o=>o,...u}=n??{};return B(o=>{let t=!0;return r.findMany(i).then(e=>{t&&(o.emit(e.map(s)),o.down([[P]]))}).catch(e=>{if(t)try{o.down([[x,e instanceof Error?e:new Error(String(e))]])}catch{}}),()=>{t=!1}},{...u,describeKind:"producer",completeWhenDepsComplete:!1})}function it(r,n){let{mapRow:i=u=>u,...s}=n??{};return B(u=>{let o=!0;return r.execute().then(t=>{o&&(u.emit(t.map(i)),u.down([[P]]))}).catch(t=>{if(o)try{u.down([[x,t instanceof Error?t:new Error(String(t))]])}catch{}}),()=>{o=!1}},{...s,describeKind:"producer",completeWhenDepsComplete:!1})}function at(r,n){let{mapRow:i=u=>u,...s}=n??{};return B(u=>{let o=!0;return r.execute().then(t=>{o&&(u.emit(t.map(i)),u.down([[P]]))}).catch(t=>{if(o)try{u.down([[x,t instanceof Error?t:new Error(String(t))]])}catch{}}),()=>{o=!1}},{...s,describeKind:"producer",completeWhenDepsComplete:!1})}async function ct(r,n){let i;try{i=await r.text()}catch{i=""}let s=n??"HTTP",u=new Error(`${s} API ${r.status}: ${r.statusText}${i?` \u2014 ${i}`:""}`);return u.status=r.status,u.headers=r.headers,u}export{oe as a,Me as b,z as c,Ke as d,Tr as e,$e as f,gr as g,yr as h,kr as i,br as j,je as k,hr as l,vr as m,wr as n,Sr as o,Er as p,xr as q,Or as r,Nr as s,Rr as t,Pr as u,Cr as v,Mr as w,Qe as x,Ar as y,Lr as z,Ir as A,Br as B,Fr as C,Hr as D,zr as E,qr as F,Ur as G,Dr as H,Kr as I,$r as J,jr as K,Wr as L,Qr as M,Ve as N,Jr as O,Vr as P,_r as Q,Gr as R,Yr as S,Xr as T,Zr as U,et as V,rt as W,tt as X,nt as Y,ot as Z,st as _,it as $,at as aa,ct as ba};
@@ -1,4 +1,4 @@
1
- import{a as $e}from"./chunk-SFIM774L.js";import{c as _e}from"./chunk-6HQ6HVTF.js";import{u as X}from"./chunk-A3GDELMY.js";import{a as Me}from"./chunk-GCUYSIM4.js";import{e as Ce}from"./chunk-3Y4BXFFR.js";import{f as we,h as le}from"./chunk-T2TB37TW.js";import{b as ue,d as U}from"./chunk-L3KUKDZC.js";import{b as Oe}from"./chunk-TZQPPQEQ.js";import{f as Se,j as ie}from"./chunk-2JO6LXFT.js";import{b as A,s as q,t as Ae,x as _}from"./chunk-4F564IPP.js";import{m as z}from"./chunk-T7EQPKOP.js";import{D as ke,E as S,F as Q,G as N,H as $,o as V}from"./chunk-LYCLF26R.js";import{b as P,i as F,j as W}from"./chunk-CK2E7BTU.js";import{b as Xe}from"./chunk-QYADASLV.js";var kt={};Xe(kt,{DEFAULT_DECAY_RATE:()=>D,DEFAULT_EXECUTE_PROMPT:()=>de,DEFAULT_QUEUE_CONFIGS:()=>Z,DEFAULT_SEVERITY_WEIGHTS:()=>L,DEFAULT_TRIAGE_PROMPT:()=>ce,DEFAULT_VERIFY_PROMPT:()=>pe,HarnessGraph:()=>te,QUEUE_NAMES:()=>b,actuatorExecutor:()=>nt,affectedTaskFilter:()=>lt,autoSolidify:()=>ot,beforeAfterCompare:()=>ut,codeChangeBridge:()=>ct,createIntakeBridge:()=>st,defaultErrorClassifier:()=>ee,defaultLlmExecutor:()=>je,defaultLlmVerifier:()=>Ge,evalIntakeBridge:()=>at,evalSource:()=>it,evalVerifier:()=>Pe,harnessEvalPair:()=>Tt,harnessLoop:()=>vt,harnessProfile:()=>ht,harnessTrace:()=>bt,notifyEffect:()=>dt,priorityScore:()=>Et,refineExecutor:()=>fe,resolvePromptFn:()=>B,strategyKey:()=>j,strategyModel:()=>me});function Ze(e,t){return{outcome:"success",detail:`actuator applied ${t.intervention} for ${rt(t.summary)}`,artifact:e}}function et(e,t){let n=e instanceof Error?e.message:String(e);return{outcome:"failure",detail:`actuator threw on ${t.intervention}: ${n}`}}function tt(e){return`actuator skipped ${e.intervention} (shouldApply returned false)`}function rt(e,t=80){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}function nt(e){let t=e.name??"actuator-executor",n=e.toOutput??Ze,r=e.onError??et,o=e.skipDetail??tt;return d=>{let s=A(d,i=>i!=null,{name:`${t}/gate-in`}),a=_(s,i=>e.shouldApply&&!e.shouldApply(i)?Q(c=>(c.down([[P,{outcome:"failure",detail:o(i)}],[F]]),()=>{}),{name:`${t}/skip`}):Q(c=>{let m=new AbortController,f=!1,l=null,g=R=>{f||(f=!0,c.down([[P,R],[F]]),l?.(),l=null)},y;try{let R=e.apply(i,{signal:m.signal});y=z(R,{signal:m.signal})}catch(R){return g(r(R,i)),()=>{m.abort()}}return l=y.subscribe(R=>{for(let E of R){if(f)return;if(E[0]===P){g(n(E[1],i));return}if(E[0]===W){g(r(E[1],i));return}if(E[0]===F){g(r(new Error("actuator inner completed without emitting DATA"),i));return}}}),f&&l&&(l(),l=null),()=>{m.abort(),l?.(),l=null}},{name:`${t}/inner`}),{name:t});return A(a,i=>i!=null,{name:`${t}/gate-out`})}}function ot(e){let t=e.name??"auto-solidify",n=e.extract??(o=>o.execution.artifact??null),r=e.predicate??(()=>!0);return Q(o=>{let d=null,s=!1,a=()=>{s||(s=!0,d?.(),d=null)},i=c=>{s||(o.down([[W,c]]),a())};return d=e.verifyResults.subscribe(c=>{if(!s)for(let m of c){if(s)return;if(m[0]!==P){if(m[0]===F){o.down([[F]]),a();return}continue}let f=m[1];if(f==null||!f.verified)continue;let l;try{l=r(f)}catch(y){i(y);return}if(!l)continue;let g;try{g=n(f)}catch(y){i(y);return}if(g!=null){try{e.write(g,f)}catch(y){i(y);return}o.down([[P,g]])}}}),s&&d&&(d(),d=null),()=>{a()}},{name:t})}function st(e,t,n,r){return $([e],([o])=>{if(o==null)return;let d=n(o);for(let s of d)t.publish(s)},{name:r?.name??"intake-bridge"})}function at(e,t,n){let r=n?.defaultSeverity??"medium";return $([e],([o])=>{if(o==null)return;let d=Array.isArray(o)?o:[o];for(let s of d)for(let a of s.tasks)if(!(a.valid&&a.judge_scores?.every(i=>i.pass))){if(!a.valid&&(!a.judge_scores||a.judge_scores.length===0)){t.publish({source:"eval",summary:`Task ${a.task_id} invalid (model: ${s.model})`,evidence:`Run ${s.run_id}: task produced invalid output`,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:r});continue}if(a.judge_scores)for(let i of a.judge_scores)i.pass||t.publish({source:"eval",summary:`${a.task_id}: ${i.claim} (model: ${s.model})`,evidence:i.reasoning,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:r})}},{name:n?.name??"eval-intake-bridge"})}function it(e,t){return _(e,()=>z(t()))}function ut(e,t){return N([e,t],([n,r])=>{let o=n,d=r,s=new Map(o.tasks.map(l=>[l.task_id,l])),a=new Map(d.tasks.map(l=>[l.task_id,l])),i=new Set([...s.keys(),...a.keys()]),c=[],m=[],f=[];for(let l of i){let g=s.get(l),y=a.get(l),R=g?.valid??!1,E=y?.valid??!1,I=g?.judge_scores?g.judge_scores.filter(w=>w.pass).length:void 0,k=y?.judge_scores?y.judge_scores.filter(w=>w.pass).length:void 0,O=I!==void 0&&k!==void 0?k-I:void 0;c.push({taskId:l,before:R,after:E,scoreDiff:O}),R&&!E&&m.push(l),!R&&E&&f.push(l)}return{newFailures:m,resolved:f,taskDeltas:c,overallImproved:f.length>m.length}},{name:"eval-delta"})}function lt(e,t){let n=t==null?null:Array.isArray(t)?S(t):t,r=[e];return n&&r.push(n),N(r,o=>{let d=o[0],s=n?new Set(o[1]):null,a=new Set;for(let i of d)for(let c of i.affectsEvalTasks??[])(s==null||s.has(c))&&a.add(c);return[...a].sort()},{name:"affected-task-filter"})}function ct(e,t,n,r){let o=r?.defaultSeverity??"high";function d(a){let i=[];for(let c of a.lintErrors??[])i.push({source:"code-change",summary:`Lint: ${c.rule} in ${c.file}:${c.line}`,evidence:c.message,affectsAreas:[c.file],severity:o});for(let c of a.testFailures??[])i.push({source:"test",summary:`Test failure: ${c.testId}`,evidence:c.message,affectsAreas:[c.file],affectsEvalTasks:[c.testId],severity:o});return i}let s=n??d;return $([e],([a])=>{if(a!=null)for(let i of s(a))t.publish(i)},{name:r?.name??"code-change-bridge"})}function dt(e,t,n){return $([e.latest],([r])=>{r!=null&&t(r)},{name:n?.name??"notify-effect"})}var b=["auto-fix","needs-decision","investigation","backlog"],Z={"auto-fix":{gated:!1},"needs-decision":{gated:!0},investigation:{gated:!0},backlog:{gated:!1}},L={critical:100,high:70,medium:40,low:10},D=Math.LN2/(168*3600);function j(e,t){return`${e}\u2192${t}`}var pt=/\b(parse|json|config|validation|syntax)\b/i,ee=e=>pt.test(e.detail)?"self-correctable":"structural",ce=`You are a triage classifier for a reactive collaboration harness.
1
+ import{a as $e}from"./chunk-PYEIPRSZ.js";import{d as _e}from"./chunk-KL7CILPL.js";import{u as X}from"./chunk-YBA5N4XY.js";import{a as Me}from"./chunk-GWOKTENT.js";import{c as Ce}from"./chunk-5CZ3KIRJ.js";import{g as we,i as ue}from"./chunk-AQC53OWG.js";import{b as ie,d as U}from"./chunk-O32GJOUJ.js";import{b as Oe}from"./chunk-TZQPPQEQ.js";import{f as ke,j as Se}from"./chunk-5KPIYVCC.js";import{b as A,s as q,t as Ae,x as _}from"./chunk-JJTF75VS.js";import{m as z}from"./chunk-MQZWA3DF.js";import{D as Ne,E as S,F as Q,G as N,H as $,o as V}from"./chunk-LYCLF26R.js";import{b as P,i as F,j as W}from"./chunk-CK2E7BTU.js";import{b as Xe}from"./chunk-QYADASLV.js";var kt={};Xe(kt,{DEFAULT_DECAY_RATE:()=>D,DEFAULT_EXECUTE_PROMPT:()=>ce,DEFAULT_QUEUE_CONFIGS:()=>Z,DEFAULT_SEVERITY_WEIGHTS:()=>L,DEFAULT_TRIAGE_PROMPT:()=>le,DEFAULT_VERIFY_PROMPT:()=>de,HarnessGraph:()=>te,QUEUE_NAMES:()=>b,actuatorExecutor:()=>nt,affectedTaskFilter:()=>lt,autoSolidify:()=>ot,beforeAfterCompare:()=>ut,codeChangeBridge:()=>ct,createIntakeBridge:()=>st,defaultErrorClassifier:()=>ee,defaultLlmExecutor:()=>je,defaultLlmVerifier:()=>Ge,evalIntakeBridge:()=>at,evalSource:()=>it,evalVerifier:()=>Pe,harnessEvalPair:()=>Tt,harnessLoop:()=>vt,harnessProfile:()=>ht,harnessTrace:()=>bt,notifyEffect:()=>dt,priorityScore:()=>Et,refineExecutor:()=>pe,resolvePromptFn:()=>B,strategyKey:()=>j,strategyModel:()=>fe});function Ze(e,t){return{outcome:"success",detail:`actuator applied ${t.intervention} for ${rt(t.summary)}`,artifact:e}}function et(e,t){let n=e instanceof Error?e.message:String(e);return{outcome:"failure",detail:`actuator threw on ${t.intervention}: ${n}`}}function tt(e){return`actuator skipped ${e.intervention} (shouldApply returned false)`}function rt(e,t=80){return e.length<=t?e:`${e.slice(0,t-1)}\u2026`}function nt(e){let t=e.name??"actuator-executor",n=e.toOutput??Ze,r=e.onError??et,o=e.skipDetail??tt;return d=>{let s=A(d,i=>i!=null,{name:`${t}/gate-in`}),a=_(s,i=>e.shouldApply&&!e.shouldApply(i)?Q(c=>(c.down([[P,{outcome:"failure",detail:o(i)}],[F]]),()=>{}),{name:`${t}/skip`}):Q(c=>{let m=new AbortController,f=!1,l=null,g=R=>{f||(f=!0,c.down([[P,R],[F]]),l?.(),l=null)},y;try{let R=e.apply(i,{signal:m.signal});y=z(R,{signal:m.signal})}catch(R){return g(r(R,i)),()=>{m.abort()}}return l=y.subscribe(R=>{for(let E of R){if(f)return;if(E[0]===P){g(n(E[1],i));return}if(E[0]===W){g(r(E[1],i));return}if(E[0]===F){g(r(new Error("actuator inner completed without emitting DATA"),i));return}}}),f&&l&&(l(),l=null),()=>{m.abort(),l?.(),l=null}},{name:`${t}/inner`}),{name:t});return A(a,i=>i!=null,{name:`${t}/gate-out`})}}function ot(e){let t=e.name??"auto-solidify",n=e.extract??(o=>o.execution.artifact??null),r=e.predicate??(()=>!0);return Q(o=>{let d=null,s=!1,a=()=>{s||(s=!0,d?.(),d=null)},i=c=>{s||(o.down([[W,c]]),a())};return d=e.verifyResults.subscribe(c=>{if(!s)for(let m of c){if(s)return;if(m[0]!==P){if(m[0]===F){o.down([[F]]),a();return}continue}let f=m[1];if(f==null||!f.verified)continue;let l;try{l=r(f)}catch(y){i(y);return}if(!l)continue;let g;try{g=n(f)}catch(y){i(y);return}if(g!=null){try{e.write(g,f)}catch(y){i(y);return}o.down([[P,g]])}}}),s&&d&&(d(),d=null),()=>{a()}},{name:t})}function st(e,t,n,r){return $([e],([o])=>{if(o==null)return;let d=n(o);for(let s of d)t.publish(s)},{name:r?.name??"intake-bridge"})}function at(e,t,n){let r=n?.defaultSeverity??"medium";return $([e],([o])=>{if(o==null)return;let d=Array.isArray(o)?o:[o];for(let s of d)for(let a of s.tasks)if(!(a.valid&&a.judge_scores?.every(i=>i.pass))){if(!a.valid&&(!a.judge_scores||a.judge_scores.length===0)){t.publish({source:"eval",summary:`Task ${a.task_id} invalid (model: ${s.model})`,evidence:`Run ${s.run_id}: task produced invalid output`,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:r});continue}if(a.judge_scores)for(let i of a.judge_scores)i.pass||t.publish({source:"eval",summary:`${a.task_id}: ${i.claim} (model: ${s.model})`,evidence:i.reasoning,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:r})}},{name:n?.name??"eval-intake-bridge"})}function it(e,t){return _(e,()=>z(t()))}function ut(e,t){return N([e,t],([n,r])=>{let o=n,d=r,s=new Map(o.tasks.map(l=>[l.task_id,l])),a=new Map(d.tasks.map(l=>[l.task_id,l])),i=new Set([...s.keys(),...a.keys()]),c=[],m=[],f=[];for(let l of i){let g=s.get(l),y=a.get(l),R=g?.valid??!1,E=y?.valid??!1,I=g?.judge_scores?g.judge_scores.filter(w=>w.pass).length:void 0,k=y?.judge_scores?y.judge_scores.filter(w=>w.pass).length:void 0,O=I!==void 0&&k!==void 0?k-I:void 0;c.push({taskId:l,before:R,after:E,scoreDiff:O}),R&&!E&&m.push(l),!R&&E&&f.push(l)}return{newFailures:m,resolved:f,taskDeltas:c,overallImproved:f.length>m.length}},{name:"eval-delta"})}function lt(e,t){let n=t==null?null:Array.isArray(t)?S(t):t,r=[e];return n&&r.push(n),N(r,o=>{let d=o[0],s=n?new Set(o[1]):null,a=new Set;for(let i of d)for(let c of i.affectsEvalTasks??[])(s==null||s.has(c))&&a.add(c);return[...a].sort()},{name:"affected-task-filter"})}function ct(e,t,n,r){let o=r?.defaultSeverity??"high";function d(a){let i=[];for(let c of a.lintErrors??[])i.push({source:"code-change",summary:`Lint: ${c.rule} in ${c.file}:${c.line}`,evidence:c.message,affectsAreas:[c.file],severity:o});for(let c of a.testFailures??[])i.push({source:"test",summary:`Test failure: ${c.testId}`,evidence:c.message,affectsAreas:[c.file],affectsEvalTasks:[c.testId],severity:o});return i}let s=n??d;return $([e],([a])=>{if(a!=null)for(let i of s(a))t.publish(i)},{name:r?.name??"code-change-bridge"})}function dt(e,t,n){return $([e.latest],([r])=>{r!=null&&t(r)},{name:n?.name??"notify-effect"})}var b=["auto-fix","needs-decision","investigation","backlog"],Z={"auto-fix":{gated:!1},"needs-decision":{gated:!0},investigation:{gated:!0},backlog:{gated:!1}},L={critical:100,high:70,medium:40,low:10},D=Math.LN2/(168*3600);function j(e,t){return`${e}\u2192${t}`}var pt=/\b(parse|json|config|validation|syntax)\b/i,ee=e=>pt.test(e.detail)?"self-correctable":"structural",le=`You are a triage classifier for a reactive collaboration harness.
2
2
 
3
3
  Given an intake item, classify it and output JSON:
4
4
  {
@@ -13,7 +13,7 @@ Strategy model (past effectiveness):
13
13
  {{strategy}}
14
14
 
15
15
  Intake item:
16
- {{item}}`,de=`You are an implementation agent.
16
+ {{item}}`,ce=`You are an implementation agent.
17
17
 
18
18
  Given a triaged issue with root cause and intervention type, produce a fix.
19
19
 
@@ -24,7 +24,7 @@ Output JSON:
24
24
  {
25
25
  "outcome": "success" | "failure" | "partial",
26
26
  "detail": "<description of what was done or what failed>"
27
- }`,pe=`You are a QA reviewer.
27
+ }`,de=`You are a QA reviewer.
28
28
 
29
29
  Given an execution result, verify whether the fix is correct.
30
30
 
@@ -39,5 +39,5 @@ Output JSON:
39
39
  "verified": true/false,
40
40
  "findings": ["<finding1>", ...],
41
41
  "errorClass": "self-correctable" | "structural" // only if verified=false
42
- }`;function B(e,t,n){if(typeof e=="function")return e;let r=e??t;return o=>n(r,o)}function ft(e){let{best:t,score:n,status:r}=e,o=Number.isFinite(n)?n.toFixed(3):String(n),d=t??void 0;return r==="converged"?{outcome:"success",detail:`refineLoop converged at score ${o}`,artifact:d}:r==="budget"?{outcome:"partial",detail:`refineLoop hit budget at score ${o}`,artifact:d}:{outcome:"failure",detail:`refineLoop errored (status=${r})`,artifact:d}}function fe(e){let t=e.name??"refine-executor",n=e.toOutput??ft;return r=>{let o=A(r,s=>s!=null,{name:`${t}/gate-in`}),d=_(o,s=>{let a=$e(e.seedFrom(s),e.evaluator,e.strategy,{...e.refine,dataset:e.datasetFor(s),name:`${t}/inner`});return N([a.status,a.best,a.score],([i,c,m])=>{let f=i;return f!=="converged"&&f!=="budget"&&f!=="errored"?null:n({best:c,score:m,status:f})},{name:`${t}/output`})},{name:t});return A(d,s=>s!=null,{name:`${t}/gate-out`})}}function mt(e){if(e.length===0)return Number.NEGATIVE_INFINITY;let t=0;for(let n of e)t+=n.score;return t/e.length}function gt(e){let{passCount:t,total:n,meanScore:r,threshold:o,missingArtifact:d}=e,s=Number.isFinite(r)?r.toFixed(3):String(r),a=!d&&n>0&&r>=o,i=d?["EXECUTE stage did not emit an artifact; cannot verify reactively"]:a?[`${t}/${n} eval tasks passed; mean score ${s} \u2265 ${o}`]:n===0?["No eval tasks were selected for this item \u2014 cannot verify"]:[`${t}/${n} eval tasks passed; mean score ${s} < threshold ${o}`];return a?{verified:!0,findings:i}:{verified:!1,findings:i,errorClass:"structural"}}function yt(e){return e.artifact??null}function Pe(e){let t=e.name??"eval-verifier",n=e.threshold??.5,r=e.toOutput??gt,o=e.extractArtifact??yt;return d=>{let s=A(d,i=>i!=null&&i[0]!=null&&i[1]!=null,{name:`${t}/gate-in`}),a=_(s,i=>{let[c,m]=i,f=o(c,m);if(f==null)return S(r({scores:[],meanScore:Number.NEGATIVE_INFINITY,passCount:0,total:0,threshold:n,missingArtifact:!0}));let l=S([f],{name:`${t}/candidates`}),g=S(e.datasetFor(m),{name:`${t}/dataset`}),y=e.evaluator(l,g);return N([y],([R])=>{let E=R;if(E==null)return null;let I=mt(E),k=E.filter(O=>O.score>=n).length;return r({scores:E,meanScore:I,passCount:k,total:E.length,threshold:n})},{name:`${t}/output`})},{name:t});return A(a,i=>i!=null,{name:`${t}/gate-out`})}}function Tt(e){let t=e.name??"harness-pair",n=fe({name:`${t}-exec`,seedFrom:e.seedFrom,evaluator:e.evaluator,strategy:e.strategy,datasetFor:e.datasetFor,refine:e.refine}),r=Pe({name:`${t}-verify`,evaluator:e.evaluator,datasetFor:e.datasetFor,threshold:e.threshold});return{executor:n,verifier:r}}function me(){let e=Oe({name:"strategy-entries"}),t=N([e.entries],([s])=>{let a=s;return new Map(a)},{name:"strategy-model",equals:(s,a)=>{let i=s,c=a;if(i.size!==c.size)return!1;for(let[m,f]of i){let l=c.get(m);if(!l||f.attempts!==l.attempts||f.successes!==l.successes)return!1}return!0}});function n(s,a,i){let c=j(s,a),m=e.get(c),f=(m?.attempts??0)+1,l=(m?.successes??0)+(i?1:0);e.set(c,{rootCause:s,intervention:a,attempts:f,successes:l,successRate:l/f})}function r(s,a){return e.get(j(s,a))}let o=t.subscribe(()=>{});function d(){o()}return{node:t,record:n,lookup:r,dispose:d}}function Et(e,t,n,r,o){let d={...L,...o?.severityWeights},s=o?.decayRate??D,a=o?.effectivenessThreshold??.7,i=o?.effectivenessBoost??15,c=[e,t,n];return r&&c.push(r),N(c,m=>{let f=m[0],l=m[1],g=m[2],y=r?m[3]:0,R=d[f.severity??"medium"],E=(V()-g)/1e9,I=Me(R,E,s,0),k=j(f.rootCause,f.intervention),O=l.get(k);return O&&O.successRate>=a&&(I+=i),I+=y*20,I},{name:"priority-score"})}var Fe="intake",Rt="triage-output",Ve="retry",Le="verify-results",De="__unrouted";function je(e,t){let n=B(t,de,(r,o)=>r.replace("{{item}}",JSON.stringify(o)));return r=>X(e,[r],n,{name:"execute",format:"json"})}function Ge(e,t){let n=B(t,pe,(r,o)=>{let[d,s]=o;return r.replace("{{execution}}",JSON.stringify(d)).replace("{{item}}",JSON.stringify(s))});return r=>X(e,[r],o=>o==null?"":n(o),{name:"verify",format:"json"})}var te=class extends ie{queues;jobs;gates;queueTopics;strategy;totalRetries;totalReingestions;priorityScores;constructor(t,n,r,o,d,s,a,i,c){super(t),this.queues=n,this.queueTopics=r,this.jobs=o,this.gates=d,this.strategy=s,this.totalRetries=a,this.totalReingestions=i,this.priorityScores=c}get intake(){return this.queues.topic(Fe)}get verifyResults(){return this.queues.topic(Le)}get retry(){return this.queues.topic(Ve)}get unrouted(){return this.queues.topic(De)}stageNodes(){let t=this.queues,n=s=>t.has(s)?`queues::${s}::latest`:null,r=s=>s==null?[]:[s],o=b.flatMap(s=>r(n(s))),d=[];for(let[s]of this.gates)d.push(`gates::${s}/gate`);return[{label:"INTAKE",paths:r(n("intake"))},{label:"TRIAGE",paths:["triage"]},{label:"QUEUE",paths:o},{label:"GATE",paths:d},{label:"EXECUTE",paths:["execute"]},{label:"VERIFY",paths:r(n("verify-results"))},{label:"REFLECT",paths:["reflect"]},{label:"STRATEGY",paths:["strategy"]}]}};function vt(e,t){let n=t.adapter,r=t.maxRetries??2,o=t.retainedLimit??1e3,d=t.errorClassifier??ee,s=new Map;for(let u of b)s.set(u,{...Z[u],...t.queues?.[u]});let a=we(`${e}/queues`,{defaultTopicOptions:{retainedLimit:o}}),i=a.topic(Fe),c=a.topic(Rt),m=a.topic(Ve),f=a.topic(Le),l=new Map;for(let u of b)l.set(u,a.topic(u));let g=a.topic(De),y=me(),R=q(i.latest,y.node),E=B(t.triagePrompt,ce,(u,p)=>{let[T,x]=p;return u.replace("{{strategy}}",JSON.stringify(Array.from(x.entries()))).replace("{{item}}",JSON.stringify(T))}),I=X(n,[R],u=>{let p=u;return!p||!p[0]?"":E(p)},{name:"triage",format:"json"}),k=q(I,R),w=$([k],([u])=>{if(u==null)return;let[p,T]=u;if(!p?.route)return;let x=T?.[0],C={...p,...x};c.publish(C)}).subscribe(()=>{}),Qe=new Set(b);for(let u of b)le(`bridge/${u}`,c,l.get(u),{map:p=>p.route===u?p:void 0});le("bridge/__unrouted",c,g,{map:u=>Qe.has(u.route)?void 0:u});let G=new Map,re=new Map;for(let u of b)G.set(u,_e(`jobs/${u}`));let ge=[];for(let u of b){let p=l.get(u),T=G.get(u),x=new WeakSet,C=$([p.events],([ae])=>{let H=ae??[];for(let h of H){if(x.has(h))continue;x.add(h);let M=T.enqueue(h);re.set(U(h),{route:u,id:M})}},{name:`jobs/${u}-mirror`});ge.push(C.subscribe(()=>{}))}function ye(u){let p=U(u),T=re.get(p);T&&(G.get(T.route)?.removeById(T.id),re.delete(p))}let Te=new ie("gates"),Y=new Map;for(let u of b){let p=s.get(u);if(!p.gated)continue;let T=l.get(u),x=Ce(Te,`${u}/gate`,T.latest,{maxPending:p.maxPending,startOpen:p.startOpen});Y.set(u,x)}let J=[];for(let u of b)s.get(u).gated&&Y.has(u)?J.push(Y.get(u).node):J.push(l.get(u).latest);J.push(m.latest);let ne=Ae(...J),Ee=(t.executor??je(n,t.executePrompt))(ne),oe=q(Ee,ne),Re=(t.verifier??Ge(n,t.verifyPrompt))(oe),ve=q(Re,oe),xe=t.maxReingestions??1,Ue=Math.min(t.maxTotalRetries??r*10,100),qe=Math.min(t.maxTotalReingestions??xe*10,100),he=S(0),Ie=S(0);function Be(u,p,T){let x={item:T,outcome:p?.outcome??"failure",detail:p?.detail??"unknown",artifact:p?.artifact};return{item:T,execution:x,verified:u.verified,findings:u.findings??[],errorClass:u.errorClass}}function Ye(u,p){y.record(p.rootCause,p.intervention,!0),f.publish(u),ye(p)}function Je(u,p){let T=U(p),x=p.$retries??0,C={...p,$retries:x+1,summary:`[RETRY ${x+1}/${r}] ${T} \u2014 Previous attempt failed: ${u.findings.join("; ")}`,relatedTo:[T]};m.publish(C)}function be(u,p){y.record(p.rootCause,p.intervention,!1),f.publish(u),ye(p);let T=U(p),x=p.$reingestions??0;x<xe&&ue(Ie,qe)&&i.publish({source:p.source,summary:`Verification failed for: ${T}`,evidence:u.findings.join(`
43
- `),affectsAreas:p.affectsAreas,affectsEvalTasks:p.affectsEvalTasks,severity:p.severity??"high",relatedTo:[T],$reingestions:x+1})}let se=ke([ve],(u,p)=>{let T=u[0];if(T==null||T.length===0)return;let x=T[T.length-1];if(x==null)return;let[C,ae]=x,[H,h]=ae??[null,null];if(!C||!h)return;if(H==null){be({item:h,execution:{item:h,outcome:"failure",detail:"executor returned null"},verified:!1,findings:["executor returned null"],errorClass:"structural"},h);return}let M=Be(C,H,h);if(M.verified){Ye(M,h);return}let We=M.errorClass??d({item:h,outcome:H.outcome,detail:M.findings.join("; ")}),ze=h.$retries??0;We==="self-correctable"&&ze<r&&ue(he,Ue)?Je(M,h):be(M,h)}),Ke=se.subscribe(()=>{}),Ne=N([se],()=>null,{name:"reflect",equals:()=>!1}),K;t.priority&&(K=xt(l,y,t));let v=new te(e,a,l,G,Y,y,he,Ie,K);v.addDisposer(w),v.addDisposer(Ke),v.addDisposer(y.dispose);for(let u of ge)v.addDisposer(u);if(v.add(I,{name:"triage"}),v.add(ne,{name:"execute-input"}),v.add(Ee,{name:"execute"}),v.add(oe,{name:"execute-context"}),v.add(Re,{name:"verify"}),v.add(ve,{name:"verify-context"}),v.add(se,{name:"verify-dispatch"}),v.add(Ne,{name:"reflect"}),v.add(y.node,{name:"strategy"}),v.addDisposer(Ne.subscribe(()=>{})),K)for(let[u,p]of K)v.add(p,{name:`priority/${u}`}),v.addDisposer(p.subscribe(()=>{}));v.mount("queues",a),v.mount("gates",Te);for(let[u,p]of G)v.mount(`jobs/${u}`,p);return v}function xt(e,t,n){if(!n.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 r=n.lastInteractionNs,o=n.priority??{},d={...L,...o.severityWeights},s=o.decayRate??D,a=o.effectivenessThreshold??.7,i=o.effectivenessBoost??15,c=new Map;for(let[m,f]of e){let l=N([f.latest,t.node,r],g=>{let y=g[0];if(y==null)return 0;let R=d[y.severity??"medium"]??40,E=(V()-g[2])/1e9,I=R*Math.exp(-s*Math.max(0,E)),k=`${y.rootCause}\u2192${y.intervention}`,w=g[1]?.get(k);return w&&w.successRate>=a&&(I+=i),I},{name:`priority/${m}`});c.set(m,l)}return c}function ht(e,t){let n=Se(e,t),r={};for(let o of b){let d=e.queues.has(o)?e.queues.topic(o):null;r[o]=d?.retained().length??0}return{...n,queueDepths:r,strategyEntries:e.strategy.node.cache?.size??0,totalRetries:e.totalRetries.cache??0,totalReingestions:e.totalReingestions.cache??0}}function It(e){let t={};for(let{label:n,paths:r}of e.stageNodes())for(let o of r)t[o]=n;return t}function bt(e,t){let n=t?.logger===null?null:t?.logger??console.log,r=t?.detail??"summary",o=V(),d=[],s=[],a=It(e);function i(){return(V()-o)/1e9}function c(m,f,l){let g={elapsed:i(),stage:m,type:f};r!=="summary"&&(g.summary=Nt(l)),r==="full"&&(g.data=l),s.push(g)}for(let[m,f]of Object.entries(a))try{let l=e.observe(m,{format:"stage-log",stageLabels:a,logger:n?g=>n(g):()=>{},includeTypes:["data","error","complete"]});l.onEvent(g=>{g.type==="data"?c(f,"data",g.data):g.type==="error"?c(f,"error",g.data):g.type==="complete"&&c(f,"complete",void 0)}),d.push(l)}catch(l){let g=l instanceof Error?l.message:String(l);c(f,"error",`observe-unavailable: ${m} \u2014 ${g}`),n&&n(`[${i().toFixed(3)}s] ${f.padEnd(9)} \u2717 observe-unavailable: ${g}`)}return{get events(){return s},dispose(){for(let m of d)m.dispose();d.length=0}}}function Nt(e){if(e==null)return"null";if(typeof e=="string")return He(e,80);if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);try{let t=JSON.stringify(e);return He(t,120)}catch{return String(e)}}function He(e,t){return e.length>t?`${e.slice(0,t-1)}\u2026`:e}export{nt as a,ot as b,st as c,at as d,it as e,ut as f,lt as g,ct as h,dt as i,b as j,Z as k,L as l,D as m,j as n,ee as o,ce as p,de as q,pe as r,B as s,fe as t,Pe as u,Tt as v,me as w,Et as x,je as y,Ge as z,te as A,vt as B,ht as C,bt as D,kt as E};
42
+ }`;function B(e,t,n){if(typeof e=="function")return e;let r=e??t;return o=>n(r,o)}function ft(e){let{best:t,score:n,status:r}=e,o=Number.isFinite(n)?n.toFixed(3):String(n),d=t??void 0;return r==="converged"?{outcome:"success",detail:`refineLoop converged at score ${o}`,artifact:d}:r==="budget"?{outcome:"partial",detail:`refineLoop hit budget at score ${o}`,artifact:d}:{outcome:"failure",detail:`refineLoop errored (status=${r})`,artifact:d}}function pe(e){let t=e.name??"refine-executor",n=e.toOutput??ft;return r=>{let o=A(r,s=>s!=null,{name:`${t}/gate-in`}),d=_(o,s=>{let a=$e(e.seedFrom(s),e.evaluator,e.strategy,{...e.refine,dataset:e.datasetFor(s),name:`${t}/inner`});return N([a.status,a.best,a.score],([i,c,m])=>{let f=i;return f!=="converged"&&f!=="budget"&&f!=="errored"?null:n({best:c,score:m,status:f})},{name:`${t}/output`})},{name:t});return A(d,s=>s!=null,{name:`${t}/gate-out`})}}function mt(e){if(e.length===0)return Number.NEGATIVE_INFINITY;let t=0;for(let n of e)t+=n.score;return t/e.length}function gt(e){let{passCount:t,total:n,meanScore:r,threshold:o,missingArtifact:d}=e,s=Number.isFinite(r)?r.toFixed(3):String(r),a=!d&&n>0&&r>=o,i=d?["EXECUTE stage did not emit an artifact; cannot verify reactively"]:a?[`${t}/${n} eval tasks passed; mean score ${s} \u2265 ${o}`]:n===0?["No eval tasks were selected for this item \u2014 cannot verify"]:[`${t}/${n} eval tasks passed; mean score ${s} < threshold ${o}`];return a?{verified:!0,findings:i}:{verified:!1,findings:i,errorClass:"structural"}}function yt(e){return e.artifact??null}function Pe(e){let t=e.name??"eval-verifier",n=e.threshold??.5,r=e.toOutput??gt,o=e.extractArtifact??yt;return d=>{let s=A(d,i=>i!=null&&i[0]!=null&&i[1]!=null,{name:`${t}/gate-in`}),a=_(s,i=>{let[c,m]=i,f=o(c,m);if(f==null)return S(r({scores:[],meanScore:Number.NEGATIVE_INFINITY,passCount:0,total:0,threshold:n,missingArtifact:!0}));let l=S([f],{name:`${t}/candidates`}),g=S(e.datasetFor(m),{name:`${t}/dataset`}),y=e.evaluator(l,g);return N([y],([R])=>{let E=R;if(E==null)return null;let I=mt(E),k=E.filter(O=>O.score>=n).length;return r({scores:E,meanScore:I,passCount:k,total:E.length,threshold:n})},{name:`${t}/output`})},{name:t});return A(a,i=>i!=null,{name:`${t}/gate-out`})}}function Tt(e){let t=e.name??"harness-pair",n=pe({name:`${t}-exec`,seedFrom:e.seedFrom,evaluator:e.evaluator,strategy:e.strategy,datasetFor:e.datasetFor,refine:e.refine}),r=Pe({name:`${t}-verify`,evaluator:e.evaluator,datasetFor:e.datasetFor,threshold:e.threshold});return{executor:n,verifier:r}}function fe(){let e=Oe({name:"strategy-entries"}),t=N([e.entries],([s])=>{let a=s;return new Map(a)},{name:"strategy-model",equals:(s,a)=>{let i=s,c=a;if(i.size!==c.size)return!1;for(let[m,f]of i){let l=c.get(m);if(!l||f.attempts!==l.attempts||f.successes!==l.successes)return!1}return!0}});function n(s,a,i){let c=j(s,a),m=e.get(c),f=(m?.attempts??0)+1,l=(m?.successes??0)+(i?1:0);e.set(c,{rootCause:s,intervention:a,attempts:f,successes:l,successRate:l/f})}function r(s,a){return e.get(j(s,a))}let o=t.subscribe(()=>{});function d(){o()}return{node:t,record:n,lookup:r,dispose:d}}function Et(e,t,n,r,o){let d={...L,...o?.severityWeights},s=o?.decayRate??D,a=o?.effectivenessThreshold??.7,i=o?.effectivenessBoost??15,c=[e,t,n];return r&&c.push(r),N(c,m=>{let f=m[0],l=m[1],g=m[2],y=r?m[3]:0,R=d[f.severity??"medium"],E=(V()-g)/1e9,I=Me(R,E,s,0),k=j(f.rootCause,f.intervention),O=l.get(k);return O&&O.successRate>=a&&(I+=i),I+=y*20,I},{name:"priority-score"})}var Fe="intake",Rt="triage-output",Ve="retry",Le="verify-results",De="__unrouted";function je(e,t){let n=B(t,ce,(r,o)=>r.replace("{{item}}",JSON.stringify(o)));return r=>X(e,[r],n,{name:"execute",format:"json"})}function Ge(e,t){let n=B(t,de,(r,o)=>{let[d,s]=o;return r.replace("{{execution}}",JSON.stringify(d)).replace("{{item}}",JSON.stringify(s))});return r=>X(e,[r],o=>o==null?"":n(o),{name:"verify",format:"json"})}var te=class extends Se{queues;jobs;gates;queueTopics;strategy;totalRetries;totalReingestions;priorityScores;constructor(t,n,r,o,d,s,a,i,c){super(t),this.queues=n,this.queueTopics=r,this.jobs=o,this.gates=d,this.strategy=s,this.totalRetries=a,this.totalReingestions=i,this.priorityScores=c}get intake(){return this.queues.topic(Fe)}get verifyResults(){return this.queues.topic(Le)}get retry(){return this.queues.topic(Ve)}get unrouted(){return this.queues.topic(De)}stageNodes(){let t=this.queues,n=s=>t.has(s)?`queues::${s}::latest`:null,r=s=>s==null?[]:[s],o=b.flatMap(s=>r(n(s))),d=[];for(let[s]of this.gates)d.push(`gates::${s}/gate`);return[{label:"INTAKE",paths:r(n("intake"))},{label:"TRIAGE",paths:["triage"]},{label:"QUEUE",paths:o},{label:"GATE",paths:d},{label:"EXECUTE",paths:["execute"]},{label:"VERIFY",paths:r(n("verify-results"))},{label:"REFLECT",paths:["reflect"]},{label:"STRATEGY",paths:["strategy"]}]}};function vt(e,t){let n=t.adapter,r=t.maxRetries??2,o=t.retainedLimit??1e3,d=t.errorClassifier??ee,s=new Map;for(let u of b)s.set(u,{...Z[u],...t.queues?.[u]});let a=we(`${e}/queues`,{defaultTopicOptions:{retainedLimit:o}}),i=a.topic(Fe),c=a.topic(Rt),m=a.topic(Ve),f=a.topic(Le),l=new Map;for(let u of b)l.set(u,a.topic(u));let g=a.topic(De),y=fe(),R=q(i.latest,y.node),E=B(t.triagePrompt,le,(u,p)=>{let[T,x]=p;return u.replace("{{strategy}}",JSON.stringify(Array.from(x.entries()))).replace("{{item}}",JSON.stringify(T))}),I=X(n,[R],u=>{let p=u;return!p||!p[0]?"":E(p)},{name:"triage",format:"json"}),k=q(I,R),w=$([k],([u])=>{if(u==null)return;let[p,T]=u;if(!p?.route)return;let x=T?.[0],C={...p,...x};c.publish(C)}).subscribe(()=>{}),Qe=new Set(b);for(let u of b)ue(`bridge/${u}`,c,l.get(u),{map:p=>p.route===u?p:void 0});ue("bridge/__unrouted",c,g,{map:u=>Qe.has(u.route)?void 0:u});let G=new Map,re=new Map;for(let u of b)G.set(u,_e(`jobs/${u}`));let me=[];for(let u of b){let p=l.get(u),T=G.get(u),x=new WeakSet,C=$([p.events],([ae])=>{let H=ae??[];for(let h of H){if(x.has(h))continue;x.add(h);let M=T.enqueue(h);re.set(U(h),{route:u,id:M})}},{name:`jobs/${u}-mirror`});me.push(C.subscribe(()=>{}))}function ge(u){let p=U(u),T=re.get(p);T&&(G.get(T.route)?.removeById(T.id),re.delete(p))}let ye=Ce("gates"),Y=new Map;for(let u of b){let p=s.get(u);if(!p.gated)continue;let T=l.get(u),x=ye.gate(`${u}/gate`,T.latest,{maxPending:p.maxPending,startOpen:p.startOpen});Y.set(u,x)}let J=[];for(let u of b)s.get(u).gated&&Y.has(u)?J.push(Y.get(u).node):J.push(l.get(u).latest);J.push(m.latest);let ne=Ae(...J),Te=(t.executor??je(n,t.executePrompt))(ne),oe=q(Te,ne),Ee=(t.verifier??Ge(n,t.verifyPrompt))(oe),Re=q(Ee,oe),ve=t.maxReingestions??1,Ue=Math.min(t.maxTotalRetries??r*10,100),qe=Math.min(t.maxTotalReingestions??ve*10,100),xe=S(0),he=S(0);function Be(u,p,T){let x={item:T,outcome:p?.outcome??"failure",detail:p?.detail??"unknown",artifact:p?.artifact};return{item:T,execution:x,verified:u.verified,findings:u.findings??[],errorClass:u.errorClass}}function Ye(u,p){y.record(p.rootCause,p.intervention,!0),f.publish(u),ge(p)}function Je(u,p){let T=U(p),x=p.$retries??0,C={...p,$retries:x+1,summary:`[RETRY ${x+1}/${r}] ${T} \u2014 Previous attempt failed: ${u.findings.join("; ")}`,relatedTo:[T]};m.publish(C)}function Ie(u,p){y.record(p.rootCause,p.intervention,!1),f.publish(u),ge(p);let T=U(p),x=p.$reingestions??0;x<ve&&ie(he,qe)&&i.publish({source:p.source,summary:`Verification failed for: ${T}`,evidence:u.findings.join(`
43
+ `),affectsAreas:p.affectsAreas,affectsEvalTasks:p.affectsEvalTasks,severity:p.severity??"high",relatedTo:[T],$reingestions:x+1})}let se=Ne([Re],(u,p)=>{let T=u[0];if(T==null||T.length===0)return;let x=T[T.length-1];if(x==null)return;let[C,ae]=x,[H,h]=ae??[null,null];if(!C||!h)return;if(H==null){Ie({item:h,execution:{item:h,outcome:"failure",detail:"executor returned null"},verified:!1,findings:["executor returned null"],errorClass:"structural"},h);return}let M=Be(C,H,h);if(M.verified){Ye(M,h);return}let We=M.errorClass??d({item:h,outcome:H.outcome,detail:M.findings.join("; ")}),ze=h.$retries??0;We==="self-correctable"&&ze<r&&ie(xe,Ue)?Je(M,h):Ie(M,h)}),Ke=se.subscribe(()=>{}),be=N([se],()=>null,{name:"reflect",equals:()=>!1}),K;t.priority&&(K=xt(l,y,t));let v=new te(e,a,l,G,Y,y,xe,he,K);v.addDisposer(w),v.addDisposer(Ke),v.addDisposer(y.dispose);for(let u of me)v.addDisposer(u);if(v.add(I,{name:"triage"}),v.add(ne,{name:"execute-input"}),v.add(Te,{name:"execute"}),v.add(oe,{name:"execute-context"}),v.add(Ee,{name:"verify"}),v.add(Re,{name:"verify-context"}),v.add(se,{name:"verify-dispatch"}),v.add(be,{name:"reflect"}),v.add(y.node,{name:"strategy"}),v.addDisposer(be.subscribe(()=>{})),K)for(let[u,p]of K)v.add(p,{name:`priority/${u}`}),v.addDisposer(p.subscribe(()=>{}));v.mount("queues",a),v.mount("gates",ye);for(let[u,p]of G)v.mount(`jobs/${u}`,p);return v}function xt(e,t,n){if(!n.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 r=n.lastInteractionNs,o=n.priority??{},d={...L,...o.severityWeights},s=o.decayRate??D,a=o.effectivenessThreshold??.7,i=o.effectivenessBoost??15,c=new Map;for(let[m,f]of e){let l=N([f.latest,t.node,r],g=>{let y=g[0];if(y==null)return 0;let R=d[y.severity??"medium"]??40,E=(V()-g[2])/1e9,I=R*Math.exp(-s*Math.max(0,E)),k=`${y.rootCause}\u2192${y.intervention}`,w=g[1]?.get(k);return w&&w.successRate>=a&&(I+=i),I},{name:`priority/${m}`});c.set(m,l)}return c}function ht(e,t){let n=ke(e,t),r={};for(let o of b){let d=e.queues.has(o)?e.queues.topic(o):null;r[o]=d?.retained().length??0}return{...n,queueDepths:r,strategyEntries:e.strategy.node.cache?.size??0,totalRetries:e.totalRetries.cache??0,totalReingestions:e.totalReingestions.cache??0}}function It(e){let t={};for(let{label:n,paths:r}of e.stageNodes())for(let o of r)t[o]=n;return t}function bt(e,t){let n=t?.logger===null?null:t?.logger??console.log,r=t?.detail??"summary",o=V(),d=[],s=[],a=It(e);function i(){return(V()-o)/1e9}function c(m,f,l){let g={elapsed:i(),stage:m,type:f};r!=="summary"&&(g.summary=Nt(l)),r==="full"&&(g.data=l),s.push(g)}for(let[m,f]of Object.entries(a))try{let l=e.observe(m,{format:"stage-log",stageLabels:a,logger:n?g=>n(g):()=>{},includeTypes:["data","error","complete"]});l.onEvent(g=>{g.type==="data"?c(f,"data",g.data):g.type==="error"?c(f,"error",g.data):g.type==="complete"&&c(f,"complete",void 0)}),d.push(l)}catch(l){let g=l instanceof Error?l.message:String(l);c(f,"error",`observe-unavailable: ${m} \u2014 ${g}`),n&&n(`[${i().toFixed(3)}s] ${f.padEnd(9)} \u2717 observe-unavailable: ${g}`)}return{get events(){return s},dispose(){for(let m of d)m.dispose();d.length=0}}}function Nt(e){if(e==null)return"null";if(typeof e=="string")return He(e,80);if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);try{let t=JSON.stringify(e);return He(t,120)}catch{return String(e)}}function He(e,t){return e.length>t?`${e.slice(0,t-1)}\u2026`:e}export{nt as a,ot as b,st as c,at as d,it as e,ut as f,lt as g,ct as h,dt as i,b as j,Z as k,L as l,D as m,j as n,ee as o,le as p,ce as q,de as r,B as s,pe as t,Pe as u,Tt as v,fe as w,Et as x,je as y,Ge as z,te as A,vt as B,ht as C,bt as D,kt as E};
@@ -1,4 +1,4 @@
1
- import{a as O,f as v,k as P}from"./chunk-2LZ6DL45.js";import{ba as _,k as A}from"./chunk-LOF5HSD3.js";import{d as E}from"./chunk-FKRPIRE6.js";import{m as U,w as T}from"./chunk-T7EQPKOP.js";import{o as y}from"./chunk-LYCLF26R.js";function G(e={}){return e.sdk?V(e):H(e)}function b(e,t,o,r){let s=t?.model??o;if(!s)throw new Error("anthropicAdapter: model must be set via options.model or invokeOpts.model");let{system:n,chat:i}=J(e,t?.systemPrompt),a={model:s,messages:i.map(F),max_tokens:t?.maxTokens??4096};return n&&(a.system=n),t?.temperature!=null&&(a.temperature=t.temperature),t?.tools&&t.tools.length>0&&(a.tools=t.tools.map(Y)),t?.maxReasoningTokens!=null&&(a.thinking={type:"enabled",budget_tokens:t.maxReasoningTokens}),t?.cacheHint,r&&(a.stream=!0),t?.providerExtras&&Object.assign(a,t.providerExtras),a}function J(e,t){let o=[];t&&o.push(t);let r=[];for(let s of e)s.role==="system"?o.push(s.content):r.push(s);return{system:o.length>0?o.join(`
1
+ import{a as O,f as v,k as P}from"./chunk-5CPPC75H.js";import{ba as _,k as A}from"./chunk-MYFR67PY.js";import{c as E}from"./chunk-A5HZZYRK.js";import{m as U,x as T}from"./chunk-MQZWA3DF.js";import{o as y}from"./chunk-LYCLF26R.js";function G(e={}){return e.sdk?V(e):H(e)}function b(e,t,o,r){let s=t?.model??o;if(!s)throw new Error("anthropicAdapter: model must be set via options.model or invokeOpts.model");let{system:n,chat:i}=J(e,t?.systemPrompt),a={model:s,messages:i.map(F),max_tokens:t?.maxTokens??4096};return n&&(a.system=n),t?.temperature!=null&&(a.temperature=t.temperature),t?.tools&&t.tools.length>0&&(a.tools=t.tools.map(Y)),t?.maxReasoningTokens!=null&&(a.thinking={type:"enabled",budget_tokens:t.maxReasoningTokens}),t?.cacheHint,r&&(a.stream=!0),t?.providerExtras&&Object.assign(a,t.providerExtras),a}function J(e,t){let o=[];t&&o.push(t);let r=[];for(let s of e)s.role==="system"?o.push(s.content):r.push(s);return{system:o.length>0?o.join(`
2
2
 
3
3
  `):void 0,chat:r}}function F(e){if(e.role==="tool")return{role:"user",content:[{type:"tool_result",tool_use_id:e.toolCallId,content:e.content}]};if(e.role==="assistant"&&e.toolCalls&&e.toolCalls.length>0){let t=[];e.content&&t.push({type:"text",text:e.content});for(let o of e.toolCalls)t.push({type:"tool_use",id:o.id,name:o.name,input:o.arguments});return{role:"assistant",content:t}}return{role:e.role,content:e.content}}function Y(e){return{name:e.name,description:e.description,input_schema:e.parameters}}function R(e,t){if(!e)return{...t};let o={...e};return t.input_tokens!=null&&(o.input_tokens=t.input_tokens),t.output_tokens!=null&&(o.output_tokens=t.output_tokens),t.cache_read_input_tokens!=null&&(o.cache_read_input_tokens=t.cache_read_input_tokens),t.cache_creation_input_tokens!=null&&(o.cache_creation_input_tokens=t.cache_creation_input_tokens),t.cache_creation&&(o.cache_creation={...e.cache_creation??{},...t.cache_creation}),t.server_tool_use&&(o.server_tool_use={...e.server_tool_use??{},...t.server_tool_use}),o}function x(e){let t={input:{regular:e?.input_tokens??0},output:{regular:e?.output_tokens??0},raw:e};return e?.cache_read_input_tokens&&(t.input.cacheRead=e.cache_read_input_tokens),e?.cache_creation?(e.cache_creation.ephemeral_5m_input_tokens&&(t.input.cacheWrite5m=e.cache_creation.ephemeral_5m_input_tokens),e.cache_creation.ephemeral_1h_input_tokens&&(t.input.cacheWrite1h=e.cache_creation.ephemeral_1h_input_tokens)):e?.cache_creation_input_tokens&&(t.input.cacheWrite5m=e.cache_creation_input_tokens),e?.server_tool_use?.web_search_requests&&(t.auxiliary={webSearchRequests:e.server_tool_use.web_search_requests}),t}function K(e,t){let o=[],r=[];for(let s of e.content)if(s.type==="text"&&typeof s.text=="string")o.push(s.text);else if(s.type==="tool_use"){let n=s;r.push({id:n.id,name:n.name,arguments:n.input??{}})}return{content:o.join(""),toolCalls:r.length>0?r:void 0,usage:x(e.usage),finishReason:e.stop_reason,latencyMs:t,model:e.model,provider:"anthropic"}}function H(e){let t=e.apiKey??globalThis.process?.env?.ANTHROPIC_API_KEY,o=e.baseURL??"https://api.anthropic.com",r=e.anthropicVersion??"2023-06-01",s=e.fetchImpl??fetch,n=()=>{if(!t)throw new Error("anthropicAdapter: apiKey required for invoke/stream (or provide opts.sdk)");return{"x-api-key":t,"anthropic-version":r,"content-type":"application/json",...e.headers??{}}};return{provider:"anthropic",model:e.model,async invoke(i,a){let d=b(i,a,e.model,!1),g=y(),l=await s(`${o}/v1/messages`,{method:"POST",headers:n(),body:JSON.stringify(d),signal:a?.signal});if(!l.ok)throw await _(l,"Anthropic");let c=await l.json(),p=Math.max(0,(y()-g)/1e6);return K(c,p)},async*stream(i,a){let d=b(i,a,e.model,!0),g=await s(`${o}/v1/messages`,{method:"POST",headers:{...n(),accept:"text/event-stream"},body:JSON.stringify(d),signal:a?.signal});if(!g.ok)throw await _(g,"Anthropic");if(!g.body)throw new Error("anthropicAdapter: streaming response has no body");let l,c,p=new Map;for await(let m of A(g.body,{signal:a?.signal})){let h=m.data;if(!h)continue;let k;try{k=JSON.parse(h)}catch{continue}switch(k.type){case"message_start":{l=R(l,k.message.usage);break}case"content_block_start":{let u=k,f=u.content_block;f.type==="tool_use"&&(p.set(u.index,{id:String(f.id??""),name:String(f.name??""),argBuf:""}),yield{type:"tool-call-delta",delta:{id:String(f.id??""),name:String(f.name??"")}});break}case"content_block_delta":{let u=k,f=u.delta;if(f.type==="text_delta"&&typeof f.text=="string")yield{type:"token",delta:f.text};else if(f.type==="input_json_delta"&&typeof f.partial_json=="string"){let S=p.get(u.index);S&&(S.argBuf+=f.partial_json),yield{type:"tool-call-delta",delta:{argumentsDelta:f.partial_json}}}else f.type==="thinking_delta"&&typeof f.thinking=="string"&&(yield{type:"thinking",delta:f.thinking});break}case"message_delta":{let u=k;u.delta.stop_reason&&(c=u.delta.stop_reason),u.delta.usage&&(l=R(l,u.delta.usage));break}case"message_stop":break}}l&&(yield{type:"usage",usage:x(l)}),yield{type:"finish",reason:c??"stop"}}}}function V(e){let t=e.sdk;if(!t)throw new Error("sdkBackedAnthropic: sdk instance required");return{provider:"anthropic",model:e.model,async invoke(o,r){let s=b(o,r,e.model,!1),n=y(),i=await t.messages.create(s,{signal:r?.signal}),a=Math.max(0,(y()-n)/1e6);return K(i,a)},async*stream(o,r){if(!t.messages.stream)throw new Error("sdkBackedAnthropic: SDK instance does not expose .messages.stream");let s=b(o,r,e.model,!0),n,i;for await(let a of t.messages.stream(s,{signal:r?.signal}))switch(a.type){case"message_start":n=R(n,a.message.usage);break;case"content_block_delta":{let d=a.delta;d?.type==="text_delta"&&typeof d.text=="string"?yield{type:"token",delta:d.text}:d?.type==="input_json_delta"&&typeof d.partial_json=="string"?yield{type:"tool-call-delta",delta:{argumentsDelta:d.partial_json}}:d?.type==="thinking_delta"&&typeof d.thinking=="string"&&(yield{type:"thinking",delta:d.thinking});break}case"message_delta":{let d=a;d.delta.stop_reason&&(i=d.delta.stop_reason),d.delta.usage&&(n=R(n,d.delta.usage));break}}n&&(yield{type:"usage",usage:x(n)}),yield{type:"finish",reason:i??"stop"}}}}function D(e={}){return e.sdk?X(e):Q(e)}function w(e,t){let o=[],r=[];t?.systemPrompt&&o.push(t.systemPrompt);for(let i of e){if(i.role==="system"){o.push(i.content);continue}if(i.role==="tool"){r.push({role:"user",parts:[{functionResponse:{name:i.name??i.toolCallId??"tool",response:{result:i.content}}}]});continue}if(i.role==="assistant"&&i.toolCalls&&i.toolCalls.length>0){let a=[];i.content&&a.push({text:i.content});for(let d of i.toolCalls)a.push({functionCall:{name:d.name,args:d.arguments}});r.push({role:"model",parts:a});continue}r.push({role:i.role==="assistant"?"model":"user",parts:[{text:i.content}]})}let s={contents:r};o.length>0&&(s.systemInstruction={role:"system",parts:[{text:o.join(`
4
4