@memoarchitect/architect 0.7.2 → 0.8.26
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 +1 -1
- package/dist/assets/{AiWorkspace-Bu9TlIWg.js → AiWorkspace-Z3BbnmaP.js} +1 -1
- package/dist/assets/{AnalysisWorkspace-CodmoI-v.js → AnalysisWorkspace-DjaUOo7U.js} +1 -1
- package/dist/assets/{ComplianceWizard-CTihkUi-.js → ComplianceWizard-DKxZ1z25.js} +1 -1
- package/dist/assets/DSMView-DJhmrXYm.js +5 -0
- package/dist/assets/Dashboard-CYT7KjqU.js +1 -0
- package/dist/assets/DhfDashboard-DacdOtkU.js +1 -0
- package/dist/assets/DhfWorkbench-CIhopT8J.js +69 -0
- package/dist/assets/DiagramCanvas-CLE_nv7Y.js +4 -0
- package/dist/assets/{DiagramEditor-UJDHcAUF.js → DiagramEditor-puQuE8gB.js} +2 -2
- package/dist/assets/DiagramToolbarControls-XMGLx08e.js +1 -0
- package/dist/assets/{ElementDetailView-10U0rr33.js → ElementDetailView-D5XvAL_i.js} +1 -1
- package/dist/assets/ExplorerTreeRow-DUmcEsqf.js +3 -0
- package/dist/assets/{ImportView-D8svP04Q.js → ImportView-9y1nhQS4.js} +1 -1
- package/dist/assets/{LayerGrid-DEe0Ryz-.js → LayerGrid-bhFpOIbe.js} +1 -1
- package/dist/assets/{LayerTable-CN_b2rDr.js → LayerTable-RuswZVUI.js} +1 -1
- package/dist/assets/{MaxGraphCanvas-bo8oPBct.js → MaxGraphCanvas-D3BXQK2y.js} +1 -1
- package/dist/assets/{ModelDiff-xe95oVua.js → ModelDiff-Cl2dhlk3.js} +1 -1
- package/dist/assets/{OntologyDecompositionDiagram-BL9R8bdB.js → OntologyDecompositionDiagram-aONGngg4.js} +1 -1
- package/dist/assets/{OntologyViewer-CtqNkkCn.js → OntologyViewer-VOrKTRuQ.js} +2 -2
- package/dist/assets/{RelationshipOverlay-DL0N8Vmk.js → RelationshipOverlay-B3AN-bM-.js} +1 -1
- package/dist/assets/{RelationshipsSection-BoJ0aUXe.js → RelationshipsSection-DggeGBKP.js} +1 -1
- package/dist/assets/{ReviewDashboard-DeTge2oC.js → ReviewDashboard--LMXZ3F4.js} +1 -1
- package/dist/assets/{ScenarioEditor-FAEYTHgP.js → ScenarioEditor-bB4iBbgO.js} +1 -1
- package/dist/assets/{StatisticsDashboard-BAZRqIPN.js → StatisticsDashboard-iXimfU20.js} +1 -1
- package/dist/assets/{SysmlCodeEditor-BBfup_Ni.js → SysmlCodeEditor-i0BHj3of.js} +117 -117
- package/dist/assets/{TabularView-I4LjHhoH.js → TabularView-DnIfq-TB.js} +1 -1
- package/dist/assets/TraceabilityMatrix-eilGn6Sr.js +3 -0
- package/dist/assets/UiScreensWorkspace-Cs1ivqzc.js +1 -0
- package/dist/assets/{WorkflowWizard-VwpEHt3R.js → WorkflowWizard-C7jI6C59.js} +1 -1
- package/dist/assets/index-CG-gfw-s.js +4067 -0
- package/dist/assets/index-DXB4CKwW.css +1 -0
- package/dist/assets/{index.es-ClbJxlAQ.js → index.es-DABt8CUc.js} +1 -1
- package/dist/assets/{jspdf.es.min-DZ68BGxk.js → jspdf.es.min-G-Vwo9yG.js} +3 -3
- package/dist/assets/{layout-providers-Dr743WlP.js → layout-providers-BSDYNZu0.js} +1 -1
- package/dist/assets/notation-scene-DLZms6VR.js +1 -0
- package/dist/assets/{reactflow-s7jmJtXx.js → reactflow-C9OlmOYw.js} +1 -1
- package/dist/assets/xlsx-CkFp8p6R.js +105 -0
- package/dist/index.html +3 -3
- package/dist-standalone/index.html +5504 -0
- package/lib/__tests__/standalone-distribution.test.d.ts +2 -0
- package/lib/__tests__/standalone-distribution.test.d.ts.map +1 -0
- package/lib/__tests__/standalone-distribution.test.js +51 -0
- package/lib/__tests__/standalone-distribution.test.js.map +1 -0
- package/lib/__tests__/supervised-child-args.test.js +21 -1
- package/lib/__tests__/supervised-child-args.test.js.map +1 -1
- package/lib/commands/build.d.ts.map +1 -1
- package/lib/commands/build.js +15 -18
- package/lib/commands/build.js.map +1 -1
- package/lib/commands/dev.d.ts +14 -0
- package/lib/commands/dev.d.ts.map +1 -1
- package/lib/commands/dev.js +40 -1
- package/lib/commands/dev.js.map +1 -1
- package/lib/feature-grants.d.ts.map +1 -1
- package/lib/feature-grants.js +3 -1
- package/lib/feature-grants.js.map +1 -1
- package/package.json +10 -6
- package/dist/assets/DSMView-BiC845df.js +0 -1
- package/dist/assets/Dashboard-CgnNLhKq.js +0 -1
- package/dist/assets/DhfDashboard-w-dJoJHU.js +0 -1
- package/dist/assets/DhfWorkbench-o6B_MT-0.js +0 -69
- package/dist/assets/DiagramCanvas-CqGqDbgT.js +0 -3
- package/dist/assets/DiagramToolbarControls-B2gZFJlg.js +0 -1
- package/dist/assets/ExplorerTreeRow-DqhF_qoO.js +0 -3
- package/dist/assets/TraceabilityMatrix-DbrvjqLN.js +0 -3
- package/dist/assets/UiScreensWorkspace-DDD_PyJs.js +0 -1
- package/dist/assets/editor.worker-DyuDvpVp.js +0 -26
- package/dist/assets/element-options-B7AgTB8R.js +0 -3
- package/dist/assets/index-BWMNo4wW.css +0 -1
- package/dist/assets/index-Bij8Q4Kg.js +0 -45
- package/dist/assets/notation-scene-DT8LpWVK.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var ko=Object.defineProperty;var Ao=(e,t,n)=>t in e?ko(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ht=(e,t,n)=>Ao(e,typeof t!="symbol"?t+"":t,n);import{h as Qt,Q as it,O as ce,U as vn,F as dt,V as pe,S as en,W as ne,X as ae,Y as eo,u as Se,j as Co}from"./index-CG-gfw-s.js";import{u as no,j as C,H as Ut,P as It}from"./reactflow-C9OlmOYw.js";import{a as yt}from"./zustand-CrhqMOHB.js";import{r as To,D as Fo}from"./layout-providers-BSDYNZu0.js";import{E as Oo}from"./ExplorerTreeRow-DUmcEsqf.js";function oo(e){return e&&e.charAt(0).toLowerCase()+e.slice(1)}function No(e){return new Set(e.map(oo))}const so=(e,t,n,s)=>e.y===t.y&&n.y===s.y&&e.y===n.y?Math.max(Math.min(e.x,t.x),Math.min(n.x,s.x))<Math.min(Math.max(e.x,t.x),Math.max(n.x,s.x)):e.x===t.x&&n.x===s.x&&e.x===n.x?Math.max(Math.min(e.y,t.y),Math.min(n.y,s.y))<Math.min(Math.max(e.y,t.y),Math.max(n.y,s.y)):!1,io=(e,t,n,s)=>{const o=e.y===t.y,i=n.y===s.y;if(o===i)return!1;const a=o?e:n,r=o?t:s,c=o?n:e,h=o?s:t;return c.x>Math.min(a.x,r.x)&&c.x<Math.max(a.x,r.x)&&a.y>Math.min(c.y,h.y)&&a.y<Math.max(c.y,h.y)},ro=26,Ue=(e,t,n)=>t==="left"?{x:e.x-n,y:e.y}:t==="right"?{x:e.x+n,y:e.y}:t==="top"?{x:e.x,y:e.y-n}:{x:e.x,y:e.y+n};function ao(e){const t=e.filter((n,s)=>s===0||Math.abs(n.x-e[s-1].x)>.01||Math.abs(n.y-e[s-1].y)>.01);return t.filter((n,s)=>s===0||s===t.length-1||!(t[s-1].x===n.x&&n.x===t[s+1].x||t[s-1].y===n.y&&n.y===t[s+1].y))}const Oe=e=>e==="left"||e==="right";function ze(e){const{source:t,target:n,sourceSide:s,targetSide:o}=e,i=Math.abs(t.x-n.x)+Math.abs(t.y-n.y),a=Math.min(ro,i/3),r=s&&a>.5?Ue(t,s,a):t,c=o&&a>.5?Ue(n,o,a):n,h=Math.abs(r.x-c.x)<.5||Math.abs(r.y-c.y)<.5?[]:Oe(s)===Oe(o)?Oe(s)||!s?[{x:(r.x+c.x)/2,y:r.y},{x:(r.x+c.x)/2,y:c.y}]:[{x:r.x,y:(r.y+c.y)/2},{x:c.x,y:(r.y+c.y)/2}]:Oe(s)?[{x:c.x,y:r.y}]:[{x:r.x,y:c.y}];return ao([t,r,...h,c,n])}function Bi(e){return new Map(e.map(t=>[t.id,ze(t)]))}const _o=12e3,Do=600,Po=90,Lo=.75,Ro=2e4,jo=96,Bo=1,$o=6,Ho=10,Ne=160,Wo=(e,t)=>e*73856093^t*19349663;function En(e,t,n,s,o){const i=Math.floor(e/Ne),a=Math.floor(n/Ne),r=Math.floor(t/Ne),c=Math.floor(s/Ne);for(let h=i;h<=a;h++)for(let g=r;g<=c;g++)o(Wo(h,g))}class co{constructor(){Ht(this,"buckets",new Map);Ht(this,"query",0)}add(t,n,s,o,i){const a={ax:t,ay:n,bx:s,by:o,owner:i,seen:0};En(Math.min(t,s),Math.min(n,o),Math.max(t,s),Math.max(n,o),r=>{const c=this.buckets.get(r);c?c.push(a):this.buckets.set(r,[a])})}near(t,n,s,o,i){const a=++this.query,r=[];return En(t,n,s,o,c=>{const h=this.buckets.get(c);if(h)for(const g of h)g.seen===a||g.owner===i||(g.seen=a,r.push(g))}),r}conflicts(t,n,s){const o=this.near(Math.min(t.x,n.x),Math.min(t.y,n.y),Math.max(t.x,n.x),Math.max(t.y,n.y),s);let i=0;for(const a of o){const r={x:a.ax,y:a.ay},c={x:a.bx,y:a.by};(so(t,n,r,c)||io(t,n,r,c))&&i++}return i}}class zo{constructor(t){Ht(this,"f");Ht(this,"state");Ht(this,"size",0);Ht(this,"poppedF",0);this.f=new Float64Array(t),this.state=new Int32Array(t)}get length(){return this.size}clear(){this.size=0}push(t,n){if(this.size===this.f.length){const o=new Float64Array(this.size*2),i=new Int32Array(this.size*2);o.set(this.f),i.set(this.state),this.f=o,this.state=i}let s=this.size++;for(this.f[s]=t,this.state[s]=n;s>0;){const o=s-1>>1;if(this.f[o]<=this.f[s])break;this.swap(o,s),s=o}}pop(){const t=this.state[0];if(this.poppedF=this.f[0],this.size--,this.size>0){this.f[0]=this.f[this.size],this.state[0]=this.state[this.size];for(let n=0;;){const s=n*2+1,o=s+1;let i=n;if(s<this.size&&this.f[s]<this.f[i]&&(i=s),o<this.size&&this.f[o]<this.f[i]&&(i=o),i===n)break;this.swap(i,n),n=i}}return t}swap(t,n){const s=this.f[t];this.f[t]=this.f[n],this.f[n]=s;const o=this.state[t];this.state[t]=this.state[n],this.state[n]=o}}function kn(e,t,n,s,o){const i=c=>{const h=[...c].sort((l,y)=>l-y),g=[];for(const l of h)(g.length===0||Math.abs(l-g[g.length-1])>.5)&&g.push(l);return g},a=(c,h)=>{if(c.length<=h)return c;const g=l=>l<s?s-l:l>o?l-o:0;return[...c].sort((l,y)=>g(l)-g(y)).slice(0,h).sort((l,y)=>l-y)},r=i([...e,...t]);for(let c=n.maxLanes;c>=1;c--){const h=[...r];for(let l=1;l<r.length;l++){const y=r[l]-r[l-1],w=Math.min(c,Math.floor(y/n.laneGap)-1);for(let m=1;m<=w;m++)h.push(r[l-1]+y*m/(w+1))}const g=i(h);if(g.length<=n.maxAxisCoords)return Float64Array.from(g)}return Float64Array.from(i([...e,...a(r,n.maxAxisCoords-e.length)]))}function Rt(e,t){let n=0,s=e.length-1,o=-1;for(;n<=s;){const i=n+s>>1;e[i]<=t?(o=i,n=i+1):s=i-1}return o}function le(e,t){const n=Rt(e,t+.25);return n>=0&&Math.abs(e[n]-t)<=.25?n:-1}const Go=e=>({laneGap:(e==null?void 0:e.laneGap)??Ho,maxLanes:(e==null?void 0:e.maxLanes)??$o,maxAxisCoords:(e==null?void 0:e.maxAxisCoords)??jo,heuristicWeight:(e==null?void 0:e.heuristicWeight)??Bo}),Yo=e=>({crossing:(e==null?void 0:e.crossing)??Do,overlap:(e==null?void 0:e.overlap)??_o,bend:(e==null?void 0:e.bend)??Po,detour:(e==null?void 0:e.detour)??Lo});function Ee(e,t,n=18,s="long-first",o={}){const i=Math.max(12,n*.75),a=Yo(o.costs),r=Go(o.lattice),c=S=>Math.abs(S.source.x-S.target.x)+Math.abs(S.source.y-S.target.y),h=e.map((S,E)=>({request:S,index:E})).sort((S,E)=>(s==="long-first"?1:-1)*(c(E.request)-c(S.request))),g=new Array(e.length);let l=new co;const y=new Uo,w=(S,E)=>{for(let v=1;v<E.length;v++)l.add(E[v-1].x,E[v-1].y,E[v].x,E[v].y,S)};for(const{request:S,index:E}of h){const v=Cn(S,t,l,E,n,i,y,a,r);g[E]=v,w(E,v)}const m=o.refineRounds??4,p=o.refineFraction??1,u=o.refineBudgetMs??150,M=performance.now();for(let S=0;S<m&&!(performance.now()-M>u);S++){const v=g.map((Z,H)=>({owner:H,crossings:An(Z,l,H)})).filter(Z=>Z.crossings>0).sort((Z,H)=>H.crossings-Z.crossings);if(v.length===0)break;const D=Math.max(1,Math.min(v.length,Math.ceil(e.length*p)));let K=!1;for(let Z=0;Z<D&&!(performance.now()-M>u);Z++){const H=v[Z].owner,B=Cn(e[H],t,l,H,n,i,y,a,r);An(B,l,H)<v[Z].crossings&&(g[H]=B,K=!0)}if(!K)break;l=Xo(g)}const I=new Map;return e.forEach((S,E)=>I.set(S.id,g[E])),I}function Xo(e){const t=new co;for(let n=0;n<e.length;n++)for(let s=1;s<e[n].length;s++)t.add(e[n][s-1].x,e[n][s-1].y,e[n][s].x,e[n][s].y,n);return t}function An(e,t,n){let s=0;for(let o=1;o<e.length;o++)s+=t.conflicts(e[o-1],e[o],n);return s}class Uo{constructor(){Ht(this,"blocked",new Uint8Array(0));Ht(this,"hClear",new Uint8Array(0));Ht(this,"vClear",new Uint8Array(0));Ht(this,"hCost",new Float64Array(0));Ht(this,"vCost",new Float64Array(0));Ht(this,"g",new Float64Array(0));Ht(this,"parent",new Int32Array(0));Ht(this,"heap",new zo(1024))}fit(t,n){const s=t*n;this.blocked.length<s&&(this.blocked=new Uint8Array(s),this.g=new Float64Array(s*3),this.parent=new Int32Array(s*3));const o=Math.max(0,t-1)*n,i=t*Math.max(0,n-1);this.hClear.length<o&&(this.hClear=new Uint8Array(o),this.hCost=new Float64Array(o)),this.vClear.length<i&&(this.vClear=new Uint8Array(i),this.vCost=new Float64Array(i)),this.blocked.fill(0,0,s),this.hClear.fill(1,0,o),this.hCost.fill(0,0,o),this.vClear.fill(1,0,i),this.vCost.fill(0,0,i),this.g.fill(Number.POSITIVE_INFINITY,0,s*3),this.parent.fill(-1,0,s*3),this.heap.clear()}}function Cn(e,t,n,s,o,i,a,r,c){const h=e.source,g=e.target,l=Math.abs(h.x-g.x)+Math.abs(h.y-g.y),y=Math.min(ro,l/3),w=!!e.sourceSide&&y>.5,m=!!e.targetSide&&y>.5,p=w?Ue(h,e.sourceSide,y):h,u=m?Ue(g,e.targetSide,y):g,M=(T,f)=>f.x>T.x-i&&f.x<T.x+T.width+i&&f.y>T.y-i&&f.y<T.y+T.height+i,I=Math.max(240,l*.35),S=Math.min(h.x,g.x),E=Math.max(h.x,g.x),v=Math.min(h.y,g.y),D=Math.max(h.y,g.y),K=[];for(const T of t)T.id===e.sourceNodeId||T.id===e.targetNodeId||T.x+T.width<S-I||T.x>E+I||T.y+T.height<v-I||T.y>D+I||M(T,h)||M(T,g)||K.push(T);const Z=[],H=[];for(const T of K)Z.push(T.x-i,T.x+T.width+i),H.push(T.y-i,T.y+T.height+i);const B=kn([p.x,u.x],[...Z,S-o,E+o,(p.x+u.x)/2],c,Math.min(p.x,u.x),Math.max(p.x,u.x)),Y=kn([p.y,u.y],[...H,v-o,D+o,(p.y+u.y)/2],c,Math.min(p.y,u.y),Math.max(p.y,u.y)),nt=B.length,ht=Y.length,ft=le(B,p.x),_t=le(Y,p.y),Bt=le(B,u.x),q=le(Y,u.y);if(nt<2||ht<2||ft<0||_t<0||Bt<0||q<0)return ze(e);a.fit(nt,ht);const{blocked:Lt,hClear:$t,vClear:wt,hCost:jt,vCost:Dt,g:zt,parent:Yt,heap:mt}=a,At=nt-1,k=ht-1,P=i-1;for(const T of K){const f=T.x-P,d=T.x+T.width+P,x=T.y-P,A=T.y+T.height+P;let F=Rt(B,f)+1,O=Rt(B,d);for(;O>=0&&O<nt&&B[O]>=d;)O--;let N=Rt(Y,x)+1,L=Rt(Y,A);for(;L>=0&&L<ht&&Y[L]>=A;)L--;for(let pt=Math.max(0,N);pt<=L;pt++){const kt=pt*nt;for(let xt=Math.max(0,F);xt<=O;xt++)Lt[kt+xt]=1}const G=Math.max(0,Rt(Y,x)+1),tt=L,ot=Math.max(0,Rt(B,f)),vt=Math.min(At-1,O);for(let pt=G;pt<=tt;pt++){const kt=pt*At;for(let xt=ot;xt<=vt;xt++)$t[kt+xt]=0}const Et=Math.max(0,Rt(B,f)+1),gt=O,Pt=Math.max(0,Rt(Y,x)),Tt=Math.min(k-1,L);for(let pt=Et;pt<=gt;pt++){const kt=pt*k;for(let xt=Pt;xt<=Tt;xt++)wt[kt+xt]=0}}Lt[_t*nt+ft]=0,Lt[q*nt+Bt]=0;const R=n.near(B[0],Y[0],B[nt-1],Y[ht-1],s);for(const T of R)if(Math.abs(T.ax-T.bx)<.01){const d=T.ax,x=Math.min(T.ay,T.by),A=Math.max(T.ay,T.by),F=Rt(B,d),O=Math.max(0,Rt(Y,x)+1);let N=Rt(Y,A);for(;N>=0&&N<ht&&Y[N]>=A;)N--;if(F>=0&&F<At&&B[F]<d&&B[F+1]>d)for(let G=O;G<=N;G++)jt[G*At+F]+=r.crossing;const L=le(B,d);if(L>=0){const G=Math.max(0,Rt(Y,x)),tt=Math.min(k-1,N);for(let ot=G;ot<=tt;ot++)Dt[L*k+ot]+=r.overlap}}else{const d=T.ay,x=Math.min(T.ax,T.bx),A=Math.max(T.ax,T.bx),F=Rt(Y,d),O=Math.max(0,Rt(B,x)+1);let N=Rt(B,A);for(;N>=0&&N<nt&&B[N]>=A;)N--;if(F>=0&&F<k&&Y[F]<d&&Y[F+1]>d)for(let G=O;G<=N;G++)Dt[G*k+F]+=r.crossing;const L=le(Y,d);if(L>=0){const G=Math.max(0,Rt(B,x)),tt=Math.min(At-1,N);for(let ot=G;ot<=tt;ot++)jt[L*At+ot]+=r.overlap}}const J=_t*nt+ft,rt=q*nt+Bt,at=B[Bt],St=Y[q],Kt=c.heuristicWeight,Xt=(T,f)=>(Math.abs(B[T]-at)+Math.abs(Y[f]-St))*Kt,b=J*3+2;zt[b]=0,mt.push(Xt(ft,_t),b);const _=e.sourceSide,j=e.targetSide,W=(T,f)=>_?w?_==="left"?T<=0:_==="right"?T>=0:_==="top"?f<=0:f>=0:_==="left"?T<0:_==="right"?T>0:_==="top"?f<0:f>0:!0,z=(T,f)=>j?m?j==="left"?T>=0:j==="right"?T<=0:j==="top"?f>=0:f<=0:j==="left"?T>0:j==="right"?T<0:j==="top"?f>0:f<0:!0;let Q=0,$=-1;for(;mt.length>0;){const T=mt.pop(),f=T/3|0;if(f===rt){$=T;break}if(++Q>Ro)break;const d=T-f*3,x=zt[T];if(x+Xt(f%nt,f/nt|0)<mt.poppedF-.001)continue;const A=f%nt,F=f/nt|0;for(let O=0;O<4;O++){const N=O===0?-1:O===1?1:0,L=O===2?-1:O===3?1:0,G=A+N,tt=F+L;if(G<0||G>=nt||tt<0||tt>=ht)continue;const ot=tt*nt+G;if(Lt[ot]||f===J&&!W(N,L)||ot===rt&&!z(N,L))continue;let vt,Et;const gt=N!==0?0:1;if(N!==0){const Ft=F*At+(N>0?A:G);if(!$t[Ft])continue;vt=jt[Ft],Et=Math.abs(B[G]-B[A])}else{const Ft=A*k+(L>0?F:tt);if(!wt[Ft])continue;vt=Dt[Ft],Et=Math.abs(Y[tt]-Y[F])}const Pt=Xt(A,F),Tt=Xt(G,tt),pt=Et+vt+(d!==2&&d!==gt?r.bend:0)+(Tt>Pt?(Tt-Pt)*r.detour:0),kt=ot*3+gt,xt=x+pt;xt>=zt[kt]||(zt[kt]=xt,Yt[kt]=T,mt.push(xt+Tt,kt))}}if($<0)return ze(e);const U=[];for(let T=$;T>=0;T=Yt[T]){const f=T/3|0;if(U.push({x:B[f%nt],y:Y[f/nt|0]}),T===b)break}return U.reverse(),w&&U.unshift(h),m&&U.push(g),U.length>=2?ao(U):ze(e)}const ke=new Set(["composedOf","composes","decomposedBy","aggregation"]);function qe(e,t,n=ke){const s=new Map;for(const r of e)s.set(r.id,r);const o=new Map,i=new Set;for(const r of t)n.has(r.type)&&(!s.has(r.sourceId)||!s.has(r.targetId)||r.sourceId!==r.targetId&&(i.has(r.targetId)||(o.has(r.sourceId)||o.set(r.sourceId,[]),o.get(r.sourceId).push(r.targetId),i.add(r.targetId))));return{roots:[...s.keys()].filter(r=>!i.has(r)),childrenMap:o,elements:s}}function $i(e,t){const n=[],s=(o,i,a)=>{const r=e.childrenMap.get(o)??[];r.length>0&&i>=t&&n.push(o);for(const c of r)a.has(c)||(a.add(c),s(c,i+1,a))};for(const o of e.roots)s(o,0,new Set([o]));return n}function Hi(e){if(e.elements.size===0)return null;const t=new Set,n=o=>{if(!t.has(o)){t.add(o);for(const i of e.childrenMap.get(o)??[])n(i)}};e.roots[0]&&n(e.roots[0]);const s=[...e.elements.keys()].filter(o=>!t.has(o));return e.roots.length===1&&s.length===0?null:{rootIds:e.roots,disconnectedIds:s}}const Ko=new Set(["name","title","description","shortDescription","longDescription","sourceReference","rationaleText","semantics","protocolSemantics","queryDescription","dataSourceDescription","documentUsage","doc"]);function Vo(e,t=4){const n=[];e.shortId&&n.push({key:"id",value:e.shortId});for(const[s,o]of Object.entries(e.attributes)){if(n.length>=t)break;if(Ko.has(s)||s.includes(".")||s==="id"&&n.some(a=>a.key==="id"))continue;const i=o.split("::").pop().trim();!i||i.length>28||n.push({key:s,value:i})}return n.slice(0,t)}const ue={layout:(e,t)=>To(e,t)},Tn=(e,t)=>{const n=Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x),s=Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y);return n>0&&s>0?n*s:0},Zo=(e,t,n)=>{if(e.y===t.y){if(e.y<n.y||e.y>n.y+n.height)return 0;const s=Math.min(Math.max(e.x,t.x),n.x+n.width)-Math.max(Math.min(e.x,t.x),n.x);return Math.max(s,0)}if(e.x===t.x){if(e.x<n.x||e.x>n.x+n.width)return 0;const s=Math.min(Math.max(e.y,t.y),n.y+n.height)-Math.max(Math.min(e.y,t.y),n.y);return Math.max(s,0)}return 0};function Je(e,t){var r;const n=new Map,s=[],o=c=>c.slice(1).reduce((h,g,l)=>h+Math.abs(g.x-c[l].x)+Math.abs(g.y-c[l].y),0),i=e.flatMap(c=>c.points.slice(1).map((h,g)=>({edgeId:c.id,a:c.points[g],b:h}))),a=[...e].sort((c,h)=>o(h.points)-o(c.points));for(const c of a){const{points:h,width:g,height:l}=c;if(h.length<2)continue;const y=[];for(let p=1;p<h.length;p++){const u=h[p-1],M=h[p],I=Math.abs(M.x-u.x)+Math.abs(M.y-u.y),S=Math.abs(M.x-u.x)>=Math.abs(M.y-u.y),E=l/2+4;for(const v of I>=g*1.5?[.5,.3,.7]:[.5,.25,.75]){const D={x:u.x+(M.x-u.x)*v,y:u.y+(M.y-u.y)*v};for(const K of[-1,1])y.push({center:S?{x:D.x,y:D.y+K*E}:{x:D.x+K*(g/2+4),y:D.y},segmentLength:I})}}let w=((r=y[0])==null?void 0:r.center)??h[0],m=Number.POSITIVE_INFINITY;for(const p of y){const u={x:p.center.x-g/2,y:p.center.y-l/2,width:g,height:l};let M=0;for(const I of s)M+=Tn(u,I)*3;for(const I of t)M+=Tn(u,I)*4;for(const I of i)I.edgeId!==c.id&&(M+=Zo(I.a,I.b,u)*12*2.5);M+=Math.max(0,g*1.4-p.segmentLength)*2,M<m&&(m=M,w=p.center)}n.set(c.id,w),s.push({x:w.x-g/2,y:w.y-l/2,width:g,height:l})}return n}const Qe=20,tn=e=>e.length*6.4+12;function qo(e){const{connectors:t,rects:n}=e,s=e.obstacles??[...n.entries()].map(([w,m])=>({id:w,...m})),o=[],i=new Map;for(const w of t){const m=n.get(w.sourceId),p=n.get(w.targetId);if(!m||!p||w.sourceId===w.targetId)continue;const u=v=>({x:v.x+v.width/2,y:v.y+v.height/2}),M=Math.abs(u(p).x-u(m).x)>=Math.abs(u(p).y-u(m).y),I=M?u(p).x>=u(m).x:u(p).y>=u(m).y,S=M?I?"right":"left":I?"bottom":"top",E=M?I?"left":"right":I?"top":"bottom";i.set(w.id,{source:S,target:E}),o.push({connectorId:w.id,nodeId:w.sourceId,side:S,otherCentre:u(p)}),o.push({connectorId:w.id,nodeId:w.targetId,side:E,otherCentre:u(m)})}const a=new Map,r=(w,m)=>`${w}\0${m}`,c=new Map;for(const w of o){const m=`${w.nodeId}\0${w.side}`;c.set(m,[...c.get(m)??[],w])}for(const w of c.values()){const m=n.get(w[0].nodeId),p=w[0].side==="left"||w[0].side==="right",u=[...w].sort((S,E)=>p?S.otherCentre.y-E.otherCentre.y:S.otherCentre.x-E.otherCentre.x),M=(p?m.height:m.width)*.7,I=(p?m.y+m.height/2:m.x+m.width/2)-M/2;u.forEach((S,E)=>{const v=u.length===1?(p?m.height:m.width)/2:I+M*(E/(u.length-1))-(p?m.y:m.x);a.set(r(S.connectorId,S.nodeId),{x:S.side==="left"?m.x:S.side==="right"?m.x+m.width:m.x+(p?m.width/2:v),y:S.side==="top"?m.y:S.side==="bottom"?m.y+m.height:m.y+(p?v:m.height/2)})})}const h=[];for(const w of t){const m=i.get(w.id);m&&h.push({id:w.id,source:a.get(r(w.id,w.sourceId)),target:a.get(r(w.id,w.targetId)),sourceNodeId:w.sourceId,targetNodeId:w.targetId,sourceSide:m.source,targetSide:m.target})}const g=Ee(h,s,e.channelGap),l=Je(t.flatMap(w=>{const m=g.get(w.id);return w.label&&m&&m.length>=2?[{id:w.id,points:m,width:tn(w.label),height:Qe}]:[]}),s),y=new Map;for(const[w,m]of g)y.set(w,{points:m,labelPoint:l.get(w)});return y}function Jo(e,t,n=1.5){if(e<=0||t<=0)return Number.POSITIVE_INFINITY;const s=1+1.35*Math.abs(Math.log(e/t/n));return e*t*s}function Qo(e,t=1.25){return e<=1?Math.max(e,1):Math.min(e,Math.max(2,Math.round(Math.sqrt(e*t))))}function lo(e,t){const n=new Set(e.map(h=>h.id)),s=new Map,o=new Map(e.map(h=>[h.id,0]));for(const h of t)!n.has(h.source)||!n.has(h.target)||h.source===h.target||(s.has(h.source)||s.set(h.source,[]),s.get(h.source).push(h.target),o.set(h.target,(o.get(h.target)??0)+1));const i=e.map(h=>h.id),a=i.filter(h=>(o.get(h)??0)===0),r=[],c=new Set;for(;a.length;){const h=a.shift();if(!c.has(h)){c.add(h),r.push(h);for(const g of s.get(h)??[])o.set(g,(o.get(g)??1)-1),o.get(g)===0&&a.push(g)}}for(const h of i)c.has(h)||r.push(h);return r}function ts(e,t,n,s,o){const i=new Map(e.map(p=>[p.id,p])),a=lo(e,t).map(p=>i.get(p)),r=Qo(e.length,o),c=Math.ceil(e.length/r),h=a.map((p,u)=>{const M=Math.floor(u/r),I=u%r,S=M%2===0?I:r-1-I;return{node:p,row:M,col:S}}),g=Array.from({length:r},()=>0),l=Array.from({length:c},()=>0);for(const{node:p,row:u,col:M}of h)g[M]=Math.max(g[M],p.width),l[u]=Math.max(l[u],p.height);const y=g.map((p,u)=>u===0?0:g.slice(0,u).reduce((M,I)=>M+I,0)+n*u),w=l.map((p,u)=>u===0?0:l.slice(0,u).reduce((M,I)=>M+I,0)+s*u),m=h.map(({node:p,row:u,col:M})=>({...p,x:y[M]+(g[M]-p.width)/2,y:w[u]+(l[u]-p.height)/2}));return{strategy:"balanced-board",width:g.reduce((p,u)=>p+u,0)+n*Math.max(r-1,0),height:l.reduce((p,u)=>p+u,0)+s*Math.max(c-1,0),children:m}}function es(e,t,n,s){const o={x:e.x+e.width/2,y:e.y+e.height/2},i={x:t.x+t.width/2,y:t.y+t.height/2},a={x:n.x+n.width/2,y:n.y+n.height/2},r={x:s.x+s.width/2,y:s.y+s.height/2},c=(h,g,l)=>(g.x-h.x)*(l.y-h.y)-(g.y-h.y)*(l.x-h.x);return c(o,i,a)*c(o,i,r)<0&&c(a,r,o)*c(a,r,i)<0}function ns(e,t,n=1.5){const s=new Map(e.children.map(m=>[m.id,m]));let o=0,i=0,a=0,r=0;const c=t.filter(m=>s.has(m.source)&&s.has(m.target));for(const m of c){const p=s.get(m.source),u=s.get(m.target);o+=Math.abs(p.x+p.width/2-(u.x+u.width/2))+Math.abs(p.y+p.height/2-(u.y+u.height/2));const M=u.x+u.width/2-(p.x+p.width/2),I=Math.abs(u.y+u.height/2-(p.y+p.height/2));M<=0&&(a+=55e3),a+=Math.max(0,I-Math.max(M,0))*80,Math.abs(M)>8&&I>8&&(r+=18e3)}for(let m=0;m<c.length;m++)for(let p=m+1;p<c.length;p++){const u=c[m],M=c[p];u.source===M.source||u.source===M.target||u.target===M.source||u.target===M.target||es(s.get(u.source),s.get(u.target),s.get(M.source),s.get(M.target))&&i++}const h=Ee(c.map(m=>{const p=s.get(m.source),u=s.get(m.target);return{id:m.id,source:{x:p.x+p.width,y:p.y+p.height/2},target:{x:u.x,y:u.y+u.height/2},sourceNodeId:m.source,targetNodeId:m.target,sourceSide:"right",targetSide:"left"}}),e.children);let g=0,l=0,y=0;const w=[];for(const[m,p]of h){l+=Math.max(0,p.length-2);for(let u=1;u<p.length;u++)g+=Math.abs(p[u].x-p[u-1].x)+Math.abs(p[u].y-p[u-1].y),w.push({edgeId:m,a:p[u-1],b:p[u]})}for(let m=0;m<w.length;m++)for(let p=m+1;p<w.length;p++){const u=w[m],M=w[p];u.edgeId!==M.edgeId&&(so(u.a,u.b,M.a,M.b)||io(u.a,u.b,M.a,M.b))&&y++}return Jo(e.width,e.height,n)+o*18+a+r+i*Math.max(e.width*e.height*.35,5e4)+g*6+l*4e3+y*Math.max(e.width*e.height*.45,7e4)}async function Fn(e){const{nodes:t,edges:n}=e;if(t.length===0)return{strategy:"balanced-board",width:0,height:0,children:[]};const s=e.targetAspect??1.5,o=e.gapX??54,i=e.gapY??58,a=h=>{const g=new Map(t.map(M=>[M.id,M])),l=lo(t,n).map(M=>g.get(M));let y=0;const w=Math.max(...h==="RIGHT"?l.map(M=>M.height):l.map(M=>M.width));let m=l.map(M=>{const I={...M,x:h==="RIGHT"?y:(w-M.width)/2,y:h==="DOWN"?y:(w-M.height)/2};return y+=h==="RIGHT"?M.width+o:M.height+i,I});if(h==="RIGHT"&&n.some(M=>M.sourceAnchorY!==void 0&&M.targetAnchorY!==void 0)){new Map(m.map(v=>[v.id,v]));const M=new Map,I=[...m].sort((v,D)=>D.width*D.height-v.width*v.height)[0];M.set(I.id,0);let S=!0;for(;S;){S=!1;for(const v of n){if(v.sourceAnchorY===void 0||v.targetAnchorY===void 0)continue;const D=M.get(v.source),K=M.get(v.target);D!==void 0&&K===void 0?(M.set(v.target,D+v.sourceAnchorY-v.targetAnchorY),S=!0):K!==void 0&&D===void 0&&(M.set(v.source,K+v.targetAnchorY-v.sourceAnchorY),S=!0)}}m=m.map(v=>({...v,y:M.get(v.id)??v.y}));const E=Math.min(...m.map(v=>v.y));m=m.map(v=>({...v,y:v.y-E}))}const p=Math.max(...m.map(M=>M.x+M.width)),u=Math.max(...m.map(M=>M.y+M.height));return{strategy:h==="RIGHT"?"layered-right":"layered-down",width:p,height:u,children:m}};if(e.directedFlowAxis==="RIGHT")return a("RIGHT");if(e.directedFlowAxis==="DOWN")return a("DOWN");const r=[ts(t,n,o,i,s),a("RIGHT"),a("DOWN")];if(t.length>=3&&n.length>0)try{const h=new Map(t.filter(u=>{var M;return(M=u.ports)==null?void 0:M.length}).map(u=>[u.id,u])),g={left:"WEST",right:"EAST",top:"NORTH",bottom:"SOUTH"},l=new Set((e.graphPorts??[]).map(u=>u.id)),y=(e.graphPorts??[]).map(u=>({id:u.id,width:1,height:1,...u.side==="left"||u.side==="right"?{layoutOptions:{"elk.layered.layering.layerConstraint":u.side==="right"?"LAST_SEPARATE":"FIRST_SEPARATE"}}:{}})),m=(await ue.layout({id:`resolver-${e.id}`,layoutOptions:{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.edgeRouting":"ORTHOGONAL","elk.aspectRatio":String(s),"elk.padding":"[top=0,left=0,bottom=0,right=0]","elk.spacing.nodeNode":String(i),"elk.layered.spacing.nodeNodeBetweenLayers":String(o),"elk.layered.nodePlacement.strategy":"BRANDES_KOEPF","elk.layered.nodePlacement.favorStraightEdges":"true","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.crossingMinimization.semiInteractive":"true","elk.layered.thoroughness":"18","elk.layered.wrapping.strategy":t.length>5?"MULTI_EDGE":"OFF","elk.layered.wrapping.additionalEdgeSpacing":"18","elk.separateConnectedComponents":"true","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.randomSeed":"1"},children:[...y,...t.map(u=>{var M;return(M=u.ports)!=null&&M.length?{id:u.id,width:u.width,height:u.height,layoutOptions:{"elk.portConstraints":"FIXED_SIDE"},ports:u.ports.map(I=>({id:I.id,width:8,height:8,layoutOptions:{"elk.port.side":g[I.side]}}))}:{id:u.id,width:u.width,height:u.height}})],edges:n.map(u=>({id:u.id,sources:[h.has(u.source)&&u.sourcePort?u.sourcePort:u.source],targets:[h.has(u.target)&&u.targetPort?u.targetPort:u.target]}))},{providerId:e.layoutProviderId})).children??[],p=m.filter(u=>!l.has(u.id));if(p.length===t.length){const u=new Map(t.map(v=>[v.id,v])),M=Math.min(...p.map(v=>v.x??0)),I=Math.min(...p.map(v=>v.y??0)),S=p.map(v=>{const D=v.ports;return{...u.get(v.id),x:(v.x??0)-M,y:(v.y??0)-I,...D!=null&&D.length?{portY:new Map(D.map(K=>[K.id,K.y??0])),portX:new Map(D.map(K=>[K.id,K.x??0]))}:{}}}),E=m.filter(v=>l.has(v.id));r.push({strategy:"elk-layered",width:Math.max(...S.map(v=>v.x+v.width)),height:Math.max(...S.map(v=>v.y+v.height)),...E.length?{graphPortY:new Map(E.map(v=>[v.id,(v.y??0)-I]))}:{},children:S})}}catch{}const c=h=>{const g=ns(h,n,s);if(!e.preferBalancedLayout)return g;const l=Math.abs(Math.log(Math.max(h.width,1)/Math.max(h.height,1)/s));return g+h.width*h.height*l*2.8};return r.reduce((h,g)=>c(g)<c(h)?g:h)}async function os(e,t){var I;const n=Object.values(e.elements),s=t!=null&&t.viewpointFilter?n.filter(t.viewpointFilter):n,o=new Set(s.map(S=>S.id)),i=(I=t==null?void 0:t.relationshipTypes)!=null&&I.length?new Set(t.relationshipTypes.map(S=>S.toLowerCase())):void 0,a=e.relationships.filter(S=>o.has(S.sourceId)&&o.has(S.targetId)&&(!i||i.has(S.type.toLowerCase()))),r=s.length,c=r>60?"RIGHT":"DOWN",h=r>40?"24":r>20?"32":"40",g=r>40?"60":r>20?"80":"100",l=t!=null&&t.compartments?new Map(s.map(S=>[S.id,Vo(S)])):void 0,y=S=>Math.max(S.name.length*7.5+48,S.kind.length*6.8+48,130),w=S=>{const E=l==null?void 0:l.get(S.id);return 52+(E!=null&&E.length?E.length*15+10:0)},m={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":c,"elk.spacing.nodeNode":h,"elk.layered.spacing.nodeNodeBetweenLayers":g,"elk.layered.spacing.edgeNodeBetweenLayers":"24","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.compaction.postCompaction.strategy":"EDGE_LENGTH","elk.layered.wrapping.strategy":"MULTI_EDGE","elk.layered.wrapping.additionalEdgeSpacing":"16","elk.separateConnectedComponents":"true","elk.spacing.componentComponent":"56","elk.aspectRatio":"1.6","elk.padding":"[top=20, left=20, bottom=20, right=20]"},children:s.map(S=>({id:S.id,width:y(S),height:w(S)})),edges:a.map((S,E)=>({id:S.id||`e-${E}`,sources:[S.sourceId],targets:[S.targetId]}))};let p;try{p=await ue.layout(m,{providerId:t==null?void 0:t.layoutProviderId})}catch(S){console.warn("ELK layout failed, retrying without edge wrapping:",S),delete m.layoutOptions["elk.layered.wrapping.strategy"],delete m.layoutOptions["elk.layered.wrapping.additionalEdgeSpacing"],p=await ue.layout(m,{providerId:t==null?void 0:t.layoutProviderId})}const u=(p.children||[]).map(S=>{const E=e.elements[S.id],v=Qt[E==null?void 0:E.layer]||"#666",D=l==null?void 0:l.get(S.id);return{id:S.id,type:"diagramNode",position:{x:S.x||0,y:S.y||0},data:{label:(E==null?void 0:E.name)||S.id,kind:(E==null?void 0:E.kind)??"",layer:(E==null?void 0:E.layer)??"",construct:E==null?void 0:E.construct,color:v,...D!=null&&D.length?{compartments:D}:{}}}}),M=a.map((S,E)=>{const v=ce[S.type]||"#9CA3AF",D=S.type.toLowerCase(),K=S.type==="flow",Z=S.type==="succession",H=D==="composedof"||D==="decomposedby"||D==="aggregation"||D==="composes";return{id:S.id||`e-${E}`,source:S.sourceId,target:S.targetId,label:H?void 0:S.type,type:Z?"smoothstep":"default",animated:K,style:{stroke:v,strokeWidth:H?2.5:K?2:it.defaultWidth,strokeDasharray:H||K?void 0:S.type==="traceTo"?"5 3":void 0},labelStyle:{fontSize:"10px",fill:"#6B7280",fontWeight:500},labelBgPadding:it.labelBgPadding,labelBgBorderRadius:it.labelBgRadius,labelBgStyle:it.labelBgStyle,markerEnd:{type:H?"arrow":"arrowclosed",color:v,width:it.arrowSize,height:it.arrowSize}}});return{nodes:u,edges:M}}function ho(e){var a;const t=new Set((((a=e.registries)==null?void 0:a.kinds)??[]).filter(r=>{var c;return(c=r.namespace)==null?void 0:c.some(h=>h==="logical"||h==="implementation"||h==="realization")}).map(r=>r.name)),n=new Map;for(const r of Object.values(e.elements))t.has(r.kind)&&n.set(r.id,r);const s=new Map,o=new Set;for(const r of e.relationships)(r.type==="composedOf"||r.type==="aggregation")&&n.has(r.sourceId)&&n.has(r.targetId)&&(s.has(r.sourceId)||s.set(r.sourceId,[]),s.get(r.sourceId).push(r.targetId),o.add(r.targetId));return{roots:[...n.keys()].filter(r=>!o.has(r)),childrenMap:s,elements:n}}const qt=64,_e=100,On=110,Nn=300,_n=44;function nn(e){return Math.max(e.name.length*8+80,220)}async function ss(e,t){const n=t.tree??ho(e);if(n.roots.length===0)return{nodes:[],edges:[]};const s=t.positionCache??new Map,o=y=>t.nodeDirections.get(y)||"vertical",i=y=>(n.childrenMap.get(y)||[]).filter(w=>n.elements.has(w)),a=y=>{const w=n.elements.get(y),m=nn(w),p=i(y);if(!t.expandedNodes.has(y)||p.length===0)return{width:m,height:qt};const u=p.map(a);if(o(y)==="vertical"){const S=u.reduce((v,D)=>v+D.width,0)+(u.length-1)*_e,E=Math.max(...u.map(v=>v.height));return{width:Math.max(m,S),height:qt+On+E}}const M=Math.max(...u.map(S=>S.width)),I=u.reduce((S,E)=>S+E.height,0)+(u.length-1)*_n;return{width:m+Nn+M,height:Math.max(qt,I)}},r=[],c=[],h=ce.composedOf,g=(y,w,m,p)=>{const u=n.elements.get(y),M=nn(u),I=i(y),S=t.expandedNodes.has(y);let E=s.get(y);E||(E={x:m-M/2,y:p-qt/2},s.set(y,E));const v={element:u,layerColor:Qt[u.layer]||"#666",isExpanded:S,hasChildren:I.length>0,childCount:I.length,direction:o(y),onToggleExpand:()=>t.callbacks.onToggleExpand(y),onToggleDirection:()=>t.callbacks.onToggleDirection(y),showDirectionButton:!0,label:u.name};if(r.push({id:y,type:"decompositionNode",position:{x:E.x,y:E.y},data:v,style:{width:M,height:qt}}),w){const K=o(w);c.push({id:`decomp-${w}-${y}`,source:w,target:y,sourceHandle:K==="vertical"?"bottom":"right",targetHandle:K==="vertical"?"top":"left",type:"smoothstep",style:{stroke:h,strokeWidth:it.defaultWidth},markerEnd:{type:"arrowclosed",color:h,width:it.arrowSize,height:it.arrowSize}})}if(!S||I.length===0)return;const D=I.map(a);if(o(y)==="vertical"){const K=D.reduce((B,Y)=>B+Y.width,0)+(D.length-1)*_e;let Z=E.x+M/2-K/2;const H=E.y+qt+On+qt/2;I.forEach((B,Y)=>{g(B,y,Z+D[Y].width/2,H),Z+=D[Y].width+_e})}else{const K=E.x+M+Nn;let Z=E.y+qt+20;I.forEach((H,B)=>{const Y=n.elements.get(H);g(H,y,K+nn(Y)/2,Z+qt/2),Z+=D[B].height+_n})}};let l=0;for(const y of n.roots){if(!n.elements.has(y))continue;const w=a(y);g(y,null,l+w.width/2,100),l+=w.width+_e*2}return{nodes:r,edges:c}}const on=240,sn=80,se=20;function is(e,t){const n=t.tree??ho(e);if(n.roots.length===0)return{nodes:[],edges:[]};const s=[];function o(l,y,w,m,p){const u=n.elements.get(l);if(!u)return{width:0,height:0};const M=Qt[u.layer]||"#666",I=n.childrenMap.get(l)||[],S=I.length>0,E=t.expandedNodes.has(l);let v=on,D=sn;if(E&&S){let H=se,B=sn+se,Y=0,nt=0;for(const ht of I){if(!n.elements.has(ht))continue;const ft=o(ht,l,w+1,H,B);H+ft.width>800&&H>se&&(H=se,B+=Y+se,Y=0,i(ht),o(ht,l,w+1,H,B)),H+=ft.width+se,Y=Math.max(Y,ft.height),nt=Math.max(nt,H)}v=Math.max(on,nt),D=B+Y+se}const K=vn[w%vn.length],Z={element:u,layerColor:M,isExpanded:E,hasChildren:S,childCount:I.length,direction:"vertical",onToggleExpand:()=>t.callbacks.onToggleExpand(l),onToggleDirection:()=>{},showDirectionButton:!1,depthBgColor:K,isContainer:S,label:u.name};return s.push({id:l,type:"decompositionNode",position:{x:m,y:p},...y?{parentId:y,extent:"parent"}:{},data:Z,style:{width:E&&S?v:on,height:E&&S?D:sn}}),{width:v,height:D}}function i(l){const y=new Set([l]),w=m=>{for(const p of n.childrenMap.get(m)||[])y.add(p),w(p)};w(l);for(let m=s.length-1;m>=0;m--)y.has(s[m].id)&&s.splice(m,1)}let a=0;for(const l of n.roots){if(!n.elements.has(l))continue;const y=o(l,null,0,a,0);a+=y.width+40}const r=new Map(s.map(l=>[l.id,l])),c=[],h=new Set,g=l=>{if(h.has(l.id))return;const y=l.parentId?r.get(l.parentId):void 0;y&&g(y),h.add(l.id),c.push(l)};for(const l of s)g(l);return{nodes:c,edges:[]}}function rs(e){var a;const t=new Set((((a=e.registries)==null?void 0:a.kinds)??[]).filter(r=>{var c;return(c=r.namespace)==null?void 0:c.includes("functional")}).map(r=>r.name)),n=new Map;for(const r of Object.values(e.elements))t.has(r.kind)&&n.set(r.id,r);const s=new Map,o=new Set;for(const r of e.relationships)(r.type==="decomposedBy"||r.type==="composedOf")&&n.has(r.sourceId)&&n.has(r.targetId)&&(s.has(r.sourceId)||s.set(r.sourceId,[]),s.get(r.sourceId).push(r.targetId),o.add(r.targetId));return{roots:[...n.keys()].filter(r=>!o.has(r)),childrenMap:s,elements:n}}async function Wi(e,t){const n=rs(e);if(n.roots.length===0)return{nodes:[],edges:[]};const s=new Set,o=[];function i(g){if(n.elements.has(g)&&(s.add(g),t.expandedNodes.has(g)))for(const l of n.childrenMap.get(g)||[])n.elements.has(l)&&(o.push({parentId:g,childId:l}),i(l))}for(const g of n.roots)i(g);const a={id:"root",layoutOptions:{"elk.algorithm":"mrtree","elk.direction":"DOWN","elk.spacing.nodeNode":"40","elk.mrtree.searchOrder":"DFS"},children:[...s].map(g=>{const l=n.elements.get(g);return{id:g,width:Math.max(l.name.length*8+80,220),height:56}}),edges:o.map((g,l)=>({id:`fbs-${l}`,sources:[g.parentId],targets:[g.childId]}))},c=((await ue.layout(a,{providerId:t.layoutProviderId})).children||[]).map(g=>{const l=n.elements.get(g.id),y=Qt[l.layer]||"#E67E22",w=(n.childrenMap.get(g.id)||[]).length,m=t.nodeDirections.get(g.id)||"vertical",p={element:l,layerColor:y,isExpanded:t.expandedNodes.has(g.id),hasChildren:w>0,childCount:w,direction:m,onToggleExpand:()=>t.callbacks.onToggleExpand(g.id),onToggleDirection:()=>t.callbacks.onToggleDirection(g.id),showDirectionButton:!0,label:l.name};return{id:g.id,type:"decompositionNode",position:{x:g.x||0,y:g.y||0},data:p}}),h=o.map((g,l)=>{const y=t.nodeDirections.get(g.parentId)||"vertical";return{id:`fbs-e-${l}`,source:g.parentId,target:g.childId,sourceHandle:y==="vertical"?"bottom":"right",targetHandle:y==="vertical"?"top":"left",type:"default",style:{stroke:ce.decomposedBy,strokeWidth:it.defaultWidth},markerEnd:{type:"arrowclosed",color:ce.decomposedBy,width:it.arrowSize,height:it.arrowSize}}});return{nodes:c,edges:h}}const zi=["graph","tree","containment"];function Gi(e){const t=e==null?void 0:e.layoutHint;return t==="tree"||t==="containment"||t==="graph"?t:"graph"}function as(e,t){const n=Object.values(e.elements);return t?n.filter(t):n}function cs(e,t,n){const s=n!=null&&n.length?No(n):void 0;return qe(as(e,t),e.relationships,s)}async function Yi(e,t){if(t.mode==="graph")return os(e,{viewpointFilter:t.viewpointFilter,relationshipTypes:t.relationshipTypes,compartments:!0,layoutProviderId:t.layoutProviderId});const n=cs(e,t.viewpointFilter,t.hierarchyRelationshipTypes);return t.mode==="tree"?ss(e,{expandedNodes:t.expandedNodes,nodeDirections:t.nodeDirections,callbacks:t.callbacks,tree:n,positionCache:t.positionCache}):is(e,{expandedNodes:t.expandedNodes,callbacks:{onToggleExpand:t.callbacks.onToggleExpand},tree:n})}const Ke="__inner";function Xi(e){if(e&&!["left","right","top","bottom"].includes(e))return e.endsWith(Ke)?e.slice(0,-Ke.length):e}const Ui={in:"#16A34A",out:"#D97706",inout:"#2563EB"},ls={data:"#3498DB",energy:"#D97706",material:"#16A34A",control:"#6B7280"},ds=new Set(["flow","bind"]);function hs(e,t=""){return e||(ds.has(oo(t))?void 0:t)||void 0}function gs(e,t){const n=e??"";return/energy|power|voltage|current|thermal|heat/i.test(n)?"energy":/material|fluid|gas|liquid|drug|dose|batch|consumable/i.test(n)?"material":t&&/succession|control/i.test(t)?"control":"data"}const In=["left","right","top","bottom"],ve=e=>e==="left"||e==="right";function Ki(e){return e&&In.includes(e)?e:void 0}function go(e){return e.construct==="port"||e.kind.endsWith("Port")}function ye(e){var n;const t=(n=e.attributes.connectorType)==null?void 0:n.trim();return t||void 0}function Dn(e){var s,o;const t=(s=e.portSpec)==null?void 0:s.direction;if(t==="in"||t==="out"||t==="inout")return t;const n=(o=(e.attributes.direction??"").split("::").pop())==null?void 0:o.trim();if(n==="bidirectional")return"inout";if(n==="in"||n==="out"||n==="inout")return n}const Nt=24,Vi=Nt,rn=Nt,he=30,yn=48,ee=yn,Pn=44,De=12,us=14,fs=104,uo=5,an=(e,t)=>{const n=Math.max(e.length*6.1+10,t?t.length*5.2+10:0);return Math.min(Math.max(n,44),fs)},cn=30,Ge=30,ms=72,Me=ms+6,ps=26,ys=Nt/2+uo+ps,xe=14,ln=90,Ln=112,xs=72,ws=(e,t=7.2)=>e.length*t+20,bs=e=>Math.min(Math.max(ws(e,7.1),96),180);function fo(e){var s,o;const t=(s=e.portSpec)==null?void 0:s.direction,n=t==="in"||t==="out"||t==="inout"?t:(o=(e.attributes.direction??"").split("::").pop())==null?void 0:o.trim();if(n==="in")return"in";if(n==="out"||n==="inout"||n==="bidirectional"||/out(put)?$/i.test(e.name))return"out";if(/in(put)?$/i.test(e.name))return"in"}function Is(e,t,n){return fo(e)??(t>n?"out":"in")}const Ms=e=>e==="in"?"left":"right";function Ss(e,t){const n=e.filter(o=>!t.isConnected(o)&&!t.hasChildParts(o)&&t.portCount(o)===0),s=new Set(n);return{flowKids:e.filter(o=>!s.has(o)),orphanKids:n}}function vs(e,t,n){const s=new Map,o=new Map;for(const[r,c]of e)c.owner&&(t(c.owner)?s.set(r,c.owner):e.has(c.owner)&&o.set(r,c.owner));for(const r of n)!ke.has(r.type)||!e.has(r.targetId)||s.has(r.targetId)||o.has(r.targetId)||(t(r.sourceId)?s.set(r.targetId,r.sourceId):e.has(r.sourceId)&&o.set(r.targetId,r.sourceId));const i=new Map,a=(r,c)=>{const h=i.get(r)??s.get(r);if(h)return i.set(r,h),h;const g=o.get(r);if(!g||c.has(g))return;c.add(g);const l=a(g,c);return l&&i.set(r,l),l};for(const r of e.keys())a(r,new Set([r]));return{ownerPart:i,parentPort:o}}function dn(e,t,n){if(t==="none")return;if(t==="all")return e;let s=e;const o=new Set([s]);for(;n.has(s);){const i=n.get(s);if(o.has(i))break;o.add(i),s=i}return s}function Es(e,t,n){const s=new Set,o=i=>{if(!(s.has(i)||!t(i))){s.add(i);for(const a of e.get(i)??[])o(a)}};return o(n),s}function ks(e,t){const n=t.size??Nt,s=t.pitch??Ge,o=t.horizontalPitch??Me,i=t.nestedPitch??he,a=t.height??t.bodyBottom,r=new Map;for(const c of In){const h=e.filter(I=>t.sideOf(I)===c);if(h.length===0)continue;const g=h.length,l=ve(c),y=l?t.bodyTop:t.bodyLeft??0,w=l?t.bodyBottom:t.bodyRight??t.width,m=l?s:o,p=Math.max(w-y,0),u=l?t.minCenterY:y+m/2;let M=-1/0;h.forEach((I,S)=>{var v;let E=g===1&&l&&t.singleCenterY!==void 0?t.singleCenterY:y+(g===1?p/2:(S+.5)/g*p);E=Math.max(E,u,M+m),M=E+((((v=t.weightOf)==null?void 0:v.call(t,I))??1)-1)*i,r.set(I,{x:l?c==="left"?-n/2:t.width-n/2:E-n/2,y:l?E-n/2:c==="top"?-n/2:a-n/2,side:c})})}return r}function Rn(e,t,n){for(const s of In){const o=ve(s),i=o?t:n;if(!i)continue;const a=[...e].filter(([c,h])=>h.side===s&&i.has(c)).map(([c])=>c);if(a.length<2)continue;const r=a.map(c=>o?e.get(c).y:e.get(c).x).sort((c,h)=>c-h);[...a].sort((c,h)=>i.get(c)-i.get(h)).forEach((c,h)=>{const g=e.get(c);o?g.y=r[h]:g.x=r[h]})}}function As(e,t){return[...e.reduce((n,s)=>{const o=`${t(s.sourceId)}\0${t(s.targetId)}`,i=n.get(o);return i?i.count++:n.set(o,{rel:s,count:1}),n},new Map).values()].map(({rel:n,count:s})=>s===1?n:{...n,id:`bundle-${n.id}`,attributes:{...n.attributes,bundleCount:String(s)}})}async function Zi(e,t){var T;const n=Object.values(e.elements),s=t!=null&&t.viewpointFilter?n.filter(t.viewpointFilter):n,o=new Map,i=[];for(const f of s)go(f)?o.set(f.id,f):i.push(f);if(i.length===0)return{nodes:[],edges:[]};const a=(t==null?void 0:t.portDisplay)??"all",r=a!=="none",c=qe(i,e.relationships),h=t!=null&&t.focusId&&c.elements.has(t.focusId)?t.focusId:void 0,g=h?Es(c.childrenMap,f=>c.elements.has(f),h):null,l=f=>c.elements.has(f)&&(!g||g.has(f)),y=f=>{var d;return(d=t==null?void 0:t.collapsedNodes)!=null&&d.has(f)?[]:(c.childrenMap.get(f)??[]).filter(l)},{ownerPart:w,parentPort:m}=vs(o,l,e.relationships);for(const f of[...o.keys()])w.has(f)||o.delete(f);const p=f=>dn(f,"ports",m),u=new Map;for(const[f,d]of w)!o.has(f)||m.has(f)||(u.has(d)||u.set(d,[]),u.get(d).push(f));const M=new Map;if(a==="all")for(const[f]of m){if(!o.has(f))continue;const d=p(f);!o.has(d)||d===f||(M.has(d)||M.set(d,[]),M.get(d).push(f))}const I=f=>{var d;return 1+(((d=M.get(f))==null?void 0:d.length)??0)},S=(T=t==null?void 0:t.relationshipTypes)!=null&&T.length?new Set(t.relationshipTypes.map(f=>f.toLowerCase())):void 0,E=f=>o.has(f)||l(f),v=e.relationships.filter(f=>!ke.has(f.type)&&(!S||S.has(f.type.toLowerCase()))&&E(f.sourceId)&&E(f.targetId)&&f.sourceId!==f.targetId),D=f=>w.get(f)??f,K=f=>(o.has(f)?dn(f,a,m):void 0)??D(f),Z=(t==null?void 0:t.connectionDisplay)??"summary",H=new Set([...w].filter(([,f])=>f===(t==null?void 0:t.focusId)).map(([f])=>f)),B=H.size>0?v.filter(f=>H.has(f.sourceId)||H.has(f.targetId)):v,Y=Z==="none"?[]:Z==="all"?v:As(B,K),nt=new Set;for(const f of v)for(const d of[f.sourceId,f.targetId]){if(!o.has(d))continue;let x=d;for(;x&&!nt.has(x);)nt.add(x),x=m.get(x)}for(const[f,d]of u)u.set(f,d.filter(x=>nt.has(x)));const ht=new Set(v.filter(f=>l(f.sourceId)).map(f=>f.sourceId)),ft=new Set(v.filter(f=>l(f.targetId)).map(f=>f.targetId)),_t=new Map;for(const[f,d]of c.childrenMap)for(const x of d)l(x)&&_t.set(x,f);const Bt=new Map,q=f=>{const d=Bt.get(f);if(d)return d;const x=o.get(f);let A=fo(x);if(!A){const F=m.get(f);if(F&&o.has(F))A=q(F);else{let O=0,N=0;for(const L of Y)L.sourceId===f&&O++,L.targetId===f&&N++;A=Is(x,O,N)}}return Bt.set(f,A),A},Lt=t==null?void 0:t.portWalls,$t=new Map,wt=f=>{const d=$t.get(f);if(d)return d;const x=Lt==null?void 0:Lt.get(f),A=m.get(f),F=x??(A&&o.has(A)?wt(A):void 0)??Ms(q(f));return $t.set(f,F),F},jt=f=>{const d=A=>{const F=f.filter(O=>wt(O)===A).map(O=>{const N=o.get(O);return an((N==null?void 0:N.name)??"",N&&ye(N))});return F.length===0?us:Math.max(...F)+Nt+uo-Nt/2},x=A=>f.some(F=>wt(F)===A);return{left:d("left"),right:d("right"),top:0,bottom:x("bottom")?ys:0}},Dt=(f,d)=>f.filter(x=>wt(x)===d).reduce((x,A)=>x+(ve(d)?Ge:Me)+(I(A)-1)*he,0),zt=f=>bs(f.name),Yt=(f,d)=>{const x=jt(d),A=Math.max(Dt(d,"left"),Dt(d,"right"),0),F=Pn+cn,O=Math.max(F+A+8+x.bottom,xs+x.bottom),N=zt(f),L=Math.max(Dt(d,"top"),Dt(d,"bottom")),G=Math.max(x.left+Math.max(N,L)+x.right,Ln),tt=ks(d,{width:G,height:O,bodyTop:Pn,bodyBottom:O-De/2-x.bottom,bodyLeft:x.left,bodyRight:G-x.right,sideOf:wt,weightOf:I,minCenterY:F,singleCenterY:Math.max((O-x.bottom)/2,F)});return{width:G,height:O,childPos:new Map,portPos:tt}},mt=new Map,At=new Map,k=new Map,P=async f=>{const d=y(f),x=r?u.get(f)??[]:[],A=c.elements.get(f);if(d.length===0){const V=Yt(A,x);return mt.set(f,V),V}const F=new Map;for(const V of d)F.set(V,await P(V));const O=new Set(d),N=new Set(x),L=V=>{if(o.has(V)){const X=p(V);if(N.has(X))return X}let st=D(V);for(;st&&!O.has(st);)st=_t.get(st);return st},G=(V,st)=>{var et;if(!o.has(V)||w.get(V)!==st)return;const X=p(V);return(et=u.get(st))!=null&&et.includes(X)?X:void 0},tt=[],ot=new Set;Y.forEach((V,st)=>{const X=L(V.sourceId),et=L(V.targetId);X&&et&&X!==et&&(tt.push({id:`ic-${st}`,source:X,target:et,sourcePort:G(V.sourceId,X),targetPort:G(V.targetId,et)}),O.has(X)&&ot.add(X),O.has(et)&&ot.add(et))});const{flowKids:vt,orphanKids:Et}=Ss(d,{isConnected:V=>ot.has(V),hasChildParts:V=>(c.childrenMap.get(V)??[]).some(l),portCount:V=>{var st;return((st=u.get(V))==null?void 0:st.length)??0}}),gt=jt(x),Pt=new Map;let Tt=0,pt=0;if(vt.length>0){const V=X=>(u.get(X)??[]).map(et=>({id:et,side:wt(et)})),st=await Fn({id:`container-${f}`,nodes:vt.map(X=>({id:X,width:F.get(X).width,height:F.get(X).height,ports:V(X)})),edges:tt,graphPorts:x.map(X=>({id:X,side:wt(X)})),gapX:54,gapY:58,targetAspect:1.3,directedFlowAxis:"AUTO",preferBalancedLayout:!0,layoutProviderId:t==null?void 0:t.layoutProviderId});for(const X of st.children){const et=X.x+gt.left,Mt=X.y+ee;Pt.set(X.id,{x:et,y:Mt}),Tt=Math.max(Tt,et-gt.left+X.width),pt=Math.max(pt,Mt+X.height),(X.portY||X.portX)&&Rn(F.get(X.id).portPos,X.portY??new Map,X.portX)}st.graphPortY&&At.set(f,new Map([...st.graphPortY].map(([X,et])=>[X,et+ee])))}if(vt.length>0&&tt.length>0){const V=(ee+Math.max(pt,ee))/2,st=new Map(At.get(f)??[]),X=new Map(k.get(f)??[]),et=(ut,lt)=>{if(N.has(ut))return{x:X.get(ut)??Tt/2,y:st.get(ut)??V};const bt=Pt.get(ut),Ot=F.get(ut);if(!bt||!Ot)return;const ct=lt?Ot.portPos.get(lt):void 0;return ct?{x:bt.x+ct.x+Nt/2,y:bt.y+ct.y+Nt/2}:{x:bt.x+Ot.width/2,y:bt.y+Ot.height/2}},Mt=ut=>ut.reduce((lt,bt)=>lt+bt,0)/ut.length;for(let ut=0;ut<2;ut++){const lt=new Map,bt=new Map,Ot=(ct,Ct)=>{if(!(ct===void 0||Ct===void 0))for(const[Gt,me]of[[lt,Ct.y],[bt,Ct.x]])Gt.has(ct)||Gt.set(ct,[]),Gt.get(ct).push(me)};for(const ct of tt){const Ct=et(ct.source,ct.sourcePort),Gt=et(ct.target,ct.targetPort);Ot(ct.sourcePort??(N.has(ct.source)?ct.source:void 0),Gt),Ot(ct.targetPort??(N.has(ct.target)?ct.target:void 0),Ct)}for(const ct of vt){const Ct=F.get(ct),Gt=new Map,me=new Map;for(const Ce of Ct.portPos.keys()){const Te=lt.get(Ce);Te!=null&&Te.length&&Gt.set(Ce,Mt(Te));const Fe=bt.get(Ce);Fe!=null&&Fe.length&&me.set(Ce,Mt(Fe))}(Gt.size>1||me.size>1)&&Rn(Ct.portPos,Gt,me)}for(const ct of x){const Ct=lt.get(ct);Ct!=null&&Ct.length&&st.set(ct,Mt(Ct));const Gt=bt.get(ct);Gt!=null&&Gt.length&&X.set(ct,Mt(Gt))}}st.size>0&&At.set(f,st),X.size>0&&k.set(f,X)}if(Et.length>0){const V=Math.max(...Et.map(Ot=>F.get(Ot).width)),st=Math.max(Tt,V),X=Math.max(1,Math.min(Et.length,Math.floor((st+xe)/(V+xe))||1)),et=pt>0?pt+xe:ee;let Mt=0,ut=et,lt=0,bt=0;for(const Ot of Et){const ct=F.get(Ot),Ct=gt.left+Mt*(V+xe);Pt.set(Ot,{x:Ct,y:ut}),Tt=Math.max(Tt,Ct-gt.left+ct.width),lt=Math.max(lt,ct.height),bt=Math.max(bt,ut+ct.height),Mt++,Mt>=X&&(Mt=0,ut+=lt+xe,lt=0)}pt=Math.max(pt,bt)}const kt=Math.min(zt(A)+32,248),xt=Math.max(Dt(x,"top"),Dt(x,"bottom"));let Ft=Math.max(gt.left+Math.max(Tt,xt)+gt.right,kt,Ln),te=Math.max(pt+De+gt.bottom,ee+De+8+gt.bottom);const oe=new Map,Ae=At.get(f)??new Map,fe=k.get(f)??new Map;for(const V of["left","right"]){const st=x.filter(et=>wt(et)===V).sort((et,Mt)=>(Ae.get(et)??0)-(Ae.get(Mt)??0));let X=-1/0;for(const et of st){const Mt=Math.max((te-gt.bottom)/2,ee+cn),ut=ee+cn;let lt=Ae.get(et)??(st.length===1?Mt:ut);lt=Math.max(lt,ut,X+Ge);const bt=lt+(I(et)-1)*he;X=bt,oe.set(et,{x:V==="left"?-Nt/2:Ft-Nt/2,y:lt-Nt/2,side:V}),te=Math.max(te,bt+Ge/2+De+gt.bottom)}}for(const V of["top","bottom"]){const st=x.filter(lt=>wt(lt)===V).sort((lt,bt)=>(fe.get(lt)??0)-(fe.get(bt)??0));if(st.length===0)continue;const X=gt.left,Mt=Math.max(Ft-gt.right,X)-X;let ut=-1/0;for(const[lt,bt]of st.entries()){let Ot=X+(st.length===1?Mt/2:(lt+.5)/st.length*Mt);Ot=Math.max(Ot,X+Me/2,ut+Me),ut=Ot+(I(bt)-1)*he,oe.set(bt,{x:Ot-Nt/2,y:0,side:V}),Ft=Math.max(Ft,ut+Me/2+gt.right)}}for(const[,V]of oe)V.side==="right"&&(V.x=Ft-Nt/2),V.side==="top"&&(V.y=-Nt/2),V.side==="bottom"&&(V.y=te-Nt/2);const Vt={width:Ft,height:te,childPos:Pt,portPos:oe};return mt.set(f,Vt),Vt},R=h?[h]:c.roots.filter(f=>l(f));for(const f of R)await P(f);const J=new Map;if(R.length===1)J.set(R[0],{x:0,y:0});else{const f=N=>{let L=D(N);const G=new Set;for(;L&&_t.has(L)&&!G.has(L);)G.add(L),L=_t.get(L);return L&&R.includes(L)?L:R.includes(N)?N:L},d=new Set(R),x=[],A=(N,L)=>{var G;if(o.has(N)&&w.get(N)===L){const tt=p(N),ot=(G=mt.get(L))==null?void 0:G.portPos.get(tt);if(ot)return ot.y+Nt/2}return mt.get(L).height/2};Y.forEach((N,L)=>{const G=f(N.sourceId),tt=f(N.targetId);G&&tt&&G!==tt&&d.has(G)&&d.has(tt)&&x.push({id:`root-${L}`,source:G,target:tt,sourceAnchorY:A(N.sourceId,G),targetAnchorY:A(N.targetId,tt)})});const F=await Fn({id:"interconnection-roots",nodes:R.map(N=>({id:N,width:mt.get(N).width,height:mt.get(N).height})),edges:x,gapX:ln,gapY:ln,targetAspect:1.3,directedFlowAxis:"AUTO",preferBalancedLayout:!0,layoutProviderId:t==null?void 0:t.layoutProviderId});for(const N of F.children)J.set(N.id,{x:N.x,y:N.y});let O=0;for(const N of R)J.has(N)||(J.set(N,{x:O,y:0}),O+=mt.get(N).width+ln)}const rt=new Map;for(const[f,d]of u){const x=mt.get(f);if(!x)continue;const A=[];for(const F of d){const O=x.portPos.get(F);if(!O)continue;const N=o.get(F),L=M.get(F)??[];A.push({id:F,name:N.name,x:O.x,y:O.y,side:O.side,direction:Dn(N)??q(F),nestedCount:L.length||void 0,labelWidth:an(N.name,ye(N)),connectorType:ye(N)});const G=ve(O.side),tt=G?O.y+Nt/2:O.x+Nt/2,ot=(G?O.x:O.y)+(Nt-rn)/2;L.forEach((vt,Et)=>{const gt=o.get(vt),Pt=tt+he*(Et+1)-rn/2;A.push({id:vt,name:gt.name,x:G?ot:Pt,y:G?Pt:ot,side:O.side,direction:Dn(gt)??q(vt),size:rn,nested:!0,labelWidth:an(gt.name,ye(gt)),connectorType:ye(gt)})})}rt.set(f,A)}const at=[],St=new Map,Kt=(f,d,x,A={x:0,y:0},F,O=!1)=>{var Pt,Tt,pt;const N=c.elements.get(f),L=mt.get(f),G=(t==null?void 0:t.legend)&&((Pt=N.attributes[t.legend.attribute])==null?void 0:Pt.split("::").pop()),tt=G&&((Tt=t==null?void 0:t.legend)==null?void 0:Tt.colors.get(G))||Qt[N.layer]||"#64748B",ot=x??J.get(f),vt=d?{x:A.x+ot.x,y:A.y+ot.y}:ot;St.set(f,vt);const Et=(c.childrenMap.get(f)??[]).some(l),gt=Et;at.push({id:f,type:"interconnectionNode",position:ot,...d?{parentId:d,extent:O&&F?[[0,yn],[Math.max(0,F.width-L.width),Math.max(yn,F.height-L.height)]]:"parent"}:{},data:{label:N.name,kind:N.kind,layer:N.layer,color:tt,isContainer:gt,isFrame:!d&>,hasChildren:Et,isCollapsed:((pt=t==null?void 0:t.collapsedNodes)==null?void 0:pt.has(f))??!1,onToggleCollapse:Et&&(t!=null&&t.onToggleCollapse)?()=>t.onToggleCollapse(f):void 0,onDrillIn:Et&&d&&(t!=null&&t.onDrillIn)?()=>t.onDrillIn(f):void 0,ports:rt.get(f)??[],showPortText:(t==null?void 0:t.showPortText)!==!1,implicitIn:r&&ft.has(f),implicitOut:r&&ht.has(f),onPortMove:t!=null&&t.onPortMove?(kt,xt,Ft)=>t.onPortMove(f,kt,xt,Ft):void 0,onPortResize:t!=null&&t.onPortResize?(kt,xt,Ft)=>t.onPortResize(f,kt,xt,Ft):void 0,onPortSelect:t!=null&&t.onPortSelect?kt=>t.onPortSelect(kt):void 0,minWidth:L.width,minHeight:L.height},style:{width:L.width,height:L.height}});for(const[kt,xt]of L.childPos)Kt(kt,f,xt,vt,L,!d&>)};for(const f of R)Kt(f);const Xt=(f,d)=>{let x=f;const A=new Set;for(;x&&!A.has(x);){if(x===d)return!0;A.add(x),x=_t.get(x)}return!1},b=(f,d)=>{const x=w.get(f),A=D(d);return Xt(A,x)?`${f}${Ke}`:f},_=f=>o.has(f)?dn(f,a,m):void 0,j=(f,d,x)=>{var G;if(!r)return;const A=rt.get(f)??[];if(!A.length)return;const F=St.get(f),O=St.get(d),N=F&&O?Math.abs(O.x-F.x)>=Math.abs(O.y-F.y)?O.x>=F.x?"right":"left":O.y>=F.y?"bottom":"top":void 0,L=tt=>x==="source"?tt==="out"?0:tt==="inout"?1:4:tt==="in"?0:tt==="inout"?1:4;return(G=[...A].sort((tt,ot)=>L(tt.direction)-L(ot.direction)||+(tt.side!==N)-+(ot.side!==N)||tt.id.localeCompare(ot.id))[0])==null?void 0:G.id},W=Y.flatMap((f,d)=>{var fe;const x=o.has(f.sourceId)?w.get(f.sourceId):f.sourceId,A=o.has(f.targetId)?w.get(f.targetId):f.targetId;if(!mt.has(x)||!mt.has(A))return[];const F=_(f.sourceId)??j(x,A,"source"),O=_(f.targetId)??j(A,x,"target"),N=gs(f.flowItem,f.type),L=ls[N],G=Number(((fe=f.attributes)==null?void 0:fe.bundleCount)??0),tt=G>1?`${G} connections`:hs(f.flowItem,f.type),ot=F?b(F,f.targetId):"right",vt=O?b(O,f.sourceId):"left",Et=Vt=>Vt==="left"?"right":Vt==="right"?"left":Vt==="top"?"bottom":"top",gt=(Vt,V,st,X)=>{var Mt;if(!V)return X;const et=((Mt=(rt.get(Vt)??[]).find(ut=>ut.id===V))==null?void 0:Mt.side)??X;return st.endsWith(Ke)?Et(et):et},Pt=gt(x,F,ot,"right"),Tt=gt(A,O,vt,"left"),pt=f.id||`ic-e-${d}`,kt=(Vt,V,st,X)=>{const et=St.get(Vt),Mt=mt.get(Vt);if(V){const ut=(rt.get(Vt)??[]).find(lt=>lt.id===V);if(ut){const lt=ut.size??Nt,bt=(ut.nestedCount??0)*he/2,Ot=ve(ut.side),ct=et.x+ut.x+lt/2+(Ot?0:bt),Ct=et.y+ut.y+lt/2+(Ot?bt:0);return X==="left"?{x:ct-lt/2,y:Ct}:X==="right"?{x:ct+lt/2,y:Ct}:X==="top"?{x:ct,y:Ct-lt/2}:{x:ct,y:Ct+lt/2}}}return{x:et.x+(st?Mt.width:0),y:et.y+Mt.height/2}},xt=kt(x,F,!0,Pt),Ft=kt(A,O,!1,Tt),te=St.get(x),oe=St.get(A);return[{edge:{id:pt,source:x,target:A,sourceHandle:ot,targetHandle:vt,type:"interconnectionEdge",className:"ibd-interconnection-edge",zIndex:5,label:tt,animated:f.type==="flow",style:{stroke:L,strokeWidth:Math.max(2,it.defaultWidth)},labelStyle:{fontSize:dt.badge,fill:"#4B5563",fontWeight:600},labelBgPadding:it.labelBgPadding,labelBgBorderRadius:it.labelBgRadius,labelBgStyle:{...it.labelBgStyle,fillOpacity:.96,stroke:"#E2E8F0",strokeWidth:1},markerEnd:{type:"arrowclosed",color:L,width:it.arrowSize,height:it.arrowSize},data:{flowCategory:N,sourceOffset:{x:xt.x-te.x,y:xt.y-te.y},targetOffset:{x:Ft.x-oe.x,y:Ft.y-oe.y},sourcePortId:F,targetPortId:O,sourceSide:Pt,targetSide:Tt}},route:{id:pt,source:xt,target:Ft,sourceNodeId:x,targetNodeId:A,sourceSide:Pt,targetSide:Tt}}]}),z=at.filter(f=>!f.data.isFrame).map(f=>{const d=St.get(f.id),x=mt.get(f.id);return{id:f.id,x:d.x,y:d.y,width:x.width,height:x.height}}),Q=Ee(W.map(f=>f.route),z,28,"short-first"),$=Je(W.flatMap(({edge:f})=>{const d=Q.get(f.id);return f.label&&d&&d.length>=2?[{id:f.id,points:d,width:tn(String(f.label)),height:Qe}]:[]}),z),U=W.map(({edge:f})=>({...f,data:{...f.data,points:Q.get(f.id)??[],labelPoint:$.get(f.id),showLabel:(t==null?void 0:t.showConnectionText)!==!1}}));return{nodes:at,edges:U}}const re="control-in",ge="control-out",Wt={background:"transparent",border:"none",width:8,height:8};function Cs({onDrillIn:e,color:t,label:n}){return C.jsx("button",{onClick:s=>{s.stopPropagation(),e()},onDoubleClick:s=>s.stopPropagation(),className:"nodrag",title:`Open ${n} as its own diagram`,"aria-label":`Drill into ${n}`,style:{width:16,height:16,flexShrink:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${t}66`,borderRadius:4,background:"#FFFFFF",color:t,fontSize:10,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"↳"})}function Ts({data:e,selected:t}){const n=e,{nodeType:s,label:o,laneColor:i,layerColor:a,inPorts:r,outPorts:c}=n,[h,g]=yt.useState(!1);if(s==="start")return C.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:"#374151",border:"2px solid #374151",boxShadow:en.sm},children:C.jsx(Ut,{id:ge,type:"source",position:n.flowDirection==="vertical"?It.Bottom:It.Right,style:Wt})});if(s==="done")return C.jsxs("div",{style:{width:28,height:28,borderRadius:"50%",background:"#FFFFFF",border:"3px solid #374151",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:en.sm},children:[C.jsx("div",{style:{width:14,height:14,borderRadius:"50%",background:"#374151"}}),C.jsx(Ut,{id:re,type:"target",position:n.flowDirection==="vertical"?It.Top:It.Left,style:Wt})]});if(s==="decision"||s==="merge"){const I=n.flowDirection==="vertical",S=I?{...Wt,left:"50%",top:0,right:"auto",bottom:"auto",transform:"translate(-50%, -50%)"}:{...Wt,left:0,top:32,right:"auto",bottom:"auto",transform:"translate(-50%, -50%)"},E=I?{...Wt,left:"50%",top:64,right:"auto",bottom:"auto",transform:"translate(-50%, -50%)"}:{...Wt,left:64,top:32,right:"auto",bottom:"auto",transform:"translate(-50%, -50%)"};return C.jsxs("div",{title:o||(s==="decision"?"Decision node":"Merge node"),style:{width:64,height:64,position:"relative",overflow:"visible"},children:[C.jsx("svg",{width:64,height:64,style:{position:"absolute",inset:0,overflow:"visible"},"aria-hidden":"true",children:C.jsx("polygon",{points:"32,2 62,32 32,62 2,32",fill:"#DDEFB8",stroke:"#374151",strokeWidth:"2.25"})}),C.jsx("span",{style:{position:"absolute",top:70,left:-34,width:132,display:"block",textAlign:"center",fontSize:13,fontWeight:600,lineHeight:1.2,color:"#374151",overflowWrap:"anywhere",pointerEvents:"none"},children:o}),C.jsx(Ut,{id:re,type:"target",position:I?It.Top:It.Left,style:S}),C.jsx(Ut,{id:ge,type:"source",position:I?It.Bottom:It.Right,style:E})]})}if(s==="activityFinal"||s==="flowFinal"){const p=s==="activityFinal";return C.jsxs("div",{title:o||(p?"Activity final / terminate":"Flow final"),style:{width:28,height:28,borderRadius:"50%",background:"#FFFFFF",border:"2px solid #374151",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",overflow:"visible"},children:[p?C.jsx("div",{style:{width:14,height:14,borderRadius:"50%",background:"#374151"}}):C.jsx("span",{style:{color:"#374151",fontSize:22,lineHeight:1},children:"×"}),o&&C.jsx("span",{style:{position:"absolute",top:33,left:-46,width:120,textAlign:"center",fontSize:12,fontWeight:600,lineHeight:1.2,color:"#374151",pointerEvents:"none",overflowWrap:"anywhere"},children:o}),C.jsx(Ut,{id:re,type:"target",position:n.flowDirection==="vertical"?It.Top:It.Left,style:Wt})]})}if(s==="fork"||s==="join"){const p=n.flowDirection==="vertical";return C.jsxs("div",{title:s==="fork"?"Fork — split into concurrent flows":"Join — synchronize concurrent flows",style:{width:"100%",height:"100%",background:"#374151",borderRadius:3,boxShadow:en.sm},children:[C.jsx(Ut,{id:re,type:"target",position:p?It.Top:It.Left,style:Wt}),C.jsx(Ut,{id:ge,type:"source",position:p?It.Bottom:It.Right,style:Wt})]})}const l=i||a||"#9CA3AF",y=s==="accept"?"«accept action»":s==="send"?"«send action»":void 0;if(n.isFrame)return C.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:`${l}08`,border:`1.5px solid ${l}66`,borderRadius:10,boxShadow:t?"0 0 0 3px #2DD4A8":"none",position:"relative"},children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px 0"},children:[n.onToggleExpand&&C.jsx("button",{"aria-label":`Collapse ${o}`,className:"nodrag",onClick:p=>{p.stopPropagation(),n.onToggleExpand()},onDoubleClick:p=>p.stopPropagation(),style:{width:16,height:16,flexShrink:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${l}66`,borderRadius:4,background:"#FFFFFF",color:l,fontSize:11,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"−"}),n.onDrillIn&&C.jsx(Cs,{onDrillIn:n.onDrillIn,color:l,label:o}),C.jsx("span",{style:{fontSize:dt.md,fontWeight:700,color:l,whiteSpace:"nowrap"},children:o}),n.allocatedTo&&C.jsxs("span",{style:{fontSize:"9px",color:"#9CA3AF",whiteSpace:"nowrap"},children:["→"," ",n.allocatedTo]})]}),C.jsx(Ut,{id:re,type:"target",position:n.flowDirection==="vertical"?It.Top:It.Left,style:Wt}),C.jsx(Ut,{id:ge,type:"source",position:n.flowDirection==="vertical"?It.Bottom:It.Right,style:Wt})]});const w=18,m=Math.max(r.length*w,c.length*w,0);return C.jsxs("div",{onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),style:{background:"#FFFFFF",border:`1.5px solid ${l}`,borderRadius:3,minWidth:"140px",boxShadow:t?"0 0 0 3px #2DD4A8, 0 4px 12px rgba(45, 212, 168, 0.35)":h?`0 0 0 2px ${l}22`:"none",transition:"box-shadow 150ms ease",overflow:"hidden"},children:[C.jsxs("div",{style:{padding:"8px 14px",fontSize:dt.md,fontWeight:600,color:"#1a1a1a",background:`${l}0D`,borderBottom:m>0?"1px solid #E5E5E0":"none",textAlign:"center",...n.flowDirection==="vertical"?{whiteSpace:"nowrap"}:{whiteSpace:"normal",overflowWrap:"anywhere",lineHeight:1.25}},children:[y&&C.jsx("div",{style:{fontSize:10,color:l,fontStyle:"italic",marginBottom:2},children:y}),o,n.hasChildren&&n.onDrillIn&&C.jsx("button",{"aria-label":`Drill into ${o}`,title:`Open ${o} as its own diagram`,className:"nodrag",onClick:p=>{p.stopPropagation(),n.onDrillIn()},onDoubleClick:p=>p.stopPropagation(),style:{float:"right",marginLeft:4,width:18,height:18,padding:0,border:`1px solid ${l}`,borderRadius:2,background:"#FFFFFF",color:l,fontSize:11,fontWeight:700,lineHeight:"16px",cursor:"pointer"},children:"↳"}),n.hasChildren&&n.onToggleExpand&&C.jsx("button",{"aria-label":n.isExpanded?`Collapse ${o}`:`Expand ${o}`,onClick:p=>{p.stopPropagation(),n.onToggleExpand()},style:{float:"right",marginLeft:8,width:18,height:18,padding:0,border:`1px solid ${l}`,borderRadius:2,background:"#FFFFFF",color:l,fontSize:13,fontWeight:700,lineHeight:"16px",cursor:"pointer"},children:n.isExpanded?"−":"+"})]}),m>0&&C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"4px 0"},children:[C.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:r.map(p=>C.jsxs("div",{style:{fontSize:dt.badge,color:"#6B7280",paddingLeft:"8px",display:"flex",alignItems:"center",height:`${w}px`,gap:"4px"},children:[C.jsx(Ut,{id:`in:${p}`,type:"target",position:n.flowDirection==="vertical"?It.Top:It.Left,style:Wt}),p]},`in-${p}`))}),C.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px",alignItems:"flex-end"},children:c.map(p=>C.jsxs("div",{style:{fontSize:dt.badge,color:"#6B7280",paddingRight:"8px",display:"flex",alignItems:"center",height:`${w}px`,gap:"4px"},children:[p,C.jsx(Ut,{id:`out:${p}`,type:"source",position:n.flowDirection==="vertical"?It.Bottom:It.Right,style:Wt})]},`out-${p}`))})]}),n.allocatedTo&&C.jsxs("div",{style:{fontSize:"9px",color:"#9CA3AF",textAlign:"center",padding:"2px 6px",borderTop:"1px solid #F3F4F6",background:"#FAFAFA"},children:["→"," ",n.allocatedTo]}),C.jsx(Ut,{id:re,type:"target",position:n.flowDirection==="vertical"?It.Top:It.Left,style:Wt}),C.jsx(Ut,{id:ge,type:"source",position:n.flowDirection==="vertical"?It.Bottom:It.Right,style:Wt})]})}const qi=yt.memo(Ts);function jn(e,t,n,s,o){const i=e*o+s;return i>=0?0:Math.max(0,Math.min(-i/o,t-n))}const Bn=40;function Fs({data:e,selected:t,positionAbsoluteX:n,positionAbsoluteY:s,width:o,height:i}){const a=e,r=a.orientation==="column",[c,h,g]=no(l=>l.transform);return C.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:`${a.color}08`,border:t?"3px solid #2DD4A8":`1px solid ${a.color}30`,borderLeft:t?"3px solid #2DD4A8":r?`1px solid ${a.color}30`:`3px solid ${a.color}`,borderTop:t?"3px solid #2DD4A8":r?`3px solid ${a.color}`:`1px solid ${a.color}30`,borderRadius:pe.md,pointerEvents:"auto",cursor:a.inspectElementId?"pointer":"default",display:"flex"},children:C.jsx("div",{style:{...r?{width:"100%",height:Os,borderBottom:`1px solid ${a.color}24`}:{width:Ns,height:"100%",borderRight:`1px solid ${a.color}24`},background:`${a.color}0F`,borderRadius:r?`${pe.md}px ${pe.md}px 0 0`:`${pe.md}px 0 0 ${pe.md}px`,flexShrink:0}})})}const Ji=yt.memo(Fs),Os=30,Ns=34;function _s({data:e,positionAbsoluteX:t,positionAbsoluteY:n,width:s,height:o}){const i=e,a=i.orientation==="column",[r,c,h]=no(l=>l.transform),g=a?jn(n,o??0,Bn,c,h):jn(t,s??0,Bn,r,h);return C.jsx("div",{style:{width:"100%",height:"100%",display:"flex",pointerEvents:"none",alignItems:a?"flex-start":"center",justifyContent:a?"center":"flex-start"},children:C.jsx("div",{style:{writingMode:a?"horizontal-tb":"vertical-rl",transform:a?void 0:"rotate(180deg)",padding:a?"6px 12px":"12px 6px",fontSize:dt.xs,fontWeight:700,color:i.color,letterSpacing:"0.04em",textTransform:"uppercase",whiteSpace:"nowrap",background:g>0?"#FFFFFFEE":"transparent",borderRadius:4,...a?{marginTop:g}:{marginLeft:g}},children:i.label})})}const Qi=yt.memo(_s);function tr(e,t){const n=t.registries,s=new Set(e.filter(i=>!ne(i,n)).map(i=>i.id)),o=new Set;for(const i of t.relationships)i.type!=="flow"&&i.type!=="succession"||(s.has(i.sourceId)&&o.add(i.sourceId),s.has(i.targetId)&&o.add(i.targetId));return e.filter(i=>!ne(i,n)&&!o.has(i.id))}function mo(e,t,n=new Set,s){const o=Object.values(e.elements),a=(t?o.filter(t):o).filter(l=>ae(l,e.registries)!==void 0),r=a.filter(l=>l.parentAction);if(r.length===0)return a;const c=new Map(a.map(l=>[l.id,l])),h=[],g=l=>{const y=a.filter(w=>w.parentAction===l.id);if(n.has(l.id)&&y.length>0){for(const w of y)g(w);return}h.push(l)};if(s){for(const l of a.filter(y=>y.parentAction===s))g(l);return h}for(const l of r){const y=l.parentAction?c.get(l.parentAction):void 0;y!=null&&y.parentAction||g(l)}return h}function Ds(e,t,n=new Set,s){if(n.size===0)return new Map;const o=new Set(mo(e,t,n,s).map(g=>g.id)),i=Object.values(e.elements),a=t?i.filter(t):i,r=new Map;for(const g of a)g.parentAction&&(r.has(g.parentAction)||r.set(g.parentAction,[]),r.get(g.parentAction).push(g));const c=new Map,h=(g,l)=>{const y=[];for(const w of r.get(g)??[])l.has(w.id)||(l.add(w.id),o.has(w.id)?y.push(w.id):y.push(...h(w.id,l)));return y};for(const g of n){if(o.has(g))continue;const l=h(g,new Set([g]));l.length>0&&c.set(g,l)}return c}function Ps(e,t,n=new Set,s){const o=Object.values(e.elements),a=(t?o.filter(t):o).filter(m=>ae(m,e.registries)!==void 0),r=[],c=new Map,h=new Map,g=m=>a.filter(p=>p.parentAction===m),l=(m,p)=>{r.push(m),p&&(c.set(m.id,p),h.has(p)||h.set(p,[]),h.get(p).push(m.id));const u=g(m.id);if(!(u.length===0||!n.has(m.id))){h.set(m.id,[]);for(const M of u)l(M,m.id)}};if(s){for(const m of g(s))l(m);return{actions:r,parentOf:c,childrenOf:h}}const y=new Map(a.map(m=>[m.id,m])),w=a.filter(m=>m.parentAction);if(w.length===0)return{actions:a,parentOf:c,childrenOf:h};for(const m of w){const p=m.parentAction?y.get(m.parentAction):void 0;p!=null&&p.parentAction||l(m)}return{actions:r,parentOf:c,childrenOf:h}}function Ls(e,t){const n=e.attributes.actionType,s=n?t.elements[n]:void 0,o=((s==null?void 0:s.construct)==="action"?s.parameters:e.parameters)??[];return{inPorts:o.filter(i=>i.direction==="in"||i.direction==="inout").map(i=>i.name),outPorts:o.filter(i=>i.direction==="out"||i.direction==="inout").map(i=>i.name)}}const $n=["#4A90D9","#E67E22","#2ECC71","#9B59B6","#E74C3C","#1ABC9C","#F39C12","#7B68EE"],hn="Unallocated",Rs="Unstaged";function Mn(e,t,n="all"){const s=new Map;for(const c of t.relationships)ke.has(c.type)&&!s.has(c.targetId)&&s.set(c.targetId,c.sourceId);const o=[e],i=new Set(o);let a=e;for(;s.has(a);){const c=s.get(a);if(i.has(c))break;o.unshift(c),i.add(c),a=c}if(n==="all")return{id:e,level:o.length};const r=Math.min(Math.max(n,1),o.length)-1;return{id:o[r],level:r+1}}function js(e,t,n="all"){var o;const s=Mn(e,t,n).id;return((o=t.elements[s])==null?void 0:o.name)??s}function er(e,t){const n=[...new Set(e)].map(o=>Mn(o,t).level);if(n.length===0)return[];const s=Math.min(...n);return s<=1?[]:Array.from({length:s},(o,i)=>i+1)}function Bs(e,t,n="allocation",s="all"){var r,c;const o=new Map,i=[],a=new Map;for(const h of e){if(ne(h,t.registries))continue;const g=h.allocatedTo?Mn(h.allocatedTo,t,s).id:hn,l=n==="stage"?h.attributes.stage||h.attributes.phase||Rs:g;if(o.set(h.id,l),!a.has(l)){const y={id:l,label:n==="allocation"&&l!==hn?((r=t.elements[l])==null?void 0:r.name)??l:l,color:$n[a.size%$n.length],inspectElementId:n==="allocation"&&l!==hn?l:((c=Object.values(t.elements).find(w=>w.id===l||w.name===l))==null?void 0:c.id)??h.id};a.set(l,y),i.push(y)}}return{laneOf:o,lanes:i}}const $s=18,xn=36,Hs=20,ie=36,Hn=16,Pe=120,gn=18,Wn=40,Le=32,zn=64,Gn=10,de=28;function Yn(e,t,n,s){return{id:`__lane_label_${e.id}`,type:"actionFlowLaneLabel",position:n,data:{label:e.label,color:e.color,orientation:t,isFrame:!0},style:{...s,pointerEvents:"none"},draggable:!1,selectable:!1,zIndex:5}}const po=140,yo=240,xo=9,Ws=20,wo=36;function wn(e){return Math.max(e.name.length*xo+wo,po)}function zs(e,t,n,s){const o=e.filter(i=>{const a=ae(i,s);return a!=="decision"&&a!=="merge"&&a!=="fork"&&a!=="join"&&a!=="activityFinal"&&a!=="flowFinal"});return o.length===0?po:n==="horizontal"?Math.min(yo,Math.max(...o.map(wn))):Math.max(...o.map(i=>bo(t.get(i.id),i)+xn))}function bo(e,t){const s=Math.max((e==null?void 0:e.inPorts.length)??0,(e==null?void 0:e.outPorts.length)??0,0)*$s;return s+(s>0?8:0)+(t.allocatedTo?Hs:0)}function Gs(e,t,n,s,o){const i=ae(e,s);if(i==="decision"||i==="merge")return{width:64,height:64};if(i==="activityFinal"||i==="flowFinal")return{width:28,height:28};if(i==="fork"||i==="join")return n==="vertical"?{width:zn,height:Gn}:{width:Gn,height:zn};const a=bo(t,e);if(n==="vertical")return{width:wn(e),height:o??xn+a};const r=o??Math.min(yo,wn(e)),c=Math.max(1,Math.ceil(e.name.length*xo/Math.max(1,r-wo)));return{width:r,height:xn+(c-1)*Ws+a}}function Xn(e){const t=e??"";return/energy|power|voltage|current|thermal|heat/i.test(t)?"energy":/material|fluid|gas|liquid|batch|consumable/i.test(t)?"material":"data"}const un={control:"#4B5563",data:"#3498DB",energy:"#D97706",material:"#16A34A"};function Ys(e,t){const n=new Map,s=new Map;for(const r of t)s.set(r,0);for(const r of e)!t.has(r.sourceId)||!t.has(r.targetId)||(n.has(r.sourceId)||n.set(r.sourceId,[]),n.get(r.sourceId).push(r),s.set(r.targetId,(s.get(r.targetId)??0)+1));const o=new Set,i=new Map,a=r=>{i.set(r,1);for(const c of n.get(r)??[]){const h=i.get(c.targetId)??0;h===1?o.add(c.id):h===0&&a(c.targetId)}i.set(r,2)};for(const r of t)(s.get(r)??0)===0&&!i.has(r)&&a(r);for(const r of t)i.has(r)||a(r);return o}async function nr(e,t){var rt,at,St,Kt,Xt;const n=(t==null?void 0:t.nesting)??"flat",s=n==="nested"?Ps(e,t==null?void 0:t.viewpointFilter,t==null?void 0:t.expandedActionIds,t==null?void 0:t.focusActionId):{actions:mo(e,t==null?void 0:t.viewpointFilter,t==null?void 0:t.expandedActionIds,t==null?void 0:t.focusActionId),childrenOf:new Map},o=s.actions;if(o.length===0)return{nodes:[],edges:[]};const i=new Set(o.map(b=>b.id)),{laneOf:a,lanes:r}=Bs(o,e,t==null?void 0:t.laneGrouping,t==null?void 0:t.displayLevel),c=(t==null?void 0:t.direction)??"horizontal",h=n!=="nested"&&((t==null?void 0:t.swimlanes)??!0)&&r.length>=1,g=e.relationships.filter(b=>b.type==="succession"),l=e.relationships.filter(b=>b.type==="flow"),y=new Map;for(const b of n==="nested"?[]:(t==null?void 0:t.expandedActionIds)??[]){const _=Object.values(e.elements).filter(z=>z.parentAction===b);if(_.length===0)continue;const j=((rt=g.find(z=>z.sourceId===`${b}__start`))==null?void 0:rt.targetId)??_[0].id,W=((at=g.find(z=>z.targetId===`${b}__done`))==null?void 0:at.sourceId)??_[_.length-1].id;y.set(b,{first:j,last:W})}const w=b=>b.map(_=>{var j,W;return{..._,sourceId:((j=y.get(_.sourceId))==null?void 0:j.last)??_.sourceId,targetId:((W=y.get(_.targetId))==null?void 0:W.first)??_.targetId}}),m=w(g),p=w(l),u=new Set;for(const b of m){const _=b.sourceId.endsWith("__start")?b.sourceId.slice(0,-7):void 0,j=b.targetId.endsWith("__done")?b.targetId.slice(0,-6):void 0;_&&!y.has(_)&&i.has(b.targetId)&&u.add(b.sourceId),j&&!y.has(j)&&i.has(b.sourceId)&&u.add(b.targetId)}const M=new Set([...i,...u]),I=p.filter(b=>M.has(b.sourceId)&&M.has(b.targetId)&&(!(t!=null&&t.visibleFlowKinds)||t.visibleFlowKinds.has(Xn(b.flowItem)))),S=new Set(I.map(b=>`${b.sourceId}\0${b.targetId}`)),E=m.filter(b=>M.has(b.sourceId)&&M.has(b.targetId)&&(!(t!=null&&t.visibleFlowKinds)||t.visibleFlowKinds.has("control"))&&!S.has(`${b.sourceId}\0${b.targetId}`)),v=Ys(E,M),D=E.filter(b=>!v.has(b.id)),K=new Map(o.map(b=>[b.id,Ls(b,e)])),Z=new Map(o.map(b=>[b.id,b])),H=new Map,B=new Map;if(n==="nested"){for(const[b,_]of s.childrenOf)H.set(b,_.filter(j=>M.has(j)));for(const b of u){const _=b.endsWith("__start")?b.slice(0,-7):b.slice(0,-6);H.has(_)&&H.get(_).push(b)}for(const[b,_]of H)for(const j of _)B.set(j,b)}const Y=zs(o,K,c,e.registries),nt=b=>{const _=Z.get(b);return _?Gs(_,K.get(b),c,e.registries,Y):{width:de,height:de}},ht=b=>{const _=H.get(b)??[];return _.length===0?{id:b,...nt(b)}:{id:b,layoutOptions:{"elk.algorithm":"layered","elk.direction":c==="vertical"?"DOWN":"RIGHT","elk.padding":"[top=44,left=24,bottom=24,right=24]","elk.spacing.nodeNode":"36","elk.layered.spacing.nodeNodeBetweenLayers":"68","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"},children:_.map(ht)}},ft=[...u,...o.map(b=>b.id)].filter(b=>!B.has(b)),_t={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":c==="vertical"?"DOWN":"RIGHT","elk.spacing.nodeNode":"40","elk.layered.spacing.nodeNodeBetweenLayers":"80","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.separateConnectedComponents":"true","elk.spacing.componentComponent":"56",...n==="nested"?{"elk.hierarchyHandling":"INCLUDE_CHILDREN"}:{}},children:ft.map(ht),edges:[...I,...D].map((b,_)=>({id:`afe-${_}`,sources:[b.sourceId],targets:[b.targetId]}))},Bt=await ue.layout(_t,{providerId:t==null?void 0:t.layoutProviderId}),q=new Map,Lt=b=>{q.set(b.id,{x:b.x??0,y:b.y??0,width:b.width??140,height:b.height??56});for(const _ of b.children??[])Lt(_)};for(const b of Bt.children??[])Lt(b);const $t=new Map(r.map(b=>[b.id,b.color])),wt=[],jt=new Map,Dt=[...u].some(b=>b.endsWith("__start")),zt=[...u].some(b=>b.endsWith("__done")),Yt=Dt?de+24:0,mt=zt?de+24:0;if(h&&c==="horizontal"){const b=new Map;for(const Q of o){if(ne(Q,e.registries))continue;const $=q.get(Q.id),U=a.get(Q.id);b.has(U)||b.set(U,[]),b.get(U).push($.y)}const _=[...r].sort((Q,$)=>{const U=T=>T.reduce((f,d)=>f+d,0)/T.length;return U(b.get(Q.id)??[0])-U(b.get($.id)??[0])});let j=1/0,W=-1/0;for(const Q of o){const $=q.get(Q.id);j=Math.min(j,$.x),W=Math.max(W,$.x+$.width)}let z=0;for(const Q of _){const $=o.filter(d=>a.get(d.id)===Q.id);$.sort((d,x)=>q.get(d.id).x-q.get(x.id).x||q.get(d.id).y-q.get(x.id).y);const U=Math.min(...$.map(d=>q.get(d.id).y));let T=0;const f=[];for(const d of $){const x=q.get(d.id);let A=z+ie+(x.y-U);for(const F of f)x.x<F.x1&&x.x+x.width>F.x0&&(A=Math.max(A,F.bottom+16));q.set(d.id,{...x,y:A}),f.push({x0:x.x,x1:x.x+x.width,bottom:A+x.height}),T=Math.max(T,A+x.height-z)}T+=ie,wt.push({id:`__lane_${Q.id}`,type:"actionFlowLane",position:{x:j-Pe,y:z},data:{label:Q.label,color:Q.color,orientation:"row",inspectElementId:Q.inspectElementId,memberIds:$.map(d=>d.id),isFrame:!0},style:{width:W-j+Pe+ie,height:T},draggable:!1,selectable:!1,zIndex:-1}),wt.push(Yn(Q,"row",{x:j-Pe,y:z},{width:W-j+Pe+ie,height:T})),z+=T+Hn}}else if(h){let b=1/0,_=-1/0;for(const W of o){const z=q.get(W.id);b=Math.min(b,z.y),_=Math.max(_,z.y+z.height)}let j=0;for(const W of r){const z=o.filter(U=>a.get(U.id)===W.id).sort((U,T)=>q.get(U.id).y-q.get(T.id).y||q.get(U.id).x-q.get(T.id).x),$=Math.max(...z.map(U=>q.get(U.id).width))+ie*2;jt.set(W.id,{left:j,width:$});for(const U of z){const T=q.get(U.id);q.set(U.id,{...T,x:j+($-T.width)/2})}wt.push({id:`__lane_${W.id}`,type:"actionFlowLane",position:{x:j,y:b-Le-Yt},data:{label:W.label,color:W.color,orientation:"column",inspectElementId:W.inspectElementId,memberIds:z.map(U=>U.id),isFrame:!0},style:{width:$,height:_-b+Le+ie+Yt+mt},draggable:!1,selectable:!1,zIndex:-1}),wt.push(Yn(W,"column",{x:j,y:b-Le-Yt},{width:$,height:_-b+Le+ie+Yt+mt})),j+=$+Hn}}const At=n==="nested"?[]:o.filter(b=>{const _=ae(b,e.registries);return _==="decision"||_==="merge"||_==="fork"||_==="join"});if(At.length>0)for(const b of At){const _=q.get(b.id),j=ae(b,e.registries),W=[];for(const Q of[...E,...I]){const $=j==="decision"||j==="fork"?Q.targetId===b.id?Q.sourceId:void 0:Q.sourceId===b.id?Q.targetId:void 0;if($===void 0)continue;const U=q.get($);U&&W.push(c==="vertical"?U.x+U.width/2:U.y+U.height/2)}if(W.length===0)continue;const z=W.reduce((Q,$)=>Q+$,0)/W.length;q.set(b.id,c==="vertical"?{..._,x:z-_.width/2}:{..._,y:z-_.height/2})}if(c==="vertical"&&h&&jt.size>0){const b=[...E,...I],_=new Map(o.map(j=>[j.id,j]));for(const j of o.filter(W=>ne(W,e.registries))){const W=new Set,z=[j.id],Q=new Set;for(;z.length>0&&W.size<=1;){const x=z.pop();if(!Q.has(x)){Q.add(x);for(const A of b){const F=A.sourceId===x?A.targetId:A.targetId===x?A.sourceId:void 0;if(!F||Q.has(F))continue;const O=_.get(F);if(O)if(ne(O,e.registries))z.push(F);else{const N=a.get(F);N&&W.add(N)}}}}if(W.size!==1)continue;const $=jt.get([...W][0]),U=q.get(j.id);if(!$||!U)continue;const T=12,f=$.left+T,d=$.left+$.width-U.width-T;q.set(j.id,{...U,x:Math.max(f,Math.min(U.x,d))})}}for(const b of n==="nested"?[]:u){const _=q.get(b);if(!_)continue;const j=[];for(const $ of E){const U=$.sourceId===b?$.targetId:$.targetId===b?$.sourceId:void 0;if(!U)continue;const T=q.get(U);T&&j.push(c==="vertical"?T.x+T.width/2:T.y+T.height/2)}if(j.length===0)continue;const W=j.reduce(($,U)=>$+U,0)/j.length,z=o.filter($=>!ne($,e.registries)).map($=>q.get($.id)).filter($=>!!$),Q=b.endsWith("__start");if(c==="vertical"){const $=Math.min(...z.map(T=>T.y)),U=Math.max(...z.map(T=>T.y+T.height));q.set(b,{..._,x:W-_.width/2,y:Q?$-_.height-16:U+16})}else{const $=Math.min(...z.map(T=>T.x)),U=Math.max(...z.map(T=>T.x+T.width));q.set(b,{..._,x:Q?$-_.width-24:U+24,y:W-_.height/2})}}const k=[];if(n!=="nested"){const b=Ds(e,t==null?void 0:t.viewpointFilter,t==null?void 0:t.expandedActionIds,t==null?void 0:t.focusActionId);for(const[_,j]of b){const W=e.elements[_],z=j.map(d=>q.get(d)).filter(d=>!!d);if(!W||z.length===0)continue;const Q=Math.min(...z.map(d=>d.x)),$=Math.min(...z.map(d=>d.y)),U=Math.max(...z.map(d=>d.x+d.width)),T=Math.max(...z.map(d=>d.y+d.height)),f={element:W,label:W.name,nodeType:"action",laneColor:"#9CA3AF",layerColor:Qt[W.layer]||"#FF6B6B",inPorts:[],outPorts:[],hasChildren:!0,isExpanded:!0,isFrame:!0,onToggleExpand:t!=null&&t.onToggleAction?()=>t.onToggleAction(_):void 0,onDrillIn:t!=null&&t.onDrillInAction?()=>t.onDrillInAction(_):void 0,flowDirection:c};k.push({id:`__group_${_}`,type:"actionFlowNode",position:{x:Q-gn,y:$-Wn},style:{width:U-Q+gn*2,height:T-$+Wn+gn},draggable:!1,selectable:!1,data:f})}}const P=[...wt,...k],R=b=>{const _=B.get(b);return _?{parentId:_,extent:"parent"}:{}};for(const b of u){const _=q.get(b),j=b.endsWith("__start"),W={label:j?"Start":"Done",nodeType:j?"start":"done",laneColor:"#374151",layerColor:"#374151",inPorts:[],outPorts:[],flowDirection:c};P.push({id:b,type:"actionFlowNode",position:{x:_.x,y:_.y},style:{width:de,height:de},...R(b),data:W})}for(const b of o){const _=q.get(b.id),j=ae(b,e.registries);if(ne(b,e.registries)){const T={element:b,label:b.name,nodeType:j,laneColor:"#374151",layerColor:"#374151",inPorts:[],outPorts:[],flowDirection:c};P.push({id:b.id,type:"actionFlowNode",position:{x:_.x,y:_.y},style:{width:_.width,height:_.height},...R(b.id),data:T});continue}const W=K.get(b.id),z=a.get(b.id),Q=b.allocatedTo?js(b.allocatedTo,e,t==null?void 0:t.displayLevel):void 0,$=(((St=H.get(b.id))==null?void 0:St.length)??0)>0,U={element:b,label:b.name,nodeType:j??"action",parameters:b.parameters,allocatedTo:Q,laneColor:$t.get(z)??"#9CA3AF",layerColor:Qt[b.layer]||"#FF6B6B",inPorts:W.inPorts,outPorts:W.outPorts,hasChildren:Object.values(e.elements).some(T=>T.parentAction===b.id),isExpanded:((Kt=t==null?void 0:t.expandedActionIds)==null?void 0:Kt.has(b.id))??!1,isFrame:$,onToggleExpand:t!=null&&t.onToggleAction?()=>t.onToggleAction(b.id):void 0,onDrillIn:t!=null&&t.onDrillInAction?()=>t.onDrillInAction(b.id):void 0,flowDirection:c};P.push({id:b.id,type:"actionFlowNode",position:{x:_.x,y:_.y},style:{width:_.width,height:_.height},...R(b.id),data:U})}if(B.size>0){const b=new Map(P.map(z=>[z.id,z])),_=[],j=new Set,W=z=>{if(j.has(z.id))return;j.add(z.id);const Q=z.parentId?b.get(z.parentId):void 0;Q&&W(Q),_.push(z)};for(const z of P)W(z);P.length=0,P.push(..._)}const J=[];for(const b of I){const _=Xn(b.flowItem),j=un[_],W=b.flowItem?/signal|error|status|code|report|alarm|response|command|data|reading/i.test(b.flowItem):!1;J.push({id:b.id,source:b.sourceId,target:b.targetId,...b.sourceEnd?{sourceHandle:`out:${b.sourceEnd}`}:{},...b.targetEnd?{targetHandle:`in:${b.targetEnd}`}:{},label:void 0,type:"smoothstep",animated:!1,style:{stroke:j,strokeWidth:it.flowWidth,strokeDasharray:W?"6 3":void 0},labelStyle:{fontSize:dt.badge,fill:j,fontWeight:600},labelBgStyle:it.labelBgStyle,labelBgPadding:it.labelBgPadding,labelBgBorderRadius:it.labelBgRadius,markerEnd:{type:"arrowclosed",color:j,width:it.arrowSize,height:it.arrowSize},zIndex:2,data:{flowCategory:_,flowItem:b.flowItem}})}for(const b of E){const _=v.has(b.id);J.push({id:b.id,source:b.sourceId,target:b.targetId,sourceHandle:ge,targetHandle:re,type:c==="vertical"&&!_?"straight":"smoothstep",animated:!1,style:{stroke:un.control,strokeWidth:1.5},markerEnd:{type:"arrowclosed",color:un.control,width:12,height:12},zIndex:2,label:(Xt=b.sourceEnd)!=null&&Xt.startsWith("[")?b.sourceEnd:void 0,data:{flowCategory:"control"}})}return{nodes:P,edges:J}}function Xs(e){return e.attributes.sourceState&&e.attributes.targetState?!0:e.kind==="Transition"||e.kind.endsWith("Transition")}function Us(e){return e.kind.endsWith("State")||e.kind.endsWith("Machine")||e.kind.endsWith("Mode")}function Ks(e,t){const n=Object.values(e.elements),s=t?n.filter(t):n,o=[],i=[],a=[];for(const r of s)Xs(r)?i.push(r):Us(r)?o.push(r):a.push(r);return{states:o,transitions:i,annotations:a}}const Un=46;function Vs(e){return e.length>Un?`${e.slice(0,Un-1)}…`:e}function Zs(e){const t=e.attributes.trigger??"",n=e.attributes.guardSummary??e.attributes.guard??"",s=n&&!/^none\b/i.test(n),o=t||e.name;return Vs(s?`${o} [${n}]`:o)}function qs(e,t){const n=new Map;for(const o of t)n.set(o.name,o.id),n.set(o.id,o.id);const s=[];for(const o of e){const i=n.get(o.attributes.sourceState??""),a=n.get(o.attributes.targetState??"");!i||!a||s.push({element:o,sourceId:i,targetId:a,label:Zs(o)})}return s}function Js(e,t={}){const n=t.collapsedStateIds??new Set,s=t.focusStateId&&e.elements.has(t.focusStateId)?t.focusStateId:void 0,o=y=>(e.childrenMap.get(y)??[]).filter(w=>e.elements.has(w)),i=s?o(s):[],a=i.length>0?i:e.roots.filter(y=>e.elements.has(y)),r=new Set,c=new Map,h=new Map,g=(y,w)=>{c.set(y,w),h.set(w,(h.get(w)??0)+1);for(const m of o(y))g(m,w)},l=y=>{r.add(y);const w=o(y);if(n.has(y)){for(const m of w)g(m,y);return}for(const m of w)l(m)};for(const y of a)l(y);return{visible:r,liftTo:c,hiddenCount:h,roots:a}}function Qs(e,t){const n=o=>t.visible.has(o)?o:t.liftTo.get(o),s=[];for(const o of e){const i=n(o.sourceId),a=n(o.targetId);if(!i||!a)continue;const r=o.sourceId===o.targetId;i===a&&!r||s.push({...o,sourceId:i,targetId:a})}return s}const ti="#FF6B6B",ei="#95A5A6",Kn="#64748B";async function or(e,t){const{states:n,transitions:s,annotations:o}=Ks(e,t==null?void 0:t.viewpointFilter);if(n.length===0&&o.length===0)return{nodes:[],edges:[]};const i=qe(n,e.relationships),a=Js(i,{focusStateId:t==null?void 0:t.focusStateId,collapsedStateIds:t==null?void 0:t.collapsedStateIds}),r=Qs(qs(s,n),a);if(a.visible.size===0&&o.length===0)return{nodes:[],edges:[]};const c=I=>({width:Math.max(I.name.length*7.5+56,150),height:(i.childrenMap.get(I.id)??[]).some(S=>i.elements.has(S))?74:54}),h=I=>{const S=i.elements.get(I),E=(i.childrenMap.get(I)??[]).filter(v=>a.visible.has(v));return E.length===0?{id:I,...c(S)}:{id:I,layoutOptions:{"elk.algorithm":"layered","elk.direction":"DOWN","elk.padding":"[top=48,left=28,bottom=28,right=28]","elk.spacing.nodeNode":"72","elk.layered.spacing.nodeNodeBetweenLayers":"120","elk.spacing.edgeNode":"32","elk.edgeRouting":"ORTHOGONAL","elk.layered.cycleBreaking.strategy":"MODEL_ORDER","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"},children:E.map(h)}},g={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"DOWN","elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.edgeRouting":"ORTHOGONAL","elk.spacing.nodeNode":"72","elk.layered.spacing.nodeNodeBetweenLayers":"120","elk.spacing.edgeNode":"32","elk.spacing.edgeLabel":"8","elk.layered.cycleBreaking.strategy":"MODEL_ORDER","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.separateConnectedComponents":"true","elk.spacing.componentComponent":"64","elk.padding":"[top=20, left=20, bottom=20, right=20]"},children:a.roots.map(h),edges:r.map((I,S)=>({id:`st-${S}`,sources:[I.sourceId],targets:[I.targetId]}))},l=await ue.layout(g,{providerId:t==null?void 0:t.layoutProviderId}),y=[],w=new Map,m=(I,S,E={x:0,y:0})=>{var D,K;const v=i.elements.get(I.id);if(v){const Z=!!((D=I.children)!=null&&D.length),H=v.kind.endsWith("Machine"),B={x:E.x+(I.x??0),y:E.y+(I.y??0)};w.set(I.id,{...B,width:I.width??150,height:I.height??54,isContainer:Z}),y.push({id:I.id,type:"stateNode",position:{x:I.x??0,y:I.y??0},...S?{parentId:S,extent:"parent"}:{},data:{label:v.name,kind:v.kind,color:ti,isContainer:Z,isMachine:H,subtitle:v.attributes.modeKind,hasChildren:(i.childrenMap.get(I.id)??[]).some(Y=>i.elements.has(Y)),isCollapsed:!!((K=t==null?void 0:t.collapsedStateIds)!=null&&K.has(I.id)),hiddenCount:a.hiddenCount.get(I.id)??0,onToggleCollapse:t!=null&&t.onToggleCollapse?()=>t.onToggleCollapse(I.id):void 0,onDrillIn:t!=null&&t.onDrillIn?()=>t.onDrillIn(I.id):void 0},style:{width:I.width??150,height:I.height??54}});for(const Y of I.children??[])m(Y,I.id,B);return}};for(const I of l.children??[])m(I);if(o.length>0){let I=0,S=800;for(const Z of l.children??[])I=Math.max(I,(Z.y??0)+(Z.height??0)),S=Math.max(S,(Z.x??0)+(Z.width??0));const E=240,v=48,D=14,K=Math.max(2,Math.floor(S/(E+D)));o.forEach((Z,H)=>{y.push({id:Z.id,type:"stateNode",position:{x:H%K*(E+D),y:I+56+Math.floor(H/K)*(v+D)},data:{label:Z.name,kind:Z.kind,color:ei,isNote:!0},style:{width:E,height:v}})})}const p=[...w.entries()].filter(([,I])=>!I.isContainer).map(([I,S])=>({id:I,x:S.x,y:S.y,width:S.width,height:S.height})),u=qo({connectors:r.map((I,S)=>({id:I.element.id||`st-e-${S}`,sourceId:I.sourceId,targetId:I.targetId,label:I.label})),rects:w,obstacles:p,channelGap:26}),M=r.map((I,S)=>{const E=I.element.id||`st-e-${S}`,v=u.get(E),D={id:E,source:I.sourceId,target:I.targetId,label:I.label,style:{stroke:Kn,strokeWidth:it.defaultWidth},markerEnd:{type:"arrowclosed",color:Kn,width:it.arrowSize,height:it.arrowSize}};return v?{...D,type:"interconnectionEdge",data:{points:v.points,labelPoint:v.labelPoint}}:{...D,type:"smoothstep",labelStyle:{fontSize:dt.badge,fill:"#6B7280",fontWeight:500},labelBgPadding:it.labelBgPadding,labelBgBorderRadius:it.labelBgRadius,labelBgStyle:it.labelBgStyle}});return{nodes:y,edges:M}}const ni=/(?:Actor|User)$/,oi=new Set(["UseCase"]),Io=new Set(["initiates","participatesin","performs","interactswith","includes","extends"]),Zt=e=>e.toLowerCase();function Mo(e){return ni.test(e.kind)||e.construct==="actor"}function Sn(e){return oi.has(e.kind)||e.construct==="use case"}function sr(e){const t=new Set(Object.values(e.elements).filter(Sn).map(o=>o.id)),n=new Map;for(const o of e.relationships.filter(i=>Zt(i.type)==="includes"&&t.has(i.sourceId)&&t.has(i.targetId)))n.set(o.targetId,[...n.get(o.targetId)??[],o.sourceId]);const s=(o,i=new Set)=>{if(i.has(o))return 0;const a=n.get(o)??[];return a.length===0?0:1+Math.min(...a.map(r=>s(r,new Set([...i,o]))))};return Math.max(0,...[...t].map(o=>s(o)))}function ir(e){const t=Object.values(e.elements),n=new Set(t.filter(Sn).map(o=>o.id)),s=new Set(e.relationships.filter(o=>Io.has(Zt(o.type))).flatMap(o=>n.has(o.sourceId)?[o.targetId]:n.has(o.targetId)?[o.sourceId]:[]));return t.filter(Mo).filter(o=>s.has(o.id)).map(o=>({id:o.id,name:o.name})).sort((o,i)=>o.name.localeCompare(i.name))}function rr(e){var o,i;const t=`${(e==null?void 0:e.layoutHint)??""};${(e==null?void 0:e.styleHint)??""}`,n=/(?:usecase:)?level\s*=\s*(all|\d+)/i.exec(t),s=/(?:edge|routing)\s*=\s*(straight|orthogonal|elbow|rounded|curved|arc)/i.exec(t);return{level:(n==null?void 0:n[1])==="all"?"all":n?Number(n[1]):"all",edgeStyle:{orthogonal:"elbow"}[((o=s==null?void 0:s[1])==null?void 0:o.toLowerCase())??""]??((i=s==null?void 0:s[1])==null?void 0:i.toLowerCase())??"straight"}}function ar(e,t={}){const n=Object.values(e.elements).filter(d=>!t.viewpointFilter||t.viewpointFilter(d)),s=n.filter(Sn),o=e.relationships.filter(d=>Io.has(Zt(d.type))),i=new Map;for(const d of o.filter(x=>Zt(x.type)==="includes")){const x=i.get(d.targetId)??[];x.push(d.sourceId),i.set(d.targetId,x)}const a=(d,x=new Set)=>{if(x.has(d))return 0;const A=i.get(d)??[];return A.length===0?0:1+Math.min(...A.map(F=>a(F,new Set([...x,d]))))},r=t.level??"all",c=new Set(s.filter(d=>r==="all"||a(d.id)<=r).map(d=>d.id));let h=!0;for(;h;){h=!1;for(const d of o.filter(x=>Zt(x.type)==="extends"))if(c.has(d.sourceId)||c.has(d.targetId))for(const x of[d.sourceId,d.targetId])!c.has(x)&&s.some(A=>A.id===x)&&(c.add(x),h=!0)}const g=t.hiddenActorIds??new Set;for(const d of o){const x=c.has(d.sourceId)?d.targetId:c.has(d.targetId)?d.sourceId:void 0;x&&g.has(x)&&(c.delete(d.sourceId),c.delete(d.targetId))}const l=s.filter(d=>c.has(d.id)),y=n.filter(Mo).filter(d=>!g.has(d.id)).filter(d=>o.some(x=>x.sourceId===d.id&&c.has(x.targetId)||x.targetId===d.id&&c.has(x.sourceId))),w=new Set([...y,...l].map(d=>d.id));if(l.length===0)return{nodes:[],edges:[]};const m=new Set(o.filter(d=>Zt(d.type)==="extends").map(d=>d.sourceId)),p=new Map;for(const d of l){if(m.has(d.id))continue;const x=a(d.id);p.set(x,[...p.get(x)??[],d])}const M=[...p.keys()].sort((d,x)=>d-x).map(d=>[...p.get(d)??[]]);if(M.length===1&&M[0].length>4){const d=M[0],x=Math.min(3,Math.ceil(d.length/4)),A=Math.ceil(d.length/x);M.splice(0,1,...Array.from({length:x},(F,O)=>d.slice(O*A,(O+1)*A)))}const I=new Map;M.forEach((d,x)=>d.forEach(A=>I.set(A.id,x)));const S=new Map;for(const d of o.filter(x=>Zt(x.type)==="extends")){const x=l.find(O=>O.id===d.sourceId),A=I.get(d.targetId);if(!x||A===void 0||I.has(x.id))continue;const F=M[A];F.splice(F.findIndex(O=>O.id===d.targetId)+1,0,x),I.set(x.id,A),S.set(d.targetId,[...S.get(d.targetId)??[],x])}const E=new Set([...S.values()].flat().map(d=>d.id)),v=d=>o.filter(x=>x.sourceId===d||x.targetId===d).map(x=>x.sourceId===d?x.targetId:x.sourceId),D=new Map,K=()=>M.forEach(d=>d.forEach((x,A)=>D.set(x.id,A)));K(),y.forEach((d,x)=>D.set(d.id,x));const Z=d=>{const x=v(d).map(A=>D.get(A)).filter(A=>A!==void 0);return x.length===0?D.get(d)??0:x.reduce((A,F)=>A+F,0)/x.length};for(let d=0;d<3;d++){const x=d%2===0?M:[...M].reverse();for(const A of x){const F=A.filter(O=>!E.has(O.id));F.sort((O,N)=>Z(O.id)-Z(N.id)),A.splice(0,A.length,...F.flatMap(O=>[O,...S.get(O.id)??[]])),K()}y.sort((A,F)=>Z(A.id)-Z(F.id)),y.forEach((A,F)=>D.set(A.id,F))}const H=176,B=88,Y=104,nt=40,ht=104,ft=88,_t=116,Bt=48,q=62,Lt=44,$t=76,wt=20,jt=Math.max(1,...M.map(d=>d.length)),Dt=Math.max(520,M.length*H+Math.max(M.length-1,0)*Y+Bt*2),zt=Math.max(300,jt*B+(jt-1)*nt+q+Lt),Yt=d=>Bt+d*(H+Y)+H/2,mt=new Map;for(const d of y){const x=v(d.id).map(F=>I.get(F)).filter(F=>F!==void 0).map(Yt),A=x.length?x.reduce((F,O)=>F+O,0)/x.length:0;mt.set(d.id,x.length===0||A<=Dt/2?"left":"right")}const At=y.filter(d=>mt.get(d.id)==="left"),k=y.filter(d=>mt.get(d.id)==="right"),P=wt+(At.length?ht+$t:0),R=wt,J=[{id:"__use_case_boundary__",type:"useCaseBoundary",position:{x:P,y:R},data:{label:t.systemName||"System Boundary",isFrame:!0,kind:"System Boundary"},style:{width:Dt,height:zt},draggable:!1,selectable:!1,zIndex:-1}],rt=new Map,at=R+q,St=zt-q-Lt;M.forEach((d,x)=>{const A=d.length*B+(d.length-1)*nt;let F=at+(St-A)/2;for(const O of d){const N={x:P+Bt+x*(H+Y),y:F};rt.set(O.id,N),J.push({id:O.id,type:"useCase",position:N,data:{label:O.name,kind:O.kind,color:"#E67E22",level:a(O.id)},style:{width:H,height:B}}),F+=B+nt}});for(const d of["left","right"]){const A=(d==="left"?At:k).map(O=>{const N=v(O.id).map(L=>rt.get(L)).filter(L=>!!L).map(L=>L.y);return{actor:O,y:N.length?N.reduce((L,G)=>L+G,0)/N.length:R+q}}).sort((O,N)=>O.y-N.y);let F=-1/0;for(const{actor:O,y:N}of A){const L=Math.max(N,F+_t-ft,wt);F=L+ft,J.push({id:O.id,type:"useCaseActor",position:{x:d==="left"?wt:P+Dt+$t,y:L},data:{label:O.name,kind:O.kind,color:"#334155",side:d},style:{width:ht,height:ft}})}}const Kt=t.edgeStyle??"straight",Xt=o.filter(d=>w.has(d.sourceId)&&w.has(d.targetId)).map(d=>{const x=k.some(O=>O.id===d.sourceId),A=x?d.targetId:d.sourceId,F=x?d.sourceId:d.targetId;return{edge:{id:d.id,source:A,target:F,label:/^(includes|extends)$/.test(Zt(d.type))?`«${Zt(d.type)}»`:void 0,type:"useCaseEdge",data:{routing:Kt},style:{stroke:"#64748B",strokeWidth:1.4,strokeDasharray:/^(includes|extends)$/.test(Zt(d.type))?"5 4":void 0}},source:A,target:F}}),b=new Map(J.map(d=>[d.id,d])),_=d=>{var x,A;return{width:Number(((x=d.style)==null?void 0:x.width)??150),height:Number(((A=d.style)==null?void 0:A.height)??82)}},j=(d,x)=>{const A=_(b.get(d));return x==="left"?{x:0,y:A.height/2}:x==="right"?{x:A.width,y:A.height/2}:x==="top"?{x:A.width/2,y:0}:{x:A.width/2,y:A.height}},W=(d,x)=>{const A=b.get(d),F=j(d,x);return{x:A.position.x+F.x,y:A.position.y+F.y}},z=Xt.map(({edge:d,source:x,target:A})=>{var ot,vt;const F=y.find(Et=>Et.id===x),O=y.find(Et=>Et.id===A),N=!F&&!O&&I.get(x)!==void 0&&I.get(x)===I.get(A),L=N&&(((ot=rt.get(x))==null?void 0:ot.y)??0)<(((vt=rt.get(A))==null?void 0:vt.y)??0),G=F?k.includes(F)?"left":"right":N?L?"bottom":"top":"right",tt=O?k.includes(O)?"left":"right":N?L?"top":"bottom":"left";return{id:d.id,source:W(x,G),target:W(A,tt),sourceNodeId:x,targetNodeId:A,sourceSide:G,targetSide:tt}}),Q=J.filter(d=>d.type==="useCase"||d.type==="useCaseActor").map(d=>({id:d.id,x:d.position.x,y:d.position.y,..._(d)})),$=Kt==="straight"?new Map:Ee(z,Q,28),U=Je(Xt.flatMap(({edge:d})=>{const x=$.get(d.id),A=d.label;return A&&x&&x.length>=2?[{id:d.id,points:x,width:tn(A),height:Qe}]:[]}),Q),T=new Map(z.map(d=>[d.id,d])),f=Xt.map(({edge:d})=>({...d,data:{...d.data,points:$.get(d.id)??[],labelPoint:U.get(d.id),sourceOffset:j(d.source,T.get(d.id).sourceSide),targetOffset:j(d.target,T.get(d.id).targetSide),sourceSide:T.get(d.id).sourceSide,targetSide:T.get(d.id).targetSide}}));return{nodes:J,edges:f}}const Vn=new Set(["includesStep",...ke]);function Zn(e){return e.kind.endsWith("Step")||!!e.attributes.stepOrder}function si(e){if(!e)return;const t=e.split(":");return(t.length>1?t[t.length-1]:t[0]).trim()||void 0}function ii(e,t){const n=e.split(":")[0].trim(),s=t.elements[n];if(s)return s.name;for(const o of Object.values(t.elements))if(o.attributes.id===n)return o.name;return e}const qn=e=>{const t=Number(e.attributes.stepOrder);return Number.isFinite(t)?t:0};function ri(e,t){const n=Object.values(e.elements),s=t?n.filter(t):n,o=s.filter(Zn),i=new Set(o.map(p=>p.id)),a=s.filter(p=>!Zn(p)&&e.relationships.some(u=>Vn.has(u.type)&&u.sourceId===p.id&&i.has(u.targetId))),r=[],c=new Map,h=p=>{const u=p.split(":")[0].trim()||p;return c.has(u)||(c.set(u,r.length),r.push({id:u,label:ii(p,e)})),c.get(u)},g=p=>[...p].sort((u,M)=>qn(u)-qn(M)).map(u=>({step:u,lane:h(u.attributes.allocatedFunction??u.allocatedTo??u.id),item:si(u.attributes.exchangeItem)})),l=p=>{var M;const u=e.relationships.find(I=>I.type==="realizesScenario"&&I.sourceId===p.id);return u?(M=e.elements[u.targetId])==null?void 0:M.name:void 0},y=new Set,w=[];for(const p of a){const u=e.relationships.filter(M=>Vn.has(M.type)&&M.sourceId===p.id&&i.has(M.targetId)).map(M=>e.elements[M.targetId]);for(const M of u)y.add(M.id);w.push({chain:p,scenario:l(p),occurrences:g(u)})}const m=o.filter(p=>!y.has(p.id));return m.length>0&&w.push({occurrences:g(m)}),{lifelines:r,sections:w.filter(p=>p.occurrences.length>0)}}const we=240,ai=52,ci=68,li=40,di=24,Jn=14;function cr(e,t){const n=ri(e,t==null?void 0:t.viewpointFilter);if(n.lifelines.length===0)return{nodes:[],edges:[]};const s=[],o=[],i=g=>g*we+we/2;let a=ai+28;const r=[];for(const g of n.sections){const l=a;a+=li;const y=g.occurrences.map(w=>{const m={...w,y:a};return a+=ci,m});r.push({section:g,top:l,bottom:a,placed:y}),a+=di}const c=a,h=n.lifelines.length*we;return n.lifelines.forEach((g,l)=>{s.push({id:`__lifeline_${g.id}`,type:"seqLifeline",position:{x:l*we,y:0},data:{label:g.label},style:{width:we,height:c},draggable:!1,selectable:!1,zIndex:-2})}),r.forEach(({section:g,top:l,bottom:y,placed:w},m)=>{var p;s.push({id:`__section_${m}`,type:"seqSection",position:{x:-24,y:l},data:{label:((p=g.chain)==null?void 0:p.name)??"Steps",scenario:g.scenario},style:{width:h+48,height:y-l},draggable:!1,selectable:!1,zIndex:-1}),w.forEach((u,M)=>{if(s.push({id:u.step.id,type:"seqOccurrence",position:{x:i(u.lane)-Jn/2,y:u.y-Jn/2},data:{label:u.step.name,kind:u.step.kind},draggable:!1,zIndex:2}),M<w.length-1){const I=w[M+1],S=I.lane>=u.lane,E=I.lane===u.lane;o.push({id:`seq-${m}-${M}`,source:u.step.id,target:I.step.id,sourceHandle:E||S?"right":"left",targetHandle:E?"right":S?"left":"right",type:E?"smoothstep":"straight",label:u.item,style:{stroke:"#3498DB",strokeWidth:it.flowWidth},labelStyle:{fontSize:dt.badge,fill:"#4A90D9",fontWeight:600},labelBgPadding:it.labelBgPadding,labelBgBorderRadius:it.labelBgRadius,labelBgStyle:it.labelBgStyle,markerEnd:{type:"arrowclosed",color:"#3498DB",width:it.arrowSize,height:it.arrowSize},zIndex:1})}})}),{nodes:s,edges:o}}const hi=new Set(["interactsincontext","interactswith","exchangeswith","appliesincontext","connectsphysically"]),fn=new Set(["Actor","User"]),Ye=e=>e.toLowerCase(),mn=e=>e.kind==="UseContext"||/environment|context/i.test(e.name)||/environment/i.test(String(e.attributes.entityKind??"")),gi=e=>/systemofinterest|system-of-interest/i.test(String(e.attributes.contextRole??""))||String(e.attributes.isSystemOfInterest??"").toLowerCase()==="true",Jt=76,So=170,ui=238,Re=30,be=104,je=240,Be=108,$e=92,He=74,pn=40,We=e=>Math.min(Math.max(e.length*7.4+28,So),ui),fi=e=>{var n;const t=String(((n=e.attributes)==null?void 0:n.contextSide)??"").toLowerCase().replace(/[^a-z]/g,"");if(t.endsWith("actor"))return"left";if(t.endsWith("externalsystem"))return"right";if(t.endsWith("environment"))return"top";if(t.endsWith("constraint"))return"bottom"},mi=e=>{var t;return((t=e.attributes)==null?void 0:t.interactionLabel)||`«${Ye(e.type)}»`};function pi(e,t,n){const s=new Map,o=[];for(const i of e){const a=t.some(c=>c.sourceId===i&&c.targetId===n),r=t.some(c=>c.sourceId===n&&c.targetId===i);a&&!r?s.set(i,"left"):r&&!a?s.set(i,"right"):o.push(i)}for(const i of o){const a=[...s.values()].filter(c=>c==="left").length,r=s.size-a;s.set(i,a<=r?"left":"right")}return s}function lr(e,t,n={}){var mt,At;const s=Object.values(e.elements).filter(k=>!n.viewpointFilter||n.viewpointFilter(k)),o=(mt=n.relationshipTypes)!=null&&mt.length?new Set(n.relationshipTypes.map(Ye)):void 0,i=e.relationships.filter(k=>hi.has(Ye(k.type))&&(!o||o.has(Ye(k.type)))),a=new Set(i.flatMap(k=>[k.sourceId,k.targetId])),r=s.filter(k=>a.has(k.id)&&!go(k));if(r.length===0)return{nodes:[],edges:[]};const c=k=>i.filter(P=>P.sourceId===k.id||P.targetId===k.id).length,h=r.find(gi)??r.find(k=>/system/i.test(k.name))??[...r].sort((k,P)=>c(P)-c(k))[0],g=r.filter(k=>k.id!==h.id),l=new Set([h.id,...g.map(k=>k.id)]),y=i.filter(k=>l.has(k.sourceId)&&l.has(k.targetId)),w=pi(g.map(k=>k.id),y,h.id);for(const k of y){const P=fi(k);P&&w.set(k.sourceId,P)}const m=k=>fn.has(k.kind)?0:mn(k)?1:2,p=k=>g.filter(P=>w.get(P.id)===k).sort((P,R)=>m(P)-m(R)||P.name.localeCompare(R.name)),u={left:p("left"),right:p("right"),top:p("top"),bottom:p("bottom")},M=k=>k.length===0?0:k.length*Jt+(k.length-1)*Re,I=k=>k.length===0?0:Math.max(...k.map(P=>We(P.name))),S=k=>k.length===0?0:k.reduce((P,R)=>P+We(R.name),0)+(k.length-1)*Re,E=je+$e*2,v=Be+He*2,D=I(u.left),K=pn+(D>0?D+be:0)+Math.max(E,S(u.top),S(u.bottom))/2,Z=pn+(u.top.length>0?Jt+be:0)+Math.max(v,M(u.left),M(u.right))/2,H=K-E/2,B=Z-v/2,Y=H+E+(u.right.length>0?be:0),nt=[{id:"__context_boundary__",type:"contextBoundary",position:{x:H,y:B},style:{width:E,height:v},data:{label:`${t??h.name} — System Boundary`,isFrame:!0,minWidth:je+$e*2,minHeight:Be+He*2},zIndex:-1},{id:h.id,type:"contextSystem",parentId:"__context_boundary__",extent:"parent",position:{x:$e,y:He},data:{label:h.name,kind:h.kind},style:{width:je,height:Be}}],ht=new Map;for(const k of["left","right"]){const P=u[k];let R=Z-M(P)/2;for(const J of P){const rt=We(J.name),at=k==="left"?pn+D-rt:Y;ht.set(J.id,{x:at,y:R,width:rt,height:Jt,side:k}),nt.push({id:J.id,type:"contextExternal",position:{x:at,y:R},data:{label:J.name,kind:J.kind,category:mn(J)?"environment":fn.has(J.kind)?"person":"system"},style:{width:rt,height:Jt}}),R+=Jt+Re}}for(const k of["top","bottom"]){const P=u[k],R=S(P);let J=K-R/2;const rt=k==="top"?B-be-Jt:B+v+be;for(const at of P){const St=We(at.name);ht.set(at.id,{x:J,y:rt,width:St,height:Jt,side:k}),nt.push({id:at.id,type:"contextExternal",position:{x:J,y:rt},data:{label:at.name,kind:at.kind,category:mn(at)?"environment":fn.has(at.kind)?"person":"system"},style:{width:St,height:Jt}}),J+=St+Re}}const ft={x:H+$e,y:B+He,width:je,height:Be},_t={left:[],right:[],top:[],bottom:[]};for(const k of y){const P=k.sourceId===h.id?k.targetId:k.sourceId;if(k.sourceId!==h.id&&k.targetId!==h.id)continue;const R=(At=ht.get(P))==null?void 0:At.side;R&&!_t[R].includes(k.id)&&_t[R].push(k.id)}for(const k of["left","right"])_t[k].sort((P,R)=>{const J=rt=>{var St;const at=y.find(Kt=>Kt.id===rt);return((St=ht.get(at.sourceId===h.id?at.targetId:at.sourceId))==null?void 0:St.y)??0};return J(P)-J(R)});const Bt=(k,P)=>{const R=_t[P],J=Math.max(R.indexOf(k),0);return{x:P==="left"?ft.x:P==="right"?ft.x+ft.width:ft.x+ft.width*(J+.5)/Math.max(R.length,1),y:P==="top"?ft.y:P==="bottom"?ft.y+ft.height:ft.y+ft.height*(J+.5)/Math.max(R.length,1)}},q=(k,P)=>{const R=ht.get(k);return P==="top"?{x:R.x+R.width/2,y:R.y}:P==="bottom"?{x:R.x+R.width/2,y:R.y+R.height}:{x:P==="left"?R.x:R.x+R.width,y:R.y+R.height/2}},Lt=(k,P)=>{var St;if(k===h.id)return((St=ht.get(P))==null?void 0:St.side)??"left";const R=ht.get(k),J=P===h.id?ft:ht.get(P),rt={x:R.x+R.width/2,y:R.y+R.height/2},at={x:J.x+J.width/2,y:J.y+J.height/2};return Math.abs(at.y-rt.y)>Math.abs(at.x-rt.x)?at.y<rt.y?"top":"bottom":J.x+(P===h.id?ft.width:ht.get(P).width)/2>=R.x+R.width/2?"right":"left"},$t=y.map(k=>{const P=Lt(k.sourceId,k.targetId),R=Lt(k.targetId,k.sourceId),J=(rt,at)=>rt===h.id?Bt(k.id,at):q(rt,at);return{rel:k,sourceSide:P,targetSide:R,source:J(k.sourceId,P),target:J(k.targetId,R)}}),wt=nt.filter(k=>!k.data.isFrame).map(k=>{var P,R;return{id:k.id,x:k.position.x,y:k.position.y,width:Number(((P=k.style)==null?void 0:P.width)??So),height:Number(((R=k.style)==null?void 0:R.height)??Jt)}}),jt=Ee($t.map(k=>({id:k.rel.id,source:k.source,target:k.target,sourceNodeId:k.rel.sourceId,targetNodeId:k.rel.targetId,sourceSide:k.sourceSide,targetSide:k.targetSide})),wt,24),Dt=new Map($t.map(k=>[k.rel.id,mi(k.rel)])),zt=Je($t.flatMap(k=>{const P=jt.get(k.rel.id),R=Dt.get(k.rel.id);return P&&P.length>=2?[{id:k.rel.id,points:P,width:tn(R),height:Qe}]:[]}),wt),Yt=$t.map(k=>{const P=(R,J,rt)=>{const at=R===h.id?ft:ht.get(R);return{x:rt.x-at.x,y:rt.y-at.y,side:J}};return{id:k.rel.id,source:k.rel.sourceId,target:k.rel.targetId,type:"useCaseEdge",label:Dt.get(k.rel.id),style:{stroke:"#0F766E",strokeWidth:1.5},data:{routing:"rounded",points:jt.get(k.rel.id)??[k.source,k.target],labelPoint:zt.get(k.rel.id),sourceSide:k.sourceSide,targetSide:k.targetSide,sourceOffset:P(k.rel.sourceId,k.sourceSide,k.source),targetOffset:P(k.rel.targetId,k.targetSide,k.target)}}});return{nodes:nt,edges:Yt}}const yi=new Set(["name","title","description","shortDescription","longDescription","sourceReference","rationaleText","semantics","queryDescription","dataSourceDescription","doc"]),xi=7,bn=80;function wi(e,t){const n=e.attributes[t];return n===void 0?void 0:(n.includes("::")?n.split("::").pop().trim():n)||void 0}function bi(e){const t=new Map;for(const n of e)for(const s of Object.keys(n.attributes))yi.has(s)||s.includes(".")||t.set(s,(t.get(s)??0)+1);return[...t.entries()].sort((n,s)=>s[1]-n[1]).slice(0,xi).map(([n])=>n)}function Ii(e){const t=new Map;for(const s of e)t.has(s.kind)||t.set(s.kind,[]),t.get(s.kind).push(s);const n=[];for(const[s,o]of t){const i=bi(o),a=o.map(c=>({element:c,values:i.map(h=>wi(c,h))})),r=i.map((c,h)=>{const g=a.map(l=>l.values[h]).filter(l=>l!==void 0);return g.length>0&&g.every(l=>Number.isFinite(Number(l)))});n.push({kind:s,columns:i,numeric:r,rows:a})}return n.sort((s,o)=>o.rows.length-s.rows.length)}function Mi(e,t,n){const s=n==="asc"?1:-1;return[...e.rows].sort((i,a)=>{if(t<0)return i.element.name.localeCompare(a.element.name)*s;const r=i.values[t],c=a.values[t];return r===void 0&&c===void 0?0:r===void 0?1:c===void 0?-1:e.numeric[t]?(Number(r)-Number(c))*s:r.localeCompare(c)*s})}function Si(e,t,n){const s=new Map(e.map(l=>[l.id,l])),o=n!=null&&n.length?new Set(n.map(l=>l.toLowerCase())):void 0,i=t.filter(l=>s.has(l.sourceId)&&s.has(l.targetId)&&l.sourceId!==l.targetId&&(!o||o.has(l.type.toLowerCase())));if(i.length===0)return;const a=new Set,r=new Set,c=new Map,h=new Set;for(const l of i){a.add(l.sourceId),r.add(l.targetId),h.add(l.type);const y=`${l.sourceId}|${l.targetId}`;c.has(y)||c.set(y,[]),c.get(y).includes(l.type)||c.get(y).push(l.type)}const g=(l,y)=>l.kind.localeCompare(y.kind)||l.name.localeCompare(y.name);return{rows:[...a].map(l=>s.get(l)).sort(g),cols:[...r].map(l=>s.get(l)).sort(g),cells:c,relTypes:[...h].sort()}}const Ve={padding:"6px 10px",fontSize:dt.xs,fontWeight:600,color:"#374151",textAlign:"left",borderBottom:"2px solid #E5E5E0",background:"#FAFAF8",position:"sticky",top:0,cursor:"pointer",whiteSpace:"nowrap",userSelect:"none"},Ze={padding:"5px 10px",fontSize:dt.xs,color:"#374151",borderBottom:"1px solid #F0F0ED",verticalAlign:"top"};function vi(e){return e.length>bn?`${e.slice(0,bn-1)}…`:e}function Ei({section:e,search:t}){var l;const n=Se(y=>y.selectElement),[s,o]=yt.useState(-1),[i,a]=yt.useState("asc"),r=yt.useMemo(()=>{const y=Mi(e,s,i);if(!t)return y;const w=t.toLowerCase();return y.filter(m=>m.element.name.toLowerCase().includes(w)||m.values.some(p=>p==null?void 0:p.toLowerCase().includes(w)))},[e,s,i,t]);if(r.length===0)return null;const c=Qt[(l=e.rows[0])==null?void 0:l.element.layer]||"#6B7280",h=y=>{s===y?a(w=>w==="asc"?"desc":"asc"):(o(y),a("asc"))},g=y=>s===y?i==="asc"?" ↑":" ↓":"";return C.jsxs("div",{style:{marginBottom:28},children:[C.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[C.jsx("span",{style:{width:8,height:8,borderRadius:2,background:c,display:"inline-block"}}),C.jsx("span",{style:{fontSize:dt.sm,fontWeight:700,color:"#1B3A4B"},children:e.kind}),C.jsx("span",{style:{fontSize:dt.xs,color:"#9CA3AF"},children:r.length})]}),C.jsxs("table",{style:{borderCollapse:"collapse",width:"100%",background:"#FFFFFF",borderRadius:8,overflow:"hidden",border:"1px solid #E5E5E0"},children:[C.jsx("thead",{children:C.jsxs("tr",{children:[C.jsxs("th",{style:Ve,onClick:()=>h(-1),children:["Element",g(-1)]}),e.columns.map((y,w)=>C.jsxs("th",{style:Ve,onClick:()=>h(w),children:[y,g(w)]},y))]})}),C.jsx("tbody",{children:r.map(y=>C.jsxs("tr",{onMouseEnter:w=>{w.currentTarget.style.background="#F7F7F5"},onMouseLeave:w=>{w.currentTarget.style.background="transparent"},children:[C.jsx("td",{style:{...Ze,whiteSpace:"nowrap"},children:C.jsx("button",{onClick:()=>n(y.element.id),style:{background:"none",border:"none",padding:0,fontSize:dt.xs,fontWeight:600,color:"#1B6FD9",cursor:"pointer",textDecoration:"none"},title:"Open element detail",children:y.element.name})}),y.values.map((w,m)=>C.jsx("td",{style:Ze,title:w&&w.length>bn?w:void 0,children:w?vi(w):C.jsx("span",{style:{color:"#D1D5DB"},children:"—"})},m))]},y.element.id))})]})]})}function ki({elements:e,model:t,relationshipTypes:n}){const s=Se(a=>a.selectElement),o=yt.useMemo(()=>Si(e,t.relationships,n),[e,t.relationships,n]);if(!o)return C.jsx("div",{style:{color:"#9CA3AF",fontSize:dt.sm,padding:24},children:"No relationships among this view's elements."});const i=(a,r=!1)=>C.jsx("button",{onClick:()=>s(a.id),style:{background:"none",border:"none",padding:0,cursor:"pointer",fontSize:"10px",fontWeight:600,color:"#374151",...r?{writingMode:"vertical-rl",transform:"rotate(180deg)",maxHeight:120}:{},whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:180},title:`${a.kind} · open detail`,children:a.name});return C.jsxs("div",{children:[C.jsx("div",{className:"flex gap-3 mb-2",style:{fontSize:dt.xs,color:"#6B7280"},children:o.relTypes.map(a=>C.jsxs("span",{className:"flex items-center gap-1",children:[C.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:ce[a]||"#6B7280",display:"inline-block"}}),a]},a))}),C.jsxs("table",{style:{borderCollapse:"collapse",background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[C.jsx("thead",{children:C.jsxs("tr",{children:[C.jsx("th",{style:{...Ve,cursor:"default"}}),o.cols.map(a=>C.jsx("th",{style:{...Ve,cursor:"default",verticalAlign:"bottom",padding:"8px 4px"},children:i(a,!0)},a.id))]})}),C.jsx("tbody",{children:o.rows.map(a=>C.jsxs("tr",{children:[C.jsx("td",{style:{...Ze,whiteSpace:"nowrap",background:"#FAFAF8"},children:i(a)}),o.cols.map(r=>{const c=o.cells.get(`${a.id}|${r.id}`);return C.jsx("td",{style:{...Ze,textAlign:"center",padding:"4px 6px"},title:c==null?void 0:c.join(", "),children:c==null?void 0:c.map(h=>C.jsx("span",{style:{width:9,height:9,borderRadius:"50%",margin:1,background:ce[h]||"#6B7280",display:"inline-block"}},h))},r.id)})]},a.id))})]})]})}function dr({diagram:e,model:t,viewpointFilter:n}){const[s,o]=yt.useState("table"),[i,a]=yt.useState(""),r=yt.useMemo(()=>{const g=Object.values(t.elements);return n?g.filter(n):g},[t,n]),c=yt.useMemo(()=>Ii(r),[r]),h=eo.grid;return C.jsx("div",{className:"flex-1 overflow-auto",style:{background:"#F7F7F5"},children:C.jsxs("div",{style:{padding:"16px 20px",maxWidth:1240},children:[C.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[C.jsx("span",{className:"px-1.5 py-0.5 rounded font-semibold",style:{background:h.color+"20",color:h.color,fontSize:dt.badge},title:h.fullName,children:h.label}),C.jsx("span",{style:{fontSize:dt.md,fontWeight:700,color:"#1a1a1a"},children:e.name}),C.jsxs("span",{style:{fontSize:dt.xs,color:"#9CA3AF"},children:[r.length," elements"]}),C.jsx("div",{className:"flex rounded overflow-hidden ml-2",style:{border:"1px solid #E5E5E0"},children:["table","matrix"].map(g=>C.jsx("button",{onClick:()=>o(g),className:"px-2 py-0.5 text-xs font-medium capitalize",style:{background:s===g?"#1B3A4B":"#FFFFFF",color:s===g?"#FFFFFF":"#6B7280",border:"none",cursor:"pointer"},children:g},g))}),s==="table"&&C.jsx("input",{value:i,onChange:g=>a(g.target.value),placeholder:"Filter rows…",className:"px-2 py-1 rounded focus:outline-none ml-auto",style:{fontSize:dt.xs,border:"1px solid #E5E5E0",background:"#FFFFFF",color:"#1a1a1a",width:200}})]}),s==="table"?c.map(g=>C.jsx(Ei,{section:g,search:i},g.kind)):C.jsx(ki,{elements:r,model:t,relationshipTypes:e.relationshipTypes}),s==="table"&&c.length===0&&C.jsx("div",{style:{color:"#9CA3AF",fontSize:dt.sm,padding:24},children:"This view selects no elements."})]})})}const Ai=8;function vo(e,t,n){const s=(t.get(e.id)??[]).filter(o=>n.has(o)).map(o=>vo(n.get(o),t,n));return s.sort(Xe),{id:e.id,label:e.name,element:e,kind:e.kind,layer:e.layer,children:s,count:1+s.reduce((o,i)=>o+i.count,0)}}const Xe=(e,t)=>(e.kind??"").localeCompare(t.kind??"")||e.label.localeCompare(t.label);function Ci(e,t){const n=qe(e,t),s=new Map,o=[];for(const i of n.roots){const a=n.elements.get(i),r=vo(a,n.childrenMap,n.elements),c=a.package;if(!c){o.push(r);continue}if(!s.has(c)){const g=c.split("::").pop()??c,l={id:`pkg:${c}`,label:g,title:c,children:[],count:0};s.set(c,l),o.push(l)}const h=s.get(c);h.children.push(r),h.count+=r.count}for(const i of s.values()){const a=new Set(i.children.map(c=>c.kind));if(i.children.length<=Ai||a.size<=1){i.children.sort(Xe);continue}const r=new Map;for(const c of i.children){const h=c.kind??"—";r.has(h)||r.set(h,[]),r.get(h).push(c)}i.children=[...r.entries()].sort((c,h)=>c[0].localeCompare(h[0])).map(([c,h])=>{var g;return{id:`kind:${i.id}:${c}`,label:c,kind:c,layer:(g=h[0])==null?void 0:g.layer,children:h.sort(Xe),count:h.reduce((l,y)=>l+y.count,0)}})}return o.sort(Xe),o}function Ti(e,t){const n=t.trim().toLowerCase();if(!n)return;const s=new Set,o=new Set,i=(a,r)=>{const c=a.label.toLowerCase().includes(n)||(a.kind??"").toLowerCase().includes(n);let h=!1;for(const g of a.children)i(g,[...r,a.id])&&(h=!0);if(c||h){s.add(a.id);for(const g of r)s.add(g),o.add(g);return h&&o.add(a.id),!0}return!1};for(const a of e)i(a,[]);return{visible:s,expanded:o}}function Fi(e){if(!e)return"·";const t=e.replace(/[^A-Za-z]/g,"").match(/[A-Z]/g);return t&&t.length>=2?t.slice(0,2).join(""):e.slice(0,2).toUpperCase()}function Eo({node:e,depth:t,expanded:n,visible:s,forceExpanded:o,onToggle:i}){const a=Se(m=>m.selectElement),r=Se(m=>m.selectedElementId),c=Se(m=>m.deleteModelElement);if(s&&!s.has(e.id))return null;const h=n.has(e.id)||!!(o!=null&&o.has(e.id)),g=e.children.length>0,l=!e.element,y=Qt[e.layer??""]||"#95A5A6",w=e.element&&e.id===r;return C.jsxs(C.Fragment,{children:[C.jsx(Oo,{id:e.id,label:e.label,depth:t,hasChildren:g,expanded:h,selected:!!w,badge:l?e.id.startsWith("pkg:")?"PKG":"GRP":Fi(e.kind),badgeColor:y,count:g?e.count:void 0,title:e.title??e.kind,onClick:()=>{g&&i(e.id),e.element&&a(e.id)},onDelete:e.element?()=>c(e.id):void 0}),h&&e.children.map(m=>C.jsx(Eo,{node:m,depth:t+1,expanded:n,visible:s,forceExpanded:o,onToggle:i},m.id))]})}function hr({diagram:e,model:t,viewpointFilter:n}){const[s,o]=yt.useState(new Set),[i,a]=yt.useState(""),r=yt.useMemo(()=>{const m=Object.values(t.elements);return n?m.filter(n):m},[t,n]),c=yt.useMemo(()=>Ci(r,t.relationships),[r,t.relationships]),h=yt.useMemo(()=>Ti(c,i),[c,i]),g=yt.useCallback(m=>{o(p=>{const u=new Set(p);return u.has(m)?u.delete(m):u.add(m),u})},[]),l=yt.useCallback((m,p)=>{for(const u of m)u.children.length>0&&(p.add(u.id),l(u.children,p));return p},[]),y=eo.browser,w=r.length;return C.jsx("div",{className:"flex-1 overflow-auto",style:{background:"#F7F7F5"},children:C.jsxs("div",{style:{padding:"16px 20px",maxWidth:860},children:[C.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[C.jsx("span",{className:"px-1.5 py-0.5 rounded font-semibold",style:{background:y.color+"20",color:y.color,fontSize:dt.badge},title:y.fullName,children:y.label}),C.jsx("span",{style:{fontSize:dt.md,fontWeight:700,color:"#1a1a1a"},children:e.name}),C.jsxs("span",{style:{fontSize:dt.xs,color:"#9CA3AF"},children:[w," elements"]}),C.jsx("button",{onClick:()=>o(l(c,new Set)),className:"px-2 py-0.5 text-xs font-medium rounded ml-2",style:{background:"#FFFFFF",color:"#374151",border:"1px solid #E5E5E0",cursor:"pointer"},children:"Expand All"}),C.jsx("button",{onClick:()=>o(new Set),className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#FFFFFF",color:"#374151",border:"1px solid #E5E5E0",cursor:"pointer"},children:"Collapse All"}),C.jsx("input",{value:i,onChange:m=>a(m.target.value),placeholder:"Filter by name or kind…",className:"px-2 py-1 rounded focus:outline-none ml-auto",style:{fontSize:dt.xs,border:"1px solid #E5E5E0",background:"#FFFFFF",color:"#1a1a1a",width:220}})]}),C.jsxs("div",{style:{background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:10,padding:"10px 8px"},children:[c.length===0&&C.jsx("div",{style:{color:"#9CA3AF",fontSize:dt.sm,padding:16},children:"This view selects no elements."}),c.map(m=>C.jsx(Eo,{node:m,depth:0,expanded:s,visible:h==null?void 0:h.visible,forceExpanded:h==null?void 0:h.expanded,onToggle:g},m.id)),h&&c.every(m=>!h.visible.has(m.id))&&C.jsxs("div",{style:{color:"#9CA3AF",fontSize:dt.sm,padding:16},children:["No matches for “",i,"”."]})]})]})})}function gr({x:e,y:t,sourceElement:n,targetElement:s,registries:o,allowedTypes:i,onSelect:a,onCancel:r}){const c=yt.useRef(null),[h,g]=yt.useState(""),[l,y]=yt.useState(""),w=yt.useRef(null);yt.useEffect(()=>{var E;(E=w.current)==null||E.focus()},[]),yt.useEffect(()=>{const E=v=>{c.current&&!c.current.contains(v.target)&&r()};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[r]),yt.useEffect(()=>{const E=v=>{v.key==="Escape"&&r()};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[r]);const m=yt.useMemo(()=>{const E=Co(n,s,o);if(!(i!=null&&i.length))return E;const v=new Set(i.map(D=>D.toLowerCase()));return E.filter(D=>v.has(D.definition.name.toLowerCase())||v.has(D.definition.sysmlName.toLowerCase()))},[n,s,o,i]),p=yt.useMemo(()=>{const E=h.trim().toLowerCase();return E?m.filter(v=>{var D;return((D=v.definition.nativeKeyword)==null?void 0:D.toLowerCase().includes(E))||v.definition.label.toLowerCase().includes(E)||v.definition.name.toLowerCase().includes(E)}):m},[m,h]),u=260,M=320,I=Math.min(e,window.innerWidth-u-8),S=Math.min(t,window.innerHeight-M-8);return C.jsxs("div",{ref:c,className:"fixed z-50 flex flex-col shadow-xl rounded-xl overflow-hidden",style:{left:I,top:S,width:u,maxHeight:M,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.16)"},children:[C.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid #E5E5E0",flexShrink:0},children:[C.jsx("div",{style:{fontSize:dt.xs,fontWeight:600,color:"#374151",marginBottom:4},children:"Relationship Type"}),C.jsxs("div",{style:{fontSize:"10px",color:"#9CA3AF",marginBottom:4},children:[n.kind," → ",s.kind]}),C.jsx("input",{ref:w,value:h,onChange:E=>g(E.target.value),placeholder:"Search…","aria-label":"Search relationship types",className:"w-full px-2 py-1 rounded focus:outline-none",style:{fontSize:dt.xs,background:"#F7F7F5",border:"1px solid #E5E5E0",color:"#374151"}}),C.jsx("input",{value:l,onChange:E=>y(E.target.value),placeholder:"Transported item / flow label (optional)","aria-label":"Transported item or flow label",className:"w-full px-2 py-1 rounded focus:outline-none",style:{marginTop:6,fontSize:dt.xs,background:"#F7F7F5",border:"1px solid #E5E5E0",color:"#374151"}})]}),C.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[p.map(E=>{const{definition:v,direction:D,sourceId:K,targetId:Z}=E,H=v.nativeKeyword??v.label,B=D==="incoming";return C.jsxs("button",{onClick:()=>a({type:v.name,sourceId:K,targetId:Z,direction:D,flowItem:l.trim()||void 0}),className:"w-full flex items-center gap-2.5 px-3 py-1.5 text-left",style:{background:"none",border:"none",cursor:"pointer"},onMouseEnter:Y=>{Y.currentTarget.style.background="#F7F7F5"},onMouseLeave:Y=>{Y.currentTarget.style.background="none"},children:[C.jsx("div",{style:{width:10,height:10,borderRadius:"50%",flexShrink:0,background:ce[v.name]??"#6B7280"}}),C.jsxs("div",{style:{minWidth:0},children:[C.jsxs("div",{style:{fontSize:dt.xs,fontWeight:500,color:"#1a1a1a"},children:[H,B&&C.jsx("span",{style:{color:"#9CA3AF",fontWeight:400},children:" (reversed)"})]}),C.jsxs("div",{className:"truncate",style:{fontSize:"10px",color:"#9CA3AF"},children:[v.sourceEnd.name," → ",v.targetEnd.name]})]})]},`${v.name}-${D}`)}),p.length===0&&C.jsx("div",{className:"p-3 text-center",style:{color:"#9CA3AF",fontSize:dt.xs},children:m.length===0?`The ontology defines no relationship between a ${n.kind} and a ${s.kind}.`:"No matching types"})]})]})}function ur(e){var t,n,s;return((s=(n=(t=e)==null?void 0:t.canvas)==null?void 0:n.layout)==null?void 0:s.provider)??Fo}const Qn={AcceptActionUsage:"accept",SendActionUsage:"send",DecisionNodeUsage:"decision",MergeNodeUsage:"merge",ForkNodeUsage:"fork",JoinNodeUsage:"join",TerminateActionUsage:"activity-final",ActivityFinalNodeUsage:"activity-final",FlowFinalNodeUsage:"flow-final"},to={action:"usage",accept:"accept",send:"send",decision:"decision",merge:"merge",fork:"fork",join:"join",activityFinal:"activity-final",flowFinal:"flow-final"};function Oi(e){return e.isDefinition?"definition":e.metaclass&&Qn[e.metaclass]?Qn[e.metaclass]:e.metaclass&&to[e.metaclass]?to[e.metaclass]:"usage"}const Ie=e=>typeof e=="number"&&Number.isFinite(e)?e:typeof e=="string"&&Number.isFinite(Number.parseFloat(e))?Number.parseFloat(e):void 0;function Ni(e){const t=new Map(e.map(i=>[i.id,i])),n=[],s=new Set,o=i=>{s.has(i.id)||(s.add(i.id),i.parentId&&t.has(i.parentId)&&o(t.get(i.parentId)),n.push(i))};return e.forEach(o),n}function fr(e,t){const n=new Set(e.map(o=>o.id));return{nodes:Ni(e).map(o=>{var m,p,u,M;const i=o.data??{},a=typeof i.label=="string"&&i.label?i.label:o.id,r=typeof i.kind=="string"?i.kind:o.type??"",c=/definition$| def$/i.test(r)||i.isDefinition===!0,h=typeof i.nodeType=="string"?i.nodeType:r,g=i.isFrame===!0?"frame":i.genericRecord===!0?"generic":Oi({metaclass:h||r,isDefinition:c,viewKind:typeof i.viewKind=="string"?i.viewKind:void 0}),l=Array.isArray(i.ports)?i.ports.filter(I=>!!I&&typeof I=="object"&&typeof I.id=="string"):[],y=l.length?l:[...Array.isArray(i.inPorts)?i.inPorts.filter(I=>typeof I=="string").map((I,S)=>({id:`in:${I}`,name:I,side:"left",direction:"in",pin:!0,_i:S})):[],...Array.isArray(i.outPorts)?i.outPorts.filter(I=>typeof I=="string").map((I,S)=>({id:`out:${I}`,name:I,side:"right",direction:"out",pin:!0,_i:S})):[]],w=Array.isArray(i.compartments)?i.compartments:void 0;return{id:o.id,subjectId:typeof i.subjectId=="string"?i.subjectId:o.id,...o.parentId&&n.has(o.parentId)?{parentId:o.parentId}:{},x:((m=o.position)==null?void 0:m.x)??0,y:((p=o.position)==null?void 0:p.y)??0,width:Ie(o.width)??Ie((u=o.style)==null?void 0:u.width)??Math.max(130,a.length*7.5+48),height:Ie(o.height)??Ie((M=o.style)==null?void 0:M.height)??52,label:a,kind:r,glyph:g,color:[i.bgColor,i.color,i.layerColor].find(I=>typeof I=="string"&&!!I)??"#6B7280",isDefinition:c,isFrame:i.isFrame===!0,...y.length?{ports:y}:{},...w!=null&&w.length?{compartments:w}:{},...Array.isArray(i.memberIds)?{memberIds:i.memberIds}:{},...i.orientation==="row"||i.orientation==="column"?{orientation:i.orientation}:{},accessibilityText:`${g} ${a}${r?` (${r})`:""}`,...i.diagnostic&&typeof i.diagnostic=="object"?{diagnostic:i.diagnostic}:{}}}),edges:t.filter(o=>n.has(o.source)&&n.has(o.target)).map(o=>{var a,r,c;const i=o.style;return{id:o.id,subjectId:typeof((a=o.data)==null?void 0:a.subjectId)=="string"?o.data.subjectId:o.id,sourceId:o.source,targetId:o.target,...typeof o.label=="string"&&o.label?{label:o.label}:{},...o.sourceHandle?{sourcePortId:o.sourceHandle}:{},...o.targetHandle?{targetPortId:o.targetHandle}:{},color:typeof(i==null?void 0:i.stroke)=="string"?i.stroke:"#9CA3AF",strokeWidth:Ie(i==null?void 0:i.strokeWidth)??1.5,dashed:typeof(i==null?void 0:i.strokeDasharray)=="string",animated:o.animated===!0,...typeof((r=o.data)==null?void 0:r.routing)=="string"?{routing:o.data.routing}:{},points:Array.isArray((c=o.data)==null?void 0:c.points)&&o.data.points.length>2?o.data.points.slice(1,-1):[]}})}}function mr(e){const t=a=>a.replace(/[&<>"']/g,r=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[r]),n=Math.max(1,...e.nodes.map(a=>a.x+a.width+24)),s=Math.max(1,...e.nodes.map(a=>a.y+a.height+24)),o=a=>{const r=a.glyph==="decision"||a.glyph==="merge"?`<polygon points="${a.x+a.width/2},${a.y} ${a.x+a.width},${a.y+a.height/2} ${a.x+a.width/2},${a.y+a.height} ${a.x},${a.y+a.height/2}"/>`:a.glyph==="fork"||a.glyph==="join"?`<rect x="${a.x}" y="${a.y+a.height/2-4}" width="${a.width}" height="8" rx="2" fill="#111"/>`:a.glyph==="activity-final"?`<circle cx="${a.x+a.width/2}" cy="${a.y+a.height/2}" r="${Math.min(a.width,a.height)/2-3}"/><circle cx="${a.x+a.width/2}" cy="${a.y+a.height/2}" r="${Math.min(a.width,a.height)/2-9}" fill="white"/>`:`<rect x="${a.x}" y="${a.y}" width="${a.width}" height="${a.height}" rx="${a.isDefinition?2:12}"/>`;return`<g data-subject-id="${t(a.subjectId)}" aria-label="${t(a.accessibilityText)}" fill="white" stroke="${a.color}" stroke-width="1.5">${r}<text x="${a.x+a.width/2}" y="${a.y+a.height/2}" text-anchor="middle" fill="#111" stroke="none" font-size="12">${t(a.label)}</text>${a.diagnostic?`<circle cx="${a.x+a.width-7}" cy="${a.y+7}" r="5" fill="#d97706" stroke="none"/>`:""}</g>`},i=a=>{const r=e.nodes.find(g=>g.id===a.sourceId),c=e.nodes.find(g=>g.id===a.targetId);if(!r||!c)return"";const h=[{x:r.x+r.width,y:r.y+r.height/2},...a.points,{x:c.x,y:c.y+c.height/2}].map(g=>`${g.x},${g.y}`).join(" ");return`<g data-subject-id="${t(a.subjectId)}"><polyline points="${h}" fill="none" stroke="${a.color}" stroke-width="${a.strokeWidth}"${a.dashed?' stroke-dasharray="5 3"':""}/>${a.label?`<text x="${(r.x+c.x)/2}" y="${(r.y+c.y)/2-5}" font-size="11">${t(a.label)}</text>`:""}</g>`};return`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${s}" viewBox="0 0 ${n} ${s}">${e.edges.map(i).join("")}${e.nodes.map(o).join("")}</svg>`}export{Qi as A,qe as B,ke as C,Hi as D,cs as E,rs as F,zi as G,ho as H,Vi as I,Xi as J,dr as K,hr as L,ls as M,he as N,Ee as O,fs as P,Bi as Q,gr as R,Je as S,Ki as T,fr as U,mr as V,ss as a,is as b,Wi as c,ar as d,lr as e,Zi as f,nr as g,or as h,cr as i,Yi as j,os as k,ms as l,Ke as m,Ui as n,uo as o,ir as p,er as q,tr as r,ur as s,Us as t,sr as u,Gi as v,rr as w,Ji as x,qi as y,$i as z};
|
|
@@ -51,4 +51,4 @@ Error generating stack: `+d.message+`
|
|
|
51
51
|
`,`
|
|
52
52
|
+`).split(`
|
|
53
53
|
`)),v=m.reduce((g,y)=>g.concat(...y),[]);return[m,v]}return[[],[]]},[n]);return q.useEffect(()=>{const p=(o==null?void 0:o.target)??Sh,m=(o==null?void 0:o.actInsideInputWithModifier)??!0;if(n!==null){const v=x=>{var N,E;if(u.current=x.ctrlKey||x.metaKey||x.shiftKey||x.altKey,(!u.current||u.current&&!m)&&Pp(x))return!1;const k=Eh(x.code,h);if(c.current.add(x[k]),_h(f,c.current,!1)){const L=((E=(N=x.composedPath)==null?void 0:N.call(x))==null?void 0:E[0])||x.target,_=(L==null?void 0:L.nodeName)==="BUTTON"||(L==null?void 0:L.nodeName)==="A";o.preventDefault!==!1&&(u.current||!_)&&x.preventDefault(),s(!0)}},g=x=>{const S=Eh(x.code,h);_h(f,c.current,!0)?(s(!1),c.current.clear()):c.current.delete(x[S]),x.key==="Meta"&&c.current.clear(),u.current=!1},y=()=>{c.current.clear(),s(!1)};return p==null||p.addEventListener("keydown",v),p==null||p.addEventListener("keyup",g),window.addEventListener("blur",y),window.addEventListener("contextmenu",y),()=>{p==null||p.removeEventListener("keydown",v),p==null||p.removeEventListener("keyup",g),window.removeEventListener("blur",y),window.removeEventListener("contextmenu",y)}}},[n,s]),i}function _h(n,o,i){return n.filter(s=>i||s.length===o.size).some(s=>s.every(u=>o.has(u)))}function Eh(n,o){return o.includes(n)?"code":"key"}const Ex=()=>{const n=De();return q.useMemo(()=>({zoomIn:o=>{const{panZoom:i}=n.getState();return i?i.scaleBy(1.2,{duration:o==null?void 0:o.duration}):Promise.resolve(!1)},zoomOut:o=>{const{panZoom:i}=n.getState();return i?i.scaleBy(1/1.2,{duration:o==null?void 0:o.duration}):Promise.resolve(!1)},zoomTo:(o,i)=>{const{panZoom:s}=n.getState();return s?s.scaleTo(o,{duration:i==null?void 0:i.duration}):Promise.resolve(!1)},getZoom:()=>n.getState().transform[2],setViewport:async(o,i)=>{const{transform:[s,u,c],panZoom:f}=n.getState();return f?(await f.setViewport({x:o.x??s,y:o.y??u,zoom:o.zoom??c},i),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[o,i,s]=n.getState().transform;return{x:o,y:i,zoom:s}},setCenter:async(o,i,s)=>n.getState().setCenter(o,i,s),fitBounds:async(o,i)=>{const{width:s,height:u,minZoom:c,maxZoom:f,panZoom:h}=n.getState(),p=Ga(o,s,u,c,f,(i==null?void 0:i.padding)??.1);return h?(await h.setViewport(p,{duration:i==null?void 0:i.duration,ease:i==null?void 0:i.ease,interpolate:i==null?void 0:i.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(o,i={})=>{const{transform:s,snapGrid:u,snapToGrid:c,domNode:f}=n.getState();if(!f)return o;const{x:h,y:p}=f.getBoundingClientRect(),m={x:o.x-h,y:o.y-p},v=i.snapGrid??u,g=i.snapToGrid??c;return hi(m,s,g,v)},flowToScreenPosition:o=>{const{transform:i,domNode:s}=n.getState();if(!s)return o;const{x:u,y:c}=s.getBoundingClientRect(),f=ts(o,i);return{x:f.x+u,y:f.y+c}}}),[])};function Zp(n,o){const i=[],s=new Map,u=[];for(const c of n)if(c.type==="add"){u.push(c);continue}else if(c.type==="remove"||c.type==="replace")s.set(c.id,[c]);else{const f=s.get(c.id);f?f.push(c):s.set(c.id,[c])}for(const c of o){const f=s.get(c.id);if(!f){i.push(c);continue}if(f[0].type==="remove")continue;if(f[0].type==="replace"){i.push({...f[0].item});continue}const h={...c};for(const p of f)kx(p,h);i.push(h)}return u.length&&u.forEach(c=>{c.index!==void 0?i.splice(c.index,0,{...c.item}):i.push({...c.item})}),i}function kx(n,o){switch(n.type){case"select":{o.selected=n.selected;break}case"position":{typeof n.position<"u"&&(o.position=n.position),typeof n.dragging<"u"&&(o.dragging=n.dragging);break}case"dimensions":{typeof n.dimensions<"u"&&(o.measured={...n.dimensions},n.setAttributes&&((n.setAttributes===!0||n.setAttributes==="width")&&(o.width=n.dimensions.width),(n.setAttributes===!0||n.setAttributes==="height")&&(o.height=n.dimensions.height))),typeof n.resizing=="boolean"&&(o.resizing=n.resizing);break}}}function qp(n,o){return Zp(n,o)}function bp(n,o){return Zp(n,o)}function ir(n,o){return{id:n,type:"select",selected:o}}function Yr(n,o=new Set,i=!1){const s=[];for(const[u,c]of n){const f=o.has(u);!(c.selected===void 0&&!f)&&c.selected!==f&&(i&&(c.selected=f),s.push(ir(c.id,f)))}return s}function kh({items:n=[],lookup:o}){var u;const i=[],s=new Map(n.map(c=>[c.id,c]));for(const[c,f]of n.entries()){const h=o.get(f.id),p=((u=h==null?void 0:h.internals)==null?void 0:u.userNode)??h;p!==void 0&&p!==f&&i.push({id:f.id,item:f,type:"replace"}),p===void 0&&i.push({item:f,type:"add",index:c})}for(const[c]of o)s.get(c)===void 0&&i.push({id:c,type:"remove"});return i}function Nh(n){return{id:n.id,type:"remove"}}const Ch=n=>Yw(n),Nx=n=>xp(n);function Jp(n){return q.forwardRef(n)}const Cx=typeof window<"u"?q.useLayoutEffect:q.useEffect;function Mh(n){const[o,i]=q.useState(BigInt(0)),[s]=q.useState(()=>Mx(()=>i(u=>u+BigInt(1))));return Cx(()=>{const u=s.get();u.length&&(n(u),s.reset())},[o]),s}function Mx(n){let o=[];return{get:()=>o,reset:()=>{o=[]},push:i=>{o.push(i),n()}}}const eg=q.createContext(null);function Px({children:n}){const o=De(),i=q.useCallback(h=>{const{nodes:p=[],setNodes:m,hasDefaultNodes:v,onNodesChange:g,nodeLookup:y,fitViewQueued:x,onNodesChangeMiddlewareMap:S}=o.getState();let k=p;for(const E of h)k=typeof E=="function"?E(k):E;let N=kh({items:k,lookup:y});for(const E of S.values())N=E(N);v&&m(k),N.length>0?g==null||g(N):x&&window.requestAnimationFrame(()=>{const{fitViewQueued:E,nodes:L,setNodes:_}=o.getState();E&&_(L)})},[]),s=Mh(i),u=q.useCallback(h=>{const{edges:p=[],setEdges:m,hasDefaultEdges:v,onEdgesChange:g,edgeLookup:y}=o.getState();let x=p;for(const S of h)x=typeof S=="function"?S(x):S;v?m(x):g&&g(kh({items:x,lookup:y}))},[]),c=Mh(u),f=q.useMemo(()=>({nodeQueue:s,edgeQueue:c}),[]);return K.jsx(eg.Provider,{value:f,children:n})}function zx(){const n=q.useContext(eg);if(!n)throw new Error("useBatchContext must be used within a BatchProvider");return n}const Ix=n=>!!n.panZoom;function nc(){const n=Ex(),o=De(),i=zx(),s=Ce(Ix),u=q.useMemo(()=>{const c=g=>o.getState().nodeLookup.get(g),f=g=>{i.nodeQueue.push(g)},h=g=>{i.edgeQueue.push(g)},p=g=>{var E,L;const{nodeLookup:y,nodeOrigin:x}=o.getState(),S=Ch(g)?g:y.get(g.id),k=S.parentId?Cp(S.position,S.measured,S.parentId,y,x):S.position,N={...S,position:k,width:((E=S.measured)==null?void 0:E.width)??S.width,height:((L=S.measured)==null?void 0:L.height)??S.height};return Jr(N)},m=(g,y,x={replace:!1})=>{f(S=>S.map(k=>{if(k.id===g){const N=typeof y=="function"?y(k):y;return x.replace&&Ch(N)?N:{...k,...N}}return k}))},v=(g,y,x={replace:!1})=>{h(S=>S.map(k=>{if(k.id===g){const N=typeof y=="function"?y(k):y;return x.replace&&Nx(N)?N:{...k,...N}}return k}))};return{getNodes:()=>o.getState().nodes.map(g=>({...g})),getNode:g=>{var y;return(y=c(g))==null?void 0:y.internals.userNode},getInternalNode:c,getEdges:()=>{const{edges:g=[]}=o.getState();return g.map(y=>({...y}))},getEdge:g=>o.getState().edgeLookup.get(g),setNodes:f,setEdges:h,addNodes:g=>{const y=Array.isArray(g)?g:[g];i.nodeQueue.push(x=>[...x,...y])},addEdges:g=>{const y=Array.isArray(g)?g:[g];i.edgeQueue.push(x=>[...x,...y])},toObject:()=>{const{nodes:g=[],edges:y=[],transform:x}=o.getState(),[S,k,N]=x;return{nodes:g.map(E=>({...E})),edges:y.map(E=>({...E})),viewport:{x:S,y:k,zoom:N}}},deleteElements:async({nodes:g=[],edges:y=[]})=>{const{nodes:x,edges:S,onNodesDelete:k,onEdgesDelete:N,triggerNodeChanges:E,triggerEdgeChanges:L,onDelete:_,onBeforeDelete:C}=o.getState(),{nodes:F,edges:D}=await qw({nodesToRemove:g,edgesToRemove:y,nodes:x,edges:S,onBeforeDelete:C}),O=D.length>0,Y=F.length>0;if(O){const Q=D.map(Nh);N==null||N(D),L(Q)}if(Y){const Q=F.map(Nh);k==null||k(F),E(Q)}return(Y||O)&&(_==null||_({nodes:F,edges:D})),{deletedNodes:F,deletedEdges:D}},getIntersectingNodes:(g,y=!0,x)=>{const S=bd(g),k=S?g:p(g),N=x!==void 0;return k?(x||o.getState().nodes).filter(E=>{const L=o.getState().nodeLookup.get(E.id);if(L&&!S&&(E.id===g.id||!L.internals.positionAbsolute))return!1;const _=Jr(N?E:L),C=ii(_,k);return y&&C>0||C>=_.width*_.height||C>=k.width*k.height}):[]},isNodeIntersecting:(g,y,x=!0)=>{const k=bd(g)?g:p(g);if(!k)return!1;const N=ii(k,y);return x&&N>0||N>=y.width*y.height||N>=k.width*k.height},updateNode:m,updateNodeData:(g,y,x={replace:!1})=>{m(g,S=>{const k=typeof y=="function"?y(S):y;return x.replace?{...S,data:k}:{...S,data:{...S.data,...k}}},x)},updateEdge:v,updateEdgeData:(g,y,x={replace:!1})=>{v(g,S=>{const k=typeof y=="function"?y(S):y;return x.replace?{...S,data:k}:{...S,data:{...S.data,...k}}},x)},getNodesBounds:g=>{const{nodeLookup:y,nodeOrigin:x}=o.getState();return Qw(g,{nodeLookup:y,nodeOrigin:x})},getHandleConnections:({type:g,id:y,nodeId:x})=>{var S;return Array.from(((S=o.getState().connectionLookup.get(`${x}-${g}${y?`-${y}`:""}`))==null?void 0:S.values())??[])},getNodeConnections:({type:g,handleId:y,nodeId:x})=>{var S;return Array.from(((S=o.getState().connectionLookup.get(`${x}${g?y?`-${g}-${y}`:`-${g}`:""}`))==null?void 0:S.values())??[])},fitView:async g=>{const y=o.getState().fitViewResolver??t1();return o.setState({fitViewQueued:!0,fitViewOptions:g,fitViewResolver:y}),i.nodeQueue.push(x=>[...x]),y.promise}}},[]);return q.useMemo(()=>({...u,...n,viewportInitialized:s}),[s])}const Ph=n=>n.selected,Tx=typeof window<"u"?window:void 0;function Lx({deleteKeyCode:n,multiSelectionKeyCode:o}){const i=De(),{deleteElements:s}=nc(),u=si(n,{actInsideInputWithModifier:!1}),c=si(o,{target:Tx});q.useEffect(()=>{if(u){const{edges:f,nodes:h}=i.getState();s({nodes:h.filter(Ph),edges:f.filter(Ph)}),i.setState({nodesSelectionActive:!1})}},[u]),q.useEffect(()=>{i.setState({multiSelectionActive:c})},[c])}function Ax(n){const o=De();q.useEffect(()=>{const i=()=>{var u,c,f,h;if(!n.current||!(((c=(u=n.current).checkVisibility)==null?void 0:c.call(u))??!0))return!1;const s=Za(n.current);(s.height===0||s.width===0)&&((h=(f=o.getState()).onError)==null||h.call(f,"004",Kt.error004())),o.setState({width:s.width||500,height:s.height||500})};if(n.current){i(),window.addEventListener("resize",i);const s=new ResizeObserver(()=>i());return s.observe(n.current),()=>{window.removeEventListener("resize",i),s&&n.current&&s.unobserve(n.current)}}},[])}const gs={position:"absolute",width:"100%",height:"100%",top:0,left:0},Dx=n=>({userSelectionActive:n.userSelectionActive,lib:n.lib,connectionInProgress:n.connection.inProgress});function Rx({onPaneContextMenu:n,zoomOnScroll:o=!0,zoomOnPinch:i=!0,panOnScroll:s=!1,panOnScrollSpeed:u=.5,panOnScrollMode:c=ur.Free,zoomOnDoubleClick:f=!0,panOnDrag:h=!0,defaultViewport:p,translateExtent:m,minZoom:v,maxZoom:g,zoomActivationKeyCode:y,preventScrolling:x=!0,children:S,noWheelClassName:k,noPanClassName:N,onViewportChange:E,isControlledViewport:L,paneClickDistance:_,selectionOnDrag:C}){const F=De(),D=q.useRef(null),{userSelectionActive:O,lib:Y,connectionInProgress:Q}=Ce(Dx,$e),ne=si(y),j=q.useRef();Ax(D);const U=q.useCallback(b=>{E==null||E({x:b[0],y:b[1],zoom:b[2]}),L||F.setState({transform:b})},[E,L]);return q.useEffect(()=>{if(D.current){j.current=O1({domNode:D.current,minZoom:v,maxZoom:g,translateExtent:m,viewport:p,onDraggingChange:R=>F.setState(W=>W.paneDragging===R?W:{paneDragging:R}),onPanZoomStart:(R,W)=>{const{onViewportChangeStart:P,onMoveStart:I}=F.getState();I==null||I(R,W),P==null||P(W)},onPanZoom:(R,W)=>{const{onViewportChange:P,onMove:I}=F.getState();I==null||I(R,W),P==null||P(W)},onPanZoomEnd:(R,W)=>{const{onViewportChangeEnd:P,onMoveEnd:I}=F.getState();I==null||I(R,W),P==null||P(W)}});const{x:b,y:z,zoom:B}=j.current.getViewport();return F.setState({panZoom:j.current,transform:[b,z,B],domNode:D.current.closest(".react-flow")}),()=>{var R;(R=j.current)==null||R.destroy()}}},[]),q.useEffect(()=>{var b;(b=j.current)==null||b.update({onPaneContextMenu:n,zoomOnScroll:o,zoomOnPinch:i,panOnScroll:s,panOnScrollSpeed:u,panOnScrollMode:c,zoomOnDoubleClick:f,panOnDrag:h,zoomActivationKeyPressed:ne,preventScrolling:x,noPanClassName:N,userSelectionActive:O,noWheelClassName:k,lib:Y,onTransformChange:U,connectionInProgress:Q,selectionOnDrag:C,paneClickDistance:_})},[n,o,i,s,u,c,f,h,ne,x,N,O,k,Y,U,Q,C,_]),K.jsx("div",{className:"react-flow__renderer",ref:D,style:gs,children:S})}const $x=n=>({userSelectionActive:n.userSelectionActive,userSelectionRect:n.userSelectionRect});function Fx(){const{userSelectionActive:n,userSelectionRect:o}=Ce($x,$e);return n&&o?K.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:o.width,height:o.height,transform:`translate(${o.x}px, ${o.y}px)`}}):null}const ka=(n,o)=>i=>{i.target===o.current&&(n==null||n(i))},Ox=n=>({userSelectionActive:n.userSelectionActive,elementsSelectable:n.elementsSelectable,connectionInProgress:n.connection.inProgress,dragging:n.paneDragging});function Hx({isSelecting:n,selectionKeyPressed:o,selectionMode:i=oi.Full,panOnDrag:s,paneClickDistance:u,selectionOnDrag:c,onSelectionStart:f,onSelectionEnd:h,onPaneClick:p,onPaneContextMenu:m,onPaneScroll:v,onPaneMouseEnter:g,onPaneMouseMove:y,onPaneMouseLeave:x,children:S}){const k=De(),{userSelectionActive:N,elementsSelectable:E,dragging:L,connectionInProgress:_}=Ce(Ox,$e),C=E&&(n||N),F=q.useRef(null),D=q.useRef(),O=q.useRef(new Set),Y=q.useRef(new Set),Q=q.useRef(!1),ne=P=>{if(Q.current||_){Q.current=!1;return}p==null||p(P),k.getState().resetSelectedElements(),k.setState({nodesSelectionActive:!1})},j=P=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){P.preventDefault();return}m==null||m(P)},U=v?P=>v(P):void 0,b=P=>{Q.current&&(P.stopPropagation(),Q.current=!1)},z=P=>{var he,fe;const{domNode:I}=k.getState();if(D.current=I==null?void 0:I.getBoundingClientRect(),!D.current)return;const $=P.target===F.current;if(!$&&!!P.target.closest(".nokey")||!n||!(c&&$||o)||P.button!==0||!P.isPrimary)return;(fe=(he=P.target)==null?void 0:he.setPointerCapture)==null||fe.call(he,P.pointerId),Q.current=!1;const{x:le,y:ie}=Ot(P.nativeEvent,D.current);k.setState({userSelectionRect:{width:0,height:0,startX:le,startY:ie,x:le,y:ie}}),$||(P.stopPropagation(),P.preventDefault())},B=P=>{const{userSelectionRect:I,transform:$,nodeLookup:Z,edgeLookup:G,connectionLookup:le,triggerNodeChanges:ie,triggerEdgeChanges:he,defaultEdgeOptions:fe,resetSelectedElements:pe}=k.getState();if(!D.current||!I)return;const{x:oe,y:me}=Ot(P.nativeEvent,D.current),{startX:Ee,startY:Se}=I;if(!Q.current){const Ne=o?0:u;if(Math.hypot(oe-Ee,me-Se)<=Ne)return;pe(),f==null||f(P)}Q.current=!0;const xe={startX:Ee,startY:Se,x:oe<Ee?oe:Ee,y:me<Se?me:Se,width:Math.abs(oe-Ee),height:Math.abs(me-Se)},ge=O.current,ke=Y.current;O.current=new Set(Ka(Z,xe,$,i===oi.Partial,!0).map(Ne=>Ne.id)),Y.current=new Set;const Ie=(fe==null?void 0:fe.selectable)??!0;for(const Ne of O.current){const Be=le.get(Ne);if(Be)for(const{edgeId:Pt}of Be.values()){const ft=G.get(Pt);ft&&(ft.selectable??Ie)&&Y.current.add(Pt)}}if(!Jd(ge,O.current)){const Ne=Yr(Z,O.current,!0);ie(Ne)}if(!Jd(ke,Y.current)){const Ne=Yr(G,Y.current);he(Ne)}k.setState({userSelectionRect:xe,userSelectionActive:!0,nodesSelectionActive:!1})},R=P=>{var I,$;P.button===0&&(($=(I=P.target)==null?void 0:I.releasePointerCapture)==null||$.call(I,P.pointerId),!N&&P.target===F.current&&k.getState().userSelectionRect&&(ne==null||ne(P)),k.setState({userSelectionActive:!1,userSelectionRect:null}),Q.current&&(h==null||h(P),k.setState({nodesSelectionActive:O.current.size>0})))},W=s===!0||Array.isArray(s)&&s.includes(0);return K.jsxs("div",{className:We(["react-flow__pane",{draggable:W,dragging:L,selection:n}]),onClick:C?void 0:ka(ne,F),onContextMenu:ka(j,F),onWheel:ka(U,F),onPointerEnter:C?void 0:g,onPointerMove:C?B:y,onPointerUp:C?R:void 0,onPointerDownCapture:C?z:void 0,onClickCapture:C?b:void 0,onPointerLeave:x,ref:F,style:gs,children:[S,K.jsx(Fx,{})]})}function Ha({id:n,store:o,unselect:i=!1,nodeRef:s}){const{addSelectedNodes:u,unselectNodesAndEdges:c,multiSelectionActive:f,nodeLookup:h,onError:p}=o.getState(),m=h.get(n);if(!m){p==null||p("012",Kt.error012(n));return}o.setState({nodesSelectionActive:!1}),m.selected?(i||m.selected&&f)&&(c({nodes:[m],edges:[]}),requestAnimationFrame(()=>{var v;return(v=s==null?void 0:s.current)==null?void 0:v.blur()})):u([n])}function tg({nodeRef:n,disabled:o=!1,noDragClassName:i,handleSelector:s,nodeId:u,isSelectable:c,nodeClickDistance:f}){const h=De(),[p,m]=q.useState(!1),v=q.useRef();return q.useEffect(()=>{v.current=k1({getStoreItems:()=>h.getState(),onNodeMouseDown:g=>{Ha({id:g,store:h,nodeRef:n})},onDragStart:()=>{m(!0)},onDragStop:()=>{m(!1)}})},[]),q.useEffect(()=>{if(!(o||!n.current||!v.current))return v.current.update({noDragClassName:i,handleSelector:s,domNode:n.current,isSelectable:c,nodeId:u,nodeClickDistance:f}),()=>{var g;(g=v.current)==null||g.destroy()}},[i,s,o,c,n,u,f]),p}const Vx=n=>o=>o.selected&&(o.draggable||n&&typeof o.draggable>"u");function ng(){const n=De();return q.useCallback(i=>{const{nodeExtent:s,snapToGrid:u,snapGrid:c,nodesDraggable:f,onError:h,updateNodePositions:p,nodeLookup:m,nodeOrigin:v}=n.getState(),g=new Map,y=Vx(f),x=u?c[0]:5,S=u?c[1]:5,k=i.direction.x*x*i.factor,N=i.direction.y*S*i.factor;for(const[,E]of m){if(!y(E))continue;let L={x:E.internals.positionAbsolute.x+k,y:E.internals.positionAbsolute.y+N};u&&(L=di(L,c));const{position:_,positionAbsolute:C}=Sp({nodeId:E.id,nextPosition:L,nodeLookup:m,nodeExtent:s,nodeOrigin:v,onError:h});E.position=_,E.internals.positionAbsolute=C,g.set(E.id,E)}p(g)},[])}const rc=q.createContext(null),jx=rc.Provider;rc.Consumer;const rg=()=>q.useContext(rc),Bx=n=>({connectOnClick:n.connectOnClick,noPanClassName:n.noPanClassName,rfId:n.rfId}),Ux=(n,o,i)=>s=>{const{connectionClickStartHandle:u,connectionMode:c,connection:f}=s,{fromHandle:h,toHandle:p,isValid:m}=f,v=(p==null?void 0:p.nodeId)===n&&(p==null?void 0:p.id)===o&&(p==null?void 0:p.type)===i;return{connectingFrom:(h==null?void 0:h.nodeId)===n&&(h==null?void 0:h.id)===o&&(h==null?void 0:h.type)===i,connectingTo:v,clickConnecting:(u==null?void 0:u.nodeId)===n&&(u==null?void 0:u.id)===o&&(u==null?void 0:u.type)===i,isPossibleEndHandle:c===qr.Strict?(h==null?void 0:h.type)!==i:n!==(h==null?void 0:h.nodeId)||o!==(h==null?void 0:h.id),connectionInProcess:!!h,clickConnectionInProcess:!!u,valid:v&&m}};function Wx({type:n="source",position:o=ye.Top,isValidConnection:i,isConnectable:s=!0,isConnectableStart:u=!0,isConnectableEnd:c=!0,id:f,onConnect:h,children:p,className:m,onMouseDown:v,onTouchStart:g,...y},x){var B,R;const S=f||null,k=n==="target",N=De(),E=rg(),{connectOnClick:L,noPanClassName:_,rfId:C}=Ce(Bx,$e),{connectingFrom:F,connectingTo:D,clickConnecting:O,isPossibleEndHandle:Y,connectionInProcess:Q,clickConnectionInProcess:ne,valid:j}=Ce(Ux(E,S,n),$e);E||(R=(B=N.getState()).onError)==null||R.call(B,"010",Kt.error010());const U=W=>{const{defaultEdgeOptions:P,onConnect:I,hasDefaultEdges:$}=N.getState(),Z={...P,...W};if($){const{edges:G,setEdges:le}=N.getState();le(u1(Z,G))}I==null||I(Z),h==null||h(Z)},b=W=>{if(!E)return;const P=zp(W.nativeEvent);if(u&&(P&&W.button===0||!P)){const I=N.getState();Oa.onPointerDown(W.nativeEvent,{handleDomNode:W.currentTarget,autoPanOnConnect:I.autoPanOnConnect,connectionMode:I.connectionMode,connectionRadius:I.connectionRadius,domNode:I.domNode,nodeLookup:I.nodeLookup,lib:I.lib,isTarget:k,handleId:S,nodeId:E,flowId:I.rfId,panBy:I.panBy,cancelConnection:I.cancelConnection,onConnectStart:I.onConnectStart,onConnectEnd:(...$)=>{var Z,G;return(G=(Z=N.getState()).onConnectEnd)==null?void 0:G.call(Z,...$)},updateConnection:I.updateConnection,onConnect:U,isValidConnection:i||((...$)=>{var Z,G;return((G=(Z=N.getState()).isValidConnection)==null?void 0:G.call(Z,...$))??!0}),getTransform:()=>N.getState().transform,getFromHandle:()=>N.getState().connection.fromHandle,autoPanSpeed:I.autoPanSpeed,dragThreshold:I.connectionDragThreshold})}P?v==null||v(W):g==null||g(W)},z=W=>{const{onClickConnectStart:P,onClickConnectEnd:I,connectionClickStartHandle:$,connectionMode:Z,isValidConnection:G,lib:le,rfId:ie,nodeLookup:he,connection:fe}=N.getState();if(!E||!$&&!u)return;if(!$){P==null||P(W.nativeEvent,{nodeId:E,handleId:S,handleType:n}),N.setState({connectionClickStartHandle:{nodeId:E,type:n,id:S}});return}const pe=Mp(W.target),oe=i||G,{connection:me,isValid:Ee}=Oa.isValid(W.nativeEvent,{handle:{nodeId:E,id:S,type:n},connectionMode:Z,fromNodeId:$.nodeId,fromHandleId:$.id||null,fromType:$.type,isValidConnection:oe,flowId:ie,doc:pe,lib:le,nodeLookup:he});Ee&&me&&U(me);const Se=structuredClone(fe);delete Se.inProgress,Se.toPosition=Se.toHandle?Se.toHandle.position:null,I==null||I(W,Se),N.setState({connectionClickStartHandle:null})};return K.jsx("div",{"data-handleid":S,"data-nodeid":E,"data-handlepos":o,"data-id":`${C}-${E}-${S}-${n}`,className:We(["react-flow__handle",`react-flow__handle-${o}`,"nodrag",_,m,{source:!k,target:k,connectable:s,connectablestart:u,connectableend:c,clickconnecting:O,connectingfrom:F,connectingto:D,valid:j,connectionindicator:s&&(!Q||Y)&&(Q||ne?c:u)}]),onMouseDown:b,onTouchStart:b,onClick:L?z:void 0,ref:x,...y,children:p})}const ns=q.memo(Jp(Wx));function Xx({data:n,isConnectable:o,sourcePosition:i=ye.Bottom}){return K.jsxs(K.Fragment,{children:[n==null?void 0:n.label,K.jsx(ns,{type:"source",position:i,isConnectable:o})]})}function Yx({data:n,isConnectable:o,targetPosition:i=ye.Top,sourcePosition:s=ye.Bottom}){return K.jsxs(K.Fragment,{children:[K.jsx(ns,{type:"target",position:i,isConnectable:o}),n==null?void 0:n.label,K.jsx(ns,{type:"source",position:s,isConnectable:o})]})}function Qx(){return null}function Kx({data:n,isConnectable:o,targetPosition:i=ye.Top}){return K.jsxs(K.Fragment,{children:[K.jsx(ns,{type:"target",position:i,isConnectable:o}),n==null?void 0:n.label]})}const rs={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},zh={input:Xx,default:Yx,output:Kx,group:Qx};function Gx(n){var o,i,s,u;return n.internals.handleBounds===void 0?{width:n.width??n.initialWidth??((o=n.style)==null?void 0:o.width),height:n.height??n.initialHeight??((i=n.style)==null?void 0:i.height)}:{width:n.width??((s=n.style)==null?void 0:s.width),height:n.height??((u=n.style)==null?void 0:u.height)}}const Zx=n=>{const{width:o,height:i,x:s,y:u}=fi(n.nodeLookup,{filter:c=>!!c.selected});return{width:Ft(o)?o:null,height:Ft(i)?i:null,userSelectionActive:n.userSelectionActive,transformString:`translate(${n.transform[0]}px,${n.transform[1]}px) scale(${n.transform[2]}) translate(${s}px,${u}px)`}};function qx({onSelectionContextMenu:n,noPanClassName:o,disableKeyboardA11y:i}){const s=De(),{width:u,height:c,transformString:f,userSelectionActive:h}=Ce(Zx,$e),p=ng(),m=q.useRef(null);q.useEffect(()=>{var x;i||(x=m.current)==null||x.focus({preventScroll:!0})},[i]);const v=!h&&u!==null&&c!==null;if(tg({nodeRef:m,disabled:!v}),!v)return null;const g=n?x=>{const S=s.getState().nodes.filter(k=>k.selected);n(x,S)}:void 0,y=x=>{Object.prototype.hasOwnProperty.call(rs,x.key)&&(x.preventDefault(),p({direction:rs[x.key],factor:x.shiftKey?4:1}))};return K.jsx("div",{className:We(["react-flow__nodesselection","react-flow__container",o]),style:{transform:f},children:K.jsx("div",{ref:m,className:"react-flow__nodesselection-rect",onContextMenu:g,tabIndex:i?void 0:-1,onKeyDown:i?void 0:y,style:{width:u,height:c}})})}const Ih=typeof window<"u"?window:void 0,bx=n=>({nodesSelectionActive:n.nodesSelectionActive,userSelectionActive:n.userSelectionActive});function og({children:n,onPaneClick:o,onPaneMouseEnter:i,onPaneMouseMove:s,onPaneMouseLeave:u,onPaneContextMenu:c,onPaneScroll:f,paneClickDistance:h,deleteKeyCode:p,selectionKeyCode:m,selectionOnDrag:v,selectionMode:g,onSelectionStart:y,onSelectionEnd:x,multiSelectionKeyCode:S,panActivationKeyCode:k,zoomActivationKeyCode:N,elementsSelectable:E,zoomOnScroll:L,zoomOnPinch:_,panOnScroll:C,panOnScrollSpeed:F,panOnScrollMode:D,zoomOnDoubleClick:O,panOnDrag:Y,defaultViewport:Q,translateExtent:ne,minZoom:j,maxZoom:U,preventScrolling:b,onSelectionContextMenu:z,noWheelClassName:B,noPanClassName:R,disableKeyboardA11y:W,onViewportChange:P,isControlledViewport:I}){const{nodesSelectionActive:$,userSelectionActive:Z}=Ce(bx,$e),G=si(m,{target:Ih}),le=si(k,{target:Ih}),ie=le||Y,he=le||C,fe=v&&ie!==!0,pe=G||Z||fe;return Lx({deleteKeyCode:p,multiSelectionKeyCode:S}),K.jsx(Rx,{onPaneContextMenu:c,elementsSelectable:E,zoomOnScroll:L,zoomOnPinch:_,panOnScroll:he,panOnScrollSpeed:F,panOnScrollMode:D,zoomOnDoubleClick:O,panOnDrag:!G&&ie,defaultViewport:Q,translateExtent:ne,minZoom:j,maxZoom:U,zoomActivationKeyCode:N,preventScrolling:b,noWheelClassName:B,noPanClassName:R,onViewportChange:P,isControlledViewport:I,paneClickDistance:h,selectionOnDrag:fe,children:K.jsxs(Hx,{onSelectionStart:y,onSelectionEnd:x,onPaneClick:o,onPaneMouseEnter:i,onPaneMouseMove:s,onPaneMouseLeave:u,onPaneContextMenu:c,onPaneScroll:f,panOnDrag:ie,isSelecting:!!pe,selectionMode:g,selectionKeyPressed:G,paneClickDistance:h,selectionOnDrag:fe,children:[n,$&&K.jsx(qx,{onSelectionContextMenu:z,noPanClassName:R,disableKeyboardA11y:W})]})})}og.displayName="FlowRenderer";const Jx=q.memo(og),eS=n=>o=>n?Ka(o.nodeLookup,{x:0,y:0,width:o.width,height:o.height},o.transform,!0).map(i=>i.id):Array.from(o.nodeLookup.keys());function tS(n){return Ce(q.useCallback(eS(n),[n]),$e)}const nS=n=>n.updateNodeInternals;function rS(){const n=Ce(nS),[o]=q.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(i=>{const s=new Map;i.forEach(u=>{const c=u.target.getAttribute("data-id");s.set(c,{id:c,nodeElement:u.target,force:!0})}),n(s)}));return q.useEffect(()=>()=>{o==null||o.disconnect()},[o]),o}function oS({node:n,nodeType:o,hasDimensions:i,resizeObserver:s}){const u=De(),c=q.useRef(null),f=q.useRef(null),h=q.useRef(n.sourcePosition),p=q.useRef(n.targetPosition),m=q.useRef(o),v=i&&!!n.internals.handleBounds;return q.useEffect(()=>{c.current&&!n.hidden&&(!v||f.current!==c.current)&&(f.current&&(s==null||s.unobserve(f.current)),s==null||s.observe(c.current),f.current=c.current)},[v,n.hidden]),q.useEffect(()=>()=>{f.current&&(s==null||s.unobserve(f.current),f.current=null)},[]),q.useEffect(()=>{if(c.current){const g=m.current!==o,y=h.current!==n.sourcePosition,x=p.current!==n.targetPosition;(g||y||x)&&(m.current=o,h.current=n.sourcePosition,p.current=n.targetPosition,u.getState().updateNodeInternals(new Map([[n.id,{id:n.id,nodeElement:c.current,force:!0}]])))}},[n.id,o,n.sourcePosition,n.targetPosition]),c}function iS({id:n,onClick:o,onMouseEnter:i,onMouseMove:s,onMouseLeave:u,onContextMenu:c,onDoubleClick:f,nodesDraggable:h,elementsSelectable:p,nodesConnectable:m,nodesFocusable:v,resizeObserver:g,noDragClassName:y,noPanClassName:x,disableKeyboardA11y:S,rfId:k,nodeTypes:N,nodeClickDistance:E,onError:L}){const{node:_,internals:C,isParent:F}=Ce(oe=>{const me=oe.nodeLookup.get(n),Ee=oe.parentLookup.has(n);return{node:me,internals:me.internals,isParent:Ee}},$e);let D=_.type||"default",O=(N==null?void 0:N[D])||zh[D];O===void 0&&(L==null||L("003",Kt.error003(D)),D="default",O=(N==null?void 0:N.default)||zh.default);const Y=!!(_.draggable||h&&typeof _.draggable>"u"),Q=!!(_.selectable||p&&typeof _.selectable>"u"),ne=!!(_.connectable||m&&typeof _.connectable>"u"),j=!!(_.focusable||v&&typeof _.focusable>"u"),U=De(),b=Np(_),z=oS({node:_,nodeType:D,hasDimensions:b,resizeObserver:g}),B=tg({nodeRef:z,disabled:_.hidden||!Y,noDragClassName:y,handleSelector:_.dragHandle,nodeId:n,isSelectable:Q,nodeClickDistance:E}),R=ng();if(_.hidden)return null;const W=dn(_),P=Gx(_),I=Q||Y||o||i||s||u,$=i?oe=>i(oe,{...C.userNode}):void 0,Z=s?oe=>s(oe,{...C.userNode}):void 0,G=u?oe=>u(oe,{...C.userNode}):void 0,le=c?oe=>c(oe,{...C.userNode}):void 0,ie=f?oe=>f(oe,{...C.userNode}):void 0,he=oe=>{const{selectNodesOnDrag:me,nodeDragThreshold:Ee}=U.getState();Q&&(!me||!Y||Ee>0)&&Ha({id:n,store:U,nodeRef:z}),o&&o(oe,{...C.userNode})},fe=oe=>{if(!(Pp(oe.nativeEvent)||S)){if(mp.includes(oe.key)&&Q){const me=oe.key==="Escape";Ha({id:n,store:U,unselect:me,nodeRef:z})}else if(Y&&_.selected&&Object.prototype.hasOwnProperty.call(rs,oe.key)){oe.preventDefault();const{ariaLabelConfig:me}=U.getState();U.setState({ariaLiveMessage:me["node.a11yDescription.ariaLiveMessage"]({direction:oe.key.replace("Arrow","").toLowerCase(),x:~~C.positionAbsolute.x,y:~~C.positionAbsolute.y})}),R({direction:rs[oe.key],factor:oe.shiftKey?4:1})}}},pe=()=>{var ke;if(S||!((ke=z.current)!=null&&ke.matches(":focus-visible")))return;const{transform:oe,width:me,height:Ee,autoPanOnNodeFocus:Se,setCenter:xe}=U.getState();if(!Se)return;Ka(new Map([[n,_]]),{x:0,y:0,width:me,height:Ee},oe,!0).length>0||xe(_.position.x+W.width/2,_.position.y+W.height/2,{zoom:oe[2]})};return K.jsx("div",{className:We(["react-flow__node",`react-flow__node-${D}`,{[x]:Y},_.className,{selected:_.selected,selectable:Q,parent:F,draggable:Y,dragging:B}]),ref:z,style:{zIndex:C.z,transform:`translate(${C.positionAbsolute.x}px,${C.positionAbsolute.y}px)`,pointerEvents:I?"all":"none",visibility:b?"visible":"hidden",..._.style,...P},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:$,onMouseMove:Z,onMouseLeave:G,onContextMenu:le,onClick:he,onDoubleClick:ie,onKeyDown:j?fe:void 0,tabIndex:j?0:void 0,onFocus:j?pe:void 0,role:_.ariaRole??(j?"group":void 0),"aria-roledescription":"node","aria-describedby":S?void 0:`${Qp}-${k}`,"aria-label":_.ariaLabel,..._.domAttributes,children:K.jsx(jx,{value:n,children:K.jsx(O,{id:n,data:_.data,type:D,positionAbsoluteX:C.positionAbsolute.x,positionAbsoluteY:C.positionAbsolute.y,selected:_.selected??!1,selectable:Q,draggable:Y,deletable:_.deletable??!0,isConnectable:ne,sourcePosition:_.sourcePosition,targetPosition:_.targetPosition,dragging:B,dragHandle:_.dragHandle,zIndex:C.z,parentId:_.parentId,...W})})})}var lS=q.memo(iS);const sS=n=>({nodesDraggable:n.nodesDraggable,nodesConnectable:n.nodesConnectable,nodesFocusable:n.nodesFocusable,elementsSelectable:n.elementsSelectable,onError:n.onError});function ig(n){const{nodesDraggable:o,nodesConnectable:i,nodesFocusable:s,elementsSelectable:u,onError:c}=Ce(sS,$e),f=tS(n.onlyRenderVisibleElements),h=rS();return K.jsx("div",{className:"react-flow__nodes",style:gs,children:f.map(p=>K.jsx(lS,{id:p,nodeTypes:n.nodeTypes,nodeExtent:n.nodeExtent,onClick:n.onNodeClick,onMouseEnter:n.onNodeMouseEnter,onMouseMove:n.onNodeMouseMove,onMouseLeave:n.onNodeMouseLeave,onContextMenu:n.onNodeContextMenu,onDoubleClick:n.onNodeDoubleClick,noDragClassName:n.noDragClassName,noPanClassName:n.noPanClassName,rfId:n.rfId,disableKeyboardA11y:n.disableKeyboardA11y,resizeObserver:h,nodesDraggable:o,nodesConnectable:i,nodesFocusable:s,elementsSelectable:u,nodeClickDistance:n.nodeClickDistance,onError:c},p))})}ig.displayName="NodeRenderer";const uS=q.memo(ig);function aS(n){return Ce(q.useCallback(i=>{if(!n)return i.edges.map(u=>u.id);const s=[];if(i.width&&i.height)for(const u of i.edges){const c=i.nodeLookup.get(u.source),f=i.nodeLookup.get(u.target);c&&f&&i1({sourceNode:c,targetNode:f,width:i.width,height:i.height,transform:i.transform})&&s.push(u.id)}return s},[n]),$e)}const cS=({color:n="none",strokeWidth:o=1})=>{const i={strokeWidth:o,...n&&{stroke:n}};return K.jsx("polyline",{className:"arrow",style:i,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},fS=({color:n="none",strokeWidth:o=1})=>{const i={strokeWidth:o,...n&&{stroke:n,fill:n}};return K.jsx("polyline",{className:"arrowclosed",style:i,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Th={[Jl.Arrow]:cS,[Jl.ArrowClosed]:fS};function dS(n){const o=De();return q.useMemo(()=>{var u,c;return Object.prototype.hasOwnProperty.call(Th,n)?Th[n]:((c=(u=o.getState()).onError)==null||c.call(u,"009",Kt.error009(n)),null)},[n])}const hS=({id:n,type:o,color:i,width:s=12.5,height:u=12.5,markerUnits:c="strokeWidth",strokeWidth:f,orient:h="auto-start-reverse"})=>{const p=dS(o);return p?K.jsx("marker",{className:"react-flow__arrowhead",id:n,markerWidth:`${s}`,markerHeight:`${u}`,viewBox:"-10 -10 20 20",markerUnits:c,orient:h,refX:"0",refY:"0",children:K.jsx(p,{color:i,strokeWidth:f})}):null},lg=({defaultColor:n,rfId:o})=>{const i=Ce(c=>c.edges),s=Ce(c=>c.defaultEdgeOptions),u=q.useMemo(()=>h1(i,{id:o,defaultColor:n,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[i,s,o,n]);return u.length?K.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:K.jsx("defs",{children:u.map(c=>K.jsx(hS,{id:c.id,type:c.type,color:c.color,width:c.width,height:c.height,markerUnits:c.markerUnits,strokeWidth:c.strokeWidth,orient:c.orient},c.id))})}):null};lg.displayName="MarkerDefinitions";var pS=q.memo(lg);function sg({x:n,y:o,label:i,labelStyle:s,labelShowBg:u=!0,labelBgStyle:c,labelBgPadding:f=[2,4],labelBgBorderRadius:h=2,children:p,className:m,...v}){const[g,y]=q.useState({x:1,y:0,width:0,height:0}),x=We(["react-flow__edge-textwrapper",m]),S=q.useRef(null);return q.useEffect(()=>{if(S.current){const k=S.current.getBBox();y({x:k.x,y:k.y,width:k.width,height:k.height})}},[i]),i?K.jsxs("g",{transform:`translate(${n-g.width/2} ${o-g.height/2})`,className:x,visibility:g.width?"visible":"hidden",...v,children:[u&&K.jsx("rect",{width:g.width+2*f[0],x:-f[0],y:-f[1],height:g.height+2*f[1],className:"react-flow__edge-textbg",style:c,rx:h,ry:h}),K.jsx("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:S,style:s,children:i}),p]}):null}sg.displayName="EdgeText";const gS=q.memo(sg);function ms({path:n,labelX:o,labelY:i,label:s,labelStyle:u,labelShowBg:c,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p,interactionWidth:m=20,...v}){return K.jsxs(K.Fragment,{children:[K.jsx("path",{...v,d:n,fill:"none",className:We(["react-flow__edge-path",v.className])}),m?K.jsx("path",{d:n,fill:"none",strokeOpacity:0,strokeWidth:m,className:"react-flow__edge-interaction"}):null,s&&Ft(o)&&Ft(i)?K.jsx(gS,{x:o,y:i,label:s,labelStyle:u,labelShowBg:c,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:p}):null]})}function Lh({pos:n,x1:o,y1:i,x2:s,y2:u}){return n===ye.Left||n===ye.Right?[.5*(o+s),i]:[o,.5*(i+u)]}function ug({sourceX:n,sourceY:o,sourcePosition:i=ye.Bottom,targetX:s,targetY:u,targetPosition:c=ye.Top}){const[f,h]=Lh({pos:i,x1:n,y1:o,x2:s,y2:u}),[p,m]=Lh({pos:c,x1:s,y1:u,x2:n,y2:o}),[v,g,y,x]=Ip({sourceX:n,sourceY:o,targetX:s,targetY:u,sourceControlX:f,sourceControlY:h,targetControlX:p,targetControlY:m});return[`M${n},${o} C${f},${h} ${p},${m} ${s},${u}`,v,g,y,x]}function ag(n){return q.memo(({id:o,sourceX:i,sourceY:s,targetX:u,targetY:c,sourcePosition:f,targetPosition:h,label:p,labelStyle:m,labelShowBg:v,labelBgStyle:g,labelBgPadding:y,labelBgBorderRadius:x,style:S,markerEnd:k,markerStart:N,interactionWidth:E})=>{const[L,_,C]=ug({sourceX:i,sourceY:s,sourcePosition:f,targetX:u,targetY:c,targetPosition:h}),F=n.isInternal?void 0:o;return K.jsx(ms,{id:F,path:L,labelX:_,labelY:C,label:p,labelStyle:m,labelShowBg:v,labelBgStyle:g,labelBgPadding:y,labelBgBorderRadius:x,style:S,markerEnd:k,markerStart:N,interactionWidth:E})})}const mS=ag({isInternal:!1}),cg=ag({isInternal:!0});mS.displayName="SimpleBezierEdge";cg.displayName="SimpleBezierEdgeInternal";function fg(n){return q.memo(({id:o,sourceX:i,sourceY:s,targetX:u,targetY:c,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:m,labelBgPadding:v,labelBgBorderRadius:g,style:y,sourcePosition:x=ye.Bottom,targetPosition:S=ye.Top,markerEnd:k,markerStart:N,pathOptions:E,interactionWidth:L})=>{const[_,C,F]=Ra({sourceX:i,sourceY:s,sourcePosition:x,targetX:u,targetY:c,targetPosition:S,borderRadius:E==null?void 0:E.borderRadius,offset:E==null?void 0:E.offset,stepPosition:E==null?void 0:E.stepPosition}),D=n.isInternal?void 0:o;return K.jsx(ms,{id:D,path:_,labelX:C,labelY:F,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:m,labelBgPadding:v,labelBgBorderRadius:g,style:y,markerEnd:k,markerStart:N,interactionWidth:L})})}const dg=fg({isInternal:!1}),hg=fg({isInternal:!0});dg.displayName="SmoothStepEdge";hg.displayName="SmoothStepEdgeInternal";function pg(n){return q.memo(({id:o,...i})=>{var u;const s=n.isInternal?void 0:o;return K.jsx(dg,{...i,id:s,pathOptions:q.useMemo(()=>{var c;return{borderRadius:0,offset:(c=i.pathOptions)==null?void 0:c.offset}},[(u=i.pathOptions)==null?void 0:u.offset])})})}const yS=pg({isInternal:!1}),gg=pg({isInternal:!0});yS.displayName="StepEdge";gg.displayName="StepEdgeInternal";function mg(n){return q.memo(({id:o,sourceX:i,sourceY:s,targetX:u,targetY:c,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:m,labelBgPadding:v,labelBgBorderRadius:g,style:y,markerEnd:x,markerStart:S,interactionWidth:k})=>{const[N,E,L]=Ap({sourceX:i,sourceY:s,targetX:u,targetY:c}),_=n.isInternal?void 0:o;return K.jsx(ms,{id:_,path:N,labelX:E,labelY:L,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:m,labelBgPadding:v,labelBgBorderRadius:g,style:y,markerEnd:x,markerStart:S,interactionWidth:k})})}const vS=mg({isInternal:!1}),yg=mg({isInternal:!0});vS.displayName="StraightEdge";yg.displayName="StraightEdgeInternal";function vg(n){return q.memo(({id:o,sourceX:i,sourceY:s,targetX:u,targetY:c,sourcePosition:f=ye.Bottom,targetPosition:h=ye.Top,label:p,labelStyle:m,labelShowBg:v,labelBgStyle:g,labelBgPadding:y,labelBgBorderRadius:x,style:S,markerEnd:k,markerStart:N,pathOptions:E,interactionWidth:L})=>{const[_,C,F]=Tp({sourceX:i,sourceY:s,sourcePosition:f,targetX:u,targetY:c,targetPosition:h,curvature:E==null?void 0:E.curvature}),D=n.isInternal?void 0:o;return K.jsx(ms,{id:D,path:_,labelX:C,labelY:F,label:p,labelStyle:m,labelShowBg:v,labelBgStyle:g,labelBgPadding:y,labelBgBorderRadius:x,style:S,markerEnd:k,markerStart:N,interactionWidth:L})})}const wS=vg({isInternal:!1}),wg=vg({isInternal:!0});wS.displayName="BezierEdge";wg.displayName="BezierEdgeInternal";const Ah={default:wg,straight:yg,step:gg,smoothstep:hg,simplebezier:cg},Dh={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},xS=(n,o,i)=>i===ye.Left?n-o:i===ye.Right?n+o:n,SS=(n,o,i)=>i===ye.Top?n-o:i===ye.Bottom?n+o:n,Rh="react-flow__edgeupdater";function $h({position:n,centerX:o,centerY:i,radius:s=10,onMouseDown:u,onMouseEnter:c,onMouseOut:f,type:h}){return K.jsx("circle",{onMouseDown:u,onMouseEnter:c,onMouseOut:f,className:We([Rh,`${Rh}-${h}`]),cx:xS(o,s,n),cy:SS(i,s,n),r:s,stroke:"transparent",fill:"transparent"})}function _S({isReconnectable:n,reconnectRadius:o,edge:i,sourceX:s,sourceY:u,targetX:c,targetY:f,sourcePosition:h,targetPosition:p,onReconnect:m,onReconnectStart:v,onReconnectEnd:g,setReconnecting:y,setUpdateHover:x}){const S=De(),k=(C,F)=>{if(C.button!==0)return;const{autoPanOnConnect:D,domNode:O,connectionMode:Y,connectionRadius:Q,lib:ne,onConnectStart:j,cancelConnection:U,nodeLookup:b,rfId:z,panBy:B,updateConnection:R}=S.getState(),W=F.type==="target",P=(Z,G)=>{y(!1),g==null||g(Z,i,F.type,G)},I=Z=>m==null?void 0:m(i,Z),$=(Z,G)=>{y(!0),v==null||v(C,i,F.type),j==null||j(Z,G)};Oa.onPointerDown(C.nativeEvent,{autoPanOnConnect:D,connectionMode:Y,connectionRadius:Q,domNode:O,handleId:F.id,nodeId:F.nodeId,nodeLookup:b,isTarget:W,edgeUpdaterType:F.type,lib:ne,flowId:z,cancelConnection:U,panBy:B,isValidConnection:(...Z)=>{var G,le;return((le=(G=S.getState()).isValidConnection)==null?void 0:le.call(G,...Z))??!0},onConnect:I,onConnectStart:$,onConnectEnd:(...Z)=>{var G,le;return(le=(G=S.getState()).onConnectEnd)==null?void 0:le.call(G,...Z)},onReconnectEnd:P,updateConnection:R,getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,dragThreshold:S.getState().connectionDragThreshold,handleDomNode:C.currentTarget})},N=C=>k(C,{nodeId:i.target,id:i.targetHandle??null,type:"target"}),E=C=>k(C,{nodeId:i.source,id:i.sourceHandle??null,type:"source"}),L=()=>x(!0),_=()=>x(!1);return K.jsxs(K.Fragment,{children:[(n===!0||n==="source")&&K.jsx($h,{position:h,centerX:s,centerY:u,radius:o,onMouseDown:N,onMouseEnter:L,onMouseOut:_,type:"source"}),(n===!0||n==="target")&&K.jsx($h,{position:p,centerX:c,centerY:f,radius:o,onMouseDown:E,onMouseEnter:L,onMouseOut:_,type:"target"})]})}function ES({id:n,edgesFocusable:o,edgesReconnectable:i,elementsSelectable:s,onClick:u,onDoubleClick:c,onContextMenu:f,onMouseEnter:h,onMouseMove:p,onMouseLeave:m,reconnectRadius:v,onReconnect:g,onReconnectStart:y,onReconnectEnd:x,rfId:S,edgeTypes:k,noPanClassName:N,onError:E,disableKeyboardA11y:L}){let _=Ce(xe=>xe.edgeLookup.get(n));const C=Ce(xe=>xe.defaultEdgeOptions);_=C?{...C,..._}:_;let F=_.type||"default",D=(k==null?void 0:k[F])||Ah[F];D===void 0&&(E==null||E("011",Kt.error011(F)),F="default",D=(k==null?void 0:k.default)||Ah.default);const O=!!(_.focusable||o&&typeof _.focusable>"u"),Y=typeof g<"u"&&(_.reconnectable||i&&typeof _.reconnectable>"u"),Q=!!(_.selectable||s&&typeof _.selectable>"u"),ne=q.useRef(null),[j,U]=q.useState(!1),[b,z]=q.useState(!1),B=De(),{zIndex:R,sourceX:W,sourceY:P,targetX:I,targetY:$,sourcePosition:Z,targetPosition:G}=Ce(q.useCallback(xe=>{const ge=xe.nodeLookup.get(_.source),ke=xe.nodeLookup.get(_.target);if(!ge||!ke)return{zIndex:_.zIndex,...Dh};const Ie=d1({id:n,sourceNode:ge,targetNode:ke,sourceHandle:_.sourceHandle||null,targetHandle:_.targetHandle||null,connectionMode:xe.connectionMode,onError:E});return{zIndex:o1({selected:_.selected,zIndex:_.zIndex,sourceNode:ge,targetNode:ke,elevateOnSelect:xe.elevateEdgesOnSelect,zIndexMode:xe.zIndexMode}),...Ie||Dh}},[_.source,_.target,_.sourceHandle,_.targetHandle,_.selected,_.zIndex]),$e),le=q.useMemo(()=>_.markerStart?`url('#${$a(_.markerStart,S)}')`:void 0,[_.markerStart,S]),ie=q.useMemo(()=>_.markerEnd?`url('#${$a(_.markerEnd,S)}')`:void 0,[_.markerEnd,S]);if(_.hidden||W===null||P===null||I===null||$===null)return null;const he=xe=>{var Ne;const{addSelectedEdges:ge,unselectNodesAndEdges:ke,multiSelectionActive:Ie}=B.getState();Q&&(B.setState({nodesSelectionActive:!1}),_.selected&&Ie?(ke({nodes:[],edges:[_]}),(Ne=ne.current)==null||Ne.blur()):ge([n])),u&&u(xe,_)},fe=c?xe=>{c(xe,{..._})}:void 0,pe=f?xe=>{f(xe,{..._})}:void 0,oe=h?xe=>{h(xe,{..._})}:void 0,me=p?xe=>{p(xe,{..._})}:void 0,Ee=m?xe=>{m(xe,{..._})}:void 0,Se=xe=>{var ge;if(!L&&mp.includes(xe.key)&&Q){const{unselectNodesAndEdges:ke,addSelectedEdges:Ie}=B.getState();xe.key==="Escape"?((ge=ne.current)==null||ge.blur(),ke({edges:[_]})):Ie([n])}};return K.jsx("svg",{style:{zIndex:R},children:K.jsxs("g",{className:We(["react-flow__edge",`react-flow__edge-${F}`,_.className,N,{selected:_.selected,animated:_.animated,inactive:!Q&&!u,updating:j,selectable:Q}]),onClick:he,onDoubleClick:fe,onContextMenu:pe,onMouseEnter:oe,onMouseMove:me,onMouseLeave:Ee,onKeyDown:O?Se:void 0,tabIndex:O?0:void 0,role:_.ariaRole??(O?"group":"img"),"aria-roledescription":"edge","data-id":n,"data-testid":`rf__edge-${n}`,"aria-label":_.ariaLabel===null?void 0:_.ariaLabel||`Edge from ${_.source} to ${_.target}`,"aria-describedby":O?`${Kp}-${S}`:void 0,ref:ne,..._.domAttributes,children:[!b&&K.jsx(D,{id:n,source:_.source,target:_.target,type:_.type,selected:_.selected,animated:_.animated,selectable:Q,deletable:_.deletable??!0,label:_.label,labelStyle:_.labelStyle,labelShowBg:_.labelShowBg,labelBgStyle:_.labelBgStyle,labelBgPadding:_.labelBgPadding,labelBgBorderRadius:_.labelBgBorderRadius,sourceX:W,sourceY:P,targetX:I,targetY:$,sourcePosition:Z,targetPosition:G,data:_.data,style:_.style,sourceHandleId:_.sourceHandle,targetHandleId:_.targetHandle,markerStart:le,markerEnd:ie,pathOptions:"pathOptions"in _?_.pathOptions:void 0,interactionWidth:_.interactionWidth}),Y&&K.jsx(_S,{edge:_,isReconnectable:Y,reconnectRadius:v,onReconnect:g,onReconnectStart:y,onReconnectEnd:x,sourceX:W,sourceY:P,targetX:I,targetY:$,sourcePosition:Z,targetPosition:G,setUpdateHover:U,setReconnecting:z})]})})}var kS=q.memo(ES);const NS=n=>({edgesFocusable:n.edgesFocusable,edgesReconnectable:n.edgesReconnectable,elementsSelectable:n.elementsSelectable,connectionMode:n.connectionMode,onError:n.onError});function xg({defaultMarkerColor:n,onlyRenderVisibleElements:o,rfId:i,edgeTypes:s,noPanClassName:u,onReconnect:c,onEdgeContextMenu:f,onEdgeMouseEnter:h,onEdgeMouseMove:p,onEdgeMouseLeave:m,onEdgeClick:v,reconnectRadius:g,onEdgeDoubleClick:y,onReconnectStart:x,onReconnectEnd:S,disableKeyboardA11y:k}){const{edgesFocusable:N,edgesReconnectable:E,elementsSelectable:L,onError:_}=Ce(NS,$e),C=aS(o);return K.jsxs("div",{className:"react-flow__edges",children:[K.jsx(pS,{defaultColor:n,rfId:i}),C.map(F=>K.jsx(kS,{id:F,edgesFocusable:N,edgesReconnectable:E,elementsSelectable:L,noPanClassName:u,onReconnect:c,onContextMenu:f,onMouseEnter:h,onMouseMove:p,onMouseLeave:m,onClick:v,reconnectRadius:g,onDoubleClick:y,onReconnectStart:x,onReconnectEnd:S,rfId:i,onError:_,edgeTypes:s,disableKeyboardA11y:k},F))]})}xg.displayName="EdgeRenderer";const CS=q.memo(xg),MS=n=>`translate(${n.transform[0]}px,${n.transform[1]}px) scale(${n.transform[2]})`;function PS({children:n}){const o=Ce(MS);return K.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:o},children:n})}function zS(n){const o=nc(),i=q.useRef(!1);q.useEffect(()=>{!i.current&&o.viewportInitialized&&n&&(setTimeout(()=>n(o),1),i.current=!0)},[n,o.viewportInitialized])}const IS=n=>{var o;return(o=n.panZoom)==null?void 0:o.syncViewport};function TS(n){const o=Ce(IS),i=De();return q.useEffect(()=>{n&&(o==null||o(n),i.setState({transform:[n.x,n.y,n.zoom]}))},[n,o]),null}function LS(n){return n.connection.inProgress?{...n.connection,to:hi(n.connection.to,n.transform)}:{...n.connection}}function AS(n){return LS}function DS(n){const o=AS();return Ce(o,$e)}const RS=n=>({nodesConnectable:n.nodesConnectable,isValid:n.connection.isValid,inProgress:n.connection.inProgress,width:n.width,height:n.height});function $S({containerStyle:n,style:o,type:i,component:s}){const{nodesConnectable:u,width:c,height:f,isValid:h,inProgress:p}=Ce(RS,$e);return!(c&&u&&p)?null:K.jsx("svg",{style:n,width:c,height:f,className:"react-flow__connectionline react-flow__container",children:K.jsx("g",{className:We(["react-flow__connection",wp(h)]),children:K.jsx(Sg,{style:o,type:i,CustomComponent:s,isValid:h})})})}const Sg=({style:n,type:o=Fn.Bezier,CustomComponent:i,isValid:s})=>{const{inProgress:u,from:c,fromNode:f,fromHandle:h,fromPosition:p,to:m,toNode:v,toHandle:g,toPosition:y,pointer:x}=DS();if(!u)return;if(i)return K.jsx(i,{connectionLineType:o,connectionLineStyle:n,fromNode:f,fromHandle:h,fromX:c.x,fromY:c.y,toX:m.x,toY:m.y,fromPosition:p,toPosition:y,connectionStatus:wp(s),toNode:v,toHandle:g,pointer:x});let S="";const k={sourceX:c.x,sourceY:c.y,sourcePosition:p,targetX:m.x,targetY:m.y,targetPosition:y};switch(o){case Fn.Bezier:[S]=Tp(k);break;case Fn.SimpleBezier:[S]=ug(k);break;case Fn.Step:[S]=Ra({...k,borderRadius:0});break;case Fn.SmoothStep:[S]=Ra(k);break;default:[S]=Ap(k)}return K.jsx("path",{d:S,fill:"none",className:"react-flow__connection-path",style:n})};Sg.displayName="ConnectionLine";const FS={};function Fh(n=FS){q.useRef(n),De(),q.useEffect(()=>{},[n])}function OS(){De(),q.useRef(!1),q.useEffect(()=>{},[])}function _g({nodeTypes:n,edgeTypes:o,onInit:i,onNodeClick:s,onEdgeClick:u,onNodeDoubleClick:c,onEdgeDoubleClick:f,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:m,onNodeContextMenu:v,onSelectionContextMenu:g,onSelectionStart:y,onSelectionEnd:x,connectionLineType:S,connectionLineStyle:k,connectionLineComponent:N,connectionLineContainerStyle:E,selectionKeyCode:L,selectionOnDrag:_,selectionMode:C,multiSelectionKeyCode:F,panActivationKeyCode:D,zoomActivationKeyCode:O,deleteKeyCode:Y,onlyRenderVisibleElements:Q,elementsSelectable:ne,defaultViewport:j,translateExtent:U,minZoom:b,maxZoom:z,preventScrolling:B,defaultMarkerColor:R,zoomOnScroll:W,zoomOnPinch:P,panOnScroll:I,panOnScrollSpeed:$,panOnScrollMode:Z,zoomOnDoubleClick:G,panOnDrag:le,onPaneClick:ie,onPaneMouseEnter:he,onPaneMouseMove:fe,onPaneMouseLeave:pe,onPaneScroll:oe,onPaneContextMenu:me,paneClickDistance:Ee,nodeClickDistance:Se,onEdgeContextMenu:xe,onEdgeMouseEnter:ge,onEdgeMouseMove:ke,onEdgeMouseLeave:Ie,reconnectRadius:Ne,onReconnect:Be,onReconnectStart:Pt,onReconnectEnd:ft,noDragClassName:dt,noWheelClassName:xt,noPanClassName:Zt,disableKeyboardA11y:hn,nodeExtent:pr,rfId:Hn,viewport:qt,onViewportChange:bt}){return Fh(n),Fh(o),OS(),zS(i),TS(qt),K.jsx(Jx,{onPaneClick:ie,onPaneMouseEnter:he,onPaneMouseMove:fe,onPaneMouseLeave:pe,onPaneContextMenu:me,onPaneScroll:oe,paneClickDistance:Ee,deleteKeyCode:Y,selectionKeyCode:L,selectionOnDrag:_,selectionMode:C,onSelectionStart:y,onSelectionEnd:x,multiSelectionKeyCode:F,panActivationKeyCode:D,zoomActivationKeyCode:O,elementsSelectable:ne,zoomOnScroll:W,zoomOnPinch:P,zoomOnDoubleClick:G,panOnScroll:I,panOnScrollSpeed:$,panOnScrollMode:Z,panOnDrag:le,defaultViewport:j,translateExtent:U,minZoom:b,maxZoom:z,onSelectionContextMenu:g,preventScrolling:B,noDragClassName:dt,noWheelClassName:xt,noPanClassName:Zt,disableKeyboardA11y:hn,onViewportChange:bt,isControlledViewport:!!qt,children:K.jsxs(PS,{children:[K.jsx(CS,{edgeTypes:o,onEdgeClick:u,onEdgeDoubleClick:f,onReconnect:Be,onReconnectStart:Pt,onReconnectEnd:ft,onlyRenderVisibleElements:Q,onEdgeContextMenu:xe,onEdgeMouseEnter:ge,onEdgeMouseMove:ke,onEdgeMouseLeave:Ie,reconnectRadius:Ne,defaultMarkerColor:R,noPanClassName:Zt,disableKeyboardA11y:hn,rfId:Hn}),K.jsx($S,{style:k,type:S,component:N,containerStyle:E}),K.jsx("div",{className:"react-flow__edgelabel-renderer"}),K.jsx(uS,{nodeTypes:n,onNodeClick:s,onNodeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:p,onNodeMouseLeave:m,onNodeContextMenu:v,nodeClickDistance:Se,onlyRenderVisibleElements:Q,noPanClassName:Zt,noDragClassName:dt,disableKeyboardA11y:hn,nodeExtent:pr,rfId:Hn}),K.jsx("div",{className:"react-flow__viewport-portal"})]})})}_g.displayName="GraphView";const HS=q.memo(_g),Oh=({nodes:n,edges:o,defaultNodes:i,defaultEdges:s,width:u,height:c,fitView:f,fitViewOptions:h,minZoom:p=.5,maxZoom:m=2,nodeOrigin:v,nodeExtent:g,zIndexMode:y="basic"}={})=>{const x=new Map,S=new Map,k=new Map,N=new Map,E=s??o??[],L=i??n??[],_=v??[0,0],C=g??ri;$p(k,N,E);const F=Fa(L,x,S,{nodeOrigin:_,nodeExtent:C,zIndexMode:y});let D=[0,0,1];if(f&&u&&c){const O=fi(x,{filter:j=>!!((j.width||j.initialWidth)&&(j.height||j.initialHeight))}),{x:Y,y:Q,zoom:ne}=Ga(O,u,c,p,m,(h==null?void 0:h.padding)??.1);D=[Y,Q,ne]}return{rfId:"1",width:u??0,height:c??0,transform:D,nodes:L,nodesInitialized:F,nodeLookup:x,parentLookup:S,edges:E,edgeLookup:N,connectionLookup:k,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:i!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:p,maxZoom:m,translateExtent:ri,nodeExtent:C,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:qr.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:_,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:f??!1,fitViewOptions:h,fitViewResolver:null,connection:{...vp},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:bw,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:yp,zIndexMode:y,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},VS=({nodes:n,edges:o,defaultNodes:i,defaultEdges:s,width:u,height:c,fitView:f,fitViewOptions:h,minZoom:p,maxZoom:m,nodeOrigin:v,nodeExtent:g,zIndexMode:y})=>ox((x,S)=>{async function k(){const{nodeLookup:N,panZoom:E,fitViewOptions:L,fitViewResolver:_,width:C,height:F,minZoom:D,maxZoom:O}=S();E&&(await Zw({nodes:N,width:C,height:F,panZoom:E,minZoom:D,maxZoom:O},L),_==null||_.resolve(!0),x({fitViewResolver:null}))}return{...Oh({nodes:n,edges:o,width:u,height:c,fitView:f,fitViewOptions:h,minZoom:p,maxZoom:m,nodeOrigin:v,nodeExtent:g,defaultNodes:i,defaultEdges:s,zIndexMode:y}),setNodes:N=>{const{nodeLookup:E,parentLookup:L,nodeOrigin:_,elevateNodesOnSelect:C,fitViewQueued:F,zIndexMode:D}=S(),O=Fa(N,E,L,{nodeOrigin:_,nodeExtent:g,elevateNodesOnSelect:C,checkEquality:!0,zIndexMode:D});F&&O?(k(),x({nodes:N,nodesInitialized:O,fitViewQueued:!1,fitViewOptions:void 0})):x({nodes:N,nodesInitialized:O})},setEdges:N=>{const{connectionLookup:E,edgeLookup:L}=S();$p(E,L,N),x({edges:N})},setDefaultNodesAndEdges:(N,E)=>{if(N){const{setNodes:L}=S();L(N),x({hasDefaultNodes:!0})}if(E){const{setEdges:L}=S();L(E),x({hasDefaultEdges:!0})}},updateNodeInternals:N=>{const{triggerNodeChanges:E,nodeLookup:L,parentLookup:_,domNode:C,nodeOrigin:F,nodeExtent:D,debug:O,fitViewQueued:Y,zIndexMode:Q}=S(),{changes:ne,updatedInternals:j}=x1(N,L,_,C,F,D,Q);j&&(m1(L,_,{nodeOrigin:F,nodeExtent:D,zIndexMode:Q}),Y?(k(),x({fitViewQueued:!1,fitViewOptions:void 0})):x({}),(ne==null?void 0:ne.length)>0&&(O&&console.log("React Flow: trigger node changes",ne),E==null||E(ne)))},updateNodePositions:(N,E=!1)=>{const L=[];let _=[];const{nodeLookup:C,triggerNodeChanges:F,connection:D,updateConnection:O,onNodesChangeMiddlewareMap:Y}=S();for(const[Q,ne]of N){const j=C.get(Q),U=!!(j!=null&&j.expandParent&&(j!=null&&j.parentId)&&(ne!=null&&ne.position)),b={id:Q,type:"position",position:U?{x:Math.max(0,ne.position.x),y:Math.max(0,ne.position.y)}:ne.position,dragging:E};if(j&&D.inProgress&&D.fromNode.id===j.id){const z=dr(j,D.fromHandle,ye.Left,!0);O({...D,from:z})}U&&j.parentId&&L.push({id:Q,parentId:j.parentId,rect:{...ne.internals.positionAbsolute,width:ne.measured.width??0,height:ne.measured.height??0}}),_.push(b)}if(L.length>0){const{parentLookup:Q,nodeOrigin:ne}=S(),j=tc(L,C,Q,ne);_.push(...j)}for(const Q of Y.values())_=Q(_);F(_)},triggerNodeChanges:N=>{const{onNodesChange:E,setNodes:L,nodes:_,hasDefaultNodes:C,debug:F}=S();if(N!=null&&N.length){if(C){const D=qp(N,_);L(D)}F&&console.log("React Flow: trigger node changes",N),E==null||E(N)}},triggerEdgeChanges:N=>{const{onEdgesChange:E,setEdges:L,edges:_,hasDefaultEdges:C,debug:F}=S();if(N!=null&&N.length){if(C){const D=bp(N,_);L(D)}F&&console.log("React Flow: trigger edge changes",N),E==null||E(N)}},addSelectedNodes:N=>{const{multiSelectionActive:E,edgeLookup:L,nodeLookup:_,triggerNodeChanges:C,triggerEdgeChanges:F}=S();if(E){const D=N.map(O=>ir(O,!0));C(D);return}C(Yr(_,new Set([...N]),!0)),F(Yr(L))},addSelectedEdges:N=>{const{multiSelectionActive:E,edgeLookup:L,nodeLookup:_,triggerNodeChanges:C,triggerEdgeChanges:F}=S();if(E){const D=N.map(O=>ir(O,!0));F(D);return}F(Yr(L,new Set([...N]))),C(Yr(_,new Set,!0))},unselectNodesAndEdges:({nodes:N,edges:E}={})=>{const{edges:L,nodes:_,nodeLookup:C,triggerNodeChanges:F,triggerEdgeChanges:D}=S(),O=N||_,Y=E||L,Q=[];for(const j of O){if(!j.selected)continue;const U=C.get(j.id);U&&(U.selected=!1),Q.push(ir(j.id,!1))}const ne=[];for(const j of Y)j.selected&&ne.push(ir(j.id,!1));F(Q),D(ne)},setMinZoom:N=>{const{panZoom:E,maxZoom:L}=S();E==null||E.setScaleExtent([N,L]),x({minZoom:N})},setMaxZoom:N=>{const{panZoom:E,minZoom:L}=S();E==null||E.setScaleExtent([L,N]),x({maxZoom:N})},setTranslateExtent:N=>{var E;(E=S().panZoom)==null||E.setTranslateExtent(N),x({translateExtent:N})},resetSelectedElements:()=>{const{edges:N,nodes:E,triggerNodeChanges:L,triggerEdgeChanges:_,elementsSelectable:C}=S();if(!C)return;const F=E.reduce((O,Y)=>Y.selected?[...O,ir(Y.id,!1)]:O,[]),D=N.reduce((O,Y)=>Y.selected?[...O,ir(Y.id,!1)]:O,[]);L(F),_(D)},setNodeExtent:N=>{const{nodes:E,nodeLookup:L,parentLookup:_,nodeOrigin:C,elevateNodesOnSelect:F,nodeExtent:D,zIndexMode:O}=S();N[0][0]===D[0][0]&&N[0][1]===D[0][1]&&N[1][0]===D[1][0]&&N[1][1]===D[1][1]||(Fa(E,L,_,{nodeOrigin:C,nodeExtent:N,elevateNodesOnSelect:F,checkEquality:!1,zIndexMode:O}),x({nodeExtent:N}))},panBy:N=>{const{transform:E,width:L,height:_,panZoom:C,translateExtent:F}=S();return S1({delta:N,panZoom:C,transform:E,translateExtent:F,width:L,height:_})},setCenter:async(N,E,L)=>{const{width:_,height:C,maxZoom:F,panZoom:D}=S();if(!D)return Promise.resolve(!1);const O=typeof(L==null?void 0:L.zoom)<"u"?L.zoom:F;return await D.setViewport({x:_/2-N*O,y:C/2-E*O,zoom:O},{duration:L==null?void 0:L.duration,ease:L==null?void 0:L.ease,interpolate:L==null?void 0:L.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{x({connection:{...vp}})},updateConnection:N=>{x({connection:N})},reset:()=>x({...Oh()})}},Object.is);function jS({initialNodes:n,initialEdges:o,defaultNodes:i,defaultEdges:s,initialWidth:u,initialHeight:c,initialMinZoom:f,initialMaxZoom:h,initialFitViewOptions:p,fitView:m,nodeOrigin:v,nodeExtent:g,zIndexMode:y,children:x}){const[S]=q.useState(()=>VS({nodes:n,edges:o,defaultNodes:i,defaultEdges:s,width:u,height:c,fitView:m,minZoom:f,maxZoom:h,fitViewOptions:p,nodeOrigin:v,nodeExtent:g,zIndexMode:y}));return K.jsx(ix,{value:S,children:K.jsx(Px,{children:x})})}function BS({children:n,nodes:o,edges:i,defaultNodes:s,defaultEdges:u,width:c,height:f,fitView:h,fitViewOptions:p,minZoom:m,maxZoom:v,nodeOrigin:g,nodeExtent:y,zIndexMode:x}){return q.useContext(hs)?K.jsx(K.Fragment,{children:n}):K.jsx(jS,{initialNodes:o,initialEdges:i,defaultNodes:s,defaultEdges:u,initialWidth:c,initialHeight:f,fitView:h,initialFitViewOptions:p,initialMinZoom:m,initialMaxZoom:v,nodeOrigin:g,nodeExtent:y,zIndexMode:x,children:n})}const US={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function WS({nodes:n,edges:o,defaultNodes:i,defaultEdges:s,className:u,nodeTypes:c,edgeTypes:f,onNodeClick:h,onEdgeClick:p,onInit:m,onMove:v,onMoveStart:g,onMoveEnd:y,onConnect:x,onConnectStart:S,onConnectEnd:k,onClickConnectStart:N,onClickConnectEnd:E,onNodeMouseEnter:L,onNodeMouseMove:_,onNodeMouseLeave:C,onNodeContextMenu:F,onNodeDoubleClick:D,onNodeDragStart:O,onNodeDrag:Y,onNodeDragStop:Q,onNodesDelete:ne,onEdgesDelete:j,onDelete:U,onSelectionChange:b,onSelectionDragStart:z,onSelectionDrag:B,onSelectionDragStop:R,onSelectionContextMenu:W,onSelectionStart:P,onSelectionEnd:I,onBeforeDelete:$,connectionMode:Z,connectionLineType:G=Fn.Bezier,connectionLineStyle:le,connectionLineComponent:ie,connectionLineContainerStyle:he,deleteKeyCode:fe="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:oe=!1,selectionMode:me=oi.Full,panActivationKeyCode:Ee="Space",multiSelectionKeyCode:Se=li()?"Meta":"Control",zoomActivationKeyCode:xe=li()?"Meta":"Control",snapToGrid:ge,snapGrid:ke,onlyRenderVisibleElements:Ie=!1,selectNodesOnDrag:Ne,nodesDraggable:Be,autoPanOnNodeFocus:Pt,nodesConnectable:ft,nodesFocusable:dt,nodeOrigin:xt=Gp,edgesFocusable:Zt,edgesReconnectable:hn,elementsSelectable:pr=!0,defaultViewport:Hn=vx,minZoom:qt=.5,maxZoom:bt=2,translateExtent:Vn=ri,preventScrolling:pi=!0,nodeExtent:Jt,defaultMarkerColor:jn="#b1b1b7",zoomOnScroll:ys=!0,zoomOnPinch:gi=!0,panOnScroll:mi=!1,panOnScrollSpeed:vs=.5,panOnScrollMode:to=ur.Free,zoomOnDoubleClick:no=!0,panOnDrag:ro=!0,onPaneClick:oo,onPaneMouseEnter:io,onPaneMouseMove:pn,onPaneMouseLeave:gn,onPaneScroll:yi,onPaneContextMenu:vi,paneClickDistance:wi=1,nodeClickDistance:xi=0,children:Si,onReconnect:lo,onReconnectStart:_i,onReconnectEnd:Bn,onEdgeContextMenu:so,onEdgeDoubleClick:Un,onEdgeMouseEnter:ws,onEdgeMouseMove:Wn,onEdgeMouseLeave:gr,reconnectRadius:mr=10,onNodesChange:uo,onEdgesChange:xs,noDragClassName:Ss="nodrag",noWheelClassName:_s="nowheel",noPanClassName:Vt="nopan",fitView:ao,fitViewOptions:co,connectOnClick:Es,attributionPosition:Ei,proOptions:ki,defaultEdgeOptions:Ni,elevateNodesOnSelect:Ci=!0,elevateEdgesOnSelect:ks=!1,disableKeyboardA11y:Mi=!1,autoPanOnConnect:Fe,autoPanOnNodeDrag:Ns,autoPanSpeed:fo,connectionRadius:Pi,isValidConnection:yr,onError:Cs,style:zi,id:Xn,nodeDragThreshold:St,connectionDragThreshold:Ms,viewport:ht,onViewportChange:Ps,width:zs,height:Is,colorMode:vr="light",debug:wr,onScroll:jt,ariaLabelConfig:xr,zIndexMode:Ii="basic",...Ts},ho){const Sr=Xn||"1",po=_x(vr),Yn=q.useCallback(Ti=>{Ti.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),jt==null||jt(Ti)},[jt]);return K.jsx("div",{"data-testid":"rf__wrapper",...Ts,onScroll:Yn,style:{...zi,...US},ref:ho,className:We(["react-flow",u,po]),id:Xn,role:"application",children:K.jsxs(BS,{nodes:n,edges:o,width:zs,height:Is,fitView:ao,fitViewOptions:co,minZoom:qt,maxZoom:bt,nodeOrigin:xt,nodeExtent:Jt,zIndexMode:Ii,children:[K.jsx(HS,{onInit:m,onNodeClick:h,onEdgeClick:p,onNodeMouseEnter:L,onNodeMouseMove:_,onNodeMouseLeave:C,onNodeContextMenu:F,onNodeDoubleClick:D,nodeTypes:c,edgeTypes:f,connectionLineType:G,connectionLineStyle:le,connectionLineComponent:ie,connectionLineContainerStyle:he,selectionKeyCode:pe,selectionOnDrag:oe,selectionMode:me,deleteKeyCode:fe,multiSelectionKeyCode:Se,panActivationKeyCode:Ee,zoomActivationKeyCode:xe,onlyRenderVisibleElements:Ie,defaultViewport:Hn,translateExtent:Vn,minZoom:qt,maxZoom:bt,preventScrolling:pi,zoomOnScroll:ys,zoomOnPinch:gi,zoomOnDoubleClick:no,panOnScroll:mi,panOnScrollSpeed:vs,panOnScrollMode:to,panOnDrag:ro,onPaneClick:oo,onPaneMouseEnter:io,onPaneMouseMove:pn,onPaneMouseLeave:gn,onPaneScroll:yi,onPaneContextMenu:vi,paneClickDistance:wi,nodeClickDistance:xi,onSelectionContextMenu:W,onSelectionStart:P,onSelectionEnd:I,onReconnect:lo,onReconnectStart:_i,onReconnectEnd:Bn,onEdgeContextMenu:so,onEdgeDoubleClick:Un,onEdgeMouseEnter:ws,onEdgeMouseMove:Wn,onEdgeMouseLeave:gr,reconnectRadius:mr,defaultMarkerColor:jn,noDragClassName:Ss,noWheelClassName:_s,noPanClassName:Vt,rfId:Sr,disableKeyboardA11y:Mi,nodeExtent:Jt,viewport:ht,onViewportChange:Ps}),K.jsx(Sx,{nodes:n,edges:o,defaultNodes:i,defaultEdges:s,onConnect:x,onConnectStart:S,onConnectEnd:k,onClickConnectStart:N,onClickConnectEnd:E,nodesDraggable:Be,autoPanOnNodeFocus:Pt,nodesConnectable:ft,nodesFocusable:dt,edgesFocusable:Zt,edgesReconnectable:hn,elementsSelectable:pr,elevateNodesOnSelect:Ci,elevateEdgesOnSelect:ks,minZoom:qt,maxZoom:bt,nodeExtent:Jt,onNodesChange:uo,onEdgesChange:xs,snapToGrid:ge,snapGrid:ke,connectionMode:Z,translateExtent:Vn,connectOnClick:Es,defaultEdgeOptions:Ni,fitView:ao,fitViewOptions:co,onNodesDelete:ne,onEdgesDelete:j,onDelete:U,onNodeDragStart:O,onNodeDrag:Y,onNodeDragStop:Q,onSelectionDrag:B,onSelectionDragStart:z,onSelectionDragStop:R,onMove:v,onMoveStart:g,onMoveEnd:y,noPanClassName:Vt,nodeOrigin:xt,rfId:Sr,autoPanOnConnect:Fe,autoPanOnNodeDrag:Ns,autoPanSpeed:fo,onError:Cs,connectionRadius:Pi,isValidConnection:yr,selectNodesOnDrag:Ne,nodeDragThreshold:St,connectionDragThreshold:Ms,onBeforeDelete:$,debug:wr,ariaLabelConfig:xr,zIndexMode:Ii}),K.jsx(yx,{onSelectionChange:b}),Si,K.jsx(dx,{proOptions:ki,position:Ei}),K.jsx(fx,{rfId:Sr,disableKeyboardA11y:Mi})]})})}var v_=Jp(WS);const XS=n=>{var o;return(o=n.domNode)==null?void 0:o.querySelector(".react-flow__edgelabel-renderer")};function w_({children:n}){const o=Ce(XS);return o?dm.createPortal(n,o):null}function x_(){const n=De();return q.useCallback(o=>{const{domNode:i,updateNodeInternals:s}=n.getState(),u=Array.isArray(o)?o:[o],c=new Map;u.forEach(f=>{const h=i==null?void 0:i.querySelector(`.react-flow__node[data-id="${f}"]`);h&&c.set(f,{id:f,nodeElement:h,force:!0})}),requestAnimationFrame(()=>s(c,{triggerFitView:!1}))},[])}function S_(n){const[o,i]=q.useState(n),s=q.useCallback(u=>i(c=>qp(u,c)),[]);return[o,i,s]}function __(n){const[o,i]=q.useState(n),s=q.useCallback(u=>i(c=>bp(u,c)),[]);return[o,i,s]}function YS({dimensions:n,lineWidth:o,variant:i,className:s}){return K.jsx("path",{strokeWidth:o,d:`M${n[0]/2} 0 V${n[1]} M0 ${n[1]/2} H${n[0]}`,className:We(["react-flow__background-pattern",i,s])})}function QS({radius:n,className:o}){return K.jsx("circle",{cx:n,cy:n,r:n,className:We(["react-flow__background-pattern","dots",o])})}var On;(function(n){n.Lines="lines",n.Dots="dots",n.Cross="cross"})(On||(On={}));const KS={[On.Dots]:1,[On.Lines]:1,[On.Cross]:6},GS=n=>({transform:n.transform,patternId:`pattern-${n.rfId}`});function Eg({id:n,variant:o=On.Dots,gap:i=20,size:s,lineWidth:u=1,offset:c=0,color:f,bgColor:h,style:p,className:m,patternClassName:v}){const g=q.useRef(null),{transform:y,patternId:x}=Ce(GS,$e),S=s||KS[o],k=o===On.Dots,N=o===On.Cross,E=Array.isArray(i)?i:[i,i],L=[E[0]*y[2]||1,E[1]*y[2]||1],_=S*y[2],C=Array.isArray(c)?c:[c,c],F=N?[_,_]:L,D=[C[0]*y[2]||1+F[0]/2,C[1]*y[2]||1+F[1]/2],O=`${x}${n||""}`;return K.jsxs("svg",{className:We(["react-flow__background",m]),style:{...p,...gs,"--xy-background-color-props":h,"--xy-background-pattern-color-props":f},ref:g,"data-testid":"rf__background",children:[K.jsx("pattern",{id:O,x:y[0]%L[0],y:y[1]%L[1],width:L[0],height:L[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${D[0]},-${D[1]})`,children:k?K.jsx(QS,{radius:_/2,className:v}):K.jsx(YS,{dimensions:F,lineWidth:u,variant:o,className:v})}),K.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${O})`})]})}Eg.displayName="Background";const E_=q.memo(Eg);function ZS(){return K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:K.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function qS(){return K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:K.jsx("path",{d:"M0 0h32v4.2H0z"})})}function bS(){return K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:K.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 JS(){return K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:K.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 e_(){return K.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:K.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 Vl({children:n,className:o,...i}){return K.jsx("button",{type:"button",className:We(["react-flow__controls-button",o]),...i,children:n})}const t_=n=>({isInteractive:n.nodesDraggable||n.nodesConnectable||n.elementsSelectable,minZoomReached:n.transform[2]<=n.minZoom,maxZoomReached:n.transform[2]>=n.maxZoom,ariaLabelConfig:n.ariaLabelConfig});function kg({style:n,showZoom:o=!0,showFitView:i=!0,showInteractive:s=!0,fitViewOptions:u,onZoomIn:c,onZoomOut:f,onFitView:h,onInteractiveChange:p,className:m,children:v,position:g="bottom-left",orientation:y="vertical","aria-label":x}){const S=De(),{isInteractive:k,minZoomReached:N,maxZoomReached:E,ariaLabelConfig:L}=Ce(t_,$e),{zoomIn:_,zoomOut:C,fitView:F}=nc(),D=()=>{_(),c==null||c()},O=()=>{C(),f==null||f()},Y=()=>{F(u),h==null||h()},Q=()=>{S.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),p==null||p(!k)},ne=y==="horizontal"?"horizontal":"vertical";return K.jsxs(ps,{className:We(["react-flow__controls",ne,m]),position:g,style:n,"data-testid":"rf__controls","aria-label":x??L["controls.ariaLabel"],children:[o&&K.jsxs(K.Fragment,{children:[K.jsx(Vl,{onClick:D,className:"react-flow__controls-zoomin",title:L["controls.zoomIn.ariaLabel"],"aria-label":L["controls.zoomIn.ariaLabel"],disabled:E,children:K.jsx(ZS,{})}),K.jsx(Vl,{onClick:O,className:"react-flow__controls-zoomout",title:L["controls.zoomOut.ariaLabel"],"aria-label":L["controls.zoomOut.ariaLabel"],disabled:N,children:K.jsx(qS,{})})]}),i&&K.jsx(Vl,{className:"react-flow__controls-fitview",onClick:Y,title:L["controls.fitView.ariaLabel"],"aria-label":L["controls.fitView.ariaLabel"],children:K.jsx(bS,{})}),s&&K.jsx(Vl,{className:"react-flow__controls-interactive",onClick:Q,title:L["controls.interactive.ariaLabel"],"aria-label":L["controls.interactive.ariaLabel"],children:k?K.jsx(e_,{}):K.jsx(JS,{})}),v]})}kg.displayName="Controls";const k_=q.memo(kg);function n_({id:n,x:o,y:i,width:s,height:u,style:c,color:f,strokeColor:h,strokeWidth:p,className:m,borderRadius:v,shapeRendering:g,selected:y,onClick:x}){const{background:S,backgroundColor:k}=c||{},N=f||S||k;return K.jsx("rect",{className:We(["react-flow__minimap-node",{selected:y},m]),x:o,y:i,rx:v,ry:v,width:s,height:u,style:{fill:N,stroke:h,strokeWidth:p},shapeRendering:g,onClick:x?E=>x(E,n):void 0})}const r_=q.memo(n_),o_=n=>n.nodes.map(o=>o.id),Na=n=>n instanceof Function?n:()=>n;function i_({nodeStrokeColor:n,nodeColor:o,nodeClassName:i="",nodeBorderRadius:s=5,nodeStrokeWidth:u,nodeComponent:c=r_,onClick:f}){const h=Ce(o_,$e),p=Na(o),m=Na(n),v=Na(i),g=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return K.jsx(K.Fragment,{children:h.map(y=>K.jsx(s_,{id:y,nodeColorFunc:p,nodeStrokeColorFunc:m,nodeClassNameFunc:v,nodeBorderRadius:s,nodeStrokeWidth:u,NodeComponent:c,onClick:f,shapeRendering:g},y))})}function l_({id:n,nodeColorFunc:o,nodeStrokeColorFunc:i,nodeClassNameFunc:s,nodeBorderRadius:u,nodeStrokeWidth:c,shapeRendering:f,NodeComponent:h,onClick:p}){const{node:m,x:v,y:g,width:y,height:x}=Ce(S=>{const k=S.nodeLookup.get(n);if(!k)return{node:void 0,x:0,y:0,width:0,height:0};const N=k.internals.userNode,{x:E,y:L}=k.internals.positionAbsolute,{width:_,height:C}=dn(N);return{node:N,x:E,y:L,width:_,height:C}},$e);return!m||m.hidden||!Np(m)?null:K.jsx(h,{x:v,y:g,width:y,height:x,style:m.style,selected:!!m.selected,className:s(m),color:o(m),borderRadius:u,strokeColor:i(m),strokeWidth:c,shapeRendering:f,onClick:p,id:m.id})}const s_=q.memo(l_);var u_=q.memo(i_);const a_=200,c_=150,f_=n=>!n.hidden,d_=n=>{const o={x:-n.transform[0]/n.transform[2],y:-n.transform[1]/n.transform[2],width:n.width/n.transform[2],height:n.height/n.transform[2]};return{viewBB:o,boundingRect:n.nodeLookup.size>0?kp(fi(n.nodeLookup,{filter:f_}),o):o,rfId:n.rfId,panZoom:n.panZoom,translateExtent:n.translateExtent,flowWidth:n.width,flowHeight:n.height,ariaLabelConfig:n.ariaLabelConfig}},h_="react-flow__minimap-desc";function Ng({style:n,className:o,nodeStrokeColor:i,nodeColor:s,nodeClassName:u="",nodeBorderRadius:c=5,nodeStrokeWidth:f,nodeComponent:h,bgColor:p,maskColor:m,maskStrokeColor:v,maskStrokeWidth:g,position:y="bottom-right",onClick:x,onNodeClick:S,pannable:k=!1,zoomable:N=!1,ariaLabel:E,inversePan:L,zoomStep:_=1,offsetScale:C=5}){const F=De(),D=q.useRef(null),{boundingRect:O,viewBB:Y,rfId:Q,panZoom:ne,translateExtent:j,flowWidth:U,flowHeight:b,ariaLabelConfig:z}=Ce(d_,$e),B=(n==null?void 0:n.width)??a_,R=(n==null?void 0:n.height)??c_,W=O.width/B,P=O.height/R,I=Math.max(W,P),$=I*B,Z=I*R,G=C*I,le=O.x-($-O.width)/2-G,ie=O.y-(Z-O.height)/2-G,he=$+G*2,fe=Z+G*2,pe=`${h_}-${Q}`,oe=q.useRef(0),me=q.useRef();oe.current=I,q.useEffect(()=>{if(D.current&&ne)return me.current=I1({domNode:D.current,panZoom:ne,getTransform:()=>F.getState().transform,getViewScale:()=>oe.current}),()=>{var ge;(ge=me.current)==null||ge.destroy()}},[ne]),q.useEffect(()=>{var ge;(ge=me.current)==null||ge.update({translateExtent:j,width:U,height:b,inversePan:L,pannable:k,zoomStep:_,zoomable:N})},[k,N,L,_,j,U,b]);const Ee=x?ge=>{var Ne;const[ke,Ie]=((Ne=me.current)==null?void 0:Ne.pointer(ge))||[0,0];x(ge,{x:ke,y:Ie})}:void 0,Se=S?q.useCallback((ge,ke)=>{const Ie=F.getState().nodeLookup.get(ke).internals.userNode;S(ge,Ie)},[]):void 0,xe=E??z["minimap.ariaLabel"];return K.jsx(ps,{position:y,style:{...n,"--xy-minimap-background-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-background-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-color-props":typeof v=="string"?v:void 0,"--xy-minimap-mask-stroke-width-props":typeof g=="number"?g*I:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof i=="string"?i:void 0,"--xy-minimap-node-stroke-width-props":typeof f=="number"?f:void 0},className:We(["react-flow__minimap",o]),"data-testid":"rf__minimap",children:K.jsxs("svg",{width:B,height:R,viewBox:`${le} ${ie} ${he} ${fe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:D,onClick:Ee,children:[xe&&K.jsx("title",{id:pe,children:xe}),K.jsx(u_,{onClick:Se,nodeColor:s,nodeStrokeColor:i,nodeBorderRadius:c,nodeClassName:u,nodeStrokeWidth:f,nodeComponent:h}),K.jsx("path",{className:"react-flow__minimap-mask",d:`M${le-G},${ie-G}h${he+G*2}v${fe+G*2}h${-he-G*2}z
|
|
54
|
-
M${Y.x},${Y.y}h${Y.width}v${Y.height}h${-Y.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Ng.displayName="MiniMap";const N_=q.memo(Ng),p_=n=>o=>n?`${Math.max(1/o.transform[2],1)}`:void 0,g_={[hr.Line]:"right",[hr.Handle]:"bottom-right"};function m_({nodeId:n,position:o,variant:i=hr.Handle,className:s,style:u=void 0,children:c,color:f,minWidth:h=10,minHeight:p=10,maxWidth:m=Number.MAX_VALUE,maxHeight:v=Number.MAX_VALUE,keepAspectRatio:g=!1,resizeDirection:y,autoScale:x=!0,shouldResize:S,onResizeStart:k,onResize:N,onResizeEnd:E}){const L=rg(),_=typeof n=="string"?n:L,C=De(),F=q.useRef(null),D=i===hr.Handle,O=Ce(q.useCallback(p_(D&&x),[D,x]),$e),Y=q.useRef(null),Q=o??g_[i];q.useEffect(()=>{if(!(!F.current||!_))return Y.current||(Y.current=Y1({domNode:F.current,nodeId:_,getStoreItems:()=>{const{nodeLookup:j,transform:U,snapGrid:b,snapToGrid:z,nodeOrigin:B,domNode:R}=C.getState();return{nodeLookup:j,transform:U,snapGrid:b,snapToGrid:z,nodeOrigin:B,paneDomNode:R}},onChange:(j,U)=>{const{triggerNodeChanges:b,nodeLookup:z,parentLookup:B,nodeOrigin:R}=C.getState(),W=[],P={x:j.x,y:j.y},I=z.get(_);if(I&&I.expandParent&&I.parentId){const $=I.origin??R,Z=j.width??I.measured.width??0,G=j.height??I.measured.height??0,le={id:I.id,parentId:I.parentId,rect:{width:Z,height:G,...Cp({x:j.x??I.position.x,y:j.y??I.position.y},{width:Z,height:G},I.parentId,z,$)}},ie=tc([le],z,B,R);W.push(...ie),P.x=j.x?Math.max($[0]*Z,j.x):void 0,P.y=j.y?Math.max($[1]*G,j.y):void 0}if(P.x!==void 0&&P.y!==void 0){const $={id:_,type:"position",position:{...P}};W.push($)}if(j.width!==void 0&&j.height!==void 0){const Z={id:_,type:"dimensions",resizing:!0,setAttributes:y?y==="horizontal"?"width":"height":!0,dimensions:{width:j.width,height:j.height}};W.push(Z)}for(const $ of U){const Z={...$,type:"position"};W.push(Z)}b(W)},onEnd:({width:j,height:U})=>{const b={id:_,type:"dimensions",resizing:!1,dimensions:{width:j,height:U}};C.getState().triggerNodeChanges([b])}})),Y.current.update({controlPosition:Q,boundaries:{minWidth:h,minHeight:p,maxWidth:m,maxHeight:v},keepAspectRatio:g,resizeDirection:y,onResizeStart:k,onResize:N,onResizeEnd:E,shouldResize:S}),()=>{var j;(j=Y.current)==null||j.destroy()}},[Q,h,p,m,v,g,k,N,E,S]);const ne=Q.split("-");return K.jsx("div",{className:We(["react-flow__resize-control","nodrag",...ne,i,s]),ref:F,style:{...u,scale:O,...f&&{[D?"backgroundColor":"borderColor"]:f}},children:c})}const Hh=q.memo(m_);function C_({nodeId:n,isVisible:o=!0,handleClassName:i,handleStyle:s,lineClassName:u,lineStyle:c,color:f,minWidth:h=10,minHeight:p=10,maxWidth:m=Number.MAX_VALUE,maxHeight:v=Number.MAX_VALUE,keepAspectRatio:g=!1,autoScale:y=!0,shouldResize:x,onResizeStart:S,onResize:k,onResizeEnd:N}){return o?K.jsxs(K.Fragment,{children:[V1.map(E=>K.jsx(Hh,{className:u,style:c,nodeId:n,position:E,variant:hr.Line,color:f,minWidth:h,minHeight:p,maxWidth:m,maxHeight:v,onResizeStart:S,keepAspectRatio:g,autoScale:y,shouldResize:x,onResize:k,onResizeEnd:N},E)),H1.map(E=>K.jsx(Hh,{className:i,style:s,nodeId:n,position:E,color:f,minWidth:h,minHeight:p,maxWidth:m,maxHeight:v,onResizeStart:S,keepAspectRatio:g,autoScale:y,shouldResize:x,onResize:k,onResizeEnd:N},E))]}):null}export{ms as B,qr as C,w_ as E,ns as H,N_ as M,C_ as N,ye as P,jS as R,dm as a,
|
|
54
|
+
M${Y.x},${Y.y}h${Y.width}v${Y.height}h${-Y.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Ng.displayName="MiniMap";const N_=q.memo(Ng),p_=n=>o=>n?`${Math.max(1/o.transform[2],1)}`:void 0,g_={[hr.Line]:"right",[hr.Handle]:"bottom-right"};function m_({nodeId:n,position:o,variant:i=hr.Handle,className:s,style:u=void 0,children:c,color:f,minWidth:h=10,minHeight:p=10,maxWidth:m=Number.MAX_VALUE,maxHeight:v=Number.MAX_VALUE,keepAspectRatio:g=!1,resizeDirection:y,autoScale:x=!0,shouldResize:S,onResizeStart:k,onResize:N,onResizeEnd:E}){const L=rg(),_=typeof n=="string"?n:L,C=De(),F=q.useRef(null),D=i===hr.Handle,O=Ce(q.useCallback(p_(D&&x),[D,x]),$e),Y=q.useRef(null),Q=o??g_[i];q.useEffect(()=>{if(!(!F.current||!_))return Y.current||(Y.current=Y1({domNode:F.current,nodeId:_,getStoreItems:()=>{const{nodeLookup:j,transform:U,snapGrid:b,snapToGrid:z,nodeOrigin:B,domNode:R}=C.getState();return{nodeLookup:j,transform:U,snapGrid:b,snapToGrid:z,nodeOrigin:B,paneDomNode:R}},onChange:(j,U)=>{const{triggerNodeChanges:b,nodeLookup:z,parentLookup:B,nodeOrigin:R}=C.getState(),W=[],P={x:j.x,y:j.y},I=z.get(_);if(I&&I.expandParent&&I.parentId){const $=I.origin??R,Z=j.width??I.measured.width??0,G=j.height??I.measured.height??0,le={id:I.id,parentId:I.parentId,rect:{width:Z,height:G,...Cp({x:j.x??I.position.x,y:j.y??I.position.y},{width:Z,height:G},I.parentId,z,$)}},ie=tc([le],z,B,R);W.push(...ie),P.x=j.x?Math.max($[0]*Z,j.x):void 0,P.y=j.y?Math.max($[1]*G,j.y):void 0}if(P.x!==void 0&&P.y!==void 0){const $={id:_,type:"position",position:{...P}};W.push($)}if(j.width!==void 0&&j.height!==void 0){const Z={id:_,type:"dimensions",resizing:!0,setAttributes:y?y==="horizontal"?"width":"height":!0,dimensions:{width:j.width,height:j.height}};W.push(Z)}for(const $ of U){const Z={...$,type:"position"};W.push(Z)}b(W)},onEnd:({width:j,height:U})=>{const b={id:_,type:"dimensions",resizing:!1,dimensions:{width:j,height:U}};C.getState().triggerNodeChanges([b])}})),Y.current.update({controlPosition:Q,boundaries:{minWidth:h,minHeight:p,maxWidth:m,maxHeight:v},keepAspectRatio:g,resizeDirection:y,onResizeStart:k,onResize:N,onResizeEnd:E,shouldResize:S}),()=>{var j;(j=Y.current)==null||j.destroy()}},[Q,h,p,m,v,g,k,N,E,S]);const ne=Q.split("-");return K.jsx("div",{className:We(["react-flow__resize-control","nodrag",...ne,i,s]),ref:F,style:{...u,scale:O,...f&&{[D?"backgroundColor":"borderColor"]:f}},children:c})}const Hh=q.memo(m_);function C_({nodeId:n,isVisible:o=!0,handleClassName:i,handleStyle:s,lineClassName:u,lineStyle:c,color:f,minWidth:h=10,minHeight:p=10,maxWidth:m=Number.MAX_VALUE,maxHeight:v=Number.MAX_VALUE,keepAspectRatio:g=!1,autoScale:y=!0,shouldResize:x,onResizeStart:S,onResize:k,onResizeEnd:N}){return o?K.jsxs(K.Fragment,{children:[V1.map(E=>K.jsx(Hh,{className:u,style:c,nodeId:n,position:E,variant:hr.Line,color:f,minWidth:h,minHeight:p,maxWidth:m,maxHeight:v,onResizeStart:S,keepAspectRatio:g,autoScale:y,shouldResize:x,onResize:k,onResizeEnd:N},E)),H1.map(E=>K.jsx(Hh,{className:i,style:s,nodeId:n,position:E,color:f,minWidth:h,minHeight:p,maxWidth:m,maxHeight:v,onResizeStart:S,keepAspectRatio:g,autoScale:y,shouldResize:x,onResize:k,onResizeEnd:N},E))]}):null}export{ms as B,qr as C,w_ as E,ns as H,N_ as M,C_ as N,ye as P,jS as R,dm as a,De as b,nc as c,x_ as d,S_ as e,__ as f,Qw as g,u1 as h,qp as i,K as j,v_ as k,E_ as l,k_ as m,Vl as n,fm as r,Ce as u};
|