@memoarchitect/architect 0.6.6 → 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.
Files changed (93) hide show
  1. package/README.md +26 -4
  2. package/dist/assets/AiWorkspace-Z3BbnmaP.js +7 -0
  3. package/dist/assets/AnalysisWorkspace-DjaUOo7U.js +39 -0
  4. package/dist/assets/{ComplianceWizard-k98NZ2ec.js → ComplianceWizard-DKxZ1z25.js} +1 -1
  5. package/dist/assets/DSMView-DJhmrXYm.js +5 -0
  6. package/dist/assets/Dashboard-CYT7KjqU.js +1 -0
  7. package/dist/assets/DhfDashboard-DacdOtkU.js +1 -0
  8. package/dist/assets/DhfWorkbench-CIhopT8J.js +69 -0
  9. package/dist/assets/DiagramCanvas-CLE_nv7Y.js +4 -0
  10. package/dist/assets/DiagramEditor-puQuE8gB.js +4 -0
  11. package/dist/assets/DiagramToolbarControls-XMGLx08e.js +1 -0
  12. package/dist/assets/ElementDetailView-D5XvAL_i.js +2 -0
  13. package/dist/assets/ExplorerTreeRow-DUmcEsqf.js +3 -0
  14. package/dist/assets/{ImportView-CyMm-tSP.js → ImportView-9y1nhQS4.js} +1 -1
  15. package/dist/assets/{LayerGrid-DNPZYTsD.js → LayerGrid-bhFpOIbe.js} +1 -1
  16. package/dist/assets/{LayerTable-DhOq1DHo.js → LayerTable-RuswZVUI.js} +2 -2
  17. package/dist/assets/{MaxGraphCanvas-DqKU1PTY.js → MaxGraphCanvas-D3BXQK2y.js} +6 -6
  18. package/dist/assets/{ModelDiff-BbqIoesG.js → ModelDiff-Cl2dhlk3.js} +1 -1
  19. package/dist/assets/OntologyDecompositionDiagram-aONGngg4.js +1 -0
  20. package/dist/assets/{OntologyViewer-BIpJC66j.js → OntologyViewer-VOrKTRuQ.js} +2 -2
  21. package/dist/assets/{RelationshipOverlay-B9bqt4zl.js → RelationshipOverlay-B3AN-bM-.js} +1 -1
  22. package/dist/assets/{RelationshipsSection-DttMvF2i.js → RelationshipsSection-DggeGBKP.js} +1 -1
  23. package/dist/assets/{ReviewDashboard-DKoExM8K.js → ReviewDashboard--LMXZ3F4.js} +1 -1
  24. package/dist/assets/ScenarioEditor-bB4iBbgO.js +3 -0
  25. package/dist/assets/{StatisticsDashboard-B8BduIDz.js → StatisticsDashboard-iXimfU20.js} +1 -1
  26. package/dist/assets/{SysmlCodeEditor-Die2RUsz.js → SysmlCodeEditor-i0BHj3of.js} +117 -117
  27. package/dist/assets/TabularView-DnIfq-TB.js +1 -0
  28. package/dist/assets/TraceabilityMatrix-eilGn6Sr.js +3 -0
  29. package/dist/assets/UiScreensWorkspace-Cs1ivqzc.js +1 -0
  30. package/dist/assets/{WorkflowWizard-7--f9OH2.js → WorkflowWizard-C7jI6C59.js} +1 -1
  31. package/dist/assets/html2canvas.esm-QH1iLAAe.js +22 -0
  32. package/dist/assets/index-CG-gfw-s.js +4067 -0
  33. package/dist/assets/index-DXB4CKwW.css +1 -0
  34. package/dist/assets/index.es-DABt8CUc.js +18 -0
  35. package/dist/assets/jspdf.es.min-G-Vwo9yG.js +170 -0
  36. package/dist/assets/{layout-providers-Dr743WlP.js → layout-providers-BSDYNZu0.js} +1 -1
  37. package/dist/assets/notation-scene-DLZms6VR.js +1 -0
  38. package/dist/assets/purify.es-DP5U8-sc.js +3 -0
  39. package/dist/assets/{reactflow-CsCqNKB-.js → reactflow-C9OlmOYw.js} +5 -5
  40. package/dist/assets/xlsx-CkFp8p6R.js +105 -0
  41. package/dist/index.html +3 -3
  42. package/dist-standalone/index.html +5504 -0
  43. package/lib/__tests__/compiler-bundling.test.d.ts +2 -0
  44. package/lib/__tests__/compiler-bundling.test.d.ts.map +1 -0
  45. package/lib/__tests__/compiler-bundling.test.js +32 -0
  46. package/lib/__tests__/compiler-bundling.test.js.map +1 -0
  47. package/lib/__tests__/standalone-distribution.test.d.ts +2 -0
  48. package/lib/__tests__/standalone-distribution.test.d.ts.map +1 -0
  49. package/lib/__tests__/standalone-distribution.test.js +51 -0
  50. package/lib/__tests__/standalone-distribution.test.js.map +1 -0
  51. package/lib/__tests__/standard-sysml-diagrams-smoke.test.d.ts +2 -0
  52. package/lib/__tests__/standard-sysml-diagrams-smoke.test.d.ts.map +1 -0
  53. package/lib/__tests__/standard-sysml-diagrams-smoke.test.js +22 -0
  54. package/lib/__tests__/standard-sysml-diagrams-smoke.test.js.map +1 -0
  55. package/lib/__tests__/supervised-child-args.test.d.ts +2 -0
  56. package/lib/__tests__/supervised-child-args.test.d.ts.map +1 -0
  57. package/lib/__tests__/supervised-child-args.test.js +55 -0
  58. package/lib/__tests__/supervised-child-args.test.js.map +1 -0
  59. package/lib/bin/memo-architect.js +30 -4
  60. package/lib/bin/memo-architect.js.map +1 -1
  61. package/lib/commands/build.d.ts.map +1 -1
  62. package/lib/commands/build.js +15 -18
  63. package/lib/commands/build.js.map +1 -1
  64. package/lib/commands/dev.d.ts +32 -2
  65. package/lib/commands/dev.d.ts.map +1 -1
  66. package/lib/commands/dev.js +95 -8
  67. package/lib/commands/dev.js.map +1 -1
  68. package/lib/commands/example.d.ts +1 -0
  69. package/lib/commands/example.d.ts.map +1 -1
  70. package/lib/commands/example.js +2 -0
  71. package/lib/commands/example.js.map +1 -1
  72. package/lib/feature-grants.d.ts.map +1 -1
  73. package/lib/feature-grants.js +3 -1
  74. package/lib/feature-grants.js.map +1 -1
  75. package/package.json +16 -6
  76. package/dist/assets/AiWorkspace-DS79vBOT.js +0 -3
  77. package/dist/assets/AnalysisWorkspace-D_u4shRY.js +0 -39
  78. package/dist/assets/DSMView-DGheBwZ0.js +0 -1
  79. package/dist/assets/Dashboard-BRUQvUFK.js +0 -1
  80. package/dist/assets/DhfDashboard-B9V_n7kg.js +0 -1
  81. package/dist/assets/DhfSettingsPanel-B8aLsWn6.js +0 -1
  82. package/dist/assets/DhfWorkbench-TOnZkdUU.js +0 -69
  83. package/dist/assets/DiagramCanvas-B9d4aLKt.js +0 -1
  84. package/dist/assets/DiagramEditor-CJ7OG2IC.js +0 -4
  85. package/dist/assets/ElementDetailView-CDcm1rvf.js +0 -2
  86. package/dist/assets/OntologyDecompositionDiagram-DkxTe2C_.js +0 -1
  87. package/dist/assets/ScenarioEditor-JQ3huCnz.js +0 -3
  88. package/dist/assets/TabularView-BXfFSluC.js +0 -1
  89. package/dist/assets/TraceabilityMatrix-CHZHFucA.js +0 -1
  90. package/dist/assets/editor.worker-DyuDvpVp.js +0 -26
  91. package/dist/assets/index-CVW92JY7.js +0 -3280
  92. package/dist/assets/index-Y1UZTZg-.css +0 -1
  93. package/dist/assets/layout-selection-ClQ295Xc.js +0 -1
