@astrale-os/cli 1.0.0-beta.0 → 1.0.0-beta.2

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 (180) hide show
  1. package/README.md +7 -11
  2. package/dist/astrale.js +3769 -3549
  3. package/dist/public/connect-core.js +396 -392
  4. package/dist/public/keys/index.js +371 -378
  5. package/dist/public/paths/index.js +371 -378
  6. package/dist/types/lib/idp.d.ts +6 -0
  7. package/dist/types/lib/meta.d.ts +2 -2
  8. package/package.json +6 -4
  9. package/src/admin/binding.ts +168 -0
  10. package/src/admin/catalog/__tests__/client.test.ts +2 -2
  11. package/src/admin/catalog/client.ts +4 -9
  12. package/src/admin/instance/__tests__/client.test.ts +5 -3
  13. package/src/admin/instance/client.ts +9 -27
  14. package/src/commands/__tests__/auth-login.test.ts +54 -1
  15. package/src/commands/__tests__/call.test.ts +5 -1
  16. package/src/commands/__tests__/domain-install-operation.test.ts +23 -7
  17. package/src/commands/__tests__/domain-install-owned.test.ts +5 -1
  18. package/src/commands/__tests__/domain-list.test.ts +83 -4
  19. package/src/commands/__tests__/install-identity-override.test.ts +30 -19
  20. package/src/commands/__tests__/studio-descriptor.test.ts +22 -0
  21. package/src/commands/__tests__/update.test.ts +73 -0
  22. package/src/commands/domain/install.ts +11 -15
  23. package/src/commands/domain/list.ts +17 -12
  24. package/src/commands/studio.ts +20 -0
  25. package/src/commands/update.ts +39 -13
  26. package/src/connection/__tests__/errors.test.ts +16 -12
  27. package/src/connection/__tests__/exchange.test.ts +6 -5
  28. package/src/connection/exchange.ts +5 -4
  29. package/src/lib/__tests__/domain-publication.test.ts +144 -0
  30. package/src/lib/__tests__/idp-session.test.ts +22 -0
  31. package/src/lib/__tests__/idp.test.ts +2 -0
  32. package/src/lib/__tests__/instance.test.ts +6 -0
  33. package/src/lib/__tests__/studio-server-deps.test.ts +53 -16
  34. package/src/lib/__tests__/update.test.ts +12 -0
  35. package/src/lib/domain-publication.ts +102 -0
  36. package/src/lib/idp.ts +5 -1
  37. package/src/lib/instance.ts +6 -1
  38. package/src/lib/login-flow.ts +13 -3
  39. package/src/lib/meta.ts +2 -2
  40. package/src/lib/update.ts +4 -4
  41. package/src/program/__tests__/program.test.ts +1 -1
  42. package/studio/client/dist/assets/{elk-api-D2xgMJvi.js → elk-api-lwhFo7vB.js} +1 -1
  43. package/studio/client/dist/assets/index-B-c-smo9.js +8 -0
  44. package/studio/client/dist/assets/index-BckHuAWk.js +81 -0
  45. package/studio/client/dist/assets/index-C4aNQ6dz.css +1 -0
  46. package/studio/client/dist/index.html +2 -2
  47. package/studio/package.json +3 -1
  48. package/studio/server/agent/bridge/stdio.ts +8 -1
  49. package/studio/server/agent/conversation.test.ts +10 -5
  50. package/studio/server/agent/conversation.ts +56 -8
  51. package/studio/server/agent/harness/codex/loadout.ts +18 -21
  52. package/studio/server/agent/harness/gateway/config.ts +20 -18
  53. package/studio/server/agent/harness/selection.ts +9 -1
  54. package/studio/server/agent/prompts/system.ts +3 -2
  55. package/studio/server/agent/prompts/turn.ts +13 -4
  56. package/studio/server/agent/run/completion.ts +2 -2
  57. package/studio/server/agent/run/preparation.ts +6 -5
  58. package/studio/server/agent/run/transcript.test.ts +35 -1
  59. package/studio/server/agent/run/transcript.ts +169 -3
  60. package/studio/server/agent/run/usage.test.ts +24 -0
  61. package/studio/server/agent/run/usage.ts +26 -1
  62. package/studio/server/api/canvas.ts +44 -0
  63. package/studio/server/api/comments.ts +85 -0
  64. package/studio/server/api/context.ts +61 -0
  65. package/studio/server/api/deployment.ts +39 -0
  66. package/studio/server/api/documents.ts +55 -0
  67. package/studio/server/api/domain.ts +59 -0
  68. package/studio/server/api/http.ts +45 -0
  69. package/studio/server/api/project.ts +57 -0
  70. package/studio/server/api/schema.ts +12 -0
  71. package/studio/server/api/views.ts +57 -0
  72. package/studio/server/api/workspace.ts +60 -0
  73. package/studio/server/api.test.ts +147 -0
  74. package/studio/server/api.ts +20 -422
  75. package/studio/server/cache.test.ts +111 -0
  76. package/studio/server/cache.ts +163 -9
  77. package/studio/server/cli-consumers.test.ts +494 -0
  78. package/studio/server/cli.test.ts +88 -0
  79. package/studio/server/cli.ts +240 -0
  80. package/studio/server/client-package.ts +25 -1
  81. package/studio/server/domain.test.ts +30 -2
  82. package/studio/server/domain.ts +14 -2
  83. package/studio/server/environment/dotenv-preview.test.ts +39 -0
  84. package/studio/server/environment/dotenv-preview.ts +27 -0
  85. package/studio/server/environment/files.test.ts +53 -0
  86. package/studio/server/{state/env.ts → environment/files.ts} +7 -48
  87. package/studio/server/{state → handoff}/copy.ts +21 -6
  88. package/studio/server/handoff/service.test.ts +22 -0
  89. package/studio/server/{state/handoff.ts → handoff/service.ts} +21 -14
  90. package/studio/server/instances/active.ts +72 -0
  91. package/studio/server/instances/deploy-record.test.ts +31 -0
  92. package/studio/server/instances/deploy-record.ts +37 -0
  93. package/studio/server/instances/deploy.ts +56 -0
  94. package/studio/server/{state/instance.test.ts → instances/probe.test.ts} +25 -21
  95. package/studio/server/instances/probe.ts +67 -0
  96. package/studio/server/instances/status.test.ts +12 -0
  97. package/studio/server/instances/status.ts +49 -0
  98. package/studio/server/introspect/anatomy/client-tree.ts +57 -0
  99. package/studio/server/introspect/anatomy/env-fields.ts +66 -0
  100. package/studio/server/introspect/anatomy/schema-definition.ts +53 -0
  101. package/studio/server/introspect/anatomy/source.ts +181 -0
  102. package/studio/server/introspect/anatomy/views/legacy.ts +232 -0
  103. package/studio/server/introspect/anatomy/views/routes.ts +105 -0
  104. package/studio/server/introspect/anatomy/views.ts +58 -0
  105. package/studio/server/introspect/anatomy-extras.test.ts +91 -4
  106. package/studio/server/introspect/anatomy-extras.ts +7 -726
  107. package/studio/server/introspect/anatomy.ts +46 -19
  108. package/studio/server/introspect/bundle.ts +15 -6
  109. package/studio/server/introspect/canonical-schema.test.ts +79 -0
  110. package/studio/server/introspect/canonical-schema.ts +80 -18
  111. package/studio/server/introspect/config-preview.test.ts +32 -0
  112. package/studio/server/introspect/config-preview.ts +119 -0
  113. package/studio/server/introspect/diff.test.ts +7 -11
  114. package/studio/server/introspect/diff.ts +28 -37
  115. package/studio/server/introspect/extractor.ts +8 -6
  116. package/studio/server/introspect/hash.ts +5 -2
  117. package/studio/server/introspect/overlay-tsmorph.ts +7 -1305
  118. package/studio/server/introspect/revision.test.ts +54 -0
  119. package/studio/server/introspect/revision.ts +49 -0
  120. package/studio/server/introspect/runtime.test.ts +63 -5
  121. package/studio/server/introspect/runtime.ts +49 -3
  122. package/studio/server/introspect/schema-ir-json.ts +181 -0
  123. package/studio/server/introspect/source-overlay/annotations.ts +14 -0
  124. package/studio/server/introspect/source-overlay/handlers.ts +681 -0
  125. package/studio/server/introspect/source-overlay/kernel-calls.ts +49 -0
  126. package/studio/server/introspect/source-overlay/project.ts +248 -0
  127. package/studio/server/introspect/source-overlay/spans.ts +360 -0
  128. package/studio/server/json.ts +46 -0
  129. package/studio/server/lifecycle.ts +5 -1
  130. package/studio/server/sse.test.ts +26 -0
  131. package/studio/server/sse.ts +4 -1
  132. package/studio/server/state/baseline.test.ts +212 -1
  133. package/studio/server/state/baseline.ts +145 -29
  134. package/studio/server/state/comments.test.ts +66 -1
  135. package/studio/server/state/comments.ts +173 -10
  136. package/studio/server/state/context.ts +34 -2
  137. package/studio/server/state/documents.ts +42 -1
  138. package/studio/server/state/integrations.ts +27 -1
  139. package/studio/server/state/layout.test.ts +34 -0
  140. package/studio/server/state/layout.ts +44 -17
  141. package/studio/server/state/settings.ts +29 -22
  142. package/studio/server/state/store.test.ts +122 -0
  143. package/studio/server/state/store.ts +66 -17
  144. package/studio/server/state/visibility.ts +22 -7
  145. package/studio/server/views/model.test.ts +57 -0
  146. package/studio/server/views/model.ts +66 -0
  147. package/studio/server/views/runtime.ts +40 -0
  148. package/studio/server/views/selection-repository.test.ts +31 -0
  149. package/studio/server/views/selection-repository.ts +60 -0
  150. package/studio/server/views/session.test.ts +73 -0
  151. package/studio/server/views/session.ts +166 -0
  152. package/studio/server/{state/views.test.ts → views/target.test.ts} +8 -159
  153. package/studio/server/views/target.ts +248 -0
  154. package/studio/server/watch.ts +1 -1
  155. package/studio/server/workspace/catalog.test.ts +17 -0
  156. package/studio/server/workspace/catalog.ts +43 -0
  157. package/studio/server/{state → workspace}/create.test.ts +1 -1
  158. package/studio/server/{state → workspace}/create.ts +1 -1
  159. package/studio/server/{state → workspace}/git.ts +1 -1
  160. package/studio/server/workspace/updates.ts +83 -0
  161. package/studio/server/workspace-state.ts +1 -1
  162. package/studio/shared/contracts/README.md +16 -0
  163. package/studio/shared/contracts/agent.ts +270 -0
  164. package/studio/shared/contracts/runtime.ts +50 -0
  165. package/studio/shared/contracts/schema.ts +462 -0
  166. package/studio/shared/contracts/surface.test.ts +319 -0
  167. package/studio/shared/contracts/workspace.ts +274 -0
  168. package/studio/shared/layout.test.ts +116 -0
  169. package/studio/shared/schema/identity.test.ts +58 -0
  170. package/studio/shared/schema/identity.ts +82 -0
  171. package/studio/shared/types.ts +11 -1099
  172. package/studio/tsconfig.json +1 -1
  173. package/viewer/dist/main.js +35 -35
  174. package/studio/client/dist/assets/index-BMdnsIJA.css +0 -1
  175. package/studio/client/dist/assets/index-D-vRV8w7.js +0 -8
  176. package/studio/client/dist/assets/index-LGSWRrk8.js +0 -81
  177. package/studio/server/state/catalog.ts +0 -117
  178. package/studio/server/state/instance.ts +0 -280
  179. package/studio/server/state/updates.ts +0 -63
  180. package/studio/server/state/views.ts +0 -535
@@ -1,8 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/elk-api-D2xgMJvi.js","assets/index-LGSWRrk8.js","assets/index-BMdnsIJA.css"])))=>i.map(i=>d[i]);
2
- import{S as Gd,n as Fs,s as Ud,r as Kd,Q as na,u as ls,a as Qd,b as Jd,c as k,e as eu,d as tu,f as nu,g as su,h as mr,i as ou,j as ru,k as ve,l as sa,m as iu,R as au,o as a,p as cu,q as X,t as oa,P as Pt,v as po,w as se,C as lu,x as Ot,T as mo,_ as du,M as ra,B as ia,y as Fe,z as Tt,A as Pe,D as uu,E as ds,F as us,N as fu,G as hu,H as _e,I as pu,J as mu,K as gu,L as xu,O as yu,U as aa,V as Bs,W as go,X as wu,Y as ca,Z as xo,$ as zt,a0 as ht,a1 as qt,a2 as la,a3 as Be,a4 as vu,a5 as ke,a6 as bu,a7 as Lt,a8 as Nu,a9 as vt,aa as ln,ab as yo,ac as ku,ad as fs,ae as ju,af as Eu,ag as Cu,ah as Oe,ai as me,aj as dn,ak as un,al as fn,am as dt,an as Su,ao as da,ap as wo,aq as Iu,ar as _u,as as ua,at as Mu,au as vo,av as $u,aw as Ru,ax as Au,ay as Du,az as Pu,aA as Ou,aB as Tu,aC as zu,aD as bo,aE as Lu,aF as fa,aG as ha,aH as No,aI as Bn,aJ as pa,aK as ma,aL as ga,aM as Wn,aN as We,aO as Hu,aP as pt,aQ as xa,aR as ya,aS as wa,aT as Vu,aU as Fu,aV as Bu,aW as pe,aX as va,aY as Wu,aZ as Yu,a_ as Xu}from"./index-LGSWRrk8.js";function gr(e,t){const n=new Set(t);return e.filter(s=>!n.has(s))}function qu(e,t,n){const s=e.slice(0);return s[t]=n,s}var Zu=class extends Gd{#o;#e;#r;#s;#t;#n;#i;#a;#c;#l=[];constructor(e,t,n){super(),this.#o=e,this.#s=n,this.#r=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#h(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#r=e,this.#s=t,Fs.batch(()=>{const n=this.#t,s=this.#f(this.#r);s.forEach(u=>u.observer.setOptions(u.defaultedQueryOptions));const o=s.map(u=>u.observer),i=o.map(u=>u.getCurrentResult()),r=n.length!==o.length,c=o.some((u,h)=>u!==n[h]),l=r||c,d=l?!0:i.some((u,h)=>{const f=this.#e[h];return!f||!Ud(u,f)});!l&&!d||(l&&(this.#l=s,this.#t=o),this.#e=i,this.hasListeners()&&(l&&(gr(n,o).forEach(u=>{u.destroy()}),gr(o,n).forEach(u=>{u.subscribe(h=>{this.#h(u,h)})})),this.#p()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const n=this.#f(e),s=n.map(i=>i.observer.getOptimisticResult(i.defaultedQueryOptions)),o=n.map(i=>i.defaultedQueryOptions.queryHash);return[s,i=>this.#u(i??s,t,o),()=>this.#d(s,n)]}#d(e,t){return t.map((n,s)=>{const o=e[s];return n.defaultedQueryOptions.notifyOnChangeProps?o:n.observer.trackResult(o,i=>{t.forEach(r=>{r.observer.trackProp(i)})})})}#u(e,t,n){if(t){const s=this.#c,o=n!==void 0&&s!==void 0&&(s.length!==n.length||n.some((i,r)=>i!==s[r]));return(!this.#n||this.#e!==this.#a||o||t!==this.#i)&&(this.#i=t,this.#a=this.#e,n!==void 0&&(this.#c=n),this.#n=Kd(this.#n,t(e))),this.#n}return e}#m(){return this.#s?.combine!==void 0&&this.#t.some((e,t)=>e.options.suspense&&this.#e[t]?.data===void 0)}#f(e){const t=new Map;this.#t.forEach(s=>{const o=s.options.queryHash;if(!o)return;const i=t.get(o);i?i.push(s):t.set(o,[s])});const n=[];return e.forEach(s=>{const o=this.#o.defaultQueryOptions(s),r=t.get(o.queryHash)?.shift()??new na(this.#o,o);n.push({defaultedQueryOptions:o,observer:r})}),n}#h(e,t){const n=this.#t.indexOf(e);n!==-1&&(this.#e=qu(this.#e,n,t),this.#p())}#p(){if(this.hasListeners()){const e=this.#d(this.#e,this.#l),t=this.#m(),n=this.#n,s=t?n:this.#u(e,this.#s?.combine);(t||n!==s)&&Fs.batch(()=>{this.listeners.forEach(o=>{o(this.#e)})})}}};function kn({queries:e,...t},n){const s=ls(),o=Qd(),i=Jd(),r=k.useMemo(()=>e.map(w=>{const y=s.defaultQueryOptions(w);return y._optimisticResults=o?"isRestoring":"optimistic",y}),[e,s,o]);r.forEach(w=>{eu(w);const y=s.getQueryCache().get(w.queryHash);tu(w,i,y)}),nu(i);const[c]=k.useState(()=>new Zu(s,r,t)),[l,d,u]=c.getOptimisticResult(r,t.combine),h=!o&&t.subscribed!==!1;k.useSyncExternalStore(k.useCallback(w=>h?c.subscribe(Fs.batchCalls(w)):su,[c,h]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),k.useEffect(()=>{c.setQueries(r,t)},[r,t,c]);const p=l.some((w,y)=>mr(r[y],w))?l.flatMap((w,y)=>{const x=r[y];if(x&&mr(x,w)){const b=new na(s,x);return ou(x,b,i)}return[]}):[];if(p.length>0)throw Promise.all(p);const m=l.find((w,y)=>{const x=r[y];return x&&ru({result:w,errorResetBoundary:i,throwOnError:x.throwOnError,query:s.getQueryCache().get(x.queryHash),suspense:x.suspense})});if(m?.error)throw m.error;return d(u())}const Gu=[["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}],["path",{d:"M10 4v4",key:"pp8u80"}],["path",{d:"M2 8h20",key:"d11cs7"}],["path",{d:"M6 4v4",key:"1svtjw"}]],hn=ve("AppWindow",Gu);const Uu=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Ku=ve("ArrowLeft",Uu);const Qu=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],ko=ve("CircleAlert",Qu);const Ju=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M2 10h20",key:"1ir3d8"}]],pn=ve("FolderClosed",Ju);const ef=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],tf=ve("FolderOpen",ef);const nf=[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]],sf=ve("FolderTree",nf);const of=[["path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",key:"yt0hxn"}]],rf=ve("Hexagon",of);const af=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],ba=ve("LayoutGrid",af);const cf=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]],lf=ve("MessageSquarePlus",cf);const df=[["path",{d:"M10 7.75a.75.75 0 0 1 1.142-.638l3.664 2.249a.75.75 0 0 1 0 1.278l-3.664 2.25a.75.75 0 0 1-1.142-.64z",key:"1pctta"}],["path",{d:"M12 17v4",key:"1riwvh"}],["path",{d:"M8 21h8",key:"1ev6f3"}],["rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",key:"x3v2xh"}]],xr=ve("MonitorPlay",df);const uf=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],jo=ve("Plug",uf);const ff=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Eo=ve("Plus",ff);const hf=[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]],pf=ve("SquareDashed",hf);const mf=[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]],yr=ve("Unplug",mf);const gf=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],xf=ve("UserRound",gf);function he(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,s;n<e.length;n++)(s=he(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var yf={value:()=>{}};function hs(){for(var e=0,t=arguments.length,n={},s;e<t;++e){if(!(s=arguments[e]+"")||s in n||/[\s.]/.test(s))throw new Error("illegal type: "+s);n[s]=[]}return new On(n)}function On(e){this._=e}function wf(e,t){return e.trim().split(/^|\s+/).map(function(n){var s="",o=n.indexOf(".");if(o>=0&&(s=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:s}})}On.prototype=hs.prototype={constructor:On,on:function(e,t){var n=this._,s=wf(e+"",n),o,i=-1,r=s.length;if(arguments.length<2){for(;++i<r;)if((o=(e=s[i]).type)&&(o=vf(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<r;)if(o=(e=s[i]).type)n[o]=wr(n[o],e.name,t);else if(t==null)for(o in n)n[o]=wr(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new On(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),s=0,o,i;s<o;++s)n[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],s=0,o=i.length;s<o;++s)i[s].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],o=0,i=s.length;o<i;++o)s[o].value.apply(t,n)}};function vf(e,t){for(var n=0,s=e.length,o;n<s;++n)if((o=e[n]).name===t)return o.value}function wr(e,t,n){for(var s=0,o=e.length;s<o;++s)if(e[s].name===t){e[s]=yf,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var Ws="http://www.w3.org/1999/xhtml";const vr={svg:"http://www.w3.org/2000/svg",xhtml:Ws,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ps(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),vr.hasOwnProperty(t)?{space:vr[t],local:e}:e}function bf(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Ws&&t.documentElement.namespaceURI===Ws?t.createElement(e):t.createElementNS(n,e)}}function Nf(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Na(e){var t=ps(e);return(t.local?Nf:bf)(t)}function kf(){}function Co(e){return e==null?kf:function(){return this.querySelector(e)}}function jf(e){typeof e!="function"&&(e=Co(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var i=t[o],r=i.length,c=s[o]=new Array(r),l,d,u=0;u<r;++u)(l=i[u])&&(d=e.call(l,l.__data__,u,i))&&("__data__"in l&&(d.__data__=l.__data__),c[u]=d);return new Se(s,this._parents)}function Ef(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Cf(){return[]}function ka(e){return e==null?Cf:function(){return this.querySelectorAll(e)}}function Sf(e){return function(){return Ef(e.apply(this,arguments))}}function If(e){typeof e=="function"?e=Sf(e):e=ka(e);for(var t=this._groups,n=t.length,s=[],o=[],i=0;i<n;++i)for(var r=t[i],c=r.length,l,d=0;d<c;++d)(l=r[d])&&(s.push(e.call(l,l.__data__,d,r)),o.push(l));return new Se(s,o)}function ja(e){return function(){return this.matches(e)}}function Ea(e){return function(t){return t.matches(e)}}var _f=Array.prototype.find;function Mf(e){return function(){return _f.call(this.children,e)}}function $f(){return this.firstElementChild}function Rf(e){return this.select(e==null?$f:Mf(typeof e=="function"?e:Ea(e)))}var Af=Array.prototype.filter;function Df(){return Array.from(this.children)}function Pf(e){return function(){return Af.call(this.children,e)}}function Of(e){return this.selectAll(e==null?Df:Pf(typeof e=="function"?e:Ea(e)))}function Tf(e){typeof e!="function"&&(e=ja(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var i=t[o],r=i.length,c=s[o]=[],l,d=0;d<r;++d)(l=i[d])&&e.call(l,l.__data__,d,i)&&c.push(l);return new Se(s,this._parents)}function Ca(e){return new Array(e.length)}function zf(){return new Se(this._enter||this._groups.map(Ca),this._parents)}function Yn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Yn.prototype={constructor:Yn,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Lf(e){return function(){return e}}function Hf(e,t,n,s,o,i){for(var r=0,c,l=t.length,d=i.length;r<d;++r)(c=t[r])?(c.__data__=i[r],s[r]=c):n[r]=new Yn(e,i[r]);for(;r<l;++r)(c=t[r])&&(o[r]=c)}function Vf(e,t,n,s,o,i,r){var c,l,d=new Map,u=t.length,h=i.length,f=new Array(u),p;for(c=0;c<u;++c)(l=t[c])&&(f[c]=p=r.call(l,l.__data__,c,t)+"",d.has(p)?o[c]=l:d.set(p,l));for(c=0;c<h;++c)p=r.call(e,i[c],c,i)+"",(l=d.get(p))?(s[c]=l,l.__data__=i[c],d.delete(p)):n[c]=new Yn(e,i[c]);for(c=0;c<u;++c)(l=t[c])&&d.get(f[c])===l&&(o[c]=l)}function Ff(e){return e.__data__}function Bf(e,t){if(!arguments.length)return Array.from(this,Ff);var n=t?Vf:Hf,s=this._parents,o=this._groups;typeof e!="function"&&(e=Lf(e));for(var i=o.length,r=new Array(i),c=new Array(i),l=new Array(i),d=0;d<i;++d){var u=s[d],h=o[d],f=h.length,p=Wf(e.call(u,u&&u.__data__,d,s)),m=p.length,w=c[d]=new Array(m),y=r[d]=new Array(m),x=l[d]=new Array(f);n(u,h,w,y,x,p,t);for(var b=0,g=0,v,E;b<m;++b)if(v=w[b]){for(b>=g&&(g=b+1);!(E=y[g])&&++g<m;);v._next=E||null}}return r=new Se(r,s),r._enter=c,r._exit=l,r}function Wf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Yf(){return new Se(this._exit||this._groups.map(Ca),this._parents)}function Xf(e,t,n){var s=this.enter(),o=this,i=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?i.remove():n(i),s&&o?s.merge(o).order():o}function qf(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,o=n.length,i=s.length,r=Math.min(o,i),c=new Array(o),l=0;l<r;++l)for(var d=n[l],u=s[l],h=d.length,f=c[l]=new Array(h),p,m=0;m<h;++m)(p=d[m]||u[m])&&(f[m]=p);for(;l<o;++l)c[l]=n[l];return new Se(c,this._parents)}function Zf(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s=e[t],o=s.length-1,i=s[o],r;--o>=0;)(r=s[o])&&(i&&r.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(r,i),i=r);return this}function Gf(e){e||(e=Uf);function t(h,f){return h&&f?e(h.__data__,f.__data__):!h-!f}for(var n=this._groups,s=n.length,o=new Array(s),i=0;i<s;++i){for(var r=n[i],c=r.length,l=o[i]=new Array(c),d,u=0;u<c;++u)(d=r[u])&&(l[u]=d);l.sort(t)}return new Se(o,this._parents).order()}function Uf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Kf(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Qf(){return Array.from(this)}function Jf(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],o=0,i=s.length;o<i;++o){var r=s[o];if(r)return r}return null}function eh(){let e=0;for(const t of this)++e;return e}function th(){return!this.node()}function nh(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var o=t[n],i=0,r=o.length,c;i<r;++i)(c=o[i])&&e.call(c,c.__data__,i,o);return this}function sh(e){return function(){this.removeAttribute(e)}}function oh(e){return function(){this.removeAttributeNS(e.space,e.local)}}function rh(e,t){return function(){this.setAttribute(e,t)}}function ih(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ah(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function ch(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function lh(e,t){var n=ps(e);if(arguments.length<2){var s=this.node();return n.local?s.getAttributeNS(n.space,n.local):s.getAttribute(n)}return this.each((t==null?n.local?oh:sh:typeof t=="function"?n.local?ch:ah:n.local?ih:rh)(n,t))}function Sa(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function dh(e){return function(){this.style.removeProperty(e)}}function uh(e,t,n){return function(){this.style.setProperty(e,t,n)}}function fh(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function hh(e,t,n){return arguments.length>1?this.each((t==null?dh:typeof t=="function"?fh:uh)(e,t,n??"")):It(this.node(),e)}function It(e,t){return e.style.getPropertyValue(t)||Sa(e).getComputedStyle(e,null).getPropertyValue(t)}function ph(e){return function(){delete this[e]}}function mh(e,t){return function(){this[e]=t}}function gh(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function xh(e,t){return arguments.length>1?this.each((t==null?ph:typeof t=="function"?gh:mh)(e,t)):this.node()[e]}function Ia(e){return e.trim().split(/^|\s+/)}function So(e){return e.classList||new _a(e)}function _a(e){this._node=e,this._names=Ia(e.getAttribute("class")||"")}_a.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Ma(e,t){for(var n=So(e),s=-1,o=t.length;++s<o;)n.add(t[s])}function $a(e,t){for(var n=So(e),s=-1,o=t.length;++s<o;)n.remove(t[s])}function yh(e){return function(){Ma(this,e)}}function wh(e){return function(){$a(this,e)}}function vh(e,t){return function(){(t.apply(this,arguments)?Ma:$a)(this,e)}}function bh(e,t){var n=Ia(e+"");if(arguments.length<2){for(var s=So(this.node()),o=-1,i=n.length;++o<i;)if(!s.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?vh:t?yh:wh)(n,t))}function Nh(){this.textContent=""}function kh(e){return function(){this.textContent=e}}function jh(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Eh(e){return arguments.length?this.each(e==null?Nh:(typeof e=="function"?jh:kh)(e)):this.node().textContent}function Ch(){this.innerHTML=""}function Sh(e){return function(){this.innerHTML=e}}function Ih(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function _h(e){return arguments.length?this.each(e==null?Ch:(typeof e=="function"?Ih:Sh)(e)):this.node().innerHTML}function Mh(){this.nextSibling&&this.parentNode.appendChild(this)}function $h(){return this.each(Mh)}function Rh(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ah(){return this.each(Rh)}function Dh(e){var t=typeof e=="function"?e:Na(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ph(){return null}function Oh(e,t){var n=typeof e=="function"?e:Na(e),s=t==null?Ph:typeof t=="function"?t:Co(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function Th(){var e=this.parentNode;e&&e.removeChild(this)}function zh(){return this.each(Th)}function Lh(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Hh(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Vh(e){return this.select(e?Hh:Lh)}function Fh(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Bh(e){return function(t){e.call(this,t,this.__data__)}}function Wh(e){return e.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");return s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),{type:t,name:n}})}function Yh(e){return function(){var t=this.__on;if(t){for(var n=0,s=-1,o=t.length,i;n<o;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++s]=i;++s?t.length=s:delete this.__on}}}function Xh(e,t,n){return function(){var s=this.__on,o,i=Bh(t);if(s){for(var r=0,c=s.length;r<c;++r)if((o=s[r]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),o.value=t;return}}this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},s?s.push(o):this.__on=[o]}}function qh(e,t,n){var s=Wh(e+""),o,i=s.length,r;if(arguments.length<2){var c=this.node().__on;if(c){for(var l=0,d=c.length,u;l<d;++l)for(o=0,u=c[l];o<i;++o)if((r=s[o]).type===u.type&&r.name===u.name)return u.value}return}for(c=t?Xh:Yh,o=0;o<i;++o)this.each(c(s[o],t,n));return this}function Ra(e,t,n){var s=Sa(e),o=s.CustomEvent;typeof o=="function"?o=new o(t,n):(o=s.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function Zh(e,t){return function(){return Ra(this,e,t)}}function Gh(e,t){return function(){return Ra(this,e,t.apply(this,arguments))}}function Uh(e,t){return this.each((typeof t=="function"?Gh:Zh)(e,t))}function*Kh(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],o=0,i=s.length,r;o<i;++o)(r=s[o])&&(yield r)}var Aa=[null];function Se(e,t){this._groups=e,this._parents=t}function mn(){return new Se([[document.documentElement]],Aa)}function Qh(){return this}Se.prototype=mn.prototype={constructor:Se,select:jf,selectAll:If,selectChild:Rf,selectChildren:Of,filter:Tf,data:Bf,enter:zf,exit:Yf,join:Xf,merge:qf,selection:Qh,order:Zf,sort:Gf,call:Kf,nodes:Qf,node:Jf,size:eh,empty:th,each:nh,attr:lh,style:hh,property:xh,classed:bh,text:Eh,html:_h,raise:$h,lower:Ah,append:Dh,insert:Oh,remove:zh,clone:Vh,datum:Fh,on:qh,dispatch:Uh,[Symbol.iterator]:Kh};function Ce(e){return typeof e=="string"?new Se([[document.querySelector(e)]],[document.documentElement]):new Se([[e]],Aa)}function Jh(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Me(e,t){if(e=Jh(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var s=n.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(t.getScreenCTM().inverse()),[s.x,s.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const ep={passive:!1},Kt={capture:!0,passive:!1};function Is(e){e.stopImmediatePropagation()}function Ct(e){e.preventDefault(),e.stopImmediatePropagation()}function Da(e){var t=e.document.documentElement,n=Ce(e).on("dragstart.drag",Ct,Kt);"onselectstart"in t?n.on("selectstart.drag",Ct,Kt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Pa(e,t){var n=e.document.documentElement,s=Ce(e).on("dragstart.drag",null);t&&(s.on("click.drag",Ct,Kt),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in n?s.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const jn=e=>()=>e;function Ys(e,{sourceEvent:t,subject:n,target:s,identifier:o,active:i,x:r,y:c,dx:l,dy:d,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:r,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:u}})}Ys.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function tp(e){return!e.ctrlKey&&!e.button}function np(){return this.parentNode}function sp(e,t){return t??{x:e.x,y:e.y}}function op(){return navigator.maxTouchPoints||"ontouchstart"in this}function Oa(){var e=tp,t=np,n=sp,s=op,o={},i=hs("start","drag","end"),r=0,c,l,d,u,h=0;function f(v){v.on("mousedown.drag",p).filter(s).on("touchstart.drag",y).on("touchmove.drag",x,ep).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(v,E){if(!(u||!e.call(this,v,E))){var j=g(this,t.call(this,v,E),v,E,"mouse");j&&(Ce(v.view).on("mousemove.drag",m,Kt).on("mouseup.drag",w,Kt),Da(v.view),Is(v),d=!1,c=v.clientX,l=v.clientY,j("start",v))}}function m(v){if(Ct(v),!d){var E=v.clientX-c,j=v.clientY-l;d=E*E+j*j>h}o.mouse("drag",v)}function w(v){Ce(v.view).on("mousemove.drag mouseup.drag",null),Pa(v.view,d),Ct(v),o.mouse("end",v)}function y(v,E){if(e.call(this,v,E)){var j=v.changedTouches,S=t.call(this,v,E),R=j.length,A,V;for(A=0;A<R;++A)(V=g(this,S,v,E,j[A].identifier,j[A]))&&(Is(v),V("start",v,j[A]))}}function x(v){var E=v.changedTouches,j=E.length,S,R;for(S=0;S<j;++S)(R=o[E[S].identifier])&&(Ct(v),R("drag",v,E[S]))}function b(v){var E=v.changedTouches,j=E.length,S,R;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),S=0;S<j;++S)(R=o[E[S].identifier])&&(Is(v),R("end",v,E[S]))}function g(v,E,j,S,R,A){var V=i.copy(),O=Me(A||j,E),z,M,N;if((N=n.call(v,new Ys("beforestart",{sourceEvent:j,target:f,identifier:R,active:r,x:O[0],y:O[1],dx:0,dy:0,dispatch:V}),S))!=null)return z=N.x-O[0]||0,M=N.y-O[1]||0,function C(I,$,_){var D=O,L;switch(I){case"start":o[R]=C,L=r++;break;case"end":delete o[R],--r;case"drag":O=Me(_||$,E),L=r;break}V.call(I,v,new Ys(I,{sourceEvent:$,subject:N,target:f,identifier:R,active:L,x:O[0]+z,y:O[1]+M,dx:O[0]-D[0],dy:O[1]-D[1],dispatch:V}),S)}}return f.filter=function(v){return arguments.length?(e=typeof v=="function"?v:jn(!!v),f):e},f.container=function(v){return arguments.length?(t=typeof v=="function"?v:jn(v),f):t},f.subject=function(v){return arguments.length?(n=typeof v=="function"?v:jn(v),f):n},f.touchable=function(v){return arguments.length?(s=typeof v=="function"?v:jn(!!v),f):s},f.on=function(){var v=i.on.apply(i,arguments);return v===i?f:v},f.clickDistance=function(v){return arguments.length?(h=(v=+v)*v,f):Math.sqrt(h)},f}function Io(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Ta(e,t){var n=Object.create(e.prototype);for(var s in t)n[s]=t[s];return n}function gn(){}var Qt=.7,Xn=1/Qt,St="\\s*([+-]?\\d+)\\s*",Jt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ye="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",rp=/^#([0-9a-f]{3,8})$/,ip=new RegExp(`^rgb\\(${St},${St},${St}\\)$`),ap=new RegExp(`^rgb\\(${Ye},${Ye},${Ye}\\)$`),cp=new RegExp(`^rgba\\(${St},${St},${St},${Jt}\\)$`),lp=new RegExp(`^rgba\\(${Ye},${Ye},${Ye},${Jt}\\)$`),dp=new RegExp(`^hsl\\(${Jt},${Ye},${Ye}\\)$`),up=new RegExp(`^hsla\\(${Jt},${Ye},${Ye},${Jt}\\)$`),br={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Io(gn,mt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Nr,formatHex:Nr,formatHex8:fp,formatHsl:hp,formatRgb:kr,toString:kr});function Nr(){return this.rgb().formatHex()}function fp(){return this.rgb().formatHex8()}function hp(){return za(this).formatHsl()}function kr(){return this.rgb().formatRgb()}function mt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=rp.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?jr(t):n===3?new Ne(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?En(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?En(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=ip.exec(e))?new Ne(t[1],t[2],t[3],1):(t=ap.exec(e))?new Ne(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=cp.exec(e))?En(t[1],t[2],t[3],t[4]):(t=lp.exec(e))?En(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=dp.exec(e))?Sr(t[1],t[2]/100,t[3]/100,1):(t=up.exec(e))?Sr(t[1],t[2]/100,t[3]/100,t[4]):br.hasOwnProperty(e)?jr(br[e]):e==="transparent"?new Ne(NaN,NaN,NaN,0):null}function jr(e){return new Ne(e>>16&255,e>>8&255,e&255,1)}function En(e,t,n,s){return s<=0&&(e=t=n=NaN),new Ne(e,t,n,s)}function pp(e){return e instanceof gn||(e=mt(e)),e?(e=e.rgb(),new Ne(e.r,e.g,e.b,e.opacity)):new Ne}function Xs(e,t,n,s){return arguments.length===1?pp(e):new Ne(e,t,n,s??1)}function Ne(e,t,n,s){this.r=+e,this.g=+t,this.b=+n,this.opacity=+s}Io(Ne,Xs,Ta(gn,{brighter(e){return e=e==null?Xn:Math.pow(Xn,e),new Ne(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Qt:Math.pow(Qt,e),new Ne(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ne(ut(this.r),ut(this.g),ut(this.b),qn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Er,formatHex:Er,formatHex8:mp,formatRgb:Cr,toString:Cr}));function Er(){return`#${lt(this.r)}${lt(this.g)}${lt(this.b)}`}function mp(){return`#${lt(this.r)}${lt(this.g)}${lt(this.b)}${lt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Cr(){const e=qn(this.opacity);return`${e===1?"rgb(":"rgba("}${ut(this.r)}, ${ut(this.g)}, ${ut(this.b)}${e===1?")":`, ${e})`}`}function qn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ut(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function lt(e){return e=ut(e),(e<16?"0":"")+e.toString(16)}function Sr(e,t,n,s){return s<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new $e(e,t,n,s)}function za(e){if(e instanceof $e)return new $e(e.h,e.s,e.l,e.opacity);if(e instanceof gn||(e=mt(e)),!e)return new $e;if(e instanceof $e)return e;e=e.rgb();var t=e.r/255,n=e.g/255,s=e.b/255,o=Math.min(t,n,s),i=Math.max(t,n,s),r=NaN,c=i-o,l=(i+o)/2;return c?(t===i?r=(n-s)/c+(n<s)*6:n===i?r=(s-t)/c+2:r=(t-n)/c+4,c/=l<.5?i+o:2-i-o,r*=60):c=l>0&&l<1?0:r,new $e(r,c,l,e.opacity)}function gp(e,t,n,s){return arguments.length===1?za(e):new $e(e,t,n,s??1)}function $e(e,t,n,s){this.h=+e,this.s=+t,this.l=+n,this.opacity=+s}Io($e,gp,Ta(gn,{brighter(e){return e=e==null?Xn:Math.pow(Xn,e),new $e(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Qt:Math.pow(Qt,e),new $e(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,s=n+(n<.5?n:1-n)*t,o=2*n-s;return new Ne(_s(e>=240?e-240:e+120,o,s),_s(e,o,s),_s(e<120?e+240:e-120,o,s),this.opacity)},clamp(){return new $e(Ir(this.h),Cn(this.s),Cn(this.l),qn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=qn(this.opacity);return`${e===1?"hsl(":"hsla("}${Ir(this.h)}, ${Cn(this.s)*100}%, ${Cn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ir(e){return e=(e||0)%360,e<0?e+360:e}function Cn(e){return Math.max(0,Math.min(1,e||0))}function _s(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const _o=e=>()=>e;function xp(e,t){return function(n){return e+n*t}}function yp(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(s){return Math.pow(e+s*t,n)}}function wp(e){return(e=+e)==1?La:function(t,n){return n-t?yp(t,n,e):_o(isNaN(t)?n:t)}}function La(e,t){var n=t-e;return n?xp(e,n):_o(isNaN(e)?t:e)}const Zn=(function e(t){var n=wp(t);function s(o,i){var r=n((o=Xs(o)).r,(i=Xs(i)).r),c=n(o.g,i.g),l=n(o.b,i.b),d=La(o.opacity,i.opacity);return function(u){return o.r=r(u),o.g=c(u),o.b=l(u),o.opacity=d(u),o+""}}return s.gamma=e,s})(1);function vp(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,s=t.slice(),o;return function(i){for(o=0;o<n;++o)s[o]=e[o]*(1-i)+t[o]*i;return s}}function bp(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Np(e,t){var n=t?t.length:0,s=e?Math.min(n,e.length):0,o=new Array(s),i=new Array(n),r;for(r=0;r<s;++r)o[r]=Zt(e[r],t[r]);for(;r<n;++r)i[r]=t[r];return function(c){for(r=0;r<s;++r)i[r]=o[r](c);return i}}function kp(e,t){var n=new Date;return e=+e,t=+t,function(s){return n.setTime(e*(1-s)+t*s),n}}function Ve(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function jp(e,t){var n={},s={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=Zt(e[o],t[o]):s[o]=t[o];return function(i){for(o in n)s[o]=n[o](i);return s}}var qs=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ms=new RegExp(qs.source,"g");function Ep(e){return function(){return e}}function Cp(e){return function(t){return e(t)+""}}function Ha(e,t){var n=qs.lastIndex=Ms.lastIndex=0,s,o,i,r=-1,c=[],l=[];for(e=e+"",t=t+"";(s=qs.exec(e))&&(o=Ms.exec(t));)(i=o.index)>n&&(i=t.slice(n,i),c[r]?c[r]+=i:c[++r]=i),(s=s[0])===(o=o[0])?c[r]?c[r]+=o:c[++r]=o:(c[++r]=null,l.push({i:r,x:Ve(s,o)})),n=Ms.lastIndex;return n<t.length&&(i=t.slice(n),c[r]?c[r]+=i:c[++r]=i),c.length<2?l[0]?Cp(l[0].x):Ep(t):(t=l.length,function(d){for(var u=0,h;u<t;++u)c[(h=l[u]).i]=h.x(d);return c.join("")})}function Zt(e,t){var n=typeof t,s;return t==null||n==="boolean"?_o(t):(n==="number"?Ve:n==="string"?(s=mt(t))?(t=s,Zn):Ha:t instanceof mt?Zn:t instanceof Date?kp:bp(t)?vp:Array.isArray(t)?Np:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?jp:Ve)(e,t)}var _r=180/Math.PI,Zs={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Va(e,t,n,s,o,i){var r,c,l;return(r=Math.sqrt(e*e+t*t))&&(e/=r,t/=r),(l=e*n+t*s)&&(n-=e*l,s-=t*l),(c=Math.sqrt(n*n+s*s))&&(n/=c,s/=c,l/=c),e*s<t*n&&(e=-e,t=-t,l=-l,r=-r),{translateX:o,translateY:i,rotate:Math.atan2(t,e)*_r,skewX:Math.atan(l)*_r,scaleX:r,scaleY:c}}var Sn;function Sp(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Zs:Va(t.a,t.b,t.c,t.d,t.e,t.f)}function Ip(e){return e==null||(Sn||(Sn=document.createElementNS("http://www.w3.org/2000/svg","g")),Sn.setAttribute("transform",e),!(e=Sn.transform.baseVal.consolidate()))?Zs:(e=e.matrix,Va(e.a,e.b,e.c,e.d,e.e,e.f))}function Fa(e,t,n,s){function o(d){return d.length?d.pop()+" ":""}function i(d,u,h,f,p,m){if(d!==h||u!==f){var w=p.push("translate(",null,t,null,n);m.push({i:w-4,x:Ve(d,h)},{i:w-2,x:Ve(u,f)})}else(h||f)&&p.push("translate("+h+t+f+n)}function r(d,u,h,f){d!==u?(d-u>180?u+=360:u-d>180&&(d+=360),f.push({i:h.push(o(h)+"rotate(",null,s)-2,x:Ve(d,u)})):u&&h.push(o(h)+"rotate("+u+s)}function c(d,u,h,f){d!==u?f.push({i:h.push(o(h)+"skewX(",null,s)-2,x:Ve(d,u)}):u&&h.push(o(h)+"skewX("+u+s)}function l(d,u,h,f,p,m){if(d!==h||u!==f){var w=p.push(o(p)+"scale(",null,",",null,")");m.push({i:w-4,x:Ve(d,h)},{i:w-2,x:Ve(u,f)})}else(h!==1||f!==1)&&p.push(o(p)+"scale("+h+","+f+")")}return function(d,u){var h=[],f=[];return d=e(d),u=e(u),i(d.translateX,d.translateY,u.translateX,u.translateY,h,f),r(d.rotate,u.rotate,h,f),c(d.skewX,u.skewX,h,f),l(d.scaleX,d.scaleY,u.scaleX,u.scaleY,h,f),d=u=null,function(p){for(var m=-1,w=f.length,y;++m<w;)h[(y=f[m]).i]=y.x(p);return h.join("")}}}var _p=Fa(Sp,"px, ","px)","deg)"),Mp=Fa(Ip,", ",")",")"),$p=1e-12;function Mr(e){return((e=Math.exp(e))+1/e)/2}function Rp(e){return((e=Math.exp(e))-1/e)/2}function Ap(e){return((e=Math.exp(2*e))-1)/(e+1)}const Tn=(function e(t,n,s){function o(i,r){var c=i[0],l=i[1],d=i[2],u=r[0],h=r[1],f=r[2],p=u-c,m=h-l,w=p*p+m*m,y,x;if(w<$p)x=Math.log(f/d)/t,y=function(S){return[c+S*p,l+S*m,d*Math.exp(t*S*x)]};else{var b=Math.sqrt(w),g=(f*f-d*d+s*w)/(2*d*n*b),v=(f*f-d*d-s*w)/(2*f*n*b),E=Math.log(Math.sqrt(g*g+1)-g),j=Math.log(Math.sqrt(v*v+1)-v);x=(j-E)/t,y=function(S){var R=S*x,A=Mr(E),V=d/(n*b)*(A*Ap(t*R+E)-Rp(E));return[c+V*p,l+V*m,d*A/Mr(t*R+E)]}}return y.duration=x*1e3*t/Math.SQRT2,y}return o.rho=function(i){var r=Math.max(.001,+i),c=r*r,l=c*c;return e(r,c,l)},o})(Math.SQRT2,2,4);var _t=0,Wt=0,Ft=0,Ba=1e3,Gn,Yt,Un=0,gt=0,ms=0,en=typeof performance=="object"&&performance.now?performance:Date,Wa=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Mo(){return gt||(Wa(Dp),gt=en.now()+ms)}function Dp(){gt=0}function Kn(){this._call=this._time=this._next=null}Kn.prototype=Ya.prototype={constructor:Kn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Mo():+n)+(t==null?0:+t),!this._next&&Yt!==this&&(Yt?Yt._next=this:Gn=this,Yt=this),this._call=e,this._time=n,Gs()},stop:function(){this._call&&(this._call=null,this._time=1/0,Gs())}};function Ya(e,t,n){var s=new Kn;return s.restart(e,t,n),s}function Pp(){Mo(),++_t;for(var e=Gn,t;e;)(t=gt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--_t}function $r(){gt=(Un=en.now())+ms,_t=Wt=0;try{Pp()}finally{_t=0,Tp(),gt=0}}function Op(){var e=en.now(),t=e-Un;t>Ba&&(ms-=t,Un=e)}function Tp(){for(var e,t=Gn,n,s=1/0;t;)t._call?(s>t._time&&(s=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Gn=n);Yt=e,Gs(s)}function Gs(e){if(!_t){Wt&&(Wt=clearTimeout(Wt));var t=e-gt;t>24?(e<1/0&&(Wt=setTimeout($r,e-en.now()-ms)),Ft&&(Ft=clearInterval(Ft))):(Ft||(Un=en.now(),Ft=setInterval(Op,Ba)),_t=1,Wa($r))}}function Rr(e,t,n){var s=new Kn;return t=t==null?0:+t,s.restart(o=>{s.stop(),e(o+t)},t,n),s}var zp=hs("start","end","cancel","interrupt"),Lp=[],Xa=0,Ar=1,Us=2,zn=3,Dr=4,Ks=5,Ln=6;function gs(e,t,n,s,o,i){var r=e.__transition;if(!r)e.__transition={};else if(n in r)return;Hp(e,n,{name:t,index:s,group:o,on:zp,tween:Lp,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Xa})}function $o(e,t){var n=ze(e,t);if(n.state>Xa)throw new Error("too late; already scheduled");return n}function Xe(e,t){var n=ze(e,t);if(n.state>zn)throw new Error("too late; already running");return n}function ze(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Hp(e,t,n){var s=e.__transition,o;s[t]=n,n.timer=Ya(i,0,n.time);function i(d){n.state=Ar,n.timer.restart(r,n.delay,n.time),n.delay<=d&&r(d-n.delay)}function r(d){var u,h,f,p;if(n.state!==Ar)return l();for(u in s)if(p=s[u],p.name===n.name){if(p.state===zn)return Rr(r);p.state===Dr?(p.state=Ln,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete s[u]):+u<t&&(p.state=Ln,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete s[u])}if(Rr(function(){n.state===zn&&(n.state=Dr,n.timer.restart(c,n.delay,n.time),c(d))}),n.state=Us,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Us){for(n.state=zn,o=new Array(f=n.tween.length),u=0,h=-1;u<f;++u)(p=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(o[++h]=p);o.length=h+1}}function c(d){for(var u=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(l),n.state=Ks,1),h=-1,f=o.length;++h<f;)o[h].call(e,u);n.state===Ks&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=Ln,n.timer.stop(),delete s[t];for(var d in s)return;delete e.__transition}}function Hn(e,t){var n=e.__transition,s,o,i=!0,r;if(n){t=t==null?null:t+"";for(r in n){if((s=n[r]).name!==t){i=!1;continue}o=s.state>Us&&s.state<Ks,s.state=Ln,s.timer.stop(),s.on.call(o?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[r]}i&&delete e.__transition}}function Vp(e){return this.each(function(){Hn(this,e)})}function Fp(e,t){var n,s;return function(){var o=Xe(this,e),i=o.tween;if(i!==n){s=n=i;for(var r=0,c=s.length;r<c;++r)if(s[r].name===t){s=s.slice(),s.splice(r,1);break}}o.tween=s}}function Bp(e,t,n){var s,o;if(typeof n!="function")throw new Error;return function(){var i=Xe(this,e),r=i.tween;if(r!==s){o=(s=r).slice();for(var c={name:t,value:n},l=0,d=o.length;l<d;++l)if(o[l].name===t){o[l]=c;break}l===d&&o.push(c)}i.tween=o}}function Wp(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=ze(this.node(),n).tween,o=0,i=s.length,r;o<i;++o)if((r=s[o]).name===e)return r.value;return null}return this.each((t==null?Fp:Bp)(n,e,t))}function Ro(e,t,n){var s=e._id;return e.each(function(){var o=Xe(this,s);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return ze(o,s).value[t]}}function qa(e,t){var n;return(typeof t=="number"?Ve:t instanceof mt?Zn:(n=mt(t))?(t=n,Zn):Ha)(e,t)}function Yp(e){return function(){this.removeAttribute(e)}}function Xp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function qp(e,t,n){var s,o=n+"",i;return function(){var r=this.getAttribute(e);return r===o?null:r===s?i:i=t(s=r,n)}}function Zp(e,t,n){var s,o=n+"",i;return function(){var r=this.getAttributeNS(e.space,e.local);return r===o?null:r===s?i:i=t(s=r,n)}}function Gp(e,t,n){var s,o,i;return function(){var r,c=n(this),l;return c==null?void this.removeAttribute(e):(r=this.getAttribute(e),l=c+"",r===l?null:r===s&&l===o?i:(o=l,i=t(s=r,c)))}}function Up(e,t,n){var s,o,i;return function(){var r,c=n(this),l;return c==null?void this.removeAttributeNS(e.space,e.local):(r=this.getAttributeNS(e.space,e.local),l=c+"",r===l?null:r===s&&l===o?i:(o=l,i=t(s=r,c)))}}function Kp(e,t){var n=ps(e),s=n==="transform"?Mp:qa;return this.attrTween(e,typeof t=="function"?(n.local?Up:Gp)(n,s,Ro(this,"attr."+e,t)):t==null?(n.local?Xp:Yp)(n):(n.local?Zp:qp)(n,s,t))}function Qp(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Jp(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function em(e,t){var n,s;function o(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&Jp(e,i)),n}return o._value=t,o}function tm(e,t){var n,s;function o(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&Qp(e,i)),n}return o._value=t,o}function nm(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var s=ps(e);return this.tween(n,(s.local?em:tm)(s,t))}function sm(e,t){return function(){$o(this,e).delay=+t.apply(this,arguments)}}function om(e,t){return t=+t,function(){$o(this,e).delay=t}}function rm(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?sm:om)(t,e)):ze(this.node(),t).delay}function im(e,t){return function(){Xe(this,e).duration=+t.apply(this,arguments)}}function am(e,t){return t=+t,function(){Xe(this,e).duration=t}}function cm(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?im:am)(t,e)):ze(this.node(),t).duration}function lm(e,t){if(typeof t!="function")throw new Error;return function(){Xe(this,e).ease=t}}function dm(e){var t=this._id;return arguments.length?this.each(lm(t,e)):ze(this.node(),t).ease}function um(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Xe(this,e).ease=n}}function fm(e){if(typeof e!="function")throw new Error;return this.each(um(this._id,e))}function hm(e){typeof e!="function"&&(e=ja(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var i=t[o],r=i.length,c=s[o]=[],l,d=0;d<r;++d)(l=i[d])&&e.call(l,l.__data__,d,i)&&c.push(l);return new Qe(s,this._parents,this._name,this._id)}function pm(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,s=t.length,o=n.length,i=Math.min(s,o),r=new Array(s),c=0;c<i;++c)for(var l=t[c],d=n[c],u=l.length,h=r[c]=new Array(u),f,p=0;p<u;++p)(f=l[p]||d[p])&&(h[p]=f);for(;c<s;++c)r[c]=t[c];return new Qe(r,this._parents,this._name,this._id)}function mm(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function gm(e,t,n){var s,o,i=mm(t)?$o:Xe;return function(){var r=i(this,e),c=r.on;c!==s&&(o=(s=c).copy()).on(t,n),r.on=o}}function xm(e,t){var n=this._id;return arguments.length<2?ze(this.node(),n).on.on(e):this.each(gm(n,e,t))}function ym(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function wm(){return this.on("end.remove",ym(this._id))}function vm(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Co(e));for(var s=this._groups,o=s.length,i=new Array(o),r=0;r<o;++r)for(var c=s[r],l=c.length,d=i[r]=new Array(l),u,h,f=0;f<l;++f)(u=c[f])&&(h=e.call(u,u.__data__,f,c))&&("__data__"in u&&(h.__data__=u.__data__),d[f]=h,gs(d[f],t,n,f,d,ze(u,n)));return new Qe(i,this._parents,t,n)}function bm(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ka(e));for(var s=this._groups,o=s.length,i=[],r=[],c=0;c<o;++c)for(var l=s[c],d=l.length,u,h=0;h<d;++h)if(u=l[h]){for(var f=e.call(u,u.__data__,h,l),p,m=ze(u,n),w=0,y=f.length;w<y;++w)(p=f[w])&&gs(p,t,n,w,f,m);i.push(f),r.push(u)}return new Qe(i,r,t,n)}var Nm=mn.prototype.constructor;function km(){return new Nm(this._groups,this._parents)}function jm(e,t){var n,s,o;return function(){var i=It(this,e),r=(this.style.removeProperty(e),It(this,e));return i===r?null:i===n&&r===s?o:o=t(n=i,s=r)}}function Za(e){return function(){this.style.removeProperty(e)}}function Em(e,t,n){var s,o=n+"",i;return function(){var r=It(this,e);return r===o?null:r===s?i:i=t(s=r,n)}}function Cm(e,t,n){var s,o,i;return function(){var r=It(this,e),c=n(this),l=c+"";return c==null&&(l=c=(this.style.removeProperty(e),It(this,e))),r===l?null:r===s&&l===o?i:(o=l,i=t(s=r,c))}}function Sm(e,t){var n,s,o,i="style."+t,r="end."+i,c;return function(){var l=Xe(this,e),d=l.on,u=l.value[i]==null?c||(c=Za(t)):void 0;(d!==n||o!==u)&&(s=(n=d).copy()).on(r,o=u),l.on=s}}function Im(e,t,n){var s=(e+="")=="transform"?_p:qa;return t==null?this.styleTween(e,jm(e,s)).on("end.style."+e,Za(e)):typeof t=="function"?this.styleTween(e,Cm(e,s,Ro(this,"style."+e,t))).each(Sm(this._id,e)):this.styleTween(e,Em(e,s,t),n).on("end.style."+e,null)}function _m(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function Mm(e,t,n){var s,o;function i(){var r=t.apply(this,arguments);return r!==o&&(s=(o=r)&&_m(e,r,n)),s}return i._value=t,i}function $m(e,t,n){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(t==null)return this.tween(s,null);if(typeof t!="function")throw new Error;return this.tween(s,Mm(e,t,n??""))}function Rm(e){return function(){this.textContent=e}}function Am(e){return function(){var t=e(this);this.textContent=t??""}}function Dm(e){return this.tween("text",typeof e=="function"?Am(Ro(this,"text",e)):Rm(e==null?"":e+""))}function Pm(e){return function(t){this.textContent=e.call(this,t)}}function Om(e){var t,n;function s(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&Pm(o)),t}return s._value=e,s}function Tm(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Om(e))}function zm(){for(var e=this._name,t=this._id,n=Ga(),s=this._groups,o=s.length,i=0;i<o;++i)for(var r=s[i],c=r.length,l,d=0;d<c;++d)if(l=r[d]){var u=ze(l,t);gs(l,e,n,d,r,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Qe(s,this._parents,e,n)}function Lm(){var e,t,n=this,s=n._id,o=n.size();return new Promise(function(i,r){var c={value:r},l={value:function(){--o===0&&i()}};n.each(function(){var d=Xe(this,s),u=d.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(l)),d.on=t}),o===0&&i()})}var Hm=0;function Qe(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function Ga(){return++Hm}var Ue=mn.prototype;Qe.prototype={constructor:Qe,select:vm,selectAll:bm,selectChild:Ue.selectChild,selectChildren:Ue.selectChildren,filter:hm,merge:pm,selection:km,transition:zm,call:Ue.call,nodes:Ue.nodes,node:Ue.node,size:Ue.size,empty:Ue.empty,each:Ue.each,on:xm,attr:Kp,attrTween:nm,style:Im,styleTween:$m,text:Dm,textTween:Tm,remove:wm,tween:Wp,delay:rm,duration:cm,ease:dm,easeVarying:fm,end:Lm,[Symbol.iterator]:Ue[Symbol.iterator]};function Vm(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Fm={time:null,delay:0,duration:250,ease:Vm};function Bm(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Wm(e){var t,n;e instanceof Qe?(t=e._id,e=e._name):(t=Ga(),(n=Fm).time=Mo(),e=e==null?null:e+"");for(var s=this._groups,o=s.length,i=0;i<o;++i)for(var r=s[i],c=r.length,l,d=0;d<c;++d)(l=r[d])&&gs(l,e,t,d,r,n||Bm(l,t));return new Qe(s,this._parents,e,t)}mn.prototype.interrupt=Vp;mn.prototype.transition=Wm;const In=e=>()=>e;function Ym(e,{sourceEvent:t,target:n,transform:s,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:o}})}function Ke(e,t,n){this.k=e,this.x=t,this.y=n}Ke.prototype={constructor:Ke,scale:function(e){return e===1?this:new Ke(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ke(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var xs=new Ke(1,0,0);Ua.prototype=Ke.prototype;function Ua(e){for(;!e.__zoom;)if(!(e=e.parentNode))return xs;return e.__zoom}function $s(e){e.stopImmediatePropagation()}function Bt(e){e.preventDefault(),e.stopImmediatePropagation()}function Xm(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function qm(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Pr(){return this.__zoom||xs}function Zm(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Gm(){return navigator.maxTouchPoints||"ontouchstart"in this}function Um(e,t,n){var s=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],r=e.invertY(t[1][1])-n[1][1];return e.translate(o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o),r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r))}function Ka(){var e=Xm,t=qm,n=Um,s=Zm,o=Gm,i=[0,1/0],r=[[-1/0,-1/0],[1/0,1/0]],c=250,l=Tn,d=hs("start","zoom","end"),u,h,f,p=500,m=150,w=0,y=10;function x(N){N.property("__zoom",Pr).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",V).filter(o).on("touchstart.zoom",O).on("touchmove.zoom",z).on("touchend.zoom touchcancel.zoom",M).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(N,C,I,$){var _=N.selection?N.selection():N;_.property("__zoom",Pr),N!==_?E(N,C,I,$):_.interrupt().each(function(){j(this,arguments).event($).start().zoom(null,typeof C=="function"?C.apply(this,arguments):C).end()})},x.scaleBy=function(N,C,I,$){x.scaleTo(N,function(){var _=this.__zoom.k,D=typeof C=="function"?C.apply(this,arguments):C;return _*D},I,$)},x.scaleTo=function(N,C,I,$){x.transform(N,function(){var _=t.apply(this,arguments),D=this.__zoom,L=I==null?v(_):typeof I=="function"?I.apply(this,arguments):I,H=D.invert(L),F=typeof C=="function"?C.apply(this,arguments):C;return n(g(b(D,F),L,H),_,r)},I,$)},x.translateBy=function(N,C,I,$){x.transform(N,function(){return n(this.__zoom.translate(typeof C=="function"?C.apply(this,arguments):C,typeof I=="function"?I.apply(this,arguments):I),t.apply(this,arguments),r)},null,$)},x.translateTo=function(N,C,I,$,_){x.transform(N,function(){var D=t.apply(this,arguments),L=this.__zoom,H=$==null?v(D):typeof $=="function"?$.apply(this,arguments):$;return n(xs.translate(H[0],H[1]).scale(L.k).translate(typeof C=="function"?-C.apply(this,arguments):-C,typeof I=="function"?-I.apply(this,arguments):-I),D,r)},$,_)};function b(N,C){return C=Math.max(i[0],Math.min(i[1],C)),C===N.k?N:new Ke(C,N.x,N.y)}function g(N,C,I){var $=C[0]-I[0]*N.k,_=C[1]-I[1]*N.k;return $===N.x&&_===N.y?N:new Ke(N.k,$,_)}function v(N){return[(+N[0][0]+ +N[1][0])/2,(+N[0][1]+ +N[1][1])/2]}function E(N,C,I,$){N.on("start.zoom",function(){j(this,arguments).event($).start()}).on("interrupt.zoom end.zoom",function(){j(this,arguments).event($).end()}).tween("zoom",function(){var _=this,D=arguments,L=j(_,D).event($),H=t.apply(_,D),F=I==null?v(H):typeof I=="function"?I.apply(_,D):I,P=Math.max(H[1][0]-H[0][0],H[1][1]-H[0][1]),W=_.__zoom,Y=typeof C=="function"?C.apply(_,D):C,J=l(W.invert(F).concat(P/W.k),Y.invert(F).concat(P/Y.k));return function(U){if(U===1)U=Y;else{var T=J(U),Z=P/T[2];U=new Ke(Z,F[0]-T[0]*Z,F[1]-T[1]*Z)}L.zoom(null,U)}})}function j(N,C,I){return!I&&N.__zooming||new S(N,C)}function S(N,C){this.that=N,this.args=C,this.active=0,this.sourceEvent=null,this.extent=t.apply(N,C),this.taps=0}S.prototype={event:function(N){return N&&(this.sourceEvent=N),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(N,C){return this.mouse&&N!=="mouse"&&(this.mouse[1]=C.invert(this.mouse[0])),this.touch0&&N!=="touch"&&(this.touch0[1]=C.invert(this.touch0[0])),this.touch1&&N!=="touch"&&(this.touch1[1]=C.invert(this.touch1[0])),this.that.__zoom=C,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(N){var C=Ce(this.that).datum();d.call(N,this.that,new Ym(N,{sourceEvent:this.sourceEvent,target:x,transform:this.that.__zoom,dispatch:d}),C)}};function R(N,...C){if(!e.apply(this,arguments))return;var I=j(this,C).event(N),$=this.__zoom,_=Math.max(i[0],Math.min(i[1],$.k*Math.pow(2,s.apply(this,arguments)))),D=Me(N);if(I.wheel)(I.mouse[0][0]!==D[0]||I.mouse[0][1]!==D[1])&&(I.mouse[1]=$.invert(I.mouse[0]=D)),clearTimeout(I.wheel);else{if($.k===_)return;I.mouse=[D,$.invert(D)],Hn(this),I.start()}Bt(N),I.wheel=setTimeout(L,m),I.zoom("mouse",n(g(b($,_),I.mouse[0],I.mouse[1]),I.extent,r));function L(){I.wheel=null,I.end()}}function A(N,...C){if(f||!e.apply(this,arguments))return;var I=N.currentTarget,$=j(this,C,!0).event(N),_=Ce(N.view).on("mousemove.zoom",F,!0).on("mouseup.zoom",P,!0),D=Me(N,I),L=N.clientX,H=N.clientY;Da(N.view),$s(N),$.mouse=[D,this.__zoom.invert(D)],Hn(this),$.start();function F(W){if(Bt(W),!$.moved){var Y=W.clientX-L,J=W.clientY-H;$.moved=Y*Y+J*J>w}$.event(W).zoom("mouse",n(g($.that.__zoom,$.mouse[0]=Me(W,I),$.mouse[1]),$.extent,r))}function P(W){_.on("mousemove.zoom mouseup.zoom",null),Pa(W.view,$.moved),Bt(W),$.event(W).end()}}function V(N,...C){if(e.apply(this,arguments)){var I=this.__zoom,$=Me(N.changedTouches?N.changedTouches[0]:N,this),_=I.invert($),D=I.k*(N.shiftKey?.5:2),L=n(g(b(I,D),$,_),t.apply(this,C),r);Bt(N),c>0?Ce(this).transition().duration(c).call(E,L,$,N):Ce(this).call(x.transform,L,$,N)}}function O(N,...C){if(e.apply(this,arguments)){var I=N.touches,$=I.length,_=j(this,C,N.changedTouches.length===$).event(N),D,L,H,F;for($s(N),L=0;L<$;++L)H=I[L],F=Me(H,this),F=[F,this.__zoom.invert(F),H.identifier],_.touch0?!_.touch1&&_.touch0[2]!==F[2]&&(_.touch1=F,_.taps=0):(_.touch0=F,D=!0,_.taps=1+!!u);u&&(u=clearTimeout(u)),D&&(_.taps<2&&(h=F[0],u=setTimeout(function(){u=null},p)),Hn(this),_.start())}}function z(N,...C){if(this.__zooming){var I=j(this,C).event(N),$=N.changedTouches,_=$.length,D,L,H,F;for(Bt(N),D=0;D<_;++D)L=$[D],H=Me(L,this),I.touch0&&I.touch0[2]===L.identifier?I.touch0[0]=H:I.touch1&&I.touch1[2]===L.identifier&&(I.touch1[0]=H);if(L=I.that.__zoom,I.touch1){var P=I.touch0[0],W=I.touch0[1],Y=I.touch1[0],J=I.touch1[1],U=(U=Y[0]-P[0])*U+(U=Y[1]-P[1])*U,T=(T=J[0]-W[0])*T+(T=J[1]-W[1])*T;L=b(L,Math.sqrt(U/T)),H=[(P[0]+Y[0])/2,(P[1]+Y[1])/2],F=[(W[0]+J[0])/2,(W[1]+J[1])/2]}else if(I.touch0)H=I.touch0[0],F=I.touch0[1];else return;I.zoom("touch",n(g(L,H,F),I.extent,r))}}function M(N,...C){if(this.__zooming){var I=j(this,C).event(N),$=N.changedTouches,_=$.length,D,L;for($s(N),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),D=0;D<_;++D)L=$[D],I.touch0&&I.touch0[2]===L.identifier?delete I.touch0:I.touch1&&I.touch1[2]===L.identifier&&delete I.touch1;if(I.touch1&&!I.touch0&&(I.touch0=I.touch1,delete I.touch1),I.touch0)I.touch0[1]=this.__zoom.invert(I.touch0[0]);else if(I.end(),I.taps===2&&(L=Me(L,this),Math.hypot(h[0]-L[0],h[1]-L[1])<y)){var H=Ce(this).on("dblclick.zoom");H&&H.apply(this,arguments)}}}return x.wheelDelta=function(N){return arguments.length?(s=typeof N=="function"?N:In(+N),x):s},x.filter=function(N){return arguments.length?(e=typeof N=="function"?N:In(!!N),x):e},x.touchable=function(N){return arguments.length?(o=typeof N=="function"?N:In(!!N),x):o},x.extent=function(N){return arguments.length?(t=typeof N=="function"?N:In([[+N[0][0],+N[0][1]],[+N[1][0],+N[1][1]]]),x):t},x.scaleExtent=function(N){return arguments.length?(i[0]=+N[0],i[1]=+N[1],x):[i[0],i[1]]},x.translateExtent=function(N){return arguments.length?(r[0][0]=+N[0][0],r[1][0]=+N[1][0],r[0][1]=+N[0][1],r[1][1]=+N[1][1],x):[[r[0][0],r[0][1]],[r[1][0],r[1][1]]]},x.constrain=function(N){return arguments.length?(n=N,x):n},x.duration=function(N){return arguments.length?(c=+N,x):c},x.interpolate=function(N){return arguments.length?(l=N,x):l},x.on=function(){var N=d.on.apply(d,arguments);return N===d?x:N},x.clickDistance=function(N){return arguments.length?(w=(N=+N)*N,x):Math.sqrt(w)},x.tapDistance=function(N){return arguments.length?(y=+N,x):y},x}const Te={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:s})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:s}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},tn=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Qa=["Enter"," ","Escape"],Ja={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Mt;(function(e){e.Strict="strict",e.Loose="loose"})(Mt||(Mt={}));var ft;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ft||(ft={}));var nn;(function(e){e.Partial="partial",e.Full="full"})(nn||(nn={}));const ec={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var st;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(st||(st={}));var Je;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Je||(Je={}));var q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(q||(q={}));const Or={[q.Left]:q.Right,[q.Right]:q.Left,[q.Top]:q.Bottom,[q.Bottom]:q.Top};function tc(e){return e===null?null:e?"valid":"invalid"}const nc=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,Km=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Ao=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),xn=(e,t=[0,0])=>{const{width:n,height:s}=Le(e),o=e.origin??t,i=n*o[0],r=s*o[1];return{x:e.position.x-i,y:e.position.y-r}},Qm=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const s=e.reduce((o,i)=>{const r=typeof i=="string";let c=!t.nodeLookup&&!r?i:void 0;return t.nodeLookup&&(c=r?t.nodeLookup.get(i):Ao(i)?i:t.nodeLookup.get(i.id)),c?(n=!0,ys(o,Qn(c,t.nodeOrigin))):o},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?ws(s):{x:0,y:0,width:0,height:0}},yn=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=ys(n,Qn(o)),s=!0)}),s?ws(n):{x:0,y:0,width:0,height:0}},Do=(e,t,[n,s,o]=[0,0,1],i=!1,r=!1)=>{const c=(t.x-n)/o,l=(t.y-s)/o,d=t.width/o,u=t.height/o,h=[];for(const f of e.values()){const{measured:p,selectable:m=!0,hidden:w=!1}=f;if(r&&!m||w)continue;const y=p.width??f.width??f.initialWidth??0,x=p.height??f.height??f.initialHeight??0,{x:b,y:g}=f.internals.positionAbsolute,v=ic(c,l,d,u,b,g,y,x),E=y*x,j=i&&v>0;(!f.internals.handleBounds||j||v>=E||f.dragging)&&h.push(f)}return h},Jm=(e,t)=>{const n=new Set;return e.forEach(s=>{n.add(s.id)}),t.filter(s=>n.has(s.source)||n.has(s.target))};function eg(e,t){const n=new Map,s=t?.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{let i;if(t?.includeHiddenNodes){const{width:r,height:c}=Le(o);i=r>0&&c>0}else i=!!(o.measured.width&&o.measured.height&&!o.hidden);i&&(!s||s.has(o.id))&&n.set(o.id,o)}),n}async function tg({nodes:e,width:t,height:n,panZoom:s,minZoom:o,maxZoom:i},r){if(e.size===0)return!0;const c=eg(e,r),l=yn(c),d=Oo(l,t,n,r?.minZoom??o,r?.maxZoom??i,r?.padding??.1);return await s.setViewport(d,{duration:r?.duration,ease:r?.ease,interpolate:r?.interpolate}),!0}function sc({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:s=[0,0],nodeExtent:o,onError:i}){const r=n.get(e),c=r.parentId?n.get(r.parentId):void 0,{x:l,y:d}=c?c.internals.positionAbsolute:{x:0,y:0},u=r.origin??s;let h=r.extent||o;if(r.extent==="parent"&&!r.expandParent)if(!c)i?.("005",Te.error005());else{const{width:p,height:m}=Le(c);p&&m&&(h=[[l,d],[l+p,d+m]])}else c&&yt(r.extent)&&(h=[[r.extent[0][0]+l,r.extent[0][1]+d],[r.extent[1][0]+l,r.extent[1][1]+d]]);const f=yt(h)?xt(t,h,r.measured):t;return(r.measured.width===void 0||r.measured.height===void 0)&&i?.("015",Te.error015()),{position:{x:f.x-l+(r.measured.width??0)*u[0],y:f.y-d+(r.measured.height??0)*u[1]},positionAbsolute:f}}async function ng({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:s,onBeforeDelete:o}){const i=new Set(e.map(f=>f.id)),r=[];for(const f of n){if(f.deletable===!1)continue;const p=i.has(f.id),m=!p&&f.parentId&&r.find(w=>w.id===f.parentId);(p||m)&&r.push(f)}const c=new Set(t.map(f=>f.id)),l=s.filter(f=>f.deletable!==!1),u=Jm(r,l);for(const f of l)c.has(f.id)&&!u.find(m=>m.id===f.id)&&u.push(f);if(!o)return{edges:u,nodes:r};const h=await o({nodes:r,edges:u});return typeof h=="boolean"?h?{edges:u,nodes:r}:{edges:[],nodes:[]}:h}const $t=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),xt=(e={x:0,y:0},t,n)=>({x:$t(e.x,t[0][0],t[1][0]-(n?.width??0)),y:$t(e.y,t[0][1],t[1][1]-(n?.height??0))});function oc(e,t,n){const{width:s,height:o}=Le(n),{x:i,y:r}=n.internals.positionAbsolute;return xt(e,[[i,r],[i+s,r+o]],t)}const Tr=(e,t,n)=>e<t?$t(Math.abs(e-t),1,t)/t:e>n?-$t(Math.abs(e-n),1,t)/t:0,Po=(e,t,n=15,s=40)=>{const o=Tr(e.x,s,t.width-s)*n,i=Tr(e.y,s,t.height-s)*n;return[o,i]},ys=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Qs=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),ws=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),sn=(e,t=[0,0])=>{const{x:n,y:s}=Ao(e)?e.internals.positionAbsolute:xn(e,t);return{x:n,y:s,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Qn=(e,t=[0,0])=>{const{x:n,y:s}=Ao(e)?e.internals.positionAbsolute:xn(e,t);return{x:n,y:s,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:s+(e.measured?.height??e.height??e.initialHeight??0)}},rc=(e,t)=>ws(ys(Qs(e),Qs(t))),ic=(e,t,n,s,o,i,r,c)=>{const l=Math.max(0,Math.min(e+n,o+r)-Math.max(e,o)),d=Math.max(0,Math.min(t+s,i+c)-Math.max(t,i));return Math.ceil(l*d)},Jn=(e,t)=>ic(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),zr=e=>Re(e.width)&&Re(e.height)&&Re(e.x)&&Re(e.y),Re=e=>!isNaN(e)&&isFinite(e),ac=(e,t)=>(n,s)=>{},wn=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),vn=({x:e,y:t},[n,s,o],i=!1,r=[1,1])=>{const c={x:(e-n)/o,y:(t-s)/o};return i?wn(c,r):c},Rt=({x:e,y:t},[n,s,o])=>({x:e*o+n,y:t*o+s});function bt(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function sg(e,t,n){if(typeof e=="string"||typeof e=="number"){const s=bt(e,n),o=bt(e,t);return{top:s,right:o,bottom:s,left:o,x:o*2,y:s*2}}if(typeof e=="object"){const s=bt(e.top??e.y??0,n),o=bt(e.bottom??e.y??0,n),i=bt(e.left??e.x??0,t),r=bt(e.right??e.x??0,t);return{top:s,right:r,bottom:o,left:i,x:i+r,y:s+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function og(e,t,n,s,o,i){const{x:r,y:c}=Rt(e,[t,n,s]),{x:l,y:d}=Rt({x:e.x+e.width,y:e.y+e.height},[t,n,s]),u=o-l,h=i-d;return{left:Math.floor(r),top:Math.floor(c),right:Math.floor(u),bottom:Math.floor(h)}}const Oo=(e,t,n,s,o,i)=>{const r=sg(i,t,n),c=(t-r.x)/e.width,l=(n-r.y)/e.height,d=Math.min(c,l),u=$t(d,s,o),h=e.x+e.width/2,f=e.y+e.height/2,p=t/2-h*u,m=n/2-f*u,w=og(e,p,m,u,t,n),y={left:Math.min(w.left-r.left,0),top:Math.min(w.top-r.top,0),right:Math.min(w.right-r.right,0),bottom:Math.min(w.bottom-r.bottom,0)};return{x:p-y.left+y.right,y:m-y.top+y.bottom,zoom:u}},on=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function yt(e){return e!=null&&e!=="parent"}function Le(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function cc(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function lc(e,t={width:0,height:0},n,s,o){const i={...e},r=s.get(n);if(r){const c=r.origin||o;i.x+=r.internals.positionAbsolute.x-(t.width??0)*c[0],i.y+=r.internals.positionAbsolute.y-(t.height??0)*c[1]}return i}function Lr(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function rg(){let e,t;return{promise:new Promise((s,o)=>{e=s,t=o}),resolve:e,reject:t}}function ig(e){return{...Ja,...e||{}}}function Gt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:s,containerBounds:o}){const{x:i,y:r}=Ae(e),c=vn({x:i-(o?.left??0),y:r-(o?.top??0)},s),{x:l,y:d}=n?wn(c,t):c;return{xSnapped:l,ySnapped:d,...c}}const To=e=>({width:e.offsetWidth,height:e.offsetHeight}),dc=e=>e?.getRootNode?.()||window?.document,ag=["INPUT","SELECT","TEXTAREA"];function uc(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:ag.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const fc=e=>"clientX"in e,Ae=(e,t)=>{const n=fc(e),s=n?e.clientX:e.touches?.[0].clientX,o=n?e.clientY:e.touches?.[0].clientY;return{x:s-(t?.left??0),y:o-(t?.top??0)}},Hr=(e,t,n,s,o)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(r=>{const c=r.getBoundingClientRect();return{id:r.getAttribute("data-handleid"),type:e,nodeId:o,position:r.getAttribute("data-handlepos"),x:(c.left-n.left)/s,y:(c.top-n.top)/s,...To(r)}})};function hc({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:o,sourceControlY:i,targetControlX:r,targetControlY:c}){const l=e*.125+o*.375+r*.375+n*.125,d=t*.125+i*.375+c*.375+s*.125,u=Math.abs(l-e),h=Math.abs(d-t);return[l,d,u,h]}function _n(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Vr({pos:e,x1:t,y1:n,x2:s,y2:o,c:i}){switch(e){case q.Left:return[t-_n(t-s,i),n];case q.Right:return[t+_n(s-t,i),n];case q.Top:return[t,n-_n(n-o,i)];case q.Bottom:return[t,n+_n(o-n,i)]}}function zo({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:s,targetY:o,targetPosition:i=q.Top,curvature:r=.25}){const[c,l]=Vr({pos:n,x1:e,y1:t,x2:s,y2:o,c:r}),[d,u]=Vr({pos:i,x1:s,y1:o,x2:e,y2:t,c:r}),[h,f,p,m]=hc({sourceX:e,sourceY:t,targetX:s,targetY:o,sourceControlX:c,sourceControlY:l,targetControlX:d,targetControlY:u});return[`M${e},${t} C${c},${l} ${d},${u} ${s},${o}`,h,f,p,m]}function pc({sourceX:e,sourceY:t,targetX:n,targetY:s}){const o=Math.abs(n-e)/2,i=n<e?n+o:n-o,r=Math.abs(s-t)/2,c=s<t?s+r:s-r;return[i,c,o,r]}function cg({sourceNode:e,targetNode:t,selected:n=!1,zIndex:s=0,elevateOnSelect:o=!1,zIndexMode:i="basic"}){if(i==="manual")return s;const r=o&&n?s+1e3:s,c=Math.max(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return r+c}function lg({sourceNode:e,targetNode:t,width:n,height:s,transform:o}){const i=ys(Qn(e),Qn(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const r={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:s/o[2]};return Jn(r,ws(i))>0}const dg=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`xy-edge__${e}${t||""}-${n}${s||""}`,ug=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),fg=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",Te.error006()),t;const s=n.getEdgeId||dg;let o;return nc(e)?o={...e}:o={...e,id:s(e)},ug(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function mc({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[o,i,r,c]=pc({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,o,i,r,c]}const Fr={[q.Left]:{x:-1,y:0},[q.Right]:{x:1,y:0},[q.Top]:{x:0,y:-1},[q.Bottom]:{x:0,y:1}},hg=({source:e,sourcePosition:t=q.Bottom,target:n})=>t===q.Left||t===q.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Br=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function pg({source:e,sourcePosition:t=q.Bottom,target:n,targetPosition:s=q.Top,center:o,offset:i,stepPosition:r}){const c=Fr[t],l=Fr[s],d={x:e.x+c.x*i,y:e.y+c.y*i},u={x:n.x+l.x*i,y:n.y+l.y*i},h=hg({source:d,sourcePosition:t,target:u}),f=h.x!==0?"x":"y",p=h[f];let m=[],w,y;const x={x:0,y:0},b={x:0,y:0},[,,g,v]=pc({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[f]*l[f]===-1){f==="x"?(w=o.x??d.x+(u.x-d.x)*r,y=o.y??(d.y+u.y)/2):(w=o.x??(d.x+u.x)/2,y=o.y??d.y+(u.y-d.y)*r);const R=[{x:w,y:d.y},{x:w,y:u.y}],A=[{x:d.x,y},{x:u.x,y}];c[f]===p?m=f==="x"?R:A:m=f==="x"?A:R}else{const R=[{x:d.x,y:u.y}],A=[{x:u.x,y:d.y}];if(f==="x"?m=c.x===p?A:R:m=c.y===p?R:A,t===s){const N=Math.abs(e[f]-n[f]);if(N<=i){const C=Math.min(i-1,i-N);c[f]===p?x[f]=(d[f]>e[f]?-1:1)*C:b[f]=(u[f]>n[f]?-1:1)*C}}if(t!==s){const N=f==="x"?"y":"x",C=c[f]===l[N],I=d[N]>u[N],$=d[N]<u[N];(c[f]===1&&(!C&&I||C&&$)||c[f]!==1&&(!C&&$||C&&I))&&(m=f==="x"?R:A)}const V={x:d.x+x.x,y:d.y+x.y},O={x:u.x+b.x,y:u.y+b.y},z=Math.max(Math.abs(V.x-m[0].x),Math.abs(O.x-m[0].x)),M=Math.max(Math.abs(V.y-m[0].y),Math.abs(O.y-m[0].y));z>=M?(w=(V.x+O.x)/2,y=m[0].y):(w=m[0].x,y=(V.y+O.y)/2)}const E={x:d.x+x.x,y:d.y+x.y},j={x:u.x+b.x,y:u.y+b.y};return[[e,...E.x!==m[0].x||E.y!==m[0].y?[E]:[],...m,...j.x!==m[m.length-1].x||j.y!==m[m.length-1].y?[j]:[],n],w,y,g,v]}function mg(e,t,n,s){const o=Math.min(Br(e,t)/2,Br(t,n)/2,s),{x:i,y:r}=t;if(e.x===i&&i===n.x||e.y===r&&r===n.y)return`L${i} ${r}`;if(e.y===r){const d=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+o*d},${r}Q ${i},${r} ${i},${r+o*u}`}const c=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${i},${r+o*l}Q ${i},${r} ${i+o*c},${r}`}function es({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:s,targetY:o,targetPosition:i=q.Top,borderRadius:r=5,centerX:c,centerY:l,offset:d=20,stepPosition:u=.5}){const[h,f,p,m,w]=pg({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:o},targetPosition:i,center:{x:c,y:l},offset:d,stepPosition:u});let y=`M${h[0].x} ${h[0].y}`;for(let x=1;x<h.length-1;x++)y+=mg(h[x-1],h[x],h[x+1],r);return y+=`L${h[h.length-1].x} ${h[h.length-1].y}`,[y,f,p,m,w]}function Wr(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function gg(e){const{sourceNode:t,targetNode:n}=e;if(!Wr(t)||!Wr(n))return null;const s=t.internals.handleBounds||Yr(t.handles),o=n.internals.handleBounds||Yr(n.handles),i=Xr(s?.source??[],e.sourceHandle),r=Xr(e.connectionMode===Mt.Strict?o?.target??[]:(o?.target??[]).concat(o?.source??[]),e.targetHandle);if(!i||!r)return e.onError?.("008",Te.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=i?.position||q.Bottom,l=r?.position||q.Top,d=wt(t,i,c),u=wt(n,r,l);return{sourceX:d.x,sourceY:d.y,targetX:u.x,targetY:u.y,sourcePosition:c,targetPosition:l}}function Yr(e){if(!e)return null;const t=[],n=[];for(const s of e)s.width=s.width??1,s.height=s.height??1,s.type==="source"?t.push(s):s.type==="target"&&n.push(s);return{source:t,target:n}}function wt(e,t,n=q.Left,s=!1){const o=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:r,height:c}=t??Le(e);if(s)return{x:o+r/2,y:i+c/2};switch(t?.position??n){case q.Top:return{x:o+r/2,y:i};case q.Right:return{x:o+r,y:i+c/2};case q.Bottom:return{x:o+r/2,y:i+c};case q.Left:return{x:o,y:i+c/2}}}function Xr(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Js(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function xg(e,{id:t,defaultColor:n,defaultMarkerStart:s,defaultMarkerEnd:o}){const i=new Set;return e.reduce((r,c)=>([c.markerStart||s,c.markerEnd||o].forEach(l=>{if(l&&typeof l=="object"){const d=Js(l,t);i.has(d)||(r.push({id:d,color:l.color||n,...l}),i.add(d))}}),r),[]).sort((r,c)=>r.id.localeCompare(c.id))}const gc=1e3,yg=10,Lo={nodeOrigin:[0,0],nodeExtent:tn,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},wg={...Lo,checkEquality:!0};function Ho(e,t){const n={...e};for(const s in t)t[s]!==void 0&&(n[s]=t[s]);return n}function vg(e,t,n){const s=Ho(Lo,n);for(const o of e.values())if(o.parentId)Fo(o,e,t,s);else{const i=xn(o,s.nodeOrigin),r=yt(o.extent)?o.extent:s.nodeExtent,c=xt(i,r,Le(o));o.internals.positionAbsolute=c}}function bg(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],s=[];for(const o of e.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(i):o.type==="target"&&s.push(i)}return{source:n,target:s}}function Vo(e){return e==="manual"}function eo(e,t,n,s={}){const o=Ho(wg,s),i={i:0},r=new Map(t),c=o?.elevateNodesOnSelect&&!Vo(o.zIndexMode)?gc:0;let l=e.length>0,d=!1;t.clear(),n.clear();for(const u of e){let h=r.get(u.id);if(o.checkEquality&&u===h?.internals.userNode)t.set(u.id,h);else{const f=xn(u,o.nodeOrigin),p=yt(u.extent)?u.extent:o.nodeExtent,m=xt(f,p,Le(u));h={...o.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:m,handleBounds:bg(u,h),z:xc(u,c,o.zIndexMode),userNode:u}},t.set(u.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(l=!1),u.parentId&&Fo(h,t,n,s,i),d||=u.selected??!1}return{nodesInitialized:l,hasSelectedNodes:d}}function Ng(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Fo(e,t,n,s,o){const{elevateNodesOnSelect:i,nodeOrigin:r,nodeExtent:c,zIndexMode:l}=Ho(Lo,s),d=e.parentId,u=t.get(d);if(!u){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Ng(e,n),o&&!u.parentId&&u.internals.rootParentIndex===void 0&&l==="auto"&&(u.internals.rootParentIndex=++o.i,u.internals.z=u.internals.z+o.i*yg),o&&u.internals.rootParentIndex!==void 0&&(o.i=u.internals.rootParentIndex);const h=i&&!Vo(l)?gc:0,{x:f,y:p,z:m}=kg(e,u,r,c,h,l),{positionAbsolute:w}=e.internals,y=f!==w.x||p!==w.y;(y||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:f,y:p}:w,z:m}})}function xc(e,t,n){const s=Re(e.zIndex)?e.zIndex:0;return Vo(n)?s:s+(e.selected?t:0)}function kg(e,t,n,s,o,i){const{x:r,y:c}=t.internals.positionAbsolute,l=Le(e),d=xn(e,n),u=yt(e.extent)?xt(d,e.extent,l):d;let h=xt({x:r+u.x,y:c+u.y},s,l);e.extent==="parent"&&(h=oc(h,l,t));const f=xc(e,o,i),p=t.internals.z??0;return{x:h.x,y:h.y,z:p>=f?p+1:f}}function Bo(e,t,n,s=[0,0]){const o=[],i=new Map;for(const r of e){const c=t.get(r.parentId);if(!c)continue;const l=i.get(r.parentId)?.expandedRect??sn(c),d=rc(l,r.rect);i.set(r.parentId,{expandedRect:d,parent:c})}return i.size>0&&i.forEach(({expandedRect:r,parent:c},l)=>{const d=c.internals.positionAbsolute,u=Le(c),h=c.origin??s,f=r.x<d.x?Math.round(Math.abs(d.x-r.x)):0,p=r.y<d.y?Math.round(Math.abs(d.y-r.y)):0,m=Math.max(u.width,Math.round(r.width)),w=Math.max(u.height,Math.round(r.height)),y=(m-u.width)*h[0],x=(w-u.height)*h[1];(f>0||p>0||y||x)&&(o.push({id:l,type:"position",position:{x:c.position.x-f+y,y:c.position.y-p+x}}),n.get(l)?.forEach(b=>{e.some(g=>g.id===b.id)||o.push({id:b.id,type:"position",position:{x:b.position.x+f,y:b.position.y+p}})})),(u.width<r.width||u.height<r.height||f||p)&&o.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:m+(f?h[0]*f-y:0),height:w+(p?h[1]*p-x:0)}})}),o}function jg(e,t,n,s,o,i,r){const c=s?.querySelector(".xyflow__viewport");let l=!1;if(!c)return{changes:[],updatedInternals:l};const d=[],u=window.getComputedStyle(c),{m22:h}=new window.DOMMatrixReadOnly(u.transform),f=[];for(const p of e.values()){const m=t.get(p.id);if(!m)continue;if(m.hidden){t.set(m.id,{...m,internals:{...m.internals,handleBounds:void 0}}),l=!0;continue}const w=To(p.nodeElement),y=m.measured.width!==w.width||m.measured.height!==w.height;if(!!(w.width&&w.height&&(y||!m.internals.handleBounds||p.force))){const b=p.nodeElement.getBoundingClientRect(),g=yt(m.extent)?m.extent:i;let{positionAbsolute:v}=m.internals;if(m.parentId&&m.extent==="parent"){const j=t.get(m.parentId);j&&(v=oc(v,w,j))}else g&&(v=xt(v,g,w));const E={...m,measured:w,internals:{...m.internals,positionAbsolute:v,handleBounds:{source:Hr("source",p.nodeElement,b,h,m.id),target:Hr("target",p.nodeElement,b,h,m.id)}}};t.set(m.id,E),m.parentId&&Fo(E,t,n,{nodeOrigin:o,zIndexMode:r}),l=!0,y&&(d.push({id:m.id,type:"dimensions",dimensions:w}),m.expandParent&&m.parentId&&f.push({id:m.id,parentId:m.parentId,rect:sn(E,o)}))}}if(f.length>0){const p=Bo(f,t,n,o);d.push(...p)}return{changes:d,updatedInternals:l}}async function Eg({delta:e,panZoom:t,transform:n,translateExtent:s,width:o,height:i}){if(!t||!e.x&&!e.y)return!1;const r=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],s);return!!r&&(r.x!==n[0]||r.y!==n[1]||r.k!==n[2])}function qr(e,t,n,s,o,i){let r=o;const c=s.get(r)||new Map;s.set(r,c.set(n,t)),r=`${o}-${e}`;const l=s.get(r)||new Map;if(s.set(r,l.set(n,t)),i){r=`${o}-${e}-${i}`;const d=s.get(r)||new Map;s.set(r,d.set(n,t))}}function yc(e,t,n){e.clear(),t.clear();for(const s of n){const{source:o,target:i,sourceHandle:r=null,targetHandle:c=null}=s,l={edgeId:s.id,source:o,target:i,sourceHandle:r,targetHandle:c},d=`${o}-${r}--${i}-${c}`,u=`${i}-${c}--${o}-${r}`;qr("source",l,u,e,o,r),qr("target",l,d,e,i,c),t.set(s.id,s)}}function wc(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:wc(n,t):!1}function Zr(e,t,n){let s=e;do{if(s?.matches?.(t))return!0;if(s===n)return!1;s=s?.parentElement}while(s);return!1}function Cg(e,t,n,s){const o=new Map;for(const[i,r]of e)if((r.selected||r.id===s)&&(!r.parentId||!wc(r,e))&&(r.draggable||t&&typeof r.draggable>"u")){const c=e.get(i);c&&o.set(i,{id:i,position:c.position||{x:0,y:0},distance:{x:n.x-c.internals.positionAbsolute.x,y:n.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return o}function Rs({nodeId:e,dragItems:t,nodeLookup:n,dragging:s=!0}){const o=[];for(const[r,c]of t){const l=n.get(r)?.internals.userNode;l&&o.push({...l,position:c.position,dragging:s})}if(!e)return[o[0],o];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:s}:o[0],o]}function Sg({dragItems:e,snapGrid:t,x:n,y:s}){const o=e.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:s-o.distance.y},r=wn(i,t);return{x:r.x-i.x,y:r.y-i.y}}function Ig({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:s,onDragStop:o}){let i={x:null,y:null},r=0,c=new Map,l=!1,d={x:0,y:0},u=null,h=!1,f=null,p=!1,m=!1,w=null;function y({noDragClassName:b,handleSelector:g,domNode:v,isSelectable:E,nodeId:j,nodeClickDistance:S=0}){f=Ce(v);function R({x:z,y:M}){const{nodeLookup:N,nodeExtent:C,snapGrid:I,snapToGrid:$,nodeOrigin:_,onNodeDrag:D,onSelectionDrag:L,onError:H,updateNodePositions:F}=t();i={x:z,y:M};let P=!1;const W=c.size>1,Y=W&&C?Qs(yn(c)):null,J=W&&$?Sg({dragItems:c,snapGrid:I,x:z,y:M}):null;for(const[U,T]of c){if(!N.has(U))continue;let Z={x:z-T.distance.x,y:M-T.distance.y};$&&(Z=J?{x:Math.round(Z.x+J.x),y:Math.round(Z.y+J.y)}:wn(Z,I));let ee=null;if(W&&C&&!T.extent&&Y){const{positionAbsolute:Q}=T.internals,re=Q.x-Y.x+C[0][0],ie=Q.x+T.measured.width-Y.x2+C[1][0],ce=Q.y-Y.y+C[0][1],ue=Q.y+T.measured.height-Y.y2+C[1][1];ee=[[re,ce],[ie,ue]]}const{position:te,positionAbsolute:K}=sc({nodeId:U,nextPosition:Z,nodeLookup:N,nodeExtent:ee||C,nodeOrigin:_,onError:H});P=P||T.position.x!==te.x||T.position.y!==te.y,T.position=te,T.internals.positionAbsolute=K}if(m=m||P,!!P&&(F(c,!0),w&&(s||D||!j&&L))){const[U,T]=Rs({nodeId:j,dragItems:c,nodeLookup:N});s?.(w,c,U,T),D?.(w,U,T),j||L?.(w,T)}}async function A(){if(!u)return;const{transform:z,panBy:M,autoPanSpeed:N,autoPanOnNodeDrag:C}=t();if(!C){l=!1,cancelAnimationFrame(r);return}const[I,$]=Po(d,u,N);(I!==0||$!==0)&&(i.x=(i.x??0)-I/z[2],i.y=(i.y??0)-$/z[2],await M({x:I,y:$})&&R(i)),r=requestAnimationFrame(A)}function V(z){const{nodeLookup:M,multiSelectionActive:N,nodesDraggable:C,transform:I,snapGrid:$,snapToGrid:_,selectNodesOnDrag:D,onNodeDragStart:L,onSelectionDragStart:H,unselectNodesAndEdges:F}=t();h=!0,(!D||!E)&&!N&&j&&(M.get(j)?.selected||F()),E&&D&&j&&e?.(j);const P=Gt(z.sourceEvent,{transform:I,snapGrid:$,snapToGrid:_,containerBounds:u});if(i=P,c=Cg(M,C,P,j),c.size>0&&(n||L||!j&&H)){const[W,Y]=Rs({nodeId:j,dragItems:c,nodeLookup:M});n?.(z.sourceEvent,c,W,Y),L?.(z.sourceEvent,W,Y),j||H?.(z.sourceEvent,Y)}}const O=Oa().clickDistance(S).on("start",z=>{const{domNode:M,nodeDragThreshold:N,transform:C,snapGrid:I,snapToGrid:$}=t();u=M?.getBoundingClientRect()||null,p=!1,m=!1,w=z.sourceEvent,N===0&&V(z),i=Gt(z.sourceEvent,{transform:C,snapGrid:I,snapToGrid:$,containerBounds:u}),d=Ae(z.sourceEvent,u)}).on("drag",z=>{const{autoPanOnNodeDrag:M,transform:N,snapGrid:C,snapToGrid:I,nodeDragThreshold:$,nodeLookup:_}=t(),D=Gt(z.sourceEvent,{transform:N,snapGrid:C,snapToGrid:I,containerBounds:u});if(w=z.sourceEvent,(z.sourceEvent.type==="touchmove"&&z.sourceEvent.touches.length>1||j&&!_.has(j))&&(p=!0),!p){if(!l&&M&&h&&(l=!0,A()),!h){const L=Ae(z.sourceEvent,u),H=L.x-d.x,F=L.y-d.y;Math.sqrt(H*H+F*F)>$&&V(z)}(i.x!==D.xSnapped||i.y!==D.ySnapped)&&c&&h&&(d=Ae(z.sourceEvent,u),R(D))}}).on("end",z=>{if(!h||p){p&&c.size>0&&t().updateNodePositions(c,!1);return}if(l=!1,h=!1,cancelAnimationFrame(r),c.size>0){const{nodeLookup:M,updateNodePositions:N,onNodeDragStop:C,onSelectionDragStop:I}=t();if(m&&(N(c,!1),m=!1),o||C||!j&&I){const[$,_]=Rs({nodeId:j,dragItems:c,nodeLookup:M,dragging:!1});o?.(z.sourceEvent,c,$,_),C?.(z.sourceEvent,$,_),j||I?.(z.sourceEvent,_)}}}).filter(z=>{const M=z.target;return!z.button&&(!b||!Zr(M,`.${b}`,v))&&(!g||Zr(M,g,v))});f.call(O)}function x(){f?.on(".drag",null)}return{update:y,destroy:x}}function _g(e,t,n){const s=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())Jn(o,sn(i))>0&&s.push(i);return s}const Mg=250;function $g(e,t,n,s){let o=[],i=1/0;const r=_g(e,n,t+Mg);for(const c of r){const l=[...c.internals.handleBounds?.source??[],...c.internals.handleBounds?.target??[]];for(const d of l){if(s.nodeId===d.nodeId&&s.type===d.type&&s.id===d.id)continue;const{x:u,y:h}=wt(c,d,d.position,!0),f=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(h-e.y,2));f>t||(f<i?(o=[{...d,x:u,y:h}],i=f):f===i&&o.push({...d,x:u,y:h}))}}if(!o.length)return null;if(o.length>1){const c=s.type==="source"?"target":"source";return o.find(l=>l.type===c)??o[0]}return o[0]}function vc(e,t,n,s,o,i=!1){const r=s.get(e);if(!r)return null;const c=o==="strict"?r.internals.handleBounds?.[t]:[...r.internals.handleBounds?.source??[],...r.internals.handleBounds?.target??[]],l=(n?c?.find(d=>d.id===n):c?.[0])??null;return l&&i?{...l,...wt(r,l,l.position,!0)}:l}function bc(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Rg(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Nc=()=>!0;function Ag(e,{connectionMode:t,connectionRadius:n,handleId:s,nodeId:o,edgeUpdaterType:i,isTarget:r,domNode:c,nodeLookup:l,lib:d,autoPanOnConnect:u,flowId:h,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:w,onConnectEnd:y,isValidConnection:x=Nc,onReconnectEnd:b,updateConnection:g,getTransform:v,getFromHandle:E,autoPanSpeed:j,dragThreshold:S=1,handleDomNode:R}){const A=dc(e.target);let V=0,O;const{x:z,y:M}=Ae(e),N=bc(i,R),C=c?.getBoundingClientRect();let I=!1;if(!C||!N)return;const $=vc(o,N,s,l,t);if(!$)return;let _=Ae(e,C),D=!1,L=null,H=!1,F=null;function P(){if(!u||!C)return;const[te,K]=Po(_,C,j);f({x:te,y:K}),V=requestAnimationFrame(P)}const W={...$,nodeId:o,type:N,position:$.position},Y=l.get(o);let U={inProgress:!0,isValid:null,from:wt(Y,W,q.Left,!0),fromHandle:W,fromPosition:W.position,fromNode:Y,to:_,toHandle:null,toPosition:Or[W.position],toNode:null,pointer:_};function T(){I=!0,g(U),m?.(e,{nodeId:o,handleId:s,handleType:N})}S===0&&T();function Z(te){if(!I){const{x:ue,y:ge}=Ae(te),be=ue-z,Ee=ge-M;if(!(be*be+Ee*Ee>S*S))return;T()}if(!E()||!W){ee(te);return}const K=v();_=Ae(te,C),O=$g(vn(_,K,!1,[1,1]),n,l,W),D||(P(),D=!0);const Q=kc(te,{handle:O,connectionMode:t,fromNodeId:o,fromHandleId:s,fromType:r?"target":"source",isValidConnection:x,doc:A,lib:d,flowId:h,nodeLookup:l});F=Q.handleDomNode,L=Q.connection,H=Rg(!!O,Q.isValid);const re=l.get(o),ie=re?wt(re,W,q.Left,!0):U.from,ce={...U,from:ie,isValid:H,to:Q.toHandle&&H?Rt({x:Q.toHandle.x,y:Q.toHandle.y},K):_,toHandle:Q.toHandle,toPosition:H&&Q.toHandle?Q.toHandle.position:Or[W.position],toNode:Q.toHandle?l.get(Q.toHandle.nodeId):null,pointer:_};g(ce),U=ce}function ee(te){if(!("touches"in te&&te.touches.length>0)){if(I){(O||F)&&L&&H&&w?.(L);const{inProgress:K,...Q}=U,re={...Q,toPosition:U.toHandle?U.toPosition:null};y?.(te,re),i&&b?.(te,re)}p(),cancelAnimationFrame(V),D=!1,H=!1,L=null,F=null,A.removeEventListener("mousemove",Z),A.removeEventListener("mouseup",ee),A.removeEventListener("touchmove",Z),A.removeEventListener("touchend",ee)}}A.addEventListener("mousemove",Z),A.addEventListener("mouseup",ee),A.addEventListener("touchmove",Z),A.addEventListener("touchend",ee)}function kc(e,{handle:t,connectionMode:n,fromNodeId:s,fromHandleId:o,fromType:i,doc:r,lib:c,flowId:l,isValidConnection:d=Nc,nodeLookup:u}){const h=i==="target",f=t?r.querySelector(`.${c}-flow__handle[data-id="${l}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=Ae(e),w=r.elementFromPoint(p,m),y=w?.classList.contains(`${c}-flow__handle`)?w:f,x={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const b=bc(void 0,y),g=y.getAttribute("data-nodeid"),v=y.getAttribute("data-handleid"),E=y.classList.contains("connectable"),j=y.classList.contains("connectableend");if(!g||!b)return x;const S={source:h?g:s,sourceHandle:h?v:o,target:h?s:g,targetHandle:h?o:v};x.connection=S;const A=E&&j&&(n===Mt.Strict?h&&b==="source"||!h&&b==="target":g!==s||v!==o);x.isValid=A&&d(S),x.toHandle=vc(g,b,v,u,n,!0)}return x}const to={onPointerDown:Ag,isValid:kc};function Dg({domNode:e,panZoom:t,getTransform:n,getViewScale:s}){const o=Ce(e);function i({translateExtent:c,width:l,height:d,zoomStep:u=1,pannable:h=!0,zoomable:f=!0,inversePan:p=!1}){const m=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const v=n(),E=g.sourceEvent.ctrlKey&&on()?10:1,j=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*u,S=v[2]*Math.pow(2,j*E);t.scaleTo(S)};let w=[0,0];const y=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(w=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},x=g=>{const v=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const E=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],j=[E[0]-w[0],E[1]-w[1]];w=E;const S=s()*Math.max(v[2],Math.log(v[2]))*(p?-1:1),R={x:v[0]-j[0]*S,y:v[1]-j[1]*S},A=[[0,0],[l,d]];t.setViewportConstrained({x:R.x,y:R.y,zoom:v[2]},A,c)},b=Ka().on("start",y).on("zoom",h?x:null).on("zoom.wheel",f?m:null);o.call(b,{})}function r(){o.on("zoom",null)}return{update:i,destroy:r,pointer:Me}}const vs=e=>({x:e.x,y:e.y,zoom:e.k}),As=({x:e,y:t,zoom:n})=>xs.translate(e,t).scale(n),nt=(e,t)=>e.target.closest(`.${t}`),jc=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Pg=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ds=(e,t=0,n=Pg,s=()=>{})=>{const o=typeof t=="number"&&t>0;return o||s(),o?e.transition().duration(t).ease(n).on("end",s):e},Ec=e=>{const t=e.ctrlKey&&on()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Og({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:s,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:r,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:d}){return u=>{if(nt(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const h=n.property("__zoom").k||1;if(u.ctrlKey&&r){const y=Me(u),x=Ec(u),b=h*Math.pow(2,x);s.scaleTo(n,b,y,u);return}const f=u.deltaMode===1?20:1;let p=o===ft.Vertical?0:u.deltaX*f,m=o===ft.Horizontal?0:u.deltaY*f;!on()&&u.shiftKey&&o!==ft.Vertical&&(p=u.deltaY*f,m=0),s.translateBy(n,-(p/h)*i,-(m/h)*i,{internal:!0});const w=vs(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?l?.(u,w):(e.isPanScrolling=!0,c?.(u,w)),e.panScrollTimeout=setTimeout(()=>{d?.(u,w),e.isPanScrolling=!1},150)}}function Tg({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(s,o){const i=s.type==="wheel",r=!t&&i&&!s.ctrlKey,c=nt(s,e);if(s.ctrlKey&&i&&c&&s.preventDefault(),r||c)return null;s.preventDefault(),n.call(this,s,o)}}function zg({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return s=>{if(s.sourceEvent?.internal)return;const o=vs(s.transform);e.mouseButton=s.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=o,s.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(s.sourceEvent,o)}}function Lg({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:s,onPanZoom:o}){return i=>{e.usedRightMouseButton=!!(n&&jc(t,e.mouseButton??0)),i.sourceEvent?.sync||s([i.transform.x,i.transform.y,i.transform.k]),o&&!i.sourceEvent?.internal&&o?.(i.sourceEvent,vs(i.transform))}}function Hg({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:s,onPanZoomEnd:o,onPaneContextMenu:i}){return r=>{if(!r.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&jc(t,e.mouseButton??0)&&!e.usedRightMouseButton&&r.sourceEvent&&i(r.sourceEvent),e.usedRightMouseButton=!1,s(!1),o)){const c=vs(r.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o?.(r.sourceEvent,c)},n?150:0)}}}function Vg({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:s,panOnDrag:o,panOnScroll:i,zoomOnDoubleClick:r,userSelectionActive:c,noWheelClassName:l,noPanClassName:d,lib:u,connectionInProgress:h}){return f=>{const p=t||n,m=s&&f.ctrlKey,w=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(nt(f,`${u}-flow__node`)||nt(f,`${u}-flow__edge`)||nt(f,`${u}-flow__selection`)||nt(f,`${u}-flow__nodesselection`)))return!0;if(!o&&!p&&!i&&!r&&!s||c||h&&!w||nt(f,l)&&w||nt(f,d)&&(!w||i&&w&&!t)||!s&&f.ctrlKey&&w)return!1;if(!s&&f.type==="touchstart"&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!i&&!m&&w||!o&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(o)&&!o.includes(f.button)&&f.type==="mousedown")return!1;const y=Array.isArray(o)&&o.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||w||e)&&y}}function Fg({domNode:e,minZoom:t,maxZoom:n,translateExtent:s,viewport:o,onPanZoom:i,onPanZoomStart:r,onPanZoomEnd:c,onDraggingChange:l}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect();let h=[[0,0],[u.width,u.height]];(typeof ResizeObserver<"u"?new ResizeObserver(M=>{const N=M[0];N&&(h=[[0,0],[N.contentRect.width,N.contentRect.height]])}):null)?.observe(e);const p=Ka().extent(()=>h).scaleExtent([t,n]).translateExtent(s),m=Ce(e).call(p);v({x:o.x,y:o.y,zoom:$t(o.zoom,t,n)},[[0,0],[u.width,u.height]],s);const w=m.on("wheel.zoom"),y=m.on("dblclick.zoom");p.wheelDelta(Ec);async function x(M,N){return m?new Promise(C=>{p?.interpolate(N?.interpolate==="linear"?Zt:Tn).transform(Ds(m,N?.duration,N?.ease,()=>C(!0)),M)}):!1}function b({noWheelClassName:M,noPanClassName:N,onPaneContextMenu:C,userSelectionActive:I,panOnScroll:$,panOnDrag:_,panOnScrollMode:D,panOnScrollSpeed:L,preventScrolling:H,zoomOnPinch:F,zoomOnScroll:P,zoomOnDoubleClick:W,panActivationKeyPressed:Y=!1,zoomActivationKeyPressed:J,lib:U,onTransformChange:T,connectionInProgress:Z,paneClickDistance:ee,selectionOnDrag:te}){I&&!d.isZoomingOrPanning&&g();const K=$&&!J&&!I;p.clickDistance(te?1/0:!Re(ee)||ee<0?0:ee);const Q=K?Og({zoomPanValues:d,noWheelClassName:M,d3Selection:m,d3Zoom:p,panOnScrollMode:D,panOnScrollSpeed:L,zoomOnPinch:F,onPanZoomStart:r,onPanZoom:i,onPanZoomEnd:c}):Tg({noWheelClassName:M,preventScrolling:H,d3ZoomHandler:w});m.on("wheel.zoom",Q,{passive:!1});const re=zg({zoomPanValues:d,onDraggingChange:l,onPanZoomStart:r});p.on("start",re);const ie=Lg({zoomPanValues:d,panOnDrag:_,onPaneContextMenu:!!C,onPanZoom:i,onTransformChange:T});p.on("zoom",ie);const ce=Hg({zoomPanValues:d,panOnDrag:_,panOnScroll:$,onPaneContextMenu:C,onPanZoomEnd:c,onDraggingChange:l});p.on("end",ce);const ue=Vg({panActivationKeyPressed:Y,zoomActivationKeyPressed:J,panOnDrag:_,zoomOnScroll:P,panOnScroll:$,zoomOnDoubleClick:W,zoomOnPinch:F,userSelectionActive:I,noPanClassName:N,noWheelClassName:M,lib:U,connectionInProgress:Z});p.filter(ue),W?m.on("dblclick.zoom",y):m.on("dblclick.zoom",null)}function g(){p.on("zoom",null)}async function v(M,N,C){const I=As(M),$=p?.constrain()(I,N,C);return $&&await x($),$}async function E(M,N){const C=As(M);return await x(C,N),C}function j(M){if(m){const N=As(M),C=m.property("__zoom");(C.k!==M.zoom||C.x!==M.x||C.y!==M.y)&&p?.transform(m,N,null,{sync:!0})}}function S(){const M=m?Ua(m.node()):{x:0,y:0,k:1};return{x:M.x,y:M.y,zoom:M.k}}async function R(M,N){return m?new Promise(C=>{p?.interpolate(N?.interpolate==="linear"?Zt:Tn).scaleTo(Ds(m,N?.duration,N?.ease,()=>C(!0)),M)}):!1}async function A(M,N){return m?new Promise(C=>{p?.interpolate(N?.interpolate==="linear"?Zt:Tn).scaleBy(Ds(m,N?.duration,N?.ease,()=>C(!0)),M)}):!1}function V(M){p?.scaleExtent(M)}function O(M){p?.translateExtent(M)}function z(M){const N=!Re(M)||M<0?0:M;p?.clickDistance(N)}return{update:b,destroy:g,setViewport:E,setViewportConstrained:v,getViewport:S,scaleTo:R,scaleBy:A,setScaleExtent:V,setTranslateExtent:O,syncViewport:j,setClickDistance:z}}var At;(function(e){e.Line="line",e.Handle="handle"})(At||(At={}));function Bg({width:e,prevWidth:t,height:n,prevHeight:s,affectsX:o,affectsY:i}){const r=e-t,c=n-s,l=[r>0?1:r<0?-1:0,c>0?1:c<0?-1:0];return r&&o&&(l[0]=l[0]*-1),c&&i&&(l[1]=l[1]*-1),l}function Gr(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),s=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:s,affectsY:o}}function et(e,t){return Math.max(0,t-e)}function tt(e,t){return Math.max(0,e-t)}function Mn(e,t,n){return Math.max(0,t-e,e-n)}function Ur(e,t){return e?!t:t}function Wg(e,t,n,s,o,i,r,c){let{affectsX:l,affectsY:d}=t;const{isHorizontal:u,isVertical:h}=t,f=u&&h,{xSnapped:p,ySnapped:m}=n,{minWidth:w,maxWidth:y,minHeight:x,maxHeight:b}=s,{x:g,y:v,width:E,height:j,aspectRatio:S}=e;let R=Math.floor(u?p-e.pointerX:0),A=Math.floor(h?m-e.pointerY:0);const V=E+(l?-R:R),O=j+(d?-A:A),z=-i[0]*E,M=-i[1]*j;let N=Mn(V,w,y),C=Mn(O,x,b);if(r){let _=0,D=0;l&&R<0?_=et(g+R+z,r[0][0]):!l&&R>0&&(_=tt(g+V+z,r[1][0])),d&&A<0?D=et(v+A+M,r[0][1]):!d&&A>0&&(D=tt(v+O+M,r[1][1])),N=Math.max(N,_),C=Math.max(C,D)}if(c){let _=0,D=0;l&&R>0?_=tt(g+R,c[0][0]):!l&&R<0&&(_=et(g+V,c[1][0])),d&&A>0?D=tt(v+A,c[0][1]):!d&&A<0&&(D=et(v+O,c[1][1])),N=Math.max(N,_),C=Math.max(C,D)}if(o){if(u){const _=Mn(V/S,x,b)*S;if(N=Math.max(N,_),r){let D=0;!l&&!d||l&&!d&&f?D=tt(v+M+V/S,r[1][1])*S:D=et(v+M+(l?R:-R)/S,r[0][1])*S,N=Math.max(N,D)}if(c){let D=0;!l&&!d||l&&!d&&f?D=et(v+V/S,c[1][1])*S:D=tt(v+(l?R:-R)/S,c[0][1])*S,N=Math.max(N,D)}}if(h){const _=Mn(O*S,w,y)/S;if(C=Math.max(C,_),r){let D=0;!l&&!d||d&&!l&&f?D=tt(g+O*S+z,r[1][0])/S:D=et(g+(d?A:-A)*S+z,r[0][0])/S,C=Math.max(C,D)}if(c){let D=0;!l&&!d||d&&!l&&f?D=et(g+O*S,c[1][0])/S:D=tt(g+(d?A:-A)*S,c[0][0])/S,C=Math.max(C,D)}}}A=A+(A<0?C:-C),R=R+(R<0?N:-N),o&&(f?V>O*S?A=(Ur(l,d)?-R:R)/S:R=(Ur(l,d)?-A:A)*S:u?(A=R/S,d=l):(R=A*S,l=d));const I=l?g+R:g,$=d?v+A:v;return{width:E+(l?-R:R),height:j+(d?-A:A),x:i[0]*R*(l?-1:1)+I,y:i[1]*A*(d?-1:1)+$}}const Cc={width:0,height:0,x:0,y:0},Yg={...Cc,pointerX:0,pointerY:0,aspectRatio:1};function Xg(e,t,n){const s=t.position.x+e.position.x,o=t.position.y+e.position.y,i=e.measured.width??0,r=e.measured.height??0,c=n[0]*i,l=n[1]*r;return[[s-c,o-l],[s+i-c,o+r-l]]}function qg({domNode:e,nodeId:t,getStoreItems:n,onChange:s,onEnd:o}){const i=Ce(e);let r={controlDirection:Gr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:d,boundaries:u,keepAspectRatio:h,resizeDirection:f,onResizeStart:p,onResize:m,onResizeEnd:w,shouldResize:y}){let x={...Cc},b={...Yg};r={boundaries:u,resizeDirection:f,keepAspectRatio:h,controlDirection:Gr(d)};let g,v=null,E=[],j,S,R,A=!1;const V=Oa().on("start",O=>{const{nodeLookup:z,transform:M,snapGrid:N,snapToGrid:C,nodeOrigin:I,paneDomNode:$}=n();if(g=z.get(t),!g)return;v=$?.getBoundingClientRect()??null;const{xSnapped:_,ySnapped:D}=Gt(O.sourceEvent,{transform:M,snapGrid:N,snapToGrid:C,containerBounds:v});x={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},b={...x,pointerX:_,pointerY:D,aspectRatio:x.width/x.height},j=void 0,S=yt(g.extent)?g.extent:void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(j=z.get(g.parentId)),j&&g.extent==="parent"&&(S=[[0,0],[j.measured.width,j.measured.height]]),E=[],R=void 0;for(const[L,H]of z)if(H.parentId===t&&(E.push({id:L,position:{...H.position},extent:H.extent}),H.extent==="parent"||H.expandParent)){const F=Xg(H,g,H.origin??I);R?R=[[Math.min(F[0][0],R[0][0]),Math.min(F[0][1],R[0][1])],[Math.max(F[1][0],R[1][0]),Math.max(F[1][1],R[1][1])]]:R=F}p?.(O,{...x})}).on("drag",O=>{const{transform:z,snapGrid:M,snapToGrid:N,nodeOrigin:C}=n(),I=Gt(O.sourceEvent,{transform:z,snapGrid:M,snapToGrid:N,containerBounds:v}),$=[];if(!g)return;const{x:_,y:D,width:L,height:H}=x,F={},P=g.origin??C,{width:W,height:Y,x:J,y:U}=Wg(b,r.controlDirection,I,r.boundaries,r.keepAspectRatio,P,S,R),T=W!==L,Z=Y!==H,ee=J!==_&&T,te=U!==D&&Z;if(!ee&&!te&&!T&&!Z)return;if((ee||te||P[0]===1||P[1]===1)&&(F.x=ee?J:x.x,F.y=te?U:x.y,x.x=F.x,x.y=F.y,E.length>0)){const ie=J-_,ce=U-D;for(const ue of E)ue.position={x:ue.position.x-ie+P[0]*(W-L),y:ue.position.y-ce+P[1]*(Y-H)},$.push(ue)}if((T||Z)&&(F.width=T&&(!r.resizeDirection||r.resizeDirection==="horizontal")?W:x.width,F.height=Z&&(!r.resizeDirection||r.resizeDirection==="vertical")?Y:x.height,x.width=F.width,x.height=F.height),j&&g.expandParent){const ie=P[0]*(F.width??0);F.x&&F.x<ie&&(x.x=ie,b.x=b.x-(F.x-ie));const ce=P[1]*(F.height??0);F.y&&F.y<ce&&(x.y=ce,b.y=b.y-(F.y-ce))}const K=Bg({width:x.width,prevWidth:L,height:x.height,prevHeight:H,affectsX:r.controlDirection.affectsX,affectsY:r.controlDirection.affectsY}),Q={...x,direction:K};y?.(O,Q)!==!1&&(A=!0,m?.(O,Q),s(F,$))}).on("end",O=>{A&&(w?.(O,{...x}),o?.({...x}),A=!1)});i.call(V)}function l(){i.on(".drag",null)}return{update:c,destroy:l}}var Ps={exports:{}},Os={},Ts={exports:{}},zs={};var Kr;function Zg(){if(Kr)return zs;Kr=1;var e=sa();function t(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,o=e.useEffect,i=e.useLayoutEffect,r=e.useDebugValue;function c(h,f){var p=f(),m=s({inst:{value:p,getSnapshot:f}}),w=m[0].inst,y=m[1];return i(function(){w.value=p,w.getSnapshot=f,l(w)&&y({inst:w})},[h,p,f]),o(function(){return l(w)&&y({inst:w}),h(function(){l(w)&&y({inst:w})})},[h]),r(p),p}function l(h){var f=h.getSnapshot;h=h.value;try{var p=f();return!n(h,p)}catch{return!0}}function d(h,f){return f()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:c;return zs.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,zs}var Qr;function Gg(){return Qr||(Qr=1,Ts.exports=Zg()),Ts.exports}var Jr;function Ug(){if(Jr)return Os;Jr=1;var e=sa(),t=Gg();function n(d,u){return d===u&&(d!==0||1/d===1/u)||d!==d&&u!==u}var s=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,i=e.useRef,r=e.useEffect,c=e.useMemo,l=e.useDebugValue;return Os.useSyncExternalStoreWithSelector=function(d,u,h,f,p){var m=i(null);if(m.current===null){var w={hasValue:!1,value:null};m.current=w}else w=m.current;m=c(function(){function x(j){if(!b){if(b=!0,g=j,j=f(j),p!==void 0&&w.hasValue){var S=w.value;if(p(S,j))return v=S}return v=j}if(S=v,s(g,j))return S;var R=f(j);return p!==void 0&&p(S,R)?(g=j,S):(g=j,v=R)}var b=!1,g,v,E=h===void 0?null:h;return[function(){return x(u())},E===null?void 0:function(){return x(E())}]},[u,h,f,p]);var y=o(d,m[0],m[1]);return r(function(){w.hasValue=!0,w.value=y},[y]),l(y),y},Os}var ei;function Kg(){return ei||(ei=1,Ps.exports=Ug()),Ps.exports}var Qg=Kg();const Jg=iu(Qg),ex={},ti=e=>{let t;const n=new Set,s=(u,h)=>{const f=typeof u=="function"?u(t):u;if(!Object.is(f,t)){const p=t;t=h??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(m=>m(t,p))}},o=()=>t,l={setState:s,getState:o,getInitialState:()=>d,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(ex?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(s,o,l);return l},tx=e=>e?ti(e):ti,{useDebugValue:nx}=au,{useSyncExternalStoreWithSelector:sx}=Jg,ox=e=>e;function Sc(e,t=ox,n){const s=sx(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return nx(s),s}const ni=(e,t)=>{const n=tx(e),s=(o,i=t)=>Sc(n,o,i);return Object.assign(s,n),s},rx=(e,t)=>e?ni(e,t):ni;function de(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[s,o]of e)if(!Object.is(o,t.get(s)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const s of e)if(!t.has(s))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const s of n)if(!Object.prototype.hasOwnProperty.call(t,s)||!Object.is(e[s],t[s]))return!1;return!0}const bs=k.createContext(null),ix=bs.Provider,Ic=Te.error001("react");function oe(e,t){const n=k.useContext(bs);if(n===null)throw new Error(Ic);return Sc(n,e,t)}function le(){const e=k.useContext(bs);if(e===null)throw new Error(Ic);return k.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const si={display:"none"},ax={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},_c="react-flow__node-desc",Mc="react-flow__edge-desc",cx="react-flow__aria-live",lx=e=>e.ariaLiveMessage,dx=e=>e.ariaLabelConfig;function ux({rfId:e}){const t=oe(lx);return a.jsx("div",{id:`${cx}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:ax,children:t})}function fx({rfId:e,disableKeyboardA11y:t}){const n=oe(dx);return a.jsxs(a.Fragment,{children:[a.jsx("div",{id:`${_c}-${e}`,style:si,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),a.jsx("div",{id:`${Mc}-${e}`,style:si,children:n["edge.a11yDescription.default"]}),!t&&a.jsx(ux,{rfId:e})]})}const rt=k.forwardRef(({position:e="top-left",children:t,className:n,style:s,...o},i)=>{const r=`${e}`.split("-");return a.jsx("div",{className:he(["react-flow__panel",n,...r]),style:s,ref:i,...o,children:t})});rt.displayName="Panel";const oi="https://reactflow.dev?utm_source=attribution";function hx({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:a.jsx(rt,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${oi}`,children:a.jsx("a",{href:oi,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const px=e=>{const t=[],n=[];for(const[,s]of e.nodeLookup)s.selected&&t.push(s.internals.userNode);for(const[,s]of e.edgeLookup)s.selected&&n.push(s);return{selectedNodes:t,selectedEdges:n}},$n=e=>e.id;function mx(e,t){return de(e.selectedNodes.map($n),t.selectedNodes.map($n))&&de(e.selectedEdges.map($n),t.selectedEdges.map($n))}function gx({onSelectionChange:e}){const t=le(),{selectedNodes:n,selectedEdges:s}=oe(px,mx);return k.useEffect(()=>{const o={nodes:n,edges:s};e?.(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,s,e]),null}const xx=e=>!!e.onSelectionChangeHandlers;function yx({onSelectionChange:e}){const t=oe(xx);return e||t?a.jsx(gx,{onSelectionChange:e}):null}const $c=[0,0],wx={x:0,y:0,zoom:1},vx=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],ri=[...vx,"rfId"],bx=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),ii={translateExtent:tn,nodeOrigin:$c,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Nx(e){const{setNodes:t,setEdges:n,setMinZoom:s,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:r,reset:c,setDefaultNodesAndEdges:l}=oe(bx,de),d=le();k.useEffect(()=>(l(e.defaultNodes,e.defaultEdges),()=>{u.current=ii,c()}),[]);const u=k.useRef(ii);return k.useEffect(()=>{for(const h of ri){const f=e[h],p=u.current[h];f!==p&&(typeof e[h]>"u"||(h==="nodes"?t(f):h==="edges"?n(f):h==="minZoom"?s(f):h==="maxZoom"?o(f):h==="translateExtent"?i(f):h==="nodeExtent"?r(f):h==="ariaLabelConfig"?d.setState({ariaLabelConfig:ig(f)}):h==="fitView"?d.setState({fitViewQueued:f}):h==="fitViewOptions"?d.setState({fitViewOptions:f}):d.setState({[h]:f})))}u.current=e},ri.map(h=>e[h])),null}function ai(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function kx(e){const[t,n]=k.useState(e==="system"?null:e);return k.useEffect(()=>{if(e!=="system"){n(e);return}const s=ai(),o=()=>n(s?.matches?"dark":"light");return o(),s?.addEventListener("change",o),()=>{s?.removeEventListener("change",o)}},[e]),t!==null?t:ai()?.matches?"dark":"light"}const ci=typeof document<"u"?document:null;function rn(e=null,t={target:ci,actInsideInputWithModifier:!0}){const[n,s]=k.useState(!1),o=k.useRef(!1),i=k.useRef(new Set([])),[r,c]=k.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(h=>typeof h=="string").map(h=>h.replace(/\+/g,`
3
- `).replace(`
4
-
5
- `,`
6
- +`).split(`
7
- `)),u=d.reduce((h,f)=>h.concat(...f),[]);return[d,u]}return[[],[]]},[e]);return k.useEffect(()=>{const l=t?.target??ci,d=t?.actInsideInputWithModifier??!0;if(e!==null){const u=p=>{if(o.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!o.current||o.current&&!d)&&uc(p))return!1;const w=di(p.code,c);if(i.current.add(p[w]),li(r,i.current,!1)){const y=p.composedPath?.()?.[0]||p.target,x=y?.nodeName==="BUTTON"||y?.nodeName==="A";t.preventDefault!==!1&&(o.current||!x)&&p.preventDefault(),s(!0)}},h=p=>{const m=di(p.code,c);li(r,i.current,!0)?(s(!1),i.current.clear()):i.current.delete(p[m]),p.key==="Meta"&&i.current.clear(),o.current=!1},f=()=>{i.current.clear(),s(!1)};return l?.addEventListener("keydown",u),l?.addEventListener("keyup",h),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{l?.removeEventListener("keydown",u),l?.removeEventListener("keyup",h),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,s]),n}function li(e,t,n){return e.filter(s=>n||s.length===t.size).some(s=>s.every(o=>t.has(o)))}function di(e,t){return t.includes(e)?"code":"key"}const jx=()=>{const e=le();return k.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:s}=e.getState();return s?s.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[s,o,i],panZoom:r}=e.getState();return r?(await r.setViewport({x:t.x??s,y:t.y??o,zoom:t.zoom??i},n),!0):!1},getViewport:()=>{const[t,n,s]=e.getState().transform;return{x:t,y:n,zoom:s}},setCenter:async(t,n,s)=>e.getState().setCenter(t,n,s),fitBounds:async(t,n)=>{const{width:s,height:o,minZoom:i,maxZoom:r,panZoom:c}=e.getState(),l=Oo(t,s,o,i,r,n?.padding??.1);return c?(await c.setViewport(l,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:s,snapGrid:o,snapToGrid:i,domNode:r}=e.getState();if(!r)return t;const{x:c,y:l}=r.getBoundingClientRect(),d={x:t.x-c,y:t.y-l},u=n.snapGrid??o,h=n.snapToGrid??i;return vn(d,s,h,u)},flowToScreenPosition:t=>{const{transform:n,domNode:s}=e.getState();if(!s)return t;const{x:o,y:i}=s.getBoundingClientRect(),r=Rt(t,n);return{x:r.x+o,y:r.y+i}}}),[])};function Rc(e,t){const n=[],s=new Map,o=[];for(const i of e)if(i.type==="add"){o.push(i);continue}else if(i.type==="remove"||i.type==="replace")s.set(i.id,[i]);else{const r=s.get(i.id);r?r.push(i):s.set(i.id,[i])}for(const i of t){const r=s.get(i.id);if(!r){n.push(i);continue}if(r[0].type==="remove")continue;if(r[0].type==="replace"){n.push({...r[0].item});continue}const c={...i};for(const l of r)Ex(l,c);n.push(c)}return o.length&&o.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function Ex(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Ns(e,t){return Rc(e,t)}function ks(e,t){return Rc(e,t)}function at(e,t){return{id:e,type:"select",selected:t}}function jt(e,t=new Set,n=!1){const s=[];for(const[o,i]of e){const r=t.has(o);!(i.selected===void 0&&!r)&&i.selected!==r&&(n&&(i.selected=r),s.push(at(i.id,r)))}return s}function ui({items:e=[],lookup:t}){const n=[],s=new Map(e.map(o=>[o.id,o]));for(const[o,i]of e.entries()){const r=t.get(i.id),c=r?.internals?.userNode??r;c!==void 0&&c!==i&&n.push({id:i.id,item:i,type:"replace"}),c===void 0&&n.push({item:i,type:"add",index:o})}for(const[o]of t)s.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function fi(e){return{id:e.id,type:"remove"}}const Cx=ac();function Sx(e,t,n={}){return fg(e,t,{...n,onError:n.onError??Cx})}const hi=e=>Km(e),Ix=e=>nc(e);function Ac(e){return k.forwardRef(e)}const Dc=typeof window<"u"?k.useLayoutEffect:k.useEffect;function pi(e){const[t,n]=k.useState(BigInt(0)),[s]=k.useState(()=>_x(()=>n(o=>o+BigInt(1))));return Dc(()=>{const o=s.get();o.length&&(e(o),s.reset())},[t]),s}function _x(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Pc=k.createContext(null);function Mx({children:e}){const t=le(),n=k.useCallback(c=>{const{nodes:l=[],setNodes:d,hasDefaultNodes:u,onNodesChange:h,nodeLookup:f,fitViewQueued:p,onNodesChangeMiddlewareMap:m}=t.getState();let w=l;for(const x of c)w=typeof x=="function"?x(w):x;let y=ui({items:w,lookup:f});for(const x of m.values())y=x(y);u&&d(w),y.length>0?h?.(y):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:x,nodes:b,setNodes:g}=t.getState();x&&g(b)})},[]),s=pi(n),o=k.useCallback(c=>{const{edges:l=[],setEdges:d,hasDefaultEdges:u,onEdgesChange:h,edgeLookup:f}=t.getState();let p=l;for(const m of c)p=typeof m=="function"?m(p):m;u?d(p):h&&h(ui({items:p,lookup:f}))},[]),i=pi(o),r=k.useMemo(()=>({nodeQueue:s,edgeQueue:i}),[]);return a.jsx(Pc.Provider,{value:r,children:e})}function $x(){const e=k.useContext(Pc);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Rx=e=>!!e.panZoom;function Ht(){const e=jx(),t=le(),n=$x(),s=oe(Rx),o=k.useMemo(()=>{const i=h=>t.getState().nodeLookup.get(h),r=h=>{n.nodeQueue.push(h)},c=h=>{n.edgeQueue.push(h)},l=h=>{const{nodeLookup:f,nodeOrigin:p}=t.getState(),m=hi(h)?h:f.get(h.id),w=m.parentId?lc(m.position,m.measured,m.parentId,f,p):m.position,y={...m,position:w,width:m.measured?.width??m.width,height:m.measured?.height??m.height};return sn(y)},d=(h,f,p={replace:!1})=>{r(m=>m.map(w=>{if(w.id===h){const y=typeof f=="function"?f(w):f;return p.replace&&hi(y)?y:{...w,...y}}return w}))},u=(h,f,p={replace:!1})=>{c(m=>m.map(w=>{if(w.id===h){const y=typeof f=="function"?f(w):f;return p.replace&&Ix(y)?y:{...w,...y}}return w}))};return{getNodes:()=>t.getState().nodes.map(h=>({...h})),getNode:h=>i(h)?.internals.userNode,getInternalNode:i,getEdges:()=>{const{edges:h=[]}=t.getState();return h.map(f=>({...f}))},getEdge:h=>t.getState().edgeLookup.get(h),setNodes:r,setEdges:c,addNodes:h=>{const f=Array.isArray(h)?h:[h];n.nodeQueue.push(p=>[...p,...f])},addEdges:h=>{const f=Array.isArray(h)?h:[h];n.edgeQueue.push(p=>[...p,...f])},toObject:()=>{const{nodes:h=[],edges:f=[],transform:p}=t.getState(),[m,w,y]=p;return{nodes:h.map(x=>({...x})),edges:f.map(x=>({...x})),viewport:{x:m,y:w,zoom:y}}},deleteElements:async({nodes:h=[],edges:f=[]})=>{const{nodes:p,edges:m,onNodesDelete:w,onEdgesDelete:y,triggerNodeChanges:x,triggerEdgeChanges:b,onDelete:g,onBeforeDelete:v}=t.getState(),{nodes:E,edges:j}=await ng({nodesToRemove:h,edgesToRemove:f,nodes:p,edges:m,onBeforeDelete:v}),S=j.length>0,R=E.length>0;if(S){const A=j.map(fi);y?.(j),b(A)}if(R){const A=E.map(fi);w?.(E),x(A)}return(R||S)&&g?.({nodes:E,edges:j}),{deletedNodes:E,deletedEdges:j}},getIntersectingNodes:(h,f=!0,p)=>{const m=zr(h),w=m?h:l(h),y=p!==void 0;return w?(p||t.getState().nodes).filter(x=>{const b=t.getState().nodeLookup.get(x.id);if(b&&!m&&(x.id===h.id||!b.internals.positionAbsolute))return!1;const g=sn(y?x:b),v=Jn(g,w);return f&&v>0||v>=g.width*g.height||v>=w.width*w.height}):[]},isNodeIntersecting:(h,f,p=!0)=>{const w=zr(h)?h:l(h);if(!w)return!1;const y=Jn(w,f);return p&&y>0||y>=f.width*f.height||y>=w.width*w.height},updateNode:d,updateNodeData:(h,f,p={replace:!1})=>{d(h,m=>{const w=typeof f=="function"?f(m):f;return p.replace?{...m,data:w}:{...m,data:{...m.data,...w}}},p)},updateEdge:u,updateEdgeData:(h,f,p={replace:!1})=>{u(h,m=>{const w=typeof f=="function"?f(m):f;return p.replace?{...m,data:w}:{...m,data:{...m.data,...w}}},p)},getNodesBounds:h=>{const{nodeLookup:f,nodeOrigin:p}=t.getState();return Qm(h,{nodeLookup:f,nodeOrigin:p})},getHandleConnections:({type:h,id:f,nodeId:p})=>Array.from(t.getState().connectionLookup.get(`${p}-${h}${f?`-${f}`:""}`)?.values()??[]),getNodeConnections:({type:h,handleId:f,nodeId:p})=>Array.from(t.getState().connectionLookup.get(`${p}${h?f?`-${h}-${f}`:`-${h}`:""}`)?.values()??[]),fitView:async h=>{const f=t.getState().fitViewResolver??rg();return t.setState({fitViewQueued:!0,fitViewOptions:h,fitViewResolver:f}),n.nodeQueue.push(p=>[...p]),f.promise}}},[]);return k.useMemo(()=>({...o,...e,viewportInitialized:s}),[s])}const mi=e=>e.selected,Ax=typeof window<"u"?window:void 0;function Dx({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=le(),{deleteElements:s}=Ht(),o=rn(e,{actInsideInputWithModifier:!1}),i=rn(t,{target:Ax});k.useEffect(()=>{if(o){const{edges:r,nodes:c}=n.getState();s({nodes:c.filter(mi),edges:r.filter(mi)}),n.setState({nodesSelectionActive:!1})}},[o]),k.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function Px(e){const t=le();k.useEffect(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const s=To(e.current);(s.height===0||s.width===0)&&t.getState().onError?.("004",Te.error004()),t.setState({width:s.width||500,height:s.height||500})};if(e.current){n(),window.addEventListener("resize",n);const s=new ResizeObserver(()=>n());return s.observe(e.current),()=>{window.removeEventListener("resize",n),s&&e.current&&s.unobserve(e.current)}}},[])}const js={position:"absolute",width:"100%",height:"100%",top:0,left:0},Ox=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Tx({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:s=!1,panActivationKeyPressed:o,panOnScrollSpeed:i=.5,panOnScrollMode:r=ft.Free,zoomOnDoubleClick:c=!0,panOnDrag:l=!0,defaultViewport:d,translateExtent:u,minZoom:h,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:m=!0,children:w,noWheelClassName:y,noPanClassName:x,onViewportChange:b,isControlledViewport:g,paneClickDistance:v,selectionOnDrag:E}){const j=le(),S=k.useRef(null),{userSelectionActive:R,lib:A,connectionInProgress:V}=oe(Ox,de),O=rn(p),z=k.useRef();Px(S);const M=k.useCallback(N=>{b?.({x:N[0],y:N[1],zoom:N[2]}),g||j.setState({transform:N})},[b,g]);return k.useEffect(()=>{if(S.current){z.current=Fg({domNode:S.current,minZoom:h,maxZoom:f,translateExtent:u,viewport:d,onDraggingChange:$=>j.setState(_=>_.paneDragging===$?_:{paneDragging:$}),onPanZoomStart:($,_)=>{const{onViewportChangeStart:D,onMoveStart:L}=j.getState();L?.($,_),D?.(_)},onPanZoom:($,_)=>{const{onViewportChange:D,onMove:L}=j.getState();L?.($,_),D?.(_)},onPanZoomEnd:($,_)=>{const{onViewportChangeEnd:D,onMoveEnd:L}=j.getState();L?.($,_),D?.(_)}});const{x:N,y:C,zoom:I}=z.current.getViewport();return j.setState({panZoom:z.current,transform:[N,C,I],domNode:S.current.closest(".react-flow")}),()=>{z.current?.destroy()}}},[]),k.useEffect(()=>{z.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:s,panActivationKeyPressed:o,panOnScrollSpeed:i,panOnScrollMode:r,zoomOnDoubleClick:c,panOnDrag:l,zoomActivationKeyPressed:O,preventScrolling:m,noPanClassName:x,userSelectionActive:R,noWheelClassName:y,lib:A,onTransformChange:M,connectionInProgress:V,selectionOnDrag:E,paneClickDistance:v})},[e,t,n,s,o,i,r,c,l,O,m,x,R,y,A,M,V,E,v]),a.jsx("div",{className:"react-flow__renderer",ref:S,style:js,children:w})}const zx=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Lx(){const{userSelectionActive:e,userSelectionRect:t}=oe(zx,de);return e&&t?a.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Ls=(e,t)=>n=>{n.target===t.current&&e?.(n)},Hx=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Vx({isSelecting:e,selectionKeyPressed:t,selectionMode:n=nn.Full,panOnDrag:s,autoPanOnSelection:o,paneClickDistance:i,selectionOnDrag:r,onSelectionStart:c,onSelectionEnd:l,onPaneClick:d,onPaneContextMenu:u,onPaneScroll:h,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:w}){const y=k.useRef(0),x=le(),{userSelectionActive:b,elementsSelectable:g,dragging:v,panBy:E,autoPanSpeed:j}=oe(Hx,de),S=g&&(e||b),R=k.useRef(null),A=k.useRef(),V=k.useRef(new Set),O=k.useRef(new Set),z=k.useRef(!1),M=k.useRef(!1),N=k.useRef({x:0,y:0}),C=k.useRef(!1),I=T=>{if(M.current||z.current||x.getState().connection.inProgress){M.current=!1,z.current=!1;return}d?.(T),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},$=T=>{if(Array.isArray(s)&&s?.includes(2)){T.preventDefault();return}u?.(T)},_=h?T=>h(T):void 0,D=T=>{M.current&&(T.stopPropagation(),M.current=!1)},L=T=>{if(T.pointerType==="touch"&&s!==!1&&!t)return;const{domNode:Z,transform:ee}=x.getState();if(A.current=Z?.getBoundingClientRect(),!A.current)return;const te=T.target===R.current;if(!te&&!!T.target.closest(".nokey")||!e||!(r&&te||t)||T.button!==0||!T.isPrimary)return;T.target?.setPointerCapture?.(T.pointerId),M.current=!1;const{x:re,y:ie}=Ae(T.nativeEvent,A.current),ce=vn({x:re,y:ie},ee);x.setState({userSelectionRect:{width:0,height:0,startX:ce.x,startY:ce.y,x:re,y:ie}}),te||(T.stopPropagation(),T.preventDefault())};function H(T,Z){const{userSelectionRect:ee}=x.getState();if(!ee)return;const{transform:te,nodeLookup:K,edgeLookup:Q,connectionLookup:re,triggerNodeChanges:ie,triggerEdgeChanges:ce,defaultEdgeOptions:ue}=x.getState(),ge={x:ee.startX,y:ee.startY},{x:be,y:Ee}=Rt(ge,te),Ie={startX:ge.x,startY:ge.y,x:T<be?T:be,y:Z<Ee?Z:Ee,width:Math.abs(T-be),height:Math.abs(Z-Ee)},qe=V.current,Ze=O.current;V.current=new Set(Do(K,Ie,te,n===nn.Partial,!0).map(B=>B.id)),O.current=new Set;const Ge=ue?.selectable??!0;for(const B of V.current){const G=re.get(B);if(G)for(const{edgeId:ne}of G.values()){const fe=Q.get(ne);fe&&(fe.selectable??Ge)&&O.current.add(ne)}}if(!Lr(qe,V.current)){const B=jt(K,V.current,!0);ie(B)}if(!Lr(Ze,O.current)){const B=jt(Q,O.current);ce(B)}x.setState({userSelectionRect:Ie,userSelectionActive:!0,nodesSelectionActive:!1})}function F(){if(!o||!A.current)return;const[T,Z]=Po(N.current,A.current,j);E({x:T,y:Z}).then(ee=>{if(!M.current||!ee){y.current=requestAnimationFrame(F);return}const{x:te,y:K}=N.current;H(te,K),y.current=requestAnimationFrame(F)})}const P=()=>{cancelAnimationFrame(y.current),y.current=0,C.current=!1};k.useEffect(()=>()=>P(),[]);const W=T=>{const{userSelectionRect:Z,transform:ee,resetSelectedElements:te}=x.getState();if(!A.current||!Z)return;const{x:K,y:Q}=Ae(T.nativeEvent,A.current);N.current={x:K,y:Q};const re=Rt({x:Z.startX,y:Z.startY},ee);if(!M.current){const ie=t?0:i;if(Math.hypot(K-re.x,Q-re.y)<=ie)return;te(),c?.(T)}M.current=!0,C.current||(F(),C.current=!0),H(K,Q)},Y=T=>{if(!S){T.target===R.current&&x.getState().connection.inProgress&&(z.current=!0);return}T.button===0&&(T.target?.releasePointerCapture?.(T.pointerId),!b&&T.target===R.current&&x.getState().userSelectionRect&&I?.(T),x.setState({userSelectionActive:!1,userSelectionRect:null}),M.current&&(l?.(T),x.setState({nodesSelectionActive:V.current.size>0})),P())},J=T=>{T.target?.releasePointerCapture?.(T.pointerId),P()},U=s===!0||Array.isArray(s)&&s.includes(0);return a.jsxs("div",{className:he(["react-flow__pane",{draggable:U,dragging:v,selection:e}]),onClick:S?void 0:Ls(I,R),onContextMenu:Ls($,R),onWheel:Ls(_,R),onPointerEnter:S?void 0:f,onPointerMove:S?W:p,onPointerUp:Y,onPointerCancel:S?J:void 0,onPointerDownCapture:S?L:void 0,onClickCapture:S?D:void 0,onPointerLeave:m,ref:R,style:js,children:[w,a.jsx(Lx,{})]})}function no({id:e,store:t,unselect:n=!1,nodeRef:s}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:r,nodeLookup:c,onError:l}=t.getState(),d=c.get(e);if(!d){l?.("012",Te.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&r)&&(i({nodes:[d],edges:[]}),requestAnimationFrame(()=>s?.current?.blur())):o([e])}function Oc({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:o,isSelectable:i,nodeClickDistance:r}){const c=le(),[l,d]=k.useState(!1),u=k.useRef();return k.useEffect(()=>{if(!t)return u.current=Ig({getStoreItems:()=>c.getState(),onNodeMouseDown:h=>{no({id:h,store:c,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,c,e]),k.useEffect(()=>{t||!e.current||!u.current||u.current.update({noDragClassName:n,handleSelector:s,domNode:e.current,isSelectable:i,nodeId:o,nodeClickDistance:r})},[n,s,t,i,e,o,r]),l}const Fx=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Tc(){const e=le();return k.useCallback(n=>{const{nodeExtent:s,snapToGrid:o,snapGrid:i,nodesDraggable:r,onError:c,updateNodePositions:l,nodeLookup:d,nodeOrigin:u}=e.getState(),h=new Map,f=Fx(r),p=o?i[0]:5,m=o?i[1]:5,w=n.direction.x*p*n.factor,y=n.direction.y*m*n.factor;for(const[,x]of d){if(!f(x))continue;let b={x:x.internals.positionAbsolute.x+w,y:x.internals.positionAbsolute.y+y};o&&(b=wn(b,i));const{position:g,positionAbsolute:v}=sc({nodeId:x.id,nextPosition:b,nodeLookup:d,nodeExtent:s,nodeOrigin:u,onError:c});x.position=g,x.internals.positionAbsolute=v,h.set(x.id,x)}l(h)},[])}const Wo=k.createContext(null),Bx=Wo.Provider;Wo.Consumer;const zc=()=>k.useContext(Wo),Wx=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Lc=k.createContext(null);function Yx({children:e}){const t=oe(Wx,de);return a.jsx(Lc.Provider,{value:t,children:e})}function Xx(){const e=k.useContext(Lc);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const qx={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Zx=(e,t,n)=>s=>{const{connectionClickStartHandle:o,connectionMode:i,connection:r}=s,{fromHandle:c,toHandle:l,isValid:d}=r;if(!c&&!o)return qx;const u=l?.nodeId===e&&l?.id===t&&l?.type===n;return{connectingFrom:c?.nodeId===e&&c?.id===t&&c?.type===n,connectingTo:u,clickConnecting:o?.nodeId===e&&o?.id===t&&o?.type===n,isPossibleEndHandle:i===Mt.Strict?c?.type!==n:e!==c?.nodeId||t!==c?.id,connectionInProcess:!!c,clickConnectionInProcess:!!o,valid:u&&d}};function Gx({type:e="source",position:t=q.Top,isValidConnection:n,isConnectable:s=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:r,onConnect:c,children:l,className:d,onMouseDown:u,onTouchStart:h,...f},p){const m=r||null,w=e==="target",y=le(),x=zc(),{connectOnClick:b,noPanClassName:g,rfId:v}=Xx(),{connectingFrom:E,connectingTo:j,clickConnecting:S,isPossibleEndHandle:R,connectionInProcess:A,clickConnectionInProcess:V,valid:O}=oe(Zx(x,m,e),de);x||y.getState().onError?.("010",Te.error010());const z=C=>{const{defaultEdgeOptions:I,onConnect:$,hasDefaultEdges:_}=y.getState(),D={...I,...C};if(_){const{edges:L,setEdges:H,onError:F}=y.getState();H(Sx(D,L,{onError:F}))}$?.(D),c?.(D)},M=C=>{if(!x)return;const I=fc(C.nativeEvent);if(o&&(I&&C.button===0||!I)){const $=y.getState();to.onPointerDown(C.nativeEvent,{handleDomNode:C.currentTarget,autoPanOnConnect:$.autoPanOnConnect,connectionMode:$.connectionMode,connectionRadius:$.connectionRadius,domNode:$.domNode,nodeLookup:$.nodeLookup,lib:$.lib,isTarget:w,handleId:m,nodeId:x,flowId:$.rfId,panBy:$.panBy,cancelConnection:$.cancelConnection,onConnectStart:$.onConnectStart,onConnectEnd:(..._)=>y.getState().onConnectEnd?.(..._),updateConnection:$.updateConnection,onConnect:z,isValidConnection:n||((..._)=>y.getState().isValidConnection?.(..._)??!0),getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,autoPanSpeed:$.autoPanSpeed,dragThreshold:$.connectionDragThreshold})}I?u?.(C):h?.(C)},N=C=>{const{onClickConnectStart:I,onClickConnectEnd:$,connectionClickStartHandle:_,connectionMode:D,isValidConnection:L,lib:H,rfId:F,nodeLookup:P,connection:W}=y.getState();if(!x||!_&&!o)return;if(!_){I?.(C.nativeEvent,{nodeId:x,handleId:m,handleType:e}),y.setState({connectionClickStartHandle:{nodeId:x,type:e,id:m}});return}const Y=dc(C.target),J=n||L,{connection:U,isValid:T}=to.isValid(C.nativeEvent,{handle:{nodeId:x,id:m,type:e},connectionMode:D,fromNodeId:_.nodeId,fromHandleId:_.id||null,fromType:_.type,isValidConnection:J,flowId:F,doc:Y,lib:H,nodeLookup:P});T&&U&&z(U);const Z=structuredClone(W);delete Z.inProgress,Z.toPosition=Z.toHandle?Z.toHandle.position:null,$?.(C,Z),y.setState({connectionClickStartHandle:null})};return a.jsx("div",{"data-handleid":m,"data-nodeid":x,"data-handlepos":t,"data-id":`${v}-${x}-${m}-${e}`,className:he(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",g,d,{source:!w,target:w,connectable:s,connectablestart:o,connectableend:i,clickconnecting:S,connectingfrom:E,connectingto:j,valid:O,connectionindicator:s&&(!A||R)&&(A||V?i:o)}]),onMouseDown:M,onTouchStart:M,onClick:b?N:void 0,ref:p,...f,children:l})}const je=k.memo(Ac(Gx));function Ux({data:e,isConnectable:t,sourcePosition:n=q.Bottom}){return a.jsxs(a.Fragment,{children:[e?.label,a.jsx(je,{type:"source",position:n,isConnectable:t})]})}function Kx({data:e,isConnectable:t,targetPosition:n=q.Top,sourcePosition:s=q.Bottom}){return a.jsxs(a.Fragment,{children:[a.jsx(je,{type:"target",position:n,isConnectable:t}),e?.label,a.jsx(je,{type:"source",position:s,isConnectable:t})]})}function Qx(){return null}function Jx({data:e,isConnectable:t,targetPosition:n=q.Top}){return a.jsxs(a.Fragment,{children:[a.jsx(je,{type:"target",position:n,isConnectable:t}),e?.label]})}const ts={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},gi={input:Ux,default:Kx,output:Jx,group:Qx};function e0(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const t0=e=>{const{width:t,height:n,x:s,y:o}=yn(e.nodeLookup,{filter:i=>!!i.selected});return{width:Re(t)?t:null,height:Re(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${s}px,${o}px)`}};function n0({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=le(),{width:o,height:i,transformString:r,userSelectionActive:c}=oe(t0,de),l=Tc(),d=k.useRef(null);k.useEffect(()=>{n||d.current?.focus({preventScroll:!0})},[n]);const u=!c&&o!==null&&i!==null;if(Oc({nodeRef:d,disabled:!u}),!u)return null;const h=e?p=>{const m=s.getState().nodes.filter(w=>w.selected);e(p,m)}:void 0,f=p=>{Object.prototype.hasOwnProperty.call(ts,p.key)&&(p.preventDefault(),l({direction:ts[p.key],factor:p.shiftKey?4:1}))};return a.jsx("div",{className:he(["react-flow__nodesselection","react-flow__container",t]),style:{transform:r},children:a.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:h,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:o,height:i}})})}const xi=typeof window<"u"?window:void 0,s0=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Hc({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:r,paneClickDistance:c,deleteKeyCode:l,selectionKeyCode:d,selectionOnDrag:u,selectionMode:h,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:w,zoomActivationKeyCode:y,elementsSelectable:x,zoomOnScroll:b,zoomOnPinch:g,panOnScroll:v,panOnScrollSpeed:E,panOnScrollMode:j,zoomOnDoubleClick:S,panOnDrag:R,autoPanOnSelection:A,defaultViewport:V,translateExtent:O,minZoom:z,maxZoom:M,preventScrolling:N,onSelectionContextMenu:C,noWheelClassName:I,noPanClassName:$,disableKeyboardA11y:_,onViewportChange:D,isControlledViewport:L}){const{nodesSelectionActive:H,userSelectionActive:F}=oe(s0,de),P=rn(d,{target:xi}),W=rn(w,{target:xi}),Y=W||R,J=W||v,U=u&&Y!==!0,T=P||F||U;return Dx({deleteKeyCode:l,multiSelectionKeyCode:m}),a.jsx(Tx,{onPaneContextMenu:i,elementsSelectable:x,zoomOnScroll:b,zoomOnPinch:g,panOnScroll:J,panActivationKeyPressed:W,panOnScrollSpeed:E,panOnScrollMode:j,zoomOnDoubleClick:S,panOnDrag:!P&&Y,defaultViewport:V,translateExtent:O,minZoom:z,maxZoom:M,zoomActivationKeyCode:y,preventScrolling:N,noWheelClassName:I,noPanClassName:$,onViewportChange:D,isControlledViewport:L,paneClickDistance:c,selectionOnDrag:U,children:a.jsxs(Vx,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:r,panOnDrag:Y,autoPanOnSelection:A,isSelecting:!!T,selectionMode:h,selectionKeyPressed:P,paneClickDistance:c,selectionOnDrag:U,children:[e,H&&a.jsx(n0,{onSelectionContextMenu:C,noPanClassName:$,disableKeyboardA11y:_})]})})}Hc.displayName="FlowRenderer";const o0=k.memo(Hc),r0=e=>t=>e?Do(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function i0(e){return oe(k.useCallback(r0(e),[e]),de)}const a0=e=>e.updateNodeInternals;function c0(){const e=oe(a0),[t]=k.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const s=new Map;n.forEach(o=>{const i=o.target.getAttribute("data-id");s.set(i,{id:i,nodeElement:o.target,force:!0})}),e(s)}));return k.useEffect(()=>()=>{t?.disconnect()},[t]),t}function l0({node:e,nodeType:t,hasDimensions:n,resizeObserver:s}){const o=le(),i=k.useRef(null),r=k.useRef(null),c=k.useRef(e.sourcePosition),l=k.useRef(e.targetPosition),d=k.useRef(t),u=n&&!!e.internals.handleBounds;return k.useEffect(()=>{i.current&&!e.hidden&&(!u||r.current!==i.current)&&(r.current&&s?.unobserve(r.current),s?.observe(i.current),r.current=i.current)},[u,e.hidden]),k.useEffect(()=>()=>{r.current&&(s?.unobserve(r.current),r.current=null)},[]),k.useEffect(()=>{if(i.current){const h=d.current!==t,f=c.current!==e.sourcePosition,p=l.current!==e.targetPosition;(h||f||p)&&(d.current=t,c.current=e.sourcePosition,l.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function d0({id:e,onClick:t,onMouseEnter:n,onMouseMove:s,onMouseLeave:o,onContextMenu:i,onDoubleClick:r,nodesDraggable:c,elementsSelectable:l,nodesConnectable:d,nodesFocusable:u,resizeObserver:h,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:w,nodeTypes:y,nodeClickDistance:x,onError:b}){const{node:g,internals:v,isParent:E}=oe(T=>{const Z=T.nodeLookup.get(e),ee=T.parentLookup.has(e);return{node:Z,internals:Z.internals,isParent:ee}},de);let j=g.type||"default",S=y?.[j]||gi[j];S===void 0&&(b?.("003",Te.error003(j)),j="default",S=y?.default||gi.default);const R=!!(g.draggable||c&&typeof g.draggable>"u"),A=!!(g.selectable||l&&typeof g.selectable>"u"),V=!!(g.connectable||d&&typeof g.connectable>"u"),O=!!(g.focusable||u&&typeof g.focusable>"u"),z=le(),M=cc(g),N=l0({node:g,nodeType:j,hasDimensions:M,resizeObserver:h}),C=Oc({nodeRef:N,disabled:g.hidden||!R,noDragClassName:f,handleSelector:g.dragHandle,nodeId:e,isSelectable:A,nodeClickDistance:x}),I=Tc();if(g.hidden)return null;const $=Le(g),_=e0(g),D=A||R||t||n||s||o,L=n?T=>n(T,{...v.userNode}):void 0,H=s?T=>s(T,{...v.userNode}):void 0,F=o?T=>o(T,{...v.userNode}):void 0,P=i?T=>i(T,{...v.userNode}):void 0,W=r?T=>r(T,{...v.userNode}):void 0,Y=T=>{const{selectNodesOnDrag:Z,nodeDragThreshold:ee}=z.getState();A&&(!Z||!R||ee>0)&&no({id:e,store:z,nodeRef:N}),t&&t(T,{...v.userNode})},J=T=>{if(!(uc(T.nativeEvent)||m)){if(Qa.includes(T.key)&&A){const Z=T.key==="Escape";no({id:e,store:z,unselect:Z,nodeRef:N})}else if(R&&g.selected&&Object.prototype.hasOwnProperty.call(ts,T.key)){T.preventDefault();const{ariaLabelConfig:Z}=z.getState();z.setState({ariaLiveMessage:Z["node.a11yDescription.ariaLiveMessage"]({direction:T.key.replace("Arrow","").toLowerCase(),x:~~v.positionAbsolute.x,y:~~v.positionAbsolute.y})}),I({direction:ts[T.key],factor:T.shiftKey?4:1})}}},U=()=>{if(m||!N.current?.matches(":focus-visible"))return;const{transform:T,width:Z,height:ee,autoPanOnNodeFocus:te,setCenter:K}=z.getState();if(!te)return;Do(new Map([[e,g]]),{x:0,y:0,width:Z,height:ee},T,!0).length>0||K(g.position.x+$.width/2,g.position.y+$.height/2,{zoom:T[2]})};return a.jsx("div",{className:he(["react-flow__node",`react-flow__node-${j}`,{[p]:R},g.className,{selected:g.selected,selectable:A,parent:E,draggable:R,dragging:C}]),ref:N,style:{zIndex:v.z,transform:`translate(${v.positionAbsolute.x}px,${v.positionAbsolute.y}px)`,pointerEvents:D?"all":"none",visibility:M?"visible":"hidden",...g.style,..._},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:L,onMouseMove:H,onMouseLeave:F,onContextMenu:P,onClick:Y,onDoubleClick:W,onKeyDown:O?J:void 0,tabIndex:O?0:void 0,onFocus:O?U:void 0,role:g.ariaRole??(O?"group":void 0),"aria-roledescription":"node","aria-describedby":m?void 0:`${_c}-${w}`,"aria-label":g.ariaLabel,...g.domAttributes,children:a.jsx(Bx,{value:e,children:a.jsx(S,{id:e,data:g.data,type:j,positionAbsoluteX:v.positionAbsolute.x,positionAbsoluteY:v.positionAbsolute.y,selected:g.selected??!1,selectable:A,draggable:R,deletable:g.deletable??!0,isConnectable:V,sourcePosition:g.sourcePosition,targetPosition:g.targetPosition,dragging:C,dragHandle:g.dragHandle,zIndex:v.z,parentId:g.parentId,...$})})})}var u0=k.memo(d0);const f0=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Vc(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:s,onError:o}=oe(f0,de),i=i0(e.onlyRenderVisibleElements),r=c0();return a.jsx("div",{className:"react-flow__nodes",style:js,children:i.map(c=>a.jsx(u0,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:r,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:o},c))})}Vc.displayName="NodeRenderer";const h0=k.memo(Vc);function p0(e){return oe(k.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const s=[];if(n.width&&n.height)for(const o of n.edges){const i=n.nodeLookup.get(o.source),r=n.nodeLookup.get(o.target);i&&r&&lg({sourceNode:i,targetNode:r,width:n.width,height:n.height,transform:n.transform})&&s.push(o.id)}return s},[e]),de)}const m0=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return a.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},g0=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return a.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},yi={[Je.Arrow]:m0,[Je.ArrowClosed]:g0};function x0(e){const t=le();return k.useMemo(()=>Object.prototype.hasOwnProperty.call(yi,e)?yi[e]:(t.getState().onError?.("009",Te.error009(e)),null),[e])}const y0=({id:e,type:t,color:n,width:s=12.5,height:o=12.5,markerUnits:i="strokeWidth",strokeWidth:r,orient:c="auto-start-reverse"})=>{const l=x0(t);return l?a.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:c,refX:"0",refY:"0",children:a.jsx(l,{color:n,strokeWidth:r})}):null},Fc=({defaultColor:e,rfId:t})=>{const n=oe(i=>i.edges),s=oe(i=>i.defaultEdgeOptions),o=k.useMemo(()=>xg(n,{id:t,defaultColor:e,defaultMarkerStart:s?.markerStart,defaultMarkerEnd:s?.markerEnd}),[n,s,t,e]);return o.length?a.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:a.jsx("defs",{children:o.map(i=>a.jsx(y0,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};Fc.displayName="MarkerDefinitions";var w0=k.memo(Fc);function Bc({x:e,y:t,label:n,labelStyle:s,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:r=[2,4],labelBgBorderRadius:c=2,children:l,className:d,...u}){const[h,f]=k.useState({x:1,y:0,width:0,height:0}),p=he(["react-flow__edge-textwrapper",d]),m=k.useRef(null);return k.useEffect(()=>{if(m.current){const w=m.current.getBBox();f({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),n?a.jsxs("g",{transform:`translate(${e-h.width/2} ${t-h.height/2})`,className:p,visibility:h.width?"visible":"hidden",...u,children:[o&&a.jsx("rect",{width:h.width+2*r[0],x:-r[0],y:-r[1],height:h.height+2*r[1],className:"react-flow__edge-textbg",style:i,rx:c,ry:c}),a.jsx("text",{className:"react-flow__edge-text",y:h.height/2,dy:"0.3em",ref:m,style:s,children:n}),l]}):null}Bc.displayName="EdgeText";const v0=k.memo(Bc);function Vt({path:e,labelX:t,labelY:n,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:r,labelBgPadding:c,labelBgBorderRadius:l,interactionWidth:d=20,...u}){return a.jsxs(a.Fragment,{children:[a.jsx("path",{...u,d:e,fill:"none",className:he(["react-flow__edge-path",u.className])}),d?a.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,s&&Re(t)&&Re(n)?a.jsx(v0,{x:t,y:n,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:r,labelBgPadding:c,labelBgBorderRadius:l}):null]})}function wi({pos:e,x1:t,y1:n,x2:s,y2:o}){return e===q.Left||e===q.Right?[.5*(t+s),n]:[t,.5*(n+o)]}function Wc({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:s,targetY:o,targetPosition:i=q.Top}){const[r,c]=wi({pos:n,x1:e,y1:t,x2:s,y2:o}),[l,d]=wi({pos:i,x1:s,y1:o,x2:e,y2:t}),[u,h,f,p]=hc({sourceX:e,sourceY:t,targetX:s,targetY:o,sourceControlX:r,sourceControlY:c,targetControlX:l,targetControlY:d});return[`M${e},${t} C${r},${c} ${l},${d} ${s},${o}`,u,h,f,p]}function Yc(e){return k.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,sourcePosition:r,targetPosition:c,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:y,interactionWidth:x})=>{const[b,g,v]=Wc({sourceX:n,sourceY:s,sourcePosition:r,targetX:o,targetY:i,targetPosition:c}),E=e.isInternal?void 0:t;return a.jsx(Vt,{id:E,path:b,labelX:g,labelY:v,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:y,interactionWidth:x})})}const b0=Yc({isInternal:!1}),Xc=Yc({isInternal:!0});b0.displayName="SimpleBezierEdge";Xc.displayName="SimpleBezierEdgeInternal";function qc(e){return k.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,label:r,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,style:f,sourcePosition:p=q.Bottom,targetPosition:m=q.Top,markerEnd:w,markerStart:y,pathOptions:x,interactionWidth:b})=>{const[g,v,E]=es({sourceX:n,sourceY:s,sourcePosition:p,targetX:o,targetY:i,targetPosition:m,borderRadius:x?.borderRadius,offset:x?.offset,stepPosition:x?.stepPosition}),j=e.isInternal?void 0:t;return a.jsx(Vt,{id:j,path:g,labelX:v,labelY:E,label:r,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:w,markerStart:y,interactionWidth:b})})}const Zc=qc({isInternal:!1}),Gc=qc({isInternal:!0});Zc.displayName="SmoothStepEdge";Gc.displayName="SmoothStepEdgeInternal";function Uc(e){return k.memo(({id:t,...n})=>{const s=e.isInternal?void 0:t;return a.jsx(Zc,{...n,id:s,pathOptions:k.useMemo(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const N0=Uc({isInternal:!1}),Kc=Uc({isInternal:!0});N0.displayName="StepEdge";Kc.displayName="StepEdgeInternal";function Qc(e){return k.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,label:r,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w})=>{const[y,x,b]=mc({sourceX:n,sourceY:s,targetX:o,targetY:i}),g=e.isInternal?void 0:t;return a.jsx(Vt,{id:g,path:y,labelX:x,labelY:b,label:r,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w})})}const k0=Qc({isInternal:!1}),Jc=Qc({isInternal:!0});k0.displayName="StraightEdge";Jc.displayName="StraightEdgeInternal";function el(e){return k.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,sourcePosition:r=q.Bottom,targetPosition:c=q.Top,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:y,pathOptions:x,interactionWidth:b})=>{const[g,v,E]=zo({sourceX:n,sourceY:s,sourcePosition:r,targetX:o,targetY:i,targetPosition:c,curvature:x?.curvature}),j=e.isInternal?void 0:t;return a.jsx(Vt,{id:j,path:g,labelX:v,labelY:E,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:y,interactionWidth:b})})}const j0=el({isInternal:!1}),tl=el({isInternal:!0});j0.displayName="BezierEdge";tl.displayName="BezierEdgeInternal";const vi={default:tl,straight:Jc,step:Kc,smoothstep:Gc,simplebezier:Xc},bi={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},E0=(e,t,n)=>n===q.Left?e-t:n===q.Right?e+t:e,C0=(e,t,n)=>n===q.Top?e-t:n===q.Bottom?e+t:e,Ni="react-flow__edgeupdater";function ki({position:e,centerX:t,centerY:n,radius:s=10,onMouseDown:o,onMouseEnter:i,onMouseOut:r,type:c}){return a.jsx("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:r,className:he([Ni,`${Ni}-${c}`]),cx:E0(t,s,e),cy:C0(n,s,e),r:s,stroke:"transparent",fill:"transparent"})}function S0({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:s,sourceY:o,targetX:i,targetY:r,sourcePosition:c,targetPosition:l,onReconnect:d,onReconnectStart:u,onReconnectEnd:h,setReconnecting:f,setUpdateHover:p}){const m=le(),w=(v,E)=>{if(v.button!==0)return;const{autoPanOnConnect:j,domNode:S,connectionMode:R,connectionRadius:A,lib:V,onConnectStart:O,cancelConnection:z,nodeLookup:M,rfId:N,panBy:C,updateConnection:I}=m.getState(),$=E.type==="target",_=(H,F)=>{f(!1),h?.(H,n,E.type,F)},D=H=>d?.(n,H),L=(H,F)=>{f(!0),u?.(v,n,E.type),O?.(H,F)};to.onPointerDown(v.nativeEvent,{autoPanOnConnect:j,connectionMode:R,connectionRadius:A,domNode:S,handleId:E.id,nodeId:E.nodeId,nodeLookup:M,isTarget:$,edgeUpdaterType:E.type,lib:V,flowId:N,cancelConnection:z,panBy:C,isValidConnection:(...H)=>m.getState().isValidConnection?.(...H)??!0,onConnect:D,onConnectStart:L,onConnectEnd:(...H)=>m.getState().onConnectEnd?.(...H),onReconnectEnd:_,updateConnection:I,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:v.currentTarget})},y=v=>w(v,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),x=v=>w(v,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>p(!0),g=()=>p(!1);return a.jsxs(a.Fragment,{children:[(e===!0||e==="source")&&a.jsx(ki,{position:c,centerX:s,centerY:o,radius:t,onMouseDown:y,onMouseEnter:b,onMouseOut:g,type:"source"}),(e===!0||e==="target")&&a.jsx(ki,{position:l,centerX:i,centerY:r,radius:t,onMouseDown:x,onMouseEnter:b,onMouseOut:g,type:"target"})]})}function I0({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:s,onClick:o,onDoubleClick:i,onContextMenu:r,onMouseEnter:c,onMouseMove:l,onMouseLeave:d,reconnectRadius:u,onReconnect:h,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:w,noPanClassName:y,onError:x,disableKeyboardA11y:b}){let g=oe(K=>K.edgeLookup.get(e));const v=oe(K=>K.defaultEdgeOptions);g=v?{...v,...g}:g;let E=g.type||"default",j=w?.[E]||vi[E];j===void 0&&(x?.("011",Te.error011(E)),E="default",j=w?.default||vi.default);const S=!!(g.focusable||t&&typeof g.focusable>"u"),R=typeof h<"u"&&(g.reconnectable||n&&typeof g.reconnectable>"u"),A=!!(g.selectable||s&&typeof g.selectable>"u"),V=k.useRef(null),[O,z]=k.useState(!1),[M,N]=k.useState(!1),C=le(),{zIndex:I=g.zIndex,sourceX:$,sourceY:_,targetX:D,targetY:L,sourcePosition:H,targetPosition:F}=oe(k.useCallback(K=>{const Q=K.nodeLookup.get(g.source),re=K.nodeLookup.get(g.target);if(!Q||!re)return bi;const ie=gg({id:e,sourceNode:Q,targetNode:re,sourceHandle:g.sourceHandle||null,targetHandle:g.targetHandle||null,connectionMode:K.connectionMode,onError:x}),ce=cg({selected:g.selected,zIndex:g.zIndex,sourceNode:Q,targetNode:re,elevateOnSelect:K.elevateEdgesOnSelect,zIndexMode:K.zIndexMode});return{...ie||bi,zIndex:ce}},[g.source,g.target,g.sourceHandle,g.targetHandle,g.selected,g.zIndex,x]),de),P=k.useMemo(()=>g.markerStart?`url('#${Js(g.markerStart,m)}')`:void 0,[g.markerStart,m]),W=k.useMemo(()=>g.markerEnd?`url('#${Js(g.markerEnd,m)}')`:void 0,[g.markerEnd,m]);if(g.hidden||$===null||_===null||D===null||L===null)return null;const Y=K=>{const{addSelectedEdges:Q,unselectNodesAndEdges:re,multiSelectionActive:ie}=C.getState();A&&(C.setState({nodesSelectionActive:!1}),g.selected&&ie?(re({nodes:[],edges:[g]}),V.current?.blur()):Q([e])),o&&o(K,g)},J=i?K=>{i(K,{...g})}:void 0,U=r?K=>{r(K,{...g})}:void 0,T=c?K=>{c(K,{...g})}:void 0,Z=l?K=>{l(K,{...g})}:void 0,ee=d?K=>{d(K,{...g})}:void 0,te=K=>{if(!b&&Qa.includes(K.key)&&A){const{unselectNodesAndEdges:Q,addSelectedEdges:re}=C.getState();K.key==="Escape"?(V.current?.blur(),Q({edges:[g]})):re([e])}};return a.jsx("svg",{style:{zIndex:I},children:a.jsxs("g",{className:he(["react-flow__edge",`react-flow__edge-${E}`,g.className,y,{selected:g.selected,animated:g.animated,inactive:!A&&!o,updating:O,selectable:A}]),onClick:Y,onDoubleClick:J,onContextMenu:U,onMouseEnter:T,onMouseMove:Z,onMouseLeave:ee,onKeyDown:S?te:void 0,tabIndex:S?0:void 0,role:g.ariaRole??(S?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":g.ariaLabel===null?void 0:g.ariaLabel||`Edge from ${g.source} to ${g.target}`,"aria-describedby":S?`${Mc}-${m}`:void 0,ref:V,...g.domAttributes,children:[!M&&a.jsx(j,{id:e,source:g.source,target:g.target,type:g.type,selected:g.selected,animated:g.animated,selectable:A,deletable:g.deletable??!0,label:g.label,labelStyle:g.labelStyle,labelShowBg:g.labelShowBg,labelBgStyle:g.labelBgStyle,labelBgPadding:g.labelBgPadding,labelBgBorderRadius:g.labelBgBorderRadius,sourceX:$,sourceY:_,targetX:D,targetY:L,sourcePosition:H,targetPosition:F,data:g.data,style:g.style,sourceHandleId:g.sourceHandle,targetHandleId:g.targetHandle,markerStart:P,markerEnd:W,pathOptions:"pathOptions"in g?g.pathOptions:void 0,interactionWidth:g.interactionWidth}),R&&a.jsx(S0,{edge:g,isReconnectable:R,reconnectRadius:u,onReconnect:h,onReconnectStart:f,onReconnectEnd:p,sourceX:$,sourceY:_,targetX:D,targetY:L,sourcePosition:H,targetPosition:F,setUpdateHover:z,setReconnecting:N})]})})}var _0=k.memo(I0);const M0=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function nl({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:s,noPanClassName:o,onReconnect:i,onEdgeContextMenu:r,onEdgeMouseEnter:c,onEdgeMouseMove:l,onEdgeMouseLeave:d,onEdgeClick:u,reconnectRadius:h,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:w}){const{edgesFocusable:y,edgesReconnectable:x,elementsSelectable:b,onError:g}=oe(M0,de),v=p0(t);return a.jsxs("div",{className:"react-flow__edges",children:[a.jsx(w0,{defaultColor:e,rfId:n}),v.map(E=>a.jsx(_0,{id:E,edgesFocusable:y,edgesReconnectable:x,elementsSelectable:b,noPanClassName:o,onReconnect:i,onContextMenu:r,onMouseEnter:c,onMouseMove:l,onMouseLeave:d,onClick:u,reconnectRadius:h,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:g,edgeTypes:s,disableKeyboardA11y:w},E))]})}nl.displayName="EdgeRenderer";const $0=k.memo(nl),ji=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function R0({children:e}){const t=le(),n=k.useRef(null),[s]=k.useState(()=>t.getState().transform);return Dc(()=>{let o=null;const i=()=>{const r=t.getState().transform;o&&r[0]===o[0]&&r[1]===o[1]&&r[2]===o[2]||(o=r,n.current&&(n.current.style.transform=ji(r)))};return i(),t.subscribe(i)},[t]),a.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:ji(s)},children:e})}function A0(e){const t=Ht(),n=k.useRef(!1);k.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const D0=e=>e.panZoom?.syncViewport;function P0(e){const t=oe(D0),n=le();return k.useEffect(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function O0(e){return e.connection.inProgress?{...e.connection,to:vn(e.connection.to,e.transform)}:{...e.connection}}function T0(e){return O0}function z0(e){const t=T0();return oe(t,de)}const L0=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function H0({containerStyle:e,style:t,type:n,component:s}){const{nodesConnectable:o,width:i,height:r,isValid:c,inProgress:l}=oe(L0,de);return!(i&&o&&l)?null:a.jsx("svg",{style:e,width:i,height:r,className:"react-flow__connectionline react-flow__container",children:a.jsx("g",{className:he(["react-flow__connection",tc(c)]),children:a.jsx(sl,{style:t,type:n,CustomComponent:s,isValid:c})})})}const sl=({style:e,type:t=st.Bezier,CustomComponent:n,isValid:s})=>{const{inProgress:o,from:i,fromNode:r,fromHandle:c,fromPosition:l,to:d,toNode:u,toHandle:h,toPosition:f,pointer:p}=z0();if(!o)return;if(n)return a.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:r,fromHandle:c,fromX:i.x,fromY:i.y,toX:d.x,toY:d.y,fromPosition:l,toPosition:f,connectionStatus:tc(s),toNode:u,toHandle:h,pointer:p});let m="";const w={sourceX:i.x,sourceY:i.y,sourcePosition:l,targetX:d.x,targetY:d.y,targetPosition:f};switch(t){case st.Bezier:[m]=zo(w);break;case st.SimpleBezier:[m]=Wc(w);break;case st.Step:[m]=es({...w,borderRadius:0});break;case st.SmoothStep:[m]=es(w);break;default:[m]=mc(w)}return a.jsx("path",{d:m,fill:"none",className:"react-flow__connection-path",style:e})};sl.displayName="ConnectionLine";const V0={};function Ei(e=V0){k.useRef(e),le(),k.useEffect(()=>{},[e])}function F0(){le(),k.useRef(!1),k.useEffect(()=>{},[])}function ol({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:s,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:r,onNodeMouseEnter:c,onNodeMouseMove:l,onNodeMouseLeave:d,onNodeContextMenu:u,onSelectionContextMenu:h,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:w,connectionLineComponent:y,connectionLineContainerStyle:x,selectionKeyCode:b,selectionOnDrag:g,selectionMode:v,multiSelectionKeyCode:E,panActivationKeyCode:j,zoomActivationKeyCode:S,deleteKeyCode:R,onlyRenderVisibleElements:A,elementsSelectable:V,defaultViewport:O,translateExtent:z,minZoom:M,maxZoom:N,preventScrolling:C,defaultMarkerColor:I,zoomOnScroll:$,zoomOnPinch:_,panOnScroll:D,panOnScrollSpeed:L,panOnScrollMode:H,zoomOnDoubleClick:F,panOnDrag:P,autoPanOnSelection:W,onPaneClick:Y,onPaneMouseEnter:J,onPaneMouseMove:U,onPaneMouseLeave:T,onPaneScroll:Z,onPaneContextMenu:ee,paneClickDistance:te,nodeClickDistance:K,onEdgeContextMenu:Q,onEdgeMouseEnter:re,onEdgeMouseMove:ie,onEdgeMouseLeave:ce,reconnectRadius:ue,onReconnect:ge,onReconnectStart:be,onReconnectEnd:Ee,noDragClassName:Ie,noWheelClassName:qe,noPanClassName:Ze,disableKeyboardA11y:Ge,nodeExtent:B,rfId:G,viewport:ne,onViewportChange:fe,nodesDraggable:ae}){return Ei(e),Ei(t),F0(),A0(n),P0(ne),a.jsx(o0,{onPaneClick:Y,onPaneMouseEnter:J,onPaneMouseMove:U,onPaneMouseLeave:T,onPaneContextMenu:ee,onPaneScroll:Z,paneClickDistance:te,deleteKeyCode:R,selectionKeyCode:b,selectionOnDrag:g,selectionMode:v,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:E,panActivationKeyCode:j,zoomActivationKeyCode:S,elementsSelectable:V,zoomOnScroll:$,zoomOnPinch:_,zoomOnDoubleClick:F,panOnScroll:D,panOnScrollSpeed:L,panOnScrollMode:H,panOnDrag:P,autoPanOnSelection:W,defaultViewport:O,translateExtent:z,minZoom:M,maxZoom:N,onSelectionContextMenu:h,preventScrolling:C,noDragClassName:Ie,noWheelClassName:qe,noPanClassName:Ze,disableKeyboardA11y:Ge,onViewportChange:fe,isControlledViewport:!!ne,children:a.jsxs(R0,{children:[a.jsx($0,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:r,onReconnect:ge,onReconnectStart:be,onReconnectEnd:Ee,onlyRenderVisibleElements:A,onEdgeContextMenu:Q,onEdgeMouseEnter:re,onEdgeMouseMove:ie,onEdgeMouseLeave:ce,reconnectRadius:ue,defaultMarkerColor:I,noPanClassName:Ze,disableKeyboardA11y:Ge,rfId:G}),a.jsx(H0,{style:w,type:m,component:y,containerStyle:x}),a.jsx("div",{className:"react-flow__edgelabel-renderer"}),a.jsx(h0,{nodeTypes:e,onNodeClick:s,onNodeDoubleClick:i,onNodeMouseEnter:c,onNodeMouseMove:l,onNodeMouseLeave:d,onNodeContextMenu:u,nodeClickDistance:K,onlyRenderVisibleElements:A,noPanClassName:Ze,noDragClassName:Ie,disableKeyboardA11y:Ge,nodeExtent:B,rfId:G,nodesDraggable:ae}),a.jsx("div",{className:"react-flow__viewport-portal"})]})})}ol.displayName="GraphView";const B0=k.memo(ol),W0=ac(),Ci=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:o,height:i,fitView:r,fitViewOptions:c,minZoom:l=.5,maxZoom:d=2,nodeOrigin:u,nodeExtent:h,zIndexMode:f="basic"}={})=>{const p=new Map,m=new Map,w=new Map,y=new Map,x=s??t??[],b=n??e??[],g=u??[0,0],v=h??tn;yc(w,y,x);const{nodesInitialized:E}=eo(b,p,m,{nodeOrigin:g,nodeExtent:v,zIndexMode:f});let j=[0,0,1];if(r&&o&&i){const S=yn(p,{filter:O=>!!((O.width||O.initialWidth)&&(O.height||O.initialHeight))}),{x:R,y:A,zoom:V}=Oo(S,o,i,l,d,c?.padding??.1);j=[R,A,V]}return{rfId:"1",width:o??0,height:i??0,transform:j,nodes:b,nodesInitialized:E,nodeLookup:p,parentLookup:m,edges:x,edgeLookup:y,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:l,maxZoom:d,translateExtent:tn,nodeExtent:v,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Mt.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:g,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:r??!1,fitViewOptions:c,fitViewResolver:null,connection:{...ec},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:W0,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Ja,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Y0=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:o,height:i,fitView:r,fitViewOptions:c,minZoom:l,maxZoom:d,nodeOrigin:u,nodeExtent:h,zIndexMode:f})=>rx((p,m)=>{async function w(){const{nodeLookup:y,panZoom:x,fitViewOptions:b,fitViewResolver:g,width:v,height:E,minZoom:j,maxZoom:S}=m();x&&(await tg({nodes:y,width:v,height:E,panZoom:x,minZoom:j,maxZoom:S},b),g?.resolve(!0),p({fitViewResolver:null}))}return{...Ci({nodes:e,edges:t,width:o,height:i,fitView:r,fitViewOptions:c,minZoom:l,maxZoom:d,nodeOrigin:u,nodeExtent:h,defaultNodes:n,defaultEdges:s,zIndexMode:f}),setNodes:y=>{const{nodeLookup:x,parentLookup:b,nodeOrigin:g,nodeExtent:v,elevateNodesOnSelect:E,fitViewQueued:j,zIndexMode:S,nodesSelectionActive:R}=m(),{nodesInitialized:A,hasSelectedNodes:V}=eo(y,x,b,{nodeOrigin:g,nodeExtent:v,elevateNodesOnSelect:E,checkEquality:!0,zIndexMode:S}),O=R&&V;j&&A?(w(),p({nodes:y,nodesInitialized:A,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:O})):p({nodes:y,nodesInitialized:A,nodesSelectionActive:O})},setEdges:y=>{const{connectionLookup:x,edgeLookup:b}=m();yc(x,b,y),p({edges:y})},setDefaultNodesAndEdges:(y,x)=>{if(y){const{setNodes:b}=m();b(y),p({hasDefaultNodes:!0})}if(x){const{setEdges:b}=m();b(x),p({hasDefaultEdges:!0})}},updateNodeInternals:y=>{const{triggerNodeChanges:x,nodeLookup:b,parentLookup:g,domNode:v,nodeOrigin:E,nodeExtent:j,debug:S,fitViewQueued:R,zIndexMode:A}=m(),{changes:V,updatedInternals:O}=jg(y,b,g,v,E,j,A);O&&(vg(b,g,{nodeOrigin:E,nodeExtent:j,zIndexMode:A}),R?(w(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),V?.length>0&&(S&&console.log("React Flow: trigger node changes",V),x?.(V)))},updateNodePositions:(y,x=!1)=>{const b=[];let g=[];const{nodeLookup:v,triggerNodeChanges:E,connection:j,updateConnection:S,onNodesChangeMiddlewareMap:R}=m();for(const[A,V]of y){const O=v.get(A),z=!!(O?.expandParent&&O?.parentId&&V?.position),M={id:A,type:"position",position:z?{x:Math.max(0,V.position.x),y:Math.max(0,V.position.y)}:V.position,dragging:x};if(O&&j.inProgress&&j.fromNode.id===O.id){const N=wt(O,j.fromHandle,q.Left,!0);S({...j,from:N})}z&&O.parentId&&b.push({id:A,parentId:O.parentId,rect:{...V.internals.positionAbsolute,width:V.measured.width??0,height:V.measured.height??0}}),g.push(M)}if(b.length>0){const{parentLookup:A,nodeOrigin:V}=m(),O=Bo(b,v,A,V);g.push(...O)}for(const A of R.values())g=A(g);E(g)},triggerNodeChanges:y=>{const{onNodesChange:x,setNodes:b,nodes:g,hasDefaultNodes:v,debug:E}=m();if(y?.length){if(v){const j=Ns(y,g);b(j)}E&&console.log("React Flow: trigger node changes",y),x?.(y)}},triggerEdgeChanges:y=>{const{onEdgesChange:x,setEdges:b,edges:g,hasDefaultEdges:v,debug:E}=m();if(y?.length){if(v){const j=ks(y,g);b(j)}E&&console.log("React Flow: trigger edge changes",y),x?.(y)}},addSelectedNodes:y=>{const{multiSelectionActive:x,edgeLookup:b,nodeLookup:g,triggerNodeChanges:v,triggerEdgeChanges:E}=m();if(x){const j=y.map(S=>at(S,!0));v(j);return}v(jt(g,new Set([...y]),!0)),E(jt(b))},addSelectedEdges:y=>{const{multiSelectionActive:x,edgeLookup:b,nodeLookup:g,triggerNodeChanges:v,triggerEdgeChanges:E}=m();if(x){const j=y.map(S=>at(S,!0));E(j);return}E(jt(b,new Set([...y]))),v(jt(g,new Set,!0))},unselectNodesAndEdges:({nodes:y,edges:x}={})=>{const{edges:b,nodes:g,nodeLookup:v,triggerNodeChanges:E,triggerEdgeChanges:j}=m(),S=y||g,R=x||b,A=[];for(const O of S){if(!O.selected)continue;const z=v.get(O.id);z&&(z.selected=!1),A.push(at(O.id,!1))}const V=[];for(const O of R)O.selected&&V.push(at(O.id,!1));E(A),j(V)},setMinZoom:y=>{const{panZoom:x,maxZoom:b}=m();x?.setScaleExtent([y,b]),p({minZoom:y})},setMaxZoom:y=>{const{panZoom:x,minZoom:b}=m();x?.setScaleExtent([b,y]),p({maxZoom:y})},setTranslateExtent:y=>{m().panZoom?.setTranslateExtent(y),p({translateExtent:y})},resetSelectedElements:()=>{const{edges:y,nodes:x,triggerNodeChanges:b,triggerEdgeChanges:g,elementsSelectable:v}=m();if(!v)return;const E=x.reduce((S,R)=>R.selected?[...S,at(R.id,!1)]:S,[]),j=y.reduce((S,R)=>R.selected?[...S,at(R.id,!1)]:S,[]);b(E),g(j)},setNodeExtent:y=>{const{nodes:x,nodeLookup:b,parentLookup:g,nodeOrigin:v,elevateNodesOnSelect:E,nodeExtent:j,zIndexMode:S}=m();y[0][0]===j[0][0]&&y[0][1]===j[0][1]&&y[1][0]===j[1][0]&&y[1][1]===j[1][1]||(eo(x,b,g,{nodeOrigin:v,nodeExtent:y,elevateNodesOnSelect:E,checkEquality:!1,zIndexMode:S}),p({nodeExtent:y}))},panBy:y=>{const{transform:x,width:b,height:g,panZoom:v,translateExtent:E}=m();return Eg({delta:y,panZoom:v,transform:x,translateExtent:E,width:b,height:g})},setCenter:async(y,x,b)=>{const{width:g,height:v,maxZoom:E,panZoom:j}=m();if(!j)return!1;const S=typeof b?.zoom<"u"?b.zoom:E;return await j.setViewport({x:g/2-y*S,y:v/2-x*S,zoom:S},{duration:b?.duration,ease:b?.ease,interpolate:b?.interpolate}),!0},cancelConnection:()=>{p({connection:{...ec}})},updateConnection:y=>{p({connection:y})},reset:()=>p({...Ci()})}},Object.is);function Yo({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:s,initialWidth:o,initialHeight:i,initialMinZoom:r,initialMaxZoom:c,initialFitViewOptions:l,fitView:d,nodeOrigin:u,nodeExtent:h,zIndexMode:f,children:p}){const[m]=k.useState(()=>Y0({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:o,height:i,fitView:d,minZoom:r,maxZoom:c,fitViewOptions:l,nodeOrigin:u,nodeExtent:h,zIndexMode:f}));return a.jsx(ix,{value:m,children:a.jsx(Mx,{children:a.jsx(Yx,{children:p})})})}function X0({children:e,nodes:t,edges:n,defaultNodes:s,defaultEdges:o,width:i,height:r,fitView:c,fitViewOptions:l,minZoom:d,maxZoom:u,nodeOrigin:h,nodeExtent:f,zIndexMode:p}){return k.useContext(bs)?a.jsx(a.Fragment,{children:e}):a.jsx(Yo,{initialNodes:t,initialEdges:n,defaultNodes:s,defaultEdges:o,initialWidth:i,initialHeight:r,fitView:c,initialFitViewOptions:l,initialMinZoom:d,initialMaxZoom:u,nodeOrigin:h,nodeExtent:f,zIndexMode:p,children:e})}const q0={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Z0({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:o,nodeTypes:i,edgeTypes:r,onNodeClick:c,onEdgeClick:l,onInit:d,onMove:u,onMoveStart:h,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:w,onClickConnectStart:y,onClickConnectEnd:x,onNodeMouseEnter:b,onNodeMouseMove:g,onNodeMouseLeave:v,onNodeContextMenu:E,onNodeDoubleClick:j,onNodeDragStart:S,onNodeDrag:R,onNodeDragStop:A,onNodesDelete:V,onEdgesDelete:O,onDelete:z,onSelectionChange:M,onSelectionDragStart:N,onSelectionDrag:C,onSelectionDragStop:I,onSelectionContextMenu:$,onSelectionStart:_,onSelectionEnd:D,onBeforeDelete:L,connectionMode:H,connectionLineType:F=st.Bezier,connectionLineStyle:P,connectionLineComponent:W,connectionLineContainerStyle:Y,deleteKeyCode:J="Backspace",selectionKeyCode:U="Shift",selectionOnDrag:T=!1,selectionMode:Z=nn.Full,panActivationKeyCode:ee="Space",multiSelectionKeyCode:te=on()?"Meta":"Control",zoomActivationKeyCode:K=on()?"Meta":"Control",snapToGrid:Q,snapGrid:re,onlyRenderVisibleElements:ie=!1,selectNodesOnDrag:ce,nodesDraggable:ue,autoPanOnNodeFocus:ge,nodesConnectable:be,nodesFocusable:Ee,nodeOrigin:Ie=$c,edgesFocusable:qe,edgesReconnectable:Ze,elementsSelectable:Ge=!0,defaultViewport:B=wx,minZoom:G=.5,maxZoom:ne=2,translateExtent:fe=tn,preventScrolling:ae=!0,nodeExtent:xe,defaultMarkerColor:ye="#b1b1b7",zoomOnScroll:it=!0,zoomOnPinch:Zl=!0,panOnScroll:Gl=!1,panOnScrollSpeed:Ul=.5,panOnScrollMode:Kl=ft.Free,zoomOnDoubleClick:Ql=!0,panOnDrag:Jl=!0,onPaneClick:ed,onPaneMouseEnter:td,onPaneMouseMove:nd,onPaneMouseLeave:sd,onPaneScroll:od,onPaneContextMenu:rd,paneClickDistance:id=1,nodeClickDistance:ad=0,children:cd,onReconnect:ld,onReconnectStart:dd,onReconnectEnd:ud,onEdgeContextMenu:fd,onEdgeDoubleClick:hd,onEdgeMouseEnter:pd,onEdgeMouseMove:md,onEdgeMouseLeave:gd,reconnectRadius:xd=10,onNodesChange:yd,onEdgesChange:wd,noDragClassName:vd="nodrag",noWheelClassName:bd="nowheel",noPanClassName:ar="nopan",fitView:cr,fitViewOptions:lr,connectOnClick:Nd,attributionPosition:kd,proOptions:jd,defaultEdgeOptions:Ed,elevateNodesOnSelect:Cd=!0,elevateEdgesOnSelect:Sd=!1,disableKeyboardA11y:dr=!1,autoPanOnConnect:Id,autoPanOnNodeDrag:_d,autoPanOnSelection:Md=!0,autoPanSpeed:$d,connectionRadius:Rd,isValidConnection:Ad,onError:Dd,style:Pd,id:ur,nodeDragThreshold:Od,connectionDragThreshold:Td,viewport:zd,onViewportChange:Ld,width:Hd,height:Vd,colorMode:Fd="light",debug:Bd,onScroll:fr,ariaLabelConfig:Wd,zIndexMode:hr="basic",...Yd},Xd){const Ss=ur||"1",qd=kx(Fd),Zd=k.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),fr?.(pr)},[fr]);return a.jsx("div",{"data-testid":"rf__wrapper",...Yd,onScroll:Zd,style:{...Pd,...q0},ref:Xd,className:he(["react-flow",o,qd]),id:ur,role:"application",children:a.jsxs(X0,{nodes:e,edges:t,width:Hd,height:Vd,fitView:cr,fitViewOptions:lr,minZoom:G,maxZoom:ne,nodeOrigin:Ie,nodeExtent:xe,zIndexMode:hr,children:[a.jsx(Nx,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:p,onConnectStart:m,onConnectEnd:w,onClickConnectStart:y,onClickConnectEnd:x,nodesDraggable:ue,autoPanOnNodeFocus:ge,nodesConnectable:be,nodesFocusable:Ee,edgesFocusable:qe,edgesReconnectable:Ze,elementsSelectable:Ge,elevateNodesOnSelect:Cd,elevateEdgesOnSelect:Sd,minZoom:G,maxZoom:ne,nodeExtent:xe,onNodesChange:yd,onEdgesChange:wd,snapToGrid:Q,snapGrid:re,connectionMode:H,translateExtent:fe,connectOnClick:Nd,defaultEdgeOptions:Ed,fitView:cr,fitViewOptions:lr,onNodesDelete:V,onEdgesDelete:O,onDelete:z,onNodeDragStart:S,onNodeDrag:R,onNodeDragStop:A,onSelectionDrag:C,onSelectionDragStart:N,onSelectionDragStop:I,onMove:u,onMoveStart:h,onMoveEnd:f,noPanClassName:ar,nodeOrigin:Ie,rfId:Ss,autoPanOnConnect:Id,autoPanOnNodeDrag:_d,autoPanSpeed:$d,onError:Dd,connectionRadius:Rd,isValidConnection:Ad,selectNodesOnDrag:ce,nodeDragThreshold:Od,connectionDragThreshold:Td,onBeforeDelete:L,debug:Bd,ariaLabelConfig:Wd,zIndexMode:hr}),a.jsx(B0,{onInit:d,onNodeClick:c,onEdgeClick:l,onNodeMouseEnter:b,onNodeMouseMove:g,onNodeMouseLeave:v,onNodeContextMenu:E,onNodeDoubleClick:j,nodeTypes:i,edgeTypes:r,connectionLineType:F,connectionLineStyle:P,connectionLineComponent:W,connectionLineContainerStyle:Y,selectionKeyCode:U,selectionOnDrag:T,selectionMode:Z,deleteKeyCode:J,multiSelectionKeyCode:te,panActivationKeyCode:ee,zoomActivationKeyCode:K,onlyRenderVisibleElements:ie,defaultViewport:B,translateExtent:fe,minZoom:G,maxZoom:ne,preventScrolling:ae,zoomOnScroll:it,zoomOnPinch:Zl,zoomOnDoubleClick:Ql,panOnScroll:Gl,panOnScrollSpeed:Ul,panOnScrollMode:Kl,panOnDrag:Jl,autoPanOnSelection:Md,onPaneClick:ed,onPaneMouseEnter:td,onPaneMouseMove:nd,onPaneMouseLeave:sd,onPaneScroll:od,onPaneContextMenu:rd,paneClickDistance:id,nodeClickDistance:ad,onSelectionContextMenu:$,onSelectionStart:_,onSelectionEnd:D,onReconnect:ld,onReconnectStart:dd,onReconnectEnd:ud,onEdgeContextMenu:fd,onEdgeDoubleClick:hd,onEdgeMouseEnter:pd,onEdgeMouseMove:md,onEdgeMouseLeave:gd,reconnectRadius:xd,defaultMarkerColor:ye,noDragClassName:vd,noWheelClassName:bd,noPanClassName:ar,rfId:Ss,disableKeyboardA11y:dr,nodeExtent:xe,viewport:zd,onViewportChange:Ld,nodesDraggable:ue}),a.jsx(yx,{onSelectionChange:M}),cd,a.jsx(hx,{proOptions:jd,position:kd}),a.jsx(fx,{rfId:Ss,disableKeyboardA11y:dr})]})})}var Xo=Ac(Z0);const G0=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");function U0({children:e}){const t=oe(G0);return t?cu.createPortal(e,t):null}function ns(e){return oe(k.useCallback(n=>n.nodeLookup.get(e),[e]),de)}function K0({dimensions:e,lineWidth:t,variant:n,className:s}){return a.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:he(["react-flow__background-pattern",n,s])})}function Q0({radius:e,className:t}){return a.jsx("circle",{cx:e,cy:e,r:e,className:he(["react-flow__background-pattern","dots",t])})}var ot;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ot||(ot={}));const J0={[ot.Dots]:1,[ot.Lines]:1,[ot.Cross]:6},ey=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function rl({id:e,variant:t=ot.Dots,gap:n=20,size:s,lineWidth:o=1,offset:i=0,color:r,bgColor:c,style:l,className:d,patternClassName:u}){const h=k.useRef(null),{transform:f,patternId:p}=oe(ey,de),m=s||J0[t],w=t===ot.Dots,y=t===ot.Cross,x=Array.isArray(n)?n:[n,n],b=[x[0]*f[2]||1,x[1]*f[2]||1],g=m*f[2],v=Array.isArray(i)?i:[i,i],E=y?[g,g]:b,j=[v[0]*f[2]+E[0]/2,v[1]*f[2]+E[1]/2],S=`${p}${e||""}`;return a.jsxs("svg",{className:he(["react-flow__background",d]),style:{...l,...js,"--xy-background-color-props":c,"--xy-background-pattern-color-props":r},ref:h,"data-testid":"rf__background",children:[a.jsx("pattern",{id:S,x:f[0]%b[0],y:f[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${j[0]},-${j[1]})`,children:w?a.jsx(Q0,{radius:g/2,className:u}):a.jsx(K0,{dimensions:E,lineWidth:o,variant:t,className:u})}),a.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${S})`})]})}rl.displayName="Background";const qo=k.memo(rl);function ty(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:a.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ny(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:a.jsx("path",{d:"M0 0h32v4.2H0z"})})}function sy(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:a.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function oy(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:a.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function ry(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:a.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Et({children:e,className:t,...n}){return a.jsx("button",{type:"button",className:he(["react-flow__controls-button",t]),...n,children:e})}const iy=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function il({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:s=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:r,onFitView:c,onInteractiveChange:l,className:d,children:u,position:h="bottom-left",orientation:f="vertical","aria-label":p}){const m=le(),{isInteractive:w,minZoomReached:y,maxZoomReached:x,ariaLabelConfig:b}=oe(iy,de),{zoomIn:g,zoomOut:v,fitView:E}=Ht(),j=()=>{g(),i?.()},S=()=>{v(),r?.()},R=()=>{E(o),c?.()},A=()=>{m.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),l?.(!w)},V=f==="horizontal"?"horizontal":"vertical";return a.jsxs(rt,{className:he(["react-flow__controls",V,d]),position:h,style:e,"data-testid":"rf__controls","aria-label":p??b["controls.ariaLabel"],children:[t&&a.jsxs(a.Fragment,{children:[a.jsx(Et,{onClick:j,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:x,children:a.jsx(ty,{})}),a.jsx(Et,{onClick:S,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:y,children:a.jsx(ny,{})})]}),n&&a.jsx(Et,{className:"react-flow__controls-fitview",onClick:R,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:a.jsx(sy,{})}),s&&a.jsx(Et,{className:"react-flow__controls-interactive",onClick:A,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:w?a.jsx(ry,{}):a.jsx(oy,{})}),u]})}il.displayName="Controls";const Zo=k.memo(il);function ay({id:e,x:t,y:n,width:s,height:o,style:i,color:r,strokeColor:c,strokeWidth:l,className:d,borderRadius:u,shapeRendering:h,selected:f,onClick:p}){const{background:m,backgroundColor:w}=i||{},y=r||m||w;return a.jsx("rect",{className:he(["react-flow__minimap-node",{selected:f},d]),x:t,y:n,rx:u,ry:u,width:s,height:o,style:{fill:y,stroke:c,strokeWidth:l},shapeRendering:h,onClick:p?x=>p(x,e):void 0})}const cy=k.memo(ay),ly=e=>e.nodes.map(t=>t.id),Hs=e=>e instanceof Function?e:()=>e;function dy({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:o,nodeComponent:i=cy,onClick:r}){const c=oe(ly,de),l=Hs(t),d=Hs(e),u=Hs(n),h=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return a.jsx(a.Fragment,{children:c.map(f=>a.jsx(fy,{id:f,nodeColorFunc:l,nodeStrokeColorFunc:d,nodeClassNameFunc:u,nodeBorderRadius:s,nodeStrokeWidth:o,NodeComponent:i,onClick:r,shapeRendering:h},f))})}function uy({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:s,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:r,NodeComponent:c,onClick:l}){const{node:d,x:u,y:h,width:f,height:p}=oe(m=>{const w=m.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};const y=w.internals.userNode,{x,y:b}=w.internals.positionAbsolute,{width:g,height:v}=Le(y);return{node:y,x,y:b,width:g,height:v}},de);return!d||d.hidden||!cc(d)?null:a.jsx(c,{x:u,y:h,width:f,height:p,style:d.style,selected:!!d.selected,className:s(d),color:t(d),borderRadius:o,strokeColor:n(d),strokeWidth:i,shapeRendering:r,onClick:l,id:d.id})}const fy=k.memo(uy);var hy=k.memo(dy);const py=200,my=150,gy=e=>!e.hidden,xy=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?rc(yn(e.nodeLookup,{filter:gy}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Si=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,yy=(e,t)=>Si(e.viewBB,t.viewBB)&&Si(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,wy="react-flow__minimap-desc";function al({style:e,className:t,nodeStrokeColor:n,nodeColor:s,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:r,nodeComponent:c,bgColor:l,maskColor:d,maskStrokeColor:u,maskStrokeWidth:h,position:f="bottom-right",onClick:p,onNodeClick:m,pannable:w=!1,zoomable:y=!1,ariaLabel:x,inversePan:b,zoomStep:g=1,offsetScale:v=5}){const E=le(),j=k.useRef(null),{boundingRect:S,viewBB:R,rfId:A,panZoom:V,translateExtent:O,flowWidth:z,flowHeight:M,ariaLabelConfig:N}=oe(xy,yy),C=e?.width??py,I=e?.height??my,$=S.width/C,_=S.height/I,D=Math.max($,_),L=D*C,H=D*I,F=v*D,P=S.x-(L-S.width)/2-F,W=S.y-(H-S.height)/2-F,Y=L+F*2,J=H+F*2,U=`${wy}-${A}`,T=k.useRef(0),Z=k.useRef();T.current=D,k.useEffect(()=>{if(j.current&&V)return Z.current=Dg({domNode:j.current,panZoom:V,getTransform:()=>E.getState().transform,getViewScale:()=>T.current}),()=>{Z.current?.destroy()}},[V]),k.useEffect(()=>{Z.current?.update({translateExtent:O,width:z,height:M,inversePan:b,pannable:w,zoomStep:g,zoomable:y})},[w,y,b,g,O,z,M]);const ee=p?Q=>{const[re,ie]=Z.current?.pointer(Q)||[0,0];p(Q,{x:re,y:ie})}:void 0,te=m?k.useCallback((Q,re)=>{const ie=E.getState().nodeLookup.get(re).internals.userNode;m(Q,ie)},[]):void 0,K=x??N["minimap.ariaLabel"];return a.jsx(rt,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof h=="number"?h*D:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof r=="number"?r:void 0},className:he(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:a.jsxs("svg",{width:C,height:I,viewBox:`${P} ${W} ${Y} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":U,ref:j,onClick:ee,children:[K&&a.jsx("title",{id:U,children:K}),a.jsx(hy,{onClick:te,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:r,nodeComponent:c}),a.jsx("path",{className:"react-flow__minimap-mask",d:`M${P-F},${W-F}h${Y+F*2}v${J+F*2}h${-Y-F*2}z
8
- M${R.x},${R.y}h${R.width}v${R.height}h${-R.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}al.displayName="MiniMap";const Go=k.memo(al),vy=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,by={[At.Line]:"right",[At.Handle]:"bottom-right"};function Ny({nodeId:e,position:t,variant:n=At.Handle,className:s,style:o=void 0,children:i,color:r,minWidth:c=10,minHeight:l=10,maxWidth:d=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:h=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:w,onResize:y,onResizeEnd:x}){const b=zc(),g=typeof e=="string"?e:b,v=le(),E=k.useRef(null),j=n===At.Handle,S=oe(k.useCallback(vy(j&&p),[j,p]),de),R=k.useRef(null),A=t??by[n];k.useEffect(()=>{if(!(!E.current||!g))return R.current||(R.current=qg({domNode:E.current,nodeId:g,getStoreItems:()=>{const{nodeLookup:O,transform:z,snapGrid:M,snapToGrid:N,nodeOrigin:C,domNode:I}=v.getState();return{nodeLookup:O,transform:z,snapGrid:M,snapToGrid:N,nodeOrigin:C,paneDomNode:I}},onChange:(O,z)=>{const{triggerNodeChanges:M,nodeLookup:N,parentLookup:C,nodeOrigin:I}=v.getState(),$=[],_={x:O.x,y:O.y},D=N.get(g);if(D&&D.expandParent&&D.parentId){const L=D.origin??I,H=O.width??D.measured.width??0,F=O.height??D.measured.height??0,P={id:D.id,parentId:D.parentId,rect:{width:H,height:F,...lc({x:O.x??D.position.x,y:O.y??D.position.y},{width:H,height:F},D.parentId,N,L)}},W=Bo([P],N,C,I);$.push(...W),_.x=O.x?Math.max(L[0]*H,O.x):void 0,_.y=O.y?Math.max(L[1]*F,O.y):void 0}if(_.x!==void 0&&_.y!==void 0){const L={id:g,type:"position",position:{..._}};$.push(L)}if(O.width!==void 0&&O.height!==void 0){const H={id:g,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};$.push(H)}for(const L of z){const H={...L,type:"position"};$.push(H)}M($)},onEnd:({width:O,height:z})=>{const M={id:g,type:"dimensions",resizing:!1,dimensions:{width:O,height:z}};v.getState().triggerNodeChanges([M])}})),R.current.update({controlPosition:A,boundaries:{minWidth:c,minHeight:l,maxWidth:d,maxHeight:u},keepAspectRatio:h,resizeDirection:f,onResizeStart:w,onResize:y,onResizeEnd:x,shouldResize:m}),()=>{R.current?.destroy()}},[A,c,l,d,u,h,w,y,x,m]);const V=A.split("-");return a.jsx("div",{className:he(["react-flow__resize-control","nodrag",...V,n,s]),ref:E,style:{...o,scale:S,...r&&{[j?"backgroundColor":"borderColor"]:r}},children:i})}const ky=k.memo(Ny);function bn({anchor:e,excerpt:t,children:n,className:s}){const o=k.useId(),i=X(f=>f.openAnchorRef),r=X(f=>f.openAnchorId),c=i===e.ref&&(r===null||r===o),l=X(f=>f.setOpenAnchor),{threads:d,status:u,orphaned:h}=oa(e.ref);return a.jsxs(Pt,{modal:!1,open:c,onOpenChange:f=>l(f?e.ref:null,f?o:null),children:[a.jsx(po,{asChild:!0,children:a.jsxs("span",{"data-anchor-ref":e.ref,"data-commentable":"",className:se("group relative block",s),children:[n,a.jsx("button",{type:"button",onClick:f=>{f.stopPropagation(),l(c?null:e.ref,o)},title:`Comment on ${e.ref}`,className:se("absolute right-1 top-1 z-10 inline-flex h-5 w-5 items-center justify-center rounded-md border bg-card text-muted-foreground shadow-sm transition-opacity hover:text-primary",c?"opacity-100":"opacity-40 group-hover:opacity-100"),children:a.jsx(lf,{className:"h-3 w-3"})}),d.length>0&&a.jsx(lu,{count:d.length,status:u,orphaned:h,onClick:()=>l(c?null:e.ref,o),className:"absolute -right-1.5 -top-1.5 z-10"})]})}),a.jsx(Ot,{onInteractOutside:f=>f.preventDefault(),className:"max-h-[var(--radix-popover-content-available-height)] overflow-y-auto",children:a.jsx(mo,{anchor:e,excerpt:t,threads:d,onClose:()=>l(null)})})]})}const jy="/assets/elk-worker.min-C9JGDOE-.js";let Ii;function Ey(){return Ii??=du(async()=>{const{default:e}=await import("./elk-api-D2xgMJvi.js").then(t=>t.e);return{default:e}},__vite__mapDeps([0,1,2])).then(({default:e})=>new e({workerUrl:jy})),Ii}const _i={"elk.algorithm":"layered","elk.direction":"RIGHT","elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.layered.spacing.nodeNodeBetweenLayers":"70","elk.spacing.nodeNode":"44","elk.spacing.componentComponent":"70","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.padding":"[top=34,left=14,bottom=14,right=14]"},Cy=160,Sy=88;async function ss(e,t){if(e.length===0)return e;const n=new Map,s=new Set;for(const d of e)d.parentId&&s.add(d.parentId);for(const d of e){const u=d.type==="classNode"||d.type==="coreNode"||d.type==="moduleNode"||d.type==="group"&&!s.has(d.id),h=typeof d.style?.width=="number"?d.style.width:void 0,f=typeof d.style?.height=="number"?d.style.height:void 0;n.set(d.id,{id:d.id,...u?{width:h??d.measured?.width??Cy,height:f??d.measured?.height??Sy}:{layoutOptions:_i},children:[]})}const o=[];for(const d of e){const u=n.get(d.id);d.parentId&&n.has(d.parentId)?n.get(d.parentId).children.push(u):o.push(u)}const i={id:"root",layoutOptions:_i,children:o,edges:t.map(d=>({id:d.id,sources:[d.source],targets:[d.target]}))};let r;try{r=await(await Ey()).layout(i)}catch{return e}const c=new Map,l=d=>{c.set(d.id,{x:d.x??0,y:d.y??0,w:d.width??0,h:d.height??0}),d.children?.forEach(l)};return r.children?.forEach(l),e.map(d=>{const u=c.get(d.id);if(!u)return d;const h={...d,position:{x:u.x,y:u.y}};return d.type==="group"&&(h.style={...d.style,width:u.w,height:u.h}),h})}const Iy=32;function os(e){const t=new Map;for(const s of e){if(s.type!=="floating"||s.source===s.target)continue;const[o,i]=[s.source,s.target].sort(),r=`${o}\0${i}`,c=t.get(r);c?c.push(s):t.set(r,[s])}const n=new Map;for(const s of t.values()){if(s.length<2)continue;const o=[...s].sort((r,c)=>{const l=String(r.data?.label??r.data?.edgeClass??""),d=String(c.data?.label??c.data?.edgeClass??"");return l.localeCompare(d)||r.id.localeCompare(c.id)}),i=(o.length-1)/2;o.forEach((r,c)=>{const l=(c-i)*Iy,d=r.source<r.target?1:-1;n.set(r.id,{parallelCount:o.length,parallelOffset:l*d})})}return e.map(s=>{const o=n.get(s.id);return o?{...s,data:{...s.data,...o}}:s})}function Mi(e,t){const n=(e.measured.width??0)/2,s=(e.measured.height??0)/2,o=e.internals.positionAbsolute,i=t.internals.positionAbsolute,r=o.x+n,c=o.y+s,l=i.x+(t.measured.width??0)/2,d=i.y+(t.measured.height??0)/2,u=(l-r)/(2*n)-(d-c)/(2*s),h=(l-r)/(2*n)+(d-c)/(2*s),f=1/(Math.abs(u)+Math.abs(h)||1),p=f*u,m=f*h;return{x:n*(p+m)+r,y:s*(-p+m)+c}}function $i(e,t){const n=e.internals.positionAbsolute,s=Math.round(n.x),o=Math.round(n.y),i=Math.round(t.x),r=Math.round(t.y);return i<=s+1?q.Left:i>=s+(e.measured.width??0)-1?q.Right:r<=o+1?q.Top:q.Bottom}function _y(e,t){const n=Mi(e,t),s=Mi(t,e);return{sx:n.x,sy:n.y,tx:s.x,ty:s.y,sourcePos:$i(e,n),targetPos:$i(t,s)}}function My({sx:e,sy:t,tx:n,ty:s,offset:o}){const i=n-e,r=s-t,c=Math.hypot(i,r)||1,l=-r/c,d=i/c,u=(e+n)/2+l*o*2,h=(t+s)/2+d*o*2,f=e*.25+u*.5+n*.25,p=t*.25+h*.5+s*.25;return[`M ${e},${t} Q ${u},${h} ${n},${s}`,f,p]}function $y({id:e,source:t,target:n,markerStart:s,markerEnd:o,style:i,data:r}){const c=ns(t),l=ns(n);if(!c||!l)return null;const{sx:d,sy:u,tx:h,ty:f,sourcePos:p,targetPos:m}=_y(c,l),w=r,[y,x,b]=(w?.parallelCount??1)>1?My({sx:d,sy:u,tx:h,ty:f,offset:w?.parallelOffset??0}):zo({sourceX:d,sourceY:u,sourcePosition:p,targetX:h,targetY:f,targetPosition:m,curvature:.25}),g=w?.label,v=w?.selected===!0,E=v?"var(--color-primary)":i?.stroke??"var(--color-muted-foreground)",j=v?{...i,stroke:E,strokeWidth:3}:i;return a.jsxs(a.Fragment,{children:[a.jsx(Vt,{id:e,path:y,markerStart:s,markerEnd:o,style:j,interactionWidth:18}),g&&a.jsx(U0,{children:a.jsx("div",{className:"absolute font-mono font-extrabold text-[9px] px-1 rounded pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${x}px, ${b}px)`,color:E,background:"oklch(0.17 0.01 270)"},children:g})})]})}function Ry({id:e,source:t,target:n,style:s}){const o=ns(t),i=ns(n);if(!o||!i)return null;const r=o.internals.positionAbsolute,c=i.internals.positionAbsolute,l=o.measured.width??0,d=o.measured.height??0,u=i.measured.width??0,h=i.measured.height??0,f=c.x>=r.x,[p]=es({sourceX:f?r.x+l:r.x,sourceY:r.y+d/2,sourcePosition:f?q.Right:q.Left,targetX:f?c.x:c.x+u,targetY:c.y+h/2,targetPosition:f?q.Left:q.Right,borderRadius:16});return a.jsx(Vt,{id:e,path:p,style:s,interactionWidth:18})}const Uo={floating:$y,tree:Ry};function Es({domainId:e,anchorRef:t,kind:n,excerpt:s,className:o}){const{threads:i,status:r,orphaned:c}=oa(t,e),l=k.useId(),d=X(m=>m.openAnchorRef),u=X(m=>m.openAnchorId),h=e?`${e}::${t}`:t,f=d===h&&(u===null||u===l),p=X(m=>m.setOpenAnchor);return i.length===0?null:a.jsxs(Pt,{modal:!1,open:f,onOpenChange:m=>p(m?h:null,m?l:null),children:[a.jsx(po,{asChild:!0,children:a.jsxs("button",{type:"button",title:"View comments",onClick:m=>{m.stopPropagation(),p(f?null:h,l)},className:se("nodrag nopan absolute right-1 top-1 z-30 flex h-[18px] min-w-[18px] items-center justify-center gap-0.5 rounded-full px-1 text-[10px] font-bold shadow-md ring-2 ring-card hover:brightness-110",c?"bg-destructive text-white":r==="open"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground",o),children:[a.jsx(ra,{className:"h-2.5 w-2.5"}),i.length]})}),a.jsx(Ot,{side:"top",align:"end",className:"w-80",children:a.jsx(mo,{domainId:e,anchor:{ref:t,kind:n},excerpt:s,threads:i,onClose:()=>p(null)})})]})}function Ay(e){const t=e.trim();if(!t.startsWith("<svg"))return null;let n=t;return n=n.replace(/<script[\s\S]*?<\/script>/gi,""),n=n.replace(/<foreignObject[\s\S]*?<\/foreignObject>/gi,""),n=n.replace(/\son\w+\s*=\s*"[^"]*"/gi,""),n=n.replace(/\son\w+\s*=\s*'[^']*'/gi,""),n=n.replace(/(href|xlink:href)\s*=\s*"(?!#)[^"]*"/gi,""),n=n.replace(/<!--[\s\S]*?-->/g,""),n=n.replace(/<svg\b([^>]*)>/i,(s,o)=>{let i=o.replace(/\swidth\s*=\s*"[^"]*"/i,"").replace(/\sheight\s*=\s*"[^"]*"/i,"");return/viewBox=/i.test(i)||(i+=' viewBox="0 0 24 24"'),`<svg${i} width="100%" height="100%" preserveAspectRatio="xMidYMid meet">`}),n}function we({svg:e,className:t}){const n=k.useMemo(()=>e?Ay(e):null,[e]);return n?a.jsx("span",{className:se("inline-flex shrink-0 items-center justify-center [&>svg]:h-full [&>svg]:w-full",t),dangerouslySetInnerHTML:{__html:n}}):null}const He=e=>`core.node.${e}`,Ko=e=>e.split("/").filter(Boolean).pop()??e;function Dt(e){const t=e.data.name??e.data.title;return typeof t=="string"&&t?t:Ko(e.path)}function Qo(e){const t=[...new Set(e.nodes.map(n=>n.className))].sort();return new Map(t.map((n,s)=>[n,uu(s)]))}const rs=e=>e==null?"—":typeof e=="string"?e:Array.isArray(e)?e.map(rs).join(", "):JSON.stringify(e);function Dy(e,t=2){const n=Dt(e);return Object.entries(e.data).filter(([,s])=>rs(s)!==n).slice(0,t).map(([s,o])=>[s,rs(o)])}function Jo(e,t){return e.ir?.classes?.[t]?.icon}function cl({count:e}){const t=X(o=>o.canvasMode),n=X(o=>o.setCanvasMode),s=t==="core";return a.jsxs(Fe,{size:"xs",variant:s?"default":"outline",onClick:()=>n(s?"schema":"core"),"aria-pressed":s,title:s?"Back to the schema graph":"Show core (genesis) data",children:[s?a.jsx(fu,{className:"h-3.5 w-3.5"}):a.jsx(ia,{className:"h-3.5 w-3.5"}),s?"Schema":"Core",!s&&e!==void 0&&a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:e})]})}function Py({data:e}){const t=e,n=t.className==="Folder";return a.jsxs("div",{className:se("relative rounded-lg border bg-card shadow-sm w-[184px] transition-shadow",t.selected?"ring-2 ring-primary":"hover:shadow-md"),style:{borderLeft:`3px solid oklch(0.72 0.15 ${t.hue})`},children:[!t.virtual&&a.jsx(Es,{anchorRef:He(t.path),kind:"section",excerpt:`${t.title} (${t.className})`}),a.jsx(je,{type:"target",position:q.Top,className:"!opacity-0"}),a.jsxs("div",{className:"px-2.5 py-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{style:{color:`oklch(0.82 0.14 ${t.hue})`},className:"shrink-0",children:t.icon?a.jsx(we,{svg:t.icon,className:"h-5 w-5"}):n?a.jsx(pn,{className:"h-5 w-5"}):a.jsx(Pe,{className:"h-5 w-5"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-[13px] font-extrabold truncate leading-tight",children:t.title}),a.jsx("div",{className:"text-[10px] font-mono text-muted-foreground/70 truncate leading-tight",children:t.className})]})]}),t.fields.length>0&&a.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:t.fields.map(([s,o])=>a.jsxs("div",{className:"flex items-baseline gap-1 text-[10px] leading-tight",children:[a.jsx("span",{className:"font-mono text-muted-foreground/60 shrink-0",children:s}),a.jsx("span",{className:"truncate text-foreground/80",children:o})]},s))})]}),a.jsx(je,{type:"source",position:q.Bottom,className:"!opacity-0"})]})}const Oy={coreNode:Py};function Ty(e,t,n){const s=new Set(e.nodes.map(c=>He(c.path))),o=e.nodes.map(c=>{const l=Dy(c);return{id:He(c.path),type:"coreNode",position:{x:0,y:0},data:{path:c.path,className:c.className,title:Dt(c),hue:n.get(c.className)??264,icon:Jo(t,c.className),fields:l,selected:!1},style:{width:184,height:50+l.length*15}}}),i=`/:${e.domain}`;for(const c of new Set(e.edges.flatMap(l=>[l.from,l.to]))){const l=He(c);if(s.has(l))continue;const d=c===i;o.push({id:l,type:"coreNode",position:{x:0,y:0},selectable:!1,focusable:!1,data:{path:c,className:d?"Domain":"External",title:d?e.domain:Ko(c),hue:d?210:264,fields:[],selected:!1,virtual:!0},style:{width:184,height:50}}),s.add(l)}const r=[];for(const c of e.nodes){if(!c.parent)continue;const l=He(c.parent),d=He(c.path);!s.has(l)||!s.has(d)||r.push({id:`core.struct.${c.path}`,source:l,target:d,type:"tree",data:{structural:!0},style:{stroke:"oklch(0.5 0.02 264)",strokeWidth:1.4,strokeDasharray:"4 4"}})}for(const c of e.edges){const l=He(c.from),d=He(c.to);if(!s.has(l)||!s.has(d))continue;const u="oklch(0.72 0.16 35)";r.push({id:`core.edge.${c.from}__${c.edgeName}__${c.to}`,source:l,target:d,type:"floating",data:{label:c.edgeName},markerEnd:{type:Je.ArrowClosed,color:u,width:16,height:16},style:{stroke:u,strokeWidth:2}})}return{nodes:o,edges:r}}function zy({core:e,bundle:t,selectedPath:n,onSelect:s}){const{fitView:o}=Ht(),i=X(j=>j.setOpenAnchor),r=k.useMemo(()=>Qo(e),[e]),c=k.useMemo(()=>Ty(e,t,r),[e,t,r]),[l,d]=k.useState([]),[u,h]=k.useState([]);k.useEffect(()=>{let j=!1;return ss(c.nodes,c.edges).then(S=>{j||(d(S),h(os(c.edges)),requestAnimationFrame(()=>o({padding:.2,duration:400})))}),()=>{j=!0}},[c,o]);const f=k.useCallback(j=>d(S=>Ns(j,S)),[]),p=k.useCallback(j=>h(S=>ks(j,S)),[]),[m,w]=k.useState(!0),[y,x]=k.useState(!0),b=k.useMemo(()=>l.filter(j=>{const S=j.data;return!(!m&&S.className==="Folder"||!y&&S.virtual)}),[l,y,m]),g=k.useMemo(()=>new Set(b.map(j=>j.id)),[b]),v=k.useMemo(()=>b.map(j=>{const S=j.data.path===n;return j.data.selected===S?j:{...j,data:{...j.data,selected:S}}}),[b,n]),E=k.useMemo(()=>u.filter(j=>!g.has(j.source)||!g.has(j.target)?!1:j.type==="tree"?m:y),[u,g,m,y]);return a.jsxs(Xo,{nodes:v,edges:E,nodeTypes:Oy,edgeTypes:Uo,onNodesChange:f,onEdgesChange:p,onNodeClick:(j,S)=>{const R=S.data;R.virtual||s(R.path)},onPaneClick:()=>{s(null),i(null)},minZoom:.15,nodesConnectable:!1,proOptions:{hideAttribution:!0},children:[a.jsx(qo,{gap:18,size:1,color:"oklch(0.3 0.01 270)"}),a.jsx(Zo,{className:"!bg-card !border !border-border [&_button]:!bg-card [&_button]:!border-border [&_button]:!fill-foreground",showInteractive:!1}),a.jsx(Go,{pannable:!0,zoomable:!0,className:"!bg-card !border !border-border",nodeColor:j=>`oklch(0.6 0.13 ${j.data.hue})`,nodeStrokeWidth:0,maskColor:"oklch(0.17 0.01 270 / 0.7)"}),a.jsxs(rt,{position:"top-right",className:"flex gap-1.5",children:[a.jsxs(Fe,{size:"xs",variant:m?"default":"outline",onClick:()=>w(j=>!j),"aria-pressed":m,title:"Folders & the parent→child tree — toggle to focus on the semantic graph alone",children:[a.jsx(sf,{className:"h-3.5 w-3.5"})," Structure"]}),a.jsxs(Fe,{size:"xs",variant:y?"default":"outline",onClick:()=>x(j=>!j),"aria-pressed":y,title:"Typed (semantic) edges — toggle to focus on the tree/organization alone",children:[a.jsx(Tt,{className:"h-3.5 w-3.5"})," Semantics"]}),a.jsx(cl,{})]})]})}function Ly(e){const t=new Set(e.nodes.map(i=>i.path)),n=new Map,s=[];for(const i of e.nodes)if(i.parent&&t.has(i.parent)){const r=n.get(i.parent)??[];r.push(i),n.set(i.parent,r)}else s.push(i);const o=i=>({node:i,children:(n.get(i.path)??[]).map(o)});return s.map(o)}function ll({item:e,depth:t,bundle:n,hues:s,selectedPath:o,onSelect:i}){const[r,c]=k.useState(!0),l=e.node,d=e.children.length>0,u=o===l.path,h=s.get(l.className)??264,f=Jo(n,l.className),p=l.className==="Folder";return a.jsxs("div",{children:[a.jsxs("div",{className:se("group/row flex items-center gap-0.5 pr-2 rounded-md hover:bg-accent/50",u&&"bg-accent text-accent-foreground"),style:{paddingLeft:6+t*12},children:[d?a.jsx("button",{type:"button",onClick:()=>c(m=>!m),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-white/5",title:r?"Collapse":"Expand",children:r?a.jsx(ds,{className:"h-3 w-3"}):a.jsx(us,{className:"h-3 w-3"})}):a.jsx("span",{className:"w-4 shrink-0"}),a.jsx(bn,{anchor:{ref:He(l.path),kind:"section"},excerpt:`${Dt(l)} (${l.className})`,className:"flex-1 min-w-0",children:a.jsxs("button",{type:"button",onClick:()=>i(l.path),className:"flex w-full items-center gap-1.5 py-1 text-left min-w-0",children:[a.jsx("span",{style:{color:`oklch(0.8 0.13 ${h})`},className:"shrink-0",children:f?a.jsx(we,{svg:f,className:"h-4 w-4"}):p?a.jsx(pn,{className:"h-3.5 w-3.5"}):a.jsx(Pe,{className:"h-3.5 w-3.5"})}),a.jsx("span",{className:"truncate font-bold",children:Dt(l)}),a.jsx("span",{className:"ml-auto text-[10px] font-mono text-muted-foreground/50 shrink-0",children:l.className})]})})]}),r&&d&&a.jsx("div",{children:e.children.map(m=>a.jsx(ll,{item:m,depth:t+1,bundle:n,hues:s,selectedPath:o,onSelect:i},m.node.path))})]})}function Hy({core:e,bundle:t,selectedPath:n,onSelect:s}){const o=k.useMemo(()=>Qo(e),[e]),i=k.useMemo(()=>Ly(e),[e]);return a.jsxs("div",{className:"text-sm py-2",children:[a.jsxs("div",{className:"flex items-center gap-1.5 px-3 pb-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[a.jsx(ia,{className:"h-3.5 w-3.5"})," Core",a.jsx("span",{className:"ml-auto tabular-nums text-muted-foreground/50",children:e.nodes.length})]}),i.length===0?a.jsx("p",{className:"px-3 pt-2 text-[12px] text-muted-foreground/60",children:e.error?e.error.message:"This domain defines no core (genesis) data."}):i.map(r=>a.jsx(ll,{item:r,depth:0,bundle:t,hues:o,selectedPath:n,onSelect:s},r.node.path))]})}function Vy({core:e,bundle:t,selectedPath:n}){const s=k.useMemo(()=>e.nodes.find(u=>u.path===n)??null,[e,n]),o=k.useMemo(()=>Qo(e),[e]);if(!s)return a.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground/70",children:"Select a core node to see what's set on it."});const i=o.get(s.className)??264,r=Jo(t,s.className),c=s.className==="Folder",l=Object.entries(s.data),d=e.edges.filter(u=>u.from===s.path||u.to===s.path);return a.jsxs("div",{className:"h-full overflow-y-auto",children:[a.jsx(bn,{anchor:{ref:He(s.path),kind:"section"},excerpt:`${Dt(s)} (${s.className})`,className:"block",children:a.jsxs("div",{className:"flex items-center gap-2.5 border-b px-4 py-3",children:[a.jsx("span",{style:{color:`oklch(0.82 0.14 ${i})`},className:"shrink-0",children:r?a.jsx(we,{svg:r,className:"h-7 w-7"}):c?a.jsx(pn,{className:"h-6 w-6"}):a.jsx(Pe,{className:"h-6 w-6"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-base font-extrabold truncate",children:Dt(s)}),a.jsx("div",{className:"text-[11px] font-mono text-muted-foreground/70",children:s.className})]})]})}),a.jsxs("div",{className:"px-4 py-3",children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:"Path"}),a.jsx("div",{className:"mt-1 break-all font-mono text-[11px] text-foreground/80",children:s.path})]}),a.jsxs("div",{className:"px-4 pb-3",children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:"Data"}),l.length===0?a.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground/60",children:"No fields set."}):a.jsx("div",{className:"mt-1.5 flex flex-col gap-1.5",children:l.map(([u,h])=>a.jsxs("div",{className:"flex flex-col gap-0.5 rounded-md border bg-card/40 px-2.5 py-1.5",children:[a.jsx("span",{className:"font-mono text-[11px] text-muted-foreground/70",children:u}),a.jsx("span",{className:"break-words text-[13px] text-foreground/90",children:rs(h)})]},u))})]}),d.length>0&&a.jsxs("div",{className:"px-4 pb-4",children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:"Edges"}),a.jsx("div",{className:"mt-1.5 flex flex-col gap-1",children:d.map((u,h)=>{const f=u.from===s.path,p=f?u.to:u.from;return a.jsxs("div",{className:"flex items-center gap-1.5 text-[12px]",children:[a.jsx(Tt,{className:"h-3.5 w-3.5 shrink-0 text-amber-400"}),a.jsx("span",{className:"font-mono text-amber-300",children:u.edgeName}),a.jsx("span",{className:"text-muted-foreground/60",children:f?"→":"←"}),a.jsx("span",{className:"truncate text-foreground/80",title:p,children:Ko(p)})]},`${u.edgeName}-${h}`)})})]})]})}const Ri=new Set(["Node","Edge"]),so="kernel.astrale.ai";function dl(e){return e.kind==="interface"}function ul(e){return`${e.origin}:${e.kind}.${e.name}`}function Ai(e){return typeof e=="string"?`legacy:${e}`:ul(e)}function Fy(e){return typeof e=="string"?e:e.name}function fl(e){return e.extendsRefs!==void 0?e.extendsRefs.filter(dl):e.extends??[]}function Di(e){return typeof e=="string"?Ri.has(e):e.origin===so&&e.kind==="interface"&&Ri.has(e.name)}function Nn(e,t){const n=e.ir;if(n){if(typeof t=="string")return n.interfaces[t]??e.importedInterfaces?.[t];if(t.kind==="interface")return t.origin===n.domain?n.interfaces[t.name]:n.importedInterfacesByKey?.[ul(t)]}}function hl(e,t){return typeof t!="string"?t.origin===e.ir?.domain?"local":t.origin===so?"kernel":"external":e.ir?.interfaces[t]?"local":e.ir?.imports[t]?.origin===so?"kernel":"external"}function By(e,t){return typeof t!="string"?t.origin===e.ir?.domain?void 0:t.origin:e.ir?.imports[t]?.origin}function pl(e,t,n,s){if(!e.ir)return[];const o=new Set(n),i=new Set,r=new Set,c=[],l=[...t];for(;l.length;){const u=l.shift(),h=Ai(u),f=Fy(u);if(r.has(h)||Di(u))continue;r.add(h);const p=Nn(e,u);if(!p)continue;for(const y of fl(p))!Di(y)&&!r.has(Ai(y))&&l.push(y);const m=Object.entries(p.properties??{}).filter(([y])=>!n.has(y)&&(typeof u!="string"||!o.has(y))).map(([y,x])=>[y,x,p.required?!p.required.includes(y):void 0]),w=Object.entries(p.methods??{}).filter(([y])=>typeof u!="string"||!i.has(y)).map(([y,x])=>({name:y,method:x,overridden:s.has(y)}));if(typeof u=="string"){for(const[y]of m)o.add(y);for(const y of w)i.add(y.name)}m.length===0&&w.length===0||c.push({iface:f,...typeof u=="string"?{}:{ref:u},tier:hl(e,u),origin:By(e,u),navigable:!0,props:m,methods:w})}const d={local:0,external:1,kernel:2};return c.sort((u,h)=>d[u.tier]-d[h.tier])}function Wy(e,t){const n=e.ir?.classes[t];return n?pl(e,n.implementsRefs!==void 0?n.implementsRefs.filter(dl):n.implements??[],new Set(Object.keys(n.properties??{})),new Set(Object.keys(n.methods??{}))):[]}function Yy(e,t){const n=Nn(e,t);return n?pl(e,fl(n),new Set(Object.keys(n.properties??{})),new Set(Object.keys(n.methods??{}))):[]}function Xy(e){return e.reduce((t,n)=>t+n.props.length+n.methods.length,0)}function qy({domainId:e,view:t,open:n,onOpenChange:s}){const o=hu(e,t.slug,n),i=o.data,[r,c]=k.useState(""),[l,d]=k.useState(0),[u,h]=k.useState(!1),[f,p]=k.useState({phase:"idle"}),m=k.useRef("");k.useEffect(()=>{if(!n){m.current="",c(""),p({phase:"idle"});return}if(!i)return;const b=`${e}:${t.slug}:${i.instance??"none"}`;m.current!==b&&(m.current=b,c(i.targets.selected?.id??""))},[e,n,i,t.slug]);const w=!!i&&(!i.targetRequired||i.targets.items.some(b=>b.id===r)),y=n&&!u&&!!i?.instance&&w;k.useEffect(()=>{if(!y){p({phase:"idle"});return}let b=!1,g=null;return p({phase:"launching"}),_e.launchView(e,t.slug,r?{targetId:r}:{}).then(v=>{v.status==="ready"?(g=v.sessionId,b?_e.closeViewSession(e,v.sessionId):p({phase:"ready",session:v})):b||p({phase:"error",reason:v.reason})}).catch(v=>{b||p({phase:"error",reason:v instanceof Error?v.message:String(v)})}),()=>{b=!0,g&&_e.closeViewSession(e,g)}},[l,e,y,i?.instance,r,t.slug]),k.useEffect(()=>{if(f.phase!=="ready")return;const b=()=>{const g=`/api/domain/${encodeURIComponent(e)}/views/sessions/close`;navigator.sendBeacon(g,new Blob([JSON.stringify({sessionId:f.session.sessionId})],{type:"application/json"}))};return window.addEventListener("pagehide",b),()=>window.removeEventListener("pagehide",b)},[e,f]);const x=async()=>{if(!u){h(!0),p({phase:"idle"});try{await o.refetch(),d(b=>b+1)}catch(b){p({phase:"error",reason:b instanceof Error?b.message:String(b)})}finally{h(!1)}}};return a.jsx(pu,{open:n,onOpenChange:s,children:a.jsxs(mu,{className:"grid h-[90vh] w-[95vw] max-w-[1500px] grid-rows-[auto_auto_1fr] gap-0 overflow-hidden rounded-2xl p-0",children:[a.jsxs("header",{className:"flex min-w-0 items-center gap-3 border-b bg-card/95 px-4 py-3 pr-12",children:[a.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-xl bg-sky-500/12 text-sky-400",children:a.jsx(xr,{className:"h-[18px] w-[18px]"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(gu,{className:"truncate text-sm font-semibold",children:t.slug}),a.jsxs("code",{className:"rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground",children:["view.",t.slug]})]}),a.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:t.description??"Domain view preview"})]}),a.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[f.phase==="ready"&&a.jsxs("a",{href:f.session.pageUrl,target:"_blank",rel:"noreferrer",className:"inline-flex h-8 items-center gap-1.5 rounded-lg px-2.5 text-[11px] text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:[a.jsx(xu,{className:"h-3.5 w-3.5"})," Open separately"]}),a.jsx("button",{type:"button",onClick:()=>{x()},disabled:u,title:"Retry the CLI-resolved View session",className:"grid h-8 w-8 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-30",children:a.jsx(yu,{className:se("h-3.5 w-3.5",u&&"animate-spin")})})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b bg-muted/15 px-4 py-3",children:[i?.targetRequired?a.jsx(Zy,{result:i.targets,value:r,onChange:c,instance:i.instance}):a.jsxs("div",{className:"inline-flex h-9 items-center gap-2 rounded-xl border bg-background/60 px-3 text-[11px]",children:[a.jsx(aa,{className:"h-3.5 w-3.5 text-emerald-400"}),a.jsx("span",{className:"font-medium",children:"Standalone view"}),a.jsx("span",{className:"text-muted-foreground",children:"No target required"})]}),a.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[a.jsxs("div",{className:se("inline-flex h-9 items-center gap-2 rounded-xl border px-3 text-[10px]",i?.instance?"border-emerald-500/20 bg-emerald-500/8 text-emerald-200":"bg-background/60 text-muted-foreground"),title:"The Astrale CLI resolves the verified View placement installed on this instance.",children:[i?.instance?a.jsxs("span",{className:"relative flex h-2 w-2",children:[a.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-30"}),a.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-emerald-400"})]}):i?a.jsx(ko,{className:"h-3 w-3 text-amber-400"}):a.jsx(Bs,{className:"h-3 w-3 animate-spin"}),a.jsx(xr,{className:"h-3.5 w-3.5"}),a.jsx("span",{className:"font-medium",children:"CLI-resolved View"})]}),a.jsxs("div",{className:"h-9 rounded-xl border bg-background/60 px-3 py-1.5 text-right text-[9px] uppercase leading-tight tracking-wider text-muted-foreground",children:[a.jsx("div",{children:"Data instance"}),a.jsx("div",{className:"max-w-40 truncate text-[10px] font-medium normal-case tracking-normal text-foreground",children:i?.instance??"not selected"})]})]})]}),a.jsx("main",{className:"relative min-h-0 overflow-hidden bg-[#0d0d11]",children:f.phase==="ready"?a.jsx("iframe",{src:f.session.pageUrl,title:`${t.slug} preview`,className:"h-full w-full border-0 bg-white",allow:"clipboard-read; clipboard-write"},f.session.sessionId):a.jsx(Uy,{loading:o.isLoading||u||f.phase==="launching",runtimeError:o.isError,runtime:i,targetId:r,sessionError:f.phase==="error"?f.reason:void 0,onRetry:()=>{x()}})})]})})}function Zy({result:e,value:t,onChange:n,instance:s}){const[o,i]=k.useState(!1),[r,c]=k.useState(""),l=e.items.find(u=>u.id===t)??null,d=k.useMemo(()=>{const u=r.trim().toLocaleLowerCase();return u?e.items.filter(h=>[h.label,h.description,h.className,h.status,h.id].filter(Boolean).some(f=>f.toLocaleLowerCase().includes(u))):e.items},[e.items,r]);return a.jsxs(Pt,{open:o,onOpenChange:u=>{i(u),u||c("")},children:[a.jsx(go,{asChild:!0,children:a.jsxs("button",{type:"button",className:se("flex h-9 min-w-64 max-w-[28rem] items-center gap-2 rounded-xl border bg-background/60 px-3 text-left transition-colors hover:bg-accent/40",e.stale&&!l&&"border-amber-500/40"),children:[a.jsx("span",{className:se("h-2 w-2 shrink-0 rounded-full",l?"bg-emerald-400":e.stale?"bg-amber-400":"bg-muted-foreground/30")}),a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"block text-[9px] uppercase tracking-wider text-muted-foreground",children:"Target"}),a.jsx("span",{className:"block truncate text-[11px] font-medium",children:l?.label??e.stale?.label??"Select a target"})]}),a.jsx("span",{className:"text-[10px] text-muted-foreground",children:e.items.length}),a.jsx(wu,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),a.jsxs(Ot,{side:"bottom",align:"start",className:"z-[70] w-[28rem] p-0",children:[a.jsxs("div",{className:"flex items-center gap-2 border-b px-3 py-2.5",children:[a.jsx(ca,{className:"h-3.5 w-3.5 text-muted-foreground"}),a.jsx("input",{autoFocus:!0,value:r,onChange:u=>c(u.target.value),placeholder:"Search visible targets…",className:"min-w-0 flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground/60"}),a.jsx("span",{className:"text-[9px] uppercase tracking-wider text-muted-foreground",children:s??"no instance"})]}),e.stale&&a.jsxs("div",{className:"m-2 flex gap-2 rounded-lg border border-amber-500/25 bg-amber-500/8 p-2.5 text-[11px] text-amber-200",children:[a.jsx(ko,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),a.jsxs("span",{children:[a.jsx("strong",{children:e.stale.label})," was remembered, but it was deleted or is no longer visible. Pick a replacement."]})]}),a.jsx("div",{className:"max-h-80 overflow-y-auto p-1.5",children:e.status==="unavailable"?a.jsx(Pi,{children:e.reason??"Targets could not be queried."}):d.length===0?a.jsx(Pi,{children:e.items.length===0?"No eligible targets are visible.":"No matches."}):d.map(u=>a.jsx(Gy,{item:u,selected:u.id===t,onClick:()=>{n(u.id),i(!1)}},u.id))}),e.truncated&&a.jsx("div",{className:"border-t px-3 py-2 text-[10px] text-muted-foreground",children:"Showing the first 200 visible targets per class."})]})]})}function Gy({item:e,selected:t,onClick:n}){return a.jsxs("button",{type:"button",onClick:n,className:se("flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-accent",t&&"bg-accent/70"),children:[a.jsx("span",{className:"grid h-7 w-7 shrink-0 place-items-center rounded-lg bg-sky-500/10 text-[10px] font-semibold text-sky-300",children:e.className.slice(0,2).toUpperCase()}),a.jsxs("span",{className:"min-w-0 flex-1",children:[a.jsx("span",{className:"block truncate text-xs font-medium",children:e.label}),a.jsx("span",{className:"block truncate text-[10px] text-muted-foreground",children:[e.className,e.description,e.status].filter(Boolean).join(" · ")})]}),a.jsx("code",{className:"text-[9px] text-muted-foreground/50",children:e.id.slice(0,8)}),t&&a.jsx(aa,{className:"h-3.5 w-3.5 text-primary"})]})}function Pi({children:e}){return a.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-muted-foreground",children:e})}function Uy({loading:e,runtimeError:t,runtime:n,targetId:s,sessionError:o,onRetry:i}){if(e)return a.jsx(Nt,{icon:a.jsx(Bs,{className:"animate-spin"}),title:"Resolving installed View",children:"The Astrale CLI is resolving the View and connecting it to the active data instance."});if(t)return a.jsx(Nt,{icon:a.jsx(yr,{}),title:"The Studio runtime did not respond",action:i,children:"Retry the View session. The schema canvas is unaffected."});if(!n?.instance)return a.jsx(Nt,{icon:a.jsx(yr,{}),title:"Choose an Astrale instance",children:"The installed View reads data from the active instance in the Studio header."});if(n.targetRequired&&!n.targets.items.some(r=>r.id===s)){const r=n.targets.stale;return a.jsx(Nt,{icon:a.jsx(ca,{}),title:r?"The remembered target is gone":"Choose what this view should open",children:r?`${r.label} was deleted or is no longer visible. Use the target selector above.`:n.targets.items.length?`${n.targets.items.length} visible candidate${n.targets.items.length===1?"":"s"} found on ${n.instance}.`:n.targets.reason||"No eligible targets are currently visible."})}return o?a.jsx(Nt,{icon:a.jsx(ko,{}),title:"The view could not be opened",action:i,children:o}):a.jsx(Nt,{icon:a.jsx(Bs,{className:"animate-spin"}),title:"Opening view session",children:"Studio is preparing the authenticated CLI-owned Shell session."})}function Nt({icon:e,title:t,children:n,action:s}){return a.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-8 text-center text-zinc-200",children:[a.jsx("div",{className:"mb-3 grid h-11 w-11 place-items-center rounded-2xl border border-white/10 bg-white/5 text-zinc-400 [&_svg]:h-5 [&_svg]:w-5",children:e}),a.jsx("h2",{className:"text-sm font-semibold",children:t}),a.jsx("div",{className:"mt-1.5 max-w-md text-[12px] leading-relaxed text-zinc-500",children:n}),s&&a.jsx("button",{type:"button",onClick:s,className:"mt-4 rounded-lg border border-white/10 bg-white/5 px-3 py-1.5 text-[11px] transition-colors hover:bg-white/10",children:"Restart preview"})]})}function Ky({kind:e,className:t}){const n=e==="inline-html"?Nu:e==="spa"?hn:vt;return a.jsx(n,{className:t})}function is({domainId:e,view:t,icon:n}){const[s,o]=k.useState(!1),i=vu(t.drift),r=[t.kind,t.mount,t.auth,t.unbound?"standalone":"targeted"].filter(Boolean).join(" · "),c=`view.${t.slug}`;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{"data-domain-id":e,"data-anchor-ref":c,"data-anchor-excerpt":t.slug,className:"group flex w-full items-center gap-2.5 rounded-lg px-2 py-1.5 transition-colors hover:bg-accent/60",children:[a.jsxs("button",{type:"button",onClick:()=>o(!0),title:"Open live view",className:"flex min-w-0 flex-1 items-center gap-2.5 text-left",children:[a.jsx(ke,{tone:"sky",size:"sm",children:n?a.jsx(we,{svg:n,className:"h-3.5 w-3.5"}):a.jsx(Ky,{kind:t.kind,className:"h-3.5 w-3.5"})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:t.slug}),a.jsx("div",{className:"truncate text-[11px] leading-tight text-muted-foreground/70",children:r})]}),i&&a.jsxs("span",{className:se("inline-flex shrink-0 items-center gap-1 text-[10px] font-medium",i.tone==="warn"?"text-warning":"text-muted-foreground/70"),children:[i.tone==="warn"&&a.jsx(ht,{className:"h-3 w-3"}),i.text]}),a.jsx(bu,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/0 transition-colors group-hover:text-primary"})]}),a.jsx(Lt,{domainId:e,anchorRef:{ref:c,kind:"section",file:t.file},excerpt:t.slug,className:"ml-1"})]}),s&&a.jsx(qy,{domainId:e,view:t,open:s,onOpenChange:o})]})}function Qy({domainId:e,model:t}){const{data:n}=xo(e),s=X(r=>r.selectClass),o=[...t.byClass.keys()].sort(),i=r=>n?.ir?.classes[r]?.icon;return a.jsx(zt,{className:"h-full",children:a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"mb-5 flex items-baseline gap-2 pr-8",children:[a.jsx("h1",{className:"text-base font-semibold",children:"Views"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:t.all.length}),t.hasDrift&&a.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-medium text-warning",children:[a.jsx(ht,{className:"h-3.5 w-3.5"})," drift"]})]}),t.all.length===0&&a.jsx(qt,{icon:a.jsx(hn,{}),title:"No views",hint:"This domain declares no views."}),o.map(r=>{const c=i(r),l=t.byClass.get(r);return a.jsxs("section",{className:"mb-6",children:[a.jsxs("button",{type:"button",onClick:()=>s(`class.${r}`),title:`Open ${r}`,className:"group mb-1.5 flex w-full items-center gap-1.5 px-1 text-left",children:[a.jsx("span",{className:"shrink-0 text-muted-foreground/70",children:c?a.jsx(we,{svg:c,className:"h-4 w-4"}):a.jsx(Pe,{className:"h-4 w-4"})}),a.jsx("span",{className:"text-[13px] font-semibold transition-colors group-hover:text-primary",children:r}),a.jsx("span",{className:"text-[11px] text-muted-foreground/50",children:l.length}),a.jsx(la,{className:"ml-auto h-3.5 w-3.5 text-muted-foreground/0 transition-colors group-hover:text-muted-foreground/60"})]}),a.jsx("div",{className:"flex flex-col gap-0.5",children:l.map(d=>a.jsx(is,{domainId:e,view:d,icon:c},d.slug))})]},r)}),t.unbound.length>0&&a.jsx(Be,{label:"Standalone",hint:"opens without a target",children:a.jsx("div",{className:"flex flex-col gap-0.5",children:t.unbound.map(r=>a.jsx(is,{domainId:e,view:r},r.slug))})}),t.orphanRoutes.length>0&&a.jsx(Be,{label:"Orphan client routes",hint:"no declaring view",children:a.jsx("div",{className:"flex flex-col gap-1",children:t.orphanRoutes.map(r=>a.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-2 py-1.5 text-[12px] text-warning",children:[a.jsx(ht,{className:"h-3.5 w-3.5 shrink-0"}),a.jsx("code",{className:"truncate",children:r})]},r))})})]})})}function ml(){const e=X(n=>n.back);return X(n=>n.selectionHistory.length>0)?a.jsx("div",{className:"px-3 pt-3",children:a.jsxs("button",{type:"button",onClick:()=>e(),title:"Back to previous selection",className:"group inline-flex items-center gap-1 rounded-md px-2 py-1 text-[12px] text-muted-foreground/55 transition-colors hover:bg-accent/50 hover:text-muted-foreground",children:[a.jsx(Ku,{className:"h-3.5 w-3.5 transition-transform group-hover:-translate-x-0.5"}),"Back"]})}):null}function Jy(e){return e.kind==="class"||e.kind==="interface"}function an(e){return e.kind==="interface"}function er(e){return`${e.origin}:${e.kind}.${e.name}`}function ew(e,t){const n=_u(t);if(!n)return;if(n.origin===e.domain)return e.interfaces[n.name]?n:void 0;const s=er(n),o=e.importsByKey?.[s];if(o?.ref&&an(o.ref))return o.ref;const i=e.importedInterfacesByKey?.[s];return i?.ref&&an(i.ref)?i.ref:i?n:void 0}function Oi(e,t,n){return(t!==void 0?t.filter(an):n??[]).map(o=>({name:typeof o=="string"?o:o.name,reference:o,identity:typeof o=="string"?`legacy:${o}`:er(o),tier:hl(e,o),origin:typeof o=="string"?e.ir?.imports[o]?.origin:o.origin===e.ir?.domain?void 0:o.origin,selectionId:fs(o,e.ir?.domain),navigable:Nn(e,o)!==void 0}))}function gl({bundle:e,selected:t}){const n=e.ir,s=X(_=>_.selectClass),{data:o}=ln(),i=yo(e.domainId),r=_=>_?o?.find(D=>D.origin===_)?.icon:void 0;if(!n||!t)return a.jsx("div",{className:"h-full flex items-center justify-center px-6",children:a.jsx(qt,{icon:a.jsx(ku,{}),title:"Nothing selected",hint:"Pick a class, interface, or edge in the graph to see its properties, methods, and handlers."})});if(t.startsWith("module."))return a.jsx(aw,{bundle:e,path:t.slice(7)});const[c,l]=cw(t),d=c==="interface"?ew(n,l):void 0,u=d?.name??l,h=c==="interface"?d?d.origin===n.domain?n.interfaces[u]:void 0:n.interfaces[u]:n.classes[u],f=c==="interface"&&!h?d?Nn(e,d):e.importedInterfaces?.[u]:void 0,p=h??f;if(!p)return a.jsx("div",{className:"h-full flex items-center justify-center px-6",children:a.jsx(qt,{title:"Not found",hint:t})});const m=p.type==="edge",w=c==="interface"?"interface":m?"edge":"class",y=f?.ref&&an(f.ref)?f.ref:d?.origin!==n.domain?d:void 0,x=y?fs(y,n.domain):ju(w,u),b=e.overlay.sourceSpans[x],g=Object.entries(p.properties??{}),v=p.required,E=Object.entries(p.methods??{}),j=p.endpoints??[],S=p,R=p,A=w==="interface"?void 0:Eu(e,u),V=Oi(e,S.implementsRefs!==void 0?A:void 0,S.implements),O=V.filter(_=>_.tier!=="kernel"),z=V.filter(_=>_.tier==="kernel"),M=Oi(e,R.extendsRefs,R.extends),N=w==="interface"?Yy(e,y??u):Wy(e,u),C=w==="interface"?"fuchsia":"violet",I=p.icon,$=w==="interface"?[]:Cu(i,u);return a.jsxs("div",{className:"h-full overflow-y-auto",...wo(x,u),children:[a.jsx(ml,{}),a.jsxs("div",{className:"px-5 py-6 space-y-7",children:[a.jsxs("header",{className:"group space-y-3","data-anchor-ref":x,"data-anchor-excerpt":u,"data-commentable":"",children:[a.jsxs("div",{className:"flex items-start gap-3.5",children:[a.jsx(ke,{tone:C,size:"lg",children:I?a.jsx(we,{svg:I,className:"h-5 w-5"}):a.jsx(Oe,{})}),a.jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("h2",{className:"text-lg font-extrabold tracking-tight truncate",children:u}),w==="interface"&&a.jsx(me,{tone:"fuchsia",children:"interface"}),f&&a.jsx(me,{tone:"outline",children:Vn(y?.origin??n.imports[u]?.origin)}),w==="edge"&&a.jsx(me,{tone:"outline",children:"edge"}),a.jsx(Lt,{anchorRef:{ref:x,kind:"schema",file:b?.file},excerpt:u,className:"ml-auto"})]}),b?.doc&&a.jsx("p",{className:"text-[13px] text-muted-foreground mt-1 leading-relaxed",children:b.doc})]})]}),(O.length>0||z.length>0||M.length>0)&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pl-[3.25rem]",children:[M.map(_=>a.jsx("button",{type:"button",disabled:!_.navigable,onClick:()=>_.navigable?s(_.selectionId):void 0,className:se("rounded-full",_.navigable&&"transition-transform hover:-translate-y-px"),children:a.jsxs(me,{tone:"outline",className:se(_.navigable&&"cursor-pointer hover:bg-accent/70"),children:["extends ",_.name,_.origin?` · ${Vn(_.origin)}`:""]})},`ext-${_.identity}`)),O.map(_=>a.jsx("button",{type:"button",disabled:!_.navigable,onClick:()=>_.navigable?s(_.selectionId):void 0,className:se("rounded-full",_.navigable&&"transition-transform hover:-translate-y-px"),children:a.jsxs(me,{tone:"fuchsia",className:se(_.navigable&&"cursor-pointer hover:bg-fuchsia-500/20"),children:[a.jsx(Oe,{className:"h-3 w-3"})," ",_.name,_.origin?` · ${Vn(_.origin)}`:""]})},_.identity)),z.length>0&&a.jsxs(dn,{openDelay:80,children:[a.jsx(un,{asChild:!0,children:a.jsx("button",{type:"button",className:"rounded-full",children:a.jsxs(me,{tone:"default",className:"cursor-default",children:[a.jsx(Eo,{className:"h-3 w-3"})," ",z.length," base"]})})}),a.jsxs(fn,{className:"w-56",children:[a.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground mb-2",children:"Kernel mixins"}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:z.map(_=>a.jsx(me,{tone:"outline",children:_.name},_.identity))})]})]})]})]}),m&&j.length>=2&&a.jsx(Be,{label:"Relationship",children:a.jsx(tw,{bundle:e,endpoints:j,edgeName:u})}),g.length>0&&a.jsx(Be,{label:"Properties",hint:`${g.length}`,children:a.jsx(dt,{className:"divide-y divide-border/70",children:g.map(([_,D])=>a.jsx(yl,{bundle:e,refBase:x,pname:_,schema:D,optional:v?!v.includes(_):void 0},_))})}),E.length>0&&a.jsx(Be,{label:"Methods",hint:(()=>{const _=Su(E.map(([D,L])=>({method:L,link:f?void 0:da(e.overlay.handlerLinks,u,D,w==="interface"?"interface":"class")})));return a.jsxs("span",{className:"inline-flex items-center gap-2",children:[_>0&&a.jsxs(me,{tone:"warning",children:[_," unguarded"]}),E.length]})})(),children:a.jsx("div",{className:"space-y-2.5",children:E.map(([_,D])=>a.jsx(wl,{bundle:e,owner:u,ownerKind:w==="interface"?"interface":"class",handlerOwnerLocal:!f,refBase:x,mname:_,method:D},_))})}),$.length>0&&a.jsx(Be,{label:"Views",hint:`${$.length}`,children:a.jsx("div",{className:"flex flex-col gap-0.5",children:$.map(_=>a.jsx(is,{domainId:e.domainId,view:_,icon:I},_.slug))})}),N.length>0&&a.jsx(rw,{bundle:e,groups:N,originIcon:r}),g.length===0&&E.length===0&&N.length===0&&!m&&a.jsx(qt,{title:"No properties or methods",hint:"This member carries no fields of its own."})]})]})}function tw({bundle:e,endpoints:t,edgeName:n}){const[s,o]=t;return a.jsx(dt,{className:"px-3 py-5",children:a.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-stretch gap-1",children:[a.jsx(zi,{bundle:e,endpoint:s,edgeName:n}),a.jsx(nw,{edgeName:n,from:s,to:o}),a.jsx(zi,{bundle:e,endpoint:o,edgeName:n})]})})}function oo(e){if(!e)return"*";const{min:t,max:n}=e;return n===null?t<=0?"*":`${t}..*`:t===n?`${n}`:`${t}..${n}`}const Rn=e=>!e||e.max===null||e.max>1,Ti=e=>!e||e.min<=0;function zi({bundle:e,endpoint:t,edgeName:n}){const s=X(f=>f.selectClass);if(!t)return null;const o=e.ir;if(!o)return null;const i=t.refs!==void 0?t.refs.filter(Jy).map(f=>({name:f.name,ref:f})):t.types.map(f=>({name:f}));i.length===0&&i.push({name:"—"});const r=t.cardinality,c=t.name?wo(`edge.${n}.endpoint.${t.name}`,t.name):{},l=({name:f,ref:p})=>{if(p){const x=p.origin===o.domain,b=x&&p.kind==="class"?o.classes[f]:void 0,g=p.kind==="interface"?x?o.interfaces[f]:Nn(e,p):void 0,v=!!b||!!g;return{t:f,key:er(p),origin:x?void 0:p.origin,isInterface:p.kind==="interface",resolvable:v,selectionId:an(p)?fs(p,o.domain):x?`class.${p.name}`:void 0,icon:b?.icon}}const m=o.classes[f],w=o.interfaces[f],y=(!!m||!!w)&&!(m&&w);return{t:f,key:`legacy:${f}`,origin:void 0,isInterface:!m&&!!w,resolvable:y,selectionId:y?!m&&w?`interface.${f}`:`class.${f}`:void 0,icon:m?.icon}},d=f=>()=>{f.resolvable&&f.selectionId&&s(f.selectionId)},u=a.jsx("div",{className:"inline-flex max-w-full items-center rounded-full bg-muted/60 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/80",children:a.jsx("span",{className:"truncate",children:t.name})}),h=a.jsx("span",{className:"inline-flex items-center rounded-full border border-border/70 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground/80",title:"declared cardinality",children:oo(r)});if(i.length===1){const f=l(i[0]);return a.jsxs("button",{type:"button",onClick:f.resolvable?d(f):void 0,disabled:!f.resolvable,title:f.resolvable?`Open ${f.t}`:f.origin?`${f.t} · ${f.origin}`:f.t,...c,className:se("group/ep flex flex-col items-center gap-2.5 rounded-xl px-2 py-3 text-center min-w-0 transition-colors",f.resolvable?"hover:bg-accent/60 cursor-pointer":"cursor-default"),children:[a.jsx(ke,{tone:f.isInterface?"fuchsia":"violet",size:"lg",className:"transition-transform group-hover/ep:-translate-y-0.5",children:f.icon?a.jsx(we,{svg:f.icon,className:"h-5 w-5"}):f.isInterface?a.jsx(Oe,{}):a.jsx(Pe,{})}),a.jsxs("div",{className:"min-w-0 w-full space-y-1.5",children:[a.jsx("div",{className:"text-sm font-bold break-words leading-tight",children:f.t}),a.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-1",children:[u,h]})]})]})}return a.jsxs("div",{...c,className:"flex flex-col items-center gap-2.5 rounded-xl px-2 py-3 text-center min-w-0",children:[a.jsx("div",{className:"flex flex-wrap items-center justify-center gap-1.5",children:i.map(f=>{const p=l(f);return a.jsxs("button",{type:"button",onClick:p.resolvable?d(p):void 0,disabled:!p.resolvable,title:p.resolvable?`Open ${p.t}`:p.origin?`${p.t} · ${p.origin}`:p.t,className:se("inline-flex items-center gap-1.5 rounded-lg border border-border/70 pl-1 pr-2 py-1 transition-colors",p.resolvable?"hover:bg-accent/60 cursor-pointer":"cursor-default"),children:[a.jsx(ke,{tone:p.isInterface?"fuchsia":"violet",size:"sm",children:p.icon?a.jsx(we,{svg:p.icon,className:"h-3.5 w-3.5"}):p.isInterface?a.jsx(Oe,{}):a.jsx(Pe,{})}),a.jsx("span",{className:"text-[13px] font-semibold",children:p.t})]},p.key)})}),a.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-1",children:[a.jsx("span",{className:"text-[10px] lowercase tracking-wide text-muted-foreground/60",children:"any of"}),u,h]})]})}function nw({edgeName:e,from:t,to:n}){const s=t?.cardinality,o=n?.cardinality,i=`${Rn(s)?"many":"one"}-to-${Rn(o)?"many":"one"}`;return a.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 self-center px-1.5 min-w-[84px]",children:[a.jsxs("div",{className:"flex w-full items-center text-muted-foreground/45",children:[a.jsx(Li,{many:Rn(s),optional:Ti(s),side:"left"}),a.jsx("span",{className:"h-px flex-1 bg-border"}),a.jsx(la,{className:"h-[18px] w-[18px] shrink-0 text-muted-foreground/70"}),a.jsx("span",{className:"h-px flex-1 bg-border"}),a.jsx(Li,{many:Rn(o),optional:Ti(o),side:"right"})]}),a.jsxs(dn,{openDelay:80,children:[a.jsx(un,{asChild:!0,children:a.jsx("button",{type:"button",className:"rounded-full border border-border/70 px-2 py-0.5 text-[10px] font-medium text-muted-foreground/75 transition-colors hover:text-muted-foreground cursor-default",children:i})}),a.jsx(fn,{className:"w-60",children:a.jsxs("p",{className:"text-[12px] leading-relaxed text-muted-foreground",children:[a.jsx("span",{className:"font-mono text-foreground/90",children:e})," links"," ",a.jsx("span",{className:"font-mono text-foreground/90",children:oo(s)})," ",t?.name," to"," ",a.jsx("span",{className:"font-mono text-foreground/90",children:oo(o)})," ",n?.name,"."]})})]})]})}function Li({many:e,optional:t,side:n}){return a.jsx("svg",{viewBox:"0 0 24 16",className:se("h-4 w-6 shrink-0",n==="right"&&"rotate-180"),fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e?a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M22 8 L9 2 M22 8 L9 8 M22 8 L9 14"}),!t&&a.jsx("circle",{cx:"16",cy:"8",r:"2.2",fill:"currentColor",stroke:"none"})]}):a.jsx("circle",{cx:"9",cy:"8",r:"3",fill:t?"none":"currentColor",stroke:t?"currentColor":"none"})})}function xl({doc:e}){return a.jsxs(dn,{openDelay:80,children:[a.jsx(un,{asChild:!0,children:a.jsx("button",{type:"button","aria-label":"Description",className:"text-muted-foreground/40 hover:text-foreground transition-colors",children:a.jsx(Tu,{className:"h-3.5 w-3.5"})})}),a.jsx(fn,{className:"w-auto max-w-xs text-[13px] leading-relaxed text-muted-foreground",children:e})]})}function yl({bundle:e,refBase:t,pname:n,schema:s,optional:o}){const i=`${t}.property.${n}`,r=e.overlay.sourceSpans[i]?.doc,c=ua(s,o),l=c.icon,d=e.overlay.annotations.filter(h=>h.target===i),u=Mu(s);return a.jsx(vo,{anchorRef:i,anchorExcerpt:n,leading:a.jsx(ke,{tone:"sky",size:"sm",children:a.jsx(l,{})}),title:a.jsxs("span",{className:"flex items-center gap-1.5",children:[n,r&&a.jsx(xl,{doc:r}),c.optional&&a.jsx(me,{tone:"default",children:"optional"}),d.map(h=>a.jsx(me,{tone:"warning",title:h.message,children:h.code},h.code))]}),subtitle:a.jsxs(dn,{openDelay:140,children:[a.jsx(un,{asChild:!0,children:a.jsx("span",{className:"cursor-default",children:c.label})}),a.jsx(fn,{className:"w-auto max-w-sm",children:a.jsx($u,{items:[{label:"type",value:Ru(u)+(c.optional?" (optional)":"")},{label:"key",value:i}]})})]}),trailing:a.jsx(Lt,{anchorRef:{ref:i,kind:"schema",file:e.overlay.sourceSpans[i]?.file},excerpt:n})})}function wl({bundle:e,owner:t,ownerKind:n="class",handlerOwnerLocal:s=!0,refBase:o,mname:i,method:r,overridden:c=!1}){const l=`${o}.method.${i}`,d=s?da(e.overlay.handlerLinks,t,i,n):void 0,u=e.overlay.sourceSpans[l]?.doc,h=Au(r),f=h.icon,p=d&&!d.implemented,m=d?.unlinked;return a.jsxs(dt,{className:"px-3 py-2.5","data-anchor-ref":l,"data-anchor-excerpt":`${t}.${i}`,"data-commentable":"",children:[a.jsx(vo,{className:"px-0 py-0 hover:bg-transparent",leading:a.jsx(ke,{tone:h.tone,size:"sm",children:a.jsx(f,{})}),title:a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:se(c&&"line-through text-muted-foreground/70"),children:i}),a.jsx(Du,{method:r,link:d}),u&&a.jsx(xl,{doc:u}),r.inheritance==="sealed"&&a.jsx(me,{tone:"warning",children:"sealed"}),r.inheritance==="abstract"&&a.jsx(me,{tone:"fuchsia",children:"contract"}),c&&a.jsx(me,{tone:"default",children:"overridden"}),p&&a.jsx(me,{tone:"warning",children:"needs handler"}),m&&a.jsx(me,{tone:"default",children:"unlinked"})]}),trailing:a.jsx(Lt,{anchorRef:{ref:l,kind:"schema",file:e.overlay.sourceSpans[l]?.file},excerpt:`${t}.${i}`})}),a.jsx("div",{className:"pl-[2.625rem] pt-1.5",children:a.jsx(Pu,{label:"Details",children:a.jsx(sw,{method:r,link:d,owner:t})})})]})}function sw({method:e,link:t,owner:n}){const s=Object.entries(e.params??{});return a.jsxs("div",{className:"space-y-3 pb-1",children:[s.length>0&&a.jsxs("div",{className:"space-y-1.5",children:[a.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Input"}),a.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[13px]",children:s.map(([o,i])=>{const r=e.requiredParams?!e.requiredParams.includes(o):void 0,c=ua(i,r);return a.jsxs("span",{className:"inline-flex items-baseline gap-1.5",children:[a.jsx("span",{className:"font-medium",children:o}),a.jsxs("span",{className:"text-muted-foreground",children:[c.label,c.optional?"?":""]})]},o)})})]}),a.jsx(ow,{owner:n,isStatic:e.static}),t?.kernelCalls&&t.kernelCalls.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.kernelCalls.map(o=>a.jsx(me,{tone:"outline",className:"font-mono",children:o},o))}),a.jsxs("div",{className:"pt-0.5",children:[a.jsx("span",{className:"text-[11px] text-muted-foreground/60",children:"returns "}),a.jsx(zu,{schema:e.returns})]})]})}function ow({owner:e,isStatic:t}){return a.jsxs(dn,{openDelay:80,children:[a.jsx(un,{asChild:!0,children:a.jsx("button",{type:"button",className:"cursor-default rounded-full",children:a.jsxs(me,{tone:"outline",children:[t?a.jsx(bo,{className:"h-3 w-3"}):a.jsx(Pe,{className:"h-3 w-3"})," ",t?`on the ${e} type`:`on a ${e}`]})})}),a.jsx(fn,{className:"w-auto max-w-[15rem]",children:a.jsx("p",{className:"text-[12px] leading-relaxed text-muted-foreground",children:t?a.jsxs(a.Fragment,{children:["Acts on the ",a.jsxs("span",{className:"font-medium text-foreground/90",children:[e," type"]}),"."," ",a.jsx("span",{className:"text-muted-foreground/60",children:"(static)"})]}):a.jsxs(a.Fragment,{children:["Acts on a single ",a.jsx("span",{className:"font-medium text-foreground/90",children:e}),"."," ",a.jsx("span",{className:"text-muted-foreground/60",children:"(instance)"})]})})})]})}function rw({bundle:e,groups:t,originIcon:n}){const s=X(o=>o.selectClass);return a.jsx(Be,{label:"Inherited",hint:`${Xy(t)}`,children:a.jsx("div",{className:"space-y-5",children:t.map(o=>{const i=o.tier==="local"?"border-l-fuchsia-500/40":o.tier==="external"?"border-l-sky-500/40":"border-l-border",r=o.tier==="local"?"fuchsia":o.tier==="external"?"sky":"muted",c=o.ref?fs(o.ref,e.ir?.domain):`interface.${o.iface}`;return a.jsxs("div",{className:se("border-l-2 pl-3.5",i),children:[a.jsxs("button",{type:"button",onClick:()=>s(c),title:o.origin??"this domain",className:"group/ih mb-2.5 flex w-full items-center gap-2.5 text-left",children:[a.jsx(ke,{tone:r,size:"sm",children:a.jsx(iw,{tier:o.tier,iconSvg:n(o.origin)})}),a.jsx("span",{className:"text-sm font-semibold tracking-tight group-hover/ih:text-foreground transition-colors",children:o.iface}),a.jsx(me,{tone:o.tier==="local"?"fuchsia":"outline",children:o.tier==="local"?"interface":Vn(o.origin)}),a.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-[11px] text-muted-foreground/50 group-hover/ih:text-muted-foreground transition-colors",children:["inherited ",a.jsx(Ou,{className:"h-3.5 w-3.5"})]})]}),a.jsxs("div",{className:"space-y-2.5",children:[o.props.length>0&&a.jsx(dt,{className:"divide-y divide-border/70",children:o.props.map(([l,d,u])=>a.jsx(yl,{bundle:e,refBase:c,pname:l,schema:d,optional:u},`p-${l}`))}),o.methods.map(l=>a.jsx(wl,{bundle:e,owner:o.iface,ownerKind:"interface",handlerOwnerLocal:o.tier==="local",refBase:c,mname:l.name,method:l.method,overridden:l.overridden},`m-${l.name}`))]})]},c)})})})}function iw({tier:e,iconSvg:t}){return e==="local"?a.jsx(Oe,{}):t?a.jsx(we,{svg:t,className:"h-4 w-4"}):e==="kernel"?a.jsx(rf,{}):a.jsx(vt,{})}function Vn(e){return e?e==="kernel.astrale.ai"?"kernel":e.split(".")[0]:"imported"}function aw({bundle:e,path:t}){const n=X(i=>i.selectClass),s=Iu(e,t),o=i=>a.jsx(vo,{onClick:()=>n(i.selectId),anchorRef:i.ref,anchorExcerpt:i.name,leading:a.jsx(ke,{tone:i.kind==="interface"?"fuchsia":i.kind==="edge"?"amber":"sky",size:"sm",children:i.icon?a.jsx(we,{svg:i.icon,className:"h-4 w-4"}):i.kind==="interface"?a.jsx(Oe,{}):i.kind==="edge"?a.jsx(Tt,{}):a.jsx(Pe,{})}),title:i.name},i.selectId);return a.jsxs("div",{className:"h-full overflow-y-auto",...wo(`module.${t}`,s.label),children:[a.jsx(ml,{}),a.jsxs("div",{className:"px-5 py-6 space-y-7",children:[a.jsxs("header",{className:"flex items-start gap-3.5",children:[a.jsx(ke,{tone:"muted",size:"lg",style:{color:`oklch(0.82 0.12 ${s.hue})`},children:a.jsx(pn,{})}),a.jsxs("div",{className:"flex-1 min-w-0 pt-0.5",children:[a.jsx("h2",{className:"text-lg font-extrabold tracking-tight truncate",children:s.label}),a.jsxs("p",{className:"text-[13px] text-muted-foreground mt-1",children:[s.classes.length," ",s.classes.length===1?"class":"classes",s.interfaces.length>0&&` · ${s.interfaces.length} interface${s.interfaces.length===1?"":"s"}`,s.edges.length>0&&` · ${s.edges.length} relationship${s.edges.length===1?"":"s"}`]})]})]}),s.interfaces.length>0&&a.jsx(Be,{label:"Interfaces",children:a.jsx(dt,{className:"divide-y divide-border/70",children:s.interfaces.map(o)})}),s.classes.length>0&&a.jsx(Be,{label:"Classes",children:a.jsx(dt,{className:"divide-y divide-border/70",children:s.classes.map(o)})}),s.edges.length>0&&a.jsx(Be,{label:"Relationships",children:a.jsx(dt,{className:"divide-y divide-border/70",children:s.edges.map(o)})})]})]})}function cw(e){const[t,...n]=e.split(".");return[t==="interface"?"interface":"class",n.join(".")]}function vl(e,t,n){return`extmember.${e}.${n}.${t}`}function bl(e){return e.kind==="class"||e.kind==="interface"}function Nl(e){return`${e.origin}:${e.kind}.${e.name}`}function lw(e,t){return e.origin===t.origin&&e.kind===t.kind&&e.name===t.name}function ro(e){return e?e.refs!==void 0?e.refs.filter(bl).map(t=>({name:t.name,ref:t})):(e.types??[]).map(t=>({name:t})):[]}function tr(e,t,n){const s=[],o=new Set;for(const i of ro(t)){const{name:r,ref:c}=i;if(c&&c.origin!==e.domain)continue;const l=c?.kind==="class",d=c?.kind==="interface",u=!c&&e.classes[r]?.type==="node",h=!c&&e.interfaces[r]!==void 0;if((l||u)&&e.classes[r]?.type==="node"){o.has(r)||(o.add(r),s.push({cls:r,ifaceNode:null,viaInterface:null}));continue}if(!(!(d||h)||!e.interfaces[r])){if(n(r)){const f=`iface.${r}`;o.has(f)||(o.add(f),s.push({cls:null,ifaceNode:f,viaInterface:null}));continue}for(const[f,p]of Object.entries(e.classes)){const m=c?p.implementsRefs?.filter(bl).some(w=>lw(w,c))===!0:(p.implements??[]).includes(r);p.type==="node"&&m&&!o.has(f)&&(o.add(f),s.push({cls:f,ifaceNode:null,viaInterface:r}))}}}return s}function kl(e){const t=e.ir;if(!t)return[];const n=[];for(const[s,o]of Object.entries(t.classes)){if(o.type!=="edge"||!o.endpoints)continue;const i=o.endpoints[0],r=o.endpoints[1];if(!(!i||!r))for(const[c,l]of[[i,r],[r,i]]){const d=ro(c).filter(({name:h,ref:f})=>f?f.origin===t.domain&&(f.kind==="interface"||t.classes[h]?.type==="node")&&(f.kind!=="interface"||t.interfaces[h]!==void 0):t.classes[h]?.type==="node"||t.interfaces[h]!==void 0),u=ro(l).flatMap(h=>{if(h.ref){if(h.ref.origin===t.domain)return[];const f=t.importsByKey?.[Nl(h.ref)];return[{...h,ref:f?.ref??h.ref}]}return t.imports[h.name]?[h]:[]});for(const h of u){const f=h.ref?.origin??t.imports[h.name]?.origin;if(f)for(const p of d)n.push({edge:s,from:p.name,origin:f,to:h.name,...p.ref?{fromRef:p.ref}:{},...h.ref?{toRef:h.ref}:{},fromCard:c.cardinality,toCard:l.cardinality})}}}return n}function jl(e){const t=e.ir;if(!t)return[];const n=new Map;for(const o of kl(e)){n.has(o.origin)||n.set(o.origin,new Map);const i=o.toRef?.kind??t.imports[o.to]?.definition??"class",r=o.toRef?Nl(o.toRef):`${i}.${o.to}`;n.get(o.origin).set(r,{name:o.to,definition:i,...o.toRef?{ref:o.toRef}:{}})}const s=[];for(const[o,i]of n)s.push({origin:o,kind:o==="kernel.astrale.ai"?"kernel":"external",members:[...i.values()].sort((r,c)=>r.name.localeCompare(c.name)||r.definition.localeCompare(c.definition))});return s.sort((o,i)=>o.kind===i.kind?o.origin.localeCompare(i.origin):o.kind==="kernel"?1:-1)}const dw={hidden:{},showInheritedEdges:!0,materializedInterfaces:{}},cn=e=>ha("class",e),El=e=>ha("edge",e),io=e=>`domain.${e}`;function De(e,t){return t[e]===!0}function ao(e,t){return t[e]===!0}function Hi(e,t){if(e.showInheritedEdges!==t.showInheritedEdges)return!1;const n=Object.keys(e.hidden);if(n.length!==Object.keys(t.hidden).length||!n.every(o=>t.hidden[o]))return!1;const s=Object.keys(e.materializedInterfaces);return s.length===Object.keys(t.materializedInterfaces).length&&s.every(o=>t.materializedInterfaces[o])}function uw(e,t){return!De(cn(e),t)}function fw(e,t){return!De(io(e),t)}function Cl(e,t,n){return!(De(El(e.edgeName),t)||De(cn(e.aClass),t)||De(cn(e.bClass),t)||e.viaInterfaces.length>0&&!n)}function hw(e,t,n){const s=e.ir?.domain;return Lu(e,t).filter(o=>typeof o=="string"?!n.has(o):o.origin!==s||!n.has(o.name)).map(o=>fa(o,s))}const co="domain.import.",Sl=e=>`${co}${e}`;function Il(){const{data:e}=ln(),t=new Map((e??[]).map(n=>[n.origin,n]));return n=>t.get(n)??{name:n.split(".")[0]||n,icon:""}}function pw({domain:e}){const t=Il(),n=X(c=>De(io(e.origin),c.hidden)),s=X(c=>c.toggleHidden),o=t(e.origin),i=e.kind==="kernel"?"violet":"emerald",r=e.members.length;return a.jsxs("div",{className:se("group flex items-center gap-2 rounded-lg px-1.5 py-1 transition-opacity",n&&"opacity-50"),children:[a.jsx(ke,{tone:i,size:"sm",children:o.icon?a.jsx(we,{svg:o.icon,className:"h-3.5 w-3.5"}):a.jsx(vt,{})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:o.name}),a.jsxs("div",{className:"text-[11px] text-muted-foreground/70 leading-tight",children:[r," linked ",r===1?"type":"types"]})]}),a.jsx("button",{type:"button",onClick:()=>s(io(e.origin)),title:n?"Show in canvas":"Hide in canvas",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground/60 transition-colors hover:bg-accent/60 hover:text-foreground",children:n?a.jsx(pa,{className:"h-3.5 w-3.5"}):a.jsx(ma,{className:"h-3.5 w-3.5"})})]})}function mw({origin:e}){const n=Il()(e);return a.jsx(bn,{anchor:{ref:Sl(e),kind:"section"},excerpt:`Import ${n.name}`,children:a.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-1.5 py-1",children:[a.jsx(ke,{tone:"amber",size:"sm",children:n.icon?a.jsx(we,{svg:n.icon,className:"h-3.5 w-3.5"}):a.jsx(vt,{})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:n.name}),a.jsx("div",{className:"text-[11px] text-muted-foreground/70 leading-tight",children:"import requested"})]})]})})}function gw({domainId:e,taken:t}){const{data:n}=ln(),{create:s}=ga(e),o=X(c=>c.setOpenAnchor),i=c=>{const l=Sl(c.origin);s.mutate({anchors:[c.origin],anchorRefs:[{ref:l,kind:"section"}],text:`Import the ${c.name} domain (${c.origin}) — add it to this domain's imports and wire up the types we depend on.`,firstRole:"user",type:"text"},{onSuccess:()=>{o(l),Wn.success("Import requested — add the why/how in the comment")},onError:d=>Wn.error(String(d))})},r=(n??[]).filter(c=>c.kind!=="kernel"&&c.origin!==e&&!t.has(c.origin));return a.jsxs(Pt,{children:[a.jsx(go,{asChild:!0,children:a.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 rounded-lg px-2 py-1.5 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:[a.jsx(Eo,{className:"h-3.5 w-3.5"}),"Import a domain"]})}),a.jsxs(Ot,{align:"start",side:"top",className:"w-64 p-1.5",children:[a.jsx("div",{className:"px-1.5 pb-1.5 pt-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Catalog"}),r.length===0?a.jsx("div",{className:"px-1.5 py-3 text-center text-xs text-muted-foreground/60",children:"Everything imported"}):a.jsx("div",{className:"flex flex-col gap-0.5",children:r.map(c=>a.jsxs("button",{type:"button",onClick:()=>i(c),disabled:s.isPending,className:"group/imp flex items-center gap-2.5 rounded-lg px-1.5 py-1.5 text-left transition-colors hover:bg-accent/60 disabled:opacity-50",children:[a.jsx(ke,{tone:c.kind==="external"?"emerald":"sky",size:"sm",children:c.icon?a.jsx(we,{svg:c.icon,className:"h-3.5 w-3.5"}):a.jsx(vt,{})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:c.name}),a.jsx("div",{className:"truncate text-[11px] text-muted-foreground/70 leading-tight",children:c.description})]}),a.jsx("span",{className:"shrink-0 text-[11px] font-medium text-primary opacity-0 transition-opacity group-hover/imp:opacity-100",children:"Import"})]},c.origin))})]})]})}function xw({domainId:e}){const{data:t}=xo(e),{data:n}=No(e),s=k.useMemo(()=>t?jl(t):[],[t]),o=k.useMemo(()=>new Set(s.map(c=>c.origin)),[s]),i=k.useMemo(()=>{const c=new Set(["kernel.astrale.ai",...o]);for(const l of t?.overlay.requires??[])c.add(l);for(const l of t?.overlay.crossDomainImports??[])c.add(l.origin);return c},[o,t]),r=k.useMemo(()=>{const c=new Set,l=[];for(const d of n?.comments??[])if(d.status==="open")for(const u of d.anchorRefs){if(!u.ref.startsWith(co))continue;const h=u.ref.slice(co.length);o.has(h)||c.has(h)||(c.add(h),l.push(h))}return l},[n,o]);return a.jsx(zt,{className:"h-full",children:a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"mb-5 flex items-baseline gap-2 pr-8",children:[a.jsx("h1",{className:"text-base font-semibold",children:"Domains"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:s.length})]}),s.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"px-1.5 pb-1.5 pt-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Imported domains"}),a.jsx("div",{className:"flex flex-col gap-0.5",children:s.map(c=>a.jsx(pw,{domain:c},c.origin))})]}),r.length>0&&a.jsxs(a.Fragment,{children:[s.length>0&&a.jsx(Bn,{className:"my-2 opacity-60"}),a.jsx("div",{className:"px-1.5 pb-1.5 pt-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Requested"}),a.jsx("div",{className:"flex flex-col gap-0.5",children:r.map(c=>a.jsx(mw,{origin:c},c))})]}),s.length===0&&r.length===0&&a.jsx("p",{className:"px-2 pb-1 pt-0.5 text-[11px] text-muted-foreground/60",children:"No imported domains yet."}),a.jsx(Bn,{className:"my-3 opacity-60"}),a.jsx(gw,{domainId:e,taken:i})]})})}const yw=18,ww=3,vw=[{id:"erd-many",draw:a.jsx("path",{d:"M6 11 L18 4 L13.5 11 L18 18 Z",fill:"context-stroke",stroke:"none"})},{id:"erd-one",draw:a.jsx("circle",{cx:15,cy:11,r:2.9,fill:"context-stroke",stroke:"none"})}];function _l(){return a.jsx("svg",{width:"0",height:"0","aria-hidden":!0,className:"absolute",style:{position:"absolute"},children:a.jsx("defs",{children:vw.map(({id:e,draw:t})=>a.jsx("marker",{id:e,viewBox:"0 0 24 22",refX:yw+ww,refY:11,markerWidth:24,markerHeight:22,markerUnits:"userSpaceOnUse",orient:"auto-start-reverse",children:a.jsx("g",{fill:"none",stroke:"context-stroke",strokeWidth:1.4,strokeLinecap:"round",strokeLinejoin:"round",children:t})},e))})})}function Vi(e){return e?e.max===null||e.max>1?"erd-many":"erd-one":"erd-many"}function nr(e,t){return{markerStart:Vi(e),markerEnd:Vi(t)}}const Fi=88,Vs=24;function Cs(e){if(e.type!=="group")return{};const t=(typeof e.measured?.width=="number"?e.measured.width:void 0)??(typeof e.style?.width=="number"?e.style.width:void 0),n=(typeof e.measured?.height=="number"?e.measured.height:void 0)??(typeof e.style?.height=="number"?e.style.height:void 0);return t!==void 0&&n!==void 0?{w:Math.round(t),h:Math.round(n)}:{}}function Ml(e,t){const n=t[e.id];if(!n)return e;const s={...e,position:{x:n.x,y:n.y}};return e.type==="group"&&n.w!==void 0&&n.h!==void 0&&(s.style={...e.style,width:n.w,height:n.h}),s}function lo(e){const t={};for(const n of e)t[n.id]={x:Math.round(n.position.x),y:Math.round(n.position.y),...Cs(n)};return t}function $l(e,t){let n=0,s=Number.POSITIVE_INFINITY;const o=new Map;for(const{node:l,position:d}of e)if(l.parentId){const u=d.y+(l.style?.height??Fi)+Vs;o.set(l.parentId,Math.max(o.get(l.parentId)??34,u))}else n=Math.max(n,d.x+(l.style?.width??200)),s=Math.min(s,d.y);Number.isFinite(s)||(s=0);const i=n+96;let r=s;const c={};for(const l of t)if(l.parentId){const d=o.get(l.parentId)??34;c[l.id]={x:14,y:d},o.set(l.parentId,d+Fi+Vs)}else c[l.id]={x:i,y:r,...Cs(l)},r+=(l.style?.height??120)+Vs;return c}function Rl(){const e=ls(),t=k.useRef(new Map),n=k.useRef(new Map),s=k.useCallback(i=>{const r=n.current.get(i);r&&clearTimeout(r),n.current.delete(i);const c=t.current.get(i);t.current.delete(i),c&&Object.keys(c).length>0&&_e.setLayout(i,c).catch(()=>{})},[]),o=k.useCallback((i,r)=>{e.setQueryData(We.layout(i),l=>({schemaHash:l?.schemaHash,positions:{...l?.positions,...r}})),t.current.set(i,{...t.current.get(i),...r});const c=n.current.get(i);c&&clearTimeout(c),n.current.set(i,setTimeout(()=>s(i),500))},[s,e]);return k.useEffect(()=>()=>{for(const i of t.current.keys())s(i)},[s]),{commitLayout:o,flushLayout:s}}function bw(e){return String(e??"").split(/[.:/]/).pop()??""}function Nw(e){return Array.isArray(e)?e.map(String):e?[String(e)]:[]}function sr(e){return e.kind==="class"||e.kind==="interface"}function Fn(e){return`${e.origin}:${e.kind}.${e.name}`}function Al(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.origin=="string"&&t.kind==="interface"&&typeof t.name=="string"}function kw(e,t){const n=e.ir;if(!n||t.kind!=="interface")return;if(t.origin===n.domain)return n.interfaces[t.name];const s=n.importedInterfacesByKey;if(s!==void 0)return s[Fn(t)];const o=n.imports[t.name];if(!(o?.origin!==t.origin||o.definition!=="interface"||o.ref&&Fn(o.ref)!==Fn(t)))return e.importedInterfaces?.[t.name]}function jw(e,t){const n=e.ir;if(n){if(n.interfaces[t])return n.interfaces[t];if(n.importedInterfacesByKey!==void 0){const s=Object.values(n.importedInterfacesByKey).filter(o=>o.name===t);return s.length===1?s[0]:void 0}return e.importedInterfaces?.[t]}}function Bi(e){return e.extendsRefs!==void 0?e.extendsRefs.filter(sr).filter(Al):Nw(e.extends)}function Ew(e,t){const n=new Set,s=new Set,o=[...e];for(;o.length;){const i=o.pop();if(!i)continue;if(typeof i=="string"){const l=bw(i),d=`legacy:${l}`;if(!l||n.has(d))continue;n.add(d),l==="Function"?s.add("function"):l==="Identity"?s.add("identity"):l==="Container"&&s.add("container");const u=jw(t,l);u&&o.push(...Bi(u));continue}const r=Fn(i);if(n.has(r))continue;n.add(r),i.origin==="kernel.astrale.ai"&&(i.name==="Function"?s.add("function"):i.name==="Identity"?s.add("identity"):i.name==="Container"&&s.add("container"));const c=kw(t,i);c&&o.push(...Bi(c))}return s.has("function")?"function":s.has("identity")?"identity":s.has("container")?"container":null}function Wi(e,t,n){const s=t!==void 0?t.filter(sr).filter(o=>o.kind==="interface"&&o.origin===e.domain&&!!e.interfaces[o.name]).map(o=>o.name):(n??[]).filter(o=>!!e.interfaces[o]);return[...new Set(s)]}function or(e,t,n,s){return ao(s,n)&&!!e.ir?.interfaces[s]&&!t.has(xa(e,s))}const An="oklch(0.72 0.18 330)";function Dl(e,t,n,s,o){const i=e.ir;if(!i)return{nodes:[],edges:[]};const r=m=>or(e,t,o,m),c=new Set(Object.keys(i.interfaces).filter(r)),l=Hu(e).filter(m=>m.classes.length>0||m.interfaces.some(w=>c.has(w))),d=[];for(const m of l){const w=`grp-${m.path}`,y=t.has(m.path);if(d.push({id:w,type:y?"moduleNode":"group",position:{x:0,y:0},selectable:!0,data:{domainId:e.domainId,domainOrigin:i.domain,label:m.label,path:m.path,hue:m.hue,interfaces:m.interfaces.filter(x=>!c.has(x)).map(x=>fa({origin:i.domain,kind:"interface",name:x},i.domain)),collapsed:y,classCount:m.classes.length},style:y?{width:200,height:44}:{width:200,height:120}}),!y){for(const x of m.classes){if(!uw(x,n))continue;const b=i.classes[x];d.push({id:`class.${x}`,type:"classNode",parentId:w,extent:"parent",expandParent:!0,position:{x:0,y:0},data:{domainId:e.domainId,domainOrigin:i.domain,name:x,props:Object.keys(b?.properties??{}).length,methods:Object.keys(b?.methods??{}).length,interfaces:hw(e,x,c),coreRole:Ew(b?.implementsRefs!==void 0?b.implementsRefs.filter(sr).filter(Al):b?.implements??[],e),hue:m.hue,icon:b?.icon}})}for(const x of m.interfaces){if(!c.has(x))continue;const b=i.interfaces[x];d.push({id:`iface.${x}`,type:"interfaceNode",parentId:w,extent:"parent",expandParent:!0,position:{x:0,y:0},data:{domainId:e.domainId,name:x,props:Object.keys(b.properties??{}).length,methods:Object.keys(b.methods??{}).length}})}}}const u=m=>{const w=pt(e,m);return t.has(w)?`grp-${w}`:`class.${m}`},h=m=>tr(i,m,r),f=m=>m.cls!==null?pt(e,m.cls):xa(e,m.ifaceNode.slice(6)),p=[];for(const m of Object.values(i.classes)){if(m.type!=="edge")continue;const w=h(m.endpoints?.[0]),y=h(m.endpoints?.[1]),x=nr(m.endpoints?.[0]?.cardinality,m.endpoints?.[1]?.cardinality);for(const b of w)for(const g of y){const v=[b.viaInterface,g.viaInterface].filter(V=>V!==null),E=b.ifaceNode??u(b.cls),j=g.ifaceNode??u(g.cls);if(!Cl({edgeName:m.name,aClass:b.cls??"",bClass:g.cls??"",viaInterfaces:v},n,s)||E===j)continue;const S=f(b)!==f(g),R=v.length>0,A=S?"oklch(0.72 0.16 35)":"oklch(0.62 0.07 264)";p.push({id:`edge-${m.name}__${E}__${j}`,source:E,target:j,type:"floating",data:{label:m.name,edgeClass:m.name,ownerDomainId:e.domainId,polymorphic:R},markerStart:x.markerStart,markerEnd:x.markerEnd,style:{stroke:A,strokeWidth:S?2.4:1.8,...R?{strokeDasharray:"7 4"}:{}}})}}for(const[m,w]of Object.entries(i.classes))if(!(w.type!=="node"||De(cn(m),n)))for(const y of Wi(i,w.implementsRefs,w.implements)){if(!r(y))continue;const x=u(m),b=`iface.${y}`;x!==b&&p.push({id:`implements-${m}__${y}`,source:x,target:b,type:"floating",data:{kind:"implements",ownerDomainId:e.domainId},markerEnd:{type:Je.ArrowClosed,color:An,width:16,height:16},style:{stroke:An,strokeWidth:1.6,strokeDasharray:"7 4"}})}for(const[m,w]of Object.entries(i.interfaces))if(r(m))for(const y of Wi(i,w.extendsRefs,w.extends))r(y)&&p.push({id:`extends-${m}__${y}`,source:`iface.${m}`,target:`iface.${y}`,type:"floating",data:{label:"extends",kind:"extends",ownerDomainId:e.domainId},markerEnd:{type:Je.ArrowClosed,color:An,width:16,height:16},style:{stroke:An,strokeWidth:1.6,strokeDasharray:"2 4"}});return{nodes:d,edges:p}}function Cw({data:e}){const t=e,n=X(l=>l.selectClass),s=X(l=>l.setDomain),o=X(l=>l.domainId===t.domainId&&l.selectedClass===`class.${t.name}`),r=oe(l=>l.transform[2])<.5,c=t.coreRole?{container:"schema-core-container",identity:"schema-core-identity",function:"schema-core-function"}[t.coreRole]:void 0;return a.jsxs("div",{"data-domain-id":t.domainId,"data-core-role":t.coreRole??void 0,className:se("relative rounded-lg border bg-card shadow-sm w-[160px] transition-shadow",c,o?"ring-2 ring-primary":"hover:shadow-md"),style:{borderLeft:`3px solid oklch(0.72 0.15 ${t.hue})`},children:[t.coreRole==="identity"&&a.jsx("span",{title:"Identity",className:"schema-core-identity-icon",children:a.jsx(xf,{className:"h-3 w-3"})}),a.jsx(Es,{domainId:t.domainId,anchorRef:`class.${t.name}`,kind:"schema",excerpt:t.name,className:t.coreRole==="identity"?"top-6":void 0}),a.jsx(je,{type:"target",position:q.Top,className:"!opacity-0"}),a.jsxs("div",{className:"px-2.5 py-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[t.coreRole==="function"?a.jsx("span",{className:"shrink-0 schema-core-function-icon",children:a.jsx(Fu,{className:"h-5 w-5"})}):t.icon?a.jsx("span",{style:{color:`oklch(0.82 0.14 ${t.hue})`},className:"shrink-0",children:a.jsx(we,{svg:t.icon,className:"h-6 w-6"})}):a.jsx("span",{className:"h-2.5 w-2.5 rounded-sm shrink-0",style:{background:`oklch(0.7 0.15 ${t.hue})`}}),a.jsx("span",{className:"text-sm font-extrabold truncate",children:t.name})]}),!r&&t.interfaces.length>0&&a.jsx("div",{className:"rf-meta mt-1.5",children:t.interfaces.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1",children:t.interfaces.map(l=>a.jsxs("button",{type:"button",title:l.ref?`interface ${l.name} (${l.ref.origin})`:`interface ${l.name}`,onClick:d=>{d.stopPropagation(),X.getState().domainId!==t.domainId&&s(t.domainId),n(l.selectionId)},className:"inline-flex items-center gap-0.5 rounded bg-fuchsia-500/15 text-fuchsia-300 px-1 py-0.5 text-[9px] font-mono hover:bg-fuchsia-500/25",children:[a.jsx(Oe,{className:"h-2.5 w-2.5"}),l.name]},l.identity))})})]}),a.jsx(je,{type:"source",position:q.Bottom,className:"!opacity-0"})]})}function Sw({data:e}){const t=e,n=X(i=>i.domainId===t.domainId&&i.selectedClass===`interface.${t.name}`),o=oe(i=>i.transform[2])<.5;return a.jsxs("div",{"data-domain-id":t.domainId,className:se("relative rounded-lg border border-dashed border-fuchsia-400/50 bg-fuchsia-500/[0.06] shadow-sm w-[160px] transition-shadow",n?"ring-2 ring-primary":"hover:shadow-md"),style:{borderLeftColor:"oklch(0.72 0.18 330)",borderLeftWidth:3,borderLeftStyle:"solid"},children:[a.jsx(Es,{domainId:t.domainId,anchorRef:`interface.${t.name}`,kind:"schema",excerpt:t.name}),a.jsx(je,{type:"target",position:q.Top,className:"!opacity-0"}),a.jsxs("div",{className:"px-2.5 py-1.5",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"shrink-0 text-fuchsia-300",children:a.jsx(Oe,{className:"h-5 w-5"})}),a.jsx("span",{className:"text-sm font-extrabold truncate",children:t.name})]}),!o&&(t.props>0||t.methods>0)&&a.jsxs("div",{className:"rf-meta mt-1.5 font-mono text-[9px] text-muted-foreground",children:[t.props,"p · ",t.methods,"m"]})]}),a.jsx(je,{type:"source",position:q.Bottom,className:"!opacity-0"})]})}function uo({data:e}){const t=e,n=X(r=>r.selectClass),s=X(r=>r.setDomain),o=X(r=>r.toggleModule),i=X(r=>r.domainId===t.domainId&&r.selectedClass===`module.${t.path}`);return a.jsxs("div",{"data-domain-id":t.domainId,className:se("relative w-full h-full rounded-xl border transition-shadow",i?"ring-2 ring-primary":t.collapsed&&"hover:shadow-md cursor-pointer"),style:{borderColor:`oklch(0.55 0.1 ${t.hue} / 0.45)`,background:`oklch(0.5 0.12 ${t.hue} / ${t.collapsed?.12:.07})`},children:[a.jsx(Es,{domainId:t.domainId,anchorRef:`module.${t.path}`,kind:"section",excerpt:t.label}),a.jsx(je,{type:"target",position:q.Top,className:"!opacity-0"}),a.jsx(je,{type:"source",position:q.Bottom,className:"!opacity-0"}),a.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1.5 text-[13px]",style:{color:`oklch(0.85 0.12 ${t.hue})`},children:[a.jsx("button",{type:"button",title:t.collapsed?"Show classes":"Hide classes",onClick:r=>{r.stopPropagation(),t.onToggleModule?t.onToggleModule(t.domainId,t.path):(X.getState().domainId!==t.domainId&&s(t.domainId),o(t.path))},className:"rounded p-0.5 hover:bg-white/10 shrink-0",children:t.collapsed?a.jsx(us,{className:"h-3.5 w-3.5"}):a.jsx(ds,{className:"h-3.5 w-3.5"})}),a.jsx("span",{className:"font-extrabold truncate",children:t.label}),t.collapsed?a.jsx("span",{className:"ml-auto text-[10px] opacity-60 shrink-0 pr-1",children:t.classCount}):t.interfaces.map(r=>a.jsxs("button",{type:"button",title:r.ref?`interface ${r.name} (${r.ref.origin})`:`interface ${r.name}`,onClick:c=>{c.stopPropagation(),X.getState().domainId!==t.domainId&&s(t.domainId),n(r.selectionId)},className:"inline-flex items-center gap-0.5 rounded bg-fuchsia-500/15 text-fuchsia-300 px-1 py-0.5 text-[9px] hover:bg-fuchsia-500/25 shrink-0",children:[a.jsx(Oe,{className:"h-2.5 w-2.5"}),r.name]},r.identity))]})]})}function Iw({data:e}){const t=e,n=t.kind==="kernel"?285:158;return a.jsx("div",{className:"w-full h-full rounded-xl border border-dashed",style:{borderColor:`oklch(0.6 0.1 ${n} / 0.55)`,background:`oklch(0.5 0.1 ${n} / 0.06)`},children:a.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5",style:{color:`oklch(0.84 0.11 ${n})`},children:[a.jsx("span",{className:"shrink-0",children:t.icon?a.jsx(we,{svg:t.icon,className:"h-4 w-4"}):a.jsx(vt,{className:"h-4 w-4"})}),a.jsx("span",{className:"text-[13px] font-extrabold truncate",children:t.name}),a.jsx("span",{className:"ml-auto text-[9px] uppercase tracking-wider opacity-60 shrink-0",children:t.kind})]})})}function _w({data:e}){const t=e,n=t.kind==="kernel"?285:158,s=t.definition==="interface"?Oe:Pe;return a.jsxs("div",{className:"w-full h-full rounded-lg border bg-card flex items-center gap-1.5 px-2 shadow-sm",style:{borderLeft:`3px solid oklch(0.72 0.14 ${n})`},children:[a.jsx(je,{type:"target",position:q.Left,className:"!opacity-0"}),a.jsx(s,{className:"h-4 w-4 shrink-0",style:{color:`oklch(0.78 0.13 ${n})`}}),a.jsx("span",{className:"text-[12px] font-extrabold truncate",children:t.name}),a.jsx(je,{type:"source",position:q.Right,className:"!opacity-0"})]})}function Mw({data:e}){const t=e;return a.jsx("div",{className:"relative w-full h-full rounded-2xl border-2 border-dashed",style:{borderColor:"oklch(0.62 0.04 264 / 0.38)",background:"oklch(0.6 0.03 264 / 0.025)"},children:a.jsx("span",{className:"absolute -top-2.5 left-5 px-2 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/55 whitespace-nowrap",style:{background:"var(--color-canvas)"},children:t.label})})}function $w({data:e}){const t=e;return a.jsx(Ol,{threads:t.comments,anchor:t.anchor,excerpt:t.excerpt,className:"nodrag nopan"})}const Pl={classNode:Cw,interfaceNode:Sw,group:uo,moduleNode:uo,extDomain:Iw,extMember:_w,internalRegion:Mw,canvasComment:$w};function Ol({threads:e,anchor:t,excerpt:n,className:s}){const[o,i]=k.useState(!1);if(e.length===0)return null;const r=e.some(l=>l.status==="open")?"open":"resolved",c=e.some(l=>l.orphaned);return a.jsxs(Pt,{modal:!1,open:o,onOpenChange:i,children:[a.jsx(po,{asChild:!0,children:a.jsxs("button",{type:"button",title:"Schema canvas comments",onClick:l=>{l.stopPropagation(),i(d=>!d)},className:se("flex h-6 min-w-6 items-center justify-center gap-1 rounded-full px-1.5 text-[11px] font-bold shadow-md ring-2 ring-card transition-colors hover:brightness-110",r==="open"?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground",c&&"bg-destructive text-white",s),children:[a.jsx(ra,{className:"h-3 w-3"}),e.length]})}),a.jsx(Ot,{side:"top",align:"center",className:"w-80",onInteractOutside:l=>l.preventDefault(),children:a.jsx(mo,{anchor:t,excerpt:n,threads:e,onClose:()=>i(!1)})})]})}function Rw(e,t,n,s){let o=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(const g of e){if(g.parentId)continue;const v=s?.[g.id]??g.position,E=g.style?.width??200,j=g.style?.height??120;o=Math.min(o,v.x),i=Math.max(i,v.x+E),r=Math.min(r,v.y),c=Math.max(c,v.y+j)}Number.isFinite(o)||(o=0,r=0,i=400,c=400);const l=56,d=o-l,u=r-l,h=i-o+2*l,f=new Map((n??[]).map(g=>[g.origin,g])),p=36,m=44,w=8,y=d+h+96,x=[];let b=u+24;for(const g of t){const v=f.get(g.origin),E=p+g.members.length*(m+w)+8,j=`extdom.${g.origin}`;x.push({id:j,type:"extDomain",position:s?.[j]??{x:y,y:b},draggable:!0,selectable:!1,data:{name:v?.name??g.origin.split(".")[0],origin:g.origin,kind:g.kind,icon:v?.icon},style:{width:216,height:E}}),g.members.forEach((S,R)=>{x.push({id:vl(g.origin,S.name,S.definition),type:"extMember",parentId:j,extent:"parent",draggable:!1,position:{x:12,y:p+R*(m+w)},data:{name:S.name,kind:g.kind,definition:S.definition},style:{width:192,height:m}})}),b+=E+40}return{extNodes:x}}function Aw(e,t){let n=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(const c of e){if(!c.id.startsWith("grp-"))continue;const l=c.style?.width??200,d=c.style?.height??120;n=Math.min(n,c.position.x),s=Math.min(s,c.position.y),o=Math.max(o,c.position.x+l),i=Math.max(i,c.position.y+d)}if(!Number.isFinite(n))return null;const r=56;return{id:"region",type:"internalRegion",position:{x:n-r,y:s-r},draggable:!1,selectable:!1,zIndex:-1,data:{label:t},style:{width:o-n+2*r,height:i-s+2*r}}}const Dw={};function Pw(e,t,n,s,o,i,r,c){const l=s.ir;if(!l)return[];const d=[],u=h=>or(s,o,c,h);for(const h of e){if(!t.has(h.origin))continue;const f=vl(h.origin,h.to,h.toRef?.kind??l.imports[h.to]?.definition??"class");if(!n.has(f))continue;const p=h.fromRef?{types:[h.from],refs:[h.fromRef]}:{types:[h.from]};for(const m of tr(l,p,u)){const w=m.viaInterface?[m.viaInterface]:[];if(!Cl({edgeName:h.edge,aClass:m.cls??"",bClass:"",viaInterfaces:w},i,r))continue;const y=m.ifaceNode??(o.has(pt(s,m.cls))?`grp-${pt(s,m.cls)}`:`class.${m.cls}`);if(!n.has(y))continue;const x="oklch(0.72 0.16 35)",b=nr(h.fromCard,h.toCard),g=w.length>0;d.push({id:`edge-${h.edge}__${y}__${f}`,source:y,target:f,type:"floating",data:{label:h.edge,edgeClass:h.edge,polymorphic:g},markerStart:b.markerStart,markerEnd:b.markerEnd,style:{stroke:x,strokeWidth:2,...g?{strokeDasharray:"7 4"}:{}}})}}return d}function rr(e){return!e||!Number.isFinite(e.x)||!Number.isFinite(e.y)?null:{x:e.x,y:e.y}}function Ow(e){const t=new Map;for(const n of e??[]){const s=n.anchorRefs.find(c=>c.ref==="section.schema");if(!s)continue;const o=rr(s);if(!o)continue;const i=`${Math.round(o.x/12)*12}:${Math.round(o.y/12)*12}`,r=t.get(i);r?r.comments.push(n):t.set(i,{key:i,anchor:s,comments:[n]})}return[...t.values()]}function Tw(e){return(e??[]).filter(t=>{const n=t.anchorRefs.find(s=>s.ref==="section.schema");return!!n&&!rr(n)})}function zw(e){return e.map(t=>{const n=rr(t.anchor)??{x:0,y:0};return{id:`canvas-comment.${t.key}`,type:"canvasComment",position:{x:n.x,y:n.y},draggable:!1,selectable:!1,data:{comments:t.comments,anchor:t.anchor,excerpt:"Schema canvas"},style:{width:24,height:24},zIndex:40}})}function Lw(e,t){const n=new Set([e]),s=new Set;for(const o of t)o.source===e?(n.add(o.target),s.add(o.id)):o.target===e&&(n.add(o.source),s.add(o.id));return{nodeIds:n,edgeIds:s}}function Hw({bundle:e,domainId:t,saved:n}){const{fitView:s,getNodes:o}=Ht(),i=X(B=>B.focusId),r=X(B=>B.focusClass),c=X(B=>B.panelOverlay),l=X(B=>B.setPanelOverlay),d=yo(t).all.length,u=ya(t).data?.detectedIntegrations?.length??0,h=wa(t).data,f=(h?.nodes.length??0)+(h?.edges.length??0),p=X(B=>B.selectClass),m=X(B=>B.selectedClass),w=X(B=>B.setFocus),y=X(B=>B.setOpenAnchor),x=X(B=>B.collapsedModules),b=X(B=>B.toggleModule),g=X(B=>B.hidden),v=X(B=>B.showInheritedEdges),E=X(B=>B.materializedInterfaces),j=X(B=>B.toggleInheritedEdges),S=X(B=>B.setVisibility),{data:R}=ln(),{data:A}=No(t),{data:V}=Vu(t),O=k.useRef(!1),[z,M]=k.useState([]),[N,C]=k.useState([]),[I,$]=k.useState(null),[_,D]=k.useState(!1),L=_?E:Dw,H=k.useMemo(()=>Dl(e,new Set(x),g,v,L),[e.schemaHash,e,x,g,v,L]),F=k.useMemo(()=>jl(e),[e]),P=k.useMemo(()=>kl(e),[e]),W=Object.keys(g).sort().join(",")+`|${v}|`+Object.keys(L).sort().join(",");k.useEffect(()=>{if(!m?.startsWith("class."))return;const B=pt(e,m.slice(6));x.includes(B)&&b(B)},[m,e,x,b]);const Y=ls(),J=k.useRef(!1),{commitLayout:U}=Rl(),T=k.useCallback(B=>{U(t,B)},[U,t]);k.useEffect(()=>{if(!V)return;const B=V,G=X.getState(),ne={hidden:B.hidden,showInheritedEdges:B.showInheritedEdges,materializedInterfaces:B.materializedInterfaces};Hi(ne,G)||S(ne),O.current=!0},[t,V,S]),k.useEffect(()=>{if(!O.current)return;const B=X.getState(),G={hidden:B.hidden,showInheritedEdges:B.showInheritedEdges,materializedInterfaces:B.materializedInterfaces},ne=Y.getQueryData(We.visibility(t))??dw;Hi(G,ne)||(Y.setQueryData(We.visibility(t),G),_e.setVisibility(t,G).catch(()=>{}))},[g,v,E,t,Y]);const Z=k.useCallback(B=>{const G=H.nodes.map(ye=>Ml(ye,B)),ne=F.filter(ye=>fw(ye.origin,g)),{extNodes:fe}=Rw(G,ne,R,B),ae=[...G,...fe],xe=new Set(ae.map(ye=>ye.id));M(ae),C(os([...H.edges,...Pw(P,new Set(ne.map(ye=>ye.origin)),xe,e,new Set(x),g,v,L)]))},[H,F,g,R,P,e,x,v,L]),ee=k.useCallback(()=>{J.current||(J.current=!0,requestAnimationFrame(()=>{s({padding:.18,duration:400}),D(!0)}))},[s]),te=k.useRef(n);te.current=n;const K=n!==void 0;k.useEffect(()=>{const B=te.current;if(!B)return;const G=H.nodes.filter(ae=>B[ae.id]),ne=H.nodes.filter(ae=>!B[ae.id]);if(ne.length===0){Z(B),ee();return}if(G.length===0){let ae=!1;return ss(H.nodes,H.edges).then(xe=>{if(ae)return;const ye=lo(xe);Z(ye),T(ye),ee()}),()=>{ae=!0}}const fe=$l(G.map(ae=>({node:ae,position:B[ae.id]})),ne);Z({...B,...fe}),T(fe),ee()},[H,K,F,P,R,W]);const Q=k.useCallback(B=>M(G=>Ns(B.filter(ne=>ne.id!=="region"),G)),[]),re=k.useCallback(B=>C(G=>ks(B,G)),[]),ie=k.useCallback((B,G)=>{const ne={[G.id]:{x:Math.round(G.position.x),y:Math.round(G.position.y),...Cs(G)}};if(G.parentId){const fe=o(),ae=fe.find(xe=>xe.id===G.parentId);if(ae){let xe=ae.measured?.width??(typeof ae.style?.width=="number"?ae.style.width:200),ye=ae.measured?.height??(typeof ae.style?.height=="number"?ae.style.height:120);for(const it of fe)it.parentId===G.parentId&&(xe=Math.max(xe,it.position.x+(it.measured?.width??160)),ye=Math.max(ye,it.position.y+(it.measured?.height??88)));ne[ae.id]={x:Math.round(ae.position.x),y:Math.round(ae.position.y),w:Math.round(xe),h:Math.round(ye)}}}T(ne)},[T,o]),ce=k.useCallback(async()=>{await _e.resetLayout(t).catch(()=>{});const B=await ss(H.nodes,H.edges),G=lo(B);Z(G),Y.setQueryData(We.layout(t),{positions:G}),_e.setLayout(t,G).catch(()=>{}),requestAnimationFrame(()=>s({padding:.18,duration:400}))},[t,H,s,Z,Y]),ue=i??I,ge=k.useMemo(()=>ue?Lw(ue,N):null,[ue,N]),be=k.useMemo(()=>Aw(z,e.overlay.origin),[z,e.overlay.origin]),Ee=k.useMemo(()=>Ow(A?.comments),[A?.comments]),Ie=k.useMemo(()=>Tw(A?.comments),[A?.comments]),qe=k.useMemo(()=>zw(Ee),[Ee]),Ze=k.useMemo(()=>{const B=z.map(ne=>{if(ne.type!=="classNode"&&ne.type!=="interfaceNode")return ne.className?{...ne,className:void 0}:ne;const fe=ge&&!ge.nodeIds.has(ne.id)?"is-dimmed":void 0;return ne.className===fe?ne:{...ne,className:fe}}),G=be?[be,...B]:B;return qe.length?[...G,...qe]:G},[z,ge,be,qe]),Ge=k.useMemo(()=>N.map(B=>{const G=B.data?.edgeClass??B.id.replace(/^edge-/,""),ne=m===`class.${G}`,fe=ge?ge.edgeIds.has(B.id)?"is-on":"is-dimmed":void 0,ae=ne?se("is-selected",fe):fe;if(ne){const xe="var(--color-primary)";return{...B,className:ae,data:{...B.data,selected:!0},style:{...B.style,stroke:xe,strokeWidth:3},markerEnd:typeof B.markerEnd=="object"?{...B.markerEnd,color:xe}:B.markerEnd}}return B.className===ae&&!B.data?.selected?B:{...B,className:ae,data:{...B.data,selected:!1}}}),[N,ge,m]);return a.jsxs(Xo,{nodes:Ze,edges:Ge,nodeTypes:Pl,edgeTypes:Uo,onNodesChange:Q,onEdgesChange:re,onNodeDragStop:ie,onNodeClick:(B,G)=>{G.id.startsWith("class.")?r(G.id):G.id.startsWith("iface.")?(p(`interface.${G.id.slice(6)}`),w(i===G.id?null:G.id)):G.id.startsWith("grp-")&&p(`module.${G.id.slice(4)}`)},onNodeMouseEnter:(B,G)=>(G.id.startsWith("class.")||G.id.startsWith("iface."))&&$(G.id),onNodeMouseLeave:()=>$(null),onEdgeClick:(B,G)=>{if(!G.id.startsWith("edge-"))return;const ne=G.data?.edgeClass??G.id.slice(5);p(`class.${ne}`)},onPaneClick:()=>{w(null),y(null)},minZoom:.15,nodesConnectable:!1,edgesFocusable:!0,proOptions:{hideAttribution:!0},children:[a.jsx(qo,{gap:18,size:1,color:"oklch(0.3 0.01 270)"}),a.jsx(_l,{}),a.jsx(Zo,{className:"!bg-card !border !border-border [&_button]:!bg-card [&_button]:!border-border [&_button]:!fill-foreground",showInteractive:!1,children:a.jsx(Et,{onClick:ce,title:"Auto-arrange (ELK) — clears manual layout",children:a.jsx(ba,{className:"h-4 w-4 text-foreground"})})}),a.jsx(Go,{pannable:!0,zoomable:!0,className:"!bg-card !border !border-border",nodeColor:B=>B.type==="classNode"?`oklch(0.6 0.13 ${B.data.hue})`:B.type==="interfaceNode"?"oklch(0.6 0.18 330)":"transparent",nodeStrokeWidth:0,maskColor:"oklch(0.17 0.01 270 / 0.7)"}),a.jsxs(rt,{position:"top-right",className:"flex gap-1.5",children:[Ie.length>0&&a.jsx(Ol,{threads:Ie,anchor:{ref:"section.schema",kind:"section"},excerpt:"Schema canvas"}),a.jsxs(Fe,{size:"xs",variant:c==="domains"?"default":"outline",onClick:()=>l(c==="domains"?null:"domains"),title:"Imported domains — shown in the right panel",children:[a.jsx(vt,{className:"h-3.5 w-3.5"})," Domains",a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:F.length})]}),a.jsxs(Fe,{size:"xs",variant:c==="views"?"default":"outline",onClick:()=>l(c==="views"?null:"views"),title:"Views — shown in the right panel",children:[a.jsx(hn,{className:"h-3.5 w-3.5"})," Views",a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:d})]}),a.jsxs(Fe,{size:"xs",variant:c==="integrations"?"default":"outline",onClick:()=>l(c==="integrations"?null:"integrations"),title:"Integrations — shown in the right panel",children:[a.jsx(jo,{className:"h-3.5 w-3.5"})," Integrations",a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:u})]}),a.jsxs(Fe,{size:"xs",variant:v?"default":"outline",onClick:j,title:"Toggle inherited (interface-induced) edges",children:[a.jsx(Tt,{className:"h-3.5 w-3.5"})," Inherited"]}),a.jsx(cl,{count:f})]})]})}const fo="integration.request.",Tl=e=>`${fo}${e}`,Vw=e=>e.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"integration";function Fw({name:e}){return a.jsx(bn,{anchor:{ref:`section.integrations.${e}`,kind:"section"},excerpt:`${e} integration`,children:a.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-1.5 py-1",children:[a.jsx(ke,{tone:"emerald",size:"sm",children:a.jsx(jo,{})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:e}),a.jsx("div",{className:"text-[11px] text-muted-foreground/70 leading-tight",children:"in integrations/"})]})]})})}function Bw({slug:e,label:t}){return a.jsx(bn,{anchor:{ref:Tl(e),kind:"section"},excerpt:`Add ${t} integration`,children:a.jsxs("div",{className:"flex items-center gap-2 rounded-lg px-1.5 py-1",children:[a.jsx(ke,{tone:"amber",size:"sm",children:a.jsx(jo,{})}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("div",{className:"truncate text-[13px] font-medium leading-tight",children:t}),a.jsx("div",{className:"text-[11px] text-muted-foreground/70 leading-tight",children:"requested"})]})]})})}function Ww({domainId:e,taken:t}){const{create:n}=ga(e),s=X(h=>h.setOpenAnchor),[o,i]=k.useState(!1),[r,c]=k.useState(""),[l,d]=k.useState(""),u=()=>{const h=r.trim();if(!h)return;const f=Tl(Vw(h)),p=`Add a "${h}" integration under the integrations/ folder${l.trim()?` — ${l.trim()}`:""}. Wire it up the Astrale way (DI, secrets, idempotency).`;n.mutate({anchors:[h],anchorRefs:[{ref:f,kind:"section"}],text:p,firstRole:"user",type:"text"},{onSuccess:()=>{c(""),d(""),i(!1),s(f),Wn.success("Integration requested — add the why/how in the comment")},onError:m=>Wn.error(String(m))})};return a.jsxs(Pt,{open:o,onOpenChange:i,children:[a.jsx(go,{asChild:!0,children:a.jsxs("button",{type:"button",className:"flex w-full items-center gap-1.5 rounded-lg px-2 py-1.5 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground",children:[a.jsx(Eo,{className:"h-3.5 w-3.5"}),"Request an integration"]})}),a.jsxs(Ot,{align:"start",side:"top",className:"w-64 p-2.5",children:[a.jsx("div",{className:"pb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Request an integration"}),a.jsx("input",{autoFocus:!0,value:r,onChange:h=>c(h.target.value),onKeyDown:h=>{h.key==="Enter"&&u()},placeholder:"Name (e.g. Stripe)",className:"mb-1.5 w-full rounded-md border bg-background px-2 py-1.5 text-[13px] outline-none focus:border-primary"}),a.jsx("textarea",{value:l,onChange:h=>d(h.target.value),placeholder:"Why / what for (optional)",rows:2,className:"mb-2 w-full resize-none rounded-md border bg-background px-2 py-1.5 text-[13px] outline-none focus:border-primary"}),a.jsx("button",{type:"button",onClick:u,disabled:!r.trim()||n.isPending,className:"w-full rounded-md bg-primary px-2 py-1.5 text-[12px] font-medium text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50",children:"Request"}),t.size>0&&a.jsxs("p",{className:"pt-2 text-[10px] leading-snug text-muted-foreground/50",children:["Already present: ",[...t].join(", ")]})]})]})}function Yw({domainId:e}){const{data:t}=ya(e),{data:n}=No(e),s=t?.detectedIntegrations??[],o=k.useMemo(()=>new Set(s),[s]),i=k.useMemo(()=>{const r=new Set,c=[];for(const l of n?.comments??[])if(l.status==="open")for(const d of l.anchorRefs){if(!d.ref.startsWith(fo))continue;const u=d.ref.slice(fo.length);o.has(u)||r.has(u)||(r.add(u),c.push({slug:u,label:l.anchors[0]??u}))}return c},[n,o]);return a.jsx(zt,{className:"h-full",children:a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"mb-5 flex items-baseline gap-2 pr-8",children:[a.jsx("h1",{className:"text-base font-semibold",children:"Integrations"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:s.length})]}),s.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"px-1.5 pb-1.5 pt-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Detected"}),a.jsx("div",{className:"flex flex-col gap-0.5",children:s.map(r=>a.jsx(Fw,{name:r},r))})]}),i.length>0&&a.jsxs(a.Fragment,{children:[s.length>0&&a.jsx(Bn,{className:"my-2 opacity-60"}),a.jsx("div",{className:"px-1.5 pb-1.5 pt-0.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"Requested"}),a.jsx("div",{className:"flex flex-col gap-0.5",children:i.map(r=>a.jsx(Bw,{slug:r.slug,label:r.label},r.slug))})]}),s.length===0&&i.length===0&&a.jsx("p",{className:"px-2 pb-1 pt-0.5 text-[11px] text-muted-foreground/60",children:"No integrations detected."}),a.jsx(Bn,{className:"my-3 opacity-60"}),a.jsx(Ww,{domainId:e,taken:o})]})})}function ct({onClose:e,children:t}){return a.jsxs("div",{className:"relative min-h-0 w-[420px] shrink-0 border-l bg-card/30",children:[a.jsx("button",{type:"button",onClick:e,"aria-label":"Close panel",title:"Close (Esc)",className:"absolute right-3.5 top-3.5 z-20 inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/50 transition-colors hover:bg-accent hover:text-foreground",children:a.jsx(Bu,{className:"h-4 w-4"})}),t]})}function ho(e,t){return t?e.members.some(n=>n.selectId===t)?!0:e.children.some(n=>ho(n,t)):!1}function zl({root:e,selected:t,onSelect:n,controls:s}){return a.jsxs("div",{className:"text-sm py-2","data-domain-id":s?.domainId,children:[a.jsx("div",{className:"px-3 pb-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Modules"}),e.children.map(o=>a.jsx(Ll,{node:o,depth:0,selected:t,onSelect:n,controls:s},o.path)),e.members.map(o=>a.jsx(Hl,{m:o,depth:1,selected:t,onSelect:n,controls:s},o.selectId))]})}function Ll({node:e,depth:t,selected:n,onSelect:s,controls:o}){const i=X(b=>b.collapsedModules),r=X(b=>b.toggleModule),c=o?.collapsedModules??i,l=o?.toggleModule??r,[d,u]=k.useState(!0),h=`module.${e.path}`,f=n===h,p=e.members.length>0,m=p?!c.includes(e.path)||ho(e,n):d||ho(e,n),w=()=>p?l(e.path):u(b=>!b),y={paddingLeft:8+t*12},x=m?tf:pn;return a.jsxs("div",{children:[a.jsxs("div",{"data-anchor-ref":h,"data-anchor-excerpt":e.path,className:se("flex items-center gap-0.5 pr-2 hover:bg-accent/50 rounded-md",f&&"bg-accent text-accent-foreground"),style:y,children:[a.jsx("button",{type:"button",onClick:w,className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-white/5",title:m?"Collapse":"Expand",children:m?a.jsx(ds,{className:"h-3 w-3"}):a.jsx(us,{className:"h-3 w-3"})}),a.jsxs("button",{type:"button",onClick:()=>s(h),className:se("flex items-center gap-1.5 flex-1 min-w-0 py-1 text-left font-bold",f&&"font-extrabold"),children:[a.jsx(x,{className:"h-3.5 w-3.5 shrink-0",style:{color:`oklch(0.78 0.12 ${e.hue})`}}),a.jsx("span",{className:"truncate",children:e.name})]}),a.jsx(Lt,{domainId:o?.domainId,anchorRef:{ref:h,kind:"section"},excerpt:e.path,className:"ml-1"})]}),m&&a.jsxs("div",{children:[e.children.map(b=>a.jsx(Ll,{node:b,depth:t+1,selected:n,onSelect:s,controls:o},b.path)),e.members.map(b=>a.jsx(Hl,{m:b,depth:t+1,selected:n,onSelect:s,controls:o},b.selectId))]})]})}function Hl({m:e,depth:t,selected:n,onSelect:s,controls:o}){const i=n===e.selectId,r=e.kind==="interface",c=X(g=>De(e.ref,g.hidden)),l=X(g=>g.toggleHidden),d=X(g=>ao(e.name,g.materializedInterfaces)),u=X(g=>g.toggleInterfaceMaterialized),h=o?De(e.ref,o.hidden):c,f=o?.toggleHidden??l,p=o?ao(e.name,o.materializedInterfaces):d,m=o?.toggleInterfaceMaterialized??u,w=!r&&h,y=e.kind==="interface"?Oe:e.kind==="edge"?Tt:Pe,x=e.kind==="interface"?"text-fuchsia-300":e.kind==="edge"?"text-amber-400":"text-sky-300",b=k.useRef(null);return k.useEffect(()=>{i&&b.current?.scrollIntoView({block:"nearest",behavior:"smooth"})},[i]),a.jsxs("div",{ref:b,"data-anchor-ref":e.selectId,"data-anchor-excerpt":`${e.kind} ${e.name}`,className:se("group w-full flex items-center pr-2 hover:bg-accent/50",i&&"bg-accent text-accent-foreground font-black",w&&"opacity-50"),style:{paddingLeft:8+(t+1)*12+12},title:`${e.kind} ${e.name}`,children:[a.jsxs("button",{type:"button",onClick:()=>s(e.selectId),className:"flex min-w-0 flex-1 items-center gap-1.5 py-1 text-left font-extrabold",children:[e.icon?a.jsx(we,{svg:e.icon,className:se("h-4 w-4 shrink-0",x)}):a.jsx(y,{className:se("h-3.5 w-3.5 shrink-0",x)}),a.jsx("span",{className:"truncate",children:e.name})]}),r?a.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),m(e.name)},title:p?"Collapse to badge":"Show as node",className:se("ml-1 shrink-0 rounded p-0.5 transition hover:bg-white/5",p?"text-fuchsia-300 opacity-100":"text-muted-foreground/60 opacity-0 hover:text-foreground group-hover:opacity-100"),children:p?a.jsx(Pe,{className:"h-3.5 w-3.5"}):a.jsx(pf,{className:"h-3.5 w-3.5"})}):a.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),f(e.ref)},title:h?"Show in canvas":"Hide in canvas",className:se("ml-1 shrink-0 rounded p-0.5 text-muted-foreground/60 transition hover:bg-white/5 hover:text-foreground",h?"opacity-100":"opacity-0 group-hover:opacity-100"),children:h?a.jsx(pa,{className:"h-3.5 w-3.5"}):a.jsx(ma,{className:"h-3.5 w-3.5"})}),a.jsx(Lt,{domainId:o?.domainId,anchorRef:{ref:e.selectId,kind:"schema"},excerpt:`${e.kind} ${e.name}`,className:"ml-1"})]})}const Xt={width:360,height:220},Vl={width:200,height:120},Dn=52,Xw=48,as=112,qw=1900;function Zw(e){const t=e.type==="classNode"||e.type==="interfaceNode"?{width:160,height:44}:e.type==="moduleNode"?{width:200,height:44}:Vl;return{width:e.measured?.width??(typeof e.style?.width=="number"?e.style.width:t.width),height:e.measured?.height??(typeof e.style?.height=="number"?e.style.height:t.height)}}function Gw(e){const t=e.filter(r=>!r.parentId);if(t.length===0)return{minX:0,minY:0,maxX:0,maxY:0};let n=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(const r of t){const c=Zw(r);n=Math.min(n,r.position.x),s=Math.min(s,r.position.y),o=Math.max(o,r.position.x+c.width),i=Math.max(i,r.position.y+c.height)}return{minX:n,minY:s,maxX:o,maxY:i}}function Uw(e){const t=[];let n=0,s=0,o=0;for(const i of e)n>0&&n+i.size.width>qw&&(n=0,s+=o+as,o=0),t.push({x:n,y:s}),n+=i.size.width+as,o=Math.max(o,i.size.height);return t}function Kw(e,t){const n=e.filter(i=>t[i.domainId]);if(n.length===0)return Uw(e);let s=n.reduce((i,r)=>{const c=t[r.domainId];return Math.max(i,c.x+r.size.width)},0);const o=n.reduce((i,r)=>Math.min(i,t[r.domainId].y),Number.POSITIVE_INFINITY);return e.map(i=>{const r=t[i.domainId];if(r)return r;s+=as;const c={x:s,y:Number.isFinite(o)?o:0};return s+=i.size.width,c})}function Qw(e,t,n,s){const o=e.map(r=>{const c=Gw(r.nodes),l=s[r.domainId]??{x:Dn-c.minX,y:Dn+Xw-c.minY},d={width:Math.max(Xt.width,c.maxX+l.x),height:Math.max(Xt.height,c.maxY+l.y)},u={width:Math.max(Xt.width,c.maxX+l.x+Dn),height:Math.max(Xt.height,c.maxY+l.y+Dn)},h=n[r.domainId];return{domainId:r.domainId,contentOffset:l,size:{width:h?Math.max(d.width,h.width):u.width,height:h?Math.max(d.height,h.height):u.height}}}),i=Kw(o,t);return o.map((r,c)=>({...r,position:i[c]}))}function Fl(e){return e.data?.workspaceGeometry??null}function Yi(e,t){const n=Fl(e);return n?{domainId:n.domainId,updates:{[n.localId]:{x:Math.round(e.position.x-n.offset.x),y:Math.round(e.position.y-n.offset.y),...t?{w:Math.round(t.width),h:Math.round(t.height)}:Cs(e)}}}:null}const Bl=k.createContext(null);function Jw({actions:e,children:t}){return a.jsx(Bl.Provider,{value:e,children:t})}function ir(){const e=k.useContext(Bl);if(!e)throw new Error("Workspace nodes require WorkspaceNodeActionsProvider");return e}function Wl({nodeId:e,minimum:t,label:n,placement:s="module"}){const o=ir();return a.jsx(ky,{position:"bottom-right",minWidth:t.width,minHeight:t.height,onResizeEnd:(i,r)=>o.resizeNode(e,{width:Math.round(r.width),height:Math.round(r.height)}),style:s==="domain"?{left:"calc(100% - 6px)",top:"calc(100% + 20px)"}:{left:"calc(100% + 20px)",top:"calc(100% + 20px)"},className:"nodrag nopan !flex !h-6 !w-6 !cursor-se-resize !items-start !justify-start !border-0 !bg-transparent !p-0",children:a.jsx("span",{"data-testid":`workspace-resize-${e}`,title:n,className:"block h-3 w-3 rounded-br-[3px] border-b-2 border-r-2 border-sky-300/60 opacity-45 transition-[opacity,border-color] hover:border-sky-200 hover:opacity-100 active:border-sky-100 active:opacity-100"})})}function ev({id:e,data:t}){const n=ir(),s=t;return a.jsxs("div",{"data-domain-id":s.domainId,title:s.active?void 0:`Click to activate ${s.origin}`,className:se("relative h-full w-full rounded-[22px] border-2 bg-card/[0.035] shadow-[0_24px_80px_-48px_rgba(0,0,0,0.9)] transition-colors",s.active?"border-sky-400/55 bg-sky-400/[0.045]":"cursor-pointer border-border/55 hover:border-border"),children:[a.jsxs("div",{"data-testid":`workspace-domain-header-${s.domainId}`,title:`Drag ${s.origin}`,onPointerDownCapture:()=>n.activateDomain(s.domainId),className:"workspace-domain-drag-handle absolute inset-x-0 top-0 flex h-12 cursor-grab select-none items-center gap-2 border-b border-border/35 px-4 active:cursor-grabbing",children:[a.jsx("span",{className:se("h-2 w-2 rounded-full",s.active?"bg-sky-300 shadow-[0_0_12px_rgba(125,211,252,0.8)]":"bg-muted-foreground/35")}),a.jsx("span",{className:"truncate text-[13px] font-extrabold tracking-tight",children:s.origin}),a.jsx("span",{className:"ml-auto rounded-full bg-muted/70 px-1.5 py-0.5 text-[9px] font-semibold tabular-nums text-muted-foreground",children:s.memberCount})]}),s.active&&a.jsx(Wl,{nodeId:e,minimum:Xt,label:`Resize ${s.origin}`,placement:"domain"})]})}function Xi(e){const t=ir(),n=Fl(e),s=e.data;return a.jsxs("div",{className:"relative h-full w-full",children:[a.jsx(uo,{...e,data:{...s,onToggleModule:t.toggleModule}}),e.type==="group"&&n?.active&&a.jsx(Wl,{nodeId:e.id,minimum:Vl,label:"Resize module"})]})}const tv={...Pl,group:Xi,moduleNode:Xi,workspaceDomain:ev},nv=216,sv=48,Yl=52,ov=12,qi=40,rv=e=>`workspace-external:${encodeURIComponent(e)}`,Xl=(e,t,n)=>`workspace-external-member:${encodeURIComponent(e)}:${n?`${n}:`:""}${encodeURIComponent(t)}`;function iv(e,t,n){return e.position.x<t.position.x+t.size.width+n&&e.position.x+e.size.width+n>t.position.x&&e.position.y<t.position.y+t.size.height+n&&e.position.y+e.size.height+n>t.position.y}function av(e,t,n,s){const o=e.ownerDomainIds.map(l=>t.get(l)).filter(l=>!!l),i=o.length>0?o:n,r=i.reduce((l,d)=>Math.max(l,d.position.x+d.size.width),0)+as;let c=i.reduce((l,d)=>Math.min(l,d.position.y),Number.POSITIVE_INFINITY);for(Number.isFinite(c)||(c=0);;){const l={position:{x:r,y:c},size:e.size},d=s.find(u=>iv(l,u,qi));if(!d)return l.position;c=d.position.y+d.size.height+qi}}function cv(e,t,n){const s=[...e].sort((r,c)=>r.origin.localeCompare(c.origin)).map(r=>({...r,size:{width:nv,height:sv+r.members.length*Yl+ov}})),o=new Map(t.map(r=>[r.domainId,r])),i=t.map(({position:r,size:c})=>({position:r,size:c}));for(const r of s){const c=n[r.origin];c&&i.push({position:c,size:r.size})}return s.map(r=>{const c=n[r.origin],l=c??av(r,o,t,i);return c||i.push({position:l,size:r.size}),{...r,position:l}})}function lv(e,t,n,s){const o=new Map((s??[]).map(c=>[c.origin,c])),i=cv(e,t,n),r=[];for(const c of i){const l=o.get(c.origin),d=rv(c.origin),u=c.origin==="kernel.astrale.ai"?"kernel":"external";r.push({id:d,type:"extDomain",position:c.position,draggable:!1,selectable:!1,data:{name:l?.name??c.origin.split(".")[0],origin:c.origin,kind:u,icon:l?.icon},style:c.size}),c.members.forEach((h,f)=>{r.push({id:Xl(c.origin,h.name,h.definition),type:"extMember",parentId:d,extent:"parent",draggable:!1,position:{x:12,y:42+f*Yl},data:{name:h.name,kind:u,definition:h.definition},style:{width:192,height:44}})})}return{nodes:r,positions:Object.fromEntries(i.map(c=>[c.origin,c.position]))}}const dv="oklch(0.76 0.16 35)",Pn="oklch(0.72 0.18 330)",uv=e=>`workspace-domain:${e}`,kt=(e,t)=>`workspace:${encodeURIComponent(e)}:${t}`;function fv(e,t){const n=new Set(t);return Object.fromEntries(Object.keys(e.bundle.ir?.interfaces??{}).filter(s=>!n.has(s)).map(s=>[s,!0]))}async function hv(e,t,n){const s=new Set(t),o=fv(e,n),i=Dl(e.bundle,s,e.visibility.hidden,e.visibility.showInheritedEdges,o),r=e.layout.positions,c=i.nodes.filter(u=>r[u.id]),l=i.nodes.filter(u=>!r[u.id]);let d;return l.length===0?d=r:c.length===0?d=lo(await ss(i.nodes,i.edges)):d={...r,...$l(c.map(u=>({node:u,position:r[u.id]})),l)},{input:e,collapsed:s,materialized:o,nodes:i.nodes.map(u=>Ml(u,d)),edges:i.edges}}function ql(e){return e.kind==="class"||e.kind==="interface"}function Zi(e){return e.refs!==void 0?e.refs.filter(ql):e.types}function Ut(e,t){const n=e.input.bundle.ir;if(!n)return[];const s=typeof t=="string"?t:t.name,o=r=>or(e.input.bundle,e.collapsed,e.materialized,r),i={types:[s],...typeof t=="string"?{}:{refs:[t]}};return tr(n,i,o).filter(r=>!r.cls||!De(cn(r.cls),e.input.visibility.hidden)).map(r=>{const c=r.ifaceNode?r.ifaceNode:e.collapsed.has(pt(e.input.bundle,r.cls))?`grp-${pt(e.input.bundle,r.cls)}`:`class.${r.cls}`;return{nodeId:kt(e.input.summary.id,c),domainId:e.input.summary.id,className:r.cls,viaInterface:r.viaInterface}})}function cs(e,t,n,s){const o=e.input.bundle.ir;if(!o)return[];const i=typeof t=="string"?t:t.name;let r;if(typeof t!="string"){if(r=t,r.origin===o.domain)return(r.kind==="interface"?!!o.interfaces[r.name]:o.classes[r.name]?.type==="node")?Ut(e,r):[]}else{if(o.classes[i]?.type==="node"||o.interfaces[i])return Ut(e,i);const l=o.imports[i];if(!l)return[];r=l.ref??{origin:l.origin,kind:l.definition,name:i}}const c=n.get(r.origin)??[];if(c.length>1&&s.add(`Multiple selected folders declare ${r.origin}; ${i} stays external.`),c.length===1){const l=c[0],d=l.input.bundle.ir;if(r.kind==="interface"?!!d?.interfaces[i]:d?.classes[i]?.type==="node")return Ut(l,r);s.add(`${e.input.summary.origin} imports ${r.origin}:${r.kind}.${i}, but the selected schema does not expose it.`)}return[{nodeId:Xl(r.origin,i,r.kind),domainId:null,className:null,viaInterface:null,unresolved:{origin:r.origin,name:i,definition:r.kind}}]}function Gi(e,t,n){return t!==void 0?t.filter(ql).filter(s=>s.kind==="interface"):n??[]}function Ui(e,t){if(typeof t!="string")return t.kind==="interface"&&t.origin!==e.domain?t:void 0;const n=e.imports[t];if(!(!n||n.definition!=="interface"))return n.ref??{origin:n.origin,kind:"interface",name:t}}function pv(e,t,n,s){return`workspace-edge:${encodeURIComponent(e)}:${t}:${n}:${s}`}function mv(e,t,n){const s=[],o=new Map,i=new Set,r=(c,l)=>{if(!c.unresolved)return;const d=o.get(c.unresolved.origin)??{members:new Map,ownerDomainIds:new Set};d.members.set(`${c.unresolved.definition}:${c.unresolved.name}`,c.unresolved),d.ownerDomainIds.add(l),o.set(c.unresolved.origin,d)};for(const c of e){const l=c.input.bundle.ir;if(l)for(const d of Object.values(l.classes)){if(d.type!=="edge"||d.endpoints?.length!==2||De(El(d.name),c.input.visibility.hidden))continue;const u=Zi(d.endpoints[0]).flatMap(p=>cs(c,p,t,n)),h=Zi(d.endpoints[1]).flatMap(p=>cs(c,p,t,n)),f=nr(d.endpoints[0].cardinality,d.endpoints[1].cardinality);for(const p of u)for(const m of h){if(!(p.domainId!==c.input.summary.id||m.domainId!==c.input.summary.id)||p.nodeId===m.nodeId||p.viaInterface&&!e.find(b=>b.input.summary.id===p.domainId)?.input.visibility.showInheritedEdges||m.viaInterface&&!e.find(b=>b.input.summary.id===m.domainId)?.input.visibility.showInheritedEdges)continue;r(p,c.input.summary.id),r(m,c.input.summary.id);const y=pv(c.input.summary.id,d.name,p.nodeId,m.nodeId);if(i.has(y))continue;i.add(y);const x=!!p.viaInterface||!!m.viaInterface;s.push({id:y,source:p.nodeId,target:m.nodeId,type:"floating",data:{label:d.name,edgeClass:d.name,ownerDomainId:c.input.summary.id,polymorphic:x},markerStart:f.markerStart,markerEnd:f.markerEnd,style:{stroke:dv,strokeWidth:2.5,...x?{strokeDasharray:"7 4"}:{}}})}}}return{edges:s,unresolved:[...o.entries()].map(([c,l])=>({origin:c,members:[...l.members.values()].sort((d,u)=>d.name.localeCompare(u.name)||d.definition.localeCompare(u.definition)),ownerDomainIds:[...l.ownerDomainIds]}))}}function gv(e,t,n){const s=[],o=new Set,i=r=>{o.has(r.id)||(o.add(r.id),s.push(r))};for(const r of e){const c=r.input.bundle.ir;if(c){for(const[l,d]of Object.entries(c.classes)){if(d.type!=="node")continue;const u=Ut(r,{origin:c.domain,kind:"class",name:l})[0];if(u)for(const h of Gi(c,d.implementsRefs,d.implements)){const f=Ui(c,h);if(!(!f||f.origin==="kernel.astrale.ai"))for(const p of cs(r,f,t,n)){if(p.unresolved)continue;const m=`workspace-implements:${u.nodeId}:${p.nodeId}`;i({id:m,source:u.nodeId,target:p.nodeId,type:"floating",data:{kind:"implements",ownerDomainId:r.input.summary.id},markerEnd:{type:Je.ArrowClosed,color:Pn,width:16,height:16},style:{stroke:Pn,strokeWidth:1.7,strokeDasharray:"7 4"}})}}}for(const l of Object.keys(c.interfaces)){const d=Ut(r,{origin:c.domain,kind:"interface",name:l})[0];if(!d)continue;const u=c.interfaces[l];for(const h of Gi(c,u?.extendsRefs,u?.extends)){const f=Ui(c,h);if(!(!f||f.origin==="kernel.astrale.ai"))for(const p of cs(r,f,t,n)){if(p.unresolved)continue;const m=`workspace-extends:${d.nodeId}:${p.nodeId}`;i({id:m,source:d.nodeId,target:p.nodeId,type:"floating",data:{label:"extends",kind:"extends",ownerDomainId:r.input.summary.id},markerEnd:{type:Je.ArrowClosed,color:Pn,width:16,height:16},style:{stroke:Pn,strokeWidth:1.7,strokeDasharray:"2 4"}})}}}}}return s}function xv(e,{activeDomainId:t,domainPositions:n={},externalPositions:s={},contentOffsets:o={},domainSizes:i={},catalog:r}){const c=new Set,l=new Map;for(const y of e){const x=y.input.bundle.ir?.domain??y.input.summary.origin,b=l.get(x)??[];b.push(y),l.set(x,b)}const d=Qw(e.map(y=>({domainId:y.input.summary.id,nodes:y.nodes})),n,i,o),u=new Map(d.map(y=>[y.domainId,y])),h=[],f=[];for(const y of e){const x=y.input.summary.id,b=u.get(x),g=uv(x),v=x===t;h.push({id:g,type:"workspaceDomain",position:b.position,draggable:!0,dragHandle:".workspace-domain-drag-handle",selectable:!0,data:{domainId:x,origin:y.input.summary.origin,memberCount:Object.keys(y.input.bundle.ir?.classes??{}).length+Object.keys(y.input.bundle.ir?.interfaces??{}).length,active:v},style:{width:b.size.width,height:b.size.height}});for(const E of y.nodes){const j=!E.parentId,S=j?b.contentOffset:{x:0,y:0};h.push({...E,id:kt(x,E.id),parentId:j?g:kt(x,E.parentId),position:{x:E.position.x+S.x,y:E.position.y+S.y},data:{...E.data,workspaceGeometry:{domainId:x,localId:E.id,offset:S,active:v}},extent:"parent",expandParent:!1,draggable:v,selectable:v,focusable:v,style:{...E.style,...v?{}:{pointerEvents:"none"}}})}for(const E of y.edges)f.push({...E,id:kt(x,E.id),source:kt(x,E.source),target:kt(x,E.target)})}const p=mv(e,l,c),m=gv(e,l,c),w=lv(p.unresolved,d,s,r);return h.push(...w.nodes),f.push(...p.edges,...m),{nodes:h,edges:f,diagnostics:[...c].sort(),domainPositions:Object.fromEntries(d.map(y=>[y.domainId,y.position])),externalPositions:w.positions,contentOffsets:Object.fromEntries(d.map(y=>[y.domainId,y.contentOffset]))}}function yv(e){if(!e.startsWith("workspace:"))return null;const[,t,...n]=e.split(":");return!t||n.length===0?null:{domainId:decodeURIComponent(t),localId:n.join(":")}}function wv({domains:e,viewsCount:t,onToggleInherited:n}){const{fitView:s,getNode:o}=Ht(),{data:i}=ln(),r=X(P=>P.domainId)??e[0]?.input.summary.id??"",c=X(P=>P.selectedClass),l=X(P=>P.setDomain),d=X(P=>P.setPanelOverlay),u=X(P=>P.panelOverlay),h=pe(P=>P.domainPositions),f=pe(P=>P.externalPositions),p=pe(P=>P.domainSizes),m=pe(P=>P.domainContentOffsets),w=pe(P=>P.setDomainPosition),y=pe(P=>P.setDomainSize),x=pe(P=>P.ensureDomainPositions),b=pe(P=>P.ensureExternalPositions),g=pe(P=>P.ensureDomainContentOffsets),v=pe(P=>P.resetWorkspaceFrames),E=pe(P=>P.toggleModule),{commitLayout:j}=Rl(),S=k.useRef(""),R=k.useRef(!1),A=k.useCallback((P,W)=>{if(P.startsWith("workspace-domain:")){y(P.slice(17),W);return}const Y=o(P);if(!Y||Y.type!=="group")return;const J=Yi(Y,W);J&&j(J.domainId,J.updates)},[j,o,y]),V=k.useCallback((P,W)=>{if(X.getState().domainId!==P){l(P);return}W&&X.getState().selectClass(W)},[l]),O=k.useCallback((P,W)=>{if(X.getState().domainId!==P){l(P);return}E(P,W)},[l,E]),z=k.useMemo(()=>({activateDomain:V,resizeNode:A,toggleModule:O}),[V,A,O]),M=k.useMemo(()=>xv(e,{activeDomainId:r,catalog:i,contentOffsets:m,domainPositions:h,domainSizes:p,externalPositions:f}),[r,i,m,h,p,e,f]),[N,C]=k.useState(M.nodes),[I,$]=k.useState(()=>os(M.edges));k.useEffect(()=>{if(x(M.domainPositions),b(M.externalPositions),g(M.contentOffsets),C(M.nodes),$(os(M.edges)),R.current){R.current=!1;const Y=requestAnimationFrame(()=>s({padding:.12,duration:420}));return()=>cancelAnimationFrame(Y)}const P=e.map(Y=>Y.input.summary.id).join("|");if(S.current===P)return;S.current=P;const W=requestAnimationFrame(()=>s({padding:.12,duration:420}));return()=>cancelAnimationFrame(W)},[e,g,x,b,s,M]);const _=k.useCallback(P=>C(W=>Ns(P.filter(Y=>Y.type!=="remove"),W)),[]),D=k.useCallback(P=>$(W=>ks(P.filter(Y=>Y.type!=="remove"),W)),[]),L=e.every(P=>P.input.visibility.showInheritedEdges),H=k.useCallback((P,W)=>{if(W.id.startsWith("workspace-domain:")){w(W.id.slice(17),{x:Math.round(W.position.x),y:Math.round(W.position.y)});return}const Y=Yi(W);Y&&j(Y.domainId,Y.updates)},[j,w]),F=k.useMemo(()=>I.map(P=>{const W=P.data?.ownerDomainId,Y=P.data?.edgeClass;if(!(!!Y&&W===r&&c===`class.${Y}`))return P;const U="var(--color-primary)";return{...P,className:se(P.className,"is-selected"),data:{...P.data,selected:!0},style:{...P.style,stroke:U,strokeWidth:3},markerEnd:typeof P.markerEnd=="object"?{...P.markerEnd,color:U}:P.markerEnd}}),[r,I,c]);return a.jsx(Jw,{actions:z,children:a.jsxs(Xo,{"data-testid":"workspace-schema-canvas",nodes:N,edges:F,nodeTypes:tv,edgeTypes:Uo,onNodesChange:_,onEdgesChange:D,onNodeDragStop:H,onNodeClick:(P,W)=>{if(W.id.startsWith("workspace-domain:")){V(W.id.slice(17));return}const Y=yv(W.id);Y&&(Y.localId.startsWith("class.")?V(Y.domainId,Y.localId):Y.localId.startsWith("iface.")?V(Y.domainId,`interface.${Y.localId.slice(6)}`):Y.localId.startsWith("grp-")&&V(Y.domainId,`module.${Y.localId.slice(4)}`))},onEdgeClick:(P,W)=>{const Y=W.data?.ownerDomainId,J=W.data?.edgeClass;Y&&J&&V(Y,`class.${J}`)},onPaneClick:()=>X.getState().setFocus(null),minZoom:.08,nodesConnectable:!1,edgesFocusable:!0,onlyRenderVisibleElements:!0,proOptions:{hideAttribution:!0},children:[a.jsx(qo,{gap:18,size:1,color:"oklch(0.3 0.01 270)"}),a.jsx(_l,{}),a.jsx(Zo,{className:"!border !border-border !bg-card [&_button]:!border-border [&_button]:!bg-card [&_button]:!fill-foreground",showInteractive:!1,children:a.jsx(Et,{onClick:()=>{R.current=!0,v()},title:"Reset and auto-pack workspace regions",children:a.jsx(ba,{className:"h-4 w-4 text-foreground"})})}),a.jsx(Go,{pannable:!0,zoomable:!0,className:"!border !border-border !bg-card",nodeColor:P=>P.type==="classNode"?`oklch(0.6 0.13 ${P.data.hue})`:P.type==="interfaceNode"?"oklch(0.6 0.18 330)":P.type==="workspaceDomain"?"oklch(0.52 0.08 225 / 0.45)":"transparent",nodeStrokeWidth:0,maskColor:"oklch(0.17 0.01 270 / 0.72)"}),M.diagnostics.length>0&&a.jsx(rt,{position:"top-center",className:"max-w-xl",children:a.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-warning/30 bg-card/95 px-3 py-2 text-[11px] text-warning shadow-lg backdrop-blur",children:[a.jsx(ht,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),a.jsx("span",{children:M.diagnostics.join(" ")})]})}),a.jsxs(rt,{position:"top-right",className:"flex gap-1.5",children:[a.jsxs(Fe,{size:"xs",variant:"outline",disabled:!0,title:"Selected workspace domains",children:[a.jsx(bo,{className:"h-3.5 w-3.5"})," Domains",a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:e.length})]}),a.jsxs(Fe,{size:"xs",variant:u==="views"?"default":"outline",onClick:()=>d(u==="views"?null:"views"),title:"Views across selected domains",children:[a.jsx(hn,{className:"h-3.5 w-3.5"})," Views",a.jsx("span",{className:"rounded-full bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:t})]}),a.jsxs(Fe,{size:"xs",variant:L?"default":"outline",onClick:n,title:"Toggle inherited edges in every selected domain",children:[a.jsx(Tt,{className:"h-3.5 w-3.5"})," Inherited"]})]})]})})}function vv({domains:e,onToggleHidden:t}){const n=X(f=>f.domainId),s=X(f=>f.selectedClass),o=X(f=>f.setDomain),i=pe(f=>f.collapsedModules),r=pe(f=>f.badgeInterfaces),c=pe(f=>f.toggleModule),l=pe(f=>f.toggleInterface),[d,u]=k.useState({}),h=(f,p)=>{X.getState().domainId!==f&&o(f),p&&X.getState().selectClass(p)};return a.jsxs("div",{className:"py-2","data-testid":"workspace-module-tree",children:[a.jsxs("div",{className:"flex items-center gap-1.5 px-3 pb-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:[a.jsx(bo,{className:"h-3 w-3"})," Workspace modules"]}),e.map(f=>{const p=f.input.summary.id,m=n===p,w=!!d[p],y=Object.fromEntries(Object.keys(f.input.bundle.ir?.interfaces??{}).filter(g=>!(r[p]??[]).includes(g)).map(g=>[g,!0])),x={domainId:p,collapsedModules:i[p]??[],hidden:f.input.visibility.hidden,materializedInterfaces:y,toggleModule:g=>c(p,g),toggleHidden:g=>t(p,g),toggleInterfaceMaterialized:g=>l(p,g)},b=va(f.input.bundle);return a.jsxs("section",{className:"border-b border-border/40 last:border-b-0",children:[a.jsxs("div",{"data-domain-id":p,className:se("flex items-center gap-1 px-2 py-2 transition-colors",m?"bg-sky-400/[0.075]":"hover:bg-accent/30"),children:[a.jsx("button",{type:"button",onClick:()=>u(g=>{const v={...g};return v[p]?delete v[p]:v[p]=!0,v}),className:"rounded p-0.5 text-muted-foreground hover:bg-white/5",title:w?"Expand domain":"Collapse domain",children:w?a.jsx(us,{className:"h-3.5 w-3.5"}):a.jsx(ds,{className:"h-3.5 w-3.5"})}),a.jsx("button",{type:"button",onClick:()=>h(p),className:"min-w-0 flex-1 truncate text-left text-[12px] font-extrabold",title:`Make ${f.input.summary.origin} active`,children:f.input.summary.origin}),m&&a.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-sky-300",title:"Active"})]}),!w&&a.jsx("div",{className:"border-t border-border/25 bg-background/15",children:a.jsx(zl,{root:b,selected:m?s:void 0,onSelect:g=>h(p,g),controls:x})})]},p)})]})}const bv={positions:{}},Nv={hidden:{},showInheritedEdges:!0,materializedInterfaces:{}};function kv(e,t){const n=kn({queries:e.map(r=>({queryKey:We.bundle(r),queryFn:()=>_e.bundle(r)}))}),s=kn({queries:e.map(r=>({queryKey:We.anatomy(r),queryFn:()=>_e.anatomy(r)}))}),o=kn({queries:e.map(r=>({queryKey:We.layout(r),queryFn:()=>_e.layout(r)}))}),i=kn({queries:e.map(r=>({queryKey:We.visibility(r),queryFn:()=>_e.visibility(r)}))});return k.useMemo(()=>{const r=new Map((t??[]).map(u=>[u.id,u])),c=[],l=[];let d=!1;return e.forEach((u,h)=>{const f=r.get(u),p=n[h]?.data,m=s[h]?.data,w=n[h]?.error??s[h]?.error;if(w&&l.push(`${f?.origin??u}: ${String(w)}`),!f||!p||!m){d=d||!w;return}c.push({summary:f,bundle:p,anatomy:m,layout:o[h]?.data??bv,visibility:i[h]?.data??Nv})}),{inputs:c,pending:d,errors:l}},[s,n,t,e,o,i])}function jv({inputs:e}){const t=e.map(o=>({input:o,model:Wu(o.anatomy,o.bundle)})),n=t.reduce((o,i)=>o+i.model.all.length,0),s=t.some(o=>o.model.hasDrift);return a.jsx(zt,{className:"h-full","data-testid":"workspace-views-panel",children:a.jsxs("div",{className:"p-5",children:[a.jsxs("div",{className:"mb-5 flex items-baseline gap-2 pr-8",children:[a.jsx("h1",{className:"text-base font-semibold",children:"Workspace views"}),a.jsx("span",{className:"text-xs text-muted-foreground",children:n}),s&&a.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-medium text-warning",children:[a.jsx(ht,{className:"h-3.5 w-3.5"})," drift"]})]}),n===0&&a.jsx(qt,{icon:a.jsx(hn,{}),title:"No views",hint:"The selected domains declare no views."}),a.jsx("div",{className:"space-y-7",children:t.filter(o=>o.model.all.length>0).map(({input:o,model:i})=>a.jsxs("section",{"data-domain-id":o.summary.id,children:[a.jsxs("div",{className:"mb-2 flex items-center gap-2 border-b border-border/45 pb-2",children:[a.jsx("span",{className:"h-2 w-2 rounded-full bg-sky-300/80"}),a.jsx("h2",{className:"min-w-0 flex-1 truncate text-[13px] font-extrabold",children:o.summary.origin}),a.jsx("span",{className:"rounded-full bg-muted px-1.5 py-0.5 text-[9px] tabular-nums text-muted-foreground",children:i.all.length})]}),a.jsx("div",{className:"space-y-0.5",children:i.all.map(r=>{const c=r.boundClass?o.bundle.ir?.classes[r.boundClass]?.icon:void 0;return a.jsx(is,{domainId:o.summary.id,view:r,icon:c},`${o.summary.id}:${r.slug}`)})})]},o.summary.id))})]})})}const Ki=220,Qi=620,Ev=300;function Ji(e,t,n){return[e.summary.id,e.summary.origin,e.bundle.schemaHash,Object.keys(e.visibility.hidden).sort().join(","),e.visibility.showInheritedEdges,Object.entries(e.layout.positions).sort(([s],[o])=>s.localeCompare(o)).map(([s,o])=>`${s}:${o.x}:${o.y}:${o.w??""}:${o.h??""}`).join(","),t.slice().sort().join(","),n.slice().sort().join(",")].join("|")}function Cv({domainIds:e}){const{data:t}=Yu(),{inputs:n,pending:s,errors:o}=kv(e,t),i=ls(),r=X(M=>M.domainId),c=X(M=>M.selectedClass),l=X(M=>M.selectClass),d=X(M=>M.setFocus),u=X(M=>M.panelOverlay),h=X(M=>M.setPanelOverlay),f=X(M=>M.setCanvasMode),p=pe(M=>M.collapsedModules),m=pe(M=>M.badgeInterfaces),[w,y]=k.useState([]),x=k.useRef(new Map),[b,g]=k.useState(()=>{try{const M=Number(localStorage.getItem("studio.workspaceModulesWidth"));if(Number.isFinite(M)&&M>=Ki&&M<=Qi)return M}catch{}return Ev});k.useEffect(()=>{f("schema"),X.getState().panelOverlay&&X.getState().panelOverlay!=="views"&&h(null)},[f,h]);const v=k.useMemo(()=>n.map(M=>Ji(M,p[M.summary.id]??[],m[M.summary.id]??[])).join("::"),[m,p,n]);k.useEffect(()=>{let M=!1;const N=new Set(n.map(C=>C.summary.id));for(const C of x.current.keys())N.has(C)||x.current.delete(C);return Promise.all(n.map(async C=>{const I=C.summary.id,$=p[I]??[],_=m[I]??[],D=Ji(C,$,_),L=x.current.get(I);if(L?.key===D)return{...L.projection,input:C};const H=await hv(C,$,_);return M||x.current.set(I,{key:D,projection:H}),H})).then(C=>{M||y(C)}),()=>{M=!0}},[v]),k.useEffect(()=>{const M=N=>{N.key!=="Escape"||N.defaultPrevented||(d(null),l(void 0),h(null))};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[l,d,h]);const E=k.useCallback((M,N)=>{const C=n.find($=>$.summary.id===M);if(!C)return;const I=N(C.visibility);i.setQueryData(We.visibility(M),I),_e.setVisibility(M,I).catch(()=>{i.invalidateQueries({queryKey:We.visibility(M)})})},[n,i]),j=k.useCallback((M,N)=>E(M,C=>{const I={...C.hidden};return I[N]?delete I[N]:I[N]=!0,{...C,hidden:I}}),[E]),S=k.useCallback(()=>{const M=!n.every(N=>N.visibility.showInheritedEdges);for(const N of n)E(N.summary.id,C=>({...C,showInheritedEdges:M}))},[n,E]),R=M=>{M.preventDefault();const N=M.clientX,C=b;let I=C;const $=D=>{I=Math.min(Qi,Math.max(Ki,C+D.clientX-N)),g(I)},_=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",_),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem("studio.workspaceModulesWidth",String(I))}catch{}};document.addEventListener("pointermove",$),document.addEventListener("pointerup",_),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},A=n.find(M=>M.summary.id===r),V=n.reduce((M,N)=>M+N.anatomy.views.length,0),O=w.length===n.length&&n.length===e.length,z=w.map(M=>`${M.input.summary.id}:${M.input.bundle.schemaHash}`).join("|");return(s||!O)&&o.length===0?a.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Composing workspace…"}):a.jsxs("div",{className:"flex h-full flex-col","data-testid":"workspace-schema-section",children:[(o.length>0||n.some(M=>M.bundle.error))&&a.jsxs("div",{className:"flex items-start gap-2 border-b border-warning/30 bg-warning/10 px-4 py-2 text-sm text-warning",children:[a.jsx(ht,{className:"mt-0.5 h-4 w-4 shrink-0"}),a.jsx("span",{children:[...o,...n.flatMap(M=>M.bundle.error?.message??[])].join(" ")})]}),a.jsxs("div",{className:"flex min-h-0 flex-1",children:[a.jsxs("div",{className:"relative min-h-0 shrink-0 border-r",style:{width:b},children:[a.jsx(zt,{className:"h-full",children:a.jsx(vv,{domains:w,onToggleHidden:j})}),a.jsx("div",{role:"separator","aria-orientation":"vertical",onPointerDown:R,title:"Drag to resize",className:"group absolute right-0 top-0 z-20 h-full w-1.5 translate-x-1/2 cursor-col-resize",children:a.jsx("div",{className:"mx-auto h-full w-px bg-transparent transition-colors group-hover:bg-primary/50"})})]}),a.jsx("div",{className:"relative min-w-0 flex-1",children:a.jsx(Yo,{children:a.jsx(wv,{domains:w,viewsCount:V,onToggleInherited:S})},z)}),u==="views"?a.jsx(ct,{onClose:()=>h(null),children:a.jsx(jv,{inputs:n})}):c&&A?a.jsx(ct,{onClose:()=>l(void 0),children:a.jsx(gl,{bundle:A.bundle,selected:c})}):null]})]})}const ea=180,ta=560,Sv=240;function Mv({domainId:e}){const t=pe(s=>s.selectedDomainIds),n=t.includes(e)?t:[e,...t];return n.length>1?a.jsx(Cv,{domainIds:n}):a.jsx(Iv,{domainId:e})}function Iv({domainId:e}){const{data:t,isLoading:n}=xo(e),{data:s}=Xu(e),{data:o}=wa(e),i=X(g=>g.selectedClass),r=X(g=>g.selectClass),c=X(g=>g.setFocus),l=X(g=>g.canvasMode),d=l==="core",u=X(g=>g.panelOverlay),h=X(g=>g.setPanelOverlay),f=yo(e),[p,m]=k.useState(()=>{try{const g=Number(localStorage.getItem("studio.modulesWidth"));if(Number.isFinite(g)&&g>=ea&&g<=ta)return g}catch{}return Sv}),w=g=>{g.preventDefault();const v=g.clientX,E=p;let j=E;const S=A=>{j=Math.min(ta,Math.max(ea,E+(A.clientX-v))),m(j)},R=()=>{document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",R),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem("studio.modulesWidth",String(j))}catch{}};document.addEventListener("pointermove",S),document.addEventListener("pointerup",R),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[y,x]=k.useState(null);k.useEffect(()=>x(null),[e,l]),k.useEffect(()=>{const g=v=>{v.key!=="Escape"||v.defaultPrevented||(c(null),r(void 0),x(null),h(null))};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[c,r,h]);const b=k.useMemo(()=>t?.ir?va(t):null,[t]);return n||!t?a.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"Introspecting schema…"}):a.jsxs("div",{className:"h-full flex flex-col",children:[t.error&&a.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-warning/10 border-b border-warning/30 text-warning text-sm",children:[a.jsx(ht,{className:"h-4 w-4 shrink-0"}),a.jsxs("span",{children:[t.error.message,!t.depsInstalled&&" — showing the static structure; run `pnpm install` in the domain for full fidelity."]})]}),t.ir?a.jsxs("div",{className:"flex-1 flex min-h-0",children:[a.jsxs("div",{className:"relative border-r shrink-0 min-h-0",style:{width:p},children:[a.jsx(zt,{className:"h-full",children:d?o&&a.jsx(Hy,{core:o,bundle:t,selectedPath:y,onSelect:x}):b&&a.jsx(zl,{root:b,selected:i,onSelect:r})}),a.jsx("div",{role:"separator","aria-orientation":"vertical",onPointerDown:w,title:"Drag to resize",className:"group absolute right-0 top-0 z-20 h-full w-1.5 translate-x-1/2 cursor-col-resize",children:a.jsx("div",{className:"mx-auto h-full w-px bg-transparent transition-colors group-hover:bg-primary/50"})})]}),a.jsx("div",{className:"flex-1 min-w-0 relative",children:a.jsx(Yo,{children:d?o?a.jsx(zy,{core:o,bundle:t,selectedPath:y,onSelect:x}):a.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:"Extracting core…"}):a.jsx(Hw,{bundle:t,domainId:e,saved:s?.positions},e)},`${e}:${l}`)}),d?y&&o&&a.jsx(ct,{onClose:()=>x(null),children:a.jsx(Vy,{core:o,bundle:t,selectedPath:y})}):u==="views"?a.jsx(ct,{onClose:()=>h(null),children:a.jsx(Qy,{domainId:e,model:f})}):u==="domains"?a.jsx(ct,{onClose:()=>h(null),children:a.jsx(xw,{domainId:e})}):u==="integrations"?a.jsx(ct,{onClose:()=>h(null),children:a.jsx(Yw,{domainId:e})}):i?a.jsx(ct,{onClose:()=>r(void 0),children:a.jsx(gl,{bundle:t,selected:i})}):null]}):a.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm p-6 text-center",children:"No compiled schema available."})]})}export{Mv as SchemaSection};