@graphrefly/graphrefly 0.28.0 → 0.30.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.
- package/dist/{cascading-D9WG1-9L.d.ts → cascading-BszPheHD.d.ts} +1 -1
- package/dist/{cascading-B-5zmAUv.d.cts → cascading-dNCtjW8j.d.cts} +1 -1
- package/dist/{chunk-OAWLCNJJ.js → chunk-2GQREQ6C.js} +1 -1
- package/dist/{chunk-DBGGMN3D.js → chunk-33FA6V4B.js} +1 -1
- package/dist/chunk-3NEPQO2E.js +43 -0
- package/dist/{chunk-UWJE5FQA.js → chunk-4C2OR2GH.js} +11 -11
- package/dist/chunk-4JJCCD5S.js +2 -0
- package/dist/{chunk-GHJJR5P4.js → chunk-4OFIQ66T.js} +1 -1
- package/dist/{chunk-PIOGHC63.js → chunk-567NWZ3T.js} +1 -1
- package/dist/chunk-5JDE5JHE.js +1 -0
- package/dist/{chunk-ETWTCCJI.js → chunk-5Z4HDCO6.js} +1 -1
- package/dist/{chunk-Y2EMPB3I.js → chunk-73Z3W2RN.js} +1 -1
- package/dist/{chunk-CRXTH3SH.js → chunk-7JDLFI6N.js} +1 -1
- package/dist/{chunk-DQA3UIQ2.js → chunk-7TDOES3L.js} +1 -1
- package/dist/{chunk-LBTDSCCO.js → chunk-AMBYCIOH.js} +1 -1
- package/dist/{chunk-D7A7DBE4.js → chunk-AUY2YKCO.js} +1 -1
- package/dist/{chunk-FNYWM6JC.js → chunk-AV3PIDFQ.js} +1 -1
- package/dist/{chunk-UMBIDLJ4.js → chunk-BA5URFYW.js} +1 -1
- package/dist/chunk-BKPLTBL5.js +1 -0
- package/dist/{chunk-UPXUCFMX.js → chunk-BZP5T4X6.js} +1 -1
- package/dist/{chunk-WQ2BN6X6.js → chunk-DDPYNMGG.js} +1 -1
- package/dist/{chunk-LQ3Y5NJS.js → chunk-GJR3P6JG.js} +1 -1
- package/dist/{chunk-3R5HFPX7.js → chunk-GLSM33ZM.js} +1 -1
- package/dist/{chunk-2FOAM3OR.js → chunk-GNCBXARM.js} +1 -1
- package/dist/{chunk-K2GNMCQT.js → chunk-ISCENNXS.js} +1 -1
- package/dist/{chunk-UPHHLMHE.js → chunk-IUK4EFCE.js} +1 -1
- package/dist/{chunk-ERLIRFPA.js → chunk-KA6MMXIY.js} +1 -1
- package/dist/{chunk-2PMCKKRK.js → chunk-KASHOCF5.js} +1 -1
- package/dist/chunk-LI3E75VE.js +64 -0
- package/dist/chunk-MGKAO4EK.js +7 -0
- package/dist/{chunk-ZV2DXV5A.js → chunk-NSG4C6BF.js} +1 -1
- package/dist/{chunk-4GKB4OUJ.js → chunk-OL33ZI6R.js} +1 -1
- package/dist/{chunk-76A3HVQE.js → chunk-P7JXGKDO.js} +1 -1
- package/dist/{chunk-U3AICJKU.js → chunk-RD52SNH2.js} +1 -1
- package/dist/{chunk-CWLN3X3N.js → chunk-SHYH5SXV.js} +1 -1
- package/dist/{chunk-VTPVOGHH.js → chunk-SLMYTGTU.js} +1 -1
- package/dist/{chunk-OYHGKYQM.js → chunk-T5SHIKJD.js} +1 -1
- package/dist/{chunk-VPYBOXVT.js → chunk-TWMEGG45.js} +1 -1
- package/dist/chunk-VIEUJSTT.js +1 -0
- package/dist/{chunk-SC3U7ETD.js → chunk-VWPRPPKR.js} +1 -1
- package/dist/chunk-W4TSQ6RJ.js +1 -0
- package/dist/{chunk-OBKQQA5I.js → chunk-WANIEEKV.js} +1 -1
- package/dist/{chunk-XAUNPIMX.js → chunk-XHVB6G6M.js} +1 -1
- package/dist/{chunk-MIQTDPY4.js → chunk-XQAXYVXX.js} +1 -1
- package/dist/{chunk-MTTAAPCK.js → chunk-Y32RJO24.js} +1 -1
- package/dist/{chunk-S35VARIR.js → chunk-Y36UZ5VS.js} +1 -1
- package/dist/compat/index.cjs +13 -12
- package/dist/compat/index.d.cts +14 -14
- package/dist/compat/index.d.ts +14 -14
- package/dist/compat/index.js +1 -1
- package/dist/compat/jotai/index.cjs +1 -1
- package/dist/compat/jotai/index.d.cts +2 -2
- package/dist/compat/jotai/index.d.ts +2 -2
- package/dist/compat/jotai/index.js +1 -1
- package/dist/compat/nanostores/index.cjs +1 -1
- package/dist/compat/nanostores/index.d.cts +2 -2
- package/dist/compat/nanostores/index.d.ts +2 -2
- package/dist/compat/nanostores/index.js +1 -1
- package/dist/compat/nestjs/index.cjs +13 -12
- package/dist/compat/nestjs/index.d.cts +6 -6
- package/dist/compat/nestjs/index.d.ts +6 -6
- package/dist/compat/nestjs/index.js +1 -1
- package/dist/compat/react/index.d.cts +2 -2
- package/dist/compat/react/index.d.ts +2 -2
- package/dist/compat/solid/index.d.cts +2 -2
- package/dist/compat/solid/index.d.ts +2 -2
- package/dist/compat/svelte/index.d.cts +2 -2
- package/dist/compat/svelte/index.d.ts +2 -2
- package/dist/compat/vue/index.d.cts +2 -2
- package/dist/compat/vue/index.d.ts +2 -2
- package/dist/compat/zustand/index.cjs +7 -6
- package/dist/compat/zustand/index.d.cts +4 -4
- package/dist/compat/zustand/index.d.ts +4 -4
- package/dist/compat/zustand/index.js +1 -1
- package/dist/{composite-BhbKHbOS.d.ts → composite-DGspwCqk.d.ts} +2 -2
- package/dist/{composite-B-xqw4Kk.d.cts → composite-nrRumJ7l.d.cts} +2 -2
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.cts +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +1 -1
- package/dist/extra/browser.cjs +1 -1
- package/dist/extra/browser.d.cts +1 -1
- package/dist/extra/browser.d.ts +1 -1
- package/dist/extra/browser.js +1 -1
- package/dist/extra/index.cjs +20 -19
- package/dist/extra/index.d.cts +9 -9
- package/dist/extra/index.d.ts +9 -9
- package/dist/extra/index.js +1 -1
- package/dist/extra/node.cjs +3 -3
- package/dist/extra/node.d.cts +1 -1
- package/dist/extra/node.d.ts +1 -1
- package/dist/extra/node.js +1 -1
- package/dist/extra/operators.cjs +1 -1
- package/dist/extra/operators.d.cts +1 -1
- package/dist/extra/operators.d.ts +1 -1
- package/dist/extra/operators.js +1 -1
- package/dist/extra/reactive.cjs +1 -1
- package/dist/extra/reactive.d.cts +3 -3
- package/dist/extra/reactive.d.ts +3 -3
- package/dist/extra/reactive.js +1 -1
- package/dist/extra/sources.cjs +1 -1
- package/dist/extra/sources.d.cts +1 -1
- package/dist/extra/sources.d.ts +1 -1
- package/dist/extra/sources.js +1 -1
- package/dist/extra/storage-browser.cjs +1 -1
- package/dist/extra/storage-browser.d.cts +1 -1
- package/dist/extra/storage-browser.d.ts +1 -1
- package/dist/extra/storage-browser.js +1 -1
- package/dist/graph/index.cjs +7 -6
- package/dist/graph/index.d.cts +5 -5
- package/dist/graph/index.d.ts +5 -5
- package/dist/graph/index.js +1 -1
- package/dist/{graph-D48Qw9Cg.d.cts → graph-C4Uxwv0T.d.cts} +22 -6
- package/dist/{graph-BZGRXwOm.d.ts → graph-CWeI0aHd.d.ts} +22 -6
- package/dist/{index-u15meRxL.d.cts → index-9iguV3bF.d.cts} +2 -2
- package/dist/{index-DyxjtScX.d.cts → index-B-z8WaSd.d.cts} +2 -2
- package/dist/{index-BgyGlizc.d.ts → index-B2HBxvMb.d.ts} +4 -4
- package/dist/{index-CzobVSMr.d.ts → index-B5iVOD7w.d.ts} +2 -2
- package/dist/{index-rX8HBM5h.d.cts → index-B8Aj_z8S.d.cts} +2 -2
- package/dist/{index-D-YB-Vl3.d.ts → index-BANwzwBV.d.ts} +3 -3
- package/dist/{index-HDpJe9hX.d.ts → index-BBINVimG.d.ts} +3 -3
- package/dist/{index-8FSVk4Uf.d.ts → index-BEpRsvhg.d.ts} +4 -4
- package/dist/{index-CHEswufn.d.cts → index-BHu_Wba0.d.cts} +4 -4
- package/dist/{index-ZftwfxJM.d.ts → index-BJHQUCZx.d.ts} +7 -7
- package/dist/{index-DUqMOlKZ.d.cts → index-BS220yqj.d.cts} +7 -7
- package/dist/{index-BWJV63ti.d.ts → index-BX22kvjh.d.ts} +1 -1
- package/dist/{index-DfyOkTvs.d.ts → index-BXbQUn4n.d.ts} +2 -2
- package/dist/{index-O6TgGUBV.d.cts → index-BpFWP7Bq.d.cts} +3 -3
- package/dist/{index-BxJ86YZZ.d.cts → index-Bs3-LC83.d.cts} +3 -3
- package/dist/{index-DiOXyAwt.d.ts → index-Bvi5uJxX.d.ts} +1 -1
- package/dist/{index-Bqachn9_.d.ts → index-ByPnK85n.d.ts} +1 -1
- package/dist/{index-CRO83MmV.d.cts → index-BydMDMf7.d.cts} +1 -1
- package/dist/{index-ROpQmGjE.d.ts → index-C5Ghnp5B.d.ts} +3 -3
- package/dist/{index-umtoWT8K.d.ts → index-C6NBfXj-.d.ts} +6 -5
- package/dist/{index-pXrDMpRO.d.cts → index-C98oJsEs.d.cts} +2 -2
- package/dist/{index-B2pwesl9.d.cts → index-CDK5RsV5.d.cts} +1 -1
- package/dist/{index-Czq6ynh8.d.ts → index-CFW32Dy1.d.ts} +3 -3
- package/dist/{index-Cyojz0AE.d.cts → index-CIXaiYDE.d.cts} +1 -1
- package/dist/{index-Oi8d8w4R.d.cts → index-CRAkoq-y.d.cts} +1 -1
- package/dist/{index-CpgYhnrG.d.ts → index-Cc8VQIgL.d.ts} +2 -2
- package/dist/{index-vscRDkjW.d.cts → index-CcpEvuPl.d.cts} +2 -2
- package/dist/{index-BpA5c4G9.d.ts → index-CfFYyLR8.d.ts} +4 -4
- package/dist/{index-9oDeHH2u.d.cts → index-ClB7TCfL.d.cts} +2 -2
- package/dist/{index-BHvIquRZ.d.ts → index-ClgKmOHe.d.ts} +592 -492
- package/dist/{index-DpHe5e0Q.d.ts → index-CotRMjtJ.d.ts} +2 -2
- package/dist/{index-B1AmmSlb.d.ts → index-CrC7urhX.d.ts} +1 -1
- package/dist/{index-B0c4cmIO.d.ts → index-CvS9IuTG.d.ts} +2 -2
- package/dist/{index-rHJSKsU8.d.cts → index-Cy7eFeIX.d.cts} +2 -2
- package/dist/{index-BVHOrDwO.d.ts → index-D0C_USMR.d.ts} +1 -1
- package/dist/{index-DEwTb_fm.d.cts → index-D6ajK8Mh.d.cts} +592 -492
- package/dist/{index-DL-rYJrx.d.cts → index-D7XxY1Ff.d.cts} +1 -1
- package/dist/{index-DAlweici.d.ts → index-D9HrBx2J.d.ts} +2 -2
- package/dist/{index-fM6y00vT.d.cts → index-D9Y_u6BG.d.cts} +3 -3
- package/dist/{index-DcXZBF5a.d.cts → index-DBQUKh59.d.cts} +4 -4
- package/dist/{index-D_NwnRYS.d.cts → index-DDo-eqQ4.d.cts} +1 -1
- package/dist/{index-m-yHof5p.d.ts → index-DGb1awva.d.ts} +4 -4
- package/dist/{index-DxsnAMWD.d.cts → index-DR3gf_DG.d.cts} +9 -9
- package/dist/{index-dtN7YA2x.d.cts → index-DVNLe3pS.d.cts} +3 -3
- package/dist/{index-Btib9rsU.d.ts → index-Dljd76bC.d.ts} +275 -9
- package/dist/{index-DP4ZTkdw.d.ts → index-DnrZghBB.d.ts} +3 -3
- package/dist/{index-DaLJvH8Z.d.ts → index-Docdiu9a.d.ts} +3 -3
- package/dist/{index-BpIFjILY.d.cts → index-DylQCKEL.d.cts} +4 -4
- package/dist/{index-B_agccPe.d.cts → index-FBqTfL_S.d.cts} +1 -1
- package/dist/{index-DraikLjn.d.ts → index-FrYrV-Vf.d.ts} +2 -2
- package/dist/{index-sm373fsH.d.ts → index-IZ3l_vQ9.d.ts} +2 -2
- package/dist/{index-BwM9BEkt.d.ts → index-Ip3q9T9x.d.ts} +1 -1
- package/dist/{index-CloUk1kY.d.ts → index-RQg6lTrN.d.ts} +9 -9
- package/dist/{index-CEXXwWVH.d.cts → index-SSGqF8mI.d.cts} +2 -2
- package/dist/{index-rnwQly8X.d.cts → index-UZO988ox.d.cts} +6 -5
- package/dist/{index-C73n7lo-.d.cts → index-iBp74eGU.d.cts} +3 -3
- package/dist/{index-tbf2gKHd.d.cts → index-lKuLYmHO.d.cts} +3 -3
- package/dist/{index-CMn8S8Hw.d.ts → index-wIx1Jisk.d.ts} +1 -1
- package/dist/{index-cByzxQIC.d.cts → index-yIdWFo2b.d.cts} +4 -4
- package/dist/{index-RukJ4DLS.d.cts → index-ybtSyjWB.d.cts} +275 -9
- package/dist/index.cjs +53 -52
- package/dist/index.d.cts +42 -42
- package/dist/index.d.ts +42 -42
- package/dist/index.js +1 -1
- package/dist/{meta-CwesDrMD.d.ts → meta-BMwx3ExI.d.ts} +1 -1
- package/dist/{meta-Cgj6zeji.d.cts → meta-COtmHLwT.d.cts} +1 -1
- package/dist/{node-Cc1TniY8.d.ts → node-BVV7G1bq.d.cts} +59 -2
- package/dist/{node-Cc1TniY8.d.cts → node-BVV7G1bq.d.ts} +59 -2
- package/dist/{observable-glXQoGj2.d.cts → observable-BrUAPeH_.d.cts} +1 -1
- package/dist/{observable-Ct-gJ9jI.d.ts → observable-ITikPXz3.d.ts} +1 -1
- package/dist/patterns/ai/browser.d.cts +3 -3
- package/dist/patterns/ai/browser.d.ts +3 -3
- package/dist/patterns/ai/browser.js +1 -1
- package/dist/patterns/ai/index.cjs +25 -24
- package/dist/patterns/ai/index.d.cts +15 -15
- package/dist/patterns/ai/index.d.ts +15 -15
- package/dist/patterns/ai/index.js +1 -1
- package/dist/patterns/ai/node.d.cts +1 -1
- package/dist/patterns/ai/node.d.ts +1 -1
- package/dist/patterns/ai/node.js +1 -1
- package/dist/patterns/audit/index.cjs +7 -6
- package/dist/patterns/audit/index.d.cts +5 -5
- package/dist/patterns/audit/index.d.ts +5 -5
- package/dist/patterns/audit/index.js +1 -1
- package/dist/patterns/cqrs/index.cjs +7 -6
- package/dist/patterns/cqrs/index.d.cts +4 -4
- package/dist/patterns/cqrs/index.d.ts +4 -4
- package/dist/patterns/cqrs/index.js +1 -1
- package/dist/patterns/demo-shell/index.cjs +8 -7
- package/dist/patterns/demo-shell/index.d.cts +5 -5
- package/dist/patterns/demo-shell/index.d.ts +5 -5
- package/dist/patterns/demo-shell/index.js +1 -1
- package/dist/patterns/domain-templates/index.cjs +7 -6
- package/dist/patterns/domain-templates/index.d.cts +4 -4
- package/dist/patterns/domain-templates/index.d.ts +4 -4
- package/dist/patterns/domain-templates/index.js +1 -1
- package/dist/patterns/graphspec/index.cjs +26 -25
- package/dist/patterns/graphspec/index.d.cts +4 -4
- package/dist/patterns/graphspec/index.d.ts +4 -4
- package/dist/patterns/graphspec/index.js +1 -1
- package/dist/patterns/guarded-execution/index.cjs +7 -6
- package/dist/patterns/guarded-execution/index.d.cts +6 -6
- package/dist/patterns/guarded-execution/index.d.ts +6 -6
- package/dist/patterns/guarded-execution/index.js +1 -1
- package/dist/patterns/harness/index.cjs +11 -10
- package/dist/patterns/harness/index.d.cts +10 -7
- package/dist/patterns/harness/index.d.ts +10 -7
- package/dist/patterns/harness/index.js +1 -1
- package/dist/patterns/job-queue/index.cjs +7 -6
- package/dist/patterns/job-queue/index.d.cts +4 -4
- package/dist/patterns/job-queue/index.d.ts +4 -4
- package/dist/patterns/job-queue/index.js +1 -1
- package/dist/patterns/lens/index.cjs +7 -6
- package/dist/patterns/lens/index.d.cts +6 -6
- package/dist/patterns/lens/index.d.ts +6 -6
- package/dist/patterns/lens/index.js +1 -1
- package/dist/patterns/memory/index.cjs +7 -6
- package/dist/patterns/memory/index.d.cts +4 -4
- package/dist/patterns/memory/index.d.ts +4 -4
- package/dist/patterns/memory/index.js +1 -1
- package/dist/patterns/messaging/index.cjs +7 -6
- package/dist/patterns/messaging/index.d.cts +4 -4
- package/dist/patterns/messaging/index.d.ts +4 -4
- package/dist/patterns/messaging/index.js +1 -1
- package/dist/patterns/orchestration/index.cjs +7 -6
- package/dist/patterns/orchestration/index.d.cts +5 -5
- package/dist/patterns/orchestration/index.d.ts +5 -5
- package/dist/patterns/orchestration/index.js +1 -1
- package/dist/patterns/reactive-layout/index.cjs +8 -7
- package/dist/patterns/reactive-layout/index.d.cts +5 -5
- package/dist/patterns/reactive-layout/index.d.ts +5 -5
- package/dist/patterns/reactive-layout/index.js +1 -1
- package/dist/patterns/reduction/index.cjs +7 -6
- package/dist/patterns/reduction/index.d.cts +4 -4
- package/dist/patterns/reduction/index.d.ts +4 -4
- package/dist/patterns/reduction/index.js +1 -1
- package/dist/patterns/refine-loop/index.cjs +9 -8
- package/dist/patterns/refine-loop/index.d.cts +5 -5
- package/dist/patterns/refine-loop/index.d.ts +5 -5
- package/dist/patterns/refine-loop/index.js +1 -1
- package/dist/patterns/resilient-pipeline/index.cjs +1 -1
- package/dist/patterns/resilient-pipeline/index.d.cts +6 -6
- package/dist/patterns/resilient-pipeline/index.d.ts +6 -6
- package/dist/patterns/resilient-pipeline/index.js +1 -1
- package/dist/patterns/surface/index.cjs +14 -13
- package/dist/patterns/surface/index.d.cts +5 -5
- package/dist/patterns/surface/index.d.ts +5 -5
- package/dist/patterns/surface/index.js +1 -1
- package/dist/{reactive-layout-CpYb5qLP.d.cts → reactive-layout-5oEn8lHM.d.cts} +2 -2
- package/dist/{reactive-layout-D8u4wuUR.d.ts → reactive-layout-BAr6-_o5.d.ts} +2 -2
- package/dist/{reactive-log-DPzuUDj5.d.cts → reactive-log-5jFeNRmd.d.cts} +1 -1
- package/dist/{reactive-log-YuH9VYN8.d.ts → reactive-log-BOJDCI5x.d.ts} +1 -1
- package/dist/{reactive-map-CdbNoSgP.d.ts → reactive-map-BvDrRuwt.d.ts} +1 -1
- package/dist/{reactive-map-DUeRmb9d.d.cts → reactive-map-CmlPPKHN.d.cts} +1 -1
- package/dist/{resilience-CGRzhnD3.d.ts → resilience-CludlzcP.d.ts} +1 -1
- package/dist/{resilience-Ba5-b4WD.d.cts → resilience-Q6Bt_7y0.d.cts} +1 -1
- package/dist/{resilience-QAHKANT5.js → resilience-XRUF267O.js} +1 -1
- package/dist/{sugar-BV0htudb.d.cts → sugar-BHbAACDG.d.ts} +10 -12
- package/dist/{sugar-Dtyrq2_q.d.ts → sugar-CqR6DJ7v.d.cts} +10 -12
- package/dist/{topology-tree-DROUdq5B.d.cts → topology-tree-CVREibAc.d.cts} +1 -1
- package/dist/{topology-tree-CYHOwQZ_.d.ts → topology-tree-CkjojcB6.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-6V3SEX2I.js +0 -1
- package/dist/chunk-7H6LGFUG.js +0 -64
- package/dist/chunk-CKCSDI7T.js +0 -6
- package/dist/chunk-QWAPKG3O.js +0 -2
- package/dist/chunk-RHESUC3V.js +0 -43
- package/dist/chunk-V6YQICXZ.js +0 -1
- package/dist/chunk-Z4HDAS2Q.js +0 -1
- package/dist/chunk-ZB5EHBIO.js +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{a as Le}from"./chunk-ESMPEKEV.js";import{a as se,b as Se}from"./chunk-TWMEGG45.js";import{A as Ee}from"./chunk-KASHOCF5.js";import{A as Oe,C as L,E as re,F as Me,G as _e,e as $e,f as Te,i as Y,k as Ne,l as we,m as Ae,o as K,p as Pe,s as W}from"./chunk-W4TSQ6RJ.js";import{b as Z,c as be,d as ye,e as ee,f as ve,g as xe,h as V,i as te,j as ne}from"./chunk-CK2E7BTU.js";function Ie(e,t,n,r={}){let o=t in e.nodes,s=n in e.nodes;if(!o)return oe(t,n,"no-such-from");if(!s)return oe(t,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(t===n){if(r.findCycle===!0){let u=lt(e,t,r);if(u!=null)return u}let l=ie(t,e.nodes[t],0,r);return ae(t,n,[l])}if(i===0)return oe(t,n,"no-path");let a=je(e,t,n,i);return a.found?ae(t,n,Be(e,a.pathOrder,r)):oe(t,n,a.truncated?"max-depth-exceeded":"no-path")}function je(e,t,n,r){let o=new Map,s=[{path:n,depth:0}],i=new Set([n]),a=0,l=!1;for(;a<s.length;){let h=s[a++];if(h.path===t)break;if(r!=null&&h.depth>=r){let g=e.nodes[h.path];g?.deps&&g.deps.length>0&&(l=!0);continue}let p=e.nodes[h.path];if(p==null)continue;let f=p.deps??[],c=new Map;for(let g=0;g<f.length;g++){let b=f[g];if(!b)continue;let v=c.get(b);v==null&&(v=[],c.set(b,v)),v.push(g)}for(let[g,b]of c)i.has(g)||(i.add(g),o.set(g,{from:h.path,depIndices:b}),s.push({path:g,depth:h.depth+1}))}if(!o.has(t))return{found:!1,pathOrder:[],truncated:l};let u=[{path:t}],d=t;for(;d!==n;){let h=o.get(d);if(h==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=h.depIndices,u.push({path:h.from}),d=h.from}return{found:!0,pathOrder:u,truncated:!1}}function lt(e,t,n){let r=e.nodes[t];if(r==null)return null;let o=r.deps??[],s=[];for(let a=0;a<o.length;a++)o[a]===t&&s.push(a);if(s.length>0){let a=ie(t,r,0,n);a.dep_index=s[0];let l=ie(t,r,1,n);return ae(t,t,[a,l])}let i=null;for(let a=0;a<o.length;a++){let l=o[a];if(!l||l===t)continue;let u=je(e,l,t,n.maxDepth);u.found&&(i==null||u.pathOrder.length<i.pathOrder.length)&&(i=u,i={found:!0,pathOrder:[{path:t,depIndices:[a]},...u.pathOrder],truncated:!1})}return i==null?null:ae(t,t,Be(e,i.pathOrder,n))}function Be(e,t,n){return t.map((r,o)=>{let s=e.nodes[r.path],i=ie(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 ie(e,t,n,r){let o={path:e,type:t.type,hop:n};t.status!==void 0&&(o.status=t.status),"value"in t&&(o.value=t.value),t.v!=null&&(o.v=t.v);let s=r.annotations?.get(e)??t.annotation;s!=null&&(o.annotation=s);let i=r.lastMutations?.get(e)??t.lastMutation;return i!=null&&(o.lastMutation=i),o}function ae(e,t,n){return Fe(e,t,!0,"ok",n)}function oe(e,t,n){return Fe(e,t,!1,n,[])}function Fe(e,t,n,r,o){let s=ct(e,t,n,r,o);return{from:e,to:t,found:n,reason:r,steps:o,text:s,toJSON(){return{from:e,to:t,found:n,reason:r,steps:o}}}}function ct(e,t,n,r,o){if(!n)switch(r){case"no-such-from":return`explainPath: no node named "${e}"`;case"no-such-to":return`explainPath: no node named "${t}"`;case"max-depth-exceeded":return`explainPath: no path from "${e}" to "${t}" within maxDepth`;default:return`explainPath: no path from "${e}" to "${t}"`}let s=[`Causal path: ${e} \u2192 ${t} (${o.length} step(s))`];for(let i of o){let l=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(s.push(l),"value"in i&&s.push(` value: ${dt(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(`
|
|
2
|
+
`)}function dt(e){if(e===void 0)return"<sentinel>";if(e===null)return"null";if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);try{let t=JSON.stringify(e);return t.length>80?`${t.slice(0,77)}...`:t}catch{return String(e)}}var A={object:56,array:64,string:40,number:8,boolean:4,null:0,undefined:0,symbol:40,bigint:16,function:120,map:72,set:72,mapEntry:40,setEntry:24,date:24,regexp:48,error:64,url:80,promise:48,weakmap:40,weakset:40},ft=Symbol.for("sizeof");function ze(e){let t=new WeakSet,n=new WeakSet,r=[e],o=0;for(;r.length>0;){let s=r.pop();o+=pt(s,t,n,r)}return o}function pt(e,t,n,r){if(e==null)return 0;switch(typeof e){case"number":return A.number;case"boolean":return A.boolean;case"string":return A.string+e.length*2;case"bigint":return A.bigint+ht(e);case"symbol":return A.symbol;case"function":return t.has(e)?0:(t.add(e),A.function);case"undefined":return 0}let s=e;if(t.has(s))return 0;t.add(s);let i=s[ft];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 A.date;if(s instanceof RegExp)return A.regexp+s.source.length*2;if(s instanceof Error){let u=s.message?s.message.length*2:0,d=s.stack?s.stack.length*2:0;return A.error+u+d}if(typeof URL<"u"&&s instanceof URL)return A.url+s.href.length*2;if(typeof Promise<"u"&&s instanceof Promise)return A.promise;if(s instanceof WeakMap)return A.weakmap;if(s instanceof WeakSet)return A.weakset;if(s instanceof Map){let u=A.map;for(let[d,h]of s)u+=A.mapEntry,r.push(d),r.push(h);return u}if(s instanceof Set){let u=A.set;for(let d of s)u+=A.setEntry,r.push(d);return u}if(Array.isArray(s)){let u=A.array+s.length*8;for(let d of s)r.push(d);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=A.object,l=Object.keys(s);for(let u of l){a+=A.string+u.length*2;try{r.push(s[u])}catch{}}return a}function ht(e){let t=e<0n?-e:e;if(t===0n)return 0;let n=t.toString(2).length;return Math.ceil(n/32)*8}function He(e,t){let n=t?.topN??10,r=e.describe({detail:"standard"}),o=[],s=e._collectObserveTargets;typeof s=="function"&&s.call(e,"",o);let i=new Map;for(let[p,f]of o)i.set(p,f);let a=[];for(let[p,f]of Object.entries(r.nodes)){let c=i.get(p),g=c instanceof L?c:null,b=g?ze(g.cache):0,v=g?g._sinkCount:0,w=f.deps?.length??0,m=f.type==="effect"&&v===0,y=v===0?f.type==="effect"?"orphan-effect":f.type==="derived"?"idle-derived":f.type==="producer"?"idle-producer":null:null;a.push({path:p,type:f.type,status:f.status??"unknown",valueSizeBytes:b,subscriberCount:v,depCount:w,isOrphanEffect:m,orphanKind:y})}let l=a.reduce((p,f)=>p+f.valueSizeBytes,0),u=(p,f)=>[...a].sort(f??((c,g)=>g[p]-c[p])).slice(0,n),d=a.filter(p=>p.orphanKind!=null),h=a.filter(p=>p.isOrphanEffect);return{nodeCount:a.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:a,totalValueSizeBytes:l,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:d,orphanEffects:h}}var X=class{constructor(t){this.capacity=t;if(!Number.isInteger(t)||t<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${t})`);this.buf=new Array(t)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(t){let n=(this.head+this._size)%this.capacity;this.buf[n]=t,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let t=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,t}at(t){if(this._size===0)return;let n=t<0?this._size+t:t;if(!(n<0||n>=this._size))return this.buf[(this.head+n)%this.capacity]}toArray(){let t=new Array(this._size);for(let n=0;n<this._size;n++)t[n]=this.buf[(this.head+n)%this.capacity];return t}clear(){for(let t=0;t<this._size;t++)this.buf[(this.head+t)%this.capacity]=void 0;this.head=0,this._size=0}};function Re(e){return e>=768&&e<=879||e>=1155&&e<=1161||e>=1425&&e<=1469||e>=1552&&e<=1562||e>=1611&&e<=1631||e>=1648&&e===1648||e>=1750&&e<=1756||e>=1759&&e<=1764||e>=1767&&e<=1768||e>=1770&&e<=1773||e>=1840&&e<=1866||e>=1958&&e<=1968||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2641||e>=2672&&e<=2673||e>=2677&&e===2677||e>=3633&&e===3633||e>=3636&&e<=3642||e>=3655&&e<=3662||e>=3761&&e===3761||e>=3764&&e<=3772||e>=3784&&e<=3790||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65024&&e<=65039||e>=65056&&e<=65071||e===8205?0:e>=4352&&e<=4447||e>=8986&&e<=8987||e>=9001&&e<=9002||e>=9193&&e<=9203||e>=9208&&e<=9210||e>=9725&&e<=9726||e>=9748&&e<=9749||e>=9800&&e<=9811||e===9855||e===9875||e===9889||e>=9898&&e<=9899||e>=9917&&e<=9918||e>=9924&&e<=9925||e===9934||e===9940||e===9962||e>=9970&&e<=9971||e===9973||e===9978||e===9981||e===9986||e===9989||e>=9992&&e<=9997||e===9999||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e>=10548&&e<=10549||e>=11013&&e<=11015||e>=11035&&e<=11036||e===11088||e===11093||e>=11904&&e<=12350||e>=12352&&e<=12447||e>=12448&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12784&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=19968&&e<=40959||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65131||e>=65281&&e<=65376||e>=65504&&e<=65510||e>=126980&&e===126980||e===127183||e>=127344&&e<=127345||e===127358||e===127359||e===127374||e>=127377&&e<=127386||e>=127456&&e<=127487||e>=127488&&e<=127490||e===127514||e===127535||e>=127538&&e<=127546||e>=127568&&e<=127569||e>=127744&&e<=129535||e>=129536&&e<=129791||e>=129792&&e<=130047||e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}function ue(e){let t=0;for(let n of e)t+=Re(n.codePointAt(0));return t}function Ve(e,t){if(t<=0)return"";let n=0,r="";for(let o of e){let s=Re(o.codePointAt(0));if(n+s>t){if(t<=1)return"\u2026";for(;n+1>t&&r.length>0;){let i=[...r].pop();r=r.slice(0,-i.length),n-=Re(i.codePointAt(0))}return`${r}\u2026`}r+=o,n+=s}return r}var gt={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"},mt={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function Ue(e,t){let n=t.charset==="ascii"?mt:gt,r=e.width,o=e.height,s=Array.from({length:o},()=>Array.from({length:r},()=>" ")),i=Array.from({length:o},()=>Array.from({length:r},()=>"empty"));for(let a of e.edges)yt(s,i,n,a);for(let a of e.boxes)bt(s,i,n,a,t.labelOf(a.id));return s.map(a=>Ot(a.join(""))).join(`
|
|
3
|
+
`)}function bt(e,t,n,r,o){let{x:s,y:i,w:a,h:l}=r;if(a<2||l<2){l>0&&Ke(e,t,s,i,a,o);return}H(e,t,s,i,n.boxTL);for(let d=s+1;d<s+a-1;d+=1)H(e,t,d,i,n.boxH);H(e,t,s+a-1,i,n.boxTR);for(let d=i+1;d<i+l-1;d+=1){H(e,t,s,d,n.boxV);for(let h=s+1;h<s+a-1;h+=1)Je(e,t,h,d," ","empty");H(e,t,s+a-1,d,n.boxV)}H(e,t,s,i+l-1,n.boxBL);for(let d=s+1;d<s+a-1;d+=1)H(e,t,d,i+l-1,n.boxH);H(e,t,s+a-1,i+l-1,n.boxBR);let u=i+Math.floor(l/2);Ke(e,t,s+1,u,a-2,o)}function H(e,t,n,r,o){Je(e,t,n,r,o,o===" "?"empty":o==="\u2500"||o==="-"?"boxH":o==="\u2502"||o==="|"?"boxV":"boxCorner")}function Je(e,t,n,r,o,s){if(r<0||r>=e.length)return;let i=e[r];n<0||n>=i.length||(i[n]=o,t[r][n]=s)}function Ke(e,t,n,r,o,s){if(r<0||r>=e.length)return;let i=n,a=o;for(let l of s){let u=ue(l);if(u!==0){if(a<u)break;i>=0&&i<e[r].length&&(e[r][i]=l,t[r][i]="label",u===2&&i+1<e[r].length&&(e[r][i+1]="",t[r][i+1]="label")),i+=u,a-=u}}for(;a>0;)i>=0&&i<e[r].length&&(e[r][i]=" ",t[r][i]="empty"),i+=1,a-=1}function yt(e,t,n,r){let o=r.points;if(o.length<2)return;for(let l=0;l+1<o.length;l+=1)vt(e,t,n,o[l],o[l+1]);for(let l=1;l+1<o.length;l+=1){let u=o[l-1],d=o[l],h=o[l+1],p=xt(u,d,h,n);p&&qe(e,t,d.x,d.y,p,"edgeCorner")}let s=o[o.length-1],i=o[o.length-2],a=wt(i,s,n);a&&qe(e,t,s.x,s.y,a,"arrow")}function vt(e,t,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 l=i;l<=a;l+=1)We(e,t,l,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 l=i;l<=a;l+=1)We(e,t,s,l,n,"v")}}}function We(e,t,n,r,o,s){if(r<0||r>=e.length)return;let i=e[r];if(n<0||n>=i.length)return;let a=t[r][n];if(!(a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label")){if(a==="empty"){i[n]=s==="h"?o.horizontal:o.vertical,t[r][n]=s==="h"?"edgeH":"edgeV";return}if(a==="edgeH"&&s==="v"){i[n]=o.cross,t[r][n]="edgeCorner";return}if(a==="edgeV"&&s==="h"){i[n]=o.cross,t[r][n]="edgeCorner";return}}}function qe(e,t,n,r,o,s){if(r<0||r>=e.length)return;let i=e[r];if(n<0||n>=i.length)return;let a=t[r][n];a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label"||(i[n]=o,t[r][n]=s)}function xt(e,t,n,r){let o=e.y===t.y,s=t.y===n.y;if(o===s)return;if(o){let l=e.x<t.x,u=n.y>t.y;return l&&u?r.cornerTR:l&&!u?r.cornerBR:!l&&u?r.cornerTL:r.cornerBL}let i=e.y<t.y,a=n.x>t.x;return i&&a?r.cornerBL:i&&!a?r.cornerBR:!i&&a?r.cornerTL:r.cornerTR}function wt(e,t,n){if(t.x>e.x)return n.arrowRight;if(t.x<e.x)return n.arrowLeft;if(t.y>e.y)return n.arrowDown;if(t.y<e.y)return n.arrowUp}function Ot(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===32;)t-=1;return e.slice(0,t)}function Qe(e){let t=_t(e);Et(t),St(t),Rt(t),Dt(t,e);let n=kt(t,e),{width:r,height:o}=Tt(t),s=[];for(let i of t.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 _t(e){let t=new Map;for(let o of e.nodes)t.set(o,{id:o,isVirtual:!1,layer:-1,order:0,x:0,y:0,w:e.widthCells(o),h:e.heightCells(o),in:[],out:[]});let n=[],r=0;for(let o of e.edges){if(o.from===o.to)continue;let s=t.get(o.from),i=t.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:t,layers:[],hops:n}}function Et(e){let t=new Map;for(let s of e.nodes.values())t.set(s.id,s.in.length);let n=[];for(let s of e.nodes.values())(t.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=e.nodes.get(i.toId);a.layer=Math.max(a.layer,s.layer+1);let l=(t.get(a.id)??0)-1;t.set(a.id,l),l<=0&&n.push(a)}}}for(let s of e.nodes.values())s.layer<0&&(s.layer=0)}function St(e){let t=Math.max(0,...Array.from(e.nodes.values(),s=>s.layer)),n=Array.from({length:t+1},()=>[]);for(let s of e.nodes.values())n[s.layer].push(s);let r=[],o=0;for(let s of e.hops){let i=e.nodes.get(s.fromId),a=e.nodes.get(s.toId),l=a.layer-i.layer;if(l<=0){i.out=i.out.filter(h=>h!==s),a.in=a.in.filter(h=>h!==s);continue}if(l===1){s.hopIndex=0,s.chainLen=1,r.push(s);continue}i.out=i.out.filter(h=>h!==s),a.in=a.in.filter(h=>h!==s);let u=i;for(let h=1;h<l;h+=1){let p=`__virt_${o++}__`,f={id:p,isVirtual:!0,layer:i.layer+h,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};e.nodes.set(p,f),n[f.layer].push(f);let c={chainId:s.chainId,chainFrom:s.chainFrom,chainTo:s.chainTo,fromId:u.id,toId:p,hopIndex:h-1,chainLen:l};u.out.push(c),f.in.push(c),r.push(c),u=f}let d={chainId:s.chainId,chainFrom:s.chainFrom,chainTo:s.chainTo,fromId:u.id,toId:a.id,hopIndex:l-1,chainLen:l};u.out.push(d),a.in.push(d),r.push(d)}for(let s of n)for(let i=0;i<s.length;i+=1)s[i].order=i;e.layers=n,e.hops=r}function Rt(e){for(let n=0;n<4;n+=1){for(let r=1;r<e.layers.length;r+=1)Ye(e,e.layers[r],"in"),le(e.layers[r]);for(let r=e.layers.length-2;r>=0;r-=1)Ye(e,e.layers[r],"out"),le(e.layers[r])}for(let n=0;n<2;n+=1){let r=!1;for(let o=1;o<e.layers.length;o+=1){let s=e.layers[o];for(let i=0;i+1<s.length;i+=1){let a=Xe(e,s[i],s[i+1],"in");[s[i],s[i+1]]=[s[i+1],s[i]],le(s),Xe(e,s[i],s[i+1],"in")<a?r=!0:([s[i],s[i+1]]=[s[i+1],s[i]],le(s))}}if(!r)break}}function Ye(e,t,n){let r=new Map;for(let o of t){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 l of s){let u=e.nodes.get(n==="in"?l.fromId:l.toId);u&&(i+=u.order,a+=1)}r.set(o.id,a===0?o.order:i/a)}t.sort((o,s)=>{let i=r.get(o.id),a=r.get(s.id);return i!==a?i-a:o.order-s.order})}function le(e){for(let t=0;t<e.length;t+=1)e[t].order=t}function Xe(e,t,n,r){let o=r==="in"?t.in:t.out,s=r==="in"?n.in:n.out,i=0;for(let a of o)for(let l of s){let u=e.nodes.get(r==="in"?a.fromId:a.toId)?.order??0,d=e.nodes.get(r==="in"?l.fromId:l.toId)?.order??0;(t.order<n.order&&u>d||t.order>n.order&&u<d)&&(i+=1)}return i}function Dt(e,t){t.direction==="LR"?Gt(e,t):Ct(e,t)}function Gt(e,t){let n=[],r=0;for(let o=0;o<e.layers.length;o+=1){n.push(r);let s=0;for(let i of e.layers[o])s=Math.max(s,i.w);r+=s+t.layerGap}for(let o=0;o<e.layers.length;o+=1)for(let s of e.layers[o])s.x=n[o];for(let o of e.layers){let s=0;for(let i of o)i.y=s,s+=i.h+t.nodeGap}Ze(e,t,"y")}function Ct(e,t){let n=[],r=0;for(let o=0;o<e.layers.length;o+=1){n.push(r);let s=0;for(let i of e.layers[o])s=Math.max(s,i.h);r+=s+t.layerGap}for(let o=0;o<e.layers.length;o+=1)for(let s of e.layers[o])s.y=n[o];for(let o of e.layers){let s=0;for(let i of o)i.x=s,s+=i.w+t.nodeGap}Ze(e,t,"x")}function Ze(e,t,n){let r=s=>n==="y"?s.h:s.w,o=t.nodeGap;for(let s=0;s<2;s+=1){let i=s===0?e.layers.slice(1):e.layers.slice(0,-1).reverse();for(let a of i){let l=new Map;for(let d of a){let h=s===0?d.in:d.out;if(h.length===0)continue;let p=[];for(let c of h){let g=e.nodes.get(s===0?c.fromId:c.toId);if(!g)continue;let b=n==="y"?g.y:g.x;p.push(b+Math.floor(r(g)/2))}if(p.length===0)continue;p.sort((c,g)=>c-g);let f=p[Math.floor(p.length/2)];l.set(d.id,f-Math.floor(r(d)/2))}let u=0;for(let d of a){let h=l.get(d.id),p=n==="y"?d.y:d.x,c=Math.max(h??p,u);n==="y"?d.y=c:d.x=c,u=c+r(d)+o}}}}function kt(e,t){let n=new Map;for(let u of e.hops){let d=n.get(u.chainId);d?d.push(u):n.set(u.chainId,[u])}for(let u of n.values())u.sort((d,h)=>d.hopIndex-h.hopIndex);let r=t.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<e.layers.length;u+=1){let d=e.layers[u],h=e.layers[u+1],p=0;for(let E of d)p=Math.max(p,o(E)+s(E));let f=Number.POSITIVE_INFINITY;for(let E of h)f=Math.min(f,o(E));let c=Number.isFinite(f)?f-1:p,g=Math.max(1,c-p+1),b=[];for(let E of d)for(let R of E.out)b.push(R);b.sort((E,R)=>{let k=i(e.nodes.get(E.fromId)),$=i(e.nodes.get(R.fromId));if(k!==$)return k-$;let G=i(e.nodes.get(E.toId)),D=i(e.nodes.get(R.toId));return G-D});let v=[],w=new Map;for(let E of b){let R=i(e.nodes.get(E.fromId)),k=i(e.nodes.get(E.toId)),$=Math.min(R,k),G=Math.max(R,k),D=-1;for(let P=0;P<v.length;P+=1){let F=v[P],z=!0;for(let U of F)if(U.lo<=G&&$<=U.hi){z=!1;break}if(z){F.push({lo:$,hi:G}),D=P;break}}D<0&&(v.push([{lo:$,hi:G}]),D=v.length-1),w.set(E,D)}let m=v.length,y=g>=Math.max(3,m+2),S=y?p+1:p,x=y?c-1:c,O=Math.max(1,x-S+1);for(let E of b){let R=w.get(E),k;if(m<=1)k=S+Math.floor(O/2);else{let $=(O-1)/(m-1);k=S+Math.floor(R*$)}a.set(E,Math.max(p,Math.min(c,k)))}}let l=[];for(let[,u]of n){let d=[];for(let p=0;p<u.length;p+=1){let f=u[p],c=e.nodes.get(f.fromId),g=e.nodes.get(f.toId),b=a.get(f),v=c.isVirtual?o(c):o(c)+s(c),w=g.isVirtual?o(g):o(g)-1,m=i(c),y=i(g);p===0&&ce(d,r,v,m),m!==y&&(ce(d,r,b,m),ce(d,r,b,y)),ce(d,r,w,y)}let h=u[0];l.push({from:h.chainFrom,to:h.chainTo,points:$t(d)})}return l}function ce(e,t,n,r){e.push(t?{x:n,y:r}:{x:r,y:n})}function $t(e){let t=[];for(let n of e){let r=t[t.length-1];(!r||r.x!==n.x||r.y!==n.y)&&t.push(n)}return t}function Tt(e){let t=0,n=0;for(let r of e.layers)for(let o of r)t=Math.max(t,o.x+o.w),n=Math.max(n,o.y+o.h);return{width:t,height:n}}var Nt=24,At=4,Pt=1,Mt=3;function et(e,t){let n=Lt(t.direction),r=Math.max(3,t.maxLabelWidth??Nt),o=t.asciiCharset??"unicode",s=Object.keys(e.nodes).sort(),i=new Set(s),a=e.edges.filter(f=>i.has(f.from)&&i.has(f.to)),l=new Map,u=new Map;for(let f of s){let c=Ve(f,r);l.set(f,c),u.set(f,ue(c)+4)}let d=Qe({nodes:s,edges:a,widthCells:f=>u.get(f)??3,heightCells:()=>Mt,layerGap:At,nodeGap:Pt,direction:n}),h=Ue(d,{charset:o,labelOf:f=>l.get(f)??f}),p=t.logger;return p&&p(h),h}function Lt(e){if(e===void 0||e==="LR")return"LR";if(e==="TD")return"TD";throw new Error(`ascii describe supports direction "LR" or "TD" only; got ${String(e)}`)}var N="::",B="__meta__",q=1;function tt(e,t){let n=Math.max(16,e.size*4),r=0;for(;e.size>0;){if(r++>=n){console.error(`[Graph "${t}".destroy] disposer drain exceeded cap (${n}); ${e.size} disposer(s) discarded`),e.clear();return}let o=e.values().next();if(o.done)return;let s=o.value;e.delete(s);try{s()}catch(i){console.error(`[Graph "${t}".destroy] disposer threw:`,i)}}}function It(e){let t=[];for(let n of Object.keys(e).sort()){let r=e[n].v;r!=null&&t.push(`${n} ${r.id} ${r.version}`)}return t.join(`
|
|
4
|
+
`)}function nt(e){if(e.version!==q)throw new Error(`unsupported snapshot version ${String(e.version)} (expected ${q})`);for(let t of["name","nodes","edges","subgraphs"])if(!(t in e))throw new Error(`snapshot missing required key "${t}"`);if(typeof e.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof e.nodes!="object"||e.nodes===null||Array.isArray(e.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(e.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(e.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function jt(e,t){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,l=s.constructor;if(a!==l)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 f=0;f<o.length;f++)if(!r(o[f],p[f]))return!1;return!0}if(o instanceof Map){let p=s;if(o.size!==p.size)return!1;for(let[f,c]of o)if(!p.has(f)||!r(c,p.get(f)))return!1;return!0}if(o instanceof Set){let p=s;if(o.size!==p.size)return!1;for(let f of o){let c=!1;for(let g of p)if(r(f,g)){c=!0;break}if(!c)return!1}return!0}if(ArrayBuffer.isView(o)){let p=o,f=s;if(p.length!==f.length)return!1;for(let c=0;c<p.length;c++)if(p[c]!==f[c])return!1;return!0}let u=Object.keys(o),d=Object.keys(s);if(u.length!==d.length)return!1;let h=new Set(d);for(let p of u)if(!h.has(p)||!r(o[p],s[p]))return!1;return!0};return r(e,t)}function Ge(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ge);let t=e,n=Object.keys(t).sort(),r={};for(let o of n)r[o]=Ge(t[o]);return r}function Bt(e){return e.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Ft(e){return e.replaceAll("\\","\\\\").replaceAll('"','\\"')}function zt(e){return e==="TD"?"down":e==="BT"?"up":e==="RL"?"left":"right"}function ot(e){let t=new Set,n=[];function r(o,s){let i=`${o}\0${s}`;t.has(i)||(t.add(i),n.push([o,s]))}for(let[o,s]of Object.entries(e.nodes)){let i=s.deps;if(i)for(let a of i)r(a,o)}for(let o of e.edges)r(o.from,o.to);return n}function it(e){if(e===void 0)return"LR";if(e==="TD"||e==="LR"||e==="BT"||e==="RL")return e;throw new Error(`invalid diagram direction ${String(e)}; expected one of: TD, LR, BT, RL`)}function Ht(e,t){let n=t.includeEdges??!0,r=t.includeSubgraphs??!0,{expand:o,...s}=e,i={...s,edges:n?e.edges:[],subgraphs:r?e.subgraphs:[]},a=JSON.stringify(Ge(i),null,t.indent??2);return t.logger?.(a),a}function Vt(e,t){let n=t.includeEdges??!0,r=t.includeSubgraphs??!0,o=[];o.push(`Graph ${e.name}`),o.push("Nodes:");for(let i of Object.keys(e.nodes).sort()){let a=e.nodes[i];o.push(`- ${i} (${a.type}/${a.status}): ${fe(a.value)}`)}if(n){o.push("Edges:");for(let i of e.edges)o.push(`- ${i.from} -> ${i.to}`)}if(r){o.push("Subgraphs:");for(let i of e.subgraphs)o.push(`- ${i}`)}let s=o.join(`
|
|
5
|
+
`);return t.logger?.(s),s}function at(e,t){let n=it(t.direction),r=Object.keys(e.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}["${Bt(i)}"]`)}for(let[i,a]of ot(e)){let l=o.get(i),u=o.get(a);!l||!u||s.push(` ${l} --> ${u}`)}return s.join(`
|
|
6
|
+
`)}function Kt(e,t){let n=at(e,t);return Wt(n)}function Wt(e,t){let n=t?.theme??"default",r=t?.autoSync??!0,s=JSON.stringify({code:e,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 qt(e,t){let n=it(t.direction),r=Object.keys(e.nodes).sort(),o=new Map;for(let i=0;i<r.length;i+=1)o.set(r[i],`n${i}`);let s=[`direction: ${zt(n)}`];for(let i of r){let a=o.get(i);s.push(`${a}: "${Ft(i)}"`)}for(let[i,a]of ot(e)){let l=o.get(i),u=o.get(a);!l||!u||s.push(`${l} -> ${u}`)}return s.join(`
|
|
7
|
+
`)}function Ut(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function de(e){let t="^";for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="*"){t+=".*";continue}if(r==="?"){t+=".";continue}if(r==="["){let o=e.indexOf("]",n+1);if(o<=n+1){t+="\\[";continue}let s=e.slice(n+1,o);s.startsWith("!")&&(s=`^${s.slice(1)}`),s=s.replace(/\\/g,"\\\\"),t+=`[${s}]`,n=o;continue}t+=Ut(r)}return t+="$",new RegExp(t)}var Jt={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"},Yt={data:"",dirty:"",resolved:"",invalidate:"",pause:"",resume:"",complete:"",error:"",teardown:"",derived:"",path:"",reset:""};function fe(e){if(typeof e=="string")return JSON.stringify(e);if(typeof e=="number"||typeof e=="boolean"||e==null)return String(e);try{return JSON.stringify(e)}catch{return"[unserializable]"}}function Xt(e){return e==="none"?Yt:e==="ansi"||e==null?Jt:{data:e.data??"",dirty:e.dirty??"",resolved:e.resolved??"",invalidate:e.invalidate??"",pause:e.pause??"",resume:e.resume??"",complete:e.complete??"",error:e.error??"",teardown:e.teardown??"",derived:e.derived??"",path:e.path??"",reset:e.reset??""}}function rt(e){if(e==null)return{};let t=e.detail;return t==="full"?{...e,structured:e.structured??!0,timeline:e.timeline??!0,causal:e.causal??!0,derived:e.derived??!0}:t==="minimal"?{...e,structured:e.structured??!0}:e.format==="stage-log"?{...e,structured:e.structured??!0,timeline:e.timeline??!0}:e}function Qt(e,t,n){for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);if(o<32||o===127)throw new Error(`Graph "${t}": ${n} "${e}" must not contain control character (U+${o.toString(16).padStart(4,"0").toUpperCase()} at index ${r})`)}}function De(e,t,n){if(e==="")throw new Error(`Graph "${t}": ${n} name must be non-empty`);if(e.includes(N))throw new Error(`Graph "${t}": ${n} "${e}" must not contain '${N}' (path separator)`);if(e===B)throw new Error(`Graph "${t}": ${n} name "${B}" is reserved for meta companion paths`);Qt(e,t,n)}function Zt(e,t){if(e==="")throw new Error(`Graph "${t}": resolve path must be non-empty`);let n=e.split(N);for(let r of n)if(r==="")throw new Error(`Graph "${t}": resolve path has empty segment`);return n}function en(e,t){let n=!1;for(let o of e)if(!t.isMetaPassthrough(o[0])){n=!0;break}return n?e.filter(o=>t.isMetaPassthrough(o[0])):e}function ut(e){for(let t of e._mounts.values())ut(t);for(let t of e._nodes.values())try{t.down([[V]],{internal:!0})}catch{}}var Ce=class e{name;opts;config;_nodes=new Map;_nodeToName=new WeakMap;_mounts=new Map;_parent=void 0;_storageDisposers=new Set;_disposers=new Set;_topology;_topologyEmitters=new Set;constructor(t,n){if(t==="")throw new Error("Graph name must be non-empty");if(t.includes(N))throw new Error(`Graph name must not contain '${N}' (got "${t}")`);if(t===B)throw new Error(`Graph name "${B}" is reserved for meta companion paths`);this.name=t,this.opts=Object.freeze({...n??{}}),this.config=n?.config??Oe,this._traceRing=new X(n?.traceCapacity??1e3),n?.versioning!=null&&this.setVersioning(n.versioning)}ancestors(t=!0){let n=[],r=t?this:this._parent;for(;r!=null;)n.push(r),r=r._parent;return n}get topology(){return this._topology==null&&(this._topology=Me(t=>{let n=r=>{t.emit(r)};return this._topologyEmitters.add(n),()=>{this._topologyEmitters.delete(n)}},{name:`${this.name}_topology`})),this._topology}_emitTopology(t){if(!(this._topology==null||this._topologyEmitters.size===0))for(let n of this._topologyEmitters)n(t)}add(t,n){let r=t.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(De(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(t);if(a!==void 0)throw new Error(`Graph "${this.name}": node instance already registered as "${a}"`);return this._nodes.set(s,t),this._nodeToName.set(t,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:K()})),t}setVersioning(t){if(t!=null)for(let n of this._nodes.values())n instanceof L&&n._applyVersioning(t)}remove(t){De(t,this.name,"remove");let n=this._mounts.get(t);if(n){let s={kind:"mount",nodes:[],mounts:[]},i=[];n._collectObserveTargets("",i);for(let[a,l]of i)a.includes(`${N}${B}${N}`)||s.nodes.push(a);return s.nodes.sort(),s.mounts.push(t),s.mounts.push(...n._collectSubgraphs(`${t}${N}`)),this._mounts.delete(t),n._parent=void 0,ut(n),this._emitTopology({kind:"removed",name:t,nodeKind:"mount",audit:s}),s}let r=this._nodes.get(t);if(!r)throw new Error(`Graph "${this.name}": unknown node or mount "${t}"`);this._nodes.delete(t),this._nodeToName.delete(r),r.down([[V]],{internal:!0});let o={kind:"node",nodes:[t],mounts:[]};return this._emitTopology({kind:"removed",name:t,nodeKind:"node",audit:o}),o}removeAll(t){let n=typeof t=="function"?t:(()=>{let s=de(t);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 t=[...this._nodes.keys()].sort(),n=this._nodes,r=0;return{[Symbol.iterator](){return this},next(){if(r>=t.length)return{value:void 0,done:!0};let o=t[r++];return{value:[o,n.get(o)],done:!1}}}}node(t){if(t==="")throw new Error(`Graph "${this.name}": node name must be non-empty`);if(t.includes(N))return this.resolve(t);let n=this._nodes.get(t);if(!n)throw new Error(`Graph "${this.name}": unknown node "${t}"`);return n}get(t){return this.node(t).cache}set(t,n,r){let o=r?.internal===!0;this.node(t).down([[Z,n]],{actor:r?.actor,internal:o,delivery:"write"})}setAll(t,n){let r=Symbol.iterator in t?t:Object.entries(t);Ae(()=>{for(let[o,s]of r)this.set(o,s,n)})}invalidate(t,n){let r=n?.internal===!0;this.node(t).down([[ee]],{actor:n?.actor,internal:r,delivery:"write"})}error(t,n,r){let o=r?.internal===!0;this.node(t).down([[ne,n]],{actor:r?.actor,internal:o,delivery:"write"})}complete(t,n){let r=n?.internal===!0;this.node(t).down([[te]],{actor:n?.actor,internal:r,delivery:"write"})}edges(t){let n=t?.recursive===!0,r=new Map;if(!n){for(let[l,u]of this._nodes)r.set(u,l);let a=[];for(let[l,u]of this._nodes)if(u instanceof L)for(let d of u._deps){let h=r.get(d.node);h!=null&&a.push([h,l])}return a.sort((l,u)=>l[0]<u[0]?-1:l[0]>u[0]?1:l[1]<u[1]?-1:l[1]>u[1]?1:0),a}let o=[];this._collectObserveTargets("",o);let s=new Map;for(let[a,l]of o)s.set(l,a);let i=[];for(let[a,l]of o)if(l instanceof L)for(let u of l._deps){let d=s.get(u.node);d!=null&&i.push([d,a])}return i.sort((a,l)=>a[0]<l[0]?-1:a[0]>l[0]?1:a[1]<l[1]?-1:a[1]>l[1]?1:0),i}mount(t,n){if(De(t,this.name,"mount"),this._nodes.has(t))throw new Error(`Graph "${this.name}": cannot mount at "${t}" \u2014 node with that name exists`);if(this._mounts.has(t))throw new Error(`Graph "${this.name}": mount "${t}" 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 r=this;r!=null;r=r._parent)if(r===n)throw new Error(`Graph "${this.name}": mount("${t}", \u2026) would create a mount cycle`);return this._mounts.set(t,n),n._parent=this,this._emitTopology({kind:"added",name:t,nodeKind:"mount"}),n}resolve(t){let n=Zt(t,this.name);return this._resolveFromSegments(n)}tryResolve(t){try{return this.resolve(t)}catch{return}}_resolveFromSegments(t){let n=t;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]===B)return this._resolveMetaChainFromNode(s,o,n.join(N));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(N)}" is invalid`):new Error(`Graph "${this.name}": unknown mount or node "${r}"`);return i.resolve(o.join(N))}_resolveMetaChainFromNode(t,n,r){let o=t,s=0,i=[...n];for(;s<i.length;){if(i[s]!==B)throw new Error(`Graph "${this.name}": expected ${B} segment in meta path "${r}"`);if(s+1>=i.length)throw new Error(`Graph "${this.name}": meta path requires a key after ${B} in "${r}"`);let a=i[s+1],l=o.meta[a];if(!l)throw new Error(`Graph "${this.name}": unknown meta "${a}" in path "${r}"`);o=l,s+=2}return o}signal(t,n){if(n?.internal!==!0){for(let o of t)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(t,n??{},new Set,r),r.length>0)throw r[0]}_signalDeliver(t,n,r,o){for(let l of this._mounts.values())l._signalDeliver(t,n,r,o);let i=n.internal===!0?{internal:!0}:{actor:n.actor,delivery:"signal"},a=en(t,this.config);for(let l of[...this._nodes.keys()].sort()){let u=this._nodes.get(l);if(!r.has(u)){r.add(u);try{u.down(t,i)}catch(d){if(d instanceof W)throw d;o.push(d)}a.length!==0&&this._signalMetaSubtree(u,a,r,i,o)}}}_signalMetaSubtree(t,n,r,o,s){for(let i of Object.keys(t.meta).sort()){let a=t.meta[i];if(!r.has(a)){r.add(a);try{a.down(n,o)}catch(l){if(l instanceof W)throw l;s.push(l)}this._signalMetaSubtree(a,n,r,o,s)}}}describe(t){if(t?.reactive===!0)return this._describeReactive(t);let n=t?.actor,r=t?.filter,o=se(t?.detail,t?.fields),s=t?.format==="spec",i=s?se("minimal"):o,a=[];this._collectObserveTargets("",a);let l=new Map;for(let[x,O]of a)l.set(O,x);let u=[];{let x=a.map(([,R])=>R),O=new Set(l.values()),E=0;for(;x.length>0;){let R=x.shift();if(R instanceof L)for(let k of R._deps){let $=k.node;if(l.has($))continue;let G=$.name??"",D=G;if(!D||O.has(D))if(G){let P=2;for(;O.has(`${G}#${P}`);)P++;D=`${G}#${P}`}else for(D=`__internal__/${E++}`;O.has(D);)D=`__internal__/${E++}`;l.set($,D),O.add(D),u.push([D,$]),x.push($)}}}let d=[...a,...u],h={};for(let[x,O]of d){if(n!=null&&!O.allowsObserve(n))continue;let E=Se(O,i),R=O instanceof L?O._deps.map(D=>l.get(D.node)??D.node.name??""):[],{name:k,...$}=E,G={...$,deps:R};if(!s){let D=this._annotations.get(x);D!=null&&(G.annotation=D)}if(r!=null)if(typeof r=="function"){let D=r;if(!(D.length>=2?D(x,G):D(G)))continue}else{let D=!0;for(let[P,F]of Object.entries(r)){let z=P==="deps_includes"?"depsIncludes":P==="meta_has"?"metaHas":P;if(z==="depsIncludes"){if(!G.deps.includes(String(F))){D=!1;break}continue}if(z==="metaHas"){if(!Object.hasOwn(G.meta??{},String(F))){D=!1;break}continue}if(G[z]!==F){D=!1;break}}if(!D)continue}h[x]=G}let p=new Set(Object.keys(h)),f=[];for(let[x,O]of d)if(O instanceof L)for(let E of O._deps){let R=l.get(E.node);R!=null&&f.push([R,x])}f.sort((x,O)=>x[0]<O[0]?-1:x[0]>O[0]?1:x[1]<O[1]?-1:x[1]>O[1]?1:0);let c=f.map(([x,O])=>({from:x,to:O}));(n!=null||r!=null)&&(c=c.filter(x=>p.has(x.from)&&p.has(x.to)));let g=this._collectSubgraphs(""),b=n!=null||r!=null?g.filter(x=>{let O=`${x}${N}`;return[...p].some(E=>E===x||E.startsWith(O))}):g,v=this,w=t,m={name:this.name,nodes:h,edges:c,subgraphs:b,expand(x){let O={...w,format:void 0};return Array.isArray(x)?(O.fields=x,O.detail=void 0):(O.detail=x,O.fields=void 0),v.describe(O)}},y=t??{},S=y.format;return S==="json"?Ht(m,y):S==="pretty"?Vt(m,y):S==="mermaid"?at(m,y):S==="mermaid-url"?Kt(m,y):S==="d2"?qt(m,y):S==="ascii"?et(m,y):m}_collectSubgraphs(t){let n=[];for(let r of[...this._mounts.keys()].sort()){let o=t===""?r:`${t}${r}`;n.push(o),n.push(...this._mounts.get(r)._collectSubgraphs(`${o}${N}`))}return n}resourceProfile(t){return He(this,t)}reachable(t,n,r={}){return r.withDetail===!0?st(this.describe(),t,n,{...r,withDetail:!0}):st(this.describe(),t,n,r)}explain(t,n,r){return r?.reactive===!0?this._explainReactive(t,n,r):this._explainStatic(t,n,r)}_explainStatic(t,n,r){let o=this.describe({detail:"full"}),s=new Map(this._annotations),i=new Map;for(let[a,l]of Object.entries(o.nodes))l.lastMutation!=null&&i.set(a,l.lastMutation);return Ie(o,t,n,{...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{},annotations:s,lastMutations:i})}_describeReactive(t){let n={...t,reactive:!1},r=t.reactiveName??"describe",o=0,s=re(o,{name:`${r}_version`}),i=this.observe({timeline:!0,structured:!0}),a=!1,l=!1,u=()=>{a||l||(a=!0,we(()=>{a=!1,!l&&(o+=1,s.emit(o))}))},d=i.onEvent(b=>{let v=b.type;v!=="data"&&v!=="error"&&v!=="complete"&&v!=="teardown"||u()}),h=[],p=new WeakSet,f=b=>{if(p.has(b)||l)return;p.add(b);let v=b.topology.subscribe(w=>{for(let m of w){if(m[0]!==Z)continue;let y=m[1];if(u(),y.kind==="added"&&y.nodeKind==="mount"){let S=b._mounts.get(y.name);S!=null&&f(S)}}});h.push(v);for(let w of b._mounts.keys()){let m=b._mounts.get(w);m!=null&&f(m)}};f(this);let c;try{c=_e([s],()=>this.describe(n),{name:r,describeKind:"derived",meta:{domain:"audit",kind:"describe"},equals:(b,v)=>b===v})}catch(b){d();for(let v of h)v();throw i.dispose(),b}let g=Ee(c);return{node:c,dispose(){l=!0,d();for(let b of h)b();h.length=0,i.dispose(),g()}}}_explainReactive(t,n,r){let o=0,s=re(o,{name:"explain_version"}),i=this.observe({timeline:!0,structured:!0}),a=!1,l=!1,u=i.onEvent(f=>{let c=f.type;c!=="data"&&c!=="error"&&c!=="complete"&&c!=="teardown"||a||l||(a=!0,we(()=>{a=!1,!l&&(o+=1,s.emit(o))}))}),d={...r?.maxDepth!=null?{maxDepth:r.maxDepth}:{},...r?.findCycle===!0?{findCycle:!0}:{}},h;try{h=_e([s],()=>this._explainStatic(t,n,d),{name:r?.name??"explain",describeKind:"derived",meta:{domain:"audit",kind:"explain_path",from:t,to:n},equals:(f,c)=>f.found===c.found&&f.reason===c.reason&&f.steps.length===c.steps.length&&nn(f.steps,c.steps)})}catch(f){throw u(),i.dispose(),f}let p=Ee(h);return{node:h,dispose(){l=!0,u(),i.dispose(),p()}}}_pathsMatching(t){let n=de(t),r=[];return this._collectObserveTargets("",r),r.map(([o])=>o).filter(o=>n.test(o))}_collectObserveTargets(t,n){for(let r of[...this._mounts.keys()].sort()){let o=t===""?r:`${t}${N}${r}`;this._mounts.get(r)._collectObserveTargets(o,n)}for(let r of[...this._nodes.keys()].sort()){let o=this._nodes.get(r),s=t===""?r:`${t}${N}${r}`;n.push([s,o]),this._appendMetaObserveTargets(s,o,n)}}_appendMetaObserveTargets(t,n,r){for(let o of Object.keys(n.meta).sort()){let s=n.meta[o],i=`${t}${N}${B}${N}${o}`;r.push([i,s]),this._appendMetaObserveTargets(i,s,r)}}observe(t,n){let r=typeof t=="string",s=rt(r?n:t),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 d=t,h=this.resolve(d);if(a!=null&&!h.allowsObserve(a))throw new W({actor:a,action:"observe",nodeName:d});return i?this._buildStructuredObserver([[d,h]],s,"one"):{subscribe(p){return h.subscribe(p)},up(p){try{h.up?.(p)}catch(f){if(f instanceof W)return;throw f}}}}let l=[];this._collectObserveTargets("",l),l.sort((d,h)=>d[0]<h[0]?-1:d[0]>h[0]?1:0);let u=a==null?l:l.filter(([,d])=>d.allowsObserve(a));return i?this._buildStructuredObserver(u,s,"all"):{subscribe:d=>{let h=u.map(([p,f])=>f.subscribe(c=>{d(p,c)}));return()=>{for(let p of h)p()}},up:(d,h)=>{try{this.resolve(d).up?.(h)}catch(p){if(p instanceof W)return;throw p}}}}_buildStructuredObserver(t,n,r){let o=r==="one"?t[0]?.[0]:void 0,s=i=>{if(r==="one"&&o!=null){let d=this.resolve(o);return this._buildStructuredObserver([[o,d]],i,"one")}let a=[];this._collectObserveTargets("",a),a.sort((d,h)=>d[0]<h[0]?-1:d[0]>h[0]?1:0);let l=i.actor,u=l==null?a:a.filter(([,d])=>d.allowsObserve(l));return this._buildStructuredObserver(u,i,"all")};return this._createObserveResult(t,n,s)}_createObserveResult(t,n,r){let o=n.timeline===!0,s=n.causal===!0,i=n.derived===!0,a=n.detail==="minimal",l=this.config.inspectorEnabled,u=(s||i)&&l,d=n.maxEvents,h=d!=null&&d>0?new X(d):null,p=[],f=new Set,c={},g=new Set,b=0,v=0,w=0,m=0,y=0,S=0,x=!1,O=!1,E=0,R=new Map,k=new Map,$=new Map,G=_=>{h?h.push(_):p.push(_);for(let T of f)T(_)},D=()=>o?{timestamp_ns:K(),in_batch:Ne(),batch_id:E}:{},P=(_,T)=>{if(!(!u||!(_ instanceof L)))return _._setInspectorHook(I=>{if(I.kind==="dep_message")R.set(_,I.depIndex);else if(I.kind==="run"){let J=I.batchData.map((C,M)=>C!=null&&C.length>0?C.at(-1):I.prevData[M]);k.set(_,J);let j=I.batchData.map(C=>C!=null?[...C]:void 0);$.set(_,j),i&&G({type:"derived",path:T,dep_values:J,dep_batches:j,...D()})}})},F=_=>{let T=R.get(_),I=k.get(_);if(!s||I==null)return{};let j=(T!=null&&T>=0&&_ instanceof L?_._deps[T]:void 0)?.node,C=j?.v,M=$.get(_);return{trigger_dep_index:T,trigger_dep_name:j?.name,...C!=null?{trigger_version:{id:C.id,version:C.version}}:{},dep_values:[...I],...M!=null?{dep_batches:M}:{}}},z=[],U=[];for(let[_,T]of t){let I=P(T,_);I&&z.push(I),U.push(T.subscribe(J=>{E++;for(let j of J){let C=j[0],M=D();if(C===Z){c[_]=j[1];let me=T instanceof L?T.lastMutation?.actor??Y:Y;G({type:"data",path:_,data:j[1],actor:me,...M,...F(T)})}else if(a)C===be?b++:C===ye?v++:C===ee?w++:C===ve?m++:C===xe?y++:C===V?S++:C===te&&!g.has(_)?x=!0:C===ne&&(O=!0,g.add(_));else if(C===be)b++,G({type:"dirty",path:_,...M});else if(C===ye)v++,G({type:"resolved",path:_,...M,...F(T)});else if(C===ee)w++,G({type:"invalidate",path:_,...M});else if(C===ve)m++,G({type:"pause",path:_,lockId:j[1],...M});else if(C===xe)y++,G({type:"resume",path:_,lockId:j[1],...M});else if(C===te)g.has(_)||(x=!0),G({type:"complete",path:_,...M});else if(C===ne){O=!0,g.add(_);let me=T instanceof L?T.lastMutation?.actor??Y:Y;G({type:"error",path:_,data:j[1],actor:me,...M})}else C===V&&(S++,G({type:"teardown",path:_,...M}))}}))}let pe=!1,he=()=>{if(!pe){pe=!0;for(let _ of U)_();for(let _ of z)_();for(let _ of Q)_({value:void 0,done:!0});Q.length=0}},ge=[],Q=[];f.add(_=>{let T=Q.shift();T?T({value:_,done:!1}):ge.push(_)});let ke={get values(){return c},get dirtyCount(){return b},get resolvedCount(){return v},get invalidateCount(){return w},get pauseCount(){return m},get resumeCount(){return y},get teardownCount(){return S},get events(){return h?h.toArray():[...p]},get anyCompletedCleanly(){return x},get anyErrored(){return O},get completedWithoutErrors(){return x&&!O},onEvent(_){return f.add(_),()=>f.delete(_)},dispose:he,expand(_){he();let T={...n};return typeof _=="string"?T.detail=_:Object.assign(T,_),r(rt(T))},[Symbol.asyncIterator](){return{next(){return ge.length>0?Promise.resolve({value:ge.shift(),done:!1}):pe?Promise.resolve({value:void 0,done:!0}):new Promise(_=>Q.push(_))},return(){return he(),Promise.resolve({value:void 0,done:!0})}}}};return n.format!=null&&this._attachFormatLogger(ke,n),ke}_attachFormatLogger(t,n){let r=n.format;if(r==null)return;let o=n.logger??(c=>console.log(c)),s=n.includeTypes?new Set(n.includeTypes):null,i=n.excludeTypes?new Set(n.excludeTypes):null,a=s==null&&i==null?()=>!0:c=>(s==null||s.has(c))&&(i==null||!i.has(c)),l=Xt(n.theme),u=r==="stage-log"?K():0,d=c=>c==null?"":n.stageLabels?.[c]??c,h=(c,g)=>c.length>g?`${c.slice(0,g-1)}\u2026`:c,p=c=>c.type==="data"||c.type==="error"?h(fe(c.data),120):"",f=c=>{if(r==="stage-log"){let O=(K()-u)/1e9,E=d(c.path).padEnd(9);if(c.type==="data"){let R=p(c);return`[${O.toFixed(3)}s] ${E} \u2190${R?` ${R}`:""}`}if(c.type==="error"){let R=p(c);return`[${O.toFixed(3)}s] ${E} \u2717${R?` ${R}`:""}`}return c.type==="complete"?`[${O.toFixed(3)}s] ${E} \u25A0 complete`:`[${O.toFixed(3)}s] ${E} ${c.type}`}if(r==="json")try{return JSON.stringify(c)}catch{return JSON.stringify({type:c.type,path:c.path,data:"[unserializable]"})}let g=l[c.type]??"",b=c.path?`${l.path}${c.path}${l.reset} `:"",v=c.type==="data"||c.type==="error",w=c.type==="pause"||c.type==="resume",m=v?` ${fe(c.data)}`:w?` ${fe(c.lockId)}`:"",y=c.type==="data"||c.type==="resolved"||c.type==="derived"?c:void 0,S=y?.trigger_dep_name!=null?` <- ${y.trigger_dep_name}`:y?.trigger_dep_index!=null?` <- #${y.trigger_dep_index}`:"",x=c.in_batch?" [batch]":"";return`${b}${g}${c.type.toUpperCase()}${l.reset}${m}${S}${x}`};t.onEvent(c=>{a(c.type)&&o(f(c),c)})}addDisposer(t){return this._disposers.add(t),()=>{this._disposers.delete(t)}}destroy(){tt(this._disposers,this.name),this.signal([[V]],{internal:!0}),tt(this._storageDisposers,this.name);for(let t of[...this._mounts.values()])t._parent=void 0,t._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}_destroyClearOnly(){for(let t of[...this._mounts.values()])t._parent=void 0,t._destroyClearOnly();this._mounts.clear(),this._nodes.clear(),this._parent=void 0}snapshot(t){let{expand:n,...r}=this.describe({detail:"full"}),o={};for(let a of Object.keys(r.nodes).sort()){let{lastMutation:l,guard:u,...d}=r.nodes[a];o[a]=d}let s=[...r.subgraphs].sort(),i={...r,version:1,nodes:o,subgraphs:s};if(t?.format==null)return i;if(t.format==="json-string")return JSON.stringify(i);if(t.format==="bytes"){if(t.codec==null)throw new Error("snapshot({format: 'bytes'}) requires a `codec` name");let a=this.config.lookupCodec(t.codec);if(a==null)throw new Error(`snapshot: codec "${t.codec}" is not registered on this graph's config. Call config.registerCodec(...) before creating nodes.`);return $e(a,a.encode(i))}throw new Error(`snapshot: unknown format "${String(t.format)}"`)}static decode(t,n){let r=n?.config??Oe,{codec:o,codecVersion:s,payload:i}=Te(t,r);return o.decode(i,s)}restore(t,n){if(nt(t),t.name!==this.name)throw new Error(`Graph "${this.name}": restore snapshot name "${t.name}" does not match this graph`);let r=n?.only==null?null:(Array.isArray(n.only)?n.only:[n.only]).map(s=>de(s)),o=n?.includeProducers===!0;for(let s of Object.keys(t.nodes).sort()){if(r!==null&&!r.some(a=>a.test(s)))continue;let i=t.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 l=this.tryResolve(s)?.v;if(l!=null&&l.id===i.v.id&&l.version===i.v.version)continue}try{this.set(s,i.value)}catch(a){n?.onError?.(s,a)}}}}}static fromSnapshot(t,n){nt(t);let r=typeof n=="function"?n:n?.build,o=typeof n=="function"?void 0:n?.factories,s=new e(t.name);if(r)return r(s),s.restore(t),s;for(let f of[...t.subgraphs].sort((c,g)=>{let b=c.split(N).length,v=g.split(N).length;return b!==v?b-v:c<g?-1:c>g?1:0})){let c=f.split(N),g=s;for(let b of c)g._mounts.has(b)||g.mount(b,new e(b)),g=g._mounts.get(b)}let i=o?Object.entries(o).map(([f,c])=>({re:de(f),factory:c})):[],a=f=>{for(let c of i)if(c.re.test(f))return c.factory},l=f=>{let c=f.split(N),g=c.pop();if(g==null||g.length===0)throw new Error(`invalid snapshot path "${f}"`);let b=s;for(let v of c){let w=b._mounts.get(v);if(!w)throw new Error(`unknown mount "${v}" in path "${f}"`);b=w}return[b,g]},u=Object.entries(t.nodes).filter(([f])=>!f.includes(`${N}${B}${N}`)).sort((f,c)=>f[0]<c[0]?-1:f[0]>c[0]?1:0),d=new Map(u),h=new Map,p=!0;for(;d.size>0&&p;){p=!1;for(let[f,c]of[...d.entries()]){let g=c?.deps??[];if(!g.every(S=>h.has(S)))continue;let[b,v]=l(f),w={...c?.meta??{}},m=a(f),y;if(c?.type==="state")y=re(c.value,{meta:w});else{if(m==null)continue;y=m(v,{path:f,type:c.type,value:c.value,meta:w,deps:g,resolvedDeps:g.map(S=>h.get(S))})}b.add(y,{name:v}),h.set(f,y),d.delete(f),p=!0}}if(d.size>0){let f=[...d.keys()].sort().join(", ");throw new Error(`Graph.fromSnapshot could not reconstruct nodes without build callback: ${f}. Pass matching factories via fromSnapshot(data, { factories: { pattern: factoryFn } }).`)}return s.restore(t),s}toJSON(){return this.snapshot()}attachStorage(t,n={}){let r=t.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(t,n.onError);let o=(u,d)=>{if(u.disposed)return;let h=It(d.nodes);if(u.lastSnapshot!=null&&h!==""&&h===u.lastFingerprint)return;let p=u.seq+1,f=Pe(),b=u.lastSnapshot==null||p%u.compactEvery===0?{mode:"full",snapshot:d,seq:p,timestamp_ns:f,format_version:q}:{mode:"diff",diff:tn(u.lastSnapshot,d),seq:p,timestamp_ns:f,format_version:q};if(u.tier.filter&&!u.tier.filter(this.name,b))return;let v;try{v=u.tier.save(this.name,b)}catch(w){n.onError?.(w,u.tier);return}if(v&&typeof v.then=="function"){let y=(u.savePending??Promise.resolve()).then(()=>v,()=>v).then(()=>{u.disposed||(u.seq=p,u.lastSnapshot=d,u.lastFingerprint=h)},S=>{n.onError?.(S,u.tier)});u.savePending=y.finally(()=>{u.savePending===y&&(u.savePending=void 0)})}else u.seq=p,u.lastSnapshot=d,u.lastFingerprint=h},s=(u,d)=>{try{o(u,d)}catch(h){n.onError?.(h,u.tier)}},i=(u,d)=>{if(!d.some(c=>{let g=this.config.messageTier(c[0]);return g>=3&&g<5}))return;if(n.filter){let c=this.tryResolve(u);if(c==null)return;let g=Se(c,se("standard"));if(!n.filter(u,g))return}let p,f=()=>(p==null&&(p=this.snapshot()),p);for(let c of r)c.disposed||(c.debounceMs===0?s(c,f()):(c.timer==null&&(c.timer=new Le),c.timer.start(c.debounceMs,()=>{c.disposed||s(c,this.snapshot())})))},a;if(n.paths!=null){let d=(typeof n.paths=="string"?this._pathsMatching(n.paths):n.paths).map(h=>{let p=this.tryResolve(h);return p==null?()=>{}:p.subscribe(f=>i(h,f))});a=()=>{for(let h of d)h()}}else a=this.observe().subscribe((u,d)=>i(u,d));let l=()=>{a();for(let u of r)u.disposed=!0,u.timer?.cancel();this._storageDisposers.delete(l)};return this._storageDisposers.add(l),{dispose:l}}async _cascadeRestore(t,n){for(let r of t){let o;try{o=await r.load(this.name)}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===q&&s.nodes!=null)return this.restore(s),!0}catch(i){n?.(i,r)}}return!1}static async fromStorage(t,n,r){for(let o of n){let s;try{s=await o.load(t)}catch(l){r?.onError?.(l,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===q&&i.nodes!=null?i:void 0;if(a!=null)try{return e.fromSnapshot(a,r)}catch(l){r?.onError?.(l,o)}}throw new Error(`Graph.fromStorage: no tier held a restorable record for "${t}" across ${n.length} tier(s)`)}_annotations=new Map;_traceRing;trace(t,n,r){if(t!=null&&n!=null){if(this.tryResolve(t)==null)return;if(this._annotations.set(t,n),this.config.inspectorEnabled){let o={path:t,annotation:n,timestamp_ns:K(),...r?.actor!=null?{actor:r.actor}:{}};this._traceRing.push(o)}return}return t!=null?this.config.inspectorEnabled?this._annotations.get(t):void 0:this.config.inspectorEnabled?this._traceRing.toArray():[]}annotation(t){return this._annotations.get(t)}clearTrace(){this._annotations.clear(),this._traceRing.clear()}pruneTrace(t){let n=this._traceRing.toArray().filter(o=>!t(o)),r=this._traceRing.size-n.length;this._traceRing.clear();for(let o of n)this._traceRing.push(o);return r}static diff(t,n){let r=new Set(Object.keys(t.nodes)),o=new Set(Object.keys(n.nodes)),s=[...o].filter(w=>!r.has(w)).sort(),i=[...r].filter(w=>!o.has(w)).sort(),a=[],l=[];for(let w of r){if(!o.has(w))continue;let m=t.nodes[w],y=n.nodes[w],S=m.v,x=y.v;S!=null&&x!=null&&S.id===x.id&&S.version!==x.version&&l.push({path:w,id:S.id,from:S.version,to:x.version});let O=S!=null&&x!=null&&S.id===x.id&&S.version===x.version;for(let E of["type","status","sentinel"]){let R=m[E],k=y[E];R!==k&&a.push({path:w,field:E,from:R,to:k})}if(!O)for(let E of["value","meta"]){let R=m[E],k=y[E];jt(R,k)||a.push({path:w,field:E,from:R,to:k})}}let u=w=>`${w.from} ${w.to}`,d=new Set(t.edges.map(u)),h=new Set(n.edges.map(u)),p=n.edges.filter(w=>!d.has(u(w))),f=t.edges.filter(w=>!h.has(u(w))),c=new Set(t.subgraphs),g=new Set(n.subgraphs),b=[...g].filter(w=>!c.has(w)).sort(),v=[...c].filter(w=>!g.has(w)).sort();return{nodesAdded:s,nodesRemoved:i,nodesChanged:a,versionChanges:l,edgesAdded:p,edgesRemoved:f,subgraphsAdded:b,subgraphsRemoved:v}}};function tn(e,t){let n=Ce.diff(e,t),r={};for(let o of n.nodesAdded){let s=t.nodes[o];s!=null&&(r[o]=s)}return{...n,nodesAddedFull:r}}function st(e,t,n,r={}){let o={paths:[],depths:new Map,truncated:!1};if(!t)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,l=new Map,u=new Map,d=new Set;for(let[m,y]of Object.entries(e.nodes)){if(!m)continue;d.add(m);let S=y.deps??[];i.set(m,S);for(let x of S)x&&(d.add(x),a.has(x)||a.set(x,new Set),a.get(x).add(m))}for(let m of e.edges){if(m==null||typeof m!="object")continue;let y=typeof m.from=="string"?m.from:"",S=typeof m.to=="string"?m.to:"";!y||!S||(d.add(y),d.add(S),u.has(y)||u.set(y,new Set),u.get(y).add(S),l.has(S)||l.set(S,new Set),l.get(S).add(y))}if(!d.has(t))return r.withDetail?o:[];let h=r.both===!0,p=m=>{if(h){let O=i.get(m)??[],E=l.get(m),R=a.get(m),k=u.get(m),$=[...O];return E&&$.push(...E),R&&$.push(...R),k&&$.push(...k),$}if(n==="upstream"){let O=i.get(m)??[],E=l.get(m);return E?[...O,...E]:O}let y=a.get(m),S=u.get(m),x=y?[...y]:[];return S&&x.push(...S),x},f=new Set([t]),c=new Map,g=[{path:t,depth:0}],b=0,v=!1;for(;b<g.length;){let m=g[b++];if(s!=null&&m.depth>=s){p(m.path).length>0&&(v=!0);continue}for(let y of p(m.path))!y||f.has(y)||(f.add(y),c.set(y,m.depth+1),g.push({path:y,depth:m.depth+1}))}let w=[...c.keys()].sort((m,y)=>m<y?-1:m>y?1:0);return r.withDetail?{paths:w,depths:c,truncated:v}:w}function nn(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],o=t[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}export{X as a,ue as b,Ie as c,A as d,ft as e,ze as f,He as g,B as h,q as i,Wt as j,Ce as k,tn as l,st as m};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as v,f as M}from"./chunk-
|
|
1
|
+
import{a as v,f as M}from"./chunk-7JDLFI6N.js";import{d as S}from"./chunk-OL33ZI6R.js";import{o as h}from"./chunk-W4TSQ6RJ.js";function O(e={}){return e.sdk?Q(e):z(e)}function _(e,t,o,n){let r=t?.model??o;if(!r)throw new Error("anthropicAdapter: model must be set via options.model or invokeOpts.model");let{system:s,chat:a}=W(e,t?.systemPrompt),i={model:r,messages:a.map(Y),max_tokens:t?.maxTokens??4096};return s&&(i.system=s),t?.temperature!=null&&(i.temperature=t.temperature),t?.tools&&t.tools.length>0&&(i.tools=t.tools.map(V)),t?.maxReasoningTokens!=null&&(i.thinking={type:"enabled",budget_tokens:t.maxReasoningTokens}),t?.cacheHint,n&&(i.stream=!0),t?.providerExtras&&Object.assign(i,t.providerExtras),i}function W(e,t){let o=[];t&&o.push(t);let n=[];for(let r of e)r.role==="system"?o.push(r.content):n.push(r);return{system:o.length>0?o.join(`
|
|
2
2
|
|
|
3
3
|
`):void 0,chat:n}}function Y(e){if(e.role==="tool")return{role:"user",content:[{type:"tool_result",tool_use_id:e.toolCallId,content:e.content}]};if(e.role==="assistant"&&e.toolCalls&&e.toolCalls.length>0){let t=[];e.content&&t.push({type:"text",text:e.content});for(let o of e.toolCalls)t.push({type:"tool_use",id:o.id,name:o.name,input:o.arguments});return{role:"assistant",content:t}}return{role:e.role,content:e.content}}function V(e){return{name:e.name,description:e.description,input_schema:e.parameters}}function A(e,t){if(!e)return{...t};let o={...e};return t.input_tokens!=null&&(o.input_tokens=t.input_tokens),t.output_tokens!=null&&(o.output_tokens=t.output_tokens),t.cache_read_input_tokens!=null&&(o.cache_read_input_tokens=t.cache_read_input_tokens),t.cache_creation_input_tokens!=null&&(o.cache_creation_input_tokens=t.cache_creation_input_tokens),t.cache_creation&&(o.cache_creation={...e.cache_creation??{},...t.cache_creation}),t.server_tool_use&&(o.server_tool_use={...e.server_tool_use??{},...t.server_tool_use}),o}function w(e){let t={input:{regular:e?.input_tokens??0},output:{regular:e?.output_tokens??0},raw:e};return e?.cache_read_input_tokens&&(t.input.cacheRead=e.cache_read_input_tokens),e?.cache_creation?(e.cache_creation.ephemeral_5m_input_tokens&&(t.input.cacheWrite5m=e.cache_creation.ephemeral_5m_input_tokens),e.cache_creation.ephemeral_1h_input_tokens&&(t.input.cacheWrite1h=e.cache_creation.ephemeral_1h_input_tokens)):e?.cache_creation_input_tokens&&(t.input.cacheWrite5m=e.cache_creation_input_tokens),e?.server_tool_use?.web_search_requests&&(t.auxiliary={webSearchRequests:e.server_tool_use.web_search_requests}),t}function P(e,t){let o=[],n=[];for(let r of e.content)if(r.type==="text"&&typeof r.text=="string")o.push(r.text);else if(r.type==="tool_use"){let s=r;n.push({id:s.id,name:s.name,arguments:s.input??{}})}return{content:o.join(""),toolCalls:n.length>0?n:void 0,usage:w(e.usage),finishReason:e.stop_reason,latencyMs:t,model:e.model,provider:"anthropic"}}function z(e){let t=e.apiKey??globalThis.process?.env?.ANTHROPIC_API_KEY,o=e.baseURL??"https://api.anthropic.com",n=e.anthropicVersion??"2023-06-01",r=e.fetchImpl??fetch,s=()=>{if(!t)throw new Error("anthropicAdapter: apiKey required for invoke/stream (or provide opts.sdk)");return{"x-api-key":t,"anthropic-version":n,"content-type":"application/json",...e.headers??{}}};return{provider:"anthropic",model:e.model,async invoke(a,i){let c=_(a,i,e.model,!1),u=h(),d=await r(`${o}/v1/messages`,{method:"POST",headers:s(),body:JSON.stringify(c),signal:i?.signal});if(!d.ok)throw await T(d);let l=await d.json(),p=Math.max(0,(h()-u)/1e6);return P(l,p)},async*stream(a,i){let c=_(a,i,e.model,!0),u=await r(`${o}/v1/messages`,{method:"POST",headers:{...s(),accept:"text/event-stream"},body:JSON.stringify(c),signal:i?.signal});if(!u.ok)throw await T(u);if(!u.body)throw new Error("anthropicAdapter: streaming response has no body");let d,l,p=new Map;for await(let f of X(u.body)){let k=f.data;if(!k)continue;let y;try{y=JSON.parse(k)}catch{continue}switch(y.type){case"message_start":{d=A(d,y.message.usage);break}case"content_block_start":{let g=y,m=g.content_block;m.type==="tool_use"&&(p.set(g.index,{id:String(m.id??""),name:String(m.name??""),argBuf:""}),yield{type:"tool-call-delta",delta:{id:String(m.id??""),name:String(m.name??"")}});break}case"content_block_delta":{let g=y,m=g.delta;if(m.type==="text_delta"&&typeof m.text=="string")yield{type:"token",delta:m.text};else if(m.type==="input_json_delta"&&typeof m.partial_json=="string"){let E=p.get(g.index);E&&(E.argBuf+=m.partial_json),yield{type:"tool-call-delta",delta:{argumentsDelta:m.partial_json}}}else m.type==="thinking_delta"&&typeof m.thinking=="string"&&(yield{type:"thinking",delta:m.thinking});break}case"message_delta":{let g=y;g.delta.stop_reason&&(l=g.delta.stop_reason),g.delta.usage&&(d=A(d,g.delta.usage));break}case"message_stop":break}}d&&(yield{type:"usage",usage:w(d)}),yield{type:"finish",reason:l??"stop"}}}}function Q(e){let t=e.sdk;if(!t)throw new Error("sdkBackedAnthropic: sdk instance required");return{provider:"anthropic",model:e.model,async invoke(o,n){let r=_(o,n,e.model,!1),s=h(),a=await t.messages.create(r,{signal:n?.signal}),i=Math.max(0,(h()-s)/1e6);return P(a,i)},async*stream(o,n){if(!t.messages.stream)throw new Error("sdkBackedAnthropic: SDK instance does not expose .messages.stream");let r=_(o,n,e.model,!0),s,a;for await(let i of t.messages.stream(r,{signal:n?.signal}))switch(i.type){case"message_start":s=A(s,i.message.usage);break;case"content_block_delta":{let c=i.delta;c?.type==="text_delta"&&typeof c.text=="string"?yield{type:"token",delta:c.text}:c?.type==="input_json_delta"&&typeof c.partial_json=="string"?yield{type:"tool-call-delta",delta:{argumentsDelta:c.partial_json}}:c?.type==="thinking_delta"&&typeof c.thinking=="string"&&(yield{type:"thinking",delta:c.thinking});break}case"message_delta":{let c=i;c.delta.stop_reason&&(a=c.delta.stop_reason),c.delta.usage&&(s=A(s,c.delta.usage));break}}s&&(yield{type:"usage",usage:w(s)}),yield{type:"finish",reason:a??"stop"}}}}async function*X(e){let t=e.getReader(),o=new TextDecoder,n="";try{for(;;){let{done:r,value:s}=await t.read();if(r){n.length>0&&(yield I(n));return}n+=o.decode(s,{stream:!0});let a=U(n);for(;a!==null;){let i=n.slice(0,a.index);n=n.slice(a.index+a.length);let c=I(i);(c.data||c.event)&&(yield c),a=U(n)}}}finally{t.releaseLock()}}function I(e){let t={},o=[];for(let n of e.split(`
|
|
4
4
|
`)){let r=n.endsWith("\r")?n.slice(0,-1):n;if(!r||r.startsWith(":"))continue;let s=r.indexOf(":"),a=s===-1?r:r.slice(0,s),i=s===-1?"":r.slice(s+1).replace(/^ /,"");a==="data"?o.push(i):a==="event"?t.event=i:a==="id"&&(t.id=i)}return o.length>0&&(t.data=o.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as E}from"./chunk-ESMPEKEV.js";import{a as B,b as R,i as _}from"./chunk-4VVTGLXJ.js";import{m as I}from"./chunk-
|
|
1
|
+
import{a as E}from"./chunk-ESMPEKEV.js";import{a as B,b as R,i as _}from"./chunk-4VVTGLXJ.js";import{m as I}from"./chunk-KASHOCF5.js";import{D as P,F as g,m as L,o as O}from"./chunk-W4TSQ6RJ.js";import{b,c as k,d as y,h as C,i as h,j as T}from"./chunk-CK2E7BTU.js";function S(e){return{describeKind:"derived",...e}}function V(e){return e<0?0:e}function M(e){return e[1]}function W(e){if(typeof e!="number"||!Number.isFinite(e))throw new TypeError("backoff strategy must return a finite number");return e<0?0:e}function Z(e,s){let r=s?.count,n=s?.backoff,l=r!==void 0?r:n===void 0?0:2147483647;if(l<0)throw new RangeError("retry count must be >= 0");let u=n===void 0?null:typeof n=="string"?_(n):n;return g(t=>{let o=0,c=!1,i=null,f,a=new E;function w(){f?.(),f=void 0}function N(p){if(c)return;if(o>=l){w(),t.down([[T,p]]);return}let m=u===null?0:u(o,p,i);if(m==null){w(),t.down([[T,p]]);return}let d;try{d=W(m)}catch{w(),t.down([[T,p]]);return}i=d,o+=1,w();let v=d>0?d/1e6:1;a.start(v,()=>{c||x()})}function x(){a.cancel(),w(),f=e.subscribe(p=>{if(!c)for(let m of p){let d=m[0];if(d===k)t.down([[k]]);else if(d===b)o=0,i=null,t.emit(m[1]);else if(d===y)t.down([[y]]);else if(d===h)w(),t.down([[h]]);else if(d===T){N(M(m));return}else t.down([m])}})}return x(),()=>{c=!0,a.cancel(),w()}},{...S(),initial:e.cache})}function ee(e,s){let r=s?.count,n=s?.backoff,l=r!==void 0?r:n===void 0?0:2147483647;if(l<0)throw new RangeError("retry count must be >= 0");let u=n===void 0?null:typeof n=="string"?_(n):n;return g(t=>{let o=0,c=!1,i=null,f,a=new E;function w(){f?.(),f=void 0}function N(p){if(c)return;if(o>=l){w(),t.down([[T,p]]);return}let m=u===null?0:u(o,p,i);if(m==null){w(),t.down([[T,p]]);return}let d;try{d=W(m)}catch{w(),t.down([[T,p]]);return}i=d,o+=1,w();let v=d>0?d/1e6:1;a.start(v,()=>{c||x()})}function x(){a.cancel(),w();let p;try{p=e()}catch(m){N(m);return}f=p.subscribe(m=>{if(!c)for(let d of m){let v=d[0];if(v===k)t.down([[k]]);else if(v===b)o=0,i=null,t.emit(d[1]);else if(v===y)t.down([[y]]);else if(v===h)w(),t.down([[h]]);else if(v===T){N(M(d));return}else t.down([d])}})}return x(),()=>{c=!0,a.cancel(),w()}},{...S(),initial:s?.initial})}var A=class extends Error{name="CircuitOpenError";constructor(){super("Circuit breaker is open")}};function te(e){let s=Math.max(1,e?.failureThreshold??5),r=V(e?.cooldownNs??30*1e9),n=e?.cooldown??null,l=Math.max(1,e?.halfOpenMax??1),u=e?.now??O,t="closed",o=0,c=0,i=0,f=r,a=0;function w(){if(!n)return r;let p=n(c);return p!==null?p:r}function N(){t="open",f=w(),i=u(),a=0}return{canExecute(){return t==="closed"?!0:t==="open"?u()-i>=f?(t="half-open",a=1,!0):!1:a<l?(a++,!0):!1},recordSuccess(){t==="half-open"?(t="closed",o=0,c=0):t==="closed"&&(o=0)},recordFailure(p){if(t==="half-open"){c++,N();return}t==="closed"&&(o++,o>=s&&N())},get state(){return t},get failureCount(){return o},reset(){t="closed",o=0,c=0,a=0}}}function ne(e,s){let r=s?.onOpen??"skip";return n=>{let l=P([],(u,t)=>{function o(){l.meta.breakerState.down([[b,e.state]])}let c=n.subscribe(i=>{for(let f of i){let a=f[0];a===k?t.down([[k]]):a===b?e.canExecute()?(o(),t.emit(f[1])):(o(),r==="error"?t.down([[T,new A]]):t.down([[y]])):a===y?t.down([[y]]):a===h?(e.recordSuccess(),o(),t.down([[h]])):a===T?(e.recordFailure(M(f)),o(),t.down([f])):t.down([f])}});return o(),c},{...S(),meta:{breakerState:e.state},completeWhenDepsComplete:!1,initial:n.cache});return{node:l,breakerState:l.meta.breakerState}}}function U(e,s){if(e<=0)throw new RangeError("capacity must be > 0");if(s<0)throw new RangeError("refillPerSecond must be >= 0");let r=e,n=O();function l(u){if(s>0){let t=u-n;r=Math.min(e,r+t/1e9*s)}n=u}return{available(){return l(O()),r},tryConsume(u=1){if(u<=0)return!0;let t=O();return l(t),r>=u?(r-=u,!0):!1},putBack(u=1){u<=0||(l(O()),r=Math.min(e,r+u))}}}var D=class extends Error{name="RateLimiterOverflowError";constructor(s){super(`rateLimiter buffer overflow (maxBuffer=${s})`)}};function re(e,s){let{maxEvents:r,windowNs:n}=s;if(r<=0)throw new RangeError("maxEvents must be > 0");if(n<=0)throw new RangeError("windowNs must be > 0");let l=s.maxBuffer;if(l!==void 0&&l<1)throw new RangeError("maxBuffer must be >= 1");let u=s.onOverflow??"drop-newest",t=r*1e9/n;return g(o=>{let c=U(r,t),i=[],f=new E,a=!1,w=1e9/t;function N(){for(;i.length>0;)if(c.tryConsume(1))o.emit(i.shift());else{f.start(Math.max(1,w/1e6),N);return}}let x=e.subscribe(p=>{for(let m of p){if(a)return;let d=m[0];if(d===k)o.down([[k]]);else if(d===b){if(l!==void 0&&i.length>=l){if(u!=="drop-newest")if(u==="drop-oldest")i.shift(),i.push(m[1]);else{a=!0,f.cancel(),i.length=0,o.down([[T,new D(l)]]);return}}else i.push(m[1]);N()}else if(d===y)o.down([[y]]);else if(d===h)a=!0,f.cancel(),i.length=0,o.down([[h]]);else if(d===T)a=!0,f.cancel(),i.length=0,o.down([m]);else if(d===C){a=!0,f.cancel(),i.length=0,o.down([m]);return}else o.down([m])}});return()=>{a=!0,f.cancel(),x()}},{...S(),initial:e.cache})}function oe(e,s){let r=s?.initialStatus??"pending",n=P([],(l,u)=>{let t=r;return n.meta.status.down([[b,r]]),n.meta.error.down([[b,null]]),e.subscribe(c=>{for(let i of c){let f=i[0];if(f===k)u.down([[k]]);else if(f===b)t==="errored"?L(()=>{n.meta.error.down([[b,null]]),n.meta.status.down([[b,"active"]])}):n.meta.status.down([[b,"active"]]),t="active",u.emit(i[1]);else if(f===y)u.down([[y]]);else if(f===h)n.meta.status.down([[b,"completed"]]),t="completed",u.down([[h]]);else if(f===T){let a=M(i);L(()=>{n.meta.error.down([[b,a]]),n.meta.status.down([[b,"errored"]])}),t="errored",u.down([i])}else u.down([i])}})},{...S(),meta:{status:r,error:null},completeWhenDepsComplete:!1,resubscribable:!0,initial:e.cache});return{node:n,status:n.meta.status,error:n.meta.error}}var F=class extends Error{name="TimeoutError";constructor(s){super(`Timed out after ${s/1e6}ms`)}};function j(e){return e!=null&&typeof e=="object"&&"cache"in e&&typeof e.subscribe=="function"}function K(e){return e!=null&&typeof e.then=="function"}function $(e){return e!=null&&typeof e=="object"&&typeof e[Symbol.asyncIterator]=="function"}function ie(e,s){return g(r=>{let n,l;function u(){l?.(),l=void 0,j(s)||K(s)||$(s)?n=I(s).subscribe(o=>{r.down(o)}):(r.emit(s),r.down([[h]]))}return l=e.subscribe(t=>{for(let o of t){let c=o[0];if(c===k)r.down([[k]]);else if(c===b)r.emit(o[1]);else if(c===y)r.down([[y]]);else if(c===h)r.down([[h]]);else if(c===T){u();return}else if(c===C){n?.(),r.down([o]);return}else r.down([o])}}),()=>{l?.(),n?.()}},{...S(),initial:e.cache})}function se(e,s){if(s<=0)throw new RangeError("timeoutNs must be > 0");return g(r=>{let n=!1,l=new E;function u(){let o=s/1e6;l.start(o,()=>{n||(n=!0,t(),r.down([[T,new F(s)]]))})}let t=e.subscribe(o=>{for(let c of o){if(n)return;let i=c[0];if(i===k)r.down([[k]]);else if(i===b)u(),r.emit(c[1]);else if(i===y)r.down([[y]]);else if(i===h){l.cancel(),n=!0,r.down([[h]]);return}else if(i===T){l.cancel(),n=!0,r.down([c]);return}else if(i===C){l.cancel(),n=!0,r.down([c]);return}else r.down([c])}});return u(),()=>{n=!0,l.cancel(),t()}},{...S(),initial:e.cache})}export{Z as a,ee as b,A as c,te as d,ne as e,U as f,D as g,re as h,oe as i,F as j,ie as k,se as l};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as ce}from"./chunk-
|
|
1
|
+
import{c as ce}from"./chunk-VIEUJSTT.js";import{a as se,b as P}from"./chunk-5QDBSZBV.js";import{k as L}from"./chunk-MGKAO4EK.js";import{f as ae,h as ie}from"./chunk-KASHOCF5.js";import{i as ne,j as U}from"./chunk-W4TSQ6RJ.js";import{b,h as _,i as T,j as W}from"./chunk-CK2E7BTU.js";import{b as Oe,c as re,d as te,e as oe}from"./chunk-QYADASLV.js";var ke={};Oe(ke,{ACTOR_KEY:()=>F,COMMAND_HANDLERS:()=>A,CQRS_EVENT_HANDLERS:()=>S,CRON_HANDLERS:()=>D,CommandHandler:()=>me,EVENT_HANDLERS:()=>G,EventHandler:()=>ve,GRAPHREFLY_REQUEST_GRAPH:()=>R,GRAPHREFLY_ROOT_GRAPH:()=>v,GraphCron:()=>fe,GraphInterval:()=>he,GraphReflyEventExplorer:()=>x,GraphReflyGuard:()=>Re,GraphReflyGuardImpl:()=>I,GraphReflyModule:()=>Q,INTERVAL_HANDLERS:()=>O,InjectCqrsGraph:()=>de,InjectGraph:()=>ue,InjectNode:()=>pe,ObserveGateway:()=>B,OnGraphEvent:()=>le,QUERY_HANDLERS:()=>H,QueryHandler:()=>ye,SAGA_HANDLERS:()=>N,SagaHandler:()=>ge,fromHeader:()=>Ee,fromJwtPayload:()=>V,getActor:()=>we,getGraphToken:()=>m,getNodeToken:()=>y,observeSSE:()=>Me,observeSubscription:()=>Ce,toObservable:()=>se});import{Inject as j}from"@nestjs/common";var v=Symbol.for("graphrefly:root-graph");var R=Symbol.for("graphrefly:request-graph");function m(s){return Symbol.for(`graphrefly:graph:${s}`)}function y(s){return Symbol.for(`graphrefly:node:${s}`)}var G=new Map,O=new Map,D=new Map,A=new Map,S=new Map,H=new Map,N=new Map;function ue(s){return s==="request"?j(R):j(s?m(s):v)}function de(s){return j(m(s))}function pe(s){return j(y(s))}function le(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=G.get(o)??[];n.push({nodeName:s,methodKey:t}),G.set(o,n)})}}function he(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=O.get(o)??[];n.push({ms:s,methodKey:t}),O.set(o,n)})}}function fe(s){return(e,r)=>{let t=r.name;r.addInitializer(function(){let o=this.constructor,n=D.get(o)??[];n.push({expr:s,methodKey:t}),D.set(o,n)})}}function me(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=A.get(n)??[];a.push({cqrsName:s,commandName:e,methodKey:o}),A.set(n,a)})}}function ve(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=S.get(n)??[];a.push({cqrsName:s,eventName:e,methodKey:o}),S.set(n,a)})}}function ye(s,e){return(r,t)=>{let o=t.name;t.addInitializer(function(){let n=this.constructor,a=H.get(n)??[];a.push({cqrsName:s,projectionName:e,methodKey:o}),H.set(n,a)})}}function ge(s,e,r){return(t,o)=>{let n=o.name;o.addInitializer(function(){let a=this.constructor,c=N.get(a)??[];c.push({cqrsName:s,eventNames:r,sagaName:e,methodKey:n}),N.set(a,c)})}}var be=0,x=class{constructor(e,r){this.graph=e;this.moduleRef=r}disposers=[];scheduleNodeNames=[];onModuleInit(){this.wireEvents(),this.wireIntervals(),this.wireCrons(),this.wireCqrsCommands(),this.wireCqrsEvents(),this.wireCqrsQueries(),this.wireCqrsSagas()}onModuleDestroy(){for(let e of this.disposers)e();this.disposers.length=0;for(let e of this.scheduleNodeNames)try{this.graph.remove(e)}catch{}this.scheduleNodeNames.length=0}wireEvents(){for(let[e,r]of G){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireEventHandler(t,o)}}wireEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),a=this.observeNode(r.nodeName).subscribe(c=>{for(let l of c)l[0]===b&&o(l[1])});this.disposers.push(a)}wireIntervals(){for(let[e,r]of O){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireIntervalHandler(t,e,o)}}wireIntervalHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ae(t.ms,{period:t.ms,name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCrons(){for(let[e,r]of D){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCronHandler(t,e,o)}}wireCronHandler(e,r,t){let o=e[t.methodKey];if(typeof o!="function")return;let n=o.bind(e),c=`__schedule__.${r.name??"anonymous"}.${String(t.methodKey)}.${be++}`,l=ie(t.expr,{name:c});this.graph.add(l),this.scheduleNodeNames.push(c);let p=this.observeNode(c).subscribe(u=>{for(let d of u)d[0]===b&&n(d[1])});this.disposers.push(p)}wireCqrsCommands(){for(let[e,r]of A){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsCommand(t,o)}}wireCqrsCommand(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.command(r.commandName,o)}wireCqrsEvents(){for(let[e,r]of S){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsEventHandler(t,o)}}wireCqrsEventHandler(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;n.event(r.eventName);let c=n.resolve(r.eventName).cache,l=c&&c.length>0?c[c.length-1].seq:0,p=this.observeNodeOn(n,r.eventName).subscribe(u=>{for(let d of u)if(d[0]===b){let g=d[1];for(let i of g)i.seq>l&&(o(i),l=i.seq)}});this.disposers.push(p)}wireCqrsQueries(){for(let[e,r]of H){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsQuery(t,o)}}wireCqrsQuery(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);if(!n)return;let c=this.observeNodeOn(n,r.projectionName).subscribe(l=>{for(let f of l)f[0]===b&&o(f[1])});this.disposers.push(c)}wireCqrsSagas(){for(let[e,r]of N){let t=this.resolveInstance(e);if(t)for(let o of r)this.wireCqrsSaga(t,o)}}wireCqrsSaga(e,r){let t=e[r.methodKey];if(typeof t!="function")return;let o=t.bind(e),n=this.resolveCqrsGraph(r.cqrsName);n&&n.saga(r.sagaName,r.eventNames,o)}observeNode(e){return this.graph.observe(e)}observeNodeOn(e,r){return e.observe(r)}resolveCqrsGraph(e){try{return this.moduleRef.get(m(e),{strict:!1})}catch{return console.warn(`[GraphReFly] CqrsGraph "${e}" not found in DI \u2014 did you import GraphReflyModule.forCqrs({ name: "${e}" })?`),null}}resolveInstance(e){try{return this.moduleRef.get(e,{strict:!1})}catch{return null}}};function Me(s,e,r){let{actor:t,serialize:o=De,keepAliveMs:n,signal:a}=r??{},c=new TextEncoder,l,f=r?.highWaterMark!=null,p,u,d=[],g=!1;return new ReadableStream({start(i){let h,w=()=>{},M=()=>{if(!g){g=!0,h!==void 0&&clearInterval(h),a?.removeEventListener("abort",K),w(),p?.dispose(),u?.(),u=void 0;for(let k of d)i.enqueue(k.frame);d.length=0,i.close()}};l=M;let K=()=>M(),ee=s.observe(e,{actor:t});f&&(p=P(k=>ee.up(k),{highWaterMark:r.highWaterMark,lowWaterMark:r.lowWaterMark??Math.floor(r.highWaterMark/2)})),w=ee.subscribe(k=>{for(let $ of k){if(g)return;let q=$[0];if(q===b){let C=c.encode(Y("data",o($[1])));f?(d.push({frame:C,counted:!0}),p.onEnqueue(),u?.(),u=void 0):i.enqueue(C)}else if(q===W){let C=c.encode(Y("error",o($[1])));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C),M();return}else if(q===T||q===_){if(q===T){let C=c.encode(Y("complete"));f?(d.push({frame:C,counted:!1}),u?.(),u=void 0):i.enqueue(C)}M();return}}}),n!==void 0&&n>0&&(h=setInterval(()=>{g||(f?(d.push({frame:c.encode(`: keepalive
|
|
2
2
|
|
|
3
3
|
`),counted:!1}),u?.(),u=void 0):i.enqueue(c.encode(`: keepalive
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as H,b as T}from"./chunk-
|
|
1
|
+
import{a as H,b as T}from"./chunk-4JJCCD5S.js";import{k as q}from"./chunk-MGKAO4EK.js";import{a as O,b as j}from"./chunk-TWMEGG45.js";import{E as d,G as o,H as x,m as A}from"./chunk-W4TSQ6RJ.js";import{b as ae}from"./chunk-QYADASLV.js";var ie={};ae(ie,{demoShell:()=>re});function w(h){return Math.max(0,Math.min(1,h))}function re(h){let B=w(h?.mainRatio??.65),E=w(h?.sideSplit??.5),J=Math.max(0,h?.viewportWidth??1280),k=h?.nodeRegistry??new Map,p=h?.adapter??null,S=h?.layoutFont??"14px monospace",u=h?.onHighlight,t=new q("demo-shell"),F=d(B,{name:"pane/main-ratio"}),D=d(E,{name:"pane/side-split"}),g=d(null,{name:"pane/fullscreen"}),G=d(J,{name:"viewport/width"});t.add(F,{name:"pane/main-ratio"}),t.add(D,{name:"pane/side-split"}),t.add(g,{name:"pane/fullscreen"}),t.add(G,{name:"viewport/width"});let L=o([F,G,g],([e,a,n])=>{let l=e,r=a,i=n;return i==="main"?r:i==="graph"||i==="code"?0:Math.round(r*l)},{name:"pane/main-width"}),R=o([L,G,g],([e,a,n])=>{let l=n,r=a;return l==="main"?0:l==="graph"||l==="code"?r:r-e},{name:"pane/side-width"}),C=o([D,g],([e,a])=>{let n=a;return n==="graph"?1:n==="code"||n==="main"?0:w(e)},{name:"pane/graph-height-ratio"}),K=o([C,g],([e,a])=>{let n=a;return n==="code"?1:n==="graph"||n==="main"?0:1-e},{name:"pane/code-height-ratio"});t.add(L,{name:"pane/main-width"}),t.add(R,{name:"pane/side-width"}),t.add(C,{name:"pane/graph-height-ratio"}),t.add(K,{name:"pane/code-height-ratio"});let b=d(null,{name:"demo/graph-ref"}),m=d(0,{name:"demo/graph-tick"});t.add(b,{name:"demo/graph-ref"}),t.add(m,{name:"demo/graph-tick"});let Q=o([b,m],([e,a])=>{let n=e;return n?n.describe({format:"mermaid"}):""},{name:"graph/mermaid"}),z=o([b,m],([e,a])=>{let n=e;if(!n)return null;let{expand:l,...r}=n.describe({detail:"standard"});return r},{name:"graph/describe"});t.add(Q,{name:"graph/mermaid"}),t.add(z,{name:"graph/describe"});let M=d(null,{name:"hover/target"});t.add(M,{name:"hover/target"});let P=o([M],([e])=>{let a=e;if(!a)return null;let n=k.get(a.id);return n?n.codeLine:null},{name:"highlight/code-scroll"}),W=o([M],([e])=>{let a=e;if(!a)return null;let n=k.get(a.id);return n?n.visualSelector:null},{name:"highlight/visual"}),N=o([M],([e])=>{let a=e;return a?a.id:null},{name:"highlight/graph"});if(t.add(P,{name:"highlight/code-scroll"}),t.add(W,{name:"highlight/visual"}),t.add(N,{name:"highlight/graph"}),u?.codeScroll){let e=u.codeScroll,a=x([P],([n])=>{e(n)});t.add(a,{name:"highlight/apply-code-scroll"})}if(u?.visual){let e=u.visual,a=x([W],([n])=>{e(n)});t.add(a,{name:"highlight/apply-visual"})}if(u?.graph){let e=u.graph,a=x([N],([n])=>{e(n)});t.add(a,{name:"highlight/apply-graph"})}let _=d(null,{name:"inspect/selected-node"});t.add(_,{name:"inspect/selected-node"});let U=O("standard"),X=o([_,b,m],([e,a,n])=>{let l=a,r=e;if(!l||!r)return null;try{let i=l.resolve(r),s=j(i,U);return{path:r,...s,value:i.cache}}catch{return null}},{name:"inspect/node-detail"}),Y=o([b,m],([e,a])=>{let n=e;return n?n.trace():[]},{name:"inspect/trace-log"});t.add(X,{name:"inspect/node-detail"}),t.add(Y,{name:"inspect/trace-log"});let I=d(!1,{name:"meta/debug"});t.add(I,{name:"meta/debug"});let Z=o([I,m],([e,a])=>e?t.describe({format:"mermaid"}):"",{name:"meta/shell-mermaid"});t.add(Z,{name:"meta/shell-mermaid"});let V=d("",{name:"layout/code-text"});if(t.add(V,{name:"layout/code-text"}),p){let e=new Map,a=o([z],([r])=>{let i=r;if(!i)return new Map;let s=new Map;for(let[c]of Object.entries(i.nodes)){let f=H(c,S,p,e),v=T(f,1/0,p,S,e),y=v.lines.reduce((te,ne)=>Math.max(te,ne.width),0),ee=v.lineCount*20;s.set(c,{width:y,height:ee})}return s},{name:"layout/graph-labels",equals:(r,i)=>{if(r===i)return!0;let s=r,c=i;if(s.size!==c.size)return!1;for(let[f,v]of s){let y=c.get(f);if(!y||y.width!==v.width||y.height!==v.height)return!1}return!0}}),n=o([V,R],([r,i])=>{let s=r;if(!s)return{lineCount:0,lines:[]};let c=H(s,S,p,e),f=i-40;return T(c,Math.max(100,f),p,S,e)},{name:"layout/code-lines"}),l=o([a],([r])=>{let i=r;if(i.size===0)return 200;let s=0;for(let{width:c}of i.values())c>s&&(s=c);return Math.max(200,Math.round(s+80))},{name:"layout/side-width-hint"});t.add(a,{name:"layout/graph-labels"}),t.add(n,{name:"layout/code-lines"}),t.add(l,{name:"layout/side-width-hint"})}let $=0;return{graph:t,setMainRatio(e){t.set("pane/main-ratio",w(e))},setSideSplit(e){t.set("pane/side-split",w(e))},setFullscreen(e){t.set("pane/fullscreen",e)},setViewportWidth(e){t.set("viewport/width",Math.max(0,e))},setHoverTarget(e){t.set("hover/target",e)},setDemoGraph(e){t.set("demo/graph-ref",e)},bumpGraphTick(){t.set("demo/graph-tick",++$)},selectNode(e){t.set("inspect/selected-node",e)},setMetaDebug(e){t.set("meta/debug",e)},setCodeText(e){t.set("layout/code-text",e)},batch(e){A(e)},destroy(){t.destroy()}}}export{re as a,ie as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as P}from"./chunk-
|
|
1
|
+
import{e as P}from"./chunk-73Z3W2RN.js";import{c as S}from"./chunk-5Z4HDCO6.js";import{a as w}from"./chunk-GNCBXARM.js";import{k as O,m as R}from"./chunk-MGKAO4EK.js";import{b as _}from"./chunk-2GQREQ6C.js";import{A as T}from"./chunk-KASHOCF5.js";import{E as k,G as x,o as H}from"./chunk-W4TSQ6RJ.js";import{b as M}from"./chunk-QYADASLV.js";var B={};M(B,{LensGraph:()=>C,graphLens:()=>N,watchTopologyTree:()=>w});function v(e){return S("lens",e)}function E(e){let t=Object.keys(e.nodes),o=new Map,n=new Map;for(let s of t){let a=e.nodes[s]?.deps??[];o.set(s,a);for(let h of a)n.has(h)||n.set(h,new Set),n.get(h).add(s)}let r=[],c=[];for(let s of t)(o.get(s)??[]).length===0&&r.push(s),n.has(s)||c.push(s);r.sort(),c.sort();let p=e.edges.length,f=0,m=1,g=2,d=new Map;for(let s of t)d.set(s,f);let y=!1,l=new Map,u=s=>{let a=d.get(s)??f;if(a===m)return y=!0,0;if(a===g)return l.get(s)??0;d.set(s,m);let h=0,b=n.get(s);if(b!=null)for(let F of b){let G=u(F);G+1>h&&(h=G+1)}return d.set(s,g),l.set(s,h),h},i=0;for(let s of r){let a=u(s);a>i&&(i=a)}for(let s of t)d.get(s)===f&&u(s);return{nodeCount:t.length,edgeCount:p,subgraphCount:e.subgraphs.length,sources:r,sinks:c,depth:i,hasCycles:y}}function $(e){let t=[];for(let[o,n]of Object.entries(e.nodes)){if(n.status!=="errored")continue;let r={path:o,status:"errored"},c=R(e,o,"upstream",{});for(let p of c)if(p!==o&&e.nodes[p]?.status==="errored"){r.upstreamCause=p;break}t.push(r)}return t.sort((o,n)=>o.path<n.path?-1:o.path>n.path?1:0),{ok:t.length===0,problems:t}}function q(e,t){return e.nodeCount===t.nodeCount&&e.edgeCount===t.edgeCount&&e.subgraphCount===t.subgraphCount&&e.depth===t.depth&&e.hasCycles===t.hasCycles&&D(e.sources,t.sources)&&D(e.sinks,t.sinks)}function L(e,t){if(e.ok!==t.ok||e.problems.length!==t.problems.length)return!1;for(let o=0;o<e.problems.length;o++){let n=e.problems[o],r=t.problems[o];if(n.path!==r.path||n.status!==r.status||n.upstreamCause!==r.upstreamCause)return!1}return!0}function D(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(e[o]!==t[o])return!1;return!0}var C=class extends O{stats;health;flow;_target;constructor(t,o={}){super(o.name??`${t.name}_lens`,o.graph),this._target=t;let n=0,r=0,c=k(0,{name:"stats_tick"}),p=k(0,{name:"health_tick"});this.add(c,{name:"stats_tick"}),this.add(p,{name:"health_tick"});let f={name:"flow"};o.maxFlowPaths!=null&&(f.maxSize=o.maxFlowPaths),this.flow=_(f),this.add(this.flow.entries,{name:"flow"});let m=o.pathFilter,g=w(t,(l,u,i)=>{if(n+=1,c.emit(n),r+=1,p.emit(r),l.kind==="removed")if(l.nodeKind==="node"){let s=`${i}${l.name}`;this.flow.delete(s)}else{let s=`${i}${l.name}::`,a=[];for(let h of l.audit.nodes){let b=h===""?`${i}${l.name}`:`${s}${h}`;a.push(b)}a.length>0&&this.flow.deleteMany(a)}});this.addDisposer(g);let d=t.observe({timeline:!0,structured:!0}),y=d.onEvent(l=>{let u=l.type;if((u==="error"||u==="complete"||u==="data"||u==="teardown")&&(r+=1,p.emit(r)),u==="data"){let i=l.path??"";if(!i||m!=null&&!m(i))return;let s=this.flow.get(i),a=s!=null?s.count+1:1;this.flow.set(i,{path:i,count:a,lastUpdate_ns:H()})}});this.addDisposer(()=>{y(),d.dispose()}),this.stats=x([c],()=>E(t.describe({detail:"minimal"})),{name:"stats",describeKind:"derived",equals:q,meta:v("stats")}),this.add(this.stats,{name:"stats"}),this.addDisposer(T(this.stats)),this.health=x([p],()=>$(t.describe({detail:"standard"})),{name:"health",describeKind:"derived",equals:L,meta:v("health")}),this.add(this.health,{name:"health"}),this.addDisposer(T(this.health))}why(t,o,n){let r=P(this._target,t,o,n);return this.addDisposer(r.dispose),r}get target(){return this._target}};function N(e,t){return new C(e,t)}export{C as a,N as b,B as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as b,m as h}from"./chunk-
|
|
1
|
+
import{E as b,m as h}from"./chunk-W4TSQ6RJ.js";import{b as p,c as l}from"./chunk-CK2E7BTU.js";var u=class{_version=0;_buf;constructor(e){this._buf=e?[...e]:[]}get version(){return this._version}get size(){return this._buf.length}at(e){if(!Number.isInteger(e))return;let n=e>=0?e:this._buf.length+e;if(!(n<0||n>=this._buf.length))return this._buf[n]}append(e){this._buf.push(e),this._version+=1}appendMany(e){if(e.length===0)return;let n=this._buf.length;this._buf.length=n+e.length;for(let i=0;i<e.length;i++)this._buf[n+i]=e[i];this._version+=1}insert(e,n){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insert: index ${e} out of range [0, ${this._buf.length}]`);this._buf.splice(e,0,n),this._version+=1}insertMany(e,n){if(!Number.isInteger(e)||e<0||e>this._buf.length)throw new RangeError(`insertMany: index ${e} out of range [0, ${this._buf.length}]`);n.length!==0&&(this._buf.splice(e,0,...n),this._version+=1)}pop(e){if(this._buf.length===0)throw new RangeError("pop from empty list");if(!Number.isInteger(e))throw new RangeError(`pop: index ${e} must be an integer`);let n=e>=0?e:this._buf.length+e;if(n<0||n>=this._buf.length)throw new RangeError(`pop: index ${e} out of range`);let[i]=this._buf.splice(n,1);return this._version+=1,i}clear(){let e=this._buf.length;return e===0?0:(this._buf.length=0,this._version+=1,e)}toArray(){return[...this._buf]}};function y(d,e={}){let{name:n,versioning:i,backend:f}=e,t=f??new u(d),a=b(t.toArray(),{name:n,describeKind:"state",equals:(r,o)=>r===o,...i!=null?{versioning:i}:{}});function v(){let r=t.toArray();h(()=>{a.down([[l]]),a.down([[p,r]])})}function s(r){let o=t.version;try{return r()}finally{t.version!==o&&v()}}return{items:a,get size(){return t.size},at(r){return t.at(r)},append(r){s(()=>t.append(r))},appendMany(r){s(()=>t.appendMany(r))},insert(r,o){s(()=>t.insert(r,o))},insertMany(r,o){s(()=>t.insertMany(r,o))},pop(r=-1){return s(()=>t.pop(r))},clear(){s(()=>t.clear())},dispose(){}}}export{u as a,y as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as n}from"./chunk-
|
|
1
|
+
import{d as n}from"./chunk-73Z3W2RN.js";import{k as a}from"./chunk-MGKAO4EK.js";import{b as c}from"./chunk-QYADASLV.js";var s={};c(s,{GuardedExecutionGraph:()=>o,guardedExecution:()=>p});var o=class extends a{enforcer;violations;_target;_defaultActor;constructor(r,e){super(e.name??`${r.name}_guarded`,e.graph),this._target=r,this._defaultActor=e.actor;let t={mode:e.mode??"enforce",name:"enforcer"};e.violationsLimit!=null&&(t.violationsLimit=e.violationsLimit),this.enforcer=n(r,e.policies,t),this.violations=this.enforcer.violations,this.mount("enforcer",this.enforcer)}scopedDescribe(r){let e=r?.actor??this._defaultActor,t={...r,...e!=null?{actor:e}:{}};return this._target.describe(t)}get target(){return this._target}};function p(i,r){return new o(i,r)}export{o as a,p as b,s as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as l,v as o}from"./chunk-
|
|
1
|
+
import{C as l,v as o}from"./chunk-W4TSQ6RJ.js";function h(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;default:return new Set(["type","deps"])}}function m(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function g(t){let e={};for(let[r,a]of Object.entries(t.meta))try{e[r]=a.cache}catch{}return e}function y(t,e){let r=e==null,a=!r&&e!=null?[...e].filter(n=>n.startsWith("meta.")).map(n=>n.slice(5)):null,d=r||e.has("meta")||a!=null&&a.length>0,c="state",p=[];t instanceof l&&(c=m(t),p=t._deps.map(n=>n.node.name??""));let s={type:c,deps:p};(r||e.has("status"))&&(s.status=t.status);let i=t instanceof l?t._guard:void 0;if(d){let n={...g(t)};if(i!=null&&n.access===void 0&&(n.access=o(i)),a!=null&&a.length>0&&!e.has("meta")){let f={};for(let u of a)u in n&&(f[u]=n[u]);s.meta=f}else s.meta=n}if(t.name!=null&&(s.name=t.name),r||e.has("value")){t.status==="sentinel"&&(s.sentinel=!0);try{s.value=t.cache}catch{}}if((r||e.has("v"))&&t.v!=null){let n={id:t.v.id,version:t.v.version};"cid"in t.v&&(n.cid=t.v.cid,n.prev=t.v.prev),s.v=n}return(r||e.has("guard"))&&i!=null&&(s.guard=o(i)),(r||e.has("lastMutation"))&&t.lastMutation!=null&&(s.lastMutation=t.lastMutation),s}export{h as a,y as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as R}from"./chunk-5Z4HDCO6.js";import{k}from"./chunk-MGKAO4EK.js";import{b as N}from"./chunk-AUY2YKCO.js";import{A as g}from"./chunk-KASHOCF5.js";import{D as T,E as S,G as y,m as q,p as w,t as u}from"./chunk-W4TSQ6RJ.js";import{b as A}from"./chunk-QYADASLV.js";var P={};A(P,{CqrsGraph:()=>h,MemoryEventStore:()=>_,cqrs:()=>O});var j=u((i,e)=>{i("write"),i("signal"),e("observe")}),D=u((i,e)=>{i("observe"),i("signal"),e("write")}),H=u((i,e)=>{i("observe"),i("signal"),e("write")});function m(i,e){return R("cqrs",i,e)}var _=class{_store=new Map;persist(e){let t=this._store.get(e.type);t||(t=[],this._store.set(e.type,t)),t.push(e)}loadEvents(e,t){let n=this._store.get(e)??[],r=t?.timestampNs,s=t?.seq,o=r==null?[...n]:n.filter(d=>d.timestampNs>r||d.timestampNs===r&&d.seq>(s??-1)),a=o.length>0?o[o.length-1]:void 0;return{events:o,cursor:a?{timestampNs:a.timestampNs,seq:a.seq}:t}}clear(){this._store.clear()}},h=class extends k{_eventLogs=new Map;_commandHandlers=new Map;_projections=new Set;_sagas=new Set;_keepaliveDisposers=[];_eventStore;_seq=0;constructor(e,t={}){super(e,t.graph)}destroy(){for(let e of this._keepaliveDisposers)e();this._keepaliveDisposers.length=0,super.destroy()}event(e){let t=this._eventLogs.get(e);if(t)return t.node;let n=N([],{name:e,versioning:0}),r=n.entries,s=y([r],([o])=>o,{name:e,describeKind:"state",meta:m("event",{event_name:e}),guard:H,initial:r.cache});return this.add(s,{name:e}),this._keepaliveDisposers.push(g(s)),this._eventLogs.set(e,{log:n,node:s}),s}_appendEvent(e,t){let n=this._eventLogs.get(e);if(n||(this.event(e),n=this._eventLogs.get(e)),n.node.status==="completed"||n.node.status==="errored")throw new Error(`Cannot dispatch to terminated event stream "${e}" (status: ${n.node.status}).`);let r=n.log.entries.v,s={type:e,payload:t,timestampNs:w(),seq:++this._seq,...r!=null?{v0:{id:r.id,version:r.version}}:{}};n.log.append(s),this._eventStore&&this._eventStore.persist(s)}command(e,t){let n=S(void 0,{name:e,describeKind:"state",meta:{...m("command",{command_name:e}),error:null},guard:j});return this.add(n,{name:e}),this._commandHandlers.set(e,t),n}dispatch(e,t){let n=this._commandHandlers.get(e);if(!n)throw new Error(`Unknown command: "${e}". Register with .command() first.`);let r=this.resolve(e);q(()=>{r.emit(t,{internal:!0});try{n(t,{emit:(s,o)=>this._appendEvent(s,o)}),r.meta.error.emit(null,{internal:!0})}catch(s){throw r.meta.error.emit(s,{internal:!0}),s}})}projection(e,t,n,r){let s=t.map(a=>(this._eventLogs.has(a)||this.event(a),this._eventLogs.get(a).node)),o=y(s,a=>{let d=[];for(let v of a){let p=v;d.push(...p)}return d.sort((v,p)=>v.timestampNs-p.timestampNs||v.seq-p.seq),n(r,d)},{name:e,describeKind:"derived",meta:m("projection",{projection_name:e,source_events:t}),guard:D,initial:r});return this.add(o,{name:e}),this._keepaliveDisposers.push(g(o)),this._projections.add(e),o}saga(e,t,n){let r=t.map(d=>(this._eventLogs.has(d)||this.event(d),this._eventLogs.get(d).node)),s=new Map,o={},a=T(r,(d,v)=>{let p=o.n.meta.error;for(let c=0;c<d.length;c++){let E=d[c];if(E==null||E.length===0)continue;let l=E.at(-1);if(!l)continue;let f=t[c],C=s.get(f)??0;if(l.length>C){let b=l.slice(C);for(let L of b)try{n(L),p.emit(null,{internal:!0})}catch(x){p.emit(x,{internal:!0})}s.set(f,l.length)}}},{name:e,describeKind:"effect",meta:{...m("saga",{saga_name:e,source_events:t}),error:null}});return o.n=a,this.add(a,{name:e}),this._keepaliveDisposers.push(g(a)),this._sagas.add(e),a}useEventStore(e){this._eventStore=e}async rebuildProjection(e,t,n){if(!this._eventStore)throw new Error("No event store wired. Call useEventStore() first.");let r=[];for(let s of e){let o=await this._eventStore.loadEvents(s);r.push(...o.events)}return r.sort((s,o)=>s.timestampNs-o.timestampNs||s.seq-o.seq),t(n,r)}};function O(i,e){return new h(i,e)}export{_ as a,h as b,O as c,P as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as I}from"./chunk-
|
|
1
|
+
import{c as I}from"./chunk-5Z4HDCO6.js";import{h as _,k as P}from"./chunk-MGKAO4EK.js";import{D as y,E as K,G as E,m as F}from"./chunk-W4TSQ6RJ.js";import{b as j,d as x,i as A,j as D}from"./chunk-CK2E7BTU.js";import{b as B}from"./chunk-QYADASLV.js";var ee={};B(ee,{approval:()=>V,branch:()=>U,gate:()=>z,join:()=>J,loop:()=>Q,onFailure:()=>Z,pipeline:()=>L,sensor:()=>Y,subPipeline:()=>X,task:()=>H});function O(e,n){if(typeof n=="string")return{node:e.resolve(n),path:n};let o=$(e,n);if(!o)throw new Error("orchestration dep node must already be registered in the graph so explicit edges can be recorded; pass a string path or register the node first");return{node:n,path:o}}function $(e,n){let o=e.describe(),r=`::${_}::`;for(let t of Object.keys(o.nodes).sort())if(!t.includes(r))try{if(e.resolve(t)===n)return t}catch{}}function w(e,n,o,r){e.add(o,{name:n})}function N(e,n){return I("orchestration",e,n)}function W(e){let n=r=>{let t=r.trim();return t.length===0?0:Number(t)},o;return typeof e=="string"?o=n(e):e===null?o=0:o=Number(e),Number.isFinite(o)?Math.max(0,Math.trunc(o)):1}function L(e,n){return new P(e,n)}function H(e,n,o,r){let a=(r?.deps??[]).map(i=>O(e,i)),{deps:s,...p}=r??{},T=(i,f,c)=>{let l=i.map((h,g)=>h!=null&&h.length>0?h.at(-1):c.prevData[g]);f.emit(o(l,c))},d=y(a.map(i=>i.node),T,{...p,name:n,describeKind:"derived",meta:N("task",r?.meta)});return w(e,n,d,a.flatMap(i=>i.path?[i.path]:[])),d}function U(e,n,o,r,t){let a=O(e,o),s=E([a.node],([p])=>({branch:r(p)?"then":"else",value:p}),{...t,name:n,meta:N("branch",t?.meta)});return w(e,n,s,a.path?[a.path]:[]),s}function V(e,n,o,r,t){let a=O(e,o),s=O(e,r),p=t?.isApproved??(d=>!!d),T=y([a.node,s.node],(d,i,f)=>{let c=d[0],l=d[1],h=l!=null&&l.length>0?l.at(-1):f.prevData[1];if(h===void 0||!p(h)){i.down([[x]]);return}if(c==null||c.length===0){l!=null&&l.length>0&&f.prevData[0]!==void 0?i.emit(f.prevData[0]):i.down([[x]]);return}for(let g of c)i.emit(g)},{...t,name:n,describeKind:"derived",meta:N("approval",t?.meta)});return w(e,n,T,[a.path,s.path].filter(d=>typeof d=="string")),T}function z(e,n,o,r){let t=r?.maxPending??1/0;if(t<1&&t!==1/0)throw new RangeError("gate: maxPending must be >= 1");let a=r?.startOpen??!1,s=O(e,o),p=K([],{name:"pending",equals:()=>!1}),T=K(a,{name:"isOpen"}),d=E([p],([u])=>u.length,{name:"count"}),i=[],f=!1,c=a,l=T.subscribe(u=>{for(let m of u)m[0]===j&&(c=m[1])});function h(){p.emit([...i])}function g(u){i.push(u),i.length>t&&i.shift(),h()}function R(u){let m=i.splice(0,u);return h(),m}function k(u){if(f)throw new Error(`gate: ${u}() called after gate was torn down`)}let b=y([s.node],(u,m,S)=>{let G=S.terminalDeps[0];if(G!==void 0){f=!0,i=[],h(),m.down(G===!0?[[A]]:[[D,G]]);return}let v=u[0];if(v==null||v.length===0){m.down([[x]]);return}for(let C of v)c?m.emit(C):(g(C),m.down([[x]]))},{name:n,describeKind:"derived",meta:N("gate",r?.meta)}),q={node:b,pending:p,count:d,isOpen:T,approve(u=1){k("approve");let m=R(u);for(let S of m){if(f)break;b.emit(S)}},reject(u=1){k("reject"),R(u)},modify(u,m=1){k("modify");let S=[...i],G=R(m);for(let v=0;v<G.length&&!f;v++)b.emit(u(G[v],v,S))},open(){k("open"),F(()=>{T.emit(!0);let u=R(i.length);for(let m of u){if(f)break;b.emit(m)}})},close(){k("close"),T.emit(!1)}};e.addDisposer(d.subscribe(()=>{})),e.addDisposer(l),w(e,n,b,s.path?[s.path]:[]);let M=new P(`${n}_state`);return M.add(p,{name:"pending"}),M.add(T,{name:"isOpen"}),M.add(d,{name:"count"}),e.mount(`${n}_state`,M),q}function J(e,n,o,r){let t=o.map(s=>O(e,s)),a=E(t.map(s=>s.node),s=>s,{...r,name:n,meta:N("join",r?.meta)});return w(e,n,a,t.flatMap(s=>s.path?[s.path]:[])),a}function Q(e,n,o,r,t){let a=O(e,o),s=t?.iterations,p=typeof s=="number"||s===void 0?void 0:O(e,s),T=typeof s=="number"?s:void 0,d=y(p?[a.node,p.node]:[a.node],(i,f,c)=>{let l=i[0],h=l!=null&&l.length>0?l.at(-1):c.prevData[0],g=p?i[1]:void 0,R=T??(p?g!=null&&g.length>0?g.at(-1):c.prevData[1]:1),k=W(R);for(let b=0;b<k;b+=1)h=r(h,b,f);f.emit(h)},{...t,name:n,describeKind:"derived",meta:N("loop",t?.meta)});return w(e,n,d,[a.path,p?.path].filter(i=>typeof i=="string")),d}function X(e,n,o,r){let t=o instanceof P?o:L(n,r);return typeof o=="function"&&o(t),e.mount(n,t),t}function Y(e,n,o,r){let t=y([],()=>{},{...r,name:n,initial:o,describeKind:"producer",meta:N("sensor",r?.meta)});return w(e,n,t,[]),{node:t,push(a){t.emit(a)},error(a){t.down([[D,a]])},complete(){t.down([[A]])}}}function Z(e,n,o,r,t){let a=O(e,o),s=!1,p=y([],(T,d)=>{let i=a.node.subscribe(f=>{for(let c of f){if(s)return;if(c[0]===D)try{d.emit(r(c[1],d))}catch(l){s=!0,d.down([[D,l]])}else d.down([c]),c[0]===A&&(s=!0)}});return()=>i()},{...t,name:n,describeKind:"derived",completeWhenDepsComplete:!1,errorWhenDepsError:!1,meta:N("onFailure",t?.meta)});return w(e,n,p,a.path?[a.path]:[]),p}export{L as a,H as b,U as c,V as d,z as e,J as f,Q as g,X as h,Y as i,Z as j,ee as k};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Y,b as m,c as M,d as S,e as C,f as N,g as L,h as k,i as D,j as _,k as P,l as he,n as se,q as ie,r as fe,s as pe,t as _e,u as re}from"./chunk-CK2E7BTU.js";var De={name:"json",version:1,contentType:"application/json",encode(n){let e=JSON.stringify(n);return new TextEncoder().encode(e)},decode(n,e){let t=new TextDecoder().decode(n);return JSON.parse(t)}};function $e(n){return{name:"dag-cbor",version:1,contentType:"application/dag-cbor",encode:e=>n.encode(e),decode:(e,t)=>n.decode(e)}}function je(n,e){return{name:"dag-cbor-zstd",version:1,contentType:"application/dag-cbor+zstd",encode:t=>e.compressSync(n.encode(t)),decode:(t,s)=>n.decode(e.decompressSync(t))}}var oe=1,ge=4;function ze(n,e){let t=new TextEncoder().encode(n.name);if(t.length===0||t.length>255)throw new Error(`encodeEnvelope: codec name "${n.name}" encodes to ${t.length} bytes (must be 1\u2013255)`);let s=n.version;if(!Number.isInteger(s)||s<0||s>65535)throw new Error(`encodeEnvelope: codec.version ${s} out of u16 range (expected integer 0\u201365535)`);let i=2+t.length+2+e.length;if(i>4294967295)throw new Error(`encodeEnvelope: total envelope size ${i} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let r=new Uint8Array(i),a=0;return r[a++]=oe,r[a++]=t.length,r.set(t,a),a+=t.length,r[a++]=s>>>8&255,r[a++]=s&255,r.set(e,a),r}function qe(n,e){if(n.length<ge)throw new Error(`decodeEnvelope: bytes too short (${n.length} < ${ge})`);let t=0,s=n[t++];if(s!==oe)throw new Error(`decodeEnvelope: unsupported envelope version ${s} (expected ${oe})`);let i=n[t++];if(i===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(t+i+2>n.length)throw new Error(`decodeEnvelope: envelope truncated (need ${t+i+2} bytes, have ${n.length})`);let r=new TextDecoder().decode(n.subarray(t,t+i));t+=i;let a=(n[t]<<8|n[t+1])>>>0;t+=2;let o=n.subarray(t),d=e.lookupCodec(r);if(d==null)throw new Error(`decodeEnvelope: codec "${r}" not registered (envelope codec_v=${a})`);return{codec:d,codecVersion:a,payload:o}}function ye(n){n.registerCodec(De)}function Ke(n){if(n.length===0)throw new Error("WAL is empty \u2014 need at least one full snapshot");let e=n[0];if(e.mode!=="full")throw new Error("WAL must start with a full record carrying a baseline snapshot");let t=JSON.parse(JSON.stringify(e.snapshot)),s=e.seq;for(let i=1;i<n.length;i++){let r=n[i];if(r.seq<=s)throw new Error(`WAL chain broken at index ${i}: seq=${r.seq} must exceed prev seq=${s}`);if(r.mode==="full"){t=JSON.parse(JSON.stringify(r.snapshot)),s=r.seq;continue}let a=r.diff;for(let d of a.nodesRemoved)delete t.nodes[d];let o=a.nodesAddedFull;if(o!=null)for(let[d,l]of Object.entries(o))t.nodes[d]=JSON.parse(JSON.stringify(l));for(let d of a.nodesChanged){let l=t.nodes[d.path];l!=null&&(l[d.field]=d.to)}s=r.seq}return t}var Oe={type:"system",id:""};function J(n){if(n==null)return Oe;let{type:e,id:t,...s}=n;return{type:e??"system",id:t??"",...s}}var O=0,U=!1,A=[],E=[],R=[],W=[];function me(){return O>0||U}function be(){return O>0}function ve(n){O>0?W.push(n):n()}function Xe(n){O+=1;let e=!1;try{n()}catch(t){throw e=!0,t}finally{if(O-=1,O===0)if(e){if(!U){let t=W.splice(0);for(let s of t)try{s()}catch{}A.length=0,E.length=0,R.length=0}}else Re()}}function Re(){let n=!U;n&&(U=!0);let e=[],t=0;try{for(;A.length>0||E.length>0||R.length>0||n&&W.length>0;){if(n&&W.length>0){let r=W.splice(0);for(let a of r)try{a()}catch(o){e.push(o)}continue}if(t+=1,t>1e3)throw A.length=0,E.length=0,R.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let i=(A.length>0?A:E.length>0?E:R).splice(0);for(let r of i)try{r()}catch(a){e.push(a)}}}finally{n&&(U=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function X(n,e,t){if(e.length===0)return;if(e.length===1){let l=t(e[0][0]);if(l<3||!me()){n(e);return}(l>=5?R:l===4?E:A).push(()=>n(e));return}let s=e.length,i=s,r=s,a=s,o=0;for(;o<s&&t(e[o][0])<3;)o++;for(i=o;o<s&&t(e[o][0])===3;)o++;for(r=o;o<s&&t(e[o][0])===4;)o++;a=o;let d=me();if(i>0){let l=e.slice(0,i);n(l)}if(r>i){let l=e.slice(i,r);d?A.push(()=>n(l)):n(l)}if(a>r){let l=e.slice(r,a);d?E.push(()=>n(l)):n(l)}if(s>a){let l=e.slice(a,s);d?R.push(()=>n(l)):n(l)}}function Qe(){return Math.trunc(performance.now()*1e6)}function we(){return Date.now()*1e6}var Z=class{_messageTypes=new Map;_codecs=new Map;_onMessage;_onSubscribe;_defaultVersioning;_defaultHashFn;_inspectorEnabled=!(typeof process<"u"&&process.env?.NODE_ENV==="production");_globalInspector;_frozen=!1;tierOf;constructor(e){this._onMessage=e.onMessage,this._onSubscribe=e.onSubscribe,this._defaultVersioning=e.defaultVersioning,this._defaultHashFn=e.defaultHashFn,this.tierOf=t=>{let s=this._messageTypes.get(t);return s!=null?s.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,t){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:t.tier,wireCrossing:t.wireCrossing??t.tier>=3,metaPassthrough:t.metaPassthrough??!0}),this}messageTier(e){let t=this._messageTypes.get(e);return t!=null?t.tier:1}isWireCrossing(e){let t=this._messageTypes.get(e);return t!=null?t.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let t=this._messageTypes.get(e);return t!=null?t.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}};function xe(n){n.registerMessageType(Y,{tier:0,wireCrossing:!1}),n.registerMessageType(M,{tier:1,wireCrossing:!1}),n.registerMessageType(C,{tier:1,wireCrossing:!1,metaPassthrough:!1}),n.registerMessageType(N,{tier:2,wireCrossing:!1}),n.registerMessageType(L,{tier:2,wireCrossing:!1}),n.registerMessageType(m,{tier:3,wireCrossing:!0}),n.registerMessageType(S,{tier:3,wireCrossing:!0}),n.registerMessageType(D,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(_,{tier:4,wireCrossing:!0,metaPassthrough:!1}),n.registerMessageType(k,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var F=class extends Error{actor;action;nodeName;constructor(e,t){super(t??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}};function Te(n){return Array.isArray(n)?[...n]:[n]}function Fe(n,e){return n.has(e)||n.has("*")}function Ge(n){let e=[];return n((i,r)=>{e.push({kind:"allow",actions:new Set(Te(i)),where:r?.where??(()=>!0)})},(i,r)=>{e.push({kind:"deny",actions:new Set(Te(i)),where:r?.where??(()=>!0)})}),(i,r)=>{let a=!1,o=!1;for(let d of e)Fe(d.actions,r)&&d.where(i)&&(d.kind==="deny"?a=!0:o=!0);return a?!1:o}}function st(n){return Ge((e,t)=>{for(let s of n){let i=s.actorType==null?null:new Set(Array.isArray(s.actorType)?s.actorType:[s.actorType]),r=s.actorId==null?null:new Set(Array.isArray(s.actorId)?s.actorId:[s.actorId]),a=Object.entries(s.claims??{}),o=d=>{if(i!==null&&!i.has(String(d.type))||r!==null&&!r.has(String(d.id??"")))return!1;for(let[l,c]of a)if(d[l]!==c)return!1;return!0};s.effect==="deny"?t(s.action,{where:o}):e(s.action,{where:o})}})}var Ie=["human","llm","wallet","system"];function it(n){let e=Ie.filter(t=>n({type:t,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(t=>t==="human"||t==="llm"||t==="system")?"both":e.length===1?e[0]:e.join("+")}function ae(n){if(n===void 0)return null;if(typeof n=="number"){if(!Number.isFinite(n))throw new TypeError(`Cannot hash non-finite number: ${n}`);if(Number.isInteger(n)&&!Number.isSafeInteger(n))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${n}. Cross-language cid parity is not guaranteed for unsafe integers.`);return n}if(typeof n=="string"||typeof n=="boolean"||n===null)return n;if(Array.isArray(n))return n.map(ae);if(typeof n=="object"&&n!==null){let e={};for(let t of Object.keys(n).sort())e[t]=ae(n[t]);return e}return null}var He=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ve=new TextEncoder;function Le(n){let e=Ve.encode(n),t=e.length,s=t*8,i=t+9+63&-64,r=new Uint8Array(i);r.set(e),r[t]=128;let a=new DataView(r.buffer);a.setUint32(i-4,s>>>0,!1),a.setUint32(i-8,Math.floor(s/4294967296)>>>0,!1);let o=1779033703,d=3144134277,l=1013904242,c=2773480762,u=1359893119,p=2600822924,h=528734635,b=1541459225,T=new Uint32Array(64),y=(w,g)=>w>>>g|w<<32-g;for(let w=0;w<i;w+=64){for(let f=0;f<16;f++)T[f]=a.getUint32(w+f*4,!1);for(let f=16;f<64;f++){let H=T[f-15],V=T[f-2],K=y(H,7)^y(H,18)^H>>>3,ne=y(V,17)^y(V,19)^V>>>10;T[f]=T[f-16]+K+T[f-7]+ne>>>0}let g=o,G=d,I=l,ee=c,x=u,z=p,q=h,te=b;for(let f=0;f<64;f++){let H=y(x,6)^y(x,11)^y(x,25),V=x&z^~x&q,K=te+H+V+He[f]+T[f]>>>0,ne=y(g,2)^y(g,13)^y(g,22),Se=g&G^g&I^G&I,Ce=ne+Se>>>0;te=q,q=z,z=x,x=ee+K>>>0,ee=I,I=G,G=g,g=K+Ce>>>0}o=o+g>>>0,d=d+G>>>0,l=l+I>>>0,c=c+ee>>>0,u=u+x>>>0,p=p+z>>>0,h=h+q>>>0,b=b+te>>>0}let v=w=>w.toString(16).padStart(8,"0");return v(o)+v(d)+v(l)+v(c)+v(u)+v(p)+v(h)+v(b)}function de(n){let e=ae(n??null),t=JSON.stringify(e);return Le(t).slice(0,16)}function Pe(){let n=globalThis.crypto;if(n?.randomUUID)return n.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),t=e()+e()+e()+e();return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,16)}-${(parseInt(t.slice(16,17),16)&3|8).toString(16)}${t.slice(17,20)}-${t.slice(20,32)}`}function le(n,e,t){let s=t?.id??Pe();if(n===0)return{id:s,version:0};let r=(t?.hash??de)(e);return{id:s,version:0,cid:r,prev:null}}function Ne(n,e,t){n.version+=1,"cid"in n&&(n.prev=n.cid,n.cid=t(e))}function ot(n){return"cid"in n}var ke=()=>{},Ae=100;function Ee(n){return{node:n,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function ce(n){n.prevData=void 0,n.dirty=!1,n.involvedThisWave=!1,n.dataBatch.length=0,n.terminal=void 0}function Q(n){return n.length===0?n:typeof n[0]=="symbol"?[n]:n}var Ue=(n,e,t,s)=>{t.direction==="down-in"&&n._onDepMessage(t.depIndex,e)},We=(n,e,t,s)=>{let i=n;if(i._status==="completed"||i._status==="errored")return;let r=i._cached,a=r===void 0?[se]:[se,[m,r]];i._status==="dirty"&&a.push(P),X(e,a,i._config.tierOf)},B=new Z({onMessage:Ue,onSubscribe:We});xe(B);ye(B);function gt(n){if(B._isFrozen())throw new Error("configure() called after a node was created \u2014 the default GraphReFlyConfig is frozen. Call configure(...) at application startup, before any node factories run.");n(B)}var $=class n{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,t,s){this._config=s.config??B,this._config.onMessage,this._optsName=s.name,this._describeKind=s.describeKind,this._equals=s.equals??Object.is,this._resubscribable=s.resubscribable??!1,this._resetOnTeardown=s.resetOnTeardown??!1,this._autoComplete=s.completeWhenDepsComplete??!0,this._autoError=s.errorWhenDepsError??!0,this._pausable=s.pausable??!0,this._guard=s.guard,this._fn=t,this._partial=s.partial??!1,this._cached=s.initial!==void 0?s.initial:void 0,this._status=e.length===0&&t==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=s.versioningHash??this._config.defaultHashFn??de;let i=s.versioning??this._config.defaultVersioning;this._versioningLevel=i,this._versioning=i!=null?le(i,this._cached===void 0?void 0:this._cached,{id:s.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Ee);let r={};for(let[o,d]of Object.entries(s.meta??{})){let l={initial:d,name:`${s.name??"node"}:meta:${o}`,describeKind:"state",config:this._config};s.guard!=null&&(l.guard=s.guard),r[o]=new n([],void 0,l)}Object.freeze(r),this.meta=r,this._hasMeta=Object.keys(r).length>0;let a=this;this._actions={emit(o){a._emit([[m,o]])},down(o){a._emit(Q(o))},up(o){a._emitUp(Q(o))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,t){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let s=this._versioningLevel;if(s!=null&&e<=s)return;let i=t?.hash??this._hashFn;i!==this._hashFn&&(this._hashFn=i);let r=this._cached===void 0?void 0:this._cached,a=this._versioning,o=a?.id??t?.id,d=a?.version??0,l=le(e,r,{id:o,hash:i});l.version=d,this._versioning=l,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let t=J(e);if(this._guard!=null&&!this._guard(t,"observe"))return!1;if(this._extraGuards!=null){for(let s of this._extraGuards)if(!s(t,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let t=this._guard!=null||this._extraGuards!=null,s=e?.actor!=null;if(!t&&!s)return;let i=J(e?.actor),r=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(i,r))throw new F({actor:i,action:r,nodeName:this.name});if(this._extraGuards!=null){for(let a of this._extraGuards)if(!a(i,r))throw new F({actor:i,action:r,nodeName:this.name})}this._lastMutation={actor:i,timestamp_ns:we()}}down(e,t){let s=Q(e);s.length!==0&&(this._checkGuard(t),this._emit(s))}emit(e,t){this._checkGuard(t),this._emit([[m,e]])}up(e,t){if(this._deps.length===0)return;let s=Q(e);if(s.length===0)return;this._checkGuard(t);let i=t??{internal:!0};this._validateUpTiers(s);for(let r of this._deps)r.node.up?.(s,i)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let t of this._deps)t.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let t=this._config.tierOf;for(let s of e){let i=t(s[0]);if(i===3||i===4)throw new Error(`Node "${this.name}": tier-${i} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,t){if(t!=null&&this._guard!=null){let d=J(t);if(!this._guard(d,"observe"))throw new F({actor:d,action:"observe",nodeName:this.name})}let i=this._isTerminal&&this._resubscribable;if(i){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let d of this._deps)ce(d);if(this._partial===!1){for(let d of this._deps)if(d.prevData!==void 0||d.dataBatch.length!==0||d.terminal!==void 0||d.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let r;try{r=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:i},this._actions)}catch(d){throw this._sinkCount-=1,d}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let a=this._isTerminal;if(this._sinkCount===1&&!a)try{this._activate()}catch(d){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof r=="function")try{r()}catch{}throw d}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let o=!1;return()=>{o||(o=!0,this._sinkCount-=1,this._removeSink(e),typeof r=="function"&&r(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[t]=this._sinks;this._sinks=t}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,t=0;try{for(let s=0;s<e;s++){let i=s,r=this._deps[s];r.unsub=ke,r.unsub=r.node.subscribe(a=>{if(r.unsub===null)return;let o=this._config.tierOf,d=!1;for(let l of a)o(l[0])>=3&&(d=!0),this._config.onMessage(this,l,{direction:"down-in",depIndex:i},this._actions);d&&this._maybeRunFnOnSettlement()}),t++}}catch(s){this._deps[t].unsub=null;for(let i=0;i<t;i++){let r=this._deps[i];if(r.unsub!=null){let a=r.unsub;r.unsub=null;try{a()}catch{}ce(r)}}throw this._dirtyDepCount=0,s}}_addDep(e){for(let i=0;i<this._deps.length;i++)if(this._deps[i].node===e)return i;let t=this._deps.length,s=Ee(e);if(this._deps.push(s),this._sinks==null)return t;s.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ie),s.unsub=ke;try{s.unsub=e.subscribe(i=>{if(s.unsub===null)return;let r=this._config.tierOf,a=!1;for(let o of i)r(o[0])>=3&&(a=!0),this._config.onMessage(this,o,{direction:"down-in",depIndex:t},this._actions);a&&this._maybeRunFnOnSettlement()})}catch(i){throw s.unsub=null,this._deps.pop(),this._dirtyDepCount--,i}return t}_deactivate(e=!1){let t=this._cleanup;if(this._cleanup=void 0,typeof t=="function")try{t()}catch(s){this._emit([[_,this._wrapFnError("cleanup threw",s)]])}else if(t!=null&&typeof t=="object"){let s=t.deactivate;if(typeof s=="function")try{s()}catch(i){this._emit([[_,this._wrapFnError("cleanup.deactivate threw",i)]])}}for(let s of this._deps){if(s.unsub!=null){let i=s.unsub;s.unsub=null;try{i()}catch{}}ce(s)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,t){let s=this._deps[e],i=t[0];if(this._inspectorHooks!=null){let r={kind:"dep_message",depIndex:e,message:t};for(let a of this._inspectorHooks)a(r)}if(i!==Y){if(i===M){this._depDirtied(s);return}if(i===C){this._depInvalidated(s),this._emit(pe);return}if(i===N||i===L){this._emit([t]);return}if(i===k){this._emit(re);return}if(i===m)this._depSettledAsData(s,t[1]);else if(i===S)this._depSettledAsResolved(s);else if(i===D)this._depSettledAsTerminal(s,!0);else if(i===_)this._depSettledAsTerminal(s,t[1]);else{this._emit([t]);return}if(!this._fn){(i===m||i===S)&&this._emit([t]),(i===D||i===_)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ie))}_depSettledAsData(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(t),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,t){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=t,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let t=this._deps[e];if(t.dataBatch.length===0&&t.prevData===void 0&&t.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(fe),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(t=>t.terminal!==void 0&&t.terminal!==!0);if(e!=null){this._autoError&&this._emit([[_,e.terminal]]);return}this._autoComplete&&this._deps.every(t=>t.terminal!==void 0)&&this._emit(_e)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(a){this._emit([[_,this._wrapFnError("cleanup threw",a)]]);return}}else if(e!=null&&typeof e=="object"){let a=e.beforeRun;if(typeof a=="function"){e.beforeRun=void 0;try{a()}catch(o){this._emit([[_,this._wrapFnError("cleanup.beforeRun threw",o)]]);return}}}let t=this._deps.map(a=>a.involvedThisWave?a.dataBatch.length>0?[...a.dataBatch]:[]:void 0),s=this._deps.map(a=>a.prevData);for(let a=0;a<this._deps.length;a++){let o=t[a];o!=null&&o.length>0&&(this._deps[a].prevData=o[o.length-1])}let i=this._deps.map(a=>a.terminal),r={prevData:s,terminalDeps:i,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let a={kind:"run",batchData:t,prevData:s};for(let o of this._inspectorHooks)o(a)}this._isExecutingFn=!0;try{let a=this._fn(t,this._actions,r);if(typeof a=="function")this._cleanup=a;else if(a!=null&&typeof a=="object"){let o=a;(typeof o.beforeRun=="function"||typeof o.deactivate=="function"||typeof o.invalidate=="function")&&(this._cleanup=a)}}catch(a){this._emit([[_,this._wrapFnError("fn threw",a)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>Ae?(this._rerunDepth=0,this._emit([[_,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${Ae} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,t){let s=t instanceof Error?t.message:String(t);return new Error(`Node "${this.name}": ${e}: ${s}`,{cause:t})}_frameBatch(e){let t=this._config.tierOf;if(e.length===1)return t(e[0][0])===3&&this._status!=="dirty"?[P,e[0]]:e;let s=!0,i=!1,r=!1,a=-1;for(let d of e){let l=t(d[0]);l<a&&(s=!1),l===3&&(i=!0),d[0]===M&&(r=!0),a=l}let o=e;if(!s){let d=e.map((l,c)=>({m:l,i:c,tier:t(l[0])}));d.sort((l,c)=>l.tier-c.tier||l.i-c.i),o=d.map(l=>l.m)}if(i&&!r&&this._status!=="dirty"){let d=0;for(;d<o.length&&t(o[d][0])===0;)d++;return d===0?[P,...o]:[...o.slice(0,d),P,...o.slice(d)]}return o}_emit(e){if(e.length===0)return;for(let o=0;o<e.length;o++){let d=e[o];if(d[0]===_&&d[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let t=e;if(this._isTerminal&&!this._resubscribable){let o=e.filter(d=>d[0]===k||d[0]===C);if(o.length===0)return;t=o}t=this._frameBatch(t);let i=null;for(let o=0;o<t.length;o++){let d=t[o],l=d[0];if(l!==N&&l!==L){i?.push(d);continue}if(d.length<2)throw new Error(`Node "${this.name}": [[${l===N?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let c=!0;if(this._pausable!==!1){let u=d[1];if(l===N)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(u),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(u))c=!1;else if(this._pauseLocks.delete(u),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let p=this._pauseBuffer;this._pauseBuffer=[],this._emit(p)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}c?i?.push(d):i==null&&(i=t.slice(0,o))}if(i!=null){if(i.length===0)return;t=i}if(this._hasMeta&&t.some(o=>o[0]===k))for(let o of Object.keys(this.meta))try{this.meta[o]._emit(re)}catch{}let{finalMessages:r,equalsError:a}=this._updateState(t);if(r.length>0&&this._config.inspectorEnabled){let o=this._config.globalInspector;if(o!=null)try{o({kind:"emit",node:this,messages:r})}catch{}}if(r.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let o=this._config.tierOf,d=[];for(let l of r)o(l[0])===3?this._pauseBuffer.push(l):d.push(l);d.length>0&&this._dispatchOrAccumulate(d)}else this._dispatchOrAccumulate(r);a!=null&&this._emit([[_,a]])}_updateState(e){let t=this._config.tierOf,s,i,r=-1,a=0;for(let c of e)t(c[0])===3&&a++;let o=a<=1,d=-1;if(this._versioning!=null&&a>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===m){d=c;break}}for(let c=0;c<e.length;c++){let u=e[c],p=u[0];if(p===m){if(u.length>=2){let h=!1;if(o&&this._cached!==void 0)try{h=this._equals(this._cached,u[1])}catch(b){i=this._wrapFnError("equals threw",b),r=c;break}if(h){s==null&&(s=e.slice(0,c)),s.push(he),this._status="resolved";continue}this._cached=u[1],this._versioning!=null&&(d<0||c===d)&&Ne(this._versioning,u[1],this._hashFn)}this._status="settled",s?.push(u)}else if(s?.push(u),p===M)this._status="dirty";else if(p===S)this._status="resolved";else if(p===D)this._status="completed";else if(p===_)this._status="errored";else if(p===C){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 b=h.invalidate;if(typeof b=="function")try{b()}catch{}}}else p===k&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let l=r>=0?s??e.slice(0,r):s??e;return i!=null?{finalMessages:l,equalsError:i}:{finalMessages:l}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let t=[...this._sinks];for(let s of t)s(e)};_dispatchOrAccumulate(e){if(be()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],ve(()=>this._flushBatchPending()));for(let t of e)this._batchPendingMessages.push(t);return}X(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let t=this._frameBatch(e);X(this._deliverToSinks,t,this._config.tierOf)}},Me=n=>Array.isArray(n),ue=n=>typeof n=="object"&&n!=null&&!Array.isArray(n);function j(n,e,t){let s=Me(n)?n:[],i=typeof n=="function"?n:typeof e=="function"?e:void 0,r={};return Me(n)?r=(ue(e)?e:t)??{}:ue(n)?r=n:r=(ue(e)?e:t)??{},new $(s,i,r)}function bt(n,e){return j([],{...e,initial:n})}function vt(n,e){return j((s,i,r)=>n(i,r)??void 0,{describeKind:"producer",...e})}function Be(n,e,t){return j(n,(i,r,a)=>{let o=i.map((d,l)=>d!=null&&d.length>0?d.at(-1):a.prevData[l]);r.emit(e(o,a))},{describeKind:"derived",...t})}function wt(n,e,t){return j(n,(i,r,a)=>{let o=i.map((d,l)=>d!=null&&d.length>0?d.at(-1):a.prevData[l]);return e(o,r,a)??void 0},{describeKind:"effect",...t})}function xt(n,e,t){let s=new Map;return n.forEach((i,r)=>{s.set(i,r)}),Be(n,(i,r)=>e(o=>{let d=s.get(o);if(d==null)throw new Error(`dynamicNode: untracked dep "${o.name??"<unnamed>"}"`);return i[d]},r),t)}function Tt(n,e){let t,s=new Map,i=(r,a,o)=>{let d=!1,l=c=>{let u=s.get(c);if(u!==void 0){if(u<r.length){let h=r[u];return h!=null&&h.length>0?h.at(-1):o.prevData[u]}return c.cache}d=!0;let p=t._addDep(c);return s.set(c,p),c.cache};try{let c=n(l,o);d||(a.emit(c),o.store.__autoTrackLastDiscoveryError!=null&&delete o.store.__autoTrackLastDiscoveryError)}catch(c){if(!d)throw c;o.store.__autoTrackLastDiscoveryError=c}};return t=new $([],i,{describeKind:"derived",...e}),t}function Nt(n,...e){let t=n;for(let s of e)t=s(t);return t}export{De as a,$e as b,je as c,oe as d,ze as e,qe as f,ye as g,Ke as h,Oe as i,J as j,me as k,ve as l,Xe as m,X as n,Qe as o,we as p,Z as q,xe as r,F as s,Ge as t,st as u,it as v,de as w,le as x,Ne as y,ot as z,B as A,gt as B,$ as C,j as D,bt as E,vt as F,Be as G,wt as H,xt as I,Tt as J,Nt as K};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as S}from"./chunk-VJLMUKOI.js";import{d as O}from"./chunk-VIMF6LGM.js";import{d as k}from"./chunk-6QZNQS5B.js";import{d as A}from"./chunk-GPW2V3RE.js";import{b as N}from"./chunk-
|
|
1
|
+
import{d as S}from"./chunk-VJLMUKOI.js";import{d as O}from"./chunk-VIMF6LGM.js";import{d as k}from"./chunk-6QZNQS5B.js";import{d as A}from"./chunk-GPW2V3RE.js";import{b as N}from"./chunk-AV3PIDFQ.js";import{b as v}from"./chunk-BA5URFYW.js";import{i as y}from"./chunk-BZP5T4X6.js";import{G as x}from"./chunk-P7JXGKDO.js";import{E as b,J as g,m as _}from"./chunk-W4TSQ6RJ.js";import{b as a,c as p,i as h,j as m}from"./chunk-CK2E7BTU.js";import{b as f}from"./chunk-QYADASLV.js";var j={};f(j,{jotai:()=>v,nanostores:()=>y,nestjs:()=>x,react:()=>S,signals:()=>T,solid:()=>O,svelte:()=>k,vue:()=>A,zustand:()=>N});var T={};f(T,{Signal:()=>q});var s=[];function i(n){let e=n.cache;return n.subscribe(o=>{for(let[d,r]of o)d===a&&(e=r)})(),e}var u=class{_node;_equals;constructor(e,t){this._equals=t?.equals??Object.is,this._node=b(e,{...t,resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}set(e){this._equals(this.get(),e)||_(()=>{this._node.down([[p],[a,e]])})}},l=class{_node;constructor(e,t){this._node=g(o=>{s.push(o);try{return e()}finally{s.pop()}},{...t,describeKind:"derived",resubscribable:!0,resetOnTeardown:!0})}get(){let e=s[s.length-1];return e?(this._node.status==="sentinel"&&i(this._node),e(this._node)):this._node.status==="sentinel"?i(this._node):this._node.cache}},q={State:u,Computed:l,sub:(n,e)=>{let t=typeof e=="function"?{data:e,error:void 0,complete:void 0}:e,o=!0;return n._node.subscribe(d=>{for(let[r,c]of d){if(r===a){if(o){o=!1;continue}t.data?.(c)}r===m&&t.error?.(c),r===h&&t.complete?.()}})}};export{T as a,j as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as G,d as F}from"./chunk-
|
|
1
|
+
import{b as G,d as F}from"./chunk-KA6MMXIY.js";import{c as E}from"./chunk-5Z4HDCO6.js";import{a as A}from"./chunk-GJR3P6JG.js";import{k as I}from"./chunk-MGKAO4EK.js";import{b as q}from"./chunk-AUY2YKCO.js";import{A as M}from"./chunk-KASHOCF5.js";import{E as d,G as o,H as O,m as S}from"./chunk-W4TSQ6RJ.js";import{b as V}from"./chunk-QYADASLV.js";var $={};V($,{contentModerationGraph:()=>Q,dataQualityGraph:()=>T,issueTrackerGraph:()=>B,observabilityGraph:()=>D});function s(u,a){return E("domain_template",u,a)}function D(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=[{name:"errors",classify:e=>C(e,"error")},{name:"traces",classify:e=>C(e,"trace")},{name:"metrics",classify:e=>C(e,"metric")}],m=a.branches??h,y=m.map(e=>({name:e.name,classify:e.classify})),c=A("stratify",a.source,y);n.mount("stratify",c);let k=m.map(e=>{try{let i=n.resolve(`stratify::branch/${e.name}`);return o([i],([x])=>x,{initial:null})}catch{return d(null)}}),l=a.correlate??(e=>e),_=o(k,e=>l(e),{meta:s("observability",{stage:"correlate"})});n.add(_,{name:"correlate"});let N=a.sloCheck??(()=>({pass:!0})),w=o([_],e=>e[0],{meta:s("observability",{stage:"slo_value"})}),f=o([w],e=>N(e[0]),{meta:s("observability",{stage:"slo_verified"})});n.add(w,{name:"slo_value"}),n.add(f,{name:"slo_verified"});let v=a.weights??m.map(()=>1),b=k.map(e=>o([e],i=>i[0]!=null?1:0)),p=v.map(e=>d(e));for(let e=0;e<b.length;e++)n.add(b[e],{name:`__signal_${e}`}),n.add(p[e],{name:`__weight_${e}`});let t=F(b,p);n.add(t,{name:"alerts"});let g=o([t,f],e=>({scored:e[0],slo:e[1]}),{meta:s("observability",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:s("observability",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let r=o([f],e=>{let i=e[0];return i&&i.pass===!1?i:null},{meta:s("observability",{stage:"feedback_condition"})});return n.add(r,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??5}),n}function B(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=0,m=e=>({id:`issue-${++h}`,title:String(e),severity:1,source:"unknown",raw:e}),y=a.extract??m,c=o([a.source],e=>y(e[0]),{meta:s("issue_tracker",{stage:"extract"})});n.add(c,{name:"extract"});let k=a.verify??(()=>({valid:!0})),l=o([c],e=>{let i=e[0];return{issue:i,verification:k(i)}},{meta:s("issue_tracker",{stage:"verify"})});n.add(l,{name:"verify"});let _=d([],{meta:s("issue_tracker",{stage:"known_patterns"})});n.add(_,{name:"known_patterns"});let N=a.detectRegression??(()=>({regression:!1})),w=o([c,_],e=>{let i=e[0],x=e[1];return{issue:i,regression:N(i,x)}},{meta:s("issue_tracker",{stage:"regression"})});n.add(w,{name:"regression"});let f=o([c],e=>e[0]?.severity??0),v=o([w],e=>e[0]?.regression?2:0);n.add(f,{name:"__severity_signal"}),n.add(v,{name:"__regression_signal"});let b=d(1),p=d(1.5);n.add(b,{name:"__severity_weight"}),n.add(p,{name:"__regression_weight"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([l,w,t],e=>({verified:e[0],regression:e[1],priority:e[2]}),{meta:s("issue_tracker",{stage:"output"})});n.add(g,{name:"output"});let R=d(null,{meta:s("issue_tracker",{stage:"feedback_reentry"})});n.add(R,{name:"feedback_reentry"});let r=o([l],e=>{let i=e[0];if(i){let x=i.verification;if(x&&x.valid===!1)return i}return null},{meta:s("issue_tracker",{stage:"feedback_condition"})});return n.add(r,{name:"feedback_condition"}),G(n,"feedback_condition","feedback_reentry",{maxIterations:a.maxFeedbackIterations??3}),n}function Q(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=r=>({label:"review",confidence:.5,original:r}),m=a.classify??h,y=o([a.source],r=>m(r[0]),{meta:s("content_moderation",{stage:"classify"})});n.add(y,{name:"classify"});let c=A("stratify",y,[{name:"safe",classify:r=>r.label==="safe"},{name:"review",classify:r=>r.label==="review"},{name:"block",classify:r=>r.label==="block"}]);n.mount("stratify",c);let k=q([],{name:"review_queue",maxSize:a.maxQueueSize});n.add(k.entries,{name:"review_queue"});let l;try{l=n.resolve("stratify::branch/review")}catch{l=d(null),n.add(l,{name:"__review_fallback"})}let _=O([l],r=>{let e=r[0];e&&k.append(e)});n.add(_,{name:"__review_accumulator"}),n.addDisposer(M(_));let N=d({},{meta:s("content_moderation",{stage:"policy",access:"both",description:"Moderation policy rules \u2014 updated via feedback"})});n.add(N,{name:"policy"});let w=a.weights??[.1,1,2],f=o([y],r=>r[0]?.confidence??0),v=o([y],r=>{let e=r[0];return e?e.label==="block"?w[2]:e.label==="review"?w[1]:w[0]:0});n.add(f,{name:"__confidence_signal"}),n.add(v,{name:"__severity_signal"});let b=d(1),p=d(1);n.add(b,{name:"__w_confidence"}),n.add(p,{name:"__w_severity"});let t=F([f,v],[b,p]);n.add(t,{name:"priority"});let g=o([y,t],r=>({classification:r[0],priority:r[1]}),{meta:s("content_moderation",{stage:"output"})});n.add(g,{name:"output"});let R=o([k.entries,N],r=>{let e=r[0];if(e&&e.length>0){let i=e[e.length-1];if(i&&i.falsePositive)return i}return null},{meta:s("content_moderation",{stage:"feedback_condition"})});return n.add(R,{name:"feedback_condition"}),G(n,"feedback_condition","policy",{maxIterations:a.maxFeedbackIterations??5}),n}function T(u,a){let n=new I(u,a);n.add(a.source,{name:"source"});let h=a.validate??(t=>({valid:!0,errors:[],record:t})),m=o([a.source],t=>t[0]!=null?h(t[0]):void 0,{meta:s("data_quality",{stage:"validate"})});n.add(m,{name:"validate"});let y=a.detectAnomaly??(t=>({anomaly:!1,score:0,record:t})),c=o([a.source],t=>t[0]!=null?y(t[0]):void 0,{meta:s("data_quality",{stage:"anomaly"})});n.add(c,{name:"anomaly"});let k=d(null,{meta:s("data_quality",{stage:"baseline",description:"Rolling baseline for drift detection"})});n.add(k,{name:"baseline"});let l=O([m],t=>{let g=t[0];g?.valid&&S(()=>{k.emit(g.record)})});n.add(l,{name:"__baseline_updater"}),M(l);let _=a.detectDrift??(()=>({drift:!1})),N=o([a.source,k],t=>_(t[0],t[1]),{meta:s("data_quality",{stage:"drift"})});n.add(N,{name:"drift"});let w=a.suggest??(()=>null),f=o([m,c],t=>w({validation:t[0],anomaly:t[1]}),{meta:s("data_quality",{stage:"remediate"})});n.add(f,{name:"remediate"});let v=o([m,c,N,f],t=>({validation:t[0],anomaly:t[1],drift:t[2],remediation:t[3]}),{meta:s("data_quality",{stage:"output"})});n.add(v,{name:"output"});let b=d([],{meta:s("data_quality",{stage:"validation_rules"})});n.add(b,{name:"validation_rules"});let p=o([c],t=>{let g=t[0];return g?.anomaly?g:null},{meta:s("data_quality",{stage:"feedback_condition"})});return n.add(p,{name:"feedback_condition"}),G(n,"feedback_condition","validation_rules",{maxIterations:a.maxFeedbackIterations??3}),n}function C(u,a){if(u==null||typeof u!="object")return!1;let n=u;return n.type===a||n.kind===a}export{D as a,B as b,Q as c,T as d,$ as e};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{f as F,g as j,h as A}from"./chunk-
|
|
1
|
+
import{f as F,g as j,h as A}from"./chunk-GLSM33ZM.js";import{i as b,k as x}from"./chunk-MGKAO4EK.js";import{p as _}from"./chunk-W4TSQ6RJ.js";import{b as $,d as T,i as v,j as N}from"./chunk-CK2E7BTU.js";import{b as K}from"./chunk-QYADASLV.js";var Y={};K(Y,{SNAPSHOT_WIRE_VERSION:()=>k,SurfaceError:()=>o,asSurfaceError:()=>D,createGraph:()=>R,deleteSnapshot:()=>H,diffSnapshots:()=>W,listSnapshots:()=>L,restoreSnapshot:()=>V,runReduction:()=>M,saveSnapshot:()=>U});var o=class extends Error{code;details;constructor(t,r,n){super(r),this.name="SurfaceError",this.code=t,n!==void 0&&(this.details=n)}toJSON(){let t={code:this.code,message:this.message};if(this.details!==void 0){let r=q(this.details);r!==void 0&&(t.details=r)}return t}};function q(e){try{return JSON.parse(JSON.stringify(e))}catch{return}}function D(e,t="internal-error"){if(e instanceof o)return e;let r=e instanceof Error?e.message:String(e);return new o(t,r)}function R(e,t){let r=j(e);if(!r.valid)throw new o("invalid-spec",`GraphSpec validation failed:
|
|
2
2
|
${r.errors.join(`
|
|
3
3
|
`)}`,{errors:r.errors});let n=t?.catalog??{},s=F(e,n);if(!s.valid)throw new o("catalog-error",`Catalog validation failed:
|
|
4
4
|
${s.errors.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as w}from"./chunk-
|
|
1
|
+
import{a as w}from"./chunk-TWMEGG45.js";import{A as b,B as F,C as H,D as G,E as k,F as B,G as Y,H as h,I as v,J as P,K as W,i as K,j,k as S,m as g,n as C,o as I,p as M,q as _,r as u,s as q,t as z,u as J,v as Q,w as L,x as m,y as x,z as V}from"./chunk-W4TSQ6RJ.js";import{a as e,b as t,c as o,d as p,e as r,f as n,g as s,h as i,i as y,j as a,k as d,l as c,m as N,n as T,o as E,p as O,q as D,r as A,s as f,t as l,u as R}from"./chunk-CK2E7BTU.js";import{b as U}from"./chunk-QYADASLV.js";var X={};U(X,{COMPLETE:()=>y,COMPLETE_MSG:()=>E,COMPLETE_ONLY_BATCH:()=>l,DATA:()=>t,DEFAULT_ACTOR:()=>K,DIRTY:()=>o,DIRTY_MSG:()=>d,DIRTY_ONLY_BATCH:()=>D,ERROR:()=>a,GraphReFlyConfig:()=>_,GuardDenied:()=>q,INVALIDATE:()=>r,INVALIDATE_MSG:()=>N,INVALIDATE_ONLY_BATCH:()=>f,NodeImpl:()=>H,PAUSE:()=>n,RESOLVED:()=>p,RESOLVED_MSG:()=>c,RESOLVED_ONLY_BATCH:()=>A,RESUME:()=>s,START:()=>e,START_MSG:()=>T,TEARDOWN:()=>i,TEARDOWN_MSG:()=>O,TEARDOWN_ONLY_BATCH:()=>R,accessHintForGuard:()=>Q,advanceVersion:()=>x,autoTrackNode:()=>P,batch:()=>g,configure:()=>F,createVersioning:()=>m,defaultConfig:()=>b,defaultHash:()=>L,derived:()=>Y,downWithBatch:()=>C,dynamicNode:()=>v,effect:()=>h,isBatching:()=>S,isV1:()=>V,monotonicNs:()=>I,node:()=>G,normalizeActor:()=>j,pipe:()=>W,policy:()=>z,policyFromRules:()=>J,producer:()=>B,registerBuiltins:()=>u,resolveDescribeFields:()=>w,state:()=>k,wallClockNs:()=>M});export{X as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as f}from"./chunk-
|
|
1
|
+
import{c as f}from"./chunk-KA6MMXIY.js";import{a as l,d as o,e as d,h as s,i as m,k as b,l as c}from"./chunk-OL33ZI6R.js";import{a as r,b as u}from"./chunk-4VVTGLXJ.js";import{b as y}from"./chunk-QYADASLV.js";var R={};y(R,{NS_PER_MS:()=>r,NS_PER_SEC:()=>u,resilientPipeline:()=>O});function O(p,e={}){let t=p;e.rateLimit!=null&&(t=s(t,e.rateLimit)),e.budget!=null&&e.budget.length>0&&(t=f(t,e.budget));let n;if(e.breaker!=null){let k=o(e.breaker),S=e.breakerOnOpen??"skip",a=d(k,{onOpen:S})(t);t=a.node,n=a.breakerState}if(e.timeoutMs!=null){if(e.timeoutMs<=0)throw new RangeError("timeoutMs must be > 0");if(e.timeoutMs>9e6)throw new RangeError("timeoutMs must be <= 9_000_000 (\u22482.5h) to stay within safe ns arithmetic");t=c(t,e.timeoutMs*1e6)}e.retry!=null&&(t=l(t,e.retry)),e.fallback!==void 0&&(t=b(t,e.fallback));let i=m(t,{initialStatus:e.initialStatus??"pending"});return{node:i.node,status:i.status,error:i.error,breakerState:n}}export{O as a,R as b};
|