@@ -1 +0,0 @@
1
- var qs=Object.defineProperty;var Zs=(t,i,n)=>i in t?qs(t,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[i]=n;var no=(t,i,n)=>Zs(t,typeof i!="symbol"?i+"":i,n);import{j as e,u as Hn,H as N,P as k,N as tt,a as xo,B as _n,E as po,R as Qs,b as Js,c as ei,d as ti,e as oi,i as ni,C as si,f as ii,g as ri,M as ai}from"./reactflow-CsCqNKB-.js";import{b as li,a as d,W as Sn}from"./zustand-CrhqMOHB.js";/* empty css */import{F as D,S as ce,z as ci,u as O,A as Kn,f as uo,g as di,D as vn,B as je,r as pi,i as kn,G as ui,R as Cn,V as En,C as In}from"./index-CVW92JY7.js";import{c as hi,a as xi,b as gi,d as fi,e as mi,f as yi,g as bi,h as Fi,i as wi,j as ji,k as Si,I as go,l as vi,P as At,s as ki,u as Ci,m as Ei,G as so,n as Ii,o as Di,C as Mt,p as Ni,r as Ai,q as io,t as Mi,v as Bi,w as zi,x as Dn,y as Ti,z as Ri,A as Li,B as $i,D as Wi,E as Oi,R as Pi,F as Hi}from"./layout-selection-ClQ295Xc.js";import"./layout-providers-Dr743WlP.js";import"./elk-6l8mIQnQ.js";function _i(t,i,n="both",a=10){const r=t.elements[i];if(!r)return{rootId:i,rootName:"(unknown)",rootKind:"",nodes:[],edges:[]};const l=new Map,p=new Map;for(const h of t.relationships)l.has(h.sourceId)||l.set(h.sourceId,[]),l.get(h.sourceId).push(h),p.has(h.targetId)||p.set(h.targetId,[]),p.get(h.targetId).push(h);const f=new Set;f.add(i);const w=[],F=[],I=[[i,0]];for(;I.length>0;){const[h,C]=I.shift();if(C>=a)continue;const j=C+1;if(n==="downstream"||n==="both")for(const m of l.get(h)||[]){const A=m.targetId;if(F.push({fromId:h,toId:A,relType:m.type,relId:m.id}),!f.has(A)){f.add(A);const b=t.elements[A];b&&(w.push({elementId:A,name:b.name,kind:b.kind,layer:b.layer,depth:j,viaRelType:m.type,direction:"downstream"}),I.push([A,j]))}}if(n==="upstream"||n==="both")for(const m of p.get(h)||[]){const A=m.sourceId;if(F.push({fromId:A,toId:h,relType:m.type,relId:m.id}),!f.has(A)){f.add(A);const b=t.elements[A];b&&(w.push({elementId:A,name:b.name,kind:b.kind,layer:b.layer,depth:j,viaRelType:m.type,direction:"upstream"}),I.push([A,j]))}}}return w.sort((h,C)=>h.depth-C.depth||h.name.localeCompare(C.name)),{rootId:i,rootName:r.name,rootKind:r.kind,nodes:w,edges:F}}function Ki(t,i=[]){let a=t.replace(/[^A-Za-z0-9]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().split(/\s+/).filter(Boolean).map((p,f)=>f===0?p.charAt(0).toLowerCase()+p.slice(1):p.charAt(0).toUpperCase()+p.slice(1)).join("");a||(a="element"),/^[0-9]/.test(a)&&(a=`n${a}`);const r=new Set(i);if(!r.has(a))return a;let l=2;for(;r.has(`${a}${l}`);)l++;return`${a}${l}`}function Vi(t){return t&&t.replace(/\s+(def|usage)$/,"").trim()||"part"}const Yi=[{value:"",label:"Default"},{value:"#FEF3C7",label:"Amber"},{value:"#DCFCE7",label:"Green"},{value:"#DBEAFE",label:"Blue"},{value:"#FCE7F3",label:"Pink"},{value:"#E5E7EB",label:"Grey"}],Ze={display:"flex",alignItems:"center",gap:2},Qe={width:1,height:18,background:"#E2E8F0",margin:"0 4px",flexShrink:0};function le({title:t,label:i,onClick:n}){return e.jsx("button",{title:t,"aria-label":t,onClick:n,style:{minWidth:26,height:26,padding:"0 5px",borderRadius:5,border:"1px solid #E2E8F0",background:"#FFFFFF",color:"#374151",fontSize:13,lineHeight:1,cursor:"pointer",fontWeight:600},children:i})}function Xi({count:t,onAlign:i,onMatchSize:n,onDistribute:a,onFill:r,onOpacity:l,opacity:p}){return e.jsxs("div",{className:"nodrag nopan",style:{position:"absolute",top:10,left:"50%",transform:"translateX(-50%)",zIndex:25,display:"flex",alignItems:"center",gap:4,padding:"6px 8px",borderRadius:9,background:"#FFFFFF",border:"1px solid #E2E8F0",boxShadow:"0 6px 20px rgba(15,23,42,0.14)",flexWrap:"wrap",maxWidth:"calc(100% - 24px)"},children:[e.jsxs("span",{style:{fontSize:D.xs,color:"#6B7280",fontWeight:700,paddingRight:2},children:[t," selected"]}),e.jsx("span",{style:Qe}),e.jsxs("div",{style:Ze,children:[e.jsx(le,{title:"Align left edges",label:"⇤",onClick:()=>i("left")}),e.jsx(le,{title:"Align horizontal centres",label:"⇹",onClick:()=>i("centerX")}),e.jsx(le,{title:"Align right edges",label:"⇥",onClick:()=>i("right")}),e.jsx(le,{title:"Align top edges",label:"⤒",onClick:()=>i("top")}),e.jsx(le,{title:"Align vertical centres",label:"⇳",onClick:()=>i("centerY")}),e.jsx(le,{title:"Align bottom edges",label:"⤓",onClick:()=>i("bottom")})]}),e.jsx("span",{style:Qe}),e.jsxs("div",{style:Ze,children:[e.jsx(le,{title:"Match width to the widest",label:"↔",onClick:()=>n("width")}),e.jsx(le,{title:"Match height to the tallest",label:"↕",onClick:()=>n("height")}),e.jsx(le,{title:"Match width and height",label:"⤢",onClick:()=>n("both")})]}),e.jsx("span",{style:Qe}),e.jsxs("div",{style:Ze,children:[e.jsx(le,{title:t>=3?"Even horizontal gaps":"Even horizontal gaps (needs 3 blocks)",label:"⇿",onClick:()=>a("horizontal")}),e.jsx(le,{title:t>=3?"Even vertical gaps":"Even vertical gaps (needs 3 blocks)",label:"⇕",onClick:()=>a("vertical")})]}),e.jsx("span",{style:Qe}),e.jsx("div",{style:Ze,children:Yi.map(f=>e.jsx("button",{title:`Fill: ${f.label}`,"aria-label":`Fill ${f.label}`,onClick:()=>r(f.value),style:{width:20,height:20,padding:0,borderRadius:4,cursor:"pointer",border:"1px solid #CBD5E1",background:f.value||"#FFFFFF",color:"#94A3B8",fontSize:11,lineHeight:1,fontWeight:700},children:f.value?"":"⌫"},f.label))}),e.jsx("span",{style:Qe}),e.jsxs("label",{title:"Fill opacity",style:{display:"flex",alignItems:"center",gap:5,fontSize:D.xs,color:"#6B7280"},children:[e.jsx("span",{style:{fontWeight:700},children:"Opacity"}),e.jsx("input",{type:"range",min:20,max:100,step:5,value:Math.round(p*100),onChange:f=>l(Number(f.target.value)/100),style:{width:72,accentColor:"#2DD4A8"}}),e.jsxs("span",{style:{width:30,textAlign:"right",fontVariantNumeric:"tabular-nums"},children:[Math.round(p*100),"%"]})]}),e.jsx("div",{style:Ze,"aria-label":"Opacity presets",children:[1,.75,.5].map(f=>e.jsx("button",{"aria-label":`Set opacity to ${Math.round(f*100)}%`,title:`Set opacity to ${Math.round(f*100)}%`,onClick:()=>l(f),style:{height:22,minWidth:30,padding:"0 4px",borderRadius:4,border:"1px solid #CBD5E1",background:"#FFFFFF",color:"#475569",cursor:"pointer",fontSize:10,fontWeight:700},children:Math.round(f*100)},f))})]})}function Gi(t,i){if(t.length===0)return;const n=a=>t.reduce((r,l)=>a(l,r)?l:r);switch(i){case"left":return n((a,r)=>a.x<r.x);case"right":return n((a,r)=>a.x+a.width>r.x+r.width);case"top":return n((a,r)=>a.y<r.y);case"bottom":return n((a,r)=>a.y+a.height>r.y+r.height);case"centerX":return n((a,r)=>a.width>r.width);case"centerY":return n((a,r)=>a.height>r.height)}}function Ui(t,i){const n=new Map,a=Gi(t,i);if(!a||t.length<2)return n;for(const r of t){let l;switch(i){case"left":l=a.x;break;case"right":l=a.x+a.width-r.width;break;case"centerX":l=a.x+a.width/2-r.width/2;break;case"top":l=a.y;break;case"bottom":l=a.y+a.height-r.height;break;case"centerY":l=a.y+a.height/2-r.height/2;break}const p=i==="left"||i==="right"||i==="centerX",f=p?r.x:r.y;Math.abs(f-l)<.5||n.set(r.id,p?{x:l}:{y:l})}return n}function qi(t,i){const n=new Map;if(t.length<2)return n;const a=Math.max(...t.map(l=>l.width)),r=Math.max(...t.map(l=>l.height));for(const l of t){const p={};i!=="height"&&Math.abs(l.width-a)>=.5&&(p.width=a),i!=="width"&&Math.abs(l.height-r)>=.5&&(p.height=r),Object.keys(p).length>0&&n.set(l.id,p)}return n}function Zi(t,i){const n=new Map;if(t.length<3)return n;const a=i==="horizontal",r=j=>a?j.x:j.y,l=j=>a?j.width:j.height,p=[...t].sort((j,m)=>r(j)-r(m)),f=p[0],w=p[p.length-1],F=r(w)+l(w)-r(f),I=p.reduce((j,m)=>j+l(m),0),h=(F-I)/(p.length-1);if(!Number.isFinite(h)||h<0)return n;let C=r(f)+l(f)+h;for(const j of p.slice(1,-1))Math.abs(r(j)-C)>=.5&&n.set(j.id,a?{x:C}:{y:C}),C+=l(j)+h;return n}const ot=li(t=>({subject:null,publish:i=>t({subject:i})})),et=t=>ot.getState().publish(t),Vn=t=>{var i,n;return[t.source,t.target,(i=t.data)==null?void 0:i.sourcePortId,(n=t.data)==null?void 0:n.targetPortId].filter(a=>!!a)},Qi=(t,i)=>t.edgeId===i.id||Vn(i).some(n=>t.endpointIds.includes(n)),fo=()=>ot(t=>t.subject!==null),Ji=t=>ot(i=>{var n;return((n=i.subject)==null?void 0:n.endpointIds.includes(t))??!1}),Yn=(t,i)=>ot(n=>{const a=n.subject;return a?a.edgeId===t||i.some(r=>r!==void 0&&a.endpointIds.includes(r)):!1}),er=t=>`.react-flow__edge[data-id="${CSS.escape(t)}"]`;function tr(){const t=ot(a=>a.subject),i=Hn(a=>t?a.edges.filter(r=>Qi(t,r)).map(r=>r.id).join("\0"):"");if(!t)return null;const n=i?i.split("\0").map(er).join(","):"";return e.jsxs("style",{children:[".react-flow__edge{opacity:0.22;transition:opacity 120ms ease}",n?`${n}{opacity:1}`:""]})}class or{constructor(){no(this,"providers",[]);no(this,"byId",new Map)}register(i,n){const a=this.byId.get(i.descriptor.id);if(a&&a!==i)throw new Error(`Template provider already registered: ${i.descriptor.id}`);if(a)return;this.byId.set(i.descriptor.id,i);const r=n?this.providers.findIndex(l=>l.descriptor.id===n):-1;r>=0?this.providers.splice(r,0,i):this.providers.push(i)}unregister(i){const n=this.byId.get(i);return n?(this.byId.delete(i),this.providers.splice(this.providers.indexOf(n),1),!0):!1}get(i){return this.byId.get(i)}has(i){return this.byId.has(i)}list(){return this.providers.map(i=>i.descriptor)}select(i){const n=this.providers.find(a=>a.matches(i));if(!n)throw new Error("No diagram template matches this view — register a catch-all provider");return n}}const Xn=new or,nr=[{descriptor:{id:"memo.template.fbs",name:"Functional Breakdown",label:"FBS",contractVersion:"1",interactive:!0,description:"Functional breakdown structure — functions per realising component."},matches:t=>t.isFBSDiagram,compute:(t,i)=>hi(t,i.fbs)},{descriptor:{id:"memo.template.decomposition",name:"Decomposition Tree",label:"Decomposition",contractVersion:"1",interactive:!0,description:"Expandable decomposition tree over composition relationships."},matches:t=>t.isDecompDiagram&&t.layoutStyle==="decomposition",compute:(t,i)=>xi(t,i.decomposition)},{descriptor:{id:"memo.template.containment",name:"Containment Blocks",label:"Containment",contractVersion:"1",interactive:!0,description:"Nested containment blocks over composition relationships."},matches:t=>t.isDecompDiagram,compute:(t,i)=>gi(t,i.containment)},{descriptor:{id:"memo.template.usecase",name:"Use Case",label:"Use case",contractVersion:"1",interactive:!1,description:"Actors outside a system boundary, use cases inside (KK-7)."},matches:t=>t.diagramType==="ucd",compute:(t,i)=>fi(t,i.useCase)},{descriptor:{id:"memo.template.context",name:"System Context",label:"Context",contractVersion:"1",interactive:!1,description:"Black-box system of interest with external actors and peer systems."},matches:t=>t.diagramType==="context",compute:(t,i)=>mi(t,i.context.systemName,i.context)},{descriptor:{id:"memo.template.interconnection",name:"Interconnection",label:"Interconnection",contractVersion:"1",interactive:!1,description:"IBD — parts with boundary ports, typed connectors, nested containment (KK-3)."},matches:t=>t.viewKind==="interconnection",compute:(t,i)=>yi(t,i.interconnection)},{descriptor:{id:"memo.template.actionflow",name:"Action Flow",label:"Action flow",contractVersion:"1",interactive:!1,description:"Actions with parameter ports, item flows, successions, optional swimlanes (KK-4)."},matches:t=>t.viewKind==="actionflow",compute:(t,i)=>bi(t,i.actionflow)},{descriptor:{id:"memo.template.statetransition",name:"State Transition",label:"State transition",contractVersion:"1",interactive:!1,description:"Nested states with routed transition edges and trigger [guard] labels (KK-5)."},matches:t=>t.viewKind==="statetransition",compute:(t,i)=>Fi(t,i.statetransition)},{descriptor:{id:"memo.template.sequence",name:"Sequence",label:"Sequence",contractVersion:"1",interactive:!1,description:"Lifelines with chronological messages (KK-6)."},matches:t=>t.viewKind==="sequence",compute:(t,i)=>wi(t,i.sequence)},{descriptor:{id:"memo.template.general",name:"General (structured)",label:"General",contractVersion:"1",interactive:!0,description:"General template tree/containment modes (KK-2)."},matches:t=>t.isGeneralTemplate&&t.generalMode!=="graph",compute:(t,i)=>ji(t,i.general)},{descriptor:{id:"memo.template.standard",name:"Standard Graph",label:"Standard",contractVersion:"1",interactive:!0,description:"Relationship graph with optional compartments — the catch-all."},matches:()=>!0,compute:(t,i)=>Si(t,i.standard)}];for(const t of nr)Xn.register(t);function nt({color:t="#334155",size:i=38}){const n=Math.round(i*1.42);return e.jsxs("svg",{width:i,height:n,viewBox:"0 0 38 54","aria-hidden":"true",fill:"none",stroke:t,strokeWidth:"2",children:[e.jsx("circle",{cx:"19",cy:"8",r:"6",fill:"#FFFFFF"}),e.jsx("path",{d:"M19 14v18M6 23h26M19 32L8 49M19 32l11 17",strokeLinecap:"round"})]})}const mo=t=>t==="Actor"||t==="User";function sr({data:t}){const i=t,{element:n,layerColor:a,isExpanded:r,hasChildren:l,childCount:p,direction:f,onToggleExpand:w,onToggleDirection:F,showDirectionButton:I,depthBgColor:h,isContainer:C}=i,j=f==="vertical"?"V":"H",m=C&&r;return e.jsxs("div",{style:{background:m?h||"#FAFAF9":"#FFFFFF",borderLeft:m?`2px solid ${a}40`:`3px solid ${a}`,borderTop:`1px solid ${m?a+"30":"#E5E5E0"}`,borderRight:`1px solid ${m?a+"30":"#E5E5E0"}`,borderBottom:`1px solid ${m?a+"30":"#E5E5E0"}`,borderRadius:3,padding:m?"0":"8px 12px",minWidth:m?void 0:"200px",boxShadow:"none",width:"100%",height:"100%",boxSizing:"border-box"},children:[e.jsx(N,{type:"target",position:k.Top,id:"top",style:vt}),e.jsx(N,{type:"source",position:k.Bottom,id:"bottom",style:vt}),e.jsx(N,{type:"target",position:k.Left,id:"left",style:vt}),e.jsx(N,{type:"source",position:k.Right,id:"right",style:vt}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:m?"8px 12px":"0"},children:[mo(n.kind)&&e.jsx(nt,{size:24,color:a}),l&&e.jsx("button",{onClick:A=>{A.stopPropagation(),w()},style:{width:"20px",height:"20px",borderRadius:2,border:`1px solid ${a}`,background:r?a+"12":"#FFFFFF",color:a,fontSize:D.md,fontWeight:700,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0,flexShrink:0,transition:"background 200ms ease, color 200ms ease"},title:r?"Collapse":"Expand",children:r?"−":"+"}),l&&I&&e.jsx("button",{onClick:A=>{A.stopPropagation(),F()},style:{width:"20px",height:"20px",borderRadius:"4px",border:"1.5px solid #10b981",background:"transparent",color:"#10b981",fontSize:"9px",fontWeight:700,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0,flexShrink:0,transition:"background 200ms ease"},title:`Direction: ${f}. Click to toggle`,children:j}),e.jsx("span",{style:{fontSize:D.md,fontWeight:600,color:m?a:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n.name})]}),!m&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"3px",paddingLeft:l?"26px":"14px"},children:[e.jsx("span",{style:{fontSize:D.badge,color:"#9CA3AF"},children:n.kind}),l&&e.jsxs("span",{style:{fontSize:"9px",color:"#6B7280",background:"#F0F0ED",padding:"1px 5px",borderRadius:2,fontWeight:600},children:[p," parts",r?"":" (collapsed)"]})]})]})}const vt={width:"8px",height:"8px",background:"#2DD4A8",border:"1.5px solid #FFFFFF",opacity:0},ir=d.memo(sr),Nn={top:k.Top,bottom:k.Bottom,left:k.Left,right:k.Right},rr={top:"bottom",bottom:"top",left:"right",right:"left"},ar="#6B7280",Gn=t=>t?At[t]:ar;function Un(t,i){if(t==="inout")return"⇄";if(!t)return"";const n=t==="in";switch(i){case"left":return n?"→":"←";case"right":return n?"←":"→";case"top":return n?"↓":"↑";default:return n?"↑":"↓"}}const lr=104,An=40,qn=t=>({opacity:0,width:t,height:t,top:"50%",left:"50%",transform:"translate(-50%, -50%)",border:"none",background:"transparent",pointerEvents:"none"}),cr=t=>({...qn(t),pointerEvents:"auto",cursor:"crosshair",zIndex:12});function dr({port:t,onMove:i}){const{getZoom:n}=xo(),a=Hn(h=>h.transform[2]),r=Ji(t.id),l=fo()&&!r,p=t.size??go,f=p+5,w=Gn(t.direction),F=t.side==="left"||t.side==="right",I={position:"absolute",fontSize:t.nested?"9.5px":"10.5px",fontWeight:r?750:t.nested?600:650,color:r?"#0F172A":t.nested?"#6B7280":"#374151",opacity:l?.45:1,transition:"color 120ms ease, opacity 120ms ease",whiteSpace:"normal",pointerEvents:"none",overflow:"hidden",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:2,width:F?lr:72,background:"rgba(255,255,255,0.94)",padding:"1px 3px",borderRadius:4,lineHeight:1.12,...t.side==="left"?{left:f,bottom:"50%",marginBottom:2}:t.side==="right"?{right:f,bottom:"50%",marginBottom:2,textAlign:"right"}:t.side==="top"?{top:f,left:"50%",transform:"translateX(-50%)"}:{bottom:f,left:"50%",transform:"translateX(-50%)"}};return e.jsxs("div",{className:"nodrag nopan",style:{position:"absolute",left:t.x,top:t.y,width:p,height:p,zIndex:t.nested?11:10},children:[e.jsx("div",{onPointerEnter:()=>et({endpointIds:[t.id]}),onPointerLeave:()=>et(null),onPointerDown:i?h=>{h.preventDefault(),h.stopPropagation();const C=h.clientY,j=t.y,m=b=>i(j+(b.clientY-C)/n()),A=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",A)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",A,{once:!0})}:void 0,title:`${t.name}${t.direction?` (${t.direction})`:""}`,style:{position:"absolute",left:"50%",top:"50%",width:An,height:An,transform:`translate(-50%, -50%) scale(${1/Math.max(a,.1)})`,cursor:i?"grab":"default",touchAction:"none"}}),e.jsxs("div",{style:{position:"absolute",inset:0,boxSizing:"border-box",background:"#FFFFFF",border:`2px solid ${w}`,borderRadius:5,boxShadow:r?`0 0 0 4px ${w}33, 0 2px 8px rgba(15,23,42,0.24)`:"0 1px 3px rgba(15,23,42,0.18)",opacity:l?.5:1,display:"flex",alignItems:"center",justifyContent:"center",color:w,fontSize:t.nested?"10px":"12px",fontWeight:800,lineHeight:1,pointerEvents:"none",transition:"box-shadow 120ms ease, opacity 120ms ease"},children:[Un(t.direction,t.side),e.jsx("span",{style:I,children:t.name.replace(/([a-z0-9])([A-Z])/g,"$1​$2")}),[{suffix:"",pos:Nn[t.side],connectable:!0},{suffix:vi,pos:Nn[rr[t.side]],connectable:!1}].flatMap(h=>{const C=h.connectable?"ibd-port-connect":"ibd-port-anchor",j=h.connectable?cr(p):qn(p);return[e.jsx(N,{className:C,type:"source",id:`${t.id}${h.suffix}`,position:h.pos,style:j,isConnectable:h.connectable},`s${h.suffix}`),e.jsx(N,{className:C,type:"target",id:`${t.id}${h.suffix}`,position:h.pos,style:j,isConnectable:h.connectable},`t${h.suffix}`)]})]})]})}function Mn({side:t,direction:i}){const n=Gn(i),a=go;return e.jsx("div",{"aria-label":`implicit ${i} port`,title:`Implicit ${i} port — relationship targets the part directly`,style:{position:"absolute",top:"50%",left:t==="left"?-a/2:void 0,right:t==="right"?-a/2:void 0,transform:"translateY(-50%)",width:a,height:a,boxSizing:"border-box",background:"#FFFFFF",border:`2px solid ${n}`,borderRadius:4,boxShadow:"0 1px 3px rgba(15,23,42,0.18)",display:"flex",alignItems:"center",justifyContent:"center",color:n,fontSize:11,fontWeight:800,lineHeight:1,zIndex:4,pointerEvents:"none"},children:Un(i,t)})}const kt={width:8,height:8,background:"#2DD4A8",border:"1.5px solid #FFFFFF",opacity:0};function Bn({name:t,kind:i,nameColor:n,typeColor:a,frame:r=!1}){return e.jsxs("span",{title:`${t} : ${i}`,style:{display:"flex",flexDirection:r?"row":"column",alignItems:r?"baseline":"flex-start",gap:r?6:1,minWidth:0,overflow:"hidden",flex:1},children:[e.jsx("span",{style:{display:r?"block":"-webkit-box",width:"100%",minWidth:0,fontSize:r?D.md:D.sm,lineHeight:1.2,fontWeight:700,color:n,whiteSpace:r?"nowrap":"normal",overflow:"hidden",textOverflow:"ellipsis",WebkitBoxOrient:"vertical",WebkitLineClamp:r?void 0:2,overflowWrap:"anywhere"},children:t}),e.jsx("span",{style:{display:"block",maxWidth:"100%",fontSize:"9px",lineHeight:1.15,fontWeight:650,letterSpacing:"0.055em",textTransform:"uppercase",color:a,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r?`: ${i}`:`«${i}»`})]})}function pr({label:t,onDrillIn:i,color:n,onColor:a}){return e.jsx("button",{"aria-label":`Drill into ${t}`,title:`Open ${t} as its own internal block diagram`,className:"nodrag",onClick:r=>{r.stopPropagation(),i()},onDoubleClick:r=>r.stopPropagation(),style:{width:18,height:18,padding:0,borderRadius:3,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",border:a?"1px solid rgba(255,255,255,0.7)":`1px solid ${n}88`,background:a?"rgba(255,255,255,0.18)":"#FFFFFF",color:a?"#FFFFFF":n,fontSize:11,lineHeight:1,cursor:"pointer",fontWeight:700},children:"↳"})}function zn({label:t,isCollapsed:i,onToggle:n,color:a,onColor:r}){return e.jsx("button",{"aria-label":i?`Expand ${t}`:`Collapse ${t}`,onClick:l=>{l.stopPropagation(),n()},style:{marginLeft:"auto",width:18,height:18,padding:0,borderRadius:3,border:r?"1px solid rgba(255,255,255,0.7)":`1px solid ${a}88`,background:r?"rgba(255,255,255,0.18)":"#FFFFFF",color:r?"#FFFFFF":a,fontSize:13,lineHeight:"15px",cursor:"pointer",fontWeight:700,flexShrink:0},children:i?"+":"−"})}function ur({id:t,data:i,selected:n,height:a}){const r=i,{label:l,kind:p,color:f,isContainer:w,isFrame:F,ports:I,implicitIn:h,implicitOut:C,onPortMove:j,hasChildren:m,isCollapsed:A,onToggleCollapse:b,onDrillIn:v,minWidth:T,minHeight:W,bgColor:E,fillOpacity:R}=r,[Q,H]=d.useState(!1),z=n?ce.selected:F?"none":Q?"0 8px 20px rgba(15,23,42,0.12)":w?"0 1px 2px rgba(15,23,42,0.05)":"0 2px 8px rgba(15,23,42,0.08)";return e.jsxs("div",{onMouseEnter:()=>H(!0),onMouseLeave:()=>H(!1),style:{width:"100%",height:"100%",boxSizing:"border-box",background:E||"#FFFFFF",opacity:R??1,border:F?"1.5px solid #94A3B8":`1px solid ${Q?f+"9A":"#CBD5E1"}`,...F?{}:{borderTop:`3px solid ${f}`},borderRadius:F?10:8,boxShadow:z,transition:"box-shadow 150ms ease, border-color 150ms ease",position:"relative"},children:[!F&&e.jsx(tt,{nodeId:t,isVisible:n,minWidth:T??180,minHeight:W??100,color:"#2563EB",lineStyle:{borderWidth:1},handleStyle:{width:10,height:10,borderRadius:2}}),e.jsx(N,{type:"target",position:k.Top,id:"top",style:kt}),e.jsx(N,{type:"source",position:k.Bottom,id:"bottom",style:kt}),e.jsx(N,{type:"target",position:k.Left,id:"left",style:kt}),e.jsx(N,{type:"source",position:k.Right,id:"right",style:kt}),F?e.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,height:38,display:"flex",alignItems:"center",gap:8,padding:"0 10px",background:"#F8FAFC",borderBottom:"1px solid #E2E8F0",borderRadius:"9px 9px 0 0"},children:[e.jsx("span",{style:{padding:"2px 6px",borderRadius:4,background:f,color:"#FFFFFF",fontSize:9,fontWeight:800,letterSpacing:"0.08em"},children:"IBD"}),e.jsx(Bn,{name:l,kind:p,nameColor:"#0F172A",typeColor:"#64748B",frame:!0}),m&&b&&e.jsx(zn,{label:l,isCollapsed:A,onToggle:b,color:f})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minHeight:58,padding:"7px 10px 6px",background:"#FFFFFF",borderBottom:m?"1px solid #E2E8F0":"none",borderRadius:"7px 7px 0 0",overflow:"hidden"},children:[mo(p)&&e.jsx(nt,{size:24,color:f}),e.jsx(Bn,{name:l,kind:p,nameColor:"#0F172A",typeColor:w?f:"#64748B"}),m&&v&&e.jsx(pr,{label:l,onDrillIn:v,color:f}),m&&b&&e.jsx(zn,{label:l,isCollapsed:A,onToggle:b,color:f})]}),I.map(q=>e.jsx(dr,{port:q,onMove:j?S=>{const te=q.size??go,K=(F||w?70:62)-te/2,X=Math.max(K,(a??K+te+18)-te-18);j(q.id,Math.min(Math.max(S,K),X))}:void 0},q.id)),h&&e.jsx(Mn,{side:"left",direction:"in"}),C&&e.jsx(Mn,{side:"right",direction:"out"})]})}const hr=d.memo(ur);function Tn(t,i){const n=t.map(r=>({...r}));let a=i;for(;n.length>=2&&a>0;){const r=n[0],l=n[1],p=Math.hypot(l.x-r.x,l.y-r.y);if(p<=a)a-=p,n.shift();else{const f=a/p;n[0]={x:r.x+(l.x-r.x)*f,y:r.y+(l.y-r.y)*f},a=0}}return n}function xr(t,i){const n=Tn(t,i);return Tn([...n].reverse(),i).reverse()}const gr=t=>t.slice(1).reduce((i,n,a)=>i+Math.hypot(n.x-t[a].x,n.y-t[a].y),0);function Ct(t,i=7){if(t.length<2)return"";let n=`M ${t[0].x},${t[0].y}`;for(let r=1;r<t.length-1;r++){const l=t[r-1],p=t[r],f=t[r+1],w=Math.hypot(p.x-l.x,p.y-l.y),F=Math.hypot(f.x-p.x,f.y-p.y),I=Math.min(i,w/2,F/2),h=p.x-Math.sign(p.x-l.x)*I,C=p.y-Math.sign(p.y-l.y)*I,j=p.x+Math.sign(f.x-p.x)*I,m=p.y+Math.sign(f.y-p.y)*I;n+=` L ${h},${C} Q ${p.x},${p.y} ${j},${m}`}const a=t[t.length-1];return`${n} L ${a.x},${a.y}`}function fr(t){let i=0,n=-1;for(let p=1;p<t.length;p++){const f=Math.abs(t[p].x-t[p-1].x)+Math.abs(t[p].y-t[p-1].y);f>n&&(n=f,i=p)}const a=t[i-1],r=t[i],l=Math.abs(r.x-a.x)>=Math.abs(r.y-a.y)?{x:0,y:-14}:{x:14,y:0};return{x:(a.x+r.x)/2+l.x,y:(a.y+r.y)/2+l.y}}function mr(t){var A,b,v,T,W,E,R,Q,H,z,q;const{getZoom:i}=xo(),n=Yn(t.id,[t.source,t.target,(A=t.data)==null?void 0:A.sourcePortId,(b=t.data)==null?void 0:b.targetPortId]),a=fo()&&!n,r=((v=t.data)==null?void 0:v.points)??[];if(r.length<2)return null;const l=String(((T=t.style)==null?void 0:T.stroke)??"#2563EB"),p=Number(((W=t.style)==null?void 0:W.strokeWidth)??2),f=n?{...t.style,strokeWidth:p+1.4}:t.style,w=((E=t.data)==null?void 0:E.labelPoint)??fr(r),F=Math.min(28/Math.max(i(),.1),gr(r)*.3),I=xr(r,F),h=(R=t.data)==null?void 0:R.onRouteChange,C=(Q=t.data)==null?void 0:Q.onSelect,j=!!((H=t.data)!=null&&H.flowAnimation),m=r.length===2?[{index:1,a:r[0],b:r[1],straight:!0}]:r.slice(1).map((S,te)=>({index:te+1,a:r[te],b:S,straight:!1})).filter(S=>S.index>=2&&S.index<=r.length-2);return e.jsxs(e.Fragment,{children:[n&&e.jsx("path",{d:Ct(r),fill:"none",stroke:l,strokeOpacity:.22,strokeWidth:p+9,strokeLinecap:"round",pointerEvents:"none"}),e.jsx(_n,{id:t.id,path:Ct(r),style:f,markerEnd:t.markerEnd}),j&&e.jsx("path",{d:Ct(r),fill:"none",stroke:String(((z=t.style)==null?void 0:z.stroke)??"#2563EB"),strokeWidth:Math.max(2,Number(((q=t.style)==null?void 0:q.strokeWidth)??2)),className:"memo-ibd-flow"}),I.length>=2&&e.jsx("path",{d:Ct(I),fill:"none",stroke:"transparent",strokeWidth:18/Math.max(i(),.1),pointerEvents:"stroke",cursor:"pointer",onClick:S=>C==null?void 0:C(S)}),t.label?e.jsx(po,{children:e.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${w.x}px, ${w.y}px)`,fontSize:D.badge,fontWeight:n?700:600,color:n?"#0F172A":"#475569",background:"rgba(255,255,255,0.96)",border:`1px solid ${n?l:"#E2E8F0"}`,opacity:a?.25:1,padding:"1px 4px",borderRadius:4,pointerEvents:"none"},children:t.label})}):null,t.selected&&h?m.map(S=>{const te=(S.a.x+S.b.x)/2,K=(S.a.y+S.b.y)/2;return e.jsx(po,{children:e.jsx("div",{className:"nodrag nopan",title:"Drag connector segment",onPointerDown:X=>{X.preventDefault(),X.stopPropagation();const st=X.clientX,it=X.clientY,ve=Ae=>{const re=(Ae.clientX-st)/i(),ge=(Ae.clientY-it)/i();if(S.straight){if(Math.abs(ge)>=Math.abs(re)){const ae=S.a.y+ge;h([S.a,{x:S.a.x,y:ae},{x:S.b.x,y:ae},S.b])}else{const ae=(S.a.x+S.b.x)/2+re;h([S.a,{x:ae,y:S.a.y},{x:ae,y:S.b.y},S.b])}return}const Z=r.map(ae=>({...ae}));S.a.y===S.b.y?(Z[S.index-1].y=S.a.y+ge,Z[S.index].y=S.b.y+ge):(Z[S.index-1].x=S.a.x+re,Z[S.index].x=S.b.x+re),h(Z)},Ne=()=>{window.removeEventListener("pointermove",ve),window.removeEventListener("pointerup",Ne)};window.addEventListener("pointermove",ve),window.addEventListener("pointerup",Ne,{once:!0})},style:{position:"absolute",transform:`translate(-50%, -50%) translate(${te}px, ${K}px)`,width:12,height:12,borderRadius:3,background:"#FFFFFF",border:"2px solid #2563EB",boxShadow:"0 1px 4px rgba(15,23,42,0.22)",cursor:S.a.y===S.b.y?"ns-resize":"ew-resize",pointerEvents:"all",touchAction:"none",zIndex:20}})},`route-${S.index}`)}):null]})}const yr=d.memo(mr);function br({onDrillIn:t,color:i,label:n}){return e.jsx("button",{onClick:a=>{a.stopPropagation(),t()},onDoubleClick:a=>a.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 ${i}66`,borderRadius:4,background:"#FFFFFF",color:i,fontSize:10,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"↳"})}function Fr({data:t,selected:i}){const n=t,{nodeType:a,label:r,laneColor:l,layerColor:p,inPorts:f,outPorts:w}=n,[F,I]=d.useState(!1);if(a==="start")return e.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:"#374151",border:"2px solid #374151",boxShadow:ce.sm},children:e.jsx(N,{type:"source",position:n.flowDirection==="vertical"?k.Bottom:k.Right,style:{background:"#374151",width:6,height:6}})});if(a==="done")return e.jsxs("div",{style:{width:28,height:28,borderRadius:"50%",background:"#FFFFFF",border:"3px solid #374151",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:ce.sm},children:[e.jsx("div",{style:{width:14,height:14,borderRadius:"50%",background:"#374151"}}),e.jsx(N,{type:"target",position:n.flowDirection==="vertical"?k.Top:k.Left,style:{background:"#374151",width:6,height:6}})]});if(a==="fork"||a==="join"){const m=n.flowDirection==="vertical";return e.jsxs("div",{title:a==="fork"?"Fork — split into concurrent flows":"Join — synchronize concurrent flows",style:{width:"100%",height:"100%",background:"#374151",borderRadius:3,boxShadow:ce.sm},children:[e.jsx(N,{type:"target",position:m?k.Top:k.Left,style:{background:"#374151",width:6,height:6,border:"none"}}),e.jsx(N,{type:"source",position:m?k.Bottom:k.Right,style:{background:"#374151",width:6,height:6,border:"none"}})]})}const h=l||p||"#9CA3AF";if(n.isFrame)return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:`${h}08`,border:`1.5px solid ${h}66`,borderRadius:10,boxShadow:i?"0 0 0 3px #2DD4A8":"none",position:"relative"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px 0"},children:[n.onToggleExpand&&e.jsx("button",{"aria-label":`Collapse ${r}`,className:"nodrag",onClick:m=>{m.stopPropagation(),n.onToggleExpand()},onDoubleClick:m=>m.stopPropagation(),style:{width:16,height:16,flexShrink:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${h}66`,borderRadius:4,background:"#FFFFFF",color:h,fontSize:11,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"−"}),n.onDrillIn&&e.jsx(br,{onDrillIn:n.onDrillIn,color:h,label:r}),e.jsx("span",{style:{fontSize:D.md,fontWeight:700,color:h,whiteSpace:"nowrap"},children:r}),n.allocatedTo&&e.jsxs("span",{style:{fontSize:"9px",color:"#9CA3AF",whiteSpace:"nowrap"},children:["→"," ",n.allocatedTo]})]}),e.jsx(N,{type:"target",position:n.flowDirection==="vertical"?k.Top:k.Left,style:{background:h,width:8,height:8,border:"2px solid #FFFFFF"}}),e.jsx(N,{type:"source",position:n.flowDirection==="vertical"?k.Bottom:k.Right,style:{background:h,width:8,height:8,border:"2px solid #FFFFFF"}})]});const C=18,j=Math.max(f.length*C,w.length*C,0);return e.jsxs("div",{onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),style:{background:"#FFFFFF",border:`1.5px solid ${h}`,borderRadius:3,minWidth:"140px",boxShadow:i?"0 0 0 3px #2DD4A8, 0 4px 12px rgba(45, 212, 168, 0.35)":F?`0 0 0 2px ${h}22`:"none",transition:"box-shadow 150ms ease",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"8px 14px",fontSize:D.md,fontWeight:600,color:"#1a1a1a",background:`${h}0D`,borderBottom:j>0?"1px solid #E5E5E0":"none",textAlign:"center",whiteSpace:"nowrap"},children:[r,n.hasChildren&&n.onDrillIn&&e.jsx("button",{"aria-label":`Drill into ${r}`,title:`Open ${r} as its own diagram`,className:"nodrag",onClick:m=>{m.stopPropagation(),n.onDrillIn()},onDoubleClick:m=>m.stopPropagation(),style:{float:"right",marginLeft:4,width:18,height:18,padding:0,border:`1px solid ${h}`,borderRadius:2,background:"#FFFFFF",color:h,fontSize:11,fontWeight:700,lineHeight:"16px",cursor:"pointer"},children:"↳"}),n.hasChildren&&n.onToggleExpand&&e.jsx("button",{"aria-label":n.isExpanded?`Collapse ${r}`:`Expand ${r}`,onClick:m=>{m.stopPropagation(),n.onToggleExpand()},style:{float:"right",marginLeft:8,width:18,height:18,padding:0,border:`1px solid ${h}`,borderRadius:2,background:"#FFFFFF",color:h,fontSize:13,fontWeight:700,lineHeight:"16px",cursor:"pointer"},children:n.isExpanded?"−":"+"})]}),j>0&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"4px 0"},children:[e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:f.map(m=>e.jsxs("div",{style:{fontSize:D.badge,color:"#6B7280",paddingLeft:"8px",display:"flex",alignItems:"center",height:`${C}px`,gap:"4px"},children:[e.jsx("span",{style:{width:"6px",height:"6px",borderRadius:"50%",background:"#3498DB",flexShrink:0}}),m]},`in-${m}`))}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px",alignItems:"flex-end"},children:w.map(m=>e.jsxs("div",{style:{fontSize:D.badge,color:"#6B7280",paddingRight:"8px",display:"flex",alignItems:"center",height:`${C}px`,gap:"4px"},children:[m,e.jsx("span",{style:{width:"6px",height:"6px",borderRadius:"50%",background:"#E67E22",flexShrink:0}})]},`out-${m}`))})]}),n.allocatedTo&&e.jsxs("div",{style:{fontSize:"9px",color:"#9CA3AF",textAlign:"center",padding:"2px 6px",borderTop:"1px solid #F3F4F6",background:"#FAFAFA"},children:["→"," ",n.allocatedTo]}),e.jsx(N,{type:"target",position:n.flowDirection==="vertical"?k.Top:k.Left,style:{background:h,width:8,height:8,border:"2px solid #FFFFFF"}}),e.jsx(N,{type:"source",position:n.flowDirection==="vertical"?k.Bottom:k.Right,style:{background:h,width:8,height:8,border:"2px solid #FFFFFF"}})]})}const wr=d.memo(Fr);function jr({data:t,selected:i}){const n=t,a=n.orientation==="column";return e.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:`${n.color}08`,border:i?"3px solid #2DD4A8":`1px solid ${n.color}30`,borderLeft:i?"3px solid #2DD4A8":a?`1px solid ${n.color}30`:`3px solid ${n.color}`,borderTop:i?"3px solid #2DD4A8":a?`3px solid ${n.color}`:`1px solid ${n.color}30`,borderRadius:ci.md,pointerEvents:"auto",cursor:n.inspectElementId?"pointer":"default",display:"flex"},children:e.jsx("div",{style:{writingMode:a?"horizontal-tb":"vertical-rl",transform:a?void 0:"rotate(180deg)",padding:a?"7px 10px":"10px 6px",fontSize:D.xs,fontWeight:700,color:n.color,letterSpacing:"0.04em",textTransform:"uppercase",alignSelf:a?"flex-start":"center",width:a?"100%":void 0,textAlign:a?"center":void 0,whiteSpace:"nowrap"},children:n.label})})}const Sr=d.memo(jr);function Rn({onDrillIn:t,color:i,label:n}){return e.jsx("button",{onClick:a=>{a.stopPropagation(),t()},onDoubleClick:a=>a.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 ${i}66`,borderRadius:4,background:"#FFFFFF",color:i,fontSize:10,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"↳"})}function Ln({collapsed:t,onToggle:i,color:n}){return e.jsx("button",{onClick:a=>{a.stopPropagation(),i()},onDoubleClick:a=>a.stopPropagation(),className:"nodrag",title:t?"Show substates":"Hide substates","aria-label":t?"Show substates":"Hide substates",style:{width:16,height:16,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${n}66`,borderRadius:4,background:"#FFFFFF",color:n,fontSize:11,fontWeight:700,lineHeight:1,cursor:"pointer"},children:t?"+":"−"})}const Et={width:8,height:8,border:"none",background:"transparent",opacity:0};function ro(){return e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"target",position:k.Top,id:"top",style:Et}),e.jsx(N,{type:"source",position:k.Bottom,id:"bottom",style:Et}),e.jsx(N,{type:"target",position:k.Left,id:"left",style:Et}),e.jsx(N,{type:"source",position:k.Right,id:"right",style:Et})]})}function vr({data:t,selected:i}){const n=t,[a,r]=d.useState(!1);if(n.isNote)return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#FFFDF5",border:`1px solid ${n.color}66`,borderRadius:4,padding:"6px 10px",boxShadow:ce.sm,display:"flex",flexDirection:"column",justifyContent:"center"},title:n.kind,children:[e.jsx(ro,{}),e.jsx("span",{style:{fontSize:D.xs,fontWeight:600,color:"#374151",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n.label}),e.jsx("span",{style:{fontSize:"8px",fontWeight:700,color:n.color,textTransform:"uppercase",letterSpacing:"0.05em"},children:n.kind})]});if(n.isContainer)return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:n.isMachine?"transparent":`${n.color}06`,borderTop:n.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${n.color}55`,borderRight:n.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${n.color}55`,borderBottom:n.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${n.color}55`,borderLeft:n.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${n.color}55`,borderRadius:14,boxShadow:i?ce.selected:"none",position:"relative"},children:[e.jsx(ro,{}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px 0"},children:[n.onToggleCollapse&&!n.isMachine&&e.jsx(Ln,{collapsed:!1,onToggle:n.onToggleCollapse,color:n.color}),n.onDrillIn&&!n.isMachine&&e.jsx(Rn,{onDrillIn:n.onDrillIn,color:n.color,label:n.label}),e.jsx("span",{style:{fontSize:D.md,fontWeight:700,color:n.isMachine?"#334155":n.color,whiteSpace:"nowrap"},children:n.label}),e.jsx("span",{style:{fontSize:"8px",fontWeight:700,color:n.isMachine?"#94A3B8":`${n.color}AA`,textTransform:"uppercase",letterSpacing:"0.06em"},children:n.kind})]})]});const l=!!n.hasChildren;return e.jsxs("div",{onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),title:l?`${n.hiddenCount??0} substate${n.hiddenCount===1?"":"s"} hidden — double-click to drill in`:void 0,style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#FFFFFF",borderTop:`3px solid ${n.color}`,borderRight:`1px solid ${a?`${n.color}9A`:"#CBD5E1"}`,borderBottom:`1px solid ${a?`${n.color}9A`:"#CBD5E1"}`,borderLeft:`1px solid ${a?`${n.color}9A`:"#CBD5E1"}`,borderRadius:12,boxShadow:i?ce.selected:a?"0 8px 20px rgba(15,23,42,0.12)":ce.md,transition:"box-shadow 150ms ease, border-color 150ms ease",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,padding:"4px 12px"},children:[e.jsx(ro,{}),e.jsx("span",{style:{fontSize:D.md,fontWeight:600,color:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:n.label}),n.subtitle&&e.jsx("span",{style:{fontSize:"8px",fontWeight:600,color:"#9CA3AF",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:n.subtitle}),l&&e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5},children:[n.onToggleCollapse&&e.jsx(Ln,{collapsed:!0,onToggle:n.onToggleCollapse,color:n.color}),n.onDrillIn&&e.jsx(Rn,{onDrillIn:n.onDrillIn,color:n.color,label:n.label}),e.jsxs("span",{style:{fontSize:"8px",fontWeight:700,color:n.color,letterSpacing:"0.05em"},children:["⊞ ",n.hiddenCount??0]})]})]})}const kr=d.memo(vr),ho="#3498DB";function Cr({data:t}){const i=t;return e.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",pointerEvents:"none"},children:[e.jsx("div",{style:{position:"absolute",top:0,left:"50%",transform:"translateX(-50%)",minWidth:140,maxWidth:"90%",padding:"10px 16px",background:"#FFFFFF",border:`1.5px solid ${ho}`,borderRadius:8,boxShadow:ce.md,textAlign:"center",fontSize:D.md,fontWeight:600,color:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i.label}),e.jsx("div",{style:{position:"absolute",top:44,bottom:0,left:"50%",borderLeft:`1.5px dashed ${ho}66`}})]})}const Er=d.memo(Cr);function Ir({data:t}){const i=t;return e.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#1B3A4B06",border:"1px solid #1B3A4B22",borderRadius:10,pointerEvents:"none"},children:e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,padding:"8px 14px"},children:[e.jsx("span",{style:{fontSize:D.sm,fontWeight:700,color:"#1B3A4B"},children:i.label}),i.scenario&&e.jsxs("span",{style:{fontSize:D.xs,color:"#6B7280"},children:["realizes ",i.scenario]})]})})}const Dr=d.memo(Ir),It={width:6,height:6,border:"none",background:"transparent",opacity:0};function Nr({data:t,selected:i}){const n=t;return e.jsxs("div",{style:{width:14,height:14,borderRadius:"50%",background:"#FFFFFF",border:`3px solid ${ho}`,boxShadow:i?ce.selected:ce.sm,position:"relative"},title:n.kind,children:[e.jsx(N,{type:"source",id:"right",position:k.Right,style:It}),e.jsx(N,{type:"target",id:"right",position:k.Right,style:It}),e.jsx(N,{type:"source",id:"left",position:k.Left,style:It}),e.jsx(N,{type:"target",id:"left",position:k.Left,style:It}),e.jsx("span",{style:{position:"absolute",top:-20,left:"50%",transform:"translateX(-50%)",fontSize:"9px",fontWeight:600,color:"#374151",whiteSpace:"nowrap",background:"#FFFFFFCC",padding:"1px 5px",borderRadius:4},children:n.label})]})}const Ar=d.memo(Nr),zt={opacity:0,width:1,height:1},Mr=d.memo(function({data:i}){const n=i;return e.jsxs("div",{style:{width:"100%",height:"100%",display:"grid",placeItems:"center",textAlign:"center",padding:"12px 22px",border:`2px solid ${n.color??"#E67E22"}`,borderRadius:"50%",background:"#FFF9F2",color:"#2D3748",fontSize:13,fontWeight:600,lineHeight:1.25},children:[n.label,e.jsx(N,{type:"target",position:k.Left,style:zt}),e.jsx(N,{type:"source",position:k.Right,style:zt})]})}),Br=d.memo(function({data:i}){const n=i,a=n.side==="right"?k.Left:k.Right;return e.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#334155",fontSize:12,fontWeight:600,textAlign:"center",gap:3},children:[e.jsx(nt,{color:n.color??"#334155"}),e.jsx("span",{children:n.label}),e.jsx(N,{type:"source",position:a,style:zt}),e.jsx(N,{type:"target",position:a,style:zt})]})}),zr=d.memo(function({data:i}){const n=i;return e.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",border:"1.5px solid #64748B",background:"rgba(255,255,255,0.32)",padding:"10px 14px",color:"#475569",fontSize:12,fontWeight:700},children:n.label})});d.memo(function({data:i}){const n=i;return e.jsx("div",{style:{width:"100%",textAlign:"center",color:"#64748B",fontSize:11,fontWeight:700,letterSpacing:".03em"},children:n.label})});function Tr(t,i=0){if(t.length<2)return"";if(i===0||t.length===2)return`M ${t.map(r=>`${r.x},${r.y}`).join(" L ")}`;let n=`M ${t[0].x},${t[0].y}`;for(let r=1;r<t.length-1;r++){const l=t[r-1],p=t[r],f=t[r+1],w=Math.min(i,Math.abs(p.x-l.x)/2+Math.abs(p.y-l.y)/2),F=Math.min(i,Math.abs(f.x-p.x)/2+Math.abs(f.y-p.y)/2),I={x:p.x+Math.sign(l.x-p.x)*w,y:p.y+Math.sign(l.y-p.y)*w},h={x:p.x+Math.sign(f.x-p.x)*F,y:p.y+Math.sign(f.y-p.y)*F};n+=` L ${I.x},${I.y} Q ${p.x},${p.y} ${h.x},${h.y}`}const a=t[t.length-1];return`${n} L ${a.x},${a.y}`}const Rr=d.memo(function(i){var C,j,m,A,b;const n=Yn(i.id,[i.source,i.target]),a=fo()&&!n,r=((C=i.data)==null?void 0:C.routing)??"rounded",l=Array.isArray((j=i.data)==null?void 0:j.points)?i.data.points:[],p=l.length>=2?l:[{x:i.sourceX,y:i.sourceY},{x:i.targetX,y:i.targetY}],w=r==="straight"?`M ${i.sourceX},${i.sourceY} L ${i.targetX},${i.targetY}`:Tr(p,r==="elbow"?0:r==="rounded"?16:r==="curved"?30:42),F=((m=i.data)==null?void 0:m.labelPoint)??p[Math.floor(p.length/2)]??{x:(i.sourceX+i.targetX)/2,y:(i.sourceY+i.targetY)/2},I=String(((A=i.style)==null?void 0:A.stroke)??"#64748B"),h=Number(((b=i.style)==null?void 0:b.strokeWidth)??1.5);return e.jsxs(e.Fragment,{children:[n&&e.jsx("path",{d:w,fill:"none",stroke:I,strokeOpacity:.22,strokeWidth:h+9,strokeLinecap:"round",pointerEvents:"none"}),e.jsx(_n,{path:w,style:n?{...i.style,strokeWidth:h+1.4}:i.style}),i.label&&e.jsx(po,{children:e.jsx("div",{className:"nodrag nopan",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${F.x}px,${F.y}px)`,background:"#FFFFFF",padding:"2px 5px",borderRadius:3,color:n?"#0F172A":"#334155",fontSize:12,pointerEvents:"all",fontWeight:n?700:void 0,opacity:a?.25:1},children:i.label})})]})}),Dt={opacity:0,width:1,height:1};function Zn(){return e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"target",position:k.Left,style:Dt}),e.jsx(N,{type:"source",position:k.Right,style:Dt}),e.jsx(N,{type:"target",position:k.Top,style:Dt}),e.jsx(N,{type:"source",position:k.Bottom,style:Dt})]})}const Lr=d.memo(function({data:i}){const n=i;return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",display:"grid",placeItems:"center",padding:"14px 18px",textAlign:"center",border:"2px solid #0F766E",borderRadius:8,background:"#F0FDFA",color:"#134E4A",fontSize:15,fontWeight:700,lineHeight:1.25,boxShadow:"0 2px 7px rgba(15, 118, 110, 0.16)"},children:[e.jsxs("span",{children:[e.jsx("small",{style:{display:"block",marginBottom:5,color:"#0F766E",fontSize:10,letterSpacing:".08em"},children:"SYSTEM OF INTEREST"}),n.label]}),e.jsx(Zn,{})]})}),$r=d.memo(function({data:i}){const n=i,a=n.category==="environment"?{border:"#7C3AED",fill:"#F5F3FF",text:"#4C1D95",tag:"ENVIRONMENT"}:n.category==="person"?{border:"#2563EB",fill:"#EFF6FF",text:"#1E3A8A",tag:"ACTOR"}:{border:"#64748B",fill:"#F8FAFC",text:"#334155",tag:"EXTERNAL SYSTEM"};return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:3,padding:"10px 14px",textAlign:"center",border:`1.5px solid ${a.border}`,borderRadius:7,background:a.fill,color:a.text,fontSize:13,fontWeight:650,lineHeight:1.25},children:[n.category==="person"&&e.jsx(nt,{size:26,color:a.border}),e.jsxs("span",{children:[e.jsx("small",{style:{display:"block",marginBottom:4,color:a.border,fontSize:9,letterSpacing:".07em"},children:a.tag}),n.label]}),e.jsx(Zn,{})]})}),Wr=d.memo(function({data:i}){const n=i;return e.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",border:"2px solid #0F766E",borderRadius:12,background:"rgba(240, 253, 250, 0.34)",padding:"12px 16px",color:"#0F766E",fontSize:12,fontWeight:750,letterSpacing:".04em"},children:n.label})}),Or=d.memo(function({id:i,data:n,selected:a}){var W;const r=n,[l,p]=d.useState(!1),[f,w]=d.useState(""),[F,I]=d.useState(!1),h=d.useRef(null),C=d.useCallback(()=>{w(r.label),p(!0),setTimeout(()=>{var E;(E=h.current)==null||E.select()},10)},[r.label]),j=d.useCallback(()=>{var R;p(!1);const E=f.trim();E&&E!==r.label&&((R=r.onInlineEdit)==null||R.call(r,i,E))},[f,r,i]),m=d.useCallback(E=>{E.key==="Enter"&&(E.preventDefault(),j()),E.key==="Escape"&&p(!1)},[j]),A=d.useCallback(E=>{var R;E.preventDefault(),(R=r.onContextMenu)==null||R.call(r,E,i)},[r,i]),b=r.bgColor??"#FFFFFF",v=r.color,T={background:v,border:"2px solid #FFFFFF",width:10,height:10,opacity:F||a?1:0,transition:"opacity 0.15s"};return e.jsxs("div",{onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),onContextMenu:A,onDoubleClick:C,style:{minWidth:120,minHeight:40,background:b,borderLeft:`3px solid ${v}`,borderRadius:8,boxShadow:a?`0 0 0 2px ${v}, 0 4px 12px ${v}44`:F?"0 4px 16px rgba(0,0,0,0.14)":"0 1px 4px rgba(0,0,0,0.08)",cursor:l?"text":"grab",position:"relative",transition:"box-shadow 0.15s",opacity:r.isNew?.7:1},children:[a&&e.jsx(tt,{minWidth:80,minHeight:36,maxWidth:600,maxHeight:400,color:v,lineStyle:{borderColor:v},handleStyle:{background:v,border:"2px solid #fff",width:10,height:10,borderRadius:2}}),e.jsxs("div",{style:{padding:"8px 12px",userSelect:"none",display:"flex",gap:8,alignItems:"center"},children:[mo(r.kind)&&e.jsx(nt,{size:26,color:v}),e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsx("div",{style:{fontSize:"9px",fontWeight:700,color:v,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:2},children:r.kind}),l?e.jsx("input",{ref:h,value:f,onChange:E=>w(E.target.value),onBlur:j,onKeyDown:m,onClick:E=>E.stopPropagation(),autoFocus:!0,style:{fontSize:D.sm,fontWeight:500,color:"#1a1a1a",background:"transparent",border:"none",outline:"none",width:"100%",padding:0}}):e.jsx("div",{style:{fontSize:D.sm,fontWeight:500,color:"#1a1a1a",lineHeight:1.3,wordBreak:"break-word"},children:r.label||r.kind}),r.isNew&&e.jsx("div",{style:{fontSize:"9px",color:"#9CA3AF",marginTop:2},children:"saving…"})]})]}),!!((W=r.compartments)!=null&&W.length)&&e.jsx("div",{style:{borderTop:"1px solid #EDEDEA",padding:"5px 12px 7px",userSelect:"none"},children:r.compartments.map(E=>e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"baseline",fontSize:"10px",lineHeight:"15px",whiteSpace:"nowrap",overflow:"hidden"},children:[e.jsx("span",{style:{color:"#9CA3AF"},children:E.key}),e.jsx("span",{style:{color:"#4B5563",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis"},children:E.value})]},E.key))}),e.jsx(N,{type:"target",position:k.Top,style:{...T,top:-5}}),e.jsx(N,{type:"source",position:k.Bottom,style:{...T,bottom:-5},id:"bottom"}),e.jsx(N,{type:"source",position:k.Right,style:{...T,right:-5},id:"right"}),e.jsx(N,{type:"target",position:k.Left,style:{...T,left:-5}})]})}),Qn="application/memo-kind";function ao({collapsed:t,onToggleCollapse:i,elementIds:n=[],eligibleKinds:a}){const r=O(b=>b.model),l=O(b=>b.selectedElementId),p=O(b=>b.inspectElement),[f,w]=d.useState(""),[F,I]=d.useState(new Set),[h,C]=d.useState(!0),j=d.useMemo(()=>{if(!(a!=null&&a.size))return[];const b=f.trim().toLowerCase();return Kn(r).kinds.filter(v=>a.has(v.name)&&!v.isAbstract).filter(v=>!b||v.name.toLowerCase().includes(b)||(v.label??"").toLowerCase().includes(b)).map(v=>({name:v.name,label:v.label||v.name,layer:v.layer??"",construct:Vi(v.construct)})).sort((v,T)=>v.label.localeCompare(T.label))},[r,a,f]),m=d.useMemo(()=>{var W;if(!r)return[];const b=f.trim().toLowerCase(),v=new Map,T=new Set(n);for(const E of n){const R=(W=r.elements[E])==null?void 0:W.allocatedTo;R&&T.add(R)}for(const E of T){const R=r.elements[E];R&&(b&&!R.name.toLowerCase().includes(b)&&!R.kind.toLowerCase().includes(b)||(v.has(R.kind)||v.set(R.kind,[]),v.get(R.kind).push(R)))}return[...v.entries()].map(([E,R])=>({kind:E,elements:R.sort((Q,H)=>Q.name.localeCompare(H.name))})).sort((E,R)=>E.kind.localeCompare(R.kind))},[r,n,f]),A=b=>I(v=>{const T=new Set(v);return T.has(b)?T.delete(b):T.add(b),T});return t?e.jsxs("button",{className:"flex flex-col items-center py-2 gap-1 cursor-pointer",style:{width:36,border:0,borderRight:"1px solid #E5E5E0",background:"#FAFAF8",flexShrink:0},onClick:i,title:"Expand diagram elements","aria-label":"Expand diagram elements",children:[e.jsx("span",{style:{color:"#6B7280",fontSize:18},children:"›"}),e.jsx("span",{style:{fontSize:10,color:"#6B7280",writingMode:"vertical-rl"},children:"Diagram Elements"})]}):e.jsxs("div",{className:"flex flex-col overflow-hidden",style:{width:240,borderRight:"1px solid #E5E5E0",background:"#FAFAF8",flexShrink:0},children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",style:{borderBottom:"1px solid #E5E5E0",flexShrink:0},children:[e.jsx("span",{style:{fontSize:D.xs,fontWeight:600,color:"#374151"},children:"Diagram Elements"}),e.jsx("button",{onClick:i,title:"Collapse diagram elements","aria-label":"Collapse diagram elements",style:{background:"none",border:"none",cursor:"pointer",color:"#6B7280",fontSize:18,lineHeight:1},children:"‹"})]}),e.jsx("div",{className:"px-2 pt-2 pb-1",style:{flexShrink:0},children:e.jsx("input",{value:f,onChange:b=>w(b.target.value),placeholder:"Search elements…",className:"w-full px-2 py-1 rounded focus:outline-none",style:{fontSize:D.xs,background:"#F0F0ED",border:"1px solid #E5E5E0",color:"#374151"}})}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[j.length>0&&e.jsxs("div",{style:{borderBottom:"1px solid #E5E5E0",paddingBottom:4,marginBottom:4},children:[e.jsxs("button",{onClick:()=>C(b=>!b),className:"w-full flex items-center gap-1.5 px-2 py-1",style:{background:"none",border:"none",cursor:"pointer",textAlign:"left"},children:[e.jsx("span",{style:{fontSize:10,color:"#6B7280"},children:h?"▼":"▶"}),e.jsx("span",{style:{fontSize:10,color:"#374151",fontWeight:700,letterSpacing:"0.04em"},children:"SHAPES"}),e.jsx("span",{style:{fontSize:9,color:"#9CA3AF",marginLeft:"auto"},children:j.length})]}),h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pb-1",style:{fontSize:9,color:"#9CA3AF"},children:"Drag onto the canvas to create"}),j.map(b=>{const v=uo[b.layer]??"#6B7280";return e.jsxs("div",{draggable:!0,onDragStart:T=>{T.dataTransfer.setData(Qn,JSON.stringify({kind:b.name,layer:b.layer,construct:b.construct})),T.dataTransfer.effectAllowed="copy"},title:`Drag to create a ${b.label} (${b.construct})`,className:"flex items-center gap-2 px-3 py-1.5",style:{cursor:"grab",fontSize:D.xs,color:"#374151"},children:[e.jsx("span",{style:{width:12,height:12,flexShrink:0,borderRadius:b.construct==="port"?2:3,border:`2px solid ${v}`,background:b.construct==="port"?"#FFFFFF":`${v}22`}}),e.jsx("span",{className:"truncate flex-1",children:b.label})]},b.name)})]})]}),m.map(b=>{var W;const v=F.has(b.kind),T=uo[(W=b.elements[0])==null?void 0:W.layer]??"#6B7280";return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>A(b.kind),className:"w-full flex items-center gap-1.5 px-2 py-1",style:{background:"none",border:"none",cursor:"pointer",textAlign:"left"},children:[e.jsx("span",{style:{fontSize:10,color:T},children:v?"▶":"▼"}),e.jsx("span",{className:"truncate",style:{fontSize:10,color:T,fontWeight:700},children:b.kind}),e.jsx("span",{style:{fontSize:9,color:"#9CA3AF",marginLeft:"auto"},children:b.elements.length})]}),!v&&b.elements.map(E=>{const R=l===E.id;return e.jsxs("button",{onClick:()=>p(E.id),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left",style:{border:"none",cursor:"pointer",fontSize:D.xs,background:R?"#DDF7EF":"transparent",color:R?"#116149":"#374151",fontWeight:R?600:400},title:`Highlight ${E.name} in diagram`,children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2,background:T,flexShrink:0}}),e.jsx("span",{className:"truncate flex-1",children:E.name})]},E.id)})]},b.kind)}),m.length===0&&e.jsx("div",{className:"p-3 text-center",style:{color:"#9CA3AF",fontSize:D.xs},children:f?"No matching elements":"No elements in this diagram"})]})]})}function ne({label:t,icon:i,danger:n,onClick:a}){return e.jsxs("button",{onClick:a,className:"w-full flex items-center gap-2 px-3 py-1.5 text-left",style:{background:"none",border:"none",cursor:"pointer",fontSize:D.xs},onMouseEnter:r=>{r.currentTarget.style.background=n?"#FEF2F2":"#F7F7F5"},onMouseLeave:r=>{r.currentTarget.style.background="none"},children:[i&&e.jsx("span",{style:{fontSize:"12px",width:16,textAlign:"center"},children:i}),e.jsx("span",{style:{color:n?"#DC2626":"#1a1a1a"},children:t})]})}function Bt(){return e.jsx("div",{style:{height:1,background:"#E5E5E0",margin:"2px 0"}})}function Jn({x:t,y:i,onClose:n,children:a}){const r=d.useRef(null);d.useEffect(()=>{const w=I=>{r.current&&!r.current.contains(I.target)&&n()},F=I=>{I.key==="Escape"&&n()};return document.addEventListener("mousedown",w),document.addEventListener("keydown",F),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",F)}},[n]);const l=210,p=Math.min(t,window.innerWidth-l-8),f=Math.min(i,window.innerHeight-200);return e.jsx("div",{ref:r,className:"fixed z-50 rounded-xl overflow-hidden py-1",style:{left:p,top:f,minWidth:l,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.14)"},children:a})}const Pr=[{label:"Layer default",value:""},{label:"Mint",value:"#E8F5E9"},{label:"Sky",value:"#E3F2FD"},{label:"Amber",value:"#FFF8E1"},{label:"Rose",value:"#FFF0F0"},{label:"Lavender",value:"#F3E5F5"},{label:"Peach",value:"#FBE9E7"}];function Hr({x:t,y:i,nodeId:n,nodeKind:a,onClose:r,onEditName:l,onChangeColor:p,onRemoveFromDiagram:f,onDeleteFromModel:w,onLinkRisk:F,onLinkRequirement:I,onShowProperties:h,onFocusElement:C,onShowInCatalog:j,onShowRelMatrix:m,onOpenSource:A,onViewKindInOntology:b}){const[v,T]=d.useState(!1);return e.jsxs(Jn,{x:t,y:i,onClose:r,children:[e.jsxs("div",{className:"px-3 py-1.5",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"#9CA3AF"},children:a}),e.jsx("div",{style:{fontSize:"9px",color:"#D1D5DB",fontFamily:"monospace"},children:n})]}),h&&e.jsx(ne,{label:"Show Properties",icon:"ℹ",onClick:()=>{r(),h()}}),j&&e.jsx(ne,{label:"Show in Catalog",icon:"☰",onClick:()=>{r(),j()}}),C&&e.jsx(ne,{label:"Focus on Element",icon:"◎",onClick:()=>{r(),C()}}),m&&e.jsx(ne,{label:"Show Relationship Matrix",icon:"☷",onClick:()=>{r(),m()}}),b&&e.jsx(ne,{label:"View Kind in Ontology",icon:"⬡",onClick:()=>{r(),b()}}),A&&e.jsx(ne,{label:"Open Source File",icon:"⟨/⟩",onClick:()=>{r(),A()}}),(h||j||C||m||b||A)&&e.jsx(Bt,{}),e.jsx(ne,{label:"Edit name",icon:"✏️",onClick:()=>{r(),l()}}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{className:"w-full flex items-center gap-2 px-3 py-1.5",style:{background:"none",border:"none",cursor:"pointer",fontSize:D.xs},onMouseEnter:W=>{T(!0),W.currentTarget.style.background="#F7F7F5"},onMouseLeave:W=>{W.currentTarget.style.background="none"},children:[e.jsx("span",{style:{fontSize:"12px",width:16,textAlign:"center"},children:"🎨"}),e.jsx("span",{style:{flex:1,textAlign:"left",color:"#1a1a1a"},children:"Change color"}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:"10px"},children:"▶"})]}),v&&e.jsx("div",{className:"absolute left-full top-0 rounded-xl overflow-hidden py-1",style:{background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",minWidth:160},onMouseEnter:()=>T(!0),onMouseLeave:()=>T(!1),children:Pr.map(W=>e.jsxs("button",{onClick:()=>{r(),p(W.value)},className:"w-full flex items-center gap-2.5 px-3 py-1.5",style:{background:"none",border:"none",cursor:"pointer"},onMouseEnter:E=>{E.currentTarget.style.background="#F7F7F5"},onMouseLeave:E=>{E.currentTarget.style.background="none"},children:[e.jsx("div",{style:{width:14,height:14,borderRadius:3,flexShrink:0,background:W.value||"#E5E5E0",border:"1px solid #D1D5DB"}}),e.jsx("span",{style:{fontSize:D.xs,color:"#374151"},children:W.label})]},W.value))})]}),e.jsx(Bt,{}),F&&e.jsx(ne,{label:"Link Risk",icon:"⚠️",onClick:()=>{r(),F()}}),I&&e.jsx(ne,{label:"Link Requirement",icon:"📋",onClick:()=>{r(),I()}}),(F||I)&&e.jsx(Bt,{}),e.jsx(ne,{label:"Remove from diagram",icon:"↩️",onClick:()=>{r(),f()}}),e.jsx(ne,{label:"Delete from model",icon:"🗑️",danger:!0,onClick:()=>{window.confirm(`Delete ${n} from the model? This cannot be undone.`)&&(r(),w())}})]})}const _r=[{label:"Auto",value:""},{label:"Red",value:"#EF4444"},{label:"Blue",value:"#3B82F6"},{label:"Green",value:"#10B981"},{label:"Orange",value:"#F59E0B"},{label:"Gray",value:"#6B7280"}];function Kr({x:t,y:i,edgeId:n,relType:a,onClose:r,onChangeStyle:l,onChangeColor:p,onToggleLabel:f,onDelete:w}){return e.jsxs(Jn,{x:t,y:i,onClose:r,children:[e.jsxs("div",{className:"px-3 py-1.5",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"#9CA3AF"},children:a}),e.jsx("div",{style:{fontSize:"9px",color:"#D1D5DB",fontFamily:"monospace"},children:n})]}),e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2",children:[e.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF",minWidth:40},children:"Style"}),["solid","dashed","dotted"].map(F=>e.jsx("button",{onClick:()=>{r(),l(F)},style:{fontSize:"10px",padding:"2px 8px",border:"1px solid #E5E5E0",borderRadius:4,cursor:"pointer",background:"#F7F7F5",color:"#374151"},children:F},F))]}),e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF",minWidth:40,flexShrink:0},children:"Color"}),_r.map(F=>e.jsx("button",{onClick:()=>{r(),p(F.value)},title:F.label,style:{width:16,height:16,borderRadius:"50%",background:F.value||"#E5E5E0",border:"1px solid #D1D5DB",cursor:"pointer"}},F.value))]}),e.jsx(Bt,{}),e.jsx(ne,{label:"Toggle label",icon:"🏷️",onClick:()=>{r(),f()}}),e.jsx(ne,{label:"Delete edge",icon:"🗑️",danger:!0,onClick:()=>{r(),w()}})]})}const Vr=d.memo(function({id:i,data:n,selected:a}){const r=n,l=r.color??r.layerColor??"#E67E22",p=80,f=d.useCallback(w=>{var F;w.preventDefault(),(F=r.onContextMenu)==null||F.call(r,w,i)},[r,i]);return e.jsxs("div",{style:{width:p,height:p,position:"relative"},onContextMenu:f,children:[a&&e.jsx(tt,{minWidth:60,minHeight:60}),e.jsx("svg",{width:p,height:p,style:{position:"absolute",top:0,left:0},children:e.jsx("polygon",{points:`${p/2},4 ${p-4},${p/2} ${p/2},${p-4} 4,${p/2}`,fill:r.color?r.color+"44":"#FFF8E1",stroke:l,strokeWidth:a?2.5:1.5})}),e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:600,color:"#374151",textAlign:"center",padding:"4px 8px",pointerEvents:"none"},children:r.condition||r.label||"?"}),e.jsx(N,{type:"target",position:k.Top,style:{background:l,border:"2px solid #fff"}}),e.jsx(N,{type:"source",position:k.Right,style:{background:l,border:"2px solid #fff"},id:"right"}),e.jsx(N,{type:"source",position:k.Bottom,style:{background:l,border:"2px solid #fff"},id:"bottom"}),e.jsx(N,{type:"target",position:k.Left,style:{background:l,border:"2px solid #fff"}})]})}),Yr=d.memo(function({id:i,data:n,selected:a}){const r=n,l=(r.orientation??"horizontal")==="horizontal",p=l?120:8,f=l?8:60,w=d.useCallback(F=>{var I;F.preventDefault(),(I=r.onContextMenu)==null||I.call(r,F,i)},[r,i]);return e.jsxs("div",{style:{width:p,height:f,background:"#1a1a1a",borderRadius:4,position:"relative"},title:r.nodeType==="join"?"Join (synchronization)":"Fork (parallel)",onContextMenu:w,children:[a&&e.jsx(tt,{minWidth:40,minHeight:6}),l?e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"target",position:k.Left,style:{background:"#2DD4A8",border:"2px solid #fff",left:-1}}),e.jsx(N,{type:"source",position:k.Top,style:{background:"#2DD4A8",border:"2px solid #fff",top:-1},id:"top"}),e.jsx(N,{type:"source",position:k.Bottom,style:{background:"#2DD4A8",border:"2px solid #fff",bottom:-1},id:"bottom"}),e.jsx(N,{type:"source",position:k.Right,style:{background:"#2DD4A8",border:"2px solid #fff",right:-1},id:"right"})]}):e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"target",position:k.Top,style:{background:"#2DD4A8",border:"2px solid #fff",top:-1}}),e.jsx(N,{type:"source",position:k.Left,style:{background:"#2DD4A8",border:"2px solid #fff",left:-1},id:"left"}),e.jsx(N,{type:"source",position:k.Right,style:{background:"#2DD4A8",border:"2px solid #fff",right:-1},id:"right"}),e.jsx(N,{type:"source",position:k.Bottom,style:{background:"#2DD4A8",border:"2px solid #fff",bottom:-1},id:"bottom"})]})]})}),Xr=d.memo(function({id:i,data:n}){const a=n,r=a.nodeType==="start",l=32,p=d.useCallback(f=>{var w;f.preventDefault(),(w=a.onContextMenu)==null||w.call(a,f,i)},[a,i]);return e.jsxs("div",{style:{width:l,height:l,position:"relative"},onContextMenu:p,children:[e.jsx("svg",{width:l,height:l,children:r?e.jsx("circle",{cx:l/2,cy:l/2,r:l/2-2,fill:"#1a1a1a"}):e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:l/2,cy:l/2,r:l/2-2,fill:"#1a1a1a"}),e.jsx("circle",{cx:l/2,cy:l/2,r:l/2-6,fill:"#FFFFFF"}),e.jsx("circle",{cx:l/2,cy:l/2,r:l/2-10,fill:"#1a1a1a"})]})}),r?e.jsx(N,{type:"source",position:k.Bottom,style:{background:"#1a1a1a",border:"2px solid #fff"}}):e.jsx(N,{type:"target",position:k.Top,style:{background:"#1a1a1a",border:"2px solid #fff"}})]})}),Gr="#ECEBE6",Tt="#1B3A4B",yo="#5B6470",Ur="0 1px 2px rgba(0,0,0,0.16), 0 0 0 0.5px rgba(0,0,0,0.05)",Se=(t,i)=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{display:"block"},children:i}),Y={arrowRight:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M4 12h14"}),e.jsx("path",{d:"M13 6l6 6-6 6"})]})),arrowDown:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 4v14"}),e.jsx("path",{d:"M6 13l6 6 6-6"})]})),lanes:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"5",width:"18",height:"3.4",rx:"1.3"}),e.jsx("rect",{x:"3",y:"10.3",width:"18",height:"3.4",rx:"1.3"}),e.jsx("rect",{x:"3",y:"15.6",width:"18",height:"3.4",rx:"1.3"})]})),grid:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3.5",y:"3.5",width:"17",height:"17",rx:"2.5"}),e.jsx("path",{d:"M9.2 3.5v17M14.8 3.5v17M3.5 9.2h17M3.5 14.8h17"})]})),expand:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M15 4h5v5"}),e.jsx("path",{d:"M9 20H4v-5"}),e.jsx("path",{d:"M20 4l-7 7"}),e.jsx("path",{d:"M4 20l7-7"})]})),collapse:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M14 10h5"}),e.jsx("path",{d:"M19 10V5"}),e.jsx("path",{d:"M10 14H5"}),e.jsx("path",{d:"M5 14v5"}),e.jsx("path",{d:"M20 4l-6 6"}),e.jsx("path",{d:"M4 20l6-6"})]})),filter:({size:t=16})=>Se(t,e.jsx("path",{d:"M4 5h16l-6.2 7.4V19l-3.6 1.8v-8.4z"})),back:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M11 5l-6 7 6 7"}),e.jsx("path",{d:"M5 12h14"})]}))};function xe(){return e.jsx("span",{"aria-hidden":"true",style:{width:1,height:18,background:"#E2E1DB",margin:"0 3px",borderRadius:1}})}function Nt({options:t,value:i,onChange:n}){return e.jsx("div",{role:"tablist",style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,background:Gr,borderRadius:9},children:t.map(a=>{const r=a.value===i;return e.jsxs("button",{role:"tab","aria-selected":r,onClick:()=>n(a.value),title:a.title,className:"flex items-center gap-1.5 text-xs font-semibold",style:{padding:a.label?"3px 9px":"4px 7px",borderRadius:7,border:"none",cursor:"pointer",color:r?Tt:yo,background:r?"#FFFFFF":"transparent",boxShadow:r?Ur:"none",transition:"background 140ms ease, color 140ms ease, box-shadow 140ms ease"},children:[a.icon,a.label&&e.jsx("span",{children:a.label})]},a.value)})})}function qr({children:t}){return e.jsx("div",{style:{display:"inline-flex",alignItems:"center",background:"#FFFFFF",border:"1px solid #E2E1DB",borderRadius:9,overflow:"hidden"},children:Sn.Children.toArray(t).map((i,n)=>e.jsxs(Sn.Fragment,{children:[n>0&&e.jsx("span",{"aria-hidden":"true",style:{width:1,alignSelf:"stretch",background:"#EDECE7"}}),i]},n))})}function ie({icon:t,label:i,onClick:n,active:a=!1,title:r,ariaExpanded:l,ariaLabel:p}){return e.jsxs("button",{onClick:n,title:r,"aria-label":p,"aria-pressed":a,"aria-expanded":l,className:"flex items-center gap-1.5 text-xs font-semibold",style:{padding:i?"5px 9px":"5px 7px",border:"none",cursor:"pointer",color:a?"#FFFFFF":yo,background:a?Tt:"transparent",transition:"background 140ms ease, color 140ms ease"},children:[t,i&&e.jsx("span",{children:i})]})}function Je({icon:t,label:i,onClick:n,active:a=!1,title:r,badge:l}){return e.jsxs("button",{onClick:n,title:r,"aria-pressed":a,className:"flex items-center gap-1.5 text-xs font-semibold",style:{padding:l!=null||i!=null?"5px 9px":"5px 7px",borderRadius:9,border:`1px solid ${a?Tt:"#E2E1DB"}`,cursor:"pointer",color:a?"#FFFFFF":yo,background:a?Tt:"#FFFFFF",transition:"background 140ms ease, color 140ms ease, border-color 140ms ease"},children:[t,i!=null&&e.jsx("span",{children:i}),l!=null&&e.jsx("span",{style:{fontSize:11,fontWeight:700,lineHeight:1,padding:"2px 5px",borderRadius:6,background:a?"rgba(255,255,255,0.22)":"#F0EFEA",color:a?"#FFFFFF":"#6B7280"},children:l})]})}const Zr=1,$n="memo-layout-progress";if(typeof document<"u"&&!document.getElementById($n)){const t=document.createElement("style");t.id=$n,t.textContent="@keyframes memo-layout-progress { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }",document.head.appendChild(t)}const Qr={background:"#F7F7F5"},Jr={padding:.08,maxZoom:2},ea={background:"#FFFFFF"},ta={hideAttribution:!0},oa=[20,20],na=50,Wn=8e3,sa=90;function ia(t,i){return new Promise((n,a)=>{const r=window.setTimeout(()=>a(new Error(`${i} layout exceeded ${Wn/1e3}s`)),Wn);t.then(l=>{window.clearTimeout(r),n(l)},l=>{window.clearTimeout(r),a(l)})})}function ra({data:t,selected:i}){const n=t.kind,a=n==="note",r=n==="constraint";return e.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",padding:a?"12px 14px":r?"10px 12px":"4px",background:a?String(t.color??"#FEF3C7"):r?"#FFFFFF":"transparent",border:r?"1.5px dashed #7C3AED":a?"1px solid #F59E0B":"1px solid transparent",borderRadius:a?3:r?5:0,boxShadow:a?"0 2px 6px rgba(0,0,0,.12)":"none",color:"#292524",fontSize:12,lineHeight:1.4},children:[e.jsx(tt,{isVisible:i,minWidth:100,minHeight:48,color:"#2563EB"}),e.jsx("button",{className:"nodrag","aria-label":"Delete annotation",title:"Delete annotation",onPointerDown:l=>{var p;l.preventDefault(),l.stopPropagation(),(p=t.onDelete)==null||p.call(t)},onClick:l=>{var p;l.stopPropagation(),(p=t.onDelete)==null||p.call(t)},style:{position:"absolute",top:3,right:5,border:0,background:"transparent",color:"#64748B",cursor:"pointer",fontSize:14,lineHeight:1,pointerEvents:"all",zIndex:30},children:"×"}),r&&e.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#7C3AED",marginBottom:4},children:"constraint"}),e.jsx("div",{contentEditable:!0,suppressContentEditableWarning:!0,className:"nodrag",style:{outline:"none",whiteSpace:"pre-wrap",minHeight:20},onBlur:l=>{var p;return(p=t.onTextChange)==null?void 0:p.call(t,l.currentTarget.textContent??"")},children:String(t.text??"")})]})}function On(t,i){const n=new Map(t.map(h=>[h.id,h])),a=new Map,r=h=>{const C=a.get(h);if(C)return C;const j=n.get(h),m=j.parentId?r(j.parentId):{x:0,y:0},A={x:m.x+j.position.x,y:m.y+j.position.y};return a.set(h,A),A},l=h=>{var C,j;return{width:Number(h.width??((C=h.style)==null?void 0:C.width)??0),height:Number(h.height??((j=h.style)==null?void 0:j.height)??0)}},p=i.flatMap(h=>{var v,T,W,E,R,Q;const C=(H,z,q)=>{var S,te;if(typeof z=="string"){const K=(((te=(S=n.get(H))==null?void 0:S.data)==null?void 0:te.ports)??[]).find(X=>X.id===z);if(K){const X=K.size??20;return{x:K.x+X/2,y:K.y+X/2}}}return q},j=C(h.source,(v=h.data)==null?void 0:v.sourcePortId,(T=h.data)==null?void 0:T.sourceOffset),m=C(h.target,(W=h.data)==null?void 0:W.targetPortId,(E=h.data)==null?void 0:E.targetOffset);if(!j||!m||!n.has(h.source)||!n.has(h.target))return[];const A=r(h.source),b=r(h.target);return[{id:h.id,source:{x:A.x+j.x,y:A.y+j.y},target:{x:b.x+m.x,y:b.y+m.y},sourceNodeId:h.source,targetNodeId:h.target,sourceSide:(R=h.data)==null?void 0:R.sourceSide,targetSide:(Q=h.data)==null?void 0:Q.targetSide}]});if(p.length===0)return i;const f=t.filter(h=>!h.data.isFrame).map(h=>({id:h.id,...r(h.id),...l(h)})),w=new Map(p.map(h=>[h.id,h])),F=p.filter(h=>{var C,j;return!((j=(C=i.find(m=>m.id===h.id))==null?void 0:C.data)!=null&&j.manualRoute)}),I=Hi(F,f);return i.map(h=>{var j;const C=w.get(h.id);if(!C)return h;if((j=h.data)!=null&&j.manualRoute){const m=[...h.data.points??[]];if(m.length>=2)return m[0]=C.source,m[m.length-1]=C.target,{...h,data:{...h.data,points:m}}}return I.has(h.id)?{...h,data:{...h.data,points:I.get(h.id)}}:h})}function aa({x:t,y:i,onConfirm:n,onCancel:a}){const[r,l]=d.useState(""),p=d.useRef(null);d.useEffect(()=>{var F;(F=p.current)==null||F.focus()},[]),d.useEffect(()=>{const F=I=>{const h=document.getElementById("quick-create-popup");h&&!h.contains(I.target)&&a()};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[a]);const f=Math.min(t,window.innerWidth-220),w=Math.min(i,window.innerHeight-80);return e.jsxs("div",{id:"quick-create-popup",className:"fixed z-50 rounded-xl shadow-xl overflow-hidden",style:{left:f,top:w,width:200,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.14)"},children:[e.jsx("div",{className:"px-3 py-2",style:{borderBottom:"1px solid #E5E5E0",fontSize:D.xs,color:"#9CA3AF",fontWeight:600},children:"New Element"}),e.jsxs("div",{className:"px-2 py-2",children:[e.jsx("input",{ref:p,value:r,onChange:F=>l(F.target.value),placeholder:"Element name…",className:"w-full px-2 py-1.5 rounded focus:outline-none",style:{fontSize:D.xs,border:"1px solid #E5E5E0",background:"#F7F7F5",color:"#1a1a1a"},onKeyDown:F=>{F.key==="Enter"&&r.trim()&&(F.preventDefault(),n(r.trim())),F.key==="Escape"&&a()}}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("button",{onClick:()=>r.trim()&&n(r.trim()),style:{flex:1,fontSize:D.xs,padding:"4px 8px",background:"#2DD4A8",color:"#FFFFFF",border:"none",borderRadius:6,cursor:"pointer",fontWeight:600},children:"Create"}),e.jsx("button",{onClick:a,style:{fontSize:D.xs,padding:"4px 8px",background:"#F7F7F5",color:"#6B7280",border:"1px solid #E5E5E0",borderRadius:6,cursor:"pointer"},children:"Cancel"})]})]})]})}function lo({color:t,glyph:i}){return e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:13,height:13,borderRadius:2,background:t+"22",border:`1.5px solid ${t}`,color:t,fontSize:9,fontWeight:800,lineHeight:1},children:i})}function Pn(t,i){if(!t||!i)return[];const n=new Map;for(const p of t.relationships)Mt.has(p.type)&&!n.has(p.targetId)&&n.set(p.targetId,p.sourceId);const a=[i],r=new Set(a);let l=i;for(;n.has(l);){const p=n.get(l);if(r.has(p))break;a.unshift(p),r.add(p),l=p}return a}function co({path:t,nameOf:i,onFocus:n,rootLabel:a}){if(t.length===0)return null;const r=t.length>1?t[t.length-2]:null;return e.jsxs(e.Fragment,{children:[e.jsx(xe,{}),e.jsx(Je,{icon:e.jsx(Y.back,{}),label:"Parent",onClick:()=>n(r),title:r?`Back to ${i(r)}`:a}),e.jsx("button",{onClick:()=>n(null),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#2563EB",border:"1px solid #E5E5E0"},title:a,children:"⌂ All"}),t.map((l,p)=>{const f=p===t.length-1;return e.jsxs("span",{className:"flex items-center gap-1",style:{color:"#9CA3AF"},children:[e.jsx("span",{children:"›"}),e.jsx("button",{onClick:()=>n(l),disabled:f,className:"text-xs font-medium",style:{color:f?"#1a1a1a":"#2563EB",fontWeight:f?700:500,cursor:f?"default":"pointer"},title:f?void 0:`Focus ${i(l)}`,children:i(l)})]},l)})]})}function la(){var cn,dn,pn,un,hn,xn,gn,fn,mn,yn;const t=O(o=>o.model),i=O(o=>o.createRelationship),n=d.useMemo(()=>Kn(t),[t]),a=O(o=>o.selectedElementId),r=O(o=>o.selectedViewpointId),l=O(o=>o.selectedDiagramId),p=O(o=>o.hiddenLayers),f=O(o=>o.selectElement),w=O(o=>o.inspectElement),F=O(o=>o.inspectRelationship),I=O(o=>o.setActiveMode),h=O(o=>o.setActiveView),C=O(o=>o.setExplorerTab),j=O(o=>o.availableOntologies),m=O(o=>o.setSelectedOntologyKind),A=O(o=>o.diagramLayouts),b=O(o=>o.setNodeLayout),v=O(o=>o.mergeDiagramLayouts),T=O(o=>o.updateDiagramElementIds),{fitView:W,screenToFlowPosition:E,getViewport:R,setViewport:Q}=xo(),[H,z]=Js([]),[q,S,te]=ei([]),K=d.useRef([]),X=d.useRef([]),st=d.useRef(t),it=d.useRef(l),ve=d.useRef(null),Ne=d.useRef(null),Ae=d.useRef(null),re=d.useRef(0);d.useEffect(()=>{K.current=H},[H]),d.useEffect(()=>{X.current=q},[q]);const ge=d.useCallback(o=>{K.current=o,Ne.current===null&&(Ne.current=requestAnimationFrame(()=>{Ne.current=null;const s=K.current,c=On(s,X.current);X.current=c,z(s),S(c)}))},[z,S]),[Z,ae]=d.useState(!1),[bo,ye]=d.useState(0),[Fo,wo]=d.useState(null),[jo,es]=d.useState(0),[ts,Rt]=d.useState(0),[Re,Lt]=d.useState(!0),[os,So]=d.useState(!0),[vo,ns]=d.useState(!0),[$t,ss]=d.useState("horizontal"),[rt,ko]=d.useState("allocation"),[Wt,Co]=d.useState("all"),[Eo,is]=d.useState(!1),[be,rs]=d.useState(new Set(["control","data","energy","material"])),[se,Le]=d.useState(null),[Fe,at]=d.useState(null),[J,$e]=d.useState(null),[fe,lt]=d.useState(null),[We,Io]=d.useState(null),[ct,as]=d.useState(2),[dt,Do]=d.useState(null),Oe=d.useRef([]),Ot=d.useRef([]),No=d.useCallback(o=>{Oe.current.push(o),Oe.current.length>na&&Oe.current.shift(),Ot.current=[]},[]),g=di(t,l),Pe=g?vn[g.diagramType]:null,pt=!!((cn=g==null?void 0:g.properties)!=null&&cn.layoutStyle),ke=((dn=g==null?void 0:g.properties)==null?void 0:dn.layoutStyle)==="fbs",Ce=l?A[l]:void 0,Ee=ki(Ce),me=((pn=Ce==null?void 0:Ce.canvas)==null?void 0:pn.autoLayout)!==!1,we=((un=Ce==null?void 0:Ce.canvas)==null?void 0:un.flowAnimation)===!0,Ao=d.useCallback((o,s)=>{var y;if(!l)return;const c=O.getState().diagramLayouts[l]??{nodes:{},edges:{}},u=(y=c.annotations)==null?void 0:y[o];if(!u)return;const x={...c,annotations:{...c.annotations,[o]:{...u,text:s}}};v({[l]:x}),je(l,x),z(M=>M.map(B=>B.id===o?{...B,data:{...B.data,text:s}}:B))},[l,v,z]),Mo=d.useCallback(o=>{if(!l)return;const s=O.getState().diagramLayouts[l]??{nodes:{},edges:{}},c={...s.annotations};delete c[o];const u={...s,annotations:c};v({[l]:u}),je(l,u),z(x=>x.filter(y=>y.id!==o))},[l,v,z]),ut=d.useCallback(o=>Object.entries((o==null?void 0:o.annotations)??{}).map(([s,c])=>({id:s,type:"annotationNode",zIndex:1e3,position:{x:c.x,y:c.y},style:{width:c.width??180,height:c.height??92},data:{kind:c.kind,text:c.text,color:c.color,onTextChange:u=>Ao(s,u),onDelete:()=>Mo(s)}})),[Ao,Mo]),ls=d.useCallback(o=>{if(!l)return;const s=`annotation-${Date.now().toString(36)}`,c=E({x:window.innerWidth/2,y:window.innerHeight/2}),u=o==="constraint"?"{constraint}":o==="note"?"Note":"Text",x=O.getState().diagramLayouts[l]??{nodes:{},edges:{}},y={kind:o,x:c.x,y:c.y,width:180,height:o==="text"?56:92,text:u},M={...x,annotations:{...x.annotations,[s]:y}};v({[l]:M}),je(l,M),z(B=>[...B,...ut(M).filter(P=>P.id===s)])},[l,E,v,z,ut]),ee=d.useCallback(()=>{var s;if(!l)return;const o=O.getState().diagramLayouts[l]??{nodes:{},edges:{}};((s=o.canvas)==null?void 0:s.autoLayout)!==!1&&v({[l]:{...o,canvas:{...o.canvas,autoLayout:!1}}})},[l,v]);d.useEffect(()=>{if(!l||me||Z||H.length===0||bo===0)return;const o=window.setTimeout(()=>{const s=O.getState().diagramLayouts[l]??{nodes:{},edges:{}},c=R(),u={nodes:Object.fromEntries(H.filter(x=>x.type!=="annotationNode").map(x=>[x.id,{...s.nodes[x.id]??{},x:x.position.x,y:x.position.y,...x.width?{width:x.width}:{},...x.height?{height:x.height}:{},ports:Object.fromEntries((x.data.ports??[]).map(y=>[y.id,{x:y.x,y:y.y,side:y.side}]))}])),edges:Object.fromEntries(q.map(x=>{var y,M,B,P,_,$;return[x.id,{...(()=>{var ue;const{points:G,...V}=((ue=s.edges)==null?void 0:ue[x.id])??{};return V})(),...(y=x.data)!=null&&y.manualRoute&&((B=(M=x.data)==null?void 0:M.points)!=null&&B.length)?{points:(P=x.data)==null?void 0:P.points,source:x.source,target:x.target,sourcePortId:(_=x.data)==null?void 0:_.sourcePortId,targetPortId:($=x.data)==null?void 0:$.targetPortId}:{}}]})),annotations:Object.fromEntries(H.filter(x=>x.type==="annotationNode").map(x=>{var y,M;return[x.id,{kind:x.data.kind,text:String(x.data.text??""),color:x.data.color,x:x.position.x,y:x.position.y,width:Number(x.width??((y=x.style)==null?void 0:y.width)??180),height:Number(x.height??((M=x.style)==null?void 0:M.height)??92)}]})),canvas:{...s.canvas,zoom:c.zoom,pan:{x:c.x,y:c.y},autoLayout:!1}};v({[l]:u}),je(l,u),ye(0)},350);return()=>window.clearTimeout(o)},[l,me,Z,bo,H,q,R,v]);const L=g?g.viewKind??(Pe==null?void 0:Pe.viewKind)??"general":void 0,Ie=L==="interconnection"?.72:.1,He=L?En[L]:null,Me=L==="general"&&!pt&&!ke,Pt=(g==null?void 0:g.diagramType)==="ucd",[De,Bo]=d.useState("graph"),[Ht,zo]=d.useState("all"),[_t,To]=d.useState("straight"),[_e,Ro]=d.useState(new Set),cs=d.useMemo(()=>t?Ci(t):0,[t]),Lo=d.useMemo(()=>t?Ei(t):[],[t]),Kt=(hn=g==null?void 0:g.properties)==null?void 0:hn.modes,ds=d.useMemo(()=>{if(!Kt)return so;const o=new Set(Kt.split(",").map(c=>c.trim())),s=so.filter(c=>o.has(c));return s.length?s:so},[Kt]),[Ke,$o]=d.useState(!0),Wo=d.useMemo(()=>{if(!t||!g)return[];const o=new Set(g.elementIds),s=Object.values(t.elements).filter(c=>o.has(c.id)&&c.allocatedTo).map(c=>c.allocatedTo);return Ii(s,t)},[t,g]),ps=d.useMemo(()=>{if(!t||!g)return"Activity Diagram";const o=pi(g);return vn[o].fullName},[t,g]),us=d.useMemo(()=>{if(!t||!g)return!1;const o=new Set(g.elementIds);return Object.values(t.elements).some(s=>o.has(s.id)&&!!(s.attributes.stage||s.attributes.phase))},[t,g]),ht=d.useMemo(()=>{if(!t||!g||L!=="actionflow")return[];const o=(g.elementIds??[]).map(s=>t.elements[s]).filter(s=>!!s&&s.construct==="action");return Di(o,t)},[t,g,L]),[Ve,hs]=d.useState("containment"),[Ye,xt]=d.useState(new Set),[Oo,Xe]=d.useState(new Set),[gt,Vt]=d.useState(null),[Ge,Po]=d.useState("all"),[Yt,Ho]=d.useState("summary"),[_o,Ko]=d.useState(!1),[Vo,Ue]=d.useState(new Set),[Be,Xt]=d.useState(null),[Gt,Yo]=d.useState("flat"),[Xo,qe]=d.useState(new Set),[ft,Ut]=d.useState(null),[mt,xs]=d.useState(new Map),de=d.useRef(new Map),gs=d.useMemo(()=>Pn(t,gt),[t,gt]),fs=d.useMemo(()=>Pn(t,ft),[t,ft]),ms=d.useMemo(()=>{var u;if(!t||!Be)return[];const o=[Be],s=new Set(o);let c=Be;for(;c;){const x=(u=t.elements[c])==null?void 0:u.parentAction;if(!x||s.has(x)||!t.elements[x])break;o.unshift(x),s.add(x),c=x}return o},[t,Be]),yt=d.useMemo(()=>{if(!t||L!=="statetransition")return[];const o=new Set;for(const s of t.relationships){if(!Mt.has(s.type))continue;const c=t.elements[s.sourceId];!c||!t.elements[s.targetId]||!Ni(c)||c.kind.endsWith("Machine")||o.add(c.id)}return[...o]},[t,L]),ys=d.useMemo(()=>t?[...new Set(t.relationships.filter(o=>Mt.has(o.type)).map(o=>o.sourceId))]:[],[t]);d.useEffect(()=>{var s,c;ye(0),Bo(Ai(g==null?void 0:g.properties)),zo(io(g==null?void 0:g.properties).level??"all"),To(io(g==null?void 0:g.properties).edgeStyle??"straight"),Ro(new Set),$o(!0),ko("allocation"),Co("all");const o=(c=(s=g==null?void 0:g.properties)==null?void 0:s.styleHint)!=null&&c.startsWith("expanded:")?g.properties.styleHint.slice(9).split(",").map(u=>u.trim()).filter(Boolean):[];xt(new Set(o)),Vt(null),Po("all"),Ho("summary"),Ko(!1),Ue(new Set),Xt(null),Yo("flat"),Ut(null),de.current.clear()},[l,(xn=g==null?void 0:g.properties)==null?void 0:xn.layoutHint,(gn=g==null?void 0:g.properties)==null?void 0:gn.styleHint]);const bs=d.useMemo(()=>({decompositionNode:ir,interconnectionNode:hr,actionFlowNode:wr,actionFlowLane:Sr,stateNode:kr,seqLifeline:Er,seqSection:Dr,seqOccurrence:Ar,useCase:Mr,useCaseActor:Br,useCaseBoundary:zr,contextSystem:Lr,contextExternal:$r,contextBoundary:Wr,diagramNode:Or,annotationNode:ra,decisionNode:Vr,forkNode:Yr,startEndNode:Xr}),[]),Fs=d.useMemo(()=>({interconnectionEdge:yr,useCaseEdge:Rr}),[]),ws=d.useCallback(o=>{var s,c;return((s=o.data)==null?void 0:s.color)||((c=o.data)==null?void 0:c.layerColor)||"#ccc"},[]),U=d.useMemo(()=>{const o=(g==null?void 0:g.viewpointId)==="__model"?null:(g==null?void 0:g.viewpointId)||r,s=o&&(t==null?void 0:t.viewpoints),c=p.size>0,u=g!=null&&g.elementIds?new Set(g.elementIds):void 0;if(!s&&!c&&!u)return;const x=s?t.viewpoints.find(B=>B.id===o):void 0,y=x?new Set(x.visibleKinds):void 0,M=x?new Set(x.visibleLayers):void 0;return B=>p.has(B.layer)?!1:u?u.has(B.id):y&&M?y.has(B.kind)||M.has(B.layer):!0},[r,g,t==null?void 0:t.viewpoints,p]),Go=d.useMemo(()=>{if(!t||L!=="interconnection")return[];const o=Object.values(t.elements),s=U?o.filter(U):o;return Mi(Bi(s,t.relationships),Zr)},[t,L,U]),Uo=d.useRef(null);d.useEffect(()=>{if(!t)return;const o=`${l??""}|${L??""}`;if(Uo.current!==o){if(L==="statetransition"){if(yt.length===0)return;qe(new Set(yt))}else L==="interconnection"&&Xe(new Set(Go));Uo.current=o}},[t,l,L,yt,Go]);const bt=d.useMemo(()=>{if(!t||!g||g.diagramType!=="bdd")return null;const o=g.relationshipTypes??[];return o.length===0||o.every(c=>Mt.has(c.charAt(0).toLowerCase()+c.slice(1)))?zi(Dn(t,U,g.relationshipTypes)):null},[t,g,U]),qo=d.useCallback(()=>{if(t)return ke?Ti(t):Me?Dn(t,U,g==null?void 0:g.relationshipTypes):Ri(t)},[t,ke,Me,U,g==null?void 0:g.relationshipTypes]),qt=d.useCallback(o=>{xt(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),Zo=d.useCallback(o=>{Xe(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),Qo=d.useCallback(o=>{Ue(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),Ft=d.useCallback(o=>{Ut(o),qe(new Set),w(null)},[w]),wt=d.useCallback(o=>{Xt(o),Ue(new Set),w(null)},[w]),jt=d.useCallback(o=>{Vt(o),Xe(new Set),w(null)},[w]),Jo=d.useCallback(o=>{qe(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),en=d.useCallback(o=>{de.current.clear(),xs(s=>{const c=new Map(s),u=c.get(o)||"vertical";return c.set(o,u==="vertical"?"horizontal":"vertical"),c})},[]),Zt=d.useCallback(()=>{const o=qo();if(!o)return;const s=new Set,c=u=>{s.add(u);for(const x of o.childrenMap.get(u)||[])o.elements.has(x)&&c(x)};for(const u of o.roots)o.elements.has(u)&&c(u);xt(s)},[qo]),Qt=d.useCallback(()=>xt(new Set),[]),Jt=d.useCallback(()=>{de.current.clear(),Rt(o=>o+1)},[]),js=d.useCallback(()=>{if(!l)return;const o=O.getState().diagramLayouts[l]??{},{pan:s,zoom:c,...u}=o.canvas??{},x={nodes:{},edges:{},canvas:{...u,autoLayout:!0}};ve.current=null,v({[l]:x}),je(l,x),de.current.clear(),Rt(y=>y+1),window.setTimeout(()=>W({padding:.08,minZoom:Ie,maxZoom:2,duration:300}),250)},[l,v,W,Ie]),tn=d.useCallback(o=>o.map(s=>{if(s.type!=="diagramNode")return s;const c=t==null?void 0:t.elements[s.id];return{...s,data:{...s.data,onContextMenu:(u,x)=>{$e({x:u.clientX,y:u.clientY,nodeId:x,nodeKind:s.data.kind??""})},onInlineEdit:(u,x)=>{if(!c)return;const y={...c,name:x};kn(y)}}}}),[t]),on=d.useCallback((o,s)=>{const c=o.map(x=>{const y=s.nodes[x.id];return y?{...x,position:{x:y.x,y:y.y},...y.width?{width:y.width}:{},...y.height?{height:y.height}:{},...y.width||y.height?{style:{...x.style,...y.width?{width:y.width}:{},...y.height?{height:y.height}:{}}}:{},data:{...x.data,bgColor:y.color||void 0,...y.opacity!==void 0?{fillOpacity:y.opacity}:{},...y.ports?{ports:(x.data.ports??[]).map(M=>{var B;return{...M,...((B=y.ports)==null?void 0:B[M.id])??{}}})}:{}}}:x}),u=new Map(c.map(x=>[x.id,x]));return c.map(x=>{if(x.type!=="actionFlowLane")return x;const y=x.data,M=(y.memberIds??[]).map(V=>u.get(V)).filter(Boolean);if(M.length===0)return x;const B=Math.min(...M.map(V=>V.position.x)),P=Math.min(...M.map(V=>V.position.y)),_=Math.max(...M.map(V=>{var ue;return V.position.x+Number(V.width??((ue=V.style)==null?void 0:ue.width)??180)})),$=Math.max(...M.map(V=>{var ue;return V.position.y+Number(V.height??((ue=V.style)==null?void 0:ue.height)??96)})),G=y.orientation==="column";return{...x,position:{x:G?B-36:B-120,y:G?P-32:P-36},style:{...x.style,width:_-B+(G?72:156),height:$-P+(G?68:72)}}})},[]),nn=d.useCallback((o,s,c)=>{re.current=Date.now()+250,ee(),ye(y=>y+1);const u=X.current.map(y=>{var $,G;if(!((($=y.data)==null?void 0:$.sourcePortId)===s||((G=y.data)==null?void 0:G.targetPortId)===s))return y;const{points:B,manualRoute:P,..._}=y.data??{};return{...y,data:_}});X.current=u;const x=K.current.map(y=>y.id!==o?y:{...y,data:{...y.data,ports:(y.data.ports??[]).map(M=>M.id===s?{...M,y:c}:M)}});ge(x)},[ge,ee]),sn=d.useCallback((o,s)=>{re.current=Date.now()+250,ee(),ye(c=>c+1),S(c=>{const u=c.map(x=>x.id===o?{...x,data:{...x.data,points:s,manualRoute:!0}}:x);return X.current=u,u})},[ee,S]);d.useEffect(()=>{if(!t)return;const o=st.current!==t&&it.current===l;if(ve.current=o?R():null,st.current=t,it.current=l,L==="grid"||L==="browser"||L==="geometry")return;let s=!1;const c=({nodes:B,edges:P},_=!0)=>{if(s)return;const $=l?O.getState().diagramLayouts[l]:void 0,V=[...$&&Object.keys($.nodes).length>0?on(B,$):B,...ut($)],ue=P.map(oe=>{var bn,Fn,wn;const he=(bn=$==null?void 0:$.edges)==null?void 0:bn[oe.id],St=!(he!=null&&he.source)||he.source===oe.source&&he.target===oe.target&&he.sourcePortId===((Fn=oe.data)==null?void 0:Fn.sourcePortId)&&he.targetPortId===((wn=oe.data)==null?void 0:wn.targetPortId)?he==null?void 0:he.points:void 0;return{...oe,data:{...oe.data,...St!=null&&St.length?{points:St,manualRoute:!0}:{},flowAnimation:we,onRouteChange:to=>sn(oe.id,to),onSelect:to=>{to.stopPropagation(),!(Date.now()<re.current)&&(S(oo=>oo.map(jn=>({...jn,selected:jn.id===oe.id}))),t.relationships.some(oo=>oo.id===oe.id)&&F(oe.id))}}}});z(_?tn(V):V),S(On(V,ue)),ae(!1),es(oe=>oe+1)},u=B=>P=>{s||(console.error(`${B} layout error:`,P),ae(!1),wo(`${B} layout could not be completed. Try resetting the layout or reducing the visible hierarchy.`))},x=(B,P,_=!0)=>{ae(!0),wo(null),ia(P,B).then($=>c($,_)).catch(u(B))},y=()=>{const B=Xn.select({viewKind:L,diagramType:g==null?void 0:g.diagramType,isFBSDiagram:ke,isDecompDiagram:pt,isGeneralTemplate:Me,generalMode:De,layoutStyle:Ve}),P={onToggleExpand:qt,onToggleDirection:en},_={fbs:{expandedNodes:Ye,nodeDirections:mt,callbacks:P,layoutProviderId:Ee},decomposition:{expandedNodes:Ye,nodeDirections:mt,callbacks:P,positionCache:de.current},containment:{expandedNodes:Ye,callbacks:{onToggleExpand:qt}},useCase:{viewpointFilter:void 0,systemName:g==null?void 0:g.name,...g?io(g.properties):{},level:Ht,edgeStyle:_t,hiddenActorIds:_e},context:{systemName:g==null?void 0:g.name,viewpointFilter:U,relationshipTypes:g==null?void 0:g.relationshipTypes},interconnection:{viewpointFilter:U,relationshipTypes:g==null?void 0:g.relationshipTypes,collapsedNodes:Oo,onDrillIn:jt,onToggleCollapse:Zo,focusId:gt??void 0,portDisplay:Ge,connectionDisplay:Yt,onPortMove:nn,layoutProviderId:Ee},actionflow:{viewpointFilter:U,swimlanes:Ke,laneGrouping:rt,displayLevel:Wt,expandedActionIds:Vo,onToggleAction:Qo,onDrillInAction:wt,focusActionId:Be??void 0,visibleFlowKinds:be,direction:$t,nesting:Gt,layoutProviderId:Ee},statetransition:{viewpointFilter:U,collapsedStateIds:Xo,onToggleCollapse:Jo,onDrillIn:Ft,focusStateId:ft??void 0,layoutProviderId:Ee},sequence:{viewpointFilter:U},general:{mode:De,viewpointFilter:U,expandedNodes:Ye,nodeDirections:mt,callbacks:P,positionCache:de.current,hierarchyRelationshipTypes:g==null?void 0:g.relationshipTypes,layoutProviderId:Ee},standard:{viewpointFilter:U,relationshipTypes:g==null?void 0:g.relationshipTypes,compartments:Me,layoutProviderId:Ee}},$=B.compute(t,_);$ instanceof Promise?x(B.descriptor.label,$,B.descriptor.interactive):c($,B.descriptor.interactive)},M=window.setTimeout(y,sa);return()=>{s=!0,window.clearTimeout(M)}},[t,U,pt,ke,Ve,L,Me,De,Ke,ts,g==null?void 0:g.relationshipTypes,g==null?void 0:g.diagramType,g==null?void 0:g.name,Ht,_t,_e,Ee,Ye,Oo,gt,Ge,Yt,Vo,Be,be,$t,rt,Wt,Gt,mt,Xo,ft,Jo,Ft,wt,qt,Zo,Qo,en,l,jt,on,tn,ut,nn,sn,F,R]),d.useEffect(()=>{if(jo===0)return;const o=setTimeout(()=>{var u;const s=ve.current;if(ve.current=null,s){Q(s);return}const c=l?(u=O.getState().diagramLayouts[l])==null?void 0:u.canvas:void 0;(c==null?void 0:c.zoom)!==void 0&&c.pan?Q({x:c.pan.x,y:c.pan.y,zoom:c.zoom},{duration:300}):W({padding:.08,minZoom:Ie,maxZoom:2,duration:500})},200);return()=>clearTimeout(o)},[jo,l,W,Ie,Q]),d.useEffect(()=>{z(o=>o.map(s=>{const c=s.type==="actionFlowLane"?s.data.inspectElementId:void 0,u=!!a&&(s.id===a||c===a);return{...s,selected:u,style:{...s.style,boxShadow:u?"0 0 0 2px #2DD4A8, 0 4px 12px rgba(45, 212, 168, 0.3)":void 0,opacity:a?u?1:.5:1}}}))},[a,z]),d.useEffect(()=>{if(!We||!t)return;const o=_i(t,We,"both",ct),s=new Set(o.nodes.map(c=>c.elementId));s.add(We),z(c=>c.map(u=>({...u,style:{...u.style,opacity:s.has(u.id)?1:.08,pointerEvents:s.has(u.id)?"all":"none"}}))),S(c=>c.map(u=>({...u,style:{...u.style,opacity:s.has(u.source)&&s.has(u.target)?1:.05}})))},[We,ct,t,z,S]),d.useEffect(()=>{if(!dt)return;const o=setTimeout(()=>Do(null),2500);return()=>clearTimeout(o)},[dt]),d.useEffect(()=>{const o=s=>{const c=s.target;if(!(c.tagName==="INPUT"||c.tagName==="TEXTAREA")){if((s.metaKey||s.ctrlKey)&&s.key==="z"&&!s.shiftKey){s.preventDefault();const u=Oe.current.pop();u&&(u.undo(),Ot.current.push(u))}if((s.metaKey||s.ctrlKey)&&(s.key==="Z"||s.key==="z"&&s.shiftKey)){s.preventDefault();const u=Ot.current.pop();u&&(u.do(),Oe.current.push(u))}s.key==="g"&&(s.metaKey||s.ctrlKey)&&s.shiftKey&&(s.preventDefault(),So(u=>!u)),s.key==="0"&&(s.metaKey||s.ctrlKey)&&(s.preventDefault(),W({padding:.08,minZoom:Ie,maxZoom:2,duration:400}))}};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[W,Ie]);const Ss=d.useCallback(o=>{o.preventDefault(),o.dataTransfer.dropEffect="copy"},[]),vs=d.useCallback(o=>{o.preventDefault();const s=o.dataTransfer.getData(Qn);if(s)try{const c=JSON.parse(s),u=E({x:o.clientX,y:o.clientY});Le({x:o.clientX,y:o.clientY,flowX:u.x,flowY:u.y,kind:c.kind,layer:c.layer,construct:c.construct})}catch{}},[E]),ks=d.useCallback(o=>{const s=E({x:o.clientX,y:o.clientY});Le({x:o.clientX,y:o.clientY,flowX:s.x,flowY:s.y})},[E]),Cs=d.useCallback(o=>{if(!se||!l){Le(null);return}const s=se.kind??"Part",c=se.layer??"logical",u=se.construct??"part",x=uo[c]??"#6B7280",y=Ki(o,Object.keys((t==null?void 0:t.elements)??{})),M={id:y,type:"diagramNode",position:{x:se.flowX,y:se.flowY},data:{label:o,kind:s,layer:c,construct:u,color:x,isNew:!0,onContextMenu:($,G)=>{$e({x:$.clientX,y:$.clientY,nodeId:G,nodeKind:s})},onInlineEdit:($,G)=>{kn({id:y,name:G,kind:s,construct:u,layer:c})}}};z($=>[...$,M]),ui({id:y,name:o,kind:s,construct:u,layer:c,attributes:{_layer:c}});const B=(g==null?void 0:g.elementIds)??[];T(l,[...B,y]);const P=l,_={nodes:{...(A[P]??{}).nodes??{},[y]:{x:se.flowX,y:se.flowY}},edges:(A[P]??{}).edges??{}};v({[P]:_}),je(P,_),Le(null)},[se,l,g,A,v,T,z]),Es=d.useCallback(()=>{$e(null),lt(null)},[]),Is=d.useCallback((o,s)=>{s!=null&&s.isValid},[]),eo=d.useCallback((o,s)=>{const c=Li(s);return(c?t==null?void 0:t.elements[c]:void 0)??(t==null?void 0:t.elements[o])},[t]),Ds=d.useCallback(o=>{const{source:s,target:c,sourceHandle:u,targetHandle:x}=o;if(!s||!c)return;const y=eo(s,u),M=eo(c,x);!y||!M||y.id!==M.id&&at({x:window.innerWidth/2-130,y:window.innerHeight/2-160,sourceElement:y,targetElement:M})},[eo]),Ns=d.useCallback(async o=>{if(!Fe||!l){at(null);return}const s=Fe.sourceElement.id;at(null);const c=await i({type:o.type,sourceId:o.sourceId,targetId:o.targetId,direction:o.direction,flowItem:o.flowItem,selectedElementId:s,diagramId:l});if(!c.success){console.warn(`[MEMO] Relationship rejected: ${c.error}`);return}if(!(K.current.some(M=>M.id===o.sourceId)&&K.current.some(M=>M.id===o.targetId)))return;const x=Cn[o.type]??"#6B7280",y={id:c.relationshipId??`e_${o.sourceId}_${o.targetId}_${o.type}`,source:o.sourceId,target:o.targetId,label:o.type,type:"default",style:{stroke:x,strokeWidth:2},labelStyle:{fontSize:"10px",fill:"#374151"},labelBgStyle:{fill:"#FFFFFF",fillOpacity:.9},labelBgPadding:[4,2],labelBgBorderRadius:4,markerEnd:{type:"arrowclosed",color:x}};S(M=>ti(y,M))},[Fe,l,S,i]),As=d.useCallback((o,s)=>{Ae.current={id:s.id,x:s.position.x,y:s.position.y}},[]),Ms=d.useCallback((o,s)=>{const c=Ae.current;if(Ae.current=null,!((c==null?void 0:c.id)===s.id&&Math.hypot(s.position.x-c.x,s.position.y-c.y)>2)||(re.current=Date.now()+250,ye(B=>B+1),!l))return;const{x,y}=s.position;if(s.type==="annotationNode")return;ee();const M=de.current.get(s.id);if(de.current.set(s.id,{x,y}),b(l,s.id,{x,y}),M){const B=s.id,P=l;No({do:()=>b(P,B,{x,y}),undo:()=>{b(P,B,M),z(_=>_.map($=>$.id===B?{...$,position:M}:$))}})}},[l,b,No,z,ee]),Bs=d.useCallback(o=>{const s=c=>{var u;return"id"in c&&((u=K.current.find(x=>x.id===c.id))==null?void 0:u.type)==="annotationNode"};o.some(c=>c.type==="position"&&c.dragging&&!s(c))&&ee(),o.some(c=>c.type==="dimensions"&&c.resizing)&&(o.some(c=>c.type==="dimensions"&&c.resizing&&!s(c))&&ee(),ye(c=>c+1)),ge(oi(o,K.current))},[ge,ee]),zs=d.useCallback((o,s)=>{},[]),Ts=d.useCallback((o,s)=>{o.preventDefault(),lt({x:o.clientX,y:o.clientY,edgeId:s.id,relType:String(s.label??"edge")})},[]),Rs=d.useCallback((o,s)=>{var x,y,M,B,P,_;if(Date.now()<re.current)return;if((o==null?void 0:o.shiftKey)||(o==null?void 0:o.metaKey)||(o==null?void 0:o.ctrlKey)||((x=o==null?void 0:o.nativeEvent)==null?void 0:x.shiftKey)||((y=o==null?void 0:o.nativeEvent)==null?void 0:y.metaKey)||((M=o==null?void 0:o.nativeEvent)==null?void 0:M.ctrlKey)||((B=o==null?void 0:o.getModifierState)==null?void 0:B.call(o,"Shift"))||((P=o==null?void 0:o.getModifierState)==null?void 0:P.call(o,"Meta"))||((_=o==null?void 0:o.getModifierState)==null?void 0:_.call(o,"Control"))){window.setTimeout(()=>z($=>$.map(G=>({...G,selected:G.selected||G.id===a||G.id===s.id}))),0);return}if(s.type==="annotationNode")return;const u=s.type==="actionFlowLane"?s.data.inspectElementId:void 0;!u&&(s.id.startsWith("__")||s.id.includes("__start")||s.id.includes("__done"))||(w(u??s.id),l&&h({type:"diagram",diagramId:l}))},[w,l,h,a,z]),Ls=d.useCallback((o,s)=>{var c;if((c=o==null?void 0:o.stopPropagation)==null||c.call(o),L==="actionflow"){if(!Object.values((t==null?void 0:t.elements)??{}).some(x=>x.parentAction===s.id))return;wt(s.id);return}if(L==="statetransition"){const u=s.data;if(!u.hasChildren||u.isMachine){w(s.id);return}Ft(s.id);return}if(L==="interconnection"){const u=s.data;if(!u.isContainer&&!u.hasChildren){w(s.id);return}jt(s.id)}},[L,t==null?void 0:t.elements,w,wt,Ft,jt]),$s=d.useCallback(()=>{f(null),F(null),$e(null),lt(null),z(o=>o.map(s=>({...s,style:{...s.style,opacity:1,boxShadow:void 0}}))),S(o=>o.map(s=>s.selected?{...s,selected:!1}:s))},[f,F,z,S]),Ws=d.useCallback((o,s)=>{var c;(c=o==null?void 0:o.stopPropagation)==null||c.call(o),!(Date.now()<re.current)&&(S(u=>u.map(x=>({...x,selected:x.id===s.id}))),t!=null&&t.relationships.some(u=>u.id===s.id)?F(s.id):t!=null&&t.elements[s.id]&&w(s.id))},[t,w,F,S]),Os=d.useCallback((o,s)=>{et({endpointIds:[s.id]})},[]),Ps=d.useCallback((o,s)=>{et({edgeId:s.id,endpointIds:Vn(s)})},[]),rn=d.useCallback(()=>et(null),[]),Hs=d.useCallback((o,s)=>{var c;l&&(b(l,o,{...((c=A[l])==null?void 0:c.nodes[o])??{x:0,y:0},color:s||void 0}),z(u=>u.map(x=>x.id===o?{...x,data:{...x.data,bgColor:s||void 0}}:x)))},[l,A,b,z]),pe=d.useMemo(()=>H.filter(o=>o.selected&&o.type!=="actionFlowLane"&&!o.id.startsWith("__")),[H]),ze=d.useCallback(()=>pe.map(o=>{var s,c,u,x;return{id:o.id,x:o.position.x,y:o.position.y,width:Number(o.width??((s=o.measured)==null?void 0:s.width)??((c=o.style)==null?void 0:c.width)??180),height:Number(o.height??((u=o.measured)==null?void 0:u.height)??((x=o.style)==null?void 0:x.height)??96)}}),[pe]),Te=d.useCallback(o=>{o.size!==0&&(ee(),z(s=>s.map(c=>{const u=o.get(c.id);return u?{...c,position:{x:u.x??c.position.x,y:u.y??c.position.y},...u.width!==void 0?{width:u.width}:{},...u.height!==void 0?{height:u.height}:{},...u.width!==void 0||u.height!==void 0?{style:{...c.style,...u.width!==void 0?{width:u.width}:{},...u.height!==void 0?{height:u.height}:{}}}:{}}:c})),ye(s=>s+1))},[ee,z]),_s=d.useCallback(o=>{Te(Ui(ze(),o))},[Te,ze]),Ks=d.useCallback(o=>{Te(qi(ze(),o))},[Te,ze]),Vs=d.useCallback(o=>{Te(Zi(ze(),o))},[Te,ze]),an=d.useCallback(o=>{if(!l||pe.length===0)return;ee();const s=O.getState().diagramLayouts[l];for(const u of pe){const x=(s==null?void 0:s.nodes[u.id])??{x:u.position.x,y:u.position.y};b(l,u.id,{...x,...o.color!==void 0?{color:o.color||void 0}:{},...o.opacity!==void 0?{opacity:o.opacity}:{}})}const c=new Set(pe.map(u=>u.id));z(u=>u.map(x=>c.has(x.id)?{...x,data:{...x.data,...o.color!==void 0?{bgColor:o.color||void 0}:{},...o.opacity!==void 0?{fillOpacity:o.opacity}:{}}}:x)),ye(u=>u+1)},[l,pe,ee,b,z]),Ys=d.useMemo(()=>{const o=pe.map(s=>Number(s.data.fillOpacity??1));return o.length===0?1:o.every(s=>s===o[0])?o[0]:1},[pe]),ln=d.useCallback(o=>{if(!l||!g)return;const s=(g.elementIds??[]).filter(c=>c!==o);T(l,s),z(c=>c.filter(u=>u.id!==o))},[l,g,T,z]),Xs=d.useCallback((o,s)=>{const c=s==="dashed"?"6 3":s==="dotted"?"2 3":void 0;S(u=>u.map(x=>x.id===o?{...x,style:{...x.style,strokeDasharray:c}}:x))},[S]),Gs=d.useCallback((o,s)=>{S(c=>c.map(u=>u.id===o?{...u,style:{...u.style,stroke:s||(Cn[String(u.label??"")]??"#6B7280")}}:u))},[S]),Us=d.useCallback(o=>{S(s=>s.map(c=>c.id===o?{...c,label:c.label?"":o.split("_")[3]??""}:c))},[S]);if(g&&t&&L==="grid")return e.jsx($i,{diagram:g,model:t,viewpointFilter:U});if(g&&t&&L==="browser")return e.jsx(Wi,{diagram:g,model:t,viewpointFilter:U});if(g&&L==="geometry"){const o=En.geometry;return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"text-center",style:{maxWidth:"380px"},children:[e.jsx("span",{className:"inline-block px-2 py-0.5 rounded font-semibold",style:{background:o.color+"20",color:o.color,fontSize:D.badge,marginBottom:"12px"},children:o.label}),e.jsx("h3",{style:{fontSize:D.lg,fontWeight:600,color:"#374151",marginBottom:"8px"},children:g.name}),e.jsx("p",{style:{fontSize:D.md,color:"#9CA3AF",lineHeight:1.6},children:"Geometry View rendering is deferred (ADR-1-19): the ontology carries no spatial data to draw. This view is recognized and validated, but has no renderer yet."})]})})}return!g&&H.length===0&&!Z?e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!Re&&e.jsx(ao,{collapsed:Re,onToggleCollapse:()=>Lt(!0)}),Re&&e.jsx(ao,{collapsed:!0,onToggleCollapse:()=>Lt(!1)}),e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"text-center",style:{maxWidth:"320px"},children:[e.jsx("div",{style:{fontSize:"40px",marginBottom:"16px",opacity:.4},children:"📊"}),e.jsx("h3",{style:{fontSize:D.lg,fontWeight:600,color:"#374151",marginBottom:"8px"},children:"Select a Diagram"}),e.jsx("p",{style:{fontSize:D.md,color:"#9CA3AF",lineHeight:1.6},children:"Choose a diagram from the sidebar or drag elements from the palette."})]})})]}):e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx(ao,{collapsed:Re,onToggleCollapse:()=>Lt(!Re),elementIds:g==null?void 0:g.elementIds,eligibleKinds:(fn=g==null?void 0:g.elementKinds)!=null&&fn.length?new Set(g.elementKinds):g!=null&&g.viewpointId&&(t!=null&&t.viewpoints)?new Set(((mn=t.viewpoints.find(o=>o.id===g.viewpointId))==null?void 0:mn.visibleKinds)??[]):void 0}),e.jsxs("div",{className:"flex-1 relative",onDragOver:Ss,onDrop:vs,onDoubleClick:ks,children:[g&&e.jsxs("div",{className:"absolute top-3 left-3 z-10 flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs relative",style:{background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:[He&&e.jsx("span",{className:"px-1.5 py-0.5 rounded font-semibold",style:{background:He.color+"20",color:He.color,fontSize:D.badge},title:`${He.fullName}${Pe?` · ${Pe.fullName}`:""}`,children:L==="actionflow"?ps:He.label}),e.jsx("span",{className:"font-medium",style:{color:"#1a1a1a"},children:g.name}),g.auto&&e.jsx("span",{style:{color:"#9CA3AF",fontSize:"9px"},children:"auto"}),e.jsx(xe,{}),e.jsx(Je,{icon:e.jsx(Y.grid,{}),label:"Grid",active:vo,onClick:()=>{ns(o=>{const s=!o;return So(s),s})},title:"Show or hide the canvas grid and snapping (⌘⇧G)"}),ke&&e.jsxs(e.Fragment,{children:[e.jsx(xe,{}),e.jsx(ie,{icon:e.jsx(Y.expand,{}),onClick:Zt,title:"Expand all nodes",ariaLabel:"Expand all"}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),onClick:Qt,title:"Collapse all nodes",ariaLabel:"Collapse all"})]}),L==="actionflow"&&e.jsxs(e.Fragment,{children:[e.jsx(Je,{icon:e.jsx(Y.lanes,{}),active:Ke,onClick:()=>$o(o=>!o),title:"Toggle allocation swimlanes"}),Ke&&us&&e.jsx(Je,{icon:e.jsx(Y.lanes,{}),label:"Stage",active:rt==="stage",onClick:()=>ko(o=>o==="stage"?"allocation":"stage"),title:"Group this flow by its modeled stages"}),Ke&&rt==="allocation"&&Wo.length>0&&e.jsxs("select",{"aria-label":"Display hierarchy level",title:"Display responsibility lanes at a hierarchy level; the SysML allocation is unchanged",value:Wt,onChange:o=>Co(o.target.value==="all"?"all":Number(o.target.value)),className:"text-xs font-semibold rounded-lg px-2 py-1",style:{color:"#5B6470",background:"#FFFFFF",border:"1px solid #E2E1DB"},children:[e.jsx("option",{value:"all",children:"All levels"}),Wo.map(o=>e.jsxs("option",{value:o,children:["L",o]},o))]}),e.jsx(xe,{}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:D.xs,fontWeight:600},children:"Steps"}),e.jsx(Nt,{value:Gt,onChange:Yo,options:[{value:"flat",label:"Inline",title:"Expanded steps join the parent flow in place"},{value:"nested",label:"Nested",title:"Expanded steps are drawn inside their composite action (swimlanes off)"}]}),e.jsx(xe,{}),e.jsx(Nt,{value:$t,onChange:ss,options:[{value:"horizontal",icon:e.jsx(Y.arrowRight,{}),title:"Left-to-right flow"},{value:"vertical",icon:e.jsx(Y.arrowDown,{}),title:"Top-to-bottom flow"}]}),e.jsx(xe,{}),e.jsxs(qr,{children:[e.jsx(ie,{icon:e.jsx(Y.expand,{}),title:"Expand all sub-actions",onClick:()=>Ue(new Set(Object.values((t==null?void 0:t.elements)??{}).map(o=>o.parentAction).filter(o=>!!o)))}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),title:"Collapse all sub-actions",onClick:()=>Ue(new Set)})]}),e.jsx(xe,{}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Je,{icon:e.jsx(Y.filter,{}),active:Eo,badge:`${be.size}/4`,onClick:()=>is(o=>!o),title:"Choose which modeled connection categories are visible"}),Eo&&e.jsxs("div",{className:"absolute top-full right-0 mt-2 p-3 rounded-lg",style:{width:264,background:"#FFFFFF",border:"1px solid #D1D5DB",boxShadow:"0 8px 24px rgba(0,0,0,0.14)",zIndex:30},children:[e.jsx("div",{style:{color:"#1F2937",fontWeight:700,fontSize:D.xs},children:"Show connection categories"}),e.jsx("div",{style:{color:"#6B7280",fontSize:D.xs,lineHeight:1.4,marginTop:3,marginBottom:8},children:"Changes this diagram view only; the SysML model is not modified."}),["control","data","energy","material"].map(o=>{const s=be.has(o),c=o==="control"?"#4B5563":o==="data"?"#3498DB":o==="energy"?"#D97706":"#16A34A";return e.jsxs("button",{role:"switch","aria-checked":s,onClick:()=>rs(u=>{const x=new Set(u);return x.has(o)?x.delete(o):x.add(o),x}),className:"w-full flex items-center justify-between px-1 py-1.5 rounded",style:{color:"#374151",textTransform:"capitalize"},title:`${s?"Hide":"Show"} ${o} connections`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:c}}),o]}),e.jsx("span",{"aria-hidden":"true",style:{width:32,height:18,borderRadius:9,background:s?"#2563EB":"#D1D5DB",padding:2,transition:"background 160ms ease"},children:e.jsx("span",{style:{display:"block",width:14,height:14,borderRadius:"50%",background:"#FFFFFF",boxShadow:"0 1px 2px rgba(0,0,0,0.22)",transform:s?"translateX(14px)":"translateX(0)",transition:"transform 160ms ease"}})})]},o)})]})]}),e.jsx(co,{path:ms,nameOf:o=>{var s;return((s=t==null?void 0:t.elements[o])==null?void 0:s.name)??o},onFocus:Xt,rootLabel:"Back to the whole action flow"})]}),L==="interconnection"&&e.jsxs(e.Fragment,{children:[e.jsx(xe,{}),e.jsx(ie,{icon:e.jsx(Y.expand,{}),onClick:()=>Xe(new Set),title:"Expand all parts",ariaLabel:"Expand all"}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),onClick:()=>Xe(new Set(ys)),title:"Collapse all parts",ariaLabel:"Collapse all"}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:D.xs,fontWeight:600},children:"Ports"}),e.jsx(Nt,{value:Ge,onChange:Po,options:[{value:"all",label:"Nested",title:"Show ports and their nested ports"},{value:"ports",label:"Top",title:"Show top-level ports only (nested connectors lift to the parent port)"},{value:"none",label:"Off",title:"Hide ports; connectors run part to part"}]}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:D.xs,fontWeight:600},children:"Connections"}),e.jsx(Nt,{value:Yt,onChange:Ho,options:[{value:"summary",label:"Summary",title:"Show focused-subsystem boundary flows and bundle repeated rendered endpoint pairs"},{value:"all",label:"All",title:"Show every model connector"},{value:"none",label:"Off",title:"Hide connectors while inspecting block structure"}]}),e.jsx(co,{path:gs,nameOf:o=>{var s;return((s=t==null?void 0:t.elements[o])==null?void 0:s.name)??o},onFocus:Vt,rootLabel:"Back to the whole diagram"})]}),L==="statetransition"&&e.jsxs(e.Fragment,{children:[e.jsx(xe,{}),e.jsx(ie,{icon:e.jsx(Y.expand,{}),onClick:()=>qe(new Set),title:"Show all substates",ariaLabel:"Expand all substates"}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),onClick:()=>qe(new Set(yt)),title:"Fold every composite state",ariaLabel:"Collapse all substates"}),e.jsx(co,{path:fs,nameOf:o=>{var s;return((s=t==null?void 0:t.elements[o])==null?void 0:s.name)??o},onFocus:Ut,rootLabel:"Back to the whole machine"})]}),Pt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsxs("label",{className:"flex items-center gap-1 text-xs font-semibold",style:{color:"#475569"},children:["Level",e.jsxs("select",{"aria-label":"Use case hierarchy level",value:Ht,onChange:o=>zo(o.target.value==="all"?"all":Number(o.target.value)),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{color:"#374151",background:"#FFFFFF",border:"1px solid #D1D5DB"},children:[e.jsx("option",{value:"all",children:"All levels"}),Array.from({length:cs+1},(o,s)=>e.jsxs("option",{value:s,children:["L",s]},s))]})]}),e.jsxs("label",{className:"flex items-center gap-1 text-xs font-semibold",style:{color:"#475569"},children:["Routing",e.jsxs("select",{"aria-label":"Use case connector routing",value:_t,onChange:o=>To(o.target.value),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{color:"#374151",background:"#FFFFFF",border:"1px solid #D1D5DB"},children:[e.jsx("option",{value:"straight",children:"Straight"}),e.jsx("option",{value:"elbow",children:"Elbow"}),e.jsx("option",{value:"rounded",children:"Rounded"}),e.jsx("option",{value:"curved",children:"Curved"}),e.jsx("option",{value:"arc",children:"Arc"})]})]}),e.jsx("button",{onClick:js,className:"px-2 py-0.5 text-xs font-semibold rounded",style:{color:"#047857",background:"#ECFDF5",border:"1px solid #A7F3D0"},title:"Reapply the constrained hierarchy layout and obstacle-aware routes",children:"Auto arrange"}),Lo.length>0&&e.jsxs("details",{className:"relative",children:[e.jsxs("summary",{className:"px-2 py-0.5 text-xs font-semibold rounded cursor-pointer",style:{color:"#374151",background:"#FFFFFF",border:"1px solid #D1D5DB"},children:["Actors",_e.size?`: ${_e.size} hidden`:""]}),e.jsxs("div",{className:"absolute top-7 left-0 z-30 min-w-48 p-2 rounded shadow-lg",style:{background:"#FFFFFF",border:"1px solid #D1D5DB"},children:[e.jsx("div",{className:"mb-1 text-xs",style:{color:"#64748B"},children:"Hide related use cases"}),Lo.map(o=>e.jsxs("label",{className:"flex items-center gap-2 py-1 text-xs",style:{color:"#374151"},children:[e.jsx("input",{type:"checkbox",checked:_e.has(o.id),onChange:()=>Ro(s=>{const c=new Set(s);return c.has(o.id)?c.delete(o.id):c.add(o.id),c})}),o.name]},o.id))]})]})]}),Me&&!Pt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #E5E5E0"},children:ds.map(o=>e.jsx("button",{onClick:()=>{Bo(o),de.current.clear()},className:"px-2 py-0.5 text-xs font-medium capitalize",style:{background:De===o?"#1B3A4B":"#FFFFFF",color:De===o?"#FFFFFF":"#6B7280"},title:o==="graph"?"Relationship graph with compartments":o==="tree"?"Decomposition tree with expand/collapse":"Nested containment blocks",children:o},o))}),De!=="graph"&&e.jsxs(e.Fragment,{children:[e.jsx(ie,{icon:e.jsx(Y.expand,{}),onClick:Zt,title:"Expand all nodes",ariaLabel:"Expand all"}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),onClick:Qt,title:"Collapse all nodes",ariaLabel:"Collapse all"}),De==="tree"&&e.jsx("button",{onClick:Jt,className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#374151",border:"1px solid #E5E5E0"},title:"Re-layout the tree from scratch",children:"↻ Reset"})]})]}),pt&&!ke&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #E5E5E0"},children:["containment","decomposition"].map(o=>e.jsx("button",{onClick:()=>{hs(o),de.current.clear()},className:"px-2 py-0.5 text-xs font-medium",style:{background:Ve===o?"#1B3A4B":"#FFFFFF",color:Ve===o?"#FFFFFF":"#6B7280"},children:o==="containment"?"Containment":"Decomposition"},o))}),e.jsx(xe,{}),e.jsx(ie,{icon:e.jsx(Y.expand,{}),onClick:Zt,title:"Expand all nodes",ariaLabel:"Expand all"}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),onClick:Qt,title:"Collapse all nodes",ariaLabel:"Collapse all"}),Ve==="decomposition"&&e.jsx("button",{onClick:Jt,className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#374151",border:"1px solid #E5E5E0"},title:"Re-layout the tree from scratch",children:"↻ Reset"})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),!Pt&&e.jsxs("button",{"aria-pressed":me,onClick:()=>{if(me)ee();else{const o=O.getState().diagramLayouts[l],s={nodes:{},edges:{},canvas:{...o==null?void 0:o.canvas,autoLayout:!0}};v({[l]:s}),je(l,s),Rt(c=>c+1)}},className:"px-2 py-0.5 text-xs font-semibold rounded",style:{background:me?"#ECFDF5":"#FFF7ED",color:me?"#047857":"#C2410C",border:`1px solid ${me?"#A7F3D0":"#FED7AA"}`},title:me?"Auto layout is on. Drag any item to switch it off and preserve your changes automatically.":"Auto layout is off. Your changes are saved automatically; click to discard overrides and recalculate.",children:["Auto layout: ",me?"On":"Off"]})]}),l&&L==="interconnection"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #CBD5E1"},children:["note","text","constraint"].map(o=>e.jsxs("button",{onClick:()=>ls(o),className:"px-2 py-0.5 text-xs font-medium capitalize",style:{background:"#FFFFFF",color:"#475569",border:0},title:`Add an editable ${o} annotation to this IBD`,children:["+ ",o]},o))}),e.jsxs("button",{"aria-pressed":we,onClick:()=>{const o=O.getState().diagramLayouts[l]??{nodes:{},edges:{}},s={...o,canvas:{...o.canvas,flowAnimation:!we}};v({[l]:s}),je(l,s),S(c=>c.map(u=>({...u,data:{...u.data,flowAnimation:!we}})))},className:"px-2 py-0.5 text-xs font-semibold rounded",style:{background:we?"#EFF6FF":"#F8FAFC",color:we?"#1D4ED8":"#64748B",border:`1px solid ${we?"#93C5FD":"#CBD5E1"}`},title:"Toggle animated source-to-target flow on IBD connectors",children:["Flow: ",we?"On":"Off"]}),e.jsx("button",{"aria-pressed":_o,onClick:()=>Ko(o=>!o),className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F8FAFC",color:"#475569",border:"1px solid #CBD5E1"},title:"Show or hide the IBD notation legend",children:"Legend"})]})]}),We&&e.jsxs("div",{className:"absolute top-3 right-3 z-10 flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs",style:{background:"#1B3A4B",color:"#FFFFFF",boxShadow:"0 2px 8px rgba(0,0,0,0.18)"},children:[e.jsx("span",{style:{color:"#2DD4A8",fontWeight:700},children:"◎ Focus"}),e.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Depth"}),[1,2,3].map(o=>e.jsx("button",{onClick:()=>as(o),style:{width:20,height:20,borderRadius:4,cursor:"pointer",background:ct===o?"#2DD4A8":"rgba(255,255,255,0.15)",color:ct===o?"#1B3A4B":"#FFFFFF",fontWeight:700,fontSize:"11px",border:"none"},children:o},o)),e.jsx("button",{onClick:()=>{Io(null),z(o=>o.map(s=>({...s,style:{...s.style,opacity:1,pointerEvents:"all"}}))),S(o=>o.map(s=>({...s,style:{...s.style,opacity:1}})))},style:{marginLeft:4,padding:"2px 8px",borderRadius:4,cursor:"pointer",background:"rgba(255,255,255,0.15)",color:"#FFFFFF",fontSize:"11px",border:"none"},children:"Exit Focus"})]}),dt&&e.jsxs("div",{className:"absolute bottom-12 left-1/2 -translate-x-1/2 z-50 px-4 py-2 rounded-lg text-xs font-mono",style:{background:"#1B3A4B",color:"#2DD4A8",boxShadow:"0 4px 16px rgba(0,0,0,0.2)",whiteSpace:"nowrap"},children:["Copied: ",dt]}),Z&&e.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-10 px-4 py-1.5 rounded-full text-xs font-medium",style:{background:"#FFFFFF",color:"#6B7280",border:"1px solid #E5E5E0",boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:"Computing layout…"}),Fo&&!Z&&e.jsxs("div",{role:"alert",className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 flex items-center gap-3 px-3 py-2",style:{maxWidth:620,background:"#FFFDF7",color:"#5F4300",border:"1px solid #E7C35A",borderRadius:4,boxShadow:"0 2px 8px rgba(31,41,55,0.10)",fontSize:D.xs},children:[e.jsx("span",{children:Fo}),e.jsx("button",{onClick:Jt,style:{border:"1px solid #B58A12",borderRadius:3,background:"#FFFFFF",color:"#5F4300",padding:"3px 8px",fontWeight:700,whiteSpace:"nowrap"},children:"Retry"})]}),ht.length>0&&!Z&&e.jsxs("div",{role:"alert",className:"absolute top-16 left-1/2 -translate-x-1/2 z-20 px-3 py-2",style:{maxWidth:720,background:"#FEF2F2",color:"#991B1B",border:"1px solid #FCA5A5",borderRadius:4,boxShadow:"0 2px 8px rgba(31,41,55,0.10)",fontSize:D.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"Diagram error:"})," ",ht.length," floating ",ht.length===1?"action has":"actions have"," no flow or succession connection:"," ",ht.map((o,s)=>e.jsxs("span",{children:[s>0&&", ",e.jsx("button",{onClick:()=>w(o.id),style:{color:"#991B1B",textDecoration:"underline",fontWeight:700},children:o.name})]},o.id))]}),bt&&!Z&&e.jsxs("div",{role:"alert",className:"absolute top-16 left-1/2 -translate-x-1/2 z-20 px-3 py-2",style:{maxWidth:720,background:"#FEF2F2",color:"#991B1B",border:"1px solid #FCA5A5",borderRadius:4,boxShadow:"0 2px 8px rgba(31,41,55,0.10)",fontSize:D.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"BDD error:"})," ","expected one connected hierarchy, but found ",bt.rootIds.length," roots",bt.disconnectedIds.length>0&&e.jsxs(e.Fragment,{children:[" and ",bt.disconnectedIds.length," disconnected/floating elements"]}),"."]}),L==="actionflow"&&e.jsxs("div",{"aria-label":"Action flow legend",className:"absolute right-3 bottom-3 z-10 flex items-center gap-4 px-3 py-2",style:{background:"rgba(255,255,255,0.96)",border:"1px solid #D1D5DB",borderRadius:3,color:"#374151",fontSize:D.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"Legend"}),be.has("control")&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:24,height:0,borderTop:"2px solid #4B5563"}}),"Control flow"]}),be.has("data")&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #3498DB"}}),"Object flow"]}),be.has("energy")&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #D97706"}}),"Energy flow"]}),be.has("material")&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #16A34A"}}),"Material flow"]})]}),L==="interconnection"&&H.length>0&&_o&&e.jsxs("div",{"aria-label":"Interconnection legend",className:"absolute right-3 bottom-3 z-10 flex flex-col gap-1.5 px-3 py-2",style:{background:"rgba(255,255,255,0.96)",border:"1px solid #D1D5DB",borderRadius:4,color:"#374151",fontSize:D.xs},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{style:{fontWeight:700},children:"Ports"}),Ge!=="none"?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(lo,{color:At.in,glyph:"→"})," in"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(lo,{color:At.out,glyph:"→"})," out"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(lo,{color:At.inout,glyph:"⇄"})," inout"]}),Ge==="all"&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{width:9,height:9,borderRadius:2,flexShrink:0,background:"#6B728022",border:"1.5px solid #6B7280"}}),"nested"]})]}):e.jsx("span",{style:{color:"#9CA3AF"},children:"hidden"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{style:{fontWeight:700},children:"Flow"}),["data","energy","material"].map(o=>e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:20,height:0,borderTop:`2.5px solid ${Oi[o]}`}}),o]},o))]})]}),!Z&&H.length===0&&g&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",style:{zIndex:1},children:g.auto&&((yn=g.elementIds)==null?void 0:yn.length)===0?e.jsxs("div",{className:"text-center",style:{maxWidth:420},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:8},children:"🔍"}),e.jsx("div",{style:{fontSize:D.sm,color:"#374151",fontWeight:600,marginBottom:4},children:"This view selects no elements"}),e.jsx("div",{style:{fontSize:D.xs,color:"#6B7280",lineHeight:1.6},children:"The view is auto-populated from its selectionQuery in the model. Add includeElementKinds / includeLayers to its SysML definition, or link elements to it with IncludedIn relationships."})]}):e.jsxs("div",{className:"text-center",style:{opacity:.4},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:8},children:"🖱️"}),e.jsx("div",{style:{fontSize:D.sm,color:"#6B7280"},children:"Drag from palette or double-click to create elements"})]})}),pe.length>=2&&e.jsx(Xi,{count:pe.length,opacity:Ys,onAlign:_s,onMatchSize:Ks,onDistribute:Vs,onFill:o=>an({color:o}),onOpacity:o=>an({opacity:o})}),Z&&e.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",zIndex:20,background:`linear-gradient(90deg, ${In.accent} 0%, ${In.accent}80 50%, transparent 100%)`,backgroundSize:"200% 100%",animation:"memo-layout-progress 1.2s linear infinite"}}),e.jsxs(ni,{nodes:H,edges:q,nodeTypes:bs,edgeTypes:Fs,onNodesChange:Bs,onEdgesChange:te,onNodeClick:Rs,onNodeDoubleClick:Ls,onEdgeClick:Ws,onPaneClick:$s,onNodeDragStart:As,onNodeDragStop:Ms,onNodeContextMenu:zs,onEdgeContextMenu:Ts,onNodeMouseEnter:Os,onNodeMouseLeave:rn,onEdgeMouseEnter:Ps,onEdgeMouseLeave:rn,onConnect:Ds,onConnectStart:Es,onConnectEnd:Is,connectionMode:si.Loose,defaultEdgeOptions:{interactionWidth:24},snapToGrid:os,snapGrid:oa,fitView:!0,fitViewOptions:{...Jr,minZoom:Ie},minZoom:.1,maxZoom:3,zoomOnScroll:!0,panOnScroll:!0,panOnScrollMode:"free",selectionOnDrag:!0,panOnDrag:[1,2],multiSelectionKeyCode:["Shift","Meta","Control"],selectionKeyCode:null,proOptions:ta,style:Qr,children:[vo&&e.jsx(ii,{color:"#C5C7C2",gap:20,size:1.5}),e.jsx(tr,{}),e.jsx(ri,{}),H.length>20&&e.jsx(ai,{style:ea,nodeColor:ws,maskColor:"rgba(247, 247, 245, 0.7)"})]})]}),se&&e.jsx(aa,{x:se.x,y:se.y,onConfirm:Cs,onCancel:()=>Le(null)}),Fe&&e.jsx(Pi,{x:Fe.x,y:Fe.y,sourceElement:Fe.sourceElement,targetElement:Fe.targetElement,registries:n,allowedTypes:g==null?void 0:g.relationshipTypes,onSelect:Ns,onCancel:()=>at(null)}),J&&e.jsx(Hr,{x:J.x,y:J.y,nodeId:J.nodeId,nodeKind:J.nodeKind,onClose:()=>$e(null),onEditName:()=>{z(o=>o.map(s=>s.id===J.nodeId?{...s,data:{...s.data,_triggerEdit:!0}}:s))},onChangeColor:o=>Hs(J.nodeId,o),onRemoveFromDiagram:()=>ln(J.nodeId),onDeleteFromModel:()=>{ln(J.nodeId)},onShowProperties:()=>{f(J.nodeId)},onShowInCatalog:()=>{f(J.nodeId),I("catalog")},onFocusElement:()=>{Io(J.nodeId)},onShowRelMatrix:()=>{h({type:"traceability"})},onOpenSource:()=>{const o=t==null?void 0:t.elements[J.nodeId];o!=null&&o.file&&(navigator.clipboard.writeText(o.file).catch(()=>{}),Do(o.file))},onViewKindInOntology:()=>{const o=J.nodeKind;let s=null,c=null;for(const u of j){for(const x of u.layers)if(x.kinds.some(y=>y.name===o)){s=u.name,c=x.id;break}if(s)break}s&&(m(o),C("ontologies"),I("ontology"),h({type:"ontology-detail",packageName:s,layerId:c??void 0}))}}),fe&&e.jsx(Kr,{x:fe.x,y:fe.y,edgeId:fe.edgeId,relType:fe.relType,onClose:()=>lt(null),onChangeStyle:o=>Xs(fe.edgeId,o),onChangeColor:o=>Gs(fe.edgeId,o),onToggleLabel:()=>Us(fe.edgeId),onDelete:()=>S(o=>o.filter(s=>s.id!==fe.edgeId))})]})}function ya(){return e.jsx(Qs,{children:e.jsx(la,{})})}export{ya as DiagramCanvas};
@@ -1,4 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiagramCanvas-B9d4aLKt.js","assets/reactflow-CsCqNKB-.js","assets/zustand-CrhqMOHB.js","assets/index-CVW92JY7.js","assets/index-Y1UZTZg-.css","assets/layout-selection-ClQ295Xc.js","assets/layout-providers-Dr743WlP.js","assets/elk-6l8mIQnQ.js","assets/style-BZV40eAE.css","assets/MaxGraphCanvas-DqKU1PTY.js","assets/SysmlCodeEditor-Die2RUsz.js","assets/SysmlCodeEditor-BwKcXIZw.css"])))=>i.map(i=>d[i]);
2
- var fe=Object.defineProperty;var me=(t,s,i)=>s in t?fe(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i;var B=(t,s,i)=>me(t,typeof s!="symbol"?s+"":s,i);import{_ as P,u as C,g as xe,a as he,l as pe,s as ge,b as ve,c as Se,F as d,C as a,d as ye,L as be,e as Ee,f as Fe}from"./index-CVW92JY7.js";import{j as e}from"./reactflow-CsCqNKB-.js";import{a as r}from"./zustand-CrhqMOHB.js";const V="memo.renderer.reactflow";class we{constructor(){B(this,"providers",new Map);B(this,"components",new Map)}register(s){const i=this.providers.get(s.descriptor.id);if(i&&i!==s)throw new Error(`Renderer provider already registered: ${s.descriptor.id}`);this.providers.set(s.descriptor.id,s)}unregister(s){return this.components.delete(s),this.providers.delete(s)}get(s){return this.providers.get(s)}has(s){return this.providers.has(s)}list(s=[]){return[...this.providers.values()].map(i=>i.descriptor).filter(i=>s.every(o=>i.capabilities.includes(o))).sort((i,o)=>i.name.localeCompare(o.name))}loadComponent(s){const i=this.providers.get(s)??this.providers.get(V);if(!i)throw new Error(`Renderer provider not found: ${s} (no default registered)`);const o=i.descriptor.id;let n=this.components.get(o);return n||(n=i.loadComponent(),this.components.set(o,n)),n}}const Re={descriptor:{id:"memo.renderer.reactflow",name:"ReactFlow",engine:"ReactFlow (@xyflow/react 12)",version:"12",contractVersion:"1",license:"MIT",description:"Default authoring canvas — React node components, palette, full editing.",capabilities:["interactive-editing","all-view-kinds","manual-layout","undo-redo","minimap","orthogonal-routes"]},loadComponent:()=>P(()=>import("./DiagramCanvas-B9d4aLKt.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(t=>t.DiagramCanvas)},je={descriptor:{id:"memo.renderer.maxgraph",name:"maxGraph",engine:"maxGraph (@maxgraph/core — draw.io rendering engine lineage)",version:"0.x",contractVersion:"1",license:"Apache-2.0",description:"draw.io-style retained-mode canvas — SVG cells, rubberband selection, image export.",capabilities:["all-view-kinds","manual-layout","export-image"]},loadComponent:()=>P(()=>import("./MaxGraphCanvas-DqKU1PTY.js"),__vite__mapDeps([9,1,2,3,4,5,6,7])).then(t=>t.MaxGraphCanvas)},$=new we;$.register(Re);$.register(je);const Ce={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Ae="memo.diagram.renderer.v3",_e="renderer",ke="memo.renderer.",se=new Set;function G(t){const s=t==null?void 0:t.trim();if(s)return s.includes(".")?s:`${ke}${s}`}function De(){if(!(typeof window>"u"))try{return G(new URLSearchParams(window.location.search).get(_e))}catch{return}}function Te(){if(!(typeof window>"u"))try{return G(window.localStorage.getItem(Ae))}catch{return}}function Le(){try{const t=Ce;return G(t==null?void 0:t.VITE_MEMO_DIAGRAM_RENDERER)}catch{return}}function re(){return De()??Te()??Le()??V}function Me(t){return se.add(t),()=>se.delete(t)}function Ne(){return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5",color:"#9CA3AF",fontSize:13},children:"Loading renderer…"})}function ze(){const t=r.useSyncExternalStore(Me,re,re),s=$.has(t)?t:V,i=r.useMemo(()=>r.lazy(()=>$.loadComponent(s).then(o=>({default:o}))),[s]);return e.jsx("div",{className:"relative flex flex-1 overflow-hidden",children:e.jsx(r.Suspense,{fallback:e.jsx(Ne,{}),children:e.jsx(i,{})})})}const $e=r.lazy(()=>P(()=>import("./SysmlCodeEditor-Die2RUsz.js"),__vite__mapDeps([10,1,2,11])).then(t=>({default:t.SysmlCodeEditor})));function Oe(t,s){const i=(t.elementIds??[]).map(o=>s[o]).filter(Boolean).map(o=>` ${o.construct??"part"} ${o.id} : ${o.kind};`).join(`
3
- `);return[`package '${t.name}' {`,` // Diagram: ${t.diagramType.toUpperCase()} | Viewpoint: ${t.viewpointId}`,i||" // No elements selected","}"].join(`
4
- `)}function Ie({diagram:t}){const s=C(c=>c.model),i=C(c=>c.updateDiagramElementIds),[o,n]=r.useState(""),m=r.useMemo(()=>ye(s),[s]),O=r.useCallback(c=>{const x=new Set(t.elementIds??[]);x.has(c)?x.delete(c):x.add(c),i(t.id,[...x])},[t.id,t.elementIds,i]),w=r.useMemo(()=>new Set(t.elementIds??[]),[t.elementIds]),E=be.filter(c=>m.has(c));return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",style:{width:"220px",borderLeft:`1px solid ${a.border}`,background:"#FAFAF8",flexShrink:0},children:[e.jsxs("div",{className:"px-2 py-1.5",style:{borderBottom:`1px solid ${a.border}`},children:[e.jsxs("div",{className:"font-semibold mb-1",style:{color:a.primary,fontSize:d.xs},children:["Elements (",w.size," selected)"]}),e.jsx("input",{value:o,onChange:c=>n(c.target.value),placeholder:"Filter…",className:"w-full px-2 py-1 rounded focus:outline-none",style:{background:"#F0F0ED",border:`1px solid ${a.border}`,color:a.primary,fontSize:d.xs}})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:E.map(c=>{const x=(m.get(c)??[]).filter(u=>!o||u.name.toLowerCase().includes(o.toLowerCase())||u.id.toLowerCase().includes(o.toLowerCase()));if(x.length===0)return null;const I=Fe[c]??a.muted;return e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1 font-semibold",style:{color:I,fontSize:d.badge},children:Ee[c]??c}),x.map(u=>e.jsxs("label",{className:"flex items-center gap-2 px-3 py-0.5 cursor-pointer",style:{fontSize:d.xs},onMouseEnter:h=>h.currentTarget.style.background="#F0F0ED",onMouseLeave:h=>h.currentTarget.style.background="transparent",children:[e.jsx("input",{type:"checkbox",checked:w.has(u.id),onChange:()=>O(u.id),style:{accentColor:a.accent}}),e.jsx("span",{className:"truncate",style:{color:a.primary},title:u.id,children:u.name||u.id})]},u.id))]},c)})})]})}function ne({tone:t,message:s,actions:i}){const o=t==="conflict";return e.jsxs("div",{role:"alert",className:"flex items-center gap-2 px-3 py-1.5 flex-wrap",style:{background:o?"#FEF2F2":"#FFFBEB",borderBottom:`1px solid ${o?"#FECACA":"#FDE68A"}`,color:o?"#B91C1C":"#92400E",fontSize:d.xs,flexShrink:0},children:[e.jsx("span",{className:"flex-1",style:{minWidth:180},children:s}),i.map(n=>e.jsx("button",{onClick:n.onClick,title:n.hint,style:{fontSize:d.xs,padding:"2px 8px",borderRadius:5,cursor:"pointer",background:"#FFFFFF",border:`1px solid ${o?"#FECACA":"#FDE68A"}`,color:"inherit",fontWeight:600,whiteSpace:"nowrap"},children:n.label},n.label))]})}const Be=4e3;function Pe({at:t}){const[s,i]=r.useState(!1);return r.useEffect(()=>{if(!t)return;i(!0);const o=setTimeout(()=>i(!1),Be);return()=>clearTimeout(o)},[t]),s?e.jsx("span",{title:"A source file this view depends on changed; the view was rebuilt",style:{fontSize:d.badge,padding:"1px 6px",borderRadius:999,background:"#ECFDF5",color:"#047857",border:"1px solid #A7F3D0",whiteSpace:"nowrap"},children:"↻ Refreshed from source"}):null}const Ve=[];function We({diagramId:t}){const s=C(l=>l.model),i=C(l=>l.diagramParseErrors[t]??Ve),o=C(l=>l.lastSourceChange),n=xe(s,t),[m,O]=r.useState("visual"),[w,E]=r.useState(""),[c,x]=r.useState(!1),[I,u]=r.useState(!1),[h,Y]=r.useState(!1),[p,A]=r.useState(!1),[R,y]=r.useState(null),[oe,q]=r.useState(null),[_,j]=r.useState(null),[k,D]=r.useState(null),[ie,le]=r.useState(null),[U,W]=r.useState([]),[T,ae]=r.useState(()=>localStorage.getItem("memo.diagramEditor.autoSave")==="true"),b=r.useRef(),v=r.useRef(""),K=r.useRef(0),L=r.useRef(void 0),M=r.useRef(0),H=r.useRef(!1);r.useEffect(()=>{H.current=p},[p]);const Q=r.useMemo(()=>he(s,t),[s,t]),N=r.useCallback(async()=>{const l=++M.current,g=t;x(!0);try{const S=await pe(g);if(M.current!==l)return!1;const f=S.text??"";return v.current=f,L.current=S.revision,E(f),u(!0),A(!1),y(null),D(null),j(null),!0}catch(S){return M.current===l&&y(S instanceof Error?S.message:String(S)),!1}finally{M.current===l&&x(!1)}},[t]);r.useEffect(()=>{if(clearTimeout(b.current),y(null),q(null),A(!1),j(null),D(null),W([]),L.current=void 0,!(!n||!s)){if(!n.sourceFile||window.__MEMO_DATA__){const l=Oe(n,s.elements);v.current=l,E(l),x(!1),u(!1);return}E(""),v.current="",u(!1),N()}},[t,n==null?void 0:n.sourceFile]),r.useEffect(()=>{if(!o||!(n!=null&&n.sourceFile)||window.__MEMO_DATA__||!ge(o,Q))return;le(o.at);const l=o.files.includes(n.sourceFile);if(l){if(H.current){j({files:o.files.filter(g=>Q.includes(g)),at:o.at,touchesOwnSource:l});return}N()}},[o==null?void 0:o.seq]);const ce=l=>{v.current=l,E(l),A(!0),y(null)},F=r.useCallback(async(l,g)=>{if(!n)return;const S=++K.current;Y(!0),y(null);try{if(n.sourceFile){const f=await ve(t,l,g!=null&&g.force?void 0:L.current);if(f.conflict){D({theirs:f.text??"",revision:f.revision,at:Date.now()}),y(f.error??"The file changed on disk since this edit began.");return}L.current=f.revision,D(null),j(null),W(f.parseErrors??[])}else Se(t,l);v.current===l&&A(!1),q(Date.now())}catch(f){y(f instanceof Error?f.message:String(f))}finally{K.current===S&&Y(!1)}},[n,t]),X=r.useCallback(()=>{clearTimeout(b.current),N()},[N]),de=r.useCallback(()=>{clearTimeout(b.current),F(v.current,{force:!0})},[F]);r.useEffect(()=>(localStorage.setItem("memo.diagramEditor.autoSave",String(T)),clearTimeout(b.current),T&&p&&!c&&!k&&(b.current=setTimeout(()=>void F(v.current),800)),()=>clearTimeout(b.current)),[T,p,c,w,F,k]);const J=r.useCallback(()=>{clearTimeout(b.current),F(v.current)},[F]),ue=r.useMemo(()=>Object.values((s==null?void 0:s.elements)??{}).map(l=>({id:l.id,name:l.name,kind:l.kind})),[s==null?void 0:s.elements]);if(!n)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:a.faint,fontSize:d.sm},children:"Diagram not found"});const Z=n.auto,z=!Z||!!n.sourceFile&&I,ee=e.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden",children:[k&&e.jsx(ne,{tone:"conflict",message:`${n.sourceFile} changed on disk while you were editing. Saving now would discard those changes.`,actions:[{label:"Reload from disk",onClick:X,hint:"Discards your unsaved edits"},{label:"Overwrite with mine",onClick:de,hint:"Discards the changes on disk"}]}),!k&&_&&e.jsx(ne,{tone:"notice",message:_.files.length>1?`${_.files.length} source files changed on disk. Your unsaved edits are untouched.`:`${_.files[0]} changed on disk. Your unsaved edits are untouched.`,actions:[{label:"Reload from disk",onClick:X,hint:"Discards your unsaved edits"},{label:"Keep editing",onClick:()=>j(null),hint:"Dismiss until the next change"}]}),e.jsx("div",{className:"flex-1 overflow-hidden",style:{background:"#1E1E1E"},children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"h-full flex items-center justify-center",style:{color:"#9CA3AF",fontSize:d.xs},children:"Loading SysML editor…"}),children:e.jsx($e,{value:w,sourceFile:n.sourceFile,readOnly:!z||c,symbols:ue,onChange:ce,onSave:()=>{z&&p&&J()}})})}),U.length>0&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C1407",color:"#FCD34D",borderTop:"1px solid #3B2A0A",fontFamily:"monospace"},title:"Saved, but the file does not parse — the model keeps its last good state for this file",children:U.join(" · ")}),i.length>0&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C0A0A",color:"#F87171",borderTop:"1px solid #3B0A0A",fontFamily:"monospace"},children:i.join(" · ")}),R&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C0A0A",color:"#FCA5A5",borderTop:"1px solid #3B0A0A"},children:R}),!z&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#F9F9F8",color:a.faint,borderTop:`1px solid ${a.border}`},children:n.sourceFile&&window.__MEMO_DATA__?"Static build — run memo-architect dev to edit the SysML source":n.sourceFile?"The SysML source could not be loaded":"Generated model view — no editable SysML source file"})]}),te=e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:e.jsx(ze,{})}),!Z&&e.jsx(Ie,{diagram:n})]});return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5",style:{borderBottom:`1px solid ${a.border}`,background:"#FAFAF8",flexShrink:0},children:[e.jsx("span",{className:"font-semibold truncate flex-1",style:{color:a.primary,fontSize:d.sm},children:n.name}),n.sourceFile&&e.jsx("span",{className:"truncate",title:n.sourceFile,style:{maxWidth:"220px",color:a.faint,fontSize:d.xs},children:n.sourceFile}),(m==="text"||m==="split")&&e.jsx("span",{title:"Local, public Monaco editor with SysML highlighting and model-aware completion",style:{color:"#4B6E80",fontSize:d.badge},children:"Monaco · SysML"}),e.jsx(Pe,{at:ie}),c&&e.jsx("span",{style:{color:a.faint,fontSize:d.xs},children:"Loading source…"}),h&&e.jsx("span",{style:{color:a.faint,fontSize:d.xs},children:"Saving…"}),!h&&R&&e.jsx("span",{title:R,style:{color:"#EF4444",fontSize:d.xs},children:"Save failed"}),!h&&!R&&p&&e.jsx("span",{style:{color:"#B45309",fontSize:d.xs},children:"Unsaved"}),!h&&!p&&oe&&e.jsx("span",{style:{color:"#15803D",fontSize:d.xs},children:"Saved"}),!h&&i.length>0&&e.jsxs("span",{style:{color:"#EF4444",fontSize:d.xs},children:[i.length," error",i.length>1?"s":""]}),z&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-center gap-1",style:{color:a.secondary,fontSize:d.xs},title:"Save changes 800ms after typing",children:[e.jsx("input",{type:"checkbox",checked:T,onChange:l=>ae(l.target.checked),style:{accentColor:a.accent}}),"Auto-save"]}),e.jsx("button",{onClick:J,disabled:!p||h||c,title:"Save SysML (Ctrl/Cmd+S)",style:{fontSize:d.xs,padding:"3px 10px",borderRadius:"5px",border:`1px solid ${a.border}`,cursor:!p||h||c?"default":"pointer",background:p?a.accent:"#F0F0ED",color:p?"#FFFFFF":a.faint,fontWeight:600},children:"Save"})]}),e.jsx("div",{className:"flex overflow-hidden",style:{border:`1px solid ${a.border}`,borderRadius:"6px"},children:[["visual","⬜ Visual"],["split","⧉ Split"],["text","</> Text"]].map(([l,g])=>e.jsx("button",{onClick:()=>O(l),style:{fontSize:d.xs,padding:"3px 10px",border:"none",cursor:"pointer",background:m===l?a.accent:"transparent",color:m===l?"#FFFFFF":a.secondary,fontWeight:m===l?600:400},children:g},l))})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[m==="visual"&&te,m==="text"&&ee,m==="split"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"50%",borderRight:`1px solid ${a.border}`,display:"flex",flexDirection:"column",overflow:"hidden"},children:ee}),e.jsx("div",{style:{width:"50%",display:"flex",overflow:"hidden"},children:te})]})]})]})}export{We as DiagramEditor};
@@ -1,2 +0,0 @@
1
- import{j as e}from"./reactflow-CsCqNKB-.js";import{a as b}from"./zustand-CrhqMOHB.js";import{u,h as W,C as i,F as o,f as B,q as C,P as v,t as S,v as M,w as O,x as $,y as k}from"./index-CVW92JY7.js";const p="page",D=new Set(["Scenario","UseCase","UserActivity"]);function V(d){return d?d.split(`
2
- `).filter(n=>n.trim()).map((n,l)=>{const x=n.match(/^\d+\.\s*(.*)/);return{index:l,text:x?x[1].trim():n.trim()}}):[]}function U({element:d,layerColor:n,onSave:l}){const x=b.useMemo(()=>V(d.doc||""),[d.doc]),[j,h]=b.useState(!1);return j||x.length===0?e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:o.xs,color:i.faint,marginBottom:6,marginTop:0},children:["One step per line, numbered: ",e.jsx("code",{children:"1. User does something"})]}),e.jsx(S,{value:d.doc||"",onSave:c=>{l(c),h(!1)},density:p,multiline:!0,placeholder:"Click to add scenario steps…"})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>h(!0),style:{position:"absolute",top:0,right:0,fontSize:o.xs,color:i.muted,padding:"2px 9px",border:`1px solid ${i.border}`,borderRadius:"6px",background:i.surface,cursor:"pointer"},onMouseEnter:c=>{c.currentTarget.style.borderColor=i.accent},onMouseLeave:c=>{c.currentTarget.style.borderColor=i.border},children:"✎ Edit steps"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",paddingTop:4},children:[e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:o.xs,fontWeight:700,background:n,color:"#fff",letterSpacing:"0.06em",textTransform:"uppercase"},children:"Start"}),x.map((c,s)=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:[e.jsx(N,{color:n}),e.jsxs("div",{style:{width:"100%",maxWidth:"560px",display:"flex",alignItems:"flex-start",gap:"12px",background:i.surface,border:`1px solid ${n}30`,borderRadius:"8px",padding:"10px 14px",boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},children:[e.jsx("span",{style:{flexShrink:0,width:"24px",height:"24px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:n+"18",color:n,fontSize:o.xs,fontWeight:700},children:s+1}),e.jsx("span",{style:{fontSize:o.sm,color:i.primary,lineHeight:1.5,paddingTop:"3px"},children:c.text})]})]},s)),e.jsx(N,{color:n}),e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:o.xs,fontWeight:700,background:n+"20",color:n,letterSpacing:"0.06em",textTransform:"uppercase",border:`1px solid ${n}40`},children:"End"})]})]})}function N({color:d}){return e.jsx("div",{style:{width:"2px",height:"20px",background:d+"50",position:"relative"},children:e.jsx("div",{style:{position:"absolute",bottom:-5,left:"50%",transform:"translateX(-50%)",width:0,height:0,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderTop:`6px solid ${d}80`}})})}function Y({elementId:d}={}){var I,R,T;const n=u(t=>t.activeView),l=u(t=>t.model),x=u(t=>t.validation),j=u(t=>t.updateElementField),h=u(t=>t.updateElementAttribute),c=u(t=>t.applyEdit),s=d??(n.type==="element-detail"?n.elementId:null),r=s&&l?l.elements[s]:null,E=b.useMemo(()=>{if(!l||!s)return{incoming:[],outgoing:[]};const t=W(l,s);return{incoming:t.filter(a=>a.targetId===s),outgoing:t.filter(a=>a.sourceId===s)}},[l,s]),g=b.useMemo(()=>!x||!s?[]:x.violations.filter(t=>t.elementId===s),[x,s]);if(!r||!s)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:i.surfaceAlt},children:e.jsxs("div",{className:"text-center",style:{color:i.faint},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"12px",opacity:.5},children:"📄"}),e.jsx("p",{style:{fontSize:o.md},children:"Select an element to view details"})]})});const f=B[r.layer]||i.muted,m=(I=l==null?void 0:l.registries)==null?void 0:I.kinds.find(t=>t.name===r.kind),w=((R=m==null?void 0:m.namespace)==null?void 0:R[1])??((T=m==null?void 0:m.namespace)==null?void 0:T[0]),z=(t,a)=>{j(s,t,a),c(s)},L=(t,a)=>{h(s,t,a),c(s)},y=Object.entries(r.attributes).filter(([t])=>t!=="id"&&t!=="name"),F=D.has(r.kind);return e.jsx("div",{className:"flex-1 overflow-y-auto",style:{background:"#EEF4F7"},children:e.jsxs("div",{style:{maxWidth:"1040px",margin:"0 auto",padding:"20px 28px 48px"},children:[e.jsxs("header",{style:{background:i.surface,border:"1px solid rgba(60,60,67,0.12)",borderLeft:`4px solid ${f}`,borderRadius:"16px",padding:"14px 18px",marginBottom:16,boxShadow:"0 1px 3px rgba(15,23,42,0.05)"},children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",style:{marginBottom:8},children:[e.jsx("span",{className:"px-2 py-0.5 rounded-md font-semibold",style:{background:f+"18",color:f,fontSize:o.xs},children:r.kind}),e.jsx("span",{className:"px-2 py-0.5 rounded-md",style:{background:i.surfaceAlt,color:i.muted,fontSize:o.xs},children:r.layer}),w&&e.jsx("span",{style:{color:i.faint,fontSize:o.xs},children:w.replace(/[_-]/g," ").replace(/\b\w/g,t=>t.toUpperCase())}),r.shortId&&e.jsx("span",{style:{marginLeft:"auto",color:i.faint,fontSize:o.xs,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:r.shortId})]}),e.jsx("h1",{style:{fontSize:"24px",fontWeight:700,color:i.primary,lineHeight:1.2,margin:0},children:r.name}),e.jsx("div",{style:{marginTop:9,paddingTop:8,borderTop:`1px solid ${i.borderLight}`},children:e.jsx(C,{density:p})})]}),g.length>0&&e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid #FEE2E2",background:"#FEF2F2",marginBottom:20},children:[e.jsxs("div",{className:"px-4 py-2 font-semibold",style:{color:"#DC2626",fontSize:o.sm,borderBottom:"1px solid #FEE2E2"},children:[g.length," violation",g.length!==1?"s":""]}),g.map((t,a)=>e.jsxs("div",{className:"px-4 py-2 flex items-center gap-2",style:{fontSize:o.xs},children:[e.jsx("span",{style:{color:"#DC2626"},children:"✖"}),e.jsxs("span",{style:{color:i.faint},children:["[",t.ruleId,"]"]}),e.jsx("span",{style:{color:"#991B1B"},children:t.description})]},a))]}),e.jsx(v,{title:F?"Flow":"Description",density:p,collapsible:!1,children:F?e.jsx(U,{element:r,layerColor:f,onSave:t=>z("doc",t)}):e.jsx(S,{value:r.doc||"",onSave:t=>z("doc",t),density:p,multiline:!0,placeholder:"Click to add a description…"})}),e.jsxs(v,{title:"Attributes",count:y.length,density:p,collapsible:!1,children:[y.length===0&&e.jsx("p",{style:{fontSize:o.sm,color:i.faint,margin:0},children:"This element defines no attributes."}),y.length>0&&e.jsx("div",{style:{borderTop:`1px solid ${i.border}`,maxWidth:900},children:y.map(([t,a])=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(150px, 24%) minmax(0, 1fr)",gap:16,alignItems:"center",padding:"7px 0",borderBottom:`1px solid ${i.borderLight}`},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{color:i.secondary,fontSize:o.sm,fontWeight:600},children:t}),e.jsx("div",{style:{color:i.faint,fontSize:"10px"},children:"Editable"})]}),e.jsx(S,{value:String(a??""),onSave:A=>L(t,A),density:p,placeholder:"Add value…",compact:!0})]},t))})]}),e.jsx(M,{element:r,outgoing:E.outgoing,incoming:E.incoming,density:p}),e.jsx(v,{title:"Source",density:p,collapsible:!1,children:e.jsx("div",{style:{maxWidth:720},children:e.jsx(O,{label:"SysML source file",editability:k("file"),density:p,children:e.jsx($,{value:r.file??"—",editability:k("file"),density:p,mono:!0})})})})]})})}export{Y as ElementDetailView};
@@ -1 +0,0 @@
1
- import{j as e,H as C,P as k,R as D,a as S,i as O,f as R,g as T}from"./reactflow-CsCqNKB-.js";import{a as p}from"./zustand-CrhqMOHB.js";/* empty css */import{r as I}from"./layout-providers-Dr743WlP.js";import{f as L,u as h,K as P,M,N as z}from"./index-CVW92JY7.js";import"./elk-6l8mIQnQ.js";const A={ontology:{bg:"#EFF6FF",fg:"#2563EB",border:"#BFDBFE"},profile:{bg:"#F0FDF4",fg:"#16A34A",border:"#BBF7D0"},extension:{bg:"#FFF7ED",fg:"#EA580C",border:"#FED7AA"}};function H({data:i}){const s=i,l=A[s.type]??A.ontology;return e.jsxs("div",{"data-testid":`ontology-package-node-${s.name}`,onClick:s.onClick,onDoubleClick:s.onDoubleClick,onContextMenu:s.onContextMenu,style:{background:"#FFFFFF",border:s.selected?"2px solid #2563EB":"1px solid #E5E5E0",borderRadius:"12px",padding:"16px",minWidth:"240px",maxWidth:"300px",cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.06)",transition:"box-shadow 200ms ease, transform 200ms ease"},children:[e.jsx(C,{type:"target",position:k.Top,id:"top",style:w}),e.jsx(C,{type:"source",position:k.Bottom,id:"bottom",style:w}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"8px"},children:[e.jsx("span",{style:{padding:"1px 8px",fontSize:"10px",borderRadius:"9999px",fontWeight:600,background:l.bg,color:l.fg,border:`1px solid ${l.border}`},children:s.type}),e.jsxs("span",{style:{fontSize:"10px",color:"#9CA3AF"},children:["v",s.version]})]}),e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"#1a1a1a",marginBottom:"4px"},children:s.name}),s.description&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginBottom:"10px",lineHeight:"1.4"},children:s.description.length>80?s.description.slice(0,80)+"…":s.description}),e.jsx("div",{style:{display:"flex",gap:"2px",marginBottom:"8px",height:"6px",borderRadius:"3px",overflow:"hidden"},children:s.layers.slice(0,12).map(d=>{const n=L[d.id]??d.color??"#6B7280";return e.jsx("div",{style:{flex:Math.max(d.kindCount,1),background:n,borderRadius:"1px"},title:`${d.label}: ${d.kindCount} kinds`},d.id)})}),e.jsxs("div",{style:{display:"flex",gap:"12px",fontSize:"11px",color:"#6B7280"},children:[e.jsxs("span",{children:[e.jsx("strong",{style:{color:"#1B3A4B"},children:s.kindCount})," kinds"]}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"#1B3A4B"},children:s.layerCount})," layers"]})]})]})}const w={width:"8px",height:"8px",background:"#2563EB",border:"2px solid #FFFFFF",opacity:0},W=p.memo(H);function $({onClose:i}){const s=h(o=>o.availableOntologies),l=h(o=>o.ontologyInstallStatus),d=h(o=>o.setOntologyInstallStatus),[n,c]=p.useState(""),[r,g]=p.useState(null);function t(){n.trim()&&(d({installing:!0}),P(n.trim()),c(""))}function x(o){M(o),g(null)}return e.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50",style:{background:"rgba(0,0,0,0.4)"},onClick:i,children:e.jsxs("div",{className:"rounded-xl shadow-2xl overflow-hidden",style:{background:"#FFFFFF",width:"520px",maxHeight:"600px",border:"1px solid #E5E5E0"},onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("h2",{className:"text-sm font-semibold",style:{color:"#1a1a1a"},children:"Manage Ontology Library"}),e.jsx("button",{onClick:i,className:"text-sm px-2 py-0.5 rounded hover:bg-gray-100",style:{color:"#9CA3AF"},children:"x"})]}),e.jsxs("div",{className:"p-5 space-y-5 overflow-y-auto",style:{maxHeight:"480px"},children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium block mb-1.5",style:{color:"#374151"},children:"Add Ontology"}),e.jsx("p",{className:"text-xs mb-2",style:{color:"#9CA3AF"},children:"Enter a git URL (https://...git), npm package name (@memoarchitect/...), or local path."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"https://gitlab.com/org/my-ontology.git",value:n,onChange:o=>c(o.target.value),onKeyDown:o=>o.key==="Enter"&&t(),className:"flex-1 px-3 py-2 text-xs rounded-lg",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151",outline:"none"},onFocus:o=>o.currentTarget.style.borderColor="#2563EB",onBlur:o=>o.currentTarget.style.borderColor="#E5E7EB",disabled:l.installing}),e.jsx("button",{onClick:t,disabled:!n.trim()||l.installing,className:"px-4 py-2 text-xs rounded-lg font-medium",style:{background:l.installing?"#9CA3AF":"#1B3A4B",color:"#FFFFFF",opacity:!n.trim()||l.installing?.5:1,cursor:!n.trim()||l.installing?"not-allowed":"pointer"},children:l.installing?"Installing...":"Install"})]}),l.error&&e.jsx("div",{className:"mt-2 px-3 py-2 rounded-lg text-xs",style:{background:"#FEF2F2",color:"#DC2626",border:"1px solid #FECACA"},children:l.error}),l.lastInstalled&&!l.error&&e.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-xs",style:{background:"#F0FDF4",color:"#16A34A",border:"1px solid #BBF7D0"},children:["Installed ",l.lastInstalled]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-medium block mb-2",style:{color:"#374151"},children:["Installed Packages (",s.length,")"]}),e.jsxs("div",{className:"space-y-1.5",children:[s.map(o=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{border:"1px solid #E5E5E0",background:"#FAFAF8"},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium truncate",style:{color:"#1a1a1a"},children:o.name}),e.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded",style:{background:o.type==="ontology"?"#EFF6FF":o.type==="profile"?"#F0FDF4":"#FFF7ED",color:o.type==="ontology"?"#2563EB":o.type==="profile"?"#16A34A":"#EA580C",fontSize:"10px"},children:o.type})]}),e.jsxs("div",{className:"text-xs mt-0.5",style:{color:"#9CA3AF"},children:["v",o.version," · ",o.kindCount," kinds · ",o.layers.length," layers"]})]}),r===o.name?e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>x(o.name),className:"px-2 py-1 text-xs rounded",style:{background:"#DC2626",color:"#FFFFFF"},children:"Confirm"}),e.jsx("button",{onClick:()=>g(null),className:"px-2 py-1 text-xs rounded",style:{background:"#F3F4F6",color:"#374151"},children:"Cancel"})]}):e.jsx("button",{onClick:()=>g(o.name),className:"text-xs px-2 py-1 rounded hover:bg-red-50",style:{color:"#DC2626",border:"1px solid #FECACA"},children:"Remove"})]},o.name)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-xs",style:{color:"#9CA3AF"},children:"No ontology packages installed"})]})]})]})]})})}const _={ontologyPackage:W},Y=260,K=180;async function V(i){const s=new Map(i.map(t=>[t.name,t])),l={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.layered.nodePlacement.strategy":"BRANDES_KOEPF","elk.layered.spacing.nodeNodeBetweenLayers":"100","elk.spacing.nodeNode":"32","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.padding":"[top=24, left=24, bottom=24, right=24]"},children:i.map(t=>({id:t.name,width:Y,height:K})),edges:i.filter(t=>t.extends&&s.has(t.extends)).map((t,x)=>({id:`e-${x}`,sources:[t.extends],targets:[t.name]}))},d=await I(l),n=new Map;for(const t of d.children??[])n.set(t.id,{x:t.x??0,y:t.y??0});const c={ontology:"#3B82F6",profile:"#10B981",extension:"#F59E0B"},r=i.map(t=>({id:t.name,type:"ontologyPackage",position:n.get(t.name)??{x:0,y:0},data:{name:t.name,type:t.type,version:t.version,description:t.description,kindCount:t.kindCount,layerCount:t.layers.length,layers:t.layers.map(x=>({id:x.id,label:x.label,color:x.color,kindCount:x.kindCount})),selected:t.selected,onClick:()=>{}}})),g=[];for(const t of i)if(t.extends&&s.has(t.extends)){const x=c[t.type]??"#94A3B8";g.push({id:`${t.extends}->${t.name}`,source:t.extends,target:t.name,type:"smoothstep",data:{edgeType:"extends"},style:{stroke:x,strokeWidth:2,strokeDasharray:"6 3"},animated:!1,label:"extends",labelStyle:{fontSize:9,fill:x,fontWeight:500},labelBgStyle:{fill:"#F7F7F5",fillOpacity:.9},labelBgPadding:[4,2],markerEnd:{type:"arrowclosed",color:x,width:14,height:14}})}return{nodes:r,edges:g}}function G(i,s){const l=new Map;for(const c of s)c.extends&&(l.has(c.extends)||l.set(c.extends,[]),l.get(c.extends).push(c.name));const d=new Set([i]),n=[i];for(;n.length;){const c=n.shift();for(const r of l.get(c)??[])d.has(r)||(d.add(r),n.push(r))}return d}function U(){const i=h(a=>a.availableOntologies),s=h(a=>a.setActiveView),l=h(a=>a.hiddenEdgeTypes),d=h(a=>a.toggleHiddenEdgeType),[n,c]=p.useState(!1),[r,g]=p.useState({nodes:[],edges:[]}),[t,x]=p.useState(null),{fitView:o}=S();p.useEffect(()=>{let a=!1;return V(i).then(u=>{a||g(u)}).catch(u=>{console.error("[OntologyDiagram] ELK layout failed:",u)}),()=>{a=!0}},[i]);const F=p.useCallback(a=>{s({type:"ontology-detail",packageName:a})},[s]),E=p.useCallback(a=>{const u=G(a,i),m=r.nodes.filter(y=>u.has(y.id));m.length!==0&&o({nodes:m.map(y=>({id:y.id})),duration:400,padding:.2})},[i,r.nodes,o]),v=p.useCallback((a,u)=>{a.preventDefault(),x({x:a.clientX,y:a.clientY,packageName:u})},[]);p.useEffect(()=>{const a=u=>{if(u.key==="Escape"){if(t){x(null);return}o({padding:.1,duration:300})}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,o]);const{nodes:N,edges:B}=p.useMemo(()=>{const a=r.nodes.map(m=>({...m,data:{...m.data,onClick:()=>E(m.id),onDoubleClick:()=>F(m.id),onContextMenu:y=>v(y,m.id)}})),u=r.edges.filter(m=>{var j;const y=(j=m.data)==null?void 0:j.edgeType;return!y||!l.has(y)});return{nodes:a,edges:u}},[r,E,F,v,l]),f=p.useRef(null);p.useEffect(()=>{if(!t)return;const a=u=>{f.current&&!f.current.contains(u.target)&&x(null)};return window.addEventListener("mousedown",a),()=>window.removeEventListener("mousedown",a)},[t]);const b=l.has("extends");return i.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"text-center",style:{color:"#9CA3AF"},children:[e.jsx("div",{className:"text-3xl mb-3",children:"◉"}),e.jsx("div",{className:"text-sm font-medium mb-1",style:{color:"#374151"},children:"No ontology packages found"}),e.jsx("div",{className:"text-xs",children:"Start the dev server to load ontology packages"})]})}):e.jsxs("div",{className:"flex-1",style:{background:"#F7F7F5"},children:[e.jsxs("div",{className:"flex items-start justify-between px-6 pt-5 pb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",style:{color:"#1a1a1a"},children:"Ontology Library"}),e.jsxs("p",{className:"text-xs mt-1",style:{color:"#9CA3AF"},children:[i.length," package",i.length!==1?"s":""," available. Click to zoom, double-click to open, right-click for source."]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{"data-testid":"toggle-tracing",onClick:()=>d("extends"),title:b?"Show extends tracing edges":"Hide extends tracing edges",className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:b?{background:"#F0F0ED",color:"#6B7280",border:"1px solid #E5E5E0"}:{background:"#1B3A4B",color:"#2DD4A8",border:"1px solid transparent"},children:b?"Show Tracing":"Hide Tracing"}),e.jsx("button",{onClick:()=>c(!0),className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:{background:"#1B3A4B",color:"#2DD4A8"},children:"+ Add Ontology"})]})]}),n&&e.jsx($,{onClose:()=>c(!1)}),e.jsx("div",{style:{flex:1,height:"calc(100% - 72px)"},children:e.jsxs(O,{nodes:N,edges:B,nodeTypes:_,fitView:!0,fitViewOptions:{padding:.1},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!0,zoomOnDoubleClick:!1,minZoom:.2,maxZoom:2.5,proOptions:{hideAttribution:!0},children:[e.jsx(R,{color:"#E5E5E0",gap:24,size:1}),e.jsx(T,{showInteractive:!1})]})}),t&&e.jsx(Z,{menuRef:f,state:t,onClose:()=>x(null),packages:i})]})}const Z=({state:i,onClose:s,packages:l,menuRef:d})=>{const n=l.find(r=>r.name===i.packageName);function c(){if(!n)return;const r=n.rootDir?`${n.rootDir}/memo.package.yaml`:"";r?z(r):window.open(`vscode://file/${encodeURIComponent(n.name)}`),s()}return e.jsxs("div",{ref:d,style:{position:"fixed",top:i.y,left:i.x,zIndex:1e3,background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"8px",boxShadow:"0 6px 16px rgba(0,0,0,0.12)",padding:"4px",minWidth:"180px",fontSize:"12px"},children:[e.jsx("div",{style:{padding:"6px 10px",color:"#9CA3AF",fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.4px"},children:i.packageName}),e.jsx("button",{onClick:c,disabled:!(n!=null&&n.rootDir),style:{display:"block",width:"100%",textAlign:"left",padding:"6px 10px",border:"none",background:"transparent",cursor:n!=null&&n.rootDir?"pointer":"not-allowed",color:n!=null&&n.rootDir?"#1a1a1a":"#9CA3AF",borderRadius:"4px"},onMouseEnter:r=>{n!=null&&n.rootDir&&(r.currentTarget.style.background="#F0F0ED")},onMouseLeave:r=>{r.currentTarget.style.background="transparent"},children:"Open source"})]})};function oe(){return e.jsx(D,{children:e.jsx(U,{})})}export{oe as OntologyDecompositionDiagram,oe as default};
@@ -1,3 +0,0 @@
1
- import{j as e}from"./reactflow-CsCqNKB-.js";import{a as x}from"./zustand-CrhqMOHB.js";import{u as A,h as he,i as fe,C as f,F as C,f as E,E as O,j as Z,r as ge,D as ye}from"./index-CVW92JY7.js";function je(d){const r=d.diagramType.toLowerCase(),b=["afd","ofd","ffd"].includes(r)?ge(d):r;return ye[b]}function ee({expanded:d,color:r=f.muted}){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",style:{transform:d?"rotate(90deg)":void 0,transition:"transform 150ms ease",flexShrink:0},children:e.jsx("path",{d:"M6 4L10 8L6 12",stroke:r,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function te({open:d,color:r}){return e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[e.jsx("path",{d:"M1.5 3.5h4.8l1.2 1.5H14.5v8H1.5z",fill:r,opacity:"0.15",stroke:r,strokeWidth:"1",strokeLinejoin:"round"}),d&&e.jsx("path",{d:"M1.5 5h13v8H1.5z",fill:r,opacity:"0.08"})]})}function ke({color:d}){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",style:{flexShrink:0},children:[e.jsx("rect",{x:"2",y:"1.5",width:"12",height:"13",rx:"1.5",fill:d,opacity:"0.1",stroke:d,strokeWidth:"1"}),e.jsx("line",{x1:"5",y1:"5.5",x2:"11",y2:"5.5",stroke:d,strokeWidth:"0.8",opacity:"0.5"}),e.jsx("line",{x1:"5",y1:"8",x2:"11",y2:"8",stroke:d,strokeWidth:"0.8",opacity:"0.5"})]})}function se(d){return d?d.split(`
2
- `).filter(b=>b.trim()).map((b,W)=>{const I=b.match(/^\d+\.\s*(.*)/);return{index:W,text:I?I[1]:b}}):[]}function be(d){return d.map((r,b)=>`${b+1}. ${r.text}`).join(`
3
- `)}function Ne({explorerOnly:d=!1}){const r=A(t=>t.model),b=A(t=>t.createRelationship),W=A(t=>t.inspectElement),I=A(t=>t.setActiveView),G=A(t=>t.setActiveMode),S=A(t=>t.selectedElementId),[D,ne]=x.useState(""),[i,F]=x.useState(null),[M,P]=x.useState(""),[z,_]=x.useState(null),[T,H]=x.useState(""),R=x.useMemo(()=>{if(!r)return[];const t=Object.values(r.elements),n=r.elements,o=(...s)=>{const y=new Set(s.map(j=>j.toLowerCase()));return r.relationships.filter(j=>y.has(j.type.toLowerCase()))},c=(s,y)=>{var j;return typeof s=="string"&&((j=s.split("::").at(-1))==null?void 0:j.trim())===y},h=t.filter(s=>s.kind.endsWith("UseCase")),w=new Set(h.map(s=>s.id)),u=new Map,a=new Set;for(const s of o("Includes")){if(!w.has(s.sourceId)||!w.has(s.targetId))continue;const y=u.get(s.sourceId)??[];y.push(s.targetId),u.set(s.sourceId,y),a.add(s.targetId)}const v=new Map,g=[],m=(s,y)=>{if(!v.has(s)){v.set(s,y),g.push(s);for(const j of u.get(s)??[])m(j,y+1)}};for(const s of h)a.has(s.id)||m(s.id,0);for(const s of h)m(s.id,0);const L=g.map(s=>n[s]).filter(s=>!!s),$=s=>!D||s.name.toLowerCase().includes(D.toLowerCase())||s.kind.toLowerCase().includes(D.toLowerCase());return L.map(s=>{var Q;const y=o("Supports","supportsUseCase").filter(l=>l.targetId===s.id).map(l=>n[l.sourceId]).filter(l=>!!l&&l.kind==="OperationalWorkflow"),j=t.filter(l=>l.kind.endsWith("Scenario")).filter(l=>c(l.attributes.parentUseCase,s.id)||o("Realizes","scenarioRealizesUseCase").some(N=>N.sourceId===l.id&&N.targetId===s.id)),U=j.map(l=>t.find(N=>c(l.attributes.parentWorkflow,N.id))).filter(l=>!!l),pe=[...new Map([...y,...U].map(l=>[l.id,l])).values()],ue=j.map(l=>{const N=(r.diagrams??[]).filter(me=>{var X;return(X=me.scenarioIds)==null?void 0:X.includes(l.id)});return{scenario:l,views:N}}),xe=pe.map(l=>({workflow:l,scenarios:ue.filter(({scenario:N})=>c(N.attributes.parentWorkflow,l.id))}));return{useCase:s,workflows:xe,depth:v.get(s.id)??0,hasChildren:(((Q=u.get(s.id))==null?void 0:Q.length)??0)>0}}).filter(s=>$(s.useCase)||s.workflows.some(({workflow:y,scenarios:j})=>$(y)||j.some(({scenario:U})=>$(U))))},[r,D]),p=S&&r?r.elements[S]:null,K=x.useMemo(()=>he(r,S||""),[r,S]),k=x.useMemo(()=>i||(p?se(p.doc||""):[]),[p,i]),oe=x.useCallback(()=>{p&&F(se(p.doc||""))},[p]),re=x.useCallback(()=>{if(!p||!i)return;const t=be(i);fe({...p,doc:t}),F(null)},[p,i]),V=x.useCallback(()=>{if(!M.trim())return;const t=[...i||k,{index:k.length,text:M.trim()}];F(t),P("")},[M,i,k]),le=x.useCallback(t=>{const n=(i||k).filter((o,c)=>c!==t);F(n)},[i,k]),Y=x.useCallback((t,n)=>{const o=[...i||k],c=t+n;c<0||c>=o.length||([o[t],o[c]]=[o[c],o[t]],F(o))},[i,k]),ae=x.useCallback((t,n)=>{const o=[...i||k];o[t]={...o[t],text:n},F(o)},[i,k]),ce=x.useMemo(()=>{if(!r||!T)return[];const t=T.toLowerCase();return Object.values(r.elements).filter(n=>n.id!==S&&n.name.toLowerCase().includes(t)).slice(0,10)},[r,T,S]),[q,ie]=x.useState(new Set),J=t=>{ie(n=>{const o=new Set(n);return o.has(t)?o.delete(t):o.add(t),o})},B=t=>{F(null),G("scenario"),W(t),I({type:"element-detail",elementId:t})},de=({workflow:t,scenarios:n})=>{const o=`workflow:${t.id}`,c=q.has(o),h=()=>J(o),w=a=>{G("scenario"),I({type:"diagram",diagramId:a.id})},u=(a,v)=>{const g=S===a.id;return e.jsxs("button",{type:"button",onClick:()=>B(a.id),className:"flex w-full items-center gap-1.5 px-2 py-1 text-left",style:{borderRadius:"4px",margin:"0 4px",marginLeft:`${v+4}px`,width:`calc(100% - ${v+8}px)`,background:g?`${f.accent}18`:"transparent"},onMouseEnter:m=>{g||(m.currentTarget.style.background="#F0F0ED")},onMouseLeave:m=>{m.currentTarget.style.background=g?`${f.accent}18`:"transparent"},children:[e.jsx(ke,{color:E[a.layer]||f.muted}),e.jsx(O,{element:a,selected:g})]},a.id)};return e.jsxs("div",{className:"mb-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 cursor-pointer select-none",style:{borderRadius:"4px",margin:"0 4px"},onMouseEnter:a=>a.currentTarget.style.background="#F0F0ED",onMouseLeave:a=>a.currentTarget.style.background="transparent",onClick:()=>B(t.id),children:[e.jsx("button",{type:"button","aria-label":`${c?"Collapse":"Expand"} ${t.name}`,onClick:a=>{a.stopPropagation(),h()},children:e.jsx(ee,{expanded:c,color:f.muted})}),e.jsx(te,{open:c,color:E.operational}),e.jsx(O,{element:t,fontSize:C.explorer.kind,fontWeight:600}),e.jsx(Z,{count:n.length,color:E.operational,title:`${n.length} scenarios`})]}),c&&n.map(({scenario:a,views:v})=>e.jsxs("div",{style:{marginLeft:"16px"},children:[u(a,0),e.jsx("div",{style:{marginLeft:"20px"},children:v.length>0&&e.jsx("div",{className:"pt-1",children:v.map(g=>{const m=je(g);return e.jsxs("button",{type:"button",onClick:()=>w(g),className:"flex w-full items-center gap-2 px-2 py-1 text-left",style:{borderRadius:"4px",margin:"0 4px",width:"calc(100% - 8px)"},onMouseEnter:L=>L.currentTarget.style.background="#F0F0ED",onMouseLeave:L=>L.currentTarget.style.background="transparent",title:m==null?void 0:m.fullName,children:[m&&e.jsx("span",{className:"px-1.5 py-0.5 rounded font-semibold",style:{background:m.color+"20",color:m.color,fontSize:C.badge},children:m.code}),e.jsxs("span",{className:"flex-1",style:{minWidth:0},children:[e.jsx("span",{className:"truncate block",style:{color:f.primary,fontSize:C.explorer.item},children:g.name}),e.jsx("span",{className:"truncate block font-mono",style:{color:f.faint,fontSize:"9px",marginTop:1},children:g.id})]})]},g.id)})})})]},a.id)),c&&n.length===0&&e.jsx("div",{className:"px-2 py-1",style:{color:f.faint,fontSize:C.explorer.count,marginLeft:"20px"},children:"No scenarios"})]})};return e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[d&&e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",style:{background:f.surface},children:[e.jsx("div",{className:"px-3 py-2",style:{borderBottom:"1px solid #E5E5E0"},children:e.jsx("input",{type:"text",placeholder:"Search "+R.length+" use cases...",value:D,onChange:t=>ne(t.target.value),className:"w-full px-3 py-2 rounded-lg focus:outline-none",style:{background:f.surfaceAlt,border:`1px solid ${f.border}`,color:f.primary,fontSize:C.explorer.search}})}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",style:{fontSize:C.explorer.item},children:[R.map(({useCase:t,workflows:n,depth:o})=>{const c="use-case:"+t.id,h=q.has(c),w=n.reduce((u,{scenarios:a})=>u+a.length,0);return e.jsxs("div",{className:"mb-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 cursor-pointer select-none",style:{borderRadius:"4px",margin:"0 4px",marginLeft:4+o*16},onMouseEnter:u=>u.currentTarget.style.background="#F0F0ED",onMouseLeave:u=>u.currentTarget.style.background="transparent",onClick:()=>B(t.id),children:[e.jsx("button",{type:"button","aria-label":`${h?"Collapse":"Expand"} ${t.name}`,onClick:u=>{u.stopPropagation(),J(c)},children:e.jsx(ee,{expanded:h,color:E.functional})}),e.jsx(te,{open:h,color:E.functional}),e.jsx(O,{element:t,fontSize:C.explorer.group,fontWeight:600}),e.jsx(Z,{count:w,color:E.functional,title:`${w} scenarios`})]}),h&&e.jsxs("div",{style:{marginLeft:16+o*16},children:[n.map(({workflow:u,scenarios:a})=>e.jsx(de,{workflow:u,scenarios:a},u.id)),n.length===0&&e.jsx("div",{className:"px-2 py-1",style:{color:f.faint,fontSize:C.explorer.kind},children:"No workflows"})]})]},t.id)}),R.length===0&&e.jsx("div",{className:"px-4 py-8 text-center",style:{color:f.faint},children:"No use-case scenario chains found."})]})]}),!d&&e.jsx("div",{className:"flex-1 overflow-y-auto p-6",style:{background:"#F7F7F5"},children:e.jsxs(e.Fragment,{children:[!p&&e.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"#9CA3AF"},children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"8px",opacity:.5},children:"▶"}),e.jsx("div",{className:"text-sm",children:"Select a scenario to edit steps and link elements"})]})}),p&&e.jsxs("div",{className:"max-w-2xl",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold",style:{color:"#1a1a1a"},children:p.name}),e.jsx("span",{className:"px-2 py-0.5 text-xs rounded-md font-medium",style:{background:"#E67E2218",color:"#E67E22"},children:p.kind})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"#6B7280"},children:"Steps"}),!i&&e.jsx("button",{onClick:oe,className:"px-2 py-0.5 text-xs rounded",style:{background:"#2DD4A815",color:"#1B3A4B",border:"1px solid #2DD4A840"},children:"Edit"}),i&&e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:re,className:"px-2 py-0.5 text-xs rounded font-medium",style:{background:"#2DD4A8",color:"#FFFFFF"},children:"Save"}),e.jsx("button",{onClick:()=>F(null),className:"px-2 py-0.5 text-xs rounded",style:{background:"#F3F4F6",color:"#6B7280"},children:"Cancel"})]})]}),e.jsx("div",{className:"space-y-1",children:k.map((t,n)=>e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("span",{className:"flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium",style:{background:"#2DD4A815",color:"#1B3A4B"},children:n+1}),i?e.jsx("input",{type:"text",value:t.text,onChange:o=>ae(n,o.target.value),className:"flex-1 text-sm px-2 py-1 rounded focus:outline-none",style:{border:"1px solid #E5E5E0",color:"#374151"}}):e.jsx("span",{className:"flex-1 text-sm",style:{color:"#374151"},children:t.text}),i&&e.jsxs("div",{className:"flex gap-0.5",children:[e.jsx("button",{onClick:()=>Y(n,-1),className:"px-1 text-xs",style:{color:"#9CA3AF"},title:"Move up",children:"▲"}),e.jsx("button",{onClick:()=>Y(n,1),className:"px-1 text-xs",style:{color:"#9CA3AF"},title:"Move down",children:"▼"}),e.jsx("button",{onClick:()=>le(n),className:"px-1 text-xs",style:{color:"#E74C3C"},title:"Remove",children:"✕"})]})]},n))}),i&&e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("input",{type:"text",value:M,onChange:t=>P(t.target.value),onKeyDown:t=>t.key==="Enter"&&V(),placeholder:"Add a step...",className:"flex-1 text-sm px-3 py-2 rounded-lg focus:outline-none",style:{background:"#FFFFFF",border:"1px solid #E5E5E0",color:"#374151"}}),e.jsx("button",{onClick:V,className:"px-3 py-2 text-xs rounded-lg font-medium",style:{background:"#2DD4A815",color:"#1B3A4B",border:"1px solid #2DD4A840"},children:"+ Add"})]}),k.length===0&&!i&&e.jsx("div",{className:"text-xs p-3 rounded-lg",style:{background:"#F3F4F6",color:"#9CA3AF"},children:"No steps defined. Click Edit to add scenario steps."})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"#6B7280"},children:["Linked Elements (",K.length,")"]}),e.jsx("button",{onClick:()=>_(z===null?0:null),className:"px-2 py-0.5 text-xs rounded",style:{background:"#4A90D915",color:"#4A90D9",border:"1px solid #4A90D940"},children:z!==null?"Done":"+ Link"})]}),z!==null&&e.jsxs("div",{className:"mb-2 p-2 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #4A90D940"},children:[e.jsx("input",{type:"text",value:T,onChange:t=>H(t.target.value),placeholder:"Search elements to link...",className:"w-full text-sm px-2 py-1 rounded focus:outline-none mb-1",style:{border:"1px solid #E5E5E0",color:"#374151"}}),ce.map(t=>e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 text-xs rounded cursor-pointer",onMouseEnter:n=>n.currentTarget.style.background="#F0F0ED",onMouseLeave:n=>n.currentTarget.style.background="transparent",onClick:()=>{b({type:"traceTo",sourceId:p.id,targetId:t.id,direction:"outgoing",selectedElementId:p.id}),H(""),_(null)},children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:E[t.layer]||"#95A5A6"}}),e.jsx("span",{style:{color:"#374151"},children:t.name}),e.jsx("span",{style:{color:"#9CA3AF"},children:t.kind})]},t.id))]}),e.jsx("div",{className:"space-y-1",children:K.map(t=>{const n=t.sourceId===p.id?t.targetId:t.sourceId,o=r.elements[n],c=t.sourceId===p.id?"→":"←";return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded-lg cursor-pointer",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},onMouseEnter:h=>h.currentTarget.style.background="#F0F0ED",onMouseLeave:h=>h.currentTarget.style.background="#FFFFFF",onClick:()=>B(n),children:[e.jsx("span",{style:{color:"#9CA3AF"},children:c}),e.jsx("span",{className:"font-medium",style:{color:"#2563EB"},children:t.type}),e.jsx("span",{style:{color:"#374151"},children:(o==null?void 0:o.name)||n}),o&&e.jsx("span",{className:"ml-auto px-1.5 py-0.5 rounded text-xs",style:{background:(E[o.layer]||"#95A5A6")+"18",color:E[o.layer]||"#95A5A6"},children:o.kind})]},t.id)})})]}),e.jsx("div",{className:"text-xs",style:{color:"#D1D5DB"},children:p.file})]})]})})]})}export{Ne as ScenarioEditor};
@@ -1 +0,0 @@
1
- import{j as t}from"./reactflow-CsCqNKB-.js";import{a as u}from"./zustand-CrhqMOHB.js";import{u as w,F as j,e as D,f as T}from"./index-CVW92JY7.js";function R({element:r}){var f;const i=!!((f=r.doc)!=null&&f.trim()),d=Object.keys(r.attributes).length,S=i&&d>=1,v=i||d>=1,p=S?"#2DD4A8":v?"#F39C12":"#E5E5E0",A=S?"Complete":v?"Partial":"Empty";return t.jsx("span",{className:"inline-block rounded-full flex-shrink-0",style:{width:8,height:8,backgroundColor:p,cursor:"default"},title:A})}function Y({col:r,sortKey:i,sortDir:d}){return r!==i?t.jsx("span",{style:{color:"#D1D5DB",fontSize:"10px",marginLeft:3},children:"⇅"}):t.jsx("span",{style:{color:"#1B3A4B",fontSize:"10px",marginLeft:3},children:d==="asc"?"↑":"↓"})}function P(){const r=w(e=>e.model),i=w(e=>e.activeView),d=w(e=>e.selectedViewpointId),S=w(e=>e.selectElement),v=w(e=>e.selectedElementId),[p,A]=u.useState("name"),[f,C]=u.useState("asc"),[E,B]=u.useState(""),[g,I]=u.useState(""),[b,M]=u.useState(""),h=u.useMemo(()=>{var o,s,n,c,l;if(!r)return[];const e=Object.values(r.elements);if(i.type==="tabular"&&i.diagramId){const a=(o=r.diagrams)==null?void 0:o.find(x=>x.id===i.diagramId);if((s=a==null?void 0:a.elementIds)!=null&&s.length){const x=new Set(a.elementIds);return e.filter(m=>x.has(m.id))}}if(d){const a=(n=r.viewpoints)==null?void 0:n.find(x=>x.id===d);if(a){const x=(c=a.visibleLayers)!=null&&c.length?new Set(a.visibleLayers):null,m=(l=a.visibleKinds)!=null&&l.length?new Set(a.visibleKinds):null;return e.filter(F=>(!x||x.has(F.layer))&&(!m||m.has(F.kind)))}}return e},[r,i,d]),k=u.useMemo(()=>{const e=new Map;for(const s of h)for(const n of Object.keys(s.attributes))e.set(n,(e.get(n)??0)+1);const o=Math.max(1,h.length*.1);return[...e.entries()].filter(([,s])=>s>=o).sort((s,n)=>n[1]-s[1]).slice(0,4).map(([s])=>s)},[h]),O=u.useMemo(()=>[...new Set(h.map(e=>e.layer))].sort(),[h]),V=u.useMemo(()=>[...new Set(h.map(e=>e.kind))].sort(),[h]),N=u.useMemo(()=>{const e=E.toLowerCase();let o=h.filter(s=>!(e&&!s.name.toLowerCase().includes(e)&&!s.kind.toLowerCase().includes(e)||g&&s.layer!==g||b&&s.kind!==b));return o.sort((s,n)=>{let c="",l="";if(p==="name")c=s.name,l=n.name;else if(p==="kind")c=s.kind,l=n.kind;else if(p==="layer")c=s.layer,l=n.layer;else if(p==="status"){const x=m=>{var L;const F=!!((L=m.doc)!=null&&L.trim()),z=Object.keys(m.attributes).length>=1;return F&&z?2:F||z?1:0};c=String(x(s)),l=String(x(n))}else c=s.attributes[p]??"",l=n.attributes[p]??"";const a=c.localeCompare(l,void 0,{numeric:!0});return f==="asc"?a:-a}),o},[h,E,g,b,p,f]);function K(e){p===e?C(o=>o==="asc"?"desc":"asc"):(A(e),C("asc"))}const W=u.useMemo(()=>{var e,o;if(!r)return"";if(i.type==="tabular"&&i.diagramId){const s=(e=r.diagrams)==null?void 0:e.find(n=>n.id===i.diagramId);return s?`Diagram: ${s.name}`:"Diagram"}if(d){const s=(o=r.viewpoints)==null?void 0:o.find(n=>n.id===d);return s?`Viewpoint: ${s.label}`:"Viewpoint"}return"All Elements"},[r,i,d]),y=({col:e,label:o,width:s})=>t.jsxs("th",{onClick:()=>K(e),className:"px-3 py-2 text-left cursor-pointer select-none",style:{fontSize:"11px",fontWeight:600,color:"#374151",background:"#F7F7F5",borderBottom:"1px solid #E5E5E0",whiteSpace:"nowrap",width:s,position:"sticky",top:0,zIndex:1},children:[o,t.jsx(Y,{col:e,sortKey:p,sortDir:f})]});return t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",style:{background:"#FFFFFF"},children:[t.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 flex-shrink-0",style:{borderBottom:"1px solid #E5E5E0",background:"#FAFAF8"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:700,color:"#1B3A4B"},children:"Tabular View"}),t.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF"},children:W})]}),t.jsx("div",{className:"flex-1"}),t.jsx("input",{type:"text",placeholder:"Search elements…",value:E,onChange:e=>B(e.target.value),className:"px-3 py-1.5 rounded-lg focus:outline-none",style:{width:220,fontSize:j.xs,color:"#1a1a1a",border:"1px solid #E5E5E0",background:"#FFFFFF"}}),t.jsxs("select",{value:g,onChange:e=>I(e.target.value),className:"px-2 py-1.5 rounded-lg focus:outline-none",style:{fontSize:j.xs,color:"#374151",border:"1px solid #E5E5E0",background:"#FFFFFF",cursor:"pointer"},children:[t.jsx("option",{value:"",children:"All layers"}),O.map(e=>t.jsx("option",{value:e,children:D[e]??e},e))]}),t.jsxs("select",{value:b,onChange:e=>M(e.target.value),className:"px-2 py-1.5 rounded-lg focus:outline-none",style:{fontSize:j.xs,color:"#374151",border:"1px solid #E5E5E0",background:"#FFFFFF",cursor:"pointer"},children:[t.jsx("option",{value:"",children:"All kinds"}),V.map(e=>t.jsx("option",{value:e,children:e},e))]}),t.jsxs("div",{style:{fontSize:"11px",color:"#9CA3AF",whiteSpace:"nowrap"},children:[N.length," / ",h.length," elements"]})]}),t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsxs("table",{className:"w-full border-collapse",style:{tableLayout:"fixed"},children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:28}}),t.jsx("col",{style:{width:"30%"}}),t.jsx("col",{style:{width:"13%"}}),t.jsx("col",{style:{width:"13%"}}),t.jsx("col",{style:{width:40}}),t.jsx("col",{style:{width:"20%"}}),k.map(e=>t.jsx("col",{style:{width:"10%"}},e))]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{style:{background:"#F7F7F5",borderBottom:"1px solid #E5E5E0",position:"sticky",top:0,zIndex:1}}),t.jsx(y,{col:"name",label:"Name"}),t.jsx(y,{col:"kind",label:"Kind"}),t.jsx(y,{col:"layer",label:"Layer"}),t.jsx(y,{col:"status",label:"",width:40}),t.jsx(y,{col:"doc",label:"Description"}),k.map(e=>t.jsx(y,{col:e,label:e},e))]})}),t.jsxs("tbody",{children:[N.length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:6+k.length,className:"py-16 text-center",style:{fontSize:"13px",color:"#9CA3AF"},children:E||g||b?"No elements match the current filters":"No elements in scope"})}),N.map(e=>{var c;const o=e.id===v,s=T[e.layer]??"#9CA3AF",n=((c=e.doc)==null?void 0:c.trim().slice(0,100))??"";return t.jsxs("tr",{onClick:()=>S(e.id),className:"cursor-pointer",style:{background:o?"#2DD4A812":"transparent",borderBottom:"1px solid #F0F0ED"},onMouseEnter:l=>{o||(l.currentTarget.style.background="#F7F7F5")},onMouseLeave:l=>{o||(l.currentTarget.style.background="transparent")},children:[t.jsx("td",{className:"px-2",children:o&&t.jsx("span",{style:{color:"#2DD4A8",fontSize:"10px"},children:"▶"})}),t.jsxs("td",{className:"px-3 py-2",children:[t.jsx("div",{style:{fontSize:j.xs,fontWeight:500,color:"#1B3A4B",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.name}),e.shortId&&t.jsx("div",{style:{fontSize:"10px",color:"#9CA3AF",fontFamily:"monospace"},children:e.shortId})]}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{style:{fontSize:"10px",fontWeight:600,color:"#374151"},children:e.kind})}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{className:"px-1.5 py-0.5 rounded",style:{fontSize:"10px",fontWeight:600,background:s+"1A",color:s,whiteSpace:"nowrap"},children:D[e.layer]??e.layer})}),t.jsx("td",{className:"px-3 py-2 text-center",children:t.jsx(R,{element:e})}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{style:{fontSize:j.xs,color:"#6B7280",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:n})}),k.map(l=>t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{style:{fontSize:j.xs,color:"#374151",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},children:e.attributes[l]??""})},l))]},e.id)})]})]})})]})}export{P as TabularView};
@@ -1 +0,0 @@
1
- import{j as s}from"./reactflow-CsCqNKB-.js";import{a as p}from"./zustand-CrhqMOHB.js";import{u as j,f as w}from"./index-CVW92JY7.js";const F=[{id:"risk-control",label:"ISO 14971: Risk → Control",description:"Hazards and hazardous situations traced to risk controls",rowKinds:["Hazard","HazardousSituation"],colKinds:["RiskControlMeasure","SafetyGoal"],relationshipTypes:["mitigates","traceTo","causes","leadsTo"]},{id:"req-test",label:"IEC 62304: Requirement → Test",description:"Software requirements traced to verification tests",rowKinds:["Requirement","Requirement","Requirement"],colKinds:["Test"],relationshipTypes:["verify","satisfy","traceTo"]},{id:"req-function",label:"Requirement → Function",description:"Requirements traced to system/component functions",rowKinds:["Requirement","Requirement","Requirement"],colKinds:["Function","Function"],relationshipTypes:["satisfy","traceTo","allocateTo"]},{id:"function-component",label:"Function → Component",description:"Functions allocated to logical/physical components",rowKinds:["Function","Function"],colKinds:["System","Subsystem","Component","LogicalComponent","SoftwareComponent","PhysicalComponent"],relationshipTypes:["allocateTo","traceTo","composedOf"]},{id:"all",label:"All Elements",description:"Full N×N matrix of all elements and relationships",rowKinds:[],colKinds:[],relationshipTypes:[]}];function N({cell:n,onClick:m}){if(!n||n.rels.length===0)return s.jsx("td",{className:"border",style:{borderColor:"#E5E5E0",width:"28px",height:"28px"}});const u=[...new Set(n.rels.map(f=>f.type))],h=n.rels.length>1?"#2DD4A830":"#2DD4A818";return s.jsx("td",{className:"border text-center cursor-pointer",style:{borderColor:"#E5E5E0",background:h,width:"28px",height:"28px"},title:u.join(", "),onClick:m,children:s.jsx("span",{className:"text-xs font-semibold",style:{color:"#1B3A4B",fontSize:"10px"},children:n.rels.length})})}function K(){const n=j(e=>e.model),m=j(e=>e.selectElement),[u,h]=p.useState("risk-control"),[f,g]=p.useState(null),[v,E]=p.useState(null),d=F.find(e=>e.id===u)||F[0],{rows:c,cols:x,matrix:y}=p.useMemo(()=>{if(!n)return{rows:[],cols:[],matrix:new Map};const e=Object.values(n.elements);let i,r;if(d.rowKinds.length===0&&d.colKinds.length===0)i=e,r=e;else{const t=new Set(d.rowKinds),o=new Set(d.colKinds);i=e.filter(l=>t.has(l.kind)),r=e.filter(l=>o.has(l.kind))}i.sort((t,o)=>t.kind.localeCompare(o.kind)||t.name.localeCompare(o.name)),r.sort((t,o)=>t.kind.localeCompare(o.kind)||t.name.localeCompare(o.name));const a=new Map,k=d.relationshipTypes.length>0?new Set(d.relationshipTypes):null,C=new Set(i.map(t=>t.id)),S=new Set(r.map(t=>t.id));for(const t of n.relationships)if(!(k&&!k.has(t.type))){if(C.has(t.sourceId)&&S.has(t.targetId)){const o=`${t.sourceId}:${t.targetId}`,l=a.get(o);l?l.rels.push(t):a.set(o,{rels:[t]})}if(C.has(t.targetId)&&S.has(t.sourceId)){const o=`${t.targetId}:${t.sourceId}`,l=a.get(o);l?l.rels.push(t):a.set(o,{rels:[t]})}}return{rows:i,cols:r,matrix:a}},[n,d]),b=p.useMemo(()=>{const e=new Set;for(const[i]of y){const r=i.split(":")[0];e.add(r)}return e.size},[y]);return n?s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",style:{background:"#FAFAF8"},children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2",style:{borderBottom:"1px solid #E5E5E0",background:"#FFFFFF"},children:[s.jsx("span",{className:"text-xs font-medium",style:{color:"#6B7280"},children:"Preset:"}),F.map(e=>s.jsx("button",{onClick:()=>h(e.id),className:"px-2 py-1 text-xs rounded-md transition-colors",style:u===e.id?{background:"#2DD4A818",color:"#1B3A4B",fontWeight:600}:{color:"#6B7280"},title:e.description,children:e.label},e.id)),s.jsx("div",{className:"flex-1"}),s.jsxs("span",{className:"text-xs",style:{color:"#9CA3AF"},children:[c.length," rows × ",x.length," cols · ",b,"/",c.length," traced (",c.length>0?Math.round(b/c.length*100):0,"%)"]})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4",children:c.length===0||x.length===0?s.jsx("div",{className:"flex items-center justify-center h-full text-xs",style:{color:"#9CA3AF"},children:"No elements match the selected preset. Try a different preset or add more model elements."}):s.jsxs("table",{className:"border-collapse text-xs",style:{borderColor:"#E5E5E0"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:"border px-2 py-1 sticky left-0 z-10",style:{borderColor:"#E5E5E0",background:"#FFFFFF",minWidth:"140px"}}),x.map(e=>(w[e.layer],s.jsx("th",{className:"border px-1 py-1",style:{borderColor:"#E5E5E0",background:v===e.id?"#F0F0ED":"#FFFFFF",writingMode:"vertical-rl",textOrientation:"mixed",maxWidth:"28px",fontSize:"10px",color:"#374151",cursor:"pointer"},onMouseEnter:()=>E(e.id),onMouseLeave:()=>E(null),onClick:()=>m(e.id),title:`${e.name} (${e.kind})`,children:s.jsx("span",{className:"truncate",style:{maxHeight:"100px",display:"block",overflow:"hidden"},children:e.name})},e.id)))]})}),s.jsx("tbody",{children:c.map(e=>{const i=w[e.layer]||"#6B7280";return s.jsxs("tr",{children:[s.jsx("td",{className:"border px-2 py-1 sticky left-0 z-10 cursor-pointer truncate",style:{borderColor:"#E5E5E0",background:f===e.id?"#F0F0ED":"#FFFFFF",maxWidth:"180px",fontSize:"11px",color:"#374151",borderLeft:`3px solid ${i}`},onMouseEnter:()=>g(e.id),onMouseLeave:()=>g(null),onClick:()=>m(e.id),title:`${e.name} (${e.kind})`,children:e.name}),x.map(r=>{const a=y.get(`${e.id}:${r.id}`)||null;return s.jsx(N,{cell:a,onClick:a?()=>m(e.id):void 0},r.id)})]},e.id)})})]})})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center text-xs",style:{color:"#9CA3AF"},children:"No model loaded"})}export{K as TraceabilityMatrix};