@graphrefly/graphrefly 0.43.0 → 0.45.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 (422) hide show
  1. package/README.md +21 -17
  2. package/dist/compat/index.cjs +20 -10
  3. package/dist/compat/index.cjs.map +1 -0
  4. package/dist/compat/index.d.cts +1 -22
  5. package/dist/compat/index.d.ts +1 -22
  6. package/dist/compat/index.js +3 -1
  7. package/dist/compat/index.js.map +1 -0
  8. package/dist/compat/jotai/index.cjs +21 -1
  9. package/dist/compat/jotai/index.cjs.map +1 -0
  10. package/dist/compat/jotai/index.d.cts +1 -2
  11. package/dist/compat/jotai/index.d.ts +1 -2
  12. package/dist/compat/jotai/index.js +3 -1
  13. package/dist/compat/jotai/index.js.map +1 -0
  14. package/dist/compat/nanostores/index.cjs +21 -1
  15. package/dist/compat/nanostores/index.cjs.map +1 -0
  16. package/dist/compat/nanostores/index.d.cts +1 -2
  17. package/dist/compat/nanostores/index.d.ts +1 -2
  18. package/dist/compat/nanostores/index.js +3 -1
  19. package/dist/compat/nanostores/index.js.map +1 -0
  20. package/dist/compat/nestjs/index.cjs +20 -10
  21. package/dist/compat/nestjs/index.cjs.map +1 -0
  22. package/dist/compat/nestjs/index.d.cts +1 -13
  23. package/dist/compat/nestjs/index.d.ts +1 -13
  24. package/dist/compat/nestjs/index.js +3 -1
  25. package/dist/compat/nestjs/index.js.map +1 -0
  26. package/dist/compat/react/index.cjs +21 -1
  27. package/dist/compat/react/index.cjs.map +1 -0
  28. package/dist/compat/react/index.d.cts +1 -2
  29. package/dist/compat/react/index.d.ts +1 -2
  30. package/dist/compat/react/index.js +3 -1
  31. package/dist/compat/react/index.js.map +1 -0
  32. package/dist/compat/solid/index.cjs +21 -1
  33. package/dist/compat/solid/index.cjs.map +1 -0
  34. package/dist/compat/solid/index.d.cts +1 -2
  35. package/dist/compat/solid/index.d.ts +1 -2
  36. package/dist/compat/solid/index.js +3 -1
  37. package/dist/compat/solid/index.js.map +1 -0
  38. package/dist/compat/svelte/index.cjs +21 -1
  39. package/dist/compat/svelte/index.cjs.map +1 -0
  40. package/dist/compat/svelte/index.d.cts +1 -2
  41. package/dist/compat/svelte/index.d.ts +1 -2
  42. package/dist/compat/svelte/index.js +3 -1
  43. package/dist/compat/svelte/index.js.map +1 -0
  44. package/dist/compat/vue/index.cjs +21 -1
  45. package/dist/compat/vue/index.cjs.map +1 -0
  46. package/dist/compat/vue/index.d.cts +1 -3
  47. package/dist/compat/vue/index.d.ts +1 -3
  48. package/dist/compat/vue/index.js +3 -1
  49. package/dist/compat/vue/index.js.map +1 -0
  50. package/dist/compat/zustand/index.cjs +21 -3
  51. package/dist/compat/zustand/index.cjs.map +1 -0
  52. package/dist/compat/zustand/index.d.cts +1 -6
  53. package/dist/compat/zustand/index.d.ts +1 -6
  54. package/dist/compat/zustand/index.js +3 -1
  55. package/dist/compat/zustand/index.js.map +1 -0
  56. package/dist/core/index.cjs +21 -1
  57. package/dist/core/index.cjs.map +1 -0
  58. package/dist/core/index.d.cts +1 -4
  59. package/dist/core/index.d.ts +1 -4
  60. package/dist/core/index.js +3 -1
  61. package/dist/core/index.js.map +1 -0
  62. package/dist/extra/browser.cjs +21 -1
  63. package/dist/extra/browser.cjs.map +1 -0
  64. package/dist/extra/browser.d.cts +1 -4
  65. package/dist/extra/browser.d.ts +1 -4
  66. package/dist/extra/browser.js +3 -1
  67. package/dist/extra/browser.js.map +1 -0
  68. package/dist/extra/index.cjs +20 -19
  69. package/dist/extra/index.cjs.map +1 -0
  70. package/dist/extra/index.d.cts +1 -17
  71. package/dist/extra/index.d.ts +1 -17
  72. package/dist/extra/index.js +3 -1
  73. package/dist/extra/index.js.map +1 -0
  74. package/dist/extra/node.cjs +21 -2
  75. package/dist/extra/node.cjs.map +1 -0
  76. package/dist/extra/node.d.cts +1 -187
  77. package/dist/extra/node.d.ts +1 -187
  78. package/dist/extra/node.js +3 -2
  79. package/dist/extra/node.js.map +1 -0
  80. package/dist/extra/operators.cjs +21 -1
  81. package/dist/extra/operators.cjs.map +1 -0
  82. package/dist/extra/operators.d.cts +1 -950
  83. package/dist/extra/operators.d.ts +1 -950
  84. package/dist/extra/operators.js +3 -1
  85. package/dist/extra/operators.js.map +1 -0
  86. package/dist/extra/reactive.cjs +21 -1
  87. package/dist/extra/reactive.cjs.map +1 -0
  88. package/dist/extra/reactive.d.cts +1 -353
  89. package/dist/extra/reactive.d.ts +1 -353
  90. package/dist/extra/reactive.js +3 -1
  91. package/dist/extra/reactive.js.map +1 -0
  92. package/dist/extra/render/index.cjs +21 -5
  93. package/dist/extra/render/index.cjs.map +1 -0
  94. package/dist/extra/render/index.d.cts +1 -183
  95. package/dist/extra/render/index.d.ts +1 -183
  96. package/dist/extra/render/index.js +3 -1
  97. package/dist/extra/render/index.js.map +1 -0
  98. package/dist/extra/sources.cjs +21 -3
  99. package/dist/extra/sources.cjs.map +1 -0
  100. package/dist/extra/sources.d.cts +1 -584
  101. package/dist/extra/sources.d.ts +1 -584
  102. package/dist/extra/sources.js +3 -1
  103. package/dist/extra/sources.js.map +1 -0
  104. package/dist/extra/storage-browser.cjs +21 -1
  105. package/dist/extra/storage-browser.cjs.map +1 -0
  106. package/dist/extra/storage-browser.d.cts +1 -37
  107. package/dist/extra/storage-browser.d.ts +1 -37
  108. package/dist/extra/storage-browser.js +3 -1
  109. package/dist/extra/storage-browser.js.map +1 -0
  110. package/dist/extra/storage-core.cjs +21 -1
  111. package/dist/extra/storage-core.cjs.map +1 -0
  112. package/dist/extra/storage-core.d.cts +1 -28
  113. package/dist/extra/storage-core.d.ts +1 -28
  114. package/dist/extra/storage-core.js +3 -1
  115. package/dist/extra/storage-core.js.map +1 -0
  116. package/dist/extra/storage-node.cjs +20 -0
  117. package/dist/extra/storage-node.cjs.map +1 -0
  118. package/dist/extra/storage-node.d.cts +1 -2
  119. package/dist/extra/storage-node.d.ts +1 -2
  120. package/dist/extra/storage-node.js +3 -0
  121. package/dist/extra/storage-node.js.map +1 -0
  122. package/dist/extra/storage-tiers-browser.cjs +21 -1
  123. package/dist/extra/storage-tiers-browser.cjs.map +1 -0
  124. package/dist/extra/storage-tiers-browser.d.cts +1 -120
  125. package/dist/extra/storage-tiers-browser.d.ts +1 -120
  126. package/dist/extra/storage-tiers-browser.js +3 -1
  127. package/dist/extra/storage-tiers-browser.js.map +1 -0
  128. package/dist/extra/storage-tiers-node.cjs +21 -1
  129. package/dist/extra/storage-tiers-node.cjs.map +1 -0
  130. package/dist/extra/storage-tiers-node.d.cts +1 -210
  131. package/dist/extra/storage-tiers-node.d.ts +1 -210
  132. package/dist/extra/storage-tiers-node.js +3 -1
  133. package/dist/extra/storage-tiers-node.js.map +1 -0
  134. package/dist/extra/storage-tiers.cjs +21 -1
  135. package/dist/extra/storage-tiers.cjs.map +1 -0
  136. package/dist/extra/storage-tiers.d.cts +1 -412
  137. package/dist/extra/storage-tiers.d.ts +1 -412
  138. package/dist/extra/storage-tiers.js +3 -1
  139. package/dist/extra/storage-tiers.js.map +1 -0
  140. package/dist/extra/storage-wal.cjs +21 -0
  141. package/dist/extra/storage-wal.cjs.map +1 -0
  142. package/dist/extra/storage-wal.d.cts +1 -0
  143. package/dist/extra/storage-wal.d.ts +1 -0
  144. package/dist/extra/storage-wal.js +3 -0
  145. package/dist/extra/storage-wal.js.map +1 -0
  146. package/dist/graph/index.cjs +21 -7
  147. package/dist/graph/index.cjs.map +1 -0
  148. package/dist/graph/index.d.cts +1 -7
  149. package/dist/graph/index.d.ts +1 -7
  150. package/dist/graph/index.js +3 -1
  151. package/dist/graph/index.js.map +1 -0
  152. package/dist/index.cjs +20 -227
  153. package/dist/index.cjs.map +1 -0
  154. package/dist/index.d.cts +45 -96
  155. package/dist/index.d.ts +45 -96
  156. package/dist/index.js +3 -1
  157. package/dist/index.js.map +1 -0
  158. package/dist/patterns/ai/browser.cjs +20 -7
  159. package/dist/patterns/ai/browser.cjs.map +1 -0
  160. package/dist/patterns/ai/browser.d.cts +1 -127
  161. package/dist/patterns/ai/browser.d.ts +1 -127
  162. package/dist/patterns/ai/browser.js +3 -3
  163. package/dist/patterns/ai/browser.js.map +1 -0
  164. package/dist/patterns/ai/index.cjs +20 -73
  165. package/dist/patterns/ai/index.cjs.map +1 -0
  166. package/dist/patterns/ai/index.d.cts +1 -21
  167. package/dist/patterns/ai/index.d.ts +1 -21
  168. package/dist/patterns/ai/index.js +3 -1
  169. package/dist/patterns/ai/index.js.map +1 -0
  170. package/dist/patterns/ai/node.cjs +21 -1
  171. package/dist/patterns/ai/node.cjs.map +1 -0
  172. package/dist/patterns/ai/node.d.cts +1 -59
  173. package/dist/patterns/ai/node.d.ts +1 -59
  174. package/dist/patterns/ai/node.js +3 -1
  175. package/dist/patterns/ai/node.js.map +1 -0
  176. package/dist/patterns/cqrs/index.cjs +21 -3
  177. package/dist/patterns/cqrs/index.cjs.map +1 -0
  178. package/dist/patterns/cqrs/index.d.cts +1 -8
  179. package/dist/patterns/cqrs/index.d.ts +1 -8
  180. package/dist/patterns/cqrs/index.js +3 -1
  181. package/dist/patterns/cqrs/index.js.map +1 -0
  182. package/dist/patterns/demo-shell/index.cjs +21 -5
  183. package/dist/patterns/demo-shell/index.cjs.map +1 -0
  184. package/dist/patterns/demo-shell/index.d.cts +1 -7
  185. package/dist/patterns/demo-shell/index.d.ts +1 -7
  186. package/dist/patterns/demo-shell/index.js +3 -1
  187. package/dist/patterns/demo-shell/index.js.map +1 -0
  188. package/dist/patterns/domain-templates/index.cjs +21 -3
  189. package/dist/patterns/domain-templates/index.cjs.map +1 -0
  190. package/dist/patterns/domain-templates/index.d.cts +1 -6
  191. package/dist/patterns/domain-templates/index.d.ts +1 -6
  192. package/dist/patterns/domain-templates/index.js +3 -1
  193. package/dist/patterns/domain-templates/index.js.map +1 -0
  194. package/dist/patterns/graphspec/index.cjs +21 -86
  195. package/dist/patterns/graphspec/index.cjs.map +1 -0
  196. package/dist/patterns/graphspec/index.d.cts +1 -8
  197. package/dist/patterns/graphspec/index.d.ts +1 -8
  198. package/dist/patterns/graphspec/index.js +3 -1
  199. package/dist/patterns/graphspec/index.js.map +1 -0
  200. package/dist/patterns/harness/index.cjs +21 -48
  201. package/dist/patterns/harness/index.cjs.map +1 -0
  202. package/dist/patterns/harness/index.d.cts +1 -14
  203. package/dist/patterns/harness/index.d.ts +1 -14
  204. package/dist/patterns/harness/index.js +3 -1
  205. package/dist/patterns/harness/index.js.map +1 -0
  206. package/dist/patterns/inspect/index.cjs +21 -3
  207. package/dist/patterns/inspect/index.cjs.map +1 -0
  208. package/dist/patterns/inspect/index.d.cts +1 -9
  209. package/dist/patterns/inspect/index.d.ts +1 -9
  210. package/dist/patterns/inspect/index.js +3 -1
  211. package/dist/patterns/inspect/index.js.map +1 -0
  212. package/dist/patterns/job-queue/index.cjs +21 -3
  213. package/dist/patterns/job-queue/index.cjs.map +1 -0
  214. package/dist/patterns/job-queue/index.d.cts +1 -9
  215. package/dist/patterns/job-queue/index.d.ts +1 -9
  216. package/dist/patterns/job-queue/index.js +3 -1
  217. package/dist/patterns/job-queue/index.js.map +1 -0
  218. package/dist/patterns/memory/index.cjs +21 -3
  219. package/dist/patterns/memory/index.cjs.map +1 -0
  220. package/dist/patterns/memory/index.d.cts +1 -8
  221. package/dist/patterns/memory/index.d.ts +1 -8
  222. package/dist/patterns/memory/index.js +3 -1
  223. package/dist/patterns/memory/index.js.map +1 -0
  224. package/dist/patterns/messaging/index.cjs +21 -3
  225. package/dist/patterns/messaging/index.cjs.map +1 -0
  226. package/dist/patterns/messaging/index.d.cts +1 -7
  227. package/dist/patterns/messaging/index.d.ts +1 -7
  228. package/dist/patterns/messaging/index.js +3 -1
  229. package/dist/patterns/messaging/index.js.map +1 -0
  230. package/dist/patterns/orchestration/index.cjs +21 -3
  231. package/dist/patterns/orchestration/index.cjs.map +1 -0
  232. package/dist/patterns/orchestration/index.d.cts +1 -9
  233. package/dist/patterns/orchestration/index.d.ts +1 -9
  234. package/dist/patterns/orchestration/index.js +3 -1
  235. package/dist/patterns/orchestration/index.js.map +1 -0
  236. package/dist/patterns/process/index.cjs +21 -1
  237. package/dist/patterns/process/index.cjs.map +1 -0
  238. package/dist/patterns/process/index.d.cts +1 -10
  239. package/dist/patterns/process/index.d.ts +1 -10
  240. package/dist/patterns/process/index.js +3 -1
  241. package/dist/patterns/process/index.js.map +1 -0
  242. package/dist/patterns/reactive-layout/index.cjs +21 -4
  243. package/dist/patterns/reactive-layout/index.cjs.map +1 -0
  244. package/dist/patterns/reactive-layout/index.d.cts +1 -7
  245. package/dist/patterns/reactive-layout/index.d.ts +1 -7
  246. package/dist/patterns/reactive-layout/index.js +3 -1
  247. package/dist/patterns/reactive-layout/index.js.map +1 -0
  248. package/dist/patterns/reduction/index.cjs +21 -3
  249. package/dist/patterns/reduction/index.cjs.map +1 -0
  250. package/dist/patterns/reduction/index.d.cts +1 -6
  251. package/dist/patterns/reduction/index.d.ts +1 -6
  252. package/dist/patterns/reduction/index.js +3 -1
  253. package/dist/patterns/reduction/index.js.map +1 -0
  254. package/dist/patterns/surface/index.cjs +21 -13
  255. package/dist/patterns/surface/index.cjs.map +1 -0
  256. package/dist/patterns/surface/index.d.cts +1 -9
  257. package/dist/patterns/surface/index.d.ts +1 -9
  258. package/dist/patterns/surface/index.js +3 -1
  259. package/dist/patterns/surface/index.js.map +1 -0
  260. package/dist/patterns/topology-view/index.cjs +21 -0
  261. package/dist/patterns/topology-view/index.cjs.map +1 -0
  262. package/dist/patterns/topology-view/index.d.cts +1 -0
  263. package/dist/patterns/topology-view/index.d.ts +1 -0
  264. package/dist/patterns/topology-view/index.js +3 -0
  265. package/dist/patterns/topology-view/index.js.map +1 -0
  266. package/dist/testing/index.cjs +21 -0
  267. package/dist/testing/index.cjs.map +1 -0
  268. package/dist/testing/index.d.cts +1 -0
  269. package/dist/testing/index.d.ts +1 -0
  270. package/dist/testing/index.js +3 -0
  271. package/dist/testing/index.js.map +1 -0
  272. package/package.json +608 -584
  273. package/dist/backoff-HPZMEZNF.js +0 -1
  274. package/dist/cascading-CH-_VwG9.d.cts +0 -199
  275. package/dist/cascading-OgKQZjsa.d.ts +0 -199
  276. package/dist/chunk-35JTVPOX.js +0 -1
  277. package/dist/chunk-3G5U5QNE.js +0 -5
  278. package/dist/chunk-3XDYJRYU.js +0 -1
  279. package/dist/chunk-4I45FVQS.js +0 -1
  280. package/dist/chunk-4VVTGLXJ.js +0 -1
  281. package/dist/chunk-4YAN45KM.js +0 -1
  282. package/dist/chunk-5QDBSZBV.js +0 -1
  283. package/dist/chunk-626TESAC.js +0 -3
  284. package/dist/chunk-6HOSXQKF.js +0 -1
  285. package/dist/chunk-6QZNQS5B.js +0 -1
  286. package/dist/chunk-C72GO4IZ.js +0 -1
  287. package/dist/chunk-CE72X3WO.js +0 -1
  288. package/dist/chunk-CK2E7BTU.js +0 -1
  289. package/dist/chunk-CLD3F4R5.js +0 -1
  290. package/dist/chunk-CUNIRONA.js +0 -1
  291. package/dist/chunk-D27JNOLZ.js +0 -1
  292. package/dist/chunk-D5RFJOZ2.js +0 -1
  293. package/dist/chunk-EBW4V6JN.js +0 -1
  294. package/dist/chunk-ESMPEKEV.js +0 -1
  295. package/dist/chunk-F3IGTWCQ.js +0 -1
  296. package/dist/chunk-F672GV32.js +0 -1
  297. package/dist/chunk-FDQGFWLF.js +0 -1
  298. package/dist/chunk-FG4TKHMC.js +0 -1
  299. package/dist/chunk-GPW2V3RE.js +0 -1
  300. package/dist/chunk-I7IGYPSL.js +0 -1
  301. package/dist/chunk-INQD2KRQ.js +0 -1
  302. package/dist/chunk-JNWRYDJN.js +0 -1
  303. package/dist/chunk-JQFH2DV6.js +0 -1
  304. package/dist/chunk-K2Q24F5T.js +0 -1
  305. package/dist/chunk-KGKJCHEK.js +0 -1
  306. package/dist/chunk-KRH66M4O.js +0 -1
  307. package/dist/chunk-KVV66NN2.js +0 -1
  308. package/dist/chunk-L6NSJVJZ.js +0 -1
  309. package/dist/chunk-LYCLF26R.js +0 -1
  310. package/dist/chunk-NNKJUORL.js +0 -1
  311. package/dist/chunk-NON4NLIC.js +0 -45
  312. package/dist/chunk-O2BLLH7M.js +0 -18
  313. package/dist/chunk-OCKEEPRJ.js +0 -2
  314. package/dist/chunk-OFZG3TB3.js +0 -9
  315. package/dist/chunk-OYJKFY7V.js +0 -1
  316. package/dist/chunk-P6C4WHZO.js +0 -5
  317. package/dist/chunk-PT7W5FCD.js +0 -5
  318. package/dist/chunk-Q4U3A3L5.js +0 -1
  319. package/dist/chunk-QE4IGY7I.js +0 -61
  320. package/dist/chunk-QYADASLV.js +0 -1
  321. package/dist/chunk-QYVXF7GW.js +0 -1
  322. package/dist/chunk-S3EEIPO7.js +0 -1
  323. package/dist/chunk-SUWT3ZON.js +0 -1
  324. package/dist/chunk-TPKQW72B.js +0 -1
  325. package/dist/chunk-TSOYJ743.js +0 -1
  326. package/dist/chunk-TZQPPQEQ.js +0 -1
  327. package/dist/chunk-V5A7M7RJ.js +0 -1
  328. package/dist/chunk-VIMF6LGM.js +0 -1
  329. package/dist/chunk-VJLMUKOI.js +0 -1
  330. package/dist/chunk-VN6RDSK2.js +0 -1
  331. package/dist/chunk-VNC3TMVY.js +0 -1
  332. package/dist/chunk-VOPGGIL7.js +0 -1
  333. package/dist/chunk-VQ4A6T2A.js +0 -1
  334. package/dist/chunk-XG62INFA.js +0 -1
  335. package/dist/chunk-Y4NI3X7O.js +0 -84
  336. package/dist/content-addressed-storage-4-ST1tYk.d.cts +0 -124
  337. package/dist/content-addressed-storage-DuYMjV7o.d.ts +0 -124
  338. package/dist/decay-2ZukgQ4o.d.cts +0 -112
  339. package/dist/decay-CdEBmDIs.d.ts +0 -112
  340. package/dist/fallback-CqYVLL6X.d.ts +0 -250
  341. package/dist/fallback-Ctlj2tMY.d.cts +0 -250
  342. package/dist/graph-7VguS7a4.d.ts +0 -1668
  343. package/dist/graph-C4SHb3Ly.d.cts +0 -1668
  344. package/dist/index-0rKFCVFp.d.cts +0 -557
  345. package/dist/index-B-i4_g3k.d.ts +0 -651
  346. package/dist/index-B5iz82A3.d.cts +0 -2655
  347. package/dist/index-BAOD98JD.d.cts +0 -754
  348. package/dist/index-BG0BN3PB.d.ts +0 -44
  349. package/dist/index-BJX94aud.d.cts +0 -34
  350. package/dist/index-BP8a88zx.d.ts +0 -385
  351. package/dist/index-BTQtTb_H.d.cts +0 -301
  352. package/dist/index-BVpm6noz.d.cts +0 -36
  353. package/dist/index-Bc41FuHp.d.cts +0 -291
  354. package/dist/index-BdGtBX-X.d.cts +0 -515
  355. package/dist/index-Bf7eqeSF.d.ts +0 -113
  356. package/dist/index-BiX1Nkgx.d.cts +0 -1844
  357. package/dist/index-BoLv_OfD.d.cts +0 -651
  358. package/dist/index-BojK2fwH.d.cts +0 -299
  359. package/dist/index-BsT7F2et.d.ts +0 -291
  360. package/dist/index-BwLvVVsy.d.cts +0 -189
  361. package/dist/index-C59mYFKp.d.ts +0 -121
  362. package/dist/index-C7O6r5fV.d.ts +0 -37
  363. package/dist/index-C9kSENB4.d.cts +0 -127
  364. package/dist/index-C9pjcz3l.d.cts +0 -209
  365. package/dist/index-CAC_rNzm.d.ts +0 -189
  366. package/dist/index-CCq87F7t.d.ts +0 -127
  367. package/dist/index-CDXc9zKM.d.cts +0 -26
  368. package/dist/index-CJK1JkYy.d.ts +0 -36
  369. package/dist/index-CLon-IWF.d.cts +0 -374
  370. package/dist/index-COD1kVoS.d.cts +0 -468
  371. package/dist/index-CPT7C_f1.d.ts +0 -374
  372. package/dist/index-CQG3D1cp.d.ts +0 -468
  373. package/dist/index-CZQXo5tH.d.ts +0 -209
  374. package/dist/index-CZjOhcBy.d.cts +0 -113
  375. package/dist/index-ChOyVLKm.d.cts +0 -86
  376. package/dist/index-CvrqGfNS.d.ts +0 -34
  377. package/dist/index-D-AEQVLo.d.ts +0 -2655
  378. package/dist/index-D4Y1cMG0.d.ts +0 -26
  379. package/dist/index-DBHK8O6H.d.ts +0 -301
  380. package/dist/index-DBevwHj_.d.ts +0 -515
  381. package/dist/index-DIOoAZUX.d.ts +0 -45
  382. package/dist/index-DSZ3ZCHF.d.ts +0 -3402
  383. package/dist/index-Dgs8zcj7.d.ts +0 -102
  384. package/dist/index-Dh_HJ82K.d.ts +0 -299
  385. package/dist/index-Dhc7a7Xo.d.cts +0 -102
  386. package/dist/index-Dmqp7KjD.d.ts +0 -86
  387. package/dist/index-Dn-wI9g4.d.ts +0 -231
  388. package/dist/index-Du7u1lSf.d.cts +0 -385
  389. package/dist/index-DwigL4lY.d.ts +0 -1844
  390. package/dist/index-DyR7eU5S.d.cts +0 -779
  391. package/dist/index-JZUPJIJy.d.ts +0 -779
  392. package/dist/index-K0_0eR8g.d.ts +0 -557
  393. package/dist/index-O16yXPK4.d.cts +0 -3402
  394. package/dist/index-O7fucFrU.d.cts +0 -121
  395. package/dist/index-RV_yDjOX.d.cts +0 -198
  396. package/dist/index-cm1GNcWE.d.ts +0 -754
  397. package/dist/index-f5IivDUX.d.cts +0 -37
  398. package/dist/index-hHcaFlJX.d.cts +0 -45
  399. package/dist/index-tJoTcnHh.d.cts +0 -231
  400. package/dist/index-wAzD9yVj.d.ts +0 -198
  401. package/dist/index-z96luz5O.d.cts +0 -44
  402. package/dist/meta-BgVAsg9j.d.ts +0 -102
  403. package/dist/meta-vE8bxW1E.d.cts +0 -102
  404. package/dist/node-ClS5yC-B.d.cts +0 -1347
  405. package/dist/node-ClS5yC-B.d.ts +0 -1347
  406. package/dist/observable-BsBzUrcI.d.ts +0 -36
  407. package/dist/observable-DLGPPtb8.d.cts +0 -36
  408. package/dist/pipeline-graph-DPqKDk59.d.cts +0 -137
  409. package/dist/pipeline-graph-loP57TBA.d.ts +0 -137
  410. package/dist/reactive-layout-Dsvob4zD.d.cts +0 -183
  411. package/dist/reactive-layout-v7KPvxoc.d.ts +0 -183
  412. package/dist/reactive-log-B00laMSQ.d.cts +0 -223
  413. package/dist/reactive-log-BezYsbA_.d.ts +0 -223
  414. package/dist/reactive-map-48mnZ-nu.d.cts +0 -296
  415. package/dist/reactive-map-BVVPdvmi.d.ts +0 -296
  416. package/dist/resilience-YIWPK4YC.js +0 -1
  417. package/dist/sugar-DLwvMr3F.d.ts +0 -223
  418. package/dist/sugar-DyVGtczU.d.cts +0 -223
  419. package/dist/topology-tree-BNGvuG82.d.ts +0 -25
  420. package/dist/topology-tree-BSdfSwMi.d.cts +0 -25
  421. package/dist/types-B1jDWVsM.d.cts +0 -442
  422. package/dist/types-DkzUUs0H.d.ts +0 -442
