@graphrefly/graphrefly 0.30.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/dist/{cascading-dNCtjW8j.d.cts → cascading-BfQmSmjU.d.cts} +21 -2
  2. package/dist/{cascading-BszPheHD.d.ts → cascading-D3sapjue.d.ts} +21 -2
  3. package/dist/{chunk-T5SHIKJD.js → chunk-3JRKP4BH.js} +1 -1
  4. package/dist/{chunk-GJR3P6JG.js → chunk-3Q2WXM6X.js} +1 -1
  5. package/dist/chunk-4KAUNEKV.js +3 -0
  6. package/dist/{chunk-SLMYTGTU.js → chunk-4UUDNFYG.js} +1 -1
  7. package/dist/chunk-4VXL3UZK.js +1 -0
  8. package/dist/{chunk-AV3PIDFQ.js → chunk-4ZPO2EL5.js} +1 -1
  9. package/dist/{chunk-VWPRPPKR.js → chunk-5LJAQTSS.js} +1 -1
  10. package/dist/{chunk-W4TSQ6RJ.js → chunk-7AJKUA36.js} +1 -1
  11. package/dist/{chunk-RD52SNH2.js → chunk-7EJTWGKW.js} +1 -1
  12. package/dist/{chunk-GNCBXARM.js → chunk-7EQPXQ7H.js} +1 -1
  13. package/dist/chunk-7QMVU3IX.js +1 -0
  14. package/dist/{chunk-BA5URFYW.js → chunk-A4JT4SAD.js} +1 -1
  15. package/dist/chunk-ASDKRNOJ.js +60 -0
  16. package/dist/{chunk-Y32RJO24.js → chunk-CZVYLXFK.js} +1 -1
  17. package/dist/{chunk-567NWZ3T.js → chunk-DWIAG62L.js} +1 -1
  18. package/dist/{chunk-33FA6V4B.js → chunk-EBQ6FXKW.js} +1 -1
  19. package/dist/chunk-FTA5TB2A.js +1 -0
  20. package/dist/{chunk-P7JXGKDO.js → chunk-GF5T7PGC.js} +1 -1
  21. package/dist/{chunk-WANIEEKV.js → chunk-I4U3TPK2.js} +1 -1
  22. package/dist/{chunk-KA6MMXIY.js → chunk-JMGGCSIC.js} +1 -1
  23. package/dist/chunk-JXRZXP3N.js +1 -0
  24. package/dist/{chunk-5Z4HDCO6.js → chunk-K54OKWNY.js} +1 -1
  25. package/dist/{chunk-DDPYNMGG.js → chunk-KN4Q5MQO.js} +1 -1
  26. package/dist/chunk-LWGLBCMU.js +1 -0
  27. package/dist/{chunk-TWMEGG45.js → chunk-N2KKISCE.js} +1 -1
  28. package/dist/{chunk-4OFIQ66T.js → chunk-OKQUPJRY.js} +1 -1
  29. package/dist/chunk-PNTBXOQ6.js +5 -0
  30. package/dist/chunk-PSQNYY72.js +7 -0
  31. package/dist/{chunk-XHVB6G6M.js → chunk-PZP4MEXK.js} +1 -1
  32. package/dist/{chunk-7TDOES3L.js → chunk-Q2SY7M7K.js} +1 -1
  33. package/dist/{chunk-OL33ZI6R.js → chunk-RWGJQQLT.js} +1 -1
  34. package/dist/chunk-SGS4OJGS.js +1 -0
  35. package/dist/chunk-UMH3HSP7.js +1 -0
  36. package/dist/{chunk-BZP5T4X6.js → chunk-W6FQIFVE.js} +1 -1
  37. package/dist/{chunk-SHYH5SXV.js → chunk-WLPVGXQ6.js} +1 -1
  38. package/dist/chunk-WQ7I7JVU.js +1 -0
  39. package/dist/{chunk-XQAXYVXX.js → chunk-WYJTXYWX.js} +1 -1
  40. package/dist/{chunk-3NEPQO2E.js → chunk-X2VHDT26.js} +1 -1
  41. package/dist/{chunk-GLSM33ZM.js → chunk-XEFAMCEA.js} +1 -1
  42. package/dist/{chunk-AUY2YKCO.js → chunk-XRSHMHEG.js} +1 -1
  43. package/dist/chunk-Y26UN6J5.js +18 -0
  44. package/dist/{chunk-BKPLTBL5.js → chunk-YQJPYEAL.js} +1 -1
  45. package/dist/{chunk-73Z3W2RN.js → chunk-YZ6VYLFD.js} +1 -1
  46. package/dist/{chunk-4JJCCD5S.js → chunk-YZKGGMPT.js} +1 -1
  47. package/dist/chunk-Z3UWIJ3A.js +1 -0
  48. package/dist/{chunk-Y36UZ5VS.js → chunk-ZM7C2FUM.js} +1 -1
  49. package/dist/compat/index.cjs +1 -1
  50. package/dist/compat/index.js +1 -1
  51. package/dist/compat/jotai/index.cjs +1 -1
  52. package/dist/compat/jotai/index.js +1 -1
  53. package/dist/compat/nanostores/index.cjs +1 -1
  54. package/dist/compat/nanostores/index.js +1 -1
  55. package/dist/compat/nestjs/index.cjs +5 -5
  56. package/dist/compat/nestjs/index.js +1 -1
  57. package/dist/compat/zustand/index.cjs +1 -1
  58. package/dist/compat/zustand/index.js +1 -1
  59. package/dist/{composite-DGspwCqk.d.ts → composite-BY9hMxN7.d.ts} +1 -1
  60. package/dist/{composite-nrRumJ7l.d.cts → composite-CH0S8DFn.d.cts} +1 -1
  61. package/dist/content-addressed-storage-BUiREIuj.d.ts +124 -0
  62. package/dist/content-addressed-storage-DqIWCmZG.d.cts +124 -0
  63. package/dist/core/index.cjs +1 -1
  64. package/dist/core/index.js +1 -1
  65. package/dist/extra/browser.cjs +1 -1
  66. package/dist/extra/browser.js +1 -1
  67. package/dist/extra/index.cjs +18 -18
  68. package/dist/extra/index.d.cts +6 -5
  69. package/dist/extra/index.d.ts +6 -5
  70. package/dist/extra/index.js +1 -1
  71. package/dist/extra/node.cjs +2 -2
  72. package/dist/extra/node.js +1 -1
  73. package/dist/extra/operators.cjs +1 -1
  74. package/dist/extra/operators.d.cts +41 -1
  75. package/dist/extra/operators.d.ts +41 -1
  76. package/dist/extra/operators.js +1 -1
  77. package/dist/extra/reactive.cjs +1 -1
  78. package/dist/extra/reactive.d.cts +1 -1
  79. package/dist/extra/reactive.d.ts +1 -1
  80. package/dist/extra/reactive.js +1 -1
  81. package/dist/extra/sources.cjs +1 -1
  82. package/dist/extra/sources.d.cts +62 -2
  83. package/dist/extra/sources.d.ts +62 -2
  84. package/dist/extra/sources.js +1 -1
  85. package/dist/extra/storage-browser.cjs +1 -1
  86. package/dist/extra/storage-browser.js +1 -1
  87. package/dist/{fallback-BaTS7vVY.d.cts → fallback-Cb3GH1O7.d.cts} +6 -14
  88. package/dist/{fallback-eOm3LNxP.d.ts → fallback-DRjJ_ZM8.d.ts} +6 -14
  89. package/dist/graph/index.cjs +4 -4
  90. package/dist/graph/index.js +1 -1
  91. package/dist/{index-ClB7TCfL.d.cts → index-BMe3pCom.d.cts} +1 -1
  92. package/dist/{index-Dljd76bC.d.ts → index-BXzl1NDD.d.ts} +1 -1
  93. package/dist/{index-ClgKmOHe.d.ts → index-Bd6oFZqO.d.ts} +223 -115
  94. package/dist/{index-BJHQUCZx.d.ts → index-CJymKyzT.d.ts} +81 -6
  95. package/dist/{index-D6ajK8Mh.d.cts → index-CZChc85Q.d.cts} +223 -115
  96. package/dist/{index-BXbQUn4n.d.ts → index-CcS0t-l2.d.ts} +1 -1
  97. package/dist/{index-B2HBxvMb.d.ts → index-CwhcFzTA.d.ts} +1 -1
  98. package/dist/{index-B8Aj_z8S.d.cts → index-D-kHVedZ.d.cts} +1 -1
  99. package/dist/{index-ybtSyjWB.d.cts → index-DD7RhHNJ.d.cts} +1 -1
  100. package/dist/{index-BHu_Wba0.d.cts → index-Dm3_D5Ta.d.cts} +1 -1
  101. package/dist/{index-Cc8VQIgL.d.ts → index-DxMS0cHM.d.ts} +1 -1
  102. package/dist/{index-BS220yqj.d.cts → index-gJQqJTKx.d.cts} +81 -6
  103. package/dist/index.cjs +99 -121
  104. package/dist/index.d.cts +14 -13
  105. package/dist/index.d.ts +14 -13
  106. package/dist/index.js +1 -1
  107. package/dist/patterns/ai/browser.cjs +5 -22
  108. package/dist/patterns/ai/browser.d.cts +3 -3
  109. package/dist/patterns/ai/browser.d.ts +3 -3
  110. package/dist/patterns/ai/browser.js +1 -1
  111. package/dist/patterns/ai/index.cjs +27 -44
  112. package/dist/patterns/ai/index.d.cts +9 -7
  113. package/dist/patterns/ai/index.d.ts +9 -7
  114. package/dist/patterns/ai/index.js +1 -1
  115. package/dist/patterns/ai/node.cjs +2 -2
  116. package/dist/patterns/ai/node.d.cts +5 -4
  117. package/dist/patterns/ai/node.d.ts +5 -4
  118. package/dist/patterns/ai/node.js +1 -1
  119. package/dist/patterns/audit/index.cjs +3 -3
  120. package/dist/patterns/audit/index.js +1 -1
  121. package/dist/patterns/cqrs/index.cjs +6 -6
  122. package/dist/patterns/cqrs/index.js +1 -1
  123. package/dist/patterns/demo-shell/index.cjs +1 -1
  124. package/dist/patterns/demo-shell/index.js +1 -1
  125. package/dist/patterns/domain-templates/index.cjs +4 -4
  126. package/dist/patterns/domain-templates/index.js +1 -1
  127. package/dist/patterns/graphspec/index.cjs +6 -6
  128. package/dist/patterns/graphspec/index.d.cts +2 -2
  129. package/dist/patterns/graphspec/index.d.ts +2 -2
  130. package/dist/patterns/graphspec/index.js +1 -1
  131. package/dist/patterns/guarded-execution/index.cjs +7 -7
  132. package/dist/patterns/guarded-execution/index.js +1 -1
  133. package/dist/patterns/harness/index.cjs +11 -11
  134. package/dist/patterns/harness/index.d.cts +2 -2
  135. package/dist/patterns/harness/index.d.ts +2 -2
  136. package/dist/patterns/harness/index.js +1 -1
  137. package/dist/patterns/job-queue/index.cjs +5 -5
  138. package/dist/patterns/job-queue/index.js +1 -1
  139. package/dist/patterns/lens/index.cjs +5 -5
  140. package/dist/patterns/lens/index.d.cts +2 -2
  141. package/dist/patterns/lens/index.d.ts +2 -2
  142. package/dist/patterns/lens/index.js +1 -1
  143. package/dist/patterns/memory/index.cjs +4 -4
  144. package/dist/patterns/memory/index.js +1 -1
  145. package/dist/patterns/messaging/index.cjs +5 -5
  146. package/dist/patterns/messaging/index.js +1 -1
  147. package/dist/patterns/orchestration/index.cjs +1 -1
  148. package/dist/patterns/orchestration/index.js +1 -1
  149. package/dist/patterns/reactive-layout/index.cjs +1 -1
  150. package/dist/patterns/reactive-layout/index.js +1 -1
  151. package/dist/patterns/reduction/index.cjs +5 -5
  152. package/dist/patterns/reduction/index.js +1 -1
  153. package/dist/patterns/refine-loop/index.cjs +8 -8
  154. package/dist/patterns/refine-loop/index.js +1 -1
  155. package/dist/patterns/resilient-pipeline/index.cjs +1 -1
  156. package/dist/patterns/resilient-pipeline/index.js +1 -1
  157. package/dist/patterns/surface/index.cjs +7 -7
  158. package/dist/patterns/surface/index.d.cts +3 -3
  159. package/dist/patterns/surface/index.d.ts +3 -3
  160. package/dist/patterns/surface/index.js +1 -1
  161. package/dist/{reactive-map-BvDrRuwt.d.ts → reactive-map-CtRaCddO.d.ts} +59 -1
  162. package/dist/{reactive-map-CmlPPKHN.d.cts → reactive-map-IJIfZxoh.d.cts} +59 -1
  163. package/dist/{resilience-XRUF267O.js → resilience-IVNDYORD.js} +1 -1
  164. package/dist/{types-O3GzJY2U.d.cts → types-BgMqbc7N.d.cts} +41 -14
  165. package/dist/{types-u64Ose53.d.ts → types-CdfO2QTt.d.ts} +41 -14
  166. package/package.json +1 -1
  167. package/dist/chunk-2GQREQ6C.js +0 -1
  168. package/dist/chunk-4C2OR2GH.js +0 -18
  169. package/dist/chunk-5JDE5JHE.js +0 -1
  170. package/dist/chunk-7JDLFI6N.js +0 -1
  171. package/dist/chunk-AMBYCIOH.js +0 -3
  172. package/dist/chunk-ISCENNXS.js +0 -1
  173. package/dist/chunk-IUK4EFCE.js +0 -1
  174. package/dist/chunk-KASHOCF5.js +0 -1
  175. package/dist/chunk-LI3E75VE.js +0 -64
  176. package/dist/chunk-MGKAO4EK.js +0 -7
  177. package/dist/chunk-NSG4C6BF.js +0 -23
  178. package/dist/chunk-VIEUJSTT.js +0 -1
