@graphrefly/graphrefly 0.40.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/dist/{cascading-Cxs1eztH.d.cts → cascading-CH-_VwG9.d.cts} +2 -2
  2. package/dist/{cascading-BNfxffgc.d.ts → cascading-OgKQZjsa.d.ts} +2 -2
  3. package/dist/{chunk-CKFQS2CJ.js → chunk-2K5RXLAH.js} +1 -1
  4. package/dist/chunk-3ERTUW2J.js +45 -0
  5. package/dist/chunk-3K7HA4Y6.js +1 -0
  6. package/dist/chunk-3ZZX7M25.js +1 -0
  7. package/dist/chunk-4QH6VJF4.js +1 -0
  8. package/dist/{chunk-I2DEVPMU.js → chunk-5QRRKBUT.js} +1 -1
  9. package/dist/chunk-5ST42ESJ.js +1 -0
  10. package/dist/{chunk-FHRBBHJN.js → chunk-6YFZMUMR.js} +1 -1
  11. package/dist/{chunk-MNZIKXK4.js → chunk-7ARY3Y3T.js} +1 -1
  12. package/dist/chunk-7B7ELAT2.js +1 -0
  13. package/dist/{chunk-Z4F3DOWS.js → chunk-7VKFXLZQ.js} +1 -1
  14. package/dist/chunk-ACMJ2ZPS.js +3 -0
  15. package/dist/{chunk-32N3JALT.js → chunk-AGNM6RS6.js} +1 -1
  16. package/dist/chunk-AS3TV2TV.js +1 -0
  17. package/dist/{chunk-B7LCDQEV.js → chunk-CISGGAIF.js} +1 -1
  18. package/dist/{chunk-N43XM7BM.js → chunk-DEJTNNQC.js} +1 -1
  19. package/dist/{chunk-2QXRYP7Q.js → chunk-FDZAZNRO.js} +1 -1
  20. package/dist/{chunk-QSK3RRII.js → chunk-FUZ6S2DY.js} +1 -1
  21. package/dist/{chunk-LYM4PBMV.js → chunk-G5VBJ5K6.js} +1 -1
  22. package/dist/{chunk-6I726LZU.js → chunk-HZKW2AAB.js} +1 -1
  23. package/dist/{chunk-LCGAVGGV.js → chunk-IZM3UEH3.js} +3 -3
  24. package/dist/{chunk-2DMKW2AD.js → chunk-KCACBSJH.js} +1 -1
  25. package/dist/{chunk-SSCGRYJ2.js → chunk-KT5DTRBP.js} +1 -1
  26. package/dist/{chunk-WL6LFPJB.js → chunk-KY2LMAXU.js} +1 -1
  27. package/dist/{chunk-YXDRGKXP.js → chunk-LDQ3IUIP.js} +1 -1
  28. package/dist/chunk-LPRWATHB.js +61 -0
  29. package/dist/{chunk-6VWBPSSY.js → chunk-NWXQIOIB.js} +3 -3
  30. package/dist/{chunk-XW4YDF6G.js → chunk-Q7QQQA3I.js} +1 -1
  31. package/dist/chunk-VE5SIZEM.js +1 -0
  32. package/dist/chunk-VRALOYRD.js +1 -0
  33. package/dist/{chunk-XJLYLLIJ.js → chunk-WHMUB5QB.js} +1 -1
  34. package/dist/chunk-XLQPNNIC.js +1 -0
  35. package/dist/{chunk-JKBOIJ22.js → chunk-YGL7FPVQ.js} +1 -1
  36. package/dist/compat/index.cjs +5 -5
  37. package/dist/compat/index.d.cts +16 -16
  38. package/dist/compat/index.d.ts +16 -16
  39. package/dist/compat/index.js +1 -1
  40. package/dist/compat/jotai/index.d.cts +2 -2
  41. package/dist/compat/jotai/index.d.ts +2 -2
  42. package/dist/compat/nanostores/index.d.cts +2 -2
  43. package/dist/compat/nanostores/index.d.ts +2 -2
  44. package/dist/compat/nestjs/index.cjs +5 -5
  45. package/dist/compat/nestjs/index.d.cts +8 -8
  46. package/dist/compat/nestjs/index.d.ts +8 -8
  47. package/dist/compat/nestjs/index.js +1 -1
  48. package/dist/compat/react/index.d.cts +2 -2
  49. package/dist/compat/react/index.d.ts +2 -2
  50. package/dist/compat/solid/index.d.cts +2 -2
  51. package/dist/compat/solid/index.d.ts +2 -2
  52. package/dist/compat/svelte/index.d.cts +2 -2
  53. package/dist/compat/svelte/index.d.ts +2 -2
  54. package/dist/compat/vue/index.d.cts +2 -2
  55. package/dist/compat/vue/index.d.ts +2 -2
  56. package/dist/compat/zustand/index.cjs +3 -3
  57. package/dist/compat/zustand/index.d.cts +4 -4
  58. package/dist/compat/zustand/index.d.ts +4 -4
  59. package/dist/compat/zustand/index.js +1 -1
  60. package/dist/core/index.d.cts +4 -4
  61. package/dist/core/index.d.ts +4 -4
  62. package/dist/{decay-C25AyNAj.d.cts → decay-2ZukgQ4o.d.cts} +2 -2
  63. package/dist/{decay-BnrlbxSv.d.ts → decay-CdEBmDIs.d.ts} +2 -2
  64. package/dist/extra/browser.d.cts +1 -1
  65. package/dist/extra/browser.d.ts +1 -1
  66. package/dist/extra/index.cjs +14 -14
  67. package/dist/extra/index.d.cts +10 -11
  68. package/dist/extra/index.d.ts +10 -11
  69. package/dist/extra/index.js +1 -1
  70. package/dist/extra/node.cjs +2 -2
  71. package/dist/extra/node.d.cts +1 -1
  72. package/dist/extra/node.d.ts +1 -1
  73. package/dist/extra/node.js +1 -1
  74. package/dist/extra/operators.cjs +1 -1
  75. package/dist/extra/operators.d.cts +1 -1
  76. package/dist/extra/operators.d.ts +1 -1
  77. package/dist/extra/operators.js +1 -1
  78. package/dist/extra/reactive.d.cts +3 -3
  79. package/dist/extra/reactive.d.ts +3 -3
  80. package/dist/extra/reactive.js +1 -1
  81. package/dist/extra/render/index.d.cts +3 -3
  82. package/dist/extra/render/index.d.ts +3 -3
  83. package/dist/extra/sources.cjs +3 -1
  84. package/dist/extra/sources.d.cts +1 -1
  85. package/dist/extra/sources.d.ts +1 -1
  86. package/dist/extra/sources.js +1 -1
  87. package/dist/extra/storage-browser.d.cts +1 -1
  88. package/dist/extra/storage-browser.d.ts +1 -1
  89. package/dist/{fallback-CMZl39L5.d.ts → fallback-CqYVLL6X.d.ts} +1 -1
  90. package/dist/{fallback-8JYU8tlT.d.cts → fallback-Ctlj2tMY.d.cts} +1 -1
  91. package/dist/graph/index.cjs +7 -7
  92. package/dist/graph/index.d.cts +5 -5
  93. package/dist/graph/index.d.ts +5 -5
  94. package/dist/graph/index.js +1 -1
  95. package/dist/{graph-BkIkog4h.d.ts → graph-7VguS7a4.d.ts} +3 -3
  96. package/dist/{graph-E6likq7w.d.cts → graph-C4SHb3Ly.d.cts} +3 -3
  97. package/dist/{index-DktLSZOc.d.cts → index-2B7u2pVn.d.cts} +4 -4
  98. package/dist/{index-BTHOTC0Q.d.cts → index-3NmAfcH0.d.cts} +25 -7
  99. package/dist/{index-D1IEZUsj.d.ts → index-4Uz-e_fL.d.ts} +573 -213
  100. package/dist/{index-BAQrjuZF.d.ts → index-B-i4_g3k.d.ts} +2 -2
  101. package/dist/{index-DpiGqtrs.d.cts → index-B11anra4.d.cts} +441 -381
  102. package/dist/{index-WSlcjhQF.d.ts → index-B3OTH1dV.d.ts} +124 -13
  103. package/dist/{index-2n8Eai6M.d.ts → index-BG0BN3PB.d.ts} +1 -1
  104. package/dist/{index-z8WFPVI8.d.cts → index-BJX94aud.d.cts} +1 -1
  105. package/dist/{index-DhLyOHYZ.d.ts → index-BP8a88zx.d.ts} +11 -4
  106. package/dist/{index-Cnr1WrlX.d.cts → index-BTQtTb_H.d.cts} +14 -3
  107. package/dist/{index-BaA-xpSw.d.ts → index-BUYXac2c.d.ts} +3 -3
  108. package/dist/{index-DOBLxOti.d.cts → index-BVpm6noz.d.cts} +1 -1
  109. package/dist/{index-DhnsQfa3.d.ts → index-Bbkgpt5t.d.ts} +441 -381
  110. package/dist/{index-Cczxgd2D.d.ts → index-Bc41FuHp.d.cts} +3 -3
  111. package/dist/{index-BiHUBEKq.d.cts → index-BdGtBX-X.d.cts} +3 -3
  112. package/dist/index-BeT2r7sk.d.ts +760 -0
  113. package/dist/{index-da2V5vPy.d.ts → index-Bf7eqeSF.d.ts} +2 -2
  114. package/dist/{index-bXXLSvor.d.ts → index-Bn4zHYLj.d.ts} +4 -4
  115. package/dist/{index-DGTo1yka.d.cts → index-BoLv_OfD.d.cts} +2 -2
  116. package/dist/{index-B72TQQHd.d.cts → index-BsT7F2et.d.ts} +3 -3
  117. package/dist/{index-Bd91Nmf4.d.cts → index-BtAsBp8K.d.cts} +4 -4
  118. package/dist/{index-DgJc8Zgc.d.cts → index-C0-Jv1kP.d.cts} +81 -5
  119. package/dist/{index-C6ZUaos7.d.ts → index-C7O6r5fV.d.ts} +1 -1
  120. package/dist/{index-CL7oilfm.d.cts → index-C9kSENB4.d.cts} +1 -1
  121. package/dist/{index-yLt-aPMp.d.ts → index-CCq87F7t.d.ts} +1 -1
  122. package/dist/{index-DQQCOIt8.d.cts → index-CEMx8n40.d.cts} +10 -5
  123. package/dist/{index-BilOa6AE.d.cts → index-CJIuLu2f.d.cts} +124 -13
  124. package/dist/{index-B2RUoIUz.d.ts → index-CJK1JkYy.d.ts} +1 -1
  125. package/dist/{index-IUCY0OFN.d.ts → index-CJQm0g38.d.ts} +25 -7
  126. package/dist/index-CPNSy-U0.d.cts +760 -0
  127. package/dist/{index-A3U3CSve.d.cts → index-CZjOhcBy.d.cts} +2 -2
  128. package/dist/{index-CAP3UGsq.d.ts → index-CZmcDtFn.d.ts} +1 -1
  129. package/dist/{index-DYTBbF8T.d.cts → index-ChOyVLKm.d.cts} +1 -1
  130. package/dist/{index-eaQuGJnv.d.ts → index-CpyNFqkB.d.ts} +3 -3
  131. package/dist/{index-BJSZxSFX.d.ts → index-CvrqGfNS.d.ts} +1 -1
  132. package/dist/{index-DJ_MPOJ5.d.cts → index-D-Xs74HZ.d.cts} +573 -213
  133. package/dist/{index-C5cQ7Gfx.d.ts → index-D6egPFAL.d.ts} +4 -4
  134. package/dist/{index-CD2dBMet.d.ts → index-D8l8hNXn.d.ts} +10 -5
  135. package/dist/{index-40ZT4MHj.d.ts → index-DBHK8O6H.d.ts} +14 -3
  136. package/dist/{index-DVDapw2k.d.cts → index-DBIqYS43.d.cts} +35 -21
  137. package/dist/{index-3k4Gg6-n.d.ts → index-DBevwHj_.d.ts} +3 -3
  138. package/dist/{index-Ctb7_2sG.d.ts → index-DIOoAZUX.d.ts} +1 -1
  139. package/dist/{index-BQ1fR4li.d.ts → index-DO9XxMzS.d.ts} +35 -21
  140. package/dist/{index-CQtWm7jS.d.ts → index-DQo8xBgd.d.ts} +9 -9
  141. package/dist/{index-DH4fm2Ck.d.ts → index-Dgs8zcj7.d.ts} +2 -2
  142. package/dist/{index-CtFNGe-m.d.cts → index-Dhc7a7Xo.d.cts} +2 -2
  143. package/dist/{index-MxYuWOrf.d.cts → index-DmAgG5CI.d.cts} +3 -3
  144. package/dist/{index-CoM4rzyB.d.ts → index-Dmqp7KjD.d.ts} +1 -1
  145. package/dist/{index-B6iTqKtJ.d.ts → index-Dn-wI9g4.d.ts} +2 -2
  146. package/dist/{index-C-dkXOpB.d.cts → index-Du7u1lSf.d.cts} +11 -4
  147. package/dist/{index-DVAlsmEU.d.cts → index-HoU88d5U.d.cts} +3 -3
  148. package/dist/{index-CRm0YIzC.d.cts → index-LIpQQE9f.d.cts} +9 -9
  149. package/dist/{index-CgnCFhr2.d.cts → index-f5IivDUX.d.cts} +1 -1
  150. package/dist/{index-PgwvGWa1.d.cts → index-hHcaFlJX.d.cts} +1 -1
  151. package/dist/{index-I1cCY3ZI.d.ts → index-pT8sCpOJ.d.ts} +81 -5
  152. package/dist/{index-D4uimgee.d.cts → index-sl4NyzQx.d.cts} +1 -1
  153. package/dist/{index-tV3AA9hI.d.cts → index-tJoTcnHh.d.cts} +2 -2
  154. package/dist/{index-D3ayz3hy.d.cts → index-z96luz5O.d.cts} +1 -1
  155. package/dist/index.cjs +48 -48
  156. package/dist/index.d.cts +45 -50
  157. package/dist/index.d.ts +45 -50
  158. package/dist/index.js +1 -1
  159. package/dist/{meta-D8OyedKp.d.ts → meta-BgVAsg9j.d.ts} +1 -1
  160. package/dist/{meta-Ct9nqQS5.d.cts → meta-vE8bxW1E.d.cts} +1 -1
  161. package/dist/{node-BYInONRr.d.cts → node-ClS5yC-B.d.cts} +1 -1
  162. package/dist/{node-BYInONRr.d.ts → node-ClS5yC-B.d.ts} +1 -1
  163. package/dist/{observable-DO8DDEzv.d.ts → observable-BsBzUrcI.d.ts} +1 -1
  164. package/dist/{observable-DMIlYJV1.d.cts → observable-DLGPPtb8.d.cts} +1 -1
  165. package/dist/patterns/ai/browser.d.cts +4 -4
  166. package/dist/patterns/ai/browser.d.ts +4 -4
  167. package/dist/patterns/ai/browser.js +1 -1
  168. package/dist/patterns/ai/index.cjs +17 -17
  169. package/dist/patterns/ai/index.d.cts +17 -17
  170. package/dist/patterns/ai/index.d.ts +17 -17
  171. package/dist/patterns/ai/index.js +1 -1
  172. package/dist/patterns/ai/node.d.cts +4 -4
  173. package/dist/patterns/ai/node.d.ts +4 -4
  174. package/dist/patterns/ai/node.js +1 -1
  175. package/dist/patterns/cqrs/index.cjs +3 -3
  176. package/dist/patterns/cqrs/index.d.cts +6 -6
  177. package/dist/patterns/cqrs/index.d.ts +6 -6
  178. package/dist/patterns/cqrs/index.js +1 -1
  179. package/dist/patterns/demo-shell/index.cjs +5 -5
  180. package/dist/patterns/demo-shell/index.d.cts +5 -5
  181. package/dist/patterns/demo-shell/index.d.ts +5 -5
  182. package/dist/patterns/demo-shell/index.js +1 -1
  183. package/dist/patterns/domain-templates/index.cjs +3 -3
  184. package/dist/patterns/domain-templates/index.d.cts +4 -4
  185. package/dist/patterns/domain-templates/index.d.ts +4 -4
  186. package/dist/patterns/domain-templates/index.js +1 -1
  187. package/dist/patterns/graphspec/index.cjs +12 -12
  188. package/dist/patterns/graphspec/index.d.cts +5 -5
  189. package/dist/patterns/graphspec/index.d.ts +5 -5
  190. package/dist/patterns/graphspec/index.js +1 -1
  191. package/dist/patterns/harness/index.cjs +10 -8
  192. package/dist/patterns/harness/index.d.cts +11 -12
  193. package/dist/patterns/harness/index.d.ts +11 -12
  194. package/dist/patterns/harness/index.js +1 -1
  195. package/dist/patterns/inspect/index.cjs +3 -0
  196. package/dist/patterns/inspect/index.d.cts +9 -0
  197. package/dist/patterns/inspect/index.d.ts +9 -0
  198. package/dist/patterns/inspect/index.js +1 -0
  199. package/dist/patterns/job-queue/index.cjs +3 -3
  200. package/dist/patterns/job-queue/index.d.cts +6 -6
  201. package/dist/patterns/job-queue/index.d.ts +6 -6
  202. package/dist/patterns/job-queue/index.js +1 -1
  203. package/dist/patterns/memory/index.cjs +3 -3
  204. package/dist/patterns/memory/index.d.cts +6 -6
  205. package/dist/patterns/memory/index.d.ts +6 -6
  206. package/dist/patterns/memory/index.js +1 -1
  207. package/dist/patterns/messaging/index.cjs +3 -3
  208. package/dist/patterns/messaging/index.d.cts +5 -5
  209. package/dist/patterns/messaging/index.d.ts +5 -5
  210. package/dist/patterns/messaging/index.js +1 -1
  211. package/dist/patterns/orchestration/index.cjs +3 -3
  212. package/dist/patterns/orchestration/index.d.cts +7 -7
  213. package/dist/patterns/orchestration/index.d.ts +7 -7
  214. package/dist/patterns/orchestration/index.js +1 -1
  215. package/dist/patterns/process/index.cjs +1 -1
  216. package/dist/patterns/process/index.d.cts +7 -7
  217. package/dist/patterns/process/index.d.ts +7 -7
  218. package/dist/patterns/process/index.js +1 -1
  219. package/dist/patterns/reactive-layout/index.cjs +4 -4
  220. package/dist/patterns/reactive-layout/index.d.cts +5 -5
  221. package/dist/patterns/reactive-layout/index.d.ts +5 -5
  222. package/dist/patterns/reactive-layout/index.js +1 -1
  223. package/dist/patterns/reduction/index.cjs +3 -3
  224. package/dist/patterns/reduction/index.d.cts +4 -4
  225. package/dist/patterns/reduction/index.d.ts +4 -4
  226. package/dist/patterns/reduction/index.js +1 -1
  227. package/dist/patterns/surface/index.cjs +8 -8
  228. package/dist/patterns/surface/index.d.cts +6 -6
  229. package/dist/patterns/surface/index.d.ts +6 -6
  230. package/dist/patterns/surface/index.js +1 -1
  231. package/dist/{pipeline-graph-MWrQZXCq.d.cts → pipeline-graph-WBlobVhU.d.cts} +5 -5
  232. package/dist/{pipeline-graph-CB4La-UW.d.ts → pipeline-graph-v8fMvqNk.d.ts} +5 -5
  233. package/dist/{reactive-layout-BtZfUKuL.d.cts → reactive-layout-Dsvob4zD.d.cts} +2 -2
  234. package/dist/{reactive-layout-KJj4E2dT.d.ts → reactive-layout-v7KPvxoc.d.ts} +2 -2
  235. package/dist/{reactive-log-_zeEnB9H.d.cts → reactive-log-B00laMSQ.d.cts} +1 -1
  236. package/dist/{reactive-log-BlAsPLl2.d.ts → reactive-log-BezYsbA_.d.ts} +1 -1
  237. package/dist/{reactive-map-6P_k3AQM.d.cts → reactive-map-48mnZ-nu.d.cts} +1 -1
  238. package/dist/{reactive-map-CjXByDV-.d.ts → reactive-map-BVVPdvmi.d.ts} +1 -1
  239. package/dist/resilience-445VFFXQ.js +1 -0
  240. package/dist/{sugar-BhfjgetH.d.ts → sugar-CH-2ZY90.d.ts} +1 -1
  241. package/dist/{sugar-DzePN5-g.d.cts → sugar-DStZfUEK.d.cts} +1 -1
  242. package/dist/{topology-tree-mF7Emqzm.d.ts → topology-tree-BNGvuG82.d.ts} +1 -1
  243. package/dist/{topology-tree-3LBKFsUo.d.cts → topology-tree-BSdfSwMi.d.cts} +1 -1
  244. package/dist/{types-1Dhoi7HM.d.cts → types-B1jDWVsM.d.cts} +1 -1
  245. package/dist/{types-39jk0kaV.d.ts → types-DkzUUs0H.d.ts} +1 -1
  246. package/package.json +11 -51
  247. package/dist/budget-gate-CmmVtasH.d.ts +0 -115
  248. package/dist/budget-gate-DiP_nK0n.d.cts +0 -115
  249. package/dist/chunk-2BX4NB34.js +0 -3
  250. package/dist/chunk-6XVD5TZV.js +0 -1
  251. package/dist/chunk-756D5TFD.js +0 -1
  252. package/dist/chunk-7Q4ZD3YW.js +0 -1
  253. package/dist/chunk-ECQRP2UT.js +0 -1
  254. package/dist/chunk-INQFTVZA.js +0 -61
  255. package/dist/chunk-J63M5U46.js +0 -1
  256. package/dist/chunk-K2Z7UENB.js +0 -1
  257. package/dist/chunk-OSZ22J7O.js +0 -1
  258. package/dist/chunk-PPUYQ66A.js +0 -1
  259. package/dist/chunk-RZJDIV2G.js +0 -1
  260. package/dist/chunk-SGS4OJGS.js +0 -1
  261. package/dist/chunk-SVFKHUCW.js +0 -1
  262. package/dist/chunk-UWA6D7UF.js +0 -3
  263. package/dist/chunk-VMF23LGB.js +0 -1
  264. package/dist/chunk-WUT362QV.js +0 -1
  265. package/dist/chunk-YKD7WUYJ.js +0 -43
  266. package/dist/index-8s-Qm-gz.d.ts +0 -218
  267. package/dist/index-BgjS2b8N.d.ts +0 -366
  268. package/dist/index-BmSQLAZo.d.cts +0 -244
  269. package/dist/index-CGhMJNHb.d.cts +0 -128
  270. package/dist/index-CUIkE1l9.d.cts +0 -230
  271. package/dist/index-Ck35nA-T.d.ts +0 -244
  272. package/dist/index-CuPUehFa.d.cts +0 -218
  273. package/dist/index-D1Gc7wV5.d.ts +0 -230
  274. package/dist/index-N2MAxt7_.d.ts +0 -128
  275. package/dist/index-t6L2qpHh.d.cts +0 -366
  276. package/dist/patterns/audit/index.cjs +0 -3
  277. package/dist/patterns/audit/index.d.cts +0 -8
  278. package/dist/patterns/audit/index.d.ts +0 -8
  279. package/dist/patterns/audit/index.js +0 -1
  280. package/dist/patterns/guarded-execution/index.cjs +0 -3
  281. package/dist/patterns/guarded-execution/index.d.cts +0 -9
  282. package/dist/patterns/guarded-execution/index.d.ts +0 -9
  283. package/dist/patterns/guarded-execution/index.js +0 -1
  284. package/dist/patterns/lens/index.cjs +0 -3
  285. package/dist/patterns/lens/index.d.cts +0 -7
  286. package/dist/patterns/lens/index.d.ts +0 -7
  287. package/dist/patterns/lens/index.js +0 -1
  288. package/dist/patterns/refine-loop/index.cjs +0 -5
  289. package/dist/patterns/refine-loop/index.d.cts +0 -9
  290. package/dist/patterns/refine-loop/index.d.ts +0 -9
  291. package/dist/patterns/refine-loop/index.js +0 -1
  292. package/dist/patterns/resilient-pipeline/index.cjs +0 -3
  293. package/dist/patterns/resilient-pipeline/index.d.cts +0 -8
  294. package/dist/patterns/resilient-pipeline/index.d.ts +0 -8
  295. package/dist/patterns/resilient-pipeline/index.js +0 -1
  296. package/dist/resilience-S33JV6XC.js +0 -1