@@ -1 +0,0 @@
1
- var e=Symbol.for("graphrefly/START"),f=Symbol.for("graphrefly/DATA"),s=Symbol.for("graphrefly/DIRTY"),o=Symbol.for("graphrefly/RESOLVED"),r=Symbol.for("graphrefly/INVALIDATE"),E=Symbol.for("graphrefly/PAUSE"),T=Symbol.for("graphrefly/RESUME"),t=Symbol.for("graphrefly/TEARDOWN"),a=Symbol.for("graphrefly/COMPLETE"),O=Symbol.for("graphrefly/ERROR"),g=Object.freeze([s]),p=Object.freeze([o]),n=Object.freeze([r]),b=Object.freeze([e]),M=Object.freeze([a]),c=Object.freeze([t]),l=Object.freeze([g]),y=Object.freeze([p]),S=Object.freeze([n]),A=Object.freeze([M]),x=Object.freeze([c]);export{e as a,f as b,s as c,o as d,r as e,E as f,T as g,t as h,a as i,O as j,g as k,p as l,n as m,b as n,M as o,c as p,l as q,y as r,S as s,A as t,x as u};
@@ -1 +0,0 @@
1
- import{E as p,I as A,m as l}from"./chunk-LYCLF26R.js";import{b as c,j as N}from"./chunk-CK2E7BTU.js";import{b as x}from"./chunk-QYADASLV.js";var B={};x(B,{action:()=>M,atom:()=>S,computed:()=>k,getValue:()=>_,map:()=>R,onMount:()=>w,onStart:()=>v,onStop:()=>g});var T=new WeakMap,f=new WeakMap;function d(e,t){let o=t.get(e);if(o)for(let n of o)n()}function m(e,t={}){let o=0;return{...t,get:()=>b(e),subscribe:a=>{o===0&&d(e,T),o++;let r=e.subscribe(s=>{for(let[i,u]of s)i===c&&a(u)});return()=>{r(),o--,o===0&&d(e,f)}},listen:a=>{o===0&&d(e,T),o++;let r=!0,s=e.subscribe(i=>{for(let[u,C]of i)if(u===c){if(r){r=!1;continue}a(C)}});return()=>{s(),o--,o===0&&d(e,f)}},_node:e}}function y(e){let t=e.cache,o;if(e.subscribe(a=>{for(let[r,s]of a)r===c&&(t=s),r===N&&(o=s)})(),o)throw o;return t}function b(e){return e.status==="sentinel"?y(e):e.cache}function S(e){let t=p(e,{resubscribable:!0,resetOnTeardown:!0});return m(t,{set:o=>t.emit(o)})}function k(e,t){let o=Array.isArray(e)?e:[e],n=o.map(r=>r._node),a=A(n,r=>{let s=o.map(i=>{let u=i._node;return u.status==="sentinel"&&y(u),r(u)});return t(...s)},{resubscribable:!0,resetOnTeardown:!0,equals:Object.is});return m(a)}function R(e){let t=p(e,{resubscribable:!0,resetOnTeardown:!0,equals:()=>!1});return m(t,{set:o=>t.emit(o),setKey:(o,n)=>{let a=b(t);t.emit({...a,[o]:n})}})}function _(e){return e.get()}function v(e,t){let o=e._node,n=T.get(o);n||(n=new Set,T.set(o,n)),n.add(t)}function g(e,t){let o=e._node,n=f.get(o);n||(n=new Set,f.set(o,n)),n.add(t)}function w(e,t){v(e,()=>{let o=t();typeof o=="function"&&g(e,o)})}function M(e,t,o){return(...n)=>{let a;return l(()=>{a=o(...n)}),a}}export{S as a,k as b,R as c,_ as d,v as e,g as f,w as g,M as h,B as i};
@@ -1 +0,0 @@
1
- import{a as I}from"./chunk-FDQGFWLF.js";import{a as F}from"./chunk-L6NSJVJZ.js";import{j as h}from"./chunk-626TESAC.js";import{t as T}from"./chunk-VOPGGIL7.js";import{C as y}from"./chunk-V5A7M7RJ.js";import{D as v,E as x,G as S,H as E,m as _}from"./chunk-LYCLF26R.js";import{b as R,i as O,j as k}from"./chunk-CK2E7BTU.js";import{b as A}from"./chunk-QYADASLV.js";var M={};A(M,{feedback:()=>G,funnel:()=>$,scorer:()=>q});function N(e,n){return F("reduction",e,n)}function $(e,n,t,l){if(n.length===0)throw new RangeError("funnel requires at least one source");if(t.length===0)throw new RangeError("funnel requires at least one stage");let r=new h(e,l),m=n.length===1?n[0]:T(...n);r.add(m,{name:"merged"});let a="merged";for(let c=0;c<t.length;c++){let o=t[c],s=new h(o.name);o.build(s);try{s.resolve("input")}catch{throw new Error(`funnel stage "${o.name}" must define an "input" node`)}try{s.resolve("output")}catch{throw new Error(`funnel stage "${o.name}" must define an "output" node`)}r.mount(o.name,s);let i=r.resolve(a),u=`${o.name}::input`,p=r.resolve(u),f=`__bridge_${a}\u2192${o.name}_input`,b=E([i],([d])=>{p.emit(d)},{name:f});r.add(b,{name:f}),r.addDisposer(y(b)),a=`${o.name}::output`}return r}function G(e,n,t,l){let r=l?.maxIterations??10,m=`__feedback_${n}`,a=x(0,{meta:N("feedback_counter",{maxIterations:r,feedbackFrom:n,feedbackTo:t})});e.add(a,{name:m});let c=e.resolve(n),o=e.resolve(t),s=`__feedback_effect_${n}`,i=v([],(u,p)=>{let f=c.subscribe(b=>{for(let d of b){let g=d[0];if(g===R){let w=d[1];if(w==null)return;_(()=>{I(a,r)&&o.emit(w)})}else if(g===O||g===k){let w=g===k&&d.length>1?[k,d[1]]:[g];a.down([w])}}});return()=>f()},{name:s,describeKind:"effect",meta:{...N("feedback_effect",{feedbackFrom:n,feedbackTo:t}),_internal:!0}});return e.add(i,{name:s}),e.addDisposer(y(i)),e}function q(e,n,t){if(e.length===0)throw new RangeError("scorer requires at least one source");if(e.length!==n.length)throw new RangeError("scorer requires the same number of sources and weights");let l=[...e,...n],r=e.length,m=t?.scoreFns;return S(l,a=>{let c=a.slice(0,r),o=a.slice(r),s=[],i=0;for(let u=0;u<r;u++){let p=c[u]??0,f=o[u]??0,d=(m?.[u]?m[u](p):p)*f;s.push(d),i+=d}return{value:c,score:i,breakdown:s}},{...t?{equals:t.equals,resubscribable:t.resubscribable,resetOnTeardown:t.resetOnTeardown}:{},describeKind:"derived",meta:N("scorer",t?.meta)})}export{$ as a,G as b,q as c,M as d};
@@ -1 +0,0 @@
1
- import{A as e,n as t}from"./chunk-LYCLF26R.js";import{b as o}from"./chunk-CK2E7BTU.js";function u(r,n){r!=null&&t(i=>r.down(i),[[o,n]],e.tierOf)}function a(r){return r.relatedTo?.[0]??r.summary}export{u as a,a as b};
@@ -1 +0,0 @@
1
- import{b as P}from"./chunk-CE72X3WO.js";var O=new TextEncoder,M=new TextDecoder("utf-8",{fatal:!0}),h={name:"json",version:1,encode(e){return O.encode(P(e))},decode(e){return JSON.parse(M.decode(e))}};function U(){return h}function k(){let e=new Map;return{name:"memory",read(n){let o=e.get(n);return o===void 0?void 0:new Uint8Array(o)},write(n,o){e.set(n,new Uint8Array(o))},delete(n){e.delete(n)},list(n){let o=[...e.keys()];return n?o.filter(r=>r.startsWith(n)).sort():o.sort()}}}function w(e,n={}){let o=n.codec??h,r=n.name??e.name??"snapshot",d=n.keyOf??(c=>c.name??n.name??e.name??"snapshot"),a,m=0,T=n.compactEvery,l,f={name:r,debounceMs:n.debounceMs,compactEvery:T,filter:n.filter,keyOf:d,save(c){if(!(n.filter&&!n.filter(c))&&(a={snapshot:c},m+=1,T!==void 0&&m%T===0||!n.debounceMs))return s()},load(){let c=l??r,t=e.read(c);if(t!==void 0)return t instanceof Uint8Array?t.length===0?void 0:o.decode(t):Promise.resolve(t).then(i=>i===void 0||i.length===0?void 0:o.decode(i))},async flush(){await s()},async rollback(){a=void 0}};function s(){let c=a;if(!c)return;a=void 0;let t=d(c.snapshot),i=o.encode(c.snapshot),u=e.write(t,i);if(u instanceof Promise)return u.then(()=>{l=t});l=t}return f}function C(e,n={}){let o=n.codec??h,r=n.name??e.name??"append-log",d=n.keyOf??(t=>r),a=n.compactEvery,m=new Map,T=0,l,f={name:r,debounceMs:n.debounceMs,compactEvery:a,keyOf:d,appendEntries(t){if(t.length!==0){for(let i of t){let u=d(i),g=m.get(u);g||(g=[],m.set(u,g)),g.push(i)}if(T+=t.length,a!==void 0&&T%a===0||!n.debounceMs)return s()}},async loadEntries(t){let i=t?.keyFilter,u=e.list===void 0?i!==void 0?[i]:[r]:await Promise.resolve(e.list(i)),g=[];for(let v of u){let y=await Promise.resolve(e.read(v));if(y===void 0||y.length===0)continue;let p=o.decode(y);Array.isArray(p)&&g.push(...p)}return{entries:g,cursor:void 0}},async flush(){await s()},async rollback(){m=new Map}};function s(){if(m.size===0)return;let t=m;m=new Map;let i=(l??Promise.resolve()).then(()=>{let u=c(t);return u instanceof Promise?u:Promise.resolve()},()=>{let u=c(t);return u instanceof Promise?u:Promise.resolve()});return l=i.finally(()=>{l===i&&(l=void 0)}),l}function c(t){let i=[];for(let[u,g]of t){let v=e.read(u),y=p=>{let b=[...p===void 0||p.length===0?[]:o.decode(p)??[],...g],x=o.encode(b);return e.write(u,x)};if(v instanceof Promise)i.push(v.then(async p=>{let S=y(p);S instanceof Promise&&await S}));else{let p=y(v);p instanceof Promise&&i.push(p)}}if(i.length>0)return Promise.all(i).then(()=>{})}return f}function A(e,n={}){let o=n.codec??h,r=n.name??e.name??"kv",d=n.compactEvery,a=new Map,m=0,T={name:r,debounceMs:n.debounceMs,compactEvery:d,filter:n.filter,save(f,s){if(!(n.filter&&!n.filter(f,s))&&(a.set(f,s),m+=1,d!==void 0&&m%d===0||!n.debounceMs))return l()},load(f){let s=e.read(f);if(s!==void 0)return s instanceof Uint8Array?s.length===0?void 0:o.decode(s):Promise.resolve(s).then(c=>c===void 0||c.length===0?void 0:o.decode(c))},delete(f){if(a.delete(f),!!e.delete)return e.delete(f)},list(f){return e.list?e.list(f):[]},async flush(){await l()},async rollback(){a=new Map}};function l(){if(a.size===0)return;let f=a;a=new Map;let s=[];for(let[c,t]of f){let i=o.encode(t),u=e.write(c,i);u instanceof Promise&&s.push(u)}if(s.length>0)return Promise.all(s).then(()=>{})}return T}function B(e){return w(k(),e)}function K(e){return C(k(),e)}function L(e){return A(k(),e)}function R(e,n){let o={name:n?.name??"dict-kv",read(r){return e[r]},write(r,d){e[r]=new Uint8Array(d)},delete(r){delete e[r]},list(r){let d=Object.keys(e).sort();return r?d.filter(a=>a.startsWith(r)):d}};return A(o,n)}function j(e,n){return w({name:"dict",read(r){return e[r]},write(r,d){e[r]=new Uint8Array(d)},delete(r){delete e[r]},list(r){let d=Object.keys(e).sort();return r?d.filter(a=>a.startsWith(r)):d}},n)}export{h as a,U as b,k as c,w as d,C as e,A as f,B as g,K as h,L as i,R as j,j as k};
@@ -1 +0,0 @@
1
- import{a as T}from"./chunk-OYJKFY7V.js";import{a as k}from"./chunk-L6NSJVJZ.js";import{a as C}from"./chunk-KVV66NN2.js";import{j as N,l as W}from"./chunk-626TESAC.js";import{b as S}from"./chunk-35JTVPOX.js";import{b as Y}from"./chunk-JQFH2DV6.js";import{C as D}from"./chunk-V5A7M7RJ.js";import{C as Q,E,G as A,m as B,o as R,p as O,u as $,w as J}from"./chunk-LYCLF26R.js";import{b as P}from"./chunk-CK2E7BTU.js";import{b as ne}from"./chunk-QYADASLV.js";var ue={};ne(ue,{AuditTrailGraph:()=>L,GuardedExecutionGraph:()=>V,InspectGraph:()=>M,PolicyGateGraph:()=>j,auditTrail:()=>H,complianceSnapshot:()=>I,computeHealthReport:()=>te,graphLens:()=>z,guardedExecution:()=>de,healthReportEqual:()=>oe,inspect:()=>ce,policyGate:()=>K,watchTopologyTree:()=>C});function ee(o,e){return k("audit",o,e)}var ie=new Set(["data","error","complete","teardown"]),L=class extends N{entries;count;includeTypes;_log;_target;constructor(e,t){super(t.name??`${e.name}_audit`,t.graph),this._target=e,this._log=Y([],{name:"entries",...t.maxSize!=null?{maxSize:t.maxSize}:{}}),this.entries=this._log.entries,this.add(this.entries,{name:"entries"}),this.count=A([this.entries],([s])=>s.length,{name:"count",describeKind:"derived",meta:ee("count")}),this.add(this.count,{name:"count"}),this.addDisposer(D(this.count));let n=t.includeTypes!=null?new Set(t.includeTypes):new Set(ie);this.includeTypes=n;let r=t.filter,i=0,u=e.observe({timeline:!0,structured:!0}),h=u.onEvent(s=>{if(s.type==="derived")return;let d=s.type;if(!n.has(d))return;let y=s.path??"",g={seq:i++,timestamp_ns:s.timestamp_ns??R(),wall_clock_ns:O(),path:y,type:d},b=(y?F(e,y):void 0)?.lastMutation;b!=null&&(g.actor=b.actor),d==="data"&&(g.value=s.data),d==="error"&&(g.error=s.data);let l=y?re(e,y):void 0;l!=null&&(g.annotation=l),!(r!=null&&!r(g))&&this._log.append(g)});this.addDisposer(()=>{h(),u.dispose()}),this.addDisposer(()=>this._log.disposeAllViews())}all(){return this.entries.cache??[]}byNode(e){return this.all().filter(t=>t.path===e)}byActor(e){return this.all().filter(t=>t.actor?.id===e)}byActorType(e){return this.all().filter(t=>t.actor?.type===e)}byTimeRange(e,t){return this.all().filter(n=>!(n.timestamp_ns<e||t!=null&&n.timestamp_ns>=t))}get target(){return this._target}};function H(o,e={}){return new L(o,e)}var j=class extends N{policies;violations;violationCount;_target;_mode;_currentGuard;constructor(e,t,n){super(n.name??`${e.name}_policy`,n.graph),this._target=e,this._mode=n.mode??"audit";let r=X(t)?t:E(t,{name:"policies"});this.policies=r,this.add(this.policies,{name:"policies"}),this.violations=new T("violations",{retainedLimit:n.violationsLimit??1e3}),this.mount("violations",this.violations),this.violationCount=A([this.violations.events],([l])=>l.length,{name:"violationCount",describeKind:"derived",meta:ee("policy_violation_count")}),this.add(this.violationCount,{name:"violationCount"}),this.addDisposer(D(this.violationCount));let u=r.cache??[];this._currentGuard=$(u);let h=r.subscribe(l=>{for(let m of l)m[0]===P&&(u=m[1]??[],this._currentGuard=$(u))});this.addDisposer(h);let s=n.paths,d=X(s)?s:void 0,y=s!=null,w=d!=null?d.cache??[]:y?[...s]:void 0,b=w??Z(e);if(this._mode!=="enforce"&&d!=null){let l=d.subscribe(m=>{for(let a of m)a[0]===P&&(w=a[1]??[])});this.addDisposer(l)}if(this._mode==="enforce"){let l=new Map,m=a=>{if(l.has(a))return;let c=F(e,a);if(!(c instanceof Q))return;let _=(p,f)=>{let G=this._currentGuard(p,f);return G||this._publishViolation(p,f,a,"blocked"),G};l.set(a,c._pushGuard(_))};for(let a of b)m(a);if(d!=null){let a=d.subscribe(c=>{for(let _ of c){if(_[0]!==P)continue;let p=_[1]??[],f=new Set(p),G=new Set(w??[]);B(()=>{for(let v of G){if(f.has(v))continue;let x=l.get(v);x!=null&&(x(),l.delete(v))}for(let v of f)G.has(v)||m(v);w=p})}});this.addDisposer(a)}if(y){let a=e.topology.subscribe(c=>{for(let _ of c){if(_[0]!==P)continue;let p=_[1];if(p.kind!=="removed"||p.nodeKind!=="node")continue;let f=l.get(p.name);f!=null&&(f(),l.delete(p.name))}});this.addDisposer(a)}else{let a=C(e,(c,_,p)=>{if(c.kind==="added")if(c.nodeKind==="node")m(`${p}${c.name}`);else{let f=_._mounts.get(c.name);if(!(f instanceof N))return;let G=`${p}${c.name}::`,v=Z(f);for(let x of v)m(x===""?`${p}${c.name}`:`${G}${x}`)}else if(c.kind==="removed")if(c.nodeKind==="node"){let f=`${p}${c.name}`,G=l.get(f);G!=null&&(G(),l.delete(f))}else{let f=`${p}${c.name}`,G=`${f}::`;for(let[v,x]of l)(v===f||v.startsWith(G))&&(x(),l.delete(v))}});this.addDisposer(a)}this.addDisposer(()=>{for(let a of l.values())a();l.clear()})}else{let l=e.observe({timeline:!0,structured:!0}),m=l.onEvent(a=>{if(a.type!=="data"&&a.type!=="error")return;let c=a.path??"";if(!c||w!=null&&!w.includes(c))return;let _=a.actor??F(e,c)?.lastMutation?.actor;if(_==null)return;let p="write";this._currentGuard(_,p)||this._publishViolation(_,p,c,"observed")});this.addDisposer(()=>{m(),l.dispose()})}}_publishViolation(e,t,n,r){this.violations.publish({timestamp_ns:R(),wall_clock_ns:O(),path:n,actor:e,action:t,mode:this._mode,result:r})}all(){return this.violations.retained()}get mode(){return this._mode}get target(){return this._target}};function K(o,e,t={}){let n=new j(o,e,t);return n.tagFactory("policyGate",S(t)),n}function I(o,e={}){let t={format_version:1,timestamp_ns:R(),wall_clock_ns:O(),graph:o.snapshot()};if(e.actor!=null&&(t.actor=e.actor),e.audit!=null){let r=[...e.audit.all()];t.audit={count:r.length,entries:r}}if(e.policies!=null){let r=e.policies.policies.cache??[];t.policies={mode:e.policies.mode,rules:r,violations:[...e.policies.all()]}}let n=ae(t);return{...t,fingerprint:n}}function X(o){return typeof o=="object"&&o!==null&&"subscribe"in o}function F(o,e){try{return o.node(e)}catch{return}}function re(o,e){try{return o.annotation(e)}catch{return}}function Z(o){let e=o.describe({detail:"minimal"});return Object.keys(e.nodes)}function ae(o){return J(JSON.stringify(se(o)))}function se(o){let e=new Set,t=n=>{if(n===void 0)return{__undefined:!0};if(n===null)return null;let r=typeof n;if(r==="bigint")return{__bigint:n.toString()};if(r!=="object")return n;let i=n;if(e.has(i))return{__circular:!0};e.add(i);try{if(Array.isArray(i))return i.map(t);if(i instanceof Date)return{__date:i.toISOString()};if(i instanceof RegExp)return{__regexp:{source:i.source,flags:i.flags}};if(i instanceof Map)return{__map:[...i.entries()].map(([s,d])=>[t(s),t(d)])};if(i instanceof Set)return{__set:[...i].map(t)};if(ArrayBuffer.isView(i)){let h=i,s=new Array(h.length);for(let d=0;d<h.length;d++)s[d]=h[d]??0;return{__typed_array:{ctor:i.constructor.name,data:s}}}let u={};for(let h of Object.keys(i).sort())u[h]=t(i[h]);return u}finally{e.delete(i)}};return t(o)}function q(o){return typeof o=="object"&&o!==null&&"subscribe"in o&&"down"in o}function le(o){return k("guarded",o)}var V=class extends N{enforcer;violations;lints;scope;scopedDescribe;_target;_actorNode;_mode;_firedLintKinds=new Set;constructor(e,t){super(t.name??`${e.name}_guarded`,t.graph),this._target=e,this._mode=t.mode??"enforce";let n=t.policies,r=q(n);if(!r&&this._mode==="enforce"&&n.length===0)throw new RangeError('guardedExecution: empty `policies` in `mode: "enforce"` denies every action. Pass at least `{ effect: "allow", action: "*" }` and layer deny rules on top.');this.lints=new T("lints",{retainedLimit:t.lintsLimit??64}),this.mount("lints",this.lints);let i=t.actor;i==null?this._actorNode=E(null,{name:"actor"}):q(i)?this._actorNode=A([i],([s])=>s??null,{name:"actor",initial:null}):this._actorNode=E(i,{name:"actor"});let u={mode:this._mode,name:"enforcer"};if(t.violationsLimit!=null&&(u.violationsLimit=t.violationsLimit),this.enforcer=K(e,t.policies,u),this.violations=this.enforcer.violations,this.mount("enforcer",this.enforcer),r&&this._mode==="enforce"){let s=n,d=s.cache;d!=null&&d.length===0&&this._fireLint("empty-policies",'`policies` Node cached an empty array in `mode: "enforce"` \u2014 every action will be denied. Add at least one allow rule.');let y=s.subscribe(g=>{for(let w of g){if(w[0]!==P)continue;let b=w[1];(b==null||b.length===0)&&this._fireLint("empty-policies",'`policies` Node emitted an empty array in `mode: "enforce"` \u2014 every action will be denied. Add at least one allow rule.')}});this.addDisposer(y)}if(this._mode==="audit"){let s=e.describe({detail:"full"});Object.values(s.nodes).some(y=>y.guard!=null)||this._fireLint("audit-no-effect",'`mode: "audit"` + target has no per-node guards \u2014 `scopedDescribeNode` filters by per-node guards only, so policy rules will not affect describe() visibility. Policies still populate the `violations` topic on writes.')}i==null&&this._fireLint("no-actor","no actor configured \u2014 `wrapper.scopedDescribe` and `scopedDescribeNode()` will return an unscoped describe (full visibility) unless a per-call actor is supplied."),this.scope=A([this._actorNode,this.enforcer.policies],([s,d])=>({actor:s??null,mode:this._mode,policiesCount:d.length}),{name:"scope",describeKind:"derived",meta:le("scope")}),this.add(this.scope,{name:"scope"}),this.addDisposer(D(this.scope));let h=e.describe({reactive:!0,actor:this._actorNode,reactiveName:"scopedDescribe"});this.scopedDescribe=h.node,this.add(this.scopedDescribe,{name:"scopedDescribe"}),this.addDisposer(h.dispose)}_fireLint(e,t){this._firedLintKinds.has(e)||(this._firedLintKinds.add(e),this.lints.publish({kind:e,message:t,timestamp_ns:R()}))}scopedDescribeNode(e,t){let n=e==null?this._actorNode:q(e)?e:E(e,{name:"actor_override"}),r=this._target.describe({reactive:!0,actor:n,...t??{}});return this.addDisposer(r.dispose),{node:r.node,dispose:r.dispose}}get target(){return this._target}};function de(o,e){return new V(o,e)}function te(o){let e=[];for(let[t,n]of Object.entries(o.nodes)){if(n.status!=="errored")continue;let r={path:t,status:"errored"},i=W(o,t,"upstream",{});for(let u of i)if(u!==t&&o.nodes[u]?.status==="errored"){r.upstreamCause=u;break}e.push(r)}return e.sort((t,n)=>t.path<n.path?-1:t.path>n.path?1:0),{ok:e.length===0,problems:e}}function oe(o,e){if(o.ok!==e.ok||o.problems.length!==e.problems.length)return!1;for(let t=0;t<o.problems.length;t++){let n=o.problems[t],r=e.problems[t];if(n.path!==r.path||n.status!==r.status||n.upstreamCause!==r.upstreamCause)return!1}return!0}function z(o){let e=o.describe({reactive:!0,detail:"standard",reactiveName:"graphLens.topology"}),t=e.node,n=A([t],([g])=>te(g),{name:"graphLens.health",describeKind:"derived",equals:oe,meta:k("lens","health")}),r=D(n),i=new Map,u=-1,h=o.observe({reactive:!0,tiers:["data"]}),s=A([h,t],([g,w])=>{let b=g,l=w;if(b!=null&&b.flushedAt_ns>u){u=b.flushedAt_ns;for(let m of b.events){if(m.type!=="data")continue;let a=m.path;if(a==null||a==="")continue;let c=i.get(a);i.set(a,{path:a,count:(c?.count??0)+1,lastUpdate_ns:b.flushedAt_ns})}}if(l!=null&&i.size>0){let m=new Set(Object.keys(l.nodes));for(let a of[...i.keys()])m.has(a)||i.delete(a)}return new Map(i)},{name:"graphLens.flow",describeKind:"derived",meta:k("lens","flow")}),d=D(s),y=!1;return{topology:t,health:n,flow:s,dispose(){y||(y=!0,d(),r(),e.dispose())}}}var U=class extends N{view;constructor(e){super("lens"),this.view=z(e),this.add(this.view.topology,{name:"topology"}),this.add(this.view.health,{name:"health"}),this.add(this.view.flow,{name:"flow"})}},M=class extends N{target;lens;audit;_defaultActor;_lensSubgraph;constructor(e,t={}){super(t.name??`inspect(${e.name})`),this.target=e,this._defaultActor=t.actor,this._lensSubgraph=new U(e),this.lens=this._lensSubgraph.view,this.mount("lens",this._lensSubgraph),this.audit=H(e,t.audit??{}),this.mount("audit",this.audit),this.addDisposer(()=>this.lens.dispose())}explainTarget(e,t,n){return this.target.explain(e,t,n)}complianceSnapshot(e){let t=e?.actor??this._defaultActor;return I(this.target,{audit:this.audit,...t!=null?{actor:t}:{},...e?.policies!=null?{policies:e.policies}:{}})}};function ce(o,e={}){let t=new M(o,e);return t.tagFactory("inspect",S(e)),t}export{L as a,H as b,j as c,K as d,I as e,V as f,de as g,te as h,oe as i,z as j,M as k,ce as l,ue as m};
@@ -1 +0,0 @@
1
- var e=class{_timer;_gen=0;start(i,t){this.cancel(),this._gen+=1;let n=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,n===this._gen&&t()},i)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}};export{e as a};
@@ -1 +0,0 @@
1
- import{F as l}from"./chunk-LYCLF26R.js";import{b as u,i as d,j as t}from"./chunk-CK2E7BTU.js";function c(r){return l(n=>{let e=!1,o=()=>{r.onsuccess=null,r.onerror=null};return r.onsuccess=()=>{e||(e=!0,o(),n.down([[u,r.result],[d]]))},r.onerror=()=>{e||(e=!0,o(),n.down([[t,r.error??new Error("IndexedDB request failed")]]))},()=>{e=!0,o()}})}function f(r){return l(n=>{let e=!1,o=()=>{r.oncomplete=null,r.onerror=null,r.onabort=null};return r.oncomplete=()=>{e||(e=!0,o(),n.down([[u,void 0],[d]]))},r.onerror=()=>{e||(e=!0,o(),n.down([[t,r.error??new Error("IndexedDB transaction failed")]]))},r.onabort=()=>{e||(e=!0,o(),n.down([[t,r.error??new Error("IndexedDB transaction aborted")]]))},()=>{e=!0,o()}})}export{c as a,f as b};
@@ -1 +0,0 @@
1
- import{d as b,e as S,f as g}from"./chunk-D5RFJOZ2.js";function u(e){return new Promise((r,o)=>{if(typeof indexedDB>"u"){o(new TypeError("indexedDB is not available in this environment"));return}let t=indexedDB.open(e.dbName,e.version??1);t.onupgradeneeded=()=>{let n=t.result;n.objectStoreNames.contains(e.storeName)||n.createObjectStore(e.storeName)},t.onsuccess=()=>r(t.result),t.onerror=()=>o(t.error??new Error(`indexedDbBackend: open(${e.dbName}) failed`))})}function p(e){let r=u(e);return{name:`idb:${e.dbName}/${e.storeName}`,async read(o){let t=await r;return new Promise((n,c)=>{let a=t.transaction(e.storeName,"readonly").objectStore(e.storeName).get(o);a.onsuccess=()=>{let d=a.result;d==null?n(void 0):d instanceof Uint8Array?n(d):d instanceof ArrayBuffer?n(new Uint8Array(d)):n(void 0)},a.onerror=()=>c(a.error)})},async write(o,t){let n=await r;await new Promise((c,s)=>{let i=n.transaction(e.storeName,"readwrite");i.objectStore(e.storeName).put(t,o),i.oncomplete=()=>c(),i.onerror=()=>s(i.error),i.onabort=()=>s(i.error??new Error("indexedDbBackend: write aborted"))})},async delete(o){let t=await r;await new Promise((n,c)=>{let s=t.transaction(e.storeName,"readwrite");s.objectStore(e.storeName).delete(o),s.oncomplete=()=>n(),s.onerror=()=>c(s.error)})},async list(o){let t=await r;return new Promise((n,c)=>{let a=t.transaction(e.storeName,"readonly").objectStore(e.storeName).getAllKeys();a.onsuccess=()=>{let d=a.result.map(m=>String(m));n(o===void 0?d.sort():d.filter(m=>m.startsWith(o)).sort())},a.onerror=()=>c(a.error)})}}}function y(e,r){return b(p(e),r)}function f(e,r){return S(p(e),r)}function l(e,r){return g(p(e),r)}export{p as a,y as b,f as c,l as d};
@@ -1 +0,0 @@
1
- import{j as y}from"./chunk-626TESAC.js";import{b as x}from"./chunk-JQFH2DV6.js";import{E as T,m as A,p as f,t as b}from"./chunk-LYCLF26R.js";import{b as m,c as R}from"./chunk-CK2E7BTU.js";function z(r,e){let n=r.cache??0;return n>=e?!1:(r.down([[R],[m,n+1]]),!0)}var k=b((r,e)=>{r("observe"),r("signal"),e("write")});function q(r){let e=x([],{name:r.name,maxSize:r.retainedLimit??1024,guard:r.guard??k,...r.versioning!=null?{versioning:r.versioning}:{}});return e.withLatest(),r.graph&&r.graph.add(e.entries,{name:r.name}),e}function p(r){if(r===null||typeof r!="object"||Object.isFrozen(r))return r;for(let e of Object.keys(r))p(r[e]);return Object.freeze(r)}var h=new WeakSet;function w(r){let e=r.cache,n=typeof e=="number"&&Number.isFinite(e);!n&&e!==void 0&&!h.has(r)&&(h.add(r),console.warn(`bumpCursor: cursor cache held a non-numeric value (${String(e)}); resetting to 0. Causes include: a snapshot codec round-tripping the cursor as a string / null / NaN, OR a malformed initial seed (e.g. state<number>(NaN)). Audit consumers may see colliding seq values after this point.`));let s=(n?e:0)+1;return r.down([[R],[m,s]]),s}function l(r,e,n,i,s,u){let o=e(n,i,s);if(o===void 0)return;let a=u!=null?{...o,handlerVersion:u}:o;r.append(a)}function G(r,e){let n=e.freeze??!0;return function(...s){let u=n?s.map(p):s,o=f(),a=e.seq?w(e.seq):void 0;try{let t=r(...u);return e.audit&&e.onSuccess&&l(e.audit,e.onSuccess,u,t,{t_ns:o,seq:a},e.handlerVersion),t}catch(t){if(e.audit&&e.onFailure){let d=t instanceof Error?t.name:typeof t;l(e.audit,e.onFailure,u,t,{t_ns:o,seq:a,errorType:d},e.handlerVersion)}throw t}}}function V(r,e){let n=e.freeze??!0;return function(...s){let u=n?s.map(p):s,o=f(),a,t,d=!1,g;try{A(()=>{e.seq&&(g=w(e.seq));try{a=r(...u),e.audit&&e.onSuccess&&l(e.audit,e.onSuccess,u,a,{t_ns:o,seq:g},e.handlerVersion)}catch(c){throw t=c,d=!0,c}})}catch(c){if(d&&e.audit&&e.onFailure){let M=t instanceof Error?t.name:typeof t;l(e.audit,e.onFailure,u,t,{t_ns:o,seq:g,errorType:M},e.handlerVersion)}throw d?t:c}return a}}function _(r,e,n=0){let i=T(n,{name:e,describeKind:"state"});return r.add(i,{name:e}),i}function C(r,e,n,i=0){let s={},u=new y(e);for(let o of n){let a=T(i,{name:o,describeKind:"state"});u.add(a,{name:o}),s[o]=a}return r.mount(e,u),s}export{z as a,k as b,q as c,w as d,l as e,G as f,V as g,_ as h,C as i};
@@ -1 +0,0 @@
1
- import{a as T,b as k}from"./chunk-OCKEEPRJ.js";import{d as H}from"./chunk-3G5U5QNE.js";import{j as B}from"./chunk-626TESAC.js";import{a as j,d as q}from"./chunk-35JTVPOX.js";import{E as d,G as o,H as x,m as O}from"./chunk-LYCLF26R.js";import{b as re}from"./chunk-QYADASLV.js";var oe={};re(oe,{demoShell:()=>ie});function w(h){return Math.max(0,Math.min(1,h))}function ie(h){let E=w(h?.mainRatio??.65),J=w(h?.sideSplit??.5),K=Math.max(0,h?.viewportWidth??1280),F=h?.nodeRegistry??new Map,m=h?.adapter??null,M=h?.layoutFont??"14px monospace",p=h?.onHighlight,t=new B("demo-shell"),D=d(E,{name:"pane/main-ratio"}),L=d(J,{name:"pane/side-split"}),g=d(null,{name:"pane/fullscreen"}),G=d(K,{name:"viewport/width"});t.add(D,{name:"pane/main-ratio"}),t.add(L,{name:"pane/side-split"}),t.add(g,{name:"pane/fullscreen"}),t.add(G,{name:"viewport/width"});let R=o([D,G,g],([e,a,n])=>{let l=e,r=a,i=n;return i==="main"?r:i==="graph"||i==="code"?0:Math.round(r*l)},{name:"pane/main-width"}),C=o([R,G,g],([e,a,n])=>{let l=n,r=a;return l==="main"?0:l==="graph"||l==="code"?r:r-e},{name:"pane/side-width"}),z=o([L,g],([e,a])=>{let n=a;return n==="graph"?1:n==="code"||n==="main"?0:w(e)},{name:"pane/graph-height-ratio"}),Q=o([z,g],([e,a])=>{let n=a;return n==="code"?1:n==="graph"||n==="main"?0:1-e},{name:"pane/code-height-ratio"});t.add(R,{name:"pane/main-width"}),t.add(C,{name:"pane/side-width"}),t.add(z,{name:"pane/graph-height-ratio"}),t.add(Q,{name:"pane/code-height-ratio"});let b=d(null,{name:"demo/graph-ref"}),u=d(0,{name:"demo/graph-tick"});t.add(b,{name:"demo/graph-ref"}),t.add(u,{name:"demo/graph-tick"});let U=o([b,u],([e,a])=>{let n=e;return n?H(n.describe()):""},{name:"graph/mermaid"}),P=o([b,u],([e,a])=>{let n=e;if(!n)return null;let{expand:l,...r}=n.describe({detail:"standard"});return r},{name:"graph/describe"});t.add(U,{name:"graph/mermaid"}),t.add(P,{name:"graph/describe"});let S=d(null,{name:"hover/target"});t.add(S,{name:"hover/target"});let W=o([S],([e])=>{let a=e;if(!a)return null;let n=F.get(a.id);return n?n.codeLine:null},{name:"highlight/code-scroll"}),N=o([S],([e])=>{let a=e;if(!a)return null;let n=F.get(a.id);return n?n.visualSelector:null},{name:"highlight/visual"}),_=o([S],([e])=>{let a=e;return a?a.id:null},{name:"highlight/graph"});if(t.add(W,{name:"highlight/code-scroll"}),t.add(N,{name:"highlight/visual"}),t.add(_,{name:"highlight/graph"}),p?.codeScroll){let e=p.codeScroll,a=x([W],([n])=>{e(n)});t.add(a,{name:"highlight/apply-code-scroll"})}if(p?.visual){let e=p.visual,a=x([N],([n])=>{e(n)});t.add(a,{name:"highlight/apply-visual"})}if(p?.graph){let e=p.graph,a=x([_],([n])=>{e(n)});t.add(a,{name:"highlight/apply-graph"})}let I=d(null,{name:"inspect/selected-node"});t.add(I,{name:"inspect/selected-node"});let X=j("standard"),Y=o([I,b,u],([e,a,n])=>{let l=a,r=e;if(!l||!r)return null;try{let i=l.resolve(r),s=q(i,X);return{path:r,...s,value:i.cache}}catch{return null}},{name:"inspect/node-detail"}),Z=o([b,u],([e,a])=>{let n=e;return n?n.trace():[]},{name:"inspect/trace-log"});t.add(Y,{name:"inspect/node-detail"}),t.add(Z,{name:"inspect/trace-log"});let V=d(!1,{name:"meta/debug"});t.add(V,{name:"meta/debug"});let $=o([V,u],([e,a])=>e?H(t.describe()):"",{name:"meta/shell-mermaid"});t.add($,{name:"meta/shell-mermaid"});let A=d("",{name:"layout/code-text"});if(t.add(A,{name:"layout/code-text"}),m){let e=new Map,a=o([P],([r])=>{let i=r;if(!i)return new Map;let s=new Map;for(let[c]of Object.entries(i.nodes)){let f=T(c,M,m,e),v=k(f,1/0,m,M,e),y=v.lines.reduce((ne,ae)=>Math.max(ne,ae.width),0),te=v.lineCount*20;s.set(c,{width:y,height:te})}return s},{name:"layout/graph-labels",equals:(r,i)=>{if(r===i)return!0;let s=r,c=i;if(s.size!==c.size)return!1;for(let[f,v]of s){let y=c.get(f);if(!y||y.width!==v.width||y.height!==v.height)return!1}return!0}}),n=o([A,C],([r,i])=>{let s=r;if(!s)return{lineCount:0,lines:[]};let c=T(s,M,m,e),f=i-40;return k(c,Math.max(100,f),m,M,e)},{name:"layout/code-lines"}),l=o([a],([r])=>{let i=r;if(i.size===0)return 200;let s=0;for(let{width:c}of i.values())c>s&&(s=c);return Math.max(200,Math.round(s+80))},{name:"layout/side-width-hint"});t.add(a,{name:"layout/graph-labels"}),t.add(n,{name:"layout/code-lines"}),t.add(l,{name:"layout/side-width-hint"})}let ee=0;return{graph:t,setMainRatio(e){t.set("pane/main-ratio",w(e))},setSideSplit(e){t.set("pane/side-split",w(e))},setFullscreen(e){t.set("pane/fullscreen",e)},setViewportWidth(e){t.set("viewport/width",Math.max(0,e))},setHoverTarget(e){t.set("hover/target",e)},setDemoGraph(e){t.set("demo/graph-ref",e)},bumpGraphTick(){t.set("demo/graph-tick",++ee)},selectNode(e){t.set("inspect/selected-node",e)},setMetaDebug(e){t.set("meta/debug",e)},setCodeText(e){t.set("layout/code-text",e)},batch(e){O(e)},destroy(){t.destroy()}}}export{ie as a,oe as b};
@@ -1 +0,0 @@
1
- import{b as y,c as b}from"./chunk-CK2E7BTU.js";import{b as w}from"./chunk-QYADASLV.js";var D={};w(D,{useStore:()=>k,useSubscribe:()=>N,useSubscribeRecord:()=>A});import{computed as m,getCurrentScope as l,isRef as g,onScopeDispose as i,readonly as K,shallowRef as R,watch as x}from"vue";function N(e){let t=R(e.cache),c=e.subscribe(()=>{t.value=e.cache});return l()?i(()=>c()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Vue scope \u2014 subscription will not be auto-disposed."),K(t)}function k(e){let t=R(e.cache),c=e.subscribe(()=>{t.value=e.cache});return l()?i(()=>c()):typeof console<"u"&&console.warn("[graphrefly-ts] useStore called outside a Vue scope \u2014 subscription will not be auto-disposed."),m({get:()=>t.value,set:o=>{e.down([[b],[y,o]])}})}function A(e,t){let c=R({}),o=new Map;function h(){let s={};for(let[u,n]of o)s[u]={...n.values};c.value=s}function v(s){for(let n of o.values())for(let r of n.subs)r();o.clear();for(let n of s){let r=t(n),T=Object.keys(r),a={},p=[];for(let f of T){let d=r[f];a[f]=d.cache;let S=d.subscribe(()=>{a[f]=d.cache,h()});p.push(S)}o.set(n,{subs:p,values:a})}let u={};for(let[n,r]of o)u[n]={...r.values};c.value=u}return x(()=>[...(typeof e=="function"?e():g(e)?e.value:e)??[]],s=>v(s??[]),{immediate:!0}),l()?i(()=>{for(let s of o.values())for(let u of s.subs)u();o.clear()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Vue scope \u2014 subscription will not be auto-disposed."),K(c)}export{N as a,k as b,A as c,D as d};
@@ -1 +0,0 @@
1
- import{b as G,c as F}from"./chunk-CUNIRONA.js";import{a as A}from"./chunk-4YAN45KM.js";import{a as q}from"./chunk-L6NSJVJZ.js";import{j as I}from"./chunk-626TESAC.js";import{b as E}from"./chunk-JQFH2DV6.js";import{C as M}from"./chunk-V5A7M7RJ.js";import{E as d,G as o,H as O,m as S}from"./chunk-LYCLF26R.js";import{b as V}from"./chunk-QYADASLV.js";var $={};V($,{contentModerationGraph:()=>Q,dataQualityGraph:()=>T,issueTrackerGraph:()=>B,observabilityGraph:()=>D});function r(u,a){return q("domain_template",u,a)}function D(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=[{name:"errors",classify:e=>C(e,"error")},{name:"traces",classify:e=>C(e,"trace")},{name:"metrics",classify:e=>C(e,"metric")}],m=a.branches??h,y=m.map(e=>({name:e.name,classify:e.classify})),c=A("stratify",a.source,y);n.mount("stratify",c);let k=m.map(e=>{try{let i=n.resolve(`stratify::branch/${e.name}`);return o([i],([x])=>x,{initial:null})}catch{return d(null)}}),l=a.correlate??(e=>e),_=o(k,e=>l(e),{meta:r("observability",{stage:"correlate"})});n.add(_,{name:"correlate"});let N=a.sloCheck??(()=>({pass:!0})),w=o([_],e=>e[0],{meta:r("observability",{stage:"slo_value"})}),f=o([w],e=>N(e[0]),{meta:r("observability",{stage:"slo_verified"})});n.add(w,{name:"slo_value"}),n.add(f,{name:"slo_verified"});let v=a.weights??m.map(()=>1),b=k.map(e=>o([e],i=>i[0]!=null?1:0)),p=v.map(e=>d(e));for(let e=0;e<b.length;e++)n.add(b[e],{name:`__signal_${e}`}),n.add(p[e],{name:`__weight_${e}`});let t=F(b,p);n.add(t,{name:"alerts"});let g=o([t,f],e=>({scored:e[0],slo:e[1]}),{meta:r("observability",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:r("observability",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let s=o([f],e=>{let i=e[0];return i&&i.pass===!1?i:null},{meta:r("observability",{stage:"feedback_condition"})});return n.add(s,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??5}),n}function B(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=0,m=e=>({id:`issue-${++h}`,title:String(e),severity:1,source:"unknown",raw:e}),y=a.extract??m,c=o([a.source],e=>y(e[0]),{meta:r("issue_tracker",{stage:"extract"})});n.add(c,{name:"extract"});let k=a.verify??(()=>({valid:!0})),l=o([c],e=>{let i=e[0];return{issue:i,verification:k(i)}},{meta:r("issue_tracker",{stage:"verify"})});n.add(l,{name:"verify"});let _=d([],{meta:r("issue_tracker",{stage:"known_patterns"})});n.add(_,{name:"known_patterns"});let N=a.detectRegression??(()=>({regression:!1})),w=o([c,_],e=>{let i=e[0],x=e[1];return{issue:i,regression:N(i,x)}},{meta:r("issue_tracker",{stage:"regression"})});n.add(w,{name:"regression"});let f=o([c],e=>e[0]?.severity??0),v=o([w],e=>e[0]?.regression?2:0);n.add(f,{name:"__severity_signal"}),n.add(v,{name:"__regression_signal"});let b=d(1),p=d(1.5);n.add(b,{name:"__severity_weight"}),n.add(p,{name:"__regression_weight"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([l,w,t],e=>({verified:e[0],regression:e[1],priority:e[2]}),{meta:r("issue_tracker",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:r("issue_tracker",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let s=o([l],e=>{let i=e[0];if(i){let x=i.verification;if(x&&x.valid===!1)return i}return null},{meta:r("issue_tracker",{stage:"feedback_condition"})});return n.add(s,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??3}),n}function Q(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=s=>({label:"review",confidence:.5,original:s}),m=a.classify??h,y=o([a.source],s=>m(s[0]),{meta:r("content_moderation",{stage:"classify"})});n.add(y,{name:"classify"});let c=A("stratify",y,[{name:"safe",classify:s=>s.label==="safe"},{name:"review",classify:s=>s.label==="review"},{name:"block",classify:s=>s.label==="block"}]);n.mount("stratify",c);let k=E([],{name:"review_queue",maxSize:a.maxQueueSize});n.add(k.entries,{name:"review_queue"});let l;try{l=n.resolve("stratify::branch/review")}catch{l=d(null),n.add(l,{name:"__review_fallback"})}let _=O([l],s=>{let e=s[0];e&&k.append(e)});n.add(_,{name:"__review_accumulator"}),n.addDisposer(M(_));let N=d({},{meta:r("content_moderation",{stage:"policy",access:"both",description:"Moderation policy rules \u2014 updated via feedback"})});n.add(N,{name:"policy"});let w=a.weights??[.1,1,2],f=o([y],s=>s[0]?.confidence??0),v=o([y],s=>{let e=s[0];return e?e.label==="block"?w[2]:e.label==="review"?w[1]:w[0]:0});n.add(f,{name:"__confidence_signal"}),n.add(v,{name:"__severity_signal"});let b=d(1),p=d(1);n.add(b,{name:"__w_confidence"}),n.add(p,{name:"__w_severity"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([y,t],s=>({classification:s[0],priority:s[1]}),{meta:r("content_moderation",{stage:"output"})});n.add(g,{name:"output"});let R=o([k.entries,N],s=>{let e=s[0];if(e&&e.length>0){let i=e[e.length-1];if(i&&i.falsePositive)return i}return null},{meta:r("content_moderation",{stage:"feedback_condition"})});return n.add(R,{name:"feedback_condition"}),G(n,"feedback_condition","policy",{maxIterations:a.maxFeedbackIterations??5}),n}function T(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=a.validate??(t=>({valid:!0,errors:[],record:t})),m=o([a.source],t=>t[0]!=null?h(t[0]):void 0,{meta:r("data_quality",{stage:"validate"})});n.add(m,{name:"validate"});let y=a.detectAnomaly??(t=>({anomaly:!1,score:0,record:t})),c=o([a.source],t=>t[0]!=null?y(t[0]):void 0,{meta:r("data_quality",{stage:"anomaly"})});n.add(c,{name:"anomaly"});let k=d(null,{meta:r("data_quality",{stage:"baseline",description:"Rolling baseline for drift detection"})});n.add(k,{name:"baseline"});let l=O([m],t=>{let g=t[0];g?.valid&&S(()=>{k.emit(g.record)})});n.add(l,{name:"__baseline_updater"}),M(l);let _=a.detectDrift??(()=>({drift:!1})),N=o([a.source,k],t=>_(t[0],t[1]),{meta:r("data_quality",{stage:"drift"})});n.add(N,{name:"drift"});let w=a.suggest??(()=>null),f=o([m,c],t=>w({validation:t[0],anomaly:t[1]}),{meta:r("data_quality",{stage:"remediate"})});n.add(f,{name:"remediate"});let v=o([m,c,N,f],t=>({validation:t[0],anomaly:t[1],drift:t[2],remediation:t[3]}),{meta:r("data_quality",{stage:"output"})});n.add(v,{name:"output"});let b=d([],{meta:r("data_quality",{stage:"validation_rules"})});n.add(b,{name:"validation_rules"});let p=o([c],t=>{let g=t[0];return g?.anomaly?g:null},{meta:r("data_quality",{stage:"feedback_condition"})});return n.add(p,{name:"feedback_condition"}),G(n,"feedback_condition","validation_rules",{maxIterations:a.maxFeedbackIterations??3}),n}function C(u,a){if(u==null||typeof u!="object")return!1;let n=u;return n.type===a||n.kind===a}export{D as a,B as b,Q as c,T as d,$ as e};
@@ -1 +0,0 @@
1
- import{c as O,f as V,h as j}from"./chunk-FDQGFWLF.js";import{f as B,m as K}from"./chunk-V5A7M7RJ.js";import{p as N}from"./chunk-LYCLF26R.js";import{b as M,i as L,j as $}from"./chunk-CK2E7BTU.js";import{b as J}from"./chunk-QYADASLV.js";var G={};J(G,{processInstanceKeyOf:()=>X,processManager:()=>Z});var X=i=>i.correlationId;function D(i){if(i==null)return Promise.resolve(void 0);let p=K(i);return new Promise((s,v)=>{let c=!1,m,r=()=>{m&&m()};m=p.subscribe(a=>{if(!c)for(let o of a){if(o[0]===M){c=!0,Promise.resolve().then(r),s(o[1]);return}if(o[0]===$){c=!0,Promise.resolve().then(r),v(o[1]);return}if(o[0]===L){c=!0,Promise.resolve().then(r),s(void 0);return}}})})}async function Y(i,p,s,v,c){let m;for(let r=0;r<=v;r++){if(r>0){let a=c[Math.min(r-1,c.length-1)]??0;a>0&&await new Promise(o=>setTimeout(o,a))}try{return await D(i(p,s))}catch(a){m=a}}return{outcome:"failure",error:m}}function Z(i,p,s){let v=s.retryMax??0,c=s.backoffMs??[0],m=1024,r=new Map,a=new Set,o=new Map,b=`${p}_process_instances`,C=`${p}_process_seq`;if(i.tryResolve(b)!==void 0||i.tryResolve(C)!==void 0)throw new Error(`processManager: name "${p}" is already in use on this CQRS graph (collides on "${b}" / "${C}"). Pick a different name or destroy the previous CQRS graph before re-creating the manager.`);let R=O({name:b,retainedLimit:m,graph:i}),Q=j(i,C,0),y=V(()=>{},{audit:R,seq:Q,freeze:!0,...s.handlerVersion!==void 0?{handlerVersion:s.handlerVersion}:{},onSuccess:([e,t,n,d],g,{t_ns:u,seq:f})=>({correlationId:e,state:t,status:n,startedAt:o.get(e)??u,updatedAt:u,t_ns:u,seq:f??0,...d!==void 0?{reason:d}:{}})}),_=`_process_${p}_started`;i.event(_),s.persistence?.eventStorage&&i.attachEventStorage(s.persistence.eventStorage);async function k(e,t,n,d){if(a.delete(e),r.delete(e),o.delete(e),s.compensate)try{await D(s.compensate(t,n)),y(e,t,"compensated",d)}catch{y(e,t,"errored",void 0)}else y(e,t,"errored",void 0)}async function z(e,t){if(a.has(e)){if(t.outcome==="failure"){let n=r.get(e)??s.initial;await k(e,n,t.error);return}if(t.outcome==="success"){if(r.set(e,t.state),t.emit)for(let n of t.emit)try{i._appendEvent(n.type,n.payload,{correlationId:e,aggregateId:e})}catch{}if(y(e,t.state,"running",void 0),s.isTerminal?.(t.state)){a.delete(e),r.delete(e),o.delete(e),y(e,t.state,"terminated",void 0);return}if(t.schedule){let{afterMs:n,eventType:d}=t.schedule,g,u=B(n),f=l=>{for(let T of l)if(T[0]===M){if(g?g():queueMicrotask(()=>g?.()),!a.has(e))return;let h=r.get(e);if(h===void 0)return;let S=s.steps[d];if(!S)return;let w={type:d,payload:null,timestampNs:N(),seq:Number.NaN,correlationId:e,aggregateId:e};q(e,S,h,w)}};g=u.subscribe(f)}return}if(t.outcome==="terminate"){if(r.set(e,t.state),t.emit)for(let n of t.emit)try{i._appendEvent(n.type,n.payload,{correlationId:e,aggregateId:e})}catch{}a.delete(e),r.delete(e),o.delete(e),y(e,t.state,"terminated",void 0)}}}let E=new Map;function q(e,t,n,d){let u=(E.get(e)??Promise.resolve()).then(async()=>{let f=r.get(e);if(f===void 0||!a.has(e))return;let l;try{l=await Y(t,f,d,v,c)}catch(T){await k(e,r.get(e)??s.initial,T);return}await z(e,l)});E.set(e,u),u.finally(()=>{E.get(e)===u&&E.delete(e)})}let P=!1,x=[];for(let e of s.watching){let t=i.event(e),n=0;n=(t.cache??[]).length;let g=t.subscribe(u=>{for(let f of u){if(f[0]!==M)continue;let l=f[1];if(l.length<=n)continue;let T=l.slice(n);n=l.length;for(let h of T){let S=h.correlationId;if(S===void 0||!a.has(S))continue;let w=s.steps[e];if(!w)continue;let A=r.get(S);A!==void 0&&q(S,w,A,h)}}});x.push(g)}function F(e,t){if(P||a.has(e))return;let n=N();o.set(e,n),r.set(e,s.initial),a.add(e);try{i._appendEvent(_,t??null,{correlationId:e,aggregateId:e})}catch{}y(e,s.initial,"running",void 0)}function U(e,t){if(P||!a.has(e))return;let n=r.get(e)??s.initial;k(e,n,new Error(`cancelled: ${t??"no reason given"}`),t)}function W(e){return r.get(e)}function H(){if(!P){P=!0;for(let e of x)try{e()}catch{}x.length=0}}return{instances:R,audit:R,start:F,cancel:U,getState:W,dispose:H}}export{X as a,Z as b,G as c};
@@ -1 +0,0 @@
1
- import{c as $,g as _}from"./chunk-FDQGFWLF.js";import{a as L}from"./chunk-L6NSJVJZ.js";import{j as F}from"./chunk-626TESAC.js";import{b as z}from"./chunk-35JTVPOX.js";import{D as j,E as G,G as D,m as E,p as B}from"./chunk-LYCLF26R.js";import{b as P,d as S,i as I,j as K}from"./chunk-CK2E7BTU.js";import{b as ie}from"./chunk-QYADASLV.js";var se={};ie(se,{PipelineGraph:()=>x,decisionKeyOf:()=>q,pipelineGraph:()=>W});function N(y,t){return L("orchestration",y,t)}var q=y=>y.action,x=class extends F{constructor(t,i){super(t,i)}task(t,i,e={}){let a=(e.deps??[]).map(c=>this._resolveStep(c)),p=D(a,i,{name:t,describeKind:"derived",meta:N("task",e.meta)});return this.add(p,{name:t}),p}classify(t,i,e,a={}){let p=this._resolveStep(i),c=D([p],([d])=>{try{return{tag:e(d),value:d}}catch(f){return{tag:"error",value:d,error:f}}},{name:t,describeKind:"derived",meta:N("classify",a.meta)});return this.add(c,{name:t}),c}combine(t,i,e={}){let a=Object.keys(i),p=a.map(d=>this._resolveStep(i[d])),c=D(p,d=>{let f={};for(let s=0;s<a.length;s++)f[a[s]]=d[s];return f},{name:t,describeKind:"derived",meta:N("combine",e.meta)});return this.add(c,{name:t}),c}approvalGate(t,i,e={}){let a=e.maxPending??1e3;if(a<1&&a!==Number.POSITIVE_INFINITY)throw new RangeError("approvalGate: maxPending must be >= 1");let p=e.startOpen??!1;typeof i!="string"&&this.nameOf(i)===void 0&&this.add(i,{name:`${t}/source`});let c=this._resolveStep(i),d=new F(`${t}_state`),f=G([],{name:"pending",equals:()=>!1}),s=G(p,{name:"isOpen"}),R=D([f],([n])=>n.length,{name:"count"}),T=G(0,{name:"droppedCount"}),u=$({name:"decisions",retainedLimit:1024,graph:d});d.add(f,{name:"pending"}),d.add(s,{name:"isOpen"}),d.add(R,{name:"count"}),d.add(T,{name:"droppedCount"}),this.mount(`${t}_state`,d);let l=[],v=!1,k=!1,w=p,M=s.subscribe(n=>{for(let o of n)o[0]===P&&(w=o[1])});this.addDisposer(M);function A(){f.emit([...l])}function C(n,o,r){u.append({action:n,t_ns:B(),...o!==void 0?{items:o,count:o.length}:{},...r!==void 0?{unflushed:r}:{},...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}function U(n){if(l.push(n),l.length>a){let o=l.shift();T.emit(T.cache+1),C("drop",[o])}A()}function O(n){let o=l.splice(0,n);return A(),o}let b=j([c],(n,o,r)=>{let h=r.terminalDeps[0];if(h!==void 0){v=!0;let g=l.length;l=[],A(),C("teardown",void 0,g),o.down(h===!0?[[I]]:[[K,h]]);return}let m=n[0];if(m==null||m.length===0){o.down([[S]]);return}for(let g of m)w?o.emit(g):(U(g),o.down([[S]]))},{name:t,describeKind:"derived",meta:N("approval_gate",e.meta)});if(this.add(b,{name:t}),e.approver!=null){e.approver.cache&&(s.emit(!0),w=!0,e.onceOnly&&(k=!0));let o=e.approver.subscribe(r=>{for(let h of r){if(h[0]!==P)continue;let m=!!h[1];if(m&&!w){if(e.onceOnly){if(k)continue;k=!0}E(()=>{s.emit(!0);let g=O(l.length);C("open",g);for(let te of g){if(v)break;b.emit(te)}})}else if(!m&&w){if(e.onceOnly&&k)continue;E(()=>{s.emit(!1),C("close")})}}});this.addDisposer(o)}let V=n=>{if(v)throw new Error(`approvalGate: ${n}() called after the gate was torn down`)},Y=(n=1)=>{V("approve");let o=O(n);for(let r of o){if(v)break;b.emit(r)}},H=(n=1)=>{V("reject"),O(n)},J=(n,o=1)=>{V("modify");let r=[...l],h=O(o);for(let m=0;m<h.length&&!v;m++)b.emit(n(h[m],m,r))},Q=()=>{V("open"),s.emit(!0);let n=O(l.length);for(let o of n){if(v)break;b.emit(o)}},X=()=>{V("close"),!(e.onceOnly&&k)&&s.emit(!1)},Z=_(Y,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"approve",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ee=_(H,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"reject",count:n[0]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),ne=_(J,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"modify",count:n[1]??1,t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),re=_(Q,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"open",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})}),oe=_(X,{audit:u,freeze:!1,onSuccess:(n,o,r)=>({action:"close",t_ns:r.t_ns,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}}),onFailure:(n,o,r)=>({action:"drop",t_ns:r.t_ns,errorType:r.errorType,...e.handlerVersion!=null?{handlerVersion:e.handlerVersion}:{}})});return this.addDisposer(R.subscribe(()=>{})),{node:b,pending:f,count:R,isOpen:s,droppedCount:T,decisions:u,audit:u,approve:Z,reject:ee,modify:ne,open:re,close:oe}}approval(t,i,e,a={}){return this.approvalGate(t,i,{...a,approver:e,maxPending:1})}catch(t,i,e,a={}){let p=this._resolveStep(i),c=a.on??"errored",d=j([p],(f,s,R)=>{let T=R.terminalDeps[0];if(T!==void 0){let l=T===!0?{kind:"completed"}:{kind:"errored",error:T};if(c==="terminal"||c===l.kind){s.emit(e(l,s));return}s.down(l.kind==="completed"?[[I]]:[[K,l.error]]);return}let u=f[0];if(u==null||u.length===0){s.down([[S]]);return}for(let l of u)s.emit(l)},{name:t,describeKind:"derived",completeWhenDepsComplete:a.completeWhenDepsComplete??!(c==="completed"||c==="terminal"),errorWhenDepsError:!(c==="errored"||c==="terminal"),meta:N("catch",a.meta)});return this.add(d,{name:t}),d}_resolveStep(t){if(typeof t=="string")return this.resolve(t);if(this.nameOf(t)===void 0)throw new Error(`PipelineGraph "${this.name}": Node dep is not registered. Pass a string path or call graph.add(node) first.`);return t}};function W(y,t){let i=new x(y,t),{factory:e,factoryArgs:a,...p}=t??{};return i.tagFactory("pipelineGraph",z(p)),i}export{q as a,x as b,W as c,se as d};
@@ -1 +0,0 @@
1
- import{C as O}from"./chunk-V5A7M7RJ.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 +0,0 @@
1
- import{b as v}from"./chunk-KRH66M4O.js";import{i as y}from"./chunk-CLD3F4R5.js";import{G as x}from"./chunk-OFZG3TB3.js";import{d as S}from"./chunk-VJLMUKOI.js";import{d as O}from"./chunk-VIMF6LGM.js";import{d as k}from"./chunk-6QZNQS5B.js";import{d as A}from"./chunk-GPW2V3RE.js";import{b as N}from"./chunk-TPKQW72B.js";import{E as b,J as g,m as _}from"./chunk-LYCLF26R.js";import{b as a,c as p,i as h,j as m}from"./chunk-CK2E7BTU.js";import{b as f}from"./chunk-QYADASLV.js";var j={};f(j,{jotai:()=>v,nanostores:()=>y,nestjs:()=>x,react:()=>S,signals:()=>T,solid:()=>O,svelte:()=>k,vue:()=>A,zustand:()=>N});var T={};f(T,{Signal:()=>q});var s=[];function i(n){let e=n.cache;return n.subscribe(o=>{for(let[d,r]of o)d===a&&(e=r)})(),e}var u=class{_node;_equals;constructor(e,t){this._equals=t?.equals??Object.is,this._node=b(e,{...t,resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}set(e){this._equals(this.get(),e)||_(()=>{this._node.down([[p],[a,e]])})}},l=class{_node;constructor(e,t){this._node=g(o=>{s.push(o);try{return e()}finally{s.pop()}},{...t,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}},q={State:u,Computed:l,sub:(n,e)=>{let t=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,o=!0;return n._node.subscribe(d=>{for(let[r,c]of d){if(r===a){if(o){o=!1;continue}t.data?.(c)}r===m&&t.error?.(c),r===h&&t.complete?.()}})}};export{T as a,j as b};
@@ -1 +0,0 @@
1
- import{E as b,m as h}from"./chunk-LYCLF26R.js";import{b as p,c as l}from"./chunk-CK2E7BTU.js";var u=class{_version=0;_buf;constructor(e){this._buf=e?[...e]:[]}get version(){return this._version}get size(){return this._buf.length}at(e){if(!Number.isInteger(e))return;let n=e>=0?e:this._buf.length+e;if(!(n<0||n>=this._buf.length))return this._buf[n]}append(e){this._buf.push(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._buf.length;this._buf.length=n+e.length;for(let i=0;i<e.length;i++)this._buf[n+i]=e[i];this._version+=1}insert(e,n){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insert: index ${e} out of range [0, ${this._buf.length}]`);this._buf.splice(e,0,n),this._version+=1}insertMany(e,n){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insertMany: index ${e} out of range [0, ${this._buf.length}]`);n.length!==0&&(this._buf.splice(e,0,...n),this._version+=1)}pop(e){if(this._buf.length===0)throw new RangeError("pop from empty list");if(!Number.isInteger(e))throw new RangeError(`pop: index ${e} must be an integer`);let n=e>=0?e:this._buf.length+e;if(n<0||n>=this._buf.length)throw new RangeError(`pop: index ${e} out of range`);let[i]=this._buf.splice(n,1);return this._version+=1,i}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._version+=1,e)}toArray(){return[...this._buf]}};function y(d,e={}){let{name:n,versioning:i,backend:f}=e,t=f??new u(d),a=b(t.toArray(),{name:n,describeKind:"state",equals:(r,o)=>r===o,...i!=null?{versioning:i}:{}});function v(){let r=t.toArray();h(()=>{a.down([[l]]),a.down([[p,r]])})}function s(r){let o=t.version;try{return r()}finally{t.version!==o&&v()}}return{items:a,get size(){return t.size},at(r){return t.at(r)},append(r){s(()=>t.append(r))},appendMany(r){s(()=>t.appendMany(r))},insert(r,o){s(()=>t.insert(r,o))},insertMany(r,o){s(()=>t.insertMany(r,o))},pop(r=-1){return s(()=>t.pop(r))},clear(){s(()=>t.clear())},dispose(){}}}export{u as a,y as b};
@@ -1 +0,0 @@
1
- import{E as l,J as f}from"./chunk-LYCLF26R.js";import{b as m,j as d}from"./chunk-CK2E7BTU.js";import{b as p}from"./chunk-QYADASLV.js";var F={};p(F,{atom:()=>A});function A(s,n,e){if(typeof s=="function"){let t=s;return typeof n=="function"?b(t,n,e):b(t,void 0,n)}return v(s,n)}function c(s){let n=s.cache,e;if(s.subscribe(i=>{for(let[r,o]of i)r===m&&(n=o),r===d&&(e=o)})(),e)throw e;return n}function v(s,n){let e=l(s,{...n,resubscribable:!0,resetOnTeardown:!0});return{get:()=>e.status==="sentinel"?c(e):e.cache,set:t=>e.emit(t),update:t=>{let i=e.status==="sentinel"?c(e):e.cache;e.emit(t(i))},subscribe:t=>{let i=!0;return e.subscribe(r=>{for(let[o,a]of r)if(o===m){if(i){i=!1;continue}t(a)}})},meta:e.meta,_node:e}}function b(s,n,e){let t=f(r=>s(o=>{let a=o._node;return a.status==="sentinel"&&c(a),r(a)}),{...e,resubscribable:!0,resetOnTeardown:!0}),i={get:()=>t.status==="sentinel"?c(t):t.cache,subscribe:r=>{let o=!0;return t.subscribe(a=>{for(let[u,T]of a)if(u===m){if(o){o=!1;continue}r(T)}})},meta:t.meta,_node:t};if(n){let r=u=>u.get(),o=(u,T)=>u.set(T),a=i;return a.set=u=>n(r,o,u),a.update=u=>{let T=t.status==="sentinel"?c(t):t.cache;return n(r,o,u(T))},a}return i}export{A as a,F as b};
@@ -1 +0,0 @@
1
- import{a as I,b as P,c as V,d as _,f as j,g as w}from"./chunk-3G5U5QNE.js";import{a as C,b as D,c as $,d as R,g as A,h as S,i as N,j as h,k as T,l as F}from"./chunk-626TESAC.js";import{a as m,b as g,c as k,d as v,e as O,f as E,g as G,h as x}from"./chunk-LYCLF26R.js";import{b as u}from"./chunk-CK2E7BTU.js";import{b as H}from"./chunk-QYADASLV.js";var q={};H(q,{ENVELOPE_VERSION:()=>v,GRAPH_META_SEGMENT:()=>S,Graph:()=>h,JsonCodec:()=>m,SIZEOF_OVERHEAD:()=>C,SIZEOF_SYMBOL:()=>D,SNAPSHOT_VERSION:()=>N,createDagCborCodec:()=>g,createDagCborZstdCodec:()=>k,decodeEnvelope:()=>E,diffForWAL:()=>T,encodeEnvelope:()=>O,explainPath:()=>R,graphProfile:()=>A,reachable:()=>F,registerBuiltinCodecs:()=>G,replayWAL:()=>x,sizeof:()=>$,validateGraphObservability:()=>W,validateNoIslands:()=>M,watchTopologyTree:()=>L});function L(n,p){let o=new Map,c=(s,a)=>{if(o.has(s))return;let i={off:()=>{},prefix:a};o.set(s,i);let f=s.topology.subscribe(l=>{for(let t of l){if(t[0]!==u)continue;let e=t[1];if(p(e,s,a),e.kind==="added"&&e.nodeKind==="mount"){let r=s._mounts.get(e.name);if(r instanceof h){let d=`${a}${e.name}::`;c(r,d)}}else if(e.kind==="removed"&&e.nodeKind==="mount"){let r=`${a}${e.name}::`;for(let[d,y]of Array.from(o.entries()))d!==n&&y.prefix.startsWith(r)&&(y.off(),o.delete(d))}}});i.off=f;for(let[l,t]of s._mounts)if(t instanceof h){let e=`${a}${l}::`;c(t,e)}};return c(n,""),()=>{for(let s of o.values())s.off();o.clear()}}function M(n){let p=n.describe({detail:"minimal"}),o=Object.keys(p.nodes),c=new Set;for(let a of o){let i=p.nodes[a];if(!i)continue;let f=i.deps??[];for(let l of f)c.add(l)}let s=[];for(let a of o){let i=p.nodes[a];if(!i||a.startsWith("__internal__/"))continue;let l=(i.deps??[]).length,t=c.has(a);if(l===0&&!t){let e=i.type??"unknown";s.push({path:a,kind:e})}}return s.sort((a,i)=>a.path<i.path?-1:a.path>i.path?1:0),{ok:s.length===0,orphans:s,summary(){if(s.length===0)return"validateNoIslands: ok (no islands)";let a=s.slice(0,3).map(i=>`${i.path} (${i.kind})`).join(", ");return`validateNoIslands: ${s.length} island node(s) \u2014 ${a}${s.length>3?", \u2026":""}`}}}var K={json:n=>V(n),pretty:n=>w(n),mermaid:n=>_(n),"mermaid-url":n=>j(n),d2:n=>P(n),ascii:n=>I(n)};function W(n,p={}){let o=[],c=p.requireFound??!0;if(p.skipDescribe!==!0)try{let t=n.describe(),e=new Set(Object.keys(t.nodes)),r=[];for(let[d,y]of Object.entries(t.nodes))for(let b of y.deps)b!==""&&!e.has(b)&&r.push(`${d} \u2192 ${b}`);for(let d of t.edges)e.has(d.from)||r.push(`edge.from: ${d.from}`),e.has(d.to)||r.push(`edge.to: ${d.to}`);r.length>0?o.push({kind:"describe",ok:!1,reason:`describe() has ${r.length} dangling pointer(s); nodes \u2289 deps`,danglingDeps:r}):o.push({kind:"describe",ok:!0,nodeCount:e.size,edgeCount:t.edges.length})}catch(t){o.push({kind:"describe",ok:!1,reason:`describe() threw: ${t instanceof Error?t.message:String(t)}`})}if((p.formats?.length??0)>0){let t=n.describe();for(let e of p.formats)try{let r=K[e](t);typeof r!="string"||r.length===0?o.push({kind:"describe-format",ok:!1,format:e,reason:`${e} renderer returned empty or non-string output`}):o.push({kind:"describe-format",ok:!0,format:e,length:r.length})}catch(r){o.push({kind:"describe-format",ok:!1,format:e,reason:r instanceof Error?r.message:String(r)})}}for(let t of p.paths??[])try{n.resolve(t),o.push({kind:"observe",ok:!0,path:t})}catch(e){o.push({kind:"observe",ok:!1,path:t,reason:e instanceof Error?e.message:String(e)})}for(let[t,e]of p.pairs??[])try{let r=n.explain(t,e);c&&r.found===!1?o.push({kind:"explain",ok:!1,from:t,to:e,reason:`explain(${t} \u2192 ${e}) found no path${r.reason?`: ${r.reason}`:""}`}):o.push({kind:"explain",ok:!0,from:t,to:e,found:r.found,steps:r.steps.length})}catch(r){o.push({kind:"explain",ok:!1,from:t,to:e,reason:r instanceof Error?r.message:String(r)})}let s=o.filter(t=>!t.ok),a=s.length===0,i=p.paths?.length??0,f=p.pairs?.length??0,l=p.formats?.length??0;return{ok:a,checks:o,failures:s,summary(){let t=[p.skipDescribe===!0?null:"describe",l>0?`${l} format${l===1?"":"s"}`:null,i>0?`${i} observe path${i===1?"":"s"}`:null,f>0?`${f} explain pair${f===1?"":"s"}`:null].filter(r=>r!=null),e=t.length>0?t.join(", "):"describe-only";return a?`validateGraphObservability: OK (${e})`:`validateGraphObservability: ${s.length} failure(s) across ${e}`}}}export{L as a,M as b,W as c,q as d};
@@ -1 +0,0 @@
1
- function e(n,r,t){return{[n]:!0,[`${n}_type`]:r,...t??{}}}export{e as a};
@@ -1 +0,0 @@
1
- import{a as Y,b,c as M,d as S,e as R,f as N,g as L,h as k,i as C,j as _,k as P,l as he,n as se,q as ie,r as fe,s as pe,t as _e,u as re}from"./chunk-CK2E7BTU.js";var Ce={name:"json",version:1,contentType:"application/json",encode(n){let e=JSON.stringify(n);return new TextEncoder().encode(e)},decode(n,e){let t=new TextDecoder().decode(n);return JSON.parse(t)}};function $e(n){return{name:"dag-cbor",version:1,contentType:"application/dag-cbor",encode:e=>n.encode(e),decode:(e,t)=>n.decode(e)}}function je(n,e){return{name:"dag-cbor-zstd",version:1,contentType:"application/dag-cbor+zstd",encode:t=>e.compressSync(n.encode(t)),decode:(t,s)=>n.decode(e.decompressSync(t))}}var oe=1,ge=4;function ze(n,e){let t=new TextEncoder().encode(n.name);if(t.length===0||t.length>255)throw new Error(`encodeEnvelope: codec name "${n.name}" encodes to ${t.length} bytes (must be 1\u2013255)`);let s=n.version;if(!Number.isInteger(s)||s<0||s>65535)throw new Error(`encodeEnvelope: codec.version ${s} out of u16 range (expected integer 0\u201365535)`);let i=2+t.length+2+e.length;if(i>4294967295)throw new Error(`encodeEnvelope: total envelope size ${i} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let r=new Uint8Array(i),a=0;return r[a++]=oe,r[a++]=t.length,r.set(t,a),a+=t.length,r[a++]=s>>>8&255,r[a++]=s&255,r.set(e,a),r}function qe(n,e){if(n.length<ge)throw new Error(`decodeEnvelope: bytes too short (${n.length} < ${ge})`);let t=0,s=n[t++];if(s!==oe)throw new Error(`decodeEnvelope: unsupported envelope version ${s} (expected ${oe})`);let i=n[t++];if(i===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+i+2>n.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+i+2} bytes, have ${n.length})`);let r=new TextDecoder().decode(n.subarray(t,t+i));t+=i;let a=(n[t]<<8|n[t+1])>>>0;t+=2;let o=n.subarray(t),d=e.lookupCodec(r);if(d==null)throw new Error(`decodeEnvelope: codec "${r}" not registered (envelope codec_v=${a})`);return{codec:d,codecVersion:a,payload:o}}function ye(n){n.registerCodec(Ce)}function Ke(n){if(n.length===0)throw new Error("WAL is empty \u2014 need at least one full snapshot");let e=n[0];if(e.mode!=="full")throw new Error("WAL must start with a full record carrying a baseline snapshot");let t=JSON.parse(JSON.stringify(e.snapshot)),s=e.seq;for(let i=1;i<n.length;i++){let r=n[i];if(r.seq<=s)throw new Error(`WAL chain broken at index ${i}: seq=${r.seq} must exceed prev seq=${s}`);if(r.mode==="full"){t=JSON.parse(JSON.stringify(r.snapshot)),s=r.seq;continue}let a=r.diff;for(let d of a.nodesRemoved)delete t.nodes[d];let o=a.nodesAddedFull;if(o!=null)for(let[d,l]of Object.entries(o))t.nodes[d]=JSON.parse(JSON.stringify(l));for(let d of a.nodesChanged){let l=t.nodes[d.path];l!=null&&(l[d.field]=d.to)}s=r.seq}return t}var De={type:"system",id:""};function J(n){if(n==null)return De;let{type:e,id:t,...s}=n;return{type:e??"system",id:t??"",...s}}var D=0,U=!1,A=[],E=[],O=[],W=[];function me(){return D>0||U}function be(){return D>0}function ve(n){D>0?W.push(n):n()}function Xe(n){D+=1;let e=!1;try{n()}catch(t){throw e=!0,t}finally{if(D-=1,D===0)if(e){if(!U){let t=W.splice(0);for(let s of t)try{s()}catch{}A.length=0,E.length=0,O.length=0}}else Oe()}}function Oe(){let n=!U;n&&(U=!0);let e=[],t=0;try{for(;A.length>0||E.length>0||O.length>0||n&&W.length>0;){if(n&&W.length>0){let r=W.splice(0);for(let a of r)try{a()}catch(o){e.push(o)}continue}if(t+=1,t>1e3)throw A.length=0,E.length=0,O.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let i=(A.length>0?A:E.length>0?E:O).splice(0);for(let r of i)try{r()}catch(a){e.push(a)}}}finally{n&&(U=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function X(n,e,t){if(e.length===0)return;if(e.length===1){let l=t(e[0][0]);if(l<3||!me()){n(e);return}(l>=5?O:l===4?E:A).push(()=>n(e));return}let s=e.length,i=s,r=s,a=s,o=0;for(;o<s&&t(e[o][0])<3;)o++;for(i=o;o<s&&t(e[o][0])===3;)o++;for(r=o;o<s&&t(e[o][0])===4;)o++;a=o;let d=me();if(i>0){let l=e.slice(0,i);n(l)}if(r>i){let l=e.slice(i,r);d?A.push(()=>n(l)):n(l)}if(a>r){let l=e.slice(r,a);d?E.push(()=>n(l)):n(l)}if(s>a){let l=e.slice(a,s);d?O.push(()=>n(l)):n(l)}}function Qe(){return Math.trunc(performance.now()*1e6)}function we(){return Date.now()*1e6}var Z=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let s=this._messageTypes.get(t);return s!=null?s.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=e}registerMessageType(e,t){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:t.tier,wireCrossing:t.wireCrossing??t.tier>=3,metaPassthrough:t.metaPassthrough??!0}),this}messageTier(e){let t=this._messageTypes.get(e);return t!=null?t.tier:1}isWireCrossing(e){let t=this._messageTypes.get(e);return t!=null?t.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let t=this._messageTypes.get(e);return t!=null?t.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}};function xe(n){n.registerMessageType(Y,{tier:0,wireCrossing:!1}),n.registerMessageType(M,{tier:1,wireCrossing:!1}),n.registerMessageType(R,{tier:1,wireCrossing:!1,metaPassthrough:!1}),n.registerMessageType(N,{tier:2,wireCrossing:!1}),n.registerMessageType(L,{tier:2,wireCrossing:!1}),n.registerMessageType(b,{tier:3,wireCrossing:!0}),n.registerMessageType(S,{tier:3,wireCrossing:!0}),n.registerMessageType(C,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(_,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(k,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var F=class extends Error{actor;action;nodeName;constructor(e,t){super(t??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}};function Te(n){return Array.isArray(n)?[...n]:[n]}function Fe(n,e){return n.has(e)||n.has("*")}function Ge(n){let e=[];return n((i,r)=>{e.push({kind:"allow",actions:new Set(Te(i)),where:r?.where??(()=>!0)})},(i,r)=>{e.push({kind:"deny",actions:new Set(Te(i)),where:r?.where??(()=>!0)})}),(i,r)=>{let a=!1,o=!1;for(let d of e)Fe(d.actions,r)&&d.where(i)&&(d.kind==="deny"?a=!0:o=!0);return a?!1:o}}function st(n){return Ge((e,t)=>{for(let s of n){let i=s.actorType==null?null:new Set(Array.isArray(s.actorType)?s.actorType:[s.actorType]),r=s.actorId==null?null:new Set(Array.isArray(s.actorId)?s.actorId:[s.actorId]),a=Object.entries(s.claims??{}),o=d=>{if(i!==null&&!i.has(String(d.type))||r!==null&&!r.has(String(d.id??"")))return!1;for(let[l,c]of a)if(d[l]!==c)return!1;return!0};s.effect==="deny"?t(s.action,{where:o}):e(s.action,{where:o})}})}var Ie=["human","llm","wallet","system"];function it(n){let e=Ie.filter(t=>n({type:t,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(t=>t==="human"||t==="llm"||t==="system")?"both":e.length===1?e[0]:e.join("+")}function ae(n){if(n===void 0)return null;if(typeof n=="number"){if(!Number.isFinite(n))throw new TypeError(`Cannot hash non-finite number: ${n}`);if(Number.isInteger(n)&&!Number.isSafeInteger(n))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${n}. Cross-language cid parity is not guaranteed for unsafe integers.`);return n}if(typeof n=="string"||typeof n=="boolean"||n===null)return n;if(Array.isArray(n))return n.map(ae);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=ae(n[t]);return e}return null}var He=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ve=new TextEncoder;function Le(n){let e=Ve.encode(n),t=e.length,s=t*8,i=t+9+63&-64,r=new Uint8Array(i);r.set(e),r[t]=128;let a=new DataView(r.buffer);a.setUint32(i-4,s>>>0,!1),a.setUint32(i-8,Math.floor(s/4294967296)>>>0,!1);let o=1779033703,d=3144134277,l=1013904242,c=2773480762,h=1359893119,p=2600822924,u=528734635,g=1541459225,T=new Uint32Array(64),m=(w,y)=>w>>>y|w<<32-y;for(let w=0;w<i;w+=64){for(let f=0;f<16;f++)T[f]=a.getUint32(w+f*4,!1);for(let f=16;f<64;f++){let H=T[f-15],V=T[f-2],K=m(H,7)^m(H,18)^H>>>3,ne=m(V,17)^m(V,19)^V>>>10;T[f]=T[f-16]+K+T[f-7]+ne>>>0}let y=o,G=d,I=l,ee=c,x=h,z=p,q=u,te=g;for(let f=0;f<64;f++){let H=m(x,6)^m(x,11)^m(x,25),V=x&z^~x&q,K=te+H+V+He[f]+T[f]>>>0,ne=m(y,2)^m(y,13)^m(y,22),Se=y&G^y&I^G&I,Re=ne+Se>>>0;te=q,q=z,z=x,x=ee+K>>>0,ee=I,I=G,G=y,y=K+Re>>>0}o=o+y>>>0,d=d+G>>>0,l=l+I>>>0,c=c+ee>>>0,h=h+x>>>0,p=p+z>>>0,u=u+q>>>0,g=g+te>>>0}let v=w=>w.toString(16).padStart(8,"0");return v(o)+v(d)+v(l)+v(c)+v(h)+v(p)+v(u)+v(g)}function de(n){let e=ae(n??null),t=JSON.stringify(e);return Le(t).slice(0,16)}function Pe(){let n=globalThis.crypto;if(n?.randomUUID)return n.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),t=e()+e()+e()+e();return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-${(parseInt(t.slice(16,17),16)&3|8).toString(16)}${t.slice(17,20)}-${t.slice(20,32)}`}function le(n,e,t){let s=t?.id??Pe();if(n===0)return{id:s,version:0};let r=(t?.hash??de)(e);return{id:s,version:0,cid:r,prev:null}}function Ne(n,e,t){n.version+=1,"cid"in n&&(n.prev=n.cid,n.cid=t(e))}function ot(n){return"cid"in n}var ke=()=>{},Ae=100;function Ee(n){return{node:n,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function ce(n){n.prevData=void 0,n.dirty=!1,n.involvedThisWave=!1,n.dataBatch.length=0,n.terminal=void 0}function Q(n){return n.length===0?n:typeof n[0]=="symbol"?[n]:n}var Ue=(n,e,t,s)=>{t.direction==="down-in"&&n._onDepMessage(t.depIndex,e)},We=(n,e,t,s)=>{let i=n;if(i._status==="completed"||i._status==="errored")return;let r=i._cached,a=r===void 0?[se]:[se,[b,r]];i._status==="dirty"&&a.push(P),X(e,a,i._config.tierOf)},B=new Z({onMessage:Ue,onSubscribe:We});xe(B);ye(B);function gt(n){if(B._isFrozen())throw new Error("configure() called after a node was created \u2014 the default GraphReFlyConfig is frozen. Call configure(...) at application startup, before any node factories run.");n(B)}var $=class n{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,s){this._config=s.config??B,this._config.onMessage,this._optsName=s.name,this._describeKind=s.describeKind,this._equals=s.equals??Object.is,this._resubscribable=s.resubscribable??!1,this._resetOnTeardown=s.resetOnTeardown??!1,this._autoComplete=s.completeWhenDepsComplete??!0,this._autoError=s.errorWhenDepsError??!0,this._pausable=s.pausable??!0,this._guard=s.guard,this._fn=t,this._partial=s.partial??!1,this._cached=s.initial!==void 0?s.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=s.versioningHash??this._config.defaultHashFn??de;let i=s.versioning??this._config.defaultVersioning;this._versioningLevel=i,this._versioning=i!=null?le(i,this._cached===void 0?void 0:this._cached,{id:s.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Ee);let r={};for(let[o,d]of Object.entries(s.meta??{})){let l={initial:d,name:`${s.name??"node"}:meta:${o}`,describeKind:"state",config:this._config};s.guard!=null&&(l.guard=s.guard),r[o]=new n([],void 0,l)}Object.freeze(r),this.meta=r,this._hasMeta=Object.keys(r).length>0;let a=this;this._actions={emit(o){a._emit([[b,o]])},down(o){a._emit(Q(o))},up(o){a._emitUp(Q(o))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let s=this._versioningLevel;if(s!=null&&e<=s)return;let i=t?.hash??this._hashFn;i!==this._hashFn&&(this._hashFn=i);let r=this._cached===void 0?void 0:this._cached,a=this._versioning,o=a?.id??t?.id,d=a?.version??0,l=le(e,r,{id:o,hash:i});l.version=d,this._versioning=l,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=J(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let s of this._extraGuards)if(!s(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,s=e?.actor!=null;if(!t&&!s)return;let i=J(e?.actor),r=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(i,r))throw new F({actor:i,action:r,nodeName:this.name});if(this._extraGuards!=null){for(let a of this._extraGuards)if(!a(i,r))throw new F({actor:i,action:r,nodeName:this.name})}this._lastMutation={actor:i,timestamp_ns:we()}}down(e,t){let s=Q(e);s.length!==0&&(this._checkGuard(t),this._emit(s))}emit(e,t){this._checkGuard(t),this._emit([[b,e]])}up(e,t){if(this._deps.length===0)return;let s=Q(e);if(s.length===0)return;this._checkGuard(t);let i=t??{internal:!0};this._validateUpTiers(s);for(let r of this._deps)r.node.up?.(s,i)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let s of e){let i=t(s[0]);if(i===3||i===4)throw new Error(`Node "${this.name}": tier-${i} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let d=J(t);if(!this._guard(d,"observe"))throw new F({actor:d,action:"observe",nodeName:this.name})}let i=this._isTerminal&&this._resubscribable;if(i){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)ce(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let r;try{r=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:i},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let a=this._isTerminal;if(this._sinkCount===1&&!a)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof r=="function")try{r()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let o=!1;return()=>{o||(o=!0,this._sinkCount-=1,this._removeSink(e),typeof r=="function"&&r(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[t]=this._sinks;this._sinks=t}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,t=0;try{for(let s=0;s<e;s++){let i=s,r=this._deps[s];r.unsub=ke,r.unsub=r.node.subscribe(a=>{if(r.unsub===null)return;let o=this._config.tierOf,d=!1;for(let l of a)o(l[0])>=3&&(d=!0),this._config.onMessage(this,l,{direction:"down-in",depIndex:i},this._actions);d&&this._maybeRunFnOnSettlement()}),t++}}catch(s){this._deps[t].unsub=null;for(let i=0;i<t;i++){let r=this._deps[i];if(r.unsub!=null){let a=r.unsub;r.unsub=null;try{a()}catch{}ce(r)}}throw this._dirtyDepCount=0,s}}_addDep(e){for(let i=0;i<this._deps.length;i++)if(this._deps[i].node===e)return i;let t=this._deps.length,s=Ee(e);if(this._deps.push(s),this._sinks==null)return t;s.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ie),s.unsub=ke;try{s.unsub=e.subscribe(i=>{if(s.unsub===null)return;let r=this._config.tierOf,a=!1;for(let o of i)r(o[0])>=3&&(a=!0),this._config.onMessage(this,o,{direction:"down-in",depIndex:t},this._actions);a&&this._maybeRunFnOnSettlement()})}catch(i){throw s.unsub=null,this._deps.pop(),this._dirtyDepCount--,i}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(s){this._emit([[_,this._wrapFnError("cleanup threw",s)]])}else if(t!=null&&typeof t=="object"){let s=t.deactivate;if(typeof s=="function")try{s()}catch(i){this._emit([[_,this._wrapFnError("cleanup.deactivate threw",i)]])}}for(let s of this._deps){if(s.unsub!=null){let i=s.unsub;s.unsub=null;try{i()}catch{}}ce(s)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,t){let s=this._deps[e],i=t[0];if(this._inspectorHooks!=null){let r={kind:"dep_message",depIndex:e,message:t};for(let a of this._inspectorHooks)a(r)}if(i!==Y){if(i===M){this._depDirtied(s);return}if(i===R){if(this._depInvalidated(s),this._cached===void 0)return;this._emit(pe);return}if(i===N||i===L){this._emit([t]);return}if(i===k){this._emit(re);return}if(i===b)this._depSettledAsData(s,t[1]);else if(i===S)this._depSettledAsResolved(s);else if(i===C)this._depSettledAsTerminal(s,!0);else if(i===_)this._depSettledAsTerminal(s,t[1]);else{this._emit([t]);return}if(!this._fn){(i===b||i===S)&&this._emit([t]),(i===C||i===_)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ie))}_depSettledAsData(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(t),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=t,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let t=this._deps[e];if(t.dataBatch.length===0&&t.prevData===void 0&&t.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(fe),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(t=>t.terminal!==void 0&&t.terminal!==!0);if(e!=null){this._autoError&&this._emit([[_,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(_e)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(a){this._emit([[_,this._wrapFnError("cleanup threw",a)]]);return}}else if(e!=null&&typeof e=="object"){let a=e.beforeRun;if(typeof a=="function"){e.beforeRun=void 0;try{a()}catch(o){this._emit([[_,this._wrapFnError("cleanup.beforeRun threw",o)]]);return}}}let t=this._deps.map(a=>a.involvedThisWave?a.dataBatch.length>0?[...a.dataBatch]:[]:void 0),s=this._deps.map(a=>a.prevData);for(let a=0;a<this._deps.length;a++){let o=t[a];o!=null&&o.length>0&&(this._deps[a].prevData=o[o.length-1])}let i=this._deps.map(a=>a.terminal),r={prevData:s,terminalDeps:i,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let a={kind:"run",batchData:t,prevData:s};for(let o of this._inspectorHooks)o(a)}this._isExecutingFn=!0;try{let a=this._fn(t,this._actions,r);if(typeof a=="function")this._cleanup=a;else if(a!=null&&typeof a=="object"){let o=a;(typeof o.beforeRun=="function"||typeof o.deactivate=="function"||typeof o.invalidate=="function")&&(this._cleanup=a)}}catch(a){this._emit([[_,this._wrapFnError("fn threw",a)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Ae?(this._rerunDepth=0,this._emit([[_,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Ae} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,t){let s=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${s}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[P,e[0]]:e;let s=!0,i=!1,r=!1,a=-1;for(let d of e){let l=t(d[0]);l<a&&(s=!1),l===3&&(i=!0),d[0]===M&&(r=!0),a=l}let o=e;if(!s){let d=e.map((l,c)=>({m:l,i:c,tier:t(l[0])}));d.sort((l,c)=>l.tier-c.tier||l.i-c.i),o=d.map(l=>l.m)}if(i&&!r&&this._status!=="dirty"){let d=0;for(;d<o.length&&t(o[d][0])===0;)d++;return d===0?[P,...o]:[...o.slice(0,d),P,...o.slice(d)]}return o}_emit(e){if(e.length===0)return;for(let o=0;o<e.length;o++){let d=e[o];if(d[0]===_&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let o=e.filter(d=>d[0]===k||d[0]===R);if(o.length===0)return;t=o}t=this._frameBatch(t);let i=null;for(let o=0;o<t.length;o++){let d=t[o],l=d[0];if(l!==N&&l!==L){i?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${l===N?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let h=d[1];if(l===N)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(h),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(h))c=!1;else if(this._pauseLocks.delete(h),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?i?.push(d):i==null&&(i=t.slice(0,o))}if(i!=null){if(i.length===0)return;t=i}if(this._hasMeta&&t.some(o=>o[0]===k))for(let o of Object.keys(this.meta))try{this.meta[o]._emit(re)}catch{}let{finalMessages:r,equalsError:a}=this._updateState(t);if(r.length>0&&this._config.inspectorEnabled){let o=this._config.globalInspector;if(o!=null)try{o({kind:"emit",node:this,messages:r})}catch{}}if(r.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let o=this._config.tierOf,d=[];for(let l of r)o(l[0])===3?this._pauseBuffer.push(l):d.push(l);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(r);a!=null&&this._emit([[_,a]])}_updateState(e){let t=this._config.tierOf,s,i,r=-1,a=0;for(let c of e)t(c[0])===3&&a++;let o=a<=1,d=-1;if(this._versioning!=null&&a>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===b){d=c;break}}for(let c=0;c<e.length;c++){let h=e[c],p=h[0];if(p===b){if(h.length>=2){let u=!1;if(o&&this._cached!==void 0)try{u=this._equals(this._cached,h[1])}catch(g){i=this._wrapFnError("equals threw",g),r=c;break}if(u){s==null&&(s=e.slice(0,c)),s.push(he),this._status="resolved";continue}this._cached=h[1],this._versioning!=null&&(d<0||c===d)&&Ne(this._versioning,h[1],this._hashFn)}this._status="settled",s?.push(h)}else if(s?.push(h),p===M)this._status="dirty";else if(p===S)this._status="resolved";else if(p===C){this._status="completed";{let u=this._config.rigorRecorder;if(u!=null)try{u.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===_){this._status="errored";{let u=this._config.rigorRecorder;if(u!=null)try{u.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===R){if(this._cached!==void 0){let g=this._config.rigorRecorder;if(g!=null)try{g.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let u=this._cleanup;if(typeof u=="function"){this._cleanup=void 0;try{u()}catch{}}else if(u!=null&&typeof u=="object"){let g=u.invalidate;if(typeof g=="function")try{g()}catch{}}}else p===k&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let l=r>=0?s??e.slice(0,r):s??e;return i!=null?{finalMessages:l,equalsError:i}:{finalMessages:l}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let s of t)s(e)};_dispatchOrAccumulate(e){if(be()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],ve(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}X(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let t=this._frameBatch(e);X(this._deliverToSinks,t,this._config.tierOf)}},Me=n=>Array.isArray(n),ue=n=>typeof n=="object"&&n!=null&&!Array.isArray(n);function j(n,e,t){let s=Me(n)?n:[],i=typeof n=="function"?n:typeof e=="function"?e:void 0,r={};return Me(n)?r=(ue(e)?e:t)??{}:ue(n)?r=n:r=(ue(e)?e:t)??{},new $(s,i,r)}function bt(n,e){return j([],{...e,initial:n})}function vt(n,e){return j((s,i,r)=>n(i,r)??void 0,{describeKind:"producer",...e})}function Be(n,e,t){return j(n,(i,r,a)=>{let o=i.map((d,l)=>d!=null&&d.length>0?d.at(-1):a.prevData[l]);r.emit(e(o,a))},{describeKind:"derived",...t})}function wt(n,e,t){return j(n,(i,r,a)=>{let o=i.map((d,l)=>d!=null&&d.length>0?d.at(-1):a.prevData[l]);return e(o,r,a)??void 0},{describeKind:"effect",...t})}function xt(n,e,t){let s=new Map;return n.forEach((i,r)=>{s.set(i,r)}),Be(n,(i,r)=>e(o=>{let d=s.get(o);if(d==null)throw new Error(`dynamicNode: untracked dep "${o.name??"<unnamed>"}"`);return i[d]},r),t)}function Tt(n,e){let t,s=new Map,i=(r,a,o)=>{let d=!1,l=c=>{let h=s.get(c);if(h!==void 0){if(h<r.length){let u=r[h];return u!=null&&u.length>0?u.at(-1):o.prevData[h]}return c.cache}d=!0;let p=t._addDep(c);return s.set(c,p),c.cache};try{let c=n(l,o);d||(a.emit(c),o.store.__autoTrackLastDiscoveryError!=null&&delete o.store.__autoTrackLastDiscoveryError)}catch(c){if(!d)throw c;o.store.__autoTrackLastDiscoveryError=c}};return t=new $([],i,{describeKind:"derived",...e}),t}function Nt(n,...e){let t=n;for(let s of e)t=s(t);return t}export{Ce as a,$e as b,je as c,oe as d,ze as e,qe as f,ye as g,Ke as h,De as i,J as j,me as k,ve as l,Xe as m,X as n,Qe as o,we as p,Z as q,xe as r,F as s,Ge as t,st as u,it as v,de as w,le as x,Ne as y,ot as z,B as A,gt as B,$ as C,j as D,bt as E,vt as F,Be as G,wt as H,xt as I,Tt as J,Nt as K};
@@ -1 +0,0 @@
1
- import{E as v,G as w,m as h}from"./chunk-LYCLF26R.js";import{b as m,c as V}from"./chunk-CK2E7BTU.js";function x(s,e){if(s===e)return 0;let r=typeof s;if(r===typeof e&&(r==="number"||r==="string"||r==="boolean"||r==="bigint")){let i=s,n=e;return i<n?-1:i>n?1:0}return String(s).localeCompare(String(e))}function k(s,e){let r=x(s[0],e[0]);return r!==0?r:x(s[1],e[1])}function g(s){return[s.secondary,s.primary]}function y(s,e){let r=g(e),o=0,i=s.length;for(;o<i;){let n=o+i>>1;k(r,g(s[n]))>0?o=n+1:i=n}return o}var b=class{_version=0;_buf=[];_byPrimary=new Map;get version(){return this._version}get size(){return this._buf.length}has(e){return this._byPrimary.has(e)}get(e){return this._byPrimary.get(e)?.value}upsert(e,r,o,i){let n=this._byPrimary.get(e),a={primary:e,secondary:r,value:o};if(n!==void 0&&i?.equals?.(n,a))return!1;if(n!==void 0){let p=y(this._buf,n);this._buf.splice(p,1)}let d=y(this._buf,a);return this._buf.splice(d,0,a),this._byPrimary.set(e,a),this._version+=1,n===void 0}upsertMany(e,r){let o=0;try{for(let i of e){let n=this._byPrimary.get(i.primary),a={primary:i.primary,secondary:i.secondary,value:i.value};if(n!==void 0&&r?.equals?.(n,a))continue;if(n!==void 0){let p=y(this._buf,n);this._buf.splice(p,1)}let d=y(this._buf,a);this._buf.splice(d,0,a),this._byPrimary.set(i.primary,a),o+=1}}finally{o>0&&(this._version+=1)}return o}delete(e){let r=this._byPrimary.get(e);if(r===void 0)return!1;let o=y(this._buf,r);return this._buf.splice(o,1),this._byPrimary.delete(e),this._version+=1,!0}deleteMany(e){let r=0;try{for(let o of e){let i=this._byPrimary.get(o);if(i===void 0)continue;let n=y(this._buf,i);this._buf.splice(n,1),this._byPrimary.delete(o),r+=1}}finally{r>0&&(this._version+=1)}return r}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._byPrimary.clear(),this._version+=1,e)}toArray(){return[...this._buf]}toPrimaryMap(){let e=new Map;for(let r of this._buf)e.set(r.primary,r.value);return e}};function R(s){return s.subscribe(()=>{})}function U(s={}){let{name:e,versioning:r,equals:o,backend:i}=s,n=i??new b;function a(t){return t?.equals!==void 0||o===void 0?t:{...t,equals:o}}let d=v([],{name:e,describeKind:"state",equals:(t,u)=>t===u,...r!=null?{versioning:r}:{}}),p=w([d],([t])=>{let u=t,l=new Map;for(let f of u)l.set(f.primary,f.value);return l},{initial:n.toPrimaryMap(),describeKind:"derived"}),_=R(p),K=!1;function I(){let t=n.toArray();h(()=>{d.down([[V]]),d.down([[m,t]])})}function c(t){let u=n.version;try{return t()}finally{n.version!==u&&I()}}return{ordered:d,byPrimary:p,has(t){return n.has(t)},get(t){return n.get(t)},get size(){return n.size},upsert(t,u,l,f){return c(()=>n.upsert(t,u,l,a(f)))},upsertMany(t,u){let l=[...t];l.length!==0&&c(()=>n.upsertMany(l,a(u)))},delete(t){c(()=>n.delete(t))},deleteMany(t){let u=[...t];u.length!==0&&c(()=>n.deleteMany(u))},clear(){c(()=>n.clear())},dispose(){K||(K=!0,_())}}}export{b as a,U as b};
@@ -1,45 +0,0 @@
1
- import{d as tt,e as rt}from"./chunk-3XDYJRYU.js";import{s as $e,t as Me,v as Ze}from"./chunk-QE4IGY7I.js";import{g as Se,i as Ge}from"./chunk-OYJKFY7V.js";import{c as et}from"./chunk-JNWRYDJN.js";import{b as me}from"./chunk-D27JNOLZ.js";import{b as Xe}from"./chunk-TSOYJ743.js";import{a as _e}from"./chunk-FDQGFWLF.js";import{g as ze,j as xe}from"./chunk-626TESAC.js";import{b as Re,s as De,t as Ke,x as Ie}from"./chunk-VOPGGIL7.js";import{b as Ye}from"./chunk-35JTVPOX.js";import{b as Ne}from"./chunk-TZQPPQEQ.js";import{C as We,m as ke}from"./chunk-V5A7M7RJ.js";import{D as Be,E as S,F as Ee,G as h,H as O,m as fe,o as H}from"./chunk-LYCLF26R.js";import{b as V,i as X,j as Y}from"./chunk-CK2E7BTU.js";import{b as pt}from"./chunk-QYADASLV.js";var Yt={};pt(Yt,{DEFAULT_DECAY_RATE:()=>ee,DEFAULT_EXECUTE_PROMPT:()=>Ve,DEFAULT_QUEUE_CONFIGS:()=>Ae,DEFAULT_SEVERITY_WEIGHTS:()=>Z,DEFAULT_TRIAGE_PROMPT:()=>He,DEFAULT_VERIFY_PROMPT:()=>Le,HarnessGraph:()=>Ce,QUEUE_NAMES:()=>M,actuatorExecutor:()=>nt,affectedTaskFilter:()=>kt,autoSolidify:()=>ht,beforeAfterCompare:()=>It,blindVariation:()=>Pt,codeChangeBridge:()=>Nt,createIntakeBridge:()=>Et,defaultErrorClassifier:()=>we,defaultLlmExecutor:()=>lt,defaultLlmVerifier:()=>dt,dispatchActuator:()=>vt,effectivenessTracker:()=>wt,errorCritique:()=>Dt,evalIntakeBridge:()=>xt,evalSource:()=>Rt,evalVerifier:()=>at,harnessEvalPair:()=>Ht,harnessLoop:()=>qt,harnessProfile:()=>Jt,harnessTrace:()=>Ut,notifyEffect:()=>St,priorityScore:()=>Vt,refineExecutor:()=>Je,refineLoop:()=>je,resolvePromptFn:()=>pe,strategyKey:()=>te,strategyModel:()=>Qe});function yt(e,r){return{outcome:"success",detail:`actuator applied ${r.intervention} for ${Tt(r.summary)}`,artifact:e}}function gt(e,r){let c=e instanceof Error?e.message:String(e);return{outcome:"failure",detail:`actuator threw on ${r.intervention}: ${c}`}}function bt(e){return`actuator skipped ${e.intervention} (shouldApply returned false)`}function Tt(e,r=80){return e.length<=r?e:`${e.slice(0,r-1)}\u2026`}function nt(e){let r=e.name??"actuator-executor",c=e.toOutput??yt,n=e.onError??gt,i=e.skipDetail??bt;return t=>{let o=t.payload.item;return e.shouldApply&&!e.shouldApply(o)?{...t.payload,execution:{item:o,outcome:"failure",detail:i(o)}}:Ee(a=>{let u=new AbortController,s=!1,l=null,m=y=>{s||(s=!0,a.down([[V,{...t.payload,execution:{item:o,...y}}],[X]]),l?.(),l=null)},f;try{let y=e.apply(o,{signal:u.signal});f=ke(y,{signal:u.signal})}catch(y){return m(n(y,o)),()=>{u.abort()}}return l=f.subscribe(y=>{for(let g of y){if(s)return;if(g[0]===V){m(c(g[1],o));return}if(g[0]===Y){m(n(g[1],o));return}if(g[0]===X){m(n(new Error("actuator inner completed without emitting DATA"),o));return}}}),s&&l&&(l(),l=null),()=>{u.abort(),l?.(),l=null}},{name:`${r}/inner`})}}function vt(e){let r=e.name??"dispatch-actuator",c=e.default??null,n=c!=null;return nt({apply:(i,t)=>{let o=Object.hasOwn(e.routes,i.intervention)?e.routes[i.intervention]:c;if(!o)throw new Error(`dispatchActuator: no route for intervention '${i.intervention}'`);return o(i,t)},shouldApply:i=>Object.hasOwn(e.routes,i.intervention)||n,skipDetail:i=>`no route for intervention '${i.intervention}'`,name:r})}function ht(e){let r=e.name??"auto-solidify",c=e.extract??(i=>i.execution.artifact??null),n=e.predicate??(()=>!0);return Ee(i=>{let t=null,o=!1,a=()=>{o||(o=!0,t?.(),t=null)},u=s=>{o||(i.down([[Y,s]]),a())};return t=e.verifyResults.subscribe(s=>{if(!o)for(let l of s){if(o)return;if(l[0]!==V){if(l[0]===X){i.down([[X]]),a();return}continue}let m=l[1];if(m==null||!m.verified)continue;let f;try{f=n(m)}catch(g){u(g);return}if(!f)continue;let y;try{y=c(m)}catch(g){u(g);return}if(y!=null){try{e.write(y,m)}catch(g){u(g);return}i.down([[V,y]])}}}),o&&t&&(t(),t=null),()=>{a()}},{name:r})}function Et(e,r,c,n){return O([e],([i])=>{if(i==null)return;let t=c(i);for(let o of t)r.publish(o)},{name:n?.name??"intake-bridge"})}function xt(e,r,c){let n=c?.defaultSeverity??"medium";return O([e],([i])=>{if(i==null)return;let t=Array.isArray(i)?i:[i];for(let o of t)for(let a of o.tasks)if(!(a.valid&&a.judge_scores?.every(u=>u.pass))){if(!a.valid&&(!a.judge_scores||a.judge_scores.length===0)){r.publish({source:"eval",summary:`Task ${a.task_id} invalid (model: ${o.model})`,evidence:`Run ${o.run_id}: task produced invalid output`,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:n});continue}if(a.judge_scores)for(let u of a.judge_scores)u.pass||r.publish({source:"eval",summary:`${a.task_id}: ${u.claim} (model: ${o.model})`,evidence:u.reasoning,affectsAreas:["graphspec"],affectsEvalTasks:[a.task_id],severity:n})}},{name:c?.name??"eval-intake-bridge"})}function Rt(e,r){return Ie(e,()=>ke(r()))}function It(e,r){return h([e,r],([c,n])=>{let i=c,t=n,o=new Map(i.tasks.map(f=>[f.task_id,f])),a=new Map(t.tasks.map(f=>[f.task_id,f])),u=new Set([...o.keys(),...a.keys()]),s=[],l=[],m=[];for(let f of u){let y=o.get(f),g=a.get(f),E=y?.valid??!1,A=g?.valid??!1,R=y?.judge_scores?y.judge_scores.filter(_=>_.pass).length:void 0,$=g?.judge_scores?g.judge_scores.filter(_=>_.pass).length:void 0,w=R!==void 0&&$!==void 0?$-R:void 0;s.push({taskId:f,before:E,after:A,scoreDiff:w}),E&&!A&&l.push(f),!E&&A&&m.push(f)}return{newFailures:l,resolved:m,taskDeltas:s,overallImproved:m.length>l.length}},{name:"eval-delta"})}function kt(e,r){let c=r==null?null:Array.isArray(r)?S(r):r,n=[e];return c&&n.push(c),h(n,i=>{let t=i[0],o=c?new Set(i[1]):null,a=new Set;for(let u of t)for(let s of u.affectsEvalTasks??[])(o==null||o.has(s))&&a.add(s);return[...a].sort()},{name:"affected-task-filter"})}function Nt(e,r,c,n){let i=n?.defaultSeverity??"high";function t(a){let u=[];for(let s of a.lintErrors??[])u.push({source:"code-change",summary:`Lint: ${s.rule} in ${s.file}:${s.line}`,evidence:s.message,affectsAreas:[s.file],severity:i});for(let s of a.testFailures??[])u.push({source:"test",summary:`Test failure: ${s.testId}`,evidence:s.message,affectsAreas:[s.file],affectsEvalTasks:[s.testId],severity:i});return u}let o=c??t;return O([e],([a])=>{if(a!=null)for(let u of o(a))r.publish(u)},{name:n?.name??"code-change-bridge"})}function St(e,r,c){return O([e.latest],([n])=>{n!=null&&r(n)},{name:c?.name??"notify-effect"})}var M=["auto-fix","needs-decision","investigation","backlog"],Ae={"auto-fix":{gated:!1},"needs-decision":{gated:!0},investigation:{gated:!0},backlog:{gated:!1}},Z={critical:100,high:70,medium:40,low:10},ee=Math.LN2/(168*3600);function te(e,r){return`${e}\u2192${r}`}var At=/\b(parse|json|config|validation|syntax)\b/i,we=e=>At.test(e.detail)?"self-correctable":"structural",He=`You are a triage classifier for a reactive collaboration harness.
2
-
3
- Given an intake item, classify it and output JSON:
4
- {
5
- "rootCause": "composition" | "missing-fn" | "bad-docs" | "schema-gap" | "regression" | "unknown",
6
- "intervention": "template" | "catalog-fn" | "docs" | "wrapper" | "schema-change" | "investigate",
7
- "route": "auto-fix" | "needs-decision" | "investigation" | "backlog",
8
- "priority": <number 0-100>,
9
- "triageReasoning": "<one sentence>"
10
- }
11
-
12
- Strategy model (past effectiveness):
13
- {{strategy}}
14
-
15
- Intake item:
16
- {{item}}`,Ve=`You are an implementation agent.
17
-
18
- Given a triaged issue with root cause and intervention type, produce a fix.
19
-
20
- Issue:
21
- {{item}}
22
-
23
- Output JSON:
24
- {
25
- "outcome": "success" | "failure" | "partial",
26
- "detail": "<description of what was done or what failed>"
27
- }`,Le=`You are a QA reviewer.
28
-
29
- Given an execution result, verify whether the fix is correct.
30
-
31
- Execution:
32
- {{execution}}
33
-
34
- Original issue:
35
- {{item}}
36
-
37
- Output JSON:
38
- {
39
- "verified": true/false,
40
- "findings": ["<finding1>", ...],
41
- "errorClass": "self-correctable" | "structural" // only if verified=false
42
- }`;function pe(e,r,c){if(typeof e=="function")return e;let n=e??r;return i=>c(n,i)}function wt(e){let r=Ne({name:e?.name??"effectiveness-entries"}),c=h([r.entries],([o])=>new Map(o),{name:`${e?.name??"effectiveness"}-snapshot`,equals:(o,a)=>{let u=o,s=a;if(u.size!==s.size)return!1;for(let[l,m]of u){let f=s.get(l);if(!f||m.attempts!==f.attempts||m.successes!==f.successes)return!1}return!0}});function n(o,a){let u=r.get(o),s=(u?.attempts??0)+1,l=(u?.successes??0)+(a?1:0);r.set(o,{key:o,attempts:s,successes:l,successRate:l/s})}function i(o){return r.get(o)}let t=We(c);return{node:c,record:n,lookup:i,dispose:()=>{t(),r.dispose()}}}function Ct(e){if(typeof e!="object"||e===null)return!1;let r=e;return typeof r.subscribe=="function"&&typeof r.down=="function"&&typeof r.emit=="function"}function ot(e,r){if(e.length===0)return{best:null,bestScore:Number.NEGATIVE_INFINITY};if(e.length===1){let t=qe(r);return{best:e[0],bestScore:t}}if(r.some(t=>typeof t.candidateIndex=="number")){let t=new Array(e.length);for(let u=0;u<e.length;u++)t[u]={sum:0,count:0};for(let u of r){let s=u.candidateIndex;typeof s=="number"&&s>=0&&s<e.length&&(t[s].sum+=u.score,t[s].count+=1)}let o=e[0],a=t[0].count>0?t[0].sum/t[0].count:Number.NEGATIVE_INFINITY;for(let u=1;u<e.length;u++){let s=t[u].count>0?t[u].sum/t[u].count:Number.NEGATIVE_INFINITY;s>a&&(a=s,o=e[u])}return{best:o,bestScore:a}}let n=e[0],i=r[0]?.score??Number.NEGATIVE_INFINITY;for(let t=1;t<e.length;t++){let o=r[t]?.score??Number.NEGATIVE_INFINITY;o>i&&(i=o,n=e[t])}return{best:n,bestScore:i}}function qe(e){if(e.length===0)return Number.NEGATIVE_INFINITY;let r=0;for(let c of e)r+=c.score;return r/e.length}function je(e,r,c,n){let i=n.name??"refine-loop",t=new xe(i,n.graph),o=Ct(n.dataset)?n.dataset:S(n.dataset,{name:"dataset"});t.add(o,{name:"dataset"});let a=S(0,{name:"iteration"});t.add(a,{name:"iteration"});let u=S(c,{name:"strategy",equals:()=>!1});t.add(u,{name:"strategy"});let s=S(null,{name:"lastFeedback"});t.add(s,{name:"lastFeedback"});let l=S([],{name:"prevCandidates"});t.add(l,{name:"prevCandidates"});let m=S(!1,{name:"paused"});t.add(m,{name:"paused"});let f=S("running",{name:"status"});t.add(f,{name:"status"});let y=S([],{name:"history",equals:()=>!1});t.add(y,{name:"history"});let g=S(null,{name:"best"});t.add(g,{name:"best"});let E=S(Number.NEGATIVE_INFINITY,{name:"score"});t.add(E,{name:"score"});let A=S(0,{name:"budget-used"});t.add(A,{name:"budget-used"});let R=Se("stages");t.mount("stages",R);let $=R.topic("generate"),w=R.topic("evaluate"),_=R.topic("analyze"),ye=R.topic("decide"),L=c,U=null,re=[];t.addDisposer(u.subscribe(b=>{for(let T of b)T[0]===V&&(L=T[1])})),t.addDisposer(s.subscribe(b=>{for(let T of b)T[0]===V&&(U=T[1])})),t.addDisposer(l.subscribe(b=>{for(let T of b)T[0]===V&&(re=T[1])}));let G=Ie(a,b=>{let T=L,C=b===0||U==null;return Be([],(I,P)=>{let v=!1;try{let d=C?T.seed(e):T.generate(U,re);if(d instanceof Promise)return d.then(p=>{v||P.emit(p)},p=>{v||P.down([[Y,p]])}),()=>{v=!0};P.emit(d)}catch(d){v=!0,P.down([[Y,d]])}},{describeKind:"producer"})},{name:"candidates"});t.add(G,{name:"candidates"});let ne=O([G],(b,T,C)=>{let I=C.terminalDeps[0];I!==void 0&&I!==!0&&f.emit("errored")},{name:"error-watcher",errorWhenDepsError:!1});t.add(ne,{name:"error-watcher"}),t.addDisposer(ne.subscribe(()=>{}));let Q=h([G,a],([b,T])=>({iteration:T,candidates:b,timestamp_ns:H()}),{name:"generate-event"});t.add(Q,{name:"generate-event"}),t.addDisposer(Q.subscribe(()=>{}));let B=O([Q],([b])=>{$.publish(b)},{name:"generate-publish"});t.add(B,{name:"generate-publish"}),t.addDisposer(B.subscribe(()=>{}));let oe=O([G],([b])=>{l.emit(b)},{name:"generate-mirror"});t.add(oe,{name:"generate-mirror"}),t.addDisposer(oe.subscribe(()=>{}));let z=r(G,o);t.add(z,{name:"scores"});let ae=h([z,G,a],([b,T,C])=>({iteration:C,candidates:T,scores:b,timestamp_ns:H()}),{name:"evaluate-event"});t.add(ae,{name:"evaluate-event"}),t.addDisposer(ae.subscribe(()=>{}));let ge=O([ae],([b])=>{w.publish(b)},{name:"evaluate-publish"});t.add(ge,{name:"evaluate-publish"}),t.addDisposer(ge.subscribe(()=>{}));let se=h([z,G],([b,T])=>L.analyze(b,T),{name:"feedback"});t.add(se,{name:"feedback"});let q=h([se,G,a],([b,T,C])=>({iteration:C,candidates:T,feedback:b,timestamp_ns:H()}),{name:"analyze-event"});t.add(q,{name:"analyze-event"}),t.addDisposer(q.subscribe(()=>{}));let ie=O([q],([b])=>{_.publish(b)},{name:"analyze-publish"});t.add(ie,{name:"analyze-publish"}),t.addDisposer(ie.subscribe(()=>{}));let ue=h([y],([b])=>{let T=b;if(n.patience==null||T.length<=n.patience)return!1;let C=T.slice(-(n.patience+1)),I=C[0].bestScore;return C.slice(1).every(P=>P.bestScore<=I)},{name:"patience-check"});t.add(ue,{name:"patience-check"});let K=h([E],([b])=>n.minScore!=null&&b>=n.minScore,{name:"min-score-check"});t.add(K,{name:"min-score-check"});let ce=h([y],([b])=>{let T=b;if(n.minDelta==null||T.length<2)return!1;let C=T[T.length-2].bestScore,I=T[T.length-1].bestScore;return Math.abs(I-C)<n.minDelta},{name:"min-delta-check"});t.add(ce,{name:"min-delta-check"});let le=h([A],([b])=>n.maxEvaluations!=null&&b>=n.maxEvaluations,{name:"max-evaluations-check"});t.add(le,{name:"max-evaluations-check"});let W=h([a],([b])=>n.maxIterations!=null&&b>=n.maxIterations,{name:"max-iterations-check"});t.add(W,{name:"max-iterations-check"});let de=h([A],([b])=>n.budget!=null&&b>=n.budget,{name:"budget-exhausted-check"});t.add(de,{name:"budget-exhausted-check"}),t.addDisposer(ue.subscribe(()=>{})),t.addDisposer(K.subscribe(()=>{})),t.addDisposer(ce.subscribe(()=>{})),t.addDisposer(le.subscribe(()=>{})),t.addDisposer(W.subscribe(()=>{})),t.addDisposer(de.subscribe(()=>{}));let be=h([ue,K,ce,le,W],([b,T,C,I,P])=>b?{converged:!0,reason:"patience"}:T?{converged:!0,reason:"min-score"}:C?{converged:!0,reason:"min-delta"}:I?{converged:!0,reason:"max-evaluations"}:P?{converged:!0,reason:"max-iterations"}:{converged:!1},{name:"converged"});t.add(be,{name:"converged"}),t.addDisposer(be.subscribe(()=>{}));let Te=-1,ve=O([se,z,G],([b,T,C])=>{let I=a.cache,P=b,v=C,d=T;if(I<=Te)return;Te=I;let{best:p,bestScore:x}=ot(v,d),k=y.cache,j={n:I,candidates:v,scores:d,feedback:P,best:p,bestScore:x,timestamp_ns:H()},F=[...k,j],J=A.cache+v.length,N="continue",D,Pe=n.budget!=null&&J>=n.budget,Fe=m.cache;if(Pe)N="budget",D="budget";else if(n.minScore!=null&&P.score>=n.minScore)N="converged",D="min-score";else if(n.maxIterations!=null&&I>=n.maxIterations)N="converged",D="max-iterations";else if(n.maxEvaluations!=null&&J>=n.maxEvaluations)N="converged",D="max-evaluations";else if(n.minDelta!=null&&F.length>=2){let he=F[F.length-2].bestScore,Oe=F[F.length-1].bestScore;Math.abs(Oe-he)<n.minDelta&&(N="converged",D="min-delta")}else if(n.patience!=null&&F.length>n.patience){let he=F.slice(-(n.patience+1)),Oe=he[0].bestScore;he.slice(1).every(mt=>mt.bestScore<=Oe)&&(N="converged",D="patience")}N==="continue"&&Fe&&(N="paused"),fe(()=>{g.emit(p),E.emit(P.score),y.emit(F),A.emit(J),s.emit(P),ye.publish({iteration:I,decision:N,reason:D,timestamp_ns:H()}),N==="continue"?a.emit(I+1):f.emit(N==="converged"?"converged":N==="budget"?"budget":"paused")})},{name:"decide-bridge"});return t.add(ve,{name:"decide-bridge"}),t.addDisposer(ve.subscribe(()=>{})),Object.assign(t,{best:g,score:E,status:f,history:y,strategy:u,iteration:a,generate:$,evaluate:w,analyze:_,decide:ye,setStrategy(b){u.emit(b)},pause(){m.emit(!0)},resume(){f.cache==="paused"&&fe(()=>{m.emit(!1),f.emit("running"),a.emit(a.cache+1)})}})}function Pt(e){let r=e.width??4;return{name:e.name??"blindVariation",seed(n){return[n]},analyze(n,i){let t=qe(n),o=null;for(let a of n)(!o||a.score<o.score)&&(o=a);return{summary:`blindVariation iteration: mean=${t.toFixed(3)}, n=${n.length}`,score:t,weakTasks:o?[o.taskId]:[]}},async generate(n,i){if(i.length===0)throw new Error("blindVariation.generate: empty candidate batch \u2014 cannot derive prior for teacher");let t=i[i.length-1],o=0,u={prior:t,reportCost:s=>{o+=s}};try{if(e.parallel!==!1)return await Promise.all(Array.from({length:r},()=>e.teacher(u)));let s=[];for(let l=0;l<r;l++)s.push(await e.teacher(u));return s}finally{if(e.tokens!=null&&o>0){let s=e.tokens.cache??0;e.tokens.emit(s+o)}}}}}function Ft(e){return typeof e=="object"&&e!==null&&e.kind==="errorCritique"}function Ot(e,r){return e.length===0?`No task scored below the batch mean (${r.score.toFixed(3)}). Reinforce the current direction.`:`Failures below threshold:
43
- ${e.map(n=>{let i=n.error!=null?` | error: ${n.error}`:"";return`- ${n.taskId} (score=${n.score.toFixed(3)})${i}`}).join(`
44
- `)}`}function Dt(e){let r=e.width??4,c=e.name??"errorCritique",n=e.maxFailureSamples??5,i=e.formatCritique??Ot;return{name:c,seed(t){return[t]},analyze(t,o){let a=qe(t),u=typeof e.failureThreshold=="function"?e.failureThreshold(t):e.failureThreshold,s=u===void 0&&!Number.isFinite(a),l=u??a,m=s?[...t].sort((w,_)=>w.score-_.score):t.filter(w=>w.score<l).slice().sort((w,_)=>w.score-_.score),f=m.slice(0,n),{best:y,bestScore:g}=ot(o,t),E={summary:"",score:a,weakTasks:f.map(w=>w.taskId)},A=i(f,E),R={kind:"errorCritique",best:y,failures:f,critiqueText:A},$=m.length>f.length?` (top ${f.length} retained)`:"";return{summary:`errorCritique iteration: mean=${a.toFixed(3)}, failures=${m.length}${$}/${t.length}, bestScore=${g.toFixed(3)}`,critique:R,weakTasks:f.map(w=>w.taskId),score:a}},async generate(t,o){if(o.length===0)throw new Error("errorCritique.generate: empty candidate batch \u2014 cannot derive prior for teacher");let a=Ft(t.critique)?t.critique:void 0,u=a!==void 0?a.best:o[o.length-1],s=a?.critiqueText??t.summary,l=a?.failures??[],m=0,y={prior:u,critique:s,failures:l,reportCost:g=>{m+=g}};try{if(e.parallel!==!1)return await Promise.all(Array.from({length:r},()=>e.teacher(y)));let g=[];for(let E=0;E<r;E++)g.push(await e.teacher(y));return g}finally{if(e.tokens!=null&&m>0){let g=e.tokens.cache??0;e.tokens.emit(g+m)}}}}}function _t(e){let{best:r,score:c,status:n}=e,i=Number.isFinite(c)?c.toFixed(3):String(c),t=r??void 0;return n==="converged"?{outcome:"success",detail:`refineLoop converged at score ${i}`,artifact:t}:n==="budget"?{outcome:"partial",detail:`refineLoop hit budget at score ${i}`,artifact:t}:{outcome:"failure",detail:`refineLoop errored (status=${n})`,artifact:t}}function Je(e){let r=e.name??"refine-executor",c=e.toOutput??_t;return n=>{let i=n.payload.item,t=je(e.seedFrom(i),e.evaluator,e.strategy,{...e.refine,dataset:e.datasetFor(i),name:`${r}/inner`}),o=h([t.status,t.best,t.score],([a,u,s])=>{let l=a;if(l!=="converged"&&l!=="budget"&&l!=="errored")return null;let m=c({best:u,score:s,status:l});return{...n.payload,execution:{item:i,...m}}},{name:`${r}/output`});return Re(o,a=>a!=null,{name:`${r}/gate-out`})}}function $t(e){if(e.length===0)return Number.NEGATIVE_INFINITY;let r=0;for(let c of e)r+=c.score;return r/e.length}function Mt(e){let{passCount:r,total:c,meanScore:n,threshold:i,missingArtifact:t}=e,o=Number.isFinite(n)?n.toFixed(3):String(n),a=!t&&c>0&&n>=i,u=t?["EXECUTE stage did not emit an artifact; cannot verify reactively"]:a?[`${r}/${c} eval tasks passed; mean score ${o} \u2265 ${i}`]:c===0?["No eval tasks were selected for this item \u2014 cannot verify"]:[`${r}/${c} eval tasks passed; mean score ${o} < threshold ${i}`];return a?{verified:!0,findings:u}:{verified:!1,findings:u,errorClass:"structural"}}function Gt(e){return e.artifact??null}function at(e){let r=e.name??"eval-verifier",c=e.threshold??.5,n=e.toOutput??Mt,i=e.extractArtifact??Gt;return t=>{let{item:o,execution:a}=t.payload;if(a==null)return{...t.payload,verify:{verified:!1,findings:["evalVerifier: prior execute stage produced no execution"],errorClass:"structural"}};let u=i(a,o);if(u==null)return{...t.payload,verify:n({scores:[],meanScore:Number.NEGATIVE_INFINITY,passCount:0,total:0,threshold:c,missingArtifact:!0})};let s=S([u],{name:`${r}/candidates`}),l=S(e.datasetFor(o),{name:`${r}/dataset`}),m;fe(()=>{m=e.evaluator(s,l)});let f=h([m],([y])=>{let g=y;if(g==null)return null;let E=$t(g),A=g.filter(R=>R.score>=c).length;return{...t.payload,verify:n({scores:g,meanScore:E,passCount:A,total:g.length,threshold:c})}},{name:`${r}/output`});return Re(f,y=>y!=null,{name:`${r}/gate-out`})}}function Ht(e){let r=e.name??"harness-pair",c=Je({name:`${r}-exec`,seedFrom:e.seedFrom,evaluator:e.evaluator,strategy:e.strategy,datasetFor:e.datasetFor,refine:e.refine}),n=at({name:`${r}-verify`,evaluator:e.evaluator,datasetFor:e.datasetFor,threshold:e.threshold});return{executor:c,verifier:n}}function Qe(){let e=Ne({name:"strategy-entries"}),r=h([e.entries],([o])=>{let a=o;return new Map(a)},{name:"strategy-model",equals:(o,a)=>{let u=o,s=a;if(u.size!==s.size)return!1;for(let[l,m]of u){let f=s.get(l);if(!f||m.attempts!==f.attempts||m.successes!==f.successes)return!1}return!0}});function c(o,a,u){let s=te(o,a),l=e.get(s),m=(l?.attempts??0)+1,f=(l?.successes??0)+(u?1:0);e.set(s,{rootCause:o,intervention:a,attempts:m,successes:f,successRate:f/m})}function n(o,a){return e.get(te(o,a))}let i=r.subscribe(()=>{});function t(){i()}return{node:r,record:c,lookup:n,dispose:t}}function Vt(e,r,c,n,i){let t={...Z,...i?.severityWeights},o=i?.decayRate??ee,a=i?.effectivenessThreshold??.7,u=i?.effectivenessBoost??15,s=[e,r,c];return n&&s.push(n),h(s,l=>{let m=l[0],f=l[1],y=l[2],g=n?l[3]:0,E=t[m.severity??"medium"],A=(H()-y)/1e9,R=Xe(E,A,o,0),$=te(m.rootCause,m.intervention),w=f.get($);return w&&w.successRate>=a&&(R+=u),R+=g*20,R},{name:"priority-score"})}var st="intake",Lt="triage-output",it="retry",ut="verify-results",ct="__unrouted";function lt(e,r){let c=pe(r,Ve,(n,i)=>n.replace("{{item}}",JSON.stringify(i)));return n=>{let i=n.payload.item,t=[{role:"user",content:c(i)}],o=u=>({...n.payload,execution:{item:i,outcome:"failure",detail:u}}),a=u=>u instanceof Error?u.message:String(u);return Me(e,t,{onSuccess:u=>{let s;try{s=JSON.parse($e(String(u.content)))}catch(m){return o(`execute parse error: ${a(m)}`)}if(s==null||typeof s!="object"||Array.isArray(s))return o(`execute parse error: non-object response: ${JSON.stringify(s)}`);let l=s;return{...n.payload,execution:{item:i,outcome:l.outcome??"failure",detail:l.detail??"unknown",artifact:l.artifact}}},onFailure:(u,s)=>o(u==="complete"?"adapter completed without emitting DATA":`executor failed: ${a(s)}`)})}}function dt(e,r){let c=pe(r,Le,(n,i)=>{let[t,o]=i;return n.replace("{{execution}}",JSON.stringify(t)).replace("{{item}}",JSON.stringify(o))});return n=>{let{item:i,execution:t}=n.payload;if(t==null)return{...n.payload,verify:{verified:!1,findings:["verifier: prior execute stage produced no execution"],errorClass:"structural"}};let o=[{role:"user",content:c([t,i])}],a=s=>({...n.payload,verify:{verified:!1,findings:[s],errorClass:"self-correctable"}}),u=s=>s instanceof Error?s.message:String(s);return Me(e,o,{onSuccess:s=>{let l;try{l=JSON.parse($e(String(s.content)))}catch(f){return a(`verify parse error: ${u(f)}`)}if(l==null||typeof l!="object"||Array.isArray(l))return a(`verify parse error: non-object response: ${JSON.stringify(l)}`);let m=l;return{...n.payload,verify:{verified:m.verified===!0,findings:m.findings??[],errorClass:m.errorClass}}},onFailure:(s,l)=>a(s==="complete"?"verifier completed without emitting DATA":`verifier failed: ${u(l)}`)})}}var Ce=class extends xe{queues;executeFlow;jobs;gates;queueTopics;strategy;totalRetries;totalReingestions;priorityScores;reflect;constructor(r,c,n,i,t,o,a,u,s,l,m){super(r),this.queues=c,this.executeFlow=n,this.queueTopics=i,this.jobs=t,this.gates=o,this.strategy=a,this.totalRetries=u,this.totalReingestions=s,this.reflect=l,this.priorityScores=m}get intake(){return this.queues.topic(st)}get verifyResults(){return this.queues.topic(ut)}get retry(){return this.queues.topic(it)}get unrouted(){return this.queues.topic(ct)}stageNodes(){let r=this.queues,c=o=>r.has(o)?`queues::${o}::latest`:null,n=o=>o==null?[]:[o],i=M.flatMap(o=>n(c(o))),t=[];for(let[o]of this.gates)t.push(`gates::${o}/gate`);return[{label:"INTAKE",paths:n(c("intake"))},{label:"TRIAGE",paths:["triage"]},{label:"QUEUE",paths:i},{label:"GATE",paths:t},{label:"EXECUTE",paths:["executeFlow::execute::events"]},{label:"VERIFY",paths:["executeFlow::verify::events"]},{label:"REFLECT",paths:["reflect"]},{label:"STRATEGY",paths:["strategy"]}]}};function qt(e,r){let c=r.adapter,n=r.maxRetries??2,i=r.retainedLimit??1e3,t=r.errorClassifier??we,o=new Map;for(let d of M)o.set(d,{...Ae[d],...r.queues?.[d]});let a=Se(`${e}/queues`,{defaultTopicOptions:{retainedLimit:i}}),u=a.topic(st),s=a.topic(Lt),l=a.topic(it),m=a.topic(ut),f=new Map;for(let d of M)f.set(d,a.topic(d));let y=a.topic(ct),g=Qe(),E=De(u.latest,g.node),A=pe(r.triagePrompt,He,(d,p)=>{let[x,k]=p;return d.replace("{{strategy}}",JSON.stringify(Array.from(k.entries()))).replace("{{item}}",JSON.stringify(x))}),R=Ze(c,[E],d=>{let p=d;return!p||!p[0]?"":A(p)},{name:"triage",format:"json"}),$=De(R,E),_=O([$],([d])=>{if(d==null)return;let[p,x]=d;if(!p?.route)return;let k=x?.[0],j={...p,...k};s.publish(j)}).subscribe(()=>{}),ye=new Set(M);for(let d of M)Ge(`bridge/${d}`,s,f.get(d),{map:p=>p.route===d?p:void 0});Ge("bridge/__unrouted",s,y,{map:d=>ye.has(d.route)?void 0:d});let L=new Map,U=new Map;for(let d of M)L.set(d,tt(`jobs/${d}`));let re=[];for(let d of M){let p=f.get(d),x=L.get(d),k=new WeakSet,j=O([p.events],([F])=>{let J=F??[];for(let N of J){if(k.has(N))continue;k.add(N);let D=x.enqueue(N);U.set(me(N),{route:d,id:D})}},{name:`jobs/${d}-mirror`});re.push(j.subscribe(()=>{}))}function G(d){let p=me(d),x=U.get(p);x&&(L.get(x.route)?.removeById(x.id),U.delete(p))}let ne=et("gates"),Q=new Map;for(let d of M){let p=o.get(d);if(!p.gated)continue;let x=f.get(d),k=ne.approvalGate(`${d}/gate`,x.latest,{maxPending:p.maxPending,startOpen:p.startOpen});Q.set(d,k)}let B=[];for(let d of M)o.get(d).gated&&Q.has(d)?B.push(Q.get(d).node):B.push(f.get(d).latest);B.push(l.latest);let oe=Ke(...B),z=r.executor??lt(c,r.executePrompt),ae=r.verifier??dt(c,r.verifyPrompt),ge=r.executeMaxPerPump??Number.MAX_SAFE_INTEGER,se=r.verifyMaxPerPump??Number.MAX_SAFE_INTEGER,q=rt(`${e}/executeFlow`,{stages:[{name:"execute",work:d=>z(d),maxPerPump:ge},{name:"verify",work:d=>ae(d),maxPerPump:se}]}),ie=O([oe],([d])=>{d!=null&&q.enqueue({item:d})},{name:"execute-enqueue"}),ue=ie.subscribe(()=>{}),K=r.maxReingestions??1,ce=Math.min(r.maxTotalRetries??n*10,100),le=Math.min(r.maxTotalReingestions??K*10,100),W=S(0),de=S(0);function be(d,p,x){return{item:x,execution:d,verified:p.verified,findings:p.findings??[],errorClass:p.errorClass}}function Te(d,p){g.record(p.rootCause,p.intervention,!0),m.publish(d),G(p)}function ve(d,p){let x=me(p),k=p.$retries??0,j={...p,$retries:k+1,summary:`[RETRY ${k+1}/${n}] ${x} \u2014 Previous attempt failed: ${d.findings.join("; ")}`,relatedTo:[x]};l.publish(j)}function Ue(d,p){g.record(p.rootCause,p.intervention,!1),m.publish(d),G(p);let x=me(p),k=p.$reingestions??0;k<K&&_e(de,le)&&u.publish({source:p.source,summary:`Verification failed for: ${x}`,evidence:d.findings.join(`
45
- `),affectsAreas:p.affectsAreas,affectsEvalTasks:p.affectsEvalTasks,severity:p.severity??"high",relatedTo:[x],$reingestions:k+1})}let b=0,T=O([q.completed],([d])=>{let p=d??[];b>p.length&&(b=p.length);let x=b;b=p.length;for(let k=x;k<p.length;k++){let j=p[k],{item:F,execution:J,verify:N}=j.payload;if(J==null||N==null){G(F);continue}let D=be(J,N,F);if(D.verified){Te(D,F);continue}let Pe=D.errorClass??t({item:F,outcome:J.outcome,detail:D.findings.join("; ")}),Fe=F.$retries??0;Pe==="self-correctable"&&Fe<n&&_e(W,ce)?ve(D,F):Ue(D,F)}},{name:"verify-dispatch"}),C=T.subscribe(()=>{}),I=h([q.completed],()=>null,{name:"reflect",equals:()=>!1}),P;r.priority&&(P=jt(f,g,r));let v=new Ce(e,a,q,f,L,Q,g,W,de,I,P);v.addDisposer(_),v.addDisposer(ue),v.addDisposer(C),v.addDisposer(g.dispose);for(let d of re)v.addDisposer(d);if(v.add(E,{name:"triage-input"}),v.add(R,{name:"triage"}),v.add($,{name:"router-input"}),v.add(oe,{name:"execute-input"}),v.add(ie,{name:"execute-enqueue"}),v.add(T,{name:"verify-dispatch"}),v.add(I,{name:"reflect"}),v.add(g.node,{name:"strategy"}),v.addDisposer(I.subscribe(()=>{})),P)for(let[d,p]of P)v.add(p,{name:`priority/${d}`}),v.addDisposer(p.subscribe(()=>{}));v.mount("queues",a),v.mount("gates",ne),v.mount("executeFlow",q);for(let[d,p]of L)v.mount(`jobs/${d}`,p);return v.tagFactory("harnessLoop",Ye(r)),v}function jt(e,r,c){if(!c.lastInteractionNs)throw new Error("harnessLoop: `opts.priority` requires `opts.lastInteractionNs` \u2014 pass a Node<number> (e.g. `fromTimer(60_000)` or a `state(monotonicNs())` you bump on human interaction). Priority scores only decay when this node settles; an internal default would freeze age at construction time.");let n=c.lastInteractionNs,i=c.priority??{},t={...Z,...i.severityWeights},o=i.decayRate??ee,a=i.effectivenessThreshold??.7,u=i.effectivenessBoost??15,s=new Map;for(let[l,m]of e){let f=h([m.latest,r.node,n],y=>{let g=y[0];if(g==null)return 0;let E=t[g.severity??"medium"]??40,A=(H()-y[2])/1e9,R=E*Math.exp(-o*Math.max(0,A)),$=`${g.rootCause}\u2192${g.intervention}`,_=y[1]?.get($);return _&&_.successRate>=a&&(R+=u),R},{name:`priority/${l}`});s.set(l,f)}return s}function Jt(e,r){let c=ze(e,r),n={};for(let i of M){let t=e.queues.has(i)?e.queues.topic(i):null;n[i]=t?.retained().length??0}return{...c,queueDepths:n,strategyEntries:e.strategy.node.cache?.size??0,totalRetries:e.totalRetries.cache??0,totalReingestions:e.totalReingestions.cache??0}}function Qt(e){let r={};for(let{label:c,paths:n}of e.stageNodes())for(let i of n)r[i]=c;return r}function Ut(e,r){let c=r?.logger===null?null:r?.logger??console.log,n=r?.detail??"summary",i=H(),t=[],o=[],a=Qt(e);function u(){return(H()-i)/1e9}function s(l,m,f){let y={elapsed:u(),stage:l,type:m};n!=="summary"&&(y.summary=Bt(f)),n==="full"&&(y.data=f),o.push(y)}for(let[l,m]of Object.entries(a))try{let f=e.observe(l,{format:"stage-log",stageLabels:a,logger:c?y=>c(y):()=>{},includeTypes:["data","error","complete"]});f.onEvent(y=>{y.type==="data"?s(m,"data",y.data):y.type==="error"?s(m,"error",y.data):y.type==="complete"&&s(m,"complete",void 0)}),t.push(f)}catch(f){let y=f instanceof Error?f.message:String(f);s(m,"error",`observe-unavailable: ${l} \u2014 ${y}`),c&&c(`[${u().toFixed(3)}s] ${m.padEnd(9)} \u2717 observe-unavailable: ${y}`)}return{get events(){return o},dispose(){for(let l of t)l.dispose();t.length=0}}}function Bt(e){if(e==null)return"null";if(typeof e=="string")return ft(e,80);if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);try{let r=JSON.stringify(e);return ft(r,120)}catch{return String(e)}}function ft(e,r){return e.length>r?`${e.slice(0,r-1)}\u2026`:e}export{nt as a,vt as b,ht as c,Et as d,xt as e,Rt as f,It as g,kt as h,Nt as i,St as j,M as k,Ae as l,Z as m,ee as n,te as o,we as p,He as q,Ve as r,Le as s,pe as t,wt as u,je as v,Pt as w,Dt as x,Je as y,at as z,Ht as A,Qe as B,Vt as C,lt as D,dt as E,Ce as F,qt as G,Jt as H,Ut as I,Yt as J};
@@ -1,18 +0,0 @@
1
- import{d as Re,k as Pe}from"./chunk-VNC3TMVY.js";import{f as Oe}from"./chunk-626TESAC.js";import{x as pe}from"./chunk-VOPGGIL7.js";import{a as Z,b as le,i as Ne}from"./chunk-4VVTGLXJ.js";import{f as fe}from"./chunk-V5A7M7RJ.js";import{A as ee,D as be,E as U,F as B,m as J,p as D}from"./chunk-LYCLF26R.js";import{b as E,c as ye,d as ke,h as de,i as P,j as x}from"./chunk-CK2E7BTU.js";function Ce(r){return{describeKind:"producer",...r}}function oe(r,n){return B(i=>{let s=!0,u={emit(t){s&&i.emit(t)},error(t){s&&(s=!1,i.down([[x,t]]))},complete(){s&&(s=!1,i.down([[P]]))}},o;try{let t=r(u);o=typeof t=="function"?t:void 0}catch(t){return u.error(t),()=>{s=!1}}return()=>{s=!1;try{o?.()}catch{}}},Ce(n))}function Me(r,n,i){let s=!0,u,o=0,t=0,e={},a=[],c=()=>{let l=u;u=void 0;try{l?.()}catch{}};for(let l of n){let m=i?.name?`${i.name}::${l}`:l,g=i?.channelOpts?.[l],y=B(T=>(o++,()=>{t++,o>0&&t>=o&&t>=n.length&&c()}),Ce({...g,name:m}));e[l]=y,a.push(y)}let f={};for(let l of n)f[l]=m=>{s&&e[l].down([[E,m]])};f.error=l=>{s&&(s=!1,J(()=>{for(let m of a)m.down([[x,l]])}),c())},f.complete=()=>{s&&(s=!1,J(()=>{for(let l of a)l.down([[P]])}),c())};let p=r(f);return u=typeof p=="function"?p:void 0,Object.assign(e,{dispose:()=>{s&&(s=!1,J(()=>{for(let l of a)try{l.down([[P]])}catch{}}),c())}})}var he=class{ring;arr;constructor(n){n===Number.POSITIVE_INFINITY||n<=0?(this.arr=[],this.ring=null):(this.ring=new Oe(n),this.arr=null)}get length(){return this.ring!=null?this.ring.size:this.arr.length}push(n){this.ring!=null?this.ring.push(n):this.arr.push(n)}shift(){return this.ring!=null?this.ring.shift():this.arr.shift()}drain(){if(this.ring!=null){let i=this.ring.toArray();return this.ring.clear(),i}let n=this.arr;return this.arr=[],n}};function se(r){return r instanceof Error?r:new Error(String(r))}function De(r){return r===void 0?null:typeof r=="string"?Ne(r):r}function z(r,n){let{name:i,onTransportError:s,retry:u,backpressure:o,batchSize:t=Number.POSITIVE_INFINITY,flushIntervalMs:e=0,serialize:a,stopOn:c,onUpstreamMessage:f,onDispose:p,send:d,sendBatch:l,ctx:m}=n;if(!d&&!l)throw new Error("reactiveSink: `send` or `sendBatch` must be provided");let g=m,y=Math.max(1,u?.maxAttempts??1),T=De(u?.backoff??(y>1?"exponential":void 0)),h=u?.shouldRetry??(()=>!0),b=l!==void 0||t<Number.POSITIVE_INFINITY||e>0,w=k=>i?`${i}::${k}`:void 0,v=U(void 0,{equals:()=>!1,name:w("sent")}),S=U(null,{name:w("failed")}),L=U(0,{name:w("inFlight")}),F=U(null,{name:w("errors")}),K=b?U(0,{name:w("buffered")}):void 0,Y=o?U(!1,{name:w("paused")}):void 0,ie=0,Q=k=>{ie+=k,L.down([[E,ie]])},O=k=>{try{s?.(k)}catch{}try{F.down([[E,k]])}catch{}},q=new Set,V=k=>{q.add(k);let N=()=>q.delete(k);k.then(N,N)},I=(k,N,C)=>{let A=T?T(N-1,C,null):0,H=A==null?0:typeof A=="number"&&A>0?A:0,j=Math.max(1,Math.ceil(H/1e6));return new Promise(M=>{setTimeout(()=>M(k()),j)})},$=k=>k!=null&&typeof k=="object"&&typeof k.then=="function",_=k=>{let N;try{N=a?a(k):k}catch(M){let R=se(M);return O({stage:"serialize",error:R,value:k}),S.down([[E,{value:k,error:R,attempts:0}]]),Promise.resolve()}let C=0,A=M=>{Q(-1);let R=se(M);if(O({stage:"send",error:R,value:k,attempt:C}),!(C<y&&h(R,C))){S.down([[E,{value:k,error:R,attempts:C}]]);return}return I(j,C,R)},H=()=>{Q(-1),v.down([[E,k]])};function j(){C+=1,Q(1);let M;try{M=d(N,g)}catch(R){return A(R)??Promise.resolve()}return $(M)?M.then(H,R=>A(R)):(H(),Promise.resolve())}return j()},te=o?.maxBuffer??Number.POSITIVE_INFINITY,X=new he(te),G,ae=!1,me=()=>{K?.down([[E,X.length]])},ue=k=>{Y&&Y.down([[E,k]])},we=o?.strategy??"drop-oldest",Be=(k,N)=>{let C={value:k,payload:N};if(X.length<te)return X.push(C),me(),!0;if(we==="drop-oldest"){let H=X.shift();return X.push(C),me(),ue(!0),S.down([[E,{value:H.value,error:new Error("backpressure: buffer overflow \u2014 dropped oldest"),attempts:0}]]),!0}if(we==="drop-newest")return ue(!0),S.down([[E,{value:k,error:new Error("backpressure: buffer overflow \u2014 dropped newest"),attempts:0}]]),!1;let A=new Error("backpressure: buffer overflow");return O({stage:"send",error:A,value:k}),S.down([[E,{value:k,error:A,attempts:0}]]),ue(!0),!1},Fe=k=>{let N=0,C=k.map(M=>M.payload),A=M=>{Q(-1);let R=se(M);if(O({stage:"send",error:R,value:k.map(ge=>ge.value),attempt:N}),!(N<y&&h(R,N))){for(let{value:ge}of k)S.down([[E,{value:ge,error:R,attempts:N}]]);return}return I(j,N,R)},H=()=>{Q(-1);for(let{value:M}of k)v.down([[E,M]])};function j(){N+=1,Q(1);let M;try{M=l(C,g)}catch(R){return A(R)??Promise.resolve()}return $(M)?M.then(H,R=>A(R)):(H(),Promise.resolve())}return j()},He=async k=>{for(let N of k)await ze(N.value,N.payload)},ze=(k,N)=>{let C=0,A=M=>{Q(-1);let R=se(M);if(O({stage:"send",error:R,value:k,attempt:C}),!(C<y&&h(R,C))){S.down([[E,{value:k,error:R,attempts:C}]]);return}return I(j,C,R)},H=()=>{Q(-1),v.down([[E,k]])};function j(){C+=1,Q(1);let M;try{M=d(N,g)}catch(R){return A(R)??Promise.resolve()}return $(M)?M.then(H,R=>A(R)):(H(),Promise.resolve())}return j()},ne=()=>{if(ae||X.length===0)return Promise.resolve();let k=X.drain();if(me(),ue(!1),l!==void 0){let C=Fe(k);return V(C),C}let N=He(k);return V(N),N},qe=()=>{G!==void 0||ae||e<=0||(G=setTimeout(()=>{G=void 0,ne()},e))},Ue=r.subscribe(k=>{for(let N of k){let C=N[0];if(C!==E)try{f?.(N)}catch{}if(C===E){let A=N[1];if(b){let H;if(a)try{H=a(A)}catch(M){let R=se(M);O({stage:"serialize",error:R,value:A}),S.down([[E,{value:A,error:R,attempts:0}]]);continue}else H=A;if(!Be(A,H))continue;X.length>=t?ne():qe()}else{let H=_(A);V(H)}}else ee.messageTier(C)>=3&&b&&(G!==void 0&&(clearTimeout(G),G=void 0),ne())}}),Se;if(c){let k=!1;Se=c.subscribe(N=>{if(!k){k=!0;return}N.length>0&&!Te&&Ee()})}let Te=!1,Ee=()=>{if(Te)return;Te=!0,G!==void 0&&(clearTimeout(G),G=void 0),b&&ne(),ae=!0,Se?.(),Ue();let k=N=>{try{N.down([[de]])}catch{}};k(F),k(S),k(v),k(L),K&&k(K),Y&&k(Y);try{p?.()}catch{}},ce={dispose:Ee,sent:v,failed:S,inFlight:L,errors:F};return b&&(ce.buffered=K,ce.flush=async()=>{ae||(await ne(),await Promise.all(q))}),Y&&(ce.paused=Y),ce}function W(r){return{describeKind:"producer",...r}}function Ke(r,n){let{parse:i,closeOnTeardown:s=!1,...u}=n??{};return B(o=>{let t=!0,e,a=()=>{let T=e;e=void 0,T?.()},c=T=>{t&&(t=!1,o.down([T]),a())},f=(T,h=T)=>{if(t)try{let b=T!==null&&typeof T=="object"&&"data"in T?T.data:T,w=i?i(b,h):b;o.emit(w)}catch(b){c([x,b])}},p=T=>{c([x,T])},d=()=>{c([P])};if(typeof r=="function"){try{if(e=r(f,p,d),typeof e!="function")throw new Error("fromWebSocket register contract violation: register must return cleanup callable")}catch(T){c([x,T])}return()=>{t=!1,a()}}let l=r,m=T=>f(T,T),g=T=>p(T),y=()=>d();return l.addEventListener("message",m),l.addEventListener("error",g),l.addEventListener("close",y),e=()=>{l.removeEventListener("message",m),l.removeEventListener("error",g),l.removeEventListener("close",y),s&&l.close()},()=>{t=!1,a()}},W(u))}function Tr(r,n){return oe(r,n)}function $e(r,n){let{method:i="GET",headers:s,body:u,transform:o=b=>b.json(),timeoutNs:t=30*1e9,signal:e,completeAfterFetch:a=!1,refetchOnSubscribe:c=!1,...f}=n??{},p=U(0,{name:`${f.name??"http"}/fetchCount`}),d=U(0,{name:`${f.name??"http"}/lastUpdated`}),l=U(!1,{name:`${f.name??"http"}/fetched`}),m=0,g=u!==void 0?typeof u=="string"?u:JSON.stringify(u):void 0,y=b=>{let w=new AbortController,v=!0;if(e?.aborted)return v=!1,b.down([[x,e.reason??new Error("Aborted")]]),()=>{};e?.addEventListener("abort",()=>w.abort(e.reason),{once:!0});let S=setTimeout(()=>w.abort(new Error("Request timeout")),Math.ceil(t/1e6));return fetch(r,{method:i,headers:s,body:g,signal:w.signal}).then(async L=>{if(clearTimeout(S),!v)return;if(!L.ok)throw new Error(`HTTP ${L.status}: ${L.statusText}`);let F=await o(L);v&&(J(()=>{m+=1,p.down([[E,m]]),d.down([[E,D()]]),l.down([[E,!0]]),b.emit(F)}),a&&b.down([[P]]))}).catch(L=>{clearTimeout(S),v&&(L&&L.name==="AbortError"||b.down([[x,L]]))}),()=>{v=!1,w.abort()}},T=B(b=>y({emit:w=>b.emit(w),down:w=>b.down(w)}),{...W(f),resubscribable:c});return{...Pe(T),fetchCount:p,lastUpdated:d,fetched:l}}function gr(r,n,i){let{method:s="POST",headers:u={"Content-Type":"application/json"},serialize:o=m=>JSON.stringify(m),timeoutNs:t,batchFormat:e="json-array",batchSize:a,flushIntervalMs:c,retry:f,onTransportError:p}=i??{},d=async m=>{let g=t!==void 0?new AbortController:void 0,y;g&&t!==void 0&&(y=setTimeout(()=>g.abort(new Error("Request timeout")),Math.ceil(t/1e6)));try{let T=await fetch(n,{method:s,headers:u,body:m,signal:g?.signal}),h=async()=>{try{await T.arrayBuffer?.()}catch{}};if(!T.ok)throw await h(),new Error(`HTTP ${T.status}: ${T.statusText}`);await h()}finally{y!==void 0&&clearTimeout(y)}};return a!==void 0||c!==void 0?z(r,{onTransportError:p,retry:f,batchSize:a,flushIntervalMs:c,sendBatch:async m=>{let g;e==="ndjson"?g=m.map(y=>{let T=o(y);return typeof T=="string"?T:new TextDecoder().decode(T)}).join(`
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 pe(fe(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 Re(()=>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 pe(fe(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 pe(fe(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,2 +0,0 @@
1
- import{a as G}from"./chunk-D27JNOLZ.js";import{j as z}from"./chunk-626TESAC.js";import{D as H,E as M,G as N,o as R}from"./chunk-LYCLF26R.js";function q(t){for(let c of t){let m=c.codePointAt(0);if(m>=19968&&m<=40959||m>=13312&&m<=19903||m>=12288&&m<=12351||m>=12352&&m<=12447||m>=12448&&m<=12543||m>=44032&&m<=55215||m>=65280&&m<=65519)return!0}return!1}var E=new Set(["\uFF0C","\uFF0E","\uFF01","\uFF1A","\uFF1B","\uFF1F","\u3001","\u3002","\u30FB","\uFF09","\u3015","\u3009","\u300B","\u300D","\u300F","\u3011"]),F=new Set([".",",","!","?",":",";",")","]","}","%",'"',"\u201D","\u2019","\xBB","\u203A","\u2026"]);function D(t){return t.replace(/[\t\n\r\f ]+/g," ").replace(/^ | $/g,"")}function O(t){let c=new Intl.Segmenter(void 0,{granularity:"word"}),m=[];for(let f of c.segment(t)){let h=f.segment,w=f.isWordLike??!1,u=[],s=[],r=[],p="",n=null;for(let i of h){let S;i===" "?S="space":i==="\u200B"?S="zero-width-break":i==="\xAD"?S="soft-hyphen":i===`
2
- `?S="hard-break":S="text",n!==null&&S===n?p+=i:(n!==null&&(u.push(p),s.push(n==="text"&&w),r.push(n)),p=i,n=S)}n!==null&&(u.push(p),s.push(n==="text"&&w),r.push(n)),m.push({texts:u,isWordLike:s,kinds:r})}return m}function V(t,c,m,f,h){let w=D(t);if(w.length===0)return[];let u=O(w),s=new Intl.Segmenter(void 0,{granularity:"grapheme"}),r=[],p=[],n=[];for(let g of u)for(let o=0;o<g.texts.length;o++)r.push(g.texts[o]),p.push(g.kinds[o]),n.push(g.isWordLike[o]);let i=[],S=[],B=[];for(let g=0;g<r.length;g++){let o=r[g],y=p[g],I=n[g];if(y==="text"&&!I&&i.length>0&&S[S.length-1]==="text"&&o.length===1&&(F.has(o)||E.has(o))){i[i.length-1]+=o;continue}if(o==="-"&&i.length>0&&S[S.length-1]==="text"&&B[B.length-1]){i[i.length-1]+=o;continue}i.push(o),S.push(y),B.push(I)}let l=f.get(c);l||(l=new Map,f.set(c,l));function b(g){let o=l.get(g);if(o===void 0){h&&(h.misses+=1);let y=m.measureSegment(g,c).width;o=Number.isFinite(y)&&y>=0?y:0,l.set(g,o)}else h&&(h.hits+=1);return o}let d=[];for(let g=0;g<i.length;g++){let o=i[g],y=S[g];if(y!=="text"){d.push({text:o,width:y==="space"?b(" ")*o.length:0,kind:y,graphemeWidths:null});continue}if(q(o)){let a="";for(let x of s.segment(o)){let k=x.segment;if(a.length>0&&E.has(k)){a+=k;continue}if(a.length>0){let L=b(a);d.push({text:a,width:L,kind:"text",graphemeWidths:null})}a=k}if(a.length>0){let x=b(a);d.push({text:a,width:x,kind:"text",graphemeWidths:null})}continue}let I=b(o),e=null;if(B[g]&&o.length>1){let a=[];for(let x of s.segment(o))a.push(b(x.segment));a.length>1&&(e=a)}d.push({text:o,width:I,kind:"text",graphemeWidths:e})}return d}function J(t,c,m,f,h){if(t.length===0)return{lines:[],lineCount:0};let w=[],u=0,s=!1,r=0,p=0,n=0,i=0,S=-1,B=0,l=h.get(f);l||(l=new Map,h.set(f,l));let b=l.get("-");b===void 0&&(b=m.measureSegment("-",f).width,l.set("-",b));function d(e=n,a=i,x=u){let k="";for(let L=r;L<e;L++){let W=t[L];if(!(W.kind==="soft-hyphen"||W.kind==="hard-break"))if(L===r&&p>0&&W.graphemeWidths){let P=[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(W.text)].map(K=>K.segment);k+=P.slice(p).join("")}else k+=W.text}if(a>0&&e<t.length){let L=t[e],v=[...new Intl.Segmenter(void 0,{granularity:"grapheme"}).segment(L.text)].map(K=>K.segment),P=r===e?p:0;k+=v.slice(P,a).join("")}e>0&&t[e-1]?.kind==="soft-hyphen"&&!(r===e&&p>0)&&(k+="-"),w.push({text:k,width:x,startSegment:r,startGrapheme:p,endSegment:e,endGrapheme:a}),u=0,s=!1,S=-1,B=0}function g(e){return e==="space"||e==="zero-width-break"||e==="soft-hyphen"}function o(e,a,x){s=!0,r=e,p=a,n=e+1,i=0,u=x}function y(e,a,x){s=!0,r=e,p=a,n=e,i=a+1,u=x}for(let e=0;e<t.length;e++){let a=t[e];if(a.kind==="hard-break"){s?d():w.push({text:"",width:0,startSegment:e,startGrapheme:0,endSegment:e,endGrapheme:0}),r=e+1,p=0;continue}let x=a.width;if(!s){x>c&&a.graphemeWidths?I(e,0,a.graphemeWidths):o(e,0,x),g(a.kind)&&(S=e+1,B=a.kind==="space"?u-x:u);continue}let k=u+x;if(k>c+.005){if(g(a.kind)){u+=x,n=e+1,i=0,d(e+1,0,a.kind==="space"?u-x:u);continue}if(S>=0){d(S,0,B),e--;continue}if(x>c&&a.graphemeWidths){d(),I(e,0,a.graphemeWidths);continue}d(),e--;continue}u=k,n=e+1,i=0,g(a.kind)&&(S=e+1,B=a.kind==="space"?u-x:u)}return s&&d(),{lines:w,lineCount:w.length};function I(e,a,x){for(let k=a;k<x.length;k++){let L=x[k];if(!s){y(e,k,L);continue}u+L>c+.005?(d(),y(e,k,L)):(u+=L,n=e,i=k+1)}s&&n===e&&i===x.length&&(n=e+1,i=0)}}function A(t){return t==="space"||t==="zero-width-break"||t==="soft-hyphen"}var T=null;function _(){return T===null&&(T=new Intl.Segmenter(void 0,{granularity:"grapheme"})),T}function j(t,c,m){if(c===0&&m<0)return t.text;let f=[..._().segment(t.text)].map(w=>w.segment),h=m<0?f.length:m;return f.slice(c,h).join("")}function C(t,c,m,f,h,w){let u="";for(let s=c;s<f;s++){let r=t[s];r.kind==="soft-hyphen"||r.kind==="hard-break"||(s===c&&m>0?u+=j(r,m,-1):u+=r.text)}if(h>0&&f<t.length){let s=t[f];u+=j(s,c===f?m:0,h)}return w&&(u+="-"),u}function $(t){if(!t?.adapter||!t.font)return 0;let c=t.cache;if(c){let m=c.get(t.font);m||(m=new Map,c.set(t.font,m));let f=m.get("-");return f===void 0&&(f=t.adapter.measureSegment("-",t.font).width,m.set("-",f)),f}return t.adapter.measureSegment("-",t.font).width}function te(t,c,m,f){let h=c.segmentIndex,w=c.graphemeIndex;if(h>=t.length)return null;if(w===0){for(;h<t.length;){let e=t[h];if(e.kind==="hard-break")return{text:"",width:0,start:{segmentIndex:c.segmentIndex,graphemeIndex:0},end:{segmentIndex:h+1,graphemeIndex:0}};if(e.kind==="space"||e.kind==="zero-width-break"||e.kind==="soft-hyphen"){h+=1;continue}break}if(h>=t.length)return null}let u=$(f),s=h,r=h===c.segmentIndex?w:0,p=0,n=s,i=0,S=!1,B=-1,l=0,b=0,d=!1,g=(e,a,x,k)=>{B=e,l=a,b=x,d=k==="soft-hyphen"},o=(e,a,x)=>{for(let k=a;k<x.length;k++){let L=x[k];if(!S){p=L,n=e,i=k+1,S=!0;continue}if(p+L>m+.005)return!0;p+=L,n=e,i=k+1}return n===e&&i===x.length&&(n=e+1,i=0),!1};if(r>0&&s<t.length){let e=t[s];if(e.graphemeWidths){if(o(s,r,e.graphemeWidths))return{text:C(t,s,r,n,i,!1),width:p,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}};h=n}}for(;h<t.length;){let e=t[h];if(e.kind==="hard-break"){if(S){let k=n>0&&t[n-1]?.kind==="soft-hyphen";return{text:C(t,s,r,n,i,k),width:p+(k?u:0),start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}}}return{text:"",width:0,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:h+1,graphemeIndex:0}}}let a=e.width;if(!S){if(a>m&&e.graphemeWidths){if(o(h,0,e.graphemeWidths))return{text:C(t,s,r,n,i,!1),width:p,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}};h=n;continue}p=a,n=h+1,i=0,S=!0,A(e.kind)&&g(h+1,0,e.kind==="space"?p-a:p,e.kind),h+=1;continue}let x=p+a;if(x>m+.005){if(A(e.kind)){n=h+1,i=0;let L=e.kind==="soft-hyphen",W=e.kind==="space"?p:p+(L?u:0);return{text:C(t,s,r,n,i,L),width:W,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}}}return B>=0?{text:C(t,s,r,B,l,d),width:b+(d?u:0),start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:B,graphemeIndex:l}}:a>m&&e.graphemeWidths?{text:C(t,s,r,n,i,!1),width:p,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}}:{text:C(t,s,r,n,i,!1),width:p,start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}}}p=x,n=h+1,i=0,A(e.kind)&&g(h+1,0,e.kind==="space"?p-a:p,e.kind),h+=1}if(!S)return null;let y=n>0&&t[n-1]?.kind==="soft-hyphen";return{text:C(t,s,r,n,i,y),width:p+(y?u:0),start:{segmentIndex:s,graphemeIndex:r},end:{segmentIndex:n,graphemeIndex:i}}}function ne(t,c,m=0){let f=[t];for(let h=0;h<c.length;h++){let w=c[h],u=[];for(let s=0;s<f.length;s++){let r=f[s];if(w.right<=r.left||w.left>=r.right){u.push(r);continue}w.left>r.left&&u.push({left:r.left,right:w.left}),w.right<r.right&&u.push({left:w.right,right:r.right})}f=u}return m>0?f.filter(h=>h.right-h.left>=m):f}function Q(t,c,m){let f=[],h=new Intl.Segmenter(void 0,{granularity:"grapheme"});for(let w=0;w<t.lines.length;w++){let u=t.lines[w],s=w*m,r=0;for(let p=u.startSegment;p<c.length;p++){let n=c[p];if(n.kind==="soft-hyphen"||n.kind==="hard-break"){if(p>=u.endSegment&&u.endGrapheme===0)break;continue}let i=[...h.segment(n.text)].map(l=>l.segment);if(i.length===0)continue;let S=p===u.startSegment?u.startGrapheme:0,B;if(p<u.endSegment)B=i.length;else if(p===u.endSegment&&u.endGrapheme>0)B=u.endGrapheme;else break;for(let l=S;l<B;l++){let b=n.graphemeWidths?n.graphemeWidths[l]:n.width/i.length;f.push({x:r,y:s,width:b,height:m,line:w}),r+=b}}}return f}function re(t){let{adapter:c,name:m="reactive-layout"}=t,f=new z(m),h=new Map,w=M(t.text??"",{name:"text"}),u=M(t.font??"16px sans-serif",{name:"font"}),s=M(t.lineHeight??20,{name:"line-height"}),r=M(Math.max(0,t.maxWidth??800),{name:"max-width"});function p(l,b){if(l===null||b===null)return l===b;if(l.length!==b.length)return!1;for(let d=0;d<l.length;d++)if(l[d]!==b[d])return!1;return!0}let n=H([w,u],(l,b,d)=>{let g=l[0],o=g!=null&&g.length>0?g.at(-1):d.prevData[0],y=l[1],I=y!=null&&y.length>0?y.at(-1):d.prevData[1],e=R(),a={hits:0,misses:0},x=V(o,I,c,h,a),k=R()-e,L=a.hits+a.misses,W=L===0?1:a.hits/L,v=n.meta;v&&(G(v["cache-hit-rate"],W),G(v["segment-count"],x.length),G(v["layout-time-ns"],k)),b.emit(x);let P=()=>{h.clear(),c.clearCache?.()};return{deactivate:P,invalidate:P}},{name:"segments",describeKind:"derived",meta:{"cache-hit-rate":0,"segment-count":0,"layout-time-ns":0},equals:(l,b)=>{let d=l,g=b;if(d==null||g==null)return d===g;if(d.length!==g.length)return!1;for(let o=0;o<d.length;o++){let y=d[o],I=g[o];if(y.text!==I.text||y.width!==I.width||y.kind!==I.kind||!p(y.graphemeWidths??null,I.graphemeWidths??null))return!1}return!0}}),i=N([n,r,u],([l,b,d])=>J(l,b,c,d,h),{name:"line-breaks",equals:(l,b)=>{let d=l,g=b;if(d==null||g==null)return d===g;if(d.lineCount!==g.lineCount)return!1;for(let o=0;o<d.lines.length;o++){let y=d.lines[o],I=g.lines[o];if(y.text!==I.text||y.width!==I.width||y.startSegment!==I.startSegment||y.startGrapheme!==I.startGrapheme||y.endSegment!==I.endSegment||y.endGrapheme!==I.endGrapheme)return!1}return!0}}),S=N([i,s],([l,b])=>l.lineCount*b,{name:"height"}),B=N([i,n,s],([l,b,d])=>Q(l,b,d),{name:"char-positions",equals:(l,b)=>{let d=l,g=b;if(d==null||g==null)return d===g;if(d.length!==g.length)return!1;for(let o=0;o<d.length;o++)if(d[o].x!==g[o].x||d[o].y!==g[o].y||d[o].width!==g[o].width)return!1;return!0}});return f.add(w,{name:"text"}),f.add(u,{name:"font"}),f.add(s,{name:"line-height"}),f.add(r,{name:"max-width"}),f.add(n,{name:"segments"}),f.add(i,{name:"line-breaks"}),f.add(S,{name:"height"}),f.add(B,{name:"char-positions"}),{graph:f,setText:l=>f.set("text",l),setFont:l=>f.set("font",l),setLineHeight:l=>f.set("line-height",l),setMaxWidth:l=>f.set("max-width",Math.max(0,l)),segments:n,lineBreaks:i,height:S,charPositions:B}}export{V as a,J as b,te as c,ne as d,Q as e,re as f};