@@ -1,4 +1,4 @@
1
- "use strict";var Je=Object.defineProperty;var ln=Object.getOwnPropertyDescriptor;var fn=Object.getOwnPropertyNames;var pn=Object.prototype.hasOwnProperty;var K=(t,e)=>()=>(t&&(e=t(t=0)),e);var hn=(t,e)=>{for(var n in e)Je(t,n,{get:e[n],enumerable:!0})},gn=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of fn(e))!pn.call(t,s)&&s!==n&&Je(t,s,{get:()=>e[s],enumerable:!(r=ln(e,s))||r.enumerable});return t};var mn=t=>gn(Je({},"__esModule",{value:!0}),t);function ke(){return le>0||_e}function yt(){return le>0}function xe(t){le>0?we.push(t):t()}function Se(t){le+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(le-=1,le===0)if(e){if(!_e){let n=we.splice(0);for(let r of n)try{r()}catch{}ie.length=0,ae.length=0,fe.length=0}}else bn()}}function bn(){let t=!_e;t&&(_e=!0);let e=[],n=0;try{for(;ie.length>0||ae.length>0||fe.length>0||t&&we.length>0;){if(t&&we.length>0){let o=we.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw ie.length=0,ae.length=0,fe.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(ie.length>0?ie:ae.length>0?ae:fe).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{t&&(_e=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Re(t,e,n){if(e.length===0)return;if(e.length===1){let u=n(e[0][0]);if(u<3||!ke()){t(e);return}(u>=5?fe:u===4?ae:ie).push(()=>t(e));return}let r=e.length,s=r,o=r,i=r,a=0;for(;a<r&&n(e[a][0])<3;)a++;for(s=a;a<r&&n(e[a][0])===3;)a++;for(o=a;a<r&&n(e[a][0])===4;)a++;i=a;let c=ke();if(s>0){let u=e.slice(0,s);t(u)}if(o>s){let u=e.slice(s,o);c?ie.push(()=>t(u)):t(u)}if(i>o){let u=e.slice(o,i);c?ae.push(()=>t(u)):t(u)}if(r>i){let u=e.slice(i,r);c?fe.push(()=>t(u)):t(u)}}var le,_e,ie,ae,fe,we,De=K(()=>{"use strict";le=0,_e=!1,ie=[],ae=[],fe=[],we=[]});var Te,$,Z,F,J,Q,te,j,H,M,pe,Xe,yn,Ze,vn,_n,Qe,vt,_t,wt,et,Oe=K(()=>{"use strict";Te=Symbol.for("graphrefly/START"),$=Symbol.for("graphrefly/DATA"),Z=Symbol.for("graphrefly/DIRTY"),F=Symbol.for("graphrefly/RESOLVED"),J=Symbol.for("graphrefly/INVALIDATE"),Q=Symbol.for("graphrefly/PAUSE"),te=Symbol.for("graphrefly/RESUME"),j=Symbol.for("graphrefly/TEARDOWN"),H=Symbol.for("graphrefly/COMPLETE"),M=Symbol.for("graphrefly/ERROR"),pe=Object.freeze([Z]),Xe=Object.freeze([F]),yn=Object.freeze([J]),Ze=Object.freeze([Te]),vn=Object.freeze([H]),_n=Object.freeze([j]),Qe=Object.freeze([pe]),vt=Object.freeze([Xe]),_t=Object.freeze([yn]),wt=Object.freeze([vn]),et=Object.freeze([_n])});function Tt(t,e){let n=new TextEncoder().encode(t.name);if(n.length===0||n.length>255)throw new Error(`encodeEnvelope: codec name "${t.name}" encodes to ${n.length} bytes (must be 1\u2013255)`);let r=t.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let s=2+n.length+2+e.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let o=new Uint8Array(s),i=0;return o[i++]=tt,o[i++]=n.length,o.set(n,i),i+=n.length,o[i++]=r>>>8&255,o[i++]=r&255,o.set(e,i),o}function Ot(t,e){if(t.length<xt)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${xt})`);let n=0,r=t[n++];if(r!==tt)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${tt})`);let s=t[n++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(n+s+2>t.length)throw new Error(`decodeEnvelope: envelope truncated (need ${n+s+2} bytes, have ${t.length})`);let o=new TextDecoder().decode(t.subarray(n,n+s));n+=s;let i=(t[n]<<8|t[n+1])>>>0;n+=2;let a=t.subarray(n),c=e.lookupCodec(o);if(c==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:c,codecVersion:i,payload:a}}function Nt(t){t.registerCodec(wn)}var wn,tt,xt,nt=K(()=>{"use strict";wn={name:"json",version:1,contentType:"application/json",encode(t){let e=JSON.stringify(t);return new TextEncoder().encode(e)},decode(t,e){let n=new TextDecoder().decode(t);return JSON.parse(n)}},tt=1,xt=4});function Ae(t){if(t==null)return he;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var he,rt=K(()=>{"use strict";he={type:"system",id:""}});function ge(){return Math.trunc(performance.now()*1e6)}function Ce(){return Date.now()*1e6}var st=K(()=>{"use strict"});function Et(t){t.registerMessageType(Te,{tier:0,wireCrossing:!1}),t.registerMessageType(Z,{tier:1,wireCrossing:!1}),t.registerMessageType(J,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(Q,{tier:2,wireCrossing:!1}),t.registerMessageType(te,{tier:2,wireCrossing:!1}),t.registerMessageType($,{tier:3,wireCrossing:!0}),t.registerMessageType(F,{tier:3,wireCrossing:!0}),t.registerMessageType(H,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(M,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(j,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Me,kt=K(()=>{"use strict";Oe();Me=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=n=>{let r=this._messageTypes.get(n);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,n){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:n.tier,wireCrossing:n.wireCrossing??n.tier>=3,metaPassthrough:n.metaPassthrough??!0}),this}messageTier(e){let n=this._messageTypes.get(e);return n!=null?n.tier:1}isWireCrossing(e){let n=this._messageTypes.get(e);return n!=null?n.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let n=this._messageTypes.get(e);return n!=null?n.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function ot(t){let e=xn.filter(n=>t({type:n,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(n=>n==="human"||n==="llm"||n==="system")?"both":e.length===1?e[0]:e.join("+")}var q,xn,Ge=K(()=>{"use strict";q=class extends Error{actor;action;nodeName;constructor(e,n){super(n??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}},xn=["human","llm","wallet","system"]});function it(t){if(t===void 0)return null;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Cannot hash non-finite number: ${t}`);if(Number.isInteger(t)&&!Number.isSafeInteger(t))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${t}. Cross-language cid parity is not guaranteed for unsafe integers.`);return t}if(typeof t=="string"||typeof t=="boolean"||t===null)return t;if(Array.isArray(t))return t.map(it);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=it(t[n]);return e}return null}function Nn(t){let e=On.encode(t),n=e.length,r=n*8,s=n+9+63&-64,o=new Uint8Array(s);o.set(e),o[n]=128;let i=new DataView(o.buffer);i.setUint32(s-4,r>>>0,!1),i.setUint32(s-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,c=3144134277,u=1013904242,d=2773480762,p=1359893119,h=2600822924,f=528734635,l=1541459225,g=new Uint32Array(64),b=(x,m)=>x>>>m|x<<32-m;for(let x=0;x<s;x+=64){for(let k=0;k<16;k++)g[k]=i.getUint32(x+k*4,!1);for(let k=16;k<64;k++){let R=g[k-15],S=g[k-2],I=b(R,7)^b(R,18)^R>>>3,V=b(S,17)^b(S,19)^S>>>10;g[k]=g[k-16]+I+g[k-7]+V>>>0}let m=a,v=c,_=u,y=d,T=p,O=h,N=f,D=l;for(let k=0;k<64;k++){let R=b(T,6)^b(T,11)^b(T,25),S=T&O^~T&N,I=D+R+S+Tn[k]+g[k]>>>0,V=b(m,2)^b(m,13)^b(m,22),Y=m&v^m&_^v&_,oe=V+Y>>>0;D=N,N=O,O=T,T=y+I>>>0,y=_,_=v,v=m,m=I+oe>>>0}a=a+m>>>0,c=c+v>>>0,u=u+_>>>0,d=d+y>>>0,p=p+T>>>0,h=h+O>>>0,f=f+N>>>0,l=l+D>>>0}let w=x=>x.toString(16).padStart(8,"0");return w(a)+w(c)+w(u)+w(d)+w(p)+w(h)+w(f)+w(l)}function at(t){let e=it(t??null),n=JSON.stringify(e);return Nn(n).slice(0,16)}function En(){let t=globalThis.crypto;if(t?.randomUUID)return t.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),n=e()+e()+e()+e();return`${n.slice(0,8)}-${n.slice(8,12)}-4${n.slice(13,16)}-${(parseInt(n.slice(16,17),16)&3|8).toString(16)}${n.slice(17,20)}-${n.slice(20,32)}`}function ut(t,e,n){let r=n?.id??En();if(t===0)return{id:r,version:0};let o=(n?.hash??at)(e);return{id:r,version:0,cid:o,prev:null}}function St(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var Tn,On,Rt=K(()=>{"use strict";Tn=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]),On=new TextEncoder});function Ct(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function ct(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function Ie(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function X(t,e,n){let r=Mt(t)?t:[],s=typeof t=="function"?t:typeof e=="function"?e:void 0,o={};return Mt(t)?o=(dt(e)?e:n)??{}:dt(t)?o=t:o=(dt(e)?e:n)??{},new L(r,s,o)}var Dt,At,kn,Sn,me,L,Mt,dt,be=K(()=>{"use strict";nt();rt();De();st();kt();Ge();Oe();Rt();Dt=()=>{},At=100;kn=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},Sn=(t,e,n,r)=>{let s=t;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[Ze]:[Ze,[$,o]];s._status==="dirty"&&i.push(pe),Re(e,i,s._config.tierOf)},me=new Me({onMessage:kn,onSubscribe:Sn});Et(me);Nt(me);L=class t{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,n,r){this._config=r.config??me,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=n,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??at;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?ut(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Ct);let o={};for(let[a,c]of Object.entries(r.meta??{})){let u={initial:c,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(u.guard=r.guard),o[a]=new t([],void 0,u)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[$,a]])},down(a){i._emit(Ie(a))},up(a){i._emitUp(Ie(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let s=n?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??n?.id,c=i?.version??0,u=ut(e,o,{id:a,hash:s});u.version=c,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=Ae(e);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(n,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let n=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!n&&!r)return;let s=Ae(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new q({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new q({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:Ce()}}down(e,n){let r=Ie(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[$,e]])}up(e,n){if(this._deps.length===0)return;let r=Ie(e);if(r.length===0)return;this._checkGuard(n);let s=n??{internal:!0};this._validateUpTiers(r);for(let o of this._deps)o.node.up?.(r,s)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let n of this._deps)n.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let n=this._config.tierOf;for(let r of e){let s=n(r[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,n){if(n!=null&&this._guard!=null){let c=Ae(n);if(!this._guard(c,"observe"))throw new q({actor:c,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let c of this._deps)ct(c);if(this._partial===!1){for(let c of this._deps)if(c.prevData!==void 0||c.dataBatch.length!==0||c.terminal!==void 0||c.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(c){throw this._sinkCount-=1,c}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(c){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw c}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[n]=this._sinks;this._sinks=n}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,n=0;try{for(let r=0;r<e;r++){let s=r,o=this._deps[r];o.unsub=Dt,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,c=!1;for(let u of i)a(u[0])>=3&&(c=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:s},this._actions);c&&this._maybeRunFnOnSettlement()}),n++}}catch(r){this._deps[n].unsub=null;for(let s=0;s<n;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}ct(o)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let n=this._deps.length,r=Ct(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Qe),r.unsub=Dt;try{r.unsub=e.subscribe(s=>{if(r.unsub===null)return;let o=this._config.tierOf,i=!1;for(let a of s)o(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(r){this._emit([[M,this._wrapFnError("cleanup threw",r)]])}else if(n!=null&&typeof n=="object"){let r=n.deactivate;if(typeof r=="function")try{r()}catch(s){this._emit([[M,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let r of this._deps){if(r.unsub!=null){let s=r.unsub;r.unsub=null;try{s()}catch{}}ct(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,n){let r=this._deps[e],s=n[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:n};for(let i of this._inspectorHooks)i(o)}if(s!==Te){if(s===Z){this._depDirtied(r);return}if(s===J){this._depInvalidated(r),this._emit(_t);return}if(s===Q||s===te){this._emit([n]);return}if(s===j){this._emit(et);return}if(s===$)this._depSettledAsData(r,n[1]);else if(s===F)this._depSettledAsResolved(r);else if(s===H)this._depSettledAsTerminal(r,!0);else if(s===M)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(s===$||s===F)&&this._emit([n]),(s===H||s===M)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Qe))}_depSettledAsData(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=n,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let n=this._deps[e];if(n.dataBatch.length===0&&n.prevData===void 0&&n.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(vt),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(e!=null){this._autoError&&this._emit([[M,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(wt)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[M,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[M,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let n=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=n[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let s=this._deps.map(i=>i.terminal),o={prevData:r,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:n,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(n,this._actions,o);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[M,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>At?(this._rerunDepth=0,this._emit([[M,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${At} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,n){let r=n instanceof Error?n.message:String(n);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:n})}_frameBatch(e){let n=this._config.tierOf;if(e.length===1)return n(e[0][0])===3&&this._status!=="dirty"?[pe,e[0]]:e;let r=!0,s=!1,o=!1,i=-1;for(let c of e){let u=n(c[0]);u<i&&(r=!1),u===3&&(s=!0),c[0]===Z&&(o=!0),i=u}let a=e;if(!r){let c=e.map((u,d)=>({m:u,i:d,tier:n(u[0])}));c.sort((u,d)=>u.tier-d.tier||u.i-d.i),a=c.map(u=>u.m)}if(s&&!o&&this._status!=="dirty"){let c=0;for(;c<a.length&&n(a[c][0])===0;)c++;return c===0?[pe,...a]:[...a.slice(0,c),pe,...a.slice(c)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let c=e[a];if(c[0]===M&&c[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let n=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(c=>c[0]===j||c[0]===J);if(a.length===0)return;n=a}n=this._frameBatch(n);let s=null;for(let a=0;a<n.length;a++){let c=n[a],u=c[0];if(u!==Q&&u!==te){s?.push(c);continue}if(c.length<2)throw new Error(`Node "${this.name}": [[${u===Q?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let d=!0;if(this._pausable!==!1){let p=c[1];if(u===Q)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(p),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(p))d=!1;else if(this._pauseLocks.delete(p),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let h=this._pauseBuffer;this._pauseBuffer=[],this._emit(h)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}d?s?.push(c):s==null&&(s=n.slice(0,a))}if(s!=null){if(s.length===0)return;n=s}if(this._hasMeta&&n.some(a=>a[0]===j))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(et)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(n);if(o.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,c=[];for(let u of o)a(u[0])===3?this._pauseBuffer.push(u):c.push(u);c.length>0&&this._dispatchOrAccumulate(c)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[M,i]])}_updateState(e){let n=this._config.tierOf,r,s,o=-1,i=0;for(let d of e)n(d[0])===3&&i++;let a=i<=1,c=-1;if(this._versioning!=null&&i>1){for(let d=e.length-1;d>=0;d--)if(e[d][0]===$){c=d;break}}for(let d=0;d<e.length;d++){let p=e[d],h=p[0];if(h===$){if(p.length>=2){let f=!1;if(a&&this._cached!==void 0)try{f=this._equals(this._cached,p[1])}catch(l){s=this._wrapFnError("equals threw",l),o=d;break}if(f){r==null&&(r=e.slice(0,d)),r.push(Xe),this._status="resolved";continue}this._cached=p[1],this._versioning!=null&&(c<0||d===c)&&St(this._versioning,p[1],this._hashFn)}this._status="settled",r?.push(p)}else if(r?.push(p),h===Z)this._status="dirty";else if(h===F)this._status="resolved";else if(h===H)this._status="completed";else if(h===M)this._status="errored";else if(h===J){this._cached=void 0,this._status="dirty";let f=this._cleanup;if(typeof f=="function"){this._cleanup=void 0;try{f()}catch{}}else if(f!=null&&typeof f=="object"){let l=f.invalidate;if(typeof l=="function")try{l()}catch{}}}else h===j&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=o>=0?r??e.slice(0,o):r??e;return s!=null?{finalMessages:u,equalsError:s}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let n=[...this._sinks];for(let r of n)r(e)};_dispatchOrAccumulate(e){if(yt()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],xe(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}Re(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let n=this._frameBatch(e);Re(this._deliverToSinks,n,this._config.tierOf)}},Mt=t=>Array.isArray(t),dt=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function ue(t,e){return X([],{...e,initial:t})}function Gt(t,e){return X((r,s,o)=>t(s,o)??void 0,{describeKind:"producer",...e})}function ce(t,e,n){return X(t,(s,o,i)=>{let a=s.map((c,u)=>c!=null&&c.length>0?c.at(-1):i.prevData[u]);o.emit(e(a,i))},{describeKind:"derived",...n})}var lt=K(()=>{"use strict";be()});function pt(t){return t.subscribe(()=>{})}var It=K(()=>{"use strict"});var Pe,Lt=K(()=>{"use strict";Pe=class{_timer;_gen=0;start(e,n){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&n()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var Lr={};hn(Lr,{approval:()=>Rr,branch:()=>Sr,gate:()=>Dr,join:()=>Ar,loop:()=>Cr,onFailure:()=>Ir,pipeline:()=>dn,sensor:()=>Gr,subPipeline:()=>Mr,task:()=>kr});module.exports=mn(Lr);De();Oe();be();lt();rt();De();st();Ge();Oe();Ge();be();function Le(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 Rn(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function Dn(t){let e={};for(let[n,r]of Object.entries(t.meta))try{e[n]=r.cache}catch{}return e}function ft(t,e){let n=e==null,r=!n&&e!=null?[...e].filter(u=>u.startsWith("meta.")).map(u=>u.slice(5)):null,s=n||e.has("meta")||r!=null&&r.length>0,o="state",i=[];t instanceof L&&(o=Rn(t),i=t._deps.map(u=>u.node.name??""));let a={type:o,deps:i};(n||e.has("status"))&&(a.status=t.status);let c=t instanceof L?t._guard:void 0;if(s){let u={...Dn(t)};if(c!=null&&u.access===void 0&&(u.access=ot(c)),r!=null&&r.length>0&&!e.has("meta")){let d={};for(let p of r)p in u&&(d[p]=u[p]);a.meta=d}else a.meta=u}if(t.name!=null&&(a.name=t.name),n||e.has("value")){t.status==="sentinel"&&(a.sentinel=!0);try{a.value=t.cache}catch{}}if((n||e.has("v"))&&t.v!=null){let u={id:t.v.id,version:t.v.version};"cid"in t.v&&(u.cid=t.v.cid,u.prev=t.v.prev),a.v=u}return(n||e.has("guard"))&&c!=null&&(a.guard=ot(c)),(n||e.has("lastMutation"))&&t.lastMutation!=null&&(a.lastMutation=t.lastMutation),a}be();lt();It();Lt();var Ne=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let n=(this.head+this._size)%this.capacity;this.buf[n]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let n=e<0?this._size+e:e;if(!(n<0||n>=this._size))return this.buf[(this.head+n)%this.capacity]}toArray(){let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this.buf[(this.head+n)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}};nt();function ht(t){return t>=768&&t<=879||t>=1155&&t<=1161||t>=1425&&t<=1469||t>=1552&&t<=1562||t>=1611&&t<=1631||t>=1648&&t===1648||t>=1750&&t<=1756||t>=1759&&t<=1764||t>=1767&&t<=1768||t>=1770&&t<=1773||t>=1840&&t<=1866||t>=1958&&t<=1968||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2641||t>=2672&&t<=2673||t>=2677&&t===2677||t>=3633&&t===3633||t>=3636&&t<=3642||t>=3655&&t<=3662||t>=3761&&t===3761||t>=3764&&t<=3772||t>=3784&&t<=3790||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65024&&t<=65039||t>=65056&&t<=65071||t===8205?0:t>=4352&&t<=4447||t>=8986&&t<=8987||t>=9001&&t<=9002||t>=9193&&t<=9203||t>=9208&&t<=9210||t>=9725&&t<=9726||t>=9748&&t<=9749||t>=9800&&t<=9811||t===9855||t===9875||t===9889||t>=9898&&t<=9899||t>=9917&&t<=9918||t>=9924&&t<=9925||t===9934||t===9940||t===9962||t>=9970&&t<=9971||t===9973||t===9978||t===9981||t===9986||t===9989||t>=9992&&t<=9997||t===9999||t>=10067&&t<=10069||t===10071||t>=10133&&t<=10135||t===10160||t===10175||t>=10548&&t<=10549||t>=11013&&t<=11015||t>=11035&&t<=11036||t===11088||t===11093||t>=11904&&t<=12350||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12784&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=19968&&t<=40959||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65131||t>=65281&&t<=65376||t>=65504&&t<=65510||t>=126980&&t===126980||t===127183||t>=127344&&t<=127345||t===127358||t===127359||t===127374||t>=127377&&t<=127386||t>=127456&&t<=127487||t>=127488&&t<=127490||t===127514||t===127535||t>=127538&&t<=127546||t>=127568&&t<=127569||t>=127744&&t<=129535||t>=129536&&t<=129791||t>=129792&&t<=130047||t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}function $e(t){let e=0;for(let n of t)e+=ht(n.codePointAt(0));return e}function Pt(t,e){if(e<=0)return"";let n=0,r="";for(let s of t){let o=ht(s.codePointAt(0));if(n+o>e){if(e<=1)return"\u2026";for(;n+1>e&&r.length>0;){let i=[...r].pop();r=r.slice(0,-i.length),n-=ht(i.codePointAt(0))}return`${r}\u2026`}r+=s,n+=o}return r}var An={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"},Cn={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function Bt(t,e){let n=e.charset==="ascii"?Cn:An,r=t.width,s=t.height,o=Array.from({length:s},()=>Array.from({length:r},()=>" ")),i=Array.from({length:s},()=>Array.from({length:r},()=>"empty"));for(let a of t.edges)Gn(o,i,n,a);for(let a of t.boxes)Mn(o,i,n,a,e.labelOf(a.id));return o.map(a=>$n(a.join(""))).join(`
1
+ "use strict";var Je=Object.defineProperty;var ln=Object.getOwnPropertyDescriptor;var fn=Object.getOwnPropertyNames;var pn=Object.prototype.hasOwnProperty;var K=(t,e)=>()=>(t&&(e=t(t=0)),e);var hn=(t,e)=>{for(var n in e)Je(t,n,{get:e[n],enumerable:!0})},gn=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of fn(e))!pn.call(t,s)&&s!==n&&Je(t,s,{get:()=>e[s],enumerable:!(r=ln(e,s))||r.enumerable});return t};var mn=t=>gn(Je({},"__esModule",{value:!0}),t);function ke(){return le>0||_e}function yt(){return le>0}function xe(t){le>0?we.push(t):t()}function Se(t){le+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(le-=1,le===0)if(e){if(!_e){let n=we.splice(0);for(let r of n)try{r()}catch{}ie.length=0,ae.length=0,fe.length=0}}else bn()}}function bn(){let t=!_e;t&&(_e=!0);let e=[],n=0;try{for(;ie.length>0||ae.length>0||fe.length>0||t&&we.length>0;){if(t&&we.length>0){let o=we.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw ie.length=0,ae.length=0,fe.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(ie.length>0?ie:ae.length>0?ae:fe).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{t&&(_e=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function Re(t,e,n){if(e.length===0)return;if(e.length===1){let u=n(e[0][0]);if(u<3||!ke()){t(e);return}(u>=5?fe:u===4?ae:ie).push(()=>t(e));return}let r=e.length,s=r,o=r,i=r,a=0;for(;a<r&&n(e[a][0])<3;)a++;for(s=a;a<r&&n(e[a][0])===3;)a++;for(o=a;a<r&&n(e[a][0])===4;)a++;i=a;let c=ke();if(s>0){let u=e.slice(0,s);t(u)}if(o>s){let u=e.slice(s,o);c?ie.push(()=>t(u)):t(u)}if(i>o){let u=e.slice(o,i);c?ae.push(()=>t(u)):t(u)}if(r>i){let u=e.slice(i,r);c?fe.push(()=>t(u)):t(u)}}var le,_e,ie,ae,fe,we,De=K(()=>{"use strict";le=0,_e=!1,ie=[],ae=[],fe=[],we=[]});var Te,$,Z,F,J,Q,te,j,H,M,pe,Xe,yn,Ze,vn,_n,Qe,vt,_t,wt,et,Oe=K(()=>{"use strict";Te=Symbol.for("graphrefly/START"),$=Symbol.for("graphrefly/DATA"),Z=Symbol.for("graphrefly/DIRTY"),F=Symbol.for("graphrefly/RESOLVED"),J=Symbol.for("graphrefly/INVALIDATE"),Q=Symbol.for("graphrefly/PAUSE"),te=Symbol.for("graphrefly/RESUME"),j=Symbol.for("graphrefly/TEARDOWN"),H=Symbol.for("graphrefly/COMPLETE"),M=Symbol.for("graphrefly/ERROR"),pe=Object.freeze([Z]),Xe=Object.freeze([F]),yn=Object.freeze([J]),Ze=Object.freeze([Te]),vn=Object.freeze([H]),_n=Object.freeze([j]),Qe=Object.freeze([pe]),vt=Object.freeze([Xe]),_t=Object.freeze([yn]),wt=Object.freeze([vn]),et=Object.freeze([_n])});function Tt(t,e){let n=new TextEncoder().encode(t.name);if(n.length===0||n.length>255)throw new Error(`encodeEnvelope: codec name "${t.name}" encodes to ${n.length} bytes (must be 1\u2013255)`);let r=t.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let s=2+n.length+2+e.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let o=new Uint8Array(s),i=0;return o[i++]=tt,o[i++]=n.length,o.set(n,i),i+=n.length,o[i++]=r>>>8&255,o[i++]=r&255,o.set(e,i),o}function Ot(t,e){if(t.length<xt)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${xt})`);let n=0,r=t[n++];if(r!==tt)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${tt})`);let s=t[n++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(n+s+2>t.length)throw new Error(`decodeEnvelope: envelope truncated (need ${n+s+2} bytes, have ${t.length})`);let o=new TextDecoder().decode(t.subarray(n,n+s));n+=s;let i=(t[n]<<8|t[n+1])>>>0;n+=2;let a=t.subarray(n),c=e.lookupCodec(o);if(c==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:c,codecVersion:i,payload:a}}function Nt(t){t.registerCodec(wn)}var wn,tt,xt,nt=K(()=>{"use strict";wn={name:"json",version:1,contentType:"application/json",encode(t){let e=JSON.stringify(t);return new TextEncoder().encode(e)},decode(t,e){let n=new TextDecoder().decode(t);return JSON.parse(n)}},tt=1,xt=4});function Ae(t){if(t==null)return he;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var he,rt=K(()=>{"use strict";he={type:"system",id:""}});function ge(){return Math.trunc(performance.now()*1e6)}function Ce(){return Date.now()*1e6}var st=K(()=>{"use strict"});function Et(t){t.registerMessageType(Te,{tier:0,wireCrossing:!1}),t.registerMessageType(Z,{tier:1,wireCrossing:!1}),t.registerMessageType(J,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(Q,{tier:2,wireCrossing:!1}),t.registerMessageType(te,{tier:2,wireCrossing:!1}),t.registerMessageType($,{tier:3,wireCrossing:!0}),t.registerMessageType(F,{tier:3,wireCrossing:!0}),t.registerMessageType(H,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(M,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(j,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Me,kt=K(()=>{"use strict";Oe();Me=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=n=>{let r=this._messageTypes.get(n);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,n){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:n.tier,wireCrossing:n.wireCrossing??n.tier>=3,metaPassthrough:n.metaPassthrough??!0}),this}messageTier(e){let n=this._messageTypes.get(e);return n!=null?n.tier:1}isWireCrossing(e){let n=this._messageTypes.get(e);return n!=null?n.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let n=this._messageTypes.get(e);return n!=null?n.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function ot(t){let e=xn.filter(n=>t({type:n,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(n=>n==="human"||n==="llm"||n==="system")?"both":e.length===1?e[0]:e.join("+")}var q,xn,Ge=K(()=>{"use strict";q=class extends Error{actor;action;nodeName;constructor(e,n){super(n??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}},xn=["human","llm","wallet","system"]});function it(t){if(t===void 0)return null;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Cannot hash non-finite number: ${t}`);if(Number.isInteger(t)&&!Number.isSafeInteger(t))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${t}. Cross-language cid parity is not guaranteed for unsafe integers.`);return t}if(typeof t=="string"||typeof t=="boolean"||t===null)return t;if(Array.isArray(t))return t.map(it);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=it(t[n]);return e}return null}function Nn(t){let e=On.encode(t),n=e.length,r=n*8,s=n+9+63&-64,o=new Uint8Array(s);o.set(e),o[n]=128;let i=new DataView(o.buffer);i.setUint32(s-4,r>>>0,!1),i.setUint32(s-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,c=3144134277,u=1013904242,d=2773480762,p=1359893119,h=2600822924,f=528734635,l=1541459225,g=new Uint32Array(64),b=(x,m)=>x>>>m|x<<32-m;for(let x=0;x<s;x+=64){for(let k=0;k<16;k++)g[k]=i.getUint32(x+k*4,!1);for(let k=16;k<64;k++){let R=g[k-15],S=g[k-2],I=b(R,7)^b(R,18)^R>>>3,V=b(S,17)^b(S,19)^S>>>10;g[k]=g[k-16]+I+g[k-7]+V>>>0}let m=a,v=c,_=u,y=d,T=p,O=h,N=f,D=l;for(let k=0;k<64;k++){let R=b(T,6)^b(T,11)^b(T,25),S=T&O^~T&N,I=D+R+S+Tn[k]+g[k]>>>0,V=b(m,2)^b(m,13)^b(m,22),Y=m&v^m&_^v&_,oe=V+Y>>>0;D=N,N=O,O=T,T=y+I>>>0,y=_,_=v,v=m,m=I+oe>>>0}a=a+m>>>0,c=c+v>>>0,u=u+_>>>0,d=d+y>>>0,p=p+T>>>0,h=h+O>>>0,f=f+N>>>0,l=l+D>>>0}let w=x=>x.toString(16).padStart(8,"0");return w(a)+w(c)+w(u)+w(d)+w(p)+w(h)+w(f)+w(l)}function at(t){let e=it(t??null),n=JSON.stringify(e);return Nn(n).slice(0,16)}function En(){let t=globalThis.crypto;if(t?.randomUUID)return t.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),n=e()+e()+e()+e();return`${n.slice(0,8)}-${n.slice(8,12)}-4${n.slice(13,16)}-${(parseInt(n.slice(16,17),16)&3|8).toString(16)}${n.slice(17,20)}-${n.slice(20,32)}`}function ut(t,e,n){let r=n?.id??En();if(t===0)return{id:r,version:0};let o=(n?.hash??at)(e);return{id:r,version:0,cid:o,prev:null}}function St(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var Tn,On,Rt=K(()=>{"use strict";Tn=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]),On=new TextEncoder});function Ct(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function ct(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function Ie(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function X(t,e,n){let r=Mt(t)?t:[],s=typeof t=="function"?t:typeof e=="function"?e:void 0,o={};return Mt(t)?o=(dt(e)?e:n)??{}:dt(t)?o=t:o=(dt(e)?e:n)??{},new L(r,s,o)}var Dt,At,kn,Sn,me,L,Mt,dt,be=K(()=>{"use strict";nt();rt();De();st();kt();Ge();Oe();Rt();Dt=()=>{},At=100;kn=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},Sn=(t,e,n,r)=>{let s=t;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[Ze]:[Ze,[$,o]];s._status==="dirty"&&i.push(pe),Re(e,i,s._config.tierOf)},me=new Me({onMessage:kn,onSubscribe:Sn});Et(me);Nt(me);L=class t{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,n,r){this._config=r.config??me,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=n,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??at;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?ut(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Ct);let o={};for(let[a,c]of Object.entries(r.meta??{})){let u={initial:c,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(u.guard=r.guard),o[a]=new t([],void 0,u)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[$,a]])},down(a){i._emit(Ie(a))},up(a){i._emitUp(Ie(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let s=n?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??n?.id,c=i?.version??0,u=ut(e,o,{id:a,hash:s});u.version=c,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=Ae(e);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(n,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let n=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!n&&!r)return;let s=Ae(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new q({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new q({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:Ce()}}down(e,n){let r=Ie(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[$,e]])}up(e,n){if(this._deps.length===0)return;let r=Ie(e);if(r.length===0)return;this._checkGuard(n);let s=n??{internal:!0};this._validateUpTiers(r);for(let o of this._deps)o.node.up?.(r,s)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let n of this._deps)n.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let n=this._config.tierOf;for(let r of e){let s=n(r[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,n){if(n!=null&&this._guard!=null){let c=Ae(n);if(!this._guard(c,"observe"))throw new q({actor:c,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let c of this._deps)ct(c);if(this._partial===!1){for(let c of this._deps)if(c.prevData!==void 0||c.dataBatch.length!==0||c.terminal!==void 0||c.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(c){throw this._sinkCount-=1,c}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(c){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw c}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[n]=this._sinks;this._sinks=n}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,n=0;try{for(let r=0;r<e;r++){let s=r,o=this._deps[r];o.unsub=Dt,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,c=!1;for(let u of i)a(u[0])>=3&&(c=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:s},this._actions);c&&this._maybeRunFnOnSettlement()}),n++}}catch(r){this._deps[n].unsub=null;for(let s=0;s<n;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}ct(o)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let n=this._deps.length,r=Ct(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Qe),r.unsub=Dt;try{r.unsub=e.subscribe(s=>{if(r.unsub===null)return;let o=this._config.tierOf,i=!1;for(let a of s)o(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(r){this._emit([[M,this._wrapFnError("cleanup threw",r)]])}else if(n!=null&&typeof n=="object"){let r=n.deactivate;if(typeof r=="function")try{r()}catch(s){this._emit([[M,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let r of this._deps){if(r.unsub!=null){let s=r.unsub;r.unsub=null;try{s()}catch{}}ct(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,n){let r=this._deps[e],s=n[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:n};for(let i of this._inspectorHooks)i(o)}if(s!==Te){if(s===Z){this._depDirtied(r);return}if(s===J){if(this._depInvalidated(r),this._cached===void 0)return;this._emit(_t);return}if(s===Q||s===te){this._emit([n]);return}if(s===j){this._emit(et);return}if(s===$)this._depSettledAsData(r,n[1]);else if(s===F)this._depSettledAsResolved(r);else if(s===H)this._depSettledAsTerminal(r,!0);else if(s===M)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(s===$||s===F)&&this._emit([n]),(s===H||s===M)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(Qe))}_depSettledAsData(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=n,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let n=this._deps[e];if(n.dataBatch.length===0&&n.prevData===void 0&&n.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(vt),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(e!=null){this._autoError&&this._emit([[M,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(wt)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[M,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[M,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let n=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=n[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let s=this._deps.map(i=>i.terminal),o={prevData:r,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:n,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(n,this._actions,o);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[M,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>At?(this._rerunDepth=0,this._emit([[M,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${At} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,n){let r=n instanceof Error?n.message:String(n);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:n})}_frameBatch(e){let n=this._config.tierOf;if(e.length===1)return n(e[0][0])===3&&this._status!=="dirty"?[pe,e[0]]:e;let r=!0,s=!1,o=!1,i=-1;for(let c of e){let u=n(c[0]);u<i&&(r=!1),u===3&&(s=!0),c[0]===Z&&(o=!0),i=u}let a=e;if(!r){let c=e.map((u,d)=>({m:u,i:d,tier:n(u[0])}));c.sort((u,d)=>u.tier-d.tier||u.i-d.i),a=c.map(u=>u.m)}if(s&&!o&&this._status!=="dirty"){let c=0;for(;c<a.length&&n(a[c][0])===0;)c++;return c===0?[pe,...a]:[...a.slice(0,c),pe,...a.slice(c)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let c=e[a];if(c[0]===M&&c[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let n=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(c=>c[0]===j||c[0]===J);if(a.length===0)return;n=a}n=this._frameBatch(n);let s=null;for(let a=0;a<n.length;a++){let c=n[a],u=c[0];if(u!==Q&&u!==te){s?.push(c);continue}if(c.length<2)throw new Error(`Node "${this.name}": [[${u===Q?"PAUSE":"RESUME"}]] must carry a lockId payload \u2014 bare PAUSE/RESUME is a protocol violation (C0 rule). Use \`[[PAUSE, lockId]]\` / \`[[RESUME, lockId]]\`.`);let d=!0;if(this._pausable!==!1){let p=c[1];if(u===Q)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(p),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(p))d=!1;else if(this._pauseLocks.delete(p),this._pauseLocks.size===0){if(this._paused=!1,this._pauseBuffer!=null&&this._pauseBuffer.length>0){let h=this._pauseBuffer;this._pauseBuffer=[],this._emit(h)}this._pendingWave&&(this._pendingWave=!1,this._maybeRunFnOnSettlement())}}d?s?.push(c):s==null&&(s=n.slice(0,a))}if(s!=null){if(s.length===0)return;n=s}if(this._hasMeta&&n.some(a=>a[0]===j))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(et)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(n);if(o.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,c=[];for(let u of o)a(u[0])===3?this._pauseBuffer.push(u):c.push(u);c.length>0&&this._dispatchOrAccumulate(c)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[M,i]])}_updateState(e){let n=this._config.tierOf,r,s,o=-1,i=0;for(let d of e)n(d[0])===3&&i++;let a=i<=1,c=-1;if(this._versioning!=null&&i>1){for(let d=e.length-1;d>=0;d--)if(e[d][0]===$){c=d;break}}for(let d=0;d<e.length;d++){let p=e[d],h=p[0];if(h===$){if(p.length>=2){let f=!1;if(a&&this._cached!==void 0)try{f=this._equals(this._cached,p[1])}catch(l){s=this._wrapFnError("equals threw",l),o=d;break}if(f){r==null&&(r=e.slice(0,d)),r.push(Xe),this._status="resolved";continue}this._cached=p[1],this._versioning!=null&&(c<0||d===c)&&St(this._versioning,p[1],this._hashFn)}this._status="settled",r?.push(p)}else if(r?.push(p),h===Z)this._status="dirty";else if(h===F)this._status="resolved";else if(h===H)this._status="completed";else if(h===M)this._status="errored";else if(h===J){this._cached=void 0,this._status="dirty";let f=this._cleanup;if(typeof f=="function"){this._cleanup=void 0;try{f()}catch{}}else if(f!=null&&typeof f=="object"){let l=f.invalidate;if(typeof l=="function")try{l()}catch{}}}else h===j&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=o>=0?r??e.slice(0,o):r??e;return s!=null?{finalMessages:u,equalsError:s}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let n=[...this._sinks];for(let r of n)r(e)};_dispatchOrAccumulate(e){if(yt()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],xe(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}Re(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let n=this._frameBatch(e);Re(this._deliverToSinks,n,this._config.tierOf)}},Mt=t=>Array.isArray(t),dt=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function ue(t,e){return X([],{...e,initial:t})}function Gt(t,e){return X((r,s,o)=>t(s,o)??void 0,{describeKind:"producer",...e})}function ce(t,e,n){return X(t,(s,o,i)=>{let a=s.map((c,u)=>c!=null&&c.length>0?c.at(-1):i.prevData[u]);o.emit(e(a,i))},{describeKind:"derived",...n})}var lt=K(()=>{"use strict";be()});function pt(t){return t.subscribe(()=>{})}var It=K(()=>{"use strict"});var Pe,Lt=K(()=>{"use strict";Pe=class{_timer;_gen=0;start(e,n){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&n()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var Lr={};hn(Lr,{approval:()=>Rr,branch:()=>Sr,gate:()=>Dr,join:()=>Ar,loop:()=>Cr,onFailure:()=>Ir,pipeline:()=>dn,sensor:()=>Gr,subPipeline:()=>Mr,task:()=>kr});module.exports=mn(Lr);De();Oe();be();lt();rt();De();st();Ge();Oe();Ge();be();function Le(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 Rn(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function Dn(t){let e={};for(let[n,r]of Object.entries(t.meta))try{e[n]=r.cache}catch{}return e}function ft(t,e){let n=e==null,r=!n&&e!=null?[...e].filter(u=>u.startsWith("meta.")).map(u=>u.slice(5)):null,s=n||e.has("meta")||r!=null&&r.length>0,o="state",i=[];t instanceof L&&(o=Rn(t),i=t._deps.map(u=>u.node.name??""));let a={type:o,deps:i};(n||e.has("status"))&&(a.status=t.status);let c=t instanceof L?t._guard:void 0;if(s){let u={...Dn(t)};if(c!=null&&u.access===void 0&&(u.access=ot(c)),r!=null&&r.length>0&&!e.has("meta")){let d={};for(let p of r)p in u&&(d[p]=u[p]);a.meta=d}else a.meta=u}if(t.name!=null&&(a.name=t.name),n||e.has("value")){t.status==="sentinel"&&(a.sentinel=!0);try{a.value=t.cache}catch{}}if((n||e.has("v"))&&t.v!=null){let u={id:t.v.id,version:t.v.version};"cid"in t.v&&(u.cid=t.v.cid,u.prev=t.v.prev),a.v=u}return(n||e.has("guard"))&&c!=null&&(a.guard=ot(c)),(n||e.has("lastMutation"))&&t.lastMutation!=null&&(a.lastMutation=t.lastMutation),a}be();lt();It();Lt();var Ne=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let n=(this.head+this._size)%this.capacity;this.buf[n]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let n=e<0?this._size+e:e;if(!(n<0||n>=this._size))return this.buf[(this.head+n)%this.capacity]}toArray(){let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this.buf[(this.head+n)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}};nt();function ht(t){return t>=768&&t<=879||t>=1155&&t<=1161||t>=1425&&t<=1469||t>=1552&&t<=1562||t>=1611&&t<=1631||t>=1648&&t===1648||t>=1750&&t<=1756||t>=1759&&t<=1764||t>=1767&&t<=1768||t>=1770&&t<=1773||t>=1840&&t<=1866||t>=1958&&t<=1968||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2641||t>=2672&&t<=2673||t>=2677&&t===2677||t>=3633&&t===3633||t>=3636&&t<=3642||t>=3655&&t<=3662||t>=3761&&t===3761||t>=3764&&t<=3772||t>=3784&&t<=3790||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65024&&t<=65039||t>=65056&&t<=65071||t===8205?0:t>=4352&&t<=4447||t>=8986&&t<=8987||t>=9001&&t<=9002||t>=9193&&t<=9203||t>=9208&&t<=9210||t>=9725&&t<=9726||t>=9748&&t<=9749||t>=9800&&t<=9811||t===9855||t===9875||t===9889||t>=9898&&t<=9899||t>=9917&&t<=9918||t>=9924&&t<=9925||t===9934||t===9940||t===9962||t>=9970&&t<=9971||t===9973||t===9978||t===9981||t===9986||t===9989||t>=9992&&t<=9997||t===9999||t>=10067&&t<=10069||t===10071||t>=10133&&t<=10135||t===10160||t===10175||t>=10548&&t<=10549||t>=11013&&t<=11015||t>=11035&&t<=11036||t===11088||t===11093||t>=11904&&t<=12350||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12784&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=19968&&t<=40959||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65131||t>=65281&&t<=65376||t>=65504&&t<=65510||t>=126980&&t===126980||t===127183||t>=127344&&t<=127345||t===127358||t===127359||t===127374||t>=127377&&t<=127386||t>=127456&&t<=127487||t>=127488&&t<=127490||t===127514||t===127535||t>=127538&&t<=127546||t>=127568&&t<=127569||t>=127744&&t<=129535||t>=129536&&t<=129791||t>=129792&&t<=130047||t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}function $e(t){let e=0;for(let n of t)e+=ht(n.codePointAt(0));return e}function Pt(t,e){if(e<=0)return"";let n=0,r="";for(let s of t){let o=ht(s.codePointAt(0));if(n+o>e){if(e<=1)return"\u2026";for(;n+1>e&&r.length>0;){let i=[...r].pop();r=r.slice(0,-i.length),n-=ht(i.codePointAt(0))}return`${r}\u2026`}r+=s,n+=o}return r}var An={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"},Cn={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function Bt(t,e){let n=e.charset==="ascii"?Cn:An,r=t.width,s=t.height,o=Array.from({length:s},()=>Array.from({length:r},()=>" ")),i=Array.from({length:s},()=>Array.from({length:r},()=>"empty"));for(let a of t.edges)Gn(o,i,n,a);for(let a of t.boxes)Mn(o,i,n,a,e.labelOf(a.id));return o.map(a=>$n(a.join(""))).join(`
2
2
  `)}function Mn(t,e,n,r,s){let{x:o,y:i,w:a,h:c}=r;if(a<2||c<2){c>0&&$t(t,e,o,i,a,s);return}ne(t,e,o,i,n.boxTL);for(let d=o+1;d<o+a-1;d+=1)ne(t,e,d,i,n.boxH);ne(t,e,o+a-1,i,n.boxTR);for(let d=i+1;d<i+c-1;d+=1){ne(t,e,o,d,n.boxV);for(let p=o+1;p<o+a-1;p+=1)jt(t,e,p,d," ","empty");ne(t,e,o+a-1,d,n.boxV)}ne(t,e,o,i+c-1,n.boxBL);for(let d=o+1;d<o+a-1;d+=1)ne(t,e,d,i+c-1,n.boxH);ne(t,e,o+a-1,i+c-1,n.boxBR);let u=i+Math.floor(c/2);$t(t,e,o+1,u,a-2,s)}function ne(t,e,n,r,s){jt(t,e,n,r,s,s===" "?"empty":s==="\u2500"||s==="-"?"boxH":s==="\u2502"||s==="|"?"boxV":"boxCorner")}function jt(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];n<0||n>=i.length||(i[n]=s,e[r][n]=o)}function $t(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=n,a=s;for(let c of o){let u=$e(c);if(u!==0){if(a<u)break;i>=0&&i<t[r].length&&(t[r][i]=c,e[r][i]="label",u===2&&i+1<t[r].length&&(t[r][i+1]="",e[r][i+1]="label")),i+=u,a-=u}}for(;a>0;)i>=0&&i<t[r].length&&(t[r][i]=" ",e[r][i]="empty"),i+=1,a-=1}function Gn(t,e,n,r){let s=r.points;if(s.length<2)return;for(let c=0;c+1<s.length;c+=1)In(t,e,n,s[c],s[c+1]);for(let c=1;c+1<s.length;c+=1){let u=s[c-1],d=s[c],p=s[c+1],h=Ln(u,d,p,n);h&&Ht(t,e,d.x,d.y,h,"edgeCorner")}let o=s[s.length-1],i=s[s.length-2],a=Pn(i,o,n);a&&Ht(t,e,o.x,o.y,a,"arrow")}function In(t,e,n,r,s){if(!(r.x===s.x&&r.y===s.y)){if(r.y===s.y){let o=r.y,i=Math.min(r.x,s.x),a=Math.max(r.x,s.x);for(let c=i;c<=a;c+=1)Ft(t,e,c,o,n,"h")}else if(r.x===s.x){let o=r.x,i=Math.min(r.y,s.y),a=Math.max(r.y,s.y);for(let c=i;c<=a;c+=1)Ft(t,e,o,c,n,"v")}}}function Ft(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];if(!(a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label")){if(a==="empty"){i[n]=o==="h"?s.horizontal:s.vertical,e[r][n]=o==="h"?"edgeH":"edgeV";return}if(a==="edgeH"&&o==="v"){i[n]=s.cross,e[r][n]="edgeCorner";return}if(a==="edgeV"&&o==="h"){i[n]=s.cross,e[r][n]="edgeCorner";return}}}function Ht(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label"||(i[n]=s,e[r][n]=o)}function Ln(t,e,n,r){let s=t.y===e.y,o=e.y===n.y;if(s===o)return;if(s){let c=t.x<e.x,u=n.y>e.y;return c&&u?r.cornerTR:c&&!u?r.cornerBR:!c&&u?r.cornerTL:r.cornerBL}let i=t.y<e.y,a=n.x>e.x;return i&&a?r.cornerBL:i&&!a?r.cornerBR:!i&&a?r.cornerTL:r.cornerTR}function Pn(t,e,n){if(e.x>t.x)return n.arrowRight;if(e.x<t.x)return n.arrowLeft;if(e.y>t.y)return n.arrowDown;if(e.y<t.y)return n.arrowUp}function $n(t){let e=t.length;for(;e>0&&t.charCodeAt(e-1)===32;)e-=1;return t.slice(0,e)}function Ut(t){let e=Fn(t);Hn(e),Bn(e),jn(e),Vn(e,t);let n=Wn(e,t),{width:r,height:s}=qn(e),o=[];for(let i of e.layers)for(let a of i)a.isVirtual||o.push({id:a.id,layer:a.layer,order:a.order,x:a.x,y:a.y,w:a.w,h:a.h});return{boxes:o,edges:n,width:r,height:s}}function Fn(t){let e=new Map;for(let s of t.nodes)e.set(s,{id:s,isVirtual:!1,layer:-1,order:0,x:0,y:0,w:t.widthCells(s),h:t.heightCells(s),in:[],out:[]});let n=[],r=0;for(let s of t.edges){if(s.from===s.to)continue;let o=e.get(s.from),i=e.get(s.to);if(!o||!i)continue;let a={chainId:r++,chainFrom:s.from,chainTo:s.to,fromId:s.from,toId:s.to,hopIndex:0,chainLen:1};o.out.push(a),i.in.push(a),n.push(a)}return{nodes:e,layers:[],hops:n}}function Hn(t){let e=new Map;for(let o of t.nodes.values())e.set(o.id,o.in.length);let n=[];for(let o of t.nodes.values())(e.get(o.id)??0)===0&&(o.layer=0,n.push(o));let r=new Set,s=0;for(;s<n.length;){let o=n[s++];if(!r.has(o.id)){r.add(o.id);for(let i of o.out){let a=t.nodes.get(i.toId);a.layer=Math.max(a.layer,o.layer+1);let c=(e.get(a.id)??0)-1;e.set(a.id,c),c<=0&&n.push(a)}}}for(let o of t.nodes.values())o.layer<0&&(o.layer=0)}function Bn(t){let e=Math.max(0,...Array.from(t.nodes.values(),o=>o.layer)),n=Array.from({length:e+1},()=>[]);for(let o of t.nodes.values())n[o.layer].push(o);let r=[],s=0;for(let o of t.hops){let i=t.nodes.get(o.fromId),a=t.nodes.get(o.toId),c=a.layer-i.layer;if(c<=0){i.out=i.out.filter(p=>p!==o),a.in=a.in.filter(p=>p!==o);continue}if(c===1){o.hopIndex=0,o.chainLen=1,r.push(o);continue}i.out=i.out.filter(p=>p!==o),a.in=a.in.filter(p=>p!==o);let u=i;for(let p=1;p<c;p+=1){let h=`__virt_${s++}__`,f={id:h,isVirtual:!0,layer:i.layer+p,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};t.nodes.set(h,f),n[f.layer].push(f);let l={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:h,hopIndex:p-1,chainLen:c};u.out.push(l),f.in.push(l),r.push(l),u=f}let d={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:a.id,hopIndex:c-1,chainLen:c};u.out.push(d),a.in.push(d),r.push(d)}for(let o of n)for(let i=0;i<o.length;i+=1)o[i].order=i;t.layers=n,t.hops=r}function jn(t){for(let n=0;n<4;n+=1){for(let r=1;r<t.layers.length;r+=1)Vt(t,t.layers[r],"in"),Fe(t.layers[r]);for(let r=t.layers.length-2;r>=0;r-=1)Vt(t,t.layers[r],"out"),Fe(t.layers[r])}for(let n=0;n<2;n+=1){let r=!1;for(let s=1;s<t.layers.length;s+=1){let o=t.layers[s];for(let i=0;i+1<o.length;i+=1){let a=zt(t,o[i],o[i+1],"in");[o[i],o[i+1]]=[o[i+1],o[i]],Fe(o),zt(t,o[i],o[i+1],"in")<a?r=!0:([o[i],o[i+1]]=[o[i+1],o[i]],Fe(o))}}if(!r)break}}function Vt(t,e,n){let r=new Map;for(let s of e){let o=n==="in"?s.in:s.out;if(o.length===0){r.set(s.id,s.order);continue}let i=0,a=0;for(let c of o){let u=t.nodes.get(n==="in"?c.fromId:c.toId);u&&(i+=u.order,a+=1)}r.set(s.id,a===0?s.order:i/a)}e.sort((s,o)=>{let i=r.get(s.id),a=r.get(o.id);return i!==a?i-a:s.order-o.order})}function Fe(t){for(let e=0;e<t.length;e+=1)t[e].order=e}function zt(t,e,n,r){let s=r==="in"?e.in:e.out,o=r==="in"?n.in:n.out,i=0;for(let a of s)for(let c of o){let u=t.nodes.get(r==="in"?a.fromId:a.toId)?.order??0,d=t.nodes.get(r==="in"?c.fromId:c.toId)?.order??0;(e.order<n.order&&u>d||e.order>n.order&&u<d)&&(i+=1)}return i}function Vn(t,e){e.direction==="LR"?zn(t,e):Un(t,e)}function zn(t,e){let n=[],r=0;for(let s=0;s<t.layers.length;s+=1){n.push(r);let o=0;for(let i of t.layers[s])o=Math.max(o,i.w);r+=o+e.layerGap}for(let s=0;s<t.layers.length;s+=1)for(let o of t.layers[s])o.x=n[s];for(let s of t.layers){let o=0;for(let i of s)i.y=o,o+=i.h+e.nodeGap}Wt(t,e,"y")}function Un(t,e){let n=[],r=0;for(let s=0;s<t.layers.length;s+=1){n.push(r);let o=0;for(let i of t.layers[s])o=Math.max(o,i.h);r+=o+e.layerGap}for(let s=0;s<t.layers.length;s+=1)for(let o of t.layers[s])o.y=n[s];for(let s of t.layers){let o=0;for(let i of s)i.x=o,o+=i.w+e.nodeGap}Wt(t,e,"x")}function Wt(t,e,n){let r=o=>n==="y"?o.h:o.w,s=e.nodeGap;for(let o=0;o<2;o+=1){let i=o===0?t.layers.slice(1):t.layers.slice(0,-1).reverse();for(let a of i){let c=new Map;for(let d of a){let p=o===0?d.in:d.out;if(p.length===0)continue;let h=[];for(let l of p){let g=t.nodes.get(o===0?l.fromId:l.toId);if(!g)continue;let b=n==="y"?g.y:g.x;h.push(b+Math.floor(r(g)/2))}if(h.length===0)continue;h.sort((l,g)=>l-g);let f=h[Math.floor(h.length/2)];c.set(d.id,f-Math.floor(r(d)/2))}let u=0;for(let d of a){let p=c.get(d.id),h=n==="y"?d.y:d.x,l=Math.max(p??h,u);n==="y"?d.y=l:d.x=l,u=l+r(d)+s}}}}function Wn(t,e){let n=new Map;for(let u of t.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,p)=>d.hopIndex-p.hopIndex);let r=e.direction==="LR",s=u=>r?u.x:u.y,o=u=>r?u.w:u.h,i=u=>r?u.y+Math.floor(u.h/2):u.x+Math.floor(u.w/2),a=new Map;for(let u=0;u+1<t.layers.length;u+=1){let d=t.layers[u],p=t.layers[u+1],h=0;for(let O of d)h=Math.max(h,s(O)+o(O));let f=Number.POSITIVE_INFINITY;for(let O of p)f=Math.min(f,s(O));let l=Number.isFinite(f)?f-1:h,g=Math.max(1,l-h+1),b=[];for(let O of d)for(let N of O.out)b.push(N);b.sort((O,N)=>{let D=i(t.nodes.get(O.fromId)),k=i(t.nodes.get(N.fromId));if(D!==k)return D-k;let R=i(t.nodes.get(O.toId)),S=i(t.nodes.get(N.toId));return R-S});let w=[],x=new Map;for(let O of b){let N=i(t.nodes.get(O.fromId)),D=i(t.nodes.get(O.toId)),k=Math.min(N,D),R=Math.max(N,D),S=-1;for(let I=0;I<w.length;I+=1){let V=w[I],Y=!0;for(let oe of V)if(oe.lo<=R&&k<=oe.hi){Y=!1;break}if(Y){V.push({lo:k,hi:R}),S=I;break}}S<0&&(w.push([{lo:k,hi:R}]),S=w.length-1),x.set(O,S)}let m=w.length,v=g>=Math.max(3,m+2),_=v?h+1:h,y=v?l-1:l,T=Math.max(1,y-_+1);for(let O of b){let N=x.get(O),D;if(m<=1)D=_+Math.floor(T/2);else{let k=(T-1)/(m-1);D=_+Math.floor(N*k)}a.set(O,Math.max(h,Math.min(l,D)))}}let c=[];for(let[,u]of n){let d=[];for(let h=0;h<u.length;h+=1){let f=u[h],l=t.nodes.get(f.fromId),g=t.nodes.get(f.toId),b=a.get(f),w=l.isVirtual?s(l):s(l)+o(l),x=g.isVirtual?s(g):s(g)-1,m=i(l),v=i(g);h===0&&He(d,r,w,m),m!==v&&(He(d,r,b,m),He(d,r,b,v)),He(d,r,x,v)}let p=u[0];c.push({from:p.chainFrom,to:p.chainTo,points:Kn(d)})}return c}function He(t,e,n,r){t.push(e?{x:n,y:r}:{x:r,y:n})}function Kn(t){let e=[];for(let n of t){let r=e[e.length-1];(!r||r.x!==n.x||r.y!==n.y)&&e.push(n)}return e}function qn(t){let e=0,n=0;for(let r of t.layers)for(let s of r)e=Math.max(e,s.x+s.w),n=Math.max(n,s.y+s.h);return{width:e,height:n}}var Yn=24,Jn=4,Xn=1,Zn=3;function Kt(t,e){let n=Qn(e.direction),r=Math.max(3,e.maxLabelWidth??Yn),s=e.asciiCharset??"unicode",o=Object.keys(t.nodes).sort(),i=new Set(o),a=t.edges.filter(f=>i.has(f.from)&&i.has(f.to)),c=new Map,u=new Map;for(let f of o){let l=Pt(f,r);c.set(f,l),u.set(f,$e(l)+4)}let d=Ut({nodes:o,edges:a,widthCells:f=>u.get(f)??3,heightCells:()=>Zn,layerGap:Jn,nodeGap:Xn,direction:n}),p=Bt(d,{charset:s,labelOf:f=>c.get(f)??f}),h=e.logger;return h&&h(p),p}function Qn(t){if(t===void 0||t==="LR")return"LR";if(t==="TD")return"TD";throw new Error(`ascii describe supports direction "LR" or "TD" only; got ${String(t)}`)}function qt(t,e,n,r={}){let s=e in t.nodes,o=n in t.nodes;if(!s)return Be(e,n,"no-such-from");if(!o)return Be(e,n,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===n){if(r.findCycle===!0){let u=er(t,e,r);if(u!=null)return u}let c=je(e,t.nodes[e],0,r);return Ve(e,n,[c])}if(i===0)return Be(e,n,"no-path");let a=Yt(t,e,n,i);return a.found?Ve(e,n,Jt(t,a.pathOrder,r)):Be(e,n,a.truncated?"max-depth-exceeded":"no-path")}function Yt(t,e,n,r){let s=new Map,o=[{path:n,depth:0}],i=new Set([n]),a=0,c=!1;for(;a<o.length;){let p=o[a++];if(p.path===e)break;if(r!=null&&p.depth>=r){let g=t.nodes[p.path];g?.deps&&g.deps.length>0&&(c=!0);continue}let h=t.nodes[p.path];if(h==null)continue;let f=h.deps??[],l=new Map;for(let g=0;g<f.length;g++){let b=f[g];if(!b)continue;let w=l.get(b);w==null&&(w=[],l.set(b,w)),w.push(g)}for(let[g,b]of l)i.has(g)||(i.add(g),s.set(g,{from:p.path,depIndices:b}),o.push({path:g,depth:p.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:c};let u=[{path:e}],d=e;for(;d!==n;){let p=s.get(d);if(p==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=p.depIndices,u.push({path:p.from}),d=p.from}return{found:!0,pathOrder:u,truncated:!1}}function er(t,e,n){let r=t.nodes[e];if(r==null)return null;let s=r.deps??[],o=[];for(let a=0;a<s.length;a++)s[a]===e&&o.push(a);if(o.length>0){let a=je(e,r,0,n);a.dep_index=o[0];let c=je(e,r,1,n);return Ve(e,e,[a,c])}let i=null;for(let a=0;a<s.length;a++){let c=s[a];if(!c||c===e)continue;let u=Yt(t,c,e,n.maxDepth);u.found&&(i==null||u.pathOrder.length<i.pathOrder.length)&&(i=u,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...u.pathOrder],truncated:!1})}return i==null?null:Ve(e,e,Jt(t,i.pathOrder,n))}function Jt(t,e,n){return e.map((r,s)=>{let o=t.nodes[r.path],i=je(r.path,o,s,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 je(t,e,n,r){let s={path:t,type:e.type,hop:n};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let o=r.annotations?.get(t)??e.annotation;o!=null&&(s.annotation=o);let i=r.lastMutations?.get(t)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function Ve(t,e,n){return Xt(t,e,!0,"ok",n)}function Be(t,e,n){return Xt(t,e,!1,n,[])}function Xt(t,e,n,r,s){let o=tr(t,e,n,r,s);return{from:t,to:e,found:n,reason:r,steps:s,text:o,toJSON(){return{from:t,to:e,found:n,reason:r,steps:s}}}}function tr(t,e,n,r,s){if(!n)switch(r){case"no-such-from":return`explainPath: no node named "${t}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${t}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${t}" to "${e}"`}let o=[`Causal path: ${t} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let c=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(c),"value"in i&&o.push(` value: ${nr(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;o.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return o.join(`
3
3
  `)}function nr(t){if(t===void 0)return"<sentinel>";if(t===null)return"null";if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return String(t);try{let e=JSON.stringify(t);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(t)}}be();var P={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},rr=Symbol.for("sizeof");function Zt(t){let e=new WeakSet,n=new WeakSet,r=[t],s=0;for(;r.length>0;){let o=r.pop();s+=sr(o,e,n,r)}return s}function sr(t,e,n,r){if(t==null)return 0;switch(typeof t){case"number":return P.number;case"boolean":return P.boolean;case"string":return P.string+t.length*2;case"bigint":return P.bigint+or(t);case"symbol":return P.symbol;case"function":return e.has(t)?0:(e.add(t),P.function);case"undefined":return 0}let o=t;if(e.has(o))return 0;e.add(o);let i=o[rr];if(typeof i=="function")try{let u=i.call(o);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(o instanceof Date)return P.date;if(o instanceof RegExp)return P.regexp+o.source.length*2;if(o instanceof Error){let u=o.message?o.message.length*2:0,d=o.stack?o.stack.length*2:0;return P.error+u+d}if(typeof URL<"u"&&o instanceof URL)return P.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return P.promise;if(o instanceof WeakMap)return P.weakmap;if(o instanceof WeakSet)return P.weakset;if(o instanceof Map){let u=P.map;for(let[d,p]of o)u+=P.mapEntry,r.push(d),r.push(p);return u}if(o instanceof Set){let u=P.set;for(let d of o)u+=P.setEntry,r.push(d);return u}if(Array.isArray(o)){let u=P.array+o.length*8;for(let d of o)r.push(d);return u}if(o instanceof ArrayBuffer)return n.has(o)?0:(n.add(o),o.byteLength);if(ArrayBuffer.isView(o)){let u=o;return n.has(u.buffer)?48:(n.add(u.buffer),u.buffer.byteLength+48)}let a=P.object,c=Object.keys(o);for(let u of c){a+=P.string+u.length*2;try{r.push(o[u])}catch{}}return a}function or(t){let e=t<0n?-t:t;if(e===0n)return 0;let n=e.toString(2).length;return Math.ceil(n/32)*8}function Qt(t,e){let n=e?.topN??10,r=t.describe({detail:"standard"}),s=[],o=t._collectObserveTargets;typeof o=="function"&&o.call(t,"",s);let i=new Map;for(let[h,f]of s)i.set(h,f);let a=[];for(let[h,f]of Object.entries(r.nodes)){let l=i.get(h),g=l instanceof L?l:null,b=g?Zt(g.cache):0,w=g?g._sinkCount:0,x=f.deps?.length??0,m=f.type==="effect"&&w===0,v=w===0?f.type==="effect"?"orphan-effect":f.type==="derived"?"idle-derived":f.type==="producer"?"idle-producer":null:null;a.push({path:h,type:f.type,status:f.status??"unknown",valueSizeBytes:b,subscriberCount:w,depCount:x,isOrphanEffect:m,orphanKind:v})}let c=a.reduce((h,f)=>h+f.valueSizeBytes,0),u=(h,f)=>[...a].sort(f??((l,g)=>g[h]-l[h])).slice(0,n),d=a.filter(h=>h.orphanKind!=null),p=a.filter(h=>h.isOrphanEffect);return{nodeCount:a.length,edgeCount:r.edges.length,subgraphCount:r.subgraphs.length,nodes:a,totalValueSizeBytes:c,hotspots:{byValueSize:u("valueSizeBytes"),bySubscriberCount:u("subscriberCount"),byDepCount:u("depCount")},orphans:d,orphanEffects:p}}var G="::",z="__meta__",ye=1;function en(t,e){let n=Math.max(16,t.size*4),r=0;for(;t.size>0;){if(r++>=n){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${n}); ${t.size} disposer(s) discarded`),t.clear();return}let s=t.values().next();if(s.done)return;let o=s.value;t.delete(o);try{o()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function ir(t){let e=[];for(let n of Object.keys(t).sort()){let r=t[n].v;r!=null&&e.push(`${n} ${r.id} ${r.version}`)}return e.join(`
4
4
  `)}function tn(t){if(t.version!==ye)throw new Error(`unsupported snapshot version ${String(t.version)} (expected ${ye})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in t))throw new Error(`snapshot missing required key "${e}"`);if(typeof t.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof t.nodes!="object"||t.nodes===null||Array.isArray(t.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(t.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(t.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function ar(t,e){let n=new WeakMap,r=(s,o)=>{if(Object.is(s,o))return!0;if(s==null||o==null||typeof s!="object"||typeof o!="object")return!1;let i=n.get(s);if(i==null&&(i=new WeakSet,n.set(s,i)),i.has(o))return!0;i.add(o);let a=s.constructor,c=o.constructor;if(a!==c)return!1;if(s instanceof Date)return s.getTime()===o.getTime();if(s instanceof RegExp)return s.source===o.source&&s.flags===o.flags;if(Array.isArray(s)){let h=o;if(s.length!==h.length)return!1;for(let f=0;f<s.length;f++)if(!r(s[f],h[f]))return!1;return!0}if(s instanceof Map){let h=o;if(s.size!==h.size)return!1;for(let[f,l]of s)if(!h.has(f)||!r(l,h.get(f)))return!1;return!0}if(s instanceof Set){let h=o;if(s.size!==h.size)return!1;for(let f of s){let l=!1;for(let g of h)if(r(f,g)){l=!0;break}if(!l)return!1}return!0}if(ArrayBuffer.isView(s)){let h=s,f=o;if(h.length!==f.length)return!1;for(let l=0;l<h.length;l++)if(h[l]!==f[l])return!1;return!0}let u=Object.keys(s),d=Object.keys(o);if(u.length!==d.length)return!1;let p=new Set(d);for(let h of u)if(!p.has(h)||!r(s[h],o[h]))return!1;return!0};return r(t,e)}function mt(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(mt);let e=t,n=Object.keys(e).sort(),r={};for(let s of n)r[s]=mt(e[s]);return r}function ur(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function cr(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function dr(t){return t==="TD"?"down":t==="BT"?"up":t==="RL"?"left":"right"}function sn(t){let e=new Set,n=[];function r(s,o){let i=`${s}\0${o}`;e.has(i)||(e.add(i),n.push([s,o]))}for(let[s,o]of Object.entries(t.nodes)){let i=o.deps;if(i)for(let a of i)r(a,s)}for(let s of t.edges)r(s.from,s.to);return n}function on(t){if(t===void 0)return"LR";if(t==="TD"||t==="LR"||t==="BT"||t==="RL")return t;throw new Error(`invalid diagram direction ${String(t)}; expected one of: TD, LR, BT, RL`)}function lr(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,{expand:s,...o}=t,i={...o,edges:n?t.edges:[],subgraphs:r?t.subgraphs:[]},a=JSON.stringify(mt(i),null,e.indent??2);return e.logger?.(a),a}function fr(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,s=[];s.push(`Graph ${t.name}`),s.push("Nodes:");for(let i of Object.keys(t.nodes).sort()){let a=t.nodes[i];s.push(`- ${i} (${a.type}/${a.status}): ${Ue(a.value)}`)}if(n){s.push("Edges:");for(let i of t.edges)s.push(`- ${i.from} -> ${i.to}`)}if(r){s.push("Subgraphs:");for(let i of t.subgraphs)s.push(`- ${i}`)}let o=s.join(`
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j}from"../../chunk-VWPRPPKR.js";import"../../chunk-5Z4HDCO6.js";import"../../chunk-MGKAO4EK.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-TWMEGG45.js";import"../../chunk-KASHOCF5.js";import"../../chunk-W4TSQ6RJ.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{d as approval,c as branch,e as gate,f as join,g as loop,j as onFailure,a as pipeline,i as sensor,h as subPipeline,b as task};
1
+ import{a,b,c,d,e,f,g,h,i,j}from"../../chunk-5LJAQTSS.js";import"../../chunk-K54OKWNY.js";import"../../chunk-PSQNYY72.js";import"../../chunk-SGS4OJGS.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-N2KKISCE.js";import"../../chunk-UMH3HSP7.js";import"../../chunk-7AJKUA36.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{d as approval,c as branch,e as gate,f as join,g as loop,j as onFailure,a as pipeline,i as sensor,h as subPipeline,b as task};
@@ -1,4 +1,4 @@
1
- "use strict";var Qe=Object.defineProperty;var Mn=Object.getOwnPropertyDescriptor;var An=Object.getOwnPropertyNames;var Dn=Object.prototype.hasOwnProperty;var U=(t,e)=>()=>(t&&(e=t(t=0)),e);var Gn=(t,e)=>{for(var n in e)Qe(t,n,{get:e[n],enumerable:!0})},Ln=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of An(e))!Dn.call(t,s)&&s!==n&&Qe(t,s,{get:()=>e[s],enumerable:!(r=Mn(e,s))||r.enumerable});return t};var In=t=>Ln(Qe({},"__esModule",{value:!0}),t);function F(){return Math.trunc(performance.now()*1e6)}function Me(){return Date.now()*1e6}var pe=U(()=>{"use strict"});function At(t,e){let n=new TextEncoder().encode(t.name);if(n.length===0||n.length>255)throw new Error(`encodeEnvelope: codec name "${t.name}" encodes to ${n.length} bytes (must be 1\u2013255)`);let r=t.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let s=2+n.length+2+e.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let o=new Uint8Array(s),i=0;return o[i++]=ut,o[i++]=n.length,o.set(n,i),i+=n.length,o[i++]=r>>>8&255,o[i++]=r&255,o.set(e,i),o}function Dt(t,e){if(t.length<Mt)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${Mt})`);let n=0,r=t[n++];if(r!==ut)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${ut})`);let s=t[n++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(n+s+2>t.length)throw new Error(`decodeEnvelope: envelope truncated (need ${n+s+2} bytes, have ${t.length})`);let o=new TextDecoder().decode(t.subarray(n,n+s));n+=s;let i=(t[n]<<8|t[n+1])>>>0;n+=2;let a=t.subarray(n),l=e.lookupCodec(o);if(l==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:l,codecVersion:i,payload:a}}function Gt(t){t.registerCodec(Pn)}var Pn,ut,Mt,lt=U(()=>{"use strict";Pn={name:"json",version:1,contentType:"application/json",encode(t){let e=JSON.stringify(t);return new TextEncoder().encode(e)},decode(t,e){let n=new TextDecoder().decode(t);return JSON.parse(n)}},ut=1,Mt=4});function Ae(t){if(t==null)return ge;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var ge,ct=U(()=>{"use strict";ge={type:"system",id:""}});function De(){return me>0||ke}function Lt(){return me>0}function Oe(t){me>0?Te.push(t):t()}function It(t){me+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(me-=1,me===0)if(e){if(!ke){let n=Te.splice(0);for(let r of n)try{r()}catch{}de.length=0,fe.length=0,be.length=0}}else $n()}}function $n(){let t=!ke;t&&(ke=!0);let e=[],n=0;try{for(;de.length>0||fe.length>0||be.length>0||t&&Te.length>0;){if(t&&Te.length>0){let o=Te.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw de.length=0,fe.length=0,be.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(de.length>0?de:fe.length>0?fe:be).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{t&&(ke=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function ye(t,e,n){if(e.length===0)return;if(e.length===1){let u=n(e[0][0]);if(u<3||!De()){t(e);return}(u>=5?be:u===4?fe:de).push(()=>t(e));return}let r=e.length,s=r,o=r,i=r,a=0;for(;a<r&&n(e[a][0])<3;)a++;for(s=a;a<r&&n(e[a][0])===3;)a++;for(o=a;a<r&&n(e[a][0])===4;)a++;i=a;let l=De();if(s>0){let u=e.slice(0,s);t(u)}if(o>s){let u=e.slice(s,o);l?de.push(()=>t(u)):t(u)}if(i>o){let u=e.slice(o,i);l?fe.push(()=>t(u)):t(u)}if(r>i){let u=e.slice(i,r);l?be.push(()=>t(u)):t(u)}}var me,ke,de,fe,be,Te,Ge=U(()=>{"use strict";me=0,ke=!1,de=[],fe=[],be=[],Te=[]});var Se,B,J,te,X,ne,ie,j,Z,$,ve,dt,Bn,ft,Fn,Hn,ht,Pt,$t,Bt,pt,Ne=U(()=>{"use strict";Se=Symbol.for("graphrefly/START"),B=Symbol.for("graphrefly/DATA"),J=Symbol.for("graphrefly/DIRTY"),te=Symbol.for("graphrefly/RESOLVED"),X=Symbol.for("graphrefly/INVALIDATE"),ne=Symbol.for("graphrefly/PAUSE"),ie=Symbol.for("graphrefly/RESUME"),j=Symbol.for("graphrefly/TEARDOWN"),Z=Symbol.for("graphrefly/COMPLETE"),$=Symbol.for("graphrefly/ERROR"),ve=Object.freeze([J]),dt=Object.freeze([te]),Bn=Object.freeze([X]),ft=Object.freeze([Se]),Fn=Object.freeze([Z]),Hn=Object.freeze([j]),ht=Object.freeze([ve]),Pt=Object.freeze([dt]),$t=Object.freeze([Bn]),Bt=Object.freeze([Fn]),pt=Object.freeze([Hn])});function Ft(t){t.registerMessageType(Se,{tier:0,wireCrossing:!1}),t.registerMessageType(J,{tier:1,wireCrossing:!1}),t.registerMessageType(X,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(ne,{tier:2,wireCrossing:!1}),t.registerMessageType(ie,{tier:2,wireCrossing:!1}),t.registerMessageType(B,{tier:3,wireCrossing:!0}),t.registerMessageType(te,{tier:3,wireCrossing:!0}),t.registerMessageType(Z,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType($,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(j,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Le,Ht=U(()=>{"use strict";Ne();Le=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=n=>{let r=this._messageTypes.get(n);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,n){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:n.tier,wireCrossing:n.wireCrossing??n.tier>=3,metaPassthrough:n.metaPassthrough??!0}),this}messageTier(e){let n=this._messageTypes.get(e);return n!=null?n.tier:1}isWireCrossing(e){let n=this._messageTypes.get(e);return n!=null?n.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let n=this._messageTypes.get(e);return n!=null?n.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function gt(t){let e=jn.filter(n=>t({type:n,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(n=>n==="human"||n==="llm"||n==="system")?"both":e.length===1?e[0]:e.join("+")}var K,jn,Ie=U(()=>{"use strict";K=class extends Error{actor;action;nodeName;constructor(e,n){super(n??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}},jn=["human","llm","wallet","system"]});function mt(t){if(t===void 0)return null;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Cannot hash non-finite number: ${t}`);if(Number.isInteger(t)&&!Number.isSafeInteger(t))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${t}. Cross-language cid parity is not guaranteed for unsafe integers.`);return t}if(typeof t=="string"||typeof t=="boolean"||t===null)return t;if(Array.isArray(t))return t.map(mt);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=mt(t[n]);return e}return null}function zn(t){let e=Wn.encode(t),n=e.length,r=n*8,s=n+9+63&-64,o=new Uint8Array(s);o.set(e),o[n]=128;let i=new DataView(o.buffer);i.setUint32(s-4,r>>>0,!1),i.setUint32(s-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,l=3144134277,u=1013904242,c=2773480762,f=1359893119,p=2600822924,h=528734635,d=1541459225,g=new Uint32Array(64),b=(v,y)=>v>>>y|v<<32-y;for(let v=0;v<s;v+=64){for(let S=0;S<16;S++)g[S]=i.getUint32(v+S*4,!1);for(let S=16;S<64;S++){let E=g[S-15],R=g[S-2],L=b(E,7)^b(E,18)^E>>>3,V=b(R,17)^b(R,19)^R>>>10;g[S]=g[S-16]+L+g[S-7]+V>>>0}let y=a,_=l,m=u,w=c,k=f,T=p,O=h,C=d;for(let S=0;S<64;S++){let E=b(k,6)^b(k,11)^b(k,25),R=k&T^~k&O,L=C+E+R+Vn[S]+g[S]>>>0,V=b(y,2)^b(y,13)^b(y,22),Y=y&_^y&m^_&m,ce=V+Y>>>0;C=O,O=T,T=k,k=w+L>>>0,w=m,m=_,_=y,y=L+ce>>>0}a=a+y>>>0,l=l+_>>>0,u=u+m>>>0,c=c+w>>>0,f=f+k>>>0,p=p+T>>>0,h=h+O>>>0,d=d+C>>>0}let x=v=>v.toString(16).padStart(8,"0");return x(a)+x(l)+x(u)+x(c)+x(f)+x(p)+x(h)+x(d)}function bt(t){let e=mt(t??null),n=JSON.stringify(e);return zn(n).slice(0,16)}function Un(){let t=globalThis.crypto;if(t?.randomUUID)return t.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),n=e()+e()+e()+e();return`${n.slice(0,8)}-${n.slice(8,12)}-4${n.slice(13,16)}-${(parseInt(n.slice(16,17),16)&3|8).toString(16)}${n.slice(17,20)}-${n.slice(20,32)}`}function yt(t,e,n){let r=n?.id??Un();if(t===0)return{id:r,version:0};let o=(n?.hash??bt)(e);return{id:r,version:0,cid:o,prev:null}}function jt(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var Vn,Wn,Vt=U(()=>{"use strict";Vn=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]),Wn=new TextEncoder});function Ut(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function vt(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function Pe(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function re(t,e,n){let r=Kt(t)?t:[],s=typeof t=="function"?t:typeof e=="function"?e:void 0,o={};return Kt(t)?o=(xt(e)?e:n)??{}:xt(t)?o=t:o=(xt(e)?e:n)??{},new I(r,s,o)}var Wt,zt,Kn,qn,ae,I,Kt,xt,se=U(()=>{"use strict";lt();ct();Ge();pe();Ht();Ie();Ne();Vt();Wt=()=>{},zt=100;Kn=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},qn=(t,e,n,r)=>{let s=t;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[ft]:[ft,[B,o]];s._status==="dirty"&&i.push(ve),ye(e,i,s._config.tierOf)},ae=new Le({onMessage:Kn,onSubscribe:qn});Ft(ae);Gt(ae);I=class t{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,n,r){this._config=r.config??ae,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=n,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??bt;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?yt(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Ut);let o={};for(let[a,l]of Object.entries(r.meta??{})){let u={initial:l,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(u.guard=r.guard),o[a]=new t([],void 0,u)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[B,a]])},down(a){i._emit(Pe(a))},up(a){i._emitUp(Pe(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let s=n?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??n?.id,l=i?.version??0,u=yt(e,o,{id:a,hash:s});u.version=l,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=Ae(e);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(n,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let n=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!n&&!r)return;let s=Ae(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new K({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new K({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:Me()}}down(e,n){let r=Pe(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[B,e]])}up(e,n){if(this._deps.length===0)return;let r=Pe(e);if(r.length===0)return;this._checkGuard(n);let s=n??{internal:!0};this._validateUpTiers(r);for(let o of this._deps)o.node.up?.(r,s)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let n of this._deps)n.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let n=this._config.tierOf;for(let r of e){let s=n(r[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,n){if(n!=null&&this._guard!=null){let l=Ae(n);if(!this._guard(l,"observe"))throw new K({actor:l,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let l of this._deps)vt(l);if(this._partial===!1){for(let l of this._deps)if(l.prevData!==void 0||l.dataBatch.length!==0||l.terminal!==void 0||l.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(l){throw this._sinkCount-=1,l}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(l){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw l}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[n]=this._sinks;this._sinks=n}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,n=0;try{for(let r=0;r<e;r++){let s=r,o=this._deps[r];o.unsub=Wt,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,l=!1;for(let u of i)a(u[0])>=3&&(l=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:s},this._actions);l&&this._maybeRunFnOnSettlement()}),n++}}catch(r){this._deps[n].unsub=null;for(let s=0;s<n;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}vt(o)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let n=this._deps.length,r=Ut(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ht),r.unsub=Wt;try{r.unsub=e.subscribe(s=>{if(r.unsub===null)return;let o=this._config.tierOf,i=!1;for(let a of s)o(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(r){this._emit([[$,this._wrapFnError("cleanup threw",r)]])}else if(n!=null&&typeof n=="object"){let r=n.deactivate;if(typeof r=="function")try{r()}catch(s){this._emit([[$,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let r of this._deps){if(r.unsub!=null){let s=r.unsub;r.unsub=null;try{s()}catch{}}vt(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,n){let r=this._deps[e],s=n[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:n};for(let i of this._inspectorHooks)i(o)}if(s!==Se){if(s===J){this._depDirtied(r);return}if(s===X){this._depInvalidated(r),this._emit($t);return}if(s===ne||s===ie){this._emit([n]);return}if(s===j){this._emit(pt);return}if(s===B)this._depSettledAsData(r,n[1]);else if(s===te)this._depSettledAsResolved(r);else if(s===Z)this._depSettledAsTerminal(r,!0);else if(s===$)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(s===B||s===te)&&this._emit([n]),(s===Z||s===$)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ht))}_depSettledAsData(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=n,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let n=this._deps[e];if(n.dataBatch.length===0&&n.prevData===void 0&&n.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Pt),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(e!=null){this._autoError&&this._emit([[$,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(Bt)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[$,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[$,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let n=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=n[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let s=this._deps.map(i=>i.terminal),o={prevData:r,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:n,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(n,this._actions,o);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[$,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>zt?(this._rerunDepth=0,this._emit([[$,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${zt} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,n){let r=n instanceof Error?n.message:String(n);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:n})}_frameBatch(e){let n=this._config.tierOf;if(e.length===1)return n(e[0][0])===3&&this._status!=="dirty"?[ve,e[0]]:e;let r=!0,s=!1,o=!1,i=-1;for(let l of e){let u=n(l[0]);u<i&&(r=!1),u===3&&(s=!0),l[0]===J&&(o=!0),i=u}let a=e;if(!r){let l=e.map((u,c)=>({m:u,i:c,tier:n(u[0])}));l.sort((u,c)=>u.tier-c.tier||u.i-c.i),a=l.map(u=>u.m)}if(s&&!o&&this._status!=="dirty"){let l=0;for(;l<a.length&&n(a[l][0])===0;)l++;return l===0?[ve,...a]:[...a.slice(0,l),ve,...a.slice(l)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let l=e[a];if(l[0]===$&&l[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let n=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(l=>l[0]===j||l[0]===X);if(a.length===0)return;n=a}n=this._frameBatch(n);let s=null;for(let a=0;a<n.length;a++){let l=n[a],u=l[0];if(u!==ne&&u!==ie){s?.push(l);continue}if(l.length<2)throw new Error(`Node "${this.name}": [[${u===ne?"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 f=l[1];if(u===ne)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(f),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(f))c=!1;else if(this._pauseLocks.delete(f),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?s?.push(l):s==null&&(s=n.slice(0,a))}if(s!=null){if(s.length===0)return;n=s}if(this._hasMeta&&n.some(a=>a[0]===j))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(pt)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(n);if(o.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,l=[];for(let u of o)a(u[0])===3?this._pauseBuffer.push(u):l.push(u);l.length>0&&this._dispatchOrAccumulate(l)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[$,i]])}_updateState(e){let n=this._config.tierOf,r,s,o=-1,i=0;for(let c of e)n(c[0])===3&&i++;let a=i<=1,l=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===B){l=c;break}}for(let c=0;c<e.length;c++){let f=e[c],p=f[0];if(p===B){if(f.length>=2){let h=!1;if(a&&this._cached!==void 0)try{h=this._equals(this._cached,f[1])}catch(d){s=this._wrapFnError("equals threw",d),o=c;break}if(h){r==null&&(r=e.slice(0,c)),r.push(dt),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(l<0||c===l)&&jt(this._versioning,f[1],this._hashFn)}this._status="settled",r?.push(f)}else if(r?.push(f),p===J)this._status="dirty";else if(p===te)this._status="resolved";else if(p===Z)this._status="completed";else if(p===$)this._status="errored";else if(p===X){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 d=h.invalidate;if(typeof d=="function")try{d()}catch{}}}else p===j&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=o>=0?r??e.slice(0,o):r??e;return s!=null?{finalMessages:u,equalsError:s}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let n=[...this._sinks];for(let r of n)r(e)};_dispatchOrAccumulate(e){if(Lt()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],Oe(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}ye(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let n=this._frameBatch(e);ye(this._deliverToSinks,n,this._config.tierOf)}},Kt=t=>Array.isArray(t),xt=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function G(t,e){return re([],{...e,initial:t})}function qt(t,e){return re((r,s,o)=>t(s,o)??void 0,{describeKind:"producer",...e})}function q(t,e,n){return re(t,(s,o,i)=>{let a=s.map((l,u)=>l!=null&&l.length>0?l.at(-1):i.prevData[u]);o.emit(e(a,i))},{describeKind:"derived",...n})}var Ee=U(()=>{"use strict";se()});function _t(t){return t.subscribe(()=>{})}var Yt=U(()=>{"use strict"});var Be,Jt=U(()=>{"use strict";Be=class{_timer;_gen=0;start(e,n){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&n()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var ts={};Gn(ts,{CanvasMeasureAdapter:()=>st,CliMeasureAdapter:()=>tt,ImageSizeAdapter:()=>at,NodeCanvasMeasureAdapter:()=>ot,PrecomputedAdapter:()=>rt,SvgBoundsAdapter:()=>it,analyzeAndMeasure:()=>we,carveTextLineSlots:()=>Et,circleIntervalForBand:()=>En,computeBlockFlow:()=>Sn,computeCharPositions:()=>qe,computeFlowLines:()=>Rn,computeLineBreaks:()=>Ke,computeTotalHeight:()=>Nn,layoutNextLine:()=>Nt,measureBlock:()=>Tn,measureBlocks:()=>On,reactiveBlockLayout:()=>Zr,reactiveFlowLayout:()=>es,reactiveLayout:()=>Xr,rectIntervalForBand:()=>Cn});module.exports=In(ts);function et(t){return t>=768&&t<=879||t>=1155&&t<=1161||t>=1425&&t<=1469||t>=1552&&t<=1562||t>=1611&&t<=1631||t>=1648&&t===1648||t>=1750&&t<=1756||t>=1759&&t<=1764||t>=1767&&t<=1768||t>=1770&&t<=1773||t>=1840&&t<=1866||t>=1958&&t<=1968||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2641||t>=2672&&t<=2673||t>=2677&&t===2677||t>=3633&&t===3633||t>=3636&&t<=3642||t>=3655&&t<=3662||t>=3761&&t===3761||t>=3764&&t<=3772||t>=3784&&t<=3790||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65024&&t<=65039||t>=65056&&t<=65071||t===8205?0:t>=4352&&t<=4447||t>=8986&&t<=8987||t>=9001&&t<=9002||t>=9193&&t<=9203||t>=9208&&t<=9210||t>=9725&&t<=9726||t>=9748&&t<=9749||t>=9800&&t<=9811||t===9855||t===9875||t===9889||t>=9898&&t<=9899||t>=9917&&t<=9918||t>=9924&&t<=9925||t===9934||t===9940||t===9962||t>=9970&&t<=9971||t===9973||t===9978||t===9981||t===9986||t===9989||t>=9992&&t<=9997||t===9999||t>=10067&&t<=10069||t===10071||t>=10133&&t<=10135||t===10160||t===10175||t>=10548&&t<=10549||t>=11013&&t<=11015||t>=11035&&t<=11036||t===11088||t===11093||t>=11904&&t<=12350||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12784&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=19968&&t<=40959||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65131||t>=65281&&t<=65376||t>=65504&&t<=65510||t>=126980&&t===126980||t===127183||t>=127344&&t<=127345||t===127358||t===127359||t===127374||t>=127377&&t<=127386||t>=127456&&t<=127487||t>=127488&&t<=127490||t===127514||t===127535||t>=127538&&t<=127546||t>=127568&&t<=127569||t>=127744&&t<=129535||t>=129536&&t<=129791||t>=129792&&t<=130047||t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}function he(t){let e=0;for(let n of t)e+=et(n.codePointAt(0));return e}function Rt(t,e){if(e<=0)return"";let n=0,r="";for(let s of t){let o=et(s.codePointAt(0));if(n+o>e){if(e<=1)return"\u2026";for(;n+1>e&&r.length>0;){let i=[...r].pop();r=r.slice(0,-i.length),n-=et(i.codePointAt(0))}return`${r}\u2026`}r+=s,n+=o}return r}var tt=class{cellPx;constructor(e){this.cellPx=e?.cellPx??8}measureSegment(e,n){return{width:he(e)*this.cellPx}}},nt=class extends Error{name="KeyError"},rt=class{metrics;fallback;constructor(e){this.metrics=e.metrics;let n=e.fallback??"per-char";if(n!=="per-char"&&n!=="error")throw new Error(`fallback must be 'per-char' or 'error', got ${JSON.stringify(e.fallback)}`);this.fallback=n}measureSegment(e,n){let r=this.metrics[n];if(r){let o=r[e];if(o!==void 0)return{width:o}}if(this.fallback==="error")throw new nt(`PrecomputedAdapter: no metrics for segment ${JSON.stringify(e)} in font ${JSON.stringify(n)}`);let s=0;if(r)for(let o of e){let i=r[o];i!==void 0&&(s+=i)}return{width:s}}},st=class{ctx=null;currentFont="";emojiCorrection;constructor(e){this.emojiCorrection=e?.emojiCorrection??1}getContext(){if(!this.ctx){if(typeof OffscreenCanvas>"u")throw new Error("CanvasMeasureAdapter requires a browser environment with OffscreenCanvas support. Use CliMeasureAdapter or NodeCanvasMeasureAdapter for Node.js.");let n=new OffscreenCanvas(0,0).getContext("2d");if(!n)throw new Error("CanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(e,n){let r=this.getContext();n!==this.currentFont&&(r.font=n,this.currentFont=n);let s=r.measureText(e).width;return this.emojiCorrection!==1&&new RegExp("\\p{Emoji_Presentation}","u").test(e)&&(s*=this.emojiCorrection),{width:s}}clearCache(){this.currentFont=""}},ot=class{ctx=null;currentFont="";canvasModule;constructor(e){this.canvasModule=e}getContext(){if(!this.ctx){let n=this.canvasModule.createCanvas(0,0).getContext("2d");if(!n)throw new Error("NodeCanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(e,n){let r=this.getContext();return n!==this.currentFont&&(r.font=n,this.currentFont=n),{width:r.measureText(e).width}}clearCache(){this.currentFont=""}},it=class{measureSvg(e){let n=e.match(/viewBox\s*=\s*["']([^"']+)["']/);if(n){let o=n[1].trim().split(/[\s,]+/);if(o.length>=4){let i=Number.parseFloat(o[2]),a=Number.parseFloat(o[3]);if(Number.isFinite(i)&&Number.isFinite(a)&&i>0&&a>0)return{width:i,height:a};throw new Error("SvgBoundsAdapter: viewBox width/height are missing, non-finite, or not positive")}}let r=e.match(/<svg[^>]*\bwidth\s*=\s*["']?([\d.]+)/),s=e.match(/<svg[^>]*\bheight\s*=\s*["']?([\d.]+)/);if(r&&s){let o=Number.parseFloat(r[1]),i=Number.parseFloat(s[1]);if(Number.isFinite(o)&&Number.isFinite(i)&&o>0&&i>0)return{width:o,height:i};throw new Error("SvgBoundsAdapter: svg width/height attributes are non-finite or not positive")}throw new Error("SvgBoundsAdapter: cannot determine dimensions \u2014 SVG has no viewBox or width/height attributes")}},at=class{sizes;constructor(e){this.sizes=new Map(Object.entries(e))}measureImage(e){let n=this.sizes.get(e);if(!n)throw new Error(`ImageSizeAdapter: no dimensions registered for ${JSON.stringify(e)}`);return{width:n.width,height:n.height}}};pe();se();Ee();ct();Ge();pe();Ie();Ne();Ie();se();function $e(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 Yn(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function Jn(t){let e={};for(let[n,r]of Object.entries(t.meta))try{e[n]=r.cache}catch{}return e}function wt(t,e){let n=e==null,r=!n&&e!=null?[...e].filter(u=>u.startsWith("meta.")).map(u=>u.slice(5)):null,s=n||e.has("meta")||r!=null&&r.length>0,o="state",i=[];t instanceof I&&(o=Yn(t),i=t._deps.map(u=>u.node.name??""));let a={type:o,deps:i};(n||e.has("status"))&&(a.status=t.status);let l=t instanceof I?t._guard:void 0;if(s){let u={...Jn(t)};if(l!=null&&u.access===void 0&&(u.access=gt(l)),r!=null&&r.length>0&&!e.has("meta")){let c={};for(let f of r)f in u&&(c[f]=u[f]);a.meta=c}else a.meta=u}if(t.name!=null&&(a.name=t.name),n||e.has("value")){t.status==="sentinel"&&(a.sentinel=!0);try{a.value=t.cache}catch{}}if((n||e.has("v"))&&t.v!=null){let u={id:t.v.id,version:t.v.version};"cid"in t.v&&(u.cid=t.v.cid,u.prev=t.v.prev),a.v=u}return(n||e.has("guard"))&&l!=null&&(a.guard=gt(l)),(n||e.has("lastMutation"))&&t.lastMutation!=null&&(a.lastMutation=t.lastMutation),a}se();Ee();Yt();Jt();var Ce=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let n=(this.head+this._size)%this.capacity;this.buf[n]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let n=e<0?this._size+e:e;if(!(n<0||n>=this._size))return this.buf[(this.head+n)%this.capacity]}toArray(){let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this.buf[(this.head+n)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}};lt();var Xn={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"},Zn={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function en(t,e){let n=e.charset==="ascii"?Zn:Xn,r=t.width,s=t.height,o=Array.from({length:s},()=>Array.from({length:r},()=>" ")),i=Array.from({length:s},()=>Array.from({length:r},()=>"empty"));for(let a of t.edges)er(o,i,n,a);for(let a of t.boxes)Qn(o,i,n,a,e.labelOf(a.id));return o.map(a=>sr(a.join(""))).join(`
1
+ "use strict";var Qe=Object.defineProperty;var Mn=Object.getOwnPropertyDescriptor;var An=Object.getOwnPropertyNames;var Dn=Object.prototype.hasOwnProperty;var U=(t,e)=>()=>(t&&(e=t(t=0)),e);var Gn=(t,e)=>{for(var n in e)Qe(t,n,{get:e[n],enumerable:!0})},Ln=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of An(e))!Dn.call(t,s)&&s!==n&&Qe(t,s,{get:()=>e[s],enumerable:!(r=Mn(e,s))||r.enumerable});return t};var In=t=>Ln(Qe({},"__esModule",{value:!0}),t);function F(){return Math.trunc(performance.now()*1e6)}function Me(){return Date.now()*1e6}var pe=U(()=>{"use strict"});function At(t,e){let n=new TextEncoder().encode(t.name);if(n.length===0||n.length>255)throw new Error(`encodeEnvelope: codec name "${t.name}" encodes to ${n.length} bytes (must be 1\u2013255)`);let r=t.version;if(!Number.isInteger(r)||r<0||r>65535)throw new Error(`encodeEnvelope: codec.version ${r} out of u16 range (expected integer 0\u201365535)`);let s=2+n.length+2+e.length;if(s>4294967295)throw new Error(`encodeEnvelope: total envelope size ${s} exceeds 2^32-1 bytes (payload ${e.length} bytes)`);let o=new Uint8Array(s),i=0;return o[i++]=ut,o[i++]=n.length,o.set(n,i),i+=n.length,o[i++]=r>>>8&255,o[i++]=r&255,o.set(e,i),o}function Dt(t,e){if(t.length<Mt)throw new Error(`decodeEnvelope: bytes too short (${t.length} < ${Mt})`);let n=0,r=t[n++];if(r!==ut)throw new Error(`decodeEnvelope: unsupported envelope version ${r} (expected ${ut})`);let s=t[n++];if(s===0)throw new Error("decodeEnvelope: name_len must be >= 1");if(n+s+2>t.length)throw new Error(`decodeEnvelope: envelope truncated (need ${n+s+2} bytes, have ${t.length})`);let o=new TextDecoder().decode(t.subarray(n,n+s));n+=s;let i=(t[n]<<8|t[n+1])>>>0;n+=2;let a=t.subarray(n),l=e.lookupCodec(o);if(l==null)throw new Error(`decodeEnvelope: codec "${o}" not registered (envelope codec_v=${i})`);return{codec:l,codecVersion:i,payload:a}}function Gt(t){t.registerCodec(Pn)}var Pn,ut,Mt,lt=U(()=>{"use strict";Pn={name:"json",version:1,contentType:"application/json",encode(t){let e=JSON.stringify(t);return new TextEncoder().encode(e)},decode(t,e){let n=new TextDecoder().decode(t);return JSON.parse(n)}},ut=1,Mt=4});function Ae(t){if(t==null)return ge;let{type:e,id:n,...r}=t;return{type:e??"system",id:n??"",...r}}var ge,ct=U(()=>{"use strict";ge={type:"system",id:""}});function De(){return me>0||ke}function Lt(){return me>0}function Oe(t){me>0?Te.push(t):t()}function It(t){me+=1;let e=!1;try{t()}catch(n){throw e=!0,n}finally{if(me-=1,me===0)if(e){if(!ke){let n=Te.splice(0);for(let r of n)try{r()}catch{}de.length=0,fe.length=0,be.length=0}}else $n()}}function $n(){let t=!ke;t&&(ke=!0);let e=[],n=0;try{for(;de.length>0||fe.length>0||be.length>0||t&&Te.length>0;){if(t&&Te.length>0){let o=Te.splice(0);for(let i of o)try{i()}catch(a){e.push(a)}continue}if(n+=1,n>1e3)throw de.length=0,fe.length=0,be.length=0,new Error("batch drain exceeded 1000 iterations \u2014 likely a reactive cycle");let s=(de.length>0?de:fe.length>0?fe:be).splice(0);for(let o of s)try{o()}catch(i){e.push(i)}}}finally{t&&(ke=!1)}if(e.length===1)throw e[0];if(e.length>1)throw new AggregateError(e,"batch drain: multiple callbacks threw")}function ye(t,e,n){if(e.length===0)return;if(e.length===1){let u=n(e[0][0]);if(u<3||!De()){t(e);return}(u>=5?be:u===4?fe:de).push(()=>t(e));return}let r=e.length,s=r,o=r,i=r,a=0;for(;a<r&&n(e[a][0])<3;)a++;for(s=a;a<r&&n(e[a][0])===3;)a++;for(o=a;a<r&&n(e[a][0])===4;)a++;i=a;let l=De();if(s>0){let u=e.slice(0,s);t(u)}if(o>s){let u=e.slice(s,o);l?de.push(()=>t(u)):t(u)}if(i>o){let u=e.slice(o,i);l?fe.push(()=>t(u)):t(u)}if(r>i){let u=e.slice(i,r);l?be.push(()=>t(u)):t(u)}}var me,ke,de,fe,be,Te,Ge=U(()=>{"use strict";me=0,ke=!1,de=[],fe=[],be=[],Te=[]});var Se,B,J,te,X,ne,ie,j,Z,$,ve,dt,Bn,ft,Fn,Hn,ht,Pt,$t,Bt,pt,Ne=U(()=>{"use strict";Se=Symbol.for("graphrefly/START"),B=Symbol.for("graphrefly/DATA"),J=Symbol.for("graphrefly/DIRTY"),te=Symbol.for("graphrefly/RESOLVED"),X=Symbol.for("graphrefly/INVALIDATE"),ne=Symbol.for("graphrefly/PAUSE"),ie=Symbol.for("graphrefly/RESUME"),j=Symbol.for("graphrefly/TEARDOWN"),Z=Symbol.for("graphrefly/COMPLETE"),$=Symbol.for("graphrefly/ERROR"),ve=Object.freeze([J]),dt=Object.freeze([te]),Bn=Object.freeze([X]),ft=Object.freeze([Se]),Fn=Object.freeze([Z]),Hn=Object.freeze([j]),ht=Object.freeze([ve]),Pt=Object.freeze([dt]),$t=Object.freeze([Bn]),Bt=Object.freeze([Fn]),pt=Object.freeze([Hn])});function Ft(t){t.registerMessageType(Se,{tier:0,wireCrossing:!1}),t.registerMessageType(J,{tier:1,wireCrossing:!1}),t.registerMessageType(X,{tier:1,wireCrossing:!1,metaPassthrough:!1}),t.registerMessageType(ne,{tier:2,wireCrossing:!1}),t.registerMessageType(ie,{tier:2,wireCrossing:!1}),t.registerMessageType(B,{tier:3,wireCrossing:!0}),t.registerMessageType(te,{tier:3,wireCrossing:!0}),t.registerMessageType(Z,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType($,{tier:4,wireCrossing:!0,metaPassthrough:!1}),t.registerMessageType(j,{tier:5,wireCrossing:!0,metaPassthrough:!1})}var Le,Ht=U(()=>{"use strict";Ne();Le=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=n=>{let r=this._messageTypes.get(n);return r!=null?r.tier:1}}get onMessage(){return this._frozen=!0,this._onMessage}get onSubscribe(){return this._frozen=!0,this._onSubscribe}set onMessage(e){this._assertUnfrozen(),this._onMessage=e}set onSubscribe(e){this._assertUnfrozen(),this._onSubscribe=e}get defaultVersioning(){return this._defaultVersioning}set defaultVersioning(e){this._assertUnfrozen(),this._defaultVersioning=e}get defaultHashFn(){return this._defaultHashFn}set defaultHashFn(e){this._assertUnfrozen(),this._defaultHashFn=e}get inspectorEnabled(){return this._inspectorEnabled}set inspectorEnabled(e){this._inspectorEnabled=e}get globalInspector(){return this._globalInspector}set globalInspector(e){this._globalInspector=e}registerMessageType(e,n){return this._assertUnfrozen(),this._messageTypes.set(e,{tier:n.tier,wireCrossing:n.wireCrossing??n.tier>=3,metaPassthrough:n.metaPassthrough??!0}),this}messageTier(e){let n=this._messageTypes.get(e);return n!=null?n.tier:1}isWireCrossing(e){let n=this._messageTypes.get(e);return n!=null?n.wireCrossing:!0}isLocalOnly(e){return!this.isWireCrossing(e)}isMetaPassthrough(e){let n=this._messageTypes.get(e);return n!=null?n.metaPassthrough:!0}isKnownMessageType(e){return this._messageTypes.has(e)}registerCodec(e){return this._assertUnfrozen(),this._codecs.set(e.name,e),this}lookupCodec(e){return this._codecs.get(e)}_isFrozen(){return this._frozen}_assertUnfrozen(){if(this._frozen)throw new Error("GraphReFlyConfig is frozen: a node has already captured this config. Register custom types and set hooks before creating any node.")}}});function gt(t){let e=jn.filter(n=>t({type:n,id:""},"write"));return e.length===0?"restricted":e.includes("human")&&e.includes("llm")&&e.every(n=>n==="human"||n==="llm"||n==="system")?"both":e.length===1?e[0]:e.join("+")}var K,jn,Ie=U(()=>{"use strict";K=class extends Error{actor;action;nodeName;constructor(e,n){super(n??`GuardDenied: action "${String(e.action)}" denied for actor type "${String(e.actor.type)}"`),this.name="GuardDenied",this.actor=e.actor,this.action=e.action,this.nodeName=e.nodeName}get node(){return this.nodeName}},jn=["human","llm","wallet","system"]});function mt(t){if(t===void 0)return null;if(typeof t=="number"){if(!Number.isFinite(t))throw new TypeError(`Cannot hash non-finite number: ${t}`);if(Number.isInteger(t)&&!Number.isSafeInteger(t))throw new TypeError(`Cannot hash integer outside safe range (|n| > 2^53-1): ${t}. Cross-language cid parity is not guaranteed for unsafe integers.`);return t}if(typeof t=="string"||typeof t=="boolean"||t===null)return t;if(Array.isArray(t))return t.map(mt);if(typeof t=="object"&&t!==null){let e={};for(let n of Object.keys(t).sort())e[n]=mt(t[n]);return e}return null}function zn(t){let e=Wn.encode(t),n=e.length,r=n*8,s=n+9+63&-64,o=new Uint8Array(s);o.set(e),o[n]=128;let i=new DataView(o.buffer);i.setUint32(s-4,r>>>0,!1),i.setUint32(s-8,Math.floor(r/4294967296)>>>0,!1);let a=1779033703,l=3144134277,u=1013904242,c=2773480762,f=1359893119,p=2600822924,h=528734635,d=1541459225,g=new Uint32Array(64),b=(v,y)=>v>>>y|v<<32-y;for(let v=0;v<s;v+=64){for(let S=0;S<16;S++)g[S]=i.getUint32(v+S*4,!1);for(let S=16;S<64;S++){let E=g[S-15],R=g[S-2],L=b(E,7)^b(E,18)^E>>>3,V=b(R,17)^b(R,19)^R>>>10;g[S]=g[S-16]+L+g[S-7]+V>>>0}let y=a,_=l,m=u,w=c,k=f,T=p,O=h,C=d;for(let S=0;S<64;S++){let E=b(k,6)^b(k,11)^b(k,25),R=k&T^~k&O,L=C+E+R+Vn[S]+g[S]>>>0,V=b(y,2)^b(y,13)^b(y,22),Y=y&_^y&m^_&m,ce=V+Y>>>0;C=O,O=T,T=k,k=w+L>>>0,w=m,m=_,_=y,y=L+ce>>>0}a=a+y>>>0,l=l+_>>>0,u=u+m>>>0,c=c+w>>>0,f=f+k>>>0,p=p+T>>>0,h=h+O>>>0,d=d+C>>>0}let x=v=>v.toString(16).padStart(8,"0");return x(a)+x(l)+x(u)+x(c)+x(f)+x(p)+x(h)+x(d)}function bt(t){let e=mt(t??null),n=JSON.stringify(e);return zn(n).slice(0,16)}function Un(){let t=globalThis.crypto;if(t?.randomUUID)return t.randomUUID();let e=()=>Math.floor(Math.random()*4294967296).toString(16).padStart(8,"0"),n=e()+e()+e()+e();return`${n.slice(0,8)}-${n.slice(8,12)}-4${n.slice(13,16)}-${(parseInt(n.slice(16,17),16)&3|8).toString(16)}${n.slice(17,20)}-${n.slice(20,32)}`}function yt(t,e,n){let r=n?.id??Un();if(t===0)return{id:r,version:0};let o=(n?.hash??bt)(e);return{id:r,version:0,cid:o,prev:null}}function jt(t,e,n){t.version+=1,"cid"in t&&(t.prev=t.cid,t.cid=n(e))}var Vn,Wn,Vt=U(()=>{"use strict";Vn=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]),Wn=new TextEncoder});function Ut(t){return{node:t,unsub:null,prevData:void 0,dirty:!1,involvedThisWave:!1,dataBatch:[],terminal:void 0}}function vt(t){t.prevData=void 0,t.dirty=!1,t.involvedThisWave=!1,t.dataBatch.length=0,t.terminal=void 0}function Pe(t){return t.length===0?t:typeof t[0]=="symbol"?[t]:t}function re(t,e,n){let r=Kt(t)?t:[],s=typeof t=="function"?t:typeof e=="function"?e:void 0,o={};return Kt(t)?o=(xt(e)?e:n)??{}:xt(t)?o=t:o=(xt(e)?e:n)??{},new I(r,s,o)}var Wt,zt,Kn,qn,ae,I,Kt,xt,se=U(()=>{"use strict";lt();ct();Ge();pe();Ht();Ie();Ne();Vt();Wt=()=>{},zt=100;Kn=(t,e,n,r)=>{n.direction==="down-in"&&t._onDepMessage(n.depIndex,e)},qn=(t,e,n,r)=>{let s=t;if(s._status==="completed"||s._status==="errored")return;let o=s._cached,i=o===void 0?[ft]:[ft,[B,o]];s._status==="dirty"&&i.push(ve),ye(e,i,s._config.tierOf)},ae=new Le({onMessage:Kn,onSubscribe:qn});Ft(ae);Gt(ae);I=class t{_optsName;_describeKind;meta;_hasMeta;_config;_deps;_sinks=null;_sinkCount=0;_cached;_status;_cleanup;_store={};_waveHasNewData=!1;_hasNewTerminal=!1;_hasCalledFnOnce=!1;_paused=!1;_pendingWave=!1;_isExecutingFn=!1;_pendingRerun=!1;_rerunDepth=0;_dirtyDepCount=0;_batchPendingMessages=null;_pauseLocks=null;_pauseBuffer=null;_fn;_equals;_resubscribable;_resetOnTeardown;_autoComplete;_autoError;_pausable;_partial;_guard;_extraGuards;_hashFn;_versioning;_versioningLevel;_lastMutation;_inspectorHooks;_actions;constructor(e,n,r){this._config=r.config??ae,this._config.onMessage,this._optsName=r.name,this._describeKind=r.describeKind,this._equals=r.equals??Object.is,this._resubscribable=r.resubscribable??!1,this._resetOnTeardown=r.resetOnTeardown??!1,this._autoComplete=r.completeWhenDepsComplete??!0,this._autoError=r.errorWhenDepsError??!0,this._pausable=r.pausable??!0,this._guard=r.guard,this._fn=n,this._partial=r.partial??!1,this._cached=r.initial!==void 0?r.initial:void 0,this._status=e.length===0&&n==null&&this._cached!==void 0?"settled":"sentinel",this._hashFn=r.versioningHash??this._config.defaultHashFn??bt;let s=r.versioning??this._config.defaultVersioning;this._versioningLevel=s,this._versioning=s!=null?yt(s,this._cached===void 0?void 0:this._cached,{id:r.versioningId,hash:this._hashFn}):void 0,this._deps=e.map(Ut);let o={};for(let[a,l]of Object.entries(r.meta??{})){let u={initial:l,name:`${r.name??"node"}:meta:${a}`,describeKind:"state",config:this._config};r.guard!=null&&(u.guard=r.guard),o[a]=new t([],void 0,u)}Object.freeze(o),this.meta=o,this._hasMeta=Object.keys(o).length>0;let i=this;this._actions={emit(a){i._emit([[B,a]])},down(a){i._emit(Pe(a))},up(a){i._emitUp(Pe(a))}},this.down=this.down.bind(this),this.up=this.up.bind(this)}get _isTerminal(){return this._status==="completed"||this._status==="errored"}get name(){return this._optsName}get status(){return this._status}get cache(){return this._cached===void 0?void 0:this._cached}get lastMutation(){return this._lastMutation}get v(){return this._versioning}hasGuard(){return this._guard!=null}_applyVersioning(e,n){if(this._isExecutingFn)throw new Error(`Node "${this.name}": _applyVersioning cannot run mid-fn \u2014 call it outside of \`_execFn\` (typically at graph setup time before the first subscribe).`);let r=this._versioningLevel;if(r!=null&&e<=r)return;let s=n?.hash??this._hashFn;s!==this._hashFn&&(this._hashFn=s);let o=this._cached===void 0?void 0:this._cached,i=this._versioning,a=i?.id??n?.id,l=i?.version??0,u=yt(e,o,{id:a,hash:s});u.version=l,this._versioning=u,this._versioningLevel=e}_setInspectorHook(e){return e==null?()=>{}:(this._inspectorHooks==null&&(this._inspectorHooks=new Set),this._inspectorHooks.add(e),()=>{this._inspectorHooks?.delete(e),this._inspectorHooks?.size===0&&(this._inspectorHooks=void 0)})}_pushGuard(e){return this._extraGuards==null&&(this._extraGuards=new Set),this._extraGuards.add(e),()=>{this._extraGuards?.delete(e),this._extraGuards?.size===0&&(this._extraGuards=void 0)}}allowsObserve(e){if(this._guard==null&&this._extraGuards==null)return!0;let n=Ae(e);if(this._guard!=null&&!this._guard(n,"observe"))return!1;if(this._extraGuards!=null){for(let r of this._extraGuards)if(!r(n,"observe"))return!1}return!0}_checkGuard(e){if(e?.internal)return;let n=this._guard!=null||this._extraGuards!=null,r=e?.actor!=null;if(!n&&!r)return;let s=Ae(e?.actor),o=e?.delivery==="signal"?"signal":"write";if(this._guard!=null&&!this._guard(s,o))throw new K({actor:s,action:o,nodeName:this.name});if(this._extraGuards!=null){for(let i of this._extraGuards)if(!i(s,o))throw new K({actor:s,action:o,nodeName:this.name})}this._lastMutation={actor:s,timestamp_ns:Me()}}down(e,n){let r=Pe(e);r.length!==0&&(this._checkGuard(n),this._emit(r))}emit(e,n){this._checkGuard(n),this._emit([[B,e]])}up(e,n){if(this._deps.length===0)return;let r=Pe(e);if(r.length===0)return;this._checkGuard(n);let s=n??{internal:!0};this._validateUpTiers(r);for(let o of this._deps)o.node.up?.(r,s)}_emitUp(e){if(this._deps.length!==0&&e.length!==0){this._validateUpTiers(e);for(let n of this._deps)n.node.up?.(e,{internal:!0})}}_validateUpTiers(e){let n=this._config.tierOf;for(let r of e){let s=n(r[0]);if(s===3||s===4)throw new Error(`Node "${this.name}": tier-${s} messages cannot flow up \u2014 DATA/RESOLVED/COMPLETE/ERROR are downstream-only. Use \`down(...)\` for value delivery; \`up(...)\` is for control signals (DIRTY, INVALIDATE, PAUSE, RESUME, TEARDOWN).`)}}subscribe(e,n){if(n!=null&&this._guard!=null){let l=Ae(n);if(!this._guard(l,"observe"))throw new K({actor:l,action:"observe",nodeName:this.name})}let s=this._isTerminal&&this._resubscribable;if(s){this._cached=void 0,this._status="sentinel",this._store={},this._hasCalledFnOnce=!1,this._waveHasNewData=!1,this._hasNewTerminal=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._isExecutingFn=!1,this._rerunDepth=0,this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null;for(let l of this._deps)vt(l);if(this._partial===!1){for(let l of this._deps)if(l.prevData!==void 0||l.dataBatch.length!==0||l.terminal!==void 0||l.dirty)throw new Error(`resubscribable-reset invariant: DepRecord not fully reset for node ${this._optsName??"(anonymous)"}`)}}this._sinkCount+=1;let o;try{o=this._config.onSubscribe(this,e,{sinkCount:this._sinkCount,afterTerminalReset:s},this._actions)}catch(l){throw this._sinkCount-=1,l}this._sinks==null?this._sinks=e:typeof this._sinks=="function"?this._sinks=new Set([this._sinks,e]):this._sinks.add(e);let i=this._isTerminal;if(this._sinkCount===1&&!i)try{this._activate()}catch(l){if(this._sinkCount-=1,this._removeSink(e),this._sinkCount===0&&(this._status="sentinel"),typeof o=="function")try{o()}catch{}throw l}this._status==="sentinel"&&this._cached===void 0&&(this._status="pending");let a=!1;return()=>{a||(a=!0,this._sinkCount-=1,this._removeSink(e),typeof o=="function"&&o(),this._sinks==null&&this._deactivate())}}_removeSink(e){if(this._sinks===e)this._sinks=null;else if(this._sinks!=null&&typeof this._sinks!="function")if(this._sinks.delete(e),this._sinks.size===1){let[n]=this._sinks;this._sinks=n}else this._sinks.size===0&&(this._sinks=null)}_activate(){if(this._deps.length===0){this._fn&&this._execFn();return}this._dirtyDepCount=0;let e=this._deps.length,n=0;try{for(let r=0;r<e;r++){let s=r,o=this._deps[r];o.unsub=Wt,o.unsub=o.node.subscribe(i=>{if(o.unsub===null)return;let a=this._config.tierOf,l=!1;for(let u of i)a(u[0])>=3&&(l=!0),this._config.onMessage(this,u,{direction:"down-in",depIndex:s},this._actions);l&&this._maybeRunFnOnSettlement()}),n++}}catch(r){this._deps[n].unsub=null;for(let s=0;s<n;s++){let o=this._deps[s];if(o.unsub!=null){let i=o.unsub;o.unsub=null;try{i()}catch{}vt(o)}}throw this._dirtyDepCount=0,r}}_addDep(e){for(let s=0;s<this._deps.length;s++)if(this._deps[s].node===e)return s;let n=this._deps.length,r=Ut(e);if(this._deps.push(r),this._sinks==null)return n;r.dirty=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ht),r.unsub=Wt;try{r.unsub=e.subscribe(s=>{if(r.unsub===null)return;let o=this._config.tierOf,i=!1;for(let a of s)o(a[0])>=3&&(i=!0),this._config.onMessage(this,a,{direction:"down-in",depIndex:n},this._actions);i&&this._maybeRunFnOnSettlement()})}catch(s){throw r.unsub=null,this._deps.pop(),this._dirtyDepCount--,s}return n}_deactivate(e=!1){let n=this._cleanup;if(this._cleanup=void 0,typeof n=="function")try{n()}catch(r){this._emit([[$,this._wrapFnError("cleanup threw",r)]])}else if(n!=null&&typeof n=="object"){let r=n.deactivate;if(typeof r=="function")try{r()}catch(s){this._emit([[$,this._wrapFnError("cleanup.deactivate threw",s)]])}}for(let r of this._deps){if(r.unsub!=null){let s=r.unsub;r.unsub=null;try{s()}catch{}}vt(r)}this._waveHasNewData=!1,this._hasNewTerminal=!1,this._hasCalledFnOnce=!1,this._paused=!1,this._pendingWave=!1,this._pendingRerun=!1,this._rerunDepth=0,this._store={},this._dirtyDepCount=0,this._pauseLocks=null,this._pauseBuffer=null,this._fn!=null&&(this._cached=void 0),e||(this._fn!=null||this._deps.length>0)&&(!this._isTerminal||this._resubscribable)&&(this._status="sentinel")}_onDepMessage(e,n){let r=this._deps[e],s=n[0];if(this._inspectorHooks!=null){let o={kind:"dep_message",depIndex:e,message:n};for(let i of this._inspectorHooks)i(o)}if(s!==Se){if(s===J){this._depDirtied(r);return}if(s===X){if(this._depInvalidated(r),this._cached===void 0)return;this._emit($t);return}if(s===ne||s===ie){this._emit([n]);return}if(s===j){this._emit(pt);return}if(s===B)this._depSettledAsData(r,n[1]);else if(s===te)this._depSettledAsResolved(r);else if(s===Z)this._depSettledAsTerminal(r,!0);else if(s===$)this._depSettledAsTerminal(r,n[1]);else{this._emit([n]);return}if(!this._fn){(s===B||s===te)&&this._emit([n]),(s===Z||s===$)&&this._maybeAutoTerminalAfterWave();return}}}_depDirtied(e){e.dirty||(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++,this._status!=="dirty"&&this._emit(ht))}_depSettledAsData(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.involvedThisWave=!0,e.dataBatch.push(n),this._waveHasNewData=!0}_depSettledAsResolved(e){e.dirty&&(e.dirty=!1,this._dirtyDepCount--)}_depSettledAsTerminal(e,n){e.dirty&&(e.dirty=!1,this._dirtyDepCount--),e.terminal=n,e.involvedThisWave=!0,this._hasNewTerminal=!0}_depInvalidated(e){e.prevData=void 0,e.terminal=void 0,e.dataBatch.length=0,e.dirty?e.involvedThisWave=!1:(e.dirty=!0,e.involvedThisWave=!0,this._dirtyDepCount++)}_maybeRunFnOnSettlement(){if(!(this._isTerminal&&!this._resubscribable)&&!(this._dirtyDepCount>0)){if(!this._partial&&!this._hasCalledFnOnce)for(let e=0;e<this._deps.length;e++){let n=this._deps[e];if(n.dataBatch.length===0&&n.prevData===void 0&&n.terminal===void 0){this._maybeAutoTerminalAfterWave();return}}if(this._paused){this._pendingWave=!0;return}if(!this._waveHasNewData&&!this._hasNewTerminal&&this._hasCalledFnOnce){this._clearWaveFlags(),this._emit(Pt),this._maybeAutoTerminalAfterWave();return}this._fn&&this._execFn(),this._maybeAutoTerminalAfterWave()}}_maybeAutoTerminalAfterWave(){if(this._deps.length===0||this._isTerminal)return;let e=this._deps.find(n=>n.terminal!==void 0&&n.terminal!==!0);if(e!=null){this._autoError&&this._emit([[$,e.terminal]]);return}this._autoComplete&&this._deps.every(n=>n.terminal!==void 0)&&this._emit(Bt)}_execFn(){if(!this._fn||this._isTerminal&&!this._resubscribable)return;if(this._isExecutingFn){this._pendingRerun=!0;return}let e=this._cleanup;if(typeof e=="function"){this._cleanup=void 0;try{e()}catch(i){this._emit([[$,this._wrapFnError("cleanup threw",i)]]);return}}else if(e!=null&&typeof e=="object"){let i=e.beforeRun;if(typeof i=="function"){e.beforeRun=void 0;try{i()}catch(a){this._emit([[$,this._wrapFnError("cleanup.beforeRun threw",a)]]);return}}}let n=this._deps.map(i=>i.involvedThisWave?i.dataBatch.length>0?[...i.dataBatch]:[]:void 0),r=this._deps.map(i=>i.prevData);for(let i=0;i<this._deps.length;i++){let a=n[i];a!=null&&a.length>0&&(this._deps[i].prevData=a[a.length-1])}let s=this._deps.map(i=>i.terminal),o={prevData:r,terminalDeps:s,store:this._store};if(this._hasCalledFnOnce=!0,this._clearWaveFlags(),this._inspectorHooks!=null){let i={kind:"run",batchData:n,prevData:r};for(let a of this._inspectorHooks)a(i)}this._isExecutingFn=!0;try{let i=this._fn(n,this._actions,o);if(typeof i=="function")this._cleanup=i;else if(i!=null&&typeof i=="object"){let a=i;(typeof a.beforeRun=="function"||typeof a.deactivate=="function"||typeof a.invalidate=="function")&&(this._cleanup=i)}}catch(i){this._emit([[$,this._wrapFnError("fn threw",i)]])}finally{this._isExecutingFn=!1,this._pendingRerun?(this._pendingRerun=!1,this._rerunDepth+=1,this._rerunDepth>zt?(this._rerunDepth=0,this._emit([[$,new Error(`Node "${this.name}": _pendingRerun depth exceeded ${zt} \u2014 likely a reactive cycle`)]])):this._maybeRunFnOnSettlement()):this._rerunDepth=0,this._clearWaveFlags()}}_clearWaveFlags(){this._waveHasNewData=!1,this._hasNewTerminal=!1;for(let e of this._deps)e.involvedThisWave=!1,e.dataBatch.length=0}_wrapFnError(e,n){let r=n instanceof Error?n.message:String(n);return new Error(`Node "${this.name}": ${e}: ${r}`,{cause:n})}_frameBatch(e){let n=this._config.tierOf;if(e.length===1)return n(e[0][0])===3&&this._status!=="dirty"?[ve,e[0]]:e;let r=!0,s=!1,o=!1,i=-1;for(let l of e){let u=n(l[0]);u<i&&(r=!1),u===3&&(s=!0),l[0]===J&&(o=!0),i=u}let a=e;if(!r){let l=e.map((u,c)=>({m:u,i:c,tier:n(u[0])}));l.sort((u,c)=>u.tier-c.tier||u.i-c.i),a=l.map(u=>u.m)}if(s&&!o&&this._status!=="dirty"){let l=0;for(;l<a.length&&n(a[l][0])===0;)l++;return l===0?[ve,...a]:[...a.slice(0,l),ve,...a.slice(l)]}return a}_emit(e){if(e.length===0)return;for(let a=0;a<e.length;a++){let l=e[a];if(l[0]===$&&l[1]===void 0)throw new TypeError('[ERROR, payload] requires a non-undefined payload (spec \xA71.2). Pass an Error object or domain tag instead \u2014 e.g. node.down([[ERROR, new Error("reason")]])')}let n=e;if(this._isTerminal&&!this._resubscribable){let a=e.filter(l=>l[0]===j||l[0]===X);if(a.length===0)return;n=a}n=this._frameBatch(n);let s=null;for(let a=0;a<n.length;a++){let l=n[a],u=l[0];if(u!==ne&&u!==ie){s?.push(l);continue}if(l.length<2)throw new Error(`Node "${this.name}": [[${u===ne?"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 f=l[1];if(u===ne)this._pauseLocks==null&&(this._pauseLocks=new Set),this._pauseLocks.add(f),this._paused=!0,this._pausable==="resumeAll"&&this._pauseBuffer==null&&(this._pauseBuffer=[]);else if(this._pauseLocks==null||!this._pauseLocks.has(f))c=!1;else if(this._pauseLocks.delete(f),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?s?.push(l):s==null&&(s=n.slice(0,a))}if(s!=null){if(s.length===0)return;n=s}if(this._hasMeta&&n.some(a=>a[0]===j))for(let a of Object.keys(this.meta))try{this.meta[a]._emit(pt)}catch{}let{finalMessages:o,equalsError:i}=this._updateState(n);if(o.length>0&&this._config.inspectorEnabled){let a=this._config.globalInspector;if(a!=null)try{a({kind:"emit",node:this,messages:o})}catch{}}if(o.length>0)if(this._paused&&this._pausable==="resumeAll"&&this._pauseBuffer!=null){let a=this._config.tierOf,l=[];for(let u of o)a(u[0])===3?this._pauseBuffer.push(u):l.push(u);l.length>0&&this._dispatchOrAccumulate(l)}else this._dispatchOrAccumulate(o);i!=null&&this._emit([[$,i]])}_updateState(e){let n=this._config.tierOf,r,s,o=-1,i=0;for(let c of e)n(c[0])===3&&i++;let a=i<=1,l=-1;if(this._versioning!=null&&i>1){for(let c=e.length-1;c>=0;c--)if(e[c][0]===B){l=c;break}}for(let c=0;c<e.length;c++){let f=e[c],p=f[0];if(p===B){if(f.length>=2){let h=!1;if(a&&this._cached!==void 0)try{h=this._equals(this._cached,f[1])}catch(d){s=this._wrapFnError("equals threw",d),o=c;break}if(h){r==null&&(r=e.slice(0,c)),r.push(dt),this._status="resolved";continue}this._cached=f[1],this._versioning!=null&&(l<0||c===l)&&jt(this._versioning,f[1],this._hashFn)}this._status="settled",r?.push(f)}else if(r?.push(f),p===J)this._status="dirty";else if(p===te)this._status="resolved";else if(p===Z)this._status="completed";else if(p===$)this._status="errored";else if(p===X){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 d=h.invalidate;if(typeof d=="function")try{d()}catch{}}}else p===j&&(this._resetOnTeardown&&(this._cached=void 0),this._deactivate(!0),this._status="sentinel")}let u=o>=0?r??e.slice(0,o):r??e;return s!=null?{finalMessages:u,equalsError:s}:{finalMessages:u}}_deliverToSinks=e=>{if(this._sinks==null)return;if(typeof this._sinks=="function"){this._sinks(e);return}let n=[...this._sinks];for(let r of n)r(e)};_dispatchOrAccumulate(e){if(Lt()){this._batchPendingMessages===null&&(this._batchPendingMessages=[],Oe(()=>this._flushBatchPending()));for(let n of e)this._batchPendingMessages.push(n);return}ye(this._deliverToSinks,e,this._config.tierOf)}_flushBatchPending(){let e=this._batchPendingMessages;if(e===null||(this._batchPendingMessages=null,e.length===0))return;let n=this._frameBatch(e);ye(this._deliverToSinks,n,this._config.tierOf)}},Kt=t=>Array.isArray(t),xt=t=>typeof t=="object"&&t!=null&&!Array.isArray(t)});function G(t,e){return re([],{...e,initial:t})}function qt(t,e){return re((r,s,o)=>t(s,o)??void 0,{describeKind:"producer",...e})}function q(t,e,n){return re(t,(s,o,i)=>{let a=s.map((l,u)=>l!=null&&l.length>0?l.at(-1):i.prevData[u]);o.emit(e(a,i))},{describeKind:"derived",...n})}var Ee=U(()=>{"use strict";se()});function _t(t){return t.subscribe(()=>{})}var Yt=U(()=>{"use strict"});var Be,Jt=U(()=>{"use strict";Be=class{_timer;_gen=0;start(e,n){this.cancel(),this._gen+=1;let r=this._gen;this._timer=setTimeout(()=>{this._timer=void 0,r===this._gen&&n()},e)}cancel(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}get pending(){return this._timer!==void 0}}});var ts={};Gn(ts,{CanvasMeasureAdapter:()=>st,CliMeasureAdapter:()=>tt,ImageSizeAdapter:()=>at,NodeCanvasMeasureAdapter:()=>ot,PrecomputedAdapter:()=>rt,SvgBoundsAdapter:()=>it,analyzeAndMeasure:()=>we,carveTextLineSlots:()=>Et,circleIntervalForBand:()=>En,computeBlockFlow:()=>Sn,computeCharPositions:()=>qe,computeFlowLines:()=>Rn,computeLineBreaks:()=>Ke,computeTotalHeight:()=>Nn,layoutNextLine:()=>Nt,measureBlock:()=>Tn,measureBlocks:()=>On,reactiveBlockLayout:()=>Zr,reactiveFlowLayout:()=>es,reactiveLayout:()=>Xr,rectIntervalForBand:()=>Cn});module.exports=In(ts);function et(t){return t>=768&&t<=879||t>=1155&&t<=1161||t>=1425&&t<=1469||t>=1552&&t<=1562||t>=1611&&t<=1631||t>=1648&&t===1648||t>=1750&&t<=1756||t>=1759&&t<=1764||t>=1767&&t<=1768||t>=1770&&t<=1773||t>=1840&&t<=1866||t>=1958&&t<=1968||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2641||t>=2672&&t<=2673||t>=2677&&t===2677||t>=3633&&t===3633||t>=3636&&t<=3642||t>=3655&&t<=3662||t>=3761&&t===3761||t>=3764&&t<=3772||t>=3784&&t<=3790||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65024&&t<=65039||t>=65056&&t<=65071||t===8205?0:t>=4352&&t<=4447||t>=8986&&t<=8987||t>=9001&&t<=9002||t>=9193&&t<=9203||t>=9208&&t<=9210||t>=9725&&t<=9726||t>=9748&&t<=9749||t>=9800&&t<=9811||t===9855||t===9875||t===9889||t>=9898&&t<=9899||t>=9917&&t<=9918||t>=9924&&t<=9925||t===9934||t===9940||t===9962||t>=9970&&t<=9971||t===9973||t===9978||t===9981||t===9986||t===9989||t>=9992&&t<=9997||t===9999||t>=10067&&t<=10069||t===10071||t>=10133&&t<=10135||t===10160||t===10175||t>=10548&&t<=10549||t>=11013&&t<=11015||t>=11035&&t<=11036||t===11088||t===11093||t>=11904&&t<=12350||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12784&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=19968&&t<=40959||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65131||t>=65281&&t<=65376||t>=65504&&t<=65510||t>=126980&&t===126980||t===127183||t>=127344&&t<=127345||t===127358||t===127359||t===127374||t>=127377&&t<=127386||t>=127456&&t<=127487||t>=127488&&t<=127490||t===127514||t===127535||t>=127538&&t<=127546||t>=127568&&t<=127569||t>=127744&&t<=129535||t>=129536&&t<=129791||t>=129792&&t<=130047||t>=131072&&t<=196605||t>=196608&&t<=262141?2:1}function he(t){let e=0;for(let n of t)e+=et(n.codePointAt(0));return e}function Rt(t,e){if(e<=0)return"";let n=0,r="";for(let s of t){let o=et(s.codePointAt(0));if(n+o>e){if(e<=1)return"\u2026";for(;n+1>e&&r.length>0;){let i=[...r].pop();r=r.slice(0,-i.length),n-=et(i.codePointAt(0))}return`${r}\u2026`}r+=s,n+=o}return r}var tt=class{cellPx;constructor(e){this.cellPx=e?.cellPx??8}measureSegment(e,n){return{width:he(e)*this.cellPx}}},nt=class extends Error{name="KeyError"},rt=class{metrics;fallback;constructor(e){this.metrics=e.metrics;let n=e.fallback??"per-char";if(n!=="per-char"&&n!=="error")throw new Error(`fallback must be 'per-char' or 'error', got ${JSON.stringify(e.fallback)}`);this.fallback=n}measureSegment(e,n){let r=this.metrics[n];if(r){let o=r[e];if(o!==void 0)return{width:o}}if(this.fallback==="error")throw new nt(`PrecomputedAdapter: no metrics for segment ${JSON.stringify(e)} in font ${JSON.stringify(n)}`);let s=0;if(r)for(let o of e){let i=r[o];i!==void 0&&(s+=i)}return{width:s}}},st=class{ctx=null;currentFont="";emojiCorrection;constructor(e){this.emojiCorrection=e?.emojiCorrection??1}getContext(){if(!this.ctx){if(typeof OffscreenCanvas>"u")throw new Error("CanvasMeasureAdapter requires a browser environment with OffscreenCanvas support. Use CliMeasureAdapter or NodeCanvasMeasureAdapter for Node.js.");let n=new OffscreenCanvas(0,0).getContext("2d");if(!n)throw new Error("CanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(e,n){let r=this.getContext();n!==this.currentFont&&(r.font=n,this.currentFont=n);let s=r.measureText(e).width;return this.emojiCorrection!==1&&new RegExp("\\p{Emoji_Presentation}","u").test(e)&&(s*=this.emojiCorrection),{width:s}}clearCache(){this.currentFont=""}},ot=class{ctx=null;currentFont="";canvasModule;constructor(e){this.canvasModule=e}getContext(){if(!this.ctx){let n=this.canvasModule.createCanvas(0,0).getContext("2d");if(!n)throw new Error("NodeCanvasMeasureAdapter: failed to get 2d context");this.ctx=n}return this.ctx}measureSegment(e,n){let r=this.getContext();return n!==this.currentFont&&(r.font=n,this.currentFont=n),{width:r.measureText(e).width}}clearCache(){this.currentFont=""}},it=class{measureSvg(e){let n=e.match(/viewBox\s*=\s*["']([^"']+)["']/);if(n){let o=n[1].trim().split(/[\s,]+/);if(o.length>=4){let i=Number.parseFloat(o[2]),a=Number.parseFloat(o[3]);if(Number.isFinite(i)&&Number.isFinite(a)&&i>0&&a>0)return{width:i,height:a};throw new Error("SvgBoundsAdapter: viewBox width/height are missing, non-finite, or not positive")}}let r=e.match(/<svg[^>]*\bwidth\s*=\s*["']?([\d.]+)/),s=e.match(/<svg[^>]*\bheight\s*=\s*["']?([\d.]+)/);if(r&&s){let o=Number.parseFloat(r[1]),i=Number.parseFloat(s[1]);if(Number.isFinite(o)&&Number.isFinite(i)&&o>0&&i>0)return{width:o,height:i};throw new Error("SvgBoundsAdapter: svg width/height attributes are non-finite or not positive")}throw new Error("SvgBoundsAdapter: cannot determine dimensions \u2014 SVG has no viewBox or width/height attributes")}},at=class{sizes;constructor(e){this.sizes=new Map(Object.entries(e))}measureImage(e){let n=this.sizes.get(e);if(!n)throw new Error(`ImageSizeAdapter: no dimensions registered for ${JSON.stringify(e)}`);return{width:n.width,height:n.height}}};pe();se();Ee();ct();Ge();pe();Ie();Ne();Ie();se();function $e(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 Yn(t){return t._describeKind!=null?t._describeKind:t._deps.length>0?"derived":t._fn!=null?"producer":"state"}function Jn(t){let e={};for(let[n,r]of Object.entries(t.meta))try{e[n]=r.cache}catch{}return e}function wt(t,e){let n=e==null,r=!n&&e!=null?[...e].filter(u=>u.startsWith("meta.")).map(u=>u.slice(5)):null,s=n||e.has("meta")||r!=null&&r.length>0,o="state",i=[];t instanceof I&&(o=Yn(t),i=t._deps.map(u=>u.node.name??""));let a={type:o,deps:i};(n||e.has("status"))&&(a.status=t.status);let l=t instanceof I?t._guard:void 0;if(s){let u={...Jn(t)};if(l!=null&&u.access===void 0&&(u.access=gt(l)),r!=null&&r.length>0&&!e.has("meta")){let c={};for(let f of r)f in u&&(c[f]=u[f]);a.meta=c}else a.meta=u}if(t.name!=null&&(a.name=t.name),n||e.has("value")){t.status==="sentinel"&&(a.sentinel=!0);try{a.value=t.cache}catch{}}if((n||e.has("v"))&&t.v!=null){let u={id:t.v.id,version:t.v.version};"cid"in t.v&&(u.cid=t.v.cid,u.prev=t.v.prev),a.v=u}return(n||e.has("guard"))&&l!=null&&(a.guard=gt(l)),(n||e.has("lastMutation"))&&t.lastMutation!=null&&(a.lastMutation=t.lastMutation),a}se();Ee();Yt();Jt();var Ce=class{constructor(e){this.capacity=e;if(!Number.isInteger(e)||e<=0)throw new Error(`RingBuffer capacity must be a positive integer (got ${e})`);this.buf=new Array(e)}buf;head=0;_size=0;get size(){return this._size}get maxSize(){return this.capacity}push(e){let n=(this.head+this._size)%this.capacity;this.buf[n]=e,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity}shift(){if(this._size===0)return;let e=this.buf[this.head];return this.buf[this.head]=void 0,this.head=(this.head+1)%this.capacity,this._size--,e}at(e){if(this._size===0)return;let n=e<0?this._size+e:e;if(!(n<0||n>=this._size))return this.buf[(this.head+n)%this.capacity]}toArray(){let e=new Array(this._size);for(let n=0;n<this._size;n++)e[n]=this.buf[(this.head+n)%this.capacity];return e}clear(){for(let e=0;e<this._size;e++)this.buf[(this.head+e)%this.capacity]=void 0;this.head=0,this._size=0}};lt();var Xn={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"},Zn={horizontal:"-",vertical:"|",cornerTL:"+",cornerTR:"+",cornerBL:"+",cornerBR:"+",tDown:"+",tUp:"+",tRight:"+",tLeft:"+",cross:"+",arrowRight:">",arrowDown:"v",arrowLeft:"<",arrowUp:"^",boxTL:"+",boxTR:"+",boxBL:"+",boxBR:"+",boxH:"-",boxV:"|"};function en(t,e){let n=e.charset==="ascii"?Zn:Xn,r=t.width,s=t.height,o=Array.from({length:s},()=>Array.from({length:r},()=>" ")),i=Array.from({length:s},()=>Array.from({length:r},()=>"empty"));for(let a of t.edges)er(o,i,n,a);for(let a of t.boxes)Qn(o,i,n,a,e.labelOf(a.id));return o.map(a=>sr(a.join(""))).join(`
2
2
  `)}function Qn(t,e,n,r,s){let{x:o,y:i,w:a,h:l}=r;if(a<2||l<2){l>0&&Xt(t,e,o,i,a,s);return}ue(t,e,o,i,n.boxTL);for(let c=o+1;c<o+a-1;c+=1)ue(t,e,c,i,n.boxH);ue(t,e,o+a-1,i,n.boxTR);for(let c=i+1;c<i+l-1;c+=1){ue(t,e,o,c,n.boxV);for(let f=o+1;f<o+a-1;f+=1)tn(t,e,f,c," ","empty");ue(t,e,o+a-1,c,n.boxV)}ue(t,e,o,i+l-1,n.boxBL);for(let c=o+1;c<o+a-1;c+=1)ue(t,e,c,i+l-1,n.boxH);ue(t,e,o+a-1,i+l-1,n.boxBR);let u=i+Math.floor(l/2);Xt(t,e,o+1,u,a-2,s)}function ue(t,e,n,r,s){tn(t,e,n,r,s,s===" "?"empty":s==="\u2500"||s==="-"?"boxH":s==="\u2502"||s==="|"?"boxV":"boxCorner")}function tn(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];n<0||n>=i.length||(i[n]=s,e[r][n]=o)}function Xt(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=n,a=s;for(let l of o){let u=he(l);if(u!==0){if(a<u)break;i>=0&&i<t[r].length&&(t[r][i]=l,e[r][i]="label",u===2&&i+1<t[r].length&&(t[r][i+1]="",e[r][i+1]="label")),i+=u,a-=u}}for(;a>0;)i>=0&&i<t[r].length&&(t[r][i]=" ",e[r][i]="empty"),i+=1,a-=1}function er(t,e,n,r){let s=r.points;if(s.length<2)return;for(let l=0;l+1<s.length;l+=1)tr(t,e,n,s[l],s[l+1]);for(let l=1;l+1<s.length;l+=1){let u=s[l-1],c=s[l],f=s[l+1],p=nr(u,c,f,n);p&&Qt(t,e,c.x,c.y,p,"edgeCorner")}let o=s[s.length-1],i=s[s.length-2],a=rr(i,o,n);a&&Qt(t,e,o.x,o.y,a,"arrow")}function tr(t,e,n,r,s){if(!(r.x===s.x&&r.y===s.y)){if(r.y===s.y){let o=r.y,i=Math.min(r.x,s.x),a=Math.max(r.x,s.x);for(let l=i;l<=a;l+=1)Zt(t,e,l,o,n,"h")}else if(r.x===s.x){let o=r.x,i=Math.min(r.y,s.y),a=Math.max(r.y,s.y);for(let l=i;l<=a;l+=1)Zt(t,e,o,l,n,"v")}}}function Zt(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];if(!(a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label")){if(a==="empty"){i[n]=o==="h"?s.horizontal:s.vertical,e[r][n]=o==="h"?"edgeH":"edgeV";return}if(a==="edgeH"&&o==="v"){i[n]=s.cross,e[r][n]="edgeCorner";return}if(a==="edgeV"&&o==="h"){i[n]=s.cross,e[r][n]="edgeCorner";return}}}function Qt(t,e,n,r,s,o){if(r<0||r>=t.length)return;let i=t[r];if(n<0||n>=i.length)return;let a=e[r][n];a==="boxH"||a==="boxV"||a==="boxCorner"||a==="label"||(i[n]=s,e[r][n]=o)}function nr(t,e,n,r){let s=t.y===e.y,o=e.y===n.y;if(s===o)return;if(s){let l=t.x<e.x,u=n.y>e.y;return l&&u?r.cornerTR:l&&!u?r.cornerBR:!l&&u?r.cornerTL:r.cornerBL}let i=t.y<e.y,a=n.x>e.x;return i&&a?r.cornerBL:i&&!a?r.cornerBR:!i&&a?r.cornerTL:r.cornerTR}function rr(t,e,n){if(e.x>t.x)return n.arrowRight;if(e.x<t.x)return n.arrowLeft;if(e.y>t.y)return n.arrowDown;if(e.y<t.y)return n.arrowUp}function sr(t){let e=t.length;for(;e>0&&t.charCodeAt(e-1)===32;)e-=1;return t.slice(0,e)}function sn(t){let e=or(t);ir(e),ar(e),ur(e),lr(e,t);let n=fr(e,t),{width:r,height:s}=pr(e),o=[];for(let i of e.layers)for(let a of i)a.isVirtual||o.push({id:a.id,layer:a.layer,order:a.order,x:a.x,y:a.y,w:a.w,h:a.h});return{boxes:o,edges:n,width:r,height:s}}function or(t){let e=new Map;for(let s of t.nodes)e.set(s,{id:s,isVirtual:!1,layer:-1,order:0,x:0,y:0,w:t.widthCells(s),h:t.heightCells(s),in:[],out:[]});let n=[],r=0;for(let s of t.edges){if(s.from===s.to)continue;let o=e.get(s.from),i=e.get(s.to);if(!o||!i)continue;let a={chainId:r++,chainFrom:s.from,chainTo:s.to,fromId:s.from,toId:s.to,hopIndex:0,chainLen:1};o.out.push(a),i.in.push(a),n.push(a)}return{nodes:e,layers:[],hops:n}}function ir(t){let e=new Map;for(let o of t.nodes.values())e.set(o.id,o.in.length);let n=[];for(let o of t.nodes.values())(e.get(o.id)??0)===0&&(o.layer=0,n.push(o));let r=new Set,s=0;for(;s<n.length;){let o=n[s++];if(!r.has(o.id)){r.add(o.id);for(let i of o.out){let a=t.nodes.get(i.toId);a.layer=Math.max(a.layer,o.layer+1);let l=(e.get(a.id)??0)-1;e.set(a.id,l),l<=0&&n.push(a)}}}for(let o of t.nodes.values())o.layer<0&&(o.layer=0)}function ar(t){let e=Math.max(0,...Array.from(t.nodes.values(),o=>o.layer)),n=Array.from({length:e+1},()=>[]);for(let o of t.nodes.values())n[o.layer].push(o);let r=[],s=0;for(let o of t.hops){let i=t.nodes.get(o.fromId),a=t.nodes.get(o.toId),l=a.layer-i.layer;if(l<=0){i.out=i.out.filter(f=>f!==o),a.in=a.in.filter(f=>f!==o);continue}if(l===1){o.hopIndex=0,o.chainLen=1,r.push(o);continue}i.out=i.out.filter(f=>f!==o),a.in=a.in.filter(f=>f!==o);let u=i;for(let f=1;f<l;f+=1){let p=`__virt_${s++}__`,h={id:p,isVirtual:!0,layer:i.layer+f,order:0,x:0,y:0,w:0,h:1,in:[],out:[]};t.nodes.set(p,h),n[h.layer].push(h);let d={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:p,hopIndex:f-1,chainLen:l};u.out.push(d),h.in.push(d),r.push(d),u=h}let c={chainId:o.chainId,chainFrom:o.chainFrom,chainTo:o.chainTo,fromId:u.id,toId:a.id,hopIndex:l-1,chainLen:l};u.out.push(c),a.in.push(c),r.push(c)}for(let o of n)for(let i=0;i<o.length;i+=1)o[i].order=i;t.layers=n,t.hops=r}function ur(t){for(let n=0;n<4;n+=1){for(let r=1;r<t.layers.length;r+=1)nn(t,t.layers[r],"in"),Fe(t.layers[r]);for(let r=t.layers.length-2;r>=0;r-=1)nn(t,t.layers[r],"out"),Fe(t.layers[r])}for(let n=0;n<2;n+=1){let r=!1;for(let s=1;s<t.layers.length;s+=1){let o=t.layers[s];for(let i=0;i+1<o.length;i+=1){let a=rn(t,o[i],o[i+1],"in");[o[i],o[i+1]]=[o[i+1],o[i]],Fe(o),rn(t,o[i],o[i+1],"in")<a?r=!0:([o[i],o[i+1]]=[o[i+1],o[i]],Fe(o))}}if(!r)break}}function nn(t,e,n){let r=new Map;for(let s of e){let o=n==="in"?s.in:s.out;if(o.length===0){r.set(s.id,s.order);continue}let i=0,a=0;for(let l of o){let u=t.nodes.get(n==="in"?l.fromId:l.toId);u&&(i+=u.order,a+=1)}r.set(s.id,a===0?s.order:i/a)}e.sort((s,o)=>{let i=r.get(s.id),a=r.get(o.id);return i!==a?i-a:s.order-o.order})}function Fe(t){for(let e=0;e<t.length;e+=1)t[e].order=e}function rn(t,e,n,r){let s=r==="in"?e.in:e.out,o=r==="in"?n.in:n.out,i=0;for(let a of s)for(let l of o){let u=t.nodes.get(r==="in"?a.fromId:a.toId)?.order??0,c=t.nodes.get(r==="in"?l.fromId:l.toId)?.order??0;(e.order<n.order&&u>c||e.order>n.order&&u<c)&&(i+=1)}return i}function lr(t,e){e.direction==="LR"?cr(t,e):dr(t,e)}function cr(t,e){let n=[],r=0;for(let s=0;s<t.layers.length;s+=1){n.push(r);let o=0;for(let i of t.layers[s])o=Math.max(o,i.w);r+=o+e.layerGap}for(let s=0;s<t.layers.length;s+=1)for(let o of t.layers[s])o.x=n[s];for(let s of t.layers){let o=0;for(let i of s)i.y=o,o+=i.h+e.nodeGap}on(t,e,"y")}function dr(t,e){let n=[],r=0;for(let s=0;s<t.layers.length;s+=1){n.push(r);let o=0;for(let i of t.layers[s])o=Math.max(o,i.h);r+=o+e.layerGap}for(let s=0;s<t.layers.length;s+=1)for(let o of t.layers[s])o.y=n[s];for(let s of t.layers){let o=0;for(let i of s)i.x=o,o+=i.w+e.nodeGap}on(t,e,"x")}function on(t,e,n){let r=o=>n==="y"?o.h:o.w,s=e.nodeGap;for(let o=0;o<2;o+=1){let i=o===0?t.layers.slice(1):t.layers.slice(0,-1).reverse();for(let a of i){let l=new Map;for(let c of a){let f=o===0?c.in:c.out;if(f.length===0)continue;let p=[];for(let d of f){let g=t.nodes.get(o===0?d.fromId:d.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((d,g)=>d-g);let h=p[Math.floor(p.length/2)];l.set(c.id,h-Math.floor(r(c)/2))}let u=0;for(let c of a){let f=l.get(c.id),p=n==="y"?c.y:c.x,d=Math.max(f??p,u);n==="y"?c.y=d:c.x=d,u=d+r(c)+s}}}}function fr(t,e){let n=new Map;for(let u of t.hops){let c=n.get(u.chainId);c?c.push(u):n.set(u.chainId,[u])}for(let u of n.values())u.sort((c,f)=>c.hopIndex-f.hopIndex);let r=e.direction==="LR",s=u=>r?u.x:u.y,o=u=>r?u.w:u.h,i=u=>r?u.y+Math.floor(u.h/2):u.x+Math.floor(u.w/2),a=new Map;for(let u=0;u+1<t.layers.length;u+=1){let c=t.layers[u],f=t.layers[u+1],p=0;for(let T of c)p=Math.max(p,s(T)+o(T));let h=Number.POSITIVE_INFINITY;for(let T of f)h=Math.min(h,s(T));let d=Number.isFinite(h)?h-1:p,g=Math.max(1,d-p+1),b=[];for(let T of c)for(let O of T.out)b.push(O);b.sort((T,O)=>{let C=i(t.nodes.get(T.fromId)),S=i(t.nodes.get(O.fromId));if(C!==S)return C-S;let E=i(t.nodes.get(T.toId)),R=i(t.nodes.get(O.toId));return E-R});let x=[],v=new Map;for(let T of b){let O=i(t.nodes.get(T.fromId)),C=i(t.nodes.get(T.toId)),S=Math.min(O,C),E=Math.max(O,C),R=-1;for(let L=0;L<x.length;L+=1){let V=x[L],Y=!0;for(let ce of V)if(ce.lo<=E&&S<=ce.hi){Y=!1;break}if(Y){V.push({lo:S,hi:E}),R=L;break}}R<0&&(x.push([{lo:S,hi:E}]),R=x.length-1),v.set(T,R)}let y=x.length,_=g>=Math.max(3,y+2),m=_?p+1:p,w=_?d-1:d,k=Math.max(1,w-m+1);for(let T of b){let O=v.get(T),C;if(y<=1)C=m+Math.floor(k/2);else{let S=(k-1)/(y-1);C=m+Math.floor(O*S)}a.set(T,Math.max(p,Math.min(d,C)))}}let l=[];for(let[,u]of n){let c=[];for(let p=0;p<u.length;p+=1){let h=u[p],d=t.nodes.get(h.fromId),g=t.nodes.get(h.toId),b=a.get(h),x=d.isVirtual?s(d):s(d)+o(d),v=g.isVirtual?s(g):s(g)-1,y=i(d),_=i(g);p===0&&He(c,r,x,y),y!==_&&(He(c,r,b,y),He(c,r,b,_)),He(c,r,v,_)}let f=u[0];l.push({from:f.chainFrom,to:f.chainTo,points:hr(c)})}return l}function He(t,e,n,r){t.push(e?{x:n,y:r}:{x:r,y:n})}function hr(t){let e=[];for(let n of t){let r=e[e.length-1];(!r||r.x!==n.x||r.y!==n.y)&&e.push(n)}return e}function pr(t){let e=0,n=0;for(let r of t.layers)for(let s of r)e=Math.max(e,s.x+s.w),n=Math.max(n,s.y+s.h);return{width:e,height:n}}var gr=24,mr=4,br=1,yr=3;function an(t,e){let n=vr(e.direction),r=Math.max(3,e.maxLabelWidth??gr),s=e.asciiCharset??"unicode",o=Object.keys(t.nodes).sort(),i=new Set(o),a=t.edges.filter(h=>i.has(h.from)&&i.has(h.to)),l=new Map,u=new Map;for(let h of o){let d=Rt(h,r);l.set(h,d),u.set(h,he(d)+4)}let c=sn({nodes:o,edges:a,widthCells:h=>u.get(h)??3,heightCells:()=>yr,layerGap:mr,nodeGap:br,direction:n}),f=en(c,{charset:s,labelOf:h=>l.get(h)??h}),p=e.logger;return p&&p(f),f}function vr(t){if(t===void 0||t==="LR")return"LR";if(t==="TD")return"TD";throw new Error(`ascii describe supports direction "LR" or "TD" only; got ${String(t)}`)}function un(t,e,n,r={}){let s=e in t.nodes,o=n in t.nodes;if(!s)return je(e,n,"no-such-from");if(!o)return je(e,n,"no-such-to");let i=r.maxDepth;if(i!=null&&(!Number.isInteger(i)||i<0))throw new Error("explainPath: maxDepth must be an integer >= 0");if(e===n){if(r.findCycle===!0){let u=xr(t,e,r);if(u!=null)return u}let l=Ve(e,t.nodes[e],0,r);return We(e,n,[l])}if(i===0)return je(e,n,"no-path");let a=ln(t,e,n,i);return a.found?We(e,n,cn(t,a.pathOrder,r)):je(e,n,a.truncated?"max-depth-exceeded":"no-path")}function ln(t,e,n,r){let s=new Map,o=[{path:n,depth:0}],i=new Set([n]),a=0,l=!1;for(;a<o.length;){let f=o[a++];if(f.path===e)break;if(r!=null&&f.depth>=r){let g=t.nodes[f.path];g?.deps&&g.deps.length>0&&(l=!0);continue}let p=t.nodes[f.path];if(p==null)continue;let h=p.deps??[],d=new Map;for(let g=0;g<h.length;g++){let b=h[g];if(!b)continue;let x=d.get(b);x==null&&(x=[],d.set(b,x)),x.push(g)}for(let[g,b]of d)i.has(g)||(i.add(g),s.set(g,{from:f.path,depIndices:b}),o.push({path:g,depth:f.depth+1}))}if(!s.has(e))return{found:!1,pathOrder:[],truncated:l};let u=[{path:e}],c=e;for(;c!==n;){let f=s.get(c);if(f==null)return{found:!1,pathOrder:[],truncated:!1};u[u.length-1].depIndices=f.depIndices,u.push({path:f.from}),c=f.from}return{found:!0,pathOrder:u,truncated:!1}}function xr(t,e,n){let r=t.nodes[e];if(r==null)return null;let s=r.deps??[],o=[];for(let a=0;a<s.length;a++)s[a]===e&&o.push(a);if(o.length>0){let a=Ve(e,r,0,n);a.dep_index=o[0];let l=Ve(e,r,1,n);return We(e,e,[a,l])}let i=null;for(let a=0;a<s.length;a++){let l=s[a];if(!l||l===e)continue;let u=ln(t,l,e,n.maxDepth);u.found&&(i==null||u.pathOrder.length<i.pathOrder.length)&&(i=u,i={found:!0,pathOrder:[{path:e,depIndices:[a]},...u.pathOrder],truncated:!1})}return i==null?null:We(e,e,cn(t,i.pathOrder,n))}function cn(t,e,n){return e.map((r,s)=>{let o=t.nodes[r.path],i=Ve(r.path,o,s,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 Ve(t,e,n,r){let s={path:t,type:e.type,hop:n};e.status!==void 0&&(s.status=e.status),"value"in e&&(s.value=e.value),e.v!=null&&(s.v=e.v);let o=r.annotations?.get(t)??e.annotation;o!=null&&(s.annotation=o);let i=r.lastMutations?.get(t)??e.lastMutation;return i!=null&&(s.lastMutation=i),s}function We(t,e,n){return dn(t,e,!0,"ok",n)}function je(t,e,n){return dn(t,e,!1,n,[])}function dn(t,e,n,r,s){let o=wr(t,e,n,r,s);return{from:t,to:e,found:n,reason:r,steps:s,text:o,toJSON(){return{from:t,to:e,found:n,reason:r,steps:s}}}}function wr(t,e,n,r,s){if(!n)switch(r){case"no-such-from":return`explainPath: no node named "${t}"`;case"no-such-to":return`explainPath: no node named "${e}"`;case"max-depth-exceeded":return`explainPath: no path from "${t}" to "${e}" within maxDepth`;default:return`explainPath: no path from "${t}" to "${e}"`}let o=[`Causal path: ${t} \u2192 ${e} (${s.length} step(s))`];for(let i of s){let l=` ${i.hop===0?"\xB7":"\u2193"} ${i.path} (${i.type}${i.status?`/${i.status}`:""})`;if(o.push(l),"value"in i&&o.push(` value: ${_r(i.value)}`),i.annotation!=null&&o.push(` annotation: ${i.annotation}`),i.lastMutation!=null){let u=i.lastMutation.actor;o.push(` actor: ${u.type}${u.id?`:${u.id}`:""}`)}}return o.join(`
3
3
  `)}function _r(t){if(t===void 0)return"<sentinel>";if(t===null)return"null";if(typeof t=="string")return JSON.stringify(t);if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return String(t);try{let e=JSON.stringify(t);return e.length>80?`${e.slice(0,77)}...`:e}catch{return String(t)}}se();var P={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},kr=Symbol.for("sizeof");function fn(t){let e=new WeakSet,n=new WeakSet,r=[t],s=0;for(;r.length>0;){let o=r.pop();s+=Tr(o,e,n,r)}return s}function Tr(t,e,n,r){if(t==null)return 0;switch(typeof t){case"number":return P.number;case"boolean":return P.boolean;case"string":return P.string+t.length*2;case"bigint":return P.bigint+Or(t);case"symbol":return P.symbol;case"function":return e.has(t)?0:(e.add(t),P.function);case"undefined":return 0}let o=t;if(e.has(o))return 0;e.add(o);let i=o[kr];if(typeof i=="function")try{let u=i.call(o);if(typeof u=="number"&&Number.isFinite(u))return u}catch{}if(o instanceof Date)return P.date;if(o instanceof RegExp)return P.regexp+o.source.length*2;if(o instanceof Error){let u=o.message?o.message.length*2:0,c=o.stack?o.stack.length*2:0;return P.error+u+c}if(typeof URL<"u"&&o instanceof URL)return P.url+o.href.length*2;if(typeof Promise<"u"&&o instanceof Promise)return P.promise;if(o instanceof WeakMap)return P.weakmap;if(o instanceof WeakSet)return P.weakset;if(o instanceof Map){let u=P.map;for(let[c,f]of o)u+=P.mapEntry,r.push(c),r.push(f);return u}if(o instanceof Set){let u=P.set;for(let c of o)u+=P.setEntry,r.push(c);return u}if(Array.isArray(o)){let u=P.array+o.length*8;for(let c of o)r.push(c);return u}if(o instanceof ArrayBuffer)return n.has(o)?0:(n.add(o),o.byteLength);if(ArrayBuffer.isView(o)){let u=o;return n.has(u.buffer)?48:(n.add(u.buffer),u.buffer.byteLength+48)}let a=P.object,l=Object.keys(o);for(let u of l){a+=P.string+u.length*2;try{r.push(o[u])}catch{}}return a}function Or(t){let e=t<0n?-t:t;if(e===0n)return 0;let n=e.toString(2).length;return Math.ceil(n/32)*8}function hn(t,e){let n=e?.topN??10,r=t.describe({detail:"standard"}),s=[],o=t._collectObserveTargets;typeof o=="function"&&o.call(t,"",s);let i=new Map;for(let[p,h]of s)i.set(p,h);let a=[];for(let[p,h]of Object.entries(r.nodes)){let d=i.get(p),g=d instanceof I?d:null,b=g?fn(g.cache):0,x=g?g._sinkCount:0,v=h.deps?.length??0,y=h.type==="effect"&&x===0,_=x===0?h.type==="effect"?"orphan-effect":h.type==="derived"?"idle-derived":h.type==="producer"?"idle-producer":null:null;a.push({path:p,type:h.type,status:h.status??"unknown",valueSizeBytes:b,subscriberCount:x,depCount:v,isOrphanEffect:y,orphanKind:_})}let l=a.reduce((p,h)=>p+h.valueSizeBytes,0),u=(p,h)=>[...a].sort(h??((d,g)=>g[p]-d[p])).slice(0,n),c=a.filter(p=>p.orphanKind!=null),f=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:c,orphanEffects:f}}var D="::",Q="__meta__",xe=1;function pn(t,e){let n=Math.max(16,t.size*4),r=0;for(;t.size>0;){if(r++>=n){console.error(`[Graph "${e}".destroy] disposer drain exceeded cap (${n}); ${t.size} disposer(s) discarded`),t.clear();return}let s=t.values().next();if(s.done)return;let o=s.value;t.delete(o);try{o()}catch(i){console.error(`[Graph "${e}".destroy] disposer threw:`,i)}}}function Sr(t){let e=[];for(let n of Object.keys(t).sort()){let r=t[n].v;r!=null&&e.push(`${n} ${r.id} ${r.version}`)}return e.join(`
4
4
  `)}function gn(t){if(t.version!==xe)throw new Error(`unsupported snapshot version ${String(t.version)} (expected ${xe})`);for(let e of["name","nodes","edges","subgraphs"])if(!(e in t))throw new Error(`snapshot missing required key "${e}"`);if(typeof t.name!="string")throw new TypeError("snapshot 'name' must be a string");if(typeof t.nodes!="object"||t.nodes===null||Array.isArray(t.nodes))throw new TypeError("snapshot 'nodes' must be an object");if(!Array.isArray(t.edges))throw new TypeError("snapshot 'edges' must be an array");if(!Array.isArray(t.subgraphs))throw new TypeError("snapshot 'subgraphs' must be an array")}function Nr(t,e){let n=new WeakMap,r=(s,o)=>{if(Object.is(s,o))return!0;if(s==null||o==null||typeof s!="object"||typeof o!="object")return!1;let i=n.get(s);if(i==null&&(i=new WeakSet,n.set(s,i)),i.has(o))return!0;i.add(o);let a=s.constructor,l=o.constructor;if(a!==l)return!1;if(s instanceof Date)return s.getTime()===o.getTime();if(s instanceof RegExp)return s.source===o.source&&s.flags===o.flags;if(Array.isArray(s)){let p=o;if(s.length!==p.length)return!1;for(let h=0;h<s.length;h++)if(!r(s[h],p[h]))return!1;return!0}if(s instanceof Map){let p=o;if(s.size!==p.size)return!1;for(let[h,d]of s)if(!p.has(h)||!r(d,p.get(h)))return!1;return!0}if(s instanceof Set){let p=o;if(s.size!==p.size)return!1;for(let h of s){let d=!1;for(let g of p)if(r(h,g)){d=!0;break}if(!d)return!1}return!0}if(ArrayBuffer.isView(s)){let p=s,h=o;if(p.length!==h.length)return!1;for(let d=0;d<p.length;d++)if(p[d]!==h[d])return!1;return!0}let u=Object.keys(s),c=Object.keys(o);if(u.length!==c.length)return!1;let f=new Set(c);for(let p of u)if(!f.has(p)||!r(s[p],o[p]))return!1;return!0};return r(t,e)}function Tt(t){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(Tt);let e=t,n=Object.keys(e).sort(),r={};for(let s of n)r[s]=Tt(e[s]);return r}function Er(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Cr(t){return t.replaceAll("\\","\\\\").replaceAll('"','\\"')}function Rr(t){return t==="TD"?"down":t==="BT"?"up":t==="RL"?"left":"right"}function yn(t){let e=new Set,n=[];function r(s,o){let i=`${s}\0${o}`;e.has(i)||(e.add(i),n.push([s,o]))}for(let[s,o]of Object.entries(t.nodes)){let i=o.deps;if(i)for(let a of i)r(a,s)}for(let s of t.edges)r(s.from,s.to);return n}function vn(t){if(t===void 0)return"LR";if(t==="TD"||t==="LR"||t==="BT"||t==="RL")return t;throw new Error(`invalid diagram direction ${String(t)}; expected one of: TD, LR, BT, RL`)}function Mr(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,{expand:s,...o}=t,i={...o,edges:n?t.edges:[],subgraphs:r?t.subgraphs:[]},a=JSON.stringify(Tt(i),null,e.indent??2);return e.logger?.(a),a}function Ar(t,e){let n=e.includeEdges??!0,r=e.includeSubgraphs??!0,s=[];s.push(`Graph ${t.name}`),s.push("Nodes:");for(let i of Object.keys(t.nodes).sort()){let a=t.nodes[i];s.push(`- ${i} (${a.type}/${a.status}): ${Ue(a.value)}`)}if(n){s.push("Edges:");for(let i of t.edges)s.push(`- ${i.from} -> ${i.to}`)}if(r){s.push("Subgraphs:");for(let i of t.subgraphs)s.push(`- ${i}`)}let o=s.join(`
@@ -1 +1 @@
1
- import{a as g,b as h,c as i,d as j,e as k,f as l,g as m,h as n,i as o,j as p,k as q,l as r,m as s,n as t,o as u}from"../../chunk-BKPLTBL5.js";import{a,b,c,d,e,f}from"../../chunk-4JJCCD5S.js";import"../../chunk-5Z4HDCO6.js";import"../../chunk-MGKAO4EK.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-TWMEGG45.js";import"../../chunk-KASHOCF5.js";import"../../chunk-W4TSQ6RJ.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{i as CanvasMeasureAdapter,g as CliMeasureAdapter,l as ImageSizeAdapter,j as NodeCanvasMeasureAdapter,h as PrecomputedAdapter,k as SvgBoundsAdapter,a as analyzeAndMeasure,d as carveTextLineSlots,r as circleIntervalForBand,o as computeBlockFlow,e as computeCharPositions,t as computeFlowLines,b as computeLineBreaks,p as computeTotalHeight,c as layoutNextLine,m as measureBlock,n as measureBlocks,q as reactiveBlockLayout,u as reactiveFlowLayout,f as reactiveLayout,s as rectIntervalForBand};
1
+ import{a as g,b as h,c as i,d as j,e as k,f as l,g as m,h as n,i as o,j as p,k as q,l as r,m as s,n as t,o as u}from"../../chunk-YQJPYEAL.js";import{a,b,c,d,e,f}from"../../chunk-YZKGGMPT.js";import"../../chunk-K54OKWNY.js";import"../../chunk-PSQNYY72.js";import"../../chunk-SGS4OJGS.js";import"../../chunk-ESMPEKEV.js";import"../../chunk-N2KKISCE.js";import"../../chunk-UMH3HSP7.js";import"../../chunk-7AJKUA36.js";import"../../chunk-CK2E7BTU.js";import"../../chunk-QYADASLV.js";export{i as CanvasMeasureAdapter,g as CliMeasureAdapter,l as ImageSizeAdapter,j as NodeCanvasMeasureAdapter,h as PrecomputedAdapter,k as SvgBoundsAdapter,a as analyzeAndMeasure,d as carveTextLineSlots,r as circleIntervalForBand,o as computeBlockFlow,e as computeCharPositions,t as computeFlowLines,b as computeLineBreaks,p as computeTotalHeight,c as layoutNextLine,m as measureBlock,n as measureBlocks,q as reactiveBlockLayout,u as reactiveFlowLayout,f as reactiveLayout,s as rectIntervalForBand};