@graphrefly/graphrefly 0.38.0 → 0.40.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 (321) hide show
  1. package/dist/budget-gate-CmmVtasH.d.ts +115 -0
  2. package/dist/budget-gate-DiP_nK0n.d.cts +115 -0
  3. package/dist/{cascading-BsJ4GbnS.d.ts → cascading-BNfxffgc.d.ts} +2 -2
  4. package/dist/{cascading-B25wxpRa.d.cts → cascading-Cxs1eztH.d.cts} +2 -2
  5. package/dist/chunk-2BX4NB34.js +3 -0
  6. package/dist/{chunk-6VFC334U.js → chunk-2DMKW2AD.js} +1 -1
  7. package/dist/{chunk-4BDQXBXE.js → chunk-2QXRYP7Q.js} +1 -1
  8. package/dist/chunk-32N3JALT.js +1 -0
  9. package/dist/chunk-35JTVPOX.js +1 -0
  10. package/dist/chunk-3G5U5QNE.js +5 -0
  11. package/dist/{chunk-PHXZRR6C.js → chunk-4I45FVQS.js} +1 -1
  12. package/dist/{chunk-B5S7KTGP.js → chunk-6I726LZU.js} +1 -1
  13. package/dist/{chunk-NV63VQHI.js → chunk-6VWBPSSY.js} +1 -1
  14. package/dist/chunk-6XVD5TZV.js +1 -0
  15. package/dist/chunk-756D5TFD.js +1 -0
  16. package/dist/{chunk-DSOVKKTI.js → chunk-7Q4ZD3YW.js} +1 -1
  17. package/dist/{chunk-TMVY7OWG.js → chunk-B7LCDQEV.js} +1 -1
  18. package/dist/chunk-C72GO4IZ.js +1 -0
  19. package/dist/{chunk-RZ5HKPGI.js → chunk-CKFQS2CJ.js} +1 -1
  20. package/dist/chunk-D27JNOLZ.js +1 -0
  21. package/dist/chunk-ECQRP2UT.js +1 -0
  22. package/dist/{chunk-6773HURD.js → chunk-FHRBBHJN.js} +1 -1
  23. package/dist/{chunk-UVLZX2OU.js → chunk-I2DEVPMU.js} +1 -1
  24. package/dist/chunk-INQFTVZA.js +61 -0
  25. package/dist/{chunk-6KZZ6XQE.js → chunk-J63M5U46.js} +1 -1
  26. package/dist/{chunk-POCWFIJ7.js → chunk-JKBOIJ22.js} +1 -1
  27. package/dist/chunk-K2Z7UENB.js +1 -0
  28. package/dist/chunk-L6NSJVJZ.js +1 -0
  29. package/dist/{chunk-K5C67OGE.js → chunk-LCGAVGGV.js} +2 -2
  30. package/dist/chunk-LYM4PBMV.js +1 -0
  31. package/dist/{chunk-O2BLVQU4.js → chunk-MNZIKXK4.js} +1 -1
  32. package/dist/chunk-N43XM7BM.js +1 -0
  33. package/dist/{chunk-FWGIZP3W.js → chunk-OSZ22J7O.js} +1 -1
  34. package/dist/{chunk-FAYEMS5M.js → chunk-PPUYQ66A.js} +1 -1
  35. package/dist/{chunk-SP5O2MIX.js → chunk-QSK3RRII.js} +1 -1
  36. package/dist/chunk-RZJDIV2G.js +1 -0
  37. package/dist/chunk-SSCGRYJ2.js +1 -0
  38. package/dist/chunk-SVFKHUCW.js +1 -0
  39. package/dist/chunk-TSOYJ743.js +1 -0
  40. package/dist/{chunk-O245YLM5.js → chunk-UWA6D7UF.js} +1 -1
  41. package/dist/chunk-VMF23LGB.js +1 -0
  42. package/dist/chunk-WL6LFPJB.js +1 -0
  43. package/dist/chunk-WUT362QV.js +1 -0
  44. package/dist/chunk-XJLYLLIJ.js +1 -0
  45. package/dist/{chunk-IBGE62GZ.js → chunk-XW4YDF6G.js} +1 -1
  46. package/dist/chunk-YKD7WUYJ.js +43 -0
  47. package/dist/{chunk-7KZZLWZ6.js → chunk-YXDRGKXP.js} +1 -1
  48. package/dist/chunk-Z4F3DOWS.js +84 -0
  49. package/dist/compat/index.cjs +9 -13
  50. package/dist/compat/index.d.cts +16 -16
  51. package/dist/compat/index.d.ts +16 -16
  52. package/dist/compat/index.js +1 -1
  53. package/dist/compat/jotai/index.d.cts +2 -2
  54. package/dist/compat/jotai/index.d.ts +2 -2
  55. package/dist/compat/nanostores/index.d.cts +2 -2
  56. package/dist/compat/nanostores/index.d.ts +2 -2
  57. package/dist/compat/nestjs/index.cjs +7 -11
  58. package/dist/compat/nestjs/index.d.cts +8 -8
  59. package/dist/compat/nestjs/index.d.ts +8 -8
  60. package/dist/compat/nestjs/index.js +1 -1
  61. package/dist/compat/react/index.d.cts +2 -2
  62. package/dist/compat/react/index.d.ts +2 -2
  63. package/dist/compat/solid/index.d.cts +2 -2
  64. package/dist/compat/solid/index.d.ts +2 -2
  65. package/dist/compat/svelte/index.d.cts +2 -2
  66. package/dist/compat/svelte/index.d.ts +2 -2
  67. package/dist/compat/vue/index.d.cts +2 -2
  68. package/dist/compat/vue/index.d.ts +2 -2
  69. package/dist/compat/zustand/index.cjs +3 -7
  70. package/dist/compat/zustand/index.d.cts +4 -4
  71. package/dist/compat/zustand/index.d.ts +4 -4
  72. package/dist/compat/zustand/index.js +1 -1
  73. package/dist/core/index.cjs +1 -1
  74. package/dist/core/index.d.cts +4 -4
  75. package/dist/core/index.d.ts +4 -4
  76. package/dist/core/index.js +1 -1
  77. package/dist/{composite-DTOlDuch.d.ts → decay-BnrlbxSv.d.ts} +39 -3
  78. package/dist/{composite-CgG0MqHm.d.cts → decay-C25AyNAj.d.cts} +39 -3
  79. package/dist/extra/browser.d.cts +1 -1
  80. package/dist/extra/browser.d.ts +1 -1
  81. package/dist/extra/index.cjs +16 -20
  82. package/dist/extra/index.d.cts +11 -9
  83. package/dist/extra/index.d.ts +11 -9
  84. package/dist/extra/index.js +1 -1
  85. package/dist/extra/node.cjs +2 -2
  86. package/dist/extra/node.d.cts +1 -1
  87. package/dist/extra/node.d.ts +1 -1
  88. package/dist/extra/node.js +1 -1
  89. package/dist/extra/operators.cjs +1 -1
  90. package/dist/extra/operators.d.cts +1 -1
  91. package/dist/extra/operators.d.ts +1 -1
  92. package/dist/extra/operators.js +1 -1
  93. package/dist/extra/reactive.cjs +1 -1
  94. package/dist/extra/reactive.d.cts +3 -3
  95. package/dist/extra/reactive.d.ts +3 -3
  96. package/dist/extra/reactive.js +1 -1
  97. package/dist/extra/render/index.cjs +5 -0
  98. package/dist/extra/render/index.d.cts +183 -0
  99. package/dist/extra/render/index.d.ts +183 -0
  100. package/dist/extra/render/index.js +1 -0
  101. package/dist/extra/sources.cjs +1 -1
  102. package/dist/extra/sources.d.cts +1 -1
  103. package/dist/extra/sources.d.ts +1 -1
  104. package/dist/extra/sources.js +1 -1
  105. package/dist/extra/storage-browser.d.cts +1 -1
  106. package/dist/extra/storage-browser.d.ts +1 -1
  107. package/dist/{fallback-axI2cXwt.d.cts → fallback-8JYU8tlT.d.cts} +1 -1
  108. package/dist/{fallback-DuEXfA4F.d.ts → fallback-CMZl39L5.d.ts} +1 -1
  109. package/dist/graph/index.cjs +7 -7
  110. package/dist/graph/index.d.cts +5 -5
  111. package/dist/graph/index.d.ts +5 -5
  112. package/dist/graph/index.js +1 -1
  113. package/dist/{graph-BjW1taJl.d.ts → graph-BkIkog4h.d.ts} +76 -100
  114. package/dist/{graph-CHsVwf9S.d.cts → graph-E6likq7w.d.cts} +76 -100
  115. package/dist/{index-CIcu6fIR.d.ts → index-2n8Eai6M.d.ts} +1 -1
  116. package/dist/{index-BwOsJfLJ.d.ts → index-3k4Gg6-n.d.ts} +3 -3
  117. package/dist/{index-BUFCHvOR.d.ts → index-40ZT4MHj.d.ts} +3 -3
  118. package/dist/index-8s-Qm-gz.d.ts +218 -0
  119. package/dist/index-A3U3CSve.d.cts +113 -0
  120. package/dist/{index-CDvC1m5p.d.ts → index-B2RUoIUz.d.ts} +1 -1
  121. package/dist/{index-Byp771zP.d.ts → index-B6iTqKtJ.d.ts} +2 -2
  122. package/dist/{index-D-B7U42V.d.cts → index-B72TQQHd.d.cts} +2 -2
  123. package/dist/{resilience-Bys63Cpd.d.ts → index-BAQrjuZF.d.ts} +202 -26
  124. package/dist/{index-BiomL7AW.d.ts → index-BJSZxSFX.d.ts} +1 -1
  125. package/dist/index-BQ1fR4li.d.ts +210 -0
  126. package/dist/{index-D7-RSD93.d.cts → index-BTHOTC0Q.d.cts} +4 -4
  127. package/dist/{index-CEVzBWeB.d.ts → index-BaA-xpSw.d.ts} +26 -19
  128. package/dist/{index-CAV-3RpJ.d.cts → index-Bd91Nmf4.d.cts} +4 -4
  129. package/dist/{index-BI1wMfyc.d.ts → index-BgjS2b8N.d.ts} +3 -3
  130. package/dist/{index-Bpr0Pwgl.d.cts → index-BiHUBEKq.d.cts} +3 -3
  131. package/dist/{index-UsU9ptzs.d.cts → index-BilOa6AE.d.cts} +55 -9
  132. package/dist/{index-DJVQ-t07.d.ts → index-BmSQLAZo.d.cts} +41 -48
  133. package/dist/{index-DTDVDzhA.d.ts → index-C-dkXOpB.d.cts} +56 -54
  134. package/dist/{index-B-ORMr3k.d.ts → index-C5cQ7Gfx.d.ts} +4 -4
  135. package/dist/{index-ML6vHKXK.d.ts → index-C6ZUaos7.d.ts} +1 -1
  136. package/dist/{index-Vz7KPfgz.d.ts → index-CAP3UGsq.d.ts} +1 -1
  137. package/dist/{index-BFaALJxR.d.ts → index-CD2dBMet.d.ts} +10 -8
  138. package/dist/index-CGhMJNHb.d.cts +128 -0
  139. package/dist/{index-B3D_z0Z6.d.cts → index-CL7oilfm.d.cts} +1 -1
  140. package/dist/{index-Bn0uZEL4.d.ts → index-CQtWm7jS.d.ts} +9 -9
  141. package/dist/{index-CM-i58FY.d.cts → index-CRm0YIzC.d.cts} +9 -9
  142. package/dist/index-CUIkE1l9.d.cts +230 -0
  143. package/dist/{index-CijfwEWx.d.ts → index-Cczxgd2D.d.ts} +2 -2
  144. package/dist/{index-CAbHN_rP.d.cts → index-CgnCFhr2.d.cts} +1 -1
  145. package/dist/{index-B2IUcH13.d.cts → index-Ck35nA-T.d.ts} +41 -48
  146. package/dist/{index-BpMZzX9P.d.cts → index-Cnr1WrlX.d.cts} +3 -3
  147. package/dist/{index-JYtN9uqM.d.ts → index-CoM4rzyB.d.ts} +1 -1
  148. package/dist/{index-Ckil6miL.d.cts → index-CtFNGe-m.d.cts} +2 -2
  149. package/dist/{index-BjWZARLy.d.ts → index-Ctb7_2sG.d.ts} +1 -1
  150. package/dist/index-CuPUehFa.d.cts +218 -0
  151. package/dist/index-D1Gc7wV5.d.ts +230 -0
  152. package/dist/{index-DqICM_I7.d.ts → index-D1IEZUsj.d.ts} +67 -9
  153. package/dist/{index-BFuVcqL8.d.cts → index-D3ayz3hy.d.cts} +1 -1
  154. package/dist/{index-CQsqqEVz.d.cts → index-D4uimgee.d.cts} +1 -1
  155. package/dist/{resilience-BWP2c7Af.d.cts → index-DGTo1yka.d.cts} +202 -26
  156. package/dist/{index-BmWuVdER.d.ts → index-DH4fm2Ck.d.ts} +2 -2
  157. package/dist/{index-BkQqf1EF.d.cts → index-DJ_MPOJ5.d.cts} +67 -9
  158. package/dist/{index-9xhIaM-w.d.cts → index-DOBLxOti.d.cts} +1 -1
  159. package/dist/{index-BqcgiSQg.d.cts → index-DQQCOIt8.d.cts} +10 -8
  160. package/dist/{index-DJNAWzcH.d.cts → index-DVAlsmEU.d.cts} +26 -19
  161. package/dist/index-DVDapw2k.d.cts +210 -0
  162. package/dist/{index-D_QQ_dTD.d.cts → index-DYTBbF8T.d.cts} +1 -1
  163. package/dist/{index-BgzPO43H.d.cts → index-DgJc8Zgc.d.cts} +6 -6
  164. package/dist/{index-Czk3r0yA.d.cts → index-DhLyOHYZ.d.ts} +56 -54
  165. package/dist/{index-CrlHFsiT.d.ts → index-DhnsQfa3.d.ts} +100 -118
  166. package/dist/{index-Bub6x_D4.d.cts → index-DktLSZOc.d.cts} +37 -90
  167. package/dist/{index-BaSy4L6w.d.cts → index-DpiGqtrs.d.cts} +100 -118
  168. package/dist/{index-D-HZ7sP4.d.ts → index-I1cCY3ZI.d.ts} +6 -6
  169. package/dist/{index-D9vBTuzo.d.ts → index-IUCY0OFN.d.ts} +4 -4
  170. package/dist/{index-DeSsvHDD.d.cts → index-MxYuWOrf.d.cts} +3 -3
  171. package/dist/index-N2MAxt7_.d.ts +128 -0
  172. package/dist/{index-CpZKtdMw.d.cts → index-PgwvGWa1.d.cts} +1 -1
  173. package/dist/{index-AUqWe_fX.d.ts → index-WSlcjhQF.d.ts} +55 -9
  174. package/dist/{index-Di7OdwlO.d.ts → index-bXXLSvor.d.ts} +37 -90
  175. package/dist/index-da2V5vPy.d.ts +113 -0
  176. package/dist/{index-DY2f2b9z.d.ts → index-eaQuGJnv.d.ts} +3 -3
  177. package/dist/{index-BsgxnHN8.d.cts → index-t6L2qpHh.d.cts} +3 -3
  178. package/dist/{index-C-3UXnHT.d.cts → index-tV3AA9hI.d.cts} +2 -2
  179. package/dist/{index-8OxXae3g.d.ts → index-yLt-aPMp.d.ts} +1 -1
  180. package/dist/{index-CqSJ25A9.d.cts → index-z8WFPVI8.d.cts} +1 -1
  181. package/dist/index.cjs +63 -59
  182. package/dist/index.d.cts +48 -47
  183. package/dist/index.d.ts +48 -47
  184. package/dist/index.js +1 -1
  185. package/dist/{meta-DreaEM_a.d.cts → meta-Ct9nqQS5.d.cts} +11 -7
  186. package/dist/{meta-BYqlATmg.d.ts → meta-D8OyedKp.d.ts} +11 -7
  187. package/dist/{node-fSc-hCv8.d.cts → node-BYInONRr.d.cts} +3 -3
  188. package/dist/{node-fSc-hCv8.d.ts → node-BYInONRr.d.ts} +3 -3
  189. package/dist/{observable-Cqty11jG.d.cts → observable-DMIlYJV1.d.cts} +1 -1
  190. package/dist/{observable-EAV_rNfM.d.ts → observable-DO8DDEzv.d.ts} +1 -1
  191. package/dist/patterns/ai/browser.cjs +5 -5
  192. package/dist/patterns/ai/browser.d.cts +4 -4
  193. package/dist/patterns/ai/browser.d.ts +4 -4
  194. package/dist/patterns/ai/browser.js +1 -1
  195. package/dist/patterns/ai/index.cjs +16 -20
  196. package/dist/patterns/ai/index.d.cts +17 -17
  197. package/dist/patterns/ai/index.d.ts +17 -17
  198. package/dist/patterns/ai/index.js +1 -1
  199. package/dist/patterns/ai/node.cjs +1 -1
  200. package/dist/patterns/ai/node.d.cts +4 -4
  201. package/dist/patterns/ai/node.d.ts +4 -4
  202. package/dist/patterns/ai/node.js +1 -1
  203. package/dist/patterns/audit/index.cjs +3 -7
  204. package/dist/patterns/audit/index.d.cts +6 -6
  205. package/dist/patterns/audit/index.d.ts +6 -6
  206. package/dist/patterns/audit/index.js +1 -1
  207. package/dist/patterns/cqrs/index.cjs +3 -7
  208. package/dist/patterns/cqrs/index.d.cts +6 -6
  209. package/dist/patterns/cqrs/index.d.ts +6 -6
  210. package/dist/patterns/cqrs/index.js +1 -1
  211. package/dist/patterns/demo-shell/index.cjs +5 -8
  212. package/dist/patterns/demo-shell/index.d.cts +5 -5
  213. package/dist/patterns/demo-shell/index.d.ts +5 -5
  214. package/dist/patterns/demo-shell/index.js +1 -1
  215. package/dist/patterns/domain-templates/index.cjs +3 -7
  216. package/dist/patterns/domain-templates/index.d.cts +4 -4
  217. package/dist/patterns/domain-templates/index.d.ts +4 -4
  218. package/dist/patterns/domain-templates/index.js +1 -1
  219. package/dist/patterns/graphspec/index.cjs +37 -37
  220. package/dist/patterns/graphspec/index.d.cts +5 -5
  221. package/dist/patterns/graphspec/index.d.ts +5 -5
  222. package/dist/patterns/graphspec/index.js +1 -1
  223. package/dist/patterns/guarded-execution/index.cjs +3 -7
  224. package/dist/patterns/guarded-execution/index.d.cts +7 -7
  225. package/dist/patterns/guarded-execution/index.d.ts +7 -7
  226. package/dist/patterns/guarded-execution/index.js +1 -1
  227. package/dist/patterns/harness/index.cjs +8 -12
  228. package/dist/patterns/harness/index.d.cts +12 -12
  229. package/dist/patterns/harness/index.d.ts +12 -12
  230. package/dist/patterns/harness/index.js +1 -1
  231. package/dist/patterns/job-queue/index.cjs +3 -7
  232. package/dist/patterns/job-queue/index.d.cts +6 -6
  233. package/dist/patterns/job-queue/index.d.ts +6 -6
  234. package/dist/patterns/job-queue/index.js +1 -1
  235. package/dist/patterns/lens/index.cjs +3 -7
  236. package/dist/patterns/lens/index.d.cts +5 -6
  237. package/dist/patterns/lens/index.d.ts +5 -6
  238. package/dist/patterns/lens/index.js +1 -1
  239. package/dist/patterns/memory/index.cjs +3 -7
  240. package/dist/patterns/memory/index.d.cts +6 -6
  241. package/dist/patterns/memory/index.d.ts +6 -6
  242. package/dist/patterns/memory/index.js +1 -1
  243. package/dist/patterns/messaging/index.cjs +3 -7
  244. package/dist/patterns/messaging/index.d.cts +5 -5
  245. package/dist/patterns/messaging/index.d.ts +5 -5
  246. package/dist/patterns/messaging/index.js +1 -1
  247. package/dist/patterns/orchestration/index.cjs +3 -7
  248. package/dist/patterns/orchestration/index.d.cts +8 -8
  249. package/dist/patterns/orchestration/index.d.ts +8 -8
  250. package/dist/patterns/orchestration/index.js +1 -1
  251. package/dist/patterns/process/index.cjs +1 -1
  252. package/dist/patterns/process/index.d.cts +7 -7
  253. package/dist/patterns/process/index.d.ts +7 -7
  254. package/dist/patterns/process/index.js +1 -1
  255. package/dist/patterns/reactive-layout/index.cjs +4 -8
  256. package/dist/patterns/reactive-layout/index.d.cts +5 -5
  257. package/dist/patterns/reactive-layout/index.d.ts +5 -5
  258. package/dist/patterns/reactive-layout/index.js +1 -1
  259. package/dist/patterns/reduction/index.cjs +3 -7
  260. package/dist/patterns/reduction/index.d.cts +4 -4
  261. package/dist/patterns/reduction/index.d.ts +4 -4
  262. package/dist/patterns/reduction/index.js +1 -1
  263. package/dist/patterns/refine-loop/index.cjs +5 -9
  264. package/dist/patterns/refine-loop/index.d.cts +6 -6
  265. package/dist/patterns/refine-loop/index.d.ts +6 -6
  266. package/dist/patterns/refine-loop/index.js +1 -1
  267. package/dist/patterns/resilient-pipeline/index.cjs +3 -1
  268. package/dist/patterns/resilient-pipeline/index.d.cts +6 -6
  269. package/dist/patterns/resilient-pipeline/index.d.ts +6 -6
  270. package/dist/patterns/resilient-pipeline/index.js +1 -1
  271. package/dist/patterns/surface/index.cjs +12 -16
  272. package/dist/patterns/surface/index.d.cts +6 -6
  273. package/dist/patterns/surface/index.d.ts +6 -6
  274. package/dist/patterns/surface/index.js +1 -1
  275. package/dist/{pipeline-graph-9JBbmRxA.d.ts → pipeline-graph-CB4La-UW.d.ts} +34 -17
  276. package/dist/{pipeline-graph-DuHpXSOn.d.cts → pipeline-graph-MWrQZXCq.d.cts} +34 -17
  277. package/dist/{reactive-layout-BMLDB4Vd.d.cts → reactive-layout-BtZfUKuL.d.cts} +2 -2
  278. package/dist/{reactive-layout-D-tRiNhg.d.ts → reactive-layout-KJj4E2dT.d.ts} +2 -2
  279. package/dist/{reactive-log-BgWSA1fg.d.ts → reactive-log-BlAsPLl2.d.ts} +2 -2
  280. package/dist/{reactive-log-C3IMAGpT.d.cts → reactive-log-_zeEnB9H.d.cts} +2 -2
  281. package/dist/{reactive-map-DmgeADH8.d.cts → reactive-map-6P_k3AQM.d.cts} +2 -2
  282. package/dist/{reactive-map-CHyeCf4D.d.ts → reactive-map-CjXByDV-.d.ts} +2 -2
  283. package/dist/resilience-S33JV6XC.js +1 -0
  284. package/dist/{sugar-D13E2M_z.d.ts → sugar-BhfjgetH.d.ts} +1 -1
  285. package/dist/{sugar-DgaGJcI6.d.cts → sugar-DzePN5-g.d.cts} +1 -1
  286. package/dist/{topology-tree-jrZue3ao.d.cts → topology-tree-3LBKFsUo.d.cts} +1 -1
  287. package/dist/{topology-tree-D47-nI6Z.d.ts → topology-tree-mF7Emqzm.d.ts} +1 -1
  288. package/dist/{types-BMSGPlpO.d.cts → types-1Dhoi7HM.d.cts} +1 -1
  289. package/dist/{types-CidcBDuk.d.ts → types-39jk0kaV.d.ts} +1 -1
  290. package/package.json +11 -1
  291. package/dist/chunk-2YFDSYEF.js +0 -1
  292. package/dist/chunk-5BGFS2XH.js +0 -1
  293. package/dist/chunk-CMTN3KPT.js +0 -80
  294. package/dist/chunk-DQJLC6YY.js +0 -1
  295. package/dist/chunk-G7JN6LCB.js +0 -1
  296. package/dist/chunk-KJEAIIIY.js +0 -43
  297. package/dist/chunk-LV3ACS5J.js +0 -1
  298. package/dist/chunk-NBGPXQSP.js +0 -1
  299. package/dist/chunk-NN3QPJ6U.js +0 -1
  300. package/dist/chunk-NSAZ6PR6.js +0 -1
  301. package/dist/chunk-O32GJOUJ.js +0 -1
  302. package/dist/chunk-QEVSIVSF.js +0 -1
  303. package/dist/chunk-QMC2PLNM.js +0 -7
  304. package/dist/chunk-QOJFR6GS.js +0 -1
  305. package/dist/chunk-SFK7MN7S.js +0 -1
  306. package/dist/chunk-TB7JKSVS.js +0 -61
  307. package/dist/chunk-UAXFKMAG.js +0 -1
  308. package/dist/chunk-XIMFHEKV.js +0 -1
  309. package/dist/chunk-XLMYQB6F.js +0 -1
  310. package/dist/chunk-XLYF4LBH.js +0 -1
  311. package/dist/imperative-audit-ahAE65a9.d.cts +0 -28
  312. package/dist/imperative-audit-ahAE65a9.d.ts +0 -28
  313. package/dist/index-5dNRlW7J.d.ts +0 -135
  314. package/dist/index-BWUMIt7J.d.cts +0 -135
  315. package/dist/index-BhzwpIJc.d.cts +0 -105
  316. package/dist/index-BsZk9T8y.d.ts +0 -105
  317. package/dist/index-C56XZiDe.d.cts +0 -163
  318. package/dist/index-CpdnP-0y.d.cts +0 -186
  319. package/dist/index-DKrIuF-r.d.ts +0 -163
  320. package/dist/index-DOU1Ee_k.d.ts +0 -186
  321. package/dist/resilience-LGBK236C.js +0 -1
