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

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 (282) hide show
  1. package/README.md +16 -1
  2. package/dist/astrale.js +51105 -58057
  3. package/dist/public/connect-core.js +2085 -30702
  4. package/dist/public/keys/index.js +884 -29476
  5. package/dist/public/paths/index.js +13101 -41452
  6. package/dist/types/admin/contract.d.ts +26 -0
  7. package/dist/types/admin/instance/client.d.ts +20 -0
  8. package/dist/types/admin/instance/index.d.ts +2 -0
  9. package/dist/types/admin/instance/model.d.ts +6 -10
  10. package/dist/types/connection/auth.d.ts +3 -0
  11. package/dist/types/connection/call.d.ts +3 -0
  12. package/dist/types/connection/command.d.ts +27 -0
  13. package/dist/types/connection/credential.d.ts +14 -0
  14. package/dist/types/connection/errors.d.ts +1 -0
  15. package/dist/types/connection/exchange.d.ts +9 -0
  16. package/dist/types/connection/failure/classify.d.ts +2 -0
  17. package/dist/types/connection/failure/index.d.ts +5 -0
  18. package/dist/types/connection/failure/model.d.ts +25 -0
  19. package/dist/types/connection/failure/render.d.ts +3 -0
  20. package/dist/types/connection/index.d.ts +8 -0
  21. package/dist/types/connection/reasons.d.ts +37 -0
  22. package/dist/types/connection/self.d.ts +37 -0
  23. package/dist/types/connection/session.d.ts +31 -0
  24. package/dist/types/connection/target.d.ts +38 -0
  25. package/dist/types/errors.d.ts +1 -1
  26. package/dist/types/lib/admin-instance.d.ts +17 -0
  27. package/dist/types/lib/admin-target.d.ts +11 -36
  28. package/dist/types/lib/config.d.ts +7 -59
  29. package/dist/types/lib/failure-debug.d.ts +1 -0
  30. package/dist/types/lib/idp.d.ts +25 -173
  31. package/dist/types/lib/instance-target.d.ts +1 -1
  32. package/dist/types/lib/instance.d.ts +30 -88
  33. package/dist/types/lib/log.d.ts +5 -3
  34. package/dist/types/lib/output.d.ts +1 -1
  35. package/dist/types/lib/proc.d.ts +43 -0
  36. package/dist/types/lib/self.d.ts +9 -0
  37. package/dist/types/lib/update.d.ts +109 -0
  38. package/dist/types/lib/validation.d.ts +4 -1
  39. package/package.json +15 -20
  40. package/src/__tests__/fixtures/publication.ts +20 -0
  41. package/src/admin/.spec/architecture.md +12 -5
  42. package/src/admin/__tests__/fixture.ts +25 -0
  43. package/src/admin/catalog/.spec/api.d.ts +1 -3
  44. package/src/admin/catalog/.spec/architecture.md +5 -4
  45. package/src/admin/catalog/__tests__/client.test.ts +143 -69
  46. package/src/admin/catalog/client.ts +40 -54
  47. package/src/admin/catalog/model.ts +3 -4
  48. package/src/admin/contract.ts +46 -0
  49. package/src/admin/graph/.spec/api.d.ts +4 -10
  50. package/src/admin/graph/nodes.ts +1 -1
  51. package/src/admin/instance/.spec/api.d.ts +5 -9
  52. package/src/admin/instance/.spec/architecture.md +7 -7
  53. package/src/admin/instance/__tests__/client.test.ts +157 -175
  54. package/src/admin/instance/client.ts +39 -128
  55. package/src/admin/instance/index.ts +1 -2
  56. package/src/admin/instance/model.ts +12 -18
  57. package/src/commands/__tests__/admin-instance.test.ts +11 -8
  58. package/src/commands/__tests__/call-describe.test.ts +46 -33
  59. package/src/commands/__tests__/call.test.ts +34 -0
  60. package/src/commands/__tests__/domain-install-operation.test.ts +7 -22
  61. package/src/commands/__tests__/domain-install-owned.test.ts +1 -1
  62. package/src/commands/__tests__/domain-list.test.ts +5 -25
  63. package/src/commands/__tests__/install-direct.test.ts +115 -8
  64. package/src/commands/__tests__/install-identity-override.test.ts +3 -14
  65. package/src/commands/__tests__/instance-list-rows.test.ts +1 -1
  66. package/src/commands/__tests__/instance-status.test.ts +139 -0
  67. package/src/commands/__tests__/introspect-parse.test.ts +80 -1
  68. package/src/commands/__tests__/logs.test.ts +250 -2
  69. package/src/commands/__tests__/read-commands.test.ts +62 -10
  70. package/src/commands/__tests__/token-ttl.test.ts +49 -4
  71. package/src/commands/__tests__/update.test.ts +25 -3
  72. package/src/commands/__tests__/view.test.ts +49 -0
  73. package/src/commands/call-describe.ts +60 -68
  74. package/src/commands/call.ts +71 -59
  75. package/src/commands/domain/install.ts +54 -35
  76. package/src/commands/domain/list.ts +1 -1
  77. package/src/commands/domain/publish.ts +14 -11
  78. package/src/commands/domain/uninstall.ts +2 -2
  79. package/src/commands/get.ts +14 -15
  80. package/src/commands/identity/__tests__/register.test.ts +3 -3
  81. package/src/commands/identity/register.ts +5 -4
  82. package/src/commands/instance/create.ts +8 -16
  83. package/src/commands/instance/delete.ts +12 -9
  84. package/src/commands/instance/list.ts +2 -2
  85. package/src/commands/instance/status.ts +66 -20
  86. package/src/commands/instance/use.ts +16 -12
  87. package/src/commands/introspect.ts +48 -35
  88. package/src/commands/logs.ts +123 -33
  89. package/src/commands/mutate.ts +6 -5
  90. package/src/commands/query.ts +35 -32
  91. package/src/commands/token.ts +42 -27
  92. package/src/commands/ui/__tests__/commands.test.ts +152 -0
  93. package/src/commands/ui/add.ts +51 -0
  94. package/src/commands/ui/doctor.ts +13 -0
  95. package/src/commands/ui/init.ts +38 -0
  96. package/src/commands/ui/list.ts +26 -0
  97. package/src/commands/ui/preset-apply.ts +19 -0
  98. package/src/commands/ui/preset-list.ts +12 -0
  99. package/src/commands/ui/shared.ts +25 -0
  100. package/src/commands/update.ts +31 -11
  101. package/src/commands/view.ts +82 -37
  102. package/src/connection/.spec/api.d.ts +7 -8
  103. package/src/connection/.spec/architecture.md +5 -4
  104. package/src/connection/.spec/flows/session.ts +2 -2
  105. package/src/connection/.spec/laws/connection.ts +6 -2
  106. package/src/connection/.spec/layout.ts +1 -0
  107. package/src/connection/__tests__/credential.test.ts +20 -1
  108. package/src/connection/__tests__/errors.test.ts +27 -20
  109. package/src/connection/__tests__/exchange.test.ts +30 -1
  110. package/src/connection/__tests__/failure-fixtures.ts +39 -0
  111. package/src/connection/__tests__/failure-safety.test.ts +75 -0
  112. package/src/connection/__tests__/self.test.ts +31 -11
  113. package/src/connection/__tests__/session.test.ts +3 -3
  114. package/src/connection/__tests__/target.test.ts +1 -0
  115. package/src/connection/auth.ts +13 -0
  116. package/src/connection/call.ts +1 -1
  117. package/src/connection/credential.ts +2 -2
  118. package/src/connection/errors.ts +1 -355
  119. package/src/connection/exchange.ts +47 -23
  120. package/src/connection/failure/classify.ts +110 -0
  121. package/src/connection/failure/index.ts +18 -0
  122. package/src/connection/failure/model.ts +28 -0
  123. package/src/connection/failure/render.ts +116 -0
  124. package/src/connection/reasons.ts +16 -0
  125. package/src/connection/self.ts +39 -21
  126. package/src/connection/session.ts +19 -8
  127. package/src/errors.ts +3 -2
  128. package/src/graph/.spec/api.d.ts +12 -5
  129. package/src/graph/.spec/layout.ts +9 -1
  130. package/src/graph/__tests__/mutation.test.ts +2 -2
  131. package/src/graph/__tests__/query.test.ts +25 -6
  132. package/src/graph/class.ts +30 -0
  133. package/src/graph/index.ts +1 -0
  134. package/src/graph/query.ts +21 -32
  135. package/src/identity/.spec/api.d.ts +2 -2
  136. package/src/identity/__tests__/registration.test.ts +1 -1
  137. package/src/identity/registration.ts +3 -3
  138. package/src/keys/__tests__/keys.test.ts +4 -0
  139. package/src/keys/credential.ts +1 -0
  140. package/src/lib/__tests__/admin-target.test.ts +12 -0
  141. package/src/lib/__tests__/binary.test.ts +16 -1
  142. package/src/lib/__tests__/command-dx.test.ts +1 -1
  143. package/src/lib/__tests__/domain-publication.test.ts +10 -16
  144. package/src/lib/__tests__/idp.test.ts +34 -4
  145. package/src/lib/__tests__/instance-candidates.test.ts +1 -3
  146. package/src/lib/__tests__/instance-target.test.ts +7 -39
  147. package/src/lib/__tests__/log-errors.test.ts +64 -0
  148. package/src/lib/__tests__/studio-server-deps.test.ts +1 -1
  149. package/src/lib/__tests__/update.test.ts +264 -11
  150. package/src/lib/__tests__/view-assets.test.ts +14 -0
  151. package/src/lib/__tests__/view-external-open-intent.test.ts +150 -0
  152. package/src/lib/__tests__/view-external-open-origins.test.ts +27 -0
  153. package/src/lib/__tests__/view-open-intent.test.ts +0 -2
  154. package/src/lib/__tests__/view-server.test.ts +26 -3
  155. package/src/lib/__tests__/view-session.test.ts +2 -1
  156. package/src/lib/admin-instance.ts +14 -8
  157. package/src/lib/admin-target.ts +21 -2
  158. package/src/lib/binary.ts +22 -5
  159. package/src/lib/command-dx.ts +9 -9
  160. package/src/lib/domain-publication.ts +9 -7
  161. package/src/lib/failure-debug.ts +26 -0
  162. package/src/lib/idp.ts +34 -3
  163. package/src/lib/instance-candidates.ts +2 -2
  164. package/src/lib/instance-target.ts +3 -14
  165. package/src/lib/instance.ts +16 -11
  166. package/src/lib/log.ts +16 -9
  167. package/src/lib/output.ts +1 -1
  168. package/src/lib/proc.ts +7 -2
  169. package/src/lib/provision-instance.ts +34 -57
  170. package/src/lib/update.ts +298 -45
  171. package/src/lib/validation.ts +2 -2
  172. package/src/lib/view/assets.ts +11 -2
  173. package/src/lib/view/external-open-intent.ts +41 -0
  174. package/src/lib/view/external-open-origins.ts +37 -0
  175. package/src/lib/view/host-capabilities.ts +17 -0
  176. package/src/lib/view/resolve.ts +1 -1
  177. package/src/lib/view/server.ts +18 -3
  178. package/src/lib/view/session.ts +2 -0
  179. package/src/program/.spec/api.d.ts +1 -0
  180. package/src/program/__tests__/program.test.ts +163 -6
  181. package/src/program/argv.ts +14 -0
  182. package/src/program/build.ts +26 -4
  183. package/src/program/command.ts +1 -0
  184. package/src/program/index.ts +1 -0
  185. package/src/program/registry.ts +2 -1
  186. package/src/setup/__tests__/instance-step.test.ts +27 -10
  187. package/src/setup/steps/instance.ts +22 -15
  188. package/src/telemetry/__tests__/recorder.test.ts +1 -0
  189. package/src/telemetry/recorder.ts +9 -1
  190. package/src/ui/.spec/api.d.ts +14 -0
  191. package/src/ui/.spec/architecture.md +10 -0
  192. package/src/ui/.spec/laws.ts +36 -0
  193. package/src/ui/.spec/layout.ts +16 -0
  194. package/src/ui/__tests__/ui.test.ts +981 -0
  195. package/src/ui/index.ts +13 -0
  196. package/src/ui/lock.ts +87 -0
  197. package/src/ui/model.ts +83 -0
  198. package/src/ui/operations.ts +710 -0
  199. package/src/ui/project.ts +219 -0
  200. package/src/ui/release.ts +321 -0
  201. package/src/ui/runner.ts +18 -0
  202. package/studio/client/dist/assets/elk-api-DjmKsHXc.js +1 -0
  203. package/studio/client/dist/assets/index-7YHdeCxp.js +81 -0
  204. package/studio/client/dist/assets/index-C0FAnwNw.css +2 -0
  205. package/studio/client/dist/assets/rolldown-runtime-Dd_uD5pT.js +1 -0
  206. package/studio/client/dist/assets/schema-studio-BilUNb6Z.css +1 -0
  207. package/studio/client/dist/assets/schema-studio-CABpTfvH.js +8 -0
  208. package/studio/client/dist/index.html +3 -2
  209. package/studio/package.json +7 -13
  210. package/studio/server/agent/ask.test.ts +1 -1
  211. package/studio/server/agent/bridge/grant.test.ts +1 -1
  212. package/studio/server/agent/bridge/routes.test.ts +1 -1
  213. package/studio/server/agent/harness/claude/adapter.test.ts +15 -5
  214. package/studio/server/agent/harness/gateway/token.test.ts +1 -1
  215. package/studio/server/agent/harness/gateway/token.ts +3 -3
  216. package/studio/server/agent/prompts/anchors.test.ts +32 -36
  217. package/studio/server/agent/prompts/anchors.ts +20 -49
  218. package/studio/server/agent/prompts/system.test.ts +3 -2
  219. package/studio/server/agent/prompts/system.ts +3 -3
  220. package/studio/server/agent/routes.test.ts +1 -1
  221. package/studio/server/agent/run/coordinator.test.ts +1 -1
  222. package/studio/server/api/canvas.ts +0 -1
  223. package/studio/server/api-agent-loadout.test.ts +1 -1
  224. package/studio/server/api.test.ts +1 -1
  225. package/studio/server/cache.test.ts +23 -12
  226. package/studio/server/cache.ts +12 -15
  227. package/studio/server/domain.test.ts +50 -68
  228. package/studio/server/domain.ts +82 -63
  229. package/studio/server/handoff/copy.ts +1 -1
  230. package/studio/server/index.ts +1 -1
  231. package/studio/server/instances/probe.test.ts +1 -1
  232. package/studio/server/introspect/anatomy/views/routes.ts +46 -37
  233. package/studio/server/introspect/anatomy/views.ts +9 -14
  234. package/studio/server/introspect/anatomy-extras.test.ts +26 -42
  235. package/studio/server/introspect/anatomy.test.ts +22 -14
  236. package/studio/server/introspect/anatomy.ts +6 -9
  237. package/studio/server/introspect/bundle.ts +0 -3
  238. package/studio/server/introspect/canonical-schema.test.ts +94 -389
  239. package/studio/server/introspect/canonical-schema.ts +227 -457
  240. package/studio/server/introspect/core-extractor.ts +18 -127
  241. package/studio/server/introspect/core.ts +1 -2
  242. package/studio/server/introspect/diff.test.ts +11 -7
  243. package/studio/server/introspect/diff.ts +18 -55
  244. package/studio/server/introspect/extractor.ts +22 -117
  245. package/studio/server/introspect/overlay-tsmorph.test.ts +119 -240
  246. package/studio/server/introspect/overlay.test.ts +26 -54
  247. package/studio/server/introspect/overlay.ts +10 -37
  248. package/studio/server/introspect/revision.test.ts +1 -1
  249. package/studio/server/introspect/revision.ts +1 -1
  250. package/studio/server/introspect/runtime.test.ts +65 -183
  251. package/studio/server/introspect/runtime.ts +8 -25
  252. package/studio/server/introspect/schema-ir-json.test.ts +70 -0
  253. package/studio/server/introspect/schema-ir-json.ts +38 -68
  254. package/studio/server/introspect/schema-refs.test.ts +43 -88
  255. package/studio/server/introspect/schema-refs.ts +14 -49
  256. package/studio/server/introspect/source-overlay/handlers.ts +116 -636
  257. package/studio/server/introspect/source-overlay/kernel-calls.ts +0 -3
  258. package/studio/server/introspect/source-overlay/spans.ts +15 -45
  259. package/studio/server/state/baseline.test.ts +14 -9
  260. package/studio/server/state/baseline.ts +3 -5
  261. package/studio/server/state/visibility.ts +1 -5
  262. package/studio/server/views/model.ts +3 -3
  263. package/studio/server/views/target.test.ts +17 -74
  264. package/studio/server/views/target.ts +24 -50
  265. package/studio/server/watch.test.ts +11 -11
  266. package/studio/server/watch.ts +8 -4
  267. package/studio/server/workspace-watch.ts +2 -2
  268. package/studio/shared/contracts/schema.ts +38 -107
  269. package/studio/shared/contracts/surface.test.ts +13 -15
  270. package/studio/shared/contracts/workspace.ts +2 -11
  271. package/studio/shared/schema/identity.test.ts +20 -44
  272. package/studio/shared/schema/identity.ts +9 -23
  273. package/viewer/dist/main.js +30 -51
  274. package/.check-workspace.cjs +0 -40
  275. package/src/admin/binding.ts +0 -168
  276. package/src/commands/__tests__/instance-create-hosts.test.ts +0 -29
  277. package/studio/client/dist/assets/elk-api-lwhFo7vB.js +0 -1
  278. package/studio/client/dist/assets/index-B-c-smo9.js +0 -8
  279. package/studio/client/dist/assets/index-BckHuAWk.js +0 -81
  280. package/studio/client/dist/assets/index-C4aNQ6dz.css +0 -1
  281. package/studio/client/dist/assets/index-ChOr3yP0.css +0 -1
  282. package/studio/server/introspect/anatomy/views/legacy.ts +0 -232
