@astrale-os/cli 0.8.0-alpha.0 → 0.8.1-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/dist/astrale.js +62968 -41240
- package/dist/public/connect-core.js +55030 -0
- package/dist/public/keys/index.js +45631 -0
- package/dist/public/paths/index.js +43990 -0
- package/dist/types/admin/instance/model.d.ts +40 -0
- package/dist/types/connect-core.d.ts +22 -0
- package/dist/types/connection/auth.d.ts +33 -0
- package/dist/types/errors.d.ts +23 -0
- package/dist/types/identity/registry.d.ts +25 -0
- package/dist/types/keys/algorithm.d.ts +6 -0
- package/dist/types/keys/credential.d.ts +21 -0
- package/dist/types/keys/index.d.ts +4 -0
- package/dist/types/keys/pair.d.ts +34 -0
- package/dist/types/lib/admin-target.d.ts +74 -0
- package/dist/types/lib/ca-fetch.d.ts +2 -0
- package/dist/types/lib/config.d.ts +71 -0
- package/dist/types/lib/format.d.ts +1 -0
- package/dist/types/lib/idp-session.d.ts +33 -0
- package/dist/types/lib/idp.d.ts +397 -0
- package/dist/types/lib/instance-target.d.ts +36 -0
- package/dist/types/lib/instance.d.ts +186 -0
- package/dist/types/lib/log.d.ts +30 -0
- package/dist/types/lib/login-flow.d.ts +49 -0
- package/dist/types/lib/meta.d.ts +36 -0
- package/dist/types/lib/output.d.ts +83 -0
- package/dist/types/lib/table.d.ts +18 -0
- package/dist/types/lib/validation.d.ts +11 -0
- package/dist/types/paths/index.d.ts +2 -0
- package/dist/types/state/exchange-credentials.d.ts +25 -0
- package/dist/types/state/files.d.ts +9 -0
- package/dist/types/state/identities.d.ts +42 -0
- package/dist/types/state/index.d.ts +8 -0
- package/dist/types/state/paths.d.ts +32 -0
- package/package.json +30 -8
- package/src/admin/.spec/api.d.ts +3 -0
- package/src/admin/.spec/architecture.md +15 -0
- package/src/admin/.spec/icon.svg +3 -0
- package/src/admin/.spec/layout.ts +6 -0
- package/src/admin/catalog/.spec/api.d.ts +65 -0
- package/src/admin/catalog/.spec/architecture.md +6 -0
- package/src/admin/catalog/.spec/icon.svg +3 -0
- package/src/admin/catalog/.spec/layout.ts +6 -0
- package/src/admin/catalog/__tests__/client.test.ts +171 -0
- package/src/admin/catalog/client.ts +214 -0
- package/src/admin/catalog/index.ts +13 -0
- package/src/admin/catalog/model.ts +42 -0
- package/src/admin/catalog/tsconfig.json +8 -0
- package/src/admin/graph/.spec/api.d.ts +28 -0
- package/src/admin/graph/.spec/architecture.md +5 -0
- package/src/admin/graph/.spec/icon.svg +3 -0
- package/src/admin/graph/.spec/layout.ts +3 -0
- package/src/admin/graph/index.ts +6 -0
- package/src/admin/graph/nodes.ts +56 -0
- package/src/admin/index.ts +2 -0
- package/src/admin/instance/.spec/api.d.ts +66 -0
- package/src/admin/instance/.spec/architecture.md +10 -0
- package/src/admin/instance/.spec/icon.svg +3 -0
- package/src/admin/instance/.spec/layout.ts +6 -0
- package/src/admin/instance/__tests__/client.test.ts +289 -0
- package/src/admin/instance/client.ts +298 -0
- package/src/admin/instance/index.ts +16 -0
- package/src/admin/instance/model.ts +65 -0
- package/src/admin/instance/tsconfig.json +8 -0
- package/src/commands/__tests__/admin-instance.test.ts +3 -36
- package/src/commands/__tests__/call.test.ts +21 -68
- package/src/commands/__tests__/domain-install-owned.test.ts +26 -27
- package/src/commands/__tests__/domain-list.test.ts +2 -6
- package/src/commands/__tests__/logs.test.ts +50 -98
- package/src/commands/__tests__/ls.test.ts +21 -17
- package/src/commands/__tests__/read-commands.test.ts +171 -101
- package/src/commands/__tests__/view.test.ts +100 -51
- package/src/commands/admin/status.ts +3 -3
- package/src/commands/admin/use.ts +29 -6
- package/src/commands/auth/login.ts +1 -1
- package/src/commands/auth/logout.ts +4 -2
- package/src/commands/auth/status.ts +2 -2
- package/src/commands/auth/token.ts +2 -2
- package/src/commands/browser.ts +1 -1
- package/src/commands/call.ts +55 -91
- package/src/commands/describe.ts +52 -147
- package/src/commands/domain/install.ts +81 -50
- package/src/commands/domain/list.ts +4 -8
- package/src/commands/domain/publish.ts +9 -31
- package/src/commands/get.ts +32 -65
- package/src/commands/identity/__tests__/register.test.ts +93 -0
- package/src/commands/identity/create.ts +2 -2
- package/src/commands/identity/delete.ts +2 -2
- package/src/commands/identity/export.ts +7 -33
- package/src/commands/identity/import.ts +21 -70
- package/src/commands/identity/list.ts +2 -2
- package/src/commands/identity/register.ts +148 -117
- package/src/commands/identity/sync.ts +2 -2
- package/src/commands/identity/unsync.ts +2 -2
- package/src/commands/identity/use.ts +2 -2
- package/src/commands/identity/whoami.ts +2 -2
- package/src/commands/idp/add.ts +1 -1
- package/src/commands/idp/list.ts +1 -1
- package/src/commands/idp/refresh.ts +1 -1
- package/src/commands/idp/remove.ts +2 -2
- package/src/commands/idp/show.ts +1 -1
- package/src/commands/instance/active.ts +2 -2
- package/src/commands/instance/bookmark.ts +8 -2
- package/src/commands/instance/create.ts +1 -1
- package/src/commands/instance/delete.ts +4 -10
- package/src/commands/instance/forget.ts +1 -1
- package/src/commands/instance/list.ts +3 -3
- package/src/commands/instance/status.ts +5 -7
- package/src/commands/instance/use.ts +3 -3
- package/src/commands/logs.ts +152 -279
- package/src/commands/ls.ts +78 -204
- package/src/commands/mutate.ts +70 -139
- package/src/commands/query.ts +100 -278
- package/src/commands/session/analyze.ts +1 -1
- package/src/commands/session/list.ts +1 -1
- package/src/commands/setup.ts +1 -1
- package/src/commands/status.ts +1 -1
- package/src/commands/studio.ts +1 -1
- package/src/commands/token.ts +26 -21
- package/src/commands/update.ts +1 -1
- package/src/commands/use.ts +2 -3
- package/src/commands/view-serve.ts +1 -1
- package/src/commands/view.ts +67 -109
- package/src/connect-core.test.ts +38 -0
- package/src/connect-core.ts +42 -0
- package/src/connection/.spec/api.d.ts +111 -0
- package/src/connection/.spec/architecture.md +41 -0
- package/src/connection/.spec/capabilities/connection.ts +13 -0
- package/src/connection/.spec/examples/call.ts +7 -0
- package/src/connection/.spec/flows/command.ts +20 -0
- package/src/connection/.spec/flows/session.ts +61 -0
- package/src/connection/.spec/laws/connection.ts +181 -0
- package/src/connection/.spec/layout.ts +19 -0
- package/src/{kernel → connection}/__tests__/auth.test.ts +26 -2
- package/src/connection/__tests__/ca-fetch.test.ts +53 -0
- package/src/connection/__tests__/call.test.ts +17 -0
- package/src/connection/__tests__/credential.test.ts +109 -0
- package/src/connection/__tests__/errors.test.ts +96 -0
- package/src/connection/__tests__/exchange.test.ts +224 -0
- package/src/connection/__tests__/fixtures/localhost-cert.pem +19 -0
- package/src/connection/__tests__/fixtures/localhost-key.base64 +1 -0
- package/src/connection/__tests__/managed.test.ts +39 -0
- package/src/connection/__tests__/self.test.ts +51 -0
- package/src/connection/__tests__/session.test.ts +140 -0
- package/src/connection/__tests__/target.test.ts +93 -0
- package/src/{kernel → connection}/auth.ts +8 -8
- package/src/connection/call.ts +7 -0
- package/src/{kernel/run.ts → connection/command.ts} +22 -13
- package/src/connection/credential.ts +114 -0
- package/src/{kernel → connection}/errors.ts +32 -9
- package/src/connection/exchange.ts +274 -0
- package/src/connection/index.ts +8 -0
- package/src/connection/self.ts +120 -0
- package/src/connection/session.ts +176 -0
- package/src/connection/target.ts +111 -0
- package/src/connection/tsconfig.json +6 -0
- package/src/graph/.spec/api.d.ts +34 -0
- package/src/graph/.spec/laws/documents.ts +24 -0
- package/src/graph/.spec/laws/projection.ts +13 -0
- package/src/graph/.spec/layout.ts +6 -0
- package/src/graph/__tests__/mutation.test.ts +43 -0
- package/src/graph/__tests__/projection.test.ts +22 -0
- package/src/graph/__tests__/query.test.ts +154 -0
- package/src/graph/index.ts +3 -0
- package/src/graph/mutation.ts +18 -0
- package/src/graph/projection.ts +21 -0
- package/src/graph/query.ts +108 -0
- package/src/graph/tsconfig.json +6 -0
- package/src/identity/.history/ard/bootstrap-root-transfer.md +57 -0
- package/src/identity/.history/ard/domain-mediated-registration.md +36 -0
- package/src/identity/.spec/api.d.ts +124 -0
- package/src/identity/.spec/architecture.md +33 -0
- package/src/identity/.spec/capabilities/identity.ts +7 -0
- package/src/identity/.spec/flows/bootstrap-root.ts +79 -0
- package/src/identity/.spec/flows/domain-mediated-registration.ts +51 -0
- package/src/identity/.spec/flows/import.ts +29 -0
- package/src/identity/.spec/laws/identity.ts +56 -0
- package/src/identity/.spec/layout.ts +13 -0
- package/src/identity/.spec/schemas/identity-export-v1.schema.json +25 -0
- package/src/identity/__tests__/fixtures/registry-journey.ts +53 -0
- package/src/identity/__tests__/registration.test.ts +64 -0
- package/src/identity/__tests__/registry.test.ts +70 -0
- package/src/identity/__tests__/transfer.test.ts +198 -0
- package/src/identity/index.ts +23 -0
- package/src/identity/registration.ts +72 -0
- package/src/identity/registry.ts +172 -0
- package/src/identity/transfer.ts +187 -0
- package/src/identity/tsconfig.json +6 -0
- package/src/index.ts +1 -0
- package/src/keys/.spec/api.d.ts +74 -0
- package/src/keys/.spec/architecture.md +13 -0
- package/src/keys/.spec/laws/keys.ts +43 -0
- package/src/keys/.spec/layout.ts +6 -0
- package/src/keys/__tests__/algorithm.test.ts +39 -0
- package/src/keys/__tests__/keys.test.ts +168 -0
- package/src/keys/algorithm.ts +33 -0
- package/src/keys/credential.ts +112 -0
- package/src/keys/index.ts +14 -0
- package/src/keys/pair.ts +219 -0
- package/src/keys/tsconfig.json +6 -0
- package/src/lib/__tests__/admin-target.test.ts +67 -7
- package/src/lib/__tests__/binary.test.ts +2 -3
- package/src/lib/__tests__/command-dx.test.ts +2 -2
- package/src/lib/__tests__/config.test.ts +3 -2
- package/src/lib/__tests__/idp.test.ts +4 -6
- package/src/lib/__tests__/instance-target.test.ts +7 -4
- package/src/lib/__tests__/local-status.test.ts +1 -1
- package/src/lib/__tests__/log.test.ts +31 -0
- package/src/lib/__tests__/meta.test.ts +55 -0
- package/src/lib/__tests__/sdk-deps.test.ts +1 -1
- package/src/lib/__tests__/self.test.ts +8 -230
- package/src/lib/__tests__/use-target.test.ts +1 -1
- package/src/lib/__tests__/view-open-intent.test.ts +78 -104
- package/src/lib/__tests__/view-session.test.ts +99 -0
- package/src/lib/admin-domain.ts +39 -25
- package/src/lib/admin-instance.ts +38 -43
- package/src/lib/admin-target.ts +67 -13
- package/src/lib/binary.ts +13 -34
- package/src/lib/browser.ts +1 -1
- package/src/{kernel → lib}/ca-fetch.ts +35 -27
- package/src/lib/config.ts +1 -1
- package/src/lib/idp-session.ts +1 -1
- package/src/lib/idp.ts +3 -8
- package/src/lib/instance-target.ts +12 -8
- package/src/lib/instance.ts +34 -2
- package/src/lib/local-status.ts +2 -2
- package/src/lib/log.ts +3 -1
- package/src/lib/login-flow.ts +32 -5
- package/src/lib/meta.ts +15 -11
- package/src/lib/provision-instance.ts +4 -12
- package/src/lib/self.ts +5 -147
- package/src/lib/update.ts +1 -1
- package/src/lib/use-target.ts +1 -1
- package/src/lib/validation.ts +2 -2
- package/src/lib/view/open-intent.ts +7 -37
- package/src/lib/view/port-allocation.ts +1 -1
- package/src/lib/view/resolve.ts +52 -45
- package/src/lib/view/server.ts +16 -33
- package/src/lib/view/session.ts +51 -22
- package/src/paths/.spec/api.d.ts +13 -0
- package/src/paths/.spec/architecture.md +5 -0
- package/src/paths/.spec/layout.ts +3 -0
- package/src/paths/index.ts +13 -0
- package/src/program/.spec/api.d.ts +42 -0
- package/src/program/.spec/architecture.md +18 -0
- package/src/program/.spec/laws/program.ts +29 -0
- package/src/program/.spec/layout.ts +14 -0
- package/src/program/__tests__/program.test.ts +359 -0
- package/src/program/build.ts +190 -0
- package/src/program/command.ts +42 -0
- package/src/program/index.ts +2 -0
- package/src/program/options.ts +40 -0
- package/src/{registry.ts → program/registry.ts} +5 -1
- package/src/program/tsconfig.json +6 -0
- package/src/setup/steps/admin.ts +18 -3
- package/src/setup/steps/instance.ts +1 -1
- package/src/state/.spec/api.d.ts +133 -0
- package/src/state/.spec/architecture.md +31 -0
- package/src/state/.spec/capabilities/state.ts +7 -0
- package/src/state/.spec/flows/identity-update.ts +22 -0
- package/src/state/.spec/laws/state.ts +73 -0
- package/src/state/.spec/layout.ts +14 -0
- package/src/state/__tests__/exchange-credentials.test.ts +188 -0
- package/src/state/__tests__/files.test.ts +113 -0
- package/src/state/__tests__/fixtures/identity-transition.ts +37 -0
- package/src/state/__tests__/identities.test.ts +142 -0
- package/src/state/__tests__/paths.test.ts +27 -0
- package/src/state/exchange-credentials.ts +219 -0
- package/src/state/files.ts +129 -0
- package/src/state/identities.ts +236 -0
- package/src/state/index.ts +29 -0
- package/src/state/paths.ts +61 -0
- package/src/state/tsconfig.json +6 -0
- package/src/telemetry/__tests__/redact.test.ts +3 -3
- package/src/telemetry/__tests__/trigger.test.ts +1 -1
- package/src/telemetry/settings.ts +1 -1
- package/src/telemetry/store.ts +1 -1
- package/src/test-utils.ts +1 -1
- package/studio/client/dist/assets/elk-api-D0cBetPW.js +1 -0
- package/studio/client/dist/assets/elk-worker.min-C9JGDOE-.js +6312 -0
- package/studio/client/dist/assets/index-BQnJ5sgd.css +1 -0
- package/studio/client/dist/assets/index-ChOr3yP0.css +1 -0
- package/studio/client/dist/assets/index-Dspir4w7.js +81 -0
- package/studio/client/dist/assets/index-bVD2KJgz.js +8 -0
- package/studio/client/dist/index.html +2 -2
- package/studio/package.json +10 -1
- package/studio/server/introspect/extractor.ts +1 -1
- package/studio/server/state/views.test.ts +3 -7
- package/studio/server/state/views.ts +23 -30
- package/studio/tsconfig.json +23 -0
- package/tsconfig.json +1 -1
- package/viewer/dist/main.js +65 -39
- package/viewer/tsconfig.json +13 -0
- package/src/command.ts +0 -42
- package/src/commands/__tests__/help-contract.test.ts +0 -164
- package/src/kernel/__tests__/client-owned-lookup.test.ts +0 -51
- package/src/kernel/__tests__/errors.test.ts +0 -43
- package/src/kernel/__tests__/expand.test.ts +0 -123
- package/src/kernel/client.ts +0 -214
- package/src/kernel/expand.ts +0 -192
- package/src/kernel/graph.ts +0 -96
- package/src/kernel/index.ts +0 -29
- package/src/kernel/options.ts +0 -22
- package/src/kernel/types.ts +0 -14
- package/src/lib/__tests__/domain-identity.test.ts +0 -60
- package/src/lib/__tests__/fs-atomic.test.ts +0 -104
- package/src/lib/__tests__/identity.test.ts +0 -79
- package/src/lib/__tests__/keys.test.ts +0 -129
- package/src/lib/domain-identity.ts +0 -49
- package/src/lib/env.ts +0 -49
- package/src/lib/fs-atomic.ts +0 -126
- package/src/lib/identity.ts +0 -256
- package/src/lib/keys.ts +0 -294
- package/src/lib/paths.ts +0 -11
- package/src/program.ts +0 -213
- package/studio/client/dist/assets/index-BaqEuIQJ.js +0 -109
- package/studio/client/dist/assets/index-jRdExahh.css +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/elk-api-D0cBetPW.js","assets/index-Dspir4w7.js","assets/index-BQnJ5sgd.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{S as Cd,n as Os,s as Sd,r as _d,Q as Hi,u as is,a as Id,b as Md,c as k,e as $d,d as Ad,f as Rd,g as Dd,h as cr,i as Pd,j as zd,k as pe,l as Vi,m as Td,R as Od,o as a,p as Ld,q as X,t as Fi,P as Pt,v as co,w as re,C as Hd,x as zt,T as lo,_ as Vd,M as Bi,B as Wi,y as Ve,z as Tt,A as Pe,D as Fd,E as as,F as cs,N as Bd,H as Ot,G as Lt,I as Ht,J as be,K as he,L as Wd,O as Yd,U as Se,V as Xd,W as qd,X as Zd,Y as Gd,Z as Ud,$ as Yi,a0 as Ls,a1 as uo,a2 as Kd,a3 as Xi,a4 as fo,a5 as Vt,a6 as mt,a7 as Ut,a8 as qi,a9 as Fe,aa as Qd,ab as Jd,ac as Ft,ad as eu,ae as dn,af as ho,ag as tu,ah as nu,ai as ze,aj as ft,ak as po,al as su,am as ou,an as Zi,ao as ru,ap as mo,aq as iu,ar as au,as as cu,at as lu,au as du,av as uu,aw as fu,ax as go,ay as hu,az as Gi,aA as xo,aB as Ln,aC as Ui,aD as Ki,aE as Qi,aF as Hn,aG as Be,aH as pu,aI as gt,aJ as Ji,aK as ea,aL as ta,aM as mu,aN as gu,aO as xu,aP as ge,aQ as na,aR as yu,aS as wu,aT as vu}from"./index-Dspir4w7.js";function lr(e,t){const n=new Set(t);return e.filter(s=>!n.has(s))}function bu(e,t,n){const s=e.slice(0);return s[t]=n,s}var Nu=class extends Cd{#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,Os.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||!Sd(u,h)});!l&&!d||(l&&(this.#l=s,this.#t=o),this.#e=i,this.hasListeners()&&(l&&(lr(n,o).forEach(u=>{u.destroy()}),lr(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=_d(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 Hi(this.#o,o);n.push({defaultedQueryOptions:o,observer:r})}),n}#h(e,t){const n=this.#t.indexOf(e);n!==-1&&(this.#e=bu(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)&&Os.batch(()=>{this.listeners.forEach(o=>{o(this.#e)})})}}};function vn({queries:e,...t},n){const s=is(),o=Id(),i=Md(),r=k.useMemo(()=>e.map(w=>{const y=s.defaultQueryOptions(w);return y._optimisticResults=o?"isRestoring":"optimistic",y}),[e,s,o]);r.forEach(w=>{$d(w);const y=s.getQueryCache().get(w.queryHash);Ad(w,i,y)}),Rd(i);const[c]=k.useState(()=>new Nu(s,r,t)),[l,d,u]=c.getOptimisticResult(r,t.combine),f=!o&&t.subscribed!==!1;k.useSyncExternalStore(k.useCallback(w=>f?c.subscribe(Os.batchCalls(w)):Dd,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),k.useEffect(()=>{c.setQueries(r,t)},[r,t,c]);const m=l.some((w,y)=>cr(r[y],w))?l.flatMap((w,y)=>{const x=r[y];if(x&&cr(x,w)){const N=new Hi(s,x);return Pd(x,N,i)}return[]}):[];if(m.length>0)throw Promise.all(m);const p=l.find((w,y)=>{const x=r[y];return x&&zd({result:w,errorResetBoundary:i,throwOnError:x.throwOnError,query:s.getQueryCache().get(x.queryHash),suspense:x.suspense})});if(p?.error)throw p.error;return d(u())}const ju=[["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"}]],un=pe("AppWindow",ju);const ku=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Eu=pe("ArrowLeft",ku);const Cu=[["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"}]],yo=pe("CircleAlert",Cu);const Su=[["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"}]],fn=pe("FolderClosed",Su);const _u=[["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"}]],Iu=pe("FolderOpen",_u);const Mu=[["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"}]],$u=pe("FolderTree",Mu);const Au=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],it=pe("Globe",Au);const Ru=[["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"}]],Du=pe("Hexagon",Ru);const Pu=[["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"}]],sa=pe("LayoutGrid",Pu);const zu=[["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"}]],Tu=pe("MessageSquarePlus",zu);const Ou=[["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"}]],Lu=pe("MonitorPlay",Ou);const Hu=[["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"}]],wo=pe("Plug",Hu);const Vu=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],vo=pe("Plus",Vu);const Fu=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],oa=pe("Server",Fu);const Bu=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],Wu=pe("ShieldAlert",Bu);const Yu=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Xu=pe("ShieldCheck",Yu);const qu=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]],Zu=pe("ShieldX",qu);const Gu=[["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"}]],Uu=pe("SquareDashed",Gu);const Ku=[["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"}]],dr=pe("Unplug",Ku);const Qu=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],Ju=pe("UserRound",Qu);function me(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=me(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var ef={value:()=>{}};function ls(){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 Dn(n)}function Dn(e){this._=e}function tf(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}})}Dn.prototype=ls.prototype={constructor:Dn,on:function(e,t){var n=this._,s=tf(e+"",n),o,i=-1,r=s.length;if(arguments.length<2){for(;++i<r;)if((o=(e=s[i]).type)&&(o=nf(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]=ur(n[o],e.name,t);else if(t==null)for(o in n)n[o]=ur(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 Dn(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 nf(e,t){for(var n=0,s=e.length,o;n<s;++n)if((o=e[n]).name===t)return o.value}function ur(e,t,n){for(var s=0,o=e.length;s<o;++s)if(e[s].name===t){e[s]=ef,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var Hs="http://www.w3.org/1999/xhtml";const fr={svg:"http://www.w3.org/2000/svg",xhtml:Hs,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ds(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),fr.hasOwnProperty(t)?{space:fr[t],local:e}:e}function sf(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Hs&&t.documentElement.namespaceURI===Hs?t.createElement(e):t.createElementNS(n,e)}}function of(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ra(e){var t=ds(e);return(t.local?of:sf)(t)}function rf(){}function bo(e){return e==null?rf:function(){return this.querySelector(e)}}function af(e){typeof e!="function"&&(e=bo(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 _e(s,this._parents)}function cf(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function lf(){return[]}function ia(e){return e==null?lf:function(){return this.querySelectorAll(e)}}function df(e){return function(){return cf(e.apply(this,arguments))}}function uf(e){typeof e=="function"?e=df(e):e=ia(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 _e(s,o)}function aa(e){return function(){return this.matches(e)}}function ca(e){return function(t){return t.matches(e)}}var ff=Array.prototype.find;function hf(e){return function(){return ff.call(this.children,e)}}function pf(){return this.firstElementChild}function mf(e){return this.select(e==null?pf:hf(typeof e=="function"?e:ca(e)))}var gf=Array.prototype.filter;function xf(){return Array.from(this.children)}function yf(e){return function(){return gf.call(this.children,e)}}function wf(e){return this.selectAll(e==null?xf:yf(typeof e=="function"?e:ca(e)))}function vf(e){typeof e!="function"&&(e=aa(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 _e(s,this._parents)}function la(e){return new Array(e.length)}function bf(){return new _e(this._enter||this._groups.map(la),this._parents)}function Vn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Vn.prototype={constructor:Vn,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 Nf(e){return function(){return e}}function jf(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 Vn(e,i[r]);for(;r<l;++r)(c=t[r])&&(o[r]=c)}function kf(e,t,n,s,o,i,r){var c,l,d=new Map,u=t.length,f=i.length,h=new Array(u),m;for(c=0;c<u;++c)(l=t[c])&&(h[c]=m=r.call(l,l.__data__,c,t)+"",d.has(m)?o[c]=l:d.set(m,l));for(c=0;c<f;++c)m=r.call(e,i[c],c,i)+"",(l=d.get(m))?(s[c]=l,l.__data__=i[c],d.delete(m)):n[c]=new Vn(e,i[c]);for(c=0;c<u;++c)(l=t[c])&&d.get(h[c])===l&&(o[c]=l)}function Ef(e){return e.__data__}function Cf(e,t){if(!arguments.length)return Array.from(this,Ef);var n=t?kf:jf,s=this._parents,o=this._groups;typeof e!="function"&&(e=Nf(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,m=Sf(e.call(u,u&&u.__data__,d,s)),p=m.length,w=c[d]=new Array(p),y=r[d]=new Array(p),x=l[d]=new Array(h);n(u,f,w,y,x,m,t);for(var N=0,g=0,v,E;N<p;++N)if(v=w[N]){for(N>=g&&(g=N+1);!(E=y[g])&&++g<p;);v._next=E||null}}return r=new _e(r,s),r._enter=c,r._exit=l,r}function Sf(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function _f(){return new _e(this._exit||this._groups.map(la),this._parents)}function If(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 Mf(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),m,p=0;p<f;++p)(m=d[p]||u[p])&&(h[p]=m);for(;l<o;++l)c[l]=n[l];return new _e(c,this._parents)}function $f(){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 Af(e){e||(e=Rf);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 _e(o,this._parents).order()}function Rf(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Df(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Pf(){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 Tf(){let e=0;for(const t of this)++e;return e}function Of(){return!this.node()}function Lf(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 Hf(e){return function(){this.removeAttribute(e)}}function Vf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ff(e,t){return function(){this.setAttribute(e,t)}}function Bf(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Wf(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Yf(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 Xf(e,t){var n=ds(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?Vf:Hf:typeof t=="function"?n.local?Yf:Wf:n.local?Bf:Ff)(n,t))}function da(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function qf(e){return function(){this.style.removeProperty(e)}}function Zf(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Gf(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function Uf(e,t,n){return arguments.length>1?this.each((t==null?qf:typeof t=="function"?Gf:Zf)(e,t,n??"")):_t(this.node(),e)}function _t(e,t){return e.style.getPropertyValue(t)||da(e).getComputedStyle(e,null).getPropertyValue(t)}function Kf(e){return function(){delete this[e]}}function Qf(e,t){return function(){this[e]=t}}function Jf(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function eh(e,t){return arguments.length>1?this.each((t==null?Kf:typeof t=="function"?Jf:Qf)(e,t)):this.node()[e]}function ua(e){return e.trim().split(/^|\s+/)}function No(e){return e.classList||new fa(e)}function fa(e){this._node=e,this._names=ua(e.getAttribute("class")||"")}fa.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 ha(e,t){for(var n=No(e),s=-1,o=t.length;++s<o;)n.add(t[s])}function pa(e,t){for(var n=No(e),s=-1,o=t.length;++s<o;)n.remove(t[s])}function th(e){return function(){ha(this,e)}}function nh(e){return function(){pa(this,e)}}function sh(e,t){return function(){(t.apply(this,arguments)?ha:pa)(this,e)}}function oh(e,t){var n=ua(e+"");if(arguments.length<2){for(var s=No(this.node()),o=-1,i=n.length;++o<i;)if(!s.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?sh:t?th:nh)(n,t))}function rh(){this.textContent=""}function ih(e){return function(){this.textContent=e}}function ah(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function ch(e){return arguments.length?this.each(e==null?rh:(typeof e=="function"?ah:ih)(e)):this.node().textContent}function lh(){this.innerHTML=""}function dh(e){return function(){this.innerHTML=e}}function uh(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function fh(e){return arguments.length?this.each(e==null?lh:(typeof e=="function"?uh:dh)(e)):this.node().innerHTML}function hh(){this.nextSibling&&this.parentNode.appendChild(this)}function ph(){return this.each(hh)}function mh(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function gh(){return this.each(mh)}function xh(e){var t=typeof e=="function"?e:ra(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function yh(){return null}function wh(e,t){var n=typeof e=="function"?e:ra(e),s=t==null?yh:typeof t=="function"?t:bo(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function vh(){var e=this.parentNode;e&&e.removeChild(this)}function bh(){return this.each(vh)}function Nh(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function jh(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function kh(e){return this.select(e?jh:Nh)}function Eh(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Ch(e){return function(t){e.call(this,t,this.__data__)}}function Sh(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 _h(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 Ih(e,t,n){return function(){var s=this.__on,o,i=Ch(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 Mh(e,t,n){var s=Sh(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?Ih:_h,o=0;o<i;++o)this.each(c(s[o],t,n));return this}function ma(e,t,n){var s=da(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 $h(e,t){return function(){return ma(this,e,t)}}function Ah(e,t){return function(){return ma(this,e,t.apply(this,arguments))}}function Rh(e,t){return this.each((typeof t=="function"?Ah:$h)(e,t))}function*Dh(){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 ga=[null];function _e(e,t){this._groups=e,this._parents=t}function hn(){return new _e([[document.documentElement]],ga)}function Ph(){return this}_e.prototype=hn.prototype={constructor:_e,select:af,selectAll:uf,selectChild:mf,selectChildren:wf,filter:vf,data:Cf,enter:bf,exit:_f,join:If,merge:Mf,selection:Ph,order:$f,sort:Af,call:Df,nodes:Pf,node:zf,size:Tf,empty:Of,each:Lf,attr:Xf,style:Uf,property:eh,classed:oh,text:ch,html:fh,raise:ph,lower:gh,append:xh,insert:wh,remove:bh,clone:kh,datum:Eh,on:Mh,dispatch:Rh,[Symbol.iterator]:Dh};function Ce(e){return typeof e=="string"?new _e([[document.querySelector(e)]],[document.documentElement]):new _e([[e]],ga)}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 Th={passive:!1},Jt={capture:!0,passive:!1};function ks(e){e.stopImmediatePropagation()}function Ct(e){e.preventDefault(),e.stopImmediatePropagation()}function xa(e){var t=e.document.documentElement,n=Ce(e).on("dragstart.drag",Ct,Jt);"onselectstart"in t?n.on("selectstart.drag",Ct,Jt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function ya(e,t){var n=e.document.documentElement,s=Ce(e).on("dragstart.drag",null);t&&(s.on("click.drag",Ct,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 bn=e=>()=>e;function Vs(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}})}Vs.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Oh(e){return!e.ctrlKey&&!e.button}function Lh(){return this.parentNode}function Hh(e,t){return t??{x:e.x,y:e.y}}function Vh(){return navigator.maxTouchPoints||"ontouchstart"in this}function wa(){var e=Oh,t=Lh,n=Hh,s=Vh,o={},i=ls("start","drag","end"),r=0,c,l,d,u,f=0;function h(v){v.on("mousedown.drag",m).filter(s).on("touchstart.drag",y).on("touchmove.drag",x,Th).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(v,E){if(!(u||!e.call(this,v,E))){var j=g(this,t.call(this,v,E),v,E,"mouse");j&&(Ce(v.view).on("mousemove.drag",p,Jt).on("mouseup.drag",w,Jt),xa(v.view),ks(v),d=!1,c=v.clientX,l=v.clientY,j("start",v))}}function p(v){if(Ct(v),!d){var E=v.clientX-c,j=v.clientY-l;d=E*E+j*j>f}o.mouse("drag",v)}function w(v){Ce(v.view).on("mousemove.drag mouseup.drag",null),ya(v.view,d),Ct(v),o.mouse("end",v)}function y(v,E){if(e.call(this,v,E)){var j=v.changedTouches,S=t.call(this,v,E),$=j.length,R,V;for(R=0;R<$;++R)(V=g(this,S,v,E,j[R].identifier,j[R]))&&(ks(v),V("start",v,j[R]))}}function x(v){var E=v.changedTouches,j=E.length,S,$;for(S=0;S<j;++S)($=o[E[S].identifier])&&(Ct(v),$("drag",v,E[S]))}function N(v){var E=v.changedTouches,j=E.length,S,$;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),S=0;S<j;++S)($=o[E[S].identifier])&&(ks(v),$("end",v,E[S]))}function g(v,E,j,S,$,R){var V=i.copy(),A=Me(R||j,E),O,_,b;if((b=n.call(v,new Vs("beforestart",{sourceEvent:j,target:h,identifier:$,active:r,x:A[0],y:A[1],dx:0,dy:0,dispatch:V}),S))!=null)return O=b.x-A[0]||0,_=b.y-A[1]||0,function C(I,M,D){var P=A,H;switch(I){case"start":o[$]=C,H=r++;break;case"end":delete o[$],--r;case"drag":A=Me(D||M,E),H=r;break}V.call(I,v,new Vs(I,{sourceEvent:M,subject:b,target:h,identifier:$,active:H,x:A[0]+O,y:A[1]+_,dx:A[0]-P[0],dy:A[1]-P[1],dispatch:V}),S)}}return h.filter=function(v){return arguments.length?(e=typeof v=="function"?v:bn(!!v),h):e},h.container=function(v){return arguments.length?(t=typeof v=="function"?v:bn(v),h):t},h.subject=function(v){return arguments.length?(n=typeof v=="function"?v:bn(v),h):n},h.touchable=function(v){return arguments.length?(s=typeof v=="function"?v:bn(!!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 jo(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function va(e,t){var n=Object.create(e.prototype);for(var s in t)n[s]=t[s];return n}function pn(){}var en=.7,Fn=1/en,St="\\s*([+-]?\\d+)\\s*",tn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",We="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Fh=/^#([0-9a-f]{3,8})$/,Bh=new RegExp(`^rgb\\(${St},${St},${St}\\)$`),Wh=new RegExp(`^rgb\\(${We},${We},${We}\\)$`),Yh=new RegExp(`^rgba\\(${St},${St},${St},${tn}\\)$`),Xh=new RegExp(`^rgba\\(${We},${We},${We},${tn}\\)$`),qh=new RegExp(`^hsl\\(${tn},${We},${We}\\)$`),Zh=new RegExp(`^hsla\\(${tn},${We},${We},${tn}\\)$`),hr={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};jo(pn,xt,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:pr,formatHex:pr,formatHex8:Gh,formatHsl:Uh,formatRgb:mr,toString:mr});function pr(){return this.rgb().formatHex()}function Gh(){return this.rgb().formatHex8()}function Uh(){return ba(this).formatHsl()}function mr(){return this.rgb().formatRgb()}function xt(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Fh.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?gr(t):n===3?new je(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Nn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Nn(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=Bh.exec(e))?new je(t[1],t[2],t[3],1):(t=Wh.exec(e))?new je(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Yh.exec(e))?Nn(t[1],t[2],t[3],t[4]):(t=Xh.exec(e))?Nn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=qh.exec(e))?wr(t[1],t[2]/100,t[3]/100,1):(t=Zh.exec(e))?wr(t[1],t[2]/100,t[3]/100,t[4]):hr.hasOwnProperty(e)?gr(hr[e]):e==="transparent"?new je(NaN,NaN,NaN,0):null}function gr(e){return new je(e>>16&255,e>>8&255,e&255,1)}function Nn(e,t,n,s){return s<=0&&(e=t=n=NaN),new je(e,t,n,s)}function Kh(e){return e instanceof pn||(e=xt(e)),e?(e=e.rgb(),new je(e.r,e.g,e.b,e.opacity)):new je}function Fs(e,t,n,s){return arguments.length===1?Kh(e):new je(e,t,n,s??1)}function je(e,t,n,s){this.r=+e,this.g=+t,this.b=+n,this.opacity=+s}jo(je,Fs,va(pn,{brighter(e){return e=e==null?Fn:Math.pow(Fn,e),new je(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?en:Math.pow(en,e),new je(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new je(ht(this.r),ht(this.g),ht(this.b),Bn(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:xr,formatHex:xr,formatHex8:Qh,formatRgb:yr,toString:yr}));function xr(){return`#${ut(this.r)}${ut(this.g)}${ut(this.b)}`}function Qh(){return`#${ut(this.r)}${ut(this.g)}${ut(this.b)}${ut((isNaN(this.opacity)?1:this.opacity)*255)}`}function yr(){const e=Bn(this.opacity);return`${e===1?"rgb(":"rgba("}${ht(this.r)}, ${ht(this.g)}, ${ht(this.b)}${e===1?")":`, ${e})`}`}function Bn(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 wr(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 ba(e){if(e instanceof $e)return new $e(e.h,e.s,e.l,e.opacity);if(e instanceof pn||(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 Jh(e,t,n,s){return arguments.length===1?ba(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}jo($e,Jh,va(pn,{brighter(e){return e=e==null?Fn:Math.pow(Fn,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 je(Es(e>=240?e-240:e+120,o,s),Es(e,o,s),Es(e<120?e+240:e-120,o,s),this.opacity)},clamp(){return new $e(vr(this.h),jn(this.s),jn(this.l),Bn(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=Bn(this.opacity);return`${e===1?"hsl(":"hsla("}${vr(this.h)}, ${jn(this.s)*100}%, ${jn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function vr(e){return e=(e||0)%360,e<0?e+360:e}function jn(e){return Math.max(0,Math.min(1,e||0))}function Es(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 ko=e=>()=>e;function ep(e,t){return function(n){return e+n*t}}function tp(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 np(e){return(e=+e)==1?Na:function(t,n){return n-t?tp(t,n,e):ko(isNaN(t)?n:t)}}function Na(e,t){var n=t-e;return n?ep(e,n):ko(isNaN(e)?t:e)}const Wn=(function e(t){var n=np(t);function s(o,i){var r=n((o=Fs(o)).r,(i=Fs(i)).r),c=n(o.g,i.g),l=n(o.b,i.b),d=Na(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 sp(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 op(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function rp(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]=Kt(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 ip(e,t){var n=new Date;return e=+e,t=+t,function(s){return n.setTime(e*(1-s)+t*s),n}}function He(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function ap(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]=Kt(e[o],t[o]):s[o]=t[o];return function(i){for(o in n)s[o]=n[o](i);return s}}var Bs=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Cs=new RegExp(Bs.source,"g");function cp(e){return function(){return e}}function lp(e){return function(t){return e(t)+""}}function ja(e,t){var n=Bs.lastIndex=Cs.lastIndex=0,s,o,i,r=-1,c=[],l=[];for(e=e+"",t=t+"";(s=Bs.exec(e))&&(o=Cs.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:He(s,o)})),n=Cs.lastIndex;return n<t.length&&(i=t.slice(n),c[r]?c[r]+=i:c[++r]=i),c.length<2?l[0]?lp(l[0].x):cp(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 Kt(e,t){var n=typeof t,s;return t==null||n==="boolean"?ko(t):(n==="number"?He:n==="string"?(s=xt(t))?(t=s,Wn):ja:t instanceof xt?Wn:t instanceof Date?ip:op(t)?sp:Array.isArray(t)?rp:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?ap:He)(e,t)}var br=180/Math.PI,Ws={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ka(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)*br,skewX:Math.atan(l)*br,scaleX:r,scaleY:c}}var kn;function dp(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Ws:ka(t.a,t.b,t.c,t.d,t.e,t.f)}function up(e){return e==null||(kn||(kn=document.createElementNS("http://www.w3.org/2000/svg","g")),kn.setAttribute("transform",e),!(e=kn.transform.baseVal.consolidate()))?Ws:(e=e.matrix,ka(e.a,e.b,e.c,e.d,e.e,e.f))}function Ea(e,t,n,s){function o(d){return d.length?d.pop()+" ":""}function i(d,u,f,h,m,p){if(d!==f||u!==h){var w=m.push("translate(",null,t,null,n);p.push({i:w-4,x:He(d,f)},{i:w-2,x:He(u,h)})}else(f||h)&&m.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:He(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:He(d,u)}):u&&f.push(o(f)+"skewX("+u+s)}function l(d,u,f,h,m,p){if(d!==f||u!==h){var w=m.push(o(m)+"scale(",null,",",null,")");p.push({i:w-4,x:He(d,f)},{i:w-2,x:He(u,h)})}else(f!==1||h!==1)&&m.push(o(m)+"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(m){for(var p=-1,w=h.length,y;++p<w;)f[(y=h[p]).i]=y.x(m);return f.join("")}}}var fp=Ea(dp,"px, ","px)","deg)"),hp=Ea(up,", ",")",")"),pp=1e-12;function Nr(e){return((e=Math.exp(e))+1/e)/2}function mp(e){return((e=Math.exp(e))-1/e)/2}function gp(e){return((e=Math.exp(2*e))-1)/(e+1)}const Pn=(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],m=u-c,p=f-l,w=m*m+p*p,y,x;if(w<pp)x=Math.log(h/d)/t,y=function(S){return[c+S*m,l+S*p,d*Math.exp(t*S*x)]};else{var N=Math.sqrt(w),g=(h*h-d*d+s*w)/(2*d*n*N),v=(h*h-d*d-s*w)/(2*h*n*N),E=Math.log(Math.sqrt(g*g+1)-g),j=Math.log(Math.sqrt(v*v+1)-v);x=(j-E)/t,y=function(S){var $=S*x,R=Nr(E),V=d/(n*N)*(R*gp(t*$+E)-mp(E));return[c+V*m,l+V*p,d*R/Nr(t*$+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 It=0,qt=0,Yt=0,Ca=1e3,Yn,Zt,Xn=0,yt=0,us=0,nn=typeof performance=="object"&&performance.now?performance:Date,Sa=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Eo(){return yt||(Sa(xp),yt=nn.now()+us)}function xp(){yt=0}function qn(){this._call=this._time=this._next=null}qn.prototype=_a.prototype={constructor:qn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Eo():+n)+(t==null?0:+t),!this._next&&Zt!==this&&(Zt?Zt._next=this:Yn=this,Zt=this),this._call=e,this._time=n,Ys()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ys())}};function _a(e,t,n){var s=new qn;return s.restart(e,t,n),s}function yp(){Eo(),++It;for(var e=Yn,t;e;)(t=yt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--It}function jr(){yt=(Xn=nn.now())+us,It=qt=0;try{yp()}finally{It=0,vp(),yt=0}}function wp(){var e=nn.now(),t=e-Xn;t>Ca&&(us-=t,Xn=e)}function vp(){for(var e,t=Yn,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:Yn=n);Zt=e,Ys(s)}function Ys(e){if(!It){qt&&(qt=clearTimeout(qt));var t=e-yt;t>24?(e<1/0&&(qt=setTimeout(jr,e-nn.now()-us)),Yt&&(Yt=clearInterval(Yt))):(Yt||(Xn=nn.now(),Yt=setInterval(wp,Ca)),It=1,Sa(jr))}}function kr(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 bp=ls("start","end","cancel","interrupt"),Np=[],Ia=0,Er=1,Xs=2,zn=3,Cr=4,qs=5,Tn=6;function fs(e,t,n,s,o,i){var r=e.__transition;if(!r)e.__transition={};else if(n in r)return;jp(e,n,{name:t,index:s,group:o,on:bp,tween:Np,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Ia})}function Co(e,t){var n=Oe(e,t);if(n.state>Ia)throw new Error("too late; already scheduled");return n}function Ye(e,t){var n=Oe(e,t);if(n.state>zn)throw new Error("too late; already running");return n}function Oe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function jp(e,t,n){var s=e.__transition,o;s[t]=n,n.timer=_a(i,0,n.time);function i(d){n.state=Er,n.timer.restart(r,n.delay,n.time),n.delay<=d&&r(d-n.delay)}function r(d){var u,f,h,m;if(n.state!==Er)return l();for(u in s)if(m=s[u],m.name===n.name){if(m.state===zn)return kr(r);m.state===Cr?(m.state=Tn,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete s[u]):+u<t&&(m.state=Tn,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete s[u])}if(kr(function(){n.state===zn&&(n.state=Cr,n.timer.restart(c,n.delay,n.time),c(d))}),n.state=Xs,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Xs){for(n.state=zn,o=new Array(h=n.tween.length),u=0,f=-1;u<h;++u)(m=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(o[++f]=m);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=qs,1),f=-1,h=o.length;++f<h;)o[f].call(e,u);n.state===qs&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=Tn,n.timer.stop(),delete s[t];for(var d in s)return;delete e.__transition}}function On(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>Xs&&s.state<qs,s.state=Tn,s.timer.stop(),s.on.call(o?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[r]}i&&delete e.__transition}}function kp(e){return this.each(function(){On(this,e)})}function Ep(e,t){var n,s;return function(){var o=Ye(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 Cp(e,t,n){var s,o;if(typeof n!="function")throw new Error;return function(){var i=Ye(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 Sp(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=Oe(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?Ep:Cp)(n,e,t))}function So(e,t,n){var s=e._id;return e.each(function(){var o=Ye(this,s);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return Oe(o,s).value[t]}}function Ma(e,t){var n;return(typeof t=="number"?He:t instanceof xt?Wn:(n=xt(t))?(t=n,Wn):ja)(e,t)}function _p(e){return function(){this.removeAttribute(e)}}function Ip(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Mp(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 $p(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 Ap(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 Rp(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 Dp(e,t){var n=ds(e),s=n==="transform"?hp:Ma;return this.attrTween(e,typeof t=="function"?(n.local?Rp:Ap)(n,s,So(this,"attr."+e,t)):t==null?(n.local?Ip:_p)(n):(n.local?$p:Mp)(n,s,t))}function Pp(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 Tp(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 Op(e,t){var n,s;function o(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&Pp(e,i)),n}return o._value=t,o}function Lp(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=ds(e);return this.tween(n,(s.local?Tp:Op)(s,t))}function Hp(e,t){return function(){Co(this,e).delay=+t.apply(this,arguments)}}function Vp(e,t){return t=+t,function(){Co(this,e).delay=t}}function Fp(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Hp:Vp)(t,e)):Oe(this.node(),t).delay}function Bp(e,t){return function(){Ye(this,e).duration=+t.apply(this,arguments)}}function Wp(e,t){return t=+t,function(){Ye(this,e).duration=t}}function Yp(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Bp:Wp)(t,e)):Oe(this.node(),t).duration}function Xp(e,t){if(typeof t!="function")throw new Error;return function(){Ye(this,e).ease=t}}function qp(e){var t=this._id;return arguments.length?this.each(Xp(t,e)):Oe(this.node(),t).ease}function Zp(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ye(this,e).ease=n}}function Gp(e){if(typeof e!="function")throw new Error;return this.each(Zp(this._id,e))}function Up(e){typeof e!="function"&&(e=aa(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var i=t[o],r=i.length,c=s[o]=[],l,d=0;d<r;++d)(l=i[d])&&e.call(l,l.__data__,d,i)&&c.push(l);return new Qe(s,this._parents,this._name,this._id)}function Kp(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,m=0;m<u;++m)(h=l[m]||d[m])&&(f[m]=h);for(;c<s;++c)r[c]=t[c];return new Qe(r,this._parents,this._name,this._id)}function Qp(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 Jp(e,t,n){var s,o,i=Qp(t)?Co:Ye;return function(){var r=i(this,e),c=r.on;c!==s&&(o=(s=c).copy()).on(t,n),r.on=o}}function em(e,t){var n=this._id;return arguments.length<2?Oe(this.node(),n).on.on(e):this.each(Jp(n,e,t))}function tm(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function nm(){return this.on("end.remove",tm(this._id))}function sm(e){var t=this._name,n=this._id;typeof e!="function"&&(e=bo(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,fs(d[h],t,n,h,d,Oe(u,n)));return new Qe(i,this._parents,t,n)}function om(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ia(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),m,p=Oe(u,n),w=0,y=h.length;w<y;++w)(m=h[w])&&fs(m,t,n,w,h,p);i.push(h),r.push(u)}return new Qe(i,r,t,n)}var rm=hn.prototype.constructor;function im(){return new rm(this._groups,this._parents)}function am(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 $a(e){return function(){this.style.removeProperty(e)}}function cm(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 lm(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 dm(e,t){var n,s,o,i="style."+t,r="end."+i,c;return function(){var l=Ye(this,e),d=l.on,u=l.value[i]==null?c||(c=$a(t)):void 0;(d!==n||o!==u)&&(s=(n=d).copy()).on(r,o=u),l.on=s}}function um(e,t,n){var s=(e+="")=="transform"?fp:Ma;return t==null?this.styleTween(e,am(e,s)).on("end.style."+e,$a(e)):typeof t=="function"?this.styleTween(e,lm(e,s,So(this,"style."+e,t))).each(dm(this._id,e)):this.styleTween(e,cm(e,s,t),n).on("end.style."+e,null)}function fm(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function hm(e,t,n){var s,o;function i(){var r=t.apply(this,arguments);return r!==o&&(s=(o=r)&&fm(e,r,n)),s}return i._value=t,i}function pm(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,hm(e,t,n??""))}function mm(e){return function(){this.textContent=e}}function gm(e){return function(){var t=e(this);this.textContent=t??""}}function xm(e){return this.tween("text",typeof e=="function"?gm(So(this,"text",e)):mm(e==null?"":e+""))}function ym(e){return function(t){this.textContent=e.call(this,t)}}function wm(e){var t,n;function s(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&ym(o)),t}return s._value=e,s}function vm(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,wm(e))}function bm(){for(var e=this._name,t=this._id,n=Aa(),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=Oe(l,t);fs(l,e,n,d,r,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Qe(s,this._parents,e,n)}function Nm(){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=Ye(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 jm=0;function Qe(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function Aa(){return++jm}var Ge=hn.prototype;Qe.prototype={constructor:Qe,select:sm,selectAll:om,selectChild:Ge.selectChild,selectChildren:Ge.selectChildren,filter:Up,merge:Kp,selection:im,transition:bm,call:Ge.call,nodes:Ge.nodes,node:Ge.node,size:Ge.size,empty:Ge.empty,each:Ge.each,on:em,attr:Dp,attrTween:Lp,style:um,styleTween:pm,text:xm,textTween:vm,remove:nm,tween:Sp,delay:Fp,duration:Yp,ease:qp,easeVarying:Gp,end:Nm,[Symbol.iterator]:Ge[Symbol.iterator]};function km(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Em={time:null,delay:0,duration:250,ease:km};function Cm(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 Sm(e){var t,n;e instanceof Qe?(t=e._id,e=e._name):(t=Aa(),(n=Em).time=Eo(),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])&&fs(l,e,t,d,r,n||Cm(l,t));return new Qe(s,this._parents,e,t)}hn.prototype.interrupt=kp;hn.prototype.transition=Sm;const En=e=>()=>e;function _m(e,{sourceEvent:t,target:n,transform:s,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:o}})}function Ke(e,t,n){this.k=e,this.x=t,this.y=n}Ke.prototype={constructor:Ke,scale:function(e){return e===1?this:new Ke(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ke(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var hs=new Ke(1,0,0);Ra.prototype=Ke.prototype;function Ra(e){for(;!e.__zoom;)if(!(e=e.parentNode))return hs;return e.__zoom}function Ss(e){e.stopImmediatePropagation()}function Xt(e){e.preventDefault(),e.stopImmediatePropagation()}function Im(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Mm(){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 Sr(){return this.__zoom||hs}function $m(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Am(){return navigator.maxTouchPoints||"ontouchstart"in this}function Rm(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 Da(){var e=Im,t=Mm,n=Rm,s=$m,o=Am,i=[0,1/0],r=[[-1/0,-1/0],[1/0,1/0]],c=250,l=Pn,d=ls("start","zoom","end"),u,f,h,m=500,p=150,w=0,y=10;function x(b){b.property("__zoom",Sr).on("wheel.zoom",$,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",V).filter(o).on("touchstart.zoom",A).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",_).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(b,C,I,M){var D=b.selection?b.selection():b;D.property("__zoom",Sr),b!==D?E(b,C,I,M):D.interrupt().each(function(){j(this,arguments).event(M).start().zoom(null,typeof C=="function"?C.apply(this,arguments):C).end()})},x.scaleBy=function(b,C,I,M){x.scaleTo(b,function(){var D=this.__zoom.k,P=typeof C=="function"?C.apply(this,arguments):C;return D*P},I,M)},x.scaleTo=function(b,C,I,M){x.transform(b,function(){var D=t.apply(this,arguments),P=this.__zoom,H=I==null?v(D):typeof I=="function"?I.apply(this,arguments):I,L=P.invert(H),F=typeof C=="function"?C.apply(this,arguments):C;return n(g(N(P,F),H,L),D,r)},I,M)},x.translateBy=function(b,C,I,M){x.transform(b,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,M)},x.translateTo=function(b,C,I,M,D){x.transform(b,function(){var P=t.apply(this,arguments),H=this.__zoom,L=M==null?v(P):typeof M=="function"?M.apply(this,arguments):M;return n(hs.translate(L[0],L[1]).scale(H.k).translate(typeof C=="function"?-C.apply(this,arguments):-C,typeof I=="function"?-I.apply(this,arguments):-I),P,r)},M,D)};function N(b,C){return C=Math.max(i[0],Math.min(i[1],C)),C===b.k?b:new Ke(C,b.x,b.y)}function g(b,C,I){var M=C[0]-I[0]*b.k,D=C[1]-I[1]*b.k;return M===b.x&&D===b.y?b:new Ke(b.k,M,D)}function v(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function E(b,C,I,M){b.on("start.zoom",function(){j(this,arguments).event(M).start()}).on("interrupt.zoom end.zoom",function(){j(this,arguments).event(M).end()}).tween("zoom",function(){var D=this,P=arguments,H=j(D,P).event(M),L=t.apply(D,P),F=I==null?v(L):typeof I=="function"?I.apply(D,P):I,z=Math.max(L[1][0]-L[0][0],L[1][1]-L[0][1]),W=D.__zoom,Y=typeof C=="function"?C.apply(D,P):C,J=l(W.invert(F).concat(z/W.k),Y.invert(F).concat(z/Y.k));return function(U){if(U===1)U=Y;else{var T=J(U),Z=z/T[2];U=new Ke(Z,F[0]-T[0]*Z,F[1]-T[1]*Z)}H.zoom(null,U)}})}function j(b,C,I){return!I&&b.__zooming||new S(b,C)}function S(b,C){this.that=b,this.args=C,this.active=0,this.sourceEvent=null,this.extent=t.apply(b,C),this.taps=0}S.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,C){return this.mouse&&b!=="mouse"&&(this.mouse[1]=C.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=C.invert(this.touch0[0])),this.touch1&&b!=="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(b){var C=Ce(this.that).datum();d.call(b,this.that,new _m(b,{sourceEvent:this.sourceEvent,target:x,transform:this.that.__zoom,dispatch:d}),C)}};function $(b,...C){if(!e.apply(this,arguments))return;var I=j(this,C).event(b),M=this.__zoom,D=Math.max(i[0],Math.min(i[1],M.k*Math.pow(2,s.apply(this,arguments)))),P=Me(b);if(I.wheel)(I.mouse[0][0]!==P[0]||I.mouse[0][1]!==P[1])&&(I.mouse[1]=M.invert(I.mouse[0]=P)),clearTimeout(I.wheel);else{if(M.k===D)return;I.mouse=[P,M.invert(P)],On(this),I.start()}Xt(b),I.wheel=setTimeout(H,p),I.zoom("mouse",n(g(N(M,D),I.mouse[0],I.mouse[1]),I.extent,r));function H(){I.wheel=null,I.end()}}function R(b,...C){if(h||!e.apply(this,arguments))return;var I=b.currentTarget,M=j(this,C,!0).event(b),D=Ce(b.view).on("mousemove.zoom",F,!0).on("mouseup.zoom",z,!0),P=Me(b,I),H=b.clientX,L=b.clientY;xa(b.view),Ss(b),M.mouse=[P,this.__zoom.invert(P)],On(this),M.start();function F(W){if(Xt(W),!M.moved){var Y=W.clientX-H,J=W.clientY-L;M.moved=Y*Y+J*J>w}M.event(W).zoom("mouse",n(g(M.that.__zoom,M.mouse[0]=Me(W,I),M.mouse[1]),M.extent,r))}function z(W){D.on("mousemove.zoom mouseup.zoom",null),ya(W.view,M.moved),Xt(W),M.event(W).end()}}function V(b,...C){if(e.apply(this,arguments)){var I=this.__zoom,M=Me(b.changedTouches?b.changedTouches[0]:b,this),D=I.invert(M),P=I.k*(b.shiftKey?.5:2),H=n(g(N(I,P),M,D),t.apply(this,C),r);Xt(b),c>0?Ce(this).transition().duration(c).call(E,H,M,b):Ce(this).call(x.transform,H,M,b)}}function A(b,...C){if(e.apply(this,arguments)){var I=b.touches,M=I.length,D=j(this,C,b.changedTouches.length===M).event(b),P,H,L,F;for(Ss(b),H=0;H<M;++H)L=I[H],F=Me(L,this),F=[F,this.__zoom.invert(F),L.identifier],D.touch0?!D.touch1&&D.touch0[2]!==F[2]&&(D.touch1=F,D.taps=0):(D.touch0=F,P=!0,D.taps=1+!!u);u&&(u=clearTimeout(u)),P&&(D.taps<2&&(f=F[0],u=setTimeout(function(){u=null},m)),On(this),D.start())}}function O(b,...C){if(this.__zooming){var I=j(this,C).event(b),M=b.changedTouches,D=M.length,P,H,L,F;for(Xt(b),P=0;P<D;++P)H=M[P],L=Me(H,this),I.touch0&&I.touch0[2]===H.identifier?I.touch0[0]=L:I.touch1&&I.touch1[2]===H.identifier&&(I.touch1[0]=L);if(H=I.that.__zoom,I.touch1){var z=I.touch0[0],W=I.touch0[1],Y=I.touch1[0],J=I.touch1[1],U=(U=Y[0]-z[0])*U+(U=Y[1]-z[1])*U,T=(T=J[0]-W[0])*T+(T=J[1]-W[1])*T;H=N(H,Math.sqrt(U/T)),L=[(z[0]+Y[0])/2,(z[1]+Y[1])/2],F=[(W[0]+J[0])/2,(W[1]+J[1])/2]}else if(I.touch0)L=I.touch0[0],F=I.touch0[1];else return;I.zoom("touch",n(g(H,L,F),I.extent,r))}}function _(b,...C){if(this.__zooming){var I=j(this,C).event(b),M=b.changedTouches,D=M.length,P,H;for(Ss(b),h&&clearTimeout(h),h=setTimeout(function(){h=null},m),P=0;P<D;++P)H=M[P],I.touch0&&I.touch0[2]===H.identifier?delete I.touch0:I.touch1&&I.touch1[2]===H.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&&(H=Me(H,this),Math.hypot(f[0]-H[0],f[1]-H[1])<y)){var L=Ce(this).on("dblclick.zoom");L&&L.apply(this,arguments)}}}return x.wheelDelta=function(b){return arguments.length?(s=typeof b=="function"?b:En(+b),x):s},x.filter=function(b){return arguments.length?(e=typeof b=="function"?b:En(!!b),x):e},x.touchable=function(b){return arguments.length?(o=typeof b=="function"?b:En(!!b),x):o},x.extent=function(b){return arguments.length?(t=typeof b=="function"?b:En([[+b[0][0],+b[0][1]],[+b[1][0],+b[1][1]]]),x):t},x.scaleExtent=function(b){return arguments.length?(i[0]=+b[0],i[1]=+b[1],x):[i[0],i[1]]},x.translateExtent=function(b){return arguments.length?(r[0][0]=+b[0][0],r[1][0]=+b[1][0],r[0][1]=+b[0][1],r[1][1]=+b[1][1],x):[[r[0][0],r[0][1]],[r[1][0],r[1][1]]]},x.constrain=function(b){return arguments.length?(n=b,x):n},x.duration=function(b){return arguments.length?(c=+b,x):c},x.interpolate=function(b){return arguments.length?(l=b,x):l},x.on=function(){var b=d.on.apply(d,arguments);return b===d?x:b},x.clickDistance=function(b){return arguments.length?(w=(b=+b)*b,x):Math.sqrt(w)},x.tapDistance=function(b){return arguments.length?(y=+b,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]],Pa=["Enter"," ","Escape"],za={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Mt;(function(e){e.Strict="strict",e.Loose="loose"})(Mt||(Mt={}));var 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 Ta={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var st;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(st||(st={}));var Je;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Je||(Je={}));var q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(q||(q={}));const _r={[q.Left]:q.Right,[q.Right]:q.Left,[q.Top]:q.Bottom,[q.Bottom]:q.Top};function Oa(e){return e===null?null:e?"valid":"invalid"}const La=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,Dm=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),_o=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),mn=(e,t=[0,0])=>{const{width:n,height:s}=Le(e),o=e.origin??t,i=n*o[0],r=s*o[1];return{x:e.position.x-i,y:e.position.y-r}},Pm=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const s=e.reduce((o,i)=>{const r=typeof i=="string";let c=!t.nodeLookup&&!r?i:void 0;return t.nodeLookup&&(c=r?t.nodeLookup.get(i):_o(i)?i:t.nodeLookup.get(i.id)),c?(n=!0,ps(o,Zn(c,t.nodeOrigin))):o},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?ms(s):{x:0,y:0,width:0,height:0}},gn=(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=ps(n,Zn(o)),s=!0)}),s?ms(n):{x:0,y:0,width:0,height:0}},Io=(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:m,selectable:p=!0,hidden:w=!1}=h;if(r&&!p||w)continue;const y=m.width??h.width??h.initialWidth??0,x=m.height??h.height??h.initialHeight??0,{x:N,y:g}=h.internals.positionAbsolute,v=Ba(c,l,d,u,N,g,y,x),E=y*x,j=i&&v>0;(!h.internals.handleBounds||j||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 Tm(e,t){const n=new Map,s=t?.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{let i;if(t?.includeHiddenNodes){const{width:r,height:c}=Le(o);i=r>0&&c>0}else i=!!(o.measured.width&&o.measured.height&&!o.hidden);i&&(!s||s.has(o.id))&&n.set(o.id,o)}),n}async function Om({nodes:e,width:t,height:n,panZoom:s,minZoom:o,maxZoom:i},r){if(e.size===0)return!0;const c=Tm(e,r),l=gn(c),d=$o(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 Ha({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{width:m,height:p}=Le(c);m&&p&&(f=[[l,d],[l+m,d+p]])}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 Lm({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 m=i.has(h.id),p=!m&&h.parentId&&r.find(w=>w.id===h.parentId);(m||p)&&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(p=>p.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 $t=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),wt=(e={x:0,y:0},t,n)=>({x:$t(e.x,t[0][0],t[1][0]-(n?.width??0)),y:$t(e.y,t[0][1],t[1][1]-(n?.height??0))});function Va(e,t,n){const{width:s,height:o}=Le(n),{x:i,y:r}=n.internals.positionAbsolute;return wt(e,[[i,r],[i+s,r+o]],t)}const Ir=(e,t,n)=>e<t?$t(Math.abs(e-t),1,t)/t:e>n?-$t(Math.abs(e-n),1,t)/t:0,Mo=(e,t,n=15,s=40)=>{const o=Ir(e.x,s,t.width-s)*n,i=Ir(e.y,s,t.height-s)*n;return[o,i]},ps=(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)}),Zs=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),ms=({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}=_o(e)?e.internals.positionAbsolute:mn(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}},Zn=(e,t=[0,0])=>{const{x:n,y:s}=_o(e)?e.internals.positionAbsolute:mn(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)}},Fa=(e,t)=>ms(ps(Zs(e),Zs(t))),Ba=(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)},Gn=(e,t)=>Ba(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Mr=e=>Ae(e.width)&&Ae(e.height)&&Ae(e.x)&&Ae(e.y),Ae=e=>!isNaN(e)&&isFinite(e),Wa=(e,t)=>(n,s)=>{},xn=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),yn=({x:e,y:t},[n,s,o],i=!1,r=[1,1])=>{const c={x:(e-n)/o,y:(t-s)/o};return i?xn(c,r):c},At=({x:e,y:t},[n,s,o])=>({x:e*o+n,y:t*o+s});function Nt(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 Hm(e,t,n){if(typeof e=="string"||typeof e=="number"){const s=Nt(e,n),o=Nt(e,t);return{top:s,right:o,bottom:s,left:o,x:o*2,y:s*2}}if(typeof e=="object"){const s=Nt(e.top??e.y??0,n),o=Nt(e.bottom??e.y??0,n),i=Nt(e.left??e.x??0,t),r=Nt(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 Vm(e,t,n,s,o,i){const{x:r,y:c}=At(e,[t,n,s]),{x:l,y:d}=At({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 $o=(e,t,n,s,o,i)=>{const r=Hm(i,t,n),c=(t-r.x)/e.width,l=(n-r.y)/e.height,d=Math.min(c,l),u=$t(d,s,o),f=e.x+e.width/2,h=e.y+e.height/2,m=t/2-f*u,p=n/2-h*u,w=Vm(e,m,p,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:m-y.left+y.right,y:p-y.top+y.bottom,zoom:u}},an=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function vt(e){return e!=null&&e!=="parent"}function Le(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Ya(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Xa(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 $r(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Fm(){let e,t;return{promise:new Promise((s,o)=>{e=s,t=o}),resolve:e,reject:t}}function Bm(e){return{...za,...e||{}}}function Qt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:s,containerBounds:o}){const{x:i,y:r}=Re(e),c=yn({x:i-(o?.left??0),y:r-(o?.top??0)},s),{x:l,y:d}=n?xn(c,t):c;return{xSnapped:l,ySnapped:d,...c}}const Ao=e=>({width:e.offsetWidth,height:e.offsetHeight}),qa=e=>e?.getRootNode?.()||window?.document,Wm=["INPUT","SELECT","TEXTAREA"];function Za(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:Wm.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Ga=e=>"clientX"in e,Re=(e,t)=>{const n=Ga(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)}},Ar=(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,...Ao(r)}})};function Ua({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 Cn(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Rr({pos:e,x1:t,y1:n,x2:s,y2:o,c:i}){switch(e){case q.Left:return[t-Cn(t-s,i),n];case q.Right:return[t+Cn(s-t,i),n];case q.Top:return[t,n-Cn(n-o,i)];case q.Bottom:return[t,n+Cn(o-n,i)]}}function Ro({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:s,targetY:o,targetPosition:i=q.Top,curvature:r=.25}){const[c,l]=Rr({pos:n,x1:e,y1:t,x2:s,y2:o,c:r}),[d,u]=Rr({pos:i,x1:s,y1:o,x2:e,y2:t,c:r}),[f,h,m,p]=Ua({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,m,p]}function Ka({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 Ym({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 Xm({sourceNode:e,targetNode:t,width:n,height:s,transform:o}){const i=ps(Zn(e),Zn(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 Gn(r,ms(i))>0}const qm=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`xy-edge__${e}${t||""}-${n}${s||""}`,Zm=(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)),Gm=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",Te.error006()),t;const s=n.getEdgeId||qm;let o;return La(e)?o={...e}:o={...e,id:s(e)},Zm(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function Qa({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[o,i,r,c]=Ka({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,o,i,r,c]}const Dr={[q.Left]:{x:-1,y:0},[q.Right]:{x:1,y:0},[q.Top]:{x:0,y:-1},[q.Bottom]:{x:0,y:1}},Um=({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},Pr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Km({source:e,sourcePosition:t=q.Bottom,target:n,targetPosition:s=q.Top,center:o,offset:i,stepPosition:r}){const c=Dr[t],l=Dr[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=Um({source:d,sourcePosition:t,target:u}),h=f.x!==0?"x":"y",m=f[h];let p=[],w,y;const x={x:0,y:0},N={x:0,y:0},[,,g,v]=Ka({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 $=[{x:w,y:d.y},{x:w,y:u.y}],R=[{x:d.x,y},{x:u.x,y}];c[h]===m?p=h==="x"?$:R:p=h==="x"?R:$}else{const $=[{x:d.x,y:u.y}],R=[{x:u.x,y:d.y}];if(h==="x"?p=c.x===m?R:$:p=c.y===m?$:R,t===s){const b=Math.abs(e[h]-n[h]);if(b<=i){const C=Math.min(i-1,i-b);c[h]===m?x[h]=(d[h]>e[h]?-1:1)*C:N[h]=(u[h]>n[h]?-1:1)*C}}if(t!==s){const b=h==="x"?"y":"x",C=c[h]===l[b],I=d[b]>u[b],M=d[b]<u[b];(c[h]===1&&(!C&&I||C&&M)||c[h]!==1&&(!C&&M||C&&I))&&(p=h==="x"?$:R)}const V={x:d.x+x.x,y:d.y+x.y},A={x:u.x+N.x,y:u.y+N.y},O=Math.max(Math.abs(V.x-p[0].x),Math.abs(A.x-p[0].x)),_=Math.max(Math.abs(V.y-p[0].y),Math.abs(A.y-p[0].y));O>=_?(w=(V.x+A.x)/2,y=p[0].y):(w=p[0].x,y=(V.y+A.y)/2)}const E={x:d.x+x.x,y:d.y+x.y},j={x:u.x+N.x,y:u.y+N.y};return[[e,...E.x!==p[0].x||E.y!==p[0].y?[E]:[],...p,...j.x!==p[p.length-1].x||j.y!==p[p.length-1].y?[j]:[],n],w,y,g,v]}function Qm(e,t,n,s){const o=Math.min(Pr(e,t)/2,Pr(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 Un({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,m,p,w]=Km({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+=Qm(f[x-1],f[x],f[x+1],r);return y+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[y,h,m,p,w]}function zr(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Jm(e){const{sourceNode:t,targetNode:n}=e;if(!zr(t)||!zr(n))return null;const s=t.internals.handleBounds||Tr(t.handles),o=n.internals.handleBounds||Tr(n.handles),i=Or(s?.source??[],e.sourceHandle),r=Or(e.connectionMode===Mt.Strict?o?.target??[]:(o?.target??[]).concat(o?.source??[]),e.targetHandle);if(!i||!r)return e.onError?.("008",Te.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=i?.position||q.Bottom,l=r?.position||q.Top,d=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 Tr(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??Le(e);if(s)return{x:o+r/2,y:i+c/2};switch(t?.position??n){case q.Top:return{x:o+r/2,y:i};case q.Right:return{x:o+r,y:i+c/2};case q.Bottom:return{x:o+r/2,y:i+c};case q.Left:return{x:o,y:i+c/2}}}function Or(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Gs(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function eg(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=Gs(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 Ja=1e3,tg=10,Do={nodeOrigin:[0,0],nodeExtent:sn,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ng={...Do,checkEquality:!0};function Po(e,t){const n={...e};for(const s in t)t[s]!==void 0&&(n[s]=t[s]);return n}function sg(e,t,n){const s=Po(Do,n);for(const o of e.values())if(o.parentId)To(o,e,t,s);else{const i=mn(o,s.nodeOrigin),r=vt(o.extent)?o.extent:s.nodeExtent,c=wt(i,r,Le(o));o.internals.positionAbsolute=c}}function og(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 zo(e){return e==="manual"}function Us(e,t,n,s={}){const o=Po(ng,s),i={i:0},r=new Map(t),c=o?.elevateNodesOnSelect&&!zo(o.zIndexMode)?Ja: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=mn(u,o.nodeOrigin),m=vt(u.extent)?u.extent:o.nodeExtent,p=wt(h,m,Le(u));f={...o.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:p,handleBounds:og(u,f),z:ec(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&&To(f,t,n,s,i),d||=u.selected??!1}return{nodesInitialized:l,hasSelectedNodes:d}}function rg(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 To(e,t,n,s,o){const{elevateNodesOnSelect:i,nodeOrigin:r,nodeExtent:c,zIndexMode:l}=Po(Do,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}rg(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*tg),o&&u.internals.rootParentIndex!==void 0&&(o.i=u.internals.rootParentIndex);const f=i&&!zo(l)?Ja:0,{x:h,y:m,z:p}=ig(e,u,r,c,f,l),{positionAbsolute:w}=e.internals,y=h!==w.x||m!==w.y;(y||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:h,y:m}:w,z:p}})}function ec(e,t,n){const s=Ae(e.zIndex)?e.zIndex:0;return zo(n)?s:s+(e.selected?t:0)}function ig(e,t,n,s,o,i){const{x:r,y:c}=t.internals.positionAbsolute,l=Le(e),d=mn(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=Va(f,l,t));const h=ec(e,o,i),m=t.internals.z??0;return{x:f.x,y:f.y,z:m>=h?m+1:h}}function Oo(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=Fa(l,r.rect);i.set(r.parentId,{expandedRect:d,parent:c})}return i.size>0&&i.forEach(({expandedRect:r,parent:c},l)=>{const d=c.internals.positionAbsolute,u=Le(c),f=c.origin??s,h=r.x<d.x?Math.round(Math.abs(d.x-r.x)):0,m=r.y<d.y?Math.round(Math.abs(d.y-r.y)):0,p=Math.max(u.width,Math.round(r.width)),w=Math.max(u.height,Math.round(r.height)),y=(p-u.width)*f[0],x=(w-u.height)*f[1];(h>0||m>0||y||x)&&(o.push({id:l,type:"position",position:{x:c.position.x-h+y,y:c.position.y-m+x}}),n.get(l)?.forEach(N=>{e.some(g=>g.id===N.id)||o.push({id:N.id,type:"position",position:{x:N.position.x+h,y:N.position.y+m}})})),(u.width<r.width||u.height<r.height||h||m)&&o.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:p+(h?f[0]*h-y:0),height:w+(m?f[1]*m-x:0)}})}),o}function ag(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 m of e.values()){const p=t.get(m.id);if(!p)continue;if(p.hidden){t.set(p.id,{...p,internals:{...p.internals,handleBounds:void 0}}),l=!0;continue}const w=Ao(m.nodeElement),y=p.measured.width!==w.width||p.measured.height!==w.height;if(!!(w.width&&w.height&&(y||!p.internals.handleBounds||m.force))){const N=m.nodeElement.getBoundingClientRect(),g=vt(p.extent)?p.extent:i;let{positionAbsolute:v}=p.internals;if(p.parentId&&p.extent==="parent"){const j=t.get(p.parentId);j&&(v=Va(v,w,j))}else g&&(v=wt(v,g,w));const E={...p,measured:w,internals:{...p.internals,positionAbsolute:v,handleBounds:{source:Ar("source",m.nodeElement,N,f,p.id),target:Ar("target",m.nodeElement,N,f,p.id)}}};t.set(p.id,E),p.parentId&&To(E,t,n,{nodeOrigin:o,zIndexMode:r}),l=!0,y&&(d.push({id:p.id,type:"dimensions",dimensions:w}),p.expandParent&&p.parentId&&h.push({id:p.id,parentId:p.parentId,rect:rn(E,o)}))}}if(h.length>0){const m=Oo(h,t,n,o);d.push(...m)}return{changes:d,updatedInternals:l}}async function cg({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 Lr(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 tc(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}`;Lr("source",l,u,e,o,r),Lr("target",l,d,e,i,c),t.set(s.id,s)}}function nc(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:nc(n,t):!1}function Hr(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 lg(e,t,n,s){const o=new Map;for(const[i,r]of e)if((r.selected||r.id===s)&&(!r.parentId||!nc(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 _s({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 dg({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=xn(i,t);return{x:r.x-i.x,y:r.y-i.y}}function ug({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,m=!1,p=!1,w=null;function y({noDragClassName:N,handleSelector:g,domNode:v,isSelectable:E,nodeId:j,nodeClickDistance:S=0}){h=Ce(v);function $({x:O,y:_}){const{nodeLookup:b,nodeExtent:C,snapGrid:I,snapToGrid:M,nodeOrigin:D,onNodeDrag:P,onSelectionDrag:H,onError:L,updateNodePositions:F}=t();i={x:O,y:_};let z=!1;const W=c.size>1,Y=W&&C?Zs(gn(c)):null,J=W&&M?dg({dragItems:c,snapGrid:I,x:O,y:_}):null;for(const[U,T]of c){if(!b.has(U))continue;let Z={x:O-T.distance.x,y:_-T.distance.y};M&&(Z=J?{x:Math.round(Z.x+J.x),y:Math.round(Z.y+J.y)}:xn(Z,I));let ee=null;if(W&&C&&!T.extent&&Y){const{positionAbsolute:Q}=T.internals,oe=Q.x-Y.x+C[0][0],ie=Q.x+T.measured.width-Y.x2+C[1][0],ce=Q.y-Y.y+C[0][1],ue=Q.y+T.measured.height-Y.y2+C[1][1];ee=[[oe,ce],[ie,ue]]}const{position:te,positionAbsolute:K}=Ha({nodeId:U,nextPosition:Z,nodeLookup:b,nodeExtent:ee||C,nodeOrigin:D,onError:L});z=z||T.position.x!==te.x||T.position.y!==te.y,T.position=te,T.internals.positionAbsolute=K}if(p=p||z,!!z&&(F(c,!0),w&&(s||P||!j&&H))){const[U,T]=_s({nodeId:j,dragItems:c,nodeLookup:b});s?.(w,c,U,T),P?.(w,U,T),j||H?.(w,T)}}async function R(){if(!u)return;const{transform:O,panBy:_,autoPanSpeed:b,autoPanOnNodeDrag:C}=t();if(!C){l=!1,cancelAnimationFrame(r);return}const[I,M]=Mo(d,u,b);(I!==0||M!==0)&&(i.x=(i.x??0)-I/O[2],i.y=(i.y??0)-M/O[2],await _({x:I,y:M})&&$(i)),r=requestAnimationFrame(R)}function V(O){const{nodeLookup:_,multiSelectionActive:b,nodesDraggable:C,transform:I,snapGrid:M,snapToGrid:D,selectNodesOnDrag:P,onNodeDragStart:H,onSelectionDragStart:L,unselectNodesAndEdges:F}=t();f=!0,(!P||!E)&&!b&&j&&(_.get(j)?.selected||F()),E&&P&&j&&e?.(j);const z=Qt(O.sourceEvent,{transform:I,snapGrid:M,snapToGrid:D,containerBounds:u});if(i=z,c=lg(_,C,z,j),c.size>0&&(n||H||!j&&L)){const[W,Y]=_s({nodeId:j,dragItems:c,nodeLookup:_});n?.(O.sourceEvent,c,W,Y),H?.(O.sourceEvent,W,Y),j||L?.(O.sourceEvent,Y)}}const A=wa().clickDistance(S).on("start",O=>{const{domNode:_,nodeDragThreshold:b,transform:C,snapGrid:I,snapToGrid:M}=t();u=_?.getBoundingClientRect()||null,m=!1,p=!1,w=O.sourceEvent,b===0&&V(O),i=Qt(O.sourceEvent,{transform:C,snapGrid:I,snapToGrid:M,containerBounds:u}),d=Re(O.sourceEvent,u)}).on("drag",O=>{const{autoPanOnNodeDrag:_,transform:b,snapGrid:C,snapToGrid:I,nodeDragThreshold:M,nodeLookup:D}=t(),P=Qt(O.sourceEvent,{transform:b,snapGrid:C,snapToGrid:I,containerBounds:u});if(w=O.sourceEvent,(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1||j&&!D.has(j))&&(m=!0),!m){if(!l&&_&&f&&(l=!0,R()),!f){const H=Re(O.sourceEvent,u),L=H.x-d.x,F=H.y-d.y;Math.sqrt(L*L+F*F)>M&&V(O)}(i.x!==P.xSnapped||i.y!==P.ySnapped)&&c&&f&&(d=Re(O.sourceEvent,u),$(P))}}).on("end",O=>{if(!f||m){m&&c.size>0&&t().updateNodePositions(c,!1);return}if(l=!1,f=!1,cancelAnimationFrame(r),c.size>0){const{nodeLookup:_,updateNodePositions:b,onNodeDragStop:C,onSelectionDragStop:I}=t();if(p&&(b(c,!1),p=!1),o||C||!j&&I){const[M,D]=_s({nodeId:j,dragItems:c,nodeLookup:_,dragging:!1});o?.(O.sourceEvent,c,M,D),C?.(O.sourceEvent,M,D),j||I?.(O.sourceEvent,D)}}}).filter(O=>{const _=O.target;return!O.button&&(!N||!Hr(_,`.${N}`,v))&&(!g||Hr(_,g,v))});h.call(A)}function x(){h?.on(".drag",null)}return{update:y,destroy:x}}function fg(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())Gn(o,rn(i))>0&&s.push(i);return s}const hg=250;function pg(e,t,n,s){let o=[],i=1/0;const r=fg(e,n,t+hg);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 sc(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 oc(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function mg(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const rc=()=>!0;function gg(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:m,onConnectStart:p,onConnect:w,onConnectEnd:y,isValidConnection:x=rc,onReconnectEnd:N,updateConnection:g,getTransform:v,getFromHandle:E,autoPanSpeed:j,dragThreshold:S=1,handleDomNode:$}){const R=qa(e.target);let V=0,A;const{x:O,y:_}=Re(e),b=oc(i,$),C=c?.getBoundingClientRect();let I=!1;if(!C||!b)return;const M=sc(o,b,s,l,t);if(!M)return;let D=Re(e,C),P=!1,H=null,L=!1,F=null;function z(){if(!u||!C)return;const[te,K]=Mo(D,C,j);h({x:te,y:K}),V=requestAnimationFrame(z)}const W={...M,nodeId:o,type:b,position:M.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:D,toHandle:null,toPosition:_r[W.position],toNode:null,pointer:D};function T(){I=!0,g(U),p?.(e,{nodeId:o,handleId:s,handleType:b})}S===0&&T();function Z(te){if(!I){const{x:ue,y:xe}=Re(te),Ne=ue-O,Ee=xe-_;if(!(Ne*Ne+Ee*Ee>S*S))return;T()}if(!E()||!W){ee(te);return}const K=v();D=Re(te,C),A=pg(yn(D,K,!1,[1,1]),n,l,W),P||(z(),P=!0);const Q=ic(te,{handle:A,connectionMode:t,fromNodeId:o,fromHandleId:s,fromType:r?"target":"source",isValidConnection:x,doc:R,lib:d,flowId:f,nodeLookup:l});F=Q.handleDomNode,H=Q.connection,L=mg(!!A,Q.isValid);const oe=l.get(o),ie=oe?bt(oe,W,q.Left,!0):U.from,ce={...U,from:ie,isValid:L,to:Q.toHandle&&L?At({x:Q.toHandle.x,y:Q.toHandle.y},K):D,toHandle:Q.toHandle,toPosition:L&&Q.toHandle?Q.toHandle.position:_r[W.position],toNode:Q.toHandle?l.get(Q.toHandle.nodeId):null,pointer:D};g(ce),U=ce}function ee(te){if(!("touches"in te&&te.touches.length>0)){if(I){(A||F)&&H&&L&&w?.(H);const{inProgress:K,...Q}=U,oe={...Q,toPosition:U.toHandle?U.toPosition:null};y?.(te,oe),i&&N?.(te,oe)}m(),cancelAnimationFrame(V),P=!1,L=!1,H=null,F=null,R.removeEventListener("mousemove",Z),R.removeEventListener("mouseup",ee),R.removeEventListener("touchmove",Z),R.removeEventListener("touchend",ee)}}R.addEventListener("mousemove",Z),R.addEventListener("mouseup",ee),R.addEventListener("touchmove",Z),R.addEventListener("touchend",ee)}function ic(e,{handle:t,connectionMode:n,fromNodeId:s,fromHandleId:o,fromType:i,doc:r,lib:c,flowId:l,isValidConnection:d=rc,nodeLookup:u}){const f=i==="target",h=t?r.querySelector(`.${c}-flow__handle[data-id="${l}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:m,y:p}=Re(e),w=r.elementFromPoint(m,p),y=w?.classList.contains(`${c}-flow__handle`)?w:h,x={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const N=oc(void 0,y),g=y.getAttribute("data-nodeid"),v=y.getAttribute("data-handleid"),E=y.classList.contains("connectable"),j=y.classList.contains("connectableend");if(!g||!N)return x;const S={source:f?g:s,sourceHandle:f?v:o,target:f?s:g,targetHandle:f?o:v};x.connection=S;const R=E&&j&&(n===Mt.Strict?f&&N==="source"||!f&&N==="target":g!==s||v!==o);x.isValid=R&&d(S),x.toHandle=sc(g,N,v,u,n,!0)}return x}const Ks={onPointerDown:gg,isValid:ic};function xg({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:m=!1}){const p=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const v=n(),E=g.sourceEvent.ctrlKey&&an()?10:1,j=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*u,S=v[2]*Math.pow(2,j*E);t.scaleTo(S)};let w=[0,0];const y=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(w=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},x=g=>{const v=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const E=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],j=[E[0]-w[0],E[1]-w[1]];w=E;const S=s()*Math.max(v[2],Math.log(v[2]))*(m?-1:1),$={x:v[0]-j[0]*S,y:v[1]-j[1]*S},R=[[0,0],[l,d]];t.setViewportConstrained({x:$.x,y:$.y,zoom:v[2]},R,c)},N=Da().on("start",y).on("zoom",f?x:null).on("zoom.wheel",h?p:null);o.call(N,{})}function r(){o.on("zoom",null)}return{update:i,destroy:r,pointer:Me}}const gs=e=>({x:e.x,y:e.y,zoom:e.k}),Is=({x:e,y:t,zoom:n})=>hs.translate(e,t).scale(n),nt=(e,t)=>e.target.closest(`.${t}`),ac=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),yg=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ms=(e,t=0,n=yg,s=()=>{})=>{const o=typeof t=="number"&&t>0;return o||s(),o?e.transition().duration(t).ease(n).on("end",s):e},cc=e=>{const t=e.ctrlKey&&an()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function wg({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:s,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:r,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:d}){return u=>{if(nt(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(u.ctrlKey&&r){const y=Me(u),x=cc(u),N=f*Math.pow(2,x);s.scaleTo(n,N,y,u);return}const h=u.deltaMode===1?20:1;let m=o===pt.Vertical?0:u.deltaX*h,p=o===pt.Horizontal?0:u.deltaY*h;!an()&&u.shiftKey&&o!==pt.Vertical&&(m=u.deltaY*h,p=0),s.translateBy(n,-(m/f)*i,-(p/f)*i,{internal:!0});const w=gs(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 vg({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(s,o){const i=s.type==="wheel",r=!t&&i&&!s.ctrlKey,c=nt(s,e);if(s.ctrlKey&&i&&c&&s.preventDefault(),r||c)return null;s.preventDefault(),n.call(this,s,o)}}function bg({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return s=>{if(s.sourceEvent?.internal)return;const o=gs(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 Ng({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:s,onPanZoom:o}){return i=>{e.usedRightMouseButton=!!(n&&ac(t,e.mouseButton??0)),i.sourceEvent?.sync||s([i.transform.x,i.transform.y,i.transform.k]),o&&!i.sourceEvent?.internal&&o?.(i.sourceEvent,gs(i.transform))}}function jg({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:s,onPanZoomEnd:o,onPaneContextMenu:i}){return r=>{if(!r.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&ac(t,e.mouseButton??0)&&!e.usedRightMouseButton&&r.sourceEvent&&i(r.sourceEvent),e.usedRightMouseButton=!1,s(!1),o)){const c=gs(r.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o?.(r.sourceEvent,c)},n?150:0)}}}function kg({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:s,panOnDrag:o,panOnScroll:i,zoomOnDoubleClick:r,userSelectionActive:c,noWheelClassName:l,noPanClassName:d,lib:u,connectionInProgress:f}){return h=>{const m=t||n,p=s&&h.ctrlKey,w=h.type==="wheel";if(h.button===1&&h.type==="mousedown"&&(nt(h,`${u}-flow__node`)||nt(h,`${u}-flow__edge`)||nt(h,`${u}-flow__selection`)||nt(h,`${u}-flow__nodesselection`)))return!0;if(!o&&!m&&!i&&!r&&!s||c||f&&!w||nt(h,l)&&w||nt(h,d)&&(!w||i&&w&&!t)||!s&&h.ctrlKey&&w)return!1;if(!s&&h.type==="touchstart"&&h.touches?.length>1)return h.preventDefault(),!1;if(!m&&!i&&!p&&w||!o&&(h.type==="mousedown"||h.type==="touchstart")||Array.isArray(o)&&!o.includes(h.button)&&h.type==="mousedown")return!1;const y=Array.isArray(o)&&o.includes(h.button)||!h.button||h.button<=1;return(!h.ctrlKey||w||e)&&y}}function Eg({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 b=_[0];b&&(f=[[0,0],[b.contentRect.width,b.contentRect.height]])}):null)?.observe(e);const m=Da().extent(()=>f).scaleExtent([t,n]).translateExtent(s),p=Ce(e).call(m);v({x:o.x,y:o.y,zoom:$t(o.zoom,t,n)},[[0,0],[u.width,u.height]],s);const w=p.on("wheel.zoom"),y=p.on("dblclick.zoom");m.wheelDelta(cc);async function x(_,b){return p?new Promise(C=>{m?.interpolate(b?.interpolate==="linear"?Kt:Pn).transform(Ms(p,b?.duration,b?.ease,()=>C(!0)),_)}):!1}function N({noWheelClassName:_,noPanClassName:b,onPaneContextMenu:C,userSelectionActive:I,panOnScroll:M,panOnDrag:D,panOnScrollMode:P,panOnScrollSpeed:H,preventScrolling:L,zoomOnPinch:F,zoomOnScroll:z,zoomOnDoubleClick:W,panActivationKeyPressed:Y=!1,zoomActivationKeyPressed:J,lib:U,onTransformChange:T,connectionInProgress:Z,paneClickDistance:ee,selectionOnDrag:te}){I&&!d.isZoomingOrPanning&&g();const K=M&&!J&&!I;m.clickDistance(te?1/0:!Ae(ee)||ee<0?0:ee);const Q=K?wg({zoomPanValues:d,noWheelClassName:_,d3Selection:p,d3Zoom:m,panOnScrollMode:P,panOnScrollSpeed:H,zoomOnPinch:F,onPanZoomStart:r,onPanZoom:i,onPanZoomEnd:c}):vg({noWheelClassName:_,preventScrolling:L,d3ZoomHandler:w});p.on("wheel.zoom",Q,{passive:!1});const oe=bg({zoomPanValues:d,onDraggingChange:l,onPanZoomStart:r});m.on("start",oe);const ie=Ng({zoomPanValues:d,panOnDrag:D,onPaneContextMenu:!!C,onPanZoom:i,onTransformChange:T});m.on("zoom",ie);const ce=jg({zoomPanValues:d,panOnDrag:D,panOnScroll:M,onPaneContextMenu:C,onPanZoomEnd:c,onDraggingChange:l});m.on("end",ce);const ue=kg({panActivationKeyPressed:Y,zoomActivationKeyPressed:J,panOnDrag:D,zoomOnScroll:z,panOnScroll:M,zoomOnDoubleClick:W,zoomOnPinch:F,userSelectionActive:I,noPanClassName:b,noWheelClassName:_,lib:U,connectionInProgress:Z});m.filter(ue),W?p.on("dblclick.zoom",y):p.on("dblclick.zoom",null)}function g(){m.on("zoom",null)}async function v(_,b,C){const I=Is(_),M=m?.constrain()(I,b,C);return M&&await x(M),M}async function E(_,b){const C=Is(_);return await x(C,b),C}function j(_){if(p){const b=Is(_),C=p.property("__zoom");(C.k!==_.zoom||C.x!==_.x||C.y!==_.y)&&m?.transform(p,b,null,{sync:!0})}}function S(){const _=p?Ra(p.node()):{x:0,y:0,k:1};return{x:_.x,y:_.y,zoom:_.k}}async function $(_,b){return p?new Promise(C=>{m?.interpolate(b?.interpolate==="linear"?Kt:Pn).scaleTo(Ms(p,b?.duration,b?.ease,()=>C(!0)),_)}):!1}async function R(_,b){return p?new Promise(C=>{m?.interpolate(b?.interpolate==="linear"?Kt:Pn).scaleBy(Ms(p,b?.duration,b?.ease,()=>C(!0)),_)}):!1}function V(_){m?.scaleExtent(_)}function A(_){m?.translateExtent(_)}function O(_){const b=!Ae(_)||_<0?0:_;m?.clickDistance(b)}return{update:N,destroy:g,setViewport:E,setViewportConstrained:v,getViewport:S,scaleTo:$,scaleBy:R,setScaleExtent:V,setTranslateExtent:A,syncViewport:j,setClickDistance:O}}var Rt;(function(e){e.Line="line",e.Handle="handle"})(Rt||(Rt={}));function Cg({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 Vr(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),s=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:s,affectsY:o}}function et(e,t){return Math.max(0,t-e)}function tt(e,t){return Math.max(0,e-t)}function Sn(e,t,n){return Math.max(0,t-e,e-n)}function Fr(e,t){return e?!t:t}function Sg(e,t,n,s,o,i,r,c){let{affectsX:l,affectsY:d}=t;const{isHorizontal:u,isVertical:f}=t,h=u&&f,{xSnapped:m,ySnapped:p}=n,{minWidth:w,maxWidth:y,minHeight:x,maxHeight:N}=s,{x:g,y:v,width:E,height:j,aspectRatio:S}=e;let $=Math.floor(u?m-e.pointerX:0),R=Math.floor(f?p-e.pointerY:0);const V=E+(l?-$:$),A=j+(d?-R:R),O=-i[0]*E,_=-i[1]*j;let b=Sn(V,w,y),C=Sn(A,x,N);if(r){let D=0,P=0;l&&$<0?D=et(g+$+O,r[0][0]):!l&&$>0&&(D=tt(g+V+O,r[1][0])),d&&R<0?P=et(v+R+_,r[0][1]):!d&&R>0&&(P=tt(v+A+_,r[1][1])),b=Math.max(b,D),C=Math.max(C,P)}if(c){let D=0,P=0;l&&$>0?D=tt(g+$,c[0][0]):!l&&$<0&&(D=et(g+V,c[1][0])),d&&R>0?P=tt(v+R,c[0][1]):!d&&R<0&&(P=et(v+A,c[1][1])),b=Math.max(b,D),C=Math.max(C,P)}if(o){if(u){const D=Sn(V/S,x,N)*S;if(b=Math.max(b,D),r){let P=0;!l&&!d||l&&!d&&h?P=tt(v+_+V/S,r[1][1])*S:P=et(v+_+(l?$:-$)/S,r[0][1])*S,b=Math.max(b,P)}if(c){let P=0;!l&&!d||l&&!d&&h?P=et(v+V/S,c[1][1])*S:P=tt(v+(l?$:-$)/S,c[0][1])*S,b=Math.max(b,P)}}if(f){const D=Sn(A*S,w,y)/S;if(C=Math.max(C,D),r){let P=0;!l&&!d||d&&!l&&h?P=tt(g+A*S+O,r[1][0])/S:P=et(g+(d?R:-R)*S+O,r[0][0])/S,C=Math.max(C,P)}if(c){let P=0;!l&&!d||d&&!l&&h?P=et(g+A*S,c[1][0])/S:P=tt(g+(d?R:-R)*S,c[0][0])/S,C=Math.max(C,P)}}}R=R+(R<0?C:-C),$=$+($<0?b:-b),o&&(h?V>A*S?R=(Fr(l,d)?-$:$)/S:$=(Fr(l,d)?-R:R)*S:u?(R=$/S,d=l):($=R*S,l=d));const I=l?g+$:g,M=d?v+R:v;return{width:E+(l?-$:$),height:j+(d?-R:R),x:i[0]*$*(l?-1:1)+I,y:i[1]*R*(d?-1:1)+M}}const lc={width:0,height:0,x:0,y:0},_g={...lc,pointerX:0,pointerY:0,aspectRatio:1};function Ig(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 Mg({domNode:e,nodeId:t,getStoreItems:n,onChange:s,onEnd:o}){const i=Ce(e);let r={controlDirection:Vr("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:m,onResize:p,onResizeEnd:w,shouldResize:y}){let x={...lc},N={..._g};r={boundaries:u,resizeDirection:h,keepAspectRatio:f,controlDirection:Vr(d)};let g,v=null,E=[],j,S,$,R=!1;const V=wa().on("start",A=>{const{nodeLookup:O,transform:_,snapGrid:b,snapToGrid:C,nodeOrigin:I,paneDomNode:M}=n();if(g=O.get(t),!g)return;v=M?.getBoundingClientRect()??null;const{xSnapped:D,ySnapped:P}=Qt(A.sourceEvent,{transform:_,snapGrid:b,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},N={...x,pointerX:D,pointerY:P,aspectRatio:x.width/x.height},j=void 0,S=vt(g.extent)?g.extent:void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(j=O.get(g.parentId)),j&&g.extent==="parent"&&(S=[[0,0],[j.measured.width,j.measured.height]]),E=[],$=void 0;for(const[H,L]of O)if(L.parentId===t&&(E.push({id:H,position:{...L.position},extent:L.extent}),L.extent==="parent"||L.expandParent)){const F=Ig(L,g,L.origin??I);$?$=[[Math.min(F[0][0],$[0][0]),Math.min(F[0][1],$[0][1])],[Math.max(F[1][0],$[1][0]),Math.max(F[1][1],$[1][1])]]:$=F}m?.(A,{...x})}).on("drag",A=>{const{transform:O,snapGrid:_,snapToGrid:b,nodeOrigin:C}=n(),I=Qt(A.sourceEvent,{transform:O,snapGrid:_,snapToGrid:b,containerBounds:v}),M=[];if(!g)return;const{x:D,y:P,width:H,height:L}=x,F={},z=g.origin??C,{width:W,height:Y,x:J,y:U}=Sg(N,r.controlDirection,I,r.boundaries,r.keepAspectRatio,z,S,$),T=W!==H,Z=Y!==L,ee=J!==D&&T,te=U!==P&&Z;if(!ee&&!te&&!T&&!Z)return;if((ee||te||z[0]===1||z[1]===1)&&(F.x=ee?J:x.x,F.y=te?U:x.y,x.x=F.x,x.y=F.y,E.length>0)){const ie=J-D,ce=U-P;for(const ue of E)ue.position={x:ue.position.x-ie+z[0]*(W-H),y:ue.position.y-ce+z[1]*(Y-L)},M.push(ue)}if((T||Z)&&(F.width=T&&(!r.resizeDirection||r.resizeDirection==="horizontal")?W:x.width,F.height=Z&&(!r.resizeDirection||r.resizeDirection==="vertical")?Y:x.height,x.width=F.width,x.height=F.height),j&&g.expandParent){const ie=z[0]*(F.width??0);F.x&&F.x<ie&&(x.x=ie,N.x=N.x-(F.x-ie));const ce=z[1]*(F.height??0);F.y&&F.y<ce&&(x.y=ce,N.y=N.y-(F.y-ce))}const K=Cg({width:x.width,prevWidth:H,height:x.height,prevHeight:L,affectsX:r.controlDirection.affectsX,affectsY:r.controlDirection.affectsY}),Q={...x,direction:K};y?.(A,Q)!==!1&&(R=!0,p?.(A,Q),s(F,M))}).on("end",A=>{R&&(w?.(A,{...x}),o?.({...x}),R=!1)});i.call(V)}function l(){i.on(".drag",null)}return{update:c,destroy:l}}var $s={exports:{}},As={},Rs={exports:{}},Ds={};var Br;function $g(){if(Br)return Ds;Br=1;var e=Vi();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 m=h(),p=s({inst:{value:m,getSnapshot:h}}),w=p[0].inst,y=p[1];return i(function(){w.value=m,w.getSnapshot=h,l(w)&&y({inst:w})},[f,m,h]),o(function(){return l(w)&&y({inst:w}),f(function(){l(w)&&y({inst:w})})},[f]),r(m),m}function l(f){var h=f.getSnapshot;f=f.value;try{var m=h();return!n(f,m)}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 Ds.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Ds}var Wr;function Ag(){return Wr||(Wr=1,Rs.exports=$g()),Rs.exports}var Yr;function Rg(){if(Yr)return As;Yr=1;var e=Vi(),t=Ag();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 As.useSyncExternalStoreWithSelector=function(d,u,f,h,m){var p=i(null);if(p.current===null){var w={hasValue:!1,value:null};p.current=w}else w=p.current;p=c(function(){function x(j){if(!N){if(N=!0,g=j,j=h(j),m!==void 0&&w.hasValue){var S=w.value;if(m(S,j))return v=S}return v=j}if(S=v,s(g,j))return S;var $=h(j);return m!==void 0&&m(S,$)?(g=j,S):(g=j,v=$)}var N=!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,m]);var y=o(d,p[0],p[1]);return r(function(){w.hasValue=!0,w.value=y},[y]),l(y),y},As}var Xr;function Dg(){return Xr||(Xr=1,$s.exports=Rg()),$s.exports}var Pg=Dg();const zg=Td(Pg),Tg={},qr=e=>{let t;const n=new Set,s=(u,f)=>{const h=typeof u=="function"?u(t):u;if(!Object.is(h,t)){const m=t;t=f??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(p=>p(t,m))}},o=()=>t,l={setState:s,getState:o,getInitialState:()=>d,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Tg?"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},Og=e=>e?qr(e):qr,{useDebugValue:Lg}=Od,{useSyncExternalStoreWithSelector:Hg}=zg,Vg=e=>e;function dc(e,t=Vg,n){const s=Hg(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Lg(s),s}const Zr=(e,t)=>{const n=Og(e),s=(o,i=t)=>dc(n,o,i);return Object.assign(s,n),s},Fg=(e,t)=>e?Zr(e,t):Zr;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 xs=k.createContext(null),Bg=xs.Provider,uc=Te.error001("react");function se(e,t){const n=k.useContext(xs);if(n===null)throw new Error(uc);return dc(n,e,t)}function le(){const e=k.useContext(xs);if(e===null)throw new Error(uc);return k.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Gr={display:"none"},Wg={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},fc="react-flow__node-desc",hc="react-flow__edge-desc",Yg="react-flow__aria-live",Xg=e=>e.ariaLiveMessage,qg=e=>e.ariaLabelConfig;function Zg({rfId:e}){const t=se(Xg);return a.jsx("div",{id:`${Yg}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Wg,children:t})}function Gg({rfId:e,disableKeyboardA11y:t}){const n=se(qg);return a.jsxs(a.Fragment,{children:[a.jsx("div",{id:`${fc}-${e}`,style:Gr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),a.jsx("div",{id:`${hc}-${e}`,style:Gr,children:n["edge.a11yDescription.default"]}),!t&&a.jsx(Zg,{rfId:e})]})}const rt=k.forwardRef(({position:e="top-left",children:t,className:n,style:s,...o},i)=>{const r=`${e}`.split("-");return a.jsx("div",{className:me(["react-flow__panel",n,...r]),style:s,ref:i,...o,children:t})});rt.displayName="Panel";const Ur="https://reactflow.dev?utm_source=attribution";function Ug({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:a.jsx(rt,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Ur}`,children:a.jsx("a",{href:Ur,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Kg=e=>{const t=[],n=[];for(const[,s]of e.nodeLookup)s.selected&&t.push(s.internals.userNode);for(const[,s]of e.edgeLookup)s.selected&&n.push(s);return{selectedNodes:t,selectedEdges:n}},_n=e=>e.id;function Qg(e,t){return de(e.selectedNodes.map(_n),t.selectedNodes.map(_n))&&de(e.selectedEdges.map(_n),t.selectedEdges.map(_n))}function Jg({onSelectionChange:e}){const t=le(),{selectedNodes:n,selectedEdges:s}=se(Kg,Qg);return k.useEffect(()=>{const o={nodes:n,edges:s};e?.(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,s,e]),null}const ex=e=>!!e.onSelectionChangeHandlers;function tx({onSelectionChange:e}){const t=se(ex);return e||t?a.jsx(Jg,{onSelectionChange:e}):null}const pc=[0,0],nx={x:0,y:0,zoom:1},sx=["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"],Kr=[...sx,"rfId"],ox=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}),Qr={translateExtent:sn,nodeOrigin:pc,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function rx(e){const{setNodes:t,setEdges:n,setMinZoom:s,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:r,reset:c,setDefaultNodesAndEdges:l}=se(ox,de),d=le();k.useEffect(()=>(l(e.defaultNodes,e.defaultEdges),()=>{u.current=Qr,c()}),[]);const u=k.useRef(Qr);return k.useEffect(()=>{for(const f of Kr){const h=e[f],m=u.current[f];h!==m&&(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:Bm(h)}):f==="fitView"?d.setState({fitViewQueued:h}):f==="fitViewOptions"?d.setState({fitViewOptions:h}):d.setState({[f]:h})))}u.current=e},Kr.map(f=>e[f])),null}function Jr(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function ix(e){const[t,n]=k.useState(e==="system"?null:e);return k.useEffect(()=>{if(e!=="system"){n(e);return}const s=Jr(),o=()=>n(s?.matches?"dark":"light");return o(),s?.addEventListener("change",o),()=>{s?.removeEventListener("change",o)}},[e]),t!==null?t:Jr()?.matches?"dark":"light"}const ei=typeof document<"u"?document:null;function cn(e=null,t={target:ei,actInsideInputWithModifier:!0}){const[n,s]=k.useState(!1),o=k.useRef(!1),i=k.useRef(new Set([])),[r,c]=k.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace(/\+/g,`
|
|
3
|
+
`).replace(`
|
|
4
|
+
|
|
5
|
+
`,`
|
|
6
|
+
+`).split(`
|
|
7
|
+
`)),u=d.reduce((f,h)=>f.concat(...h),[]);return[d,u]}return[[],[]]},[e]);return k.useEffect(()=>{const l=t?.target??ei,d=t?.actInsideInputWithModifier??!0;if(e!==null){const u=m=>{if(o.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!o.current||o.current&&!d)&&Za(m))return!1;const w=ni(m.code,c);if(i.current.add(m[w]),ti(r,i.current,!1)){const y=m.composedPath?.()?.[0]||m.target,x=y?.nodeName==="BUTTON"||y?.nodeName==="A";t.preventDefault!==!1&&(o.current||!x)&&m.preventDefault(),s(!0)}},f=m=>{const p=ni(m.code,c);ti(r,i.current,!0)?(s(!1),i.current.clear()):i.current.delete(m[p]),m.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 ti(e,t,n){return e.filter(s=>n||s.length===t.size).some(s=>s.every(o=>t.has(o)))}function ni(e,t){return t.includes(e)?"code":"key"}const ax=()=>{const e=le();return k.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:s}=e.getState();return s?s.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[s,o,i],panZoom:r}=e.getState();return r?(await r.setViewport({x:t.x??s,y:t.y??o,zoom:t.zoom??i},n),!0):!1},getViewport:()=>{const[t,n,s]=e.getState().transform;return{x:t,y:n,zoom:s}},setCenter:async(t,n,s)=>e.getState().setCenter(t,n,s),fitBounds:async(t,n)=>{const{width:s,height:o,minZoom:i,maxZoom:r,panZoom:c}=e.getState(),l=$o(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 yn(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=At(t,n);return{x:r.x+o,y:r.y+i}}}),[])};function mc(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)cx(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 cx(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 ys(e,t){return mc(e,t)}function ws(e,t){return mc(e,t)}function lt(e,t){return{id:e,type:"select",selected:t}}function kt(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 si({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 oi(e){return{id:e.id,type:"remove"}}const lx=Wa();function dx(e,t,n={}){return Gm(e,t,{...n,onError:n.onError??lx})}const ri=e=>Dm(e),ux=e=>La(e);function gc(e){return k.forwardRef(e)}const xc=typeof window<"u"?k.useLayoutEffect:k.useEffect;function ii(e){const[t,n]=k.useState(BigInt(0)),[s]=k.useState(()=>fx(()=>n(o=>o+BigInt(1))));return xc(()=>{const o=s.get();o.length&&(e(o),s.reset())},[t]),s}function fx(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const yc=k.createContext(null);function hx({children:e}){const t=le(),n=k.useCallback(c=>{const{nodes:l=[],setNodes:d,hasDefaultNodes:u,onNodesChange:f,nodeLookup:h,fitViewQueued:m,onNodesChangeMiddlewareMap:p}=t.getState();let w=l;for(const x of c)w=typeof x=="function"?x(w):x;let y=si({items:w,lookup:h});for(const x of p.values())y=x(y);u&&d(w),y.length>0?f?.(y):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:x,nodes:N,setNodes:g}=t.getState();x&&g(N)})},[]),s=ii(n),o=k.useCallback(c=>{const{edges:l=[],setEdges:d,hasDefaultEdges:u,onEdgesChange:f,edgeLookup:h}=t.getState();let m=l;for(const p of c)m=typeof p=="function"?p(m):p;u?d(m):f&&f(si({items:m,lookup:h}))},[]),i=ii(o),r=k.useMemo(()=>({nodeQueue:s,edgeQueue:i}),[]);return a.jsx(yc.Provider,{value:r,children:e})}function px(){const e=k.useContext(yc);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const mx=e=>!!e.panZoom;function Bt(){const e=ax(),t=le(),n=px(),s=se(mx),o=k.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:m}=t.getState(),p=ri(f)?f:h.get(f.id),w=p.parentId?Xa(p.position,p.measured,p.parentId,h,m):p.position,y={...p,position:w,width:p.measured?.width??p.width,height:p.measured?.height??p.height};return rn(y)},d=(f,h,m={replace:!1})=>{r(p=>p.map(w=>{if(w.id===f){const y=typeof h=="function"?h(w):h;return m.replace&&ri(y)?y:{...w,...y}}return w}))},u=(f,h,m={replace:!1})=>{c(p=>p.map(w=>{if(w.id===f){const y=typeof h=="function"?h(w):h;return m.replace&&ux(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(m=>[...m,...h])},addEdges:f=>{const h=Array.isArray(f)?f:[f];n.edgeQueue.push(m=>[...m,...h])},toObject:()=>{const{nodes:f=[],edges:h=[],transform:m}=t.getState(),[p,w,y]=m;return{nodes:f.map(x=>({...x})),edges:h.map(x=>({...x})),viewport:{x:p,y:w,zoom:y}}},deleteElements:async({nodes:f=[],edges:h=[]})=>{const{nodes:m,edges:p,onNodesDelete:w,onEdgesDelete:y,triggerNodeChanges:x,triggerEdgeChanges:N,onDelete:g,onBeforeDelete:v}=t.getState(),{nodes:E,edges:j}=await Lm({nodesToRemove:f,edgesToRemove:h,nodes:m,edges:p,onBeforeDelete:v}),S=j.length>0,$=E.length>0;if(S){const R=j.map(oi);y?.(j),N(R)}if($){const R=E.map(oi);w?.(E),x(R)}return($||S)&&g?.({nodes:E,edges:j}),{deletedNodes:E,deletedEdges:j}},getIntersectingNodes:(f,h=!0,m)=>{const p=Mr(f),w=p?f:l(f),y=m!==void 0;return w?(m||t.getState().nodes).filter(x=>{const N=t.getState().nodeLookup.get(x.id);if(N&&!p&&(x.id===f.id||!N.internals.positionAbsolute))return!1;const g=rn(y?x:N),v=Gn(g,w);return h&&v>0||v>=g.width*g.height||v>=w.width*w.height}):[]},isNodeIntersecting:(f,h,m=!0)=>{const w=Mr(f)?f:l(f);if(!w)return!1;const y=Gn(w,h);return m&&y>0||y>=h.width*h.height||y>=w.width*w.height},updateNode:d,updateNodeData:(f,h,m={replace:!1})=>{d(f,p=>{const w=typeof h=="function"?h(p):h;return m.replace?{...p,data:w}:{...p,data:{...p.data,...w}}},m)},updateEdge:u,updateEdgeData:(f,h,m={replace:!1})=>{u(f,p=>{const w=typeof h=="function"?h(p):h;return m.replace?{...p,data:w}:{...p,data:{...p.data,...w}}},m)},getNodesBounds:f=>{const{nodeLookup:h,nodeOrigin:m}=t.getState();return Pm(f,{nodeLookup:h,nodeOrigin:m})},getHandleConnections:({type:f,id:h,nodeId:m})=>Array.from(t.getState().connectionLookup.get(`${m}-${f}${h?`-${h}`:""}`)?.values()??[]),getNodeConnections:({type:f,handleId:h,nodeId:m})=>Array.from(t.getState().connectionLookup.get(`${m}${f?h?`-${f}-${h}`:`-${f}`:""}`)?.values()??[]),fitView:async f=>{const h=t.getState().fitViewResolver??Fm();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:h}),n.nodeQueue.push(m=>[...m]),h.promise}}},[]);return k.useMemo(()=>({...o,...e,viewportInitialized:s}),[s])}const ai=e=>e.selected,gx=typeof window<"u"?window:void 0;function xx({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=le(),{deleteElements:s}=Bt(),o=cn(e,{actInsideInputWithModifier:!1}),i=cn(t,{target:gx});k.useEffect(()=>{if(o){const{edges:r,nodes:c}=n.getState();s({nodes:c.filter(ai),edges:r.filter(ai)}),n.setState({nodesSelectionActive:!1})}},[o]),k.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function yx(e){const t=le();k.useEffect(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const s=Ao(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 vs={position:"absolute",width:"100%",height:"100%",top:0,left:0},wx=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function vx({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:s=!1,panActivationKeyPressed:o,panOnScrollSpeed:i=.5,panOnScrollMode:r=pt.Free,zoomOnDoubleClick:c=!0,panOnDrag:l=!0,defaultViewport:d,translateExtent:u,minZoom:f,maxZoom:h,zoomActivationKeyCode:m,preventScrolling:p=!0,children:w,noWheelClassName:y,noPanClassName:x,onViewportChange:N,isControlledViewport:g,paneClickDistance:v,selectionOnDrag:E}){const j=le(),S=k.useRef(null),{userSelectionActive:$,lib:R,connectionInProgress:V}=se(wx,de),A=cn(m),O=k.useRef();yx(S);const _=k.useCallback(b=>{N?.({x:b[0],y:b[1],zoom:b[2]}),g||j.setState({transform:b})},[N,g]);return k.useEffect(()=>{if(S.current){O.current=Eg({domNode:S.current,minZoom:f,maxZoom:h,translateExtent:u,viewport:d,onDraggingChange:M=>j.setState(D=>D.paneDragging===M?D:{paneDragging:M}),onPanZoomStart:(M,D)=>{const{onViewportChangeStart:P,onMoveStart:H}=j.getState();H?.(M,D),P?.(D)},onPanZoom:(M,D)=>{const{onViewportChange:P,onMove:H}=j.getState();H?.(M,D),P?.(D)},onPanZoomEnd:(M,D)=>{const{onViewportChangeEnd:P,onMoveEnd:H}=j.getState();H?.(M,D),P?.(D)}});const{x:b,y:C,zoom:I}=O.current.getViewport();return j.setState({panZoom:O.current,transform:[b,C,I],domNode:S.current.closest(".react-flow")}),()=>{O.current?.destroy()}}},[]),k.useEffect(()=>{O.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:s,panActivationKeyPressed:o,panOnScrollSpeed:i,panOnScrollMode:r,zoomOnDoubleClick:c,panOnDrag:l,zoomActivationKeyPressed:A,preventScrolling:p,noPanClassName:x,userSelectionActive:$,noWheelClassName:y,lib:R,onTransformChange:_,connectionInProgress:V,selectionOnDrag:E,paneClickDistance:v})},[e,t,n,s,o,i,r,c,l,A,p,x,$,y,R,_,V,E,v]),a.jsx("div",{className:"react-flow__renderer",ref:S,style:vs,children:w})}const bx=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Nx(){const{userSelectionActive:e,userSelectionRect:t}=se(bx,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 Ps=(e,t)=>n=>{n.target===t.current&&e?.(n)},jx=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function kx({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:m,onPaneMouseLeave:p,children:w}){const y=k.useRef(0),x=le(),{userSelectionActive:N,elementsSelectable:g,dragging:v,panBy:E,autoPanSpeed:j}=se(jx,de),S=g&&(e||N),$=k.useRef(null),R=k.useRef(),V=k.useRef(new Set),A=k.useRef(new Set),O=k.useRef(!1),_=k.useRef(!1),b=k.useRef({x:0,y:0}),C=k.useRef(!1),I=T=>{if(_.current||O.current||x.getState().connection.inProgress){_.current=!1,O.current=!1;return}d?.(T),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},M=T=>{if(Array.isArray(s)&&s?.includes(2)){T.preventDefault();return}u?.(T)},D=f?T=>f(T):void 0,P=T=>{_.current&&(T.stopPropagation(),_.current=!1)},H=T=>{if(T.pointerType==="touch"&&s!==!1&&!t)return;const{domNode:Z,transform:ee}=x.getState();if(R.current=Z?.getBoundingClientRect(),!R.current)return;const te=T.target===$.current;if(!te&&!!T.target.closest(".nokey")||!e||!(r&&te||t)||T.button!==0||!T.isPrimary)return;T.target?.setPointerCapture?.(T.pointerId),_.current=!1;const{x:oe,y:ie}=Re(T.nativeEvent,R.current),ce=yn({x:oe,y:ie},ee);x.setState({userSelectionRect:{width:0,height:0,startX:ce.x,startY:ce.y,x:oe,y:ie}}),te||(T.stopPropagation(),T.preventDefault())};function L(T,Z){const{userSelectionRect:ee}=x.getState();if(!ee)return;const{transform:te,nodeLookup:K,edgeLookup:Q,connectionLookup:oe,triggerNodeChanges:ie,triggerEdgeChanges:ce,defaultEdgeOptions:ue}=x.getState(),xe={x:ee.startX,y:ee.startY},{x:Ne,y:Ee}=At(xe,te),Ie={startX:xe.x,startY:xe.y,x:T<Ne?T:Ne,y:Z<Ee?Z:Ee,width:Math.abs(T-Ne),height:Math.abs(Z-Ee)},Xe=V.current,qe=A.current;V.current=new Set(Io(K,Ie,te,n===on.Partial,!0).map(B=>B.id)),A.current=new Set;const Ze=ue?.selectable??!0;for(const B of V.current){const G=oe.get(B);if(G)for(const{edgeId:ne}of G.values()){const fe=Q.get(ne);fe&&(fe.selectable??Ze)&&A.current.add(ne)}}if(!$r(Xe,V.current)){const B=kt(K,V.current,!0);ie(B)}if(!$r(qe,A.current)){const B=kt(Q,A.current);ce(B)}x.setState({userSelectionRect:Ie,userSelectionActive:!0,nodesSelectionActive:!1})}function F(){if(!o||!R.current)return;const[T,Z]=Mo(b.current,R.current,j);E({x:T,y:Z}).then(ee=>{if(!_.current||!ee){y.current=requestAnimationFrame(F);return}const{x:te,y:K}=b.current;L(te,K),y.current=requestAnimationFrame(F)})}const z=()=>{cancelAnimationFrame(y.current),y.current=0,C.current=!1};k.useEffect(()=>()=>z(),[]);const W=T=>{const{userSelectionRect:Z,transform:ee,resetSelectedElements:te}=x.getState();if(!R.current||!Z)return;const{x:K,y:Q}=Re(T.nativeEvent,R.current);b.current={x:K,y:Q};const oe=At({x:Z.startX,y:Z.startY},ee);if(!_.current){const ie=t?0:i;if(Math.hypot(K-oe.x,Q-oe.y)<=ie)return;te(),c?.(T)}_.current=!0,C.current||(F(),C.current=!0),L(K,Q)},Y=T=>{if(!S){T.target===$.current&&x.getState().connection.inProgress&&(O.current=!0);return}T.button===0&&(T.target?.releasePointerCapture?.(T.pointerId),!N&&T.target===$.current&&x.getState().userSelectionRect&&I?.(T),x.setState({userSelectionActive:!1,userSelectionRect:null}),_.current&&(l?.(T),x.setState({nodesSelectionActive:V.current.size>0})),z())},J=T=>{T.target?.releasePointerCapture?.(T.pointerId),z()},U=s===!0||Array.isArray(s)&&s.includes(0);return a.jsxs("div",{className:me(["react-flow__pane",{draggable:U,dragging:v,selection:e}]),onClick:S?void 0:Ps(I,$),onContextMenu:Ps(M,$),onWheel:Ps(D,$),onPointerEnter:S?void 0:h,onPointerMove:S?W:m,onPointerUp:Y,onPointerCancel:S?J:void 0,onPointerDownCapture:S?H:void 0,onClickCapture:S?P:void 0,onPointerLeave:p,ref:$,style:vs,children:[w,a.jsx(Nx,{})]})}function Qs({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 wc({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:o,isSelectable:i,nodeClickDistance:r}){const c=le(),[l,d]=k.useState(!1),u=k.useRef();return k.useEffect(()=>{if(!t)return u.current=ug({getStoreItems:()=>c.getState(),onNodeMouseDown:f=>{Qs({id:f,store:c,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,c,e]),k.useEffect(()=>{t||!e.current||!u.current||u.current.update({noDragClassName:n,handleSelector:s,domNode:e.current,isSelectable:i,nodeId:o,nodeClickDistance:r})},[n,s,t,i,e,o,r]),l}const Ex=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function vc(){const e=le();return k.useCallback(n=>{const{nodeExtent:s,snapToGrid:o,snapGrid:i,nodesDraggable:r,onError:c,updateNodePositions:l,nodeLookup:d,nodeOrigin:u}=e.getState(),f=new Map,h=Ex(r),m=o?i[0]:5,p=o?i[1]:5,w=n.direction.x*m*n.factor,y=n.direction.y*p*n.factor;for(const[,x]of d){if(!h(x))continue;let N={x:x.internals.positionAbsolute.x+w,y:x.internals.positionAbsolute.y+y};o&&(N=xn(N,i));const{position:g,positionAbsolute:v}=Ha({nodeId:x.id,nextPosition:N,nodeLookup:d,nodeExtent:s,nodeOrigin:u,onError:c});x.position=g,x.internals.positionAbsolute=v,f.set(x.id,x)}l(f)},[])}const Lo=k.createContext(null),Cx=Lo.Provider;Lo.Consumer;const bc=()=>k.useContext(Lo),Sx=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Nc=k.createContext(null);function _x({children:e}){const t=se(Sx,de);return a.jsx(Nc.Provider,{value:t,children:e})}function Ix(){const e=k.useContext(Nc);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const Mx={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},$x=(e,t,n)=>s=>{const{connectionClickStartHandle:o,connectionMode:i,connection:r}=s,{fromHandle:c,toHandle:l,isValid:d}=r;if(!c&&!o)return Mx;const u=l?.nodeId===e&&l?.id===t&&l?.type===n;return{connectingFrom:c?.nodeId===e&&c?.id===t&&c?.type===n,connectingTo:u,clickConnecting:o?.nodeId===e&&o?.id===t&&o?.type===n,isPossibleEndHandle:i===Mt.Strict?c?.type!==n:e!==c?.nodeId||t!==c?.id,connectionInProcess:!!c,clickConnectionInProcess:!!o,valid:u&&d}};function Ax({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},m){const p=r||null,w=e==="target",y=le(),x=bc(),{connectOnClick:N,noPanClassName:g,rfId:v}=Ix(),{connectingFrom:E,connectingTo:j,clickConnecting:S,isPossibleEndHandle:$,connectionInProcess:R,clickConnectionInProcess:V,valid:A}=se($x(x,p,e),de);x||y.getState().onError?.("010",Te.error010());const O=C=>{const{defaultEdgeOptions:I,onConnect:M,hasDefaultEdges:D}=y.getState(),P={...I,...C};if(D){const{edges:H,setEdges:L,onError:F}=y.getState();L(dx(P,H,{onError:F}))}M?.(P),c?.(P)},_=C=>{if(!x)return;const I=Ga(C.nativeEvent);if(o&&(I&&C.button===0||!I)){const M=y.getState();Ks.onPointerDown(C.nativeEvent,{handleDomNode:C.currentTarget,autoPanOnConnect:M.autoPanOnConnect,connectionMode:M.connectionMode,connectionRadius:M.connectionRadius,domNode:M.domNode,nodeLookup:M.nodeLookup,lib:M.lib,isTarget:w,handleId:p,nodeId:x,flowId:M.rfId,panBy:M.panBy,cancelConnection:M.cancelConnection,onConnectStart:M.onConnectStart,onConnectEnd:(...D)=>y.getState().onConnectEnd?.(...D),updateConnection:M.updateConnection,onConnect:O,isValidConnection:n||((...D)=>y.getState().isValidConnection?.(...D)??!0),getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,autoPanSpeed:M.autoPanSpeed,dragThreshold:M.connectionDragThreshold})}I?u?.(C):f?.(C)},b=C=>{const{onClickConnectStart:I,onClickConnectEnd:M,connectionClickStartHandle:D,connectionMode:P,isValidConnection:H,lib:L,rfId:F,nodeLookup:z,connection:W}=y.getState();if(!x||!D&&!o)return;if(!D){I?.(C.nativeEvent,{nodeId:x,handleId:p,handleType:e}),y.setState({connectionClickStartHandle:{nodeId:x,type:e,id:p}});return}const Y=qa(C.target),J=n||H,{connection:U,isValid:T}=Ks.isValid(C.nativeEvent,{handle:{nodeId:x,id:p,type:e},connectionMode:P,fromNodeId:D.nodeId,fromHandleId:D.id||null,fromType:D.type,isValidConnection:J,flowId:F,doc:Y,lib:L,nodeLookup:z});T&&U&&O(U);const Z=structuredClone(W);delete Z.inProgress,Z.toPosition=Z.toHandle?Z.toHandle.position:null,M?.(C,Z),y.setState({connectionClickStartHandle:null})};return a.jsx("div",{"data-handleid":p,"data-nodeid":x,"data-handlepos":t,"data-id":`${v}-${x}-${p}-${e}`,className:me(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",g,d,{source:!w,target:w,connectable:s,connectablestart:o,connectableend:i,clickconnecting:S,connectingfrom:E,connectingto:j,valid:A,connectionindicator:s&&(!R||$)&&(R||V?i:o)}]),onMouseDown:_,onTouchStart:_,onClick:N?b:void 0,ref:m,...h,children:l})}const ke=k.memo(gc(Ax));function Rx({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 Dx({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 Px(){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 Kn={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ci={input:Rx,default:Dx,output:zx,group:Px};function Tx(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 Ox=e=>{const{width:t,height:n,x:s,y:o}=gn(e.nodeLookup,{filter:i=>!!i.selected});return{width:Ae(t)?t:null,height:Ae(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 Lx({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=le(),{width:o,height:i,transformString:r,userSelectionActive:c}=se(Ox,de),l=vc(),d=k.useRef(null);k.useEffect(()=>{n||d.current?.focus({preventScroll:!0})},[n]);const u=!c&&o!==null&&i!==null;if(wc({nodeRef:d,disabled:!u}),!u)return null;const f=e?m=>{const p=s.getState().nodes.filter(w=>w.selected);e(m,p)}:void 0,h=m=>{Object.prototype.hasOwnProperty.call(Kn,m.key)&&(m.preventDefault(),l({direction:Kn[m.key],factor:m.shiftKey?4:1}))};return a.jsx("div",{className:me(["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 li=typeof window<"u"?window:void 0,Hx=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function jc({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:m,multiSelectionKeyCode:p,panActivationKeyCode:w,zoomActivationKeyCode:y,elementsSelectable:x,zoomOnScroll:N,zoomOnPinch:g,panOnScroll:v,panOnScrollSpeed:E,panOnScrollMode:j,zoomOnDoubleClick:S,panOnDrag:$,autoPanOnSelection:R,defaultViewport:V,translateExtent:A,minZoom:O,maxZoom:_,preventScrolling:b,onSelectionContextMenu:C,noWheelClassName:I,noPanClassName:M,disableKeyboardA11y:D,onViewportChange:P,isControlledViewport:H}){const{nodesSelectionActive:L,userSelectionActive:F}=se(Hx,de),z=cn(d,{target:li}),W=cn(w,{target:li}),Y=W||$,J=W||v,U=u&&Y!==!0,T=z||F||U;return xx({deleteKeyCode:l,multiSelectionKeyCode:p}),a.jsx(vx,{onPaneContextMenu:i,elementsSelectable:x,zoomOnScroll:N,zoomOnPinch:g,panOnScroll:J,panActivationKeyPressed:W,panOnScrollSpeed:E,panOnScrollMode:j,zoomOnDoubleClick:S,panOnDrag:!z&&Y,defaultViewport:V,translateExtent:A,minZoom:O,maxZoom:_,zoomActivationKeyCode:y,preventScrolling:b,noWheelClassName:I,noPanClassName:M,onViewportChange:P,isControlledViewport:H,paneClickDistance:c,selectionOnDrag:U,children:a.jsxs(kx,{onSelectionStart:h,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:r,panOnDrag:Y,autoPanOnSelection:R,isSelecting:!!T,selectionMode:f,selectionKeyPressed:z,paneClickDistance:c,selectionOnDrag:U,children:[e,L&&a.jsx(Lx,{onSelectionContextMenu:C,noPanClassName:M,disableKeyboardA11y:D})]})})}jc.displayName="FlowRenderer";const Vx=k.memo(jc),Fx=e=>t=>e?Io(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 Bx(e){return se(k.useCallback(Fx(e),[e]),de)}const Wx=e=>e.updateNodeInternals;function Yx(){const e=se(Wx),[t]=k.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const s=new Map;n.forEach(o=>{const i=o.target.getAttribute("data-id");s.set(i,{id:i,nodeElement:o.target,force:!0})}),e(s)}));return k.useEffect(()=>()=>{t?.disconnect()},[t]),t}function Xx({node:e,nodeType:t,hasDimensions:n,resizeObserver:s}){const o=le(),i=k.useRef(null),r=k.useRef(null),c=k.useRef(e.sourcePosition),l=k.useRef(e.targetPosition),d=k.useRef(t),u=n&&!!e.internals.handleBounds;return k.useEffect(()=>{i.current&&!e.hidden&&(!u||r.current!==i.current)&&(r.current&&s?.unobserve(r.current),s?.observe(i.current),r.current=i.current)},[u,e.hidden]),k.useEffect(()=>()=>{r.current&&(s?.unobserve(r.current),r.current=null)},[]),k.useEffect(()=>{if(i.current){const f=d.current!==t,h=c.current!==e.sourcePosition,m=l.current!==e.targetPosition;(f||h||m)&&(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 qx({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:m,disableKeyboardA11y:p,rfId:w,nodeTypes:y,nodeClickDistance:x,onError:N}){const{node:g,internals:v,isParent:E}=se(T=>{const Z=T.nodeLookup.get(e),ee=T.parentLookup.has(e);return{node:Z,internals:Z.internals,isParent:ee}},de);let j=g.type||"default",S=y?.[j]||ci[j];S===void 0&&(N?.("003",Te.error003(j)),j="default",S=y?.default||ci.default);const $=!!(g.draggable||c&&typeof g.draggable>"u"),R=!!(g.selectable||l&&typeof g.selectable>"u"),V=!!(g.connectable||d&&typeof g.connectable>"u"),A=!!(g.focusable||u&&typeof g.focusable>"u"),O=le(),_=Ya(g),b=Xx({node:g,nodeType:j,hasDimensions:_,resizeObserver:f}),C=wc({nodeRef:b,disabled:g.hidden||!$,noDragClassName:h,handleSelector:g.dragHandle,nodeId:e,isSelectable:R,nodeClickDistance:x}),I=vc();if(g.hidden)return null;const M=Le(g),D=Tx(g),P=R||$||t||n||s||o,H=n?T=>n(T,{...v.userNode}):void 0,L=s?T=>s(T,{...v.userNode}):void 0,F=o?T=>o(T,{...v.userNode}):void 0,z=i?T=>i(T,{...v.userNode}):void 0,W=r?T=>r(T,{...v.userNode}):void 0,Y=T=>{const{selectNodesOnDrag:Z,nodeDragThreshold:ee}=O.getState();R&&(!Z||!$||ee>0)&&Qs({id:e,store:O,nodeRef:b}),t&&t(T,{...v.userNode})},J=T=>{if(!(Za(T.nativeEvent)||p)){if(Pa.includes(T.key)&&R){const Z=T.key==="Escape";Qs({id:e,store:O,unselect:Z,nodeRef:b})}else if($&&g.selected&&Object.prototype.hasOwnProperty.call(Kn,T.key)){T.preventDefault();const{ariaLabelConfig:Z}=O.getState();O.setState({ariaLiveMessage:Z["node.a11yDescription.ariaLiveMessage"]({direction:T.key.replace("Arrow","").toLowerCase(),x:~~v.positionAbsolute.x,y:~~v.positionAbsolute.y})}),I({direction:Kn[T.key],factor:T.shiftKey?4:1})}}},U=()=>{if(p||!b.current?.matches(":focus-visible"))return;const{transform:T,width:Z,height:ee,autoPanOnNodeFocus:te,setCenter:K}=O.getState();if(!te)return;Io(new Map([[e,g]]),{x:0,y:0,width:Z,height:ee},T,!0).length>0||K(g.position.x+M.width/2,g.position.y+M.height/2,{zoom:T[2]})};return a.jsx("div",{className:me(["react-flow__node",`react-flow__node-${j}`,{[m]:$},g.className,{selected:g.selected,selectable:R,parent:E,draggable:$,dragging:C}]),ref:b,style:{zIndex:v.z,transform:`translate(${v.positionAbsolute.x}px,${v.positionAbsolute.y}px)`,pointerEvents:P?"all":"none",visibility:_?"visible":"hidden",...g.style,...D},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:H,onMouseMove:L,onMouseLeave:F,onContextMenu:z,onClick:Y,onDoubleClick:W,onKeyDown:A?J:void 0,tabIndex:A?0:void 0,onFocus:A?U:void 0,role:g.ariaRole??(A?"group":void 0),"aria-roledescription":"node","aria-describedby":p?void 0:`${fc}-${w}`,"aria-label":g.ariaLabel,...g.domAttributes,children:a.jsx(Cx,{value:e,children:a.jsx(S,{id:e,data:g.data,type:j,positionAbsoluteX:v.positionAbsolute.x,positionAbsoluteY:v.positionAbsolute.y,selected:g.selected??!1,selectable:R,draggable:$,deletable:g.deletable??!0,isConnectable:V,sourcePosition:g.sourcePosition,targetPosition:g.targetPosition,dragging:C,dragHandle:g.dragHandle,zIndex:v.z,parentId:g.parentId,...M})})})}var Zx=k.memo(qx);const Gx=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function kc(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:s,onError:o}=se(Gx,de),i=Bx(e.onlyRenderVisibleElements),r=Yx();return a.jsx("div",{className:"react-flow__nodes",style:vs,children:i.map(c=>a.jsx(Zx,{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))})}kc.displayName="NodeRenderer";const Ux=k.memo(kc);function Kx(e){return se(k.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const s=[];if(n.width&&n.height)for(const o of n.edges){const i=n.nodeLookup.get(o.source),r=n.nodeLookup.get(o.target);i&&r&&Xm({sourceNode:i,targetNode:r,width:n.width,height:n.height,transform:n.transform})&&s.push(o.id)}return s},[e]),de)}const Qx=({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"})},Jx=({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"})},di={[Je.Arrow]:Qx,[Je.ArrowClosed]:Jx};function e0(e){const t=le();return k.useMemo(()=>Object.prototype.hasOwnProperty.call(di,e)?di[e]:(t.getState().onError?.("009",Te.error009(e)),null),[e])}const t0=({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=e0(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},Ec=({defaultColor:e,rfId:t})=>{const n=se(i=>i.edges),s=se(i=>i.defaultEdgeOptions),o=k.useMemo(()=>eg(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(t0,{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};Ec.displayName="MarkerDefinitions";var n0=k.memo(Ec);function Cc({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]=k.useState({x:1,y:0,width:0,height:0}),m=me(["react-flow__edge-textwrapper",d]),p=k.useRef(null);return k.useEffect(()=>{if(p.current){const w=p.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:m,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:p,style:s,children:n}),l]}):null}Cc.displayName="EdgeText";const s0=k.memo(Cc);function Wt({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:me(["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&&Ae(t)&&Ae(n)?a.jsx(s0,{x:t,y:n,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:r,labelBgPadding:c,labelBgBorderRadius:l}):null]})}function ui({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 Sc({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:s,targetY:o,targetPosition:i=q.Top}){const[r,c]=ui({pos:n,x1:e,y1:t,x2:s,y2:o}),[l,d]=ui({pos:i,x1:s,y1:o,x2:e,y2:t}),[u,f,h,m]=Ua({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,m]}function _c(e){return k.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,sourcePosition:r,targetPosition:c,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:m,style:p,markerEnd:w,markerStart:y,interactionWidth:x})=>{const[N,g,v]=Sc({sourceX:n,sourceY:s,sourcePosition:r,targetX:o,targetY:i,targetPosition:c}),E=e.isInternal?void 0:t;return a.jsx(Wt,{id:E,path:N,labelX:g,labelY:v,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:m,style:p,markerEnd:w,markerStart:y,interactionWidth:x})})}const o0=_c({isInternal:!1}),Ic=_c({isInternal:!0});o0.displayName="SimpleBezierEdge";Ic.displayName="SimpleBezierEdgeInternal";function Mc(e){return k.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,label:r,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:f,style:h,sourcePosition:m=q.Bottom,targetPosition:p=q.Top,markerEnd:w,markerStart:y,pathOptions:x,interactionWidth:N})=>{const[g,v,E]=Un({sourceX:n,sourceY:s,sourcePosition:m,targetX:o,targetY:i,targetPosition:p,borderRadius:x?.borderRadius,offset:x?.offset,stepPosition:x?.stepPosition}),j=e.isInternal?void 0:t;return a.jsx(Wt,{id:j,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:N})})}const $c=Mc({isInternal:!1}),Ac=Mc({isInternal:!0});$c.displayName="SmoothStepEdge";Ac.displayName="SmoothStepEdgeInternal";function Rc(e){return k.memo(({id:t,...n})=>{const s=e.isInternal?void 0:t;return a.jsx($c,{...n,id:s,pathOptions:k.useMemo(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const r0=Rc({isInternal:!1}),Dc=Rc({isInternal:!0});r0.displayName="StepEdge";Dc.displayName="StepEdgeInternal";function Pc(e){return k.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,label:r,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:p,interactionWidth:w})=>{const[y,x,N]=Qa({sourceX:n,sourceY:s,targetX:o,targetY:i}),g=e.isInternal?void 0:t;return a.jsx(Wt,{id:g,path:y,labelX:x,labelY:N,label:r,labelStyle:c,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:f,style:h,markerEnd:m,markerStart:p,interactionWidth:w})})}const i0=Pc({isInternal:!1}),zc=Pc({isInternal:!0});i0.displayName="StraightEdge";zc.displayName="StraightEdgeInternal";function Tc(e){return k.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,sourcePosition:r=q.Bottom,targetPosition:c=q.Top,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:m,style:p,markerEnd:w,markerStart:y,pathOptions:x,interactionWidth:N})=>{const[g,v,E]=Ro({sourceX:n,sourceY:s,sourcePosition:r,targetX:o,targetY:i,targetPosition:c,curvature:x?.curvature}),j=e.isInternal?void 0:t;return a.jsx(Wt,{id:j,path:g,labelX:v,labelY:E,label:l,labelStyle:d,labelShowBg:u,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:m,style:p,markerEnd:w,markerStart:y,interactionWidth:N})})}const a0=Tc({isInternal:!1}),Oc=Tc({isInternal:!0});a0.displayName="BezierEdge";Oc.displayName="BezierEdgeInternal";const fi={default:Oc,straight:zc,step:Dc,smoothstep:Ac,simplebezier:Ic},hi={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},c0=(e,t,n)=>n===q.Left?e-t:n===q.Right?e+t:e,l0=(e,t,n)=>n===q.Top?e-t:n===q.Bottom?e+t:e,pi="react-flow__edgeupdater";function mi({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:me([pi,`${pi}-${c}`]),cx:c0(t,s,e),cy:l0(n,s,e),r:s,stroke:"transparent",fill:"transparent"})}function d0({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:m}){const p=le(),w=(v,E)=>{if(v.button!==0)return;const{autoPanOnConnect:j,domNode:S,connectionMode:$,connectionRadius:R,lib:V,onConnectStart:A,cancelConnection:O,nodeLookup:_,rfId:b,panBy:C,updateConnection:I}=p.getState(),M=E.type==="target",D=(L,F)=>{h(!1),f?.(L,n,E.type,F)},P=L=>d?.(n,L),H=(L,F)=>{h(!0),u?.(v,n,E.type),A?.(L,F)};Ks.onPointerDown(v.nativeEvent,{autoPanOnConnect:j,connectionMode:$,connectionRadius:R,domNode:S,handleId:E.id,nodeId:E.nodeId,nodeLookup:_,isTarget:M,edgeUpdaterType:E.type,lib:V,flowId:b,cancelConnection:O,panBy:C,isValidConnection:(...L)=>p.getState().isValidConnection?.(...L)??!0,onConnect:P,onConnectStart:H,onConnectEnd:(...L)=>p.getState().onConnectEnd?.(...L),onReconnectEnd:D,updateConnection:I,getTransform:()=>p.getState().transform,getFromHandle:()=>p.getState().connection.fromHandle,dragThreshold:p.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"}),N=()=>m(!0),g=()=>m(!1);return a.jsxs(a.Fragment,{children:[(e===!0||e==="source")&&a.jsx(mi,{position:c,centerX:s,centerY:o,radius:t,onMouseDown:y,onMouseEnter:N,onMouseOut:g,type:"source"}),(e===!0||e==="target")&&a.jsx(mi,{position:l,centerX:i,centerY:r,radius:t,onMouseDown:x,onMouseEnter:N,onMouseOut:g,type:"target"})]})}function u0({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:m,rfId:p,edgeTypes:w,noPanClassName:y,onError:x,disableKeyboardA11y:N}){let g=se(K=>K.edgeLookup.get(e));const v=se(K=>K.defaultEdgeOptions);g=v?{...v,...g}:g;let E=g.type||"default",j=w?.[E]||fi[E];j===void 0&&(x?.("011",Te.error011(E)),E="default",j=w?.default||fi.default);const S=!!(g.focusable||t&&typeof g.focusable>"u"),$=typeof f<"u"&&(g.reconnectable||n&&typeof g.reconnectable>"u"),R=!!(g.selectable||s&&typeof g.selectable>"u"),V=k.useRef(null),[A,O]=k.useState(!1),[_,b]=k.useState(!1),C=le(),{zIndex:I=g.zIndex,sourceX:M,sourceY:D,targetX:P,targetY:H,sourcePosition:L,targetPosition:F}=se(k.useCallback(K=>{const Q=K.nodeLookup.get(g.source),oe=K.nodeLookup.get(g.target);if(!Q||!oe)return hi;const ie=Jm({id:e,sourceNode:Q,targetNode:oe,sourceHandle:g.sourceHandle||null,targetHandle:g.targetHandle||null,connectionMode:K.connectionMode,onError:x}),ce=Ym({selected:g.selected,zIndex:g.zIndex,sourceNode:Q,targetNode:oe,elevateOnSelect:K.elevateEdgesOnSelect,zIndexMode:K.zIndexMode});return{...ie||hi,zIndex:ce}},[g.source,g.target,g.sourceHandle,g.targetHandle,g.selected,g.zIndex,x]),de),z=k.useMemo(()=>g.markerStart?`url('#${Gs(g.markerStart,p)}')`:void 0,[g.markerStart,p]),W=k.useMemo(()=>g.markerEnd?`url('#${Gs(g.markerEnd,p)}')`:void 0,[g.markerEnd,p]);if(g.hidden||M===null||D===null||P===null||H===null)return null;const Y=K=>{const{addSelectedEdges:Q,unselectNodesAndEdges:oe,multiSelectionActive:ie}=C.getState();R&&(C.setState({nodesSelectionActive:!1}),g.selected&&ie?(oe({nodes:[],edges:[g]}),V.current?.blur()):Q([e])),o&&o(K,g)},J=i?K=>{i(K,{...g})}:void 0,U=r?K=>{r(K,{...g})}:void 0,T=c?K=>{c(K,{...g})}:void 0,Z=l?K=>{l(K,{...g})}:void 0,ee=d?K=>{d(K,{...g})}:void 0,te=K=>{if(!N&&Pa.includes(K.key)&&R){const{unselectNodesAndEdges:Q,addSelectedEdges:oe}=C.getState();K.key==="Escape"?(V.current?.blur(),Q({edges:[g]})):oe([e])}};return a.jsx("svg",{style:{zIndex:I},children:a.jsxs("g",{className:me(["react-flow__edge",`react-flow__edge-${E}`,g.className,y,{selected:g.selected,animated:g.animated,inactive:!R&&!o,updating:A,selectable:R}]),onClick:Y,onDoubleClick:J,onContextMenu:U,onMouseEnter:T,onMouseMove:Z,onMouseLeave:ee,onKeyDown:S?te:void 0,tabIndex:S?0:void 0,role:g.ariaRole??(S?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":g.ariaLabel===null?void 0:g.ariaLabel||`Edge from ${g.source} to ${g.target}`,"aria-describedby":S?`${hc}-${p}`:void 0,ref:V,...g.domAttributes,children:[!_&&a.jsx(j,{id:e,source:g.source,target:g.target,type:g.type,selected:g.selected,animated:g.animated,selectable:R,deletable:g.deletable??!0,label:g.label,labelStyle:g.labelStyle,labelShowBg:g.labelShowBg,labelBgStyle:g.labelBgStyle,labelBgPadding:g.labelBgPadding,labelBgBorderRadius:g.labelBgBorderRadius,sourceX:M,sourceY:D,targetX:P,targetY:H,sourcePosition:L,targetPosition:F,data:g.data,style:g.style,sourceHandleId:g.sourceHandle,targetHandleId:g.targetHandle,markerStart:z,markerEnd:W,pathOptions:"pathOptions"in g?g.pathOptions:void 0,interactionWidth:g.interactionWidth}),$&&a.jsx(d0,{edge:g,isReconnectable:$,reconnectRadius:u,onReconnect:f,onReconnectStart:h,onReconnectEnd:m,sourceX:M,sourceY:D,targetX:P,targetY:H,sourcePosition:L,targetPosition:F,setUpdateHover:O,setReconnecting:b})]})})}var f0=k.memo(u0);const h0=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Lc({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:m,onReconnectEnd:p,disableKeyboardA11y:w}){const{edgesFocusable:y,edgesReconnectable:x,elementsSelectable:N,onError:g}=se(h0,de),v=Kx(t);return a.jsxs("div",{className:"react-flow__edges",children:[a.jsx(n0,{defaultColor:e,rfId:n}),v.map(E=>a.jsx(f0,{id:E,edgesFocusable:y,edgesReconnectable:x,elementsSelectable:N,noPanClassName:o,onReconnect:i,onContextMenu:r,onMouseEnter:c,onMouseMove:l,onMouseLeave:d,onClick:u,reconnectRadius:f,onDoubleClick:h,onReconnectStart:m,onReconnectEnd:p,rfId:n,onError:g,edgeTypes:s,disableKeyboardA11y:w},E))]})}Lc.displayName="EdgeRenderer";const p0=k.memo(Lc),gi=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function m0({children:e}){const t=le(),n=k.useRef(null),[s]=k.useState(()=>t.getState().transform);return xc(()=>{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=gi(r)))};return i(),t.subscribe(i)},[t]),a.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:gi(s)},children:e})}function g0(e){const t=Bt(),n=k.useRef(!1);k.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const x0=e=>e.panZoom?.syncViewport;function y0(e){const t=se(x0),n=le();return k.useEffect(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function w0(e){return e.connection.inProgress?{...e.connection,to:yn(e.connection.to,e.transform)}:{...e.connection}}function v0(e){return w0}function b0(e){const t=v0();return se(t,de)}const N0=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function j0({containerStyle:e,style:t,type:n,component:s}){const{nodesConnectable:o,width:i,height:r,isValid:c,inProgress:l}=se(N0,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:me(["react-flow__connection",Oa(c)]),children:a.jsx(Hc,{style:t,type:n,CustomComponent:s,isValid:c})})})}const Hc=({style:e,type:t=st.Bezier,CustomComponent:n,isValid:s})=>{const{inProgress:o,from:i,fromNode:r,fromHandle:c,fromPosition:l,to:d,toNode:u,toHandle:f,toPosition:h,pointer:m}=b0();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:Oa(s),toNode:u,toHandle:f,pointer:m});let p="";const w={sourceX:i.x,sourceY:i.y,sourcePosition:l,targetX:d.x,targetY:d.y,targetPosition:h};switch(t){case st.Bezier:[p]=Ro(w);break;case st.SimpleBezier:[p]=Sc(w);break;case st.Step:[p]=Un({...w,borderRadius:0});break;case st.SmoothStep:[p]=Un(w);break;default:[p]=Qa(w)}return a.jsx("path",{d:p,fill:"none",className:"react-flow__connection-path",style:e})};Hc.displayName="ConnectionLine";const k0={};function xi(e=k0){k.useRef(e),le(),k.useEffect(()=>{},[e])}function E0(){le(),k.useRef(!1),k.useEffect(()=>{},[])}function Vc({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:m,connectionLineType:p,connectionLineStyle:w,connectionLineComponent:y,connectionLineContainerStyle:x,selectionKeyCode:N,selectionOnDrag:g,selectionMode:v,multiSelectionKeyCode:E,panActivationKeyCode:j,zoomActivationKeyCode:S,deleteKeyCode:$,onlyRenderVisibleElements:R,elementsSelectable:V,defaultViewport:A,translateExtent:O,minZoom:_,maxZoom:b,preventScrolling:C,defaultMarkerColor:I,zoomOnScroll:M,zoomOnPinch:D,panOnScroll:P,panOnScrollSpeed:H,panOnScrollMode:L,zoomOnDoubleClick:F,panOnDrag:z,autoPanOnSelection:W,onPaneClick:Y,onPaneMouseEnter:J,onPaneMouseMove:U,onPaneMouseLeave:T,onPaneScroll:Z,onPaneContextMenu:ee,paneClickDistance:te,nodeClickDistance:K,onEdgeContextMenu:Q,onEdgeMouseEnter:oe,onEdgeMouseMove:ie,onEdgeMouseLeave:ce,reconnectRadius:ue,onReconnect:xe,onReconnectStart:Ne,onReconnectEnd:Ee,noDragClassName:Ie,noWheelClassName:Xe,noPanClassName:qe,disableKeyboardA11y:Ze,nodeExtent:B,rfId:G,viewport:ne,onViewportChange:fe,nodesDraggable:ae}){return xi(e),xi(t),E0(),g0(n),y0(ne),a.jsx(Vx,{onPaneClick:Y,onPaneMouseEnter:J,onPaneMouseMove:U,onPaneMouseLeave:T,onPaneContextMenu:ee,onPaneScroll:Z,paneClickDistance:te,deleteKeyCode:$,selectionKeyCode:N,selectionOnDrag:g,selectionMode:v,onSelectionStart:h,onSelectionEnd:m,multiSelectionKeyCode:E,panActivationKeyCode:j,zoomActivationKeyCode:S,elementsSelectable:V,zoomOnScroll:M,zoomOnPinch:D,zoomOnDoubleClick:F,panOnScroll:P,panOnScrollSpeed:H,panOnScrollMode:L,panOnDrag:z,autoPanOnSelection:W,defaultViewport:A,translateExtent:O,minZoom:_,maxZoom:b,onSelectionContextMenu:f,preventScrolling:C,noDragClassName:Ie,noWheelClassName:Xe,noPanClassName:qe,disableKeyboardA11y:Ze,onViewportChange:fe,isControlledViewport:!!ne,children:a.jsxs(m0,{children:[a.jsx(p0,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:r,onReconnect:xe,onReconnectStart:Ne,onReconnectEnd:Ee,onlyRenderVisibleElements:R,onEdgeContextMenu:Q,onEdgeMouseEnter:oe,onEdgeMouseMove:ie,onEdgeMouseLeave:ce,reconnectRadius:ue,defaultMarkerColor:I,noPanClassName:qe,disableKeyboardA11y:Ze,rfId:G}),a.jsx(j0,{style:w,type:p,component:y,containerStyle:x}),a.jsx("div",{className:"react-flow__edgelabel-renderer"}),a.jsx(Ux,{nodeTypes:e,onNodeClick:s,onNodeDoubleClick:i,onNodeMouseEnter:c,onNodeMouseMove:l,onNodeMouseLeave:d,onNodeContextMenu:u,nodeClickDistance:K,onlyRenderVisibleElements:R,noPanClassName:qe,noDragClassName:Ie,disableKeyboardA11y:Ze,nodeExtent:B,rfId:G,nodesDraggable:ae}),a.jsx("div",{className:"react-flow__viewport-portal"})]})})}Vc.displayName="GraphView";const C0=k.memo(Vc),S0=Wa(),yi=({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 m=new Map,p=new Map,w=new Map,y=new Map,x=s??t??[],N=n??e??[],g=u??[0,0],v=f??sn;tc(w,y,x);const{nodesInitialized:E}=Us(N,m,p,{nodeOrigin:g,nodeExtent:v,zIndexMode:h});let j=[0,0,1];if(r&&o&&i){const S=gn(m,{filter:A=>!!((A.width||A.initialWidth)&&(A.height||A.initialHeight))}),{x:$,y:R,zoom:V}=$o(S,o,i,l,d,c?.padding??.1);j=[$,R,V]}return{rfId:"1",width:o??0,height:i??0,transform:j,nodes:N,nodesInitialized:E,nodeLookup:m,parentLookup:p,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:Mt.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:g,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:r??!1,fitViewOptions:c,fitViewResolver:null,connection:{...Ta},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:S0,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:za,zIndexMode:h,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},_0=({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})=>Fg((m,p)=>{async function w(){const{nodeLookup:y,panZoom:x,fitViewOptions:N,fitViewResolver:g,width:v,height:E,minZoom:j,maxZoom:S}=p();x&&(await Om({nodes:y,width:v,height:E,panZoom:x,minZoom:j,maxZoom:S},N),g?.resolve(!0),m({fitViewResolver:null}))}return{...yi({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:N,nodeOrigin:g,nodeExtent:v,elevateNodesOnSelect:E,fitViewQueued:j,zIndexMode:S,nodesSelectionActive:$}=p(),{nodesInitialized:R,hasSelectedNodes:V}=Us(y,x,N,{nodeOrigin:g,nodeExtent:v,elevateNodesOnSelect:E,checkEquality:!0,zIndexMode:S}),A=$&&V;j&&R?(w(),m({nodes:y,nodesInitialized:R,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:A})):m({nodes:y,nodesInitialized:R,nodesSelectionActive:A})},setEdges:y=>{const{connectionLookup:x,edgeLookup:N}=p();tc(x,N,y),m({edges:y})},setDefaultNodesAndEdges:(y,x)=>{if(y){const{setNodes:N}=p();N(y),m({hasDefaultNodes:!0})}if(x){const{setEdges:N}=p();N(x),m({hasDefaultEdges:!0})}},updateNodeInternals:y=>{const{triggerNodeChanges:x,nodeLookup:N,parentLookup:g,domNode:v,nodeOrigin:E,nodeExtent:j,debug:S,fitViewQueued:$,zIndexMode:R}=p(),{changes:V,updatedInternals:A}=ag(y,N,g,v,E,j,R);A&&(sg(N,g,{nodeOrigin:E,nodeExtent:j,zIndexMode:R}),$?(w(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),V?.length>0&&(S&&console.log("React Flow: trigger node changes",V),x?.(V)))},updateNodePositions:(y,x=!1)=>{const N=[];let g=[];const{nodeLookup:v,triggerNodeChanges:E,connection:j,updateConnection:S,onNodesChangeMiddlewareMap:$}=p();for(const[R,V]of y){const A=v.get(R),O=!!(A?.expandParent&&A?.parentId&&V?.position),_={id:R,type:"position",position:O?{x:Math.max(0,V.position.x),y:Math.max(0,V.position.y)}:V.position,dragging:x};if(A&&j.inProgress&&j.fromNode.id===A.id){const b=bt(A,j.fromHandle,q.Left,!0);S({...j,from:b})}O&&A.parentId&&N.push({id:R,parentId:A.parentId,rect:{...V.internals.positionAbsolute,width:V.measured.width??0,height:V.measured.height??0}}),g.push(_)}if(N.length>0){const{parentLookup:R,nodeOrigin:V}=p(),A=Oo(N,v,R,V);g.push(...A)}for(const R of $.values())g=R(g);E(g)},triggerNodeChanges:y=>{const{onNodesChange:x,setNodes:N,nodes:g,hasDefaultNodes:v,debug:E}=p();if(y?.length){if(v){const j=ys(y,g);N(j)}E&&console.log("React Flow: trigger node changes",y),x?.(y)}},triggerEdgeChanges:y=>{const{onEdgesChange:x,setEdges:N,edges:g,hasDefaultEdges:v,debug:E}=p();if(y?.length){if(v){const j=ws(y,g);N(j)}E&&console.log("React Flow: trigger edge changes",y),x?.(y)}},addSelectedNodes:y=>{const{multiSelectionActive:x,edgeLookup:N,nodeLookup:g,triggerNodeChanges:v,triggerEdgeChanges:E}=p();if(x){const j=y.map(S=>lt(S,!0));v(j);return}v(kt(g,new Set([...y]),!0)),E(kt(N))},addSelectedEdges:y=>{const{multiSelectionActive:x,edgeLookup:N,nodeLookup:g,triggerNodeChanges:v,triggerEdgeChanges:E}=p();if(x){const j=y.map(S=>lt(S,!0));E(j);return}E(kt(N,new Set([...y]))),v(kt(g,new Set,!0))},unselectNodesAndEdges:({nodes:y,edges:x}={})=>{const{edges:N,nodes:g,nodeLookup:v,triggerNodeChanges:E,triggerEdgeChanges:j}=p(),S=y||g,$=x||N,R=[];for(const A of S){if(!A.selected)continue;const O=v.get(A.id);O&&(O.selected=!1),R.push(lt(A.id,!1))}const V=[];for(const A of $)A.selected&&V.push(lt(A.id,!1));E(R),j(V)},setMinZoom:y=>{const{panZoom:x,maxZoom:N}=p();x?.setScaleExtent([y,N]),m({minZoom:y})},setMaxZoom:y=>{const{panZoom:x,minZoom:N}=p();x?.setScaleExtent([N,y]),m({maxZoom:y})},setTranslateExtent:y=>{p().panZoom?.setTranslateExtent(y),m({translateExtent:y})},resetSelectedElements:()=>{const{edges:y,nodes:x,triggerNodeChanges:N,triggerEdgeChanges:g,elementsSelectable:v}=p();if(!v)return;const E=x.reduce((S,$)=>$.selected?[...S,lt($.id,!1)]:S,[]),j=y.reduce((S,$)=>$.selected?[...S,lt($.id,!1)]:S,[]);N(E),g(j)},setNodeExtent:y=>{const{nodes:x,nodeLookup:N,parentLookup:g,nodeOrigin:v,elevateNodesOnSelect:E,nodeExtent:j,zIndexMode:S}=p();y[0][0]===j[0][0]&&y[0][1]===j[0][1]&&y[1][0]===j[1][0]&&y[1][1]===j[1][1]||(Us(x,N,g,{nodeOrigin:v,nodeExtent:y,elevateNodesOnSelect:E,checkEquality:!1,zIndexMode:S}),m({nodeExtent:y}))},panBy:y=>{const{transform:x,width:N,height:g,panZoom:v,translateExtent:E}=p();return cg({delta:y,panZoom:v,transform:x,translateExtent:E,width:N,height:g})},setCenter:async(y,x,N)=>{const{width:g,height:v,maxZoom:E,panZoom:j}=p();if(!j)return!1;const S=typeof N?.zoom<"u"?N.zoom:E;return await j.setViewport({x:g/2-y*S,y:v/2-x*S,zoom:S},{duration:N?.duration,ease:N?.ease,interpolate:N?.interpolate}),!0},cancelConnection:()=>{m({connection:{...Ta}})},updateConnection:y=>{m({connection:y})},reset:()=>m({...yi()})}},Object.is);function Ho({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:m}){const[p]=k.useState(()=>_0({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(Bg,{value:p,children:a.jsx(hx,{children:a.jsx(_x,{children:m})})})}function I0({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:m}){return k.useContext(xs)?a.jsx(a.Fragment,{children:e}):a.jsx(Ho,{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:m,children:e})}const M0={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function $0({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:m,onConnectStart:p,onConnectEnd:w,onClickConnectStart:y,onClickConnectEnd:x,onNodeMouseEnter:N,onNodeMouseMove:g,onNodeMouseLeave:v,onNodeContextMenu:E,onNodeDoubleClick:j,onNodeDragStart:S,onNodeDrag:$,onNodeDragStop:R,onNodesDelete:V,onEdgesDelete:A,onDelete:O,onSelectionChange:_,onSelectionDragStart:b,onSelectionDrag:C,onSelectionDragStop:I,onSelectionContextMenu:M,onSelectionStart:D,onSelectionEnd:P,onBeforeDelete:H,connectionMode:L,connectionLineType:F=st.Bezier,connectionLineStyle:z,connectionLineComponent:W,connectionLineContainerStyle:Y,deleteKeyCode:J="Backspace",selectionKeyCode:U="Shift",selectionOnDrag:T=!1,selectionMode:Z=on.Full,panActivationKeyCode:ee="Space",multiSelectionKeyCode:te=an()?"Meta":"Control",zoomActivationKeyCode:K=an()?"Meta":"Control",snapToGrid:Q,snapGrid:oe,onlyRenderVisibleElements:ie=!1,selectNodesOnDrag:ce,nodesDraggable:ue,autoPanOnNodeFocus:xe,nodesConnectable:Ne,nodesFocusable:Ee,nodeOrigin:Ie=pc,edgesFocusable:Xe,edgesReconnectable:qe,elementsSelectable:Ze=!0,defaultViewport:B=nx,minZoom:G=.5,maxZoom:ne=2,translateExtent:fe=sn,preventScrolling:ae=!0,nodeExtent:ye,defaultMarkerColor:we="#b1b1b7",zoomOnScroll:at=!0,zoomOnPinch:El=!0,panOnScroll:Cl=!1,panOnScrollSpeed:Sl=.5,panOnScrollMode:_l=pt.Free,zoomOnDoubleClick:Il=!0,panOnDrag:Ml=!0,onPaneClick:$l,onPaneMouseEnter:Al,onPaneMouseMove:Rl,onPaneMouseLeave:Dl,onPaneScroll:Pl,onPaneContextMenu:zl,paneClickDistance:Tl=1,nodeClickDistance:Ol=0,children:Ll,onReconnect:Hl,onReconnectStart:Vl,onReconnectEnd:Fl,onEdgeContextMenu:Bl,onEdgeDoubleClick:Wl,onEdgeMouseEnter:Yl,onEdgeMouseMove:Xl,onEdgeMouseLeave:ql,reconnectRadius:Zl=10,onNodesChange:Gl,onEdgesChange:Ul,noDragClassName:Kl="nodrag",noWheelClassName:Ql="nowheel",noPanClassName:er="nopan",fitView:tr,fitViewOptions:nr,connectOnClick:Jl,attributionPosition:ed,proOptions:td,defaultEdgeOptions:nd,elevateNodesOnSelect:sd=!0,elevateEdgesOnSelect:od=!1,disableKeyboardA11y:sr=!1,autoPanOnConnect:rd,autoPanOnNodeDrag:id,autoPanOnSelection:ad=!0,autoPanSpeed:cd,connectionRadius:ld,isValidConnection:dd,onError:ud,style:fd,id:or,nodeDragThreshold:hd,connectionDragThreshold:pd,viewport:md,onViewportChange:gd,width:xd,height:yd,colorMode:wd="light",debug:vd,onScroll:rr,ariaLabelConfig:bd,zIndexMode:ir="basic",...Nd},jd){const js=or||"1",kd=ix(wd),Ed=k.useCallback(ar=>{ar.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),rr?.(ar)},[rr]);return a.jsx("div",{"data-testid":"rf__wrapper",...Nd,onScroll:Ed,style:{...fd,...M0},ref:jd,className:me(["react-flow",o,kd]),id:or,role:"application",children:a.jsxs(I0,{nodes:e,edges:t,width:xd,height:yd,fitView:tr,fitViewOptions:nr,minZoom:G,maxZoom:ne,nodeOrigin:Ie,nodeExtent:ye,zIndexMode:ir,children:[a.jsx(rx,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:m,onConnectStart:p,onConnectEnd:w,onClickConnectStart:y,onClickConnectEnd:x,nodesDraggable:ue,autoPanOnNodeFocus:xe,nodesConnectable:Ne,nodesFocusable:Ee,edgesFocusable:Xe,edgesReconnectable:qe,elementsSelectable:Ze,elevateNodesOnSelect:sd,elevateEdgesOnSelect:od,minZoom:G,maxZoom:ne,nodeExtent:ye,onNodesChange:Gl,onEdgesChange:Ul,snapToGrid:Q,snapGrid:oe,connectionMode:L,translateExtent:fe,connectOnClick:Jl,defaultEdgeOptions:nd,fitView:tr,fitViewOptions:nr,onNodesDelete:V,onEdgesDelete:A,onDelete:O,onNodeDragStart:S,onNodeDrag:$,onNodeDragStop:R,onSelectionDrag:C,onSelectionDragStart:b,onSelectionDragStop:I,onMove:u,onMoveStart:f,onMoveEnd:h,noPanClassName:er,nodeOrigin:Ie,rfId:js,autoPanOnConnect:rd,autoPanOnNodeDrag:id,autoPanSpeed:cd,onError:ud,connectionRadius:ld,isValidConnection:dd,selectNodesOnDrag:ce,nodeDragThreshold:hd,connectionDragThreshold:pd,onBeforeDelete:H,debug:vd,ariaLabelConfig:bd,zIndexMode:ir}),a.jsx(C0,{onInit:d,onNodeClick:c,onEdgeClick:l,onNodeMouseEnter:N,onNodeMouseMove:g,onNodeMouseLeave:v,onNodeContextMenu:E,onNodeDoubleClick:j,nodeTypes:i,edgeTypes:r,connectionLineType:F,connectionLineStyle:z,connectionLineComponent:W,connectionLineContainerStyle:Y,selectionKeyCode:U,selectionOnDrag:T,selectionMode:Z,deleteKeyCode:J,multiSelectionKeyCode:te,panActivationKeyCode:ee,zoomActivationKeyCode:K,onlyRenderVisibleElements:ie,defaultViewport:B,translateExtent:fe,minZoom:G,maxZoom:ne,preventScrolling:ae,zoomOnScroll:at,zoomOnPinch:El,zoomOnDoubleClick:Il,panOnScroll:Cl,panOnScrollSpeed:Sl,panOnScrollMode:_l,panOnDrag:Ml,autoPanOnSelection:ad,onPaneClick:$l,onPaneMouseEnter:Al,onPaneMouseMove:Rl,onPaneMouseLeave:Dl,onPaneScroll:Pl,onPaneContextMenu:zl,paneClickDistance:Tl,nodeClickDistance:Ol,onSelectionContextMenu:M,onSelectionStart:D,onSelectionEnd:P,onReconnect:Hl,onReconnectStart:Vl,onReconnectEnd:Fl,onEdgeContextMenu:Bl,onEdgeDoubleClick:Wl,onEdgeMouseEnter:Yl,onEdgeMouseMove:Xl,onEdgeMouseLeave:ql,reconnectRadius:Zl,defaultMarkerColor:we,noDragClassName:Kl,noWheelClassName:Ql,noPanClassName:er,rfId:js,disableKeyboardA11y:sr,nodeExtent:ye,viewport:md,onViewportChange:gd,nodesDraggable:ue}),a.jsx(tx,{onSelectionChange:_}),Ll,a.jsx(Ug,{proOptions:td,position:ed}),a.jsx(Gg,{rfId:js,disableKeyboardA11y:sr})]})})}var Vo=gc($0);const A0=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");function R0({children:e}){const t=se(A0);return t?Ld.createPortal(e,t):null}function Qn(e){return se(k.useCallback(n=>n.nodeLookup.get(e),[e]),de)}function D0({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:me(["react-flow__background-pattern",n,s])})}function P0({radius:e,className:t}){return a.jsx("circle",{cx:e,cy:e,r:e,className:me(["react-flow__background-pattern","dots",t])})}var ot;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ot||(ot={}));const z0={[ot.Dots]:1,[ot.Lines]:1,[ot.Cross]:6},T0=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Fc({id:e,variant:t=ot.Dots,gap:n=20,size:s,lineWidth:o=1,offset:i=0,color:r,bgColor:c,style:l,className:d,patternClassName:u}){const f=k.useRef(null),{transform:h,patternId:m}=se(T0,de),p=s||z0[t],w=t===ot.Dots,y=t===ot.Cross,x=Array.isArray(n)?n:[n,n],N=[x[0]*h[2]||1,x[1]*h[2]||1],g=p*h[2],v=Array.isArray(i)?i:[i,i],E=y?[g,g]:N,j=[v[0]*h[2]+E[0]/2,v[1]*h[2]+E[1]/2],S=`${m}${e||""}`;return a.jsxs("svg",{className:me(["react-flow__background",d]),style:{...l,...vs,"--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]%N[0],y:h[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${j[0]},-${j[1]})`,children:w?a.jsx(P0,{radius:g/2,className:u}):a.jsx(D0,{dimensions:E,lineWidth:o,variant:t,className:u})}),a.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${S})`})]})}Fc.displayName="Background";const Fo=k.memo(Fc);function O0(){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 L0(){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 H0(){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 V0(){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 F0(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:a.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Et({children:e,className:t,...n}){return a.jsx("button",{type:"button",className:me(["react-flow__controls-button",t]),...n,children:e})}const B0=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Bc({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":m}){const p=le(),{isInteractive:w,minZoomReached:y,maxZoomReached:x,ariaLabelConfig:N}=se(B0,de),{zoomIn:g,zoomOut:v,fitView:E}=Bt(),j=()=>{g(),i?.()},S=()=>{v(),r?.()},$=()=>{E(o),c?.()},R=()=>{p.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),l?.(!w)},V=h==="horizontal"?"horizontal":"vertical";return a.jsxs(rt,{className:me(["react-flow__controls",V,d]),position:f,style:e,"data-testid":"rf__controls","aria-label":m??N["controls.ariaLabel"],children:[t&&a.jsxs(a.Fragment,{children:[a.jsx(Et,{onClick:j,className:"react-flow__controls-zoomin",title:N["controls.zoomIn.ariaLabel"],"aria-label":N["controls.zoomIn.ariaLabel"],disabled:x,children:a.jsx(O0,{})}),a.jsx(Et,{onClick:S,className:"react-flow__controls-zoomout",title:N["controls.zoomOut.ariaLabel"],"aria-label":N["controls.zoomOut.ariaLabel"],disabled:y,children:a.jsx(L0,{})})]}),n&&a.jsx(Et,{className:"react-flow__controls-fitview",onClick:$,title:N["controls.fitView.ariaLabel"],"aria-label":N["controls.fitView.ariaLabel"],children:a.jsx(H0,{})}),s&&a.jsx(Et,{className:"react-flow__controls-interactive",onClick:R,title:N["controls.interactive.ariaLabel"],"aria-label":N["controls.interactive.ariaLabel"],children:w?a.jsx(F0,{}):a.jsx(V0,{})}),u]})}Bc.displayName="Controls";const Bo=k.memo(Bc);function W0({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:m}){const{background:p,backgroundColor:w}=i||{},y=r||p||w;return a.jsx("rect",{className:me(["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:m?x=>m(x,e):void 0})}const Y0=k.memo(W0),X0=e=>e.nodes.map(t=>t.id),zs=e=>e instanceof Function?e:()=>e;function q0({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:o,nodeComponent:i=Y0,onClick:r}){const c=se(X0,de),l=zs(t),d=zs(e),u=zs(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return a.jsx(a.Fragment,{children:c.map(h=>a.jsx(G0,{id:h,nodeColorFunc:l,nodeStrokeColorFunc:d,nodeClassNameFunc:u,nodeBorderRadius:s,nodeStrokeWidth:o,NodeComponent:i,onClick:r,shapeRendering:f},h))})}function Z0({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:m}=se(p=>{const w=p.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};const y=w.internals.userNode,{x,y:N}=w.internals.positionAbsolute,{width:g,height:v}=Le(y);return{node:y,x,y:N,width:g,height:v}},de);return!d||d.hidden||!Ya(d)?null:a.jsx(c,{x:u,y:f,width:h,height:m,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 G0=k.memo(Z0);var U0=k.memo(q0);const K0=200,Q0=150,J0=e=>!e.hidden,ey=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?Fa(gn(e.nodeLookup,{filter:J0}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},wi=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,ty=(e,t)=>wi(e.viewBB,t.viewBB)&&wi(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,ny="react-flow__minimap-desc";function Wc({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:m,onNodeClick:p,pannable:w=!1,zoomable:y=!1,ariaLabel:x,inversePan:N,zoomStep:g=1,offsetScale:v=5}){const E=le(),j=k.useRef(null),{boundingRect:S,viewBB:$,rfId:R,panZoom:V,translateExtent:A,flowWidth:O,flowHeight:_,ariaLabelConfig:b}=se(ey,ty),C=e?.width??K0,I=e?.height??Q0,M=S.width/C,D=S.height/I,P=Math.max(M,D),H=P*C,L=P*I,F=v*P,z=S.x-(H-S.width)/2-F,W=S.y-(L-S.height)/2-F,Y=H+F*2,J=L+F*2,U=`${ny}-${R}`,T=k.useRef(0),Z=k.useRef();T.current=P,k.useEffect(()=>{if(j.current&&V)return Z.current=xg({domNode:j.current,panZoom:V,getTransform:()=>E.getState().transform,getViewScale:()=>T.current}),()=>{Z.current?.destroy()}},[V]),k.useEffect(()=>{Z.current?.update({translateExtent:A,width:O,height:_,inversePan:N,pannable:w,zoomStep:g,zoomable:y})},[w,y,N,g,A,O,_]);const ee=m?Q=>{const[oe,ie]=Z.current?.pointer(Q)||[0,0];m(Q,{x:oe,y:ie})}:void 0,te=p?k.useCallback((Q,oe)=>{const ie=E.getState().nodeLookup.get(oe).internals.userNode;p(Q,ie)},[]):void 0,K=x??b["minimap.ariaLabel"];return a.jsx(rt,{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*P: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:me(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:a.jsxs("svg",{width:C,height:I,viewBox:`${z} ${W} ${Y} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":U,ref:j,onClick:ee,children:[K&&a.jsx("title",{id:U,children:K}),a.jsx(U0,{onClick:te,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:r,nodeComponent:c}),a.jsx("path",{className:"react-flow__minimap-mask",d:`M${z-F},${W-F}h${Y+F*2}v${J+F*2}h${-Y-F*2}z
|
|
8
|
+
M${$.x},${$.y}h${$.width}v${$.height}h${-$.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Wc.displayName="MiniMap";const Wo=k.memo(Wc),sy=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,oy={[Rt.Line]:"right",[Rt.Handle]:"bottom-right"};function ry({nodeId:e,position:t,variant:n=Rt.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:m=!0,shouldResize:p,onResizeStart:w,onResize:y,onResizeEnd:x}){const N=bc(),g=typeof e=="string"?e:N,v=le(),E=k.useRef(null),j=n===Rt.Handle,S=se(k.useCallback(sy(j&&m),[j,m]),de),$=k.useRef(null),R=t??oy[n];k.useEffect(()=>{if(!(!E.current||!g))return $.current||($.current=Mg({domNode:E.current,nodeId:g,getStoreItems:()=>{const{nodeLookup:A,transform:O,snapGrid:_,snapToGrid:b,nodeOrigin:C,domNode:I}=v.getState();return{nodeLookup:A,transform:O,snapGrid:_,snapToGrid:b,nodeOrigin:C,paneDomNode:I}},onChange:(A,O)=>{const{triggerNodeChanges:_,nodeLookup:b,parentLookup:C,nodeOrigin:I}=v.getState(),M=[],D={x:A.x,y:A.y},P=b.get(g);if(P&&P.expandParent&&P.parentId){const H=P.origin??I,L=A.width??P.measured.width??0,F=A.height??P.measured.height??0,z={id:P.id,parentId:P.parentId,rect:{width:L,height:F,...Xa({x:A.x??P.position.x,y:A.y??P.position.y},{width:L,height:F},P.parentId,b,H)}},W=Oo([z],b,C,I);M.push(...W),D.x=A.x?Math.max(H[0]*L,A.x):void 0,D.y=A.y?Math.max(H[1]*F,A.y):void 0}if(D.x!==void 0&&D.y!==void 0){const H={id:g,type:"position",position:{...D}};M.push(H)}if(A.width!==void 0&&A.height!==void 0){const L={id:g,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:A.width,height:A.height}};M.push(L)}for(const H of O){const L={...H,type:"position"};M.push(L)}_(M)},onEnd:({width:A,height:O})=>{const _={id:g,type:"dimensions",resizing:!1,dimensions:{width:A,height:O}};v.getState().triggerNodeChanges([_])}})),$.current.update({controlPosition:R,boundaries:{minWidth:c,minHeight:l,maxWidth:d,maxHeight:u},keepAspectRatio:f,resizeDirection:h,onResizeStart:w,onResize:y,onResizeEnd:x,shouldResize:p}),()=>{$.current?.destroy()}},[R,c,l,d,u,f,w,y,x,p]);const V=R.split("-");return a.jsx("div",{className:me(["react-flow__resize-control","nodrag",...V,n,s]),ref:E,style:{...o,scale:S,...r&&{[j?"backgroundColor":"borderColor"]:r}},children:i})}const iy=k.memo(ry);function wn({anchor:e,excerpt:t,children:n,className:s}){const o=k.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}=Fi(e.ref);return a.jsxs(Pt,{modal:!1,open:c,onOpenChange:h=>l(h?e.ref:null,h?o:null),children:[a.jsx(co,{asChild:!0,children:a.jsxs("span",{"data-anchor-ref":e.ref,"data-commentable":"",className:re("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:re("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(Tu,{className:"h-3 w-3"})}),d.length>0&&a.jsx(Hd,{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(zt,{onInteractOutside:h=>h.preventDefault(),className:"max-h-[var(--radix-popover-content-available-height)] overflow-y-auto",children:a.jsx(lo,{anchor:e,excerpt:t,threads:d,onClose:()=>l(null)})})]})}const ay="/assets/elk-worker.min-C9JGDOE-.js";let vi;function cy(){return vi??=Vd(async()=>{const{default:e}=await import("./elk-api-D0cBetPW.js").then(t=>t.e);return{default:e}},__vite__mapDeps([0,1,2])).then(({default:e})=>new e({workerUrl:ay})),vi}const bi={"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]"},ly=160,dy=88;async function Jn(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??ly,height:h??d.measured?.height??dy}:{layoutOptions:bi},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:bi,children:o,edges:t.map(d=>({id:d.id,sources:[d.source],targets:[d.target]}))};let r;try{r=await(await cy()).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 uy=32;function es(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)*uy,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 Ni(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),m=h*u,p=h*f;return{x:n*(m+p)+r,y:s*(-m+p)+c}}function ji(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 fy(e,t){const n=Ni(e,t),s=Ni(t,e);return{sx:n.x,sy:n.y,tx:s.x,ty:s.y,sourcePos:ji(e,n),targetPos:ji(t,s)}}function hy({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,m=t*.25+f*.5+s*.25;return[`M ${e},${t} Q ${u},${f} ${n},${s}`,h,m]}function py({id:e,source:t,target:n,markerStart:s,markerEnd:o,style:i,data:r}){const c=Qn(t),l=Qn(n);if(!c||!l)return null;const{sx:d,sy:u,tx:f,ty:h,sourcePos:m,targetPos:p}=fy(c,l),w=r,[y,x,N]=(w?.parallelCount??1)>1?hy({sx:d,sy:u,tx:f,ty:h,offset:w?.parallelOffset??0}):Ro({sourceX:d,sourceY:u,sourcePosition:m,targetX:f,targetY:h,targetPosition:p,curvature:.25}),g=w?.label,v=w?.selected===!0,E=v?"var(--color-primary)":i?.stroke??"var(--color-muted-foreground)",j=v?{...i,stroke:E,strokeWidth:3}:i;return a.jsxs(a.Fragment,{children:[a.jsx(Wt,{id:e,path:y,markerStart:s,markerEnd:o,style:j,interactionWidth:18}),g&&a.jsx(R0,{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, ${N}px)`,color:E,background:"oklch(0.17 0.01 270)"},children:g})})]})}function my({id:e,source:t,target:n,style:s}){const o=Qn(t),i=Qn(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,[m]=Un({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(Wt,{id:e,path:m,style:s,interactionWidth:18})}const Yo={floating:py,tree:my};function bs({domainId:e,anchorRef:t,kind:n,excerpt:s,className:o}){const{threads:i,status:r,orphaned:c}=Fi(t,e),l=k.useId(),d=X(p=>p.openAnchorRef),u=X(p=>p.openAnchorId),f=e?`${e}::${t}`:t,h=d===f&&(u===null||u===l),m=X(p=>p.setOpenAnchor);return i.length===0?null:a.jsxs(Pt,{modal:!1,open:h,onOpenChange:p=>m(p?f:null,p?l:null),children:[a.jsx(co,{asChild:!0,children:a.jsxs("button",{type:"button",title:"View comments",onClick:p=>{p.stopPropagation(),m(h?null:f,l)},className:re("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(Bi,{className:"h-2.5 w-2.5"}),i.length]})}),a.jsx(zt,{side:"top",align:"end",className:"w-80",children:a.jsx(lo,{domainId:e,anchor:{ref:t,kind:n},excerpt:s,threads:i,onClose:()=>m(null)})})]})}function gy(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 ve({svg:e,className:t}){const n=k.useMemo(()=>e?gy(e):null,[e]);return n?a.jsx("span",{className:re("inline-flex shrink-0 items-center justify-center [&>svg]:h-full [&>svg]:w-full",t),dangerouslySetInnerHTML:{__html:n}}):null}const Ue=e=>`core.node.${e}`,Yc=e=>e.split("/").filter(Boolean).pop()??e;function Dt(e){const t=e.data.name??e.data.title;return typeof t=="string"&&t?t:Yc(e.path)}function Xo(e){const t=[...new Set(e.nodes.map(n=>n.className))].sort();return new Map(t.map((n,s)=>[n,Fd(s)]))}const ts=e=>e==null?"—":typeof e=="string"?e:Array.isArray(e)?e.map(ts).join(", "):JSON.stringify(e);function xy(e,t=2){const n=Dt(e);return Object.entries(e.data).filter(([,s])=>ts(s)!==n).slice(0,t).map(([s,o])=>[s,ts(o)])}function qo(e,t){return e.ir?.classes?.[t]?.icon}function Xc({count:e}){const t=X(o=>o.canvasMode),n=X(o=>o.setCanvasMode),s=t==="core";return a.jsxs(Ve,{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(Bd,{className:"h-3.5 w-3.5"}):a.jsx(Wi,{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 yy({data:e}){const t=e,n=t.className==="Folder";return a.jsxs("div",{className:re("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:[a.jsx(bs,{anchorRef:Ue(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(ve,{svg:t.icon,className:"h-5 w-5"}):n?a.jsx(fn,{className:"h-5 w-5"}):a.jsx(Pe,{className:"h-5 w-5"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-[13px] font-extrabold truncate leading-tight",children:t.title}),a.jsx("div",{className:"text-[10px] font-mono text-muted-foreground/70 truncate leading-tight",children:t.className})]})]}),t.fields.length>0&&a.jsx("div",{className:"mt-1.5 flex flex-col gap-0.5",children:t.fields.map(([s,o])=>a.jsxs("div",{className:"flex items-baseline gap-1 text-[10px] leading-tight",children:[a.jsx("span",{className:"font-mono text-muted-foreground/60 shrink-0",children:s}),a.jsx("span",{className:"truncate text-foreground/80",children:o})]},s))})]}),a.jsx(ke,{type:"source",position:q.Bottom,className:"!opacity-0"})]})}const wy={coreNode:yy};function vy(e,t,n){const s=new Set(e.nodes.map(r=>Ue(r.path))),o=e.nodes.map(r=>{const c=xy(r);return{id:Ue(r.path),type:"coreNode",position:{x:0,y:0},data:{path:r.path,className:r.className,title:Dt(r),hue:n.get(r.className)??264,icon:qo(t,r.className),fields:c,selected:!1},style:{width:184,height:50+c.length*15}}}),i=[];for(const r of e.nodes){if(!r.parent)continue;const c=Ue(r.parent),l=Ue(r.path);!s.has(c)||!s.has(l)||i.push({id:`core.struct.${r.path}`,source:c,target:l,type:"tree",data:{structural:!0},style:{stroke:"oklch(0.5 0.02 264)",strokeWidth:1.4,strokeDasharray:"4 4"}})}for(const r of e.edges){const c=Ue(r.from),l=Ue(r.to);if(!s.has(c)||!s.has(l))continue;const d="oklch(0.72 0.16 35)";i.push({id:`core.edge.${r.from}__${r.edgeName}__${r.to}`,source:c,target:l,type:"floating",data:{label:r.edgeName},markerEnd:{type:Je.ArrowClosed,color:d,width:16,height:16},style:{stroke:d,strokeWidth:2}})}return{nodes:o,edges:i}}function by({core:e,bundle:t,selectedPath:n,onSelect:s}){const{fitView:o}=Bt(),i=X(j=>j.setOpenAnchor),r=k.useMemo(()=>Xo(e),[e]),c=k.useMemo(()=>vy(e,t,r),[e,t,r]),[l,d]=k.useState([]),[u,f]=k.useState([]);k.useEffect(()=>{let j=!1;return Jn(c.nodes,c.edges).then(S=>{j||(d(S),f(es(c.edges)),requestAnimationFrame(()=>o({padding:.2,duration:400})))}),()=>{j=!0}},[c,o]);const h=k.useCallback(j=>d(S=>ys(j,S)),[]),m=k.useCallback(j=>f(S=>ws(j,S)),[]),[p,w]=k.useState(!0),[y,x]=k.useState(!0),N=k.useMemo(()=>p?l:l.filter(j=>j.data.className!=="Folder"),[l,p]),g=k.useMemo(()=>new Set(N.map(j=>j.id)),[N]),v=k.useMemo(()=>N.map(j=>{const S=j.data.path===n;return j.data.selected===S?j:{...j,data:{...j.data,selected:S}}}),[N,n]),E=k.useMemo(()=>u.filter(j=>!g.has(j.source)||!g.has(j.target)?!1:j.type==="tree"?p:y),[u,g,p,y]);return a.jsxs(Vo,{nodes:v,edges:E,nodeTypes:wy,edgeTypes:Yo,onNodesChange:h,onEdgesChange:m,onNodeClick:(j,S)=>s(S.data.path),onPaneClick:()=>{s(null),i(null)},minZoom:.15,nodesConnectable:!1,proOptions:{hideAttribution:!0},children:[a.jsx(Fo,{gap:18,size:1,color:"oklch(0.3 0.01 270)"}),a.jsx(Bo,{className:"!bg-card !border !border-border [&_button]:!bg-card [&_button]:!border-border [&_button]:!fill-foreground",showInteractive:!1}),a.jsx(Wo,{pannable:!0,zoomable:!0,className:"!bg-card !border !border-border",nodeColor:j=>`oklch(0.6 0.13 ${j.data.hue})`,nodeStrokeWidth:0,maskColor:"oklch(0.17 0.01 270 / 0.7)"}),a.jsxs(rt,{position:"top-right",className:"flex gap-1.5",children:[a.jsxs(Ve,{size:"xs",variant:p?"default":"outline",onClick:()=>w(j=>!j),"aria-pressed":p,title:"Folders & the parent→child tree — toggle to focus on the semantic graph alone",children:[a.jsx($u,{className:"h-3.5 w-3.5"})," Structure"]}),a.jsxs(Ve,{size:"xs",variant:y?"default":"outline",onClick:()=>x(j=>!j),"aria-pressed":y,title:"Typed (semantic) edges — toggle to focus on the tree/organization alone",children:[a.jsx(Tt,{className:"h-3.5 w-3.5"})," Semantics"]}),a.jsx(Xc,{})]})]})}function Ny(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 qc({item:e,depth:t,bundle:n,hues:s,selectedPath:o,onSelect:i}){const[r,c]=k.useState(!0),l=e.node,d=e.children.length>0,u=o===l.path,f=s.get(l.className)??264,h=qo(n,l.className),m=l.className==="Folder";return a.jsxs("div",{children:[a.jsxs("div",{className:re("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(p=>!p),className:"shrink-0 rounded p-0.5 text-muted-foreground hover:bg-white/5",title:r?"Collapse":"Expand",children:r?a.jsx(as,{className:"h-3 w-3"}):a.jsx(cs,{className:"h-3 w-3"})}):a.jsx("span",{className:"w-4 shrink-0"}),a.jsx(wn,{anchor:{ref:Ue(l.path),kind:"section"},excerpt:`${Dt(l)} (${l.className})`,className:"flex-1 min-w-0",children:a.jsxs("button",{type:"button",onClick:()=>i(l.path),className:"flex w-full items-center gap-1.5 py-1 text-left min-w-0",children:[a.jsx("span",{style:{color:`oklch(0.8 0.13 ${f})`},className:"shrink-0",children:h?a.jsx(ve,{svg:h,className:"h-4 w-4"}):m?a.jsx(fn,{className:"h-3.5 w-3.5"}):a.jsx(Pe,{className:"h-3.5 w-3.5"})}),a.jsx("span",{className:"truncate font-bold",children:Dt(l)}),a.jsx("span",{className:"ml-auto text-[10px] font-mono text-muted-foreground/50 shrink-0",children:l.className})]})})]}),r&&d&&a.jsx("div",{children:e.children.map(p=>a.jsx(qc,{item:p,depth:t+1,bundle:n,hues:s,selectedPath:o,onSelect:i},p.node.path))})]})}function jy({core:e,bundle:t,selectedPath:n,onSelect:s}){const o=k.useMemo(()=>Xo(e),[e]),i=k.useMemo(()=>Ny(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(Wi,{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(qc,{item:r,depth:0,bundle:t,hues:o,selectedPath:n,onSelect:s},r.node.path))]})}function ky({core:e,bundle:t,selectedPath:n}){const s=k.useMemo(()=>e.nodes.find(u=>u.path===n)??null,[e,n]),o=k.useMemo(()=>Xo(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=qo(t,s.className),c=s.className==="Folder",l=Object.entries(s.data),d=e.edges.filter(u=>u.from===s.path||u.to===s.path);return a.jsxs("div",{className:"h-full overflow-y-auto",children:[a.jsx(wn,{anchor:{ref:Ue(s.path),kind:"section"},excerpt:`${Dt(s)} (${s.className})`,className:"block",children:a.jsxs("div",{className:"flex items-center gap-2.5 border-b px-4 py-3",children:[a.jsx("span",{style:{color:`oklch(0.82 0.14 ${i})`},className:"shrink-0",children:r?a.jsx(ve,{svg:r,className:"h-7 w-7"}):c?a.jsx(fn,{className:"h-6 w-6"}):a.jsx(Pe,{className:"h-6 w-6"})}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("div",{className:"text-base font-extrabold truncate",children:Dt(s)}),a.jsx("div",{className:"text-[11px] font-mono text-muted-foreground/70",children:s.className})]})]})}),a.jsxs("div",{className:"px-4 py-3",children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:"Path"}),a.jsx("div",{className:"mt-1 break-all font-mono text-[11px] text-foreground/80",children:s.path})]}),a.jsxs("div",{className:"px-4 pb-3",children:[a.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:"Data"}),l.length===0?a.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground/60",children:"No fields set."}):a.jsx("div",{className:"mt-1.5 flex flex-col gap-1.5",children:l.map(([u,f])=>a.jsxs("div",{className:"flex flex-col gap-0.5 rounded-md border bg-card/40 px-2.5 py-1.5",children:[a.jsx("span",{className:"font-mono text-[11px] text-muted-foreground/70",children:u}),a.jsx("span",{className:"break-words text-[13px] text-foreground/90",children:ts(f)})]},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,m=h?u.to:u.from;return a.jsxs("div",{className:"flex items-center gap-1.5 text-[12px]",children:[a.jsx(Tt,{className:"h-3.5 w-3.5 shrink-0 text-amber-400"}),a.jsx("span",{className:"font-mono text-amber-300",children:u.edgeName}),a.jsx("span",{className:"text-muted-foreground/60",children:h?"→":"←"}),a.jsx("span",{className:"truncate text-foreground/80",title:m,children:Yc(m)})]},`${u.edgeName}-${f}`)})})]})]})}function Zo(e){if(!e)return null;const t=e.auth??"required",n=e.authorize??"absent",s=n==="custom";return t==="public"?{level:"public",warn:!1,icon:it,tone:"sky",chipTone:"primary",label:"Public",auth:t,authorize:n,blurb:"Public — no credential required."}:s?{level:"secured",warn:!1,icon:Xu,tone:"emerald",chipTone:"success",label:"Secured",auth:t,authorize:n,blurb:"Runs an authorization check."}:t==="optional"?{level:"open",warn:!0,icon:Zu,tone:"rose",chipTone:"danger",label:"Open",auth:t,authorize:n,blurb:"No authz check — even anonymous callers pass."}:{level:"insecure",warn:!0,icon:Wu,tone:"amber",chipTone:"warning",label:"Unguarded",auth:t,authorize:n,blurb:"No authz check — any authenticated caller passes."}}function Ey(e){let t=0;for(const n of e)Zo(n)?.warn&&t++;return t}const Cy={emerald:"text-emerald-400 hover:text-emerald-300",sky:"text-sky-400 hover:text-sky-300",amber:"text-amber-400 hover:text-amber-300",rose:"text-rose-400 hover:text-rose-300"};function Sy({link:e}){const t=Zo(e);if(!t)return null;const n=t.icon;return a.jsxs(Ot,{openDelay:80,children:[a.jsx(Lt,{asChild:!0,children:a.jsx("button",{type:"button","aria-label":`Authorization: ${t.label}`,className:re("inline-flex items-center justify-center rounded-md transition-colors",Cy[t.tone]),children:a.jsx(n,{className:"h-3.5 w-3.5"})})}),a.jsx(Ht,{align:"start",className:"w-96 p-0 overflow-hidden",children:a.jsx(_y,{link:e})})]})}function _y({link:e}){const t=Zo(e);if(!t)return null;const n=t.icon;return a.jsxs("div",{className:"text-[13px]",children:[a.jsxs("div",{className:"flex items-start gap-2.5 p-3",children:[a.jsx(be,{tone:t.tone,size:"sm",children:a.jsx(n,{})}),a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-semibold text-foreground",children:t.label}),t.warn&&a.jsx(he,{tone:t.chipTone,children:"review"})]}),a.jsx("p",{className:"mt-1 leading-relaxed text-muted-foreground",children:t.blurb})]})]}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 border-t px-3 py-2",children:[a.jsxs(he,{tone:"outline",className:"font-mono",children:["auth: ",t.auth]}),a.jsxs(he,{tone:"outline",className:"font-mono",children:["authorize: ",t.authorize]})]}),t.authorize==="custom"&&e?.authorizeSnippet&&a.jsxs("div",{className:"border-t px-3 py-2",children:[a.jsx("p",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:"authorize"}),a.jsx(Wd,{children:e.authorizeSnippet})]})]})}const ki=new Set(["Node","Edge"]),Iy="kernel.astrale.ai";function Zc(e,t){return e.ir?.interfaces[t]??e.importedInterfaces?.[t]}function My(e,t){return e.ir?.interfaces[t]?"local":e.ir?.imports[t]?.origin===Iy?"kernel":"external"}function $y(e,t){return e.ir?.imports[t]?.origin}function Gc(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();if(r.has(u)||ki.has(u))continue;r.add(u);const f=Zc(e,u);if(!f)continue;for(const p of f.extends??[])!ki.has(p)&&!r.has(p)&&l.push(p);const h=Object.entries(f.properties??{}).filter(([p])=>!o.has(p)),m=Object.entries(f.methods??{}).filter(([p])=>!i.has(p)).map(([p,w])=>({name:p,method:w,overridden:s.has(p)}));for(const[p]of h)o.add(p);for(const p of m)i.add(p.name);h.length===0&&m.length===0||c.push({iface:u,tier:My(e,u),origin:$y(e,u),navigable:!0,props:h,methods:m})}const d={local:0,external:1,kernel:2};return c.sort((u,f)=>d[u.tier]-d[f.tier])}function Ay(e,t){const n=e.ir?.classes[t];return n?Gc(e,n.implements??[],new Set(Object.keys(n.properties??{})),new Set(Object.keys(n.methods??{}))):[]}function Ry(e,t){const n=Zc(e,t);return n?Gc(e,n.extends??[],new Set(Object.keys(n.properties??{})),new Set(Object.keys(n.methods??{}))):[]}function Dy(e){return e.reduce((t,n)=>t+n.props.length+n.methods.length,0)}function Py({domainId:e,view:t,open:n,onOpenChange:s}){const o=Yd(e,t.slug,n),i=o.data,[r,c]=k.useState(""),[l,d]=k.useState(0),[u,f]=k.useState(!1),[h,m]=k.useState({phase:"idle"}),p=k.useRef("");k.useEffect(()=>{if(!n){p.current="",c(""),m({phase:"idle"});return}if(!i)return;const v=`${e}:${t.slug}:${i.instance??"none"}`;p.current!==v&&(p.current=v,c(i.targets.selected?.id??""))},[e,n,i,t.slug]);const w=!!i&&(!i.targetRequired||i.targets.items.some(v=>v.id===r)),y=i?.server.status==="running"?i.server.startedAt:"not-running",x=n&&!u&&!!i?.instance&&i.server.status==="running"&&w;k.useEffect(()=>{if(!x){m({phase:"idle"});return}let v=!1,E=null;return m({phase:"launching"}),Se.launchView(e,t.slug,r?{targetId:r}:{}).then(j=>{j.status==="ready"?(E=j.sessionId,v?Se.closeViewSession(e,j.sessionId):m({phase:"ready",session:j})):v||m({phase:"error",reason:j.reason})}).catch(j=>{v||m({phase:"error",reason:j instanceof Error?j.message:String(j)})}),()=>{v=!0,E&&Se.closeViewSession(e,E)}},[l,e,x,i?.instance,y,r,t.slug]),k.useEffect(()=>{if(h.phase!=="ready")return;const v=()=>{const E=`/api/domain/${encodeURIComponent(e)}/views/sessions/close`;navigator.sendBeacon(E,new Blob([JSON.stringify({sessionId:h.session.sessionId})],{type:"application/json"}))};return window.addEventListener("pagehide",v),()=>window.removeEventListener("pagehide",v)},[e,h]);const N=async()=>{if(!u){f(!0),m({phase:"idle"});try{await Se.restartViewServer(e),await o.refetch(),d(v=>v+1)}catch(v){m({phase:"error",reason:v instanceof Error?v.message:String(v)})}finally{f(!1)}}},g=i?.server.status==="running"?i.server:null;return a.jsx(Xd,{open:n,onOpenChange:s,children:a.jsxs(qd,{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(Lu,{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(Zd,{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(Gd,{className:"h-3.5 w-3.5"})," Open separately"]}),a.jsx("button",{type:"button",onClick:()=>{N()},disabled:!i||u,title:"Restart the managed local preview",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(Ud,{className:re("h-3.5 w-3.5",u&&"animate-spin")})})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b bg-muted/15 px-4 py-3",children:[i?.targetRequired?a.jsx(zy,{result:i.targets,value:r,onChange:c,instance:i.instance}):a.jsxs("div",{className:"inline-flex h-9 items-center gap-2 rounded-xl border bg-background/60 px-3 text-[11px]",children:[a.jsx(Yi,{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:re("inline-flex h-9 items-center gap-2 rounded-xl border px-3 text-[10px]",g?"border-emerald-500/20 bg-emerald-500/8 text-emerald-200":"bg-background/60 text-muted-foreground"),title:g?`Studio-managed server; sleeps after ${Ly(g.idleTimeoutMs)} without an open view.`:i?.server.status==="failed"||i?.server.status==="unavailable"?i.server.reason:"Starting the local frontend…",children:[g?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(yo,{className:"h-3 w-3 text-amber-400"}):a.jsx(Ls,{className:"h-3 w-3 animate-spin"}),a.jsx(oa,{className:"h-3.5 w-3.5"}),a.jsx("span",{className:"font-medium",children:"Managed locally"}),g&&a.jsxs("code",{className:"opacity-65",children:[":",g.port]})]}),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"&&g?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(Oy,{loading:o.isLoading||u||h.phase==="launching",runtimeError:o.isError,runtime:i,targetId:r,sessionError:h.phase==="error"?h.reason:void 0,onRetry:()=>{N()}})})]})})}function zy({result:e,value:t,onChange:n,instance:s}){const[o,i]=k.useState(!1),[r,c]=k.useState(""),l=e.items.find(u=>u.id===t)??null,d=k.useMemo(()=>{const u=r.trim().toLocaleLowerCase();return u?e.items.filter(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(Pt,{open:o,onOpenChange:u=>{i(u),u||c("")},children:[a.jsx(uo,{asChild:!0,children:a.jsxs("button",{type:"button",className:re("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:re("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(Kd,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),a.jsxs(zt,{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(Xi,{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(yo,{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(Ei,{children:e.reason??"Targets could not be queried."}):d.length===0?a.jsx(Ei,{children:e.items.length===0?"No eligible targets are visible.":"No matches."}):d.map(u=>a.jsx(Ty,{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 Ty({item:e,selected:t,onClick:n}){return a.jsxs("button",{type:"button",onClick:n,className:re("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(Yi,{className:"h-3.5 w-3.5 text-primary"})]})}function Ei({children:e}){return a.jsx("div",{className:"px-3 py-8 text-center text-[11px] text-muted-foreground",children:e})}function Oy({loading:e,runtimeError:t,runtime:n,targetId:s,sessionError:o,onRetry:i}){if(e)return a.jsx(ct,{icon:a.jsx(Ls,{className:"animate-spin"}),title:"Preparing local preview",children:"Studio is starting the domain frontend and connecting it to the active data instance."});if(t)return a.jsx(ct,{icon:a.jsx(dr,{}),title:"The Studio runtime did not respond",action:i,children:"Retry the managed preview. The schema canvas is unaffected."});if(!n?.instance)return a.jsx(ct,{icon:a.jsx(dr,{}),title:"Choose an Astrale instance",children:"The local frontend always 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(ct,{icon:a.jsx(Xi,{}),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(ct,{icon:a.jsx(yo,{}),title:"The view could not be opened",action:i,children:o}):n.server.status!=="running"?a.jsx(ct,{icon:a.jsx(oa,{}),title:"Local preview could not start",action:i,children:n.server.reason}):a.jsx(ct,{icon:a.jsx(Ls,{className:"animate-spin"}),title:"Opening view session",children:"The frontend is ready. Studio is preparing its authenticated shell session."})}function ct({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 Ly(e){const t=Math.max(1,Math.round(e/6e4));return`${t} minute${t===1?"":"s"}`}function Hy({kind:e,className:t}){const n=e==="inline-html"?eu:e==="spa"?un:it;return a.jsx(n,{className:t})}function ns({domainId:e,view:t,icon:n}){const[s,o]=k.useState(!1),i=Qd(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(be,{tone:"sky",size:"sm",children:n?a.jsx(ve,{svg:n,className:"h-3.5 w-3.5"}):a.jsx(Hy,{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:re("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(Jd,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/0 transition-colors group-hover:text-primary"})]}),a.jsx(Ft,{domainId:e,anchorRef:{ref:c,kind:"section",file:t.file},excerpt:t.slug,className:"ml-1"})]}),s&&a.jsx(Py,{domainId:e,view:t,open:s,onOpenChange:o})]})}function Vy({domainId:e,model:t}){const{data:n}=fo(e),s=X(r=>r.selectClass),o=[...t.byClass.keys()].sort(),i=r=>n?.ir?.classes[r]?.icon;return a.jsx(Vt,{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(Ut,{icon:a.jsx(un,{}),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(ve,{svg:c,className:"h-4 w-4"}):a.jsx(Pe,{className:"h-4 w-4"})}),a.jsx("span",{className:"text-[13px] font-semibold transition-colors group-hover:text-primary",children:r}),a.jsx("span",{className:"text-[11px] text-muted-foreground/50",children:l.length}),a.jsx(qi,{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(ns,{domainId:e,view:d,icon:c},d.slug))})]},r)}),t.unbound.length>0&&a.jsx(Fe,{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(ns,{domainId:e,view:r},r.slug))})}),t.orphanRoutes.length>0&&a.jsx(Fe,{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 Uc(){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(Eu,{className:"h-3.5 w-3.5 transition-transform group-hover:-translate-x-0.5"}),"Back"]})}):null}function Kc({bundle:e,selected:t}){const n=e.ir,s=X(A=>A.selectClass),{data:o}=dn(),i=ho(e.domainId),r=A=>A?o?.find(O=>O.origin===A)?.icon:void 0;if(!n||!t)return a.jsx("div",{className:"h-full flex items-center justify-center px-6",children:a.jsx(Ut,{icon:a.jsx(tu,{}),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(Zy,{bundle:e,path:t.slice(7)});const[c,l]=Gy(t),d=c==="interface"?n.interfaces[l]:n.classes[l],u=c==="interface"&&!d?e.importedInterfaces?.[l]:void 0,f=d??u;if(!f)return a.jsx("div",{className:"h-full flex items-center justify-center px-6",children:a.jsx(Ut,{title:"Not found",hint:t})});const h=f.type==="edge",m=c==="interface"?"interface":h?"edge":"class",p=ou(m,l),w=e.overlay.sourceSpans[p],y=Object.entries(f.properties??{}),x=Object.entries(f.methods??{}),N=f.endpoints??[],g=f.implements??[],v=g.filter(A=>!!n.interfaces[A]),E=g.filter(A=>!n.interfaces[A]),j=f.extends??[],S=m==="interface"?Ry(e,l):Ay(e,l),$=m==="interface"?"fuchsia":"violet",R=f.icon,V=nu(i,l);return a.jsxs("div",{className:"h-full overflow-y-auto",...po(p,l),children:[a.jsx(Uc,{}),a.jsxs("div",{className:"px-5 py-6 space-y-7",children:[a.jsxs("header",{className:"group space-y-3","data-anchor-ref":p,"data-anchor-excerpt":l,"data-commentable":"",children:[a.jsxs("div",{className:"flex items-start gap-3.5",children:[a.jsx(be,{tone:$,size:"lg",children:R?a.jsx(ve,{svg:R,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:l}),m==="interface"&&a.jsx(he,{tone:"fuchsia",children:"interface"}),u&&a.jsx(he,{tone:"outline",children:tl(n.imports[l]?.origin)}),m==="edge"&&a.jsx(he,{tone:"outline",children:"edge"}),a.jsx(Ft,{anchorRef:{ref:p,kind:"schema",file:w?.file},excerpt:l,className:"ml-auto"})]}),w?.doc&&a.jsx("p",{className:"text-[13px] text-muted-foreground mt-1 leading-relaxed",children:w.doc})]})]}),(v.length>0||E.length>0||j.length>0)&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pl-[3.25rem]",children:[j.map(A=>a.jsxs(he,{tone:"outline",children:["extends ",A]},`ext-${A}`)),v.map(A=>a.jsx("button",{type:"button",onClick:()=>s(`interface.${A}`),className:"rounded-full transition-transform hover:-translate-y-px",children:a.jsxs(he,{tone:"fuchsia",className:"cursor-pointer hover:bg-fuchsia-500/20",children:[a.jsx(ze,{className:"h-3 w-3"})," ",A]})},A)),E.length>0&&a.jsxs(Ot,{openDelay:80,children:[a.jsx(Lt,{asChild:!0,children:a.jsx("button",{type:"button",className:"rounded-full",children:a.jsxs(he,{tone:"default",className:"cursor-default",children:[a.jsx(vo,{className:"h-3 w-3"})," ",E.length," base"]})})}),a.jsxs(Ht,{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:E.map(A=>a.jsx(he,{tone:"outline",children:A},A))})]})]})]})]}),h&&N.length>=2&&a.jsx(Fe,{label:"Relationship",children:a.jsx(Fy,{ir:n,endpoints:N,edgeName:l})}),y.length>0&&a.jsx(Fe,{label:"Properties",hint:`${y.length}`,children:a.jsx(ft,{className:"divide-y divide-border/70",children:y.map(([A,O])=>a.jsx(Jc,{bundle:e,refBase:p,pname:A,schema:O},A))})}),x.length>0&&a.jsx(Fe,{label:"Methods",hint:(()=>{const A=Ey(x.map(([O])=>e.overlay.handlerLinks.find(_=>_.owner===l&&_.method===O)));return a.jsxs("span",{className:"inline-flex items-center gap-2",children:[A>0&&a.jsxs(he,{tone:"warning",children:[A," unguarded"]}),x.length]})})(),children:a.jsx("div",{className:"space-y-2.5",children:x.map(([A,O])=>a.jsx(el,{bundle:e,owner:l,refBase:p,mname:A,method:O},A))})}),V.length>0&&a.jsx(Fe,{label:"Views",hint:`${V.length}`,children:a.jsx("div",{className:"flex flex-col gap-0.5",children:V.map(A=>a.jsx(ns,{domainId:e.domainId,view:A,icon:R},A.slug))})}),S.length>0&&a.jsx(Xy,{bundle:e,groups:S,originIcon:r}),y.length===0&&x.length===0&&S.length===0&&!h&&a.jsx(Ut,{title:"No properties or methods",hint:"This member carries no fields of its own."})]})]})}function Fy({ir: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(Si,{ir:e,endpoint:s,edgeName:n}),a.jsx(By,{edgeName:n,from:s,to:o}),a.jsx(Si,{ir:e,endpoint:o,edgeName:n})]})})}function Js(e){if(!e)return"*";const{min:t,max:n}=e;return n===null?t<=0?"*":`${t}..*`:t===n?`${n}`:`${t}..${n}`}const In=e=>!e||e.max===null||e.max>1,Ci=e=>!e||e.min<=0;function Si({ir:e,endpoint:t,edgeName:n}){const s=X(f=>f.selectClass);if(!t)return null;const o=t.types.length?t.types:["—"],i=t.cardinality,r=t.name?po(`edge.${n}.endpoint.${t.name}`,t.name):{},c=f=>{const h=e.classes[f],m=e.interfaces[f];return{t:f,isInterface:!h&&!!m,resolvable:!!h||!!m,icon:h?.icon}},l=f=>()=>{f.resolvable&&s(f.isInterface?`interface.${f.t}`:`class.${f.t}`)},d=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})}),u=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:Js(i)});if(o.length===1){const f=c(o[0]);return a.jsxs("button",{type:"button",onClick:f.resolvable?l(f):void 0,disabled:!f.resolvable,title:f.resolvable?`Open ${f.t}`:f.t,...r,className:re("group/ep flex flex-col items-center gap-2.5 rounded-xl px-2 py-3 text-center min-w-0 transition-colors",f.resolvable?"hover:bg-accent/60 cursor-pointer":"cursor-default"),children:[a.jsx(be,{tone:f.isInterface?"fuchsia":"violet",size:"lg",className:"transition-transform group-hover/ep:-translate-y-0.5",children:f.icon?a.jsx(ve,{svg:f.icon,className:"h-5 w-5"}):f.isInterface?a.jsx(ze,{}):a.jsx(Pe,{})}),a.jsxs("div",{className:"min-w-0 w-full space-y-1.5",children:[a.jsx("div",{className:"text-sm font-bold break-words leading-tight",children:f.t}),a.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-1",children:[d,u]})]})]})}return a.jsxs("div",{...r,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:o.map(f=>{const h=c(f);return a.jsxs("button",{type:"button",onClick:h.resolvable?l(h):void 0,disabled:!h.resolvable,title:h.resolvable?`Open ${f}`:f,className:re("inline-flex items-center gap-1.5 rounded-lg border border-border/70 pl-1 pr-2 py-1 transition-colors",h.resolvable?"hover:bg-accent/60 cursor-pointer":"cursor-default"),children:[a.jsx(be,{tone:h.isInterface?"fuchsia":"violet",size:"sm",children:h.icon?a.jsx(ve,{svg:h.icon,className:"h-3.5 w-3.5"}):h.isInterface?a.jsx(ze,{}):a.jsx(Pe,{})}),a.jsx("span",{className:"text-[13px] font-semibold",children:f})]},f)})}),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"}),d,u]})]})}function By({edgeName:e,from:t,to:n}){const s=t?.cardinality,o=n?.cardinality,i=`${In(s)?"many":"one"}-to-${In(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(_i,{many:In(s),optional:Ci(s),side:"left"}),a.jsx("span",{className:"h-px flex-1 bg-border"}),a.jsx(qi,{className:"h-[18px] w-[18px] shrink-0 text-muted-foreground/70"}),a.jsx("span",{className:"h-px flex-1 bg-border"}),a.jsx(_i,{many:In(o),optional:Ci(o),side:"right"})]}),a.jsxs(Ot,{openDelay:80,children:[a.jsx(Lt,{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(Ht,{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:Js(s)})," ",t?.name," to"," ",a.jsx("span",{className:"font-mono text-foreground/90",children:Js(o)})," ",n?.name,"."]})})]})]})}function _i({many:e,optional:t,side:n}){return a.jsx("svg",{viewBox:"0 0 24 16",className:re("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 Qc({doc:e}){return a.jsxs(Ot,{openDelay:80,children:[a.jsx(Lt,{asChild:!0,children:a.jsx("button",{type:"button","aria-label":"Description",className:"text-muted-foreground/40 hover:text-foreground transition-colors",children:a.jsx(uu,{className:"h-3.5 w-3.5"})})}),a.jsx(Ht,{className:"w-auto max-w-xs text-[13px] leading-relaxed text-muted-foreground",children:e})]})}function Jc({bundle:e,refBase:t,pname:n,schema:s}){const o=`${t}.property.${n}`,i=e.overlay.sourceSpans[o]?.doc,r=Zi(s),c=r.icon,l=e.overlay.annotations.filter(u=>u.target===o),d=ru(s);return a.jsx(mo,{anchorRef:o,anchorExcerpt:n,leading:a.jsx(be,{tone:"sky",size:"sm",children:a.jsx(c,{})}),title:a.jsxs("span",{className:"flex items-center gap-1.5",children:[n,i&&a.jsx(Qc,{doc:i}),r.optional&&a.jsx(he,{tone:"default",children:"optional"}),l.map(u=>a.jsx(he,{tone:"warning",title:u.message,children:u.code==="ENUM_DROPPED_BY_UPDATE"?"enum changes need migration":u.code},u.code))]}),subtitle:a.jsxs(Ot,{openDelay:140,children:[a.jsx(Lt,{asChild:!0,children:a.jsx("span",{className:"cursor-default",children:r.label})}),a.jsx(Ht,{className:"w-auto max-w-sm",children:a.jsx(iu,{items:[{label:"type",value:au(d)+(r.optional?" (optional)":"")},{label:"key",value:o}]})})]}),trailing:a.jsx(Ft,{anchorRef:{ref:o,kind:"schema",file:e.overlay.sourceSpans[o]?.file},excerpt:n})})}function el({bundle:e,owner:t,refBase:n,mname:s,method:o,overridden:i=!1}){const r=`${n}.method.${s}`,c=e.overlay.handlerLinks.find(m=>m.owner===t&&m.method===s),l=e.overlay.sourceSpans[r]?.doc,d=cu(o),u=d.icon,f=c&&!c.implemented,h=c?.unlinked;return a.jsxs(ft,{className:"px-3 py-2.5","data-anchor-ref":r,"data-anchor-excerpt":`${t}.${s}`,"data-commentable":"",children:[a.jsx(mo,{className:"px-0 py-0 hover:bg-transparent",leading:a.jsx(be,{tone:d.tone,size:"sm",children:a.jsx(u,{})}),title:a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx("span",{className:re(i&&"line-through text-muted-foreground/70"),children:s}),a.jsx(Sy,{link:c}),l&&a.jsx(Qc,{doc:l}),o.inheritance==="sealed"&&a.jsx(he,{tone:"warning",children:"sealed"}),o.inheritance==="abstract"&&a.jsx(he,{tone:"fuchsia",children:"contract"}),i&&a.jsx(he,{tone:"default",children:"overridden"}),f&&a.jsx(he,{tone:"warning",children:"needs handler"}),h&&a.jsx(he,{tone:"default",children:"unlinked"})]}),trailing:a.jsx(Ft,{anchorRef:{ref:r,kind:"schema",file:e.overlay.sourceSpans[r]?.file},excerpt:`${t}.${s}`})}),a.jsx("div",{className:"pl-[2.625rem] pt-1.5",children:a.jsx(lu,{label:"Details",children:a.jsx(Wy,{method:o,link:c,owner:t})})})]})}function Wy({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=Zi(i);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:[r.label,r.optional?"?":""]})]},o)})})]}),a.jsx(Yy,{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(he,{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(fu,{schema:e.returns})]})]})}function Yy({owner:e,isStatic:t}){return a.jsxs(Ot,{openDelay:80,children:[a.jsx(Lt,{asChild:!0,children:a.jsx("button",{type:"button",className:"cursor-default rounded-full",children:a.jsxs(he,{tone:"outline",children:[t?a.jsx(go,{className:"h-3 w-3"}):a.jsx(Pe,{className:"h-3 w-3"})," ",t?`on the ${e} type`:`on a ${e}`]})})}),a.jsx(Ht,{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 Xy({bundle:e,groups:t,originIcon:n}){const s=X(o=>o.selectClass);return a.jsx(Fe,{label:"Inherited",hint:`${Dy(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=`interface.${o.iface}`;return a.jsxs("div",{className:re("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(be,{tone:r,size:"sm",children:a.jsx(qy,{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(he,{tone:o.tier==="local"?"fuchsia":"outline",children:o.tier==="local"?"interface":tl(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(du,{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])=>a.jsx(Jc,{bundle:e,refBase:c,pname:l,schema:d},`p-${l}`))}),o.methods.map(l=>a.jsx(el,{bundle:e,owner:o.iface,refBase:c,mname:l.name,method:l.method,overridden:l.overridden},`m-${l.name}`))]})]},o.iface)})})})}function qy({tier:e,iconSvg:t}){return e==="local"?a.jsx(ze,{}):t?a.jsx(ve,{svg:t,className:"h-4 w-4"}):e==="kernel"?a.jsx(Du,{}):a.jsx(it,{})}function tl(e){return e?e==="kernel.astrale.ai"?"kernel":e.split(".")[0]:"imported"}function Zy({bundle:e,path:t}){const n=X(i=>i.selectClass),s=su(e,t),o=i=>a.jsx(mo,{onClick:()=>n(i.selectId),anchorRef:i.ref,anchorExcerpt:i.name,leading:a.jsx(be,{tone:i.kind==="interface"?"fuchsia":i.kind==="edge"?"amber":"sky",size:"sm",children:i.icon?a.jsx(ve,{svg:i.icon,className:"h-4 w-4"}):i.kind==="interface"?a.jsx(ze,{}):i.kind==="edge"?a.jsx(Tt,{}):a.jsx(Pe,{})}),title:i.name},i.selectId);return a.jsxs("div",{className:"h-full overflow-y-auto",...po(`module.${t}`,s.label),children:[a.jsx(Uc,{}),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(be,{tone:"muted",size:"lg",style:{color:`oklch(0.82 0.12 ${s.hue})`},children:a.jsx(fn,{})}),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(Fe,{label:"Interfaces",children:a.jsx(ft,{className:"divide-y divide-border/70",children:s.interfaces.map(o)})}),s.classes.length>0&&a.jsx(Fe,{label:"Classes",children:a.jsx(ft,{className:"divide-y divide-border/70",children:s.classes.map(o)})}),s.edges.length>0&&a.jsx(Fe,{label:"Relationships",children:a.jsx(ft,{className:"divide-y divide-border/70",children:s.edges.map(o)})})]})]})}function Gy(e){const[t,...n]=e.split(".");return[t==="interface"?"interface":"class",n.join(".")]}function Go(e,t,n){const s=[],o=new Set;for(const i of t?.types??[]){if(e.classes[i]?.type==="node"){o.has(i)||(o.add(i),s.push({cls:i,ifaceNode:null,viaInterface:null}));continue}if(e.interfaces[i]){if(n(i)){const r=`iface.${i}`;o.has(r)||(o.add(r),s.push({cls:null,ifaceNode:r,viaInterface:null}));continue}for(const[r,c]of Object.entries(e.classes))c.type==="node"&&(c.implements??[]).includes(i)&&!o.has(r)&&(o.add(r),s.push({cls:r,ifaceNode:null,viaInterface:i}))}}return s}function nl(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=c.types.filter(f=>t.classes[f]?.type==="node"||t.interfaces[f]!==void 0),u=l.types.filter(f=>t.imports[f]!==void 0);for(const f of u){const h=t.imports[f].origin;for(const m of d)n.push({edge:s,from:m,origin:h,to:f,fromCard:c.cardinality,toCard:l.cardinality})}}}return n}function sl(e){const t=e.ir;if(!t)return[];const n=new Map;for(const o of nl(e))n.has(o.origin)||n.set(o.origin,new Map),n.get(o.origin).set(o.to,{name:o.to,definition:t.imports[o.to]?.definition??"class"});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))});return s.sort((o,i)=>o.kind===i.kind?o.origin.localeCompare(i.origin):o.kind==="kernel"?1:-1)}const Uy={hidden:{},showInheritedEdges:!0,materializedInterfaces:{}},ln=e=>Gi("class",e),ol=e=>Gi("edge",e),eo=e=>`domain.${e}`;function De(e,t){return t[e]===!0}function to(e,t){return t[e]===!0}function Ii(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 Ky(e,t){return!De(ln(e),t)}function Qy(e,t){return!De(eo(e),t)}function rl(e,t,n){return!(De(ol(e.edgeName),t)||De(ln(e.aClass),t)||De(ln(e.bClass),t)||e.viaInterfaces.length>0&&!n)}function Jy(e,t,n){return hu(e,t).filter(s=>!n.has(s))}const no="domain.import.",il=e=>`${no}${e}`;function al(){const{data:e}=dn(),t=new Map((e??[]).map(n=>[n.origin,n]));return n=>t.get(n)??{name:n.split(".")[0]||n,icon:""}}function ew({domain:e}){const t=al(),n=X(c=>De(eo(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:re("group flex items-center gap-2 rounded-lg px-1.5 py-1 transition-opacity",n&&"opacity-50"),children:[a.jsx(be,{tone:i,size:"sm",children:o.icon?a.jsx(ve,{svg:o.icon,className:"h-3.5 w-3.5"}):a.jsx(it,{})}),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(eo(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(Ui,{className:"h-3.5 w-3.5"}):a.jsx(Ki,{className:"h-3.5 w-3.5"})})]})}function tw({origin:e}){const n=al()(e);return a.jsx(wn,{anchor:{ref:il(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(be,{tone:"amber",size:"sm",children:n.icon?a.jsx(ve,{svg:n.icon,className:"h-3.5 w-3.5"}):a.jsx(it,{})}),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 nw({domainId:e,taken:t}){const{data:n}=dn(),{create:s}=Qi(e),o=X(c=>c.setOpenAnchor),i=c=>{const l=il(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),Hn.success("Import requested — add the why/how in the comment")},onError:d=>Hn.error(String(d))})},r=(n??[]).filter(c=>c.kind!=="kernel"&&c.origin!==e&&!t.has(c.origin));return a.jsxs(Pt,{children:[a.jsx(uo,{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(vo,{className:"h-3.5 w-3.5"}),"Import a domain"]})}),a.jsxs(zt,{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(be,{tone:c.kind==="external"?"emerald":"sky",size:"sm",children:c.icon?a.jsx(ve,{svg:c.icon,className:"h-3.5 w-3.5"}):a.jsx(it,{})}),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 sw({domainId:e}){const{data:t}=fo(e),{data:n}=xo(e),s=k.useMemo(()=>t?sl(t):[],[t]),o=k.useMemo(()=>new Set(s.map(c=>c.origin)),[s]),i=k.useMemo(()=>{const c=new Set(["kernel.astrale.ai",...o]);for(const l of t?.overlay.requires??[])c.add(l);for(const l of t?.overlay.crossDomainImports??[])c.add(l.origin);return c},[o,t]),r=k.useMemo(()=>{const c=new Set,l=[];for(const d of n?.comments??[])if(d.status==="open")for(const u of d.anchorRefs){if(!u.ref.startsWith(no))continue;const f=u.ref.slice(no.length);o.has(f)||c.has(f)||(c.add(f),l.push(f))}return l},[n,o]);return a.jsx(Vt,{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(ew,{domain:c},c.origin))})]}),r.length>0&&a.jsxs(a.Fragment,{children:[s.length>0&&a.jsx(Ln,{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(tw,{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(Ln,{className:"my-3 opacity-60"}),a.jsx(nw,{domainId:e,taken:i})]})})}const ow=18,rw=3,iw=[{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:iw.map(({id:e,draw:t})=>a.jsx("marker",{id:e,viewBox:"0 0 24 22",refX:ow+rw,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 Mi(e){return e?e.max===null||e.max>1?"erd-many":"erd-one":"erd-many"}function Uo(e,t){return{markerStart:Mi(e),markerEnd:Mi(t)}}const $i=88,Ts=24;function Ns(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 ll(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 so(e){const t={};for(const n of e)t[n.id]={x:Math.round(n.position.x),y:Math.round(n.position.y),...Ns(n)};return t}function dl(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??$i)+Ts;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+$i+Ts)}else c[l.id]={x:i,y:r,...Ns(l)},r+=(l.style?.height??120)+Ts;return c}function ul(){const e=is(),t=k.useRef(new Map),n=k.useRef(new Map),s=k.useCallback(i=>{const r=n.current.get(i);r&&clearTimeout(r),n.current.delete(i);const c=t.current.get(i);t.current.delete(i),c&&Object.keys(c).length>0&&Se.setLayout(i,c).catch(()=>{})},[]),o=k.useCallback((i,r)=>{e.setQueryData(Be.layout(i),l=>({schemaHash:l?.schemaHash,positions:{...l?.positions,...r}})),t.current.set(i,{...t.current.get(i),...r});const c=n.current.get(i);c&&clearTimeout(c),n.current.set(i,setTimeout(()=>s(i),500))},[s,e]);return k.useEffect(()=>()=>{for(const i of t.current.keys())s(i)},[s]),{commitLayout:o,flushLayout:s}}function oo(e){return String(e??"").split(/[.:/]/).pop()??""}function Mn(e){return Array.isArray(e)?e.map(String):e?[String(e)]:[]}function aw(e){const t={};for(const n of[e.importedInterfaces,e.ir?.interfaces])for(const[s,o]of Object.entries(n??{}))t[oo(s)]=o;return t}function cw(e,t){const n=aw(t),s=new Set,o=Mn(e).map(oo);for(;o.length;){const i=o.pop();if(!i||s.has(i))continue;s.add(i);const r=n[i];for(const c of[...Mn(r?.extends),...Mn(r?.implements),...Mn(r?.interfaces)])o.push(oo(c))}return s.has("Function")?"function":s.has("Identity")?"identity":s.has("Container")?"container":null}function Ko(e,t,n,s){return to(s,n)&&!!e.ir?.interfaces[s]&&!t.has(Ji(e,s))}const $n="oklch(0.72 0.18 330)";function fl(e,t,n,s,o){const i=e.ir;if(!i)return{nodes:[],edges:[]};const r=p=>Ko(e,t,o,p),c=new Set(Object.keys(i.interfaces).filter(r)),l=pu(e).filter(p=>p.classes.length>0||p.interfaces.some(w=>c.has(w))),d=[];for(const p of l){const w=`grp-${p.path}`,y=t.has(p.path);if(d.push({id:w,type:y?"moduleNode":"group",position:{x:0,y:0},selectable:!0,data:{domainId:e.domainId,label:p.label,path:p.path,hue:p.hue,interfaces:p.interfaces.filter(x=>!c.has(x)),collapsed:y,classCount:p.classes.length},style:y?{width:200,height:44}:{width:200,height:120}}),!y){for(const x of p.classes){if(!Ky(x,n))continue;const N=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,name:x,props:Object.keys(N?.properties??{}).length,methods:Object.keys(N?.methods??{}).length,interfaces:Jy(e,x,c),coreRole:cw(N?.implements??[],e),hue:p.hue,icon:N?.icon}})}for(const x of p.interfaces){if(!c.has(x))continue;const N=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(N.properties??{}).length,methods:Object.keys(N.methods??{}).length}})}}}const u=p=>{const w=gt(e,p);return t.has(w)?`grp-${w}`:`class.${p}`},f=p=>Go(i,p,r),h=p=>p.cls!==null?gt(e,p.cls):Ji(e,p.ifaceNode.slice(6)),m=[];for(const p of Object.values(i.classes)){if(p.type!=="edge")continue;const w=f(p.endpoints?.[0]),y=f(p.endpoints?.[1]),x=Uo(p.endpoints?.[0]?.cardinality,p.endpoints?.[1]?.cardinality);for(const N of w)for(const g of y){const v=[N.viaInterface,g.viaInterface].filter(V=>V!==null),E=N.ifaceNode??u(N.cls),j=g.ifaceNode??u(g.cls);if(!rl({edgeName:p.name,aClass:N.cls??"",bClass:g.cls??"",viaInterfaces:v},n,s)||E===j)continue;const S=h(N)!==h(g),$=v.length>0,R=S?"oklch(0.72 0.16 35)":"oklch(0.62 0.07 264)";m.push({id:`edge-${p.name}__${E}__${j}`,source:E,target:j,type:"floating",data:{label:p.name,edgeClass:p.name,ownerDomainId:e.domainId,polymorphic:$},markerStart:x.markerStart,markerEnd:x.markerEnd,style:{stroke:R,strokeWidth:S?2.4:1.8,...$?{strokeDasharray:"7 4"}:{}}})}}for(const[p,w]of Object.entries(i.classes))if(!(w.type!=="node"||De(ln(p),n)))for(const y of w.implements??[]){if(!r(y))continue;const x=u(p),N=`iface.${y}`;x!==N&&m.push({id:`implements-${p}__${y}`,source:x,target:N,type:"floating",data:{kind:"implements",ownerDomainId:e.domainId},markerEnd:{type:Je.ArrowClosed,color:$n,width:16,height:16},style:{stroke:$n,strokeWidth:1.6,strokeDasharray:"7 4"}})}for(const[p,w]of Object.entries(i.interfaces))if(r(p))for(const y of w.extends??[])r(y)&&m.push({id:`extends-${p}__${y}`,source:`iface.${p}`,target:`iface.${y}`,type:"floating",data:{label:"extends",kind:"extends",ownerDomainId:e.domainId},markerEnd:{type:Je.ArrowClosed,color:$n,width:16,height:16},style:{stroke:$n,strokeWidth:1.6,strokeDasharray:"2 4"}});return{nodes:d,edges:m}}function lw({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=se(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:re("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(Ju,{className:"h-3 w-3"})}),a.jsx(bs,{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(gu,{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(ve,{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:`interface ${l}`,onClick:d=>{d.stopPropagation(),X.getState().domainId!==t.domainId&&s(t.domainId),n(`interface.${l}`)},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]},l))})})]}),a.jsx(ke,{type:"source",position:q.Bottom,className:"!opacity-0"})]})}function dw({data:e}){const t=e,n=X(i=>i.domainId===t.domainId&&i.selectedClass===`interface.${t.name}`),o=se(i=>i.transform[2])<.5;return a.jsxs("div",{"data-domain-id":t.domainId,className:re("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(bs,{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 ro({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:re("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(bs,{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(cs,{className:"h-3.5 w-3.5"}):a.jsx(as,{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",onClick:c=>{c.stopPropagation(),X.getState().domainId!==t.domainId&&s(t.domainId),n(`interface.${r}`)},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]},r))]})]})}function uw({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(ve,{svg:t.icon,className:"h-4 w-4"}):a.jsx(it,{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 fw({data:e}){const t=e,n=t.kind==="kernel"?285:158,s=t.definition==="interface"?ze:Pe;return a.jsxs("div",{className:"w-full h-full rounded-lg border bg-card flex items-center gap-1.5 px-2 shadow-sm",style:{borderLeft:`3px solid oklch(0.72 0.14 ${n})`},children:[a.jsx(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 hw({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 pw({data:e}){const t=e;return a.jsx(pl,{threads:t.comments,anchor:t.anchor,excerpt:t.excerpt,className:"nodrag nopan"})}const hl={classNode:lw,interfaceNode:dw,group:ro,moduleNode:ro,extDomain:uw,extMember:fw,internalRegion:hw,canvasComment:pw};function pl({threads:e,anchor:t,excerpt:n,className:s}){const[o,i]=k.useState(!1);if(e.length===0)return null;const r=e.some(l=>l.status==="open")?"open":"resolved",c=e.some(l=>l.orphaned);return a.jsxs(Pt,{modal:!1,open:o,onOpenChange:i,children:[a.jsx(co,{asChild:!0,children:a.jsxs("button",{type:"button",title:"Schema canvas comments",onClick:l=>{l.stopPropagation(),i(d=>!d)},className:re("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(Bi,{className:"h-3 w-3"}),e.length]})}),a.jsx(zt,{side:"top",align:"center",className:"w-80",onInteractOutside:l=>l.preventDefault(),children:a.jsx(lo,{anchor:t,excerpt:n,threads:e,onClose:()=>i(!1)})})]})}function mw(e,t,n,s){let o=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY;for(const g of e){if(g.parentId)continue;const v=s?.[g.id]??g.position,E=g.style?.width??200,j=g.style?.height??120;o=Math.min(o,v.x),i=Math.max(i,v.x+E),r=Math.min(r,v.y),c=Math.max(c,v.y+j)}Number.isFinite(o)||(o=0,r=0,i=400,c=400);const l=56,d=o-l,u=r-l,f=i-o+2*l,h=new Map((n??[]).map(g=>[g.origin,g])),m=36,p=44,w=8,y=d+f+96,x=[];let N=u+24;for(const g of t){const v=h.get(g.origin),E=m+g.members.length*(p+w)+8,j=`extdom.${g.origin}`;x.push({id:j,type:"extDomain",position:s?.[j]??{x:y,y:N},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,$)=>{x.push({id:`extmember.${g.origin}.${S.name}`,type:"extMember",parentId:j,extent:"parent",draggable:!1,position:{x:12,y:m+$*(p+w)},data:{name:S.name,kind:g.kind,definition:S.definition},style:{width:192,height:p}})}),N+=E+40}return{extNodes:x}}function gw(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 xw={};function yw(e,t,n,s,o,i,r,c){const l=s.ir;if(!l)return[];const d=[],u=f=>Ko(s,o,c,f);for(const f of e){if(!t.has(f.origin))continue;const h=`extmember.${f.origin}.${f.to}`;if(n.has(h))for(const m of Go(l,{types:[f.from]},u)){const p=m.viaInterface?[m.viaInterface]:[];if(!rl({edgeName:f.edge,aClass:m.cls??"",bClass:"",viaInterfaces:p},i,r))continue;const w=m.ifaceNode??(o.has(gt(s,m.cls))?`grp-${gt(s,m.cls)}`:`class.${m.cls}`);if(!n.has(w))continue;const y="oklch(0.72 0.16 35)",x=Uo(f.fromCard,f.toCard),N=p.length>0;d.push({id:`edge-${f.edge}__${w}__${h}`,source:w,target:h,type:"floating",data:{label:f.edge,edgeClass:f.edge,polymorphic:N},markerStart:x.markerStart,markerEnd:x.markerEnd,style:{stroke:y,strokeWidth:2,...N?{strokeDasharray:"7 4"}:{}}})}}return d}function Qo(e){return!e||!Number.isFinite(e.x)||!Number.isFinite(e.y)?null:{x:e.x,y:e.y}}function ww(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=Qo(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 vw(e){return(e??[]).filter(t=>{const n=t.anchorRefs.find(s=>s.ref==="section.schema");return!!n&&!Qo(n)})}function bw(e){return e.map(t=>{const n=Qo(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 Nw(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 jw({bundle:e,domainId:t,saved:n}){const{fitView:s,getNodes:o}=Bt(),i=X(B=>B.focusId),r=X(B=>B.focusClass),c=X(B=>B.panelOverlay),l=X(B=>B.setPanelOverlay),d=ho(t).all.length,u=ea(t).data?.detectedIntegrations?.length??0,f=ta(t).data,h=(f?.nodes.length??0)+(f?.edges.length??0),m=X(B=>B.selectClass),p=X(B=>B.selectedClass),w=X(B=>B.setFocus),y=X(B=>B.setOpenAnchor),x=X(B=>B.collapsedModules),N=X(B=>B.toggleModule),g=X(B=>B.hidden),v=X(B=>B.showInheritedEdges),E=X(B=>B.materializedInterfaces),j=X(B=>B.toggleInheritedEdges),S=X(B=>B.setVisibility),{data:$}=dn(),{data:R}=xo(t),{data:V}=mu(t),A=k.useRef(!1),[O,_]=k.useState([]),[b,C]=k.useState([]),[I,M]=k.useState(null),[D,P]=k.useState(!1),H=D?E:xw,L=k.useMemo(()=>fl(e,new Set(x),g,v,H),[e.schemaHash,e,x,g,v,H]),F=k.useMemo(()=>sl(e),[e]),z=k.useMemo(()=>nl(e),[e]),W=Object.keys(g).sort().join(",")+`|${v}|`+Object.keys(H).sort().join(",");k.useEffect(()=>{if(!p?.startsWith("class."))return;const B=gt(e,p.slice(6));x.includes(B)&&N(B)},[p,e,x,N]);const Y=is(),J=k.useRef(!1),{commitLayout:U}=ul(),T=k.useCallback(B=>{U(t,B)},[U,t]);k.useEffect(()=>{if(!V)return;const B=V,G=X.getState(),ne={hidden:B.hidden,showInheritedEdges:B.showInheritedEdges,materializedInterfaces:B.materializedInterfaces};Ii(ne,G)||S(ne),A.current=!0},[t,V,S]),k.useEffect(()=>{if(!A.current)return;const B=X.getState(),G={hidden:B.hidden,showInheritedEdges:B.showInheritedEdges,materializedInterfaces:B.materializedInterfaces},ne=Y.getQueryData(Be.visibility(t))??Uy;Ii(G,ne)||(Y.setQueryData(Be.visibility(t),G),Se.setVisibility(t,G).catch(()=>{}))},[g,v,E,t,Y]);const Z=k.useCallback(B=>{const G=L.nodes.map(we=>ll(we,B)),ne=F.filter(we=>Qy(we.origin,g)),{extNodes:fe}=mw(G,ne,$,B),ae=[...G,...fe],ye=new Set(ae.map(we=>we.id));_(ae),C(es([...L.edges,...yw(z,new Set(ne.map(we=>we.origin)),ye,e,new Set(x),g,v,H)]))},[L,F,g,$,z,e,x,v,H]),ee=k.useCallback(()=>{J.current||(J.current=!0,requestAnimationFrame(()=>{s({padding:.18,duration:400}),P(!0)}))},[s]),te=k.useRef(n);te.current=n;const K=n!==void 0;k.useEffect(()=>{const B=te.current;if(!B)return;const G=L.nodes.filter(ae=>B[ae.id]),ne=L.nodes.filter(ae=>!B[ae.id]);if(ne.length===0){Z(B),ee();return}if(G.length===0){let ae=!1;return Jn(L.nodes,L.edges).then(ye=>{if(ae)return;const we=so(ye);Z(we),T(we),ee()}),()=>{ae=!0}}const fe=dl(G.map(ae=>({node:ae,position:B[ae.id]})),ne);Z({...B,...fe}),T(fe),ee()},[L,K,F,z,$,W]);const Q=k.useCallback(B=>_(G=>ys(B.filter(ne=>ne.id!=="region"),G)),[]),oe=k.useCallback(B=>C(G=>ws(B,G)),[]),ie=k.useCallback((B,G)=>{const ne={[G.id]:{x:Math.round(G.position.x),y:Math.round(G.position.y),...Ns(G)}};if(G.parentId){const fe=o(),ae=fe.find(ye=>ye.id===G.parentId);if(ae){let ye=ae.measured?.width??(typeof ae.style?.width=="number"?ae.style.width:200),we=ae.measured?.height??(typeof ae.style?.height=="number"?ae.style.height:120);for(const at of fe)at.parentId===G.parentId&&(ye=Math.max(ye,at.position.x+(at.measured?.width??160)),we=Math.max(we,at.position.y+(at.measured?.height??88)));ne[ae.id]={x:Math.round(ae.position.x),y:Math.round(ae.position.y),w:Math.round(ye),h:Math.round(we)}}}T(ne)},[T,o]),ce=k.useCallback(async()=>{await Se.resetLayout(t).catch(()=>{});const B=await Jn(L.nodes,L.edges),G=so(B);Z(G),Y.setQueryData(Be.layout(t),{positions:G}),Se.setLayout(t,G).catch(()=>{}),requestAnimationFrame(()=>s({padding:.18,duration:400}))},[t,L,s,Z,Y]),ue=i??I,xe=k.useMemo(()=>ue?Nw(ue,b):null,[ue,b]),Ne=k.useMemo(()=>gw(O,e.overlay.origin),[O,e.overlay.origin]),Ee=k.useMemo(()=>ww(R?.comments),[R?.comments]),Ie=k.useMemo(()=>vw(R?.comments),[R?.comments]),Xe=k.useMemo(()=>bw(Ee),[Ee]),qe=k.useMemo(()=>{const B=O.map(ne=>{if(ne.type!=="classNode"&&ne.type!=="interfaceNode")return ne.className?{...ne,className:void 0}:ne;const fe=xe&&!xe.nodeIds.has(ne.id)?"is-dimmed":void 0;return ne.className===fe?ne:{...ne,className:fe}}),G=Ne?[Ne,...B]:B;return Xe.length?[...G,...Xe]:G},[O,xe,Ne,Xe]),Ze=k.useMemo(()=>b.map(B=>{const G=B.data?.edgeClass??B.id.replace(/^edge-/,""),ne=p===`class.${G}`,fe=xe?xe.edgeIds.has(B.id)?"is-on":"is-dimmed":void 0,ae=ne?re("is-selected",fe):fe;if(ne){const ye="var(--color-primary)";return{...B,className:ae,data:{...B.data,selected:!0},style:{...B.style,stroke:ye,strokeWidth:3},markerEnd:typeof B.markerEnd=="object"?{...B.markerEnd,color:ye}:B.markerEnd}}return B.className===ae&&!B.data?.selected?B:{...B,className:ae,data:{...B.data,selected:!1}}}),[b,xe,p]);return a.jsxs(Vo,{nodes:qe,edges:Ze,nodeTypes:hl,edgeTypes:Yo,onNodesChange:Q,onEdgesChange:oe,onNodeDragStop:ie,onNodeClick:(B,G)=>{G.id.startsWith("class.")?r(G.id):G.id.startsWith("iface.")?(m(`interface.${G.id.slice(6)}`),w(i===G.id?null:G.id)):G.id.startsWith("grp-")&&m(`module.${G.id.slice(4)}`)},onNodeMouseEnter:(B,G)=>(G.id.startsWith("class.")||G.id.startsWith("iface."))&&M(G.id),onNodeMouseLeave:()=>M(null),onEdgeClick:(B,G)=>{if(!G.id.startsWith("edge-"))return;const ne=G.data?.edgeClass??G.id.slice(5);m(`class.${ne}`)},onPaneClick:()=>{w(null),y(null)},minZoom:.15,nodesConnectable:!1,edgesFocusable:!0,proOptions:{hideAttribution:!0},children:[a.jsx(Fo,{gap:18,size:1,color:"oklch(0.3 0.01 270)"}),a.jsx(cl,{}),a.jsx(Bo,{className:"!bg-card !border !border-border [&_button]:!bg-card [&_button]:!border-border [&_button]:!fill-foreground",showInteractive:!1,children:a.jsx(Et,{onClick:ce,title:"Auto-arrange (ELK) — clears manual layout",children:a.jsx(sa,{className:"h-4 w-4 text-foreground"})})}),a.jsx(Wo,{pannable:!0,zoomable:!0,className:"!bg-card !border !border-border",nodeColor:B=>B.type==="classNode"?`oklch(0.6 0.13 ${B.data.hue})`:B.type==="interfaceNode"?"oklch(0.6 0.18 330)":"transparent",nodeStrokeWidth:0,maskColor:"oklch(0.17 0.01 270 / 0.7)"}),a.jsxs(rt,{position:"top-right",className:"flex gap-1.5",children:[Ie.length>0&&a.jsx(pl,{threads:Ie,anchor:{ref:"section.schema",kind:"section"},excerpt:"Schema canvas"}),a.jsxs(Ve,{size:"xs",variant:c==="domains"?"default":"outline",onClick:()=>l(c==="domains"?null:"domains"),title:"Imported domains — shown in the right panel",children:[a.jsx(it,{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(Ve,{size:"xs",variant:c==="views"?"default":"outline",onClick:()=>l(c==="views"?null:"views"),title:"Views — shown in the right panel",children:[a.jsx(un,{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(Ve,{size:"xs",variant:c==="integrations"?"default":"outline",onClick:()=>l(c==="integrations"?null:"integrations"),title:"Integrations — shown in the right panel",children:[a.jsx(wo,{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(Ve,{size:"xs",variant:v?"default":"outline",onClick:j,title:"Toggle inherited (interface-induced) edges",children:[a.jsx(Tt,{className:"h-3.5 w-3.5"})," Inherited"]}),a.jsx(Xc,{count:h})]})]})}const io="integration.request.",ml=e=>`${io}${e}`,kw=e=>e.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"integration";function Ew({name:e}){return a.jsx(wn,{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(be,{tone:"emerald",size:"sm",children:a.jsx(wo,{})}),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 Cw({slug:e,label:t}){return a.jsx(wn,{anchor:{ref:ml(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(be,{tone:"amber",size:"sm",children:a.jsx(wo,{})}),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 Sw({domainId:e,taken:t}){const{create:n}=Qi(e),s=X(f=>f.setOpenAnchor),[o,i]=k.useState(!1),[r,c]=k.useState(""),[l,d]=k.useState(""),u=()=>{const f=r.trim();if(!f)return;const h=ml(kw(f)),m=`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:m,firstRole:"user",type:"text"},{onSuccess:()=>{c(""),d(""),i(!1),s(h),Hn.success("Integration requested — add the why/how in the comment")},onError:p=>Hn.error(String(p))})};return a.jsxs(Pt,{open:o,onOpenChange:i,children:[a.jsx(uo,{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(vo,{className:"h-3.5 w-3.5"}),"Request an integration"]})}),a.jsxs(zt,{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 _w({domainId:e}){const{data:t}=ea(e),{data:n}=xo(e),s=t?.detectedIntegrations??[],o=k.useMemo(()=>new Set(s),[s]),i=k.useMemo(()=>{const r=new Set,c=[];for(const l of n?.comments??[])if(l.status==="open")for(const d of l.anchorRefs){if(!d.ref.startsWith(io))continue;const u=d.ref.slice(io.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(Vt,{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(Ew,{name:r},r))})]}),i.length>0&&a.jsxs(a.Fragment,{children:[s.length>0&&a.jsx(Ln,{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(Cw,{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(Ln,{className:"my-3 opacity-60"}),a.jsx(Sw,{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(xu,{className:"h-4 w-4"})}),t]})}function ao(e,t){return t?e.members.some(n=>n.selectId===t)?!0:e.children.some(n=>ao(n,t)):!1}function gl({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(xl,{node:o,depth:0,selected:t,onSelect:n,controls:s},o.path)),e.members.map(o=>a.jsx(yl,{m:o,depth:1,selected:t,onSelect:n,controls:s},o.selectId))]})}function xl({node:e,depth:t,selected:n,onSelect:s,controls:o}){const i=X(N=>N.collapsedModules),r=X(N=>N.toggleModule),c=o?.collapsedModules??i,l=o?.toggleModule??r,[d,u]=k.useState(!0),f=`module.${e.path}`,h=n===f,m=e.members.length>0,p=m?!c.includes(e.path)||ao(e,n):d||ao(e,n),w=()=>m?l(e.path):u(N=>!N),y={paddingLeft:8+t*12},x=p?Iu:fn;return a.jsxs("div",{children:[a.jsxs("div",{"data-anchor-ref":f,"data-anchor-excerpt":e.path,className:re("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:p?"Collapse":"Expand",children:p?a.jsx(as,{className:"h-3 w-3"}):a.jsx(cs,{className:"h-3 w-3"})}),a.jsxs("button",{type:"button",onClick:()=>s(f),className:re("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(Ft,{domainId:o?.domainId,anchorRef:{ref:f,kind:"section"},excerpt:e.path,className:"ml-1"})]}),p&&a.jsxs("div",{children:[e.children.map(N=>a.jsx(xl,{node:N,depth:t+1,selected:n,onSelect:s,controls:o},N.path)),e.members.map(N=>a.jsx(yl,{m:N,depth:t+1,selected:n,onSelect:s,controls:o},N.selectId))]})]})}function yl({m:e,depth:t,selected:n,onSelect:s,controls:o}){const i=n===e.selectId,r=e.kind==="interface",c=X(g=>De(e.ref,g.hidden)),l=X(g=>g.toggleHidden),d=X(g=>to(e.name,g.materializedInterfaces)),u=X(g=>g.toggleInterfaceMaterialized),f=o?De(e.ref,o.hidden):c,h=o?.toggleHidden??l,m=o?to(e.name,o.materializedInterfaces):d,p=o?.toggleInterfaceMaterialized??u,w=!r&&f,y=e.kind==="interface"?ze:e.kind==="edge"?Tt:Pe,x=e.kind==="interface"?"text-fuchsia-300":e.kind==="edge"?"text-amber-400":"text-sky-300",N=k.useRef(null);return k.useEffect(()=>{i&&N.current?.scrollIntoView({block:"nearest",behavior:"smooth"})},[i]),a.jsxs("div",{ref:N,"data-anchor-ref":e.selectId,"data-anchor-excerpt":`${e.kind} ${e.name}`,className:re("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(ve,{svg:e.icon,className:re("h-4 w-4 shrink-0",x)}):a.jsx(y,{className:re("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(),p(e.name)},title:m?"Collapse to badge":"Show as node",className:re("ml-1 shrink-0 rounded p-0.5 transition hover:bg-white/5",m?"text-fuchsia-300 opacity-100":"text-muted-foreground/60 opacity-0 hover:text-foreground group-hover:opacity-100"),children:m?a.jsx(Pe,{className:"h-3.5 w-3.5"}):a.jsx(Uu,{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:re("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(Ui,{className:"h-3.5 w-3.5"}):a.jsx(Ki,{className:"h-3.5 w-3.5"})}),a.jsx(Ft,{domainId:o?.domainId,anchorRef:{ref:e.selectId,kind:"schema"},excerpt:`${e.kind} ${e.name}`,className:"ml-1"})]})}const Gt={width:360,height:220},wl={width:200,height:120},An=52,Iw=48,ss=112,Mw=1900;function $w(e){const t=e.type==="classNode"||e.type==="interfaceNode"?{width:160,height:44}:e.type==="moduleNode"?{width:200,height:44}:wl;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 Aw(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=$w(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 Rw(e){const t=[];let n=0,s=0,o=0;for(const i of e)n>0&&n+i.size.width>Mw&&(n=0,s+=o+ss,o=0),t.push({x:n,y:s}),n+=i.size.width+ss,o=Math.max(o,i.size.height);return t}function Dw(e,t){const n=e.filter(i=>t[i.domainId]);if(n.length===0)return Rw(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+=ss;const c={x:s,y:Number.isFinite(o)?o:0};return s+=i.size.width,c})}function Pw(e,t,n,s){const o=e.map(r=>{const c=Aw(r.nodes),l=s[r.domainId]??{x:An-c.minX,y:An+Iw-c.minY},d={width:Math.max(Gt.width,c.maxX+l.x),height:Math.max(Gt.height,c.maxY+l.y)},u={width:Math.max(Gt.width,c.maxX+l.x+An),height:Math.max(Gt.height,c.maxY+l.y+An)},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=Dw(o,t);return o.map((r,c)=>({...r,position:i[c]}))}function vl(e){return e.data?.workspaceGeometry??null}function Ai(e,t){const n=vl(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)}:Ns(e)}}}:null}const bl=k.createContext(null);function zw({actions:e,children:t}){return a.jsx(bl.Provider,{value:e,children:t})}function Jo(){const e=k.useContext(bl);if(!e)throw new Error("Workspace nodes require WorkspaceNodeActionsProvider");return e}function Nl({nodeId:e,minimum:t,label:n,placement:s="module"}){const o=Jo();return a.jsx(iy,{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 Tw({id:e,data:t}){const n=Jo(),s=t;return a.jsxs("div",{"data-domain-id":s.domainId,title:s.active?void 0:`Click to activate ${s.origin}`,className:re("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:re("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(Nl,{nodeId:e,minimum:Gt,label:`Resize ${s.origin}`,placement:"domain"})]})}function Ri(e){const t=Jo(),n=vl(e),s=e.data;return a.jsxs("div",{className:"relative h-full w-full",children:[a.jsx(ro,{...e,data:{...s,onToggleModule:t.toggleModule}}),e.type==="group"&&n?.active&&a.jsx(Nl,{nodeId:e.id,minimum:wl,label:"Resize module"})]})}const Ow={...hl,group:Ri,moduleNode:Ri,workspaceDomain:Tw},Lw=216,Hw=48,jl=52,Vw=12,Di=40,Fw=e=>`workspace-external:${encodeURIComponent(e)}`,kl=(e,t)=>`workspace-external-member:${encodeURIComponent(e)}:${encodeURIComponent(t)}`;function Bw(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 Ww(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)+ss;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=>Bw(l,u,Di));if(!d)return l.position;c=d.position.y+d.size.height+Di}}function Yw(e,t,n){const s=[...e].sort((r,c)=>r.origin.localeCompare(c.origin)).map(r=>({...r,size:{width:Lw,height:Hw+r.members.length*jl+Vw}})),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??Ww(r,o,t,i);return c||i.push({position:l,size:r.size}),{...r,position:l}})}function Xw(e,t,n,s){const o=new Map((s??[]).map(c=>[c.origin,c])),i=Yw(e,t,n),r=[];for(const c of i){const l=o.get(c.origin),d=Fw(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:kl(c.origin,f.name),type:"extMember",parentId:d,extent:"parent",draggable:!1,position:{x:12,y:42+h*jl},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 qw="oklch(0.76 0.16 35)",Rn="oklch(0.72 0.18 330)",Zw=e=>`workspace-domain:${e}`,jt=(e,t)=>`workspace:${encodeURIComponent(e)}:${t}`;function Gw(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 Uw(e,t,n){const s=new Set(t),o=Gw(e,n),i=fl(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=so(await Jn(i.nodes,i.edges)):d={...r,...dl(c.map(u=>({node:u,position:r[u.id]})),l)},{input:e,collapsed:s,materialized:o,nodes:i.nodes.map(u=>ll(u,d)),edges:i.edges}}function os(e,t){const n=e.input.bundle.ir;return n?Go(n,{types:[t]},o=>Ko(e.input.bundle,e.collapsed,e.materialized,o)).filter(o=>!o.cls||!De(ln(o.cls),e.input.visibility.hidden)).map(o=>{const i=o.ifaceNode?o.ifaceNode:e.collapsed.has(gt(e.input.bundle,o.cls))?`grp-${gt(e.input.bundle,o.cls)}`:`class.${o.cls}`;return{nodeId:jt(e.input.summary.id,i),domainId:e.input.summary.id,className:o.cls,viaInterface:o.viaInterface}}):[]}function rs(e,t,n,s){const o=e.input.bundle.ir;if(!o)return[];if(o.classes[t]?.type==="node"||o.interfaces[t])return os(e,t);const i=o.imports[t];if(!i)return[];const r=n.get(i.origin)??[];if(r.length>1&&s.add(`Multiple selected folders declare ${i.origin}; ${t} stays external.`),r.length===1){const c=r[0],l=c.input.bundle.ir;if(i.definition==="interface"?!!l?.interfaces[t]:l?.classes[t]?.type==="node")return os(c,t);s.add(`${e.input.summary.origin} imports ${i.origin}.${t}, but the selected schema does not expose it.`)}return[{nodeId:kl(i.origin,t),domainId:null,className:null,viaInterface:null,unresolved:{origin:i.origin,name:t,definition:i.definition}}]}function Kw(e,t,n,s){return`workspace-edge:${encodeURIComponent(e)}:${t}:${n}:${s}`}function Qw(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.name,c.unresolved),d.ownerDomainIds.add(l),o.set(c.unresolved.origin,d)};for(const c of e){const l=c.input.bundle.ir;if(l)for(const d of Object.values(l.classes)){if(d.type!=="edge"||d.endpoints?.length!==2||De(ol(d.name),c.input.visibility.hidden))continue;const u=d.endpoints[0].types.flatMap(m=>rs(c,m,t,n)),f=d.endpoints[1].types.flatMap(m=>rs(c,m,t,n)),h=Uo(d.endpoints[0].cardinality,d.endpoints[1].cardinality);for(const m of u)for(const p of f){if(!(m.domainId!==c.input.summary.id||p.domainId!==c.input.summary.id)||m.nodeId===p.nodeId||m.viaInterface&&!e.find(N=>N.input.summary.id===m.domainId)?.input.visibility.showInheritedEdges||p.viaInterface&&!e.find(N=>N.input.summary.id===p.domainId)?.input.visibility.showInheritedEdges)continue;r(m,c.input.summary.id),r(p,c.input.summary.id);const y=Kw(c.input.summary.id,d.name,m.nodeId,p.nodeId);if(i.has(y))continue;i.add(y);const x=!!m.viaInterface||!!p.viaInterface;s.push({id:y,source:m.nodeId,target:p.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:qw,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)),ownerDomainIds:[...l.ownerDomainIds]}))}}function Jw(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=os(r,l)[0];if(u)for(const f of d.implements??[]){const h=c.imports[f];if(!(!h||h.origin==="kernel.astrale.ai"))for(const m of rs(r,f,t,n)){if(m.unresolved)continue;const p=`workspace-implements:${u.nodeId}:${m.nodeId}`;i({id:p,source:u.nodeId,target:m.nodeId,type:"floating",data:{kind:"implements",ownerDomainId:r.input.summary.id},markerEnd:{type:Je.ArrowClosed,color:Rn,width:16,height:16},style:{stroke:Rn,strokeWidth:1.7,strokeDasharray:"7 4"}})}}}for(const l of Object.keys(c.interfaces)){const d=os(r,l)[0];if(d)for(const u of c.interfaces[l]?.extends??[]){const f=c.imports[u];if(!(!f||f.origin==="kernel.astrale.ai"))for(const h of rs(r,u,t,n)){if(h.unresolved)continue;const m=`workspace-extends:${d.nodeId}:${h.nodeId}`;i({id:m,source:d.nodeId,target:h.nodeId,type:"floating",data:{label:"extends",kind:"extends",ownerDomainId:r.input.summary.id},markerEnd:{type:Je.ArrowClosed,color:Rn,width:16,height:16},style:{stroke:Rn,strokeWidth:1.7,strokeDasharray:"2 4"}})}}}}}return s}function ev(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,N=l.get(x)??[];N.push(y),l.set(x,N)}const d=Pw(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,N=u.get(x),g=Zw(x),v=x===t;f.push({id:g,type:"workspaceDomain",position:N.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:N.size.width,height:N.size.height}});for(const E of y.nodes){const j=!E.parentId,S=j?N.contentOffset:{x:0,y:0};f.push({...E,id:jt(x,E.id),parentId:j?g:jt(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:jt(x,E.id),source:jt(x,E.source),target:jt(x,E.target)})}const m=Qw(e,l,c),p=Jw(e,l,c),w=Xw(m.unresolved,d,s,r);return f.push(...w.nodes),h.push(...m.edges,...p),{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 tv(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 nv({domains:e,viewsCount:t,onToggleInherited:n}){const{fitView:s,getNode:o}=Bt(),{data:i}=dn(),r=X(z=>z.domainId)??e[0]?.input.summary.id??"",c=X(z=>z.selectedClass),l=X(z=>z.setDomain),d=X(z=>z.setPanelOverlay),u=X(z=>z.panelOverlay),f=ge(z=>z.domainPositions),h=ge(z=>z.externalPositions),m=ge(z=>z.domainSizes),p=ge(z=>z.domainContentOffsets),w=ge(z=>z.setDomainPosition),y=ge(z=>z.setDomainSize),x=ge(z=>z.ensureDomainPositions),N=ge(z=>z.ensureExternalPositions),g=ge(z=>z.ensureDomainContentOffsets),v=ge(z=>z.resetWorkspaceFrames),E=ge(z=>z.toggleModule),{commitLayout:j}=ul(),S=k.useRef(""),$=k.useRef(!1),R=k.useCallback((z,W)=>{if(z.startsWith("workspace-domain:")){y(z.slice(17),W);return}const Y=o(z);if(!Y||Y.type!=="group")return;const J=Ai(Y,W);J&&j(J.domainId,J.updates)},[j,o,y]),V=k.useCallback((z,W)=>{if(X.getState().domainId!==z){l(z);return}W&&X.getState().selectClass(W)},[l]),A=k.useCallback((z,W)=>{if(X.getState().domainId!==z){l(z);return}E(z,W)},[l,E]),O=k.useMemo(()=>({activateDomain:V,resizeNode:R,toggleModule:A}),[V,R,A]),_=k.useMemo(()=>ev(e,{activeDomainId:r,catalog:i,contentOffsets:p,domainPositions:f,domainSizes:m,externalPositions:h}),[r,i,p,f,m,e,h]),[b,C]=k.useState(_.nodes),[I,M]=k.useState(()=>es(_.edges));k.useEffect(()=>{if(x(_.domainPositions),N(_.externalPositions),g(_.contentOffsets),C(_.nodes),M(es(_.edges)),$.current){$.current=!1;const Y=requestAnimationFrame(()=>s({padding:.12,duration:420}));return()=>cancelAnimationFrame(Y)}const z=e.map(Y=>Y.input.summary.id).join("|");if(S.current===z)return;S.current=z;const W=requestAnimationFrame(()=>s({padding:.12,duration:420}));return()=>cancelAnimationFrame(W)},[e,g,x,N,s,_]);const D=k.useCallback(z=>C(W=>ys(z.filter(Y=>Y.type!=="remove"),W)),[]),P=k.useCallback(z=>M(W=>ws(z.filter(Y=>Y.type!=="remove"),W)),[]),H=e.every(z=>z.input.visibility.showInheritedEdges),L=k.useCallback((z,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=Ai(W);Y&&j(Y.domainId,Y.updates)},[j,w]),F=k.useMemo(()=>I.map(z=>{const W=z.data?.ownerDomainId,Y=z.data?.edgeClass;if(!(!!Y&&W===r&&c===`class.${Y}`))return z;const U="var(--color-primary)";return{...z,className:re(z.className,"is-selected"),data:{...z.data,selected:!0},style:{...z.style,stroke:U,strokeWidth:3},markerEnd:typeof z.markerEnd=="object"?{...z.markerEnd,color:U}:z.markerEnd}}),[r,I,c]);return a.jsx(zw,{actions:O,children:a.jsxs(Vo,{"data-testid":"workspace-schema-canvas",nodes:b,edges:F,nodeTypes:Ow,edgeTypes:Yo,onNodesChange:D,onEdgesChange:P,onNodeDragStop:L,onNodeClick:(z,W)=>{if(W.id.startsWith("workspace-domain:")){V(W.id.slice(17));return}const Y=tv(W.id);Y&&(Y.localId.startsWith("class.")?V(Y.domainId,Y.localId):Y.localId.startsWith("iface.")?V(Y.domainId,`interface.${Y.localId.slice(6)}`):Y.localId.startsWith("grp-")&&V(Y.domainId,`module.${Y.localId.slice(4)}`))},onEdgeClick:(z,W)=>{const Y=W.data?.ownerDomainId,J=W.data?.edgeClass;Y&&J&&V(Y,`class.${J}`)},onPaneClick:()=>X.getState().setFocus(null),minZoom:.08,nodesConnectable:!1,edgesFocusable:!0,onlyRenderVisibleElements:!0,proOptions:{hideAttribution:!0},children:[a.jsx(Fo,{gap:18,size:1,color:"oklch(0.3 0.01 270)"}),a.jsx(cl,{}),a.jsx(Bo,{className:"!border !border-border !bg-card [&_button]:!border-border [&_button]:!bg-card [&_button]:!fill-foreground",showInteractive:!1,children:a.jsx(Et,{onClick:()=>{$.current=!0,v()},title:"Reset and auto-pack workspace regions",children:a.jsx(sa,{className:"h-4 w-4 text-foreground"})})}),a.jsx(Wo,{pannable:!0,zoomable:!0,className:"!border !border-border !bg-card",nodeColor:z=>z.type==="classNode"?`oklch(0.6 0.13 ${z.data.hue})`:z.type==="interfaceNode"?"oklch(0.6 0.18 330)":z.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(rt,{position:"top-center",className:"max-w-xl",children:a.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-warning/30 bg-card/95 px-3 py-2 text-[11px] text-warning shadow-lg backdrop-blur",children:[a.jsx(mt,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),a.jsx("span",{children:_.diagnostics.join(" ")})]})}),a.jsxs(rt,{position:"top-right",className:"flex gap-1.5",children:[a.jsxs(Ve,{size:"xs",variant:"outline",disabled:!0,title:"Selected workspace domains",children:[a.jsx(go,{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(Ve,{size:"xs",variant:u==="views"?"default":"outline",onClick:()=>d(u==="views"?null:"views"),title:"Views across selected domains",children:[a.jsx(un,{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(Ve,{size:"xs",variant:H?"default":"outline",onClick:n,title:"Toggle inherited edges in every selected domain",children:[a.jsx(Tt,{className:"h-3.5 w-3.5"})," Inherited"]})]})]})})}function sv({domains:e,onToggleHidden:t}){const n=X(h=>h.domainId),s=X(h=>h.selectedClass),o=X(h=>h.setDomain),i=ge(h=>h.collapsedModules),r=ge(h=>h.badgeInterfaces),c=ge(h=>h.toggleModule),l=ge(h=>h.toggleInterface),[d,u]=k.useState({}),f=(h,m)=>{X.getState().domainId!==h&&o(h),m&&X.getState().selectClass(m)};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(go,{className:"h-3 w-3"})," Workspace modules"]}),e.map(h=>{const m=h.input.summary.id,p=n===m,w=!!d[m],y=Object.fromEntries(Object.keys(h.input.bundle.ir?.interfaces??{}).filter(g=>!(r[m]??[]).includes(g)).map(g=>[g,!0])),x={domainId:m,collapsedModules:i[m]??[],hidden:h.input.visibility.hidden,materializedInterfaces:y,toggleModule:g=>c(m,g),toggleHidden:g=>t(m,g),toggleInterfaceMaterialized:g=>l(m,g)},N=na(h.input.bundle);return a.jsxs("section",{className:"border-b border-border/40 last:border-b-0",children:[a.jsxs("div",{"data-domain-id":m,className:re("flex items-center gap-1 px-2 py-2 transition-colors",p?"bg-sky-400/[0.075]":"hover:bg-accent/30"),children:[a.jsx("button",{type:"button",onClick:()=>u(g=>{const v={...g};return v[m]?delete v[m]:v[m]=!0,v}),className:"rounded p-0.5 text-muted-foreground hover:bg-white/5",title:w?"Expand domain":"Collapse domain",children:w?a.jsx(cs,{className:"h-3.5 w-3.5"}):a.jsx(as,{className:"h-3.5 w-3.5"})}),a.jsx("button",{type:"button",onClick:()=>f(m),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}),p&&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(gl,{root:N,selected:p?s:void 0,onSelect:g=>f(m,g),controls:x})})]},m)})]})}const ov={positions:{}},rv={hidden:{},showInheritedEdges:!0,materializedInterfaces:{}};function iv(e,t){const n=vn({queries:e.map(r=>({queryKey:Be.bundle(r),queryFn:()=>Se.bundle(r)}))}),s=vn({queries:e.map(r=>({queryKey:Be.anatomy(r),queryFn:()=>Se.anatomy(r)}))}),o=vn({queries:e.map(r=>({queryKey:Be.layout(r),queryFn:()=>Se.layout(r)}))}),i=vn({queries:e.map(r=>({queryKey:Be.visibility(r),queryFn:()=>Se.visibility(r)}))});return k.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),m=n[f]?.data,p=s[f]?.data,w=n[f]?.error??s[f]?.error;if(w&&l.push(`${h?.origin??u}: ${String(w)}`),!h||!m||!p){d=d||!w;return}c.push({summary:h,bundle:m,anatomy:p,layout:o[f]?.data??ov,visibility:i[f]?.data??rv})}),{inputs:c,pending:d,errors:l}},[s,n,t,e,o,i])}function av({inputs:e}){const t=e.map(o=>({input:o,model:yu(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(Vt,{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(Ut,{icon:a.jsx(un,{}),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(ns,{domainId:o.summary.id,view:r,icon:c},`${o.summary.id}:${r.slug}`)})})]},o.summary.id))})]})})}const Pi=220,zi=620,cv=300;function Ti(e,t,n){return[e.summary.id,e.summary.origin,e.bundle.schemaHash,Object.keys(e.visibility.hidden).sort().join(","),e.visibility.showInheritedEdges,Object.entries(e.layout.positions).sort(([s],[o])=>s.localeCompare(o)).map(([s,o])=>`${s}:${o.x}:${o.y}:${o.w??""}:${o.h??""}`).join(","),t.slice().sort().join(","),n.slice().sort().join(",")].join("|")}function lv({domainIds:e}){const{data:t}=wu(),{inputs:n,pending:s,errors:o}=iv(e,t),i=is(),r=X(_=>_.domainId),c=X(_=>_.selectedClass),l=X(_=>_.selectClass),d=X(_=>_.setFocus),u=X(_=>_.panelOverlay),f=X(_=>_.setPanelOverlay),h=X(_=>_.setCanvasMode),m=ge(_=>_.collapsedModules),p=ge(_=>_.badgeInterfaces),[w,y]=k.useState([]),x=k.useRef(new Map),[N,g]=k.useState(()=>{try{const _=Number(localStorage.getItem("studio.workspaceModulesWidth"));if(Number.isFinite(_)&&_>=Pi&&_<=zi)return _}catch{}return cv});k.useEffect(()=>{h("schema"),X.getState().panelOverlay&&X.getState().panelOverlay!=="views"&&f(null)},[h,f]);const v=k.useMemo(()=>n.map(_=>Ti(_,m[_.summary.id]??[],p[_.summary.id]??[])).join("::"),[p,m,n]);k.useEffect(()=>{let _=!1;const b=new Set(n.map(C=>C.summary.id));for(const C of x.current.keys())b.has(C)||x.current.delete(C);return Promise.all(n.map(async C=>{const I=C.summary.id,M=m[I]??[],D=p[I]??[],P=Ti(C,M,D),H=x.current.get(I);if(H?.key===P)return{...H.projection,input:C};const L=await Uw(C,M,D);return _||x.current.set(I,{key:P,projection:L}),L})).then(C=>{_||y(C)}),()=>{_=!0}},[v]),k.useEffect(()=>{const _=b=>{b.key!=="Escape"||b.defaultPrevented||(d(null),l(void 0),f(null))};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[l,d,f]);const E=k.useCallback((_,b)=>{const C=n.find(M=>M.summary.id===_);if(!C)return;const I=b(C.visibility);i.setQueryData(Be.visibility(_),I),Se.setVisibility(_,I).catch(()=>{i.invalidateQueries({queryKey:Be.visibility(_)})})},[n,i]),j=k.useCallback((_,b)=>E(_,C=>{const I={...C.hidden};return I[b]?delete I[b]:I[b]=!0,{...C,hidden:I}}),[E]),S=k.useCallback(()=>{const _=!n.every(b=>b.visibility.showInheritedEdges);for(const b of n)E(b.summary.id,C=>({...C,showInheritedEdges:_}))},[n,E]),$=_=>{_.preventDefault();const b=_.clientX,C=N;let I=C;const M=P=>{I=Math.min(zi,Math.max(Pi,C+P.clientX-b)),g(I)},D=()=>{document.removeEventListener("pointermove",M),document.removeEventListener("pointerup",D),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem("studio.workspaceModulesWidth",String(I))}catch{}};document.addEventListener("pointermove",M),document.addEventListener("pointerup",D),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},R=n.find(_=>_.summary.id===r),V=n.reduce((_,b)=>_+b.anatomy.views.length,0),A=w.length===n.length&&n.length===e.length,O=w.map(_=>`${_.input.summary.id}:${_.input.bundle.schemaHash}`).join("|");return(s||!A)&&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:N},children:[a.jsx(Vt,{className:"h-full",children:a.jsx(sv,{domains:w,onToggleHidden:j})}),a.jsx("div",{role:"separator","aria-orientation":"vertical",onPointerDown:$,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(Ho,{children:a.jsx(nv,{domains:w,viewsCount:V,onToggleInherited:S})},O)}),u==="views"?a.jsx(dt,{onClose:()=>f(null),children:a.jsx(av,{inputs:n})}):c&&R?a.jsx(dt,{onClose:()=>l(void 0),children:a.jsx(Kc,{bundle:R.bundle,selected:c})}):null]})]})}const Oi=180,Li=560,dv=240;function hv({domainId:e}){const t=ge(s=>s.selectedDomainIds),n=t.includes(e)?t:[e,...t];return n.length>1?a.jsx(lv,{domainIds:n}):a.jsx(uv,{domainId:e})}function uv({domainId:e}){const{data:t,isLoading:n}=fo(e),{data:s}=vu(e),{data:o}=ta(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=ho(e),[m,p]=k.useState(()=>{try{const g=Number(localStorage.getItem("studio.modulesWidth"));if(Number.isFinite(g)&&g>=Oi&&g<=Li)return g}catch{}return dv}),w=g=>{g.preventDefault();const v=g.clientX,E=m;let j=E;const S=R=>{j=Math.min(Li,Math.max(Oi,E+(R.clientX-v))),p(j)},$=()=>{document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",$),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem("studio.modulesWidth",String(j))}catch{}};document.addEventListener("pointermove",S),document.addEventListener("pointerup",$),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[y,x]=k.useState(null);k.useEffect(()=>x(null),[e,l]),k.useEffect(()=>{const g=v=>{v.key!=="Escape"||v.defaultPrevented||(c(null),r(void 0),x(null),f(null))};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[c,r,f]);const N=k.useMemo(()=>t?.ir?na(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:m},children:[a.jsx(Vt,{className:"h-full",children:d?o&&a.jsx(jy,{core:o,bundle:t,selectedPath:y,onSelect:x}):N&&a.jsx(gl,{root:N,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(Ho,{children:d?o?a.jsx(by,{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(jw,{bundle:t,domainId:e,saved:s?.positions},e)},`${e}:${l}`)}),d?y&&o&&a.jsx(dt,{onClose:()=>x(null),children:a.jsx(ky,{core:o,bundle:t,selectedPath:y})}):u==="views"?a.jsx(dt,{onClose:()=>f(null),children:a.jsx(Vy,{domainId:e,model:h})}):u==="domains"?a.jsx(dt,{onClose:()=>f(null),children:a.jsx(sw,{domainId:e})}):u==="integrations"?a.jsx(dt,{onClose:()=>f(null),children:a.jsx(_w,{domainId:e})}):i?a.jsx(dt,{onClose:()=>r(void 0),children:a.jsx(Kc,{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{hv as SchemaSection};
|