@@ -1,15 +1,11 @@
1
- "use strict";var Co=Object.create;var Pe=Object.defineProperty;var Un=Object.getOwnPropertyDescriptor;var Mo=Object.getOwnPropertyNames;var Do=Object.prototype.hasOwnProperty;var Yn=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),tt=t=>{throw TypeError(t)};var Go=(t,e,n)=>e in t?Pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Bn=(t,e)=>Pe(t,"name",{value:e,configurable:!0});var J=(t,e)=>()=>(t&&(e=t(t=0)),e);var ce=(t,e)=>{for(var n in e)Pe(t,n,{get:e[n],enumerable:!0})},Io=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Mo(e))!Do.call(t,o)&&o!==n&&Pe(t,o,{get:()=>e[o],enumerable:!(r=Un(e,o))||r.enumerable});return t};var Lo=t=>Io(Pe({},"__esModule",{value:!0}),t);var Jn=t=>[,,,Co(t?.[Yn("metadata")]??null)],Qn=["class","method","getter","setter","accessor","field","value","get","set"],et=t=>t!==void 0&&typeof t!="function"?tt("Function expected"):t,Po=(t,e,n,r,o)=>({kind:Qn[t],name:e,metadata:r,addInitializer:s=>n._?tt("Already initialized"):o.push(et(s||null))}),$o=(t,e)=>Go(e,Yn("metadata"),t[3]),Xn=(t,e,n,r)=>{for(var o=0,s=t[e>>1],i=s&&s.length;o<i;o++)e&1?s[o].call(n):r=s[o].call(n,r);return r},Zn=(t,e,n,r,o,s)=>{var i,a,d,u,c,l=e&7,p=!!(e&8),h=!!(e&16),f=l>3?t.length+1:l?p?1:2:0,y=Qn[l+5],m=l>3&&(t[f-1]=[]),w=t[f]||(t[f]=[]),_=l&&(!h&&!p&&(o=o.prototype),l<5&&(l>3||!h)&&Un(l<4?o:{get[n](){return Wn(this,s)},set[n](b){return Kn(this,s,b)}},n));l?h&&l<4&&Bn(s,(l>2?"set ":l>1?"get ":"")+n):Bn(o,n);for(var v=r.length-1;v>=0;v--)u=Po(l,n,d={},t[3],w),l&&(u.static=p,u.private=h,c=u.access={has:h?b=>Fo(o,b):b=>n in b},l^3&&(c.get=h?b=>(l^1?Wn:Ho)(b,o,l^4?s:_.get):b=>b[n]),l>2&&(c.set=h?(b,E)=>Kn(b,o,E,l^4?s:_.set):(b,E)=>b[n]=E)),a=(0,r[v])(l?l<4?h?s:_[y]:l>4?void 0:{get:_.get,set:_.set}:o,u),d._=1,l^4||a===void 0?et(a)&&(l>4?m.unshift(a):l?h?s=a:_[y]=a:o=a):typeof a!="object"||a===null?tt("Object expected"):(et(i=a.get)&&(_.get=i),et(i=a.set)&&(_.set=i),et(i=a.init)&&m.unshift(i));return l||$o(t,o),_&&Pe(o,n,_),h?l^4?s:_:o};var Xt=(t,e,n)=>e.has(t)||tt("Cannot "+n),Fo=(t,e)=>Object(e)!==e?tt('Cannot use the "in" operator on this value'):t.has(e),Wn=(t,e,n)=>(Xt(t,e,"read from private field"),n?n.call(t):e.get(t));var Kn=(t,e,n,r)=>(Xt(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),Ho=(t,e,n)=>(Xt(t,e,"access private method"),n);var we,C,$,B,re,ee,oe,q,P,D,xe,vt,er,_t,tr,nr,Tt,Zt,en,tn,wt,K=J(()=>{"use strict";we=Symbol.for("graphrefly/START"),C=Symbol.for("graphrefly/DATA"),$=Symbol.for("graphrefly/DIRTY"),B=Symbol.for("graphrefly/RESOLVED"),re=Symbol.for("graphrefly/INVALIDATE"),ee=Symbol.for("graphrefly/PAUSE"),oe=Symbol.for("graphrefly/RESUME"),q=Symbol.for("graphrefly/TEARDOWN"),P=Symbol.for("graphrefly/COMPLETE"),D=Symbol.for("graphrefly/ERROR"),xe=Object.freeze([$]),vt=Object.freeze([B]),er=Object.freeze([re]),_t=Object.freeze([we]),tr=Object.freeze([P]),nr=Object.freeze([q]),Tt=Object.freeze([xe]),Zt=Object.freeze([vt]),en=Object.freeze([er]),tn=Object.freeze([tr]),wt=Object.freeze([nr])});function or(t,e){let n=new TextEncoder().encode(t.name);if(n.length===0||n.length>255)throw new Error(`encodeEnvelope: codec name "${t.name}" encodes to ${n.length} bytes (must be 1\u2013255)`);let r=t.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let o=2+n.length+2+e.length;if(o>4294967295)throw new Error(`encodeEnvelope: total envelope size ${o} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let s=new Uint8Array(o),i=0;return s[i++]=nn,s[i++]=n.length,s.set(n,i),i+=n.length,s[i++]=r>>>8&255,s[i++]=r&255,s.set(e,i),s}function sr(t,e){if(t.length<rr)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${rr})`);let n=0,r=t[n++];if(r!==nn)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${nn})`);let o=t[n++];if(o===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(n+o+2>t.length)throw new Error(`decodeEnvelope: envelope truncated (need ${n+o+2} bytes, have ${t.length})`);let s=new TextDecoder().decode(t.subarray(n,n+o));n+=o;let i=(t[n]<<8|t[n+1])>>>0;n+=2;let a=t.subarray(n),d=e.lookupCodec(s);if(d==null)throw new Error(`decodeEnvelope: codec "${s}" not registered (envelope codec_v=${i})`);return{codec:d,codecVersion:i,payload:a}}function ir(t){t.registerCodec(Vo)}var Vo,nn,rr,rn=J(()=>{"use strict";Vo={name:"json",version:1,contentType:"application/json",encode(t){let e=JSON.stringify(t);return new TextEncoder().encode(e)},decode(t,e){let n=new TextDecoder().decode(t);return JSON.parse(n)}},nn=1,rr=4});function Re(t){if(t==null)return be;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var be,nt=J(()=>{"use strict";be={type:"system",id:""}});function xt(){return $e>0||rt}function ar(){return $e>0}function He(t){$e>0?ot.push(t):t()}function le(t){$e+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if($e-=1,$e===0)if(e){if(!rt){let n=ot.splice(0);for(let r of n)try{r()}catch{}Ee.length=0,Oe.length=0,Fe.length=0}}else jo()}}function jo(){let t=!rt;t&&(rt=!0);let e=[],n=0;try{for(;Ee.length>0||Oe.length>0||Fe.length>0||t&&ot.length>0;){if(t&&ot.length>0){let s=ot.splice(0);for(let i of s)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw Ee.length=0,Oe.length=0,Fe.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let o=(Ee.length>0?Ee:Oe.length>0?Oe:Fe).splice(0);for(let s of o)try{s()}catch(i){e.push(i)}}}finally{t&&(rt=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Rt(t,e,n){if(e.length===0)return;if(e.length===1){let u=n(e[0][0]);if(u<3||!xt()){t(e);return}(u>=5?Fe:u===4?Oe:Ee).push(()=>t(e));return}let r=e.length,o=r,s=r,i=r,a=0;for(;a<r&&n(e[a][0])<3;)a++;for(o=a;a<r&&n(e[a][0])===3;)a++;for(s=a;a<r&&n(e[a][0])===4;)a++;i=a;let d=xt();if(o>0){let u=e.slice(0,o);t(u)}if(s>o){let u=e.slice(o,s);d?Ee.push(()=>t(u)):t(u)}if(i>s){let u=e.slice(s,i);d?Oe.push(()=>t(u)):t(u)}if(r>i){let u=e.slice(i,r);d?Fe.push(()=>t(u)):t(u)}}var $e,rt,Ee,Oe,Fe,ot,Se=J(()=>{"use strict";$e=0,rt=!1,Ee=[],Oe=[],Fe=[],ot=[]});function he(){return Math.trunc(performance.now()*1e6)}function se(){return Date.now()*1e6}var Ve=J(()=>{"use strict"});function ur(t){t.registerMessageType(we,{tier:0,wireCrossing:!1}),t.registerMessageType($,{tier:1,wireCrossing:!1}),t.registerMessageType(re,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(ee,{tier:2,wireCrossing:!1}),t.registerMessageType(oe,{tier:2,wireCrossing:!1}),t.registerMessageType(C,{tier:3,wireCrossing:!0}),t.registerMessageType(B,{tier:3,wireCrossing:!0}),t.registerMessageType(P,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(D,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(q,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Et,dr=J(()=>{"use strict";K();Et=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_rigorRecorder;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=n=>{let r=this._messageTypes.get(n);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}get rigorRecorder(){return this._rigorRecorder}set rigorRecorder(e){this._rigorRecorder=e}registerMessageType(e,n){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:n.tier,wireCrossing:n.wireCrossing??n.tier>=3,metaPassthrough:n.metaPassthrough??!0}),this}messageTier(e){let n=this._messageTypes.get(e);return n!=null?n.tier:1}isWireCrossing(e){let n=this._messageTypes.get(e);return n!=null?n.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let n=this._messageTypes.get(e);return n!=null?n.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function cr(t){return Array.isArray(t)?[...t]:[t]}function qo(t,e){return t.has(e)||t.has("*")}function je(t){let e=[];return t((o,s)=>{e.push({kind:"allow",actions:new Set(cr(o)),where:s?.where??(()=>!0)})},(o,s)=>{e.push({kind:"deny",actions:new Set(cr(o)),where:s?.where??(()=>!0)})}),(o,s)=>{let i=!1,a=!1;for(let d of e)qo(d.actions,s)&&d.where(o)&&(d.kind==="deny"?i=!0:a=!0);return i?!1:a}}function on(t){let e=zo.filter(n=>t({type:n,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(n=>n==="human"||n==="llm"||n==="system")?"both":e.length===1?e[0]:e.join("+")}var ie,zo,Ae=J(()=>{"use strict";ie=class extends Error{actor;action;nodeName;constructor(e,n){super(n??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}};zo=["human","llm","wallet","system"]});function sn(t){if(t===void 0)return null;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Cannot hash non-finite number: ${t}`);if(Number.isInteger(t)&&!Number.isSafeInteger(t))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${t}. Cross-language cid parity is not guaranteed for unsafe integers.`);return t}if(typeof t=="string"||typeof t=="boolean"||t===null)return t;if(Array.isArray(t))return t.map(sn);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=sn(t[n]);return e}return null}function Ko(t){let e=Wo.encode(t),n=e.length,r=n*8,o=n+9+63&-64,s=new Uint8Array(o);s.set(e),s[n]=128;let i=new DataView(s.buffer);i.setUint32(o-4,r>>>0,!1),i.setUint32(o-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,d=3144134277,u=1013904242,c=2773480762,l=1359893119,p=2600822924,h=528734635,f=1541459225,y=new Uint32Array(64),m=(_,v)=>_>>>v|_<<32-v;for(let _=0;_<o;_+=64){for(let x=0;x<16;x++)y[x]=i.getUint32(_+x*4,!1);for(let x=16;x<64;x++){let N=y[x-15],A=y[x-2],k=m(N,7)^m(N,18)^N>>>3,G=m(A,17)^m(A,19)^A>>>10;y[x]=y[x-16]+k+y[x-7]+G>>>0}let v=a,b=d,E=u,O=c,g=l,T=p,S=h,R=f;for(let x=0;x<64;x++){let N=m(g,6)^m(g,11)^m(g,25),A=g&T^~g&S,k=R+N+A+Bo[x]+y[x]>>>0,G=m(v,2)^m(v,13)^m(v,22),L=v&b^v&E^b&E,U=G+L>>>0;R=S,S=T,T=g,g=O+k>>>0,O=E,E=b,b=v,v=k+U>>>0}a=a+v>>>0,d=d+b>>>0,u=u+E>>>0,c=c+O>>>0,l=l+g>>>0,p=p+T>>>0,h=h+S>>>0,f=f+R>>>0}let w=_=>_.toString(16).padStart(8,"0");return w(a)+w(d)+w(u)+w(c)+w(l)+w(p)+w(h)+w(f)}function an(t){let e=sn(t??null),n=JSON.stringify(e);return Ko(n).slice(0,16)}function Uo(){let t=globalThis.crypto;if(t?.randomUUID)return t.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),n=e()+e()+e()+e();return`${n.slice(0,8)}-${n.slice(8,12)}-4${n.slice(13,16)}-${(parseInt(n.slice(16,17),16)&3|8).toString(16)}${n.slice(17,20)}-${n.slice(20,32)}`}function un(t,e,n){let r=n?.id??Uo();if(t===0)return{id:r,version:0};let s=(n?.hash??an)(e);return{id:r,version:0,cid:s,prev:null}}function lr(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var Bo,Wo,fr=J(()=>{"use strict";Bo=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]),Wo=new TextEncoder});function gr(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function dn(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function Ot(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function ge(t,e,n){let r=mr(t)?t:[],o=typeof t=="function"?t:typeof e=="function"?e:void 0,s={};return mr(t)?s=(cn(e)?e:n)??{}:cn(t)?s=t:s=(cn(e)?e:n)??{},new j(r,o,s)}var pr,hr,Yo,Jo,Ne,j,mr,cn,ke=J(()=>{"use strict";rn();nt();Se();Ve();dr();Ae();K();fr();pr=()=>{},hr=100;Yo=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},Jo=(t,e,n,r)=>{let o=t;if(o._status==="completed"||o._status==="errored")return;let s=o._cached,i=s===void 0?[_t]:[_t,[C,s]];o._status==="dirty"&&i.push(xe),Rt(e,i,o._config.tierOf)},Ne=new Et({onMessage:Yo,onSubscribe:Jo});ur(Ne);ir(Ne);j=class t{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,n,r){this._config=r.config??Ne,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=n,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??an;let o=r.versioning??this._config.defaultVersioning;this._versioningLevel=o,this._versioning=o!=null?un(o,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(gr);let s={};for(let[a,d]of Object.entries(r.meta??{})){let u={initial:d,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(u.guard=r.guard),s[a]=new t([],void 0,u)}Object.freeze(s),this.meta=s,this._hasMeta=Object.keys(s).length>0;let i=this;this._actions={emit(a){i._emit([[C,a]])},down(a){i._emit(Ot(a))},up(a){i._emitUp(Ot(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,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let o=n?.hash??this._hashFn;o!==this._hashFn&&(this._hashFn=o);let s=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??n?.id,d=i?.version??0,u=un(e,s,{id:a,hash:o});u.version=d,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=Re(e);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(n,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let n=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!n&&!r)return;let o=Re(e?.actor),s=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(o,s))throw new ie({actor:o,action:s,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(o,s))throw new ie({actor:o,action:s,nodeName:this.name})}this._lastMutation={actor:o,timestamp_ns:se()}}down(e,n){let r=Ot(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[C,e]])}up(e,n){if(this._deps.length===0)return;let r=Ot(e);if(r.length===0)return;this._checkGuard(n);let o=n??{internal:!0};this._validateUpTiers(r);for(let s of this._deps)s.node.up?.(r,o)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let n of this._deps)n.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let n=this._config.tierOf;for(let r of e){let o=n(r[0]);if(o===3||o===4)throw new Error(`Node "${this.name}": tier-${o} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,n){if(n!=null&&this._guard!=null){let d=Re(n);if(!this._guard(d,"observe"))throw new ie({actor:d,action:"observe",nodeName:this.name})}let o=this._isTerminal&&this._resubscribable;if(o){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)dn(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let s;try{s=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:o},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof s=="function")try{s()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof s=="function"&&s(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[n]=this._sinks;this._sinks=n}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,n=0;try{for(let r=0;r<e;r++){let o=r,s=this._deps[r];s.unsub=pr,s.unsub=s.node.subscribe(i=>{if(s.unsub===null)return;let a=this._config.tierOf,d=!1;for(let u of i)a(u[0])>=3&&(d=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:o},this._actions);d&&this._maybeRunFnOnSettlement()}),n++}}catch(r){this._deps[n].unsub=null;for(let o=0;o<n;o++){let s=this._deps[o];if(s.unsub!=null){let i=s.unsub;s.unsub=null;try{i()}catch{}dn(s)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let o=0;o<this._deps.length;o++)if(this._deps[o].node===e)return o;let n=this._deps.length,r=gr(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Tt),r.unsub=pr;try{r.unsub=e.subscribe(o=>{if(r.unsub===null)return;let s=this._config.tierOf,i=!1;for(let a of o)s(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(o){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,o}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(r){this._emit([[D,this._wrapFnError("cleanup threw",r)]])}else if(n!=null&&typeof n=="object"){let r=n.deactivate;if(typeof r=="function")try{r()}catch(o){this._emit([[D,this._wrapFnError("cleanup.deactivate threw",o)]])}}for(let r of this._deps){if(r.unsub!=null){let o=r.unsub;r.unsub=null;try{o()}catch{}}dn(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,n){let r=this._deps[e],o=n[0];if(this._inspectorHooks!=null){let s={kind:"dep_message",depIndex:e,message:n};for(let i of this._inspectorHooks)i(s)}if(o!==we){if(o===$){this._depDirtied(r);return}if(o===re){if(this._depInvalidated(r),this._cached===void 0)return;this._emit(en);return}if(o===ee||o===oe){this._emit([n]);return}if(o===q){this._emit(wt);return}if(o===C)this._depSettledAsData(r,n[1]);else if(o===B)this._depSettledAsResolved(r);else if(o===P)this._depSettledAsTerminal(r,!0);else if(o===D)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(o===C||o===B)&&this._emit([n]),(o===P||o===D)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Tt))}_depSettledAsData(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=n,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let n=this._deps[e];if(n.dataBatch.length===0&&n.prevData===void 0&&n.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Zt),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(e!=null){this._autoError&&this._emit([[D,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(tn)}_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([[D,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([[D,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let n=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=n[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let o=this._deps.map(i=>i.terminal),s={prevData:r,terminalDeps:o,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:n,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(n,this._actions,s);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([[D,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>hr?(this._rerunDepth=0,this._emit([[D,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${hr} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,n){let r=n instanceof Error?n.message:String(n);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:n})}_frameBatch(e){let n=this._config.tierOf;if(e.length===1)return n(e[0][0])===3&&this._status!=="dirty"?[xe,e[0]]:e;let r=!0,o=!1,s=!1,i=-1;for(let d of e){let u=n(d[0]);u<i&&(r=!1),u===3&&(o=!0),d[0]===$&&(s=!0),i=u}let a=e;if(!r){let d=e.map((u,c)=>({m:u,i:c,tier:n(u[0])}));d.sort((u,c)=>u.tier-c.tier||u.i-c.i),a=d.map(u=>u.m)}if(o&&!s&&this._status!=="dirty"){let d=0;for(;d<a.length&&n(a[d][0])===0;)d++;return d===0?[xe,...a]:[...a.slice(0,d),xe,...a.slice(d)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let d=e[a];if(d[0]===D&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let n=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(d=>d[0]===q||d[0]===re);if(a.length===0)return;n=a}n=this._frameBatch(n);let o=null;for(let a=0;a<n.length;a++){let d=n[a],u=d[0];if(u!==ee&&u!==oe){o?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${u===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 l=d[1];if(u===ee)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(l),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(l))c=!1;else if(this._pauseLocks.delete(l),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?o?.push(d):o==null&&(o=n.slice(0,a))}if(o!=null){if(o.length===0)return;n=o}if(this._hasMeta&&n.some(a=>a[0]===q))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(wt)}catch{}let{finalMessages:s,equalsError:i}=this._updateState(n);if(s.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:s})}catch{}}if(s.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,d=[];for(let u of s)a(u[0])===3?this._pauseBuffer.push(u):d.push(u);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(s);i!=null&&this._emit([[D,i]])}_updateState(e){let n=this._config.tierOf,r,o,s=-1,i=0;for(let c of e)n(c[0])===3&&i++;let a=i<=1,d=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===C){d=c;break}}for(let c=0;c<e.length;c++){let l=e[c],p=l[0];if(p===C){if(l.length>=2){let h=!1;if(a&&this._cached!==void 0)try{h=this._equals(this._cached,l[1])}catch(f){o=this._wrapFnError("equals threw",f),s=c;break}if(h){r==null&&(r=e.slice(0,c)),r.push(vt),this._status="resolved";continue}this._cached=l[1],this._versioning!=null&&(d<0||c===d)&&lr(this._versioning,l[1],this._hashFn)}this._status="settled",r?.push(l)}else if(r?.push(l),p===$)this._status="dirty";else if(p===B)this._status="resolved";else if(p===P){this._status="completed";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===D){this._status="errored";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===re){if(this._cached!==void 0){let f=this._config.rigorRecorder;if(f!=null)try{f.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let h=this._cleanup;if(typeof h=="function"){this._cleanup=void 0;try{h()}catch{}}else if(h!=null&&typeof h=="object"){let f=h.invalidate;if(typeof f=="function")try{f()}catch{}}}else p===q&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=s>=0?r??e.slice(0,s):r??e;return o!=null?{finalMessages:u,equalsError:o}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let n=[...this._sinks];for(let r of n)r(e)};_dispatchOrAccumulate(e){if(ar()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],He(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}Rt(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let n=this._frameBatch(e);Rt(this._deliverToSinks,n,this._config.tierOf)}},mr=t=>Array.isArray(t),cn=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function V(t,e){return ge([],{...e,initial:t})}function Ce(t,e){return ge((r,o,s)=>t(o,s)??void 0,{describeKind:"producer",...e})}function Q(t,e,n){return ge(t,(o,s,i)=>{let a=o.map((d,u)=>d!=null&&d.length>0?d.at(-1):i.prevData[u]);s.emit(e(a,i))},{describeKind:"derived",...n})}function ln(t,e,n){let r=new Map;return t.forEach((o,s)=>{r.set(o,s)}),Q(t,(o,s)=>e(a=>{let d=r.get(a);if(d==null)throw new Error(`dynamicNode: untracked dep "${a.name??"<unnamed>"}"`);return o[d]},s),n)}function st(t,e){let n,r=new Map,o=(s,i,a)=>{let d=!1,u=c=>{let l=r.get(c);if(l!==void 0){if(l<s.length){let h=s[l];return h!=null&&h.length>0?h.at(-1):a.prevData[l]}return c.cache}d=!0;let p=n._addDep(c);return r.set(c,p),c.cache};try{let c=t(u,a);d||(i.emit(c),a.store.__autoTrackLastDiscoveryError!=null&&delete a.store.__autoTrackLastDiscoveryError)}catch(c){if(!d)throw c;a.store.__autoTrackLastDiscoveryError=c}};return n=new j([],o,{describeKind:"derived",...e}),n}var fe=J(()=>{"use strict";ke()});function ut(t,e,n){let r=new Set;for(let o of t.split(",")){let[s,i]=o.split("/"),a=i?Number.parseInt(i,10):1;if(Number.isNaN(a)||a<1)throw new Error(`Invalid cron step: ${o}`);let d,u;if(s==="*")d=e,u=n;else if(s.includes("-")){let[c,l]=s.split("-");d=Number.parseInt(c,10),u=Number.parseInt(l,10)}else d=Number.parseInt(s,10),u=d;if(Number.isNaN(d)||Number.isNaN(u))throw new Error(`Invalid cron field: ${t}`);if(d<e||u>n)throw new Error(`Cron field out of range: ${t} (${e}-${n})`);if(d>u)throw new Error(`Invalid cron range: ${d}-${u} in ${t}`);for(let c=d;c<=u;c+=a)r.add(c)}return r}function Dr(t){let e=t.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:ut(e[0],0,59),hours:ut(e[1],0,23),daysOfMonth:ut(e[2],1,31),months:ut(e[3],1,12),daysOfWeek:ut(e[4],0,6)}}function Gr(t,e){return t.minutes.has(e.getMinutes())&&t.hours.has(e.getHours())&&t.daysOfMonth.has(e.getDate())&&t.months.has(e.getMonth()+1)&&t.daysOfWeek.has(e.getDay())}var Ir=J(()=>{"use strict"});function Lr(t){return{describeKind:"producer",...t}}function Pr(t,e){let{signal:n,period:r,...o}=e??{};return Ce(s=>{let i=!1,a=0,d,u,c=()=>{i=!0,d!==void 0&&clearTimeout(d),u!==void 0&&clearInterval(u),n?.removeEventListener("abort",p)},l=()=>{i||(r!=null?(s.emit(a++),u=setInterval(()=>{i||s.emit(a++)},r)):(i=!0,n?.removeEventListener("abort",p),s.emit(a++),s.down([[P]])))},p=()=>{i||(c(),s.down([[D,n.reason]]))};if(n?.aborted){p();return}return d=setTimeout(l,t),n?.addEventListener("abort",p,{once:!0}),c},Lr(o))}function $r(t,e){let n=Dr(t),{tickMs:r,output:o,...s}=e??{},i=r??6e4,a=o==="date";return Ce(d=>{let u=-1,c=()=>{let p=new Date,h=p.getFullYear()*1e8+(p.getMonth()+1)*1e6+p.getDate()*1e4+p.getHours()*100+p.getMinutes();h!==u&&Gr(n,p)&&(u=h,d.emit(a?p:se()))};c();let l=setInterval(c,i);return()=>clearInterval(l)},{...Lr(s),name:s.name??`cron:${t}`})}function pe(t){return t.subscribe(()=>{})}var kt=J(()=>{"use strict";Ve();K();fe();Ir()});function ct(t,e){if(e!=null&&e.length>0)return new Set(e);switch(t){case"standard":return new Set(["type","status","value","deps","meta","v"]);case"full":return null;case"spec":return new Set(["type","deps","meta"]);default:return new Set(["type","deps"])}}function ds(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function _n(t){let e=new WeakSet,n={};for(let[r,o]of Br(t))n[r]=vn(o,e);return n}function vn(t,e){if(t==null)return t;let n=typeof t;if(n==="boolean"||n==="number"||n==="string")return t;if(n==="function")return"<function>";if(Array.isArray(t))return e.has(t)?"<cycle>":(e.add(t),t.map(r=>vn(r,e)));if(n==="object"){let r=t;if(e.has(r))return"<cycle>";e.add(r);try{if(typeof r.subscribe=="function"&&"cache"in r)return"<Node>"}catch{return"<unserializable>"}let o={};for(let[s,i]of Br(r))o[s]=vn(i,e);return o}return"<unserializable>"}function Br(t){let e=[],n;try{n=Object.keys(t)}catch{return e}for(let r of n)try{e.push([r,t[r]])}catch{e.push([r,"<unserializable>"])}return e}function cs(t){let e={};for(let[n,r]of Object.entries(t.meta))try{e[n]=r.cache}catch{}return e}function Tn(t,e){let n=e==null,r=!n&&e!=null?[...e].filter(u=>u.startsWith("meta.")).map(u=>u.slice(5)):null,o=n||e.has("meta")||r!=null&&r.length>0,s="state",i=[];t instanceof j&&(s=ds(t),i=t._deps.map(u=>u.node.name??""));let a={type:s,deps:i};(n||e.has("status"))&&(a.status=t.status);let d=t instanceof j?t._guard:void 0;if(o){let u={...cs(t)};if(d!=null&&u.access===void 0&&(u.access=on(d)),r!=null&&r.length>0&&!e.has("meta")){let c={};for(let l of r)l in u&&(c[l]=u[l]);a.meta=c}else a.meta=u}if(t.name!=null&&(a.name=t.name),n||e.has("value")){t.status==="sentinel"&&(a.sentinel=!0);try{a.value=t.cache}catch{}}if((n||e.has("v"))&&t.v!=null){let u={id:t.v.id,version:t.v.version};"cid"in t.v&&(u.cid=t.v.cid,u.prev=t.v.prev),a.v=u}return(n||e.has("guard"))&&d!=null&&(a.guard=on(d)),(n||e.has("lastMutation"))&&t.lastMutation!=null&&(a.lastMutation=t.lastMutation),a}var wn=J(()=>{"use strict";Ae();ke()});var Gt,Kr=J(()=>{"use strict";Gt=class{_timer;_gen=0;start(e,n){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&n()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var Ti={};ce(Ti,{jotai:()=>fn,nanostores:()=>hn,nestjs:()=>In,react:()=>Ln,signals:()=>Fn,solid:()=>Hn,svelte:()=>Vn,vue:()=>jn,zustand:()=>qn});module.exports=Lo(Ti);var fn={};ce(fn,{atom:()=>Qo});K();fe();function Qo(t,e,n){if(typeof t=="function"){let r=t;return typeof e=="function"?yr(r,e,n):yr(r,void 0,e)}return Xo(t,e)}function it(t){let e=t.cache,n;if(t.subscribe(o=>{for(let[s,i]of o)s===C&&(e=i),s===D&&(n=i)})(),n)throw n;return e}function Xo(t,e){let n=V(t,{...e,resubscribable:!0,resetOnTeardown:!0});return{get:()=>n.status==="sentinel"?it(n):n.cache,set:r=>n.emit(r),update:r=>{let o=n.status==="sentinel"?it(n):n.cache;n.emit(r(o))},subscribe:r=>{let o=!0;return n.subscribe(s=>{for(let[i,a]of s)if(i===C){if(o){o=!1;continue}r(a)}})},meta:n.meta,_node:n}}function yr(t,e,n){let r=st(s=>t(i=>{let a=i._node;return a.status==="sentinel"&&it(a),s(a)}),{...n,resubscribable:!0,resetOnTeardown:!0}),o={get:()=>r.status==="sentinel"?it(r):r.cache,subscribe:s=>{let i=!0;return r.subscribe(a=>{for(let[d,u]of a)if(d===C){if(i){i=!1;continue}s(u)}})},meta:r.meta,_node:r};if(e){let s=d=>d.get(),i=(d,u)=>d.set(u),a=o;return a.set=d=>e(s,i,d),a.update=d=>{let u=r.status==="sentinel"?it(r):r.cache;return e(s,i,d(u))},a}return o}var hn={};ce(hn,{action:()=>os,atom:()=>Zo,computed:()=>es,getValue:()=>ns,map:()=>ts,onMount:()=>rs,onStart:()=>_r,onStop:()=>Tr});Se();K();fe();var At=new WeakMap,Nt=new WeakMap;function St(t,e){let n=e.get(t);if(n)for(let r of n)r()}function pn(t,e={}){let n=0;return{...e,get:()=>vr(t),subscribe:o=>{n===0&&St(t,At),n++;let s=t.subscribe(i=>{for(let[a,d]of i)a===C&&o(d)});return()=>{s(),n--,n===0&&St(t,Nt)}},listen:o=>{n===0&&St(t,At),n++;let s=!0,i=t.subscribe(a=>{for(let[d,u]of a)if(d===C){if(s){s=!1;continue}o(u)}});return()=>{i(),n--,n===0&&St(t,Nt)}},_node:t}}function br(t){let e=t.cache,n;if(t.subscribe(o=>{for(let[s,i]of o)s===C&&(e=i),s===D&&(n=i)})(),n)throw n;return e}function vr(t){return t.status==="sentinel"?br(t):t.cache}function Zo(t){let e=V(t,{resubscribable:!0,resetOnTeardown:!0});return pn(e,{set:n=>e.emit(n)})}function es(t,e){let n=Array.isArray(t)?t:[t],r=n.map(s=>s._node),o=ln(r,s=>{let i=n.map(a=>{let d=a._node;return d.status==="sentinel"&&br(d),s(d)});return e(...i)},{resubscribable:!0,resetOnTeardown:!0,equals:Object.is});return pn(o)}function ts(t){let e=V(t,{resubscribable:!0,resetOnTeardown:!0,equals:()=>!1});return pn(e,{set:n=>e.emit(n),setKey:(n,r)=>{let o=vr(e);e.emit({...o,[n]:r})}})}function ns(t){return t.get()}function _r(t,e){let n=t._node,r=At.get(n);r||(r=new Set,At.set(n,r)),r.add(e)}function Tr(t,e){let n=t._node,r=Nt.get(n);r||(r=new Set,Nt.set(n,r)),r.add(e)}function rs(t,e){_r(t,()=>{let n=e();typeof n=="function"&&Tr(t,n)})}function os(t,e,n){return(...r)=>{let o;return le(()=>{o=n(...r)}),o}}var In={};ce(In,{ACTOR_KEY:()=>Dt,COMMAND_HANDLERS:()=>We,CQRS_EVENT_HANDLERS:()=>Ke,CRON_HANDLERS:()=>Be,CommandHandler:()=>Nr,EVENT_HANDLERS:()=>qe,EventHandler:()=>kr,GRAPHREFLY_REQUEST_GRAPH:()=>Me,GRAPHREFLY_ROOT_GRAPH:()=>ae,GraphCron:()=>Ar,GraphInterval:()=>Sr,GraphReflyEventExplorer:()=>De,GraphReflyGuard:()=>zr,GraphReflyGuardImpl:()=>dt,GraphReflyModule:()=>Ut,INTERVAL_HANDLERS:()=>ze,InjectCqrsGraph:()=>Rr,InjectGraph:()=>xr,InjectNode:()=>Er,ObserveGateway:()=>Mt,OnGraphEvent:()=>Or,QUERY_HANDLERS:()=>Ue,QueryHandler:()=>Cr,SAGA_HANDLERS:()=>Ye,SagaHandler:()=>Mr,fromHeader:()=>jr,fromJwtPayload:()=>bn,getActor:()=>qr,getGraphToken:()=>X,getNodeToken:()=>de,observeSSE:()=>Hr,observeSubscription:()=>Vr,toObservable:()=>wr});var gn=require("rxjs");K();function wr(t,e){return e?.raw?new gn.Observable(n=>t.subscribe(o=>{if(!n.closed){n.next(o);for(let s of o){if(s[0]===D){n.error(s[1]);return}if(s[0]===P){n.complete();return}}}})):new gn.Observable(n=>t.subscribe(o=>{for(let s of o){if(n.closed)return;if(s[0]===C)n.next(s[1]);else if(s[0]===D){n.error(s[1]);return}else if(s[0]===P){n.complete();return}}}))}var at=require("@nestjs/common");var ae=Symbol.for("graphrefly:root-graph");var Me=Symbol.for("graphrefly:request-graph");function X(t){return Symbol.for(`graphrefly:graph:${t}`)}function de(t){return Symbol.for(`graphrefly:node:${t}`)}var qe=new Map,ze=new Map,Be=new Map,We=new Map,Ke=new Map,Ue=new Map,Ye=new Map;function xr(t){return t==="request"?(0,at.Inject)(Me):(0,at.Inject)(t?X(t):ae)}function Rr(t){return(0,at.Inject)(X(t))}function Er(t){return(0,at.Inject)(de(t))}function Or(t){return(e,n)=>{let r=n.name;n.addInitializer(function(){let o=this.constructor,s=qe.get(o)??[];s.push({nodeName:t,methodKey:r}),qe.set(o,s)})}}function Sr(t){return(e,n)=>{let r=n.name;n.addInitializer(function(){let o=this.constructor,s=ze.get(o)??[];s.push({ms:t,methodKey:r}),ze.set(o,s)})}}function Ar(t){return(e,n)=>{let r=n.name;n.addInitializer(function(){let o=this.constructor,s=Be.get(o)??[];s.push({expr:t,methodKey:r}),Be.set(o,s)})}}function Nr(t,e){return(n,r)=>{let o=r.name;r.addInitializer(function(){let s=this.constructor,i=We.get(s)??[];i.push({cqrsName:t,commandName:e,methodKey:o}),We.set(s,i)})}}function kr(t,e){return(n,r)=>{let o=r.name;r.addInitializer(function(){let s=this.constructor,i=Ke.get(s)??[];i.push({cqrsName:t,eventName:e,methodKey:o}),Ke.set(s,i)})}}function Cr(t,e){return(n,r)=>{let o=r.name;r.addInitializer(function(){let s=this.constructor,i=Ue.get(s)??[];i.push({cqrsName:t,projectionName:e,methodKey:o}),Ue.set(s,i)})}}function Mr(t,e,n){return(r,o)=>{let s=o.name;o.addInitializer(function(){let i=this.constructor,a=Ye.get(i)??[];a.push({cqrsName:t,eventNames:n,sagaName:e,methodKey:s}),Ye.set(i,a)})}}K();kt();var Fr=0,De=class{constructor(e,n){this.graph=e;this.moduleRef=n}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,n]of qe){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireEventHandler(r,o)}}wireEventHandler(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),i=this.observeNode(n.nodeName).subscribe(a=>{for(let d of a)d[0]===C&&o(d[1])});this.disposers.push(i)}wireIntervals(){for(let[e,n]of ze){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireIntervalHandler(r,e,o)}}wireIntervalHandler(e,n,r){let o=e[r.methodKey];if(typeof o!="function")return;let s=o.bind(e),a=`__schedule__.${n.name??"anonymous"}.${String(r.methodKey)}.${Fr++}`,d=Pr(r.ms,{period:r.ms,name:a});this.graph.add(d),this.scheduleNodeNames.push(a);let c=this.observeNode(a).subscribe(l=>{for(let p of l)p[0]===C&&s(p[1])});this.disposers.push(c)}wireCrons(){for(let[e,n]of Be){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCronHandler(r,e,o)}}wireCronHandler(e,n,r){let o=e[r.methodKey];if(typeof o!="function")return;let s=o.bind(e),a=`__schedule__.${n.name??"anonymous"}.${String(r.methodKey)}.${Fr++}`,d=$r(r.expr,{name:a});this.graph.add(d),this.scheduleNodeNames.push(a);let c=this.observeNode(a).subscribe(l=>{for(let p of l)p[0]===C&&s(p[1])});this.disposers.push(c)}wireCqrsCommands(){for(let[e,n]of We){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsCommand(r,o)}}wireCqrsCommand(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);s&&s.command(n.commandName,o)}wireCqrsEvents(){for(let[e,n]of Ke){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsEventHandler(r,o)}}wireCqrsEventHandler(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);if(!s)return;s.event(n.eventName);let a=s.resolve(n.eventName).cache,d=a&&a.length>0?a[a.length-1].seq:0,c=this.observeNodeOn(s,n.eventName).subscribe(l=>{for(let p of l)if(p[0]===C){let h=p[1];for(let f of h)f.seq>d&&(o(f),d=f.seq)}});this.disposers.push(c)}wireCqrsQueries(){for(let[e,n]of Ue){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsQuery(r,o)}}wireCqrsQuery(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);if(!s)return;let a=this.observeNodeOn(s,n.projectionName).subscribe(d=>{for(let u of d)u[0]===C&&o(u[1])});this.disposers.push(a)}wireCqrsSagas(){for(let[e,n]of Ye){let r=this.resolveInstance(e);if(r)for(let o of n)this.wireCqrsSaga(r,o)}}wireCqrsSaga(e,n){let r=e[n.methodKey];if(typeof r!="function")return;let o=r.bind(e),s=this.resolveCqrsGraph(n.cqrsName);s&&s.saga(n.sagaName,n.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,n){return e.observe(n)}resolveCqrsGraph(e){try{return this.moduleRef.get(X(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};K();K();var ss=0;function Ct(t,e){if(e.highWaterMark<1)throw new RangeError("highWaterMark must be >= 1");if(e.lowWaterMark<0)throw new RangeError("lowWaterMark must be >= 0");if(e.lowWaterMark>=e.highWaterMark)throw new RangeError("lowWaterMark must be < highWaterMark");let n=Symbol(`bp-${++ss}`),r=0,o=!1;return{onEnqueue(){return r+=1,!o&&r>=e.highWaterMark?(o=!0,t([[ee,n]]),!0):!1},onDequeue(){return r>0&&(r-=1),o&&r<=e.lowWaterMark?(o=!1,t([[oe,n]]),!0):!1},get pending(){return r},get paused(){return o},dispose(){o&&(o=!1,t([[oe,n]]))}}}function Hr(t,e,n){let{actor:r,serialize:o=is,keepAliveMs:s,signal:i}=n??{},a=new TextEncoder,d,u=n?.highWaterMark!=null,c,l,p=[],h=!1;return new ReadableStream({start(f){let y,m=()=>{},w=()=>{if(!h){h=!0,y!==void 0&&clearInterval(y),i?.removeEventListener("abort",_),m(),c?.dispose(),l?.(),l=void 0;for(let b of p)f.enqueue(b.frame);p.length=0,f.close()}};d=w;let _=()=>w(),v=t.observe(e,{actor:r});u&&(c=Ct(b=>v.up(b),{highWaterMark:n.highWaterMark,lowWaterMark:n.lowWaterMark??Math.floor(n.highWaterMark/2)})),m=v.subscribe(b=>{for(let E of b){if(h)return;let O=E[0];if(O===C){let g=a.encode(mn("data",o(E[1])));u?(p.push({frame:g,counted:!0}),c.onEnqueue(),l?.(),l=void 0):f.enqueue(g)}else if(O===D){let g=a.encode(mn("error",o(E[1])));u?(p.push({frame:g,counted:!1}),l?.(),l=void 0):f.enqueue(g),w();return}else if(O===P||O===q){if(O===P){let g=a.encode(mn("complete"));u?(p.push({frame:g,counted:!1}),l?.(),l=void 0):f.enqueue(g)}w();return}}}),s!==void 0&&s>0&&(y=setInterval(()=>{h||(u?(p.push({frame:a.encode(`: keepalive
1
+ "use strict";var yo=Object.create;var $e=Object.defineProperty;var zn=Object.getOwnPropertyDescriptor;var bo=Object.getOwnPropertyNames;var vo=Object.prototype.hasOwnProperty;var Wn=(r,e)=>(e=Symbol[r])?e:Symbol.for("Symbol."+r),nt=r=>{throw TypeError(r)};var _o=(r,e,t)=>e in r?$e(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var Hn=(r,e)=>$e(r,"name",{value:e,configurable:!0});var U=(r,e)=>()=>(r&&(e=r(r=0)),e);var ce=(r,e)=>{for(var t in e)$e(r,t,{get:e[t],enumerable:!0})},To=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of bo(e))!vo.call(r,o)&&o!==t&&$e(r,o,{get:()=>e[o],enumerable:!(n=zn(e,o))||n.enumerable});return r};var wo=r=>To($e({},"__esModule",{value:!0}),r);var Bn=r=>[,,,yo(r?.[Wn("metadata")]??null)],Kn=["class","method","getter","setter","accessor","field","value","get","set"],tt=r=>r!==void 0&&typeof r!="function"?nt("Function expected"):r,xo=(r,e,t,n,o)=>({kind:Kn[r],name:e,metadata:n,addInitializer:s=>t._?nt("Already initialized"):o.push(tt(s||null))}),Ro=(r,e)=>_o(e,Wn("metadata"),r[3]),Un=(r,e,t,n)=>{for(var o=0,s=r[e>>1],a=s&&s.length;o<a;o++)e&1?s[o].call(t):n=s[o].call(t,n);return n},Yn=(r,e,t,n,o,s)=>{var a,i,d,u,c,l=e&7,p=!!(e&8),h=!!(e&16),f=l>3?r.length+1:l?p?1:2:0,m=Kn[l+5],g=l>3&&(r[f-1]=[]),x=r[f]||(r[f]=[]),v=l&&(!h&&!p&&(o=o.prototype),l<5&&(l>3||!h)&&zn(l<4?o:{get[t](){return qn(this,s)},set[t](b){return jn(this,s,b)}},t));l?h&&l<4&&Hn(s,(l>2?"set ":l>1?"get ":"")+t):Hn(o,t);for(var _=n.length-1;_>=0;_--)u=xo(l,t,d={},r[3],x),l&&(u.static=p,u.private=h,c=u.access={has:h?b=>Eo(o,b):b=>t in b},l^3&&(c.get=h?b=>(l^1?qn:Oo)(b,o,l^4?s:v.get):b=>b[t]),l>2&&(c.set=h?(b,T)=>jn(b,o,T,l^4?s:v.set):(b,T)=>b[t]=T)),i=(0,n[_])(l?l<4?h?s:v[m]:l>4?void 0:{get:v.get,set:v.set}:o,u),d._=1,l^4||i===void 0?tt(i)&&(l>4?g.unshift(i):l?h?s=i:v[m]=i:o=i):typeof i!="object"||i===null?nt("Object expected"):(tt(a=i.get)&&(v.get=a),tt(a=i.set)&&(v.set=a),tt(a=i.init)&&g.unshift(a));return l||Ro(r,o),v&&$e(o,t,v),h?l^4?s:v:o};var Yt=(r,e,t)=>e.has(r)||nt("Cannot "+t),Eo=(r,e)=>Object(e)!==e?nt('Cannot use the "in" operator on this value'):r.has(e),qn=(r,e,t)=>(Yt(r,e,"read from private field"),t?t.call(r):e.get(r));var jn=(r,e,t,n)=>(Yt(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),Oo=(r,e,t)=>(Yt(r,e,"access private method"),t);var we,O,P,z,re,ee,oe,V,I,D,xe,vt,Jn,_t,Qn,Zn,Tt,Jt,Qt,Zt,wt,K=U(()=>{"use strict";we=Symbol.for("graphrefly/START"),O=Symbol.for("graphrefly/DATA"),P=Symbol.for("graphrefly/DIRTY"),z=Symbol.for("graphrefly/RESOLVED"),re=Symbol.for("graphrefly/INVALIDATE"),ee=Symbol.for("graphrefly/PAUSE"),oe=Symbol.for("graphrefly/RESUME"),V=Symbol.for("graphrefly/TEARDOWN"),I=Symbol.for("graphrefly/COMPLETE"),D=Symbol.for("graphrefly/ERROR"),xe=Object.freeze([P]),vt=Object.freeze([z]),Jn=Object.freeze([re]),_t=Object.freeze([we]),Qn=Object.freeze([I]),Zn=Object.freeze([V]),Tt=Object.freeze([xe]),Jt=Object.freeze([vt]),Qt=Object.freeze([Jn]),Zt=Object.freeze([Qn]),wt=Object.freeze([Zn])});function er(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 o=2+t.length+2+e.length;if(o>4294967295)throw new Error(`encodeEnvelope: total envelope size ${o} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let s=new Uint8Array(o),a=0;return s[a++]=Xt,s[a++]=t.length,s.set(t,a),a+=t.length,s[a++]=n>>>8&255,s[a++]=n&255,s.set(e,a),s}function tr(r,e){if(r.length<Xn)throw new Error(`decodeEnvelope: bytes too short (${r.length} < ${Xn})`);let t=0,n=r[t++];if(n!==Xt)throw new Error(`decodeEnvelope: unsupported envelope version ${n} (expected ${Xt})`);let o=r[t++];if(o===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+o+2>r.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+o+2} bytes, have ${r.length})`);let s=new TextDecoder().decode(r.subarray(t,t+o));t+=o;let a=(r[t]<<8|r[t+1])>>>0;t+=2;let i=r.subarray(t),d=e.lookupCodec(s);if(d==null)throw new Error(`decodeEnvelope: codec "${s}" not registered (envelope codec_v=${a})`);return{codec:d,codecVersion:a,payload:i}}function nr(r){r.registerCodec(No)}var No,Xt,Xn,en=U(()=>{"use strict";No={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)}},Xt=1,Xn=4});function Re(r){if(r==null)return be;let{type:e,id:t,...n}=r;return{type:e??"system",id:t??"",...n}}var be,rt=U(()=>{"use strict";be={type:"system",id:""}});function xt(){return Fe>0||ot}function rr(){return Fe>0}function He(r){Fe>0?st.push(r):r()}function le(r){Fe+=1;let e=!1;try{r()}catch(t){throw e=!0,t}finally{if(Fe-=1,Fe===0)if(e){if(!ot){let t=st.splice(0);for(let n of t)try{n()}catch{}Ee.length=0,Oe.length=0,Ve.length=0}}else So()}}function So(){let r=!ot;r&&(ot=!0);let e=[],t=0;try{for(;Ee.length>0||Oe.length>0||Ve.length>0||r&&st.length>0;){if(r&&st.length>0){let s=st.splice(0);for(let a of s)try{a()}catch(i){e.push(i)}continue}if(t+=1,t>1e3)throw Ee.length=0,Oe.length=0,Ve.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let o=(Ee.length>0?Ee:Oe.length>0?Oe:Ve).splice(0);for(let s of o)try{s()}catch(a){e.push(a)}}}finally{r&&(ot=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Rt(r,e,t){if(e.length===0)return;if(e.length===1){let u=t(e[0][0]);if(u<3||!xt()){r(e);return}(u>=5?Ve:u===4?Oe:Ee).push(()=>r(e));return}let n=e.length,o=n,s=n,a=n,i=0;for(;i<n&&t(e[i][0])<3;)i++;for(o=i;i<n&&t(e[i][0])===3;)i++;for(s=i;i<n&&t(e[i][0])===4;)i++;a=i;let d=xt();if(o>0){let u=e.slice(0,o);r(u)}if(s>o){let u=e.slice(o,s);d?Ee.push(()=>r(u)):r(u)}if(a>s){let u=e.slice(s,a);d?Oe.push(()=>r(u)):r(u)}if(n>a){let u=e.slice(a,n);d?Ve.push(()=>r(u)):r(u)}}var Fe,ot,Ee,Oe,Ve,st,Ne=U(()=>{"use strict";Fe=0,ot=!1,Ee=[],Oe=[],Ve=[],st=[]});function pe(){return Math.trunc(performance.now()*1e6)}function se(){return Date.now()*1e6}var qe=U(()=>{"use strict"});function or(r){r.registerMessageType(we,{tier:0,wireCrossing:!1}),r.registerMessageType(P,{tier:1,wireCrossing:!1}),r.registerMessageType(re,{tier:1,wireCrossing:!1,metaPassthrough:!1}),r.registerMessageType(ee,{tier:2,wireCrossing:!1}),r.registerMessageType(oe,{tier:2,wireCrossing:!1}),r.registerMessageType(O,{tier:3,wireCrossing:!0}),r.registerMessageType(z,{tier:3,wireCrossing:!0}),r.registerMessageType(I,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType(D,{tier:4,wireCrossing:!0,metaPassthrough:!1}),r.registerMessageType(V,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Et,sr=U(()=>{"use strict";K();Et=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 ir(r){return Array.isArray(r)?[...r]:[r]}function ko(r,e){return r.has(e)||r.has("*")}function je(r){let e=[];return r((o,s)=>{e.push({kind:"allow",actions:new Set(ir(o)),where:s?.where??(()=>!0)})},(o,s)=>{e.push({kind:"deny",actions:new Set(ir(o)),where:s?.where??(()=>!0)})}),(o,s)=>{let a=!1,i=!1;for(let d of e)ko(d.actions,s)&&d.where(o)&&(d.kind==="deny"?a=!0:i=!0);return a?!1:i}}function tn(r){let e=Ao.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 ie,Ao,Se=U(()=>{"use strict";ie=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}};Ao=["human","llm","wallet","system"]});function nn(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(nn);if(typeof r=="object"&&r!==null){let e={};for(let t of Object.keys(r).sort())e[t]=nn(r[t]);return e}return null}function Do(r){let e=Mo.encode(r),t=e.length,n=t*8,o=t+9+63&-64,s=new Uint8Array(o);s.set(e),s[t]=128;let a=new DataView(s.buffer);a.setUint32(o-4,n>>>0,!1),a.setUint32(o-8,Math.floor(n/4294967296)>>>0,!1);let i=1779033703,d=3144134277,u=1013904242,c=2773480762,l=1359893119,p=2600822924,h=528734635,f=1541459225,m=new Uint32Array(64),g=(v,_)=>v>>>_|v<<32-_;for(let v=0;v<o;v+=64){for(let w=0;w<16;w++)m[w]=a.getUint32(v+w*4,!1);for(let w=16;w<64;w++){let k=m[w-15],M=m[w-2],A=g(k,7)^g(k,18)^k>>>3,q=g(M,17)^g(M,19)^M>>>10;m[w]=m[w-16]+A+m[w-7]+q>>>0}let _=i,b=d,T=u,N=c,y=l,E=p,S=h,R=f;for(let w=0;w<64;w++){let k=g(y,6)^g(y,11)^g(y,25),M=y&E^~y&S,A=R+k+M+Co[w]+m[w]>>>0,q=g(_,2)^g(_,13)^g(_,22),B=_&b^_&T^b&T,X=q+B>>>0;R=S,S=E,E=y,y=N+A>>>0,N=T,T=b,b=_,_=A+X>>>0}i=i+_>>>0,d=d+b>>>0,u=u+T>>>0,c=c+N>>>0,l=l+y>>>0,p=p+E>>>0,h=h+S>>>0,f=f+R>>>0}let x=v=>v.toString(16).padStart(8,"0");return x(i)+x(d)+x(u)+x(c)+x(l)+x(p)+x(h)+x(f)}function rn(r){let e=nn(r??null),t=JSON.stringify(e);return Do(t).slice(0,16)}function Go(){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 on(r,e,t){let n=t?.id??Go();if(r===0)return{id:n,version:0};let s=(t?.hash??rn)(e);return{id:n,version:0,cid:s,prev:null}}function ar(r,e,t){r.version+=1,"cid"in r&&(r.prev=r.cid,r.cid=t(e))}var Co,Mo,dr=U(()=>{"use strict";Co=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]),Mo=new TextEncoder});function lr(r){return{node:r,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function sn(r){r.prevData=void 0,r.dirty=!1,r.involvedThisWave=!1,r.dataBatch.length=0,r.terminal=void 0}function Ot(r){return r.length===0?r:typeof r[0]=="symbol"?[r]:r}function he(r,e,t){let n=fr(r)?r:[],o=typeof r=="function"?r:typeof e=="function"?e:void 0,s={};return fr(r)?s=(an(e)?e:t)??{}:an(r)?s=r:s=(an(e)?e:t)??{},new H(n,o,s)}var ur,cr,Io,Po,ke,H,fr,an,Ae=U(()=>{"use strict";en();rt();Ne();qe();sr();Se();K();dr();ur=()=>{},cr=100;Io=(r,e,t,n)=>{t.direction==="down-in"&&r._onDepMessage(t.depIndex,e)},Po=(r,e,t,n)=>{let o=r;if(o._status==="completed"||o._status==="errored")return;let s=o._cached,a=s===void 0?[_t]:[_t,[O,s]];o._status==="dirty"&&a.push(xe),Rt(e,a,o._config.tierOf)},ke=new Et({onMessage:Io,onSubscribe:Po});or(ke);nr(ke);H=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??ke,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??rn;let o=n.versioning??this._config.defaultVersioning;this._versioningLevel=o,this._versioning=o!=null?on(o,this._cached===void 0?void 0:this._cached,{id:n.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(lr);let s={};for(let[i,d]of Object.entries(n.meta??{})){let u={initial:d,name:`${n.name??"node"}:meta:${i}`,describeKind:"state",config:this._config};n.guard!=null&&(u.guard=n.guard),s[i]=new r([],void 0,u)}Object.freeze(s),this.meta=s,this._hasMeta=Object.keys(s).length>0;let a=this;this._actions={emit(i){a._emit([[O,i]])},down(i){a._emit(Ot(i))},up(i){a._emitUp(Ot(i))}},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 o=t?.hash??this._hashFn;o!==this._hashFn&&(this._hashFn=o);let s=this._cached===void 0?void 0:this._cached,a=this._versioning,i=a?.id??t?.id,d=a?.version??0,u=on(e,s,{id:i,hash:o});u.version=d,this._versioning=u,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=Re(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 o=Re(e?.actor),s=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(o,s))throw new ie({actor:o,action:s,nodeName:this.name});if(this._extraGuards!=null){for(let a of this._extraGuards)if(!a(o,s))throw new ie({actor:o,action:s,nodeName:this.name})}this._lastMutation={actor:o,timestamp_ns:se()}}down(e,t){let n=Ot(e);n.length!==0&&(this._checkGuard(t),this._emit(n))}emit(e,t){this._checkGuard(t),this._emit([[O,e]])}up(e,t){if(this._deps.length===0)return;let n=Ot(e);if(n.length===0)return;this._checkGuard(t);let o=t??{internal:!0};this._validateUpTiers(n);for(let s of this._deps)s.node.up?.(n,o)}_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 o=t(n[0]);if(o===3||o===4)throw new Error(`Node "${this.name}": tier-${o} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let d=Re(t);if(!this._guard(d,"observe"))throw new ie({actor:d,action:"observe",nodeName:this.name})}let o=this._isTerminal&&this._resubscribable;if(o){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)sn(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let s;try{s=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:o},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let a=this._isTerminal;if(this._sinkCount===1&&!a)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof s=="function")try{s()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let i=!1;return()=>{i||(i=!0,this._sinkCount-=1,this._removeSink(e),typeof s=="function"&&s(),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 o=n,s=this._deps[n];s.unsub=ur,s.unsub=s.node.subscribe(a=>{if(s.unsub===null)return;let i=this._config.tierOf,d=!1;for(let u of a)i(u[0])>=3&&(d=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:o},this._actions);d&&this._maybeRunFnOnSettlement()}),t++}}catch(n){this._deps[t].unsub=null;for(let o=0;o<t;o++){let s=this._deps[o];if(s.unsub!=null){let a=s.unsub;s.unsub=null;try{a()}catch{}sn(s)}}throw this._dirtyDepCount=0,n}}_addDep(e){for(let o=0;o<this._deps.length;o++)if(this._deps[o].node===e)return o;let t=this._deps.length,n=lr(e);if(this._deps.push(n),this._sinks==null)return t;n.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Tt),n.unsub=ur;try{n.unsub=e.subscribe(o=>{if(n.unsub===null)return;let s=this._config.tierOf,a=!1;for(let i of o)s(i[0])>=3&&(a=!0),this._config.onMessage(this,i,{direction:"down-in",depIndex:t},this._actions);a&&this._maybeRunFnOnSettlement()})}catch(o){throw n.unsub=null,this._deps.pop(),this._dirtyDepCount--,o}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(n){this._emit([[D,this._wrapFnError("cleanup threw",n)]])}else if(t!=null&&typeof t=="object"){let n=t.deactivate;if(typeof n=="function")try{n()}catch(o){this._emit([[D,this._wrapFnError("cleanup.deactivate threw",o)]])}}for(let n of this._deps){if(n.unsub!=null){let o=n.unsub;n.unsub=null;try{o()}catch{}}sn(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],o=t[0];if(this._inspectorHooks!=null){let s={kind:"dep_message",depIndex:e,message:t};for(let a of this._inspectorHooks)a(s)}if(o!==we){if(o===P){this._depDirtied(n);return}if(o===re){if(this._depInvalidated(n),this._cached===void 0)return;this._emit(Qt);return}if(o===ee||o===oe){this._emit([t]);return}if(o===V){this._emit(wt);return}if(o===O)this._depSettledAsData(n,t[1]);else if(o===z)this._depSettledAsResolved(n);else if(o===I)this._depSettledAsTerminal(n,!0);else if(o===D)this._depSettledAsTerminal(n,t[1]);else{this._emit([t]);return}if(!this._fn){(o===O||o===z)&&this._emit([t]),(o===I||o===D)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Tt))}_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(Jt),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([[D,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(Zt)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(a){this._emit([[D,this._wrapFnError("cleanup threw",a)]]);return}}else if(e!=null&&typeof e=="object"){let a=e.beforeRun;if(typeof a=="function"){e.beforeRun=void 0;try{a()}catch(i){this._emit([[D,this._wrapFnError("cleanup.beforeRun threw",i)]]);return}}}let t=this._deps.map(a=>a.involvedThisWave?a.dataBatch.length>0?[...a.dataBatch]:[]:void 0),n=this._deps.map(a=>a.prevData);for(let a=0;a<this._deps.length;a++){let i=t[a];i!=null&&i.length>0&&(this._deps[a].prevData=i[i.length-1])}let o=this._deps.map(a=>a.terminal),s={prevData:n,terminalDeps:o,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let a={kind:"run",batchData:t,prevData:n};for(let i of this._inspectorHooks)i(a)}this._isExecutingFn=!0;try{let a=this._fn(t,this._actions,s);if(typeof a=="function")this._cleanup=a;else if(a!=null&&typeof a=="object"){let i=a;(typeof i.beforeRun=="function"||typeof i.deactivate=="function"||typeof i.invalidate=="function")&&(this._cleanup=a)}}catch(a){this._emit([[D,this._wrapFnError("fn threw",a)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>cr?(this._rerunDepth=0,this._emit([[D,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${cr} \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"?[xe,e[0]]:e;let n=!0,o=!1,s=!1,a=-1;for(let d of e){let u=t(d[0]);u<a&&(n=!1),u===3&&(o=!0),d[0]===P&&(s=!0),a=u}let i=e;if(!n){let d=e.map((u,c)=>({m:u,i:c,tier:t(u[0])}));d.sort((u,c)=>u.tier-c.tier||u.i-c.i),i=d.map(u=>u.m)}if(o&&!s&&this._status!=="dirty"){let d=0;for(;d<i.length&&t(i[d][0])===0;)d++;return d===0?[xe,...i]:[...i.slice(0,d),xe,...i.slice(d)]}return i}_emit(e){if(e.length===0)return;for(let i=0;i<e.length;i++){let d=e[i];if(d[0]===D&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let i=e.filter(d=>d[0]===V||d[0]===re);if(i.length===0)return;t=i}t=this._frameBatch(t);let o=null;for(let i=0;i<t.length;i++){let d=t[i],u=d[0];if(u!==ee&&u!==oe){o?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${u===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 l=d[1];if(u===ee)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(l),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(l))c=!1;else if(this._pauseLocks.delete(l),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?o?.push(d):o==null&&(o=t.slice(0,i))}if(o!=null){if(o.length===0)return;t=o}if(this._hasMeta&&t.some(i=>i[0]===V))for(let i of Object.keys(this.meta))try{this.meta[i]._emit(wt)}catch{}let{finalMessages:s,equalsError:a}=this._updateState(t);if(s.length>0&&this._config.inspectorEnabled){let i=this._config.globalInspector;if(i!=null)try{i({kind:"emit",node:this,messages:s})}catch{}}if(s.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let i=this._config.tierOf,d=[];for(let u of s)i(u[0])===3?this._pauseBuffer.push(u):d.push(u);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(s);a!=null&&this._emit([[D,a]])}_updateState(e){let t=this._config.tierOf,n,o,s=-1,a=0;for(let c of e)t(c[0])===3&&a++;let i=a<=1,d=-1;if(this._versioning!=null&&a>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===O){d=c;break}}for(let c=0;c<e.length;c++){let l=e[c],p=l[0];if(p===O){if(l.length>=2){let h=!1;if(i&&this._cached!==void 0)try{h=this._equals(this._cached,l[1])}catch(f){o=this._wrapFnError("equals threw",f),s=c;break}if(h){n==null&&(n=e.slice(0,c)),n.push(vt),this._status="resolved";continue}this._cached=l[1],this._versioning!=null&&(d<0||c===d)&&ar(this._versioning,l[1],this._hashFn)}this._status="settled",n?.push(l)}else if(n?.push(l),p===P)this._status="dirty";else if(p===z)this._status="resolved";else if(p===I){this._status="completed";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"completed",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===D){this._status="errored";{let h=this._config.rigorRecorder;if(h!=null)try{h.onTerminalTransition(this,"errored",this._autoComplete,this._autoError,this._deps.length>0)}catch{}}}else if(p===re){if(this._cached!==void 0){let f=this._config.rigorRecorder;if(f!=null)try{f.onNonVacuousInvalidate(this,this._cached)}catch{}}this._cached=void 0,this._status="dirty";let h=this._cleanup;if(typeof h=="function"){this._cleanup=void 0;try{h()}catch{}}else if(h!=null&&typeof h=="object"){let f=h.invalidate;if(typeof f=="function")try{f()}catch{}}}else p===V&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=s>=0?n??e.slice(0,s):n??e;return o!=null?{finalMessages:u,equalsError:o}:{finalMessages:u}}_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(rr()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],He(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}Rt(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);Rt(this._deliverToSinks,t,this._config.tierOf)}},fr=r=>Array.isArray(r),an=r=>typeof r=="object"&&r!=null&&!Array.isArray(r)});function F(r,e){return he([],{...e,initial:r})}function Ce(r,e){return he((n,o,s)=>r(o,s)??void 0,{describeKind:"producer",...e})}function J(r,e,t){return he(r,(o,s,a)=>{let i=o.map((d,u)=>d!=null&&d.length>0?d.at(-1):a.prevData[u]);s.emit(e(i,a))},{describeKind:"derived",...t})}function dn(r,e,t){let n=new Map;return r.forEach((o,s)=>{n.set(o,s)}),J(r,(o,s)=>e(i=>{let d=n.get(i);if(d==null)throw new Error(`dynamicNode: untracked dep "${i.name??"<unnamed>"}"`);return o[d]},s),t)}function it(r,e){let t,n=new Map,o=(s,a,i)=>{let d=!1,u=c=>{let l=n.get(c);if(l!==void 0){if(l<s.length){let h=s[l];return h!=null&&h.length>0?h.at(-1):i.prevData[l]}return c.cache}d=!0;let p=t._addDep(c);return n.set(c,p),c.cache};try{let c=r(u,i);d||(a.emit(c),i.store.__autoTrackLastDiscoveryError!=null&&delete i.store.__autoTrackLastDiscoveryError)}catch(c){if(!d)throw c;i.store.__autoTrackLastDiscoveryError=c}};return t=new H([],o,{describeKind:"derived",...e}),t}var fe=U(()=>{"use strict";Ae()});function ut(r,e,t){let n=new Set;for(let o of r.split(",")){let[s,a]=o.split("/"),i=a?Number.parseInt(a,10):1;if(Number.isNaN(i)||i<1)throw new Error(`Invalid cron step: ${o}`);let d,u;if(s==="*")d=e,u=t;else if(s.includes("-")){let[c,l]=s.split("-");d=Number.parseInt(c,10),u=Number.parseInt(l,10)}else d=Number.parseInt(s,10),u=d;if(Number.isNaN(d)||Number.isNaN(u))throw new Error(`Invalid cron field: ${r}`);if(d<e||u>t)throw new Error(`Cron field out of range: ${r} (${e}-${t})`);if(d>u)throw new Error(`Invalid cron range: ${d}-${u} in ${r}`);for(let c=d;c<=u;c+=i)n.add(c)}return n}function kr(r){let e=r.trim().split(/\s+/);if(e.length!==5)throw new Error(`Invalid cron: expected 5 fields, got ${e.length}`);return{minutes:ut(e[0],0,59),hours:ut(e[1],0,23),daysOfMonth:ut(e[2],1,31),months:ut(e[3],1,12),daysOfWeek:ut(e[4],0,6)}}function Ar(r,e){return r.minutes.has(e.getMinutes())&&r.hours.has(e.getHours())&&r.daysOfMonth.has(e.getDate())&&r.months.has(e.getMonth()+1)&&r.daysOfWeek.has(e.getDay())}var Cr=U(()=>{"use strict"});function Mr(r){return{describeKind:"producer",...r}}function Dr(r,e){let{signal:t,period:n,...o}=e??{};return Ce(s=>{let a=!1,i=0,d,u,c=()=>{a=!0,d!==void 0&&clearTimeout(d),u!==void 0&&clearInterval(u),t?.removeEventListener("abort",p)},l=()=>{a||(n!=null?(s.emit(i++),u=setInterval(()=>{a||s.emit(i++)},n)):(a=!0,t?.removeEventListener("abort",p),s.emit(i++),s.down([[I]])))},p=()=>{a||(c(),s.down([[D,t.reason]]))};if(t?.aborted){p();return}return d=setTimeout(l,r),t?.addEventListener("abort",p,{once:!0}),c},Mr(o))}function Gr(r,e){let t=kr(r),{tickMs:n,output:o,...s}=e??{},a=n??6e4,i=o==="date";return Ce(d=>{let u=-1,c=()=>{let p=new Date,h=p.getFullYear()*1e8+(p.getMonth()+1)*1e6+p.getDate()*1e4+p.getHours()*100+p.getMinutes();h!==u&&Ar(t,p)&&(u=h,d.emit(i?p:se()))};c();let l=setInterval(c,a);return()=>clearInterval(l)},{...Mr(s),name:s.name??`cron:${r}`})}function ge(r){return r.subscribe(()=>{})}var Ir=U(()=>{"use strict";qe();K();fe();Cr()});var At=U(()=>{"use strict";Ir()});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 Yo(r){return r._describeKind!=null?r._describeKind:r._deps.length>0?"derived":r._fn!=null?"producer":"state"}function yn(r){let e=new WeakSet,t={};for(let[n,o]of qr(r))t[n]=mn(o,e);return t}function mn(r,e){if(r==null)return r;let t=typeof r;if(t==="boolean"||t==="number"||t==="string")return r;if(t==="function")return"<function>";if(Array.isArray(r))return e.has(r)?"<cycle>":(e.add(r),r.map(n=>mn(n,e)));if(t==="object"){let n=r;if(e.has(n))return"<cycle>";e.add(n);try{if(typeof n.subscribe=="function"&&"cache"in n)return"<Node>"}catch{return"<unserializable>"}let o={};for(let[s,a]of qr(n))o[s]=mn(a,e);return o}return"<unserializable>"}function qr(r){let e=[],t;try{t=Object.keys(r)}catch{return e}for(let n of t)try{e.push([n,r[n]])}catch{e.push([n,"<unserializable>"])}return e}function Jo(r){let e={};for(let[t,n]of Object.entries(r.meta))try{e[t]=n.cache}catch{}return e}function bn(r,e,t){let n=e==null,o=!n&&e!=null?[...e].filter(c=>c.startsWith("meta.")).map(c=>c.slice(5)):null,s=n||e.has("meta")||o!=null&&o.length>0,a="state",i=[];r instanceof H&&(a=Yo(r),i=r._deps.map(c=>c.node.name??""));let d={type:a,deps:i};(n||e.has("status"))&&(d.status=r.status);let u=r instanceof H?r._guard:void 0;if(s){let c={...Jo(r)};if(u!=null&&c.access===void 0&&(c.access=tn(u)),o!=null&&o.length>0&&!e.has("meta")){let l={};for(let p of o)p in c&&(l[p]=c[p]);d.meta=l}else d.meta=c}if(r.name!=null&&(d.name=r.name),(n||e.has("value"))&&(!t||a==="state")){r.status==="sentinel"&&(d.sentinel=!0);try{d.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),d.v=c}return(n||e.has("guard"))&&u!=null&&(d.guard=tn(u)),(n||e.has("lastMutation"))&&r.lastMutation!=null&&(d.lastMutation=r.lastMutation),d}var vn=U(()=>{"use strict";Se();Ae()});var It,zr=U(()=>{"use strict";It=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 lt,Wr=U(()=>{"use strict";lt=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 uo(r,e,t){return{[r]:!0,[`${r}_type`]:e,...t??{}}}var co=U(()=>{"use strict"});var Cs={};ce(Cs,{jotai:()=>un,nanostores:()=>ln,nestjs:()=>Cn,react:()=>Mn,signals:()=>In,solid:()=>Pn,svelte:()=>Ln,vue:()=>$n,zustand:()=>Fn});module.exports=wo(Cs);var un={};ce(un,{atom:()=>Lo});K();fe();function Lo(r,e,t){if(typeof r=="function"){let n=r;return typeof e=="function"?pr(n,e,t):pr(n,void 0,e)}return $o(r,e)}function at(r){let e=r.cache,t;if(r.subscribe(o=>{for(let[s,a]of o)s===O&&(e=a),s===D&&(t=a)})(),t)throw t;return e}function $o(r,e){let t=F(r,{...e,resubscribable:!0,resetOnTeardown:!0});return{get:()=>t.status==="sentinel"?at(t):t.cache,set:n=>t.emit(n),update:n=>{let o=t.status==="sentinel"?at(t):t.cache;t.emit(n(o))},subscribe:n=>{let o=!0;return t.subscribe(s=>{for(let[a,i]of s)if(a===O){if(o){o=!1;continue}n(i)}})},meta:t.meta,_node:t}}function pr(r,e,t){let n=it(s=>r(a=>{let i=a._node;return i.status==="sentinel"&&at(i),s(i)}),{...t,resubscribable:!0,resetOnTeardown:!0}),o={get:()=>n.status==="sentinel"?at(n):n.cache,subscribe:s=>{let a=!0;return n.subscribe(i=>{for(let[d,u]of i)if(d===O){if(a){a=!1;continue}s(u)}})},meta:n.meta,_node:n};if(e){let s=d=>d.get(),a=(d,u)=>d.set(u),i=o;return i.set=d=>e(s,a,d),i.update=d=>{let u=n.status==="sentinel"?at(n):n.cache;return e(s,a,d(u))},i}return o}var ln={};ce(ln,{action:()=>zo,atom:()=>Fo,computed:()=>Vo,getValue:()=>qo,map:()=>Ho,onMount:()=>jo,onStart:()=>mr,onStop:()=>yr});Ne();K();fe();var St=new WeakMap,kt=new WeakMap;function Nt(r,e){let t=e.get(r);if(t)for(let n of t)n()}function cn(r,e={}){let t=0;return{...e,get:()=>gr(r),subscribe:o=>{t===0&&Nt(r,St),t++;let s=r.subscribe(a=>{for(let[i,d]of a)i===O&&o(d)});return()=>{s(),t--,t===0&&Nt(r,kt)}},listen:o=>{t===0&&Nt(r,St),t++;let s=!0,a=r.subscribe(i=>{for(let[d,u]of i)if(d===O){if(s){s=!1;continue}o(u)}});return()=>{a(),t--,t===0&&Nt(r,kt)}},_node:r}}function hr(r){let e=r.cache,t;if(r.subscribe(o=>{for(let[s,a]of o)s===O&&(e=a),s===D&&(t=a)})(),t)throw t;return e}function gr(r){return r.status==="sentinel"?hr(r):r.cache}function Fo(r){let e=F(r,{resubscribable:!0,resetOnTeardown:!0});return cn(e,{set:t=>e.emit(t)})}function Vo(r,e){let t=Array.isArray(r)?r:[r],n=t.map(s=>s._node),o=dn(n,s=>{let a=t.map(i=>{let d=i._node;return d.status==="sentinel"&&hr(d),s(d)});return e(...a)},{resubscribable:!0,resetOnTeardown:!0,equals:Object.is});return cn(o)}function Ho(r){let e=F(r,{resubscribable:!0,resetOnTeardown:!0,equals:()=>!1});return cn(e,{set:t=>e.emit(t),setKey:(t,n)=>{let o=gr(e);e.emit({...o,[t]:n})}})}function qo(r){return r.get()}function mr(r,e){let t=r._node,n=St.get(t);n||(n=new Set,St.set(t,n)),n.add(e)}function yr(r,e){let t=r._node,n=kt.get(t);n||(n=new Set,kt.set(t,n)),n.add(e)}function jo(r,e){mr(r,()=>{let t=e();typeof t=="function"&&yr(r,t)})}function zo(r,e,t){return(...n)=>{let o;return le(()=>{o=t(...n)}),o}}var Cn={};ce(Cn,{ACTOR_KEY:()=>Dt,COMMAND_HANDLERS:()=>Ke,CQRS_EVENT_HANDLERS:()=>Ue,CRON_HANDLERS:()=>Be,CommandHandler:()=>Er,EVENT_HANDLERS:()=>ze,EventHandler:()=>Or,GRAPHREFLY_REQUEST_GRAPH:()=>Me,GRAPHREFLY_ROOT_GRAPH:()=>ae,GraphCron:()=>Rr,GraphInterval:()=>xr,GraphReflyEventExplorer:()=>De,GraphReflyGuard:()=>Hr,GraphReflyGuardImpl:()=>ct,GraphReflyModule:()=>Wt,INTERVAL_HANDLERS:()=>We,InjectCqrsGraph:()=>_r,InjectGraph:()=>vr,InjectNode:()=>Tr,ObserveGateway:()=>Mt,OnGraphEvent:()=>wr,QUERY_HANDLERS:()=>Ye,QueryHandler:()=>Nr,SAGA_HANDLERS:()=>Je,SagaHandler:()=>Sr,fromHeader:()=>Fr,fromJwtPayload:()=>gn,getActor:()=>Vr,getGraphToken:()=>Q,getNodeToken:()=>ue,observeSSE:()=>Lr,observeSubscription:()=>$r,toObservable:()=>br});var fn=require("rxjs");K();function br(r,e){return e?.raw?new fn.Observable(t=>r.subscribe(o=>{if(!t.closed){t.next(o);for(let s of o){if(s[0]===D){t.error(s[1]);return}if(s[0]===I){t.complete();return}}}})):new fn.Observable(t=>r.subscribe(o=>{for(let s of o){if(t.closed)return;if(s[0]===O)t.next(s[1]);else if(s[0]===D){t.error(s[1]);return}else if(s[0]===I){t.complete();return}}}))}var dt=require("@nestjs/common");var ae=Symbol.for("graphrefly:root-graph");var Me=Symbol.for("graphrefly:request-graph");function Q(r){return Symbol.for(`graphrefly:graph:${r}`)}function ue(r){return Symbol.for(`graphrefly:node:${r}`)}var ze=new Map,We=new Map,Be=new Map,Ke=new Map,Ue=new Map,Ye=new Map,Je=new Map;function vr(r){return r==="request"?(0,dt.Inject)(Me):(0,dt.Inject)(r?Q(r):ae)}function _r(r){return(0,dt.Inject)(Q(r))}function Tr(r){return(0,dt.Inject)(ue(r))}function wr(r){return(e,t)=>{let n=t.name;t.addInitializer(function(){let o=this.constructor,s=ze.get(o)??[];s.push({nodeName:r,methodKey:n}),ze.set(o,s)})}}function xr(r){return(e,t)=>{let n=t.name;t.addInitializer(function(){let o=this.constructor,s=We.get(o)??[];s.push({ms:r,methodKey:n}),We.set(o,s)})}}function Rr(r){return(e,t)=>{let n=t.name;t.addInitializer(function(){let o=this.constructor,s=Be.get(o)??[];s.push({expr:r,methodKey:n}),Be.set(o,s)})}}function Er(r,e){return(t,n)=>{let o=n.name;n.addInitializer(function(){let s=this.constructor,a=Ke.get(s)??[];a.push({cqrsName:r,commandName:e,methodKey:o}),Ke.set(s,a)})}}function Or(r,e){return(t,n)=>{let o=n.name;n.addInitializer(function(){let s=this.constructor,a=Ue.get(s)??[];a.push({cqrsName:r,eventName:e,methodKey:o}),Ue.set(s,a)})}}function Nr(r,e){return(t,n)=>{let o=n.name;n.addInitializer(function(){let s=this.constructor,a=Ye.get(s)??[];a.push({cqrsName:r,projectionName:e,methodKey:o}),Ye.set(s,a)})}}function Sr(r,e,t){return(n,o)=>{let s=o.name;o.addInitializer(function(){let a=this.constructor,i=Je.get(a)??[];i.push({cqrsName:r,eventNames:t,sagaName:e,methodKey:s}),Je.set(a,i)})}}K();At();var Pr=0,De=class{constructor(e,t){this.graph=e;this.moduleRef=t}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,t]of ze){let n=this.resolveInstance(e);if(n)for(let o of t)this.wireEventHandler(n,o)}}wireEventHandler(e,t){let n=e[t.methodKey];if(typeof n!="function")return;let o=n.bind(e),a=this.observeNode(t.nodeName).subscribe(i=>{for(let d of i)d[0]===O&&o(d[1])});this.disposers.push(a)}wireIntervals(){for(let[e,t]of We){let n=this.resolveInstance(e);if(n)for(let o of t)this.wireIntervalHandler(n,e,o)}}wireIntervalHandler(e,t,n){let o=e[n.methodKey];if(typeof o!="function")return;let s=o.bind(e),i=`__schedule__.${t.name??"anonymous"}.${String(n.methodKey)}.${Pr++}`,d=Dr(n.ms,{period:n.ms,name:i});this.graph.add(d),this.scheduleNodeNames.push(i);let c=this.observeNode(i).subscribe(l=>{for(let p of l)p[0]===O&&s(p[1])});this.disposers.push(c)}wireCrons(){for(let[e,t]of Be){let n=this.resolveInstance(e);if(n)for(let o of t)this.wireCronHandler(n,e,o)}}wireCronHandler(e,t,n){let o=e[n.methodKey];if(typeof o!="function")return;let s=o.bind(e),i=`__schedule__.${t.name??"anonymous"}.${String(n.methodKey)}.${Pr++}`,d=Gr(n.expr,{name:i});this.graph.add(d),this.scheduleNodeNames.push(i);let c=this.observeNode(i).subscribe(l=>{for(let p of l)p[0]===O&&s(p[1])});this.disposers.push(c)}wireCqrsCommands(){for(let[e,t]of Ke){let n=this.resolveInstance(e);if(n)for(let o of t)this.wireCqrsCommand(n,o)}}wireCqrsCommand(e,t){let n=e[t.methodKey];if(typeof n!="function")return;let o=n.bind(e),s=this.resolveCqrsGraph(t.cqrsName);s&&s.command(t.commandName,o)}wireCqrsEvents(){for(let[e,t]of Ue){let n=this.resolveInstance(e);if(n)for(let o of t)this.wireCqrsEventHandler(n,o)}}wireCqrsEventHandler(e,t){let n=e[t.methodKey];if(typeof n!="function")return;let o=n.bind(e),s=this.resolveCqrsGraph(t.cqrsName);if(!s)return;s.event(t.eventName);let i=s.resolve(t.eventName).cache,d=i&&i.length>0?i[i.length-1].seq:0,c=this.observeNodeOn(s,t.eventName).subscribe(l=>{for(let p of l)if(p[0]===O){let h=p[1];for(let f of h)f.seq>d&&(o(f),d=f.seq)}});this.disposers.push(c)}wireCqrsQueries(){for(let[e,t]of Ye){let n=this.resolveInstance(e);if(n)for(let o of t)this.wireCqrsQuery(n,o)}}wireCqrsQuery(e,t){let n=e[t.methodKey];if(typeof n!="function")return;let o=n.bind(e),s=this.resolveCqrsGraph(t.cqrsName);if(!s)return;let i=this.observeNodeOn(s,t.projectionName).subscribe(d=>{for(let u of d)u[0]===O&&o(u[1])});this.disposers.push(i)}wireCqrsSagas(){for(let[e,t]of Je){let n=this.resolveInstance(e);if(n)for(let o of t)this.wireCqrsSaga(n,o)}}wireCqrsSaga(e,t){let n=e[t.methodKey];if(typeof n!="function")return;let o=n.bind(e),s=this.resolveCqrsGraph(t.cqrsName);s&&s.saga(t.sagaName,t.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,t){return e.observe(t)}resolveCqrsGraph(e){try{return this.moduleRef.get(Q(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};K();K();var Wo=0;function Ct(r,e){if(e.highWaterMark<1)throw new RangeError("highWaterMark must be >= 1");if(e.lowWaterMark<0)throw new RangeError("lowWaterMark must be >= 0");if(e.lowWaterMark>=e.highWaterMark)throw new RangeError("lowWaterMark must be < highWaterMark");let t=Symbol(`bp-${++Wo}`),n=0,o=!1;return{onEnqueue(){return n+=1,!o&&n>=e.highWaterMark?(o=!0,r([[ee,t]]),!0):!1},onDequeue(){return n>0&&(n-=1),o&&n<=e.lowWaterMark?(o=!1,r([[oe,t]]),!0):!1},get pending(){return n},get paused(){return o},dispose(){o&&(o=!1,r([[oe,t]]))}}}function Lr(r,e,t){let{actor:n,serialize:o=Bo,keepAliveMs:s,signal:a}=t??{},i=new TextEncoder,d,u=t?.highWaterMark!=null,c,l,p=[],h=!1;return new ReadableStream({start(f){let m,g=()=>{},x=()=>{if(!h){h=!0,m!==void 0&&clearInterval(m),a?.removeEventListener("abort",v),g(),c?.dispose(),l?.(),l=void 0;for(let b of p)f.enqueue(b.frame);p.length=0,f.close()}};d=x;let v=()=>x(),_=r.observe(e,{actor:n});u&&(c=Ct(b=>_.up(b),{highWaterMark:t.highWaterMark,lowWaterMark:t.lowWaterMark??Math.floor(t.highWaterMark/2)})),g=_.subscribe(b=>{for(let T of b){if(h)return;let N=T[0];if(N===O){let y=i.encode(pn("data",o(T[1])));u?(p.push({frame:y,counted:!0}),c.onEnqueue(),l?.(),l=void 0):f.enqueue(y)}else if(N===D){let y=i.encode(pn("error",o(T[1])));u?(p.push({frame:y,counted:!1}),l?.(),l=void 0):f.enqueue(y),x();return}else if(N===I||N===V){if(N===I){let y=i.encode(pn("complete"));u?(p.push({frame:y,counted:!1}),l?.(),l=void 0):f.enqueue(y)}x();return}}}),s!==void 0&&s>0&&(m=setInterval(()=>{h||(u?(p.push({frame:i.encode(`: keepalive
2
2
 
3
- `),counted:!1}),l?.(),l=void 0):f.enqueue(a.encode(`: keepalive
3
+ `),counted:!1}),l?.(),l=void 0):f.enqueue(i.encode(`: keepalive
4
4
 
5
- `)))},s)),i?.aborted?_():i?.addEventListener("abort",_,{once:!0})},pull(f){if(u&&!h){if(p.length>0){let y=p.shift();f.enqueue(y.frame),y.counted&&c.onDequeue();return}return new Promise(y=>{l=y})}},cancel(){try{d?.()}catch{}}})}function Vr(t,e,n){let{actor:r,filter:o}=n??{},s=[],i=[],a=!1,d=t.observe(e,{actor:r}),u=n?.highWaterMark!=null?Ct(f=>d.up(f),{highWaterMark:n.highWaterMark,lowWaterMark:n.lowWaterMark??Math.floor(n.highWaterMark/2)}):void 0,c=()=>{a||(a=!0,u?.dispose(),p())},l=f=>{if(!a)if(i.length>0){let y=i.shift();f.done&&f.error?y.reject(f.error):f.done?y.resolve({done:!0,value:void 0}):y.resolve({done:!1,value:f.value})}else s.push(f),f.done||u?.onEnqueue()},p=d.subscribe(f=>{for(let y of f){let m=y[0];if(m===C){let w=y[1];if(o&&!o(w))continue;l({done:!1,value:w})}else if(m===D){let w=y[1]instanceof Error?y[1]:new Error(String(y[1]));l({done:!0,error:w}),c();return}else if(m===P||m===q){l({done:!0}),c();return}}});return{next(){if(s.length>0){let f=s.shift();return f.done||u?.onDequeue(),f.done&&f.error?Promise.reject(f.error):Promise.resolve(f.done?{done:!0,value:void 0}:{done:!1,value:f.value})}return a?Promise.resolve({done:!0,value:void 0}):new Promise((f,y)=>{i.push({resolve:f,reject:y})})},return(){c();for(let f of i)f.resolve({done:!0,value:void 0});return i.length=0,Promise.resolve({done:!0,value:void 0})},throw(f){return c(),Promise.reject(f)},[Symbol.asyncIterator](){return this}}}var Mt=class{constructor(e,n){this.graph=e;this.extractActor=n?.extractActor??(()=>{}),this.parse=n?.parse??as,this.highWaterMark=n?.highWaterMark,this.lowWaterMark=n?.lowWaterMark}clients=new Map;extractActor;parse;highWaterMark;lowWaterMark;handleConnection(e){this.clients.has(e)||this.clients.set(e,new Map)}handleDisconnect(e){let n=this.clients.get(e);if(n){for(let r of n.values())r.wm?.dispose(),r.unsub();this.clients.delete(e)}}handleMessage(e,n,r){let o=r??us.bind(null,e),s;try{s=typeof n=="string"?this.parse(n):n}catch{o({type:"err",message:"invalid command"});return}s.type==="subscribe"?this.subscribe(e,s.path,o):s.type==="unsubscribe"?this.unsubscribe(e,s.path,o):s.type==="ack"?this.ack(e,s.path,s.count??1):o({type:"err",message:`unknown command type: ${s.type}`})}subscriptionCount(e){return this.clients.get(e)?.size??0}destroy(){for(let[e]of this.clients)this.handleDisconnect(e)}subscribe(e,n,r){let o=this.clients.get(e);if(o||(o=new Map,this.clients.set(e,o)),o.has(n)){r({type:"subscribed",path:n});return}let s=this.extractActor(e),i;try{i=this.graph.observe(n,{actor:s})}catch(c){let l=c instanceof Error?c.message:String(c);r({type:"err",message:l});return}let a=this.highWaterMark!=null?Ct(c=>i.up(c),{highWaterMark:this.highWaterMark,lowWaterMark:this.lowWaterMark??Math.floor(this.highWaterMark/2)}):void 0,d=()=>{a?.dispose(),u(),o.delete(n)},u=i.subscribe(c=>{for(let l of c){let p=l[0];if(p===C)a?.onEnqueue(),yn(r,{type:"data",path:n,value:l[1]});else if(p===D){let h=l[1]instanceof Error?l[1].message:String(l[1]);yn(r,{type:"error",path:n,error:h}),d();return}else if(p===P||p===q){yn(r,{type:"complete",path:n}),d();return}}});o.set(n,{unsub:u,wm:a}),r({type:"subscribed",path:n})}unsubscribe(e,n,r){let o=this.clients.get(e),s=o?.get(n);s&&(s.wm?.dispose(),s.unsub(),o.delete(n)),r({type:"unsubscribed",path:n})}ack(e,n,r){let o=this.clients.get(e)?.get(n);if(!o?.wm)return;let s=Math.min(Math.max(0,Math.floor(r)),1024);for(let i=0;i<s;i++)o.wm.onDequeue()}};function is(t){if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function mn(t,e){let n=`event: ${t}
6
- `;if(e!==void 0)for(let r of e.split(`
7
- `))n+=`data: ${r}
8
- `;return n+=`
9
- `,n}function as(t){return JSON.parse(t)}function us(t,e){try{t.send(JSON.stringify(e))}catch{}}function yn(t,e){try{t(e)}catch{}}nt();var Dt="graphReflyActor";function bn(t){return e=>{let r=e.switchToHttp().getRequest()?.user;if(r!=null)return t?t(r):r}}function jr(t="x-graphrefly-actor"){return e=>{let r=e.switchToHttp().getRequest()?.headers?.[t.toLowerCase()];if(!(typeof r!="string"||r.length===0))try{return JSON.parse(r)}catch{return}}}function qr(t){let e=t?.[Dt];return e!=null?Re(e):be}var dt=class{constructor(e){this.extractor=e}canActivate(e){let n=Re(this.extractor(e)),r=e.switchToHttp().getRequest();return r!=null&&(r[Dt]=n),!0}};function zr(t){return new dt(t??bn())}var yt=require("@nestjs/common"),Ao=require("@nestjs/core");nt();Se();Ve();Ae();K();wn();ke();fe();Ve();function xn(t,e){if(Object.is(t,e))return!0;if(t==null||e==null||typeof t!="object"||typeof e!="object")return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(!xn(t[s],e[s]))return!1;return!0}if(Array.isArray(e))return!1;let n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;let o=new Set(r);for(let s of n)if(!o.has(s)||!xn(t[s],e[s]))return!1;return!0}function Wr(t,e){return`${t}\0${e}`}function Rn(t,e){let n=[],r=new Set(t.subgraphs),o=new Set(e.subgraphs),s=[];for(let m of o)r.has(m)||s.push(m);s.sort();for(let m of s)n.push({type:"subgraph-mounted",path:m});let i=new Set(Object.keys(t.nodes)),a=new Set(Object.keys(e.nodes)),d=[];for(let m of a)i.has(m)||d.push(m);d.sort();for(let m of d)n.push({type:"node-added",path:m,node:{...e.nodes[m]}});let u=[];for(let m of a){if(!i.has(m))continue;let w=t.nodes[m]?.meta,_=e.nodes[m]?.meta;w==null&&_==null||xn(w??{},_??{})||u.push(m)}u.sort();for(let m of u)n.push({type:"node-meta-changed",path:m,prevMeta:t.nodes[m]?.meta??{},nextMeta:e.nodes[m]?.meta??{}});let c=new Map;for(let m of t.edges)c.set(Wr(m.from,m.to),m);let l=new Map;for(let m of e.edges)l.set(Wr(m.from,m.to),m);let p=[];for(let[m,w]of l)c.has(m)||p.push(w);p.sort((m,w)=>m.from<w.from?-1:m.from>w.from?1:m.to<w.to?-1:m.to>w.to?1:0);for(let m of p)n.push({type:"edge-added",from:m.from,to:m.to});let h=[];for(let[m,w]of c)l.has(m)||h.push(w);h.sort((m,w)=>m.from<w.from?-1:m.from>w.from?1:m.to<w.to?-1:m.to>w.to?1:0);for(let m of h)n.push({type:"edge-removed",from:m.from,to:m.to});let f=[];for(let m of i)a.has(m)||f.push(m);f.sort();for(let m of f)n.push({type:"node-removed",path:m});let y=[];for(let m of r)o.has(m)||y.push(m);y.sort();for(let m of y)n.push({type:"subgraph-unmounted",path:m});return{events:n,flushedAt_ns:he()}}kt();Kr();var lt=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 n=(this.head+this._size)%this.capacity;this.buf[n]=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 n=e<0?this._size+e:e;if(!(n<0||n>=this._size))return this.buf[(this.head+n)%this.capacity]}toArray(){let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this.buf[(this.head+n)%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}};rn();function En(t){return t>=768&&t<=879||t>=1155&&t<=1161||t>=1425&&t<=1469||t>=1552&&t<=1562||t>=1611&&t<=1631||t>=1648&&t===1648||t>=1750&&t<=1756||t>=1759&&t<=1764||t>=1767&&t<=1768||t>=1770&&t<=1773||t>=1840&&t<=1866||t>=1958&&t<=1968||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2641||t>=2672&&t<=2673||t>=2677&&t===2677||t>=3633&&t===3633||t>=3636&&t<=3642||t>=3655&&t<=3662||t>=3761&&t===3761||t>=3764&&t<=3772||t>=3784&&t<=3790||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65024&&t<=65039||t>=65056&&t<=65071||t===8205?0:t>=4352&&t<=4447||t>=8986&&t<=8987||t>=9001&&t<=9002||t>=9193&&t<=9203||t>=9208&&t<=9210||t>=9725&&t<=9726||t>=9748&&t<=9749||t>=9800&&t<=9811||t===9855||t===9875||t===9889||t>=9898&&t<=9899||t>=9917&&t<=9918||t>=9924&&t<=9925||t===9934||t===9940||t===9962||t>=9970&&t<=9971||t===9973||t===9978||t===9981||t===9986||t===9989||t>=9992&&t<=9997||t===9999||t>=10067&&t<=10069||t===10071||t>=10133&&t<=10135||t===10160||t===10175||t>=10548&&t<=10549||t>=11013&&t<=11015||t>=11035&&t<=11036||t===11088||t===11093||t>=11904&&t<=12350||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12784&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=19968&&t<=40959||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65131||t>=65281&&t<=65376||t>=65504&&t<=65510||t>=126980&&t===126980||t===127183||t>=127344&&t<=127345||t===127358||t===127359||t===127374||t>=127377&&t<=127386||t>=127456&&t<=127487||t>=127488&&t<=127490||t===127514||t===127535||t>=127538&&t<=127546||t>=127568&&t<=127569||t>=127744&&t<=129535||t>=129536&&t<=129791||t>=129792&&t<=130047||t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}function It(t){let e=0;for(let n of t)e+=En(n.codePointAt(0));return e}function Ur(t,e){if(e<=0)return"";let n=0,r="";for(let o of t){let s=En(o.codePointAt(0));if(n+s>e){if(e<=1)return"\u2026";for(;n+1>e&&r.length>0;){let i=[...r].pop();r=r.slice(0,-i.length),n-=En(i.codePointAt(0))}return`${r}\u2026`}r+=o,n+=s}return r}var ls={horizontal:"\u2500",vertical:"\u2502",cornerTL:"\u250C",cornerTR:"\u2510",cornerBL:"\u2514",cornerBR:"\u2518",tDown:"\u252C",tUp:"\u2534",tRight:"\u251C",tLeft:"\u2524",cross:"\u253C",arrowRight:"\u25B6",arrowDown:"\u25BC",arrowLeft:"\u25C0",arrowUp:"\u25B2",boxTL:"\u250C",boxTR:"\u2510",boxBL:"\u2514",boxBR:"\u2518",boxH:"\u2500",boxV:"\u2502"},fs={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function Xr(t,e){let n=e.charset==="ascii"?fs:ls,r=t.width,o=t.height,s=Array.from({length:o},()=>Array.from({length:r},()=>" ")),i=Array.from({length:o},()=>Array.from({length:r},()=>"empty"));for(let a of t.edges)hs(s,i,n,a);for(let a of t.boxes)ps(s,i,n,a,e.labelOf(a.id));return s.map(a=>bs(a.join(""))).join(`
10
- `)}function ps(t,e,n,r,o){let{x:s,y:i,w:a,h:d}=r;if(a<2||d<2){d>0&&Yr(t,e,s,i,a,o);return}ve(t,e,s,i,n.boxTL);for(let c=s+1;c<s+a-1;c+=1)ve(t,e,c,i,n.boxH);ve(t,e,s+a-1,i,n.boxTR);for(let c=i+1;c<i+d-1;c+=1){ve(t,e,s,c,n.boxV);for(let l=s+1;l<s+a-1;l+=1)Zr(t,e,l,c," ","empty");ve(t,e,s+a-1,c,n.boxV)}ve(t,e,s,i+d-1,n.boxBL);for(let c=s+1;c<s+a-1;c+=1)ve(t,e,c,i+d-1,n.boxH);ve(t,e,s+a-1,i+d-1,n.boxBR);let u=i+Math.floor(d/2);Yr(t,e,s+1,u,a-2,o)}function ve(t,e,n,r,o){Zr(t,e,n,r,o,o===" "?"empty":o==="\u2500"||o==="-"?"boxH":o==="\u2502"||o==="|"?"boxV":"boxCorner")}function Zr(t,e,n,r,o,s){if(r<0||r>=t.length)return;let i=t[r];n<0||n>=i.length||(i[n]=o,e[r][n]=s)}function Yr(t,e,n,r,o,s){if(r<0||r>=t.length)return;let i=n,a=o;for(let d of s){let u=It(d);if(u!==0){if(a<u)break;i>=0&&i<t[r].length&&(t[r][i]=d,e[r][i]="label",u===2&&i+1<t[r].length&&(t[r][i+1]="",e[r][i+1]="label")),i+=u,a-=u}}for(;a>0;)i>=0&&i<t[r].length&&(t[r][i]=" ",e[r][i]="empty"),i+=1,a-=1}function hs(t,e,n,r){let o=r.points;if(o.length<2)return;for(let d=0;d+1<o.length;d+=1)gs(t,e,n,o[d],o[d+1]);for(let d=1;d+1<o.length;d+=1){let u=o[d-1],c=o[d],l=o[d+1],p=ms(u,c,l,n);p&&Qr(t,e,c.x,c.y,p,"edgeCorner")}let s=o[o.length-1],i=o[o.length-2],a=ys(i,s,n);a&&Qr(t,e,s.x,s.y,a,"arrow")}function gs(t,e,n,r,o){if(!(r.x===o.x&&r.y===o.y)){if(r.y===o.y){let s=r.y,i=Math.min(r.x,o.x),a=Math.max(r.x,o.x);for(let d=i;d<=a;d+=1)Jr(t,e,d,s,n,"h")}else if(r.x===o.x){let s=r.x,i=Math.min(r.y,o.y),a=Math.max(r.y,o.y);for(let d=i;d<=a;d+=1)Jr(t,e,s,d,n,"v")}}}function Jr(t,e,n,r,o,s){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];if(!(a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label")){if(a==="empty"){i[n]=s==="h"?o.horizontal:o.vertical,e[r][n]=s==="h"?"edgeH":"edgeV";return}if(a==="edgeH"&&s==="v"){i[n]=o.cross,e[r][n]="edgeCorner";return}if(a==="edgeV"&&s==="h"){i[n]=o.cross,e[r][n]="edgeCorner";return}}}function Qr(t,e,n,r,o,s){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label"||(i[n]=o,e[r][n]=s)}function ms(t,e,n,r){let o=t.y===e.y,s=e.y===n.y;if(o===s)return;if(o){let d=t.x<e.x,u=n.y>e.y;return d&&u?r.cornerTR:d&&!u?r.cornerBR:!d&&u?r.cornerTL:r.cornerBL}let i=t.y<e.y,a=n.x>e.x;return i&&a?r.cornerBL:i&&!a?r.cornerBR:!i&&a?r.cornerTL:r.cornerTR}function ys(t,e,n){if(e.x>t.x)return n.arrowRight;if(e.x<t.x)return n.arrowLeft;if(e.y>t.y)return n.arrowDown;if(e.y<t.y)return n.arrowUp}function bs(t){let e=t.length;for(;e>0&&t.charCodeAt(e-1)===32;)e-=1;return t.slice(0,e)}function no(t){let e=vs(t);_s(e),Ts(e),ws(e),xs(e,t);let n=Os(e,t),{width:r,height:o}=As(e),s=[];for(let i of e.layers)for(let a of i)a.isVirtual||s.push({id:a.id,layer:a.layer,order:a.order,x:a.x,y:a.y,w:a.w,h:a.h});return{boxes:s,edges:n,width:r,height:o}}function vs(t){let e=new Map;for(let o of t.nodes)e.set(o,{id:o,isVirtual:!1,layer:-1,order:0,x:0,y:0,w:t.widthCells(o),h:t.heightCells(o),in:[],out:[]});let n=[],r=0;for(let o of t.edges){if(o.from===o.to)continue;let s=e.get(o.from),i=e.get(o.to);if(!s||!i)continue;let a={chainId:r++,chainFrom:o.from,chainTo:o.to,fromId:o.from,toId:o.to,hopIndex:0,chainLen:1};s.out.push(a),i.in.push(a),n.push(a)}return{nodes:e,layers:[],hops:n}}function _s(t){let e=new Map;for(let s of t.nodes.values())e.set(s.id,s.in.length);let n=[];for(let s of t.nodes.values())(e.get(s.id)??0)===0&&(s.layer=0,n.push(s));let r=new Set,o=0;for(;o<n.length;){let s=n[o++];if(!r.has(s.id)){r.add(s.id);for(let i of s.out){let a=t.nodes.get(i.toId);a.layer=Math.max(a.layer,s.layer+1);let d=(e.get(a.id)??0)-1;e.set(a.id,d),d<=0&&n.push(a)}}}for(let s of t.nodes.values())s.layer<0&&(s.layer=0)}function Ts(t){let e=Math.max(0,...Array.from(t.nodes.values(),s=>s.layer)),n=Array.from({length:e+1},()=>[]);for(let s of t.nodes.values())n[s.layer].push(s);let r=[],o=0;for(let s of t.hops){let i=t.nodes.get(s.fromId),a=t.nodes.get(s.toId),d=a.layer-i.layer;if(d<=0){i.out=i.out.filter(l=>l!==s),a.in=a.in.filter(l=>l!==s);continue}if(d===1){s.hopIndex=0,s.chainLen=1,r.push(s);continue}i.out=i.out.filter(l=>l!==s),a.in=a.in.filter(l=>l!==s);let u=i;for(let l=1;l<d;l+=1){let p=`__virt_${o++}__`,h={id:p,isVirtual:!0,layer:i.layer+l,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};t.nodes.set(p,h),n[h.layer].push(h);let f={chainId:s.chainId,chainFrom:s.chainFrom,chainTo:s.chainTo,fromId:u.id,toId:p,hopIndex:l-1,chainLen:d};u.out.push(f),h.in.push(f),r.push(f),u=h}let c={chainId:s.chainId,chainFrom:s.chainFrom,chainTo:s.chainTo,fromId:u.id,toId:a.id,hopIndex:d-1,chainLen:d};u.out.push(c),a.in.push(c),r.push(c)}for(let s of n)for(let i=0;i<s.length;i+=1)s[i].order=i;t.layers=n,t.hops=r}function ws(t){for(let n=0;n<4;n+=1){for(let r=1;r<t.layers.length;r+=1)eo(t,t.layers[r],"in"),Lt(t.layers[r]);for(let r=t.layers.length-2;r>=0;r-=1)eo(t,t.layers[r],"out"),Lt(t.layers[r])}for(let n=0;n<2;n+=1){let r=!1;for(let o=1;o<t.layers.length;o+=1){let s=t.layers[o];for(let i=0;i+1<s.length;i+=1){let a=to(t,s[i],s[i+1],"in");[s[i],s[i+1]]=[s[i+1],s[i]],Lt(s),to(t,s[i],s[i+1],"in")<a?r=!0:([s[i],s[i+1]]=[s[i+1],s[i]],Lt(s))}}if(!r)break}}function eo(t,e,n){let r=new Map;for(let o of e){let s=n==="in"?o.in:o.out;if(s.length===0){r.set(o.id,o.order);continue}let i=0,a=0;for(let d of s){let u=t.nodes.get(n==="in"?d.fromId:d.toId);u&&(i+=u.order,a+=1)}r.set(o.id,a===0?o.order:i/a)}e.sort((o,s)=>{let i=r.get(o.id),a=r.get(s.id);return i!==a?i-a:o.order-s.order})}function Lt(t){for(let e=0;e<t.length;e+=1)t[e].order=e}function to(t,e,n,r){let o=r==="in"?e.in:e.out,s=r==="in"?n.in:n.out,i=0;for(let a of o)for(let d of s){let u=t.nodes.get(r==="in"?a.fromId:a.toId)?.order??0,c=t.nodes.get(r==="in"?d.fromId:d.toId)?.order??0;(e.order<n.order&&u>c||e.order>n.order&&u<c)&&(i+=1)}return i}function xs(t,e){e.direction==="LR"?Rs(t,e):Es(t,e)}function Rs(t,e){let n=[],r=0;for(let o=0;o<t.layers.length;o+=1){n.push(r);let s=0;for(let i of t.layers[o])s=Math.max(s,i.w);r+=s+e.layerGap}for(let o=0;o<t.layers.length;o+=1)for(let s of t.layers[o])s.x=n[o];for(let o of t.layers){let s=0;for(let i of o)i.y=s,s+=i.h+e.nodeGap}ro(t,e,"y")}function Es(t,e){let n=[],r=0;for(let o=0;o<t.layers.length;o+=1){n.push(r);let s=0;for(let i of t.layers[o])s=Math.max(s,i.h);r+=s+e.layerGap}for(let o=0;o<t.layers.length;o+=1)for(let s of t.layers[o])s.y=n[o];for(let o of t.layers){let s=0;for(let i of o)i.x=s,s+=i.w+e.nodeGap}ro(t,e,"x")}function ro(t,e,n){let r=s=>n==="y"?s.h:s.w,o=e.nodeGap;for(let s=0;s<2;s+=1){let i=s===0?t.layers.slice(1):t.layers.slice(0,-1).reverse();for(let a of i){let d=new Map;for(let c of a){let l=s===0?c.in:c.out;if(l.length===0)continue;let p=[];for(let f of l){let y=t.nodes.get(s===0?f.fromId:f.toId);if(!y)continue;let m=n==="y"?y.y:y.x;p.push(m+Math.floor(r(y)/2))}if(p.length===0)continue;p.sort((f,y)=>f-y);let h=p[Math.floor(p.length/2)];d.set(c.id,h-Math.floor(r(c)/2))}let u=0;for(let c of a){let l=d.get(c.id),p=n==="y"?c.y:c.x,f=Math.max(l??p,u);n==="y"?c.y=f:c.x=f,u=f+r(c)+o}}}}function Os(t,e){let n=new Map;for(let u of t.hops){let c=n.get(u.chainId);c?c.push(u):n.set(u.chainId,[u])}for(let u of n.values())u.sort((c,l)=>c.hopIndex-l.hopIndex);let r=e.direction==="LR",o=u=>r?u.x:u.y,s=u=>r?u.w:u.h,i=u=>r?u.y+Math.floor(u.h/2):u.x+Math.floor(u.w/2),a=new Map;for(let u=0;u+1<t.layers.length;u+=1){let c=t.layers[u],l=t.layers[u+1],p=0;for(let T of c)p=Math.max(p,o(T)+s(T));let h=Number.POSITIVE_INFINITY;for(let T of l)h=Math.min(h,o(T));let f=Number.isFinite(h)?h-1:p,y=Math.max(1,f-p+1),m=[];for(let T of c)for(let S of T.out)m.push(S);m.sort((T,S)=>{let R=i(t.nodes.get(T.fromId)),x=i(t.nodes.get(S.fromId));if(R!==x)return R-x;let N=i(t.nodes.get(T.toId)),A=i(t.nodes.get(S.toId));return N-A});let w=[],_=new Map;for(let T of m){let S=i(t.nodes.get(T.fromId)),R=i(t.nodes.get(T.toId)),x=Math.min(S,R),N=Math.max(S,R),A=-1;for(let k=0;k<w.length;k+=1){let G=w[k],L=!0;for(let U of G)if(U.lo<=N&&x<=U.hi){L=!1;break}if(L){G.push({lo:x,hi:N}),A=k;break}}A<0&&(w.push([{lo:x,hi:N}]),A=w.length-1),_.set(T,A)}let v=w.length,b=y>=Math.max(3,v+2),E=b?p+1:p,O=b?f-1:f,g=Math.max(1,O-E+1);for(let T of m){let S=_.get(T),R;if(v<=1)R=E+Math.floor(g/2);else{let x=(g-1)/(v-1);R=E+Math.floor(S*x)}a.set(T,Math.max(p,Math.min(f,R)))}}let d=[];for(let[,u]of n){let c=[];for(let p=0;p<u.length;p+=1){let h=u[p],f=t.nodes.get(h.fromId),y=t.nodes.get(h.toId),m=a.get(h),w=f.isVirtual?o(f):o(f)+s(f),_=y.isVirtual?o(y):o(y)-1,v=i(f),b=i(y);p===0&&Pt(c,r,w,v),v!==b&&(Pt(c,r,m,v),Pt(c,r,m,b)),Pt(c,r,_,b)}let l=u[0];d.push({from:l.chainFrom,to:l.chainTo,points:Ss(c)})}return d}function Pt(t,e,n,r){t.push(e?{x:n,y:r}:{x:r,y:n})}function Ss(t){let e=[];for(let n of t){let r=e[e.length-1];(!r||r.x!==n.x||r.y!==n.y)&&e.push(n)}return e}function As(t){let e=0,n=0;for(let r of t.layers)for(let o of r)e=Math.max(e,o.x+o.w),n=Math.max(n,o.y+o.h);return{width:e,height:n}}var Ns=24,ks=4,Cs=1,Ms=3;function oo(t,e){let n=Ds(e.direction),r=Math.max(3,e.maxLabelWidth??Ns),o=e.asciiCharset??"unicode",s=Object.keys(t.nodes).sort(),i=new Set(s),a=t.edges.filter(h=>i.has(h.from)&&i.has(h.to)),d=new Map,u=new Map;for(let h of s){let f=Ur(h,r);d.set(h,f),u.set(h,It(f)+4)}let c=no({nodes:s,edges:a,widthCells:h=>u.get(h)??3,heightCells:()=>Ms,layerGap:ks,nodeGap:Cs,direction:n}),l=Xr(c,{charset:o,labelOf:h=>d.get(h)??h}),p=e.logger;return p&&p(l),l}function Ds(t){if(t===void 0||t==="LR")return"LR";if(t==="TD")return"TD";throw new Error(`ascii describe supports direction "LR" or "TD" only; got ${String(t)}`)}function so(t,e,n,r={}){let o=e in t.nodes,s=n in t.nodes;if(!o)return $t(e,n,"no-such-from");if(!s)return $t(e,n,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===n){if(r.findCycle===!0){let u=Gs(t,e,r);if(u!=null)return u}let d=Ft(e,t.nodes[e],0,r);return Ht(e,n,[d])}if(i===0)return $t(e,n,"no-path");let a=io(t,e,n,i);return a.found?Ht(e,n,ao(t,a.pathOrder,r)):$t(e,n,a.truncated?"max-depth-exceeded":"no-path")}function io(t,e,n,r){let o=new Map,s=[{path:n,depth:0}],i=new Set([n]),a=0,d=!1;for(;a<s.length;){let l=s[a++];if(l.path===e)break;if(r!=null&&l.depth>=r){let y=t.nodes[l.path];y?.deps&&y.deps.length>0&&(d=!0);continue}let p=t.nodes[l.path];if(p==null)continue;let h=p.deps??[],f=new Map;for(let y=0;y<h.length;y++){let m=h[y];if(!m)continue;let w=f.get(m);w==null&&(w=[],f.set(m,w)),w.push(y)}for(let[y,m]of f)i.has(y)||(i.add(y),o.set(y,{from:l.path,depIndices:m}),s.push({path:y,depth:l.depth+1}))}if(!o.has(e))return{found:!1,pathOrder:[],truncated:d};let u=[{path:e}],c=e;for(;c!==n;){let l=o.get(c);if(l==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=l.depIndices,u.push({path:l.from}),c=l.from}return{found:!0,pathOrder:u,truncated:!1}}function Gs(t,e,n){let r=t.nodes[e];if(r==null)return null;let o=r.deps??[],s=[];for(let a=0;a<o.length;a++)o[a]===e&&s.push(a);if(s.length>0){let a=Ft(e,r,0,n);a.dep_index=s[0];let d=Ft(e,r,1,n);return Ht(e,e,[a,d])}let i=null;for(let a=0;a<o.length;a++){let d=o[a];if(!d||d===e)continue;let u=io(t,d,e,n.maxDepth);u.found&&(i==null||u.pathOrder.length<i.pathOrder.length)&&(i=u,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...u.pathOrder],truncated:!1})}return i==null?null:Ht(e,e,ao(t,i.pathOrder,n))}function ao(t,e,n){return e.map((r,o)=>{let s=t.nodes[r.path],i=Ft(r.path,s,o,n);return r.depIndices!=null&&r.depIndices.length>0&&(i.dep_index=r.depIndices[0],r.depIndices.length>1&&(i.dep_indices=[...r.depIndices])),i})}function Ft(t,e,n,r){let o={path:t,type:e.type,hop:n};e.status!==void 0&&(o.status=e.status),"value"in e&&(o.value=e.value),e.v!=null&&(o.v=e.v);let s=r.annotations?.get(t)??e.annotation;s!=null&&(o.annotation=s);let i=r.lastMutations?.get(t)??e.lastMutation;return i!=null&&(o.lastMutation=i),o}function Ht(t,e,n){return uo(t,e,!0,"ok",n)}function $t(t,e,n){return uo(t,e,!1,n,[])}function uo(t,e,n,r,o){let s=Is(t,e,n,r,o);return{from:t,to:e,found:n,reason:r,steps:o,text:s,toJSON(){return{from:t,to:e,found:n,reason:r,steps:o}}}}function Is(t,e,n,r,o){if(!n)switch(r){case"no-such-from":return`explainPath: no node named "${t}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${t}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${t}" to "${e}"`}let s=[`Causal path: ${t} \u2192 ${e} (${o.length} step(s))`];for(let i of o){let d=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(s.push(d),"value"in i&&s.push(` value: ${Ls(i.value)}`),i.annotation!=null&&s.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;s.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return s.join(`
11
- `)}function Ls(t){if(t===void 0)return"<sentinel>";if(t===null)return"null";if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return String(t);try{let e=JSON.stringify(t);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(t)}}ke();var W={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},Ps=Symbol.for("sizeof");function co(t){let e=new WeakSet,n=new WeakSet,r=[t],o=0;for(;r.length>0;){let s=r.pop();o+=$s(s,e,n,r)}return o}function $s(t,e,n,r){if(t==null)return 0;switch(typeof t){case"number":return W.number;case"boolean":return W.boolean;case"string":return W.string+t.length*2;case"bigint":return W.bigint+Fs(t);case"symbol":return W.symbol;case"function":return e.has(t)?0:(e.add(t),W.function);case"undefined":return 0}let s=t;if(e.has(s))return 0;e.add(s);let i=s[Ps];if(typeof i=="function")try{let u=i.call(s);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(s instanceof Date)return W.date;if(s instanceof RegExp)return W.regexp+s.source.length*2;if(s instanceof Error){let u=s.message?s.message.length*2:0,c=s.stack?s.stack.length*2:0;return W.error+u+c}if(typeof URL<"u"&&s instanceof URL)return W.url+s.href.length*2;if(typeof Promise<"u"&&s instanceof Promise)return W.promise;if(s instanceof WeakMap)return W.weakmap;if(s instanceof WeakSet)return W.weakset;if(s instanceof Map){let u=W.map;for(let[c,l]of s)u+=W.mapEntry,r.push(c),r.push(l);return u}if(s instanceof Set){let u=W.set;for(let c of s)u+=W.setEntry,r.push(c);return u}if(Array.isArray(s)){let u=W.array+s.length*8;for(let c of s)r.push(c);return u}if(s instanceof ArrayBuffer)return n.has(s)?0:(n.add(s),s.byteLength);if(ArrayBuffer.isView(s)){let u=s;return n.has(u.buffer)?48:(n.add(u.buffer),u.buffer.byteLength+48)}let a=W.object,d=Object.keys(s);for(let u of d){a+=W.string+u.length*2;try{r.push(s[u])}catch{}}return a}function Fs(t){let e=t<0n?-t:t;if(e===0n)return 0;let n=e.toString(2).length;return Math.ceil(n/32)*8}function lo(t,e){let n=e?.topN??10,r=t.describe({detail:"standard"}),o=[],s=t._collectObserveTargets;typeof s=="function"&&s.call(t,"",o);let i=new Map;for(let[p,h]of o)i.set(p,h);let a=[];for(let[p,h]of Object.entries(r.nodes)){let f=i.get(p),y=f instanceof j?f:null,m=y?co(y.cache):0,w=y?y._sinkCount:0,_=h.deps?.length??0,v=h.type==="effect"&&w===0,b=w===0?h.type==="effect"?"orphan-effect":h.type==="derived"?"idle-derived":h.type==="producer"?"idle-producer":null:null;a.push({path:p,type:h.type,status:h.status??"unknown",valueSizeBytes:m,subscriberCount:w,depCount:_,isOrphanEffect:v,orphanKind:b})}let d=a.reduce((p,h)=>p+h.valueSizeBytes,0),u=(p,h)=>[...a].sort(h??((f,y)=>y[p]-f[p])).slice(0,n),c=a.filter(p=>p.orphanKind!=null),l=a.filter(p=>p.isOrphanEffect);return{nodeCount:a.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:a,totalValueSizeBytes:d,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:c,orphanEffects:l}}var H="::",ue="__meta__",Ge=1;function fo(t,e){let n=Math.max(16,t.size*4),r=0;for(;t.size>0;){if(r++>=n){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${n}); ${t.size} disposer(s) discarded`),t.clear();return}let o=t.values().next();if(o.done)return;let s=o.value;t.delete(s);try{s()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function go(t){return t!=null&&typeof t=="object"&&"cache"in t&&typeof t.subscribe=="function"&&typeof t.down=="function"}function Hs(t){if(t!=null)return go(t)?t.cache:t}function Vs(t){let e=[];for(let n of Object.keys(t).sort()){let r=t[n].v;r!=null&&e.push(`${n} ${r.id} ${r.version}`)}return e.join(`
12
- `)}function po(t){if(t.version!==Ge)throw new Error(`unsupported snapshot version ${String(t.version)} (expected ${Ge})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in t))throw new Error(`snapshot missing required key "${e}"`);if(typeof t.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof t.nodes!="object"||t.nodes===null||Array.isArray(t.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(t.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(t.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function js(t,e){let n=new WeakMap,r=(o,s)=>{if(Object.is(o,s))return!0;if(o==null||s==null||typeof o!="object"||typeof s!="object")return!1;let i=n.get(o);if(i==null&&(i=new WeakSet,n.set(o,i)),i.has(s))return!0;i.add(s);let a=o.constructor,d=s.constructor;if(a!==d)return!1;if(o instanceof Date)return o.getTime()===s.getTime();if(o instanceof RegExp)return o.source===s.source&&o.flags===s.flags;if(Array.isArray(o)){let p=s;if(o.length!==p.length)return!1;for(let h=0;h<o.length;h++)if(!r(o[h],p[h]))return!1;return!0}if(o instanceof Map){let p=s;if(o.size!==p.size)return!1;for(let[h,f]of o)if(!p.has(h)||!r(f,p.get(h)))return!1;return!0}if(o instanceof Set){let p=s;if(o.size!==p.size)return!1;for(let h of o){let f=!1;for(let y of p)if(r(h,y)){f=!0;break}if(!f)return!1}return!0}if(ArrayBuffer.isView(o)){let p=o,h=s;if(p.length!==h.length)return!1;for(let f=0;f<p.length;f++)if(p[f]!==h[f])return!1;return!0}let u=Object.keys(o),c=Object.keys(s);if(u.length!==c.length)return!1;let l=new Set(c);for(let p of u)if(!l.has(p)||!r(o[p],s[p]))return!1;return!0};return r(t,e)}function Sn(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Sn);let e=t,n=Object.keys(e).sort(),r={};for(let o of n)r[o]=Sn(e[o]);return r}function qs(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function zs(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Bs(t){return t==="TD"?"down":t==="BT"?"up":t==="RL"?"left":"right"}function mo(t){let e=new Set,n=[];function r(o,s){let i=`${o}\0${s}`;e.has(i)||(e.add(i),n.push([o,s]))}for(let[o,s]of Object.entries(t.nodes)){let i=s.deps;if(i)for(let a of i)r(a,o)}for(let o of t.edges)r(o.from,o.to);return n}function yo(t){if(t===void 0)return"LR";if(t==="TD"||t==="LR"||t==="BT"||t==="RL")return t;throw new Error(`invalid diagram direction ${String(t)}; expected one of: TD, LR, BT, RL`)}function Ws(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,{expand:o,...s}=t,i={...s,edges:n?t.edges:[],subgraphs:r?t.subgraphs:[]},a=JSON.stringify(Sn(i),null,e.indent??2);return e.logger?.(a),a}function Ks(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,o=[];o.push(`Graph ${t.name}`),o.push("Nodes:");for(let i of Object.keys(t.nodes).sort()){let a=t.nodes[i];o.push(`- ${i} (${a.type}/${a.status}): ${jt(a.value)}`)}if(n){o.push("Edges:");for(let i of t.edges)o.push(`- ${i.from} -> ${i.to}`)}if(r){o.push("Subgraphs:");for(let i of t.subgraphs)o.push(`- ${i}`)}let s=o.join(`
13
- `);return e.logger?.(s),s}function bo(t,e){let n=yo(e.direction),r=Object.keys(t.nodes).sort(),o=new Map;for(let i=0;i<r.length;i+=1)o.set(r[i],`n${i}`);let s=[`flowchart ${n}`];for(let i of r){let a=o.get(i);s.push(` ${a}["${qs(i)}"]`)}for(let[i,a]of mo(t)){let d=o.get(i),u=o.get(a);!d||!u||s.push(` ${d} --> ${u}`)}return s.join(`
14
- `)}function Us(t,e){let n=bo(t,e);return vo(n)}function vo(t,e){let n=e?.theme??"default",r=e?.autoSync??!0,s=JSON.stringify({code:t,mermaid:{theme:n},autoSync:r}),i=new TextEncoder().encode(s),a="";for(let u=0;u<i.length;u++)a+=String.fromCharCode(i[u]);return`https://mermaid.live/edit#base64:${globalThis.btoa(a).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}`}function Ys(t,e){let n=yo(e.direction),r=Object.keys(t.nodes).sort(),o=new Map;for(let i=0;i<r.length;i+=1)o.set(r[i],`n${i}`);let s=[`direction: ${Bs(n)}`];for(let i of r){let a=o.get(i);s.push(`${a}: "${zs(i)}"`)}for(let[i,a]of mo(t)){let d=o.get(i),u=o.get(a);!d||!u||s.push(`${d} -> ${u}`)}return s.join(`
15
- `)}function Js(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Vt(t){let e="^";for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="*"){e+=".*";continue}if(r==="?"){e+=".";continue}if(r==="["){let o=t.indexOf("]",n+1);if(o<=n+1){e+="\\[";continue}let s=t.slice(n+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,n=o;continue}e+=Js(r)}return e+="$",new RegExp(e)}var Qs={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"},Xs={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function jt(t){if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||t==null)return String(t);try{return JSON.stringify(t)}catch{return"[unserializable]"}}function Zs(t){return t==="none"?Xs:t==="ansi"||t==null?Qs:{data:t.data??"",dirty:t.dirty??"",resolved:t.resolved??"",invalidate:t.invalidate??"",pause:t.pause??"",resume:t.resume??"",complete:t.complete??"",error:t.error??"",teardown:t.teardown??"",derived:t.derived??"",path:t.path??"",reset:t.reset??""}}function ho(t){if(t==null)return{};let e=t.detail;return e==="full"?{...t,structured:t.structured??!0,timeline:t.timeline??!0,causal:t.causal??!0,derived:t.derived??!0}:e==="minimal"?{...t,structured:t.structured??!0}:t.format==="stage-log"?{...t,structured:t.structured??!0,timeline:t.timeline??!0}:t}function ei(t,e,n){for(let r=0;r<t.length;r++){let o=t.charCodeAt(r);if(o<32||o===127)throw new Error(`Graph "${e}": ${n} "${t}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function On(t,e,n){if(t==="")throw new Error(`Graph "${e}": ${n} name must be non-empty`);if(t.includes(H))throw new Error(`Graph "${e}": ${n} "${t}" must not contain '${H}' (path separator)`);if(t===ue)throw new Error(`Graph "${e}": ${n} name "${ue}" is reserved for meta companion paths`);ei(t,e,n)}function ti(t,e){if(t==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let n=t.split(H);for(let r of n)if(r==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return n}function ni(t,e){let n=!1;for(let o of t)if(!e.isMetaPassthrough(o[0])){n=!0;break}return n?t.filter(o=>e.isMetaPassthrough(o[0])):t}function _o(t){for(let e of t._mounts.values())_o(e);for(let e of t._nodes.values())try{e.down([[q]],{internal:!0})}catch{}}var Z=class t{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,n){if(e==="")throw new Error("Graph name must be non-empty");if(e.includes(H))throw new Error(`Graph name must not contain '${H}' (got "${e}")`);if(e===ue)throw new Error(`Graph name "${ue}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...n??{}}),this.config=n?.config??Ne,this._traceRing=new lt(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning),typeof n?.factory=="string"&&(this._factory=n.factory,n.factoryArgs!==void 0&&(this._factoryArgs=n.factoryArgs))}tagFactory(e,n){return this._factory=e,this._factoryArgs=n,this}ancestors(e=!0){let n=[],r=e?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=Ce(e=>{let n=r=>{e.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(e){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(e)}nameOf(e){return this._nodeToName.get(e)}add(e,n){let r=e.name,o=n?.name??r;if(o==null||o==="")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 s=o,i=n?.annotation;if(On(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" 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(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),i!=null&&(this._annotations.set(s,i),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:i,timestamp_ns:he()})),e}setVersioning(e){if(e!=null)for(let n of this._nodes.values())n instanceof j&&n._applyVersioning(e)}remove(e){On(e,this.name,"remove");let n=this._mounts.get(e);if(n){let s={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,d]of i)a.includes(`${H}${ue}${H}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...n._collectSubgraphs(`${e}${H}`)),this._mounts.delete(e),n._parent=void 0,_o(n),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}let r=this._nodes.get(e);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${e}"`);this._nodes.delete(e),this._nodeToName.delete(r),r.down([[q]],{internal:!0});let o={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:o}),o}removeAll(e){let n=typeof e=="function"?e:(()=>{let s=Vt(e);return i=>s.test(i)})(),r={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>n(s));for(let s of o){let i=this.remove(s);r.nodes.push(...i.nodes),r.mounts.push(...i.mounts)}return r.nodes.sort(),r.mounts.sort(),r}[Symbol.iterator](){let e=[...this._nodes.keys()].sort(),n=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=e.length)return{value:void 0,done:!0};let o=e[r++];return{value:[o,n.get(o)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes(H))return this.resolve(e);let n=this._nodes.get(e);if(!n)throw new Error(`Graph "${this.name}": unknown node "${e}"`);return n}get(e){return this.node(e).cache}set(e,n,r){let o=r?.internal===!0;this.node(e).down([[C,n]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(e,n){let r=Symbol.iterator in e?e:Object.entries(e);le(()=>{for(let[o,s]of r)this.set(o,s,n)})}invalidate(e,n){let r=n?.internal===!0;this.node(e).down([[re]],{actor:n?.actor,internal:r,delivery:"write"})}error(e,n,r){let o=r?.internal===!0;this.node(e).down([[D,n]],{actor:r?.actor,internal:o,delivery:"write"})}complete(e,n){let r=n?.internal===!0;this.node(e).down([[P]],{actor:n?.actor,internal:r,delivery:"write"})}edges(e){let n=e?.recursive===!0,r=new Map;if(!n){for(let[d,u]of this._nodes)r.set(u,d);let a=[];for(let[d,u]of this._nodes)if(u instanceof j)for(let c of u._deps){let l=r.get(c.node);l!=null&&a.push([l,d])}return a.sort((d,u)=>d[0]<u[0]?-1:d[0]>u[0]?1:d[1]<u[1]?-1:d[1]>u[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,d]of o)s.set(d,a);let i=[];for(let[a,d]of o)if(d instanceof j)for(let u of d._deps){let c=s.get(u.node);c!=null&&i.push([c,a])}return i.sort((a,d)=>a[0]<d[0]?-1:a[0]>d[0]?1:a[1]<d[1]?-1:a[1]>d[1]?1:0),i}mount(e,n){if(n===void 0){let o=new t(e);return this.mount(e,o)}if(typeof n=="function"){let o=new t(e);return n(o),this.mount(e,o)}let r=n;if(On(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(r===this)throw new Error(`Graph "${this.name}": cannot mount a graph into itself`);if(r._parent!=null)throw new Error(`Graph "${this.name}": this child graph is already mounted on "${r._parent.name}"`);for(let o=this;o!=null;o=o._parent)if(o===r)throw new Error(`Graph "${this.name}": mount("${e}", \u2026) would create a mount cycle`);return this._mounts.set(e,r),r._parent=this,this._emitTopology({kind:"added",name:e,nodeKind:"mount"}),r}resolve(e){let n=ti(e,this.name);return this._resolveFromSegments(n)}tryResolve(e){try{return this.resolve(e)}catch{return}}_resolveFromSegments(e){let n=e;if(n[0]===this.name&&(n=n.slice(1),n.length===0))throw new Error(`Graph "${this.name}": resolve path ends at graph name only`);let r=n[0],o=n.slice(1);if(o.length===0){let a=this._nodes.get(r);if(a)return a;throw this._mounts.has(r)?new Error(`Graph "${this.name}": path ends at subgraph "${r}" \u2014 not a node (GRAPHREFLY-SPEC \xA73.5)`):new Error(`Graph "${this.name}": unknown name "${r}"`)}let s=this._nodes.get(r);if(s&&o.length>0&&o[0]===ue)return this._resolveMetaChainFromNode(s,o,n.join(H));let i=this._mounts.get(r);if(!i)throw this._nodes.has(r)?new Error(`Graph "${this.name}": "${r}" is a node; trailing path "${o.join(H)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(H))}_resolveMetaChainFromNode(e,n,r){let o=e,s=0,i=[...n];for(;s<i.length;){if(i[s]!==ue)throw new Error(`Graph "${this.name}": expected ${ue} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${ue} in "${r}"`);let a=i[s+1],d=o.meta[a];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=d,s+=2}return o}signal(e,n){if(n?.internal!==!0){for(let o of e)if(this.config.messageTier(o[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 r=[];if(this._signalDeliver(e,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(e,n,r,o){for(let d of this._mounts.values())d._signalDeliver(e,n,r,o);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=ni(e,this.config);for(let d of[...this._nodes.keys()].sort()){let u=this._nodes.get(d);if(!r.has(u)){r.add(u);try{u.down(e,i)}catch(c){if(c instanceof ie)throw c;o.push(c)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,o)}}}_signalMetaSubtree(e,n,r,o,s){for(let i of Object.keys(e.meta).sort()){let a=e.meta[i];if(!r.has(a)){r.add(a);try{a.down(n,o)}catch(d){if(d instanceof ie)throw d;s.push(d)}this._signalMetaSubtree(a,n,r,o,s)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let n=Hs(e?.actor),r=e?.filter,o=ct(e?.detail,e?.fields),s=e?.format==="spec",i=s?ct("minimal"):o,a=[];this._collectObserveTargets("",a);let d=new Map;for(let[O,g]of a)d.set(g,O);let u=[];{let O=a.map(([,S])=>S),g=new Set(d.values()),T=0;for(;O.length>0;){let S=O.shift();if(S instanceof j)for(let R of S._deps){let x=R.node;if(d.has(x))continue;let N=x.name??"",A=N;if(!A||g.has(A))if(N){let k=2;for(;g.has(`${N}#${k}`);)k++;A=`${N}#${k}`}else for(A=`__internal__/${T++}`;g.has(A);)A=`__internal__/${T++}`;d.set(x,A),g.add(A),u.push([A,x]),O.push(x)}}}let c=[...a,...u],l={};for(let[O,g]of c){if(n!=null&&!g.allowsObserve(n))continue;let T=Tn(g,i),S=g instanceof j?g._deps.map(A=>d.get(A.node)??A.node.name??""):[],{name:R,...x}=T,N={...x,deps:S};if(!s){let A=this._annotations.get(O);A!=null&&(N.annotation=A)}if(r!=null)if(typeof r=="function"){let A=r;if(!(A.length>=2?A(O,N):A(N)))continue}else{let A=!0;for(let[k,G]of Object.entries(r)){let L=k==="deps_includes"?"depsIncludes":k==="meta_has"?"metaHas":k;if(L==="depsIncludes"){if(!N.deps.includes(String(G))){A=!1;break}continue}if(L==="metaHas"){if(!Object.hasOwn(N.meta??{},String(G))){A=!1;break}continue}if(N[L]!==G){A=!1;break}}if(!A)continue}l[O]=N}let p=new Set(Object.keys(l)),h=[];for(let[O,g]of c)if(g instanceof j)for(let T of g._deps){let S=d.get(T.node);S!=null&&h.push([S,O])}h.sort((O,g)=>O[0]<g[0]?-1:O[0]>g[0]?1:O[1]<g[1]?-1:O[1]>g[1]?1:0);let f=h.map(([O,g])=>({from:O,to:g}));(n!=null||r!=null)&&(f=f.filter(O=>p.has(O.from)&&p.has(O.to)));let y=this._collectSubgraphs(""),m=n!=null||r!=null?y.filter(O=>{let g=`${O}${H}`;return[...p].some(T=>T===O||T.startsWith(g))}):y,w=this,_=e,v={name:this.name,nodes:l,edges:f,subgraphs:m,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(O){let g={..._,format:void 0};return Array.isArray(O)?(g.fields=O,g.detail=void 0):(g.detail=O,g.fields=void 0),w.describe(g)}},b=e??{},E=b.format;return E==="json"?Ws(v,b):E==="pretty"?Ks(v,b):E==="mermaid"?bo(v,b):E==="mermaid-url"?Us(v,b):E==="d2"?Ys(v,b):E==="ascii"?oo(v,b):v}_collectSubgraphs(e){let n=[];for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${r}`;n.push(o),n.push(...this._mounts.get(r)._collectSubgraphs(`${o}${H}`))}return n}resourceProfile(e){return lo(this,e)}reachable(e,n,r={}){return r.withDetail===!0?An(this.describe(),e,n,{...r,withDetail:!0}):An(this.describe(),e,n,r)}explain(e,n,r){return r?.reactive===!0?this._explainReactive(e,n,r):this._explainStatic(e,n,r)}_explainStatic(e,n,r){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,d]of Object.entries(o.nodes))d.lastMutation!=null&&i.set(a,d.lastMutation);return so(o,e,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(e){let n={...e,reactive:!1},r=e.reactiveName??"describe",o=0,s=V(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=()=>{a||d||(a=!0,He(()=>{a=!1,!d&&(o+=1,s.emit(o))}))},c=i.onEvent(_=>{let v=_.type;v!=="data"&&v!=="error"&&v!=="complete"&&v!=="teardown"||u()}),l=[],p=new WeakSet,h=_=>{if(p.has(_)||d)return;p.add(_);let v=_.topology.subscribe(b=>{for(let E of b){if(E[0]!==C)continue;let O=E[1];if(u(),O.kind==="added"&&O.nodeKind==="mount"){let g=_._mounts.get(O.name);g!=null&&h(g)}}});l.push(v);for(let b of _._mounts.keys()){let E=_._mounts.get(b);E!=null&&h(E)}};h(this);let f,y=e.actor;go(y)&&(f=y.subscribe(_=>{let v=!1,b=!1;for(let E of _){let O=E[0];O===C?v=!0:(O===P||O===D||O===q)&&(b=!0)}v&&u(),b&&(f?.(),f=void 0,u())}));let m;try{m=Q([s],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(_,v)=>_===v})}catch(_){c(),f?.();for(let v of l)v();throw i.dispose(),_}let w=pe(m);return{node:m,dispose(){d=!0,c(),f?.();for(let _ of l)_();l.length=0,i.dispose(),w()}}}_describeReactiveDiff(e){let n={...e,format:void 0,reactive:!1},r=e.reactiveName??"describe-diff",o={name:this.name,nodes:{},edges:[],subgraphs:[]},s=this.describe(n),i=Rn(o,s),a=V(i,{name:r,meta:{domain:"audit",kind:"describe-diff"},equals:(p,h)=>p===h}),d=this._describeReactive({...e,format:void 0,reactiveName:void 0}),u=!1,c=d.node.subscribe(p=>{if(!u)for(let h of p){if(h[0]!==C)continue;let f=h[1],y=Rn(s,f);s=f,y.events.length!==0&&a.emit(y)}}),l=pe(a);return{node:a,dispose(){u=!0,c(),d.dispose(),a.down([[q,"describe-diff disposed"]]),l()}}}_explainReactive(e,n,r){let o=0,s=V(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,d=!1,u=i.onEvent(h=>{let f=h.type;f!=="data"&&f!=="error"&&f!=="complete"&&f!=="teardown"||a||d||(a=!0,He(()=>{a=!1,!d&&(o+=1,s.emit(o))}))}),c={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},l;try{l=Q([s],()=>this._explainStatic(e,n,c),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:e,to:n},equals:(h,f)=>h.found===f.found&&h.reason===f.reason&&h.steps.length===f.steps.length&&ri(h.steps,f.steps)})}catch(h){throw u(),i.dispose(),h}let p=pe(l);return{node:l,dispose(){d=!0,u(),i.dispose(),p()}}}_pathsMatching(e){let n=Vt(e),r=[];return this._collectObserveTargets("",r),r.map(([o])=>o).filter(o=>n.test(o))}_collectObserveTargets(e,n){for(let r of[...this._mounts.keys()].sort()){let o=e===""?r:`${e}${H}${r}`;this._mounts.get(r)._collectObserveTargets(o,n)}for(let r of[...this._nodes.keys()].sort()){let o=this._nodes.get(r),s=e===""?r:`${e}${H}${r}`;n.push([s,o]),this._appendMetaObserveTargets(s,o,n)}}_appendMetaObserveTargets(e,n,r){for(let o of Object.keys(n.meta).sort()){let s=n.meta[o],i=`${e}${H}${ue}${H}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(e,n){let r=typeof e=="string",s=ho(r?n:e);if(s.reactive===!0)return this._observeReactive(r?e:void 0,s);let i=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,a=s.actor;if(r){let c=e,l=this.resolve(c);if(a!=null&&!l.allowsObserve(a))throw new ie({actor:a,action:"observe",nodeName:c});return i?this._buildStructuredObserver([[c,l]],s,"one"):{subscribe(p){return l.subscribe(p)},up(p){try{l.up?.(p)}catch(h){if(h instanceof ie)return;throw h}}}}let d=[];this._collectObserveTargets("",d),d.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let u=a==null?d:d.filter(([,c])=>c.allowsObserve(a));return i?this._buildStructuredObserver(u,s,"all"):{subscribe:c=>{let l=u.map(([p,h])=>h.subscribe(f=>{c(p,f)}));return()=>{for(let p of l)p()}},up:(c,l)=>{try{this.resolve(c).up?.(l)}catch(p){if(p instanceof ie)return;throw p}}}}_observeReactive(e,n){let r=n.tiers,o=r!=null?new Set(r):null,s=n.reactiveName??"observe";return Ce(i=>{let a=[],d=!1,u=!1,c=()=>{if(a.length===0||u)return;let y={events:a.slice(),flushedAt_ns:he()};a.length=0,i.emit(y)},l={...n,reactive:!1,structured:!0,timeline:!0},p=e!=null?this.observe(e,l):this.observe(l),h=y=>{u||(a.push(y),!d&&(d=!0,He(()=>{d=!1,c()})))};for(let y of p.events)h(y);let f=p.onEvent(h);return()=>{u=!0,f(),p.dispose()}},{name:s,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,n,r){let o=r==="one"?e[0]?.[0]:void 0,s=i=>{if(r==="one"&&o!=null){let c=this.resolve(o);return this._buildStructuredObserver([[o,c]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let d=i.actor,u=d==null?a:a.filter(([,c])=>c.allowsObserve(d));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(e,n,s)}_createObserveResult(e,n,r){let o=n.timeline===!0,s=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",d=this.config.inspectorEnabled,u=(s||i)&&d,c=n.maxEvents,l=c!=null&&c>0?new lt(c):null,p=[],h=new Set,f=n.tiers!=null?new Set(n.tiers):null,y={},m=new Set,w=0,_=0,v=0,b=0,E=0,O=0,g=!1,T=!1,S=0,R=new Map,x=new Map,N=new Map,A=M=>{if(!(f!=null&&!f.has(M.type))){l?l.push(M):p.push(M);for(let F of h)F(M)}},k=M=>f==null||f.has(M),G=()=>o?{timestamp_ns:he(),in_batch:xt(),batch_id:S}:{},L=(M,F)=>{if(!(!u||!(M instanceof j)))return M._setInspectorHook(te=>{if(te.kind==="dep_message")R.set(M,te.depIndex);else if(te.kind==="run"){let Ze=te.batchData.map((I,Y)=>I!=null&&I.length>0?I.at(-1):te.prevData[Y]);x.set(M,Ze);let ne=te.batchData.map(I=>I!=null?[...I]:void 0);N.set(M,ne),i&&A({type:"derived",path:F,dep_values:Ze,dep_batches:ne,...G()})}})},U=M=>{let F=R.get(M),te=x.get(M);if(!s||te==null)return{};let ne=(F!=null&&F>=0&&M instanceof j?M._deps[F]:void 0)?.node,I=ne?.v,Y=N.get(M);return{trigger_dep_index:F,trigger_dep_name:ne?.name,...I!=null?{trigger_version:{id:I.id,version:I.version}}:{},dep_values:[...te],...Y!=null?{dep_batches:Y}:{}}},Ie=[],Le=[];for(let[M,F]of e){let te=L(F,M);te&&Ie.push(te),Le.push(F.subscribe(Ze=>{S++;for(let ne of Ze){let I=ne[0],Y=G();if(I===C){y[M]=ne[1];let Qt=F instanceof j?F.lastMutation?.actor??be:be;A({type:"data",path:M,data:ne[1],actor:Qt,...Y,...U(F)})}else if(a)I===$?k("dirty")&&w++:I===B?k("resolved")&&_++:I===re?k("invalidate")&&v++:I===ee?k("pause")&&b++:I===oe?k("resume")&&E++:I===q?k("teardown")&&O++:I===P&&!m.has(M)?k("complete")&&(g=!0):I===D&&k("error")&&(T=!0,m.add(M));else if(I===$)k("dirty")&&w++,A({type:"dirty",path:M,...Y});else if(I===B)k("resolved")&&_++,A({type:"resolved",path:M,...Y,...U(F)});else if(I===re)k("invalidate")&&v++,A({type:"invalidate",path:M,...Y});else if(I===ee)k("pause")&&b++,A({type:"pause",path:M,lockId:ne[1],...Y});else if(I===oe)k("resume")&&E++,A({type:"resume",path:M,lockId:ne[1],...Y});else if(I===P)k("complete")&&!m.has(M)&&(g=!0),A({type:"complete",path:M,...Y});else if(I===D){k("error")&&(T=!0,m.add(M));let Qt=F instanceof j?F.lastMutation?.actor??be:be;A({type:"error",path:M,data:ne[1],actor:Qt,...Y})}else I===q&&(k("teardown")&&O++,A({type:"teardown",path:M,...Y}))}}))}let Qe=!1,Xe=()=>{if(!Qe){Qe=!0;for(let M of Le)M();for(let M of Ie)M();for(let M of bt)M({value:void 0,done:!0});bt.length=0}},Jt=[],bt=[];h.add(M=>{let F=bt.shift();F?F({value:M,done:!1}):Jt.push(M)});let zn={get values(){return y},get dirtyCount(){return w},get resolvedCount(){return _},get invalidateCount(){return v},get pauseCount(){return b},get resumeCount(){return E},get teardownCount(){return O},get events(){return l?l.toArray():[...p]},get anyCompletedCleanly(){return g},get anyErrored(){return T},get completedWithoutErrors(){return g&&!T},onEvent(M){return h.add(M),()=>h.delete(M)},dispose:Xe,expand(M){Xe();let F={...n};return typeof M=="string"?F.detail=M:Object.assign(F,M),r(ho(F))},[Symbol.asyncIterator](){return{next(){return Jt.length>0?Promise.resolve({value:Jt.shift(),done:!1}):Qe?Promise.resolve({value:void 0,done:!0}):new Promise(M=>bt.push(M))},return(){return Xe(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(zn,n),zn}_attachFormatLogger(e,n){let r=n.format;if(r==null)return;let o=n.logger??(f=>console.log(f)),s=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=s==null&&i==null?()=>!0:f=>(s==null||s.has(f))&&(i==null||!i.has(f)),d=Zs(n.theme),u=r==="stage-log"?he():0,c=f=>f==null?"":n.stageLabels?.[f]??f,l=(f,y)=>f.length>y?`${f.slice(0,y-1)}\u2026`:f,p=f=>f.type==="data"||f.type==="error"?l(jt(f.data),120):"",h=f=>{if(r==="stage-log"){let g=(he()-u)/1e9,T=c(f.path).padEnd(9);if(f.type==="data"){let S=p(f);return`[${g.toFixed(3)}s] ${T} \u2190${S?` ${S}`:""}`}if(f.type==="error"){let S=p(f);return`[${g.toFixed(3)}s] ${T} \u2717${S?` ${S}`:""}`}return f.type==="complete"?`[${g.toFixed(3)}s] ${T} \u25A0 complete`:`[${g.toFixed(3)}s] ${T} ${f.type}`}if(r==="json")try{return JSON.stringify(f)}catch{return JSON.stringify({type:f.type,path:f.path,data:"[unserializable]"})}let y=d[f.type]??"",m=f.path?`${d.path}${f.path}${d.reset} `:"",w=f.type==="data"||f.type==="error",_=f.type==="pause"||f.type==="resume",v=w?` ${jt(f.data)}`:_?` ${jt(f.lockId)}`:"",b=f.type==="data"||f.type==="resolved"||f.type==="derived"?f:void 0,E=b?.trigger_dep_name!=null?` <- ${b.trigger_dep_name}`:b?.trigger_dep_index!=null?` <- #${b.trigger_dep_index}`:"",O=f.in_batch?" [batch]":"";return`${m}${y}${f.type.toUpperCase()}${d.reset}${v}${E}${O}`};e.onEvent(f=>{a(f.type)&&o(h(f),f)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){fo(this._disposers,this.name),this.signal([[q]],{internal:!0}),fo(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:n,...r}=this.describe({detail:"full"}),o={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:d,guard:u,...c}=r.nodes[a];o[a]=c}let s=[...r.subgraphs].sort(),i={...r,version:1,nodes:o,subgraphs:s};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 or(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,n){let r=n?.config??Ne,{codec:o,codecVersion:s,payload:i}=sr(e,r);return o.decode(i,s)}restore(e,n){if(po(e),e.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${e.name}" does not match this graph`);let r=n?.only==null?null:(Array.isArray(n.only)?n.only:[n.only]).map(s=>Vt(s)),o=n?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(r!==null&&!r.some(a=>a.test(s)))continue;let i=e.nodes[s];if(i!==void 0){if(!("value"in i)||i.value===void 0){"value"in i&&i.value===void 0&&n?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(i.type==="derived"||i.type==="effect")&&!(i.type==="producer"&&!o)){if(i.v!=null){let d=this.tryResolve(s)?.v;if(d!=null&&d.id===i.v.id&&d.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){n?.onError?.(s,a)}}}}}static fromSnapshot(e,n){po(e);let r=typeof n=="function"?n:n?.build,o=typeof n=="function"?void 0:n?.factories,s=new t(e.name);if(r)return r(s),s.restore(e),s;for(let h of[...e.subgraphs].sort((f,y)=>{let m=f.split(H).length,w=y.split(H).length;return m!==w?m-w:f<y?-1:f>y?1:0})){let f=h.split(H),y=s;for(let m of f)y._mounts.has(m)||y.mount(m,new t(m)),y=y._mounts.get(m)}let i=o?Object.entries(o).map(([h,f])=>({re:Vt(h),factory:f})):[],a=h=>{for(let f of i)if(f.re.test(h))return f.factory},d=h=>{let f=h.split(H),y=f.pop();if(y==null||y.length===0)throw new Error(`invalid snapshot path "${h}"`);let m=s;for(let w of f){let _=m._mounts.get(w);if(!_)throw new Error(`unknown mount "${w}" in path "${h}"`);m=_}return[m,y]},u=Object.entries(e.nodes).filter(([h])=>!h.includes(`${H}${ue}${H}`)).sort((h,f)=>h[0]<f[0]?-1:h[0]>f[0]?1:0),c=new Map(u),l=new Map,p=!0;for(;c.size>0&&p;){p=!1;for(let[h,f]of[...c.entries()]){let y=f?.deps??[];if(!y.every(E=>l.has(E)))continue;let[m,w]=d(h),_={...f?.meta??{}},v=a(h),b;if(f?.type==="state")b=V(f.value,{meta:_});else{if(v==null)continue;b=v(w,{path:h,type:f.type,value:f.value,meta:_,deps:y,resolvedDeps:y.map(E=>l.get(E))})}m.add(b,{name:w}),l.set(h,b),c.delete(h),p=!0}}if(c.size>0){let h=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${h}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}toJSON(){return this.snapshot()}attachSnapshotStorage(e,n={}){let r=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));n.autoRestore===!0&&this._cascadeRestore(e,n.onError);let o=(u,c)=>{if(u.disposed)return;let l=Vs(c.nodes);if(u.lastSnapshot!=null&&l!==""&&l===u.lastFingerprint)return;let p=u.seq+1,h=se(),m=u.lastSnapshot==null||p%u.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:p,timestamp_ns:h,format_version:Ge}:{name:this.name,mode:"diff",diff:To(u.lastSnapshot,c),seq:p,timestamp_ns:h,format_version:Ge};if(u.tier.filter&&!u.tier.filter(m))return;let w;try{w=u.tier.save(m)}catch(_){n.onError?.(_,u.tier);return}if(w&&typeof w.then=="function"){let b=(u.savePending??Promise.resolve()).then(()=>w,()=>w).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=c,u.lastFingerprint=l)},E=>{n.onError?.(E,u.tier)});u.savePending=b.finally(()=>{u.savePending===b&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=c,u.lastFingerprint=l},s=(u,c)=>{try{o(u,c)}catch(l){n.onError?.(l,u.tier)}},i=(u,c)=>{if(!c.some(f=>{let y=this.config.messageTier(f[0]);return y>=3&&y<5}))return;if(n.filter){let f=this.tryResolve(u);if(f==null)return;let y=Tn(f,ct("standard"));if(!n.filter(u,y))return}let p,h=()=>(p==null&&(p=this.snapshot()),p);for(let f of r)f.disposed||(f.debounceMs===0?s(f,h()):(f.timer==null&&(f.timer=new Gt),f.timer.start(f.debounceMs,()=>{f.disposed||s(f,this.snapshot())})))},a;if(n.paths!=null){let c=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(l=>{let p=this.tryResolve(l);return p==null?()=>{}:p.subscribe(h=>i(l,h))});a=()=>{for(let l of c)l()}}else a=this.observe().subscribe((u,c)=>i(u,c));let d=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,n){for(let r of e){let o;try{o=await r.load?.()}catch(i){n?.(i,r);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===Ge&&s.nodes!=null)return this.restore(s),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(e,n,r){for(let o of n){let s;try{s=await o.load?.()}catch(d){r?.onError?.(d,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let i=s,a=i.mode==="full"&&i.snapshot!=null?i.snapshot:i.version===Ge&&i.nodes!=null?i:void 0;if(a!=null)try{return t.fromSnapshot(a,r)}catch(d){r?.onError?.(d,o)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${e}" across ${n.length} tier(s)`)}_annotations=new Map;_traceRing;trace(e,n,r){if(e!=null&&n!=null){if(this.tryResolve(e)==null)return;if(this._annotations.set(e,n),this.config.inspectorEnabled){let o={path:e,annotation:n,timestamp_ns:he(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(o)}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 n=this._traceRing.toArray().filter(o=>!e(o)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let o of n)this._traceRing.push(o);return r}static diff(e,n){let r=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(n.nodes)),s=[...o].filter(_=>!r.has(_)).sort(),i=[...r].filter(_=>!o.has(_)).sort(),a=[],d=[];for(let _ of r){if(!o.has(_))continue;let v=e.nodes[_],b=n.nodes[_],E=v.v,O=b.v;E!=null&&O!=null&&E.id===O.id&&E.version!==O.version&&d.push({path:_,id:E.id,from:E.version,to:O.version});let g=E!=null&&O!=null&&E.id===O.id&&E.version===O.version;for(let T of["type","status","sentinel"]){let S=v[T],R=b[T];S!==R&&a.push({path:_,field:T,from:S,to:R})}if(!g)for(let T of["value","meta"]){let S=v[T],R=b[T];js(S,R)||a.push({path:_,field:T,from:S,to:R})}}let u=_=>`${_.from} ${_.to}`,c=new Set(e.edges.map(u)),l=new Set(n.edges.map(u)),p=n.edges.filter(_=>!c.has(u(_))),h=e.edges.filter(_=>!l.has(u(_))),f=new Set(e.subgraphs),y=new Set(n.subgraphs),m=[...y].filter(_=>!f.has(_)).sort(),w=[...f].filter(_=>!y.has(_)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:d,edgesAdded:p,edgesRemoved:h,subgraphsAdded:m,subgraphsRemoved:w}}};function To(t,e){let n=Z.diff(t,e),r={};for(let o of n.nodesAdded){let s=e.nodes[o];s!=null&&(r[o]=s)}return{...n,nodesAddedFull:r}}function An(t,e,n,r={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return r.withDetail?o:[];if(!r.both&&n!=="upstream"&&n!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=r.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return r.withDetail?o:[];let i=new Map,a=new Map,d=new Map,u=new Map,c=new Set;for(let[v,b]of Object.entries(t.nodes)){if(!v)continue;c.add(v);let E=b.deps??[];i.set(v,E);for(let O of E)O&&(c.add(O),a.has(O)||a.set(O,new Set),a.get(O).add(v))}for(let v of t.edges){if(v==null||typeof v!="object")continue;let b=typeof v.from=="string"?v.from:"",E=typeof v.to=="string"?v.to:"";!b||!E||(c.add(b),c.add(E),u.has(b)||u.set(b,new Set),u.get(b).add(E),d.has(E)||d.set(E,new Set),d.get(E).add(b))}if(!c.has(e))return r.withDetail?o:[];let l=r.both===!0,p=v=>{if(l){let g=i.get(v)??[],T=d.get(v),S=a.get(v),R=u.get(v),x=[...g];return T&&x.push(...T),S&&x.push(...S),R&&x.push(...R),x}if(n==="upstream"){let g=i.get(v)??[],T=d.get(v);return T?[...g,...T]:g}let b=a.get(v),E=u.get(v),O=b?[...b]:[];return E&&O.push(...E),O},h=new Set([e]),f=new Map,y=[{path:e,depth:0}],m=0,w=!1;for(;m<y.length;){let v=y[m++];if(s!=null&&v.depth>=s){p(v.path).length>0&&(w=!0);continue}for(let b of p(v.path))!b||h.has(b)||(h.add(b),f.set(b,v.depth+1),y.push({path:b,depth:v.depth+1}))}let _=[...f.keys()].sort((v,b)=>v<b?-1:v>b?1:0);return r.withDetail?{paths:_,depths:f,truncated:w}:_}function ri(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){let r=t[n],o=e[n];if(r.path!==o.path||r.type!==o.type||r.status!==o.status||r.hop!==o.hop||r.dep_index!==o.dep_index||r.annotation!==o.annotation||r.value!==o.value||r.lastMutation!==o.lastMutation)return!1;let s=r.v,i=o.v;if(s!==i&&(s==null||i==null||s.id!==i.id||s.version!==i.version))return!1}return!0}Se();Ve();Ae();nt();Ae();K();wn();ke();fe();Se();K();ke();fe();var Nn=class{_version=0;_maxSize;_buf;_head=0;_size=0;constructor(e,n){if(n!==void 0&&n<1)throw new RangeError("maxSize must be >= 1");if(this._maxSize=n,n!==void 0){if(this._buf=new Array(n),e&&e.length>0){let r=Math.min(e.length,n),o=e.length-r;for(let s=0;s<r;s++)this._buf[s]=e[o+s];this._size=r}}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 n=e>=0?e:this._size+e;if(!(n<0||n>=this._size))return this._maxSize!==void 0?this._buf[(this._head+n)%this._maxSize]:this._buf[n]}append(e){this._rawAppend(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._maxSize!==void 0&&e.length>this._maxSize?e.length-this._maxSize:0;for(let r=n;r<e.length;r++)this._rawAppend(e[r]);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 n=0;n<e;n++)this._buf[(this._head+n)%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 n=Math.min(e,this._size);if(this._maxSize===void 0)this._buf.splice(0,n);else{for(let r=0;r<n;r++)this._buf[(this._head+r)%this._maxSize]=void 0;this._head=(this._head+n)%this._maxSize}return this._size-=n,this._version+=1,n}slice(e,n){if(!Number.isInteger(e)||e<0)throw new RangeError(`slice: start must be a non-negative integer (got ${e})`);if(n!==void 0&&(!Number.isInteger(n)||n<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${n})`);let r=n===void 0?this._size:Math.min(Math.max(n,0),this._size),o=Math.min(e,this._size);if(o>=r)return[];let s=r-o;if(this._maxSize===void 0)return this._buf.slice(o,r);let i=new Array(s);for(let a=0;a<s;a++)i[a]=this._buf[(this._head+o+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 n=Math.min(e,this._size);return this.slice(this._size-n,this._size)}toArray(){if(this._maxSize===void 0)return[...this._buf];let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this._buf[(this._head+n)%this._maxSize];return e}snapshot(){return this.toArray()}restore(e){if(this._maxSize===void 0){this._buf.length=0;for(let n=0;n<e.length;n++)this._buf.push(e[n]);this._size=this._buf.length}else{let n=this._maxSize;for(let s=0;s<n;s++)this._buf[s]=void 0;this._head=0;let r=Math.min(e.length,n),o=e.length-r;for(let s=0;s<r;s++)this._buf[s]=e[o+s];this._size=r}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 ft(t){return t.subscribe(()=>{})}var oi=64;function pt(t,e={}){let{name:n,maxSize:r,versioning:o,guard:s,backend:i}=e,a=i??new Nn(t,r),d=V(a.toArray(),{name:n,describeKind:"state",equals:(g,T)=>g===T,...o!=null?{versioning:o}:{},...s!=null?{guard:s}:{}});function u(){let g=a.toArray();le(()=>{d.down([[$]],{internal:!0}),d.down([[C,g]],{internal:!0})})}let c=new Map,l=new Map,p=new Map;function h(g,T){return`${g}:${T===void 0?"END":T}`}function f(g){if(g.size<oi)return;let T=g.keys().next();if(T.done)return;let S=g.get(T.value);S!==void 0&&S.dispose(),g.delete(T.value)}function y(g){let T=a.version;try{return g()}finally{a.version!==T&&u()}}function m(g){if(!Number.isInteger(g)||g<0)throw new RangeError(`tail: n must be a non-negative integer (got ${g})`);let T=c.get(g);if(T!==void 0)return c.delete(g),c.set(g,T),T.node;f(c);let S=Q([d],([x])=>{let N=x;return g===0||N.length===0?[]:N.slice(Math.max(0,N.length-g))},{initial:a.tail(g),describeKind:"derived"}),R=ft(S);return c.set(g,{node:S,dispose:R}),S}function w(g,T){if(!Number.isInteger(g)||g<0)throw new RangeError(`slice: start must be a non-negative integer (got ${g})`);if(T!==void 0&&(!Number.isInteger(T)||T<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${T})`);let S=h(g,T),R=l.get(S);if(R!==void 0)return l.delete(S),l.set(S,R),R.node;f(l);let x=Q([d],([A])=>{let k=A;return T===void 0?k.slice(g):k.slice(g,T)},{initial:a.slice(g,T),describeKind:"derived"}),N=ft(x);return l.set(S,{node:x,dispose:N}),x}function _(g){let T=p.get(g);if(T!==void 0)return T.node;let S=Q([d,g],([x,N])=>{let A=x,k=Math.max(0,Math.trunc(N??0));return A.slice(k)},{initial:[],describeKind:"derived"}),R=ft(S);return p.set(g,{node:S,dispose:R}),S}let v,b;function E(){v===void 0&&(v=ge([d],(g,T,S)=>{let R=g[0],N=R!=null&&R.length>0?R.at(-1):S.prevData[0];if(N==null||N.length===0){T.down([[B]]);return}T.emit(N[N.length-1])},{name:n!=null?`${n}::lastValue`:"lastValue",describeKind:"derived",initial:a.size===0?void 0:a.at(a.size-1)}),b=Q([d],([g])=>g.length>0,{name:n!=null?`${n}::hasLatest`:"hasLatest",describeKind:"derived",initial:a.size>0}),ft(v),ft(b))}let O={entries:d,get size(){return a.size},at(g){return a.at(g)},append(g){y(()=>a.append(g))},appendMany(g){g.length!==0&&y(()=>a.appendMany(g))},clear(){y(()=>a.clear())},trimHead(g){y(()=>a.trimHead(g))},withLatest(){return E(),d},get lastValue(){return E(),v},get hasLatest(){return E(),b},view(g){switch(g.kind){case"tail":return m(g.n);case"slice":return w(g.start,g.stop);case"fromCursor":return _(g.cursor)}},attach(g){let T=g.subscribe(S=>{for(let R of S)R[0]===C&&O.append(R[1])});return()=>T()},attachStorage(g){if(g.length===0)return()=>{};let T=new Map;for(let R of g)T.set(R,a.size);(async()=>{for(let R of g)if(typeof R.loadEntries=="function")try{let x=await Promise.resolve(R.loadEntries());x.entries.length>0&&a.size===0&&(a.restore(x.entries),T.set(R,x.entries.length),u());break}catch{}})();let S=d.subscribe(R=>{for(let x of R){if(x[0]!==C)continue;let N=x[1];for(let A of g){let k=T.get(A)??0;if(N.length<k){try{let L=A.appendEntries(N);L instanceof Promise&&L.catch(()=>{})}catch{}T.set(A,N.length);continue}if(N.length===k)continue;let G=N.slice(k);T.set(A,N.length);try{let L=A.appendEntries(G);L instanceof Promise&&L.catch(()=>{})}catch{}}}});return()=>S()},disposeAllViews(){for(let g of c.values())g.dispose();c.clear();for(let g of l.values())g.dispose();l.clear();for(let g of p.values())g.dispose();p.clear()},dispose(){for(let g of c.values())g.dispose();c.clear();for(let g of l.values())g.dispose();l.clear();for(let g of p.values())g.dispose();p.clear()}};return O}var _e=class extends Error{constructor(e,n){super(e,n),this.name=this.constructor.name}},qt=class extends _e{constructor(n,r){super(`Duplicate ${n} registration: "${r}"`);this.kind=n;this.registrationName=r}},zt=class extends _e{constructor(n,r,o){super(`Command "${n}" emitted undeclared event "${r}". Declared emits: [${o.join(", ")}]`);this.commandName=n;this.eventName=r;this.declaredEmits=o}},Bt=class extends _e{constructor(n,r,o){super(`Optimistic concurrency conflict on aggregate "${n}": expected version ${r}, got ${o}`);this.aggregateId=n;this.expected=r;this.actual=o}},Wt=class extends _e{constructor(n){super(`Unknown command: "${n}". Register with command() first.`);this.commandName=n}},ht=class extends _e{constructor(n,r){super(`Command handler "${n}" threw: ${r instanceof Error?r.message:String(r)}`,{cause:r});this.commandName=n}};var gt=class extends _e{constructor(n,r){super(`Projection "${n}" rebuild failed: ${r instanceof Error?r.message:String(r)}`,{cause:r});this.projectionName=n}};Ae();fe();var si=je((t,e)=>{t("observe"),t("signal"),e("write")});function Kt(t){let e=pt([],{name:t.name,maxSize:t.retainedLimit??1024,guard:t.guard??si,...t.versioning!=null?{versioning:t.versioning}:{}});return e.withLatest(),t.graph&&t.graph.add(e.entries,{name:t.name}),e}function wo(t,e,n=0){let r=V(n,{name:e,describeKind:"state"});return t.add(r,{name:e}),r}function xo(t,e,n,r=0){let o={},s=new Z(e);for(let i of n){let a=V(r,{name:i,describeKind:"state"});s.add(a,{name:i}),o[i]=a}return t.mount(e,s),o}kt();function Ro(t,e,n){return{[t]:!0,[`${t}_type`]:e,...n??{}}}var ii=je((t,e)=>{t("write"),t("signal"),e("observe")}),ai=je((t,e)=>{t("observe"),t("signal"),e("write")}),Eo=je((t,e)=>{t("observe"),t("signal"),e("write")});function mt(t,e){return Ro("cqrs",t,e)}function kn(t){if(t===null||typeof t!="object"||Object.isFrozen(t))return t;for(let e of Object.keys(t))kn(t[e]);return Object.freeze(t)}var Cn=class extends Z{_eventLogs=new Map;_eventLogsByAggregate=new Map;_aggregateVersions=new Map;_aggregateLru=new Map;_commandRegs=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_seq=0;_retainedLimit;_freezeCommandPayload;_freezeEventPayload;_maxAggregates;_dispatchSeqCursor;dispatches;audit;aggregateEvictions;constructor(e,n={}){super(e,n.graph),this._retainedLimit=n.retainedLimit??1024,this._freezeCommandPayload=n.freezeCommandPayload??!0,this._freezeEventPayload=n.freezeEventPayload??!0,this._maxAggregates=n.maxAggregates??1e4,this.dispatches=Kt({name:"dispatches",retainedLimit:this._retainedLimit,graph:this}),this.audit=this.dispatches,this.aggregateEvictions=Kt({name:"aggregateEvictions",retainedLimit:this._retainedLimit,graph:this}),this._dispatchSeqCursor=wo(this,"dispatch_seq",0)}aggregateVersion(e,n){return this._aggregateVersions.get(`${e}::${n}`)??0}_touchAggregate(e){this._aggregateLru.delete(e),this._aggregateLru.set(e,!0)}_enforceAggregateLru(){for(;this._aggregateLru.size>this._maxAggregates;){let e=this._aggregateLru.keys().next();if(e.done)break;let n=e.value;this._aggregateLru.delete(n);let r=n.indexOf("::");if(r<0)continue;let o=n.slice(0,r),s=n.slice(r+2),i=this._aggregateVersions.get(n)??0;this._aggregateVersions.delete(n);let a=this._eventLogsByAggregate.get(o);a&&(a.delete(s),a.size===0&&this._eventLogsByAggregate.delete(o)),this.aggregateEvictions.append({aggregateId:s,type:o,lastVersion:i,t_ns:se()})}}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}_attachedEventTiers=[];_attachedTierDisposers=new Map;attachEventStorage(e){this._attachedEventTiers.push(e);for(let[n,r]of this._eventLogs){let o=r.log.attachStorage(e),s=this._attachedTierDisposers.get(n);s||(s=[],this._attachedTierDisposers.set(n,s)),s.push(o)}for(let[n,r]of this._eventLogsByAggregate)for(let[o,s]of r){let i=`${n}::${o}`,a=s.log.attachStorage(e),d=this._attachedTierDisposers.get(i);d||(d=[],this._attachedTierDisposers.set(i,d)),d.push(a)}return()=>{let n=this._attachedEventTiers.indexOf(e);n>=0&&this._attachedEventTiers.splice(n,1)}}_autoWireStreamStorage(e,n){if(this._attachedEventTiers.length===0)return;let r=this._attachedTierDisposers.get(e);r||(r=[],this._attachedTierDisposers.set(e,r));for(let o of this._attachedEventTiers)r.push(n.attachStorage(o))}_bumpDispatchSeq(){let n=(this._dispatchSeqCursor.cache??0)+1;return this._dispatchSeqCursor.emit(n),n}event(e,n){if(n!==void 0)return this._ensureAggregateStream(e,n).node;let r=this._eventLogs.get(e);if(r)return r.node;let o=pt([],{name:e,versioning:0,maxSize:this._retainedLimit});o.withLatest();let s=o.entries,i=Q([s],([a])=>a,{name:e,describeKind:"state",meta:mt("event",{event_name:e}),guard:Eo,initial:s.cache});return this.add(i,{name:e}),this._keepaliveDisposers.push(pe(i)),this._eventLogs.set(e,{log:o,node:i}),this._autoWireStreamStorage(e,o),i}_ensureAggregateStream(e,n){this._eventLogs.has(e)||this.event(e);let r=this._eventLogsByAggregate.get(e);r||(r=new Map,this._eventLogsByAggregate.set(e,r));let o=`${e}::${n}`;this._touchAggregate(o);let s=r.get(n);if(s)return s;let i=`${e}_${n.replace(/[^a-zA-Z0-9_-]/g,"_")}`,a=pt([],{name:i,versioning:0,maxSize:this._retainedLimit});a.withLatest();let d=a.entries,u=Q([d],([h])=>h,{name:i,describeKind:"state",meta:mt("event_aggregate",{event_name:e,aggregate_id:n}),guard:Eo,initial:d.cache}),c=i,l=0;for(;this.nameOf(this.resolveOptional(c)??u)===c&&(l+=1,c=`${i}_${l}`,this.resolveOptional(c)!==void 0););try{this.add(u,{name:c})}catch{}this._keepaliveDisposers.push(pe(u));let p={log:a,node:u};return r.set(n,p),this._autoWireStreamStorage(`${e}::${n}`,a),this._enforceAggregateLru(),p}resolveOptional(e){try{return this.resolve(e)}catch{return}}_appendEvent(e,n,r){let o=this._eventLogs.get(e);if(o||(this.event(e),o=this._eventLogs.get(e)),o.node.status==="completed"||o.node.status==="errored")throw new Error(`Cannot dispatch to terminated event stream "${e}" (status: ${o.node.status}).`);let s,i;if(r?.aggregateId!==void 0){let c=`${e}::${r.aggregateId}`;s=(this._aggregateVersions.get(c)??0)+1,this._aggregateVersions.set(c,s),i=this._ensureAggregateStream(e,r.aggregateId)}let a=o.log.entries.v,d=this._freezeEventPayload?kn(n):n,u={type:e,payload:d,timestampNs:se(),seq:++this._seq,...r?.aggregateId!==void 0?{aggregateId:r.aggregateId}:{},...s!==void 0?{aggregateVersion:s}:{},...r?.correlationId!==void 0?{correlationId:r.correlationId}:{},...r?.causationId!==void 0?{causationId:r.causationId}:{},...r?.metadata!==void 0?{metadata:Object.freeze({...r.metadata})}:{},...r?.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{},...a!=null?{v0:{id:a.id,version:a.version}}:{}};return o.log.append(u),i&&i.log.append(u),u}command(e,n){if(this._commandRegs.has(e))throw new qt("command",e);let r=typeof n=="function"?{handler:n}:n,o=V(void 0,{name:e,describeKind:"state",meta:{...mt("command",{command_name:e}),error:null},guard:ii});if(this.add(o,{name:e}),this._commandRegs.set(e,{handler:r.handler,...r.emits!==void 0?{emits:r.emits}:{},...r.handlerVersion!==void 0?{handlerVersion:r.handlerVersion}:{}}),r.emits)for(let s of r.emits)this._eventLogs.has(s)||this.event(s);return o}dispatch(e,n,r){let o=this._commandRegs.get(e);if(!o)throw new Wt(e);if(r?.aggregateId!==void 0&&r.expectedAggregateVersion!==void 0&&o.emits!==void 0){let p=0;for(let h of o.emits){let f=this._aggregateVersions.get(`${h}::${r.aggregateId}`);f!==void 0&&f>p&&(p=f)}if(p!==r.expectedAggregateVersion)throw new Bt(r.aggregateId,r.expectedAggregateVersion,p)}let s=this.resolve(e),i=this._freezeCommandPayload?kn(n):n,a=[],d=se(),u=0,c,l=!1;try{le(()=>{u=this._bumpDispatchSeq(),s.emit(i,{internal:!0});try{o.handler(i,{emit:(p,h)=>{if(o.emits!==void 0&&!o.emits.includes(p))throw new zt(e,p,o.emits);a.push(p),this._appendEvent(p,h,{...r?.aggregateId!==void 0?{aggregateId:r.aggregateId}:{},...r?.correlationId!==void 0?{correlationId:r.correlationId}:{},...r?.causationId!==void 0?{causationId:r.causationId}:{},...r?.metadata!==void 0?{metadata:Object.freeze({...r.metadata})}:{},...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}})}}),s.meta.error.emit(null,{internal:!0}),this.dispatches.append({commandName:e,payload:i,status:"success",emittedEvents:[...a],t_ns:d,seq:u,...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}})}catch(p){throw c=p,l=!0,p}})}catch(p){if(l){s.meta.error.emit(c,{internal:!0});let h=c instanceof Error?c.name:typeof c,f=c instanceof ht?c:new ht(e,c);this.dispatches.append({commandName:e,payload:i,status:"failed",error:f,errorType:h,emittedEvents:[...a],t_ns:d,seq:u,...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}})}throw l?c:p}}projection(e){let{name:n,events:r,reducer:o,initial:s}=e,i=e.mode??"scan",a=e.freezeInputs??!0,d=e.snapshot,u=r.map(R=>(this._eventLogs.has(R)||this.event(R),this._eventLogs.get(R).node));function c(R){R.sort((x,N)=>x.timestampNs-N.timestampNs||x.seq-N.seq||(x.aggregateId??"").localeCompare(N.aggregateId??""))}function l(R){let x=[];for(let N of R)x.push(...N);return c(x),x}let p=u.map(R=>R.cache??[]),h=l(p),f=a?Object.freeze(h):h,y=0,m=s;i==="scan"&&h.length>0&&(m=o(s,f),y=h.length);let w=i==="replay"?o(s,f):m,_=d?.saveDebounceMs??1e3,v=d?.saveEvery??1e3,b,E=0;function O(R){if(d?.save){if(E+=1,E>=v){E=0,b!==void 0&&(clearTimeout(b),b=void 0);let x=d.save(R);x instanceof Promise&&x.catch(()=>{});return}b!==void 0&&clearTimeout(b),b=setTimeout(()=>{b=void 0,E=0;let x=d.save(R);x instanceof Promise&&x.catch(()=>{})},_)}}let g=Q(u,R=>{let x=l(R),N;if(i==="replay"){let A=a?Object.freeze(x):x;N=o(s,A)}else{let A=x.slice(y);y=x.length;let k=a?Object.freeze(A):A;N=o(m,k),m=N}return O(N),N},{name:n,describeKind:"derived",meta:mt("projection",{projection_name:n,source_events:r}),guard:ai,initial:w});return this.add(g,{name:n}),this._keepaliveDisposers.push(pe(g)),this._keepaliveDisposers.push(()=>{b!==void 0&&(clearTimeout(b),b=void 0)}),this._projections.add(n),{node:g,rebuild:async R=>{try{let x=R?.pageSize??1e3,N=R?.fromTier??this._attachedEventTiers[0]?.[0],A=l(u.map(G=>G.cache??[])).length,k=s;if(d?.load){let G=await d.load();G!==void 0&&(k=G)}if(!N||!N.loadEntries){let G=l(u.map(U=>U.cache??[])),L=a?Object.freeze(G):G;k=o(k,L)}else{let G=new Set(r),L,U=!1;for(;!U;){let Ie=await N.loadEntries({cursor:L,pageSize:x}),Le=[...Ie.entries].filter(Xe=>G.has(Xe.type));c(Le);let Qe=a?Object.freeze(Le):Le;k=o(k,Qe),L=Ie.cursor,U=!L||Ie.entries.length===0}}if(i==="scan"){let G=l(u.map(U=>U.cache??[])),L=G.slice(A);if(L.length>0){let U=a?Object.freeze(L):L;k=o(k,U)}m=k,y=G.length}return g.emit(k,{internal:!0}),k}catch(x){throw new gt(n,x)}},reset:async()=>{try{let R=s;if(d?.load){let k=await d.load();k!==void 0&&(R=k)}let x=l(u.map(k=>k.cache??[])),N=a?Object.freeze(x):x,A=o(R,N);return i==="scan"&&(m=A,y=x.length),g.emit(A,{internal:!0}),A}catch(R){throw new gt(n,R)}}}}saga(e,n,r,o={}){let s=n.map(h=>(this._eventLogs.has(h)||this.event(h),this._eventLogs.get(h).node)),i=xo(this,`${e}_cursor`,n,0),a=Kt({name:`${e}_invocations`,retainedLimit:this._retainedLimit,graph:this}),d=o.aggregateId,u=o.errorPolicy??"advance",c=new Map;for(let h of n){let f=i[h];c.set(h,f.cache??0);let y=f.subscribe(m=>{for(let w of m)w[0]===C&&c.set(h,w[1])});this._keepaliveDisposers.push(y)}let l={},p=ge(s,(h,f)=>{let y=l.n.meta.error;for(let m=0;m<h.length;m++){let w=h[m];if(w==null||w.length===0)continue;let _=w.at(-1);if(!_)continue;let v=n[m],b=i[v],E=c.get(v)??0;if(_.length>E){let O=_.slice(E),g=E;for(let T of O){let S=T;if(d!==void 0&&S.aggregateId!==d){g+=1;continue}try{r(S),y.emit(null,{internal:!0}),a.append({eventType:v,status:"success",aggregateId:S.aggregateId,event:S,t_ns:se(),...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}}),g+=1}catch(R){if(y.emit(R,{internal:!0}),a.append({eventType:v,status:"failed",error:R,errorType:R instanceof Error?R.name:typeof R,aggregateId:S.aggregateId,event:S,t_ns:se(),...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}}),u==="hold")break;g+=1}}b.emit(g)}}},{name:e,describeKind:"effect",meta:{...mt("saga",{saga_name:e,source_events:n}),error:null}});return l.n=p,this.add(p,{name:e}),this._keepaliveDisposers.push(pe(p)),this._sagas.add(e),{node:p,invocations:a,audit:a,cursors:i}}};function Oo(t,e){let n=new Cn(t,e),{factory:r,factoryArgs:o,...s}=e??{};return n.tagFactory("cqrs",_n(s)),n}var Dn=class{constructor(e){this.graph=e}onModuleDestroy(){this.graph.destroy()}},Gn=class{graph=new Z("request");onModuleDestroy(){this.graph.destroy()}},So,Mn;So=[(0,yt.Module)({})];var Te=class Te{static forRoot(e){let n=e??{},r=n.name??"root",o=[{provide:ae,useFactory:()=>{let s=new Z(r);return n.build&&n.build(s),n.snapshot&&s.restore(n.snapshot),s}},{provide:Symbol.for("graphrefly:root-lifecycle"),useFactory:s=>new Dn(s),inject:[ae]},{provide:De,useFactory:(s,i)=>new De(s,i),inject:[ae,Ao.ModuleRef]}];if(n.nodes)for(let s of n.nodes)o.push({provide:de(s),useFactory:i=>i.resolve(s),inject:[ae]});return n.requestScope&&o.push({provide:Symbol.for("graphrefly:request-lifecycle"),useFactory:()=>new Gn,scope:yt.Scope.REQUEST},{provide:Me,useFactory:s=>s.graph,inject:[Symbol.for("graphrefly:request-lifecycle")],scope:yt.Scope.REQUEST}),{module:Te,global:!0,providers:o,exports:[ae,...(n.nodes??[]).map(de),...n.requestScope?[Me]:[]]}}static forFeature(e){let n=[{provide:X(e.name),useFactory:r=>{let o=new Z(e.name);return e.build&&e.build(o),e.snapshot&&o.restore(e.snapshot),r.mount(e.name,o),o},inject:[ae]}];if(e.nodes)for(let r of e.nodes)n.push({provide:de(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[X(e.name)]});return{module:Te,providers:n,exports:[X(e.name),...(e.nodes??[]).map(r=>de(`${e.name}::${r}`))]}}static forCqrs(e){let n=[{provide:X(e.name),useFactory:r=>{let o=Oo(e.name,e.cqrs);return e.eventStorage&&o.attachEventStorage(e.eventStorage),e.build&&e.build(o),r.mount(e.name,o),o},inject:[ae]}];if(e.nodes)for(let r of e.nodes)n.push({provide:de(`${e.name}::${r}`),useFactory:o=>o.resolve(r),inject:[X(e.name)]});return{module:Te,providers:n,exports:[X(e.name),...(e.nodes??[]).map(r=>de(`${e.name}::${r}`))]}}};Mn=Jn(null),Te=Zn(Mn,0,"GraphReflyModule",So,Te),Xn(Mn,1,Te);var Ut=Te;var Ln={};ce(Ln,{useStore:()=>ui,useSubscribe:()=>No,useSubscribeRecord:()=>di});var me=require("react");K();function No(t){return(0,me.useSyncExternalStore)(e=>{let n=!1,r=t.subscribe(()=>{n||e()});return()=>{n=!0,r()}},()=>t.cache,()=>t.cache)}function ui(t){let e=No(t),n=(0,me.useCallback)(r=>{t.down([[$],[C,r]])},[t]);return[e,n]}function di(t,e){let n=(0,me.useRef)(e);n.current=e;let r=(0,me.useMemo)(()=>{let o=()=>{let i={},a=t.cache??[];for(let d of a){let u=n.current(d),c={};for(let l of Object.keys(u))c[l]=u[l].cache;i[d]=c}return i},s=o();return{subscribe:i=>{let a=!1,d=[],u=()=>{for(let p of d)p();d=[]},c=p=>{u();for(let h of p){let f=n.current(h);for(let y of Object.keys(f)){let m=f[y].subscribe(()=>{s=o(),a||i()});d.push(m)}}s=o(),a||i()},l=t.subscribe(p=>{let h=p.some(f=>f[0]===C||f[0]===B);!a&&h&&c(t.cache??[])});return c(t.cache??[]),()=>{a=!0,l(),u()}},getSnapshot:()=>s}},[t]);return(0,me.useSyncExternalStore)(r.subscribe,r.getSnapshot,r.getSnapshot)}var Fn={};ce(Fn,{Signal:()=>ci});Se();K();fe();var Je=[];function Yt(t){let e=t.cache;return t.subscribe(r=>{for(let[o,s]of r)o===C&&(e=s)})(),e}var Pn=class{_node;_equals;constructor(e,n){this._equals=n?.equals??Object.is,this._node=V(e,{...n,resubscribable:!0,resetOnTeardown:!0})}get(){let e=Je[Je.length-1];return e?(this._node.status==="sentinel"&&Yt(this._node),e(this._node)):this._node.status==="sentinel"?Yt(this._node):this._node.cache}set(e){this._equals(this.get(),e)||le(()=>{this._node.down([[$],[C,e]])})}},$n=class{_node;constructor(e,n){this._node=st(r=>{Je.push(r);try{return e()}finally{Je.pop()}},{...n,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=Je[Je.length-1];return e?(this._node.status==="sentinel"&&Yt(this._node),e(this._node)):this._node.status==="sentinel"?Yt(this._node):this._node.cache}},ci={State:Pn,Computed:$n,sub:(t,e)=>{let n=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,r=!0;return t._node.subscribe(o=>{for(let[s,i]of o){if(s===C){if(r){r=!1;continue}n.data?.(i)}s===D&&n.error?.(i),s===P&&n.complete?.()}})}};var Hn={};ce(Hn,{useStore:()=>li,useSubscribe:()=>ko,useSubscribeRecord:()=>fi});var ye=require("solid-js");K();function ko(t){let[e,n]=(0,ye.createSignal)(t.cache,{equals:!1}),r=t.subscribe(()=>{n(()=>t.cache)});return(0,ye.getOwner)()?(0,ye.onCleanup)(()=>r()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),e}function li(t){return[ko(t),r=>{t.down([[$],[C,r]])}]}function fi(t,e){let[n,r]=(0,ye.createSignal)({},{equals:!1}),o=[],s=()=>{for(let u of o)u();o=[]},i=()=>{let u={};for(let c of t.cache??[]){let l=e(c),p={};for(let h of Object.keys(l))p[h]=l[h].cache;u[c]=p}return u},a=u=>{s();for(let c of u){let l=e(c);for(let p of Object.keys(l)){let h=l[p].subscribe(()=>{r(()=>i())});o.push(h)}}r(()=>i())},d=t.subscribe(u=>{u.some(c=>c[0]===C||c[0]===B)&&a(t.cache??[])});return a(t.cache??[]),(0,ye.getOwner)()?(0,ye.onCleanup)(()=>{d(),s()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),n}var Vn={};ce(Vn,{useStore:()=>hi,useSubscribe:()=>pi,useSubscribeRecord:()=>gi});K();function pi(t){return{subscribe(e){let n=t.subscribe(()=>{e(t.cache)});return e(t.cache),n}}}function hi(t){return{subscribe(e){let n=t.subscribe(()=>{e(t.cache)});return e(t.cache),n},set(e){t.down([[$],[C,e]])},update(e){let n=e(t.cache);t.down([[$],[C,n]])}}}function gi(t,e){return{subscribe(n){let r=[],o=()=>{for(let d of r)d();r=[]},s=()=>{let d={};for(let u of t.cache??[]){let c=e(u),l={};for(let p of Object.keys(c))l[p]=c[p].cache;d[u]=l}return d},i=d=>{o();for(let u of d){let c=e(u);for(let l of Object.keys(c)){let p=c[l].subscribe(()=>{n(s())});r.push(p)}}n(s())},a=t.subscribe(d=>{d.some(u=>u[0]===C||u[0]===B)&&i(t.cache??[])});return i(t.cache??[]),()=>{a(),o()}}}}var jn={};ce(jn,{useStore:()=>yi,useSubscribe:()=>mi,useSubscribeRecord:()=>bi});var z=require("vue");K();function mi(t){let e=(0,z.shallowRef)(t.cache),n=t.subscribe(()=>{e.value=t.cache});return(0,z.getCurrentScope)()?(0,z.onScopeDispose)(()=>n()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,z.readonly)(e)}function yi(t){let e=(0,z.shallowRef)(t.cache),n=t.subscribe(()=>{e.value=t.cache});return(0,z.getCurrentScope)()?(0,z.onScopeDispose)(()=>n()):typeof console<"u"&&console.warn("[graphrefly-ts] useStore called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,z.computed)({get:()=>e.value,set:r=>{t.down([[$],[C,r]])}})}function bi(t,e){let n=(0,z.shallowRef)({}),r=new Map;function o(){let a={};for(let[d,u]of r)a[d]={...u.values};n.value=a}function s(a){for(let u of r.values())for(let c of u.subs)c();r.clear();for(let u of a){let c=e(u),l=Object.keys(c),p={},h=[];for(let f of l){let y=c[f];p[f]=y.cache;let m=y.subscribe(()=>{p[f]=y.cache,o()});h.push(m)}r.set(u,{subs:h,values:p})}let d={};for(let[u,c]of r)d[u]={...c.values};n.value=d}return(0,z.watch)(()=>[...(typeof t=="function"?t():(0,z.isRef)(t)?t.value:t)??[]],a=>s(a??[]),{immediate:!0}),(0,z.getCurrentScope)()?(0,z.onScopeDispose)(()=>{for(let a of r.values())for(let d of a.subs)d();r.clear()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,z.readonly)(n)}var qn={};ce(qn,{create:()=>_i});K();fe();var vi=()=>!1;function _i(t){let e=new Z("zustand"),n=V(void 0,{name:"state",equals:vi});e.add(n,{name:"state"});let r=()=>n.cache,o=(a,d)=>{let u=n.cache,c=typeof a=="function"?a(u):a;n.emit(d?c:{...u,...c})},s={getState:r,setState:o,getInitialState:()=>i,subscribe:a=>{let d=!0,u=n.cache;return n.subscribe(c=>{for(let[l,p]of c)if(l===C){if(d){d=!1;continue}a(p,u),u=p}})},destroy:e.destroy.bind(e)},i=t(o,r,s);return n.emit(i),Object.assign(e,s)}0&&(module.exports={jotai,nanostores,nestjs,react,signals,solid,svelte,vue,zustand});
5
+ `)))},s)),a?.aborted?v():a?.addEventListener("abort",v,{once:!0})},pull(f){if(u&&!h){if(p.length>0){let m=p.shift();f.enqueue(m.frame),m.counted&&c.onDequeue();return}return new Promise(m=>{l=m})}},cancel(){try{d?.()}catch{}}})}function $r(r,e,t){let{actor:n,filter:o}=t??{},s=[],a=[],i=!1,d=r.observe(e,{actor:n}),u=t?.highWaterMark!=null?Ct(f=>d.up(f),{highWaterMark:t.highWaterMark,lowWaterMark:t.lowWaterMark??Math.floor(t.highWaterMark/2)}):void 0,c=()=>{i||(i=!0,u?.dispose(),p())},l=f=>{if(!i)if(a.length>0){let m=a.shift();f.done&&f.error?m.reject(f.error):f.done?m.resolve({done:!0,value:void 0}):m.resolve({done:!1,value:f.value})}else s.push(f),f.done||u?.onEnqueue()},p=d.subscribe(f=>{for(let m of f){let g=m[0];if(g===O){let x=m[1];if(o&&!o(x))continue;l({done:!1,value:x})}else if(g===D){let x=m[1]instanceof Error?m[1]:new Error(String(m[1]));l({done:!0,error:x}),c();return}else if(g===I||g===V){l({done:!0}),c();return}}});return{next(){if(s.length>0){let f=s.shift();return f.done||u?.onDequeue(),f.done&&f.error?Promise.reject(f.error):Promise.resolve(f.done?{done:!0,value:void 0}:{done:!1,value:f.value})}return i?Promise.resolve({done:!0,value:void 0}):new Promise((f,m)=>{a.push({resolve:f,reject:m})})},return(){c();for(let f of a)f.resolve({done:!0,value:void 0});return a.length=0,Promise.resolve({done:!0,value:void 0})},throw(f){return c(),Promise.reject(f)},[Symbol.asyncIterator](){return this}}}var Mt=class{constructor(e,t){this.graph=e;this.extractActor=t?.extractActor??(()=>{}),this.parse=t?.parse??Ko,this.highWaterMark=t?.highWaterMark,this.lowWaterMark=t?.lowWaterMark}clients=new Map;extractActor;parse;highWaterMark;lowWaterMark;handleConnection(e){this.clients.has(e)||this.clients.set(e,new Map)}handleDisconnect(e){let t=this.clients.get(e);if(t){for(let n of t.values())n.wm?.dispose(),n.unsub();this.clients.delete(e)}}handleMessage(e,t,n){let o=n??Uo.bind(null,e),s;try{s=typeof t=="string"?this.parse(t):t}catch{o({type:"err",message:"invalid command"});return}s.type==="subscribe"?this.subscribe(e,s.path,o):s.type==="unsubscribe"?this.unsubscribe(e,s.path,o):s.type==="ack"?this.ack(e,s.path,s.count??1):o({type:"err",message:`unknown command type: ${s.type}`})}subscriptionCount(e){return this.clients.get(e)?.size??0}destroy(){for(let[e]of this.clients)this.handleDisconnect(e)}subscribe(e,t,n){let o=this.clients.get(e);if(o||(o=new Map,this.clients.set(e,o)),o.has(t)){n({type:"subscribed",path:t});return}let s=this.extractActor(e),a;try{a=this.graph.observe(t,{actor:s})}catch(c){let l=c instanceof Error?c.message:String(c);n({type:"err",message:l});return}let i=this.highWaterMark!=null?Ct(c=>a.up(c),{highWaterMark:this.highWaterMark,lowWaterMark:this.lowWaterMark??Math.floor(this.highWaterMark/2)}):void 0,d=()=>{i?.dispose(),u(),o.delete(t)},u=a.subscribe(c=>{for(let l of c){let p=l[0];if(p===O)i?.onEnqueue(),hn(n,{type:"data",path:t,value:l[1]});else if(p===D){let h=l[1]instanceof Error?l[1].message:String(l[1]);hn(n,{type:"error",path:t,error:h}),d();return}else if(p===I||p===V){hn(n,{type:"complete",path:t}),d();return}}});o.set(t,{unsub:u,wm:i}),n({type:"subscribed",path:t})}unsubscribe(e,t,n){let o=this.clients.get(e),s=o?.get(t);s&&(s.wm?.dispose(),s.unsub(),o.delete(t)),n({type:"unsubscribed",path:t})}ack(e,t,n){let o=this.clients.get(e)?.get(t);if(!o?.wm)return;let s=Math.min(Math.max(0,Math.floor(n)),1024);for(let a=0;a<s;a++)o.wm.onDequeue()}};function Bo(r){if(r instanceof Error)return r.message;try{return JSON.stringify(r)}catch{return String(r)}}function pn(r,e){let t=`event: ${r}
6
+ `;if(e!==void 0)for(let n of e.split(`
7
+ `))t+=`data: ${n}
8
+ `;return t+=`
9
+ `,t}function Ko(r){return JSON.parse(r)}function Uo(r,e){try{r.send(JSON.stringify(e))}catch{}}function hn(r,e){try{r(e)}catch{}}rt();var Dt="graphReflyActor";function gn(r){return e=>{let n=e.switchToHttp().getRequest()?.user;if(n!=null)return r?r(n):n}}function Fr(r="x-graphrefly-actor"){return e=>{let n=e.switchToHttp().getRequest()?.headers?.[r.toLowerCase()];if(!(typeof n!="string"||n.length===0))try{return JSON.parse(n)}catch{return}}}function Vr(r){let e=r?.[Dt];return e!=null?Re(e):be}var ct=class{constructor(e){this.extractor=e}canActivate(e){let t=Re(this.extractor(e)),n=e.switchToHttp().getRequest();return n!=null&&(n[Dt]=t),!0}};function Hr(r){return new ct(r??gn())}var yt=require("@nestjs/common"),ho=require("@nestjs/core");rt();Ne();qe();Se();K();vn();Ae();fe();qe();function _n(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 s=0;s<r.length;s++)if(!_n(r[s],e[s]))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 o=new Set(n);for(let s of t)if(!o.has(s)||!_n(r[s],e[s]))return!1;return!0}function jr(r,e){return`${r}\0${e}`}function Tn(r,e){let t=[],n=new Set(r.subgraphs),o=new Set(e.subgraphs),s=[];for(let g of o)n.has(g)||s.push(g);s.sort();for(let g of s)t.push({type:"subgraph-mounted",path:g});let a=new Set(Object.keys(r.nodes)),i=new Set(Object.keys(e.nodes)),d=[];for(let g of i)a.has(g)||d.push(g);d.sort();for(let g of d)t.push({type:"node-added",path:g,node:{...e.nodes[g]}});let u=[];for(let g of i){if(!a.has(g))continue;let x=r.nodes[g]?.meta,v=e.nodes[g]?.meta;x==null&&v==null||_n(x??{},v??{})||u.push(g)}u.sort();for(let g of u)t.push({type:"node-meta-changed",path:g,prevMeta:r.nodes[g]?.meta??{},nextMeta:e.nodes[g]?.meta??{}});let c=new Map;for(let g of r.edges)c.set(jr(g.from,g.to),g);let l=new Map;for(let g of e.edges)l.set(jr(g.from,g.to),g);let p=[];for(let[g,x]of l)c.has(g)||p.push(x);p.sort((g,x)=>g.from<x.from?-1:g.from>x.from?1:g.to<x.to?-1:g.to>x.to?1:0);for(let g of p)t.push({type:"edge-added",from:g.from,to:g.to});let h=[];for(let[g,x]of c)l.has(g)||h.push(x);h.sort((g,x)=>g.from<x.from?-1:g.from>x.from?1:g.to<x.to?-1:g.to>x.to?1:0);for(let g of h)t.push({type:"edge-removed",from:g.from,to:g.to});let f=[];for(let g of a)i.has(g)||f.push(g);f.sort();for(let g of f)t.push({type:"node-removed",path:g});let m=[];for(let g of n)o.has(g)||m.push(g);m.sort();for(let g of m)t.push({type:"subgraph-unmounted",path:g});return{events:t,flushedAt_ns:pe()}}At();zr();Wr();en();function Br(r,e,t,n={}){let o=e in r.nodes,s=t in r.nodes;if(!o)return Pt(e,t,"no-such-from");if(!s)return Pt(e,t,"no-such-to");let a=n.maxDepth;if(a!=null&&(!Number.isInteger(a)||a<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===t){if(n.findCycle===!0){let u=Qo(r,e,n);if(u!=null)return u}let d=Lt(e,r.nodes[e],0,n);return $t(e,t,[d])}if(a===0)return Pt(e,t,"no-path");let i=Kr(r,e,t,a);return i.found?$t(e,t,Ur(r,i.pathOrder,n)):Pt(e,t,i.truncated?"max-depth-exceeded":"no-path")}function Kr(r,e,t,n){let o=new Map,s=[{path:t,depth:0}],a=new Set([t]),i=0,d=!1;for(;i<s.length;){let l=s[i++];if(l.path===e)break;if(n!=null&&l.depth>=n){let m=r.nodes[l.path];m?.deps&&m.deps.length>0&&(d=!0);continue}let p=r.nodes[l.path];if(p==null)continue;let h=p.deps??[],f=new Map;for(let m=0;m<h.length;m++){let g=h[m];if(!g)continue;let x=f.get(g);x==null&&(x=[],f.set(g,x)),x.push(m)}for(let[m,g]of f)a.has(m)||(a.add(m),o.set(m,{from:l.path,depIndices:g}),s.push({path:m,depth:l.depth+1}))}if(!o.has(e))return{found:!1,pathOrder:[],truncated:d};let u=[{path:e}],c=e;for(;c!==t;){let l=o.get(c);if(l==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=l.depIndices,u.push({path:l.from}),c=l.from}return{found:!0,pathOrder:u,truncated:!1}}function Qo(r,e,t){let n=r.nodes[e];if(n==null)return null;let o=n.deps??[],s=[];for(let i=0;i<o.length;i++)o[i]===e&&s.push(i);if(s.length>0){let i=Lt(e,n,0,t);i.dep_index=s[0];let d=Lt(e,n,1,t);return $t(e,e,[i,d])}let a=null;for(let i=0;i<o.length;i++){let d=o[i];if(!d||d===e)continue;let u=Kr(r,d,e,t.maxDepth);u.found&&(a==null||u.pathOrder.length<a.pathOrder.length)&&(a=u,a={found:!0,pathOrder:[{path:e,depIndices:[i]},...u.pathOrder],truncated:!1})}return a==null?null:$t(e,e,Ur(r,a.pathOrder,t))}function Ur(r,e,t){return e.map((n,o)=>{let s=r.nodes[n.path],a=Lt(n.path,s,o,t);return n.depIndices!=null&&n.depIndices.length>0&&(a.dep_index=n.depIndices[0],n.depIndices.length>1&&(a.dep_indices=[...n.depIndices])),a})}function Lt(r,e,t,n){let o={path:r,type:e.type,hop:t};e.status!==void 0&&(o.status=e.status),"value"in e&&(o.value=e.value),e.v!=null&&(o.v=e.v);let s=n.annotations?.get(r)??e.annotation;s!=null&&(o.annotation=s);let a=n.lastMutations?.get(r)??e.lastMutation;return a!=null&&(o.lastMutation=a),o}function $t(r,e,t){return Yr(r,e,!0,"ok",t)}function Pt(r,e,t){return Yr(r,e,!1,t,[])}function Yr(r,e,t,n,o){let s=Zo(r,e,t,n,o);return{from:r,to:e,found:t,reason:n,steps:o,text:s,toJSON(){return{from:r,to:e,found:t,reason:n,steps:o}}}}function Zo(r,e,t,n,o){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 s=[`Causal path: ${r} \u2192 ${e} (${o.length} step(s))`];for(let a of o){let d=` ${a.hop===0?"\xB7":"\u2193"} ${a.path} (${a.type}${a.status?`/${a.status}`:""})`;if(s.push(d),"value"in a&&s.push(` value: ${Xo(a.value)}`),a.annotation!=null&&s.push(` annotation: ${a.annotation}`),a.lastMutation!=null){let u=a.lastMutation.actor;s.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return s.join(`
10
+ `)}function Xo(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)}}Ae();var W={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},es=Symbol.for("sizeof");function Jr(r){let e=new WeakSet,t=new WeakSet,n=[r],o=0;for(;n.length>0;){let s=n.pop();o+=ts(s,e,t,n)}return o}function ts(r,e,t,n){if(r==null)return 0;switch(typeof r){case"number":return W.number;case"boolean":return W.boolean;case"string":return W.string+r.length*2;case"bigint":return W.bigint+ns(r);case"symbol":return W.symbol;case"function":return e.has(r)?0:(e.add(r),W.function);case"undefined":return 0}let s=r;if(e.has(s))return 0;e.add(s);let a=s[es];if(typeof a=="function")try{let u=a.call(s);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(s instanceof Date)return W.date;if(s instanceof RegExp)return W.regexp+s.source.length*2;if(s instanceof Error){let u=s.message?s.message.length*2:0,c=s.stack?s.stack.length*2:0;return W.error+u+c}if(typeof URL<"u"&&s instanceof URL)return W.url+s.href.length*2;if(typeof Promise<"u"&&s instanceof Promise)return W.promise;if(s instanceof WeakMap)return W.weakmap;if(s instanceof WeakSet)return W.weakset;if(s instanceof Map){let u=W.map;for(let[c,l]of s)u+=W.mapEntry,n.push(c),n.push(l);return u}if(s instanceof Set){let u=W.set;for(let c of s)u+=W.setEntry,n.push(c);return u}if(Array.isArray(s)){let u=W.array+s.length*8;for(let c of s)n.push(c);return u}if(s instanceof ArrayBuffer)return t.has(s)?0:(t.add(s),s.byteLength);if(ArrayBuffer.isView(s)){let u=s;return t.has(u.buffer)?48:(t.add(u.buffer),u.buffer.byteLength+48)}let i=W.object,d=Object.keys(s);for(let u of d){i+=W.string+u.length*2;try{n.push(s[u])}catch{}}return i}function ns(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 Qr(r,e){let t=e?.topN??10,n=r.describe({detail:"standard"}),o=[],s=r._collectObserveTargets;typeof s=="function"&&s.call(r,"",o);let a=new Map;for(let[p,h]of o)a.set(p,h);let i=[];for(let[p,h]of Object.entries(n.nodes)){let f=a.get(p),m=f instanceof H?f:null,g=m?Jr(m.cache):0,x=m?m._sinkCount:0,v=h.deps?.length??0,_=h.type==="effect"&&x===0,b=x===0?h.type==="effect"?"orphan-effect":h.type==="derived"?"idle-derived":h.type==="producer"?"idle-producer":null:null;i.push({path:p,type:h.type,status:h.status??"unknown",valueSizeBytes:g,subscriberCount:x,depCount:v,isOrphanEffect:_,orphanKind:b})}let d=i.reduce((p,h)=>p+h.valueSizeBytes,0),u=(p,h)=>[...i].sort(h??((f,m)=>m[p]-f[p])).slice(0,t),c=i.filter(p=>p.orphanKind!=null),l=i.filter(p=>p.isOrphanEffect);return{nodeCount:i.length,edgeCount:n.edges.length,subgraphCount:n.subgraphs.length,nodes:i,totalValueSizeBytes:d,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:c,orphanEffects:l}}var $="::",de="__meta__",Ge=1;function Zr(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 o=r.values().next();if(o.done)return;let s=o.value;r.delete(s);try{s()}catch(a){console.error(`[Graph "${e}".destroy] disposer threw:`,a)}}}function ro(r){return r!=null&&typeof r=="object"&&"cache"in r&&typeof r.subscribe=="function"&&typeof r.down=="function"}function rs(r){if(r!=null)return ro(r)?r.cache:r}function Ie(r){return r!=null&&typeof r=="object"&&"cache"in r&&typeof r.subscribe=="function"&&typeof r.down=="function"}function ve(r){return Ie(r)?r.cache??"":r}function Xr(r){return Ie(r)?r.cache??0:r}function eo(r){return Ie(r)?r.cache??!1:r}function os(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(`
11
+ `)}function to(r){if(r.version!==Ge)throw new Error(`unsupported snapshot version ${String(r.version)} (expected ${Ge})`);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 ss(r,e){let t=new WeakMap,n=(o,s)=>{if(Object.is(o,s))return!0;if(o==null||s==null||typeof o!="object"||typeof s!="object")return!1;let a=t.get(o);if(a==null&&(a=new WeakSet,t.set(o,a)),a.has(s))return!0;a.add(s);let i=o.constructor,d=s.constructor;if(i!==d)return!1;if(o instanceof Date)return o.getTime()===s.getTime();if(o instanceof RegExp)return o.source===s.source&&o.flags===s.flags;if(Array.isArray(o)){let p=s;if(o.length!==p.length)return!1;for(let h=0;h<o.length;h++)if(!n(o[h],p[h]))return!1;return!0}if(o instanceof Map){let p=s;if(o.size!==p.size)return!1;for(let[h,f]of o)if(!p.has(h)||!n(f,p.get(h)))return!1;return!0}if(o instanceof Set){let p=s;if(o.size!==p.size)return!1;for(let h of o){let f=!1;for(let m of p)if(n(h,m)){f=!0;break}if(!f)return!1}return!0}if(ArrayBuffer.isView(o)){let p=o,h=s;if(p.length!==h.length)return!1;for(let f=0;f<p.length;f++)if(p[f]!==h[f])return!1;return!0}let u=Object.keys(o),c=Object.keys(s);if(u.length!==c.length)return!1;let l=new Set(c);for(let p of u)if(!l.has(p)||!n(o[p],s[p]))return!1;return!0};return n(r,e)}function is(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ft(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 o=r.indexOf("]",t+1);if(o<=t+1){e+="\\[";continue}let s=r.slice(t+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),e+=`[${s}]`,t=o;continue}e+=is(n)}return e+="$",new RegExp(e)}var as={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"},ds={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function wn(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 us(r){return r==="none"?ds:r==="ansi"||r==null?as:{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 no(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 cs(r,e,t){for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);if(o<32||o===127)throw new Error(`Graph "${e}": ${t} "${r}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${n})`)}}function xn(r,e,t){if(r==="")throw new Error(`Graph "${e}": ${t} name must be non-empty`);if(r.includes($))throw new Error(`Graph "${e}": ${t} "${r}" must not contain '${$}' (path separator)`);if(r===de)throw new Error(`Graph "${e}": ${t} name "${de}" is reserved for meta companion paths`);cs(r,e,t)}function ls(r,e){if(r==="")throw new Error(`Graph "${e}": resolve path must be non-empty`);let t=r.split($);for(let n of t)if(n==="")throw new Error(`Graph "${e}": resolve path has empty segment`);return t}function fs(r,e){let t=!1;for(let o of r)if(!e.isMetaPassthrough(o[0])){t=!0;break}return t?r.filter(o=>e.isMetaPassthrough(o[0])):r}function oo(r){for(let e of r._mounts.values())oo(e);for(let e of r._nodes.values())try{e.down([[V]],{internal:!0})}catch{}}var Z=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($))throw new Error(`Graph name must not contain '${$}' (got "${e}")`);if(e===de)throw new Error(`Graph name "${de}" is reserved for meta companion paths`);this.name=e,this.opts=Object.freeze({...t??{}}),this.config=t?.config??ke,this._traceRing=new lt(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=Ce(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,o=t?.name??n;if(o==null||o==="")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 s=o,a=t?.annotation;if(xn(s,this.name,"add"),this._mounts.has(s))throw new Error(`Graph "${this.name}": name "${s}" is already a mount point`);if(this._nodes.has(s))throw new Error(`Graph "${this.name}": node "${s}" already exists`);let i=this._nodeToName.get(e);if(i!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${i}"`);return this._nodes.set(s,e),this._nodeToName.set(e,s),this._emitTopology({kind:"added",name:s,nodeKind:"node"}),a!=null&&(this._annotations.set(s,a),this.config.inspectorEnabled&&this._traceRing.push({path:s,annotation:a,timestamp_ns:pe()})),e}setVersioning(e){if(e!=null)for(let t of this._nodes.values())t instanceof H&&t._applyVersioning(e)}remove(e){xn(e,this.name,"remove");let t=this._mounts.get(e);if(t){let s={kind:"mount",nodes:[],mounts:[]},a=[];t._collectObserveTargets("",a);for(let[i,d]of a)i.includes(`${$}${de}${$}`)||s.nodes.push(i);return s.nodes.sort(),s.mounts.push(e),s.mounts.push(...t._collectSubgraphs(`${e}${$}`)),this._mounts.delete(e),t._parent=void 0,oo(t),this._emitTopology({kind:"removed",name:e,nodeKind:"mount",audit:s}),s}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([[V]],{internal:!0});let o={kind:"node",nodes:[e],mounts:[]};return this._emitTopology({kind:"removed",name:e,nodeKind:"node",audit:o}),o}removeAll(e){let t=typeof e=="function"?e:(()=>{let s=Ft(e);return a=>s.test(a)})(),n={kind:"mount",nodes:[],mounts:[]},o=[...this._nodes.keys(),...this._mounts.keys()].filter(s=>t(s));for(let s of o){let a=this.remove(s);n.nodes.push(...a.nodes),n.mounts.push(...a.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 o=e[n++];return{value:[o,t.get(o)],done:!1}}}}node(e){if(e==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(e.includes($))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 o=n?.internal===!0;this.node(e).down([[O,t]],{actor:n?.actor,internal:o,delivery:"write"})}setAll(e,t){let n=Symbol.iterator in e?e:Object.entries(e);le(()=>{for(let[o,s]of n)this.set(o,s,t)})}invalidate(e,t){let n=t?.internal===!0;this.node(e).down([[re]],{actor:t?.actor,internal:n,delivery:"write"})}error(e,t,n){let o=n?.internal===!0;this.node(e).down([[D,t]],{actor:n?.actor,internal:o,delivery:"write"})}complete(e,t){let n=t?.internal===!0;this.node(e).down([[I]],{actor:t?.actor,internal:n,delivery:"write"})}edges(e){let t=e?.recursive===!0,n=new Map;if(!t){for(let[d,u]of this._nodes)n.set(u,d);let i=[];for(let[d,u]of this._nodes)if(u instanceof H)for(let c of u._deps){let l=n.get(c.node);l!=null&&i.push([l,d])}return i.sort((d,u)=>d[0]<u[0]?-1:d[0]>u[0]?1:d[1]<u[1]?-1:d[1]>u[1]?1:0),i}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[i,d]of o)s.set(d,i);let a=[];for(let[i,d]of o)if(d instanceof H)for(let u of d._deps){let c=s.get(u.node);c!=null&&a.push([c,i])}return a.sort((i,d)=>i[0]<d[0]?-1:i[0]>d[0]?1:i[1]<d[1]?-1:i[1]>d[1]?1:0),a}mount(e,t){if(t===void 0){let o=new r(e);return this.mount(e,o)}if(typeof t=="function"){let o=new r(e);return t(o),this.mount(e,o)}let n=t;if(xn(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 o=this;o!=null;o=o._parent)if(o===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=ls(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],o=t.slice(1);if(o.length===0){let i=this._nodes.get(n);if(i)return i;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 s=this._nodes.get(n);if(s&&o.length>0&&o[0]===de)return this._resolveMetaChainFromNode(s,o,t.join($));let a=this._mounts.get(n);if(!a)throw this._nodes.has(n)?new Error(`Graph "${this.name}": "${n}" is a node; trailing path "${o.join($)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${n}"`);return a.resolve(o.join($))}_resolveMetaChainFromNode(e,t,n){let o=e,s=0,a=[...t];for(;s<a.length;){if(a[s]!==de)throw new Error(`Graph "${this.name}": expected ${de} segment in meta path "${n}"`);if(s+1>=a.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${de} in "${n}"`);let i=a[s+1],d=o.meta[i];if(!d)throw new Error(`Graph "${this.name}": unknown meta "${i}" in path "${n}"`);o=d,s+=2}return o}signal(e,t){if(t?.internal!==!0){for(let o of e)if(this.config.messageTier(o[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,o){for(let d of this._mounts.values())d._signalDeliver(e,t,n,o);let a=t.internal===!0?{internal:!0}:{actor:t.actor,delivery:"signal"},i=fs(e,this.config);for(let d of[...this._nodes.keys()].sort()){let u=this._nodes.get(d);if(!n.has(u)){n.add(u);try{u.down(e,a)}catch(c){if(c instanceof ie)throw c;o.push(c)}i.length!==0&&this._signalMetaSubtree(u,i,n,a,o)}}}_signalMetaSubtree(e,t,n,o,s){for(let a of Object.keys(e.meta).sort()){let i=e.meta[a];if(!n.has(i)){n.add(i);try{i.down(t,o)}catch(d){if(d instanceof ie)throw d;s.push(d)}this._signalMetaSubtree(i,t,n,o,s)}}}describe(e){if(e?.reactive==="diff")return this._describeReactiveDiff(e);if(e?.reactive===!0)return this._describeReactive(e);let t=rs(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 o=Gt(e?.detail,e?.fields),s=e?.detail==="spec",a=o,i=[];this._collectObserveTargets("",i);let d=new Map;for(let[b,T]of i)d.set(T,b);let u=[];{let b=i.map(([,y])=>y),T=new Set(d.values()),N=0;for(;b.length>0;){let y=b.shift();if(y instanceof H)for(let E of y._deps){let S=E.node;if(d.has(S))continue;let R=S.name??"",w=R;if(!w||T.has(w))if(R){let k=2;for(;T.has(`${R}#${k}`);)k++;w=`${R}#${k}`}else for(w=`__internal__/${N++}`;T.has(w);)w=`__internal__/${N++}`;d.set(S,w),T.add(w),u.push([w,S]),b.push(S)}}}let c=[...i,...u],l={};for(let[b,T]of c){if(t!=null&&!T.allowsObserve(t))continue;let N=bn(T,a,s),y=T instanceof H?T._deps.map(w=>d.get(w.node)??w.node.name??""):[],{name:E,...S}=N,R={...S,deps:y};if(!s){let w=this._annotations.get(b);w!=null&&(R.annotation=w)}if(n!=null)if(typeof n=="function"){let w=n;if(!(w.length>=2?w(b,R):w(R)))continue}else{let w=!0;for(let[k,M]of Object.entries(n)){let A=k==="deps_includes"?"depsIncludes":k==="meta_has"?"metaHas":k;if(A==="depsIncludes"){if(!R.deps.includes(String(M))){w=!1;break}continue}if(A==="metaHas"){if(!Object.hasOwn(R.meta??{},String(M))){w=!1;break}continue}if(R[A]!==M){w=!1;break}}if(!w)continue}l[b]=R}let p=new Set(Object.keys(l)),h=[];for(let[b,T]of c)if(T instanceof H)for(let N of T._deps){let y=d.get(N.node);y!=null&&h.push([y,b])}h.sort((b,T)=>b[0]<T[0]?-1:b[0]>T[0]?1:b[1]<T[1]?-1:b[1]>T[1]?1:0);let f=h.map(([b,T])=>({from:b,to:T}));(t!=null||n!=null)&&(f=f.filter(b=>p.has(b.from)&&p.has(b.to)));let m=this._collectSubgraphs(""),g=t!=null||n!=null?m.filter(b=>{let T=`${b}${$}`;return[...p].some(N=>N===b||N.startsWith(T))}):m,x=this,v=e;return{name:this.name,nodes:l,edges:f,subgraphs:g,...this._factory!==void 0?{factory:this._factory}:{},...this._factoryArgs!==void 0?{factoryArgs:this._factoryArgs}:{},expand(b){let T={...v};return Array.isArray(b)?(T.fields=b,T.detail=void 0):(T.detail=b,T.fields=void 0),x.describe(T)}}}_collectSubgraphs(e){let t=[];for(let n of[...this._mounts.keys()].sort()){let o=e===""?n:`${e}${n}`;t.push(o),t.push(...this._mounts.get(n)._collectSubgraphs(`${o}${$}`))}return t}resourceProfile(e){return Qr(this,e)}reachable(e,t,n={}){return n.withDetail===!0?Rn(this.describe(),e,t,{...n,withDetail:!0}):Rn(this.describe(),e,t,n)}explain(e,t,n){return n?.reactive===!0?this._explainReactive(e,t,n):this._explainStatic(ve(e),ve(t),{...n?.maxDepth!==void 0?{maxDepth:Xr(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:eo(n.findCycle)}:{}})}_explainStatic(e,t,n){let o=this.describe({detail:"full"}),s=new Map(this._annotations),a=new Map;for(let[i,d]of Object.entries(o.nodes))d.lastMutation!=null&&a.set(i,d.lastMutation);return Br(o,e,t,{...n?.maxDepth!=null?{maxDepth:n.maxDepth}:{},...n?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:a})}_describeReactive(e){let t={...e,reactive:!1},n=e.reactiveName??"describe",o=0,s=F(o,{name:`${n}_version`}),a=this.observe({timeline:!0,structured:!0}),i=!1,d=!1,u=()=>{i||d||(i=!0,He(()=>{i=!1,!d&&(o+=1,s.emit(o))}))},c=a.onEvent(v=>{let _=v.type;_!=="data"&&_!=="error"&&_!=="complete"&&_!=="teardown"||u()}),l=[],p=new WeakSet,h=v=>{if(p.has(v)||d)return;p.add(v);let _=v.topology.subscribe(b=>{for(let T of b){if(T[0]!==O)continue;let N=T[1];if(u(),N.kind==="added"&&N.nodeKind==="mount"){let y=v._mounts.get(N.name);y!=null&&h(y)}}});l.push(_);for(let b of v._mounts.keys()){let T=v._mounts.get(b);T!=null&&h(T)}};h(this);let f,m=e.actor;ro(m)&&(f=m.subscribe(v=>{let _=!1,b=!1;for(let T of v){let N=T[0];N===O?_=!0:(N===I||N===D||N===V)&&(b=!0)}_&&u(),b&&(f?.(),f=void 0,u())}));let g;try{g=J([s],()=>this.describe(t),{name:n,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(v,_)=>v===_})}catch(v){c(),f?.();for(let _ of l)_();throw a.dispose(),v}let x=ge(g);return{node:g,dispose(){d=!0,c(),f?.();for(let v of l)v();l.length=0,a.dispose(),x()}}}_describeReactiveDiff(e){let t={...e,reactive:!1},n=e.reactiveName??"describe-diff",o={name:this.name,nodes:{},edges:[],subgraphs:[]},s=this.describe(t),a=Tn(o,s),i=F(a,{name:n,meta:{domain:"audit",kind:"describe-diff"},equals:(p,h)=>p===h}),d=this._describeReactive({...e,reactiveName:void 0}),u=!1,c=d.node.subscribe(p=>{if(!u)for(let h of p){if(h[0]!==O)continue;let f=h[1],m=Tn(s,f);s=f,m.events.length!==0&&i.emit(m)}}),l=ge(i);return{node:i,dispose(){u=!0,c(),d.dispose(),i.down([[V,"describe-diff disposed"]]),l()}}}_explainReactive(e,t,n){let o=0,s=F(o,{name:"explain_version"}),a=this.observe({timeline:!0,structured:!0}),i=!1,d=!1,u=()=>{i||d||(i=!0,He(()=>{i=!1,!d&&(o+=1,s.emit(o))}))},c=a.onEvent(v=>{let _=v.type;_!=="data"&&_!=="error"&&_!=="complete"&&_!=="teardown"||u()}),l=[];e!=null&&Ie(e)&&l.push(e),t!=null&&Ie(t)&&l.push(t),n?.maxDepth!=null&&Ie(n.maxDepth)&&l.push(n.maxDepth),n?.findCycle!=null&&Ie(n.findCycle)&&l.push(n.findCycle);let p=()=>{for(let v of l)if(v.cache===void 0)return!1;return!0},h=()=>{let v=ve(e),_=ve(t);return{from:v,to:_,found:!1,reason:"pending",steps:[],text:"(awaiting reactive args)",toJSON:()=>({from:v,to:_,found:!1,reason:"pending",steps:[]})}},f;try{f=J([s],()=>{if(!p())return h();let v=ve(e),_=ve(t),b={...n?.maxDepth!==void 0?{maxDepth:Xr(n.maxDepth)}:{},...n?.findCycle!==void 0?{findCycle:eo(n.findCycle)}:{}};return this._explainStatic(v,_,b)},{name:n?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:ve(e),to:ve(t)},equals:(v,_)=>v.found===_.found&&v.reason===_.reason&&v.steps.length===_.steps.length&&ps(v.steps,_.steps)})}catch(v){throw c(),a.dispose(),v}let m=ge(f),g=[],x=v=>{let _;return _=v.subscribe(b=>{let T=!1,N=!1;for(let y of b){let E=y[0];E===O?T=!0:(E===I||E===D||E===V)&&(N=!0)}(T||N)&&u(),N&&_&&(_(),_=void 0)}),()=>{_&&(_(),_=void 0)}};for(let v of l)g.push(x(v));return{node:f,dispose(){d=!0,c();for(let v of g)v?.();g.length=0,a.dispose(),m()}}}_pathsMatching(e){let t=Ft(e),n=[];return this._collectObserveTargets("",n),n.map(([o])=>o).filter(o=>t.test(o))}_collectObserveTargets(e,t){for(let n of[...this._mounts.keys()].sort()){let o=e===""?n:`${e}${$}${n}`;this._mounts.get(n)._collectObserveTargets(o,t)}for(let n of[...this._nodes.keys()].sort()){let o=this._nodes.get(n),s=e===""?n:`${e}${$}${n}`;t.push([s,o]),this._appendMetaObserveTargets(s,o,t)}}_appendMetaObserveTargets(e,t,n){for(let o of Object.keys(t.meta).sort()){let s=t.meta[o],a=`${e}${$}${de}${$}${o}`;n.push([a,s]),this._appendMetaObserveTargets(a,s,n)}}observe(e,t){let n=typeof e=="string",s=no(n?t:e);if(s.reactive===!0)return this._observeReactive(n?e:void 0,s);let a=s.structured===!0||s.timeline===!0||s.causal===!0||s.derived===!0||s.detail==="minimal"||s.detail==="full"||s.format!=null,i=s.actor;if(n){let c=e,l=this.resolve(c);if(i!=null&&!l.allowsObserve(i))throw new ie({actor:i,action:"observe",nodeName:c});return a?this._buildStructuredObserver([[c,l]],s,"one"):{subscribe(p){return l.subscribe(p)},up(p){try{l.up?.(p)}catch(h){if(h instanceof ie)return;throw h}}}}let d=[];this._collectObserveTargets("",d),d.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let u=i==null?d:d.filter(([,c])=>c.allowsObserve(i));return a?this._buildStructuredObserver(u,s,"all"):{subscribe:c=>{let l=u.map(([p,h])=>h.subscribe(f=>{c(p,f)}));return()=>{for(let p of l)p()}},up:(c,l)=>{try{this.resolve(c).up?.(l)}catch(p){if(p instanceof ie)return;throw p}}}}_observeReactive(e,t){let n=t.tiers,o=n!=null?new Set(n):null,s=t.reactiveName??"observe";return Ce(a=>{let i=[],d=!1,u=!1,c=()=>{if(i.length===0||u)return;let m={events:i.slice(),flushedAt_ns:pe()};i.length=0,a.emit(m)},l={...t,reactive:!1,structured:!0,timeline:!0},p=e!=null?this.observe(e,l):this.observe(l),h=m=>{u||(i.push(m),!d&&(d=!0,He(()=>{d=!1,c()})))};for(let m of p.events)h(m);let f=p.onEvent(h);return()=>{u=!0,f(),p.dispose()}},{name:s,meta:{domain:"audit",kind:"observe-reactive"}})}_buildStructuredObserver(e,t,n){let o=n==="one"?e[0]?.[0]:void 0,s=a=>{if(n==="one"&&o!=null){let c=this.resolve(o);return this._buildStructuredObserver([[o,c]],a,"one")}let i=[];this._collectObserveTargets("",i),i.sort((c,l)=>c[0]<l[0]?-1:c[0]>l[0]?1:0);let d=a.actor,u=d==null?i:i.filter(([,c])=>c.allowsObserve(d));return this._buildStructuredObserver(u,a,"all")};return this._createObserveResult(e,t,s)}_createObserveResult(e,t,n){let o=t.timeline===!0,s=t.causal===!0,a=t.derived===!0,i=t.detail==="minimal",d=this.config.inspectorEnabled,u=(s||a)&&d,c=t.maxEvents,l=c!=null&&c>0?new lt(c):null,p=[],h=new Set,f=t.tiers!=null?new Set(t.tiers):null,m={},g=new Set,x=0,v=0,_=0,b=0,T=0,N=0,y=!1,E=!1,S=0,R=new Map,w=new Map,k=new Map,M=C=>{if(!(f!=null&&!f.has(C.type))){l?l.push(C):p.push(C);for(let L of h)L(C)}},A=C=>f==null||f.has(C),q=()=>o?{timestamp_ns:pe(),in_batch:xt(),batch_id:S}:{},B=(C,L)=>{if(!(!u||!(C instanceof H)))return C._setInspectorHook(te=>{if(te.kind==="dep_message")R.set(C,te.depIndex);else if(te.kind==="run"){let et=te.batchData.map((G,Y)=>G!=null&&G.length>0?G.at(-1):te.prevData[Y]);w.set(C,et);let ne=te.batchData.map(G=>G!=null?[...G]:void 0);k.set(C,ne),a&&M({type:"derived",path:L,dep_values:et,dep_batches:ne,...q()})}})},X=C=>{let L=R.get(C),te=w.get(C);if(!s||te==null)return{};let ne=(L!=null&&L>=0&&C instanceof H?C._deps[L]:void 0)?.node,G=ne?.v,Y=k.get(C);return{trigger_dep_index:L,trigger_dep_name:ne?.name,...G!=null?{trigger_version:{id:G.id,version:G.version}}:{},dep_values:[...te],...Y!=null?{dep_batches:Y}:{}}},Pe=[],Le=[];for(let[C,L]of e){let te=B(L,C);te&&Pe.push(te),Le.push(L.subscribe(et=>{S++;for(let ne of et){let G=ne[0],Y=q();if(G===O){m[C]=ne[1];let Ut=L instanceof H?L.lastMutation?.actor??be:be;M({type:"data",path:C,data:ne[1],actor:Ut,...Y,...X(L)})}else if(i)G===P?A("dirty")&&x++:G===z?A("resolved")&&v++:G===re?A("invalidate")&&_++:G===ee?A("pause")&&b++:G===oe?A("resume")&&T++:G===V?A("teardown")&&N++:G===I&&!g.has(C)?A("complete")&&(y=!0):G===D&&A("error")&&(E=!0,g.add(C));else if(G===P)A("dirty")&&x++,M({type:"dirty",path:C,...Y});else if(G===z)A("resolved")&&v++,M({type:"resolved",path:C,...Y,...X(L)});else if(G===re)A("invalidate")&&_++,M({type:"invalidate",path:C,...Y});else if(G===ee)A("pause")&&b++,M({type:"pause",path:C,lockId:ne[1],...Y});else if(G===oe)A("resume")&&T++,M({type:"resume",path:C,lockId:ne[1],...Y});else if(G===I)A("complete")&&!g.has(C)&&(y=!0),M({type:"complete",path:C,...Y});else if(G===D){A("error")&&(E=!0,g.add(C));let Ut=L instanceof H?L.lastMutation?.actor??be:be;M({type:"error",path:C,data:ne[1],actor:Ut,...Y})}else G===V&&(A("teardown")&&N++,M({type:"teardown",path:C,...Y}))}}))}let Ze=!1,Xe=()=>{if(!Ze){Ze=!0;for(let C of Le)C();for(let C of Pe)C();for(let C of bt)C({value:void 0,done:!0});bt.length=0}},Kt=[],bt=[];h.add(C=>{let L=bt.shift();L?L({value:C,done:!1}):Kt.push(C)});let Vn={get values(){return m},get dirtyCount(){return x},get resolvedCount(){return v},get invalidateCount(){return _},get pauseCount(){return b},get resumeCount(){return T},get teardownCount(){return N},get events(){return l?l.toArray():[...p]},get anyCompletedCleanly(){return y},get anyErrored(){return E},get completedWithoutErrors(){return y&&!E},onEvent(C){return h.add(C),()=>h.delete(C)},dispose:Xe,expand(C){Xe();let L={...t};return typeof C=="string"?L.detail=C:Object.assign(L,C),n(no(L))},[Symbol.asyncIterator](){return{next(){return Kt.length>0?Promise.resolve({value:Kt.shift(),done:!1}):Ze?Promise.resolve({value:void 0,done:!0}):new Promise(C=>bt.push(C))},return(){return Xe(),Promise.resolve({value:void 0,done:!0})}}}};return t.format!=null&&this._attachFormatLogger(Vn,t),Vn}_attachFormatLogger(e,t){let n=t.format;if(n==null)return;let o=t.logger??(f=>console.log(f)),s=t.includeTypes?new Set(t.includeTypes):null,a=t.excludeTypes?new Set(t.excludeTypes):null,i=s==null&&a==null?()=>!0:f=>(s==null||s.has(f))&&(a==null||!a.has(f)),d=us(t.theme),u=n==="stage-log"?pe():0,c=f=>f==null?"":t.stageLabels?.[f]??f,l=(f,m)=>f.length>m?`${f.slice(0,m-1)}\u2026`:f,p=f=>f.type==="data"||f.type==="error"?l(wn(f.data),120):"",h=f=>{if(n==="stage-log"){let y=(pe()-u)/1e9,E=c(f.path).padEnd(9);if(f.type==="data"){let S=p(f);return`[${y.toFixed(3)}s] ${E} \u2190${S?` ${S}`:""}`}if(f.type==="error"){let S=p(f);return`[${y.toFixed(3)}s] ${E} \u2717${S?` ${S}`:""}`}return f.type==="complete"?`[${y.toFixed(3)}s] ${E} \u25A0 complete`:`[${y.toFixed(3)}s] ${E} ${f.type}`}if(n==="json")try{return JSON.stringify(f)}catch{return JSON.stringify({type:f.type,path:f.path,data:"[unserializable]"})}let m=d[f.type]??"",g=f.path?`${d.path}${f.path}${d.reset} `:"",x=f.type==="data"||f.type==="error",v=f.type==="pause"||f.type==="resume",_=x?` ${wn(f.data)}`:v?` ${wn(f.lockId)}`:"",b=f.type==="data"||f.type==="resolved"||f.type==="derived"?f:void 0,T=b?.trigger_dep_name!=null?` <- ${b.trigger_dep_name}`:b?.trigger_dep_index!=null?` <- #${b.trigger_dep_index}`:"",N=f.in_batch?" [batch]":"";return`${g}${m}${f.type.toUpperCase()}${d.reset}${_}${T}${N}`};e.onEvent(f=>{i(f.type)&&o(h(f),f)})}addDisposer(e){return this._disposers.add(e),()=>{this._disposers.delete(e)}}destroy(){Zr(this._disposers,this.name),this.signal([[V]],{internal:!0}),Zr(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"}),o={};for(let i of Object.keys(n.nodes).sort()){let{lastMutation:d,guard:u,...c}=n.nodes[i];o[i]=c}let s=[...n.subgraphs].sort(),a={...n,version:1,nodes:o,subgraphs:s};if(e?.format==null)return a;if(e.format==="json-string")return JSON.stringify(a);if(e.format==="bytes"){if(e.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let i=this.config.lookupCodec(e.codec);if(i==null)throw new Error(`snapshot: codec "${e.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return er(i,i.encode(a))}throw new Error(`snapshot: unknown format "${String(e.format)}"`)}static decode(e,t){let n=t?.config??ke,{codec:o,codecVersion:s,payload:a}=tr(e,n);return o.decode(a,s)}restore(e,t){if(to(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(s=>Ft(s)),o=t?.includeProducers===!0;for(let s of Object.keys(e.nodes).sort()){if(n!==null&&!n.some(i=>i.test(s)))continue;let a=e.nodes[s];if(a!==void 0){if(!("value"in a)||a.value===void 0){"value"in a&&a.value===void 0&&t?.onError?.(s,new Error(`restore: slice.value is undefined for "${s}" (undefined is the global SENTINEL; not valid DATA)`));continue}if(!(a.type==="derived"||a.type==="effect")&&!(a.type==="producer"&&!o)){if(a.v!=null){let d=this.tryResolve(s)?.v;if(d!=null&&d.id===a.v.id&&d.version===a.v.version)continue}try{this.set(s,a.value)}catch(i){t?.onError?.(s,i)}}}}}static fromSnapshot(e,t){to(e);let n=typeof t=="function"?t:t?.build,o=typeof t=="function"?void 0:t?.factories,s=new r(e.name);if(n)return n(s),s.restore(e),s;for(let h of[...e.subgraphs].sort((f,m)=>{let g=f.split($).length,x=m.split($).length;return g!==x?g-x:f<m?-1:f>m?1:0})){let f=h.split($),m=s;for(let g of f)m._mounts.has(g)||m.mount(g,new r(g)),m=m._mounts.get(g)}let a=o?Object.entries(o).map(([h,f])=>({re:Ft(h),factory:f})):[],i=h=>{for(let f of a)if(f.re.test(h))return f.factory},d=h=>{let f=h.split($),m=f.pop();if(m==null||m.length===0)throw new Error(`invalid snapshot path "${h}"`);let g=s;for(let x of f){let v=g._mounts.get(x);if(!v)throw new Error(`unknown mount "${x}" in path "${h}"`);g=v}return[g,m]},u=Object.entries(e.nodes).filter(([h])=>!h.includes(`${$}${de}${$}`)).sort((h,f)=>h[0]<f[0]?-1:h[0]>f[0]?1:0),c=new Map(u),l=new Map,p=!0;for(;c.size>0&&p;){p=!1;for(let[h,f]of[...c.entries()]){let m=f?.deps??[];if(!m.every(T=>l.has(T)))continue;let[g,x]=d(h),v={...f?.meta??{}},_=i(h),b;if(f?.type==="state")b=F(f.value,{meta:v});else{if(_==null)continue;b=_(x,{path:h,type:f.type,value:f.value,meta:v,deps:m,resolvedDeps:m.map(T=>l.get(T))})}g.add(b,{name:x}),l.set(h,b),c.delete(h),p=!0}}if(c.size>0){let h=[...c.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${h}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(e),s}toJSON(){return this.snapshot()}attachSnapshotStorage(e,t={}){let n=e.map(u=>({tier:u,debounceMs:Math.max(0,u.debounceMs??0),compactEvery:Math.max(1,u.compactEvery??10),timer:void 0,seq:0,lastSnapshot:void 0,lastFingerprint:"",disposed:!1,savePending:void 0}));t.autoRestore===!0&&this._cascadeRestore(e,t.onError);let o=(u,c)=>{if(u.disposed)return;let l=os(c.nodes);if(u.lastSnapshot!=null&&l!==""&&l===u.lastFingerprint)return;let p=u.seq+1,h=se(),g=u.lastSnapshot==null||p%u.compactEvery===0?{name:this.name,mode:"full",snapshot:c,seq:p,timestamp_ns:h,format_version:Ge}:{name:this.name,mode:"diff",diff:so(u.lastSnapshot,c),seq:p,timestamp_ns:h,format_version:Ge};if(u.tier.filter&&!u.tier.filter(g))return;let x;try{x=u.tier.save(g)}catch(v){t.onError?.(v,u.tier);return}if(x&&typeof x.then=="function"){let b=(u.savePending??Promise.resolve()).then(()=>x,()=>x).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=c,u.lastFingerprint=l)},T=>{t.onError?.(T,u.tier)});u.savePending=b.finally(()=>{u.savePending===b&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=c,u.lastFingerprint=l},s=(u,c)=>{try{o(u,c)}catch(l){t.onError?.(l,u.tier)}},a=(u,c)=>{if(!c.some(f=>{let m=this.config.messageTier(f[0]);return m>=3&&m<5}))return;if(t.filter){let f=this.tryResolve(u);if(f==null)return;let m=bn(f,Gt("standard"));if(!t.filter(u,m))return}let p,h=()=>(p==null&&(p=this.snapshot()),p);for(let f of n)f.disposed||(f.debounceMs===0?s(f,h()):(f.timer==null&&(f.timer=new It),f.timer.start(f.debounceMs,()=>{f.disposed||s(f,this.snapshot())})))},i;if(t.paths!=null){let c=(typeof t.paths=="string"?this._pathsMatching(t.paths):t.paths).map(l=>{let p=this.tryResolve(l);return p==null?()=>{}:p.subscribe(h=>a(l,h))});i=()=>{for(let l of c)l()}}else i=this.observe().subscribe((u,c)=>a(u,c));let d=()=>{i();for(let u of n)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(d)};return this._storageDisposers.add(d),{dispose:d}}async _cascadeRestore(e,t){for(let n of e){let o;try{o=await n.load?.()}catch(a){t?.(a,n);continue}if(o==null||typeof o!="object"||Array.isArray(o))continue;let s=o;try{if(s.mode==="full"&&s.snapshot!=null)return this.restore(s.snapshot),!0;if(s.version===Ge&&s.nodes!=null)return this.restore(s),!0}catch(a){t?.(a,n)}}return!1}static async fromStorage(e,t,n){for(let o of t){let s;try{s=await o.load?.()}catch(d){n?.onError?.(d,o);continue}if(s==null||typeof s!="object"||Array.isArray(s))continue;let a=s,i=a.mode==="full"&&a.snapshot!=null?a.snapshot:a.version===Ge&&a.nodes!=null?a:void 0;if(i!=null)try{return r.fromSnapshot(i,n)}catch(d){n?.onError?.(d,o)}}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 o={path:e,annotation:t,timestamp_ns:pe(),...n?.actor!=null?{actor:n.actor}:{}};this._traceRing.push(o)}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(o=>!e(o)),n=this._traceRing.size-t.length;this._traceRing.clear();for(let o of t)this._traceRing.push(o);return n}static diff(e,t){let n=new Set(Object.keys(e.nodes)),o=new Set(Object.keys(t.nodes)),s=[...o].filter(v=>!n.has(v)).sort(),a=[...n].filter(v=>!o.has(v)).sort(),i=[],d=[];for(let v of n){if(!o.has(v))continue;let _=e.nodes[v],b=t.nodes[v],T=_.v,N=b.v;T!=null&&N!=null&&T.id===N.id&&T.version!==N.version&&d.push({path:v,id:T.id,from:T.version,to:N.version});let y=T!=null&&N!=null&&T.id===N.id&&T.version===N.version;for(let E of["type","status","sentinel"]){let S=_[E],R=b[E];S!==R&&i.push({path:v,field:E,from:S,to:R})}if(!y)for(let E of["value","meta"]){let S=_[E],R=b[E];ss(S,R)||i.push({path:v,field:E,from:S,to:R})}}let u=v=>`${v.from} ${v.to}`,c=new Set(e.edges.map(u)),l=new Set(t.edges.map(u)),p=t.edges.filter(v=>!c.has(u(v))),h=e.edges.filter(v=>!l.has(u(v))),f=new Set(e.subgraphs),m=new Set(t.subgraphs),g=[...m].filter(v=>!f.has(v)).sort(),x=[...f].filter(v=>!m.has(v)).sort();return{nodesAdded:s,nodesRemoved:a,nodesChanged:i,versionChanges:d,edgesAdded:p,edgesRemoved:h,subgraphsAdded:g,subgraphsRemoved:x}}};function so(r,e){let t=Z.diff(r,e),n={};for(let o of t.nodesAdded){let s=e.nodes[o];s!=null&&(n[o]=s)}return{...t,nodesAddedFull:n}}function Rn(r,e,t,n={}){let o={paths:[],depths:new Map,truncated:!1};if(!e)return n.withDetail?o:[];if(!n.both&&t!=="upstream"&&t!=="downstream")throw new Error('reachable: direction must be "upstream" or "downstream"');let s=n.maxDepth;if(s!=null&&(!Number.isInteger(s)||s<0))throw new Error("reachable: maxDepth must be an integer >= 0");if(s===0)return n.withDetail?o:[];let a=new Map,i=new Map,d=new Map,u=new Map,c=new Set;for(let[_,b]of Object.entries(r.nodes)){if(!_)continue;c.add(_);let T=b.deps??[];a.set(_,T);for(let N of T)N&&(c.add(N),i.has(N)||i.set(N,new Set),i.get(N).add(_))}for(let _ of r.edges){if(_==null||typeof _!="object")continue;let b=typeof _.from=="string"?_.from:"",T=typeof _.to=="string"?_.to:"";!b||!T||(c.add(b),c.add(T),u.has(b)||u.set(b,new Set),u.get(b).add(T),d.has(T)||d.set(T,new Set),d.get(T).add(b))}if(!c.has(e))return n.withDetail?o:[];let l=n.both===!0,p=_=>{if(l){let y=a.get(_)??[],E=d.get(_),S=i.get(_),R=u.get(_),w=[...y];return E&&w.push(...E),S&&w.push(...S),R&&w.push(...R),w}if(t==="upstream"){let y=a.get(_)??[],E=d.get(_);return E?[...y,...E]:y}let b=i.get(_),T=u.get(_),N=b?[...b]:[];return T&&N.push(...T),N},h=new Set([e]),f=new Map,m=[{path:e,depth:0}],g=0,x=!1;for(;g<m.length;){let _=m[g++];if(s!=null&&_.depth>=s){p(_.path).length>0&&(x=!0);continue}for(let b of p(_.path))!b||h.has(b)||(h.add(b),f.set(b,_.depth+1),m.push({path:b,depth:_.depth+1}))}let v=[...f.keys()].sort((_,b)=>_<b?-1:_>b?1:0);return n.withDetail?{paths:v,depths:f,truncated:x}:v}function ps(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++){let n=r[t],o=e[t];if(n.path!==o.path||n.type!==o.type||n.status!==o.status||n.hop!==o.hop||n.dep_index!==o.dep_index||n.annotation!==o.annotation||n.value!==o.value||n.lastMutation!==o.lastMutation)return!1;let s=n.v,a=o.v;if(s!==a&&(s==null||a==null||s.id!==a.id||s.version!==a.version))return!1}return!0}Ne();qe();Se();rt();Se();K();vn();Ae();fe();Se();fe();Ne();K();Ae();fe();var En=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),o=e.length-n;for(let s=0;s<n;s++)this._buf[s]=e[o+s];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),o=Math.min(e,this._size);if(o>=n)return[];let s=n-o;if(this._maxSize===void 0)return this._buf.slice(o,n);let a=new Array(s);for(let i=0;i<s;i++)a[i]=this._buf[(this._head+o+i)%this._maxSize];return a}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 s=0;s<t;s++)this._buf[s]=void 0;this._head=0;let n=Math.min(e.length,t),o=e.length-n;for(let s=0;s<n;s++)this._buf[s]=e[o+s];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 ft(r){return r.subscribe(()=>{})}var hs=64;function pt(r,e={}){let{name:t,maxSize:n,versioning:o,guard:s,backend:a}=e,i=a??new En(r,n),d=F(i.toArray(),{name:t,describeKind:"state",equals:(y,E)=>y===E,...o!=null?{versioning:o}:{},...s!=null?{guard:s}:{}});function u(){let y=i.toArray();le(()=>{d.down([[P]],{internal:!0}),d.down([[O,y]],{internal:!0})})}let c=new Map,l=new Map,p=new Map;function h(y,E){return`${y}:${E===void 0?"END":E}`}function f(y){if(y.size<hs)return;let E=y.keys().next();if(E.done)return;let S=y.get(E.value);S!==void 0&&S.dispose(),y.delete(E.value)}function m(y){let E=i.version;try{return y()}finally{i.version!==E&&u()}}function g(y){if(!Number.isInteger(y)||y<0)throw new RangeError(`tail: n must be a non-negative integer (got ${y})`);let E=c.get(y);if(E!==void 0)return c.delete(y),c.set(y,E),E.node;f(c);let S=J([d],([w])=>{let k=w;return y===0||k.length===0?[]:k.slice(Math.max(0,k.length-y))},{initial:i.tail(y),describeKind:"derived"}),R=ft(S);return c.set(y,{node:S,dispose:R}),S}function x(y,E){if(!Number.isInteger(y)||y<0)throw new RangeError(`slice: start must be a non-negative integer (got ${y})`);if(E!==void 0&&(!Number.isInteger(E)||E<0))throw new RangeError(`slice: stop must be a non-negative integer or undefined (got ${E})`);let S=h(y,E),R=l.get(S);if(R!==void 0)return l.delete(S),l.set(S,R),R.node;f(l);let w=J([d],([M])=>{let A=M;return E===void 0?A.slice(y):A.slice(y,E)},{initial:i.slice(y,E),describeKind:"derived"}),k=ft(w);return l.set(S,{node:w,dispose:k}),w}function v(y){let E=p.get(y);if(E!==void 0)return E.node;let S=J([d,y],([w,k])=>{let M=w,A=Math.max(0,Math.trunc(k??0));return M.slice(A)},{initial:[],describeKind:"derived"}),R=ft(S);return p.set(y,{node:S,dispose:R}),S}let _,b;function T(){_===void 0&&(_=he([d],(y,E,S)=>{let R=y[0],k=R!=null&&R.length>0?R.at(-1):S.prevData[0];if(k==null||k.length===0){E.down([[z]]);return}E.emit(k[k.length-1])},{name:t!=null?`${t}::lastValue`:"lastValue",describeKind:"derived",initial:i.size===0?void 0:i.at(i.size-1)}),b=J([d],([y])=>y.length>0,{name:t!=null?`${t}::hasLatest`:"hasLatest",describeKind:"derived",initial:i.size>0}),ft(_),ft(b))}let N={entries:d,get size(){return i.size},at(y){return i.at(y)},append(y){m(()=>i.append(y))},appendMany(y){y.length!==0&&m(()=>i.appendMany(y))},clear(){m(()=>i.clear())},trimHead(y){m(()=>i.trimHead(y))},withLatest(){return T(),d},get lastValue(){return T(),_},get hasLatest(){return T(),b},view(y){switch(y.kind){case"tail":return g(y.n);case"slice":return x(y.start,y.stop);case"fromCursor":return v(y.cursor)}},attach(y){let E=y.subscribe(S=>{for(let R of S)R[0]===O&&N.append(R[1])});return()=>E()},attachStorage(y){if(y.length===0)return()=>{};let E=new Map;for(let R of y)E.set(R,i.size);(async()=>{for(let R of y)if(typeof R.loadEntries=="function")try{let w=await Promise.resolve(R.loadEntries());w.entries.length>0&&i.size===0&&(i.restore(w.entries),E.set(R,w.entries.length),u());break}catch{}})();let S=d.subscribe(R=>{for(let w of R){if(w[0]!==O)continue;let k=w[1];for(let M of y){let A=E.get(M)??0;if(k.length<A){try{let B=M.appendEntries(k);B instanceof Promise&&B.catch(()=>{})}catch{}E.set(M,k.length);continue}if(k.length===A)continue;let q=k.slice(A);E.set(M,k.length);try{let B=M.appendEntries(q);B instanceof Promise&&B.catch(()=>{})}catch{}}}});return()=>S()},disposeAllViews(){for(let y of c.values())y.dispose();c.clear();for(let y of l.values())y.dispose();l.clear();for(let y of p.values())y.dispose();p.clear()},dispose(){for(let y of c.values())y.dispose();c.clear();for(let y of l.values())y.dispose();l.clear();for(let y of p.values())y.dispose();p.clear()}};return N}var gs=je((r,e)=>{r("observe"),r("signal"),e("write")});function Vt(r){let e=pt([],{name:r.name,maxSize:r.retainedLimit??1024,guard:r.guard??gs,...r.versioning!=null?{versioning:r.versioning}:{}});return e.withLatest(),r.graph&&r.graph.add(e.entries,{name:r.name}),e}function io(r,e,t=0){let n=F(t,{name:e,describeKind:"state"});return r.add(n,{name:e}),n}function ao(r,e,t,n=0){let o={},s=new Z(e);for(let a of t){let i=F(n,{name:a,describeKind:"state"});s.add(i,{name:a}),o[a]=i}return r.mount(e,s),o}var _e=class extends Error{constructor(e,t){super(e,t),this.name=this.constructor.name}},Ht=class extends _e{constructor(t,n){super(`Duplicate ${t} registration: "${n}"`);this.kind=t;this.registrationName=n}},qt=class extends _e{constructor(t,n,o){super(`Command "${t}" emitted undeclared event "${n}". Declared emits: [${o.join(", ")}]`);this.commandName=t;this.eventName=n;this.declaredEmits=o}},jt=class extends _e{constructor(t,n,o){super(`Optimistic concurrency conflict on aggregate "${t}": expected version ${n}, got ${o}`);this.aggregateId=t;this.expected=n;this.actual=o}},zt=class extends _e{constructor(t){super(`Unknown command: "${t}". Register with command() first.`);this.commandName=t}},ht=class extends _e{constructor(t,n){super(`Command handler "${t}" threw: ${n instanceof Error?n.message:String(n)}`,{cause:n});this.commandName=t}};var gt=class extends _e{constructor(t,n){super(`Projection "${t}" rebuild failed: ${n instanceof Error?n.message:String(n)}`,{cause:n});this.projectionName=t}};co();At();var ms=je((r,e)=>{r("write"),r("signal"),e("observe")}),ys=je((r,e)=>{r("observe"),r("signal"),e("write")}),lo=je((r,e)=>{r("observe"),r("signal"),e("write")});function mt(r,e){return uo("cqrs",r,e)}function On(r){if(r===null||typeof r!="object"||Object.isFrozen(r))return r;for(let e of Object.keys(r))On(r[e]);return Object.freeze(r)}var Nn=class extends Z{_eventLogs=new Map;_eventLogsByAggregate=new Map;_aggregateVersions=new Map;_aggregateLru=new Map;_commandRegs=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_seq=0;_retainedLimit;_freezeCommandPayload;_freezeEventPayload;_maxAggregates;_dispatchSeqCursor;dispatches;audit;aggregateEvictions;constructor(e,t={}){super(e,t.graph),this._retainedLimit=t.retainedLimit??1024,this._freezeCommandPayload=t.freezeCommandPayload??!0,this._freezeEventPayload=t.freezeEventPayload??!0,this._maxAggregates=t.maxAggregates??1e4,this.dispatches=Vt({name:"dispatches",retainedLimit:this._retainedLimit,graph:this}),this.audit=this.dispatches,this.aggregateEvictions=Vt({name:"aggregateEvictions",retainedLimit:this._retainedLimit,graph:this}),this._dispatchSeqCursor=io(this,"dispatch_seq",0)}aggregateVersion(e,t){return this._aggregateVersions.get(`${e}::${t}`)??0}_touchAggregate(e){this._aggregateLru.delete(e),this._aggregateLru.set(e,!0)}_enforceAggregateLru(){for(;this._aggregateLru.size>this._maxAggregates;){let e=this._aggregateLru.keys().next();if(e.done)break;let t=e.value;this._aggregateLru.delete(t);let n=t.indexOf("::");if(n<0)continue;let o=t.slice(0,n),s=t.slice(n+2),a=this._aggregateVersions.get(t)??0;this._aggregateVersions.delete(t);let i=this._eventLogsByAggregate.get(o);i&&(i.delete(s),i.size===0&&this._eventLogsByAggregate.delete(o)),this.aggregateEvictions.append({aggregateId:s,type:o,lastVersion:a,t_ns:se()})}}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}_attachedEventTiers=[];_attachedTierDisposers=new Map;attachEventStorage(e){this._attachedEventTiers.push(e);for(let[t,n]of this._eventLogs){let o=n.log.attachStorage(e),s=this._attachedTierDisposers.get(t);s||(s=[],this._attachedTierDisposers.set(t,s)),s.push(o)}for(let[t,n]of this._eventLogsByAggregate)for(let[o,s]of n){let a=`${t}::${o}`,i=s.log.attachStorage(e),d=this._attachedTierDisposers.get(a);d||(d=[],this._attachedTierDisposers.set(a,d)),d.push(i)}return()=>{let t=this._attachedEventTiers.indexOf(e);t>=0&&this._attachedEventTiers.splice(t,1)}}_autoWireStreamStorage(e,t){if(this._attachedEventTiers.length===0)return;let n=this._attachedTierDisposers.get(e);n||(n=[],this._attachedTierDisposers.set(e,n));for(let o of this._attachedEventTiers)n.push(t.attachStorage(o))}_bumpDispatchSeq(){let t=(this._dispatchSeqCursor.cache??0)+1;return this._dispatchSeqCursor.emit(t),t}event(e,t){if(t!==void 0)return this._ensureAggregateStream(e,t).node;let n=this._eventLogs.get(e);if(n)return n.node;let o=pt([],{name:e,versioning:0,maxSize:this._retainedLimit});o.withLatest();let s=o.entries,a=J([s],([i])=>i,{name:e,describeKind:"state",meta:mt("event",{event_name:e}),guard:lo,initial:s.cache});return this.add(a,{name:e}),this._keepaliveDisposers.push(ge(a)),this._eventLogs.set(e,{log:o,node:a}),this._autoWireStreamStorage(e,o),a}_ensureAggregateStream(e,t){this._eventLogs.has(e)||this.event(e);let n=this._eventLogsByAggregate.get(e);n||(n=new Map,this._eventLogsByAggregate.set(e,n));let o=`${e}::${t}`;this._touchAggregate(o);let s=n.get(t);if(s)return s;let a=`${e}_${t.replace(/[^a-zA-Z0-9_-]/g,"_")}`,i=pt([],{name:a,versioning:0,maxSize:this._retainedLimit});i.withLatest();let d=i.entries,u=J([d],([h])=>h,{name:a,describeKind:"state",meta:mt("event_aggregate",{event_name:e,aggregate_id:t}),guard:lo,initial:d.cache}),c=a,l=0;for(;this.nameOf(this.resolveOptional(c)??u)===c&&(l+=1,c=`${a}_${l}`,this.resolveOptional(c)!==void 0););try{this.add(u,{name:c})}catch{}this._keepaliveDisposers.push(ge(u));let p={log:i,node:u};return n.set(t,p),this._autoWireStreamStorage(`${e}::${t}`,i),this._enforceAggregateLru(),p}resolveOptional(e){try{return this.resolve(e)}catch{return}}_appendEvent(e,t,n){let o=this._eventLogs.get(e);if(o||(this.event(e),o=this._eventLogs.get(e)),o.node.status==="completed"||o.node.status==="errored")throw new Error(`Cannot dispatch to terminated event stream "${e}" (status: ${o.node.status}).`);let s,a;if(n?.aggregateId!==void 0){let c=`${e}::${n.aggregateId}`;s=(this._aggregateVersions.get(c)??0)+1,this._aggregateVersions.set(c,s),a=this._ensureAggregateStream(e,n.aggregateId)}let i=o.log.entries.v,d=this._freezeEventPayload?On(t):t,u={type:e,payload:d,timestampNs:se(),seq:++this._seq,...n?.aggregateId!==void 0?{aggregateId:n.aggregateId}:{},...s!==void 0?{aggregateVersion:s}:{},...n?.correlationId!==void 0?{correlationId:n.correlationId}:{},...n?.causationId!==void 0?{causationId:n.causationId}:{},...n?.metadata!==void 0?{metadata:Object.freeze({...n.metadata})}:{},...n?.handlerVersion!==void 0?{handlerVersion:n.handlerVersion}:{},...i!=null?{v0:{id:i.id,version:i.version}}:{}};return o.log.append(u),a&&a.log.append(u),u}command(e,t){if(this._commandRegs.has(e))throw new Ht("command",e);let n=typeof t=="function"?{handler:t}:t,o=F(void 0,{name:e,describeKind:"state",meta:{...mt("command",{command_name:e}),error:null},guard:ms});if(this.add(o,{name:e}),this._commandRegs.set(e,{handler:n.handler,...n.emits!==void 0?{emits:n.emits}:{},...n.handlerVersion!==void 0?{handlerVersion:n.handlerVersion}:{}}),n.emits)for(let s of n.emits)this._eventLogs.has(s)||this.event(s);return o}dispatch(e,t,n){let o=this._commandRegs.get(e);if(!o)throw new zt(e);if(n?.aggregateId!==void 0&&n.expectedAggregateVersion!==void 0&&o.emits!==void 0){let p=0;for(let h of o.emits){let f=this._aggregateVersions.get(`${h}::${n.aggregateId}`);f!==void 0&&f>p&&(p=f)}if(p!==n.expectedAggregateVersion)throw new jt(n.aggregateId,n.expectedAggregateVersion,p)}let s=this.resolve(e),a=this._freezeCommandPayload?On(t):t,i=[],d=se(),u=0,c,l=!1;try{le(()=>{u=this._bumpDispatchSeq(),s.emit(a,{internal:!0});try{o.handler(a,{emit:(p,h)=>{if(o.emits!==void 0&&!o.emits.includes(p))throw new qt(e,p,o.emits);i.push(p),this._appendEvent(p,h,{...n?.aggregateId!==void 0?{aggregateId:n.aggregateId}:{},...n?.correlationId!==void 0?{correlationId:n.correlationId}:{},...n?.causationId!==void 0?{causationId:n.causationId}:{},...n?.metadata!==void 0?{metadata:Object.freeze({...n.metadata})}:{},...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}})}}),s.meta.error.emit(null,{internal:!0}),this.dispatches.append({commandName:e,payload:a,outcome:"success",emittedEvents:[...i],t_ns:d,seq:u,...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}})}catch(p){throw c=p,l=!0,p}})}catch(p){if(l){s.meta.error.emit(c,{internal:!0});let h=c instanceof Error?c.name:typeof c,f=c instanceof ht?c:new ht(e,c);this.dispatches.append({commandName:e,payload:a,outcome:"failure",error:f,errorType:h,emittedEvents:[...i],t_ns:d,seq:u,...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}})}throw l?c:p}}projection(e){let{name:t,events:n,reducer:o,initial:s}=e,a=e.mode??"scan",i=e.freezeInputs??!0,d=e.snapshot,u=n.map(R=>(this._eventLogs.has(R)||this.event(R),this._eventLogs.get(R).node));function c(R){R.sort((w,k)=>w.timestampNs-k.timestampNs||w.seq-k.seq||(w.aggregateId??"").localeCompare(k.aggregateId??""))}function l(R){let w=[];for(let k of R)w.push(...k);return c(w),w}let p=u.map(R=>R.cache??[]),h=l(p),f=i?Object.freeze(h):h,m=0,g=s;a==="scan"&&h.length>0&&(g=o(s,f),m=h.length);let x=a==="replay"?o(s,f):g,v=d?.saveDebounceMs??1e3,_=d?.saveEvery??1e3,b,T=0;function N(R){if(d?.save){if(T+=1,T>=_){T=0,b!==void 0&&(clearTimeout(b),b=void 0);let w=d.save(R);w instanceof Promise&&w.catch(()=>{});return}b!==void 0&&clearTimeout(b),b=setTimeout(()=>{b=void 0,T=0;let w=d.save(R);w instanceof Promise&&w.catch(()=>{})},v)}}let y=J(u,R=>{let w=l(R),k;if(a==="replay"){let M=i?Object.freeze(w):w;k=o(s,M)}else{let M=w.slice(m);m=w.length;let A=i?Object.freeze(M):M;k=o(g,A),g=k}return N(k),k},{name:t,describeKind:"derived",meta:mt("projection",{projection_name:t,source_events:n}),guard:ys,initial:x});return this.add(y,{name:t}),this._keepaliveDisposers.push(ge(y)),this._keepaliveDisposers.push(()=>{b!==void 0&&(clearTimeout(b),b=void 0)}),this._projections.add(t),{node:y,rebuild:async R=>{try{let w=R?.pageSize??1e3,k=R?.fromTier??this._attachedEventTiers[0]?.[0],M=l(u.map(q=>q.cache??[])).length,A=s;if(d?.load){let q=await d.load();q!==void 0&&(A=q)}if(!k||!k.loadEntries){let q=l(u.map(X=>X.cache??[])),B=i?Object.freeze(q):q;A=o(A,B)}else{let q=new Set(n),B,X=!1;for(;!X;){let Pe=await k.loadEntries({cursor:B,pageSize:w}),Le=[...Pe.entries].filter(Xe=>q.has(Xe.type));c(Le);let Ze=i?Object.freeze(Le):Le;A=o(A,Ze),B=Pe.cursor,X=!B||Pe.entries.length===0}}if(a==="scan"){let q=l(u.map(X=>X.cache??[])),B=q.slice(M);if(B.length>0){let X=i?Object.freeze(B):B;A=o(A,X)}g=A,m=q.length}return y.emit(A,{internal:!0}),A}catch(w){throw new gt(t,w)}},reset:async()=>{try{let R=s;if(d?.load){let A=await d.load();A!==void 0&&(R=A)}let w=l(u.map(A=>A.cache??[])),k=i?Object.freeze(w):w,M=o(R,k);return a==="scan"&&(g=M,m=w.length),y.emit(M,{internal:!0}),M}catch(R){throw new gt(t,R)}}}}saga(e,t,n,o={}){let s=t.map(h=>(this._eventLogs.has(h)||this.event(h),this._eventLogs.get(h).node)),a=ao(this,`${e}_cursor`,t,0),i=Vt({name:`${e}_invocations`,retainedLimit:this._retainedLimit,graph:this}),d=o.aggregateId,u=o.errorPolicy??"advance",c=new Map;for(let h of t){let f=a[h];c.set(h,f.cache??0);let m=f.subscribe(g=>{for(let x of g)x[0]===O&&c.set(h,x[1])});this._keepaliveDisposers.push(m)}let l={},p=he(s,(h,f)=>{let m=l.n.meta.error;for(let g=0;g<h.length;g++){let x=h[g];if(x==null||x.length===0)continue;let v=x.at(-1);if(!v)continue;let _=t[g],b=a[_],T=c.get(_)??0;if(v.length>T){let N=v.slice(T),y=T;for(let E of N){let S=E;if(d!==void 0&&S.aggregateId!==d){y+=1;continue}try{n(S),m.emit(null,{internal:!0}),i.append({eventType:_,outcome:"success",aggregateId:S.aggregateId,event:S,t_ns:se(),...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}}),y+=1}catch(R){if(m.emit(R,{internal:!0}),i.append({eventType:_,outcome:"failure",error:R,errorType:R instanceof Error?R.name:typeof R,aggregateId:S.aggregateId,event:S,t_ns:se(),...o.handlerVersion!==void 0?{handlerVersion:o.handlerVersion}:{}}),u==="hold")break;y+=1}}b.emit(y)}}},{name:e,describeKind:"effect",meta:{...mt("saga",{saga_name:e,source_events:t}),error:null}});return l.n=p,this.add(p,{name:e}),this._keepaliveDisposers.push(ge(p)),this._sagas.add(e),{node:p,invocations:i,audit:i,cursors:a}}};function fo(r,e){let t=new Nn(r,e),{factory:n,factoryArgs:o,...s}=e??{};return t.tagFactory("cqrs",yn(s)),t}var kn=class{constructor(e){this.graph=e}onModuleDestroy(){this.graph.destroy()}},An=class{graph=new Z("request");onModuleDestroy(){this.graph.destroy()}},po,Sn;po=[(0,yt.Module)({})];var Te=class Te{static forRoot(e){let t=e??{},n=t.name??"root",o=[{provide:ae,useFactory:()=>{let s=new Z(n);return t.build&&t.build(s),t.snapshot&&s.restore(t.snapshot),s}},{provide:Symbol.for("graphrefly:root-lifecycle"),useFactory:s=>new kn(s),inject:[ae]},{provide:De,useFactory:(s,a)=>new De(s,a),inject:[ae,ho.ModuleRef]}];if(t.nodes)for(let s of t.nodes)o.push({provide:ue(s),useFactory:a=>a.resolve(s),inject:[ae]});return t.requestScope&&o.push({provide:Symbol.for("graphrefly:request-lifecycle"),useFactory:()=>new An,scope:yt.Scope.REQUEST},{provide:Me,useFactory:s=>s.graph,inject:[Symbol.for("graphrefly:request-lifecycle")],scope:yt.Scope.REQUEST}),{module:Te,global:!0,providers:o,exports:[ae,...(t.nodes??[]).map(ue),...t.requestScope?[Me]:[]]}}static forFeature(e){let t=[{provide:Q(e.name),useFactory:n=>{let o=new Z(e.name);return e.build&&e.build(o),e.snapshot&&o.restore(e.snapshot),n.mount(e.name,o),o},inject:[ae]}];if(e.nodes)for(let n of e.nodes)t.push({provide:ue(`${e.name}::${n}`),useFactory:o=>o.resolve(n),inject:[Q(e.name)]});return{module:Te,providers:t,exports:[Q(e.name),...(e.nodes??[]).map(n=>ue(`${e.name}::${n}`))]}}static forCqrs(e){let t=[{provide:Q(e.name),useFactory:n=>{let o=fo(e.name,e.cqrs);return e.eventStorage&&o.attachEventStorage(e.eventStorage),e.build&&e.build(o),n.mount(e.name,o),o},inject:[ae]}];if(e.nodes)for(let n of e.nodes)t.push({provide:ue(`${e.name}::${n}`),useFactory:o=>o.resolve(n),inject:[Q(e.name)]});return{module:Te,providers:t,exports:[Q(e.name),...(e.nodes??[]).map(n=>ue(`${e.name}::${n}`))]}}};Sn=Bn(null),Te=Yn(Sn,0,"GraphReflyModule",po,Te),Un(Sn,1,Te);var Wt=Te;var Mn={};ce(Mn,{useStore:()=>bs,useSubscribe:()=>go,useSubscribeRecord:()=>vs});var me=require("react");K();function go(r){return(0,me.useSyncExternalStore)(e=>{let t=!1,n=r.subscribe(()=>{t||e()});return()=>{t=!0,n()}},()=>r.cache,()=>r.cache)}function bs(r){let e=go(r),t=(0,me.useCallback)(n=>{r.down([[P],[O,n]])},[r]);return[e,t]}function vs(r,e){let t=(0,me.useRef)(e);t.current=e;let n=(0,me.useMemo)(()=>{let o=()=>{let a={},i=r.cache??[];for(let d of i){let u=t.current(d),c={};for(let l of Object.keys(u))c[l]=u[l].cache;a[d]=c}return a},s=o();return{subscribe:a=>{let i=!1,d=[],u=()=>{for(let p of d)p();d=[]},c=p=>{u();for(let h of p){let f=t.current(h);for(let m of Object.keys(f)){let g=f[m].subscribe(()=>{s=o(),i||a()});d.push(g)}}s=o(),i||a()},l=r.subscribe(p=>{let h=p.some(f=>f[0]===O||f[0]===z);!i&&h&&c(r.cache??[])});return c(r.cache??[]),()=>{i=!0,l(),u()}},getSnapshot:()=>s}},[r]);return(0,me.useSyncExternalStore)(n.subscribe,n.getSnapshot,n.getSnapshot)}var In={};ce(In,{Signal:()=>_s});Ne();K();fe();var Qe=[];function Bt(r){let e=r.cache;return r.subscribe(n=>{for(let[o,s]of n)o===O&&(e=s)})(),e}var Dn=class{_node;_equals;constructor(e,t){this._equals=t?.equals??Object.is,this._node=F(e,{...t,resubscribable:!0,resetOnTeardown:!0})}get(){let e=Qe[Qe.length-1];return e?(this._node.status==="sentinel"&&Bt(this._node),e(this._node)):this._node.status==="sentinel"?Bt(this._node):this._node.cache}set(e){this._equals(this.get(),e)||le(()=>{this._node.down([[P],[O,e]])})}},Gn=class{_node;constructor(e,t){this._node=it(n=>{Qe.push(n);try{return e()}finally{Qe.pop()}},{...t,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=Qe[Qe.length-1];return e?(this._node.status==="sentinel"&&Bt(this._node),e(this._node)):this._node.status==="sentinel"?Bt(this._node):this._node.cache}},_s={State:Dn,Computed:Gn,sub:(r,e)=>{let t=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,n=!0;return r._node.subscribe(o=>{for(let[s,a]of o){if(s===O){if(n){n=!1;continue}t.data?.(a)}s===D&&t.error?.(a),s===I&&t.complete?.()}})}};var Pn={};ce(Pn,{useStore:()=>Ts,useSubscribe:()=>mo,useSubscribeRecord:()=>ws});var ye=require("solid-js");K();function mo(r){let[e,t]=(0,ye.createSignal)(r.cache,{equals:!1}),n=r.subscribe(()=>{t(()=>r.cache)});return(0,ye.getOwner)()?(0,ye.onCleanup)(()=>n()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),e}function Ts(r){return[mo(r),n=>{r.down([[P],[O,n]])}]}function ws(r,e){let[t,n]=(0,ye.createSignal)({},{equals:!1}),o=[],s=()=>{for(let u of o)u();o=[]},a=()=>{let u={};for(let c of r.cache??[]){let l=e(c),p={};for(let h of Object.keys(l))p[h]=l[h].cache;u[c]=p}return u},i=u=>{s();for(let c of u){let l=e(c);for(let p of Object.keys(l)){let h=l[p].subscribe(()=>{n(()=>a())});o.push(h)}}n(()=>a())},d=r.subscribe(u=>{u.some(c=>c[0]===O||c[0]===z)&&i(r.cache??[])});return i(r.cache??[]),(0,ye.getOwner)()?(0,ye.onCleanup)(()=>{d(),s()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Solid reactive owner \u2014 subscription will not be auto-disposed."),t}var Ln={};ce(Ln,{useStore:()=>Rs,useSubscribe:()=>xs,useSubscribeRecord:()=>Es});K();function xs(r){return{subscribe(e){let t=r.subscribe(()=>{e(r.cache)});return e(r.cache),t}}}function Rs(r){return{subscribe(e){let t=r.subscribe(()=>{e(r.cache)});return e(r.cache),t},set(e){r.down([[P],[O,e]])},update(e){let t=e(r.cache);r.down([[P],[O,t]])}}}function Es(r,e){return{subscribe(t){let n=[],o=()=>{for(let d of n)d();n=[]},s=()=>{let d={};for(let u of r.cache??[]){let c=e(u),l={};for(let p of Object.keys(c))l[p]=c[p].cache;d[u]=l}return d},a=d=>{o();for(let u of d){let c=e(u);for(let l of Object.keys(c)){let p=c[l].subscribe(()=>{t(s())});n.push(p)}}t(s())},i=r.subscribe(d=>{d.some(u=>u[0]===O||u[0]===z)&&a(r.cache??[])});return a(r.cache??[]),()=>{i(),o()}}}}var $n={};ce($n,{useStore:()=>Ns,useSubscribe:()=>Os,useSubscribeRecord:()=>Ss});var j=require("vue");K();function Os(r){let e=(0,j.shallowRef)(r.cache),t=r.subscribe(()=>{e.value=r.cache});return(0,j.getCurrentScope)()?(0,j.onScopeDispose)(()=>t()):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribe called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,j.readonly)(e)}function Ns(r){let e=(0,j.shallowRef)(r.cache),t=r.subscribe(()=>{e.value=r.cache});return(0,j.getCurrentScope)()?(0,j.onScopeDispose)(()=>t()):typeof console<"u"&&console.warn("[graphrefly-ts] useStore called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,j.computed)({get:()=>e.value,set:n=>{r.down([[P],[O,n]])}})}function Ss(r,e){let t=(0,j.shallowRef)({}),n=new Map;function o(){let i={};for(let[d,u]of n)i[d]={...u.values};t.value=i}function s(i){for(let u of n.values())for(let c of u.subs)c();n.clear();for(let u of i){let c=e(u),l=Object.keys(c),p={},h=[];for(let f of l){let m=c[f];p[f]=m.cache;let g=m.subscribe(()=>{p[f]=m.cache,o()});h.push(g)}n.set(u,{subs:h,values:p})}let d={};for(let[u,c]of n)d[u]={...c.values};t.value=d}return(0,j.watch)(()=>[...(typeof r=="function"?r():(0,j.isRef)(r)?r.value:r)??[]],i=>s(i??[]),{immediate:!0}),(0,j.getCurrentScope)()?(0,j.onScopeDispose)(()=>{for(let i of n.values())for(let d of i.subs)d();n.clear()}):typeof console<"u"&&console.warn("[graphrefly-ts] useSubscribeRecord called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,j.readonly)(t)}var Fn={};ce(Fn,{create:()=>As});K();fe();var ks=()=>!1;function As(r){let e=new Z("zustand"),t=F(void 0,{name:"state",equals:ks});e.add(t,{name:"state"});let n=()=>t.cache,o=(i,d)=>{let u=t.cache,c=typeof i=="function"?i(u):i;t.emit(d?c:{...u,...c})},s={getState:n,setState:o,getInitialState:()=>a,subscribe:i=>{let d=!0,u=t.cache;return t.subscribe(c=>{for(let[l,p]of c)if(l===O){if(d){d=!1;continue}i(p,u),u=p}})},destroy:e.destroy.bind(e)},a=r(o,n,s);return t.emit(a),Object.assign(e,s)}0&&(module.exports={jotai,nanostores,nestjs,react,signals,solid,svelte,vue,zustand});