@@ -1,8 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/elk-api-lwhFo7vB.js","assets/index-BckHuAWk.js","assets/index-C4aNQ6dz.css"])))=>i.map(i=>d[i]);
2
- import{S as Wd,n as Fs,s as Yd,r as Xd,Q as na,u as ls,a as qd,b as Zd,c as j,e as Gd,d as Ud,f as Kd,g as Qd,h as mr,i as Jd,j as eu,k as ve,l as sa,m as tu,R as nu,o as a,p as su,_ as ou,q as oa,t as X,P as zt,v as po,M as ra,w as se,x as Tt,T as mo,y as ru,B as Fe,z as Lt,A as Oe,N as iu,C as ia,D as au,E as ds,F as us,G as De,H as Je,I as cu,J as _e,K as lu,L as du,O as uu,U as fu,V as hu,W as aa,X as Bs,Y as go,Z as pu,$ as ca,a0 as xo,a1 as Ht,a2 as mt,a3 as Gt,a4 as la,a5 as Be,a6 as mu,a7 as je,a8 as gu,a9 as Vt,aa as xu,ab as Nt,ac as yu,ad as fs,ae as da,af as wu,ag as yo,ah as un,ai as fn,aj as hn,ak as vu,al as bu,am as me,an as ua,ao as Nu,ap as ft,aq as ju,ar as ku,as as Eu,at as Cu,au as Su,av as ze,aw as wo,ax as at,ay as vo,az as pn,aA as bo,aB as Iu,aC as _u,aD as Mu,aE as $u,aF as Ru,aG as Au,aH as Du,aI as fa,aJ as ha,aK as No,aL as Wn,aM as pa,aN as ma,aO as ga,aP as Yn,aQ as We,aR as Pu,aS as gt,aT as xa,aU as Ou,aV as ya,aW as wa,aX as zu,aY as Tu,aZ as pe,a_ as va,a$ as Lu,b0 as Hu,b1 as Vu}from"./index-BckHuAWk.js";function gr(e,t){const n=new Set(t);return e.filter(s=>!n.has(s))}function Fu(e,t,n){const s=e.slice(0);return s[t]=n,s}var Bu=class extends Wd{#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,f)=>u!==n[f]),l=r||c,d=l?!0:i.some((u,f)=>{const h=this.#e[f];return!h||!Yd(u,h)});!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(f=>{this.#h(u,f)})})),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=Xd(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=Fu(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 En({queries:e,...t},n){const s=ls(),o=qd(),i=Zd(),r=j.useMemo(()=>e.map(w=>{const y=s.defaultQueryOptions(w);return y._optimisticResults=o?"isRestoring":"optimistic",y}),[e,s,o]);r.forEach(w=>{Gd(w);const y=s.getQueryCache().get(w.queryHash);Ud(w,i,y)}),Kd(i);const[c]=j.useState(()=>new Bu(s,r,t)),[l,d,u]=c.getOptimisticResult(r,t.combine),f=!o&&t.subscribed!==!1;j.useSyncExternalStore(j.useCallback(w=>f?c.subscribe(Fs.batchCalls(w)):Qd,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),j.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 Jd(x,b,i)}return[]}):[];if(p.length>0)throw Promise.all(p);const m=l.find((w,y)=>{const x=r[y];return x&&eu({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 Wu=[["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"}]],mn=ve("AppWindow",Wu);const Yu=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Xu=ve("ArrowLeft",Yu);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"}]],jo=ve("CircleAlert",qu);const Zu=[["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"}]],gn=ve("FolderClosed",Zu);const Gu=[["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"}]],Uu=ve("FolderOpen",Gu);const Ku=[["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"}]],Qu=ve("FolderTree",Ku);const Ju=[["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"}]],ef=ve("Hexagon",Ju);const tf=[["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",tf);const nf=[["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"}]],sf=ve("MessageSquarePlus",nf);const of=[["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",of);const rf=[["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"}]],ko=ve("Plug",rf);const af=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Eo=ve("Plus",af);const cf=[["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"}]],lf=ve("SquareDashed",cf);const df=[["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",df);const uf=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],ff=ve("UserRound",uf);function fe(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=fe(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var hf={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 Tn(n)}function Tn(e){this._=e}function pf(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}})}Tn.prototype=hs.prototype={constructor:Tn,on:function(e,t){var n=this._,s=pf(e+"",n),o,i=-1,r=s.length;if(arguments.length<2){for(;++i<r;)if((o=(e=s[i]).type)&&(o=mf(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 Tn(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 mf(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]=hf,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 gf(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 xf(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Na(e){var t=ps(e);return(t.local?xf:gf)(t)}function yf(){}function Co(e){return e==null?yf:function(){return this.querySelector(e)}}function wf(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 vf(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function bf(){return[]}function ja(e){return e==null?bf:function(){return this.querySelectorAll(e)}}function Nf(e){return function(){return vf(e.apply(this,arguments))}}function jf(e){typeof e=="function"?e=Nf(e):e=ja(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 ka(e){return function(){return this.matches(e)}}function Ea(e){return function(t){return t.matches(e)}}var kf=Array.prototype.find;function Ef(e){return function(){return kf.call(this.children,e)}}function Cf(){return this.firstElementChild}function Sf(e){return this.select(e==null?Cf:Ef(typeof e=="function"?e:Ea(e)))}var If=Array.prototype.filter;function _f(){return Array.from(this.children)}function Mf(e){return function(){return If.call(this.children,e)}}function $f(e){return this.selectAll(e==null?_f:Mf(typeof e=="function"?e:Ea(e)))}function Rf(e){typeof e!="function"&&(e=ka(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 Af(){return new Se(this._enter||this._groups.map(Ca),this._parents)}function Xn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Xn.prototype={constructor:Xn,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 Df(e){return function(){return e}}function Pf(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 Xn(e,i[r]);for(;r<l;++r)(c=t[r])&&(o[r]=c)}function Of(e,t,n,s,o,i,r){var c,l,d=new Map,u=t.length,f=i.length,h=new Array(u),p;for(c=0;c<u;++c)(l=t[c])&&(h[c]=p=r.call(l,l.__data__,c,t)+"",d.has(p)?o[c]=l:d.set(p,l));for(c=0;c<f;++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 Xn(e,i[c]);for(c=0;c<u;++c)(l=t[c])&&d.get(h[c])===l&&(o[c]=l)}function zf(e){return e.__data__}function Tf(e,t){if(!arguments.length)return Array.from(this,zf);var n=t?Of:Pf,s=this._parents,o=this._groups;typeof e!="function"&&(e=Df(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],f=o[d],h=f.length,p=Lf(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(h);n(u,f,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 Lf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Hf(){return new Se(this._exit||this._groups.map(Ca),this._parents)}function Vf(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 Ff(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],f=d.length,h=c[l]=new Array(f),p,m=0;m<f;++m)(p=d[m]||u[m])&&(h[m]=p);for(;l<o;++l)c[l]=n[l];return new Se(c,this._parents)}function Bf(){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 Wf(e){e||(e=Yf);function t(f,h){return f&&h?e(f.__data__,h.__data__):!f-!h}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 Yf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Xf(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function qf(){return Array.from(this)}function Zf(){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 Gf(){let e=0;for(const t of this)++e;return e}function Uf(){return!this.node()}function Kf(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 Qf(e){return function(){this.removeAttribute(e)}}function Jf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function eh(e,t){return function(){this.setAttribute(e,t)}}function th(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function nh(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function sh(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 oh(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?Jf:Qf:typeof t=="function"?n.local?sh:nh:n.local?th:eh)(n,t))}function Sa(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function rh(e){return function(){this.style.removeProperty(e)}}function ih(e,t,n){return function(){this.style.setProperty(e,t,n)}}function ah(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function ch(e,t,n){return arguments.length>1?this.each((t==null?rh:typeof t=="function"?ah:ih)(e,t,n??"")):$t(this.node(),e)}function $t(e,t){return e.style.getPropertyValue(t)||Sa(e).getComputedStyle(e,null).getPropertyValue(t)}function lh(e){return function(){delete this[e]}}function dh(e,t){return function(){this[e]=t}}function uh(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function fh(e,t){return arguments.length>1?this.each((t==null?lh:typeof t=="function"?uh:dh)(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 hh(e){return function(){Ma(this,e)}}function ph(e){return function(){$a(this,e)}}function mh(e,t){return function(){(t.apply(this,arguments)?Ma:$a)(this,e)}}function gh(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"?mh:t?hh:ph)(n,t))}function xh(){this.textContent=""}function yh(e){return function(){this.textContent=e}}function wh(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function vh(e){return arguments.length?this.each(e==null?xh:(typeof e=="function"?wh:yh)(e)):this.node().textContent}function bh(){this.innerHTML=""}function Nh(e){return function(){this.innerHTML=e}}function jh(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function kh(e){return arguments.length?this.each(e==null?bh:(typeof e=="function"?jh:Nh)(e)):this.node().innerHTML}function Eh(){this.nextSibling&&this.parentNode.appendChild(this)}function Ch(){return this.each(Eh)}function Sh(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ih(){return this.each(Sh)}function _h(e){var t=typeof e=="function"?e:Na(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Mh(){return null}function $h(e,t){var n=typeof e=="function"?e:Na(e),s=t==null?Mh:typeof t=="function"?t:Co(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function Rh(){var e=this.parentNode;e&&e.removeChild(this)}function Ah(){return this.each(Rh)}function Dh(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Ph(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Oh(e){return this.select(e?Ph:Dh)}function zh(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Th(e){return function(t){e.call(this,t,this.__data__)}}function Lh(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 Hh(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 Vh(e,t,n){return function(){var s=this.__on,o,i=Th(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 Fh(e,t,n){var s=Lh(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?Vh:Hh,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 Bh(e,t){return function(){return Ra(this,e,t)}}function Wh(e,t){return function(){return Ra(this,e,t.apply(this,arguments))}}function Yh(e,t){return this.each((typeof t=="function"?Wh:Bh)(e,t))}function*Xh(){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 xn(){return new Se([[document.documentElement]],Aa)}function qh(){return this}Se.prototype=xn.prototype={constructor:Se,select:wf,selectAll:jf,selectChild:Sf,selectChildren:$f,filter:Rf,data:Tf,enter:Af,exit:Hf,join:Vf,merge:Ff,selection:qh,order:Bf,sort:Wf,call:Xf,nodes:qf,node:Zf,size:Gf,empty:Uf,each:Kf,attr:oh,style:ch,property:fh,classed:gh,text:vh,html:kh,raise:Ch,lower:Ih,append:_h,insert:$h,remove:Ah,clone:Oh,datum:zh,on:Fh,dispatch:Yh,[Symbol.iterator]:Xh};function Ce(e){return typeof e=="string"?new Se([[document.querySelector(e)]],[document.documentElement]):new Se([[e]],Aa)}function Zh(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Me(e,t){if(e=Zh(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 Gh={passive:!1},Jt={capture:!0,passive:!1};function Is(e){e.stopImmediatePropagation()}function _t(e){e.preventDefault(),e.stopImmediatePropagation()}function Da(e){var t=e.document.documentElement,n=Ce(e).on("dragstart.drag",_t,Jt);"onselectstart"in t?n.on("selectstart.drag",_t,Jt):(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",_t,Jt),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 Cn=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 Uh(e){return!e.ctrlKey&&!e.button}function Kh(){return this.parentNode}function Qh(e,t){return t??{x:e.x,y:e.y}}function Jh(){return navigator.maxTouchPoints||"ontouchstart"in this}function Oa(){var e=Uh,t=Kh,n=Qh,s=Jh,o={},i=hs("start","drag","end"),r=0,c,l,d,u,f=0;function h(v){v.on("mousedown.drag",p).filter(s).on("touchstart.drag",y).on("touchmove.drag",x,Gh).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 k=g(this,t.call(this,v,E),v,E,"mouse");k&&(Ce(v.view).on("mousemove.drag",m,Jt).on("mouseup.drag",w,Jt),Da(v.view),Is(v),d=!1,c=v.clientX,l=v.clientY,k("start",v))}}function m(v){if(_t(v),!d){var E=v.clientX-c,k=v.clientY-l;d=E*E+k*k>f}o.mouse("drag",v)}function w(v){Ce(v.view).on("mousemove.drag mouseup.drag",null),Pa(v.view,d),_t(v),o.mouse("end",v)}function y(v,E){if(e.call(this,v,E)){var k=v.changedTouches,S=t.call(this,v,E),R=k.length,A,L;for(A=0;A<R;++A)(L=g(this,S,v,E,k[A].identifier,k[A]))&&(Is(v),L("start",v,k[A]))}}function x(v){var E=v.changedTouches,k=E.length,S,R;for(S=0;S<k;++S)(R=o[E[S].identifier])&&(_t(v),R("drag",v,E[S]))}function b(v){var E=v.changedTouches,k=E.length,S,R;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),S=0;S<k;++S)(R=o[E[S].identifier])&&(Is(v),R("end",v,E[S]))}function g(v,E,k,S,R,A){var L=i.copy(),O=Me(A||k,E),H,_,N;if((N=n.call(v,new Ys("beforestart",{sourceEvent:k,target:h,identifier:R,active:r,x:O[0],y:O[1],dx:0,dy:0,dispatch:L}),S))!=null)return H=N.x-O[0]||0,_=N.y-O[1]||0,function C(I,$,M){var D=O,V;switch(I){case"start":o[R]=C,V=r++;break;case"end":delete o[R],--r;case"drag":O=Me(M||$,E),V=r;break}L.call(I,v,new Ys(I,{sourceEvent:$,subject:N,target:h,identifier:R,active:V,x:O[0]+H,y:O[1]+_,dx:O[0]-D[0],dy:O[1]-D[1],dispatch:L}),S)}}return h.filter=function(v){return arguments.length?(e=typeof v=="function"?v:Cn(!!v),h):e},h.container=function(v){return arguments.length?(t=typeof v=="function"?v:Cn(v),h):t},h.subject=function(v){return arguments.length?(n=typeof v=="function"?v:Cn(v),h):n},h.touchable=function(v){return arguments.length?(s=typeof v=="function"?v:Cn(!!v),h):s},h.on=function(){var v=i.on.apply(i,arguments);return v===i?h:v},h.clickDistance=function(v){return arguments.length?(f=(v=+v)*v,h):Math.sqrt(f)},h}function Io(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function za(e,t){var n=Object.create(e.prototype);for(var s in t)n[s]=t[s];return n}function yn(){}var en=.7,qn=1/en,Mt="\\s*([+-]?\\d+)\\s*",tn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ye="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ep=/^#([0-9a-f]{3,8})$/,tp=new RegExp(`^rgb\\(${Mt},${Mt},${Mt}\\)$`),np=new RegExp(`^rgb\\(${Ye},${Ye},${Ye}\\)$`),sp=new RegExp(`^rgba\\(${Mt},${Mt},${Mt},${tn}\\)$`),op=new RegExp(`^rgba\\(${Ye},${Ye},${Ye},${tn}\\)$`),rp=new RegExp(`^hsl\\(${tn},${Ye},${Ye}\\)$`),ip=new RegExp(`^hsla\\(${tn},${Ye},${Ye},${tn}\\)$`),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(yn,xt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Nr,formatHex:Nr,formatHex8:ap,formatHsl:cp,formatRgb:jr,toString:jr});function Nr(){return this.rgb().formatHex()}function ap(){return this.rgb().formatHex8()}function cp(){return Ta(this).formatHsl()}function jr(){return this.rgb().formatRgb()}function xt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=ep.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?kr(t):n===3?new Ne(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Sn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Sn(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=tp.exec(e))?new Ne(t[1],t[2],t[3],1):(t=np.exec(e))?new Ne(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=sp.exec(e))?Sn(t[1],t[2],t[3],t[4]):(t=op.exec(e))?Sn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=rp.exec(e))?Sr(t[1],t[2]/100,t[3]/100,1):(t=ip.exec(e))?Sr(t[1],t[2]/100,t[3]/100,t[4]):br.hasOwnProperty(e)?kr(br[e]):e==="transparent"?new Ne(NaN,NaN,NaN,0):null}function kr(e){return new Ne(e>>16&255,e>>8&255,e&255,1)}function Sn(e,t,n,s){return s<=0&&(e=t=n=NaN),new Ne(e,t,n,s)}function lp(e){return e instanceof yn||(e=xt(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?lp(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,za(yn,{brighter(e){return e=e==null?qn:Math.pow(qn,e),new Ne(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?en:Math.pow(en,e),new Ne(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ne(ht(this.r),ht(this.g),ht(this.b),Zn(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:dp,formatRgb:Cr,toString:Cr}));function Er(){return`#${ut(this.r)}${ut(this.g)}${ut(this.b)}`}function dp(){return`#${ut(this.r)}${ut(this.g)}${ut(this.b)}${ut((isNaN(this.opacity)?1:this.opacity)*255)}`}function Cr(){const e=Zn(this.opacity);return`${e===1?"rgb(":"rgba("}${ht(this.r)}, ${ht(this.g)}, ${ht(this.b)}${e===1?")":`, ${e})`}`}function Zn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ht(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ut(e){return e=ht(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 Ta(e){if(e instanceof $e)return new $e(e.h,e.s,e.l,e.opacity);if(e instanceof yn||(e=xt(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 up(e,t,n,s){return arguments.length===1?Ta(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,up,za(yn,{brighter(e){return e=e==null?qn:Math.pow(qn,e),new $e(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?en:Math.pow(en,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),In(this.s),In(this.l),Zn(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=Zn(this.opacity);return`${e===1?"hsl(":"hsla("}${Ir(this.h)}, ${In(this.s)*100}%, ${In(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ir(e){return e=(e||0)%360,e<0?e+360:e}function In(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 fp(e,t){return function(n){return e+n*t}}function hp(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 pp(e){return(e=+e)==1?La:function(t,n){return n-t?hp(t,n,e):_o(isNaN(t)?n:t)}}function La(e,t){var n=t-e;return n?fp(e,n):_o(isNaN(e)?t:e)}const Gn=(function e(t){var n=pp(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 mp(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 gp(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function xp(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]=Ut(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 yp(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 wp(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]=Ut(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 vp(e){return function(){return e}}function bp(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]?bp(l[0].x):vp(t):(t=l.length,function(d){for(var u=0,f;u<t;++u)c[(f=l[u]).i]=f.x(d);return c.join("")})}function Ut(e,t){var n=typeof t,s;return t==null||n==="boolean"?_o(t):(n==="number"?Ve:n==="string"?(s=xt(t))?(t=s,Gn):Ha:t instanceof xt?Gn:t instanceof Date?yp:gp(t)?mp:Array.isArray(t)?xp:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?wp: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 _n;function Np(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 jp(e){return e==null||(_n||(_n=document.createElementNS("http://www.w3.org/2000/svg","g")),_n.setAttribute("transform",e),!(e=_n.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,f,h,p,m){if(d!==f||u!==h){var w=p.push("translate(",null,t,null,n);m.push({i:w-4,x:Ve(d,f)},{i:w-2,x:Ve(u,h)})}else(f||h)&&p.push("translate("+f+t+h+n)}function r(d,u,f,h){d!==u?(d-u>180?u+=360:u-d>180&&(d+=360),h.push({i:f.push(o(f)+"rotate(",null,s)-2,x:Ve(d,u)})):u&&f.push(o(f)+"rotate("+u+s)}function c(d,u,f,h){d!==u?h.push({i:f.push(o(f)+"skewX(",null,s)-2,x:Ve(d,u)}):u&&f.push(o(f)+"skewX("+u+s)}function l(d,u,f,h,p,m){if(d!==f||u!==h){var w=p.push(o(p)+"scale(",null,",",null,")");m.push({i:w-4,x:Ve(d,f)},{i:w-2,x:Ve(u,h)})}else(f!==1||h!==1)&&p.push(o(p)+"scale("+f+","+h+")")}return function(d,u){var f=[],h=[];return d=e(d),u=e(u),i(d.translateX,d.translateY,u.translateX,u.translateY,f,h),r(d.rotate,u.rotate,f,h),c(d.skewX,u.skewX,f,h),l(d.scaleX,d.scaleY,u.scaleX,u.scaleY,f,h),d=u=null,function(p){for(var m=-1,w=h.length,y;++m<w;)f[(y=h[m]).i]=y.x(p);return f.join("")}}}var kp=Fa(Np,"px, ","px)","deg)"),Ep=Fa(jp,", ",")",")"),Cp=1e-12;function Mr(e){return((e=Math.exp(e))+1/e)/2}function Sp(e){return((e=Math.exp(e))-1/e)/2}function Ip(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ln=(function e(t,n,s){function o(i,r){var c=i[0],l=i[1],d=i[2],u=r[0],f=r[1],h=r[2],p=u-c,m=f-l,w=p*p+m*m,y,x;if(w<Cp)x=Math.log(h/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=(h*h-d*d+s*w)/(2*d*n*b),v=(h*h-d*d-s*w)/(2*h*n*b),E=Math.log(Math.sqrt(g*g+1)-g),k=Math.log(Math.sqrt(v*v+1)-v);x=(k-E)/t,y=function(S){var R=S*x,A=Mr(E),L=d/(n*b)*(A*Ip(t*R+E)-Sp(E));return[c+L*p,l+L*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 Rt=0,Xt=0,Wt=0,Ba=1e3,Un,qt,Kn=0,yt=0,ms=0,nn=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 yt||(Wa(_p),yt=nn.now()+ms)}function _p(){yt=0}function Qn(){this._call=this._time=this._next=null}Qn.prototype=Ya.prototype={constructor:Qn,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&&qt!==this&&(qt?qt._next=this:Un=this,qt=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 Qn;return s.restart(e,t,n),s}function Mp(){Mo(),++Rt;for(var e=Un,t;e;)(t=yt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Rt}function $r(){yt=(Kn=nn.now())+ms,Rt=Xt=0;try{Mp()}finally{Rt=0,Rp(),yt=0}}function $p(){var e=nn.now(),t=e-Kn;t>Ba&&(ms-=t,Kn=e)}function Rp(){for(var e,t=Un,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:Un=n);qt=e,Gs(s)}function Gs(e){if(!Rt){Xt&&(Xt=clearTimeout(Xt));var t=e-yt;t>24?(e<1/0&&(Xt=setTimeout($r,e-nn.now()-ms)),Wt&&(Wt=clearInterval(Wt))):(Wt||(Kn=nn.now(),Wt=setInterval($p,Ba)),Rt=1,Wa($r))}}function Rr(e,t,n){var s=new Qn;return t=t==null?0:+t,s.restart(o=>{s.stop(),e(o+t)},t,n),s}var Ap=hs("start","end","cancel","interrupt"),Dp=[],Xa=0,Ar=1,Us=2,Hn=3,Dr=4,Ks=5,Vn=6;function gs(e,t,n,s,o,i){var r=e.__transition;if(!r)e.__transition={};else if(n in r)return;Pp(e,n,{name:t,index:s,group:o,on:Ap,tween:Dp,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Xa})}function $o(e,t){var n=Le(e,t);if(n.state>Xa)throw new Error("too late; already scheduled");return n}function Xe(e,t){var n=Le(e,t);if(n.state>Hn)throw new Error("too late; already running");return n}function Le(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Pp(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,f,h,p;if(n.state!==Ar)return l();for(u in s)if(p=s[u],p.name===n.name){if(p.state===Hn)return Rr(r);p.state===Dr?(p.state=Vn,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete s[u]):+u<t&&(p.state=Vn,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete s[u])}if(Rr(function(){n.state===Hn&&(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=Hn,o=new Array(h=n.tween.length),u=0,f=-1;u<h;++u)(p=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(o[++f]=p);o.length=f+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),f=-1,h=o.length;++f<h;)o[f].call(e,u);n.state===Ks&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=Vn,n.timer.stop(),delete s[t];for(var d in s)return;delete e.__transition}}function Fn(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=Vn,s.timer.stop(),s.on.call(o?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[r]}i&&delete e.__transition}}function Op(e){return this.each(function(){Fn(this,e)})}function zp(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 Tp(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 Lp(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=Le(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?zp:Tp)(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 Le(o,s).value[t]}}function qa(e,t){var n;return(typeof t=="number"?Ve:t instanceof xt?Gn:(n=xt(t))?(t=n,Gn):Ha)(e,t)}function Hp(e){return function(){this.removeAttribute(e)}}function Vp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Fp(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 Bp(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 Wp(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 Yp(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 Xp(e,t){var n=ps(e),s=n==="transform"?Ep:qa;return this.attrTween(e,typeof t=="function"?(n.local?Yp:Wp)(n,s,Ro(this,"attr."+e,t)):t==null?(n.local?Vp:Hp)(n):(n.local?Bp:Fp)(n,s,t))}function qp(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Zp(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Gp(e,t){var n,s;function o(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&Zp(e,i)),n}return o._value=t,o}function Up(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 Kp(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?Gp:Up)(s,t))}function Qp(e,t){return function(){$o(this,e).delay=+t.apply(this,arguments)}}function Jp(e,t){return t=+t,function(){$o(this,e).delay=t}}function em(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Qp:Jp)(t,e)):Le(this.node(),t).delay}function tm(e,t){return function(){Xe(this,e).duration=+t.apply(this,arguments)}}function nm(e,t){return t=+t,function(){Xe(this,e).duration=t}}function sm(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?tm:nm)(t,e)):Le(this.node(),t).duration}function om(e,t){if(typeof t!="function")throw new Error;return function(){Xe(this,e).ease=t}}function rm(e){var t=this._id;return arguments.length?this.each(om(t,e)):Le(this.node(),t).ease}function im(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Xe(this,e).ease=n}}function am(e){if(typeof e!="function")throw new Error;return this.each(im(this._id,e))}function cm(e){typeof e!="function"&&(e=ka(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 et(s,this._parents,this._name,this._id)}function lm(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,f=r[c]=new Array(u),h,p=0;p<u;++p)(h=l[p]||d[p])&&(f[p]=h);for(;c<s;++c)r[c]=t[c];return new et(r,this._parents,this._name,this._id)}function dm(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 um(e,t,n){var s,o,i=dm(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 fm(e,t){var n=this._id;return arguments.length<2?Le(this.node(),n).on.on(e):this.each(um(n,e,t))}function hm(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function pm(){return this.on("end.remove",hm(this._id))}function mm(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,f,h=0;h<l;++h)(u=c[h])&&(f=e.call(u,u.__data__,h,c))&&("__data__"in u&&(f.__data__=u.__data__),d[h]=f,gs(d[h],t,n,h,d,Le(u,n)));return new et(i,this._parents,t,n)}function gm(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ja(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,f=0;f<d;++f)if(u=l[f]){for(var h=e.call(u,u.__data__,f,l),p,m=Le(u,n),w=0,y=h.length;w<y;++w)(p=h[w])&&gs(p,t,n,w,h,m);i.push(h),r.push(u)}return new et(i,r,t,n)}var xm=xn.prototype.constructor;function ym(){return new xm(this._groups,this._parents)}function wm(e,t){var n,s,o;return function(){var i=$t(this,e),r=(this.style.removeProperty(e),$t(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 vm(e,t,n){var s,o=n+"",i;return function(){var r=$t(this,e);return r===o?null:r===s?i:i=t(s=r,n)}}function bm(e,t,n){var s,o,i;return function(){var r=$t(this,e),c=n(this),l=c+"";return c==null&&(l=c=(this.style.removeProperty(e),$t(this,e))),r===l?null:r===s&&l===o?i:(o=l,i=t(s=r,c))}}function Nm(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 jm(e,t,n){var s=(e+="")=="transform"?kp:qa;return t==null?this.styleTween(e,wm(e,s)).on("end.style."+e,Za(e)):typeof t=="function"?this.styleTween(e,bm(e,s,Ro(this,"style."+e,t))).each(Nm(this._id,e)):this.styleTween(e,vm(e,s,t),n).on("end.style."+e,null)}function km(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function Em(e,t,n){var s,o;function i(){var r=t.apply(this,arguments);return r!==o&&(s=(o=r)&&km(e,r,n)),s}return i._value=t,i}function Cm(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,Em(e,t,n??""))}function Sm(e){return function(){this.textContent=e}}function Im(e){return function(){var t=e(this);this.textContent=t??""}}function _m(e){return this.tween("text",typeof e=="function"?Im(Ro(this,"text",e)):Sm(e==null?"":e+""))}function Mm(e){return function(t){this.textContent=e.call(this,t)}}function $m(e){var t,n;function s(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&Mm(o)),t}return s._value=e,s}function Rm(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,$m(e))}function Am(){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=Le(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 et(s,this._parents,e,n)}function Dm(){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 Pm=0;function et(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function Ga(){return++Pm}var Ke=xn.prototype;et.prototype={constructor:et,select:mm,selectAll:gm,selectChild:Ke.selectChild,selectChildren:Ke.selectChildren,filter:cm,merge:lm,selection:ym,transition:Am,call:Ke.call,nodes:Ke.nodes,node:Ke.node,size:Ke.size,empty:Ke.empty,each:Ke.each,on:fm,attr:Xp,attrTween:Kp,style:jm,styleTween:Cm,text:_m,textTween:Rm,remove:pm,tween:Lp,delay:em,duration:sm,ease:rm,easeVarying:am,end:Dm,[Symbol.iterator]:Ke[Symbol.iterator]};function Om(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var zm={time:null,delay:0,duration:250,ease:Om};function Tm(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 Lm(e){var t,n;e instanceof et?(t=e._id,e=e._name):(t=Ga(),(n=zm).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||Tm(l,t));return new et(s,this._parents,e,t)}xn.prototype.interrupt=Op;xn.prototype.transition=Lm;const Mn=e=>()=>e;function Hm(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 Qe(e,t,n){this.k=e,this.x=t,this.y=n}Qe.prototype={constructor:Qe,scale:function(e){return e===1?this:new Qe(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Qe(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 Qe(1,0,0);Ua.prototype=Qe.prototype;function Ua(e){for(;!e.__zoom;)if(!(e=e.parentNode))return xs;return e.__zoom}function $s(e){e.stopImmediatePropagation()}function Yt(e){e.preventDefault(),e.stopImmediatePropagation()}function Vm(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Fm(){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 Bm(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Wm(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ym(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=Vm,t=Fm,n=Ym,s=Bm,o=Wm,i=[0,1/0],r=[[-1/0,-1/0],[1/0,1/0]],c=250,l=Ln,d=hs("start","zoom","end"),u,f,h,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",L).filter(o).on("touchstart.zoom",O).on("touchmove.zoom",H).on("touchend.zoom touchcancel.zoom",_).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(N,C,I,$){var M=N.selection?N.selection():N;M.property("__zoom",Pr),N!==M?E(N,C,I,$):M.interrupt().each(function(){k(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 M=this.__zoom.k,D=typeof C=="function"?C.apply(this,arguments):C;return M*D},I,$)},x.scaleTo=function(N,C,I,$){x.transform(N,function(){var M=t.apply(this,arguments),D=this.__zoom,V=I==null?v(M):typeof I=="function"?I.apply(this,arguments):I,T=D.invert(V),F=typeof C=="function"?C.apply(this,arguments):C;return n(g(b(D,F),V,T),M,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,$,M){x.transform(N,function(){var D=t.apply(this,arguments),V=this.__zoom,T=$==null?v(D):typeof $=="function"?$.apply(this,arguments):$;return n(xs.translate(T[0],T[1]).scale(V.k).translate(typeof C=="function"?-C.apply(this,arguments):-C,typeof I=="function"?-I.apply(this,arguments):-I),D,r)},$,M)};function b(N,C){return C=Math.max(i[0],Math.min(i[1],C)),C===N.k?N:new Qe(C,N.x,N.y)}function g(N,C,I){var $=C[0]-I[0]*N.k,M=C[1]-I[1]*N.k;return $===N.x&&M===N.y?N:new Qe(N.k,$,M)}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(){k(this,arguments).event($).start()}).on("interrupt.zoom end.zoom",function(){k(this,arguments).event($).end()}).tween("zoom",function(){var M=this,D=arguments,V=k(M,D).event($),T=t.apply(M,D),F=I==null?v(T):typeof I=="function"?I.apply(M,D):I,P=Math.max(T[1][0]-T[0][0],T[1][1]-T[0][1]),W=M.__zoom,Y=typeof C=="function"?C.apply(M,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 z=J(U),Z=P/z[2];U=new Qe(Z,F[0]-z[0]*Z,F[1]-z[1]*Z)}V.zoom(null,U)}})}function k(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 Hm(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=k(this,C).event(N),$=this.__zoom,M=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===M)return;I.mouse=[D,$.invert(D)],Fn(this),I.start()}Yt(N),I.wheel=setTimeout(V,m),I.zoom("mouse",n(g(b($,M),I.mouse[0],I.mouse[1]),I.extent,r));function V(){I.wheel=null,I.end()}}function A(N,...C){if(h||!e.apply(this,arguments))return;var I=N.currentTarget,$=k(this,C,!0).event(N),M=Ce(N.view).on("mousemove.zoom",F,!0).on("mouseup.zoom",P,!0),D=Me(N,I),V=N.clientX,T=N.clientY;Da(N.view),$s(N),$.mouse=[D,this.__zoom.invert(D)],Fn(this),$.start();function F(W){if(Yt(W),!$.moved){var Y=W.clientX-V,J=W.clientY-T;$.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){M.on("mousemove.zoom mouseup.zoom",null),Pa(W.view,$.moved),Yt(W),$.event(W).end()}}function L(N,...C){if(e.apply(this,arguments)){var I=this.__zoom,$=Me(N.changedTouches?N.changedTouches[0]:N,this),M=I.invert($),D=I.k*(N.shiftKey?.5:2),V=n(g(b(I,D),$,M),t.apply(this,C),r);Yt(N),c>0?Ce(this).transition().duration(c).call(E,V,$,N):Ce(this).call(x.transform,V,$,N)}}function O(N,...C){if(e.apply(this,arguments)){var I=N.touches,$=I.length,M=k(this,C,N.changedTouches.length===$).event(N),D,V,T,F;for($s(N),V=0;V<$;++V)T=I[V],F=Me(T,this),F=[F,this.__zoom.invert(F),T.identifier],M.touch0?!M.touch1&&M.touch0[2]!==F[2]&&(M.touch1=F,M.taps=0):(M.touch0=F,D=!0,M.taps=1+!!u);u&&(u=clearTimeout(u)),D&&(M.taps<2&&(f=F[0],u=setTimeout(function(){u=null},p)),Fn(this),M.start())}}function H(N,...C){if(this.__zooming){var I=k(this,C).event(N),$=N.changedTouches,M=$.length,D,V,T,F;for(Yt(N),D=0;D<M;++D)V=$[D],T=Me(V,this),I.touch0&&I.touch0[2]===V.identifier?I.touch0[0]=T:I.touch1&&I.touch1[2]===V.identifier&&(I.touch1[0]=T);if(V=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,z=(z=J[0]-W[0])*z+(z=J[1]-W[1])*z;V=b(V,Math.sqrt(U/z)),T=[(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)T=I.touch0[0],F=I.touch0[1];else return;I.zoom("touch",n(g(V,T,F),I.extent,r))}}function _(N,...C){if(this.__zooming){var I=k(this,C).event(N),$=N.changedTouches,M=$.length,D,V;for($s(N),h&&clearTimeout(h),h=setTimeout(function(){h=null},p),D=0;D<M;++D)V=$[D],I.touch0&&I.touch0[2]===V.identifier?delete I.touch0:I.touch1&&I.touch1[2]===V.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&&(V=Me(V,this),Math.hypot(f[0]-V[0],f[1]-V[1])<y)){var T=Ce(this).on("dblclick.zoom");T&&T.apply(this,arguments)}}}return x.wheelDelta=function(N){return arguments.length?(s=typeof N=="function"?N:Mn(+N),x):s},x.filter=function(N){return arguments.length?(e=typeof N=="function"?N:Mn(!!N),x):e},x.touchable=function(N){return arguments.length?(o=typeof N=="function"?N:Mn(!!N),x):o},x.extent=function(N){return arguments.length?(t=typeof N=="function"?N:Mn([[+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.`},sn=[[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 At;(function(e){e.Strict="strict",e.Loose="loose"})(At||(At={}));var pt;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(pt||(pt={}));var on;(function(e){e.Partial="partial",e.Full="full"})(on||(on={}));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 ot;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ot||(ot={}));var tt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(tt||(tt={}));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,Xm=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),wn=(e,t=[0,0])=>{const{width:n,height:s}=qe(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};const n=e.reduce((s,o)=>{const i=typeof o=="string";let r=!t.nodeLookup&&!i?o:void 0;t.nodeLookup&&(r=i?t.nodeLookup.get(o):Ao(o)?o:t.nodeLookup.get(o.id));const c=r?Jn(r,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return ys(s,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ws(n)},vn=(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,Jn(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,f=[];for(const h of e.values()){const{measured:p,selectable:m=!0,hidden:w=!1}=h;if(r&&!m||w)continue;const y=p.width??h.width??h.initialWidth??0,x=p.height??h.height??h.initialHeight??0,{x:b,y:g}=h.internals.positionAbsolute,v=ic(c,l,d,u,b,g,y,x),E=y*x,k=i&&v>0;(!h.internals.handleBounds||k||v>=E||h.dragging)&&f.push(h)}return f},Zm=(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 Gm(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}=qe(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 Um({nodes:e,width:t,height:n,panZoom:s,minZoom:o,maxZoom:i},r){if(e.size===0)return!0;const c=Gm(e,r),l=vn(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 f=r.extent||o;if(r.extent==="parent"&&!r.expandParent)if(!c)i?.("005",Te.error005());else{const p=c.measured.width,m=c.measured.height;p&&m&&(f=[[l,d],[l+p,d+m]])}else c&&vt(r.extent)&&(f=[[r.extent[0][0]+l,r.extent[0][1]+d],[r.extent[1][0]+l,r.extent[1][1]+d]]);const h=vt(f)?wt(t,f,r.measured):t;return(r.measured.width===void 0||r.measured.height===void 0)&&i?.("015",Te.error015()),{position:{x:h.x-l+(r.measured.width??0)*u[0],y:h.y-d+(r.measured.height??0)*u[1]},positionAbsolute:h}}async function Km({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:s,onBeforeDelete:o}){const i=new Set(e.map(h=>h.id)),r=[];for(const h of n){if(h.deletable===!1)continue;const p=i.has(h.id),m=!p&&h.parentId&&r.find(w=>w.id===h.parentId);(p||m)&&r.push(h)}const c=new Set(t.map(h=>h.id)),l=s.filter(h=>h.deletable!==!1),u=Zm(r,l);for(const h of l)c.has(h.id)&&!u.find(m=>m.id===h.id)&&u.push(h);if(!o)return{edges:u,nodes:r};const f=await o({nodes:r,edges:u});return typeof f=="boolean"?f?{edges:u,nodes:r}:{edges:[],nodes:[]}:f}const Dt=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),wt=(e={x:0,y:0},t,n)=>({x:Dt(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Dt(e.y,t[0][1],t[1][1]-(n?.height??0))});function oc(e,t,n){const{width:s,height:o}=qe(n),{x:i,y:r}=n.internals.positionAbsolute;return wt(e,[[i,r],[i+s,r+o]],t)}const zr=(e,t,n)=>e<t?Dt(Math.abs(e-t),1,t)/t:e>n?-Dt(Math.abs(e-n),1,t)/t:0,Po=(e,t,n=15,s=40)=>{const o=zr(e.x,s,t.width-s)*n,i=zr(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}),rn=(e,t=[0,0])=>{const{x:n,y:s}=Ao(e)?e.internals.positionAbsolute:wn(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}},Jn=(e,t=[0,0])=>{const{x:n,y:s}=Ao(e)?e.internals.positionAbsolute:wn(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)},es=(e,t)=>ic(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Tr=e=>Re(e.width)&&Re(e.height)&&Re(e.x)&&Re(e.y),Re=e=>!isNaN(e)&&isFinite(e),ac=(e,t)=>(n,s)=>{},bn=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Nn=({x:e,y:t},[n,s,o],i=!1,r=[1,1])=>{const c={x:(e-n)/o,y:(t-s)/o};return i?bn(c,r):c},Pt=({x:e,y:t},[n,s,o])=>({x:e*o+n,y:t*o+s});function jt(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 Qm(e,t,n){if(typeof e=="string"||typeof e=="number"){const s=jt(e,n),o=jt(e,t);return{top:s,right:o,bottom:s,left:o,x:o*2,y:s*2}}if(typeof e=="object"){const s=jt(e.top??e.y??0,n),o=jt(e.bottom??e.y??0,n),i=jt(e.left??e.x??0,t),r=jt(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 Jm(e,t,n,s,o,i){const{x:r,y:c}=Pt(e,[t,n,s]),{x:l,y:d}=Pt({x:e.x+e.width,y:e.y+e.height},[t,n,s]),u=o-l,f=i-d;return{left:Math.floor(r),top:Math.floor(c),right:Math.floor(u),bottom:Math.floor(f)}}const Oo=(e,t,n,s,o,i)=>{const r=Qm(i,t,n),c=(t-r.x)/e.width,l=(n-r.y)/e.height,d=Math.min(c,l),u=Dt(d,s,o),f=e.x+e.width/2,h=e.y+e.height/2,p=t/2-f*u,m=n/2-h*u,w=Jm(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}},an=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function vt(e){return e!=null&&e!=="parent"}function qe(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 eg(){let e,t;return{promise:new Promise((s,o)=>{e=s,t=o}),resolve:e,reject:t}}function tg(e){return{...Ja,...e||{}}}function Kt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:s,containerBounds:o}){const{x:i,y:r}=Ae(e),c=Nn({x:i-(o?.left??0),y:r-(o?.top??0)},s),{x:l,y:d}=n?bn(c,t):c;return{xSnapped:l,ySnapped:d,...c}}const zo=e=>({width:e.offsetWidth,height:e.offsetHeight}),dc=e=>e?.getRootNode?.()||window?.document,ng=["INPUT","SELECT","TEXTAREA"];function uc(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:ng.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,...zo(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),f=Math.abs(d-t);return[l,d,u,f]}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 To({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}),[f,h,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}`,f,h,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 sg({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 og({sourceNode:e,targetNode:t,width:n,height:s,transform:o}){const i=ys(Jn(e),Jn(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 es(r,ws(i))>0}const rg=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`xy-edge__${e}${t||""}-${n}${s||""}`,ig=(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)),ag=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",Te.error006()),t;const s=n.getEdgeId||rg;let o;return nc(e)?o={...e}:o={...e,id:s(e)},ig(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}},cg=({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 lg({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},f=cg({source:d,sourcePosition:t,target:u}),h=f.x!==0?"x":"y",p=f[h];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[h]*l[h]===-1){h==="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[h]===p?m=h==="x"?R:A:m=h==="x"?A:R}else{const R=[{x:d.x,y:u.y}],A=[{x:u.x,y:d.y}];if(h==="x"?m=c.x===p?A:R:m=c.y===p?R:A,t===s){const N=Math.abs(e[h]-n[h]);if(N<=i){const C=Math.min(i-1,i-N);c[h]===p?x[h]=(d[h]>e[h]?-1:1)*C:b[h]=(u[h]>n[h]?-1:1)*C}}if(t!==s){const N=h==="x"?"y":"x",C=c[h]===l[N],I=d[N]>u[N],$=d[N]<u[N];(c[h]===1&&(!C&&I||C&&$)||c[h]!==1&&(!C&&$||C&&I))&&(m=h==="x"?R:A)}const L={x:d.x+x.x,y:d.y+x.y},O={x:u.x+b.x,y:u.y+b.y},H=Math.max(Math.abs(L.x-m[0].x),Math.abs(O.x-m[0].x)),_=Math.max(Math.abs(L.y-m[0].y),Math.abs(O.y-m[0].y));H>=_?(w=(L.x+O.x)/2,y=m[0].y):(w=m[0].x,y=(L.y+O.y)/2)}const E={x:d.x+x.x,y:d.y+x.y},k={x:u.x+b.x,y:u.y+b.y};return[[e,...E.x!==m[0].x||E.y!==m[0].y?[E]:[],...m,...k.x!==m[m.length-1].x||k.y!==m[m.length-1].y?[k]:[],n],w,y,g,v]}function dg(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 ts({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[f,h,p,m,w]=lg({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${f[0].x} ${f[0].y}`;for(let x=1;x<f.length-1;x++)y+=dg(f[x-1],f[x],f[x+1],r);return y+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[y,h,p,m,w]}function Wr(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function ug(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===At.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=bt(t,i,c),u=bt(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 bt(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??qe(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 fg(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,hg=10,Lo={nodeOrigin:[0,0],nodeExtent:sn,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},pg={...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 mg(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=wn(o,s.nodeOrigin),r=vt(o.extent)?o.extent:s.nodeExtent,c=wt(i,r,qe(o));o.internals.positionAbsolute=c}}function gg(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(pg,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 f=r.get(u.id);if(o.checkEquality&&u===f?.internals.userNode)t.set(u.id,f);else{const h=wn(u,o.nodeOrigin),p=vt(u.extent)?u.extent:o.nodeExtent,m=wt(h,p,qe(u));f={...o.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:m,handleBounds:gg(u,f),z:xc(u,c,o.zIndexMode),userNode:u}},t.set(u.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(l=!1),u.parentId&&Fo(f,t,n,s,i),d||=u.selected??!1}return{nodesInitialized:l,hasSelectedNodes:d}}function xg(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}xg(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*hg),o&&u.internals.rootParentIndex!==void 0&&(o.i=u.internals.rootParentIndex);const f=i&&!Vo(l)?gc:0,{x:h,y:p,z:m}=yg(e,u,r,c,f,l),{positionAbsolute:w}=e.internals,y=h!==w.x||p!==w.y;(y||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:h,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 yg(e,t,n,s,o,i){const{x:r,y:c}=t.internals.positionAbsolute,l=qe(e),d=wn(e,n),u=vt(e.extent)?wt(d,e.extent,l):d;let f=wt({x:r+u.x,y:c+u.y},s,l);e.extent==="parent"&&(f=oc(f,l,t));const h=xc(e,o,i),p=t.internals.z??0;return{x:f.x,y:f.y,z:p>=h?p+1:h}}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??rn(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=qe(c),f=c.origin??s,h=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)*f[0],x=(w-u.height)*f[1];(h>0||p>0||y||x)&&(o.push({id:l,type:"position",position:{x:c.position.x-h+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+h,y:b.position.y+p}})})),(u.width<r.width||u.height<r.height||h||p)&&o.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:m+(h?f[0]*h-y:0),height:w+(p?f[1]*p-x:0)}})}),o}function wg(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:f}=new window.DOMMatrixReadOnly(u.transform),h=[];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=zo(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=vt(m.extent)?m.extent:i;let{positionAbsolute:v}=m.internals;if(m.parentId&&m.extent==="parent"){const k=t.get(m.parentId);k&&(v=oc(v,w,k))}else g&&(v=wt(v,g,w));const E={...m,measured:w,internals:{...m.internals,positionAbsolute:v,handleBounds:{source:Hr("source",p.nodeElement,b,f,m.id),target:Hr("target",p.nodeElement,b,f,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&&h.push({id:m.id,parentId:m.parentId,rect:rn(E,o)}))}}if(h.length>0){const p=Bo(h,t,n,o);d.push(...p)}return{changes:d,updatedInternals:l}}async function vg({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 bg(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 Ng({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=bn(i,t);return{x:r.x-i.x,y:r.y-i.y}}function jg({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,f=!1,h=null,p=!1,m=!1,w=null;function y({noDragClassName:b,handleSelector:g,domNode:v,isSelectable:E,nodeId:k,nodeClickDistance:S=0}){h=Ce(v);function R({x:H,y:_}){const{nodeLookup:N,nodeExtent:C,snapGrid:I,snapToGrid:$,nodeOrigin:M,onNodeDrag:D,onSelectionDrag:V,onError:T,updateNodePositions:F}=t();i={x:H,y:_};let P=!1;const W=c.size>1,Y=W&&C?Qs(vn(c)):null,J=W&&$?Ng({dragItems:c,snapGrid:I,x:H,y:_}):null;for(const[U,z]of c){if(!N.has(U))continue;let Z={x:H-z.distance.x,y:_-z.distance.y};$&&(Z=J?{x:Math.round(Z.x+J.x),y:Math.round(Z.y+J.y)}:bn(Z,I));let te=null;if(W&&C&&!z.extent&&Y){const{positionAbsolute:Q}=z.internals,re=Q.x-Y.x+C[0][0],ie=Q.x+z.measured.width-Y.x2+C[1][0],ce=Q.y-Y.y+C[0][1],he=Q.y+z.measured.height-Y.y2+C[1][1];te=[[re,ce],[ie,he]]}const{position:ee,positionAbsolute:K}=sc({nodeId:U,nextPosition:Z,nodeLookup:N,nodeExtent:te||C,nodeOrigin:M,onError:T});P=P||z.position.x!==ee.x||z.position.y!==ee.y,z.position=ee,z.internals.positionAbsolute=K}if(m=m||P,!!P&&(F(c,!0),w&&(s||D||!k&&V))){const[U,z]=Rs({nodeId:k,dragItems:c,nodeLookup:N});s?.(w,c,U,z),D?.(w,U,z),k||V?.(w,z)}}async function A(){if(!u)return;const{transform:H,panBy:_,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/H[2],i.y=(i.y??0)-$/H[2],await _({x:I,y:$})&&R(i)),r=requestAnimationFrame(A)}function L(H){const{nodeLookup:_,multiSelectionActive:N,nodesDraggable:C,transform:I,snapGrid:$,snapToGrid:M,selectNodesOnDrag:D,onNodeDragStart:V,onSelectionDragStart:T,unselectNodesAndEdges:F}=t();f=!0,(!D||!E)&&!N&&k&&(_.get(k)?.selected||F()),E&&D&&k&&e?.(k);const P=Kt(H.sourceEvent,{transform:I,snapGrid:$,snapToGrid:M,containerBounds:u});if(i=P,c=bg(_,C,P,k),c.size>0&&(n||V||!k&&T)){const[W,Y]=Rs({nodeId:k,dragItems:c,nodeLookup:_});n?.(H.sourceEvent,c,W,Y),V?.(H.sourceEvent,W,Y),k||T?.(H.sourceEvent,Y)}}const O=Oa().clickDistance(S).on("start",H=>{const{domNode:_,nodeDragThreshold:N,transform:C,snapGrid:I,snapToGrid:$}=t();u=_?.getBoundingClientRect()||null,p=!1,m=!1,w=H.sourceEvent,N===0&&L(H),i=Kt(H.sourceEvent,{transform:C,snapGrid:I,snapToGrid:$,containerBounds:u}),d=Ae(H.sourceEvent,u)}).on("drag",H=>{const{autoPanOnNodeDrag:_,transform:N,snapGrid:C,snapToGrid:I,nodeDragThreshold:$,nodeLookup:M}=t(),D=Kt(H.sourceEvent,{transform:N,snapGrid:C,snapToGrid:I,containerBounds:u});if(w=H.sourceEvent,(H.sourceEvent.type==="touchmove"&&H.sourceEvent.touches.length>1||k&&!M.has(k))&&(p=!0),!p){if(!l&&_&&f&&(l=!0,A()),!f){const V=Ae(H.sourceEvent,u),T=V.x-d.x,F=V.y-d.y;Math.sqrt(T*T+F*F)>$&&L(H)}(i.x!==D.xSnapped||i.y!==D.ySnapped)&&c&&f&&(d=Ae(H.sourceEvent,u),R(D))}}).on("end",H=>{if(!f||p){p&&c.size>0&&t().updateNodePositions(c,!1);return}if(l=!1,f=!1,cancelAnimationFrame(r),c.size>0){const{nodeLookup:_,updateNodePositions:N,onNodeDragStop:C,onSelectionDragStop:I}=t();if(m&&(N(c,!1),m=!1),o||C||!k&&I){const[$,M]=Rs({nodeId:k,dragItems:c,nodeLookup:_,dragging:!1});o?.(H.sourceEvent,c,$,M),C?.(H.sourceEvent,$,M),k||I?.(H.sourceEvent,M)}}}).filter(H=>{const _=H.target;return!H.button&&(!b||!Zr(_,`.${b}`,v))&&(!g||Zr(_,g,v))});h.call(O)}function x(){h?.on(".drag",null)}return{update:y,destroy:x}}function kg(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())es(o,rn(i))>0&&s.push(i);return s}const Eg=250;function Cg(e,t,n,s){let o=[],i=1/0;const r=kg(e,n,t+Eg);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:f}=bt(c,d,d.position,!0),h=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(f-e.y,2));h>t||(h<i?(o=[{...d,x:u,y:f}],i=h):h===i&&o.push({...d,x:u,y:f}))}}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,...bt(r,l,l.position,!0)}:l}function bc(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Sg(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Nc=()=>!0;function Ig(e,{connectionMode:t,connectionRadius:n,handleId:s,nodeId:o,edgeUpdaterType:i,isTarget:r,domNode:c,nodeLookup:l,lib:d,autoPanOnConnect:u,flowId:f,panBy:h,cancelConnection:p,onConnectStart:m,onConnect:w,onConnectEnd:y,isValidConnection:x=Nc,onReconnectEnd:b,updateConnection:g,getTransform:v,getFromHandle:E,autoPanSpeed:k,dragThreshold:S=1,handleDomNode:R}){const A=dc(e.target);let L=0,O;const{x:H,y:_}=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 M=Ae(e,C),D=!1,V=null,T=!1,F=null;function P(){if(!u||!C)return;const[ee,K]=Po(M,C,k);h({x:ee,y:K}),L=requestAnimationFrame(P)}const W={...$,nodeId:o,type:N,position:$.position},Y=l.get(o);let U={inProgress:!0,isValid:null,from:bt(Y,W,q.Left,!0),fromHandle:W,fromPosition:W.position,fromNode:Y,to:M,toHandle:null,toPosition:Or[W.position],toNode:null,pointer:M};function z(){I=!0,g(U),m?.(e,{nodeId:o,handleId:s,handleType:N})}S===0&&z();function Z(ee){if(!I){const{x:he,y:ge}=Ae(ee),be=he-H,Ee=ge-_;if(!(be*be+Ee*Ee>S*S))return;z()}if(!E()||!W){te(ee);return}const K=v();M=Ae(ee,C),O=Cg(Nn(M,K,!1,[1,1]),n,l,W),D||(P(),D=!0);const Q=jc(ee,{handle:O,connectionMode:t,fromNodeId:o,fromHandleId:s,fromType:r?"target":"source",isValidConnection:x,doc:A,lib:d,flowId:f,nodeLookup:l});F=Q.handleDomNode,V=Q.connection,T=Sg(!!O,Q.isValid);const re=l.get(o),ie=re?bt(re,W,q.Left,!0):U.from,ce={...U,from:ie,isValid:T,to:Q.toHandle&&T?Pt({x:Q.toHandle.x,y:Q.toHandle.y},K):M,toHandle:Q.toHandle,toPosition:T&&Q.toHandle?Q.toHandle.position:Or[W.position],toNode:Q.toHandle?l.get(Q.toHandle.nodeId):null,pointer:M};g(ce),U=ce}function te(ee){if(!("touches"in ee&&ee.touches.length>0)){if(I){(O||F)&&V&&T&&w?.(V);const{inProgress:K,...Q}=U,re={...Q,toPosition:U.toHandle?U.toPosition:null};y?.(ee,re),i&&b?.(ee,re)}p(),cancelAnimationFrame(L),D=!1,T=!1,V=null,F=null,A.removeEventListener("mousemove",Z),A.removeEventListener("mouseup",te),A.removeEventListener("touchmove",Z),A.removeEventListener("touchend",te)}}A.addEventListener("mousemove",Z),A.addEventListener("mouseup",te),A.addEventListener("touchmove",Z),A.addEventListener("touchend",te)}function jc(e,{handle:t,connectionMode:n,fromNodeId:s,fromHandleId:o,fromType:i,doc:r,lib:c,flowId:l,isValidConnection:d=Nc,nodeLookup:u}){const f=i==="target",h=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:h,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"),k=y.classList.contains("connectableend");if(!g||!b)return x;const S={source:f?g:s,sourceHandle:f?v:o,target:f?s:g,targetHandle:f?o:v};x.connection=S;const A=E&&k&&(n===At.Strict?f&&b==="source"||!f&&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:Ig,isValid:jc};function _g({domNode:e,panZoom:t,getTransform:n,getViewScale:s}){const o=Ce(e);function i({translateExtent:c,width:l,height:d,zoomStep:u=1,pannable:f=!0,zoomable:h=!0,inversePan:p=!1}){const m=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const v=n(),E=g.sourceEvent.ctrlKey&&an()?10:1,k=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*u,S=v[2]*Math.pow(2,k*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],k=[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]-k[0]*S,y:v[1]-k[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",f?x:null).on("zoom.wheel",h?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),Ct=(e,t)=>e.target.closest(`.${t}`),kc=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Mg=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ds=(e,t=0,n=Mg,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&&an()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function $g({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:s,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:r,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:d}){return u=>{if(Ct(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(u.ctrlKey&&r){const y=Me(u),x=Ec(u),b=f*Math.pow(2,x);s.scaleTo(n,b,y,u);return}const h=u.deltaMode===1?20:1;let p=o===pt.Vertical?0:u.deltaX*h,m=o===pt.Horizontal?0:u.deltaY*h;!an()&&u.shiftKey&&o!==pt.Vertical&&(p=u.deltaY*h,m=0),s.translateBy(n,-(p/f)*i,-(m/f)*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 Rg({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(s,o){const i=s.type==="wheel",r=!t&&i&&!s.ctrlKey,c=Ct(s,e);if(s.ctrlKey&&i&&c&&s.preventDefault(),r||c)return null;s.preventDefault(),n.call(this,s,o)}}function Ag({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 Dg({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:s,onPanZoom:o}){return i=>{e.usedRightMouseButton=!!(n&&kc(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 Pg({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:s,onPanZoomEnd:o,onPaneContextMenu:i}){return r=>{if(!r.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&kc(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 Og({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:s,panOnScroll:o,zoomOnDoubleClick:i,userSelectionActive:r,noWheelClassName:c,noPanClassName:l,lib:d,connectionInProgress:u}){return f=>{const h=e||t,p=n&&f.ctrlKey,m=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(Ct(f,`${d}-flow__node`)||Ct(f,`${d}-flow__edge`)))return!0;if(!s&&!h&&!o&&!i&&!n||r||u&&!m||Ct(f,c)&&m||Ct(f,l)&&(!m||o&&m&&!e)||!n&&f.ctrlKey&&m)return!1;if(!n&&f.type==="touchstart"&&f.touches?.length>1)return f.preventDefault(),!1;if(!h&&!o&&!p&&m||!s&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(s)&&!s.includes(f.button)&&f.type==="mousedown")return!1;const w=Array.isArray(s)&&s.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||m)&&w}}function zg({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 f=[[0,0],[u.width,u.height]];(typeof ResizeObserver<"u"?new ResizeObserver(_=>{const N=_[0];N&&(f=[[0,0],[N.contentRect.width,N.contentRect.height]])}):null)?.observe(e);const p=Ka().extent(()=>f).scaleExtent([t,n]).translateExtent(s),m=Ce(e).call(p);v({x:o.x,y:o.y,zoom:Dt(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(_,N){return m?new Promise(C=>{p?.interpolate(N?.interpolate==="linear"?Ut:Ln).transform(Ds(m,N?.duration,N?.ease,()=>C(!0)),_)}):!1}function b({noWheelClassName:_,noPanClassName:N,onPaneContextMenu:C,userSelectionActive:I,panOnScroll:$,panOnDrag:M,panOnScrollMode:D,panOnScrollSpeed:V,preventScrolling:T,zoomOnPinch:F,zoomOnScroll:P,zoomOnDoubleClick:W,zoomActivationKeyPressed:Y,lib:J,onTransformChange:U,connectionInProgress:z,paneClickDistance:Z,selectionOnDrag:te}){I&&!d.isZoomingOrPanning&&g();const ee=$&&!Y&&!I;p.clickDistance(te?1/0:!Re(Z)||Z<0?0:Z);const K=ee?$g({zoomPanValues:d,noWheelClassName:_,d3Selection:m,d3Zoom:p,panOnScrollMode:D,panOnScrollSpeed:V,zoomOnPinch:F,onPanZoomStart:r,onPanZoom:i,onPanZoomEnd:c}):Rg({noWheelClassName:_,preventScrolling:T,d3ZoomHandler:w});m.on("wheel.zoom",K,{passive:!1});const Q=Ag({zoomPanValues:d,onDraggingChange:l,onPanZoomStart:r});p.on("start",Q);const re=Dg({zoomPanValues:d,panOnDrag:M,onPaneContextMenu:!!C,onPanZoom:i,onTransformChange:U});p.on("zoom",re);const ie=Pg({zoomPanValues:d,panOnDrag:M,panOnScroll:$,onPaneContextMenu:C,onPanZoomEnd:c,onDraggingChange:l});p.on("end",ie);const ce=Og({zoomActivationKeyPressed:Y,panOnDrag:M,zoomOnScroll:P,panOnScroll:$,zoomOnDoubleClick:W,zoomOnPinch:F,userSelectionActive:I,noPanClassName:N,noWheelClassName:_,lib:J,connectionInProgress:z});p.filter(ce),W?m.on("dblclick.zoom",y):m.on("dblclick.zoom",null)}function g(){p.on("zoom",null)}async function v(_,N,C){const I=As(_),$=p?.constrain()(I,N,C);return $&&await x($),$}async function E(_,N){const C=As(_);return await x(C,N),C}function k(_){if(m){const N=As(_),C=m.property("__zoom");(C.k!==_.zoom||C.x!==_.x||C.y!==_.y)&&p?.transform(m,N,null,{sync:!0})}}function S(){const _=m?Ua(m.node()):{x:0,y:0,k:1};return{x:_.x,y:_.y,zoom:_.k}}async function R(_,N){return m?new Promise(C=>{p?.interpolate(N?.interpolate==="linear"?Ut:Ln).scaleTo(Ds(m,N?.duration,N?.ease,()=>C(!0)),_)}):!1}async function A(_,N){return m?new Promise(C=>{p?.interpolate(N?.interpolate==="linear"?Ut:Ln).scaleBy(Ds(m,N?.duration,N?.ease,()=>C(!0)),_)}):!1}function L(_){p?.scaleExtent(_)}function O(_){p?.translateExtent(_)}function H(_){const N=!Re(_)||_<0?0:_;p?.clickDistance(N)}return{update:b,destroy:g,setViewport:E,setViewportConstrained:v,getViewport:S,scaleTo:R,scaleBy:A,setScaleExtent:L,setTranslateExtent:O,syncViewport:k,setClickDistance:H}}var Ot;(function(e){e.Line="line",e.Handle="handle"})(Ot||(Ot={}));function Tg({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 nt(e,t){return Math.max(0,t-e)}function st(e,t){return Math.max(0,e-t)}function Rn(e,t,n){return Math.max(0,t-e,e-n)}function Ur(e,t){return e?!t:t}function Lg(e,t,n,s,o,i,r,c){let{affectsX:l,affectsY:d}=t;const{isHorizontal:u,isVertical:f}=t,h=u&&f,{xSnapped:p,ySnapped:m}=n,{minWidth:w,maxWidth:y,minHeight:x,maxHeight:b}=s,{x:g,y:v,width:E,height:k,aspectRatio:S}=e;let R=Math.floor(u?p-e.pointerX:0),A=Math.floor(f?m-e.pointerY:0);const L=E+(l?-R:R),O=k+(d?-A:A),H=-i[0]*E,_=-i[1]*k;let N=Rn(L,w,y),C=Rn(O,x,b);if(r){let M=0,D=0;l&&R<0?M=nt(g+R+H,r[0][0]):!l&&R>0&&(M=st(g+L+H,r[1][0])),d&&A<0?D=nt(v+A+_,r[0][1]):!d&&A>0&&(D=st(v+O+_,r[1][1])),N=Math.max(N,M),C=Math.max(C,D)}if(c){let M=0,D=0;l&&R>0?M=st(g+R,c[0][0]):!l&&R<0&&(M=nt(g+L,c[1][0])),d&&A>0?D=st(v+A,c[0][1]):!d&&A<0&&(D=nt(v+O,c[1][1])),N=Math.max(N,M),C=Math.max(C,D)}if(o){if(u){const M=Rn(L/S,x,b)*S;if(N=Math.max(N,M),r){let D=0;!l&&!d||l&&!d&&h?D=st(v+_+L/S,r[1][1])*S:D=nt(v+_+(l?R:-R)/S,r[0][1])*S,N=Math.max(N,D)}if(c){let D=0;!l&&!d||l&&!d&&h?D=nt(v+L/S,c[1][1])*S:D=st(v+(l?R:-R)/S,c[0][1])*S,N=Math.max(N,D)}}if(f){const M=Rn(O*S,w,y)/S;if(C=Math.max(C,M),r){let D=0;!l&&!d||d&&!l&&h?D=st(g+O*S+H,r[1][0])/S:D=nt(g+(d?A:-A)*S+H,r[0][0])/S,C=Math.max(C,D)}if(c){let D=0;!l&&!d||d&&!l&&h?D=nt(g+O*S,c[1][0])/S:D=st(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&&(h?L>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:k+(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},Hg={...Cc,pointerX:0,pointerY:0,aspectRatio:1};function Vg(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 Fg({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:f,resizeDirection:h,onResizeStart:p,onResize:m,onResizeEnd:w,shouldResize:y}){let x={...Cc},b={...Hg};r={boundaries:u,resizeDirection:h,keepAspectRatio:f,controlDirection:Gr(d)};let g,v=null,E=[],k,S,R,A=!1;const L=Oa().on("start",O=>{const{nodeLookup:H,transform:_,snapGrid:N,snapToGrid:C,nodeOrigin:I,paneDomNode:$}=n();if(g=H.get(t),!g)return;v=$?.getBoundingClientRect()??null;const{xSnapped:M,ySnapped:D}=Kt(O.sourceEvent,{transform:_,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:M,pointerY:D,aspectRatio:x.width/x.height},k=void 0,S=vt(g.extent)?g.extent:void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(k=H.get(g.parentId)),k&&g.extent==="parent"&&(S=[[0,0],[k.measured.width,k.measured.height]]),E=[],R=void 0;for(const[V,T]of H)if(T.parentId===t&&(E.push({id:V,position:{...T.position},extent:T.extent}),T.extent==="parent"||T.expandParent)){const F=Vg(T,g,T.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:H,snapGrid:_,snapToGrid:N,nodeOrigin:C}=n(),I=Kt(O.sourceEvent,{transform:H,snapGrid:_,snapToGrid:N,containerBounds:v}),$=[];if(!g)return;const{x:M,y:D,width:V,height:T}=x,F={},P=g.origin??C,{width:W,height:Y,x:J,y:U}=Lg(b,r.controlDirection,I,r.boundaries,r.keepAspectRatio,P,S,R),z=W!==V,Z=Y!==T,te=J!==M&&z,ee=U!==D&&Z;if(!te&&!ee&&!z&&!Z)return;if((te||ee||P[0]===1||P[1]===1)&&(F.x=te?J:x.x,F.y=ee?U:x.y,x.x=F.x,x.y=F.y,E.length>0)){const ie=J-M,ce=U-D;for(const he of E)he.position={x:he.position.x-ie+P[0]*(W-V),y:he.position.y-ce+P[1]*(Y-T)},$.push(he)}if((z||Z)&&(F.width=z&&(!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),k&&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=Tg({width:x.width,prevWidth:V,height:x.height,prevHeight:T,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(L)}function l(){i.on(".drag",null)}return{update:c,destroy:l}}var Ps={exports:{}},Os={},zs={exports:{}},Ts={};var Kr;function Bg(){if(Kr)return Ts;Kr=1;var e=sa();function t(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,o=e.useEffect,i=e.useLayoutEffect,r=e.useDebugValue;function c(f,h){var p=h(),m=s({inst:{value:p,getSnapshot:h}}),w=m[0].inst,y=m[1];return i(function(){w.value=p,w.getSnapshot=h,l(w)&&y({inst:w})},[f,p,h]),o(function(){return l(w)&&y({inst:w}),f(function(){l(w)&&y({inst:w})})},[f]),r(p),p}function l(f){var h=f.getSnapshot;f=f.value;try{var p=h();return!n(f,p)}catch{return!0}}function d(f,h){return h()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:c;return Ts.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Ts}var Qr;function Wg(){return Qr||(Qr=1,zs.exports=Bg()),zs.exports}var Jr;function Yg(){if(Jr)return Os;Jr=1;var e=sa(),t=Wg();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,f,h,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(k){if(!b){if(b=!0,g=k,k=h(k),p!==void 0&&w.hasValue){var S=w.value;if(p(S,k))return v=S}return v=k}if(S=v,s(g,k))return S;var R=h(k);return p!==void 0&&p(S,R)?(g=k,S):(g=k,v=R)}var b=!1,g,v,E=f===void 0?null:f;return[function(){return x(u())},E===null?void 0:function(){return x(E())}]},[u,f,h,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 Xg(){return ei||(ei=1,Ps.exports=Yg()),Ps.exports}var qg=Xg();const Zg=tu(qg),Gg={},ti=e=>{let t;const n=new Set,s=(u,f)=>{const h=typeof u=="function"?u(t):u;if(!Object.is(h,t)){const p=t;t=f??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(m=>m(t,p))}},o=()=>t,l={setState:s,getState:o,getInitialState:()=>d,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Gg?"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},Ug=e=>e?ti(e):ti,{useDebugValue:Kg}=nu,{useSyncExternalStoreWithSelector:Qg}=Zg,Jg=e=>e;function Sc(e,t=Jg,n){const s=Qg(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Kg(s),s}const ni=(e,t)=>{const n=Ug(e),s=(o,i=t)=>Sc(n,o,i);return Object.assign(s,n),s},ex=(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=j.createContext(null),tx=bs.Provider,Ic=Te.error001("react");function oe(e,t){const n=j.useContext(bs);if(n===null)throw new Error(Ic);return Sc(n,e,t)}function le(){const e=j.useContext(bs);if(e===null)throw new Error(Ic);return j.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const si={display:"none"},nx={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",sx="react-flow__aria-live",ox=e=>e.ariaLiveMessage,rx=e=>e.ariaLabelConfig;function ix({rfId:e}){const t=oe(ox);return a.jsx("div",{id:`${sx}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:nx,children:t})}function ax({rfId:e,disableKeyboardA11y:t}){const n=oe(rx);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(ix,{rfId:e})]})}const it=j.forwardRef(({position:e="top-left",children:t,className:n,style:s,...o},i)=>{const r=`${e}`.split("-");return a.jsx("div",{className:fe(["react-flow__panel",n,...r]),style:s,ref:i,...o,children:t})});it.displayName="Panel";const oi="https://reactflow.dev?utm_source=attribution";function cx({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:a.jsx(it,{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 lx=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}},An=e=>e.id;function dx(e,t){return de(e.selectedNodes.map(An),t.selectedNodes.map(An))&&de(e.selectedEdges.map(An),t.selectedEdges.map(An))}function ux({onSelectionChange:e}){const t=le(),{selectedNodes:n,selectedEdges:s}=oe(lx,dx);return j.useEffect(()=>{const o={nodes:n,edges:s};e?.(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,s,e]),null}const fx=e=>!!e.onSelectionChangeHandlers;function hx({onSelectionChange:e}){const t=oe(fx);return e||t?a.jsx(ux,{onSelectionChange:e}):null}const $c=[0,0],px={x:0,y:0,zoom:1},mx=["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=[...mx,"rfId"],gx=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:sn,nodeOrigin:$c,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function xx(e){const{setNodes:t,setEdges:n,setMinZoom:s,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:r,reset:c,setDefaultNodesAndEdges:l}=oe(gx,de),d=le();j.useEffect(()=>(l(e.defaultNodes,e.defaultEdges),()=>{u.current=ii,c()}),[]);const u=j.useRef(ii);return j.useEffect(()=>{for(const f of ri){const h=e[f],p=u.current[f];h!==p&&(typeof e[f]>"u"||(f==="nodes"?t(h):f==="edges"?n(h):f==="minZoom"?s(h):f==="maxZoom"?o(h):f==="translateExtent"?i(h):f==="nodeExtent"?r(h):f==="ariaLabelConfig"?d.setState({ariaLabelConfig:tg(h)}):f==="fitView"?d.setState({fitViewQueued:h}):f==="fitViewOptions"?d.setState({fitViewOptions:h}):d.setState({[f]:h})))}u.current=e},ri.map(f=>e[f])),null}function ai(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function yx(e){const[t,n]=j.useState(e==="system"?null:e);return j.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 cn(e=null,t={target:ci,actInsideInputWithModifier:!0}){const[n,s]=j.useState(!1),o=j.useRef(!1),i=j.useRef(new Set([])),[r,c]=j.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
3
- `).replace(`
4
-
5
- `,`
6
- +`).split(`
7
- `)),u=d.reduce((f,h)=>f.concat(...h),[]);return[d,u]}return[[],[]]},[e]);return j.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)}},f=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},h=()=>{i.current.clear(),s(!1)};return l?.addEventListener("keydown",u),l?.addEventListener("keyup",f),window.addEventListener("blur",h),window.addEventListener("contextmenu",h),()=>{l?.removeEventListener("keydown",u),l?.removeEventListener("keyup",f),window.removeEventListener("blur",h),window.removeEventListener("contextmenu",h)}}},[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 wx=()=>{const e=le();return j.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,f=n.snapToGrid??i;return Nn(d,s,f,u)},flowToScreenPosition:t=>{const{transform:n,domNode:s}=e.getState();if(!s)return t;const{x:o,y:i}=s.getBoundingClientRect(),r=Pt(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)vx(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 vx(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 js(e,t){return Rc(e,t)}function lt(e,t){return{id:e,type:"select",selected:t}}function St(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(lt(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 bx=ac();function Nx(e,t,n={}){return ag(e,t,{...n,onError:n.onError??bx})}const hi=e=>Xm(e),jx=e=>nc(e);function Ac(e){return j.forwardRef(e)}const Dc=typeof window<"u"?j.useLayoutEffect:j.useEffect;function pi(e){const[t,n]=j.useState(BigInt(0)),[s]=j.useState(()=>kx(()=>n(o=>o+BigInt(1))));return Dc(()=>{const o=s.get();o.length&&(e(o),s.reset())},[t]),s}function kx(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Pc=j.createContext(null);function Ex({children:e}){const t=le(),n=j.useCallback(c=>{const{nodes:l=[],setNodes:d,hasDefaultNodes:u,onNodesChange:f,nodeLookup:h,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:h});for(const x of m.values())y=x(y);u&&d(w),y.length>0?f?.(y):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:x,nodes:b,setNodes:g}=t.getState();x&&g(b)})},[]),s=pi(n),o=j.useCallback(c=>{const{edges:l=[],setEdges:d,hasDefaultEdges:u,onEdgesChange:f,edgeLookup:h}=t.getState();let p=l;for(const m of c)p=typeof m=="function"?m(p):m;u?d(p):f&&f(ui({items:p,lookup:h}))},[]),i=pi(o),r=j.useMemo(()=>({nodeQueue:s,edgeQueue:i}),[]);return a.jsx(Pc.Provider,{value:r,children:e})}function Cx(){const e=j.useContext(Pc);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Sx=e=>!!e.panZoom;function Ft(){const e=wx(),t=le(),n=Cx(),s=oe(Sx),o=j.useMemo(()=>{const i=f=>t.getState().nodeLookup.get(f),r=f=>{n.nodeQueue.push(f)},c=f=>{n.edgeQueue.push(f)},l=f=>{const{nodeLookup:h,nodeOrigin:p}=t.getState(),m=hi(f)?f:h.get(f.id),w=m.parentId?lc(m.position,m.measured,m.parentId,h,p):m.position,y={...m,position:w,width:m.measured?.width??m.width,height:m.measured?.height??m.height};return rn(y)},d=(f,h,p={replace:!1})=>{r(m=>m.map(w=>{if(w.id===f){const y=typeof h=="function"?h(w):h;return p.replace&&hi(y)?y:{...w,...y}}return w}))},u=(f,h,p={replace:!1})=>{c(m=>m.map(w=>{if(w.id===f){const y=typeof h=="function"?h(w):h;return p.replace&&jx(y)?y:{...w,...y}}return w}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>i(f)?.internals.userNode,getInternalNode:i,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(h=>({...h}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:r,setEdges:c,addNodes:f=>{const h=Array.isArray(f)?f:[f];n.nodeQueue.push(p=>[...p,...h])},addEdges:f=>{const h=Array.isArray(f)?f:[f];n.edgeQueue.push(p=>[...p,...h])},toObject:()=>{const{nodes:f=[],edges:h=[],transform:p}=t.getState(),[m,w,y]=p;return{nodes:f.map(x=>({...x})),edges:h.map(x=>({...x})),viewport:{x:m,y:w,zoom:y}}},deleteElements:async({nodes:f=[],edges:h=[]})=>{const{nodes:p,edges:m,onNodesDelete:w,onEdgesDelete:y,triggerNodeChanges:x,triggerEdgeChanges:b,onDelete:g,onBeforeDelete:v}=t.getState(),{nodes:E,edges:k}=await Km({nodesToRemove:f,edgesToRemove:h,nodes:p,edges:m,onBeforeDelete:v}),S=k.length>0,R=E.length>0;if(S){const A=k.map(fi);y?.(k),b(A)}if(R){const A=E.map(fi);w?.(E),x(A)}return(R||S)&&g?.({nodes:E,edges:k}),{deletedNodes:E,deletedEdges:k}},getIntersectingNodes:(f,h=!0,p)=>{const m=Tr(f),w=m?f:l(f),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===f.id||!b.internals.positionAbsolute))return!1;const g=rn(y?x:b),v=es(g,w);return h&&v>0||v>=g.width*g.height||v>=w.width*w.height}):[]},isNodeIntersecting:(f,h,p=!0)=>{const w=Tr(f)?f:l(f);if(!w)return!1;const y=es(w,h);return p&&y>0||y>=h.width*h.height||y>=w.width*w.height},updateNode:d,updateNodeData:(f,h,p={replace:!1})=>{d(f,m=>{const w=typeof h=="function"?h(m):h;return p.replace?{...m,data:w}:{...m,data:{...m.data,...w}}},p)},updateEdge:u,updateEdgeData:(f,h,p={replace:!1})=>{u(f,m=>{const w=typeof h=="function"?h(m):h;return p.replace?{...m,data:w}:{...m,data:{...m.data,...w}}},p)},getNodesBounds:f=>{const{nodeLookup:h,nodeOrigin:p}=t.getState();return qm(f,{nodeLookup:h,nodeOrigin:p})},getHandleConnections:({type:f,id:h,nodeId:p})=>Array.from(t.getState().connectionLookup.get(`${p}-${f}${h?`-${h}`:""}`)?.values()??[]),getNodeConnections:({type:f,handleId:h,nodeId:p})=>Array.from(t.getState().connectionLookup.get(`${p}${f?h?`-${f}-${h}`:`-${f}`:""}`)?.values()??[]),fitView:async f=>{const h=t.getState().fitViewResolver??eg();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:h}),n.nodeQueue.push(p=>[...p]),h.promise}}},[]);return j.useMemo(()=>({...o,...e,viewportInitialized:s}),[s])}const mi=e=>e.selected,Ix=typeof window<"u"?window:void 0;function _x({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=le(),{deleteElements:s}=Ft(),o=cn(e,{actInsideInputWithModifier:!1}),i=cn(t,{target:Ix});j.useEffect(()=>{if(o){const{edges:r,nodes:c}=n.getState();s({nodes:c.filter(mi),edges:r.filter(mi)}),n.setState({nodesSelectionActive:!1})}},[o]),j.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function Mx(e){const t=le();j.useEffect(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const s=zo(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 ks={position:"absolute",width:"100%",height:"100%",top:0,left:0},$x=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Rx({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:s=!1,panOnScrollSpeed:o=.5,panOnScrollMode:i=pt.Free,zoomOnDoubleClick:r=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:d,minZoom:u,maxZoom:f,zoomActivationKeyCode:h,preventScrolling:p=!0,children:m,noWheelClassName:w,noPanClassName:y,onViewportChange:x,isControlledViewport:b,paneClickDistance:g,selectionOnDrag:v}){const E=le(),k=j.useRef(null),{userSelectionActive:S,lib:R,connectionInProgress:A}=oe($x,de),L=cn(h),O=j.useRef();Mx(k);const H=j.useCallback(_=>{x?.({x:_[0],y:_[1],zoom:_[2]}),b||E.setState({transform:_})},[x,b]);return j.useEffect(()=>{if(k.current){O.current=zg({domNode:k.current,minZoom:u,maxZoom:f,translateExtent:d,viewport:l,onDraggingChange:I=>E.setState($=>$.paneDragging===I?$:{paneDragging:I}),onPanZoomStart:(I,$)=>{const{onViewportChangeStart:M,onMoveStart:D}=E.getState();D?.(I,$),M?.($)},onPanZoom:(I,$)=>{const{onViewportChange:M,onMove:D}=E.getState();D?.(I,$),M?.($)},onPanZoomEnd:(I,$)=>{const{onViewportChangeEnd:M,onMoveEnd:D}=E.getState();D?.(I,$),M?.($)}});const{x:_,y:N,zoom:C}=O.current.getViewport();return E.setState({panZoom:O.current,transform:[_,N,C],domNode:k.current.closest(".react-flow")}),()=>{O.current?.destroy()}}},[]),j.useEffect(()=>{O.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:s,panOnScrollSpeed:o,panOnScrollMode:i,zoomOnDoubleClick:r,panOnDrag:c,zoomActivationKeyPressed:L,preventScrolling:p,noPanClassName:y,userSelectionActive:S,noWheelClassName:w,lib:R,onTransformChange:H,connectionInProgress:A,selectionOnDrag:v,paneClickDistance:g})},[e,t,n,s,o,i,r,c,L,p,y,S,w,R,H,A,v,g]),a.jsx("div",{className:"react-flow__renderer",ref:k,style:ks,children:m})}const Ax=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Dx(){const{userSelectionActive:e,userSelectionRect:t}=oe(Ax,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)},Px=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Ox({isSelecting:e,selectionKeyPressed:t,selectionMode:n=on.Full,panOnDrag:s,autoPanOnSelection:o,paneClickDistance:i,selectionOnDrag:r,onSelectionStart:c,onSelectionEnd:l,onPaneClick:d,onPaneContextMenu:u,onPaneScroll:f,onPaneMouseEnter:h,onPaneMouseMove:p,onPaneMouseLeave:m,children:w}){const y=j.useRef(0),x=le(),{userSelectionActive:b,elementsSelectable:g,dragging:v,panBy:E,autoPanSpeed:k}=oe(Px,de),S=g&&(e||b),R=j.useRef(null),A=j.useRef(),L=j.useRef(new Set),O=j.useRef(new Set),H=j.useRef(!1),_=j.useRef(!1),N=j.useRef({x:0,y:0}),C=j.useRef(!1),I=z=>{if(_.current||H.current||x.getState().connection.inProgress){_.current=!1,H.current=!1;return}d?.(z),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},$=z=>{if(Array.isArray(s)&&s?.includes(2)){z.preventDefault();return}u?.(z)},M=f?z=>f(z):void 0,D=z=>{_.current&&(z.stopPropagation(),_.current=!1)},V=z=>{const{domNode:Z,transform:te}=x.getState();if(A.current=Z?.getBoundingClientRect(),!A.current)return;const ee=z.target===R.current;if(!ee&&!!z.target.closest(".nokey")||!e||!(r&&ee||t)||z.button!==0||!z.isPrimary)return;z.target?.setPointerCapture?.(z.pointerId),_.current=!1;const{x:re,y:ie}=Ae(z.nativeEvent,A.current),ce=Nn({x:re,y:ie},te);x.setState({userSelectionRect:{width:0,height:0,startX:ce.x,startY:ce.y,x:re,y:ie}}),ee||(z.stopPropagation(),z.preventDefault())};function T(z,Z){const{userSelectionRect:te}=x.getState();if(!te)return;const{transform:ee,nodeLookup:K,edgeLookup:Q,connectionLookup:re,triggerNodeChanges:ie,triggerEdgeChanges:ce,defaultEdgeOptions:he}=x.getState(),ge={x:te.startX,y:te.startY},{x:be,y:Ee}=Pt(ge,ee),Ie={startX:ge.x,startY:ge.y,x:z<be?z:be,y:Z<Ee?Z:Ee,width:Math.abs(z-be),height:Math.abs(Z-Ee)},Ze=L.current,Ge=O.current;L.current=new Set(Do(K,Ie,ee,n===on.Partial,!0).map(B=>B.id)),O.current=new Set;const Ue=he?.selectable??!0;for(const B of L.current){const G=re.get(B);if(G)for(const{edgeId:ne}of G.values()){const ue=Q.get(ne);ue&&(ue.selectable??Ue)&&O.current.add(ne)}}if(!Lr(Ze,L.current)){const B=St(K,L.current,!0);ie(B)}if(!Lr(Ge,O.current)){const B=St(Q,O.current);ce(B)}x.setState({userSelectionRect:Ie,userSelectionActive:!0,nodesSelectionActive:!1})}function F(){if(!o||!A.current)return;const[z,Z]=Po(N.current,A.current,k);E({x:z,y:Z}).then(te=>{if(!_.current||!te){y.current=requestAnimationFrame(F);return}const{x:ee,y:K}=N.current;T(ee,K),y.current=requestAnimationFrame(F)})}const P=()=>{cancelAnimationFrame(y.current),y.current=0,C.current=!1};j.useEffect(()=>()=>P(),[]);const W=z=>{const{userSelectionRect:Z,transform:te,resetSelectedElements:ee}=x.getState();if(!A.current||!Z)return;const{x:K,y:Q}=Ae(z.nativeEvent,A.current);N.current={x:K,y:Q};const re=Pt({x:Z.startX,y:Z.startY},te);if(!_.current){const ie=t?0:i;if(Math.hypot(K-re.x,Q-re.y)<=ie)return;ee(),c?.(z)}_.current=!0,C.current||(F(),C.current=!0),T(K,Q)},Y=z=>{if(!S){z.target===R.current&&x.getState().connection.inProgress&&(H.current=!0);return}z.button===0&&(z.target?.releasePointerCapture?.(z.pointerId),!b&&z.target===R.current&&x.getState().userSelectionRect&&I?.(z),x.setState({userSelectionActive:!1,userSelectionRect:null}),_.current&&(l?.(z),x.setState({nodesSelectionActive:L.current.size>0})),P())},J=z=>{z.target?.releasePointerCapture?.(z.pointerId),P()},U=s===!0||Array.isArray(s)&&s.includes(0);return a.jsxs("div",{className:fe(["react-flow__pane",{draggable:U,dragging:v,selection:e}]),onClick:S?void 0:Ls(I,R),onContextMenu:Ls($,R),onWheel:Ls(M,R),onPointerEnter:S?void 0:h,onPointerMove:S?W:p,onPointerUp:Y,onPointerCancel:S?J:void 0,onPointerDownCapture:S?V:void 0,onClickCapture:S?D:void 0,onPointerLeave:m,ref:R,style:ks,children:[w,a.jsx(Dx,{})]})}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]=j.useState(!1),u=j.useRef();return j.useEffect(()=>{if(!t)return u.current=jg({getStoreItems:()=>c.getState(),onNodeMouseDown:f=>{no({id:f,store:c,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,c,e]),j.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 zx=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function zc(){const e=le();return j.useCallback(n=>{const{nodeExtent:s,snapToGrid:o,snapGrid:i,nodesDraggable:r,onError:c,updateNodePositions:l,nodeLookup:d,nodeOrigin:u}=e.getState(),f=new Map,h=zx(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(!h(x))continue;let b={x:x.internals.positionAbsolute.x+w,y:x.internals.positionAbsolute.y+y};o&&(b=bn(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,f.set(x.id,x)}l(f)},[])}const Wo=j.createContext(null),Tx=Wo.Provider;Wo.Consumer;const Tc=()=>j.useContext(Wo),Lx=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Lc=j.createContext(null);function Hx({children:e}){const t=oe(Lx,de);return a.jsx(Lc.Provider,{value:t,children:e})}function Vx(){const e=j.useContext(Lc);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const Fx={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Bx=(e,t,n)=>s=>{const{connectionClickStartHandle:o,connectionMode:i,connection:r}=s,{fromHandle:c,toHandle:l,isValid:d}=r;if(!c&&!o)return Fx;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===At.Strict?c?.type!==n:e!==c?.nodeId||t!==c?.id,connectionInProcess:!!c,clickConnectionInProcess:!!o,valid:u&&d}};function Wx({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:f,...h},p){const m=r||null,w=e==="target",y=le(),x=Tc(),{connectOnClick:b,noPanClassName:g,rfId:v}=Vx(),{connectingFrom:E,connectingTo:k,clickConnecting:S,isPossibleEndHandle:R,connectionInProcess:A,clickConnectionInProcess:L,valid:O}=oe(Bx(x,m,e),de);x||y.getState().onError?.("010",Te.error010());const H=C=>{const{defaultEdgeOptions:I,onConnect:$,hasDefaultEdges:M}=y.getState(),D={...I,...C};if(M){const{edges:V,setEdges:T,onError:F}=y.getState();T(Nx(D,V,{onError:F}))}$?.(D),c?.(D)},_=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:(...M)=>y.getState().onConnectEnd?.(...M),updateConnection:$.updateConnection,onConnect:H,isValidConnection:n||((...M)=>y.getState().isValidConnection?.(...M)??!0),getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,autoPanSpeed:$.autoPanSpeed,dragThreshold:$.connectionDragThreshold})}I?u?.(C):f?.(C)},N=C=>{const{onClickConnectStart:I,onClickConnectEnd:$,connectionClickStartHandle:M,connectionMode:D,isValidConnection:V,lib:T,rfId:F,nodeLookup:P,connection:W}=y.getState();if(!x||!M&&!o)return;if(!M){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||V,{connection:U,isValid:z}=to.isValid(C.nativeEvent,{handle:{nodeId:x,id:m,type:e},connectionMode:D,fromNodeId:M.nodeId,fromHandleId:M.id||null,fromType:M.type,isValidConnection:J,flowId:F,doc:Y,lib:T,nodeLookup:P});z&&U&&H(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:fe(["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:k,valid:O,connectionindicator:s&&(!A||R)&&(A||L?i:o)}]),onMouseDown:_,onTouchStart:_,onClick:b?N:void 0,ref:p,...h,children:l})}const ke=j.memo(Ac(Wx));function Yx({data:e,isConnectable:t,sourcePosition:n=q.Bottom}){return a.jsxs(a.Fragment,{children:[e?.label,a.jsx(ke,{type:"source",position:n,isConnectable:t})]})}function Xx({data:e,isConnectable:t,targetPosition:n=q.Top,sourcePosition:s=q.Bottom}){return a.jsxs(a.Fragment,{children:[a.jsx(ke,{type:"target",position:n,isConnectable:t}),e?.label,a.jsx(ke,{type:"source",position:s,isConnectable:t})]})}function qx(){return null}function Zx({data:e,isConnectable:t,targetPosition:n=q.Top}){return a.jsxs(a.Fragment,{children:[a.jsx(ke,{type:"target",position:n,isConnectable:t}),e?.label]})}const ns={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},gi={input:Yx,default:Xx,output:Zx,group:qx};function Gx(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 Ux=e=>{const{width:t,height:n,x:s,y:o}=vn(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 Kx({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=le(),{width:o,height:i,transformString:r,userSelectionActive:c}=oe(Ux,de),l=zc(),d=j.useRef(null);j.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 f=e?p=>{const m=s.getState().nodes.filter(w=>w.selected);e(p,m)}:void 0,h=p=>{Object.prototype.hasOwnProperty.call(ns,p.key)&&(p.preventDefault(),l({direction:ns[p.key],factor:p.shiftKey?4:1}))};return a.jsx("div",{className:fe(["react-flow__nodesselection","react-flow__container",t]),style:{transform:r},children:a.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:o,height:i}})})}const xi=typeof window<"u"?window:void 0,Qx=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:f,onSelectionStart:h,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:w,zoomActivationKeyCode:y,elementsSelectable:x,zoomOnScroll:b,zoomOnPinch:g,panOnScroll:v,panOnScrollSpeed:E,panOnScrollMode:k,zoomOnDoubleClick:S,panOnDrag:R,autoPanOnSelection:A,defaultViewport:L,translateExtent:O,minZoom:H,maxZoom:_,preventScrolling:N,onSelectionContextMenu:C,noWheelClassName:I,noPanClassName:$,disableKeyboardA11y:M,onViewportChange:D,isControlledViewport:V}){const{nodesSelectionActive:T,userSelectionActive:F}=oe(Qx,de),P=cn(d,{target:xi}),W=cn(w,{target:xi}),Y=W||R,J=W||v,U=u&&Y!==!0,z=P||F||U;return _x({deleteKeyCode:l,multiSelectionKeyCode:m}),a.jsx(Rx,{onPaneContextMenu:i,elementsSelectable:x,zoomOnScroll:b,zoomOnPinch:g,panOnScroll:J,panOnScrollSpeed:E,panOnScrollMode:k,zoomOnDoubleClick:S,panOnDrag:!P&&Y,defaultViewport:L,translateExtent:O,minZoom:H,maxZoom:_,zoomActivationKeyCode:y,preventScrolling:N,noWheelClassName:I,noPanClassName:$,onViewportChange:D,isControlledViewport:V,paneClickDistance:c,selectionOnDrag:U,children:a.jsxs(Ox,{onSelectionStart:h,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:r,panOnDrag:Y,autoPanOnSelection:A,isSelecting:!!z,selectionMode:f,selectionKeyPressed:P,paneClickDistance:c,selectionOnDrag:U,children:[e,T&&a.jsx(Kx,{onSelectionContextMenu:C,noPanClassName:$,disableKeyboardA11y:M})]})})}Hc.displayName="FlowRenderer";const Jx=j.memo(Hc),e0=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 t0(e){return oe(j.useCallback(e0(e),[e]),de)}const n0=e=>e.updateNodeInternals;function s0(){const e=oe(n0),[t]=j.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 j.useEffect(()=>()=>{t?.disconnect()},[t]),t}function o0({node:e,nodeType:t,hasDimensions:n,resizeObserver:s}){const o=le(),i=j.useRef(null),r=j.useRef(null),c=j.useRef(e.sourcePosition),l=j.useRef(e.targetPosition),d=j.useRef(t),u=n&&!!e.internals.handleBounds;return j.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]),j.useEffect(()=>()=>{r.current&&(s?.unobserve(r.current),r.current=null)},[]),j.useEffect(()=>{if(i.current){const f=d.current!==t,h=c.current!==e.sourcePosition,p=l.current!==e.targetPosition;(f||h||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 r0({id:e,onClick:t,onMouseEnter:n,onMouseMove:s,onMouseLeave:o,onContextMenu:i,onDoubleClick:r,nodesDraggable:c,elementsSelectable:l,nodesConnectable:d,nodesFocusable:u,resizeObserver:f,noDragClassName:h,noPanClassName:p,disableKeyboardA11y:m,rfId:w,nodeTypes:y,nodeClickDistance:x,onError:b}){const{node:g,internals:v,isParent:E}=oe(z=>{const Z=z.nodeLookup.get(e),te=z.parentLookup.has(e);return{node:Z,internals:Z.internals,isParent:te}},de);let k=g.type||"default",S=y?.[k]||gi[k];S===void 0&&(b?.("003",Te.error003(k)),k="default",S=y?.default||gi.default);const R=!!(g.draggable||c&&typeof g.draggable>"u"),A=!!(g.selectable||l&&typeof g.selectable>"u"),L=!!(g.connectable||d&&typeof g.connectable>"u"),O=!!(g.focusable||u&&typeof g.focusable>"u"),H=le(),_=cc(g),N=o0({node:g,nodeType:k,hasDimensions:_,resizeObserver:f}),C=Oc({nodeRef:N,disabled:g.hidden||!R,noDragClassName:h,handleSelector:g.dragHandle,nodeId:e,isSelectable:A,nodeClickDistance:x}),I=zc();if(g.hidden)return null;const $=qe(g),M=Gx(g),D=A||R||t||n||s||o,V=n?z=>n(z,{...v.userNode}):void 0,T=s?z=>s(z,{...v.userNode}):void 0,F=o?z=>o(z,{...v.userNode}):void 0,P=i?z=>i(z,{...v.userNode}):void 0,W=r?z=>r(z,{...v.userNode}):void 0,Y=z=>{const{selectNodesOnDrag:Z,nodeDragThreshold:te}=H.getState();A&&(!Z||!R||te>0)&&no({id:e,store:H,nodeRef:N}),t&&t(z,{...v.userNode})},J=z=>{if(!(uc(z.nativeEvent)||m)){if(Qa.includes(z.key)&&A){const Z=z.key==="Escape";no({id:e,store:H,unselect:Z,nodeRef:N})}else if(R&&g.selected&&Object.prototype.hasOwnProperty.call(ns,z.key)){z.preventDefault();const{ariaLabelConfig:Z}=H.getState();H.setState({ariaLiveMessage:Z["node.a11yDescription.ariaLiveMessage"]({direction:z.key.replace("Arrow","").toLowerCase(),x:~~v.positionAbsolute.x,y:~~v.positionAbsolute.y})}),I({direction:ns[z.key],factor:z.shiftKey?4:1})}}},U=()=>{if(m||!N.current?.matches(":focus-visible"))return;const{transform:z,width:Z,height:te,autoPanOnNodeFocus:ee,setCenter:K}=H.getState();if(!ee)return;Do(new Map([[e,g]]),{x:0,y:0,width:Z,height:te},z,!0).length>0||K(g.position.x+$.width/2,g.position.y+$.height/2,{zoom:z[2]})};return a.jsx("div",{className:fe(["react-flow__node",`react-flow__node-${k}`,{[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:_?"visible":"hidden",...g.style,...M},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:V,onMouseMove:T,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(Tx,{value:e,children:a.jsx(S,{id:e,data:g.data,type:k,positionAbsoluteX:v.positionAbsolute.x,positionAbsoluteY:v.positionAbsolute.y,selected:g.selected??!1,selectable:A,draggable:R,deletable:g.deletable??!0,isConnectable:L,sourcePosition:g.sourcePosition,targetPosition:g.targetPosition,dragging:C,dragHandle:g.dragHandle,zIndex:v.z,parentId:g.parentId,...$})})})}var i0=j.memo(r0);const a0=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(a0,de),i=t0(e.onlyRenderVisibleElements),r=s0();return a.jsx("div",{className:"react-flow__nodes",style:ks,children:i.map(c=>a.jsx(i0,{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 c0=j.memo(Vc);function l0(e){return oe(j.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&&og({sourceNode:i,targetNode:r,width:n.width,height:n.height,transform:n.transform})&&s.push(o.id)}return s},[e]),de)}const d0=({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"})},u0=({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={[tt.Arrow]:d0,[tt.ArrowClosed]:u0};function f0(e){const t=le();return j.useMemo(()=>Object.prototype.hasOwnProperty.call(yi,e)?yi[e]:(t.getState().onError?.("009",Te.error009(e)),null),[e])}const h0=({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=f0(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=j.useMemo(()=>fg(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(h0,{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 p0=j.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[f,h]=j.useState({x:1,y:0,width:0,height:0}),p=fe(["react-flow__edge-textwrapper",d]),m=j.useRef(null);return j.useEffect(()=>{if(m.current){const w=m.current.getBBox();h({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),n?a.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:p,visibility:f.width?"visible":"hidden",...u,children:[o&&a.jsx("rect",{width:f.width+2*r[0],x:-r[0],y:-r[1],height:f.height+2*r[1],className:"react-flow__edge-textbg",style:i,rx:c,ry:c}),a.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:m,style:s,children:n}),l]}):null}Bc.displayName="EdgeText";const m0=j.memo(Bc);function Bt({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:fe(["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(m0,{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,f,h,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,f,h,p]}function Yc(e){return j.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,sourcePosition:r,targetPosition:c,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:f,labelBgPadding:h,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(Bt,{id:E,path:b,labelX:g,labelY:v,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:y,interactionWidth:x})})}const g0=Yc({isInternal:!1}),Xc=Yc({isInternal:!0});g0.displayName="SimpleBezierEdge";Xc.displayName="SimpleBezierEdgeInternal";function qc(e){return j.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,label:r,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:f,style:h,sourcePosition:p=q.Bottom,targetPosition:m=q.Top,markerEnd:w,markerStart:y,pathOptions:x,interactionWidth:b})=>{const[g,v,E]=ts({sourceX:n,sourceY:s,sourcePosition:p,targetX:o,targetY:i,targetPosition:m,borderRadius:x?.borderRadius,offset:x?.offset,stepPosition:x?.stepPosition}),k=e.isInternal?void 0:t;return a.jsx(Bt,{id:k,path:g,labelX:v,labelY:E,label:r,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:f,style:h,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 j.memo(({id:t,...n})=>{const s=e.isInternal?void 0:t;return a.jsx(Zc,{...n,id:s,pathOptions:j.useMemo(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const x0=Uc({isInternal:!1}),Kc=Uc({isInternal:!0});x0.displayName="StepEdge";Kc.displayName="StepEdgeInternal";function Qc(e){return j.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,label:r,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:f,style:h,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(Bt,{id:g,path:y,labelX:x,labelY:b,label:r,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:f,style:h,markerEnd:p,markerStart:m,interactionWidth:w})})}const y0=Qc({isInternal:!1}),Jc=Qc({isInternal:!0});y0.displayName="StraightEdge";Jc.displayName="StraightEdgeInternal";function el(e){return j.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:f,labelBgPadding:h,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:y,pathOptions:x,interactionWidth:b})=>{const[g,v,E]=To({sourceX:n,sourceY:s,sourcePosition:r,targetX:o,targetY:i,targetPosition:c,curvature:x?.curvature}),k=e.isInternal?void 0:t;return a.jsx(Bt,{id:k,path:g,labelX:v,labelY:E,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:y,interactionWidth:b})})}const w0=el({isInternal:!1}),tl=el({isInternal:!0});w0.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},v0=(e,t,n)=>n===q.Left?e-t:n===q.Right?e+t:e,b0=(e,t,n)=>n===q.Top?e-t:n===q.Bottom?e+t:e,Ni="react-flow__edgeupdater";function ji({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:fe([Ni,`${Ni}-${c}`]),cx:v0(t,s,e),cy:b0(n,s,e),r:s,stroke:"transparent",fill:"transparent"})}function N0({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:s,sourceY:o,targetX:i,targetY:r,sourcePosition:c,targetPosition:l,onReconnect:d,onReconnectStart:u,onReconnectEnd:f,setReconnecting:h,setUpdateHover:p}){const m=le(),w=(v,E)=>{if(v.button!==0)return;const{autoPanOnConnect:k,domNode:S,connectionMode:R,connectionRadius:A,lib:L,onConnectStart:O,cancelConnection:H,nodeLookup:_,rfId:N,panBy:C,updateConnection:I}=m.getState(),$=E.type==="target",M=(T,F)=>{h(!1),f?.(T,n,E.type,F)},D=T=>d?.(n,T),V=(T,F)=>{h(!0),u?.(v,n,E.type),O?.(T,F)};to.onPointerDown(v.nativeEvent,{autoPanOnConnect:k,connectionMode:R,connectionRadius:A,domNode:S,handleId:E.id,nodeId:E.nodeId,nodeLookup:_,isTarget:$,edgeUpdaterType:E.type,lib:L,flowId:N,cancelConnection:H,panBy:C,isValidConnection:(...T)=>m.getState().isValidConnection?.(...T)??!0,onConnect:D,onConnectStart:V,onConnectEnd:(...T)=>m.getState().onConnectEnd?.(...T),onReconnectEnd:M,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(ji,{position:c,centerX:s,centerY:o,radius:t,onMouseDown:y,onMouseEnter:b,onMouseOut:g,type:"source"}),(e===!0||e==="target")&&a.jsx(ji,{position:l,centerX:i,centerY:r,radius:t,onMouseDown:x,onMouseEnter:b,onMouseOut:g,type:"target"})]})}function j0({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:s,onClick:o,onDoubleClick:i,onContextMenu:r,onMouseEnter:c,onMouseMove:l,onMouseLeave:d,reconnectRadius:u,onReconnect:f,onReconnectStart:h,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",k=w?.[E]||vi[E];k===void 0&&(x?.("011",Te.error011(E)),E="default",k=w?.default||vi.default);const S=!!(g.focusable||t&&typeof g.focusable>"u"),R=typeof f<"u"&&(g.reconnectable||n&&typeof g.reconnectable>"u"),A=!!(g.selectable||s&&typeof g.selectable>"u"),L=j.useRef(null),[O,H]=j.useState(!1),[_,N]=j.useState(!1),C=le(),{zIndex:I=g.zIndex,sourceX:$,sourceY:M,targetX:D,targetY:V,sourcePosition:T,targetPosition:F}=oe(j.useCallback(K=>{const Q=K.nodeLookup.get(g.source),re=K.nodeLookup.get(g.target);if(!Q||!re)return bi;const ie=ug({id:e,sourceNode:Q,targetNode:re,sourceHandle:g.sourceHandle||null,targetHandle:g.targetHandle||null,connectionMode:K.connectionMode,onError:x}),ce=sg({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]),de),P=j.useMemo(()=>g.markerStart?`url('#${Js(g.markerStart,m)}')`:void 0,[g.markerStart,m]),W=j.useMemo(()=>g.markerEnd?`url('#${Js(g.markerEnd,m)}')`:void 0,[g.markerEnd,m]);if(g.hidden||$===null||M===null||D===null||V===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]}),L.current?.blur()):Q([e])),o&&o(K,g)},J=i?K=>{i(K,{...g})}:void 0,U=r?K=>{r(K,{...g})}:void 0,z=c?K=>{c(K,{...g})}:void 0,Z=l?K=>{l(K,{...g})}:void 0,te=d?K=>{d(K,{...g})}:void 0,ee=K=>{if(!b&&Qa.includes(K.key)&&A){const{unselectNodesAndEdges:Q,addSelectedEdges:re}=C.getState();K.key==="Escape"?(L.current?.blur(),Q({edges:[g]})):re([e])}};return a.jsx("svg",{style:{zIndex:I},children:a.jsxs("g",{className:fe(["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:z,onMouseMove:Z,onMouseLeave:te,onKeyDown:S?ee: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:L,...g.domAttributes,children:[!_&&a.jsx(k,{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:M,targetX:D,targetY:V,sourcePosition:T,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(N0,{edge:g,isReconnectable:R,reconnectRadius:u,onReconnect:f,onReconnectStart:h,onReconnectEnd:p,sourceX:$,sourceY:M,targetX:D,targetY:V,sourcePosition:T,targetPosition:F,setUpdateHover:H,setReconnecting:N})]})})}var k0=j.memo(j0);const E0=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:f,onEdgeDoubleClick:h,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:w}){const{edgesFocusable:y,edgesReconnectable:x,elementsSelectable:b,onError:g}=oe(E0,de),v=l0(t);return a.jsxs("div",{className:"react-flow__edges",children:[a.jsx(p0,{defaultColor:e,rfId:n}),v.map(E=>a.jsx(k0,{id:E,edgesFocusable:y,edgesReconnectable:x,elementsSelectable:b,noPanClassName:o,onReconnect:i,onContextMenu:r,onMouseEnter:c,onMouseMove:l,onMouseLeave:d,onClick:u,reconnectRadius:f,onDoubleClick:h,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:g,edgeTypes:s,disableKeyboardA11y:w},E))]})}nl.displayName="EdgeRenderer";const C0=j.memo(nl),ki=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function S0({children:e}){const t=le(),n=j.useRef(null),[s]=j.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=ki(r)))};return i(),t.subscribe(i)},[t]),a.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:ki(s)},children:e})}function I0(e){const t=Ft(),n=j.useRef(!1);j.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const _0=e=>e.panZoom?.syncViewport;function M0(e){const t=oe(_0),n=le();return j.useEffect(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function $0(e){return e.connection.inProgress?{...e.connection,to:Nn(e.connection.to,e.transform)}:{...e.connection}}function R0(e){return $0}function A0(e){const t=R0();return oe(t,de)}const D0=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function P0({containerStyle:e,style:t,type:n,component:s}){const{nodesConnectable:o,width:i,height:r,isValid:c,inProgress:l}=oe(D0,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:fe(["react-flow__connection",tc(c)]),children:a.jsx(sl,{style:t,type:n,CustomComponent:s,isValid:c})})})}const sl=({style:e,type:t=ot.Bezier,CustomComponent:n,isValid:s})=>{const{inProgress:o,from:i,fromNode:r,fromHandle:c,fromPosition:l,to:d,toNode:u,toHandle:f,toPosition:h,pointer:p}=A0();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:h,connectionStatus:tc(s),toNode:u,toHandle:f,pointer:p});let m="";const w={sourceX:i.x,sourceY:i.y,sourcePosition:l,targetX:d.x,targetY:d.y,targetPosition:h};switch(t){case ot.Bezier:[m]=To(w);break;case ot.SimpleBezier:[m]=Wc(w);break;case ot.Step:[m]=ts({...w,borderRadius:0});break;case ot.SmoothStep:[m]=ts(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 O0={};function Ei(e=O0){j.useRef(e),le(),j.useEffect(()=>{},[e])}function z0(){le(),j.useRef(!1),j.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:f,onSelectionStart:h,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:w,connectionLineComponent:y,connectionLineContainerStyle:x,selectionKeyCode:b,selectionOnDrag:g,selectionMode:v,multiSelectionKeyCode:E,panActivationKeyCode:k,zoomActivationKeyCode:S,deleteKeyCode:R,onlyRenderVisibleElements:A,elementsSelectable:L,defaultViewport:O,translateExtent:H,minZoom:_,maxZoom:N,preventScrolling:C,defaultMarkerColor:I,zoomOnScroll:$,zoomOnPinch:M,panOnScroll:D,panOnScrollSpeed:V,panOnScrollMode:T,zoomOnDoubleClick:F,panOnDrag:P,autoPanOnSelection:W,onPaneClick:Y,onPaneMouseEnter:J,onPaneMouseMove:U,onPaneMouseLeave:z,onPaneScroll:Z,onPaneContextMenu:te,paneClickDistance:ee,nodeClickDistance:K,onEdgeContextMenu:Q,onEdgeMouseEnter:re,onEdgeMouseMove:ie,onEdgeMouseLeave:ce,reconnectRadius:he,onReconnect:ge,onReconnectStart:be,onReconnectEnd:Ee,noDragClassName:Ie,noWheelClassName:Ze,noPanClassName:Ge,disableKeyboardA11y:Ue,nodeExtent:B,rfId:G,viewport:ne,onViewportChange:ue,nodesDraggable:ae}){return Ei(e),Ei(t),z0(),I0(n),M0(ne),a.jsx(Jx,{onPaneClick:Y,onPaneMouseEnter:J,onPaneMouseMove:U,onPaneMouseLeave:z,onPaneContextMenu:te,onPaneScroll:Z,paneClickDistance:ee,deleteKeyCode:R,selectionKeyCode:b,selectionOnDrag:g,selectionMode:v,onSelectionStart:h,onSelectionEnd:p,multiSelectionKeyCode:E,panActivationKeyCode:k,zoomActivationKeyCode:S,elementsSelectable:L,zoomOnScroll:$,zoomOnPinch:M,zoomOnDoubleClick:F,panOnScroll:D,panOnScrollSpeed:V,panOnScrollMode:T,panOnDrag:P,autoPanOnSelection:W,defaultViewport:O,translateExtent:H,minZoom:_,maxZoom:N,onSelectionContextMenu:f,preventScrolling:C,noDragClassName:Ie,noWheelClassName:Ze,noPanClassName:Ge,disableKeyboardA11y:Ue,onViewportChange:ue,isControlledViewport:!!ne,children:a.jsxs(S0,{children:[a.jsx(C0,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:r,onReconnect:ge,onReconnectStart:be,onReconnectEnd:Ee,onlyRenderVisibleElements:A,onEdgeContextMenu:Q,onEdgeMouseEnter:re,onEdgeMouseMove:ie,onEdgeMouseLeave:ce,reconnectRadius:he,defaultMarkerColor:I,noPanClassName:Ge,disableKeyboardA11y:Ue,rfId:G}),a.jsx(P0,{style:w,type:m,component:y,containerStyle:x}),a.jsx("div",{className:"react-flow__edgelabel-renderer"}),a.jsx(c0,{nodeTypes:e,onNodeClick:s,onNodeDoubleClick:i,onNodeMouseEnter:c,onNodeMouseMove:l,onNodeMouseLeave:d,onNodeContextMenu:u,nodeClickDistance:K,onlyRenderVisibleElements:A,noPanClassName:Ge,noDragClassName:Ie,disableKeyboardA11y:Ue,nodeExtent:B,rfId:G,nodesDraggable:ae}),a.jsx("div",{className:"react-flow__viewport-portal"})]})})}ol.displayName="GraphView";const T0=j.memo(ol),L0=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:f,zIndexMode:h="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=f??sn;yc(w,y,x);const{nodesInitialized:E}=eo(b,p,m,{nodeOrigin:g,nodeExtent:v,zIndexMode:h});let k=[0,0,1];if(r&&o&&i){const S=vn(p,{filter:O=>!!((O.width||O.initialWidth)&&(O.height||O.initialHeight))}),{x:R,y:A,zoom:L}=Oo(S,o,i,l,d,c?.padding??.1);k=[R,A,L]}return{rfId:"1",width:o??0,height:i??0,transform:k,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:sn,nodeExtent:v,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:At.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:L0,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Ja,zIndexMode:h,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},H0=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:o,height:i,fitView:r,fitViewOptions:c,minZoom:l,maxZoom:d,nodeOrigin:u,nodeExtent:f,zIndexMode:h})=>ex((p,m)=>{async function w(){const{nodeLookup:y,panZoom:x,fitViewOptions:b,fitViewResolver:g,width:v,height:E,minZoom:k,maxZoom:S}=m();x&&(await Um({nodes:y,width:v,height:E,panZoom:x,minZoom:k,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:f,defaultNodes:n,defaultEdges:s,zIndexMode:h}),setNodes:y=>{const{nodeLookup:x,parentLookup:b,nodeOrigin:g,elevateNodesOnSelect:v,fitViewQueued:E,zIndexMode:k,nodesSelectionActive:S}=m(),{nodesInitialized:R,hasSelectedNodes:A}=eo(y,x,b,{nodeOrigin:g,nodeExtent:f,elevateNodesOnSelect:v,checkEquality:!0,zIndexMode:k}),L=S&&A;E&&R?(w(),p({nodes:y,nodesInitialized:R,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:L})):p({nodes:y,nodesInitialized:R,nodesSelectionActive:L})},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:k,debug:S,fitViewQueued:R,zIndexMode:A}=m(),{changes:L,updatedInternals:O}=wg(y,b,g,v,E,k,A);O&&(mg(b,g,{nodeOrigin:E,nodeExtent:k,zIndexMode:A}),R?(w(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),L?.length>0&&(S&&console.log("React Flow: trigger node changes",L),x?.(L)))},updateNodePositions:(y,x=!1)=>{const b=[];let g=[];const{nodeLookup:v,triggerNodeChanges:E,connection:k,updateConnection:S,onNodesChangeMiddlewareMap:R}=m();for(const[A,L]of y){const O=v.get(A),H=!!(O?.expandParent&&O?.parentId&&L?.position),_={id:A,type:"position",position:H?{x:Math.max(0,L.position.x),y:Math.max(0,L.position.y)}:L.position,dragging:x};if(O&&k.inProgress&&k.fromNode.id===O.id){const N=bt(O,k.fromHandle,q.Left,!0);S({...k,from:N})}H&&O.parentId&&b.push({id:A,parentId:O.parentId,rect:{...L.internals.positionAbsolute,width:L.measured.width??0,height:L.measured.height??0}}),g.push(_)}if(b.length>0){const{parentLookup:A,nodeOrigin:L}=m(),O=Bo(b,v,A,L);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 k=Ns(y,g);b(k)}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 k=js(y,g);b(k)}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 k=y.map(S=>lt(S,!0));v(k);return}v(St(g,new Set([...y]),!0)),E(St(b))},addSelectedEdges:y=>{const{multiSelectionActive:x,edgeLookup:b,nodeLookup:g,triggerNodeChanges:v,triggerEdgeChanges:E}=m();if(x){const k=y.map(S=>lt(S,!0));E(k);return}E(St(b,new Set([...y]))),v(St(g,new Set,!0))},unselectNodesAndEdges:({nodes:y,edges:x}={})=>{const{edges:b,nodes:g,nodeLookup:v,triggerNodeChanges:E,triggerEdgeChanges:k}=m(),S=y||g,R=x||b,A=[];for(const O of S){if(!O.selected)continue;const H=v.get(O.id);H&&(H.selected=!1),A.push(lt(O.id,!1))}const L=[];for(const O of R)O.selected&&L.push(lt(O.id,!1));E(A),k(L)},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,lt(R.id,!1)]:S,[]),k=y.reduce((S,R)=>R.selected?[...S,lt(R.id,!1)]:S,[]);b(E),g(k)},setNodeExtent:y=>{const{nodes:x,nodeLookup:b,parentLookup:g,nodeOrigin:v,elevateNodesOnSelect:E,nodeExtent:k,zIndexMode:S}=m();y[0][0]===k[0][0]&&y[0][1]===k[0][1]&&y[1][0]===k[1][0]&&y[1][1]===k[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 vg({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:k}=m();if(!k)return!1;const S=typeof b?.zoom<"u"?b.zoom:E;return await k.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:f,zIndexMode:h,children:p}){const[m]=j.useState(()=>H0({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:o,height:i,fitView:d,minZoom:r,maxZoom:c,fitViewOptions:l,nodeOrigin:u,nodeExtent:f,zIndexMode:h}));return a.jsx(tx,{value:m,children:a.jsx(Ex,{children:a.jsx(Hx,{children:p})})})}function V0({children:e,nodes:t,edges:n,defaultNodes:s,defaultEdges:o,width:i,height:r,fitView:c,fitViewOptions:l,minZoom:d,maxZoom:u,nodeOrigin:f,nodeExtent:h,zIndexMode:p}){return j.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:f,nodeExtent:h,zIndexMode:p,children:e})}const F0={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function B0({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:o,nodeTypes:i,edgeTypes:r,onNodeClick:c,onEdgeClick:l,onInit:d,onMove:u,onMoveStart:f,onMoveEnd:h,onConnect:p,onConnectStart:m,onConnectEnd:w,onClickConnectStart:y,onClickConnectEnd:x,onNodeMouseEnter:b,onNodeMouseMove:g,onNodeMouseLeave:v,onNodeContextMenu:E,onNodeDoubleClick:k,onNodeDragStart:S,onNodeDrag:R,onNodeDragStop:A,onNodesDelete:L,onEdgesDelete:O,onDelete:H,onSelectionChange:_,onSelectionDragStart:N,onSelectionDrag:C,onSelectionDragStop:I,onSelectionContextMenu:$,onSelectionStart:M,onSelectionEnd:D,onBeforeDelete:V,connectionMode:T,connectionLineType:F=ot.Bezier,connectionLineStyle:P,connectionLineComponent:W,connectionLineContainerStyle:Y,deleteKeyCode:J="Backspace",selectionKeyCode:U="Shift",selectionOnDrag:z=!1,selectionMode:Z=on.Full,panActivationKeyCode:te="Space",multiSelectionKeyCode:ee=an()?"Meta":"Control",zoomActivationKeyCode:K=an()?"Meta":"Control",snapToGrid:Q,snapGrid:re,onlyRenderVisibleElements:ie=!1,selectNodesOnDrag:ce,nodesDraggable:he,autoPanOnNodeFocus:ge,nodesConnectable:be,nodesFocusable:Ee,nodeOrigin:Ie=$c,edgesFocusable:Ze,edgesReconnectable:Ge,elementsSelectable:Ue=!0,defaultViewport:B=px,minZoom:G=.5,maxZoom:ne=2,translateExtent:ue=sn,preventScrolling:ae=!0,nodeExtent:xe,defaultMarkerColor:ye="#b1b1b7",zoomOnScroll:ct=!0,zoomOnPinch:Bl=!0,panOnScroll:Wl=!1,panOnScrollSpeed:Yl=.5,panOnScrollMode:Xl=pt.Free,zoomOnDoubleClick:ql=!0,panOnDrag:Zl=!0,onPaneClick:Gl,onPaneMouseEnter:Ul,onPaneMouseMove:Kl,onPaneMouseLeave:Ql,onPaneScroll:Jl,onPaneContextMenu:ed,paneClickDistance:td=1,nodeClickDistance:nd=0,children:sd,onReconnect:od,onReconnectStart:rd,onReconnectEnd:id,onEdgeContextMenu:ad,onEdgeDoubleClick:cd,onEdgeMouseEnter:ld,onEdgeMouseMove:dd,onEdgeMouseLeave:ud,reconnectRadius:fd=10,onNodesChange:hd,onEdgesChange:pd,noDragClassName:md="nodrag",noWheelClassName:gd="nowheel",noPanClassName:ar="nopan",fitView:cr,fitViewOptions:lr,connectOnClick:xd,attributionPosition:yd,proOptions:wd,defaultEdgeOptions:vd,elevateNodesOnSelect:bd=!0,elevateEdgesOnSelect:Nd=!1,disableKeyboardA11y:dr=!1,autoPanOnConnect:jd,autoPanOnNodeDrag:kd,autoPanOnSelection:Ed=!0,autoPanSpeed:Cd,connectionRadius:Sd,isValidConnection:Id,onError:_d,style:Md,id:ur,nodeDragThreshold:$d,connectionDragThreshold:Rd,viewport:Ad,onViewportChange:Dd,width:Pd,height:Od,colorMode:zd="light",debug:Td,onScroll:fr,ariaLabelConfig:Ld,zIndexMode:hr="basic",...Hd},Vd){const Ss=ur||"1",Fd=yx(zd),Bd=j.useCallback(pr=>{pr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),fr?.(pr)},[fr]);return a.jsx("div",{"data-testid":"rf__wrapper",...Hd,onScroll:Bd,style:{...Md,...F0},ref:Vd,className:fe(["react-flow",o,Fd]),id:ur,role:"application",children:a.jsxs(V0,{nodes:e,edges:t,width:Pd,height:Od,fitView:cr,fitViewOptions:lr,minZoom:G,maxZoom:ne,nodeOrigin:Ie,nodeExtent:xe,zIndexMode:hr,children:[a.jsx(xx,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:p,onConnectStart:m,onConnectEnd:w,onClickConnectStart:y,onClickConnectEnd:x,nodesDraggable:he,autoPanOnNodeFocus:ge,nodesConnectable:be,nodesFocusable:Ee,edgesFocusable:Ze,edgesReconnectable:Ge,elementsSelectable:Ue,elevateNodesOnSelect:bd,elevateEdgesOnSelect:Nd,minZoom:G,maxZoom:ne,nodeExtent:xe,onNodesChange:hd,onEdgesChange:pd,snapToGrid:Q,snapGrid:re,connectionMode:T,translateExtent:ue,connectOnClick:xd,defaultEdgeOptions:vd,fitView:cr,fitViewOptions:lr,onNodesDelete:L,onEdgesDelete:O,onDelete:H,onNodeDragStart:S,onNodeDrag:R,onNodeDragStop:A,onSelectionDrag:C,onSelectionDragStart:N,onSelectionDragStop:I,onMove:u,onMoveStart:f,onMoveEnd:h,noPanClassName:ar,nodeOrigin:Ie,rfId:Ss,autoPanOnConnect:jd,autoPanOnNodeDrag:kd,autoPanSpeed:Cd,onError:_d,connectionRadius:Sd,isValidConnection:Id,selectNodesOnDrag:ce,nodeDragThreshold:$d,connectionDragThreshold:Rd,onBeforeDelete:V,debug:Td,ariaLabelConfig:Ld,zIndexMode:hr}),a.jsx(T0,{onInit:d,onNodeClick:c,onEdgeClick:l,onNodeMouseEnter:b,onNodeMouseMove:g,onNodeMouseLeave:v,onNodeContextMenu:E,onNodeDoubleClick:k,nodeTypes:i,edgeTypes:r,connectionLineType:F,connectionLineStyle:P,connectionLineComponent:W,connectionLineContainerStyle:Y,selectionKeyCode:U,selectionOnDrag:z,selectionMode:Z,deleteKeyCode:J,multiSelectionKeyCode:ee,panActivationKeyCode:te,zoomActivationKeyCode:K,onlyRenderVisibleElements:ie,defaultViewport:B,translateExtent:ue,minZoom:G,maxZoom:ne,preventScrolling:ae,zoomOnScroll:ct,zoomOnPinch:Bl,zoomOnDoubleClick:ql,panOnScroll:Wl,panOnScrollSpeed:Yl,panOnScrollMode:Xl,panOnDrag:Zl,autoPanOnSelection:Ed,onPaneClick:Gl,onPaneMouseEnter:Ul,onPaneMouseMove:Kl,onPaneMouseLeave:Ql,onPaneScroll:Jl,onPaneContextMenu:ed,paneClickDistance:td,nodeClickDistance:nd,onSelectionContextMenu:$,onSelectionStart:M,onSelectionEnd:D,onReconnect:od,onReconnectStart:rd,onReconnectEnd:id,onEdgeContextMenu:ad,onEdgeDoubleClick:cd,onEdgeMouseEnter:ld,onEdgeMouseMove:dd,onEdgeMouseLeave:ud,reconnectRadius:fd,defaultMarkerColor:ye,noDragClassName:md,noWheelClassName:gd,noPanClassName:ar,rfId:Ss,disableKeyboardA11y:dr,nodeExtent:xe,viewport:Ad,onViewportChange:Dd,nodesDraggable:he}),a.jsx(hx,{onSelectionChange:_}),sd,a.jsx(cx,{proOptions:wd,position:yd}),a.jsx(ax,{rfId:Ss,disableKeyboardA11y:dr})]})})}var Xo=Ac(B0);const W0=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");function Y0({children:e}){const t=oe(W0);return t?su.createPortal(e,t):null}function ss(e){return oe(j.useCallback(n=>n.nodeLookup.get(e),[e]),de)}function X0({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:fe(["react-flow__background-pattern",n,s])})}function q0({radius:e,className:t}){return a.jsx("circle",{cx:e,cy:e,r:e,className:fe(["react-flow__background-pattern","dots",t])})}var rt;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(rt||(rt={}));const Z0={[rt.Dots]:1,[rt.Lines]:1,[rt.Cross]:6},G0=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function rl({id:e,variant:t=rt.Dots,gap:n=20,size:s,lineWidth:o=1,offset:i=0,color:r,bgColor:c,style:l,className:d,patternClassName:u}){const f=j.useRef(null),{transform:h,patternId:p}=oe(G0,de),m=s||Z0[t],w=t===rt.Dots,y=t===rt.Cross,x=Array.isArray(n)?n:[n,n],b=[x[0]*h[2]||1,x[1]*h[2]||1],g=m*h[2],v=Array.isArray(i)?i:[i,i],E=y?[g,g]:b,k=[v[0]*h[2]||1+E[0]/2,v[1]*h[2]||1+E[1]/2],S=`${p}${e||""}`;return a.jsxs("svg",{className:fe(["react-flow__background",d]),style:{...l,...ks,"--xy-background-color-props":c,"--xy-background-pattern-color-props":r},ref:f,"data-testid":"rf__background",children:[a.jsx("pattern",{id:S,x:h[0]%b[0],y:h[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`,children:w?a.jsx(q0,{radius:g/2,className:u}):a.jsx(X0,{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=j.memo(rl);function U0(){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 K0(){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 Q0(){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 J0(){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 ey(){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 It({children:e,className:t,...n}){return a.jsx("button",{type:"button",className:fe(["react-flow__controls-button",t]),...n,children:e})}const ty=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:f="bottom-left",orientation:h="vertical","aria-label":p}){const m=le(),{isInteractive:w,minZoomReached:y,maxZoomReached:x,ariaLabelConfig:b}=oe(ty,de),{zoomIn:g,zoomOut:v,fitView:E}=Ft(),k=()=>{g(),i?.()},S=()=>{v(),r?.()},R=()=>{E(o),c?.()},A=()=>{m.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),l?.(!w)},L=h==="horizontal"?"horizontal":"vertical";return a.jsxs(it,{className:fe(["react-flow__controls",L,d]),position:f,style:e,"data-testid":"rf__controls","aria-label":p??b["controls.ariaLabel"],children:[t&&a.jsxs(a.Fragment,{children:[a.jsx(It,{onClick:k,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:x,children:a.jsx(U0,{})}),a.jsx(It,{onClick:S,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:y,children:a.jsx(K0,{})})]}),n&&a.jsx(It,{className:"react-flow__controls-fitview",onClick:R,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:a.jsx(Q0,{})}),s&&a.jsx(It,{className:"react-flow__controls-interactive",onClick:A,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:w?a.jsx(ey,{}):a.jsx(J0,{})}),u]})}il.displayName="Controls";const Zo=j.memo(il);function ny({id:e,x:t,y:n,width:s,height:o,style:i,color:r,strokeColor:c,strokeWidth:l,className:d,borderRadius:u,shapeRendering:f,selected:h,onClick:p}){const{background:m,backgroundColor:w}=i||{},y=r||m||w;return a.jsx("rect",{className:fe(["react-flow__minimap-node",{selected:h},d]),x:t,y:n,rx:u,ry:u,width:s,height:o,style:{fill:y,stroke:c,strokeWidth:l},shapeRendering:f,onClick:p?x=>p(x,e):void 0})}const sy=j.memo(ny),oy=e=>e.nodes.map(t=>t.id),Hs=e=>e instanceof Function?e:()=>e;function ry({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:o,nodeComponent:i=sy,onClick:r}){const c=oe(oy,de),l=Hs(t),d=Hs(e),u=Hs(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return a.jsx(a.Fragment,{children:c.map(h=>a.jsx(ay,{id:h,nodeColorFunc:l,nodeStrokeColorFunc:d,nodeClassNameFunc:u,nodeBorderRadius:s,nodeStrokeWidth:o,NodeComponent:i,onClick:r,shapeRendering:f},h))})}function iy({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:s,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:r,NodeComponent:c,onClick:l}){const{node:d,x:u,y:f,width:h,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}=qe(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:f,width:h,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 ay=j.memo(iy);var cy=j.memo(ry);const ly=200,dy=150,uy=e=>!e.hidden,fy=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(vn(e.nodeLookup,{filter:uy}),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,hy=(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,py="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:f,position:h="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(),k=j.useRef(null),{boundingRect:S,viewBB:R,rfId:A,panZoom:L,translateExtent:O,flowWidth:H,flowHeight:_,ariaLabelConfig:N}=oe(fy,hy),C=e?.width??ly,I=e?.height??dy,$=S.width/C,M=S.height/I,D=Math.max($,M),V=D*C,T=D*I,F=v*D,P=S.x-(V-S.width)/2-F,W=S.y-(T-S.height)/2-F,Y=V+F*2,J=T+F*2,U=`${py}-${A}`,z=j.useRef(0),Z=j.useRef();z.current=D,j.useEffect(()=>{if(k.current&&L)return Z.current=_g({domNode:k.current,panZoom:L,getTransform:()=>E.getState().transform,getViewScale:()=>z.current}),()=>{Z.current?.destroy()}},[L]),j.useEffect(()=>{Z.current?.update({translateExtent:O,width:H,height:_,inversePan:b,pannable:w,zoomStep:g,zoomable:y})},[w,y,b,g,O,H,_]);const te=p?Q=>{const[re,ie]=Z.current?.pointer(Q)||[0,0];p(Q,{x:re,y:ie})}:void 0,ee=m?j.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(it,{position:h,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 f=="number"?f*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:fe(["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:k,onClick:te,children:[K&&a.jsx("title",{id:U,children:K}),a.jsx(cy,{onClick:ee,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=j.memo(al),my=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,gy={[Ot.Line]:"right",[Ot.Handle]:"bottom-right"};function xy({nodeId:e,position:t,variant:n=Ot.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:f=!1,resizeDirection:h,autoScale:p=!0,shouldResize:m,onResizeStart:w,onResize:y,onResizeEnd:x}){const b=Tc(),g=typeof e=="string"?e:b,v=le(),E=j.useRef(null),k=n===Ot.Handle,S=oe(j.useCallback(my(k&&p),[k,p]),de),R=j.useRef(null),A=t??gy[n];j.useEffect(()=>{if(!(!E.current||!g))return R.current||(R.current=Fg({domNode:E.current,nodeId:g,getStoreItems:()=>{const{nodeLookup:O,transform:H,snapGrid:_,snapToGrid:N,nodeOrigin:C,domNode:I}=v.getState();return{nodeLookup:O,transform:H,snapGrid:_,snapToGrid:N,nodeOrigin:C,paneDomNode:I}},onChange:(O,H)=>{const{triggerNodeChanges:_,nodeLookup:N,parentLookup:C,nodeOrigin:I}=v.getState(),$=[],M={x:O.x,y:O.y},D=N.get(g);if(D&&D.expandParent&&D.parentId){const V=D.origin??I,T=O.width??D.measured.width??0,F=O.height??D.measured.height??0,P={id:D.id,parentId:D.parentId,rect:{width:T,height:F,...lc({x:O.x??D.position.x,y:O.y??D.position.y},{width:T,height:F},D.parentId,N,V)}},W=Bo([P],N,C,I);$.push(...W),M.x=O.x?Math.max(V[0]*T,O.x):void 0,M.y=O.y?Math.max(V[1]*F,O.y):void 0}if(M.x!==void 0&&M.y!==void 0){const V={id:g,type:"position",position:{...M}};$.push(V)}if(O.width!==void 0&&O.height!==void 0){const T={id:g,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};$.push(T)}for(const V of H){const T={...V,type:"position"};$.push(T)}_($)},onEnd:({width:O,height:H})=>{const _={id:g,type:"dimensions",resizing:!1,dimensions:{width:O,height:H}};v.getState().triggerNodeChanges([_])}})),R.current.update({controlPosition:A,boundaries:{minWidth:c,minHeight:l,maxWidth:d,maxHeight:u},keepAspectRatio:f,resizeDirection:h,onResizeStart:w,onResize:y,onResizeEnd:x,shouldResize:m}),()=>{R.current?.destroy()}},[A,c,l,d,u,f,w,y,x,m]);const L=A.split("-");return a.jsx("div",{className:fe(["react-flow__resize-control","nodrag",...L,n,s]),ref:E,style:{...o,scale:S,...r&&{[k?"backgroundColor":"borderColor"]:r}},children:i})}const yy=j.memo(xy),wy="/assets/elk-worker.min-C9JGDOE-.js";let Ii;function vy(){return Ii??=ou(async()=>{const{default:e}=await import("./elk-api-lwhFo7vB.js").then(t=>t.e);return{default:e}},__vite__mapDeps([0,1,2])).then(({default:e})=>new e({workerUrl:wy})),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]"},by=160,Ny=88;async function os(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),f=typeof d.style?.width=="number"?d.style.width:void 0,h=typeof d.style?.height=="number"?d.style.height:void 0;n.set(d.id,{id:d.id,...u?{width:f??d.measured?.width??by,height:h??d.measured?.height??Ny}:{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 vy()).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 f={...d,position:{x:u.x,y:u.y}};return d.type==="group"&&(f.style={...d.style,width:u.w,height:u.h}),f})}const jy=32;function rs(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)*jy,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),f=(l-r)/(2*n)+(d-c)/(2*s),h=1/(Math.abs(u)+Math.abs(f)||1),p=h*u,m=h*f;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 ky(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 Ey({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,f=(t+s)/2+d*o*2,h=e*.25+u*.5+n*.25,p=t*.25+f*.5+s*.25;return[`M ${e},${t} Q ${u},${f} ${n},${s}`,h,p]}function Cy({id:e,source:t,target:n,markerStart:s,markerEnd:o,style:i,data:r}){const c=ss(t),l=ss(n);if(!c||!l)return null;const{sx:d,sy:u,tx:f,ty:h,sourcePos:p,targetPos:m}=ky(c,l),w=r,[y,x,b]=(w?.parallelCount??1)>1?Ey({sx:d,sy:u,tx:f,ty:h,offset:w?.parallelOffset??0}):To({sourceX:d,sourceY:u,sourcePosition:p,targetX:f,targetY:h,targetPosition:m,curvature:.25}),g=w?.label,v=w?.selected===!0,E=v?"var(--color-primary)":i?.stroke??"var(--color-muted-foreground)",k=v?{...i,stroke:E,strokeWidth:3}:i;return a.jsxs(a.Fragment,{children:[a.jsx(Bt,{id:e,path:y,markerStart:s,markerEnd:o,style:k,interactionWidth:18}),g&&a.jsx(Y0,{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 Sy({id:e,source:t,target:n,style:s}){const o=ss(t),i=ss(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,f=i.measured.height??0,h=c.x>=r.x,[p]=ts({sourceX:h?r.x+l:r.x,sourceY:r.y+d/2,sourcePosition:h?q.Right:q.Left,targetX:h?c.x:c.x+u,targetY:c.y+f/2,targetPosition:h?q.Left:q.Right,borderRadius:16});return a.jsx(Bt,{id:e,path:p,style:s,interactionWidth:18})}const Uo={floating:Cy,tree:Sy};function Es({domainId:e,anchorRef:t,kind:n,excerpt:s,className:o}){const{threads:i,status:r,orphaned:c}=oa(t,e),l=j.useId(),d=X(m=>m.openAnchorRef),u=X(m=>m.openAnchorId),f=e?`${e}::${t}`:t,h=d===f&&(u===null||u===l),p=X(m=>m.setOpenAnchor);return i.length===0?null:a.jsxs(zt,{modal:!1,open:h,onOpenChange:m=>p(m?f:null,m?l:null),children:[a.jsx(po,{asChild:!0,children:a.jsxs("button",{type:"button",title:"View comments",onClick:m=>{m.stopPropagation(),p(h?null:f,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(Tt,{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 Iy(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=j.useMemo(()=>e?Iy(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,_y=/^.+:(?:class|interface)\.[A-Za-z][A-Za-z0-9_]*\.property\.([A-Za-z][A-Za-z0-9_]*)$/;function Qo(e){const t=Object.entries(e).map(([s,o])=>({key:s,shortName:_y.exec(s)?.[1]??s,value:o})),n=new Map;for(const s of t)n.set(s.shortName,(n.get(s.shortName)??0)+1);return t.map(({key:s,shortName:o,value:i})=>({key:s,label:n.get(o)===1?o:s,value:i}))}function cl(e,t){const n=Qo(e);return t.flatMap(s=>n.filter(o=>o.label===s))[0]}function ln(e){const t=cl(e.data,["name","title"])?.value;return typeof t=="string"&&t?t:Ko(e.path)}function Jo(e){const t=[...new Set(e.nodes.map(n=>n.className))].sort();return new Map(t.map((n,s)=>[n,ru(s)]))}const er=e=>e==null?"—":typeof e=="string"?e:Array.isArray(e)?e.map(er).join(", "):JSON.stringify(e);function My(e,t=2){const n=cl(e.data,["name","title"]);return Qo(e.data).filter(s=>s.key!==n?.key).slice(0,t).map(({label:s,value:o})=>[s,er(o)])}function tr(e,t){return e.ir?.classes?.[t]?.icon}function $y(e,t,n){const s=new Set(e.nodes.map(c=>He(c.path))),o=e.nodes.map(c=>{const l=My(c);return{id:He(c.path),type:"coreNode",position:{x:0,y:0},data:{path:c.path,className:c.className,title:ln(c),hue:n.get(c.className)??264,icon:tr(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:tt.ArrowClosed,color:u,width:16,height:16},style:{stroke:u,strokeWidth:2}})}return{nodes:o,edges:r}}function ll({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(iu,{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 Ry({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(ke,{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(gn,{className:"h-5 w-5"}):a.jsx(Oe,{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(ke,{type:"source",position:q.Bottom,className:"!opacity-0"})]})}const Ay={coreNode:Ry};function Dy({core:e,bundle:t,selectedPath:n,onSelect:s}){const{fitView:o}=Ft(),i=X(k=>k.setOpenAnchor),r=j.useMemo(()=>Jo(e),[e]),c=j.useMemo(()=>$y(e,t,r),[e,t,r]),[l,d]=j.useState([]),[u,f]=j.useState([]);j.useEffect(()=>{let k=!1;return os(c.nodes,c.edges).then(S=>{k||(d(S),f(rs(c.edges)),requestAnimationFrame(()=>o({padding:.2,duration:400})))}),()=>{k=!0}},[c,o]);const h=j.useCallback(k=>d(S=>Ns(k,S)),[]),p=j.useCallback(k=>f(S=>js(k,S)),[]),[m,w]=j.useState(!0),[y,x]=j.useState(!0),b=j.useMemo(()=>l.filter(k=>{const S=k.data;return!(!m&&S.className==="Folder"||!y&&S.virtual)}),[l,y,m]),g=j.useMemo(()=>new Set(b.map(k=>k.id)),[b]),v=j.useMemo(()=>b.map(k=>{const S=k.data.path===n;return k.data.selected===S?k:{...k,data:{...k.data,selected:S}}}),[b,n]),E=j.useMemo(()=>u.filter(k=>!g.has(k.source)||!g.has(k.target)?!1:k.type==="tree"?m:y),[u,g,m,y]);return a.jsxs(Xo,{nodes:v,edges:E,nodeTypes:Ay,edgeTypes:Uo,onNodesChange:h,onEdgesChange:p,onNodeClick:(k,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:k=>`oklch(0.6 0.13 ${k.data.hue})`,nodeStrokeWidth:0,maskColor:"oklch(0.17 0.01 270 / 0.7)"}),a.jsxs(it,{position:"top-right",className:"flex gap-1.5",children:[a.jsxs(Fe,{size:"xs",variant:m?"default":"outline",onClick:()=>w(k=>!k),"aria-pressed":m,title:"Folders & the parent→child tree — toggle to focus on the semantic graph alone",children:[a.jsx(Qu,{className:"h-3.5 w-3.5"})," Structure"]}),a.jsxs(Fe,{size:"xs",variant:y?"default":"outline",onClick:()=>x(k=>!k),"aria-pressed":y,title:"Typed (semantic) edges — toggle to focus on the tree/organization alone",children:[a.jsx(Lt,{className:"h-3.5 w-3.5"})," Semantics"]}),a.jsx(ll,{})]})]})}function jn({anchor:e,excerpt:t,children:n,className:s}){const o=j.useId(),i=X(h=>h.openAnchorRef),r=X(h=>h.openAnchorId),c=i===e.ref&&(r===null||r===o),l=X(h=>h.setOpenAnchor),{threads:d,status:u,orphaned:f}=oa(e.ref);return a.jsxs(zt,{modal:!1,open:c,onOpenChange:h=>l(h?e.ref:null,h?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:h=>{h.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(sf,{className:"h-3 w-3"})}),d.length>0&&a.jsx(au,{count:d.length,status:u,orphaned:f,onClick:()=>l(c?null:e.ref,o),className:"absolute -right-1.5 -top-1.5 z-10"})]})}),a.jsx(Tt,{onInteractOutside:h=>h.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)})})]})}function Py({core:e,bundle:t,selectedPath:n}){const s=j.useMemo(()=>e.nodes.find(u=>u.path===n)??null,[e,n]),o=j.useMemo(()=>Jo(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=tr(t,s.className),c=s.className==="Folder",l=Qo(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(jn,{anchor:{ref:He(s.path),kind:"section"},excerpt:`${ln(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(gn,{className:"h-6 w-6"}):a.jsx(Oe,{className:"h-6 w-6"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-base font-extrabold truncate",children:ln(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(({key:u,label:f,value: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",title:f===u?void 0:u,children:f}),a.jsx("span",{className:"break-words text-[13px] text-foreground/90",children:er(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,f)=>{const h=u.from===s.path,p=h?u.to:u.from;return a.jsxs("div",{className:"flex items-center gap-1.5 text-[12px]",children:[a.jsx(Lt,{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:h?"→":"←"}),a.jsx("span",{className:"truncate text-foreground/80",title:p,children:Ko(p)})]},`${u.edgeName}-${f}`)})})]})]})}function Oy(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 dl({item:e,depth:t,bundle:n,hues:s,selectedPath:o,onSelect:i}){const[r,c]=j.useState(!0),l=e.node,d=e.children.length>0,u=o===l.path,f=s.get(l.className)??264,h=tr(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(jn,{anchor:{ref:He(l.path),kind:"section"},excerpt:`${ln(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 ${f})`},className:"shrink-0",children:h?a.jsx(we,{svg:h,className:"h-4 w-4"}):p?a.jsx(gn,{className:"h-3.5 w-3.5"}):a.jsx(Oe,{className:"h-3.5 w-3.5"})}),a.jsx("span",{className:"truncate font-bold",children:ln(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(dl,{item:m,depth:t+1,bundle:n,hues:s,selectedPath:o,onSelect:i},m.node.path))})]})}function zy({core:e,bundle:t,selectedPath:n,onSelect:s}){const o=j.useMemo(()=>Jo(e),[e]),i=j.useMemo(()=>Oy(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(dl,{item:r,depth:0,bundle:t,hues:o,selectedPath:n,onSelect:s},r.node.path))]})}const Ri=new Set(["Node","Edge"]),so="kernel.astrale.ai";function Ai(e){return typeof e=="string"?`legacy:${e}`:De(e)}function Ty(e){return typeof e=="string"?e:e.name}function ul(e){return e.extendsRefs!==void 0?e.extendsRefs.filter(Je):e.extends??[]}function Di(e){return typeof e=="string"?Ri.has(e):e.origin===so&&e.kind==="interface"&&Ri.has(e.name)}function kn(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?.[De(t)]}}function fl(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 Ly(e,t){return typeof t!="string"?t.origin===e.ir?.domain?void 0:t.origin:e.ir?.imports[t]?.origin}function hl(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(),f=Ai(u),h=Ty(u);if(r.has(f)||Di(u))continue;r.add(f);const p=kn(e,u);if(!p)continue;for(const y of ul(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:h,...typeof u=="string"?{}:{ref:u},tier:fl(e,u),origin:Ly(e,u),navigable:!0,props:m,methods:w})}const d={local:0,external:1,kernel:2};return c.sort((u,f)=>d[u.tier]-d[f.tier])}function Hy(e,t){const n=e.ir?.classes[t];return n?hl(e,n.implementsRefs!==void 0?n.implementsRefs.filter(Je):n.implements??[],new Set(Object.keys(n.properties??{})),new Set(Object.keys(n.methods??{}))):[]}function Vy(e,t){const n=kn(e,t);return n?hl(e,ul(n),new Set(Object.keys(n.properties??{})),new Set(Object.keys(n.methods??{}))):[]}function Fy(e){return e.reduce((t,n)=>t+n.props.length+n.methods.length,0)}function By({domainId:e,view:t,open:n,onOpenChange:s}){const o=cu(e,t.slug,n),i=o.data,[r,c]=j.useState(""),[l,d]=j.useState(0),[u,f]=j.useState(!1),[h,p]=j.useState({phase:"idle"}),m=j.useRef("");j.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;j.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]),j.useEffect(()=>{if(h.phase!=="ready")return;const b=()=>{const g=`/api/domain/${encodeURIComponent(e)}/views/sessions/close`;navigator.sendBeacon(g,new Blob([JSON.stringify({sessionId:h.session.sessionId})],{type:"application/json"}))};return window.addEventListener("pagehide",b),()=>window.removeEventListener("pagehide",b)},[e,h]);const x=async()=>{if(!u){f(!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{f(!1)}}};return a.jsx(lu,{open:n,onOpenChange:s,children:a.jsxs(du,{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(uu,{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:[h.phase==="ready"&&a.jsxs("a",{href:h.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(fu,{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(hu,{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(Wy,{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(jo,{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:h.phase==="ready"?a.jsx("iframe",{src:h.session.pageUrl,title:`${t.slug} preview`,className:"h-full w-full border-0 bg-white",allow:"clipboard-read; clipboard-write"},h.session.sessionId):a.jsx(Xy,{loading:o.isLoading||u||h.phase==="launching",runtimeError:o.isError,runtime:i,targetId:r,sessionError:h.phase==="error"?h.reason:void 0,onRetry:()=>{x()}})})]})})}function Wy({result:e,value:t,onChange:n,instance:s}){const[o,i]=j.useState(!1),[r,c]=j.useState(""),l=e.items.find(u=>u.id===t)??null,d=j.useMemo(()=>{const u=r.trim().toLocaleLowerCase();return u?e.items.filter(f=>[f.label,f.description,f.className,f.status,f.id].filter(Boolean).some(h=>h.toLocaleLowerCase().includes(u))):e.items},[e.items,r]);return a.jsxs(zt,{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(pu,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),a.jsxs(Tt,{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(jo,{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(Yy,{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 Yy({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 Xy({loading:e,runtimeError:t,runtime:n,targetId:s,sessionError:o,onRetry:i}){if(e)return a.jsx(kt,{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(kt,{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(kt,{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(kt,{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(kt,{icon:a.jsx(jo,{}),title:"The view could not be opened",action:i,children:o}):a.jsx(kt,{icon:a.jsx(Bs,{className:"animate-spin"}),title:"Opening view session",children:"Studio is preparing the authenticated CLI-owned Shell session."})}function kt({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 qy({kind:e,className:t}){const n=e==="inline-html"?xu:e==="spa"?mn:Nt;return a.jsx(n,{className:t})}function is({domainId:e,view:t,icon:n}){const[s,o]=j.useState(!1),i=mu(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(je,{tone:"sky",size:"sm",children:n?a.jsx(we,{svg:n,className:"h-3.5 w-3.5"}):a.jsx(qy,{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(mt,{className:"h-3 w-3"}),i.text]}),a.jsx(gu,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/0 transition-colors group-hover:text-primary"})]}),a.jsx(Vt,{domainId:e,anchorRef:{ref:c,kind:"section",file:t.file},excerpt:t.slug,className:"ml-1"})]}),s&&a.jsx(By,{domainId:e,view:t,open:s,onOpenChange:o})]})}function Zy({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(Ht,{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(mt,{className:"h-3.5 w-3.5"})," drift"]})]}),t.all.length===0&&a.jsx(Gt,{icon:a.jsx(mn,{}),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(Oe,{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(mt,{className:"h-3.5 w-3.5 shrink-0"}),a.jsx("code",{className:"truncate",children:r})]},r))})})]})})}function Gy(e,t){const n=yu(t);if(!n)return;if(n.origin===e.domain)return e.interfaces[n.name]?n:void 0;const s=De(n),o=e.importsByKey?.[s];if(o?.ref&&Je(o.ref))return o.ref;const i=e.importedInterfacesByKey?.[s];return i?.ref&&Je(i.ref)?i.ref:i?n:void 0}function Oi(e,t,n){return(t!==void 0?t.filter(Je):n??[]).map(o=>({name:typeof o=="string"?o:o.name,reference:o,identity:typeof o=="string"?`legacy:${o}`:De(o),tier:fl(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:kn(e,o)!==void 0}))}function oo(e){if(!e)return"*";const{min:t,max:n}=e;return n===null?t<=0?"*":`${t}..*`:t===n?`${n}`:`${t}..${n}`}const Dn=e=>!e||e.max===null||e.max>1,zi=e=>!e||e.min<=0;function Bn(e){return e?e==="kernel.astrale.ai"?"kernel":e.split(".")[0]:"imported"}function Uy(e){const[t,...n]=e.split(".");return[t==="interface"?"interface":"class",n.join(".")]}function pl({doc:e}){return a.jsxs(un,{openDelay:80,children:[a.jsx(fn,{asChild:!0,children:a.jsx("button",{type:"button","aria-label":"Description",className:"text-muted-foreground/40 hover:text-foreground transition-colors",children:a.jsx(Cu,{className:"h-3.5 w-3.5"})})}),a.jsx(hn,{className:"w-auto max-w-xs text-[13px] leading-relaxed text-muted-foreground",children:e})]})}function ml({bundle:e,refBase:t,pname:n,schema:s,optional:o}){const i=`${t}.property.${n}`,r=e.overlay.sourceSpans[i]?.doc,c=da(s,o),l=c.icon,d=e.overlay.annotations.filter(f=>f.target===i),u=wu(s);return a.jsx(yo,{anchorRef:i,anchorExcerpt:n,leading:a.jsx(je,{tone:"sky",size:"sm",children:a.jsx(l,{})}),title:a.jsxs("span",{className:"flex items-center gap-1.5",children:[n,r&&a.jsx(pl,{doc:r}),c.optional&&a.jsx(me,{tone:"default",children:"optional"}),d.map(f=>a.jsx(me,{tone:"warning",title:f.message,children:f.code},f.code))]}),subtitle:a.jsxs(un,{openDelay:140,children:[a.jsx(fn,{asChild:!0,children:a.jsx("span",{className:"cursor-default",children:c.label})}),a.jsx(hn,{className:"w-auto max-w-sm",children:a.jsx(vu,{items:[{label:"type",value:bu(u)+(c.optional?" (optional)":"")},{label:"key",value:i}]})})]}),trailing:a.jsx(Vt,{anchorRef:{ref:i,kind:"schema",file:e.overlay.sourceSpans[i]?.file},excerpt:n})})}function gl({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?ua(e.overlay.handlerLinks,t,i,n):void 0,u=e.overlay.sourceSpans[l]?.doc,f=Nu(r),h=f.icon,p=d&&!d.implemented,m=d?.unlinked;return a.jsxs(ft,{className:"px-3 py-2.5","data-anchor-ref":l,"data-anchor-excerpt":`${t}.${i}`,"data-commentable":"",children:[a.jsx(yo,{className:"px-0 py-0 hover:bg-transparent",leading:a.jsx(je,{tone:f.tone,size:"sm",children:a.jsx(h,{})}),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(ju,{method:r,link:d}),u&&a.jsx(pl,{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(Vt,{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(ku,{label:"Details",children:a.jsx(Ky,{method:r,link:d,owner:t})})})]})}function Ky({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=da(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(Qy,{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(Su,{schema:e.returns})]})]})}function Qy({owner:e,isStatic:t}){return a.jsxs(un,{openDelay:80,children:[a.jsx(fn,{asChild:!0,children:a.jsx("button",{type:"button",className:"cursor-default rounded-full",children:a.jsxs(me,{tone:"outline",children:[t?a.jsx(wo,{className:"h-3 w-3"}):a.jsx(Oe,{className:"h-3 w-3"})," ",t?`on the ${e} type`:`on a ${e}`]})})}),a.jsx(hn,{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 Jy({bundle:e,groups:t,originIcon:n}){const s=X(o=>o.selectClass);return a.jsx(Be,{label:"Inherited",hint:`${Fy(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(je,{tone:r,size:"sm",children:a.jsx(ew,{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":Bn(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(Eu,{className:"h-3.5 w-3.5"})]})]}),a.jsxs("div",{className:"space-y-2.5",children:[o.props.length>0&&a.jsx(ft,{className:"divide-y divide-border/70",children:o.props.map(([l,d,u])=>a.jsx(ml,{bundle:e,refBase:c,pname:l,schema:d,optional:u},`p-${l}`))}),o.methods.map(l=>a.jsx(gl,{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 ew({tier:e,iconSvg:t}){return e==="local"?a.jsx(ze,{}):t?a.jsx(we,{svg:t,className:"h-4 w-4"}):e==="kernel"?a.jsx(ef,{}):a.jsx(Nt,{})}function tw({bundle:e,endpoints:t,edgeName:n}){const[s,o]=t;return a.jsx(ft,{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(Ti,{bundle:e,endpoint:s,edgeName:n}),a.jsx(nw,{edgeName:n,from:s,to:o}),a.jsx(Ti,{bundle:e,endpoint:o,edgeName:n})]})})}function Ti({bundle:e,endpoint:t,edgeName:n}){const s=X(h=>h.selectClass);if(!t)return null;const o=e.ir;if(!o)return null;const i=t.refs!==void 0?t.refs.filter(at).map(h=>({name:h.name,ref:h})):t.types.map(h=>({name:h}));i.length===0&&i.push({name:"—"});const r=t.cardinality,c=t.name?vo(`edge.${n}.endpoint.${t.name}`,t.name):{},l=({name:h,ref:p})=>{if(p){const x=p.origin===o.domain,b=x&&p.kind==="class"?o.classes[h]:void 0,g=p.kind==="interface"?x?o.interfaces[h]:kn(e,p):void 0,v=!!b||!!g;return{t:h,key:De(p),origin:x?void 0:p.origin,isInterface:p.kind==="interface",resolvable:v,selectionId:Je(p)?fs(p,o.domain):x?`class.${p.name}`:void 0,icon:b?.icon}}const m=o.classes[h],w=o.interfaces[h],y=(!!m||!!w)&&!(m&&w);return{t:h,key:`legacy:${h}`,origin:void 0,isInterface:!m&&!!w,resolvable:y,selectionId:y?!m&&w?`interface.${h}`:`class.${h}`:void 0,icon:m?.icon}},d=h=>()=>{h.resolvable&&h.selectionId&&s(h.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})}),f=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 h=l(i[0]);return a.jsxs("button",{type:"button",onClick:h.resolvable?d(h):void 0,disabled:!h.resolvable,title:h.resolvable?`Open ${h.t}`:h.origin?`${h.t} · ${h.origin}`:h.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",h.resolvable?"hover:bg-accent/60 cursor-pointer":"cursor-default"),children:[a.jsx(je,{tone:h.isInterface?"fuchsia":"violet",size:"lg",className:"transition-transform group-hover/ep:-translate-y-0.5",children:h.icon?a.jsx(we,{svg:h.icon,className:"h-5 w-5"}):h.isInterface?a.jsx(ze,{}):a.jsx(Oe,{})}),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:h.t}),a.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-1",children:[u,f]})]})]})}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(h=>{const p=l(h);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(je,{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(ze,{}):a.jsx(Oe,{})}),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,f]})]})}function nw({edgeName:e,from:t,to:n}){const s=t?.cardinality,o=n?.cardinality,i=`${Dn(s)?"many":"one"}-to-${Dn(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:Dn(s),optional:zi(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:Dn(o),optional:zi(o),side:"right"})]}),a.jsxs(un,{openDelay:80,children:[a.jsx(fn,{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(hn,{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(){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(Xu,{className:"h-3.5 w-3.5 transition-transform group-hover:-translate-x-0.5"}),"Back"]})}):null}function yl({bundle:e,selected:t}){const n=e.ir,s=X(M=>M.selectClass),{data:o}=pn(),i=bo(e.domainId),r=M=>M?o?.find(D=>D.origin===M)?.icon:void 0;if(!n||!t)return a.jsx("div",{className:"h-full flex items-center justify-center px-6",children:a.jsx(Gt,{icon:a.jsx(Iu,{}),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(sw,{bundle:e,path:t.slice(7)});const[c,l]=Uy(t),d=c==="interface"?Gy(n,l):void 0,u=d?.name??l,f=c==="interface"?d?d.origin===n.domain?n.interfaces[u]:void 0:n.interfaces[u]:n.classes[u],h=c==="interface"&&!f?d?kn(e,d):e.importedInterfaces?.[u]:void 0,p=f??h;if(!p)return a.jsx("div",{className:"h-full flex items-center justify-center px-6",children:a.jsx(Gt,{title:"Not found",hint:t})});const m=p.type==="edge",w=c==="interface"?"interface":m?"edge":"class",y=h?.ref&&Je(h.ref)?h.ref:d?.origin!==n.domain?d:void 0,x=y?fs(y,n.domain):_u(w,u),b=e.overlay.sourceSpans[x],g=Object.entries(p.properties??{}),v=p.required,E=Object.entries(p.methods??{}),k=p.endpoints??[],S=p,R=p,A=w==="interface"?void 0:Mu(e,u),L=Oi(e,S.implementsRefs!==void 0?A:void 0,S.implements),O=L.filter(M=>M.tier!=="kernel"),H=L.filter(M=>M.tier==="kernel"),_=Oi(e,R.extendsRefs,R.extends),N=w==="interface"?Vy(e,y??u):Hy(e,u),C=w==="interface"?"fuchsia":"violet",I=p.icon,$=w==="interface"?[]:$u(i,u);return a.jsxs("div",{className:"h-full overflow-y-auto",...vo(x,u),children:[a.jsx(xl,{}),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(je,{tone:C,size:"lg",children:I?a.jsx(we,{svg:I,className:"h-5 w-5"}):a.jsx(ze,{})}),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"}),h&&a.jsx(me,{tone:"outline",children:Bn(y?.origin??n.imports[u]?.origin)}),w==="edge"&&a.jsx(me,{tone:"outline",children:"edge"}),a.jsx(Vt,{anchorRef:{ref:x,kind:"schema",file:b?.file},excerpt:u,className:"ml-auto"})]}),(b?.doc??p.description)&&a.jsx("p",{className:"text-[13px] text-muted-foreground mt-1 leading-relaxed",children:b?.doc??p.description})]})]}),(O.length>0||H.length>0||_.length>0)&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pl-[3.25rem]",children:[_.map(M=>a.jsx("button",{type:"button",disabled:!M.navigable,onClick:()=>M.navigable?s(M.selectionId):void 0,className:se("rounded-full",M.navigable&&"transition-transform hover:-translate-y-px"),children:a.jsxs(me,{tone:"outline",className:se(M.navigable&&"cursor-pointer hover:bg-accent/70"),children:["extends ",M.name,M.origin?` · ${Bn(M.origin)}`:""]})},`ext-${M.identity}`)),O.map(M=>a.jsx("button",{type:"button",disabled:!M.navigable,onClick:()=>M.navigable?s(M.selectionId):void 0,className:se("rounded-full",M.navigable&&"transition-transform hover:-translate-y-px"),children:a.jsxs(me,{tone:"fuchsia",className:se(M.navigable&&"cursor-pointer hover:bg-fuchsia-500/20"),children:[a.jsx(ze,{className:"h-3 w-3"})," ",M.name,M.origin?` · ${Bn(M.origin)}`:""]})},M.identity)),H.length>0&&a.jsxs(un,{openDelay:80,children:[a.jsx(fn,{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"})," ",H.length," base"]})})}),a.jsxs(hn,{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:H.map(M=>a.jsx(me,{tone:"outline",children:M.name},M.identity))})]})]})]})]}),m&&k.length>=2&&a.jsx(Be,{label:"Relationship",children:a.jsx(tw,{bundle:e,endpoints:k,edgeName:u})}),g.length>0&&a.jsx(Be,{label:"Properties",hint:`${g.length}`,children:a.jsx(ft,{className:"divide-y divide-border/70",children:g.map(([M,D])=>a.jsx(ml,{bundle:e,refBase:x,pname:M,schema:D,optional:v?!v.includes(M):void 0},M))})}),E.length>0&&a.jsx(Be,{label:"Methods",hint:(()=>{const M=Ru(E.map(([D,V])=>({method:V,link:h?void 0:ua(e.overlay.handlerLinks,u,D,w==="interface"?"interface":"class")})));return a.jsxs("span",{className:"inline-flex items-center gap-2",children:[M>0&&a.jsxs(me,{tone:"warning",children:[M," unguarded"]}),E.length]})})(),children:a.jsx("div",{className:"space-y-2.5",children:E.map(([M,D])=>a.jsx(gl,{bundle:e,owner:u,ownerKind:w==="interface"?"interface":"class",handlerOwnerLocal:!h,refBase:x,mname:M,method:D},M))})}),$.length>0&&a.jsx(Be,{label:"Views",hint:`${$.length}`,children:a.jsx("div",{className:"flex flex-col gap-0.5",children:$.map(M=>a.jsx(is,{domainId:e.domainId,view:M,icon:I},M.slug))})}),N.length>0&&a.jsx(Jy,{bundle:e,groups:N,originIcon:r}),g.length===0&&E.length===0&&N.length===0&&!m&&a.jsx(Gt,{title:"No properties or methods",hint:"This member carries no fields of its own."})]})]})}function sw({bundle:e,path:t}){const n=X(i=>i.selectClass),s=Au(e,t),o=i=>a.jsx(yo,{onClick:()=>n(i.selectId),anchorRef:i.ref,anchorExcerpt:i.name,leading:a.jsx(je,{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(ze,{}):i.kind==="edge"?a.jsx(Lt,{}):a.jsx(Oe,{})}),title:i.name},i.selectId);return a.jsxs("div",{className:"h-full overflow-y-auto",...vo(`module.${t}`,s.label),children:[a.jsx(xl,{}),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(je,{tone:"muted",size:"lg",style:{color:`oklch(0.82 0.12 ${s.hue})`},children:a.jsx(gn,{})}),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(ft,{className:"divide-y divide-border/70",children:s.interfaces.map(o)})}),s.classes.length>0&&a.jsx(Be,{label:"Classes",children:a.jsx(ft,{className:"divide-y divide-border/70",children:s.classes.map(o)})}),s.edges.length>0&&a.jsx(Be,{label:"Relationships",children:a.jsx(ft,{className:"divide-y divide-border/70",children:s.edges.map(o)})})]})]})}function wl(e,t,n){return`extmember.${e}.${n}.${t}`}function ow(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(at).map(t=>({name:t.name,ref:t})):(e.types??[]).map(t=>({name:t})):[]}function nr(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",f=!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||f)||!e.interfaces[r])){if(n(r)){const h=`iface.${r}`;o.has(h)||(o.add(h),s.push({cls:null,ifaceNode:h,viaInterface:null}));continue}for(const[h,p]of Object.entries(e.classes)){const m=c?p.implementsRefs?.filter(at).some(w=>ow(w,c))===!0:(p.implements??[]).includes(r);p.type==="node"&&m&&!o.has(h)&&(o.add(h),s.push({cls:h,ifaceNode:null,viaInterface:r}))}}}return s}function vl(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:f,ref:h})=>h?h.origin===t.domain&&(h.kind==="interface"||t.classes[f]?.type==="node")&&(h.kind!=="interface"||t.interfaces[f]!==void 0):t.classes[f]?.type==="node"||t.interfaces[f]!==void 0),u=ro(l).flatMap(f=>{if(f.ref){if(f.ref.origin===t.domain)return[];const h=t.importsByKey?.[De(f.ref)];return[{...f,ref:h?.ref??f.ref}]}return t.imports[f.name]?[f]:[]});for(const f of u){const h=f.ref?.origin??t.imports[f.name]?.origin;if(h)for(const p of d)n.push({edge:s,from:p.name,origin:h,to:f.name,...p.ref?{fromRef:p.ref}:{},...f.ref?{toRef:f.ref}:{},fromCard:c.cardinality,toCard:l.cardinality})}}}return n}function bl(e){const t=e.ir;if(!t)return[];const n=new Map;for(const o of vl(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?De(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 rw={hidden:{},showInheritedEdges:!0,materializedInterfaces:{}},dn=e=>ha("class",e),Nl=e=>ha("edge",e),io=e=>`domain.${e}`;function Pe(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 iw(e,t){return!Pe(dn(e),t)}function aw(e,t){return!Pe(io(e),t)}function jl(e,t,n){return!(Pe(Nl(e.edgeName),t)||Pe(dn(e.aClass),t)||Pe(dn(e.bClass),t)||e.viaInterfaces.length>0&&!n)}function cw(e,t,n){const s=e.ir?.domain;return Du(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.",kl=e=>`${co}${e}`;function El(){const{data:e}=pn(),t=new Map((e??[]).map(n=>[n.origin,n]));return n=>t.get(n)??{name:n.split(".")[0]||n,icon:""}}function lw({domain:e}){const t=El(),n=X(c=>Pe(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(je,{tone:i,size:"sm",children:o.icon?a.jsx(we,{svg:o.icon,className:"h-3.5 w-3.5"}):a.jsx(Nt,{})}),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 dw({origin:e}){const n=El()(e);return a.jsx(jn,{anchor:{ref:kl(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(je,{tone:"amber",size:"sm",children:n.icon?a.jsx(we,{svg:n.icon,className:"h-3.5 w-3.5"}):a.jsx(Nt,{})}),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 uw({domainId:e,taken:t}){const{data:n}=pn(),{create:s}=ga(e),o=X(c=>c.setOpenAnchor),i=c=>{const l=kl(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),Yn.success("Import requested — add the why/how in the comment")},onError:d=>Yn.error(String(d))})},r=(n??[]).filter(c=>c.kind!=="kernel"&&c.origin!==e&&!t.has(c.origin));return a.jsxs(zt,{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(Tt,{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(je,{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(Nt,{})}),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 fw({domainId:e}){const{data:t}=xo(e),{data:n}=No(e),s=j.useMemo(()=>t?bl(t):[],[t]),o=j.useMemo(()=>new Set(s.map(c=>c.origin)),[s]),i=j.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=j.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 f=u.ref.slice(co.length);o.has(f)||c.has(f)||(c.add(f),l.push(f))}return l},[n,o]);return a.jsx(Ht,{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(lw,{domain:c},c.origin))})]}),r.length>0&&a.jsxs(a.Fragment,{children:[s.length>0&&a.jsx(Wn,{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(dw,{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(Wn,{className:"my-3 opacity-60"}),a.jsx(uw,{domainId:e,taken:i})]})})}const hw=18,pw=3,mw=[{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 Cl(){return a.jsx("svg",{width:"0",height:"0","aria-hidden":!0,className:"absolute",style:{position:"absolute"},children:a.jsx("defs",{children:mw.map(({id:e,draw:t})=>a.jsx("marker",{id:e,viewBox:"0 0 24 22",refX:hw+pw,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 sr(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 Sl(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 Il(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 _l(){const e=ls(),t=j.useRef(new Map),n=j.useRef(new Map),s=j.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=j.useCallback((i,r)=>{e.setQueryData(We.layout(i),l=>({renderFingerprint:l?.renderFingerprint,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 j.useEffect(()=>()=>{for(const i of t.current.keys())s(i)},[s]),{commitLayout:o,flushLayout:s}}function gw(e){return String(e??"").split(/[.:/]/).pop()??""}function xw(e){return Array.isArray(e)?e.map(String):e?[String(e)]:[]}function yw(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[De(t)];const o=n.imports[t.name];if(!(o?.origin!==t.origin||o.definition!=="interface"||o.ref&&De(o.ref)!==De(t)))return e.importedInterfaces?.[t.name]}function ww(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(at).filter(Je):xw(e.extends)}function vw(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=gw(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=ww(t,l);u&&o.push(...Bi(u));continue}const r=De(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=yw(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(at).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 Pn="oklch(0.72 0.18 330)";function Ml(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=Pu(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(!iw(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:cw(e,x,c),coreRole:vw(b?.implementsRefs!==void 0?b.implementsRefs.filter(at).filter(Je):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=gt(e,m);return t.has(w)?`grp-${w}`:`class.${m}`},f=m=>nr(i,m,r),h=m=>m.cls!==null?gt(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=f(m.endpoints?.[0]),y=f(m.endpoints?.[1]),x=sr(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(L=>L!==null),E=b.ifaceNode??u(b.cls),k=g.ifaceNode??u(g.cls);if(!jl({edgeName:m.name,aClass:b.cls??"",bClass:g.cls??"",viaInterfaces:v},n,s)||E===k)continue;const S=h(b)!==h(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}__${k}`,source:E,target:k,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"||Pe(dn(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:tt.ArrowClosed,color:Pn,width:16,height:16},style:{stroke:Pn,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:tt.ArrowClosed,color:Pn,width:16,height:16},style:{stroke:Pn,strokeWidth:1.6,strokeDasharray:"2 4"}});return{nodes:d,edges:p}}function bw({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(ff,{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(ke,{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(Ou,{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(ze,{className:"h-2.5 w-2.5"}),l.name]},l.identity))})})]}),a.jsx(ke,{type:"source",position:q.Bottom,className:"!opacity-0"})]})}function Nw({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(ke,{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(ze,{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(ke,{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(ke,{type:"target",position:q.Top,className:"!opacity-0"}),a.jsx(ke,{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(ze,{className:"h-2.5 w-2.5"}),r.name]},r.identity))]})]})}function jw({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(Nt,{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 kw({data:e}){const t=e,n=t.kind==="kernel"?285:158,s=t.definition==="interface"?ze:Oe;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(ke,{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(ke,{type:"source",position:q.Right,className:"!opacity-0"})]})}function Ew({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 Cw({data:e}){const t=e;return a.jsx(Rl,{threads:t.comments,anchor:t.anchor,excerpt:t.excerpt,className:"nodrag nopan"})}const $l={classNode:bw,interfaceNode:Nw,group:uo,moduleNode:uo,extDomain:jw,extMember:kw,internalRegion:Ew,canvasComment:Cw};function Rl({threads:e,anchor:t,excerpt:n,className:s}){const[o,i]=j.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(zt,{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(Tt,{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 Sw(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,k=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+k)}Number.isFinite(o)||(o=0,r=0,i=400,c=400);const l=56,d=o-l,u=r-l,f=i-o+2*l,h=new Map((n??[]).map(g=>[g.origin,g])),p=36,m=44,w=8,y=d+f+96,x=[];let b=u+24;for(const g of t){const v=h.get(g.origin),E=p+g.members.length*(m+w)+8,k=`extdom.${g.origin}`;x.push({id:k,type:"extDomain",position:s?.[k]??{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:wl(g.origin,S.name,S.definition),type:"extMember",parentId:k,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 Iw(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 _w={};function Mw(e,t,n,s,o,i,r,c){const l=s.ir;if(!l)return[];const d=[],u=f=>or(s,o,c,f);for(const f of e){if(!t.has(f.origin))continue;const h=wl(f.origin,f.to,f.toRef?.kind??l.imports[f.to]?.definition??"class");if(!n.has(h))continue;const p=f.fromRef?{types:[f.from],refs:[f.fromRef]}:{types:[f.from]};for(const m of nr(l,p,u)){const w=m.viaInterface?[m.viaInterface]:[];if(!jl({edgeName:f.edge,aClass:m.cls??"",bClass:"",viaInterfaces:w},i,r))continue;const y=m.ifaceNode??(o.has(gt(s,m.cls))?`grp-${gt(s,m.cls)}`:`class.${m.cls}`);if(!n.has(y))continue;const x="oklch(0.72 0.16 35)",b=sr(f.fromCard,f.toCard),g=w.length>0;d.push({id:`edge-${f.edge}__${y}__${h}`,source:y,target:h,type:"floating",data:{label:f.edge,edgeClass:f.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 $w(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 Rw(e){return(e??[]).filter(t=>{const n=t.anchorRefs.find(s=>s.ref==="section.schema");return!!n&&!rr(n)})}function Aw(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 Dw(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 Pw({bundle:e,domainId:t,saved:n}){const{fitView:s,getNodes:o}=Ft(),i=X(B=>B.focusId),r=X(B=>B.focusClass),c=X(B=>B.panelOverlay),l=X(B=>B.setPanelOverlay),d=bo(t).all.length,u=ya(t).data?.detectedIntegrations?.length??0,f=wa(t).data,h=(f?.nodes.length??0)+(f?.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),k=X(B=>B.toggleInheritedEdges),S=X(B=>B.setVisibility),{data:R}=pn(),{data:A}=No(t),{data:L}=zu(t),O=j.useRef(!1),[H,_]=j.useState([]),[N,C]=j.useState([]),[I,$]=j.useState(null),[M,D]=j.useState(!1),V=M?E:_w,T=j.useMemo(()=>Ml(e,new Set(x),g,v,V),[e.renderFingerprint,e,x,g,v,V]),F=j.useMemo(()=>bl(e),[e]),P=j.useMemo(()=>vl(e),[e]),W=Object.keys(g).sort().join(",")+`|${v}|`+Object.keys(V).sort().join(",");j.useEffect(()=>{if(!m?.startsWith("class."))return;const B=gt(e,m.slice(6));x.includes(B)&&b(B)},[m,e,x,b]);const Y=ls(),J=j.useRef(!1),{commitLayout:U}=_l(),z=j.useCallback(B=>{U(t,B)},[U,t]);j.useEffect(()=>{if(!L)return;const B=L,G=X.getState(),ne={hidden:B.hidden,showInheritedEdges:B.showInheritedEdges,materializedInterfaces:B.materializedInterfaces};Hi(ne,G)||S(ne),O.current=!0},[t,L,S]),j.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))??rw;Hi(G,ne)||(Y.setQueryData(We.visibility(t),G),_e.setVisibility(t,G).catch(()=>{}))},[g,v,E,t,Y]);const Z=j.useCallback(B=>{const G=T.nodes.map(ye=>Sl(ye,B)),ne=F.filter(ye=>aw(ye.origin,g)),{extNodes:ue}=Sw(G,ne,R,B),ae=[...G,...ue],xe=new Set(ae.map(ye=>ye.id));_(ae),C(rs([...T.edges,...Mw(P,new Set(ne.map(ye=>ye.origin)),xe,e,new Set(x),g,v,V)]))},[T,F,g,R,P,e,x,v,V]),te=j.useCallback(()=>{J.current||(J.current=!0,requestAnimationFrame(()=>{s({padding:.18,duration:400}),D(!0)}))},[s]),ee=j.useRef(n);ee.current=n;const K=n!==void 0;j.useEffect(()=>{const B=ee.current;if(!B)return;const G=T.nodes.filter(ae=>B[ae.id]),ne=T.nodes.filter(ae=>!B[ae.id]);if(ne.length===0){Z(B),te();return}if(G.length===0){let ae=!1;return os(T.nodes,T.edges).then(xe=>{if(ae)return;const ye=lo(xe);Z(ye),z(ye),te()}),()=>{ae=!0}}const ue=Il(G.map(ae=>({node:ae,position:B[ae.id]})),ne);Z({...B,...ue}),z(ue),te()},[T,K,F,P,R,W]);const Q=j.useCallback(B=>_(G=>Ns(B.filter(ne=>ne.id!=="region"),G)),[]),re=j.useCallback(B=>C(G=>js(B,G)),[]),ie=j.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 ue=o(),ae=ue.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 ct of ue)ct.parentId===G.parentId&&(xe=Math.max(xe,ct.position.x+(ct.measured?.width??160)),ye=Math.max(ye,ct.position.y+(ct.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)}}}z(ne)},[z,o]),ce=j.useCallback(async()=>{await _e.resetLayout(t).catch(()=>{});const B=await os(T.nodes,T.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,T,s,Z,Y]),he=i??I,ge=j.useMemo(()=>he?Dw(he,N):null,[he,N]),be=j.useMemo(()=>Iw(H,e.overlay.origin),[H,e.overlay.origin]),Ee=j.useMemo(()=>$w(A?.comments),[A?.comments]),Ie=j.useMemo(()=>Rw(A?.comments),[A?.comments]),Ze=j.useMemo(()=>Aw(Ee),[Ee]),Ge=j.useMemo(()=>{const B=H.map(ne=>{if(ne.type!=="classNode"&&ne.type!=="interfaceNode")return ne.className?{...ne,className:void 0}:ne;const ue=ge&&!ge.nodeIds.has(ne.id)?"is-dimmed":void 0;return ne.className===ue?ne:{...ne,className:ue}}),G=be?[be,...B]:B;return Ze.length?[...G,...Ze]:G},[H,ge,be,Ze]),Ue=j.useMemo(()=>N.map(B=>{const G=B.data?.edgeClass??B.id.replace(/^edge-/,""),ne=m===`class.${G}`,ue=ge?ge.edgeIds.has(B.id)?"is-on":"is-dimmed":void 0,ae=ne?se("is-selected",ue):ue;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:Ge,edges:Ue,nodeTypes:$l,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(Cl,{}),a.jsx(Zo,{className:"!bg-card !border !border-border [&_button]:!bg-card [&_button]:!border-border [&_button]:!fill-foreground",showInteractive:!1,children:a.jsx(It,{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(it,{position:"top-right",className:"flex gap-1.5",children:[Ie.length>0&&a.jsx(Rl,{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(Nt,{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(mn,{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(ko,{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:k,title:"Toggle inherited (interface-induced) edges",children:[a.jsx(Lt,{className:"h-3.5 w-3.5"})," Inherited"]}),a.jsx(ll,{count:h})]})]})}const fo="integration.request.",Al=e=>`${fo}${e}`,Ow=e=>e.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"integration";function zw({name:e}){return a.jsx(jn,{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(je,{tone:"emerald",size:"sm",children:a.jsx(ko,{})}),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 Tw({slug:e,label:t}){return a.jsx(jn,{anchor:{ref:Al(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(je,{tone:"amber",size:"sm",children:a.jsx(ko,{})}),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 Lw({domainId:e,taken:t}){const{create:n}=ga(e),s=X(f=>f.setOpenAnchor),[o,i]=j.useState(!1),[r,c]=j.useState(""),[l,d]=j.useState(""),u=()=>{const f=r.trim();if(!f)return;const h=Al(Ow(f)),p=`Add a "${f}" integration under the integrations/ folder${l.trim()?` — ${l.trim()}`:""}. Wire it up the Astrale way (DI, secrets, idempotency).`;n.mutate({anchors:[f],anchorRefs:[{ref:h,kind:"section"}],text:p,firstRole:"user",type:"text"},{onSuccess:()=>{c(""),d(""),i(!1),s(h),Yn.success("Integration requested — add the why/how in the comment")},onError:m=>Yn.error(String(m))})};return a.jsxs(zt,{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(Tt,{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:f=>c(f.target.value),onKeyDown:f=>{f.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:f=>d(f.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 Hw({domainId:e}){const{data:t}=ya(e),{data:n}=No(e),s=t?.detectedIntegrations??[],o=j.useMemo(()=>new Set(s),[s]),i=j.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(Ht,{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(zw,{name:r},r))})]}),i.length>0&&a.jsxs(a.Fragment,{children:[s.length>0&&a.jsx(Wn,{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(Tw,{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(Wn,{className:"my-3 opacity-60"}),a.jsx(Lw,{domainId:e,taken:o})]})})}function dt({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(Tu,{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 Dl({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(Pl,{node:o,depth:0,selected:t,onSelect:n,controls:s},o.path)),e.members.map(o=>a.jsx(Ol,{m:o,depth:1,selected:t,onSelect:n,controls:s},o.selectId))]})}function Pl({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]=j.useState(!0),f=`module.${e.path}`,h=n===f,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?Uu:gn;return a.jsxs("div",{children:[a.jsxs("div",{"data-anchor-ref":f,"data-anchor-excerpt":e.path,className:se("flex items-center gap-0.5 pr-2 hover:bg-accent/50 rounded-md",h&&"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(f),className:se("flex items-center gap-1.5 flex-1 min-w-0 py-1 text-left font-bold",h&&"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(Vt,{domainId:o?.domainId,anchorRef:{ref:f,kind:"section"},excerpt:e.path,className:"ml-1"})]}),m&&a.jsxs("div",{children:[e.children.map(b=>a.jsx(Pl,{node:b,depth:t+1,selected:n,onSelect:s,controls:o},b.path)),e.members.map(b=>a.jsx(Ol,{m:b,depth:t+1,selected:n,onSelect:s,controls:o},b.selectId))]})]})}function Ol({m:e,depth:t,selected:n,onSelect:s,controls:o}){const i=n===e.selectId,r=e.kind==="interface",c=X(g=>Pe(e.ref,g.hidden)),l=X(g=>g.toggleHidden),d=X(g=>ao(e.name,g.materializedInterfaces)),u=X(g=>g.toggleInterfaceMaterialized),f=o?Pe(e.ref,o.hidden):c,h=o?.toggleHidden??l,p=o?ao(e.name,o.materializedInterfaces):d,m=o?.toggleInterfaceMaterialized??u,w=!r&&f,y=e.kind==="interface"?ze:e.kind==="edge"?Lt:Oe,x=e.kind==="interface"?"text-fuchsia-300":e.kind==="edge"?"text-amber-400":"text-sky-300",b=j.useRef(null);return j.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(Oe,{className:"h-3.5 w-3.5"}):a.jsx(lf,{className:"h-3.5 w-3.5"})}):a.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),h(e.ref)},title:f?"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",f?"opacity-100":"opacity-0 group-hover:opacity-100"),children:f?a.jsx(pa,{className:"h-3.5 w-3.5"}):a.jsx(ma,{className:"h-3.5 w-3.5"})}),a.jsx(Vt,{domainId:o?.domainId,anchorRef:{ref:e.selectId,kind:"schema"},excerpt:`${e.kind} ${e.name}`,className:"ml-1"})]})}const Zt={width:360,height:220},zl={width:200,height:120},On=52,Vw=48,as=112,Fw=1900;function Bw(e){const t=e.type==="classNode"||e.type==="interfaceNode"?{width:160,height:44}:e.type==="moduleNode"?{width:200,height:44}:zl;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 Ww(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=Bw(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 Yw(e){const t=[];let n=0,s=0,o=0;for(const i of e)n>0&&n+i.size.width>Fw&&(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 Xw(e,t){const n=e.filter(i=>t[i.domainId]);if(n.length===0)return Yw(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=Ww(r.nodes),l=s[r.domainId]??{x:On-c.minX,y:On+Vw-c.minY},d={width:Math.max(Zt.width,c.maxX+l.x),height:Math.max(Zt.height,c.maxY+l.y)},u={width:Math.max(Zt.width,c.maxX+l.x+On),height:Math.max(Zt.height,c.maxY+l.y+On)},f=n[r.domainId];return{domainId:r.domainId,contentOffset:l,size:{width:f?Math.max(d.width,f.width):u.width,height:f?Math.max(d.height,f.height):u.height}}}),i=Xw(o,t);return o.map((r,c)=>({...r,position:i[c]}))}function Tl(e){return e.data?.workspaceGeometry??null}function Yi(e,t){const n=Tl(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 Ll=j.createContext(null);function Zw({actions:e,children:t}){return a.jsx(Ll.Provider,{value:e,children:t})}function ir(){const e=j.useContext(Ll);if(!e)throw new Error("Workspace nodes require WorkspaceNodeActionsProvider");return e}function Hl({nodeId:e,minimum:t,label:n,placement:s="module"}){const o=ir();return a.jsx(yy,{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 Gw({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(Hl,{nodeId:e,minimum:Zt,label:`Resize ${s.origin}`,placement:"domain"})]})}function Xi(e){const t=ir(),n=Tl(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(Hl,{nodeId:e.id,minimum:zl,label:"Resize module"})]})}const Uw={...$l,group:Xi,moduleNode:Xi,workspaceDomain:Gw},Kw=216,Qw=48,Vl=52,Jw=12,qi=40,ev=e=>`workspace-external:${encodeURIComponent(e)}`,Fl=(e,t,n)=>`workspace-external-member:${encodeURIComponent(e)}:${n?`${n}:`:""}${encodeURIComponent(t)}`;function tv(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 nv(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=>tv(l,u,qi));if(!d)return l.position;c=d.position.y+d.size.height+qi}}function sv(e,t,n){const s=[...e].sort((r,c)=>r.origin.localeCompare(c.origin)).map(r=>({...r,size:{width:Kw,height:Qw+r.members.length*Vl+Jw}})),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??nv(r,o,t,i);return c||i.push({position:l,size:r.size}),{...r,position:l}})}function ov(e,t,n,s){const o=new Map((s??[]).map(c=>[c.origin,c])),i=sv(e,t,n),r=[];for(const c of i){const l=o.get(c.origin),d=ev(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((f,h)=>{r.push({id:Fl(c.origin,f.name,f.definition),type:"extMember",parentId:d,extent:"parent",draggable:!1,position:{x:12,y:42+h*Vl},data:{name:f.name,kind:u,definition:f.definition},style:{width:192,height:44}})})}return{nodes:r,positions:Object.fromEntries(i.map(c=>[c.origin,c.position]))}}const rv="oklch(0.76 0.16 35)",zn="oklch(0.72 0.18 330)",iv=e=>`workspace-domain:${e}`,Et=(e,t)=>`workspace:${encodeURIComponent(e)}:${t}`;function av(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 cv(e,t,n){const s=new Set(t),o=av(e,n),i=Ml(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 os(i.nodes,i.edges)):d={...r,...Il(c.map(u=>({node:u,position:r[u.id]})),l)},{input:e,collapsed:s,materialized:o,nodes:i.nodes.map(u=>Sl(u,d)),edges:i.edges}}function Zi(e){return e.refs!==void 0?e.refs.filter(at):e.types}function Qt(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 nr(n,i,o).filter(r=>!r.cls||!Pe(dn(r.cls),e.input.visibility.hidden)).map(r=>{const c=r.ifaceNode?r.ifaceNode:e.collapsed.has(gt(e.input.bundle,r.cls))?`grp-${gt(e.input.bundle,r.cls)}`:`class.${r.cls}`;return{nodeId:Et(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")?Qt(e,r):[]}else{if(o.classes[i]?.type==="node"||o.interfaces[i])return Qt(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 Qt(l,r);s.add(`${e.input.summary.origin} imports ${r.origin}:${r.kind}.${i}, but the selected schema does not expose it.`)}return[{nodeId:Fl(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(at).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 lv(e,t,n,s){return`workspace-edge:${encodeURIComponent(e)}:${t}:${n}:${s}`}function dv(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||Pe(Nl(d.name),c.input.visibility.hidden))continue;const u=Zi(d.endpoints[0]).flatMap(p=>cs(c,p,t,n)),f=Zi(d.endpoints[1]).flatMap(p=>cs(c,p,t,n)),h=sr(d.endpoints[0].cardinality,d.endpoints[1].cardinality);for(const p of u)for(const m of f){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=lv(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:h.markerStart,markerEnd:h.markerEnd,style:{stroke:rv,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 uv(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=Qt(r,{origin:c.domain,kind:"class",name:l})[0];if(u)for(const f of Gi(c,d.implementsRefs,d.implements)){const h=Ui(c,f);if(!(!h||h.origin==="kernel.astrale.ai"))for(const p of cs(r,h,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:tt.ArrowClosed,color:zn,width:16,height:16},style:{stroke:zn,strokeWidth:1.7,strokeDasharray:"7 4"}})}}}for(const l of Object.keys(c.interfaces)){const d=Qt(r,{origin:c.domain,kind:"interface",name:l})[0];if(!d)continue;const u=c.interfaces[l];for(const f of Gi(c,u?.extendsRefs,u?.extends)){const h=Ui(c,f);if(!(!h||h.origin==="kernel.astrale.ai"))for(const p of cs(r,h,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:tt.ArrowClosed,color:zn,width:16,height:16},style:{stroke:zn,strokeWidth:1.7,strokeDasharray:"2 4"}})}}}}}return s}function fv(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])),f=[],h=[];for(const y of e){const x=y.input.summary.id,b=u.get(x),g=iv(x),v=x===t;f.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 k=!E.parentId,S=k?b.contentOffset:{x:0,y:0};f.push({...E,id:Et(x,E.id),parentId:k?g:Et(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)h.push({...E,id:Et(x,E.id),source:Et(x,E.source),target:Et(x,E.target)})}const p=dv(e,l,c),m=uv(e,l,c),w=ov(p.unresolved,d,s,r);return f.push(...w.nodes),h.push(...p.edges,...m),{nodes:f,edges:h,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 hv(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 pv({domains:e,viewsCount:t,onToggleInherited:n}){const{fitView:s,getNode:o}=Ft(),{data:i}=pn(),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),f=pe(P=>P.domainPositions),h=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:k}=_l(),S=j.useRef(""),R=j.useRef(!1),A=j.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&&k(J.domainId,J.updates)},[k,o,y]),L=j.useCallback((P,W)=>{if(X.getState().domainId!==P){l(P);return}W&&X.getState().selectClass(W)},[l]),O=j.useCallback((P,W)=>{if(X.getState().domainId!==P){l(P);return}E(P,W)},[l,E]),H=j.useMemo(()=>({activateDomain:L,resizeNode:A,toggleModule:O}),[L,A,O]),_=j.useMemo(()=>fv(e,{activeDomainId:r,catalog:i,contentOffsets:m,domainPositions:f,domainSizes:p,externalPositions:h}),[r,i,m,f,p,e,h]),[N,C]=j.useState(_.nodes),[I,$]=j.useState(()=>rs(_.edges));j.useEffect(()=>{if(x(_.domainPositions),b(_.externalPositions),g(_.contentOffsets),C(_.nodes),$(rs(_.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,_]);const M=j.useCallback(P=>C(W=>Ns(P.filter(Y=>Y.type!=="remove"),W)),[]),D=j.useCallback(P=>$(W=>js(P.filter(Y=>Y.type!=="remove"),W)),[]),V=e.every(P=>P.input.visibility.showInheritedEdges),T=j.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&&k(Y.domainId,Y.updates)},[k,w]),F=j.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(Zw,{actions:H,children:a.jsxs(Xo,{"data-testid":"workspace-schema-canvas",nodes:N,edges:F,nodeTypes:Uw,edgeTypes:Uo,onNodesChange:M,onEdgesChange:D,onNodeDragStop:T,onNodeClick:(P,W)=>{if(W.id.startsWith("workspace-domain:")){L(W.id.slice(17));return}const Y=hv(W.id);Y&&(Y.localId.startsWith("class.")?L(Y.domainId,Y.localId):Y.localId.startsWith("iface.")?L(Y.domainId,`interface.${Y.localId.slice(6)}`):Y.localId.startsWith("grp-")&&L(Y.domainId,`module.${Y.localId.slice(4)}`))},onEdgeClick:(P,W)=>{const Y=W.data?.ownerDomainId,J=W.data?.edgeClass;Y&&J&&L(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(Cl,{}),a.jsx(Zo,{className:"!border !border-border !bg-card [&_button]:!border-border [&_button]:!bg-card [&_button]:!fill-foreground",showInteractive:!1,children:a.jsx(It,{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)"}),_.diagnostics.length>0&&a.jsx(it,{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(mt,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),a.jsx("span",{children:_.diagnostics.join(" ")})]})}),a.jsxs(it,{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(wo,{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(mn,{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:V?"default":"outline",onClick:n,title:"Toggle inherited edges in every selected domain",children:[a.jsx(Lt,{className:"h-3.5 w-3.5"})," Inherited"]})]})]})})}function mv({domains:e,onToggleHidden:t}){const n=X(h=>h.domainId),s=X(h=>h.selectedClass),o=X(h=>h.setDomain),i=pe(h=>h.collapsedModules),r=pe(h=>h.badgeInterfaces),c=pe(h=>h.toggleModule),l=pe(h=>h.toggleInterface),[d,u]=j.useState({}),f=(h,p)=>{X.getState().domainId!==h&&o(h),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(wo,{className:"h-3 w-3"})," Workspace modules"]}),e.map(h=>{const p=h.input.summary.id,m=n===p,w=!!d[p],y=Object.fromEntries(Object.keys(h.input.bundle.ir?.interfaces??{}).filter(g=>!(r[p]??[]).includes(g)).map(g=>[g,!0])),x={domainId:p,collapsedModules:i[p]??[],hidden:h.input.visibility.hidden,materializedInterfaces:y,toggleModule:g=>c(p,g),toggleHidden:g=>t(p,g),toggleInterfaceMaterialized:g=>l(p,g)},b=va(h.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:()=>f(p),className:"min-w-0 flex-1 truncate text-left text-[12px] font-extrabold",title:`Make ${h.input.summary.origin} active`,children:h.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(Dl,{root:b,selected:m?s:void 0,onSelect:g=>f(p,g),controls:x})})]},p)})]})}const gv={positions:{}},xv={hidden:{},showInheritedEdges:!0,materializedInterfaces:{}};function yv(e,t){const n=En({queries:e.map(r=>({queryKey:We.bundle(r),queryFn:()=>_e.bundle(r)}))}),s=En({queries:e.map(r=>({queryKey:We.anatomy(r),queryFn:()=>_e.anatomy(r)}))}),o=En({queries:e.map(r=>({queryKey:We.layout(r),queryFn:()=>_e.layout(r)}))}),i=En({queries:e.map(r=>({queryKey:We.visibility(r),queryFn:()=>_e.visibility(r)}))});return j.useMemo(()=>{const r=new Map((t??[]).map(u=>[u.id,u])),c=[],l=[];let d=!1;return e.forEach((u,f)=>{const h=r.get(u),p=n[f]?.data,m=s[f]?.data,w=n[f]?.error??s[f]?.error;if(w&&l.push(`${h?.origin??u}: ${String(w)}`),!h||!p||!m){d=d||!w;return}c.push({summary:h,bundle:p,anatomy:m,layout:o[f]?.data??gv,visibility:i[f]?.data??xv})}),{inputs:c,pending:d,errors:l}},[s,n,t,e,o,i])}function wv({inputs:e}){const t=e.map(o=>({input:o,model:Lu(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(Ht,{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(mt,{className:"h-3.5 w-3.5"})," drift"]})]}),n===0&&a.jsx(Gt,{icon:a.jsx(mn,{}),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,vv=300;function Ji(e,t,n){return[e.summary.id,e.summary.origin,e.bundle.renderFingerprint,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 bv({domainIds:e}){const{data:t}=Hu(),{inputs:n,pending:s,errors:o}=yv(e,t),i=ls(),r=X(_=>_.domainId),c=X(_=>_.selectedClass),l=X(_=>_.selectClass),d=X(_=>_.setFocus),u=X(_=>_.panelOverlay),f=X(_=>_.setPanelOverlay),h=X(_=>_.setCanvasMode),p=pe(_=>_.collapsedModules),m=pe(_=>_.badgeInterfaces),[w,y]=j.useState([]),x=j.useRef(new Map),[b,g]=j.useState(()=>{try{const _=Number(localStorage.getItem("studio.workspaceModulesWidth"));if(Number.isFinite(_)&&_>=Ki&&_<=Qi)return _}catch{}return vv});j.useEffect(()=>{h("schema"),X.getState().panelOverlay&&X.getState().panelOverlay!=="views"&&f(null)},[h,f]);const v=j.useMemo(()=>n.map(_=>Ji(_,p[_.summary.id]??[],m[_.summary.id]??[])).join("::"),[m,p,n]);j.useEffect(()=>{let _=!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=m[I]??[],D=Ji(C,$,M),V=x.current.get(I);if(V?.key===D)return{...V.projection,input:C};const T=await cv(C,$,M);return _||x.current.set(I,{key:D,projection:T}),T})).then(C=>{_||y(C)}),()=>{_=!0}},[v]),j.useEffect(()=>{const _=N=>{N.key!=="Escape"||N.defaultPrevented||(d(null),l(void 0),f(null))};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[l,d,f]);const E=j.useCallback((_,N)=>{const C=n.find($=>$.summary.id===_);if(!C)return;const I=N(C.visibility);i.setQueryData(We.visibility(_),I),_e.setVisibility(_,I).catch(()=>{i.invalidateQueries({queryKey:We.visibility(_)})})},[n,i]),k=j.useCallback((_,N)=>E(_,C=>{const I={...C.hidden};return I[N]?delete I[N]:I[N]=!0,{...C,hidden:I}}),[E]),S=j.useCallback(()=>{const _=!n.every(N=>N.visibility.showInheritedEdges);for(const N of n)E(N.summary.id,C=>({...C,showInheritedEdges:_}))},[n,E]),R=_=>{_.preventDefault();const N=_.clientX,C=b;let I=C;const $=D=>{I=Math.min(Qi,Math.max(Ki,C+D.clientX-N)),g(I)},M=()=>{document.removeEventListener("pointermove",$),document.removeEventListener("pointerup",M),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem("studio.workspaceModulesWidth",String(I))}catch{}};document.addEventListener("pointermove",$),document.addEventListener("pointerup",M),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},A=n.find(_=>_.summary.id===r),L=n.reduce((_,N)=>_+N.anatomy.views.length,0),O=w.length===n.length&&n.length===e.length,H=w.map(_=>`${_.input.summary.id}:${_.input.bundle.renderFingerprint}`).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(_=>_.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(mt,{className:"mt-0.5 h-4 w-4 shrink-0"}),a.jsx("span",{children:[...o,...n.flatMap(_=>_.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(Ht,{className:"h-full",children:a.jsx(mv,{domains:w,onToggleHidden:k})}),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(pv,{domains:w,viewsCount:L,onToggleInherited:S})},H)}),u==="views"?a.jsx(dt,{onClose:()=>f(null),children:a.jsx(wv,{inputs:n})}):c&&A?a.jsx(dt,{onClose:()=>l(void 0),children:a.jsx(yl,{bundle:A.bundle,selected:c})}):null]})]})}const ea=180,ta=560,Nv=240;function Ev({domainId:e}){const t=pe(s=>s.selectedDomainIds),n=t.includes(e)?t:[e,...t];return n.length>1?a.jsx(bv,{domainIds:n}):a.jsx(jv,{domainId:e})}function jv({domainId:e}){const{data:t,isLoading:n}=xo(e),{data:s}=Vu(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),f=X(g=>g.setPanelOverlay),h=bo(e),[p,m]=j.useState(()=>{try{const g=Number(localStorage.getItem("studio.modulesWidth"));if(Number.isFinite(g)&&g>=ea&&g<=ta)return g}catch{}return Nv}),w=g=>{g.preventDefault();const v=g.clientX,E=p;let k=E;const S=A=>{k=Math.min(ta,Math.max(ea,E+(A.clientX-v))),m(k)},R=()=>{document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",R),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem("studio.modulesWidth",String(k))}catch{}};document.addEventListener("pointermove",S),document.addEventListener("pointerup",R),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[y,x]=j.useState(null);j.useEffect(()=>x(null),[e,l]),j.useEffect(()=>{const g=v=>{v.key!=="Escape"||v.defaultPrevented||(c(null),r(void 0),x(null),f(null))};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[c,r,f]);const b=j.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(mt,{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(Ht,{className:"h-full",children:d?o&&a.jsx(zy,{core:o,bundle:t,selectedPath:y,onSelect:x}):b&&a.jsx(Dl,{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(Dy,{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(Pw,{bundle:t,domainId:e,saved:s?.positions},e)},`${e}:${l}`)}),d?y&&o&&a.jsx(dt,{onClose:()=>x(null),children:a.jsx(Py,{core:o,bundle:t,selectedPath:y})}):u==="views"?a.jsx(dt,{onClose:()=>f(null),children:a.jsx(Zy,{domainId:e,model:h})}):u==="domains"?a.jsx(dt,{onClose:()=>f(null),children:a.jsx(fw,{domainId:e})}):u==="integrations"?a.jsx(dt,{onClose:()=>f(null),children:a.jsx(Hw,{domainId:e})}):i?a.jsx(dt,{onClose:()=>r(void 0),children:a.jsx(yl,{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{Ev as SchemaSection};