@@ -1,3 +1,3 @@
1
- "use strict";var Ze=Object.defineProperty;var hn=Object.getOwnPropertyDescriptor;var gn=Object.getOwnPropertyNames;var mn=Object.prototype.hasOwnProperty;var W=(r,e)=>()=>(r&&(e=r(r=0)),e);var bn=(r,e)=>{for(var t in e)Ze(r,t,{get:e[t],enumerable:!0})},yn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of gn(e))!mn.call(r,s)&&s!==t&&Ze(r,s,{get:()=>e[s],enumerable:!(n=hn(e,s))||n.enumerable});return r};var vn=r=>yn(Ze({},"__esModule",{value:!0}),r);function Ce(){return he>0||Ne}function Et(){return he>0}function me(r){he>0?xe.push(r):r()}function ie(r){he+=1;let e=!1;try{r()}catch(t){throw e=!0,t}finally{if(he-=1,he===0)if(e){if(!Ne){let t=xe.splice(0);for(let n of t)try{n()}catch{}le.length=0,fe.length=0,ge.length=0}}else _n()}}function _n(){let r=!Ne;r&&(Ne=!0);let e=[],t=0;try{for(;le.length>0||fe.length>0||ge.length>0||r&&xe.length>0;){if(r&&xe.length>0){let o=xe.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(t+=1,t>1e3)throw le.length=0,fe.length=0,ge.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(le.length>0?le:fe.length>0?fe:ge).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{r&&(Ne=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Ge(r,e,t){if(e.length===0)return;if(e.length===1){let d=t(e[0][0]);if(d<3||!Ce()){r(e);return}(d>=5?ge:d===4?fe:le).push(()=>r(e));return}let n=e.length,s=n,o=n,i=n,a=0;for(;a<n&&t(e[a][0])<3;)a++;for(s=a;a<n&&t(e[a][0])===3;)a++;for(o=a;a<n&&t(e[a][0])===4;)a++;i=a;let u=Ce();if(s>0){let d=e.slice(0,s);r(d)}if(o>s){let d=e.slice(s,o);u?le.push(()=>r(d)):r(d)}if(i>o){let d=e.slice(o,i);u?fe.push(()=>r(d)):r(d)}if(n>i){let d=e.slice(i,n);u?ge.push(()=>r(d)):r(d)}}var he,Ne,le,fe,ge,xe,be=W(()=>{"use strict";he=0,Ne=!1,le=[],fe=[],ge=[],xe=[]});function St(r,e){let t=new TextEncoder().encode(r.name);if(t.length===0||t.length>255)throw new Error(`encodeEnvelope: codec name "${r.name}" encodes to ${t.length} bytes (must be 1\u2013255)`);let n=r.version;if(!Number.isInteger(n)||n<0||n>65535)throw new Error(`encodeEnvelope: codec.version ${n} out of u16 range (expected integer 0\u201365535)`);let s=2+t.length+2+e.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let o=new Uint8Array(s),i=0;return o[i++]=et,o[i++]=t.length,o.set(t,i),i+=t.length,o[i++]=n>>>8&255,o[i++]=n&255,o.set(e,i),o}function Dt(r,e){if(r.length<At)throw new Error(`decodeEnvelope: bytes too short (${r.length} < ${At})`);let t=0,n=r[t++];if(n!==et)throw new Error(`decodeEnvelope: unsupported envelope version ${n} (expected ${et})`);let s=r[t++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+s+2>r.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+s+2} bytes, have ${r.length})`);let o=new TextDecoder().decode(r.subarray(t,t+s));t+=s;let i=(r[t]<<8|r[t+1])>>>0;t+=2;let a=r.subarray(t),u=e.lookupCodec(o);if(u==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:u,codecVersion:i,payload:a}}function Mt(r){r.registerCodec(wn)}var wn,et,At,tt=W(()=>{"use strict";wn={name:"json",version:1,contentType:"application/json",encode(r){let e=JSON.stringify(r);return new TextEncoder().encode(e)},decode(r,e){let t=new TextDecoder().decode(r);return JSON.parse(t)}},et=1,At=4});function $e(r){if(r==null)return ye;let{type:e,id:t,...n}=r;return{type:e??"system",id:t??"",...n}}var ye,nt=W(()=>{"use strict";ye={type:"system",id:""}});function re(){return Math.trunc(performance.now()*1e6)}function Pe(){return Date.now()*1e6}var Ie=W(()=>{"use strict"});var Oe,C,B,U,Q,ee,ae,j,H,$,ve,rt,kn,st,Tn,Nn,ot,Ct,Gt,$t,it,ue=W(()=>{"use strict";Oe=Symbol.for("graphrefly/START"),C=Symbol.for("graphrefly/DATA"),B=Symbol.for("graphrefly/DIRTY"),U=Symbol.for("graphrefly/RESOLVED"),Q=Symbol.for("graphrefly/INVALIDATE"),ee=Symbol.for("graphrefly/PAUSE"),ae=Symbol.for("graphrefly/RESUME"),j=Symbol.for("graphrefly/TEARDOWN"),H=Symbol.for("graphrefly/COMPLETE"),$=Symbol.for("graphrefly/ERROR"),ve=Object.freeze([B]),rt=Object.freeze([U]),kn=Object.freeze([Q]),st=Object.freeze([Oe]),Tn=Object.freeze([H]),Nn=Object.freeze([j]),ot=Object.freeze([ve]),Ct=Object.freeze([rt]),Gt=Object.freeze([kn]),$t=Object.freeze([Tn]),it=Object.freeze([Nn])});function Pt(r){r.registerMessageType(Oe,{tier:0,wireCrossing:!1}),r.registerMessageType(B,{tier:1,wireCrossing:!1}),r.registerMessageType(Q,{tier:1,wireCrossing:!1,metaPassthrough:!1}),r.registerMessageType(ee,{tier:2,wireCrossing:!1}),r.registerMessageType(ae,{tier:2,wireCrossing:!1}),r.registerMessageType(C,{tier:3,wireCrossing:!0}),r.registerMessageType(U,{tier:3,wireCrossing:!0}),r.registerMessageType(H,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType($,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType(j,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Fe,It=W(()=>{"use strict";ue();Fe=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 n=this._messageTypes.get(t);return n!=null?n.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 Ft(r){return Array.isArray(r)?[...r]:[r]}function xn(r,e){return r.has(e)||r.has("*")}function Lt(r){let e=[];return r((s,o)=>{e.push({kind:"allow",actions:new Set(Ft(s)),where:o?.where??(()=>!0)})},(s,o)=>{e.push({kind:"deny",actions:new Set(Ft(s)),where:o?.where??(()=>!0)})}),(s,o)=>{let i=!1,a=!1;for(let u of e)xn(u.actions,o)&&u.where(s)&&(u.kind==="deny"?i=!0:a=!0);return i?!1:a}}function at(r){let e=On.filter(t=>r({type:t,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(t=>t==="human"||t==="llm"||t==="system")?"both":e.length===1?e[0]:e.join("+")}var J,On,Re=W(()=>{"use strict";J=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}};On=["human","llm","wallet","system"]});function ut(r){if(r===void 0)return null;if(typeof r=="number"){if(!Number.isFinite(r))throw new TypeError(`Cannot hash non-finite number: ${r}`);if(Number.isInteger(r)&&!Number.isSafeInteger(r))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${r}. Cross-language cid parity is not guaranteed for unsafe integers.`);return r}if(typeof r=="string"||typeof r=="boolean"||r===null)return r;if(Array.isArray(r))return r.map(ut);if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r).sort())e[t]=ut(r[t]);return e}return null}function An(r){let e=En.encode(r),t=e.length,n=t*8,s=t+9+63&-64,o=new Uint8Array(s);o.set(e),o[t]=128;let i=new DataView(o.buffer);i.setUint32(s-4,n>>>0,!1),i.setUint32(s-8,Math.floor(n/4294967296)>>>0,!1);let a=1779033703,u=3144134277,d=1013904242,c=2773480762,h=1359893119,g=2600822924,m=528734635,l=1541459225,y=new Uint32Array(64),f=(v,b)=>v>>>b|v<<32-b;for(let v=0;v<s;v+=64){for(let N=0;N<16;N++)y[N]=i.getUint32(v+N*4,!1);for(let N=16;N<64;N++){let A=y[N-15],M=y[N-2],D=f(A,7)^f(A,18)^A>>>3,oe=f(M,17)^f(M,19)^M>>>10;y[N]=y[N-16]+D+y[N-7]+oe>>>0}let b=a,p=u,w=d,x=c,_=h,T=g,O=m,E=l;for(let N=0;N<64;N++){let A=f(_,6)^f(_,11)^f(_,25),M=_&T^~_&O,D=E+A+M+Rn[N]+y[N]>>>0,oe=f(b,2)^f(b,13)^f(b,22),ne=b&p^b&w^p&w,De=oe+ne>>>0;E=O,O=T,T=_,_=x+D>>>0,x=w,w=p,p=b,b=D+De>>>0}a=a+b>>>0,u=u+p>>>0,d=d+w>>>0,c=c+x>>>0,h=h+_>>>0,g=g+T>>>0,m=m+O>>>0,l=l+E>>>0}let k=v=>v.toString(16).padStart(8,"0");return k(a)+k(u)+k(d)+k(c)+k(h)+k(g)+k(m)+k(l)}function dt(r){let e=ut(r??null),t=JSON.stringify(e);return An(t).slice(0,16)}function Sn(){let r=globalThis.crypto;if(r?.randomUUID)return r.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 ct(r,e,t){let n=t?.id??Sn();if(r===0)return{id:n,version:0};let o=(t?.hash??dt)(e);return{id:n,version:0,cid:o,prev:null}}function zt(r,e,t){r.version+=1,"cid"in r&&(r.prev=r.cid,r.cid=t(e))}var Rn,En,Vt=W(()=>{"use strict";Rn=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]),En=new TextEncoder});function Ht(r){return{node:r,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function lt(r){r.prevData=void 0,r.dirty=!1,r.involvedThisWave=!1,r.dataBatch.length=0,r.terminal=void 0}function Le(r){return r.length===0?r:typeof r[0]=="symbol"?[r]:r}function X(r,e,t){let n=Ut(r)?r:[],s=typeof r=="function"?r:typeof e=="function"?e:void 0,o={};return Ut(r)?o=(ft(e)?e:t)??{}:ft(r)?o=r:o=(ft(e)?e:t)??{},new z(n,s,o)}var jt,Bt,Dn,Mn,_e,z,Ut,ft,de=W(()=>{"use strict";tt();nt();be();Ie();It();Re();ue();Vt();jt=()=>{},Bt=100;Dn=(r,e,t,n)=>{t.direction==="down-in"&&r._onDepMessage(t.depIndex,e)},Mn=(r,e,t,n)=>{let s=r;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[st]:[st,[C,o]];s._status==="dirty"&&i.push(ve),Ge(e,i,s._config.tierOf)},_e=new Fe({onMessage:Dn,onSubscribe:Mn});Pt(_e);Mt(_e);z=class r{_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,n){this._config=n.config??_e,this._config.onMessage,this._optsName=n.name,this._describeKind=n.describeKind,this._equals=n.equals??Object.is,this._resubscribable=n.resubscribable??!1,this._resetOnTeardown=n.resetOnTeardown??!1,this._autoComplete=n.completeWhenDepsComplete??!0,this._autoError=n.errorWhenDepsError??!0,this._pausable=n.pausable??!0,this._guard=n.guard,this._fn=t,this._partial=n.partial??!1,this._cached=n.initial!==void 0?n.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=n.versioningHash??this._config.defaultHashFn??dt;let s=n.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?ct(s,this._cached===void 0?void 0:this._cached,{id:n.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Ht);let o={};for(let[a,u]of Object.entries(n.meta??{})){let d={initial:u,name:`${n.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};n.guard!=null&&(d.guard=n.guard),o[a]=new r([],void 0,d)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[C,a]])},down(a){i._emit(Le(a))},up(a){i._emitUp(Le(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let n=this._versioningLevel;if(n!=null&&e<=n)return;let s=t?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??t?.id,u=i?.version??0,d=ct(e,o,{id:a,hash:s});d.version=u,this._versioning=d,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=$e(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let n of this._extraGuards)if(!n(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,n=e?.actor!=null;if(!t&&!n)return;let s=$e(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new J({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new J({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:Pe()}}down(e,t){let n=Le(e);n.length!==0&&(this._checkGuard(t),this._emit(n))}emit(e,t){this._checkGuard(t),this._emit([[C,e]])}up(e,t){if(this._deps.length===0)return;let n=Le(e);if(n.length===0)return;this._checkGuard(t);let s=t??{internal:!0};this._validateUpTiers(n);for(let o of this._deps)o.node.up?.(n,s)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let n of e){let s=t(n[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let u=$e(t);if(!this._guard(u,"observe"))throw new J({actor:u,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let u of this._deps)lt(u);if(this._partial===!1){for(let u of this._deps)if(u.prevData!==void 0||u.dataBatch.length!==0||u.terminal!==void 0||u.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(u){throw this._sinkCount-=1,u}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(u){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw u}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[t]=this._sinks;this._sinks=t}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,t=0;try{for(let n=0;n<e;n++){let s=n,o=this._deps[n];o.unsub=jt,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,u=!1;for(let d of i)a(d[0])>=3&&(u=!0),this._config.onMessage(this,d,{direction:"down-in",depIndex:s},this._actions);u&&this._maybeRunFnOnSettlement()}),t++}}catch(n){this._deps[t].unsub=null;for(let s=0;s<t;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}lt(o)}}throw this._dirtyDepCount=0,n}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let t=this._deps.length,n=Ht(e);if(this._deps.push(n),this._sinks==null)return t;n.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ot),n.unsub=jt;try{n.unsub=e.subscribe(s=>{if(n.unsub===null)return;let o=this._config.tierOf,i=!1;for(let a of s)o(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:t},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw n.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(n){this._emit([[$,this._wrapFnError("cleanup threw",n)]])}else if(t!=null&&typeof t=="object"){let n=t.deactivate;if(typeof n=="function")try{n()}catch(s){this._emit([[$,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let n of this._deps){if(n.unsub!=null){let s=n.unsub;n.unsub=null;try{s()}catch{}}lt(n)}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 n=this._deps[e],s=t[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:t};for(let i of this._inspectorHooks)i(o)}if(s!==Oe){if(s===B){this._depDirtied(n);return}if(s===Q){if(this._depInvalidated(n),this._cached===void 0)return;this._emit(Gt);return}if(s===ee||s===ae){this._emit([t]);return}if(s===j){this._emit(it);return}if(s===C)this._depSettledAsData(n,t[1]);else if(s===U)this._depSettledAsResolved(n);else if(s===H)this._depSettledAsTerminal(n,!0);else if(s===$)this._depSettledAsTerminal(n,t[1]);else{this._emit([t]);return}if(!this._fn){(s===C||s===U)&&this._emit([t]),(s===H||s===$)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ot))}_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(Ct),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($t)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[$,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[$,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let t=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),n=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=t[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let s=this._deps.map(i=>i.terminal),o={prevData:n,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:t,prevData:n};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(t,this._actions,o);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[$,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Bt?(this._rerunDepth=0,this._emit([[$,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Bt} \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 n=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${n}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[ve,e[0]]:e;let n=!0,s=!1,o=!1,i=-1;for(let u of e){let d=t(u[0]);d<i&&(n=!1),d===3&&(s=!0),u[0]===B&&(o=!0),i=d}let a=e;if(!n){let u=e.map((d,c)=>({m:d,i:c,tier:t(d[0])}));u.sort((d,c)=>d.tier-c.tier||d.i-c.i),a=u.map(d=>d.m)}if(s&&!o&&this._status!=="dirty"){let u=0;for(;u<a.length&&t(a[u][0])===0;)u++;return u===0?[ve,...a]:[...a.slice(0,u),ve,...a.slice(u)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let u=e[a];if(u[0]===$&&u[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(u=>u[0]===j||u[0]===Q);if(a.length===0)return;t=a}t=this._frameBatch(t);let s=null;for(let a=0;a<t.length;a++){let u=t[a],d=u[0];if(d!==ee&&d!==ae){s?.push(u);continue}if(u.length<2)throw new Error(`Node "${this.name}": [[${d===ee?"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=u[1];if(d===ee)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 g=this._pauseBuffer;this._pauseBuffer=[],this._emit(g)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?s?.push(u):s==null&&(s=t.slice(0,a))}if(s!=null){if(s.length===0)return;t=s}if(this._hasMeta&&t.some(a=>a[0]===j))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(it)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(t);if(o.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,u=[];for(let d of o)a(d[0])===3?this._pauseBuffer.push(d):u.push(d);u.length>0&&this._dispatchOrAccumulate(u)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[$,i]])}_updateState(e){let t=this._config.tierOf,n,s,o=-1,i=0;for(let c of e)t(c[0])===3&&i++;let a=i<=1,u=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===C){u=c;break}}for(let c=0;c<e.length;c++){let h=e[c],g=h[0];if(g===C){if(h.length>=2){let m=!1;if(a&&this._cached!==void 0)try{m=this._equals(this._cached,h[1])}catch(l){s=this._wrapFnError("equals threw",l),o=c;break}if(m){n==null&&(n=e.slice(0,c)),n.push(rt),this._status="resolved";continue}this._cached=h[1],this._versioning!=null&&(u<0||c===u)&&zt(this._versioning,h[1],this._hashFn)}this._status="settled",n?.push(h)}else if(n?.push(h),g===B)this._status="dirty";else if(g===U)this._status="resolved";else if(g===H){this._status="completed";{let m=this._config.rigorRecorder;if(m!=null)try{m.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(g===$){this._status="errored";{let m=this._config.rigorRecorder;if(m!=null)try{m.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(g===Q){if(this._cached!==void 0){let l=this._config.rigorRecorder;if(l!=null)try{l.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let m=this._cleanup;if(typeof m=="function"){this._cleanup=void 0;try{m()}catch{}}else if(m!=null&&typeof m=="object"){let l=m.invalidate;if(typeof l=="function")try{l()}catch{}}}else g===j&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let d=o>=0?n??e.slice(0,o):n??e;return s!=null?{finalMessages:d,equalsError:s}:{finalMessages:d}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let n of t)n(e)};_dispatchOrAccumulate(e){if(Et()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],me(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}Ge(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);Ge(this._deliverToSinks,t,this._config.tierOf)}},Ut=r=>Array.isArray(r),ft=r=>typeof r=="object"&&r!=null&&!Array.isArray(r)});function P(r,e){return X([],{...e,initial:r})}function pt(r,e){return X((n,s,o)=>r(s,o)??void 0,{describeKind:"producer",...e})}function S(r,e,t){return X(r,(s,o,i)=>{let a=s.map((u,d)=>u!=null&&u.length>0?u.at(-1):i.prevData[d]);o.emit(e(a,i))},{describeKind:"derived",...t})}function ze(r,e,t){return X(r,(s,o,i)=>{let a=s.map((u,d)=>u!=null&&u.length>0?u.at(-1):i.prevData[d]);return e(a,o,i)??void 0},{describeKind:"effect",...t})}var we=W(()=>{"use strict";de()});function se(r){return r.subscribe(()=>{})}var Wt=W(()=>{"use strict"});var Ve=W(()=>{"use strict";Wt()});function gt(r,e){if(e!=null&&e.length>0)return new Set(e);switch(r){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;case"spec":return new Set(["type","deps","meta","value"]);default:return new Set(["type","deps"])}}function Gn(r){return r._describeKind!=null?r._describeKind:r._deps.length>0?"derived":r._fn!=null?"producer":"state"}function $n(r){let e={};for(let[t,n]of Object.entries(r.meta))try{e[t]=n.cache}catch{}return e}function mt(r,e,t){let n=e==null,s=!n&&e!=null?[...e].filter(c=>c.startsWith("meta.")).map(c=>c.slice(5)):null,o=n||e.has("meta")||s!=null&&s.length>0,i="state",a=[];r instanceof z&&(i=Gn(r),a=r._deps.map(c=>c.node.name??""));let u={type:i,deps:a};(n||e.has("status"))&&(u.status=r.status);let d=r instanceof z?r._guard:void 0;if(o){let c={...$n(r)};if(d!=null&&c.access===void 0&&(c.access=at(d)),s!=null&&s.length>0&&!e.has("meta")){let h={};for(let g of s)g in c&&(h[g]=c[g]);u.meta=h}else u.meta=c}if(r.name!=null&&(u.name=r.name),(n||e.has("value"))&&(!t||i==="state")){r.status==="sentinel"&&(u.sentinel=!0);try{u.value=r.cache}catch{}}if((n||e.has("v"))&&r.v!=null){let c={id:r.v.id,version:r.v.version};"cid"in r.v&&(c.cid=r.v.cid,c.prev=r.v.prev),u.v=c}return(n||e.has("guard"))&&d!=null&&(u.guard=at(d)),(n||e.has("lastMutation"))&&r.lastMutation!=null&&(u.lastMutation=r.lastMutation),u}var Kt=W(()=>{"use strict";Re();de()});var je,Jt=W(()=>{"use strict";je=class{_timer;_gen=0;start(e,t){this.cancel(),this._gen+=1;let n=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,n===this._gen&&t()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var Ae,Qt=W(()=>{"use strict";Ae=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let t=(this.head+this._size)%this.capacity;this.buf[t]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let t=e<0?this._size+e:e;if(!(t<0||t>=this._size))return this.buf[(this.head+t)%this.capacity]}toArray(){let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this.buf[(this.head+t)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}}});function qe(r,e,t){return{[r]:!0,[`${r}_type`]:e,...t??{}}}var kt=W(()=>{"use strict"});var or={};bn(or,{contentModerationGraph:()=>rr,dataQualityGraph:()=>sr,issueTrackerGraph:()=>nr,observabilityGraph:()=>tr});module.exports=vn(or);be();we();be();ue();de();we();var ht=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,t){if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=t,t!==void 0){if(this._buf=new Array(t),e&&e.length>0){let n=Math.min(e.length,t),s=e.length-n;for(let o=0;o<n;o++)this._buf[o]=e[s+o];this._size=n}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let t=e>=0?e:this._size+e;if(!(t<0||t>=this._size))return this._maxSize!==void 0?this._buf[(this._head+t)%this._maxSize]:this._buf[t]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let t=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let n=t;n<e.length;n++)this._rawAppend(e[n]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let t=0;t<e;t++)this._buf[(this._head+t)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let t=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,t);else{for(let n=0;n<t;n++)this._buf[(this._head+n)%this._maxSize]=void 0;this._head=(this._head+t)%this._maxSize}return this._size-=t,this._version+=1,t}slice(e,t){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${t})`);let n=t===void 0?this._size:Math.min(Math.max(t,0),this._size),s=Math.min(e,this._size);if(s>=n)return[];let o=n-s;if(this._maxSize===void 0)return this._buf.slice(s,n);let i=new Array(o);for(let a=0;a<o;a++)i[a]=this._buf[(this._head+s+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let t=Math.min(e,this._size);return this.slice(this._size-t,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this._buf[(this._head+t)%this._maxSize];return e}snapshot(){return this.toArray()}restore(e){if(this._maxSize===void 0){this._buf.length=0;for(let t=0;t<e.length;t++)this._buf.push(e[t]);this._size=this._buf.length}else{let t=this._maxSize;for(let o=0;o<t;o++)this._buf[o]=void 0;this._head=0;let n=Math.min(e.length,t),s=e.length-n;for(let o=0;o<n;o++)this._buf[o]=e[s+o];this._size=n}this._version+=1}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function Ee(r){return r.subscribe(()=>{})}var Cn=64;function qt(r,e={}){let{name:t,maxSize:n,versioning:s,guard:o,backend:i}=e,a=i??new ht(r,n),u=P(a.toArray(),{name:t,describeKind:"state",equals:(_,T)=>_===T,...s!=null?{versioning:s}:{},...o!=null?{guard:o}:{}});function d(){let _=a.toArray();ie(()=>{u.down([[B]],{internal:!0}),u.down([[C,_]],{internal:!0})})}let c=new Map,h=new Map,g=new Map;function m(_,T){return`${_}:${T===void 0?"END":T}`}function l(_){if(_.size<Cn)return;let T=_.keys().next();if(T.done)return;let O=_.get(T.value);O!==void 0&&O.dispose(),_.delete(T.value)}function y(_){let T=a.version;try{return _()}finally{a.version!==T&&d()}}function f(_){if(!Number.isInteger(_)||_<0)throw new RangeError(`tail: n must be a non-negative integer (got ${_})`);let T=c.get(_);if(T!==void 0)return c.delete(_),c.set(_,T),T.node;l(c);let O=S([u],([N])=>{let A=N;return _===0||A.length===0?[]:A.slice(Math.max(0,A.length-_))},{initial:a.tail(_),describeKind:"derived"}),E=Ee(O);return c.set(_,{node:O,dispose:E}),O}function k(_,T){if(!Number.isInteger(_)||_<0)throw new RangeError(`slice: start must be a non-negative integer (got ${_})`);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 O=m(_,T),E=h.get(O);if(E!==void 0)return h.delete(O),h.set(O,E),E.node;l(h);let N=S([u],([M])=>{let D=M;return T===void 0?D.slice(_):D.slice(_,T)},{initial:a.slice(_,T),describeKind:"derived"}),A=Ee(N);return h.set(O,{node:N,dispose:A}),N}function v(_){let T=g.get(_);if(T!==void 0)return T.node;let O=S([u,_],([N,A])=>{let M=N,D=Math.max(0,Math.trunc(A??0));return M.slice(D)},{initial:[],describeKind:"derived"}),E=Ee(O);return g.set(_,{node:O,dispose:E}),O}let b,p;function w(){b===void 0&&(b=X([u],(_,T,O)=>{let E=_[0],A=E!=null&&E.length>0?E.at(-1):O.prevData[0];if(A==null||A.length===0){T.down([[U]]);return}T.emit(A[A.length-1])},{name:t!=null?`${t}::lastValue`:"lastValue",describeKind:"derived",initial:a.size===0?void 0:a.at(a.size-1)}),p=S([u],([_])=>_.length>0,{name:t!=null?`${t}::hasLatest`:"hasLatest",describeKind:"derived",initial:a.size>0}),Ee(b),Ee(p))}let x={entries:u,get size(){return a.size},at(_){return a.at(_)},append(_){y(()=>a.append(_))},appendMany(_){_.length!==0&&y(()=>a.appendMany(_))},clear(){y(()=>a.clear())},trimHead(_){y(()=>a.trimHead(_))},withLatest(){return w(),u},get lastValue(){return w(),b},get hasLatest(){return w(),p},view(_){switch(_.kind){case"tail":return f(_.n);case"slice":return k(_.start,_.stop);case"fromCursor":return v(_.cursor)}},attach(_){let T=_.subscribe(O=>{for(let E of O)E[0]===C&&x.append(E[1])});return()=>T()},attachStorage(_){if(_.length===0)return()=>{};let T=new Map;for(let E of _)T.set(E,a.size);(async()=>{for(let E of _)if(typeof E.loadEntries=="function")try{let N=await Promise.resolve(E.loadEntries());N.entries.length>0&&a.size===0&&(a.restore(N.entries),T.set(E,N.entries.length),d());break}catch{}})();let O=u.subscribe(E=>{for(let N of E){if(N[0]!==C)continue;let A=N[1];for(let M of _){let D=T.get(M)??0;if(A.length<D){try{let ne=M.appendEntries(A);ne instanceof Promise&&ne.catch(()=>{})}catch{}T.set(M,A.length);continue}if(A.length===D)continue;let oe=A.slice(D);T.set(M,A.length);try{let ne=M.appendEntries(oe);ne instanceof Promise&&ne.catch(()=>{})}catch{}}}});return()=>O()},disposeAllViews(){for(let _ of c.values())_.dispose();c.clear();for(let _ of h.values())_.dispose();h.clear();for(let _ of g.values())_.dispose();g.clear()},dispose(){for(let _ of c.values())_.dispose();c.clear();for(let _ of h.values())_.dispose();h.clear();for(let _ of g.values())_.dispose();g.clear()}};return x}ue();de();we();nt();be();Ie();Re();ue();Kt();de();we();Ie();function bt(r,e){if(Object.is(r,e))return!0;if(r==null||e==null||typeof r!="object"||typeof e!="object")return!1;if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(let o=0;o<r.length;o++)if(!bt(r[o],e[o]))return!1;return!0}if(Array.isArray(e))return!1;let t=Object.keys(r),n=Object.keys(e);if(t.length!==n.length)return!1;let s=new Set(n);for(let o of t)if(!s.has(o)||!bt(r[o],e[o]))return!1;return!0}function Yt(r,e){return`${r}\0${e}`}function yt(r,e){let t=[],n=new Set(r.subgraphs),s=new Set(e.subgraphs),o=[];for(let f of s)n.has(f)||o.push(f);o.sort();for(let f of o)t.push({type:"subgraph-mounted",path:f});let i=new Set(Object.keys(r.nodes)),a=new Set(Object.keys(e.nodes)),u=[];for(let f of a)i.has(f)||u.push(f);u.sort();for(let f of u)t.push({type:"node-added",path:f,node:{...e.nodes[f]}});let d=[];for(let f of a){if(!i.has(f))continue;let k=r.nodes[f]?.meta,v=e.nodes[f]?.meta;k==null&&v==null||bt(k??{},v??{})||d.push(f)}d.sort();for(let f of d)t.push({type:"node-meta-changed",path:f,prevMeta:r.nodes[f]?.meta??{},nextMeta:e.nodes[f]?.meta??{}});let c=new Map;for(let f of r.edges)c.set(Yt(f.from,f.to),f);let h=new Map;for(let f of e.edges)h.set(Yt(f.from,f.to),f);let g=[];for(let[f,k]of h)c.has(f)||g.push(k);g.sort((f,k)=>f.from<k.from?-1:f.from>k.from?1:f.to<k.to?-1:f.to>k.to?1:0);for(let f of g)t.push({type:"edge-added",from:f.from,to:f.to});let m=[];for(let[f,k]of c)h.has(f)||m.push(k);m.sort((f,k)=>f.from<k.from?-1:f.from>k.from?1:f.to<k.to?-1:f.to>k.to?1:0);for(let f of m)t.push({type:"edge-removed",from:f.from,to:f.to});let l=[];for(let f of i)a.has(f)||l.push(f);l.sort();for(let f of l)t.push({type:"node-removed",path:f});let y=[];for(let f of n)s.has(f)||y.push(f);y.sort();for(let f of y)t.push({type:"subgraph-unmounted",path:f});return{events:t,flushedAt_ns:re()}}Ve();Jt();Qt();tt();function Xt(r,e,t,n={}){let s=e in r.nodes,o=t in r.nodes;if(!s)return Be(e,t,"no-such-from");if(!o)return Be(e,t,"no-such-to");let i=n.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(n.findCycle===!0){let d=Pn(r,e,n);if(d!=null)return d}let u=He(e,r.nodes[e],0,n);return Ue(e,t,[u])}if(i===0)return Be(e,t,"no-path");let a=Zt(r,e,t,i);return a.found?Ue(e,t,en(r,a.pathOrder,n)):Be(e,t,a.truncated?"max-depth-exceeded":"no-path")}function Zt(r,e,t,n){let s=new Map,o=[{path:t,depth:0}],i=new Set([t]),a=0,u=!1;for(;a<o.length;){let h=o[a++];if(h.path===e)break;if(n!=null&&h.depth>=n){let y=r.nodes[h.path];y?.deps&&y.deps.length>0&&(u=!0);continue}let g=r.nodes[h.path];if(g==null)continue;let m=g.deps??[],l=new Map;for(let y=0;y<m.length;y++){let f=m[y];if(!f)continue;let k=l.get(f);k==null&&(k=[],l.set(f,k)),k.push(y)}for(let[y,f]of l)i.has(y)||(i.add(y),s.set(y,{from:h.path,depIndices:f}),o.push({path:y,depth:h.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:u};let d=[{path:e}],c=e;for(;c!==t;){let h=s.get(c);if(h==null)return{found:!1,pathOrder:[],truncated:!1};d[d.length-1].depIndices=h.depIndices,d.push({path:h.from}),c=h.from}return{found:!0,pathOrder:d,truncated:!1}}function Pn(r,e,t){let n=r.nodes[e];if(n==null)return null;let s=n.deps??[],o=[];for(let a=0;a<s.length;a++)s[a]===e&&o.push(a);if(o.length>0){let a=He(e,n,0,t);a.dep_index=o[0];let u=He(e,n,1,t);return Ue(e,e,[a,u])}let i=null;for(let a=0;a<s.length;a++){let u=s[a];if(!u||u===e)continue;let d=Zt(r,u,e,t.maxDepth);d.found&&(i==null||d.pathOrder.length<i.pathOrder.length)&&(i=d,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...d.pathOrder],truncated:!1})}return i==null?null:Ue(e,e,en(r,i.pathOrder,t))}function en(r,e,t){return e.map((n,s)=>{let o=r.nodes[n.path],i=He(n.path,o,s,t);return n.depIndices!=null&&n.depIndices.length>0&&(i.dep_index=n.depIndices[0],n.depIndices.length>1&&(i.dep_indices=[...n.depIndices])),i})}function He(r,e,t,n){let s={path:r,type:e.type,hop:t};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let o=n.annotations?.get(r)??e.annotation;o!=null&&(s.annotation=o);let i=n.lastMutations?.get(r)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function Ue(r,e,t){return tn(r,e,!0,"ok",t)}function Be(r,e,t){return tn(r,e,!1,t,[])}function tn(r,e,t,n,s){let o=In(r,e,t,n,s);return{from:r,to:e,found:t,reason:n,steps:s,text:o,toJSON(){return{from:r,to:e,found:t,reason:n,steps:s}}}}function In(r,e,t,n,s){if(!t)switch(n){case"no-such-from":return`explainPath: no node named "${r}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${r}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${r}" to "${e}"`}let o=[`Causal path: ${r} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let u=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(u),"value"in i&&o.push(` value: ${Fn(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let d=i.lastMutation.actor;o.push(` actor: ${d.type}${d.id?`:${d.id}`:""}`)}}return o.join(`
2
- `)}function Fn(r){if(r===void 0)return"<sentinel>";if(r===null)return"null";if(typeof r=="string")return JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean"||typeof r=="bigint")return String(r);try{let e=JSON.stringify(r);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(r)}}de();var V={object:56,array:64,string:40,number:8,boolean:4,null:0,undefined:0,symbol:40,bigint:16,function:120,map:72,set:72,mapEntry:40,setEntry:24,date:24,regexp:48,error:64,url:80,promise:48,weakmap:40,weakset:40},Ln=Symbol.for("sizeof");function nn(r){let e=new WeakSet,t=new WeakSet,n=[r],s=0;for(;n.length>0;){let o=n.pop();s+=zn(o,e,t,n)}return s}function zn(r,e,t,n){if(r==null)return 0;switch(typeof r){case"number":return V.number;case"boolean":return V.boolean;case"string":return V.string+r.length*2;case"bigint":return V.bigint+Vn(r);case"symbol":return V.symbol;case"function":return e.has(r)?0:(e.add(r),V.function);case"undefined":return 0}let o=r;if(e.has(o))return 0;e.add(o);let i=o[Ln];if(typeof i=="function")try{let d=i.call(o);if(typeof d=="number"&&Number.isFinite(d))return d}catch{}if(o instanceof Date)return V.date;if(o instanceof RegExp)return V.regexp+o.source.length*2;if(o instanceof Error){let d=o.message?o.message.length*2:0,c=o.stack?o.stack.length*2:0;return V.error+d+c}if(typeof URL<"u"&&o instanceof URL)return V.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return V.promise;if(o instanceof WeakMap)return V.weakmap;if(o instanceof WeakSet)return V.weakset;if(o instanceof Map){let d=V.map;for(let[c,h]of o)d+=V.mapEntry,n.push(c),n.push(h);return d}if(o instanceof Set){let d=V.set;for(let c of o)d+=V.setEntry,n.push(c);return d}if(Array.isArray(o)){let d=V.array+o.length*8;for(let c of o)n.push(c);return d}if(o instanceof ArrayBuffer)return t.has(o)?0:(t.add(o),o.byteLength);if(ArrayBuffer.isView(o)){let d=o;return t.has(d.buffer)?48:(t.add(d.buffer),d.buffer.byteLength+48)}let a=V.object,u=Object.keys(o);for(let d of u){a+=V.string+d.length*2;try{n.push(o[d])}catch{}}return a}function Vn(r){let e=r<0n?-r:r;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}function rn(r,e){let t=e?.topN??10,n=r.describe({detail:"standard"}),s=[],o=r._collectObserveTargets;typeof o=="function"&&o.call(r,"",s);let i=new Map;for(let[g,m]of s)i.set(g,m);let a=[];for(let[g,m]of Object.entries(n.nodes)){let l=i.get(g),y=l instanceof z?l:null,f=y?nn(y.cache):0,k=y?y._sinkCount:0,v=m.deps?.length??0,b=m.type==="effect"&&k===0,p=k===0?m.type==="effect"?"orphan-effect":m.type==="derived"?"idle-derived":m.type==="producer"?"idle-producer":null:null;a.push({path:g,type:m.type,status:m.status??"unknown",valueSizeBytes:f,subscriberCount:k,depCount:v,isOrphanEffect:b,orphanKind:p})}let u=a.reduce((g,m)=>g+m.valueSizeBytes,0),d=(g,m)=>[...a].sort(m??((l,y)=>y[g]-l[g])).slice(0,t),c=a.filter(g=>g.orphanKind!=null),h=a.filter(g=>g.isOrphanEffect);return{nodeCount:a.length,edgeCount:n.edges.length,subgraphCount:n.subgraphs.length,nodes:a,totalValueSizeBytes:u,hotspots:{byValueSize:d("valueSizeBytes"),bySubscriberCount:d("subscriberCount"),byDepCount:d("depCount")},orphans:c,orphanEffects:h}}var L="::",Z="__meta__",ke=1;function sn(r,e){let t=Math.max(16,r.size*4),n=0;for(;r.size>0;){if(n++>=t){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${t}); ${r.size} disposer(s) discarded`),r.clear();return}let s=r.values().next();if(s.done)return;let o=s.value;r.delete(o);try{o()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function ln(r){return r!=null&&typeof r=="object"&&"cache"in r&&typeof r.subscribe=="function"&&typeof r.down=="function"}function jn(r){if(r!=null)return ln(r)?r.cache:r}function pe(r){return r!=null&&typeof r=="object"&&"cache"in r&&typeof r.subscribe=="function"&&typeof r.down=="function"}function ce(r){return pe(r)?r.cache??"":r}function on(r){return pe(r)?r.cache??0:r}function an(r){return pe(r)?r.cache??!1:r}function Bn(r){let e=[];for(let t of Object.keys(r).sort()){let n=r[t].v;n!=null&&e.push(`${t} ${n.id} ${n.version}`)}return e.join(`
3
- `)}function un(r){if(r.version!==ke)throw new Error(`unsupported snapshot version ${String(r.version)} (expected ${ke})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in r))throw new Error(`snapshot missing required key "${e}"`);if(typeof r.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof r.nodes!="object"||r.nodes===null||Array.isArray(r.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(r.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(r.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function Hn(r,e){let t=new WeakMap,n=(s,o)=>{if(Object.is(s,o))return!0;if(s==null||o==null||typeof s!="object"||typeof o!="object")return!1;let i=t.get(s);if(i==null&&(i=new WeakSet,t.set(s,i)),i.has(o))return!0;i.add(o);let a=s.constructor,u=o.constructor;if(a!==u)return!1;if(s instanceof Date)return s.getTime()===o.getTime();if(s instanceof RegExp)return s.source===o.source&&s.flags===o.flags;if(Array.isArray(s)){let g=o;if(s.length!==g.length)return!1;for(let m=0;m<s.length;m++)if(!n(s[m],g[m]))return!1;return!0}if(s instanceof Map){let g=o;if(s.size!==g.size)return!1;for(let[m,l]of s)if(!g.has(m)||!n(l,g.get(m)))return!1;return!0}if(s instanceof Set){let g=o;if(s.size!==g.size)return!1;for(let m of s){let l=!1;for(let y of g)if(n(m,y)){l=!0;break}if(!l)return!1}return!0}if(ArrayBuffer.isView(s)){let g=s,m=o;if(g.length!==m.length)return!1;for(let l=0;l<g.length;l++)if(g[l]!==m[l])return!1;return!0}let d=Object.keys(s),c=Object.keys(o);if(d.length!==c.length)return!1;let h=new Set(c);for(let g of d)if(!h.has(g)||!n(s[g],o[g]))return!1;return!0};return n(r,e)}function Un(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function We(r){let e="^";for(let t=0;t<r.length;t+=1){let n=r[t];if(n==="*"){e+=".*";continue}if(n==="?"){e+=".";continue}if(n==="["){let s=r.indexOf("]",t+1);if(s<=t+1){e+="\\[";continue}let o=r.slice(t+1,s);o.startsWith("!")&&(o=`^${o.slice(1)}`),o=o.replace(/\\/g,"\\\\"),e+=`[${o}]`,t=s;continue}e+=Un(n)}return e+="$",new RegExp(e)}var Wn={data:"\x1B[32m",dirty:"\x1B[33m",resolved:"\x1B[36m",invalidate:"\x1B[93m",pause:"\x1B[90m",resume:"\x1B[96m",complete:"\x1B[34m",error:"\x1B[31m",teardown:"\x1B[91m",derived:"\x1B[35m",path:"\x1B[90m",reset:"\x1B[0m"},qn={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function vt(r){if(typeof r=="string")return JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean"||r==null)return String(r);try{return JSON.stringify(r)}catch{return"[unserializable]"}}function Kn(r){return r==="none"?qn:r==="ansi"||r==null?Wn:{data:r.data??"",dirty:r.dirty??"",resolved:r.resolved??"",invalidate:r.invalidate??"",pause:r.pause??"",resume:r.resume??"",complete:r.complete??"",error:r.error??"",teardown:r.teardown??"",derived:r.derived??"",path:r.path??"",reset:r.reset??""}}function dn(r){if(r==null)return{};let e=r.detail;return e==="full"?{...r,structured:r.structured??!0,timeline:r.timeline??!0,causal:r.causal??!0,derived:r.derived??!0}:e==="minimal"?{...r,structured:r.structured??!0}:r.format==="stage-log"?{...r,structured:r.structured??!0,timeline:r.timeline??!0}:r}function Yn(r,e,t){for(let n=0;n<r.length;n++){let s=r.charCodeAt(n);if(s<32||s===127)throw new Error(`Graph "${e}": ${t} "${r}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${n})`)}}function _t(r,e,t){if(r==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(r.includes(L))throw new Error(`Graph "${e}": ${t} "${r}" must not contain '${L}' (path separator)`);if(r===Z)throw new Error(`Graph "${e}": ${t} name "${Z}" is reserved for meta companion paths`);Yn(r,e,t)}function Jn(r,e){if(r==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=r.split(L);for(let n of t)if(n==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function Qn(r,e){let t=!1;for(let s of r)if(!e.isMetaPassthrough(s[0])){t=!0;break}return t?r.filter(s=>e.isMetaPassthrough(s[0])):r}function fn(r){for(let e of r._mounts.values())fn(e);for(let e of r._nodes.values())try{e.down([[j]],{internal:!0})}catch{}}var te=class r{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;_factory;_factoryArgs;constructor(e,t){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(L))throw new Error(`Graph name must not contain '${L}' (got "${e}")`);if(e===Z)throw new Error(`Graph name "${Z}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??_e,this._traceRing=new Ae(t?.traceCapacity??1e3),t?.versioning!=null&&this.setVersioning(t.versioning),typeof t?.factory=="string"&&(this._factory=t.factory,t.factoryArgs!==void 0&&(this._factoryArgs=t.factoryArgs))}tagFactory(e,t){return this._factory=e,this._factoryArgs=t,this}ancestors(e=!0){let t=[],n=e?this:this._parent;for(;n!=null;)t.push(n),n=n._parent;return t}get topology(){return this._topology==null&&(this._topology=pt(e=>{let t=n=>{e.emit(n)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}nameOf(e){return this._nodeToName.get(e)}add(e,t){let n=e.name,s=t?.name??n;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let o=s,i=t?.annotation;if(_t(o,this.name,"add"),this._mounts.has(o))throw new Error(`Graph "${this.name}": name "${o}" is already a mount point`);if(this._nodes.has(o))throw new Error(`Graph "${this.name}": node "${o}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(o,e),this._nodeToName.set(e,o),this._emitTopology({kind:"added",name:o,nodeKind:"node"}),i!=null&&(this._annotations.set(o,i),this.config.inspectorEnabled&&this._traceRing.push({path:o,annotation:i,timestamp_ns:re()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof z&&t._applyVersioning(e)}remove(e){_t(e,this.name,"remove");let t=this._mounts.get(e);if(t){let o={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[a,u]of i)a.includes(`${L}${Z}${L}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...t._collectSubgraphs(`${e}${L}`)),this._mounts.delete(e),t._parent=void 0,fn(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:o}),o}let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(n),n.down([[j]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let t=typeof e=="function"?e:(()=>{let o=We(e);return i=>o.test(i)})(),n={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(o=>t(o));for(let o of s){let i=this.remove(o);n.nodes.push(...i.nodes),n.mounts.push(...i.mounts)}return n.nodes.sort(),n.mounts.sort(),n}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,n=0;return{[Symbol.iterator](){return this},next(){if(n>=e.length)return{value:void 0,done:!0};let s=e[n++];return{value:[s,t.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(L))return this.resolve(e);let t=this._nodes.get(e);if(!t)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return t}get(e){return this.node(e).cache}set(e,t,n){let s=n?.internal===!0;this.node(e).down([[C,t]],{actor:n?.actor,internal:s,delivery:"write"})}setAll(e,t){let n=Symbol.iterator in e?e:Object.entries(e);ie(()=>{for(let[s,o]of n)this.set(s,o,t)})}invalidate(e,t){let n=t?.internal===!0;this.node(e).down([[Q]],{actor:t?.actor,internal:n,delivery:"write"})}error(e,t,n){let s=n?.internal===!0;this.node(e).down([[$,t]],{actor:n?.actor,internal:s,delivery:"write"})}complete(e,t){let n=t?.internal===!0;this.node(e).down([[H]],{actor:t?.actor,internal:n,delivery:"write"})}edges(e){let t=e?.recursive===!0,n=new Map;if(!t){for(let[u,d]of this._nodes)n.set(d,u);let a=[];for(let[u,d]of this._nodes)if(d instanceof z)for(let c of d._deps){let h=n.get(c.node);h!=null&&a.push([h,u])}return a.sort((u,d)=>u[0]<d[0]?-1:u[0]>d[0]?1:u[1]<d[1]?-1:u[1]>d[1]?1:0),a}let s=[];this._collectObserveTargets("",s);let o=new Map;for(let[a,u]of s)o.set(u,a);let i=[];for(let[a,u]of s)if(u instanceof z)for(let d of u._deps){let c=o.get(d.node);c!=null&&i.push([c,a])}return i.sort((a,u)=>a[0]<u[0]?-1:a[0]>u[0]?1:a[1]<u[1]?-1:a[1]>u[1]?1:0),i}mount(e,t){if(t===void 0){let s=new r(e);return this.mount(e,s)}if(typeof t=="function"){let s=new r(e);return t(s),this.mount(e,s)}let n=t;if(_t(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let s=this;s!=null;s=s._parent)if(s===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let t=Jn(e,this.name);return this._resolveFromSegments(t)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let t=e;if(t[0]===this.name&&(t=t.slice(1),t.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let n=t[0],s=t.slice(1);if(s.length===0){let a=this._nodes.get(n);if(a)return a;throw this._mounts.has(n)?new Error(`Graph "${this.name}": path ends at subgraph "${n}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${n}"`)}let o=this._nodes.get(n);if(o&&s.length>0&&s[0]===Z)return this._resolveMetaChainFromNode(o,s,t.join(L));let i=this._mounts.get(n);if(!i)throw this._nodes.has(n)?new Error(`Graph "${this.name}": "${n}" is a node; trailing path "${s.join(L)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${n}"`);return i.resolve(s.join(L))}_resolveMetaChainFromNode(e,t,n){let s=e,o=0,i=[...t];for(;o<i.length;){if(i[o]!==Z)throw new Error(`Graph "${this.name}": expected ${Z} segment in meta path "${n}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Z} in "${n}"`);let a=i[o+1],u=s.meta[a];if(!u)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${n}"`);s=u,o+=2}return s}signal(e,t){if(t?.internal!==!0){for(let s of e)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let n=[];if(this._signalDeliver(e,t??{},new Set,n),n.length>0)throw n[0]}_signalDeliver(e,t,n,s){for(let u of this._mounts.values())u._signalDeliver(e,t,n,s);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},a=Qn(e,this.config);for(let u of[...this._nodes.keys()].sort()){let d=this._nodes.get(u);if(!n.has(d)){n.add(d);try{d.down(e,i)}catch(c){if(c instanceof J)throw c;s.push(c)}a.length!==0&&this._signalMetaSubtree(d,a,n,i,s)}}}_signalMetaSubtree(e,t,n,s,o){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!n.has(a)){n.add(a);try{a.down(t,s)}catch(u){if(u instanceof J)throw u;o.push(u)}this._signalMetaSubtree(a,t,n,s,o)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=jn(e?.actor),n=e?.filter;if(e?.detail!=null&&e?.fields!=null)throw new TypeError("Graph.describe(): pass either `detail` or `fields`, not both. `detail: 'spec'` is the canonical spec projection; use `fields` only when you need a custom subset.");let s=gt(e?.detail,e?.fields),o=e?.detail==="spec",i=s,a=[];this._collectObserveTargets("",a);let u=new Map;for(let[p,w]of a)u.set(w,p);let d=[];{let p=a.map(([,_])=>_),w=new Set(u.values()),x=0;for(;p.length>0;){let _=p.shift();if(_ instanceof z)for(let T of _._deps){let O=T.node;if(u.has(O))continue;let E=O.name??"",N=E;if(!N||w.has(N))if(E){let A=2;for(;w.has(`${E}#${A}`);)A++;N=`${E}#${A}`}else for(N=`__internal__/${x++}`;w.has(N);)N=`__internal__/${x++}`;u.set(O,N),w.add(N),d.push([N,O]),p.push(O)}}}let c=[...a,...d],h={};for(let[p,w]of c){if(t!=null&&!w.allowsObserve(t))continue;let x=mt(w,i,o),_=w instanceof z?w._deps.map(N=>u.get(N.node)??N.node.name??""):[],{name:T,...O}=x,E={...O,deps:_};if(!o){let N=this._annotations.get(p);N!=null&&(E.annotation=N)}if(n!=null)if(typeof n=="function"){let N=n;if(!(N.length>=2?N(p,E):N(E)))continue}else{let N=!0;for(let[A,M]of Object.entries(n)){let D=A==="deps_includes"?"depsIncludes":A==="meta_has"?"metaHas":A;if(D==="depsIncludes"){if(!E.deps.includes(String(M))){N=!1;break}continue}if(D==="metaHas"){if(!Object.hasOwn(E.meta??{},String(M))){N=!1;break}continue}if(E[D]!==M){N=!1;break}}if(!N)continue}h[p]=E}let g=new Set(Object.keys(h)),m=[];for(let[p,w]of c)if(w instanceof z)for(let x of w._deps){let _=u.get(x.node);_!=null&&m.push([_,p])}m.sort((p,w)=>p[0]<w[0]?-1:p[0]>w[0]?1:p[1]<w[1]?-1:p[1]>w[1]?1:0);let l=m.map(([p,w])=>({from:p,to:w}));(t!=null||n!=null)&&(l=l.filter(p=>g.has(p.from)&&g.has(p.to)));let y=this._collectSubgraphs(""),f=t!=null||n!=null?y.filter(p=>{let w=`${p}${L}`;return[...g].some(x=>x===p||x.startsWith(w))}):y,k=this,v=e;return{name:this.name,nodes:h,edges:l,subgraphs:f,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(p){let w={...v};return Array.isArray(p)?(w.fields=p,w.detail=void 0):(w.detail=p,w.fields=void 0),k.describe(w)}}}_collectSubgraphs(e){let t=[];for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${n}`;t.push(s),t.push(...this._mounts.get(n)._collectSubgraphs(`${s}${L}`))}return t}resourceProfile(e){return rn(this,e)}reachable(e,t,n={}){return n.withDetail===!0?cn(this.describe(),e,t,{...n,withDetail:!0}):cn(this.describe(),e,t,n)}explain(e,t,n){return n?.reactive===!0?this._explainReactive(e,t,n):this._explainStatic(ce(e),ce(t),{...n?.maxDepth!==void 0?{maxDepth:on(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:an(n.findCycle)}:{}})}_explainStatic(e,t,n){let s=this.describe({detail:"full"}),o=new Map(this._annotations),i=new Map;for(let[a,u]of Object.entries(s.nodes))u.lastMutation!=null&&i.set(a,u.lastMutation);return Xt(s,e,t,{...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{},annotations:o,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},n=e.reactiveName??"describe",s=0,o=P(s,{name:`${n}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,me(()=>{a=!1,!u&&(s+=1,o.emit(s))}))},c=i.onEvent(v=>{let b=v.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||d()}),h=[],g=new WeakSet,m=v=>{if(g.has(v)||u)return;g.add(v);let b=v.topology.subscribe(p=>{for(let w of p){if(w[0]!==C)continue;let x=w[1];if(d(),x.kind==="added"&&x.nodeKind==="mount"){let _=v._mounts.get(x.name);_!=null&&m(_)}}});h.push(b);for(let p of v._mounts.keys()){let w=v._mounts.get(p);w!=null&&m(w)}};m(this);let l,y=e.actor;ln(y)&&(l=y.subscribe(v=>{let b=!1,p=!1;for(let w of v){let x=w[0];x===C?b=!0:(x===H||x===$||x===j)&&(p=!0)}b&&d(),p&&(l?.(),l=void 0,d())}));let f;try{f=S([o],()=>this.describe(t),{name:n,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(v,b)=>v===b})}catch(v){c(),l?.();for(let b of h)b();throw i.dispose(),v}let k=se(f);return{node:f,dispose(){u=!0,c(),l?.();for(let v of h)v();h.length=0,i.dispose(),k()}}}_describeReactiveDiff(e){let t={...e,reactive:!1},n=e.reactiveName??"describe-diff",s={name:this.name,nodes:{},edges:[],subgraphs:[]},o=this.describe(t),i=yt(s,o),a=P(i,{name:n,meta:{domain:"audit",kind:"describe-diff"},equals:(g,m)=>g===m}),u=this._describeReactive({...e,reactiveName:void 0}),d=!1,c=u.node.subscribe(g=>{if(!d)for(let m of g){if(m[0]!==C)continue;let l=m[1],y=yt(o,l);o=l,y.events.length!==0&&a.emit(y)}}),h=se(a);return{node:a,dispose(){d=!0,c(),u.dispose(),a.down([[j,"describe-diff disposed"]]),h()}}}_explainReactive(e,t,n){let s=0,o=P(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,me(()=>{a=!1,!u&&(s+=1,o.emit(s))}))},c=i.onEvent(v=>{let b=v.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||d()}),h=[];e!=null&&pe(e)&&h.push(e),t!=null&&pe(t)&&h.push(t),n?.maxDepth!=null&&pe(n.maxDepth)&&h.push(n.maxDepth),n?.findCycle!=null&&pe(n.findCycle)&&h.push(n.findCycle);let g=()=>{for(let v of h)if(v.cache===void 0)return!1;return!0},m=()=>{let v=ce(e),b=ce(t);return{from:v,to:b,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:v,to:b,found:!1,reason:"pending",steps:[]})}},l;try{l=S([o],()=>{if(!g())return m();let v=ce(e),b=ce(t),p={...n?.maxDepth!==void 0?{maxDepth:on(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:an(n.findCycle)}:{}};return this._explainStatic(v,b,p)},{name:n?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:ce(e),to:ce(t)},equals:(v,b)=>v.found===b.found&&v.reason===b.reason&&v.steps.length===b.steps.length&&Zn(v.steps,b.steps)})}catch(v){throw c(),i.dispose(),v}let y=se(l),f=[],k=v=>{let b;return b=v.subscribe(p=>{let w=!1,x=!1;for(let _ of p){let T=_[0];T===C?w=!0:(T===H||T===$||T===j)&&(x=!0)}(w||x)&&d(),x&&b&&(b(),b=void 0)}),()=>{b&&(b(),b=void 0)}};for(let v of h)f.push(k(v));return{node:l,dispose(){u=!0,c();for(let v of f)v?.();f.length=0,i.dispose(),y()}}}_pathsMatching(e){let t=We(e),n=[];return this._collectObserveTargets("",n),n.map(([s])=>s).filter(s=>t.test(s))}_collectObserveTargets(e,t){for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${L}${n}`;this._mounts.get(n)._collectObserveTargets(s,t)}for(let n of[...this._nodes.keys()].sort()){let s=this._nodes.get(n),o=e===""?n:`${e}${L}${n}`;t.push([o,s]),this._appendMetaObserveTargets(o,s,t)}}_appendMetaObserveTargets(e,t,n){for(let s of Object.keys(t.meta).sort()){let o=t.meta[s],i=`${e}${L}${Z}${L}${s}`;n.push([i,o]),this._appendMetaObserveTargets(i,o,n)}}observe(e,t){let n=typeof e=="string",o=dn(n?t:e);if(o.reactive===!0)return this._observeReactive(n?e:void 0,o);let i=o.structured===!0||o.timeline===!0||o.causal===!0||o.derived===!0||o.detail==="minimal"||o.detail==="full"||o.format!=null,a=o.actor;if(n){let c=e,h=this.resolve(c);if(a!=null&&!h.allowsObserve(a))throw new J({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,h]],o,"one"):{subscribe(g){return h.subscribe(g)},up(g){try{h.up?.(g)}catch(m){if(m instanceof J)return;throw m}}}}let u=[];this._collectObserveTargets("",u),u.sort((c,h)=>c[0]<h[0]?-1:c[0]>h[0]?1:0);let d=a==null?u:u.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(d,o,"all"):{subscribe:c=>{let h=d.map(([g,m])=>m.subscribe(l=>{c(g,l)}));return()=>{for(let g of h)g()}},up:(c,h)=>{try{this.resolve(c).up?.(h)}catch(g){if(g instanceof J)return;throw g}}}}_observeReactive(e,t){let n=t.tiers,s=n!=null?new Set(n):null,o=t.reactiveName??"observe";return pt(i=>{let a=[],u=!1,d=!1,c=()=>{if(a.length===0||d)return;let y={events:a.slice(),flushedAt_ns:re()};a.length=0,i.emit(y)},h={...t,reactive:!1,structured:!0,timeline:!0},g=e!=null?this.observe(e,h):this.observe(h),m=y=>{d||(a.push(y),!u&&(u=!0,me(()=>{u=!1,c()})))};for(let y of g.events)m(y);let l=g.onEvent(m);return()=>{d=!0,l(),g.dispose()}},{name:o,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,t,n){let s=n==="one"?e[0]?.[0]:void 0,o=i=>{if(n==="one"&&s!=null){let c=this.resolve(s);return this._buildStructuredObserver([[s,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,h)=>c[0]<h[0]?-1:c[0]>h[0]?1:0);let u=i.actor,d=u==null?a:a.filter(([,c])=>c.allowsObserve(u));return this._buildStructuredObserver(d,i,"all")};return this._createObserveResult(e,t,o)}_createObserveResult(e,t,n){let s=t.timeline===!0,o=t.causal===!0,i=t.derived===!0,a=t.detail==="minimal",u=this.config.inspectorEnabled,d=(o||i)&&u,c=t.maxEvents,h=c!=null&&c>0?new Ae(c):null,g=[],m=new Set,l=t.tiers!=null?new Set(t.tiers):null,y={},f=new Set,k=0,v=0,b=0,p=0,w=0,x=0,_=!1,T=!1,O=0,E=new Map,N=new Map,A=new Map,M=R=>{if(!(l!=null&&!l.has(R.type))){h?h.push(R):g.push(R);for(let F of m)F(R)}},D=R=>l==null||l.has(R),oe=()=>s?{timestamp_ns:re(),in_batch:Ce(),batch_id:O}:{},ne=(R,F)=>{if(!(!d||!(R instanceof z)))return R._setInspectorHook(K=>{if(K.kind==="dep_message")E.set(R,K.depIndex);else if(K.kind==="run"){let Te=K.batchData.map((G,q)=>G!=null&&G.length>0?G.at(-1):K.prevData[q]);N.set(R,Te);let Y=K.batchData.map(G=>G!=null?[...G]:void 0);A.set(R,Y),i&&M({type:"derived",path:F,dep_values:Te,dep_batches:Y,...oe()})}})},De=R=>{let F=E.get(R),K=N.get(R);if(!o||K==null)return{};let Y=(F!=null&&F>=0&&R instanceof z?R._deps[F]:void 0)?.node,G=Y?.v,q=A.get(R);return{trigger_dep_index:F,trigger_dep_name:Y?.name,...G!=null?{trigger_version:{id:G.id,version:G.version}}:{},dep_values:[...K],...q!=null?{dep_batches:q}:{}}},xt=[],Ot=[];for(let[R,F]of e){let K=ne(F,R);K&&xt.push(K),Ot.push(F.subscribe(Te=>{O++;for(let Y of Te){let G=Y[0],q=oe();if(G===C){y[R]=Y[1];let Xe=F instanceof z?F.lastMutation?.actor??ye:ye;M({type:"data",path:R,data:Y[1],actor:Xe,...q,...De(F)})}else if(a)G===B?D("dirty")&&k++:G===U?D("resolved")&&v++:G===Q?D("invalidate")&&b++:G===ee?D("pause")&&p++:G===ae?D("resume")&&w++:G===j?D("teardown")&&x++:G===H&&!f.has(R)?D("complete")&&(_=!0):G===$&&D("error")&&(T=!0,f.add(R));else if(G===B)D("dirty")&&k++,M({type:"dirty",path:R,...q});else if(G===U)D("resolved")&&v++,M({type:"resolved",path:R,...q,...De(F)});else if(G===Q)D("invalidate")&&b++,M({type:"invalidate",path:R,...q});else if(G===ee)D("pause")&&p++,M({type:"pause",path:R,lockId:Y[1],...q});else if(G===ae)D("resume")&&w++,M({type:"resume",path:R,lockId:Y[1],...q});else if(G===H)D("complete")&&!f.has(R)&&(_=!0),M({type:"complete",path:R,...q});else if(G===$){D("error")&&(T=!0,f.add(R));let Xe=F instanceof z?F.lastMutation?.actor??ye:ye;M({type:"error",path:R,data:Y[1],actor:Xe,...q})}else G===j&&(D("teardown")&&x++,M({type:"teardown",path:R,...q}))}}))}let Ye=!1,Je=()=>{if(!Ye){Ye=!0;for(let R of Ot)R();for(let R of xt)R();for(let R of Me)R({value:void 0,done:!0});Me.length=0}},Qe=[],Me=[];m.add(R=>{let F=Me.shift();F?F({value:R,done:!1}):Qe.push(R)});let Rt={get values(){return y},get dirtyCount(){return k},get resolvedCount(){return v},get invalidateCount(){return b},get pauseCount(){return p},get resumeCount(){return w},get teardownCount(){return x},get events(){return h?h.toArray():[...g]},get anyCompletedCleanly(){return _},get anyErrored(){return T},get completedWithoutErrors(){return _&&!T},onEvent(R){return m.add(R),()=>m.delete(R)},dispose:Je,expand(R){Je();let F={...t};return typeof R=="string"?F.detail=R:Object.assign(F,R),n(dn(F))},[Symbol.asyncIterator](){return{next(){return Qe.length>0?Promise.resolve({value:Qe.shift(),done:!1}):Ye?Promise.resolve({value:void 0,done:!0}):new Promise(R=>Me.push(R))},return(){return Je(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(Rt,t),Rt}_attachFormatLogger(e,t){let n=t.format;if(n==null)return;let s=t.logger??(l=>console.log(l)),o=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,a=o==null&&i==null?()=>!0:l=>(o==null||o.has(l))&&(i==null||!i.has(l)),u=Kn(t.theme),d=n==="stage-log"?re():0,c=l=>l==null?"":t.stageLabels?.[l]??l,h=(l,y)=>l.length>y?`${l.slice(0,y-1)}\u2026`:l,g=l=>l.type==="data"||l.type==="error"?h(vt(l.data),120):"",m=l=>{if(n==="stage-log"){let _=(re()-d)/1e9,T=c(l.path).padEnd(9);if(l.type==="data"){let O=g(l);return`[${_.toFixed(3)}s] ${T} \u2190${O?` ${O}`:""}`}if(l.type==="error"){let O=g(l);return`[${_.toFixed(3)}s] ${T} \u2717${O?` ${O}`:""}`}return l.type==="complete"?`[${_.toFixed(3)}s] ${T} \u25A0 complete`:`[${_.toFixed(3)}s] ${T} ${l.type}`}if(n==="json")try{return JSON.stringify(l)}catch{return JSON.stringify({type:l.type,path:l.path,data:"[unserializable]"})}let y=u[l.type]??"",f=l.path?`${u.path}${l.path}${u.reset} `:"",k=l.type==="data"||l.type==="error",v=l.type==="pause"||l.type==="resume",b=k?` ${vt(l.data)}`:v?` ${vt(l.lockId)}`:"",p=l.type==="data"||l.type==="resolved"||l.type==="derived"?l:void 0,w=p?.trigger_dep_name!=null?` <- ${p.trigger_dep_name}`:p?.trigger_dep_index!=null?` <- #${p.trigger_dep_index}`:"",x=l.in_batch?" [batch]":"";return`${f}${y}${l.type.toUpperCase()}${u.reset}${b}${w}${x}`};e.onEvent(l=>{a(l.type)&&s(m(l),l)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){sn(this._disposers,this.name),this.signal([[j]],{internal:!0}),sn(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:t,...n}=this.describe({detail:"full"}),s={};for(let a of Object.keys(n.nodes).sort()){let{lastMutation:u,guard:d,...c}=n.nodes[a];s[a]=c}let o=[...n.subgraphs].sort(),i={...n,version:1,nodes:s,subgraphs:o};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return St(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let n=t?.config??_e,{codec:s,codecVersion:o,payload:i}=Dt(e,n);return s.decode(i,o)}restore(e,t){if(un(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let n=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(o=>We(o)),s=t?.includeProducers===!0;for(let o of Object.keys(e.nodes).sort()){if(n!==null&&!n.some(a=>a.test(o)))continue;let i=e.nodes[o];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&t?.onError?.(o,new Error(`restore: slice.value is undefined for "${o}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let u=this.tryResolve(o)?.v;if(u!=null&&u.id===i.v.id&&u.version===i.v.version)continue}try{this.set(o,i.value)}catch(a){t?.onError?.(o,a)}}}}}static fromSnapshot(e,t){un(e);let n=typeof t=="function"?t:t?.build,s=typeof t=="function"?void 0:t?.factories,o=new r(e.name);if(n)return n(o),o.restore(e),o;for(let m of[...e.subgraphs].sort((l,y)=>{let f=l.split(L).length,k=y.split(L).length;return f!==k?f-k:l<y?-1:l>y?1:0})){let l=m.split(L),y=o;for(let f of l)y._mounts.has(f)||y.mount(f,new r(f)),y=y._mounts.get(f)}let i=s?Object.entries(s).map(([m,l])=>({re:We(m),factory:l})):[],a=m=>{for(let l of i)if(l.re.test(m))return l.factory},u=m=>{let l=m.split(L),y=l.pop();if(y==null||y.length===0)throw new Error(`invalid snapshot path "${m}"`);let f=o;for(let k of l){let v=f._mounts.get(k);if(!v)throw new Error(`unknown mount "${k}" in path "${m}"`);f=v}return[f,y]},d=Object.entries(e.nodes).filter(([m])=>!m.includes(`${L}${Z}${L}`)).sort((m,l)=>m[0]<l[0]?-1:m[0]>l[0]?1:0),c=new Map(d),h=new Map,g=!0;for(;c.size>0&&g;){g=!1;for(let[m,l]of[...c.entries()]){let y=l?.deps??[];if(!y.every(w=>h.has(w)))continue;let[f,k]=u(m),v={...l?.meta??{}},b=a(m),p;if(l?.type==="state")p=P(l.value,{meta:v});else{if(b==null)continue;p=b(k,{path:m,type:l.type,value:l.value,meta:v,deps:y,resolvedDeps:y.map(w=>h.get(w))})}f.add(p,{name:k}),h.set(m,p),c.delete(m),g=!0}}if(c.size>0){let m=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${m}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return o.restore(e),o}toJSON(){return this.snapshot()}attachSnapshotStorage(e,t={}){let n=e.map(d=>({tier:d,debounceMs:Math.max(0,d.debounceMs??0),compactEvery:Math.max(1,d.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let s=(d,c)=>{if(d.disposed)return;let h=Bn(c.nodes);if(d.lastSnapshot!=null&&h!==""&&h===d.lastFingerprint)return;let g=d.seq+1,m=Pe(),f=d.lastSnapshot==null||g%d.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:g,timestamp_ns:m,format_version:ke}:{name:this.name,mode:"diff",diff:Xn(d.lastSnapshot,c),seq:g,timestamp_ns:m,format_version:ke};if(d.tier.filter&&!d.tier.filter(f))return;let k;try{k=d.tier.save(f)}catch(v){t.onError?.(v,d.tier);return}if(k&&typeof k.then=="function"){let p=(d.savePending??Promise.resolve()).then(()=>k,()=>k).then(()=>{d.disposed||(d.seq=g,d.lastSnapshot=c,d.lastFingerprint=h)},w=>{t.onError?.(w,d.tier)});d.savePending=p.finally(()=>{d.savePending===p&&(d.savePending=void 0)})}else d.seq=g,d.lastSnapshot=c,d.lastFingerprint=h},o=(d,c)=>{try{s(d,c)}catch(h){t.onError?.(h,d.tier)}},i=(d,c)=>{if(!c.some(l=>{let y=this.config.messageTier(l[0]);return y>=3&&y<5}))return;if(t.filter){let l=this.tryResolve(d);if(l==null)return;let y=mt(l,gt("standard"));if(!t.filter(d,y))return}let g,m=()=>(g==null&&(g=this.snapshot()),g);for(let l of n)l.disposed||(l.debounceMs===0?o(l,m()):(l.timer==null&&(l.timer=new je),l.timer.start(l.debounceMs,()=>{l.disposed||o(l,this.snapshot())})))},a;if(t.paths!=null){let c=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(h=>{let g=this.tryResolve(h);return g==null?()=>{}:g.subscribe(m=>i(h,m))});a=()=>{for(let h of c)h()}}else a=this.observe().subscribe((d,c)=>i(d,c));let u=()=>{a();for(let d of n)d.disposed=!0,d.timer?.cancel();this._storageDisposers.delete(u)};return this._storageDisposers.add(u),{dispose:u}}async _cascadeRestore(e,t){for(let n of e){let s;try{s=await n.load?.()}catch(i){t?.(i,n);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let o=s;try{if(o.mode==="full"&&o.snapshot!=null)return this.restore(o.snapshot),!0;if(o.version===ke&&o.nodes!=null)return this.restore(o),!0}catch(i){t?.(i,n)}}return!1}static async fromStorage(e,t,n){for(let s of t){let o;try{o=await s.load?.()}catch(u){n?.onError?.(u,s);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===ke&&i.nodes!=null?i:void 0;if(a!=null)try{return r.fromSnapshot(a,n)}catch(u){n?.onError?.(u,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${t.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,t,n){if(e!=null&&t!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,t),this.config.inspectorEnabled){let s={path:e,annotation:t,timestamp_ns:re(),...n?.actor!=null?{actor:n.actor}:{}};this._traceRing.push(s)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let t=this._traceRing.toArray().filter(s=>!e(s)),n=this._traceRing.size-t.length;this._traceRing.clear();for(let s of t)this._traceRing.push(s);return n}static diff(e,t){let n=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(t.nodes)),o=[...s].filter(v=>!n.has(v)).sort(),i=[...n].filter(v=>!s.has(v)).sort(),a=[],u=[];for(let v of n){if(!s.has(v))continue;let b=e.nodes[v],p=t.nodes[v],w=b.v,x=p.v;w!=null&&x!=null&&w.id===x.id&&w.version!==x.version&&u.push({path:v,id:w.id,from:w.version,to:x.version});let _=w!=null&&x!=null&&w.id===x.id&&w.version===x.version;for(let T of["type","status","sentinel"]){let O=b[T],E=p[T];O!==E&&a.push({path:v,field:T,from:O,to:E})}if(!_)for(let T of["value","meta"]){let O=b[T],E=p[T];Hn(O,E)||a.push({path:v,field:T,from:O,to:E})}}let d=v=>`${v.from} ${v.to}`,c=new Set(e.edges.map(d)),h=new Set(t.edges.map(d)),g=t.edges.filter(v=>!c.has(d(v))),m=e.edges.filter(v=>!h.has(d(v))),l=new Set(e.subgraphs),y=new Set(t.subgraphs),f=[...y].filter(v=>!l.has(v)).sort(),k=[...l].filter(v=>!y.has(v)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:u,edgesAdded:g,edgesRemoved:m,subgraphsAdded:f,subgraphsRemoved:k}}};function Xn(r,e){let t=te.diff(r,e),n={};for(let s of t.nodesAdded){let o=e.nodes[s];o!=null&&(n[s]=o)}return{...t,nodesAddedFull:n}}function cn(r,e,t,n={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return n.withDetail?s:[];if(!n.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let o=n.maxDepth;if(o!=null&&(!Number.isInteger(o)||o<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(o===0)return n.withDetail?s:[];let i=new Map,a=new Map,u=new Map,d=new Map,c=new Set;for(let[b,p]of Object.entries(r.nodes)){if(!b)continue;c.add(b);let w=p.deps??[];i.set(b,w);for(let x of w)x&&(c.add(x),a.has(x)||a.set(x,new Set),a.get(x).add(b))}for(let b of r.edges){if(b==null||typeof b!="object")continue;let p=typeof b.from=="string"?b.from:"",w=typeof b.to=="string"?b.to:"";!p||!w||(c.add(p),c.add(w),d.has(p)||d.set(p,new Set),d.get(p).add(w),u.has(w)||u.set(w,new Set),u.get(w).add(p))}if(!c.has(e))return n.withDetail?s:[];let h=n.both===!0,g=b=>{if(h){let _=i.get(b)??[],T=u.get(b),O=a.get(b),E=d.get(b),N=[..._];return T&&N.push(...T),O&&N.push(...O),E&&N.push(...E),N}if(t==="upstream"){let _=i.get(b)??[],T=u.get(b);return T?[..._,...T]:_}let p=a.get(b),w=d.get(b),x=p?[...p]:[];return w&&x.push(...w),x},m=new Set([e]),l=new Map,y=[{path:e,depth:0}],f=0,k=!1;for(;f<y.length;){let b=y[f++];if(o!=null&&b.depth>=o){g(b.path).length>0&&(k=!0);continue}for(let p of g(b.path))!p||m.has(p)||(m.add(p),l.set(p,b.depth+1),y.push({path:p,depth:b.depth+1}))}let v=[...l.keys()].sort((b,p)=>b<p?-1:b>p?1:0);return n.withDetail?{paths:v,depths:l,truncated:k}:v}function Zn(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++){let n=r[t],s=e[t];if(n.path!==s.path||n.type!==s.type||n.status!==s.status||n.hop!==s.hop||n.dep_index!==s.dep_index||n.annotation!==s.annotation||n.value!==s.value||n.lastMutation!==s.lastMutation)return!1;let o=n.v,i=s.v;if(o!==i&&(o==null||i==null||o.id!==i.id||o.version!==i.version))return!1}return!0}function wt(r,e,t,n){let s=new te(r,n);s.add(e,{name:"source"});let o=P(t,{meta:{kind:"stratify_rules"}});s.add(o,{name:"rules"});for(let i of t)er(s,e,o,i);return s}function er(r,e,t,n){let s=`branch/${n.name}`,o=Symbol("noValue"),i=!1,a=!1,u=!1,d=o,c=!1,h=t.cache??[];function g(y){if(u){u=!1;let f=d;if(d=o,f!==o){let k=h.find(b=>b.name===n.name),v=!1;try{v=k?.classify(f)??!1}catch{v=!1}v?(c=!1,y.emit(f)):c&&(c=!1,y.down([[B],[U]]))}else c?(c=!1,y.down([[B],[U]])):y.down([[U]])}}let m=X([],(y,f)=>{let k=e.subscribe(b=>{for(let p of b)l(p,0,f)}),v=t.subscribe(b=>{for(let p of b)l(p,1,f)});return()=>{k(),v()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:n.name},completeWhenDepsComplete:!1});function l(y,f,k){let v=y[0];return v===B?(f===0?(i=!0,c=!0):a=!0,!0):v===C||v===U?(f===0?(i=!1,u=!0,d=v===C?y[1]:o):(v===C&&(h=y[1]),a=!1),i||a||g(k),!0):v===H||v===$||v===j?(i=!1,a=!1,u=!1,d=o,c=!1,f===0&&k.down([y]),!0):f===1}if(r.add(m,{name:s}),n.ops){let y=n.ops(m),f=`branch/${n.name}/out`;r.add(y,{name:f})}}be();ue();de();we();kt();Re();ue();function pn(r,e){let t=r.cache??0;return t>=e?!1:(r.down([[B],[C,t+1]]),!0)}var bs=Lt((r,e)=>{r("observe"),r("signal"),e("write")});Ve();function Tt(r,e){return qe("reduction",r,e)}function Se(r,e,t,n){let s=n?.maxIterations??10,o=`__feedback_${e}`,i=P(0,{meta:Tt("feedback_counter",{maxIterations:s,feedbackFrom:e,feedbackTo:t})});r.add(i,{name:o});let a=r.resolve(e),u=r.resolve(t),d=`__feedback_effect_${e}`,c=X([],(h,g)=>{let m=a.subscribe(l=>{for(let y of l){let f=y[0];if(f===C){let k=y[1];if(k==null)return;ie(()=>{pn(i,s)&&u.emit(k)})}else if(f===H||f===$){let k=f===$&&y.length>1?[$,y[1]]:[f];i.down([k])}}});return()=>m()},{name:d,describeKind:"effect",meta:{...Tt("feedback_effect",{feedbackFrom:e,feedbackTo:t}),_internal:!0}});return r.add(c,{name:d}),r.addDisposer(se(c)),r}function Ke(r,e,t){if(r.length===0)throw new RangeError("scorer requires at least one source");if(r.length!==e.length)throw new RangeError("scorer requires the same number of sources and weights");let n=[...r,...e],s=r.length,o=t?.scoreFns;return S(n,i=>{let a=i.slice(0,s),u=i.slice(s),d=[],c=0;for(let h=0;h<s;h++){let g=a[h]??0,m=u[h]??0,y=(o?.[h]?o[h](g):g)*m;d.push(y),c+=y}return{value:a,score:c,breakdown:d}},{...t?{equals:t.equals,resubscribable:t.resubscribable,resetOnTeardown:t.resetOnTeardown}:{},describeKind:"derived",meta:Tt("scorer",t?.meta)})}kt();Ve();function I(r,e){return qe("domain_template",r,e)}function tr(r,e){let t=new te(r,e);t.add(e.source,{name:"source"});let n=[{name:"errors",classify:p=>Nt(p,"error")},{name:"traces",classify:p=>Nt(p,"trace")},{name:"metrics",classify:p=>Nt(p,"metric")}],s=e.branches??n,o=s.map(p=>({name:p.name,classify:p.classify})),i=wt("stratify",e.source,o);t.mount("stratify",i);let a=s.map(p=>{try{let w=t.resolve(`stratify::branch/${p.name}`);return S([w],([x])=>x,{initial:null})}catch{return P(null)}}),u=e.correlate??(p=>p),d=S(a,p=>u(p),{meta:I("observability",{stage:"correlate"})});t.add(d,{name:"correlate"});let c=e.sloCheck??(()=>({pass:!0})),h=S([d],p=>p[0],{meta:I("observability",{stage:"slo_value"})}),g=S([h],p=>c(p[0]),{meta:I("observability",{stage:"slo_verified"})});t.add(h,{name:"slo_value"}),t.add(g,{name:"slo_verified"});let m=e.weights??s.map(()=>1),l=a.map(p=>S([p],w=>w[0]!=null?1:0)),y=m.map(p=>P(p));for(let p=0;p<l.length;p++)t.add(l[p],{name:`__signal_${p}`}),t.add(y[p],{name:`__weight_${p}`});let f=Ke(l,y);t.add(f,{name:"alerts"});let k=S([f,g],p=>({scored:p[0],slo:p[1]}),{meta:I("observability",{stage:"output"})});t.add(k,{name:"output"});let v=P(null,{meta:I("observability",{stage:"feedback_reentry"})});t.add(v,{name:"feedback_reentry"});let b=S([g],p=>{let w=p[0];return w&&w.pass===!1?w:null},{meta:I("observability",{stage:"feedback_condition"})});return t.add(b,{name:"feedback_condition"}),Se(t,"feedback_condition","feedback_reentry",{maxIterations:e.maxFeedbackIterations??5}),t}function nr(r,e){let t=new te(r,e);t.add(e.source,{name:"source"});let n=0,s=p=>({id:`issue-${++n}`,title:String(p),severity:1,source:"unknown",raw:p}),o=e.extract??s,i=S([e.source],p=>o(p[0]),{meta:I("issue_tracker",{stage:"extract"})});t.add(i,{name:"extract"});let a=e.verify??(()=>({valid:!0})),u=S([i],p=>{let w=p[0];return{issue:w,verification:a(w)}},{meta:I("issue_tracker",{stage:"verify"})});t.add(u,{name:"verify"});let d=P([],{meta:I("issue_tracker",{stage:"known_patterns"})});t.add(d,{name:"known_patterns"});let c=e.detectRegression??(()=>({regression:!1})),h=S([i,d],p=>{let w=p[0],x=p[1];return{issue:w,regression:c(w,x)}},{meta:I("issue_tracker",{stage:"regression"})});t.add(h,{name:"regression"});let g=S([i],p=>p[0]?.severity??0),m=S([h],p=>p[0]?.regression?2:0);t.add(g,{name:"__severity_signal"}),t.add(m,{name:"__regression_signal"});let l=P(1),y=P(1.5);t.add(l,{name:"__severity_weight"}),t.add(y,{name:"__regression_weight"});let f=Ke([g,m],[l,y]);t.add(f,{name:"priority"});let k=S([u,h,f],p=>({verified:p[0],regression:p[1],priority:p[2]}),{meta:I("issue_tracker",{stage:"output"})});t.add(k,{name:"output"});let v=P(null,{meta:I("issue_tracker",{stage:"feedback_reentry"})});t.add(v,{name:"feedback_reentry"});let b=S([u],p=>{let w=p[0];if(w){let x=w.verification;if(x&&x.valid===!1)return w}return null},{meta:I("issue_tracker",{stage:"feedback_condition"})});return t.add(b,{name:"feedback_condition"}),Se(t,"feedback_condition","feedback_reentry",{maxIterations:e.maxFeedbackIterations??3}),t}function rr(r,e){let t=new te(r,e);t.add(e.source,{name:"source"});let n=b=>({label:"review",confidence:.5,original:b}),s=e.classify??n,o=S([e.source],b=>s(b[0]),{meta:I("content_moderation",{stage:"classify"})});t.add(o,{name:"classify"});let i=wt("stratify",o,[{name:"safe",classify:b=>b.label==="safe"},{name:"review",classify:b=>b.label==="review"},{name:"block",classify:b=>b.label==="block"}]);t.mount("stratify",i);let a=qt([],{name:"review_queue",maxSize:e.maxQueueSize});t.add(a.entries,{name:"review_queue"});let u;try{u=t.resolve("stratify::branch/review")}catch{u=P(null),t.add(u,{name:"__review_fallback"})}let d=ze([u],b=>{let p=b[0];p&&a.append(p)});t.add(d,{name:"__review_accumulator"}),t.addDisposer(se(d));let c=P({},{meta:I("content_moderation",{stage:"policy",access:"both",description:"Moderation policy rules \u2014 updated via feedback"})});t.add(c,{name:"policy"});let h=e.weights??[.1,1,2],g=S([o],b=>b[0]?.confidence??0),m=S([o],b=>{let p=b[0];return p?p.label==="block"?h[2]:p.label==="review"?h[1]:h[0]:0});t.add(g,{name:"__confidence_signal"}),t.add(m,{name:"__severity_signal"});let l=P(1),y=P(1);t.add(l,{name:"__w_confidence"}),t.add(y,{name:"__w_severity"});let f=Ke([g,m],[l,y]);t.add(f,{name:"priority"});let k=S([o,f],b=>({classification:b[0],priority:b[1]}),{meta:I("content_moderation",{stage:"output"})});t.add(k,{name:"output"});let v=S([a.entries,c],b=>{let p=b[0];if(p&&p.length>0){let w=p[p.length-1];if(w&&w.falsePositive)return w}return null},{meta:I("content_moderation",{stage:"feedback_condition"})});return t.add(v,{name:"feedback_condition"}),Se(t,"feedback_condition","policy",{maxIterations:e.maxFeedbackIterations??5}),t}function sr(r,e){let t=new te(r,e);t.add(e.source,{name:"source"});let n=e.validate??(f=>({valid:!0,errors:[],record:f})),s=S([e.source],f=>f[0]!=null?n(f[0]):void 0,{meta:I("data_quality",{stage:"validate"})});t.add(s,{name:"validate"});let o=e.detectAnomaly??(f=>({anomaly:!1,score:0,record:f})),i=S([e.source],f=>f[0]!=null?o(f[0]):void 0,{meta:I("data_quality",{stage:"anomaly"})});t.add(i,{name:"anomaly"});let a=P(null,{meta:I("data_quality",{stage:"baseline",description:"Rolling baseline for drift detection"})});t.add(a,{name:"baseline"});let u=ze([s],f=>{let k=f[0];k?.valid&&ie(()=>{a.emit(k.record)})});t.add(u,{name:"__baseline_updater"}),se(u);let d=e.detectDrift??(()=>({drift:!1})),c=S([e.source,a],f=>d(f[0],f[1]),{meta:I("data_quality",{stage:"drift"})});t.add(c,{name:"drift"});let h=e.suggest??(()=>null),g=S([s,i],f=>h({validation:f[0],anomaly:f[1]}),{meta:I("data_quality",{stage:"remediate"})});t.add(g,{name:"remediate"});let m=S([s,i,c,g],f=>({validation:f[0],anomaly:f[1],drift:f[2],remediation:f[3]}),{meta:I("data_quality",{stage:"output"})});t.add(m,{name:"output"});let l=P([],{meta:I("data_quality",{stage:"validation_rules"})});t.add(l,{name:"validation_rules"});let y=S([i],f=>{let k=f[0];return k?.anomaly?k:null},{meta:I("data_quality",{stage:"feedback_condition"})});return t.add(y,{name:"feedback_condition"}),Se(t,"feedback_condition","validation_rules",{maxIterations:e.maxFeedbackIterations??3}),t}function Nt(r,e){if(r==null||typeof r!="object")return!1;let t=r;return t.type===e||t.kind===e}0&&(module.exports={contentModerationGraph,dataQualityGraph,issueTrackerGraph,observabilityGraph});
1
+ "use strict";var Ze=Object.defineProperty;var vn=Object.getOwnPropertyDescriptor;var _n=Object.getOwnPropertyNames;var wn=Object.prototype.hasOwnProperty;var z=(r,e)=>()=>(r&&(e=r(r=0)),e);var kn=(r,e)=>{for(var t in e)Ze(r,t,{get:e[t],enumerable:!0})},Tn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of _n(e))!wn.call(r,s)&&s!==t&&Ze(r,s,{get:()=>e[s],enumerable:!(n=vn(e,s))||n.enumerable});return r};var Nn=r=>Tn(Ze({},"__esModule",{value:!0}),r);function Ce(){return he>0||Ne}function At(){return he>0}function me(r){he>0?xe.push(r):r()}function ie(r){he+=1;let e=!1;try{r()}catch(t){throw e=!0,t}finally{if(he-=1,he===0)if(e){if(!Ne){let t=xe.splice(0);for(let n of t)try{n()}catch{}le.length=0,fe.length=0,ge.length=0}}else xn()}}function xn(){let r=!Ne;r&&(Ne=!0);let e=[],t=0;try{for(;le.length>0||fe.length>0||ge.length>0||r&&xe.length>0;){if(r&&xe.length>0){let o=xe.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(t+=1,t>1e3)throw le.length=0,fe.length=0,ge.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(le.length>0?le:fe.length>0?fe:ge).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{r&&(Ne=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Ge(r,e,t){if(e.length===0)return;if(e.length===1){let d=t(e[0][0]);if(d<3||!Ce()){r(e);return}(d>=5?ge:d===4?fe:le).push(()=>r(e));return}let n=e.length,s=n,o=n,i=n,a=0;for(;a<n&&t(e[a][0])<3;)a++;for(s=a;a<n&&t(e[a][0])===3;)a++;for(o=a;a<n&&t(e[a][0])===4;)a++;i=a;let u=Ce();if(s>0){let d=e.slice(0,s);r(d)}if(o>s){let d=e.slice(s,o);u?le.push(()=>r(d)):r(d)}if(i>o){let d=e.slice(o,i);u?fe.push(()=>r(d)):r(d)}if(n>i){let d=e.slice(i,n);u?ge.push(()=>r(d)):r(d)}}var he,Ne,le,fe,ge,xe,be=z(()=>{"use strict";he=0,Ne=!1,le=[],fe=[],ge=[],xe=[]});function Dt(r,e){let t=new TextEncoder().encode(r.name);if(t.length===0||t.length>255)throw new Error(`encodeEnvelope: codec name "${r.name}" encodes to ${t.length} bytes (must be 1\u2013255)`);let n=r.version;if(!Number.isInteger(n)||n<0||n>65535)throw new Error(`encodeEnvelope: codec.version ${n} out of u16 range (expected integer 0\u201365535)`);let s=2+t.length+2+e.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let o=new Uint8Array(s),i=0;return o[i++]=et,o[i++]=t.length,o.set(t,i),i+=t.length,o[i++]=n>>>8&255,o[i++]=n&255,o.set(e,i),o}function Mt(r,e){if(r.length<St)throw new Error(`decodeEnvelope: bytes too short (${r.length} < ${St})`);let t=0,n=r[t++];if(n!==et)throw new Error(`decodeEnvelope: unsupported envelope version ${n} (expected ${et})`);let s=r[t++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+s+2>r.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+s+2} bytes, have ${r.length})`);let o=new TextDecoder().decode(r.subarray(t,t+s));t+=s;let i=(r[t]<<8|r[t+1])>>>0;t+=2;let a=r.subarray(t),u=e.lookupCodec(o);if(u==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:u,codecVersion:i,payload:a}}function Ct(r){r.registerCodec(On)}var On,et,St,tt=z(()=>{"use strict";On={name:"json",version:1,contentType:"application/json",encode(r){let e=JSON.stringify(r);return new TextEncoder().encode(e)},decode(r,e){let t=new TextDecoder().decode(r);return JSON.parse(t)}},et=1,St=4});function $e(r){if(r==null)return ye;let{type:e,id:t,...n}=r;return{type:e??"system",id:t??"",...n}}var ye,nt=z(()=>{"use strict";ye={type:"system",id:""}});function re(){return Math.trunc(performance.now()*1e6)}function Pe(){return Date.now()*1e6}var Ie=z(()=>{"use strict"});var Oe,C,H,W,Q,ee,ae,B,U,$,ve,rt,Rn,st,En,An,ot,Gt,$t,Pt,it,ue=z(()=>{"use strict";Oe=Symbol.for("graphrefly/START"),C=Symbol.for("graphrefly/DATA"),H=Symbol.for("graphrefly/DIRTY"),W=Symbol.for("graphrefly/RESOLVED"),Q=Symbol.for("graphrefly/INVALIDATE"),ee=Symbol.for("graphrefly/PAUSE"),ae=Symbol.for("graphrefly/RESUME"),B=Symbol.for("graphrefly/TEARDOWN"),U=Symbol.for("graphrefly/COMPLETE"),$=Symbol.for("graphrefly/ERROR"),ve=Object.freeze([H]),rt=Object.freeze([W]),Rn=Object.freeze([Q]),st=Object.freeze([Oe]),En=Object.freeze([U]),An=Object.freeze([B]),ot=Object.freeze([ve]),Gt=Object.freeze([rt]),$t=Object.freeze([Rn]),Pt=Object.freeze([En]),it=Object.freeze([An])});function It(r){r.registerMessageType(Oe,{tier:0,wireCrossing:!1}),r.registerMessageType(H,{tier:1,wireCrossing:!1}),r.registerMessageType(Q,{tier:1,wireCrossing:!1,metaPassthrough:!1}),r.registerMessageType(ee,{tier:2,wireCrossing:!1}),r.registerMessageType(ae,{tier:2,wireCrossing:!1}),r.registerMessageType(C,{tier:3,wireCrossing:!0}),r.registerMessageType(W,{tier:3,wireCrossing:!0}),r.registerMessageType(U,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType($,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType(B,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Fe,Ft=z(()=>{"use strict";ue();Fe=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 n=this._messageTypes.get(t);return n!=null?n.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 Lt(r){return Array.isArray(r)?[...r]:[r]}function Sn(r,e){return r.has(e)||r.has("*")}function zt(r){let e=[];return r((s,o)=>{e.push({kind:"allow",actions:new Set(Lt(s)),where:o?.where??(()=>!0)})},(s,o)=>{e.push({kind:"deny",actions:new Set(Lt(s)),where:o?.where??(()=>!0)})}),(s,o)=>{let i=!1,a=!1;for(let u of e)Sn(u.actions,o)&&u.where(s)&&(u.kind==="deny"?i=!0:a=!0);return i?!1:a}}function at(r){let e=Dn.filter(t=>r({type:t,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(t=>t==="human"||t==="llm"||t==="system")?"both":e.length===1?e[0]:e.join("+")}var J,Dn,Re=z(()=>{"use strict";J=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}};Dn=["human","llm","wallet","system"]});function ut(r){if(r===void 0)return null;if(typeof r=="number"){if(!Number.isFinite(r))throw new TypeError(`Cannot hash non-finite number: ${r}`);if(Number.isInteger(r)&&!Number.isSafeInteger(r))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${r}. Cross-language cid parity is not guaranteed for unsafe integers.`);return r}if(typeof r=="string"||typeof r=="boolean"||r===null)return r;if(Array.isArray(r))return r.map(ut);if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r).sort())e[t]=ut(r[t]);return e}return null}function Gn(r){let e=Cn.encode(r),t=e.length,n=t*8,s=t+9+63&-64,o=new Uint8Array(s);o.set(e),o[t]=128;let i=new DataView(o.buffer);i.setUint32(s-4,n>>>0,!1),i.setUint32(s-8,Math.floor(n/4294967296)>>>0,!1);let a=1779033703,u=3144134277,d=1013904242,c=2773480762,h=1359893119,g=2600822924,m=528734635,l=1541459225,y=new Uint32Array(64),f=(v,b)=>v>>>b|v<<32-b;for(let v=0;v<s;v+=64){for(let N=0;N<16;N++)y[N]=i.getUint32(v+N*4,!1);for(let N=16;N<64;N++){let A=y[N-15],M=y[N-2],D=f(A,7)^f(A,18)^A>>>3,oe=f(M,17)^f(M,19)^M>>>10;y[N]=y[N-16]+D+y[N-7]+oe>>>0}let b=a,p=u,w=d,x=c,_=h,T=g,O=m,E=l;for(let N=0;N<64;N++){let A=f(_,6)^f(_,11)^f(_,25),M=_&T^~_&O,D=E+A+M+Mn[N]+y[N]>>>0,oe=f(b,2)^f(b,13)^f(b,22),ne=b&p^b&w^p&w,De=oe+ne>>>0;E=O,O=T,T=_,_=x+D>>>0,x=w,w=p,p=b,b=D+De>>>0}a=a+b>>>0,u=u+p>>>0,d=d+w>>>0,c=c+x>>>0,h=h+_>>>0,g=g+T>>>0,m=m+O>>>0,l=l+E>>>0}let k=v=>v.toString(16).padStart(8,"0");return k(a)+k(u)+k(d)+k(c)+k(h)+k(g)+k(m)+k(l)}function dt(r){let e=ut(r??null),t=JSON.stringify(e);return Gn(t).slice(0,16)}function $n(){let r=globalThis.crypto;if(r?.randomUUID)return r.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 ct(r,e,t){let n=t?.id??$n();if(r===0)return{id:n,version:0};let o=(t?.hash??dt)(e);return{id:n,version:0,cid:o,prev:null}}function Vt(r,e,t){r.version+=1,"cid"in r&&(r.prev=r.cid,r.cid=t(e))}var Mn,Cn,jt=z(()=>{"use strict";Mn=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]),Cn=new TextEncoder});function Ut(r){return{node:r,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function lt(r){r.prevData=void 0,r.dirty=!1,r.involvedThisWave=!1,r.dataBatch.length=0,r.terminal=void 0}function Le(r){return r.length===0?r:typeof r[0]=="symbol"?[r]:r}function X(r,e,t){let n=Wt(r)?r:[],s=typeof r=="function"?r:typeof e=="function"?e:void 0,o={};return Wt(r)?o=(ft(e)?e:t)??{}:ft(r)?o=r:o=(ft(e)?e:t)??{},new V(n,s,o)}var Bt,Ht,Pn,In,_e,V,Wt,ft,de=z(()=>{"use strict";tt();nt();be();Ie();Ft();Re();ue();jt();Bt=()=>{},Ht=100;Pn=(r,e,t,n)=>{t.direction==="down-in"&&r._onDepMessage(t.depIndex,e)},In=(r,e,t,n)=>{let s=r;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[st]:[st,[C,o]];s._status==="dirty"&&i.push(ve),Ge(e,i,s._config.tierOf)},_e=new Fe({onMessage:Pn,onSubscribe:In});It(_e);Ct(_e);V=class r{_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,n){this._config=n.config??_e,this._config.onMessage,this._optsName=n.name,this._describeKind=n.describeKind,this._equals=n.equals??Object.is,this._resubscribable=n.resubscribable??!1,this._resetOnTeardown=n.resetOnTeardown??!1,this._autoComplete=n.completeWhenDepsComplete??!0,this._autoError=n.errorWhenDepsError??!0,this._pausable=n.pausable??!0,this._guard=n.guard,this._fn=t,this._partial=n.partial??!1,this._cached=n.initial!==void 0?n.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=n.versioningHash??this._config.defaultHashFn??dt;let s=n.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?ct(s,this._cached===void 0?void 0:this._cached,{id:n.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Ut);let o={};for(let[a,u]of Object.entries(n.meta??{})){let d={initial:u,name:`${n.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};n.guard!=null&&(d.guard=n.guard),o[a]=new r([],void 0,d)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[C,a]])},down(a){i._emit(Le(a))},up(a){i._emitUp(Le(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let n=this._versioningLevel;if(n!=null&&e<=n)return;let s=t?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??t?.id,u=i?.version??0,d=ct(e,o,{id:a,hash:s});d.version=u,this._versioning=d,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=$e(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let n of this._extraGuards)if(!n(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,n=e?.actor!=null;if(!t&&!n)return;let s=$e(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new J({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new J({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:Pe()}}down(e,t){let n=Le(e);n.length!==0&&(this._checkGuard(t),this._emit(n))}emit(e,t){this._checkGuard(t),this._emit([[C,e]])}up(e,t){if(this._deps.length===0)return;let n=Le(e);if(n.length===0)return;this._checkGuard(t);let s=t??{internal:!0};this._validateUpTiers(n);for(let o of this._deps)o.node.up?.(n,s)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let n of e){let s=t(n[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let u=$e(t);if(!this._guard(u,"observe"))throw new J({actor:u,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let u of this._deps)lt(u);if(this._partial===!1){for(let u of this._deps)if(u.prevData!==void 0||u.dataBatch.length!==0||u.terminal!==void 0||u.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(u){throw this._sinkCount-=1,u}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(u){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw u}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[t]=this._sinks;this._sinks=t}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,t=0;try{for(let n=0;n<e;n++){let s=n,o=this._deps[n];o.unsub=Bt,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,u=!1;for(let d of i)a(d[0])>=3&&(u=!0),this._config.onMessage(this,d,{direction:"down-in",depIndex:s},this._actions);u&&this._maybeRunFnOnSettlement()}),t++}}catch(n){this._deps[t].unsub=null;for(let s=0;s<t;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}lt(o)}}throw this._dirtyDepCount=0,n}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let t=this._deps.length,n=Ut(e);if(this._deps.push(n),this._sinks==null)return t;n.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ot),n.unsub=Bt;try{n.unsub=e.subscribe(s=>{if(n.unsub===null)return;let o=this._config.tierOf,i=!1;for(let a of s)o(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:t},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw n.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(n){this._emit([[$,this._wrapFnError("cleanup threw",n)]])}else if(t!=null&&typeof t=="object"){let n=t.deactivate;if(typeof n=="function")try{n()}catch(s){this._emit([[$,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let n of this._deps){if(n.unsub!=null){let s=n.unsub;n.unsub=null;try{s()}catch{}}lt(n)}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 n=this._deps[e],s=t[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:t};for(let i of this._inspectorHooks)i(o)}if(s!==Oe){if(s===H){this._depDirtied(n);return}if(s===Q){if(this._depInvalidated(n),this._cached===void 0)return;this._emit($t);return}if(s===ee||s===ae){this._emit([t]);return}if(s===B){this._emit(it);return}if(s===C)this._depSettledAsData(n,t[1]);else if(s===W)this._depSettledAsResolved(n);else if(s===U)this._depSettledAsTerminal(n,!0);else if(s===$)this._depSettledAsTerminal(n,t[1]);else{this._emit([t]);return}if(!this._fn){(s===C||s===W)&&this._emit([t]),(s===U||s===$)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ot))}_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(Gt),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(Pt)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[$,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[$,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let t=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),n=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=t[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let s=this._deps.map(i=>i.terminal),o={prevData:n,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:t,prevData:n};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(t,this._actions,o);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[$,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Ht?(this._rerunDepth=0,this._emit([[$,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Ht} \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 n=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${n}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[ve,e[0]]:e;let n=!0,s=!1,o=!1,i=-1;for(let u of e){let d=t(u[0]);d<i&&(n=!1),d===3&&(s=!0),u[0]===H&&(o=!0),i=d}let a=e;if(!n){let u=e.map((d,c)=>({m:d,i:c,tier:t(d[0])}));u.sort((d,c)=>d.tier-c.tier||d.i-c.i),a=u.map(d=>d.m)}if(s&&!o&&this._status!=="dirty"){let u=0;for(;u<a.length&&t(a[u][0])===0;)u++;return u===0?[ve,...a]:[...a.slice(0,u),ve,...a.slice(u)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let u=e[a];if(u[0]===$&&u[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(u=>u[0]===B||u[0]===Q);if(a.length===0)return;t=a}t=this._frameBatch(t);let s=null;for(let a=0;a<t.length;a++){let u=t[a],d=u[0];if(d!==ee&&d!==ae){s?.push(u);continue}if(u.length<2)throw new Error(`Node "${this.name}": [[${d===ee?"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=u[1];if(d===ee)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 g=this._pauseBuffer;this._pauseBuffer=[],this._emit(g)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?s?.push(u):s==null&&(s=t.slice(0,a))}if(s!=null){if(s.length===0)return;t=s}if(this._hasMeta&&t.some(a=>a[0]===B))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(it)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(t);if(o.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,u=[];for(let d of o)a(d[0])===3?this._pauseBuffer.push(d):u.push(d);u.length>0&&this._dispatchOrAccumulate(u)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[$,i]])}_updateState(e){let t=this._config.tierOf,n,s,o=-1,i=0;for(let c of e)t(c[0])===3&&i++;let a=i<=1,u=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===C){u=c;break}}for(let c=0;c<e.length;c++){let h=e[c],g=h[0];if(g===C){if(h.length>=2){let m=!1;if(a&&this._cached!==void 0)try{m=this._equals(this._cached,h[1])}catch(l){s=this._wrapFnError("equals threw",l),o=c;break}if(m){n==null&&(n=e.slice(0,c)),n.push(rt),this._status="resolved";continue}this._cached=h[1],this._versioning!=null&&(u<0||c===u)&&Vt(this._versioning,h[1],this._hashFn)}this._status="settled",n?.push(h)}else if(n?.push(h),g===H)this._status="dirty";else if(g===W)this._status="resolved";else if(g===U){this._status="completed";{let m=this._config.rigorRecorder;if(m!=null)try{m.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(g===$){this._status="errored";{let m=this._config.rigorRecorder;if(m!=null)try{m.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(g===Q){if(this._cached!==void 0){let l=this._config.rigorRecorder;if(l!=null)try{l.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let m=this._cleanup;if(typeof m=="function"){this._cleanup=void 0;try{m()}catch{}}else if(m!=null&&typeof m=="object"){let l=m.invalidate;if(typeof l=="function")try{l()}catch{}}}else g===B&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let d=o>=0?n??e.slice(0,o):n??e;return s!=null?{finalMessages:d,equalsError:s}:{finalMessages:d}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let n of t)n(e)};_dispatchOrAccumulate(e){if(At()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],me(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}Ge(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);Ge(this._deliverToSinks,t,this._config.tierOf)}},Wt=r=>Array.isArray(r),ft=r=>typeof r=="object"&&r!=null&&!Array.isArray(r)});function P(r,e){return X([],{...e,initial:r})}function pt(r,e){return X((n,s,o)=>r(s,o)??void 0,{describeKind:"producer",...e})}function S(r,e,t){return X(r,(s,o,i)=>{let a=s.map((u,d)=>u!=null&&u.length>0?u.at(-1):i.prevData[d]);o.emit(e(a,i))},{describeKind:"derived",...t})}function ze(r,e,t){return X(r,(s,o,i)=>{let a=s.map((u,d)=>u!=null&&u.length>0?u.at(-1):i.prevData[d]);return e(a,o,i)??void 0},{describeKind:"effect",...t})}var we=z(()=>{"use strict";de()});function se(r){return r.subscribe(()=>{})}var qt=z(()=>{"use strict"});var Ve=z(()=>{"use strict";qt()});function gt(r,e){if(e!=null&&e.length>0)return new Set(e);switch(r){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;case"spec":return new Set(["type","deps","meta","value"]);default:return new Set(["type","deps"])}}function Ln(r){return r._describeKind!=null?r._describeKind:r._deps.length>0?"derived":r._fn!=null?"producer":"state"}function zn(r){let e={};for(let[t,n]of Object.entries(r.meta))try{e[t]=n.cache}catch{}return e}function mt(r,e,t){let n=e==null,s=!n&&e!=null?[...e].filter(c=>c.startsWith("meta.")).map(c=>c.slice(5)):null,o=n||e.has("meta")||s!=null&&s.length>0,i="state",a=[];r instanceof V&&(i=Ln(r),a=r._deps.map(c=>c.node.name??""));let u={type:i,deps:a};(n||e.has("status"))&&(u.status=r.status);let d=r instanceof V?r._guard:void 0;if(o){let c={...zn(r)};if(d!=null&&c.access===void 0&&(c.access=at(d)),s!=null&&s.length>0&&!e.has("meta")){let h={};for(let g of s)g in c&&(h[g]=c[g]);u.meta=h}else u.meta=c}if(r.name!=null&&(u.name=r.name),(n||e.has("value"))&&(!t||i==="state")){r.status==="sentinel"&&(u.sentinel=!0);try{u.value=r.cache}catch{}}if((n||e.has("v"))&&r.v!=null){let c={id:r.v.id,version:r.v.version};"cid"in r.v&&(c.cid=r.v.cid,c.prev=r.v.prev),u.v=c}return(n||e.has("guard"))&&d!=null&&(u.guard=at(d)),(n||e.has("lastMutation"))&&r.lastMutation!=null&&(u.lastMutation=r.lastMutation),u}var Yt=z(()=>{"use strict";Re();de()});function bt(r,e){if(Object.is(r,e))return!0;if(r==null||e==null||typeof r!="object"||typeof e!="object")return!1;if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(let o=0;o<r.length;o++)if(!bt(r[o],e[o]))return!1;return!0}if(Array.isArray(e))return!1;let t=Object.keys(r),n=Object.keys(e);if(t.length!==n.length)return!1;let s=new Set(n);for(let o of t)if(!s.has(o)||!bt(r[o],e[o]))return!1;return!0}function Jt(r,e){return`${r}\0${e}`}function yt(r,e){let t=[],n=new Set(r.subgraphs),s=new Set(e.subgraphs),o=[];for(let f of s)n.has(f)||o.push(f);o.sort();for(let f of o)t.push({type:"subgraph-mounted",path:f});let i=new Set(Object.keys(r.nodes)),a=new Set(Object.keys(e.nodes)),u=[];for(let f of a)i.has(f)||u.push(f);u.sort();for(let f of u)t.push({type:"node-added",path:f,node:{...e.nodes[f]}});let d=[];for(let f of a){if(!i.has(f))continue;let k=r.nodes[f]?.meta,v=e.nodes[f]?.meta;k==null&&v==null||bt(k??{},v??{})||d.push(f)}d.sort();for(let f of d)t.push({type:"node-meta-changed",path:f,prevMeta:r.nodes[f]?.meta??{},nextMeta:e.nodes[f]?.meta??{}});let c=new Map;for(let f of r.edges)c.set(Jt(f.from,f.to),f);let h=new Map;for(let f of e.edges)h.set(Jt(f.from,f.to),f);let g=[];for(let[f,k]of h)c.has(f)||g.push(k);g.sort((f,k)=>f.from<k.from?-1:f.from>k.from?1:f.to<k.to?-1:f.to>k.to?1:0);for(let f of g)t.push({type:"edge-added",from:f.from,to:f.to});let m=[];for(let[f,k]of c)h.has(f)||m.push(k);m.sort((f,k)=>f.from<k.from?-1:f.from>k.from?1:f.to<k.to?-1:f.to>k.to?1:0);for(let f of m)t.push({type:"edge-removed",from:f.from,to:f.to});let l=[];for(let f of i)a.has(f)||l.push(f);l.sort();for(let f of l)t.push({type:"node-removed",path:f});let y=[];for(let f of n)s.has(f)||y.push(f);y.sort();for(let f of y)t.push({type:"subgraph-unmounted",path:f});return{events:t,flushedAt_ns:re()}}var Qt=z(()=>{"use strict";Ie()});var je,Xt=z(()=>{"use strict";je=class{_timer;_gen=0;start(e,t){this.cancel(),this._gen+=1;let n=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,n===this._gen&&t()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var Ae,Zt=z(()=>{"use strict";Ae=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let t=(this.head+this._size)%this.capacity;this.buf[t]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let t=e<0?this._size+e:e;if(!(t<0||t>=this._size))return this.buf[(this.head+t)%this.capacity]}toArray(){let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this.buf[(this.head+t)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}}});function en(r,e,t,n={}){let s=e in r.nodes,o=t in r.nodes;if(!s)return Be(e,t,"no-such-from");if(!o)return Be(e,t,"no-such-to");let i=n.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(n.findCycle===!0){let d=Vn(r,e,n);if(d!=null)return d}let u=He(e,r.nodes[e],0,n);return Ue(e,t,[u])}if(i===0)return Be(e,t,"no-path");let a=tn(r,e,t,i);return a.found?Ue(e,t,nn(r,a.pathOrder,n)):Be(e,t,a.truncated?"max-depth-exceeded":"no-path")}function tn(r,e,t,n){let s=new Map,o=[{path:t,depth:0}],i=new Set([t]),a=0,u=!1;for(;a<o.length;){let h=o[a++];if(h.path===e)break;if(n!=null&&h.depth>=n){let y=r.nodes[h.path];y?.deps&&y.deps.length>0&&(u=!0);continue}let g=r.nodes[h.path];if(g==null)continue;let m=g.deps??[],l=new Map;for(let y=0;y<m.length;y++){let f=m[y];if(!f)continue;let k=l.get(f);k==null&&(k=[],l.set(f,k)),k.push(y)}for(let[y,f]of l)i.has(y)||(i.add(y),s.set(y,{from:h.path,depIndices:f}),o.push({path:y,depth:h.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:u};let d=[{path:e}],c=e;for(;c!==t;){let h=s.get(c);if(h==null)return{found:!1,pathOrder:[],truncated:!1};d[d.length-1].depIndices=h.depIndices,d.push({path:h.from}),c=h.from}return{found:!0,pathOrder:d,truncated:!1}}function Vn(r,e,t){let n=r.nodes[e];if(n==null)return null;let s=n.deps??[],o=[];for(let a=0;a<s.length;a++)s[a]===e&&o.push(a);if(o.length>0){let a=He(e,n,0,t);a.dep_index=o[0];let u=He(e,n,1,t);return Ue(e,e,[a,u])}let i=null;for(let a=0;a<s.length;a++){let u=s[a];if(!u||u===e)continue;let d=tn(r,u,e,t.maxDepth);d.found&&(i==null||d.pathOrder.length<i.pathOrder.length)&&(i=d,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...d.pathOrder],truncated:!1})}return i==null?null:Ue(e,e,nn(r,i.pathOrder,t))}function nn(r,e,t){return e.map((n,s)=>{let o=r.nodes[n.path],i=He(n.path,o,s,t);return n.depIndices!=null&&n.depIndices.length>0&&(i.dep_index=n.depIndices[0],n.depIndices.length>1&&(i.dep_indices=[...n.depIndices])),i})}function He(r,e,t,n){let s={path:r,type:e.type,hop:t};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let o=n.annotations?.get(r)??e.annotation;o!=null&&(s.annotation=o);let i=n.lastMutations?.get(r)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function Ue(r,e,t){return rn(r,e,!0,"ok",t)}function Be(r,e,t){return rn(r,e,!1,t,[])}function rn(r,e,t,n,s){let o=jn(r,e,t,n,s);return{from:r,to:e,found:t,reason:n,steps:s,text:o,toJSON(){return{from:r,to:e,found:t,reason:n,steps:s}}}}function jn(r,e,t,n,s){if(!t)switch(n){case"no-such-from":return`explainPath: no node named "${r}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${r}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${r}" to "${e}"`}let o=[`Causal path: ${r} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let u=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(u),"value"in i&&o.push(` value: ${Bn(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let d=i.lastMutation.actor;o.push(` actor: ${d.type}${d.id?`:${d.id}`:""}`)}}return o.join(`
2
+ `)}function Bn(r){if(r===void 0)return"<sentinel>";if(r===null)return"null";if(typeof r=="string")return JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean"||typeof r=="bigint")return String(r);try{let e=JSON.stringify(r);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(r)}}var sn=z(()=>{"use strict"});function on(r){let e=new WeakSet,t=new WeakSet,n=[r],s=0;for(;n.length>0;){let o=n.pop();s+=Un(o,e,t,n)}return s}function Un(r,e,t,n){if(r==null)return 0;switch(typeof r){case"number":return j.number;case"boolean":return j.boolean;case"string":return j.string+r.length*2;case"bigint":return j.bigint+Wn(r);case"symbol":return j.symbol;case"function":return e.has(r)?0:(e.add(r),j.function);case"undefined":return 0}let o=r;if(e.has(o))return 0;e.add(o);let i=o[Hn];if(typeof i=="function")try{let d=i.call(o);if(typeof d=="number"&&Number.isFinite(d))return d}catch{}if(o instanceof Date)return j.date;if(o instanceof RegExp)return j.regexp+o.source.length*2;if(o instanceof Error){let d=o.message?o.message.length*2:0,c=o.stack?o.stack.length*2:0;return j.error+d+c}if(typeof URL<"u"&&o instanceof URL)return j.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return j.promise;if(o instanceof WeakMap)return j.weakmap;if(o instanceof WeakSet)return j.weakset;if(o instanceof Map){let d=j.map;for(let[c,h]of o)d+=j.mapEntry,n.push(c),n.push(h);return d}if(o instanceof Set){let d=j.set;for(let c of o)d+=j.setEntry,n.push(c);return d}if(Array.isArray(o)){let d=j.array+o.length*8;for(let c of o)n.push(c);return d}if(o instanceof ArrayBuffer)return t.has(o)?0:(t.add(o),o.byteLength);if(ArrayBuffer.isView(o)){let d=o;return t.has(d.buffer)?48:(t.add(d.buffer),d.buffer.byteLength+48)}let a=j.object,u=Object.keys(o);for(let d of u){a+=j.string+d.length*2;try{n.push(o[d])}catch{}}return a}function Wn(r){let e=r<0n?-r:r;if(e===0n)return 0;let t=e.toString(2).length;return Math.ceil(t/32)*8}var j,Hn,an=z(()=>{"use strict";j={object:56,array:64,string:40,number:8,boolean:4,null:0,undefined:0,symbol:40,bigint:16,function:120,map:72,set:72,mapEntry:40,setEntry:24,date:24,regexp:48,error:64,url:80,promise:48,weakmap:40,weakset:40},Hn=Symbol.for("sizeof")});function un(r,e){let t=e?.topN??10,n=r.describe({detail:"standard"}),s=[],o=r._collectObserveTargets;typeof o=="function"&&o.call(r,"",s);let i=new Map;for(let[g,m]of s)i.set(g,m);let a=[];for(let[g,m]of Object.entries(n.nodes)){let l=i.get(g),y=l instanceof V?l:null,f=y?on(y.cache):0,k=y?y._sinkCount:0,v=m.deps?.length??0,b=m.type==="effect"&&k===0,p=k===0?m.type==="effect"?"orphan-effect":m.type==="derived"?"idle-derived":m.type==="producer"?"idle-producer":null:null;a.push({path:g,type:m.type,status:m.status??"unknown",valueSizeBytes:f,subscriberCount:k,depCount:v,isOrphanEffect:b,orphanKind:p})}let u=a.reduce((g,m)=>g+m.valueSizeBytes,0),d=(g,m)=>[...a].sort(m??((l,y)=>y[g]-l[g])).slice(0,t),c=a.filter(g=>g.orphanKind!=null),h=a.filter(g=>g.isOrphanEffect);return{nodeCount:a.length,edgeCount:n.edges.length,subgraphCount:n.subgraphs.length,nodes:a,totalValueSizeBytes:u,hotspots:{byValueSize:d("valueSizeBytes"),bySubscriberCount:d("subscriberCount"),byDepCount:d("depCount")},orphans:c,orphanEffects:h}}var dn=z(()=>{"use strict";de();an()});function cn(r,e){let t=Math.max(16,r.size*4),n=0;for(;r.size>0;){if(n++>=t){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${t}); ${r.size} disposer(s) discarded`),r.clear();return}let s=r.values().next();if(s.done)return;let o=s.value;r.delete(o);try{o()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function mn(r){return r!=null&&typeof r=="object"&&"cache"in r&&typeof r.subscribe=="function"&&typeof r.down=="function"}function qn(r){if(r!=null)return mn(r)?r.cache:r}function pe(r){return r!=null&&typeof r=="object"&&"cache"in r&&typeof r.subscribe=="function"&&typeof r.down=="function"}function ce(r){return pe(r)?r.cache??"":r}function ln(r){return pe(r)?r.cache??0:r}function fn(r){return pe(r)?r.cache??!1:r}function Kn(r){let e=[];for(let t of Object.keys(r).sort()){let n=r[t].v;n!=null&&e.push(`${t} ${n.id} ${n.version}`)}return e.join(`
3
+ `)}function pn(r){if(r.version!==ke)throw new Error(`unsupported snapshot version ${String(r.version)} (expected ${ke})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in r))throw new Error(`snapshot missing required key "${e}"`);if(typeof r.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof r.nodes!="object"||r.nodes===null||Array.isArray(r.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(r.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(r.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function Yn(r,e){let t=new WeakMap,n=(s,o)=>{if(Object.is(s,o))return!0;if(s==null||o==null||typeof s!="object"||typeof o!="object")return!1;let i=t.get(s);if(i==null&&(i=new WeakSet,t.set(s,i)),i.has(o))return!0;i.add(o);let a=s.constructor,u=o.constructor;if(a!==u)return!1;if(s instanceof Date)return s.getTime()===o.getTime();if(s instanceof RegExp)return s.source===o.source&&s.flags===o.flags;if(Array.isArray(s)){let g=o;if(s.length!==g.length)return!1;for(let m=0;m<s.length;m++)if(!n(s[m],g[m]))return!1;return!0}if(s instanceof Map){let g=o;if(s.size!==g.size)return!1;for(let[m,l]of s)if(!g.has(m)||!n(l,g.get(m)))return!1;return!0}if(s instanceof Set){let g=o;if(s.size!==g.size)return!1;for(let m of s){let l=!1;for(let y of g)if(n(m,y)){l=!0;break}if(!l)return!1}return!0}if(ArrayBuffer.isView(s)){let g=s,m=o;if(g.length!==m.length)return!1;for(let l=0;l<g.length;l++)if(g[l]!==m[l])return!1;return!0}let d=Object.keys(s),c=Object.keys(o);if(d.length!==c.length)return!1;let h=new Set(c);for(let g of d)if(!h.has(g)||!n(s[g],o[g]))return!1;return!0};return n(r,e)}function Jn(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function We(r){let e="^";for(let t=0;t<r.length;t+=1){let n=r[t];if(n==="*"){e+=".*";continue}if(n==="?"){e+=".";continue}if(n==="["){let s=r.indexOf("]",t+1);if(s<=t+1){e+="\\[";continue}let o=r.slice(t+1,s);o.startsWith("!")&&(o=`^${o.slice(1)}`),o=o.replace(/\\/g,"\\\\"),e+=`[${o}]`,t=s;continue}e+=Jn(n)}return e+="$",new RegExp(e)}function vt(r){if(typeof r=="string")return JSON.stringify(r);if(typeof r=="number"||typeof r=="boolean"||r==null)return String(r);try{return JSON.stringify(r)}catch{return"[unserializable]"}}function Zn(r){return r==="none"?Xn:r==="ansi"||r==null?Qn:{data:r.data??"",dirty:r.dirty??"",resolved:r.resolved??"",invalidate:r.invalidate??"",pause:r.pause??"",resume:r.resume??"",complete:r.complete??"",error:r.error??"",teardown:r.teardown??"",derived:r.derived??"",path:r.path??"",reset:r.reset??""}}function hn(r){if(r==null)return{};let e=r.detail;return e==="full"?{...r,structured:r.structured??!0,timeline:r.timeline??!0,causal:r.causal??!0,derived:r.derived??!0}:e==="minimal"?{...r,structured:r.structured??!0}:r.format==="stage-log"?{...r,structured:r.structured??!0,timeline:r.timeline??!0}:r}function er(r,e,t){for(let n=0;n<r.length;n++){let s=r.charCodeAt(n);if(s<32||s===127)throw new Error(`Graph "${e}": ${t} "${r}" must not contain control character (U+${s.toString(16).padStart(4,"0").toUpperCase()} at index ${n})`)}}function _t(r,e,t){if(r==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(r.includes(L))throw new Error(`Graph "${e}": ${t} "${r}" must not contain '${L}' (path separator)`);if(r===Z)throw new Error(`Graph "${e}": ${t} name "${Z}" is reserved for meta companion paths`);er(r,e,t)}function tr(r,e){if(r==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=r.split(L);for(let n of t)if(n==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function nr(r,e){let t=!1;for(let s of r)if(!e.isMetaPassthrough(s[0])){t=!0;break}return t?r.filter(s=>e.isMetaPassthrough(s[0])):r}function bn(r){for(let e of r._mounts.values())bn(e);for(let e of r._nodes.values())try{e.down([[B]],{internal:!0})}catch{}}function rr(r,e){let t=te.diff(r,e),n={};for(let s of t.nodesAdded){let o=e.nodes[s];o!=null&&(n[s]=o)}return{...t,nodesAddedFull:n}}function gn(r,e,t,n={}){let s={paths:[],depths:new Map,truncated:!1};if(!e)return n.withDetail?s:[];if(!n.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let o=n.maxDepth;if(o!=null&&(!Number.isInteger(o)||o<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(o===0)return n.withDetail?s:[];let i=new Map,a=new Map,u=new Map,d=new Map,c=new Set;for(let[b,p]of Object.entries(r.nodes)){if(!b)continue;c.add(b);let w=p.deps??[];i.set(b,w);for(let x of w)x&&(c.add(x),a.has(x)||a.set(x,new Set),a.get(x).add(b))}for(let b of r.edges){if(b==null||typeof b!="object")continue;let p=typeof b.from=="string"?b.from:"",w=typeof b.to=="string"?b.to:"";!p||!w||(c.add(p),c.add(w),d.has(p)||d.set(p,new Set),d.get(p).add(w),u.has(w)||u.set(w,new Set),u.get(w).add(p))}if(!c.has(e))return n.withDetail?s:[];let h=n.both===!0,g=b=>{if(h){let _=i.get(b)??[],T=u.get(b),O=a.get(b),E=d.get(b),N=[..._];return T&&N.push(...T),O&&N.push(...O),E&&N.push(...E),N}if(t==="upstream"){let _=i.get(b)??[],T=u.get(b);return T?[..._,...T]:_}let p=a.get(b),w=d.get(b),x=p?[...p]:[];return w&&x.push(...w),x},m=new Set([e]),l=new Map,y=[{path:e,depth:0}],f=0,k=!1;for(;f<y.length;){let b=y[f++];if(o!=null&&b.depth>=o){g(b.path).length>0&&(k=!0);continue}for(let p of g(b.path))!p||m.has(p)||(m.add(p),l.set(p,b.depth+1),y.push({path:p,depth:b.depth+1}))}let v=[...l.keys()].sort((b,p)=>b<p?-1:b>p?1:0);return n.withDetail?{paths:v,depths:l,truncated:k}:v}function sr(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++){let n=r[t],s=e[t];if(n.path!==s.path||n.type!==s.type||n.status!==s.status||n.hop!==s.hop||n.dep_index!==s.dep_index||n.annotation!==s.annotation||n.value!==s.value||n.lastMutation!==s.lastMutation)return!1;let o=n.v,i=s.v;if(o!==i&&(o==null||i==null||o.id!==i.id||o.version!==i.version))return!1}return!0}var L,Z,ke,Qn,Xn,te,wt=z(()=>{"use strict";nt();be();Ie();Re();ue();Yt();de();we();Qt();Ve();Xt();Zt();tt();sn();dn();L="::",Z="__meta__",ke=1;Qn={data:"\x1B[32m",dirty:"\x1B[33m",resolved:"\x1B[36m",invalidate:"\x1B[93m",pause:"\x1B[90m",resume:"\x1B[96m",complete:"\x1B[34m",error:"\x1B[31m",teardown:"\x1B[91m",derived:"\x1B[35m",path:"\x1B[90m",reset:"\x1B[0m"},Xn={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};te=class r{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_destroyed=!1;_topology;_topologyEmitters=new Set;_factory;_factoryArgs;constructor(e,t){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(L))throw new Error(`Graph name must not contain '${L}' (got "${e}")`);if(e===Z)throw new Error(`Graph name "${Z}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??_e,this._traceRing=new Ae(t?.traceCapacity??1e3),t?.versioning!=null&&this.setVersioning(t.versioning),typeof t?.factory=="string"&&(this._factory=t.factory,t.factoryArgs!==void 0&&(this._factoryArgs=t.factoryArgs))}tagFactory(e,t){return this._factory=e,this._factoryArgs=t,this}ancestors(e=!0){let t=[],n=e?this:this._parent;for(;n!=null;)t.push(n),n=n._parent;return t}get topology(){return this._topology==null&&(this._topology=pt(e=>{let t=n=>{e.emit(n)};return this._topologyEmitters.add(t),()=>{this._topologyEmitters.delete(t)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let t of this._topologyEmitters)t(e)}nameOf(e){return this._nodeToName.get(e)}add(e,t){let n=e.name,s=t?.name??n;if(s==null||s==="")throw new Error(`Graph "${this.name}": graph.add requires a non-empty name \u2014 pass via opts.name or set it on the node (e.g. state(0, { name: "x" }))`);let o=s,i=t?.annotation;if(_t(o,this.name,"add"),this._mounts.has(o))throw new Error(`Graph "${this.name}": name "${o}" is already a mount point`);if(this._nodes.has(o))throw new Error(`Graph "${this.name}": node "${o}" already exists`);let a=this._nodeToName.get(e);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(o,e),this._nodeToName.set(e,o),this._emitTopology({kind:"added",name:o,nodeKind:"node"}),i!=null&&(this._annotations.set(o,i),this.config.inspectorEnabled&&this._traceRing.push({path:o,annotation:i,timestamp_ns:re()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof V&&t._applyVersioning(e)}remove(e){_t(e,this.name,"remove");let t=this._mounts.get(e);if(t){let o={kind:"mount",nodes:[],mounts:[]},i=[];t._collectObserveTargets("",i);for(let[a,u]of i)a.includes(`${L}${Z}${L}`)||o.nodes.push(a);return o.nodes.sort(),o.mounts.push(e),o.mounts.push(...t._collectSubgraphs(`${e}${L}`)),this._mounts.delete(e),t._parent=void 0,bn(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:o}),o}let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(n),n.down([[B]],{internal:!0});let s={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:s}),s}removeAll(e){let t=typeof e=="function"?e:(()=>{let o=We(e);return i=>o.test(i)})(),n={kind:"mount",nodes:[],mounts:[]},s=[...this._nodes.keys(),...this._mounts.keys()].filter(o=>t(o));for(let o of s){let i=this.remove(o);n.nodes.push(...i.nodes),n.mounts.push(...i.mounts)}return n.nodes.sort(),n.mounts.sort(),n}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),t=this._nodes,n=0;return{[Symbol.iterator](){return this},next(){if(n>=e.length)return{value:void 0,done:!0};let s=e[n++];return{value:[s,t.get(s)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(L))return this.resolve(e);let t=this._nodes.get(e);if(!t)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return t}get(e){return this.node(e).cache}set(e,t,n){let s=n?.internal===!0;this.node(e).down([[C,t]],{actor:n?.actor,internal:s,delivery:"write"})}setAll(e,t){let n=Symbol.iterator in e?e:Object.entries(e);ie(()=>{for(let[s,o]of n)this.set(s,o,t)})}invalidate(e,t){let n=t?.internal===!0;this.node(e).down([[Q]],{actor:t?.actor,internal:n,delivery:"write"})}error(e,t,n){let s=n?.internal===!0;this.node(e).down([[$,t]],{actor:n?.actor,internal:s,delivery:"write"})}complete(e,t){let n=t?.internal===!0;this.node(e).down([[U]],{actor:t?.actor,internal:n,delivery:"write"})}edges(e){let t=e?.recursive===!0,n=new Map;if(!t){for(let[u,d]of this._nodes)n.set(d,u);let a=[];for(let[u,d]of this._nodes)if(d instanceof V)for(let c of d._deps){let h=n.get(c.node);h!=null&&a.push([h,u])}return a.sort((u,d)=>u[0]<d[0]?-1:u[0]>d[0]?1:u[1]<d[1]?-1:u[1]>d[1]?1:0),a}let s=[];this._collectObserveTargets("",s);let o=new Map;for(let[a,u]of s)o.set(u,a);let i=[];for(let[a,u]of s)if(u instanceof V)for(let d of u._deps){let c=o.get(d.node);c!=null&&i.push([c,a])}return i.sort((a,u)=>a[0]<u[0]?-1:a[0]>u[0]?1:a[1]<u[1]?-1:a[1]>u[1]?1:0),i}mount(e,t){if(t===void 0){let s=new r(e);return this.mount(e,s)}if(typeof t=="function"){let s=new r(e);return t(s),this.mount(e,s)}let n=t;if(_t(e,this.name,"mount"),this._nodes.has(e))throw new Error(`Graph "${this.name}": cannot mount at "${e}" \u2014 node with that name exists`);if(this._mounts.has(e))throw new Error(`Graph "${this.name}": mount "${e}" already exists`);if(n===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(n._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${n._parent.name}"`);for(let s=this;s!=null;s=s._parent)if(s===n)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,n),n._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),n}resolve(e){let t=tr(e,this.name);return this._resolveFromSegments(t)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let t=e;if(t[0]===this.name&&(t=t.slice(1),t.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let n=t[0],s=t.slice(1);if(s.length===0){let a=this._nodes.get(n);if(a)return a;throw this._mounts.has(n)?new Error(`Graph "${this.name}": path ends at subgraph "${n}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${n}"`)}let o=this._nodes.get(n);if(o&&s.length>0&&s[0]===Z)return this._resolveMetaChainFromNode(o,s,t.join(L));let i=this._mounts.get(n);if(!i)throw this._nodes.has(n)?new Error(`Graph "${this.name}": "${n}" is a node; trailing path "${s.join(L)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${n}"`);return i.resolve(s.join(L))}_resolveMetaChainFromNode(e,t,n){let s=e,o=0,i=[...t];for(;o<i.length;){if(i[o]!==Z)throw new Error(`Graph "${this.name}": expected ${Z} segment in meta path "${n}"`);if(o+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${Z} in "${n}"`);let a=i[o+1],u=s.meta[a];if(!u)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${n}"`);s=u,o+=2}return s}signal(e,t){if(t?.internal!==!0){for(let s of e)if(this.config.messageTier(s[0])===3)throw new Error(`Graph "${this.name}": Graph.signal() rejects tier-3 messages (DATA / RESOLVED). Broadcast is for control-plane tiers (START / DIRTY / INVALIDATE / PAUSE / RESUME / COMPLETE / ERROR / TEARDOWN). For per-node value writes, use Graph.set or graph.node(name).down(...).`)}let n=[];if(this._signalDeliver(e,t??{},new Set,n),n.length>0)throw n[0]}_signalDeliver(e,t,n,s){for(let u of this._mounts.values())u._signalDeliver(e,t,n,s);let i=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},a=nr(e,this.config);for(let u of[...this._nodes.keys()].sort()){let d=this._nodes.get(u);if(!n.has(d)){n.add(d);try{d.down(e,i)}catch(c){if(c instanceof J)throw c;s.push(c)}a.length!==0&&this._signalMetaSubtree(d,a,n,i,s)}}}_signalMetaSubtree(e,t,n,s,o){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!n.has(a)){n.add(a);try{a.down(t,s)}catch(u){if(u instanceof J)throw u;o.push(u)}this._signalMetaSubtree(a,t,n,s,o)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=qn(e?.actor),n=e?.filter;if(e?.detail!=null&&e?.fields!=null)throw new TypeError("Graph.describe(): pass either `detail` or `fields`, not both. `detail: 'spec'` is the canonical spec projection; use `fields` only when you need a custom subset.");let s=gt(e?.detail,e?.fields),o=e?.detail==="spec",i=s,a=[];this._collectObserveTargets("",a);let u=new Map;for(let[p,w]of a)u.set(w,p);let d=[];{let p=a.map(([,_])=>_),w=new Set(u.values()),x=0;for(;p.length>0;){let _=p.shift();if(_ instanceof V)for(let T of _._deps){let O=T.node;if(u.has(O))continue;let E=O.name??"",N=E;if(!N||w.has(N))if(E){let A=2;for(;w.has(`${E}#${A}`);)A++;N=`${E}#${A}`}else for(N=`__internal__/${x++}`;w.has(N);)N=`__internal__/${x++}`;u.set(O,N),w.add(N),d.push([N,O]),p.push(O)}}}let c=[...a,...d],h={};for(let[p,w]of c){if(t!=null&&!w.allowsObserve(t))continue;let x=mt(w,i,o),_=w instanceof V?w._deps.map(N=>u.get(N.node)??N.node.name??""):[],{name:T,...O}=x,E={...O,deps:_};if(!o){let N=this._annotations.get(p);N!=null&&(E.annotation=N)}if(n!=null)if(typeof n=="function"){let N=n;if(!(N.length>=2?N(p,E):N(E)))continue}else{let N=!0;for(let[A,M]of Object.entries(n)){let D=A==="deps_includes"?"depsIncludes":A==="meta_has"?"metaHas":A;if(D==="depsIncludes"){if(!E.deps.includes(String(M))){N=!1;break}continue}if(D==="metaHas"){if(!Object.hasOwn(E.meta??{},String(M))){N=!1;break}continue}if(E[D]!==M){N=!1;break}}if(!N)continue}h[p]=E}let g=new Set(Object.keys(h)),m=[];for(let[p,w]of c)if(w instanceof V)for(let x of w._deps){let _=u.get(x.node);_!=null&&m.push([_,p])}m.sort((p,w)=>p[0]<w[0]?-1:p[0]>w[0]?1:p[1]<w[1]?-1:p[1]>w[1]?1:0);let l=m.map(([p,w])=>({from:p,to:w}));(t!=null||n!=null)&&(l=l.filter(p=>g.has(p.from)&&g.has(p.to)));let y=this._collectSubgraphs(""),f=t!=null||n!=null?y.filter(p=>{let w=`${p}${L}`;return[...g].some(x=>x===p||x.startsWith(w))}):y,k=this,v=e;return{name:this.name,nodes:h,edges:l,subgraphs:f,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(p){let w={...v};return Array.isArray(p)?(w.fields=p,w.detail=void 0):(w.detail=p,w.fields=void 0),k.describe(w)}}}_collectSubgraphs(e){let t=[];for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${n}`;t.push(s),t.push(...this._mounts.get(n)._collectSubgraphs(`${s}${L}`))}return t}resourceProfile(e){return un(this,e)}reachable(e,t,n={}){return n.withDetail===!0?gn(this.describe(),e,t,{...n,withDetail:!0}):gn(this.describe(),e,t,n)}explain(e,t,n){return n?.reactive===!0?this._explainReactive(e,t,n):this._explainStatic(ce(e),ce(t),{...n?.maxDepth!==void 0?{maxDepth:ln(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:fn(n.findCycle)}:{}})}_explainStatic(e,t,n){let s=this.describe({detail:"full"}),o=new Map(this._annotations),i=new Map;for(let[a,u]of Object.entries(s.nodes))u.lastMutation!=null&&i.set(a,u.lastMutation);return en(s,e,t,{...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{},annotations:o,lastMutations:i})}_describeReactive(e){let t={...e,reactive:!1},n=e.reactiveName??"describe",s=0,o=P(s,{name:`${n}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,me(()=>{a=!1,!u&&(s+=1,o.emit(s))}))},c=i.onEvent(v=>{let b=v.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||d()}),h=[],g=new WeakSet,m=v=>{if(g.has(v)||u)return;g.add(v);let b=v.topology.subscribe(p=>{for(let w of p){if(w[0]!==C)continue;let x=w[1];if(d(),x.kind==="added"&&x.nodeKind==="mount"){let _=v._mounts.get(x.name);_!=null&&m(_)}}});h.push(b);for(let p of v._mounts.keys()){let w=v._mounts.get(p);w!=null&&m(w)}};m(this);let l,y=e.actor;mn(y)&&(l=y.subscribe(v=>{let b=!1,p=!1;for(let w of v){let x=w[0];x===C?b=!0:(x===U||x===$||x===B)&&(p=!0)}b&&d(),p&&(l?.(),l=void 0,d())}));let f;try{f=S([o],()=>this.describe(t),{name:n,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(v,b)=>v===b})}catch(v){c(),l?.();for(let b of h)b();throw i.dispose(),v}let k=se(f);return{node:f,dispose(){u=!0,c(),l?.();for(let v of h)v();h.length=0,i.dispose(),k()}}}_describeReactiveDiff(e){let t={...e,reactive:!1},n=e.reactiveName??"describe-diff",s={name:this.name,nodes:{},edges:[],subgraphs:[]},o=this.describe(t),i=yt(s,o),a=P(i,{name:n,meta:{domain:"audit",kind:"describe-diff"},equals:(g,m)=>g===m}),u=this._describeReactive({...e,reactiveName:void 0}),d=!1,c=u.node.subscribe(g=>{if(!d)for(let m of g){if(m[0]!==C)continue;let l=m[1],y=yt(o,l);o=l,y.events.length!==0&&a.emit(y)}}),h=se(a);return{node:a,dispose(){d=!0,c(),u.dispose(),a.down([[B,"describe-diff disposed"]]),h()}}}_explainReactive(e,t,n){let s=0,o=P(s,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,u=!1,d=()=>{a||u||(a=!0,me(()=>{a=!1,!u&&(s+=1,o.emit(s))}))},c=i.onEvent(v=>{let b=v.type;b!=="data"&&b!=="error"&&b!=="complete"&&b!=="teardown"||d()}),h=[];e!=null&&pe(e)&&h.push(e),t!=null&&pe(t)&&h.push(t),n?.maxDepth!=null&&pe(n.maxDepth)&&h.push(n.maxDepth),n?.findCycle!=null&&pe(n.findCycle)&&h.push(n.findCycle);let g=()=>{for(let v of h)if(v.cache===void 0)return!1;return!0},m=()=>{let v=ce(e),b=ce(t);return{from:v,to:b,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:v,to:b,found:!1,reason:"pending",steps:[]})}},l;try{l=S([o],()=>{if(!g())return m();let v=ce(e),b=ce(t),p={...n?.maxDepth!==void 0?{maxDepth:ln(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:fn(n.findCycle)}:{}};return this._explainStatic(v,b,p)},{name:n?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:ce(e),to:ce(t)},equals:(v,b)=>v.found===b.found&&v.reason===b.reason&&v.steps.length===b.steps.length&&sr(v.steps,b.steps)})}catch(v){throw c(),i.dispose(),v}let y=se(l),f=[],k=v=>{let b;return b=v.subscribe(p=>{let w=!1,x=!1;for(let _ of p){let T=_[0];T===C?w=!0:(T===U||T===$||T===B)&&(x=!0)}(w||x)&&d(),x&&b&&(b(),b=void 0)}),()=>{b&&(b(),b=void 0)}};for(let v of h)f.push(k(v));return{node:l,dispose(){u=!0,c();for(let v of f)v?.();f.length=0,i.dispose(),y()}}}_pathsMatching(e){let t=We(e),n=[];return this._collectObserveTargets("",n),n.map(([s])=>s).filter(s=>t.test(s))}_collectObserveTargets(e,t){for(let n of[...this._mounts.keys()].sort()){let s=e===""?n:`${e}${L}${n}`;this._mounts.get(n)._collectObserveTargets(s,t)}for(let n of[...this._nodes.keys()].sort()){let s=this._nodes.get(n),o=e===""?n:`${e}${L}${n}`;t.push([o,s]),this._appendMetaObserveTargets(o,s,t)}}_appendMetaObserveTargets(e,t,n){for(let s of Object.keys(t.meta).sort()){let o=t.meta[s],i=`${e}${L}${Z}${L}${s}`;n.push([i,o]),this._appendMetaObserveTargets(i,o,n)}}observe(e,t){let n=typeof e=="string",o=hn(n?t:e);if(o.reactive===!0)return this._observeReactive(n?e:void 0,o);let i=o.structured===!0||o.timeline===!0||o.causal===!0||o.derived===!0||o.detail==="minimal"||o.detail==="full"||o.format!=null,a=o.actor;if(n){let c=e,h=this.resolve(c);if(a!=null&&!h.allowsObserve(a))throw new J({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,h]],o,"one"):{subscribe(g){return h.subscribe(g)},up(g){try{h.up?.(g)}catch(m){if(m instanceof J)return;throw m}}}}let u=[];this._collectObserveTargets("",u),u.sort((c,h)=>c[0]<h[0]?-1:c[0]>h[0]?1:0);let d=a==null?u:u.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(d,o,"all"):{subscribe:c=>{let h=d.map(([g,m])=>m.subscribe(l=>{c(g,l)}));return()=>{for(let g of h)g()}},up:(c,h)=>{try{this.resolve(c).up?.(h)}catch(g){if(g instanceof J)return;throw g}}}}_observeReactive(e,t){let n=t.tiers,s=n!=null?new Set(n):null,o=t.reactiveName??"observe";return pt(i=>{let a=[],u=!1,d=!1,c=()=>{if(a.length===0||d)return;let y={events:a.slice(),flushedAt_ns:re()};a.length=0,i.emit(y)},h={...t,reactive:!1,structured:!0,timeline:!0},g=e!=null?this.observe(e,h):this.observe(h),m=y=>{d||(a.push(y),!u&&(u=!0,me(()=>{u=!1,c()})))};for(let y of g.events)m(y);let l=g.onEvent(m);return()=>{d=!0,l(),g.dispose()}},{name:o,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,t,n){let s=n==="one"?e[0]?.[0]:void 0,o=i=>{if(n==="one"&&s!=null){let c=this.resolve(s);return this._buildStructuredObserver([[s,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,h)=>c[0]<h[0]?-1:c[0]>h[0]?1:0);let u=i.actor,d=u==null?a:a.filter(([,c])=>c.allowsObserve(u));return this._buildStructuredObserver(d,i,"all")};return this._createObserveResult(e,t,o)}_createObserveResult(e,t,n){let s=t.timeline===!0,o=t.causal===!0,i=t.derived===!0,a=t.detail==="minimal",u=this.config.inspectorEnabled,d=(o||i)&&u,c=t.maxEvents,h=c!=null&&c>0?new Ae(c):null,g=[],m=new Set,l=t.tiers!=null?new Set(t.tiers):null,y={},f=new Set,k=0,v=0,b=0,p=0,w=0,x=0,_=!1,T=!1,O=0,E=new Map,N=new Map,A=new Map,M=R=>{if(!(l!=null&&!l.has(R.type))){h?h.push(R):g.push(R);for(let F of m)F(R)}},D=R=>l==null||l.has(R),oe=()=>s?{timestamp_ns:re(),in_batch:Ce(),batch_id:O}:{},ne=(R,F)=>{if(!(!d||!(R instanceof V)))return R._setInspectorHook(K=>{if(K.kind==="dep_message")E.set(R,K.depIndex);else if(K.kind==="run"){let Te=K.batchData.map((G,q)=>G!=null&&G.length>0?G.at(-1):K.prevData[q]);N.set(R,Te);let Y=K.batchData.map(G=>G!=null?[...G]:void 0);A.set(R,Y),i&&M({type:"derived",path:F,dep_values:Te,dep_batches:Y,...oe()})}})},De=R=>{let F=E.get(R),K=N.get(R);if(!o||K==null)return{};let Y=(F!=null&&F>=0&&R instanceof V?R._deps[F]:void 0)?.node,G=Y?.v,q=A.get(R);return{trigger_dep_index:F,trigger_dep_name:Y?.name,...G!=null?{trigger_version:{id:G.id,version:G.version}}:{},dep_values:[...K],...q!=null?{dep_batches:q}:{}}},Ot=[],Rt=[];for(let[R,F]of e){let K=ne(F,R);K&&Ot.push(K),Rt.push(F.subscribe(Te=>{O++;for(let Y of Te){let G=Y[0],q=oe();if(G===C){y[R]=Y[1];let Xe=F instanceof V?F.lastMutation?.actor??ye:ye;M({type:"data",path:R,data:Y[1],actor:Xe,...q,...De(F)})}else if(a)G===H?D("dirty")&&k++:G===W?D("resolved")&&v++:G===Q?D("invalidate")&&b++:G===ee?D("pause")&&p++:G===ae?D("resume")&&w++:G===B?D("teardown")&&x++:G===U&&!f.has(R)?D("complete")&&(_=!0):G===$&&D("error")&&(T=!0,f.add(R));else if(G===H)D("dirty")&&k++,M({type:"dirty",path:R,...q});else if(G===W)D("resolved")&&v++,M({type:"resolved",path:R,...q,...De(F)});else if(G===Q)D("invalidate")&&b++,M({type:"invalidate",path:R,...q});else if(G===ee)D("pause")&&p++,M({type:"pause",path:R,lockId:Y[1],...q});else if(G===ae)D("resume")&&w++,M({type:"resume",path:R,lockId:Y[1],...q});else if(G===U)D("complete")&&!f.has(R)&&(_=!0),M({type:"complete",path:R,...q});else if(G===$){D("error")&&(T=!0,f.add(R));let Xe=F instanceof V?F.lastMutation?.actor??ye:ye;M({type:"error",path:R,data:Y[1],actor:Xe,...q})}else G===B&&(D("teardown")&&x++,M({type:"teardown",path:R,...q}))}}))}let Ye=!1,Je=()=>{if(!Ye){Ye=!0;for(let R of Rt)R();for(let R of Ot)R();for(let R of Me)R({value:void 0,done:!0});Me.length=0}},Qe=[],Me=[];m.add(R=>{let F=Me.shift();F?F({value:R,done:!1}):Qe.push(R)});let Et={get values(){return y},get dirtyCount(){return k},get resolvedCount(){return v},get invalidateCount(){return b},get pauseCount(){return p},get resumeCount(){return w},get teardownCount(){return x},get events(){return h?h.toArray():[...g]},get anyCompletedCleanly(){return _},get anyErrored(){return T},get completedWithoutErrors(){return _&&!T},onEvent(R){return m.add(R),()=>m.delete(R)},dispose:Je,expand(R){Je();let F={...t};return typeof R=="string"?F.detail=R:Object.assign(F,R),n(hn(F))},[Symbol.asyncIterator](){return{next(){return Qe.length>0?Promise.resolve({value:Qe.shift(),done:!1}):Ye?Promise.resolve({value:void 0,done:!0}):new Promise(R=>Me.push(R))},return(){return Je(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(Et,t),Et}_attachFormatLogger(e,t){let n=t.format;if(n==null)return;let s=t.logger??(l=>console.log(l)),o=t.includeTypes?new Set(t.includeTypes):null,i=t.excludeTypes?new Set(t.excludeTypes):null,a=o==null&&i==null?()=>!0:l=>(o==null||o.has(l))&&(i==null||!i.has(l)),u=Zn(t.theme),d=n==="stage-log"?re():0,c=l=>l==null?"":t.stageLabels?.[l]??l,h=(l,y)=>l.length>y?`${l.slice(0,y-1)}\u2026`:l,g=l=>l.type==="data"||l.type==="error"?h(vt(l.data),120):"",m=l=>{if(n==="stage-log"){let _=(re()-d)/1e9,T=c(l.path).padEnd(9);if(l.type==="data"){let O=g(l);return`[${_.toFixed(3)}s] ${T} \u2190${O?` ${O}`:""}`}if(l.type==="error"){let O=g(l);return`[${_.toFixed(3)}s] ${T} \u2717${O?` ${O}`:""}`}return l.type==="complete"?`[${_.toFixed(3)}s] ${T} \u25A0 complete`:`[${_.toFixed(3)}s] ${T} ${l.type}`}if(n==="json")try{return JSON.stringify(l)}catch{return JSON.stringify({type:l.type,path:l.path,data:"[unserializable]"})}let y=u[l.type]??"",f=l.path?`${u.path}${l.path}${u.reset} `:"",k=l.type==="data"||l.type==="error",v=l.type==="pause"||l.type==="resume",b=k?` ${vt(l.data)}`:v?` ${vt(l.lockId)}`:"",p=l.type==="data"||l.type==="resolved"||l.type==="derived"?l:void 0,w=p?.trigger_dep_name!=null?` <- ${p.trigger_dep_name}`:p?.trigger_dep_index!=null?` <- #${p.trigger_dep_index}`:"",x=l.in_batch?" [batch]":"";return`${f}${y}${l.type.toUpperCase()}${u.reset}${b}${w}${x}`};e.onEvent(l=>{a(l.type)&&s(m(l),l)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){cn(this._disposers,this.name),this.signal([[B]],{internal:!0}),cn(this._storageDisposers,this.name);for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}get destroyed(){return this._destroyed}_destroyClearOnly(){for(let e of[...this._mounts.values()])e._parent=void 0,e._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0,this._destroyed=!0}snapshot(e){let{expand:t,...n}=this.describe({detail:"full"}),s={};for(let a of Object.keys(n.nodes).sort()){let{lastMutation:u,guard:d,...c}=n.nodes[a];s[a]=c}let o=[...n.subgraphs].sort(),i={...n,version:1,nodes:s,subgraphs:o};if(e?.format==null)return i;if(e.format==="json-string")return JSON.stringify(i);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(e.codec);if(a==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return Dt(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let n=t?.config??_e,{codec:s,codecVersion:o,payload:i}=Mt(e,n);return s.decode(i,o)}restore(e,t){if(pn(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let n=t?.only==null?null:(Array.isArray(t.only)?t.only:[t.only]).map(o=>We(o)),s=t?.includeProducers===!0;for(let o of Object.keys(e.nodes).sort()){if(n!==null&&!n.some(a=>a.test(o)))continue;let i=e.nodes[o];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&t?.onError?.(o,new Error(`restore: slice.value is undefined for "${o}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!s)){if(i.v!=null){let u=this.tryResolve(o)?.v;if(u!=null&&u.id===i.v.id&&u.version===i.v.version)continue}try{this.set(o,i.value)}catch(a){t?.onError?.(o,a)}}}}}static fromSnapshot(e,t){pn(e);let n=typeof t=="function"?t:t?.build,s=typeof t=="function"?void 0:t?.factories,o=new r(e.name);if(n)return n(o),o.restore(e),o;for(let m of[...e.subgraphs].sort((l,y)=>{let f=l.split(L).length,k=y.split(L).length;return f!==k?f-k:l<y?-1:l>y?1:0})){let l=m.split(L),y=o;for(let f of l)y._mounts.has(f)||y.mount(f,new r(f)),y=y._mounts.get(f)}let i=s?Object.entries(s).map(([m,l])=>({re:We(m),factory:l})):[],a=m=>{for(let l of i)if(l.re.test(m))return l.factory},u=m=>{let l=m.split(L),y=l.pop();if(y==null||y.length===0)throw new Error(`invalid snapshot path "${m}"`);let f=o;for(let k of l){let v=f._mounts.get(k);if(!v)throw new Error(`unknown mount "${k}" in path "${m}"`);f=v}return[f,y]},d=Object.entries(e.nodes).filter(([m])=>!m.includes(`${L}${Z}${L}`)).sort((m,l)=>m[0]<l[0]?-1:m[0]>l[0]?1:0),c=new Map(d),h=new Map,g=!0;for(;c.size>0&&g;){g=!1;for(let[m,l]of[...c.entries()]){let y=l?.deps??[];if(!y.every(w=>h.has(w)))continue;let[f,k]=u(m),v={...l?.meta??{}},b=a(m),p;if(l?.type==="state")p=P(l.value,{meta:v});else{if(b==null)continue;p=b(k,{path:m,type:l.type,value:l.value,meta:v,deps:y,resolvedDeps:y.map(w=>h.get(w))})}f.add(p,{name:k}),h.set(m,p),c.delete(m),g=!0}}if(c.size>0){let m=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${m}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return o.restore(e),o}toJSON(){return this.snapshot()}attachSnapshotStorage(e,t={}){let n=e.map(d=>({tier:d,debounceMs:Math.max(0,d.debounceMs??0),compactEvery:Math.max(1,d.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let s=(d,c)=>{if(d.disposed)return;let h=Kn(c.nodes);if(d.lastSnapshot!=null&&h!==""&&h===d.lastFingerprint)return;let g=d.seq+1,m=Pe(),f=d.lastSnapshot==null||g%d.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:g,timestamp_ns:m,format_version:ke}:{name:this.name,mode:"diff",diff:rr(d.lastSnapshot,c),seq:g,timestamp_ns:m,format_version:ke};if(d.tier.filter&&!d.tier.filter(f))return;let k;try{k=d.tier.save(f)}catch(v){t.onError?.(v,d.tier);return}if(k&&typeof k.then=="function"){let p=(d.savePending??Promise.resolve()).then(()=>k,()=>k).then(()=>{d.disposed||(d.seq=g,d.lastSnapshot=c,d.lastFingerprint=h)},w=>{t.onError?.(w,d.tier)});d.savePending=p.finally(()=>{d.savePending===p&&(d.savePending=void 0)})}else d.seq=g,d.lastSnapshot=c,d.lastFingerprint=h},o=(d,c)=>{try{s(d,c)}catch(h){t.onError?.(h,d.tier)}},i=(d,c)=>{if(!c.some(l=>{let y=this.config.messageTier(l[0]);return y>=3&&y<5}))return;if(t.filter){let l=this.tryResolve(d);if(l==null)return;let y=mt(l,gt("standard"));if(!t.filter(d,y))return}let g,m=()=>(g==null&&(g=this.snapshot()),g);for(let l of n)l.disposed||(l.debounceMs===0?o(l,m()):(l.timer==null&&(l.timer=new je),l.timer.start(l.debounceMs,()=>{l.disposed||o(l,this.snapshot())})))},a;if(t.paths!=null){let c=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(h=>{let g=this.tryResolve(h);return g==null?()=>{}:g.subscribe(m=>i(h,m))});a=()=>{for(let h of c)h()}}else a=this.observe().subscribe((d,c)=>i(d,c));let u=()=>{a();for(let d of n)d.disposed=!0,d.timer?.cancel();this._storageDisposers.delete(u)};return this._storageDisposers.add(u),{dispose:u}}async _cascadeRestore(e,t){for(let n of e){let s;try{s=await n.load?.()}catch(i){t?.(i,n);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let o=s;try{if(o.mode==="full"&&o.snapshot!=null)return this.restore(o.snapshot),!0;if(o.version===ke&&o.nodes!=null)return this.restore(o),!0}catch(i){t?.(i,n)}}return!1}static async fromStorage(e,t,n){for(let s of t){let o;try{o=await s.load?.()}catch(u){n?.onError?.(u,s);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===ke&&i.nodes!=null?i:void 0;if(a!=null)try{return r.fromSnapshot(a,n)}catch(u){n?.onError?.(u,s)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${t.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,t,n){if(e!=null&&t!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,t),this.config.inspectorEnabled){let s={path:e,annotation:t,timestamp_ns:re(),...n?.actor!=null?{actor:n.actor}:{}};this._traceRing.push(s)}return}return e!=null?this.config.inspectorEnabled?this._annotations.get(e):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(e){return this._annotations.get(e)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(e){let t=this._traceRing.toArray().filter(s=>!e(s)),n=this._traceRing.size-t.length;this._traceRing.clear();for(let s of t)this._traceRing.push(s);return n}static diff(e,t){let n=new Set(Object.keys(e.nodes)),s=new Set(Object.keys(t.nodes)),o=[...s].filter(v=>!n.has(v)).sort(),i=[...n].filter(v=>!s.has(v)).sort(),a=[],u=[];for(let v of n){if(!s.has(v))continue;let b=e.nodes[v],p=t.nodes[v],w=b.v,x=p.v;w!=null&&x!=null&&w.id===x.id&&w.version!==x.version&&u.push({path:v,id:w.id,from:w.version,to:x.version});let _=w!=null&&x!=null&&w.id===x.id&&w.version===x.version;for(let T of["type","status","sentinel"]){let O=b[T],E=p[T];O!==E&&a.push({path:v,field:T,from:O,to:E})}if(!_)for(let T of["value","meta"]){let O=b[T],E=p[T];Yn(O,E)||a.push({path:v,field:T,from:O,to:E})}}let d=v=>`${v.from} ${v.to}`,c=new Set(e.edges.map(d)),h=new Set(t.edges.map(d)),g=t.edges.filter(v=>!c.has(d(v))),m=e.edges.filter(v=>!h.has(d(v))),l=new Set(e.subgraphs),y=new Set(t.subgraphs),f=[...y].filter(v=>!l.has(v)).sort(),k=[...l].filter(v=>!y.has(v)).sort();return{nodesAdded:o,nodesRemoved:i,nodesChanged:a,versionChanges:u,edgesAdded:g,edgesRemoved:m,subgraphsAdded:f,subgraphsRemoved:k}}}});function qe(r,e,t){return{[r]:!0,[`${r}_type`]:e,...t??{}}}var Tt=z(()=>{"use strict"});var cr={};kn(cr,{contentModerationGraph:()=>ur,dataQualityGraph:()=>dr,issueTrackerGraph:()=>ar,observabilityGraph:()=>ir});module.exports=Nn(cr);be();we();be();ue();de();we();var ht=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,t){if(t!==void 0&&t<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=t,t!==void 0){if(this._buf=new Array(t),e&&e.length>0){let n=Math.min(e.length,t),s=e.length-n;for(let o=0;o<n;o++)this._buf[o]=e[s+o];this._size=n}}else this._buf=e?[...e]:[],this._size=this._buf.length}get version(){return this._version}get size(){return this._size}at(e){if(!Number.isInteger(e))return;let t=e>=0?e:this._size+e;if(!(t<0||t>=this._size))return this._maxSize!==void 0?this._buf[(this._head+t)%this._maxSize]:this._buf[t]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let t=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let n=t;n<e.length;n++)this._rawAppend(e[n]);this._version+=1}clear(){if(this._size===0)return 0;let e=this._size;if(this._maxSize===void 0)this._buf.length=0;else for(let t=0;t<e;t++)this._buf[(this._head+t)%this._maxSize]=void 0;return this._head=0,this._size=0,this._version+=1,e}trimHead(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`trimHead: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return 0;let t=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,t);else{for(let n=0;n<t;n++)this._buf[(this._head+n)%this._maxSize]=void 0;this._head=(this._head+t)%this._maxSize}return this._size-=t,this._version+=1,t}slice(e,t){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(t!==void 0&&(!Number.isInteger(t)||t<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${t})`);let n=t===void 0?this._size:Math.min(Math.max(t,0),this._size),s=Math.min(e,this._size);if(s>=n)return[];let o=n-s;if(this._maxSize===void 0)return this._buf.slice(s,n);let i=new Array(o);for(let a=0;a<o;a++)i[a]=this._buf[(this._head+s+a)%this._maxSize];return i}tail(e){if(!Number.isInteger(e)||e<0)throw new RangeError(`tail: n must be a non-negative integer (got ${e})`);if(e===0||this._size===0)return[];let t=Math.min(e,this._size);return this.slice(this._size-t,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let t=0;t<this._size;t++)e[t]=this._buf[(this._head+t)%this._maxSize];return e}snapshot(){return this.toArray()}restore(e){if(this._maxSize===void 0){this._buf.length=0;for(let t=0;t<e.length;t++)this._buf.push(e[t]);this._size=this._buf.length}else{let t=this._maxSize;for(let o=0;o<t;o++)this._buf[o]=void 0;this._head=0;let n=Math.min(e.length,t),s=e.length-n;for(let o=0;o<n;o++)this._buf[o]=e[s+o];this._size=n}this._version+=1}_rawAppend(e){if(this._maxSize===void 0){this._buf.push(e),this._size=this._buf.length;return}this._size<this._maxSize?(this._buf[(this._head+this._size)%this._maxSize]=e,this._size+=1):(this._buf[this._head]=e,this._head=(this._head+1)%this._maxSize)}};function Ee(r){return r.subscribe(()=>{})}var Fn=64;function Kt(r,e={}){let{name:t,maxSize:n,versioning:s,guard:o,backend:i}=e,a=i??new ht(r,n),u=P(a.toArray(),{name:t,describeKind:"state",equals:(_,T)=>_===T,...s!=null?{versioning:s}:{},...o!=null?{guard:o}:{}});function d(){let _=a.toArray();ie(()=>{u.down([[H]],{internal:!0}),u.down([[C,_]],{internal:!0})})}let c=new Map,h=new Map,g=new Map;function m(_,T){return`${_}:${T===void 0?"END":T}`}function l(_){if(_.size<Fn)return;let T=_.keys().next();if(T.done)return;let O=_.get(T.value);O!==void 0&&O.dispose(),_.delete(T.value)}function y(_){let T=a.version;try{return _()}finally{a.version!==T&&d()}}function f(_){if(!Number.isInteger(_)||_<0)throw new RangeError(`tail: n must be a non-negative integer (got ${_})`);let T=c.get(_);if(T!==void 0)return c.delete(_),c.set(_,T),T.node;l(c);let O=S([u],([N])=>{let A=N;return _===0||A.length===0?[]:A.slice(Math.max(0,A.length-_))},{initial:a.tail(_),describeKind:"derived"}),E=Ee(O);return c.set(_,{node:O,dispose:E}),O}function k(_,T){if(!Number.isInteger(_)||_<0)throw new RangeError(`slice: start must be a non-negative integer (got ${_})`);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 O=m(_,T),E=h.get(O);if(E!==void 0)return h.delete(O),h.set(O,E),E.node;l(h);let N=S([u],([M])=>{let D=M;return T===void 0?D.slice(_):D.slice(_,T)},{initial:a.slice(_,T),describeKind:"derived"}),A=Ee(N);return h.set(O,{node:N,dispose:A}),N}function v(_){let T=g.get(_);if(T!==void 0)return T.node;let O=S([u,_],([N,A])=>{let M=N,D=Math.max(0,Math.trunc(A??0));return M.slice(D)},{initial:[],describeKind:"derived"}),E=Ee(O);return g.set(_,{node:O,dispose:E}),O}let b,p;function w(){b===void 0&&(b=X([u],(_,T,O)=>{let E=_[0],A=E!=null&&E.length>0?E.at(-1):O.prevData[0];if(A==null||A.length===0){T.down([[W]]);return}T.emit(A[A.length-1])},{name:t!=null?`${t}::lastValue`:"lastValue",describeKind:"derived",initial:a.size===0?void 0:a.at(a.size-1)}),p=S([u],([_])=>_.length>0,{name:t!=null?`${t}::hasLatest`:"hasLatest",describeKind:"derived",initial:a.size>0}),Ee(b),Ee(p))}let x={entries:u,get size(){return a.size},at(_){return a.at(_)},append(_){y(()=>a.append(_))},appendMany(_){_.length!==0&&y(()=>a.appendMany(_))},clear(){y(()=>a.clear())},trimHead(_){y(()=>a.trimHead(_))},withLatest(){return w(),u},get lastValue(){return w(),b},get hasLatest(){return w(),p},view(_){switch(_.kind){case"tail":return f(_.n);case"slice":return k(_.start,_.stop);case"fromCursor":return v(_.cursor)}},attach(_){let T=_.subscribe(O=>{for(let E of O)E[0]===C&&x.append(E[1])});return()=>T()},attachStorage(_){if(_.length===0)return()=>{};let T=new Map;for(let E of _)T.set(E,a.size);(async()=>{for(let E of _)if(typeof E.loadEntries=="function")try{let N=await Promise.resolve(E.loadEntries());N.entries.length>0&&a.size===0&&(a.restore(N.entries),T.set(E,N.entries.length),d());break}catch{}})();let O=u.subscribe(E=>{for(let N of E){if(N[0]!==C)continue;let A=N[1];for(let M of _){let D=T.get(M)??0;if(A.length<D){try{let ne=M.appendEntries(A);ne instanceof Promise&&ne.catch(()=>{})}catch{}T.set(M,A.length);continue}if(A.length===D)continue;let oe=A.slice(D);T.set(M,A.length);try{let ne=M.appendEntries(oe);ne instanceof Promise&&ne.catch(()=>{})}catch{}}}});return()=>O()},disposeAllViews(){for(let _ of c.values())_.dispose();c.clear();for(let _ of h.values())_.dispose();h.clear();for(let _ of g.values())_.dispose();g.clear()},dispose(){for(let _ of c.values())_.dispose();c.clear();for(let _ of h.values())_.dispose();h.clear();for(let _ of g.values())_.dispose();g.clear()}};return x}ue();de();we();wt();function kt(r,e,t,n){let s=new te(r,n);s.add(e,{name:"source"});let o=P(t,{meta:{kind:"stratify_rules"}});s.add(o,{name:"rules"});for(let i of t)or(s,e,o,i);return s}function or(r,e,t,n){let s=`branch/${n.name}`,o=Symbol("noValue"),i=!1,a=!1,u=!1,d=o,c=!1,h=t.cache??[];function g(y){if(u){u=!1;let f=d;if(d=o,f!==o){let k=h.find(b=>b.name===n.name),v=!1;try{v=k?.classify(f)??!1}catch{v=!1}v?(c=!1,y.emit(f)):c&&(c=!1,y.down([[H],[W]]))}else c?(c=!1,y.down([[H],[W]])):y.down([[W]])}}let m=X([],(y,f)=>{let k=e.subscribe(b=>{for(let p of b)l(p,0,f)}),v=t.subscribe(b=>{for(let p of b)l(p,1,f)});return()=>{k(),v()}},{describeKind:"derived",meta:{kind:"stratify_branch",branch:n.name},completeWhenDepsComplete:!1});function l(y,f,k){let v=y[0];return v===H?(f===0?(i=!0,c=!0):a=!0,!0):v===C||v===W?(f===0?(i=!1,u=!0,d=v===C?y[1]:o):(v===C&&(h=y[1]),a=!1),i||a||g(k),!0):v===U||v===$||v===B?(i=!1,a=!1,u=!1,d=o,c=!1,f===0&&k.down([y]),!0):f===1}if(r.add(m,{name:s}),n.ops){let y=n.ops(m),f=`branch/${n.name}/out`;r.add(y,{name:f})}}wt();be();ue();de();we();Tt();Re();ue();function yn(r,e){let t=r.cache??0;return t>=e?!1:(r.down([[H],[C,t+1]]),!0)}var ks=zt((r,e)=>{r("observe"),r("signal"),e("write")});Ve();function Nt(r,e){return qe("reduction",r,e)}function Se(r,e,t,n){let s=n?.maxIterations??10,o=`__feedback_${e}`,i=P(0,{meta:Nt("feedback_counter",{maxIterations:s,feedbackFrom:e,feedbackTo:t})});r.add(i,{name:o});let a=r.resolve(e),u=r.resolve(t),d=`__feedback_effect_${e}`,c=X([],(h,g)=>{let m=a.subscribe(l=>{for(let y of l){let f=y[0];if(f===C){let k=y[1];if(k==null)return;ie(()=>{yn(i,s)&&u.emit(k)})}else if(f===U||f===$){let k=f===$&&y.length>1?[$,y[1]]:[f];i.down([k])}}});return()=>m()},{name:d,describeKind:"effect",meta:{...Nt("feedback_effect",{feedbackFrom:e,feedbackTo:t}),_internal:!0}});return r.add(c,{name:d}),r.addDisposer(se(c)),r}function Ke(r,e,t){if(r.length===0)throw new RangeError("scorer requires at least one source");if(r.length!==e.length)throw new RangeError("scorer requires the same number of sources and weights");let n=[...r,...e],s=r.length,o=t?.scoreFns;return S(n,i=>{let a=i.slice(0,s),u=i.slice(s),d=[],c=0;for(let h=0;h<s;h++){let g=a[h]??0,m=u[h]??0,y=(o?.[h]?o[h](g):g)*m;d.push(y),c+=y}return{value:a,score:c,breakdown:d}},{...t?{equals:t.equals,resubscribable:t.resubscribable,resetOnTeardown:t.resetOnTeardown}:{},describeKind:"derived",meta:Nt("scorer",t?.meta)})}Tt();Ve();function I(r,e){return qe("domain_template",r,e)}function ir(r,e){let t=new te(r,e);t.add(e.source,{name:"source"});let n=[{name:"errors",classify:p=>xt(p,"error")},{name:"traces",classify:p=>xt(p,"trace")},{name:"metrics",classify:p=>xt(p,"metric")}],s=e.branches??n,o=s.map(p=>({name:p.name,classify:p.classify})),i=kt("stratify",e.source,o);t.mount("stratify",i);let a=s.map(p=>{try{let w=t.resolve(`stratify::branch/${p.name}`);return S([w],([x])=>x,{initial:null})}catch{return P(null)}}),u=e.correlate??(p=>p),d=S(a,p=>u(p),{meta:I("observability",{stage:"correlate"})});t.add(d,{name:"correlate"});let c=e.sloCheck??(()=>({pass:!0})),h=S([d],p=>p[0],{meta:I("observability",{stage:"slo_value"})}),g=S([h],p=>c(p[0]),{meta:I("observability",{stage:"slo_verified"})});t.add(h,{name:"slo_value"}),t.add(g,{name:"slo_verified"});let m=e.weights??s.map(()=>1),l=a.map(p=>S([p],w=>w[0]!=null?1:0)),y=m.map(p=>P(p));for(let p=0;p<l.length;p++)t.add(l[p],{name:`__signal_${p}`}),t.add(y[p],{name:`__weight_${p}`});let f=Ke(l,y);t.add(f,{name:"alerts"});let k=S([f,g],p=>({scored:p[0],slo:p[1]}),{meta:I("observability",{stage:"output"})});t.add(k,{name:"output"});let v=P(null,{meta:I("observability",{stage:"feedback_reentry"})});t.add(v,{name:"feedback_reentry"});let b=S([g],p=>{let w=p[0];return w&&w.pass===!1?w:null},{meta:I("observability",{stage:"feedback_condition"})});return t.add(b,{name:"feedback_condition"}),Se(t,"feedback_condition","feedback_reentry",{maxIterations:e.maxFeedbackIterations??5}),t}function ar(r,e){let t=new te(r,e);t.add(e.source,{name:"source"});let n=0,s=p=>({id:`issue-${++n}`,title:String(p),severity:1,source:"unknown",raw:p}),o=e.extract??s,i=S([e.source],p=>o(p[0]),{meta:I("issue_tracker",{stage:"extract"})});t.add(i,{name:"extract"});let a=e.verify??(()=>({valid:!0})),u=S([i],p=>{let w=p[0];return{issue:w,verification:a(w)}},{meta:I("issue_tracker",{stage:"verify"})});t.add(u,{name:"verify"});let d=P([],{meta:I("issue_tracker",{stage:"known_patterns"})});t.add(d,{name:"known_patterns"});let c=e.detectRegression??(()=>({regression:!1})),h=S([i,d],p=>{let w=p[0],x=p[1];return{issue:w,regression:c(w,x)}},{meta:I("issue_tracker",{stage:"regression"})});t.add(h,{name:"regression"});let g=S([i],p=>p[0]?.severity??0),m=S([h],p=>p[0]?.regression?2:0);t.add(g,{name:"__severity_signal"}),t.add(m,{name:"__regression_signal"});let l=P(1),y=P(1.5);t.add(l,{name:"__severity_weight"}),t.add(y,{name:"__regression_weight"});let f=Ke([g,m],[l,y]);t.add(f,{name:"priority"});let k=S([u,h,f],p=>({verified:p[0],regression:p[1],priority:p[2]}),{meta:I("issue_tracker",{stage:"output"})});t.add(k,{name:"output"});let v=P(null,{meta:I("issue_tracker",{stage:"feedback_reentry"})});t.add(v,{name:"feedback_reentry"});let b=S([u],p=>{let w=p[0];if(w){let x=w.verification;if(x&&x.valid===!1)return w}return null},{meta:I("issue_tracker",{stage:"feedback_condition"})});return t.add(b,{name:"feedback_condition"}),Se(t,"feedback_condition","feedback_reentry",{maxIterations:e.maxFeedbackIterations??3}),t}function ur(r,e){let t=new te(r,e);t.add(e.source,{name:"source"});let n=b=>({label:"review",confidence:.5,original:b}),s=e.classify??n,o=S([e.source],b=>s(b[0]),{meta:I("content_moderation",{stage:"classify"})});t.add(o,{name:"classify"});let i=kt("stratify",o,[{name:"safe",classify:b=>b.label==="safe"},{name:"review",classify:b=>b.label==="review"},{name:"block",classify:b=>b.label==="block"}]);t.mount("stratify",i);let a=Kt([],{name:"review_queue",maxSize:e.maxQueueSize});t.add(a.entries,{name:"review_queue"});let u;try{u=t.resolve("stratify::branch/review")}catch{u=P(null),t.add(u,{name:"__review_fallback"})}let d=ze([u],b=>{let p=b[0];p&&a.append(p)});t.add(d,{name:"__review_accumulator"}),t.addDisposer(se(d));let c=P({},{meta:I("content_moderation",{stage:"policy",access:"both",description:"Moderation policy rules \u2014 updated via feedback"})});t.add(c,{name:"policy"});let h=e.weights??[.1,1,2],g=S([o],b=>b[0]?.confidence??0),m=S([o],b=>{let p=b[0];return p?p.label==="block"?h[2]:p.label==="review"?h[1]:h[0]:0});t.add(g,{name:"__confidence_signal"}),t.add(m,{name:"__severity_signal"});let l=P(1),y=P(1);t.add(l,{name:"__w_confidence"}),t.add(y,{name:"__w_severity"});let f=Ke([g,m],[l,y]);t.add(f,{name:"priority"});let k=S([o,f],b=>({classification:b[0],priority:b[1]}),{meta:I("content_moderation",{stage:"output"})});t.add(k,{name:"output"});let v=S([a.entries,c],b=>{let p=b[0];if(p&&p.length>0){let w=p[p.length-1];if(w&&w.falsePositive)return w}return null},{meta:I("content_moderation",{stage:"feedback_condition"})});return t.add(v,{name:"feedback_condition"}),Se(t,"feedback_condition","policy",{maxIterations:e.maxFeedbackIterations??5}),t}function dr(r,e){let t=new te(r,e);t.add(e.source,{name:"source"});let n=e.validate??(f=>({valid:!0,errors:[],record:f})),s=S([e.source],f=>f[0]!=null?n(f[0]):void 0,{meta:I("data_quality",{stage:"validate"})});t.add(s,{name:"validate"});let o=e.detectAnomaly??(f=>({anomaly:!1,score:0,record:f})),i=S([e.source],f=>f[0]!=null?o(f[0]):void 0,{meta:I("data_quality",{stage:"anomaly"})});t.add(i,{name:"anomaly"});let a=P(null,{meta:I("data_quality",{stage:"baseline",description:"Rolling baseline for drift detection"})});t.add(a,{name:"baseline"});let u=ze([s],f=>{let k=f[0];k?.valid&&ie(()=>{a.emit(k.record)})});t.add(u,{name:"__baseline_updater"}),se(u);let d=e.detectDrift??(()=>({drift:!1})),c=S([e.source,a],f=>d(f[0],f[1]),{meta:I("data_quality",{stage:"drift"})});t.add(c,{name:"drift"});let h=e.suggest??(()=>null),g=S([s,i],f=>h({validation:f[0],anomaly:f[1]}),{meta:I("data_quality",{stage:"remediate"})});t.add(g,{name:"remediate"});let m=S([s,i,c,g],f=>({validation:f[0],anomaly:f[1],drift:f[2],remediation:f[3]}),{meta:I("data_quality",{stage:"output"})});t.add(m,{name:"output"});let l=P([],{meta:I("data_quality",{stage:"validation_rules"})});t.add(l,{name:"validation_rules"});let y=S([i],f=>{let k=f[0];return k?.anomaly?k:null},{meta:I("data_quality",{stage:"feedback_condition"})});return t.add(y,{name:"feedback_condition"}),Se(t,"feedback_condition","validation_rules",{maxIterations:e.maxFeedbackIterations??3}),t}function xt(r,e){if(r==null||typeof r!="object")return!1;let t=r;return t.type===e||t.kind===e}0&&(module.exports={contentModerationGraph,dataQualityGraph,issueTrackerGraph,observabilityGraph});
@@ -1,6 +1,6 @@
1
- import '../../node-BYInONRr.cjs';
2
- import '../../graph-E6likq7w.cjs';
3
- export { A as AnomalyResult, C as ContentModerationGraphOptions, D as DataQualityGraphOptions, E as ExtractedIssue, I as IssueTrackerGraphOptions, M as ModerationResult, O as ObservabilityBranch, a as ObservabilityGraphOptions, V as ValidationResult, c as contentModerationGraph, d as dataQualityGraph, b as issueTrackerGraph, o as observabilityGraph } from '../../index-tV3AA9hI.cjs';
4
- import '../../meta-Ct9nqQS5.cjs';
1
+ import '../../node-ClS5yC-B.cjs';
2
+ import '../../graph-C4SHb3Ly.cjs';
3
+ export { A as AnomalyResult, C as ContentModerationGraphOptions, D as DataQualityGraphOptions, E as ExtractedIssue, I as IssueTrackerGraphOptions, M as ModerationResult, O as ObservabilityBranch, a as ObservabilityGraphOptions, V as ValidationResult, c as contentModerationGraph, d as dataQualityGraph, b as issueTrackerGraph, o as observabilityGraph } from '../../index-tJoTcnHh.cjs';
4
+ import '../../meta-vE8bxW1E.cjs';
5
5
  import '../../extra/storage-core.cjs';
6
6
  import '../../extra/storage-tiers.cjs';
@@ -1,6 +1,6 @@
1
- import '../../node-BYInONRr.js';
2
- import '../../graph-BkIkog4h.js';
3
- export { A as AnomalyResult, C as ContentModerationGraphOptions, D as DataQualityGraphOptions, E as ExtractedIssue, I as IssueTrackerGraphOptions, M as ModerationResult, O as ObservabilityBranch, a as ObservabilityGraphOptions, V as ValidationResult, c as contentModerationGraph, d as dataQualityGraph, b as issueTrackerGraph, o as observabilityGraph } from '../../index-B6iTqKtJ.js';
4
- import '../../meta-D8OyedKp.js';
1
+ import '../../node-ClS5yC-B.js';
2
+ import '../../graph-7VguS7a4.js';
3
+ export { A as AnomalyResult, C as ContentModerationGraphOptions, D as DataQualityGraphOptions, E as ExtractedIssue, I as IssueTrackerGraphOptions, M as ModerationResult, O as ObservabilityBranch, a as ObservabilityGraphOptions, V as ValidationResult, c as contentModerationGraph, d as dataQualityGraph, b as issueTrackerGraph, o as observabilityGraph } from '../../index-Dn-wI9g4.js';
4
+ import '../../meta-BgVAsg9j.js';
5
5
  import '../../extra/storage-core.js';
6
6
  import '../../extra/storage-tiers.js';
@@ -1 +1 @@
1
- import{a,b,c,d}from"../../chunk-JKBOIJ22.js";import"../../chunk-LYM4PBMV.js";import"../../chunk-2QXRYP7Q.js";import"../../chunk-756D5TFD.js";import"../../chunk-L6NSJVJZ.js";import"../../chunk-2BX4NB34.js";import"../../chunk-SGS4OJGS.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-FHRBBHJN.js";import"../../chunk-4VVTGLXJ.js";import"../../chunk-35JTVPOX.js";import"../../chunk-YXDRGKXP.js";import"../../chunk-CKFQS2CJ.js";import"../../chunk-LYCLF26R.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{c as contentModerationGraph,d as dataQualityGraph,b as issueTrackerGraph,a as observabilityGraph};
1
+ import{a,b,c,d}from"../../chunk-YGL7FPVQ.js";import"../../chunk-G5VBJ5K6.js";import"../../chunk-FDZAZNRO.js";import"../../chunk-3ZZX7M25.js";import"../../chunk-L6NSJVJZ.js";import"../../chunk-LDQ3IUIP.js";import"../../chunk-ACMJ2ZPS.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-6YFZMUMR.js";import"../../chunk-4VVTGLXJ.js";import"../../chunk-2K5RXLAH.js";import"../../chunk-35JTVPOX.js";import"../../chunk-LYCLF26R.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{c as contentModerationGraph,d as dataQualityGraph,b as issueTrackerGraph,a as observabilityGraph};