@memoarchitect/architect 0.4.6 → 0.6.0

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 (57) hide show
  1. package/README.md +44 -3
  2. package/dist/assets/AskPanel-CbZrbBeK.js +1 -0
  3. package/dist/assets/ComplianceWizard-s0BYP9sH.js +1 -0
  4. package/dist/assets/{DSMView-B4IEz19F.js → DSMView-C55GKPeE.js} +1 -1
  5. package/dist/assets/{Dashboard-DNRzU1Hk.js → Dashboard-DGiiwpMx.js} +1 -1
  6. package/dist/assets/DhfDashboard-BE5JabB1.js +1 -0
  7. package/dist/assets/{DhfSettingsPanel-C89T0dv7.js → DhfSettingsPanel-BYTUIoK4.js} +1 -1
  8. package/dist/assets/{DhfWorkbench-4gHayn-l.js → DhfWorkbench-CUzn_SQo.js} +3 -3
  9. package/dist/assets/DiagramCanvas-IINBJE7R.js +1 -0
  10. package/dist/assets/DiagramEditor-Ce5_o4RB.js +4 -0
  11. package/dist/assets/{ElementDetailView-AclSjurg.js → ElementDetailView-CZ8SUxsc.js} +2 -2
  12. package/dist/assets/{ImportView-t1dIoZF5.js → ImportView-CdHzpWCe.js} +1 -1
  13. package/dist/assets/{LayerGrid-fSGvqSEj.js → LayerGrid-Bnv8Ww8p.js} +1 -1
  14. package/dist/assets/{LayerTable-D8QCFY1b.js → LayerTable-CeO0t2NX.js} +2 -2
  15. package/dist/assets/{MaxGraphCanvas-DYs6MPuP.js → MaxGraphCanvas-BH29OQf7.js} +6 -6
  16. package/dist/assets/{ModelDiff-CLFqnELG.js → ModelDiff-DoGTGDhy.js} +1 -1
  17. package/dist/assets/OntologyDecompositionDiagram-CerdFGpm.js +1 -0
  18. package/dist/assets/{OntologyViewer-72jTw72H.js → OntologyViewer-BGl9FWMx.js} +2 -2
  19. package/dist/assets/{RelationshipOverlay-BDrBRSPP.js → RelationshipOverlay-DSzjs5U7.js} +1 -1
  20. package/dist/assets/{RelationshipsSection-D1-tuVYo.js → RelationshipsSection-2CEoiF6o.js} +1 -1
  21. package/dist/assets/{ReviewDashboard-BVOe2I5w.js → ReviewDashboard-Du0bEgrG.js} +1 -1
  22. package/dist/assets/ScenarioEditor-BjLWOYwL.js +3 -0
  23. package/dist/assets/{StatisticsDashboard-Dn6lsnKe.js → StatisticsDashboard-BdrXtbp4.js} +1 -1
  24. package/dist/assets/{SysmlCodeEditor-BLcw6hdp.js → SysmlCodeEditor-CGOcUFE7.js} +1 -1
  25. package/dist/assets/SysmlGenerator-CxtxOJ9I.js +1 -0
  26. package/dist/assets/{TabularView-B99xy3H3.js → TabularView-BJQSVDMO.js} +1 -1
  27. package/dist/assets/TraceabilityMatrix-BhDLjHki.js +1 -0
  28. package/dist/assets/{WorkflowWizard-C38DZKOe.js → WorkflowWizard-BWKNcz03.js} +1 -1
  29. package/dist/assets/index-CRFOCEAK.js +3277 -0
  30. package/dist/assets/index-DPzXL4uF.css +1 -0
  31. package/dist/assets/{layout-providers-BAUgp0nu.js → layout-providers-BFnfta4Z.js} +13 -13
  32. package/dist/assets/layout-selection-CtqXOAtf.js +1 -0
  33. package/dist/assets/{reactflow-WKyu73tD.js → reactflow-CX-HDacK.js} +1 -1
  34. package/dist/index.html +3 -3
  35. package/lib/bin/memo-architect.js +39 -3
  36. package/lib/bin/memo-architect.js.map +1 -1
  37. package/lib/commands/dev.d.ts.map +1 -1
  38. package/lib/commands/dev.js +9 -0
  39. package/lib/commands/dev.js.map +1 -1
  40. package/lib/commands/example.d.ts +16 -0
  41. package/lib/commands/example.d.ts.map +1 -0
  42. package/lib/commands/example.js +143 -0
  43. package/lib/commands/example.js.map +1 -0
  44. package/package.json +4 -4
  45. package/dist/assets/AskPanel-D9_AKyYt.js +0 -1
  46. package/dist/assets/ComplianceWizard-BNvT_ic6.js +0 -1
  47. package/dist/assets/DhfDashboard-DguH-rDT.js +0 -1
  48. package/dist/assets/DiagramCanvas-BgfO0AtP.js +0 -1
  49. package/dist/assets/DiagramEditor-CEr6iqBf.js +0 -4
  50. package/dist/assets/DiagramSurface-B_lfUNzV.js +0 -2
  51. package/dist/assets/OntologyDecompositionDiagram-cpmTTMRH.js +0 -1
  52. package/dist/assets/ScenarioEditor-CvOkiRC6.js +0 -3
  53. package/dist/assets/SysmlGenerator-CfBQWovl.js +0 -1
  54. package/dist/assets/TraceabilityMatrix-BAJb0X7G.js +0 -1
  55. package/dist/assets/index-CgRwea72.js +0 -3277
  56. package/dist/assets/index-CnFhl4_e.css +0 -1
  57. package/dist/assets/layout-selection-BQ2WuAEB.js +0 -1
@@ -0,0 +1 @@
1
+ var Ss=Object.defineProperty;var ks=(t,i,n)=>i in t?Ss(t,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[i]=n;var Kt=(t,i,n)=>ks(t,typeof i!="symbol"?i+"":i,n);import{u as vn,j as e,H as C,P as j,N as St,a as eo,B as Sn,E as Qt,R as Es,b as Cs,c as Is,d as Ds,e as Ns,i as As,C as Rs,f as Bs,g as Ms,M as Ts}from"./reactflow-CX-HDacK.js";import{c as Ls,a as d,W as on}from"./zustand-qbFpP9Up.js";/* empty css */import{F as N,S as ie,n as zs,u as L,f as kn,o as $s,g as Ws,D as nn,p as Ve,r as Os,i as sn,q as Ps,R as rn,V as an,C as ln}from"./index-CRFOCEAK.js";import{c as _s,a as Hs,b as Ks,d as Vs,e as Ys,f as Us,g as Xs,h as Gs,i as qs,j as Zs,k as Qs,I as to,l as Js,P as Ft,s as ei,u as ti,m as oi,G as Vt,n as ni,o as si,C as En,p as ii,r as ri,q as Yt,v as ai,t as dn,w as li,x as di,y as ci,B as pi,z as ui,R as xi,A as hi}from"./layout-selection-CtqXOAtf.js";import"./layout-providers-BFnfta4Z.js";import"./elk-B75IRfCd.js";import"web-worker";function gi(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,u=new Map;for(const p of t.relationships)l.has(p.sourceId)||l.set(p.sourceId,[]),l.get(p.sourceId).push(p),u.has(p.targetId)||u.set(p.targetId,[]),u.get(p.targetId).push(p);const m=new Set;m.add(i);const F=[],b=[],I=[[i,0]];for(;I.length>0;){const[p,y]=I.shift();if(y>=a)continue;const v=y+1;if(n==="downstream"||n==="both")for(const f of l.get(p)||[]){const k=f.targetId;if(b.push({fromId:p,toId:k,relType:f.type,relId:f.id}),!m.has(k)){m.add(k);const E=t.elements[k];E&&(F.push({elementId:k,name:E.name,kind:E.kind,layer:E.layer,depth:v,viaRelType:f.type,direction:"downstream"}),I.push([k,v]))}}if(n==="upstream"||n==="both")for(const f of u.get(p)||[]){const k=f.sourceId;if(b.push({fromId:k,toId:p,relType:f.type,relId:f.id}),!m.has(k)){m.add(k);const E=t.elements[k];E&&(F.push({elementId:k,name:E.name,kind:E.kind,layer:E.layer,depth:v,viaRelType:f.type,direction:"upstream"}),I.push([k,v]))}}}return F.sort((p,y)=>p.depth-y.depth||p.name.localeCompare(y.name)),{rootId:i,rootName:r.name,rootKind:r.kind,nodes:F,edges:b}}const Xe=Ls(t=>({subject:null,publish:i=>t({subject:i})})),Ue=t=>Xe.getState().publish(t),Cn=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)},fi=(t,i)=>t.edgeId===i.id||Cn(i).some(n=>t.endpointIds.includes(n)),oo=()=>Xe(t=>t.subject!==null),mi=t=>Xe(i=>{var n;return((n=i.subject)==null?void 0:n.endpointIds.includes(t))??!1}),In=(t,i)=>Xe(n=>{const a=n.subject;return a?a.edgeId===t||i.some(r=>r!==void 0&&a.endpointIds.includes(r)):!1}),bi=t=>`.react-flow__edge[data-id="${CSS.escape(t)}"]`;function yi(){const t=Xe(a=>a.subject),i=vn(a=>t?a.edges.filter(r=>fi(t,r)).map(r=>r.id).join("\0"):"");if(!t)return null;const n=i?i.split("\0").map(bi).join(","):"";return e.jsxs("style",{children:[".react-flow__edge{opacity:0.22;transition:opacity 120ms ease}",n?`${n}{opacity:1}`:""]})}class Fi{constructor(){Kt(this,"providers",[]);Kt(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 Dn=new Fi,wi=[{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)=>_s(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)=>Hs(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)=>Ks(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)=>Vs(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)=>Ys(t,i.contextSystemName)},{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)=>Us(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)=>Xs(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)=>Gs(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)=>qs(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)=>Zs(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)=>Qs(t,i.standard)}];for(const t of wi)Dn.register(t);function ji({data:t}){const i=t,{element:n,layerColor:a,isExpanded:r,hasChildren:l,childCount:u,direction:m,onToggleExpand:F,onToggleDirection:b,showDirectionButton:I,depthBgColor:p,isContainer:y}=i,v=m==="vertical"?"V":"H",f=y&&r;return e.jsxs("div",{style:{background:f?p||"#FAFAF9":"#FFFFFF",borderLeft:f?`2px solid ${a}40`:`3px solid ${a}`,borderTop:`1px solid ${f?a+"30":"#E5E5E0"}`,borderRight:`1px solid ${f?a+"30":"#E5E5E0"}`,borderBottom:`1px solid ${f?a+"30":"#E5E5E0"}`,borderRadius:3,padding:f?"0":"8px 12px",minWidth:f?void 0:"200px",boxShadow:"none",width:"100%",height:"100%",boxSizing:"border-box"},children:[e.jsx(C,{type:"target",position:j.Top,id:"top",style:ht}),e.jsx(C,{type:"source",position:j.Bottom,id:"bottom",style:ht}),e.jsx(C,{type:"target",position:j.Left,id:"left",style:ht}),e.jsx(C,{type:"source",position:j.Right,id:"right",style:ht}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:f?"8px 12px":"0"},children:[l&&e.jsx("button",{onClick:k=>{k.stopPropagation(),F()},style:{width:"20px",height:"20px",borderRadius:2,border:`1px solid ${a}`,background:r?a+"12":"#FFFFFF",color:a,fontSize:N.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:k=>{k.stopPropagation(),b()},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: ${m}. Click to toggle`,children:v}),e.jsx("span",{style:{fontSize:N.md,fontWeight:600,color:f?a:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n.name})]}),!f&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"3px",paddingLeft:l?"26px":"14px"},children:[e.jsx("span",{style:{fontSize:N.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:[u," parts",r?"":" (collapsed)"]})]})]})}const ht={width:"8px",height:"8px",background:"#2DD4A8",border:"1.5px solid #FFFFFF",opacity:0},vi=d.memo(ji),cn={top:j.Top,bottom:j.Bottom,left:j.Left,right:j.Right},Si={top:"bottom",bottom:"top",left:"right",right:"left"},ki="#6B7280",Nn=t=>t?Ft[t]:ki;function An(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 Ei=104,pn=40,un=t=>({opacity:0,width:t,height:t,top:"50%",left:"50%",transform:"translate(-50%, -50%)",border:"none",background:"transparent",pointerEvents:"none"});function Ci({port:t,onMove:i}){const{getZoom:n}=eo(),a=vn(p=>p.transform[2]),r=mi(t.id),l=oo()&&!r,u=t.size??to,m=u+5,F=Nn(t.direction),b=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:b?Ei:72,background:"rgba(255,255,255,0.94)",padding:"1px 3px",borderRadius:4,lineHeight:1.12,...t.side==="left"?{left:m,bottom:"50%",marginBottom:2}:t.side==="right"?{right:m,bottom:"50%",marginBottom:2,textAlign:"right"}:t.side==="top"?{top:m,left:"50%",transform:"translateX(-50%)"}:{bottom:m,left:"50%",transform:"translateX(-50%)"}};return e.jsxs("div",{className:"nodrag nopan",style:{position:"absolute",left:t.x,top:t.y,width:u,height:u,zIndex:t.nested?11:10},children:[e.jsx("div",{onPointerEnter:()=>Ue({endpointIds:[t.id]}),onPointerLeave:()=>Ue(null),onPointerDown:i?p=>{p.preventDefault(),p.stopPropagation();const y=p.clientY,v=t.y,f=E=>i(v+(E.clientY-y)/n()),k=()=>{window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",k)};window.addEventListener("pointermove",f),window.addEventListener("pointerup",k,{once:!0})}:void 0,title:`${t.name}${t.direction?` (${t.direction})`:""}`,style:{position:"absolute",left:"50%",top:"50%",width:pn,height:pn,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 ${F}`,borderRadius:5,boxShadow:r?`0 0 0 4px ${F}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:F,fontSize:t.nested?"10px":"12px",fontWeight:800,lineHeight:1,pointerEvents:"none",transition:"box-shadow 120ms ease, opacity 120ms ease"},children:[An(t.direction,t.side),e.jsx("span",{style:I,children:t.name.replace(/([a-z0-9])([A-Z])/g,"$1​$2")}),[{suffix:"",pos:cn[t.side]},{suffix:Js,pos:cn[Si[t.side]]}].flatMap(p=>[e.jsx(C,{className:"ibd-port-anchor",type:"source",id:`${t.id}${p.suffix}`,position:p.pos,style:un(u),isConnectable:!1},`s${p.suffix}`),e.jsx(C,{className:"ibd-port-anchor",type:"target",id:`${t.id}${p.suffix}`,position:p.pos,style:un(u),isConnectable:!1},`t${p.suffix}`)])]})]})}function xn({side:t,direction:i}){const n=Nn(i),a=to;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:An(i,t)})}const gt={width:8,height:8,background:"#2DD4A8",border:"1.5px solid #FFFFFF",opacity:0};function hn({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?N.md:N.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 gn({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 Ii({id:t,data:i,selected:n,height:a}){const r=i,{label:l,kind:u,color:m,isContainer:F,isFrame:b,ports:I,implicitIn:p,implicitOut:y,onPortMove:v,hasChildren:f,isCollapsed:k,onToggleCollapse:E}=r,[D,O]=d.useState(!1),T=n?ie.selected:b?"none":D?"0 8px 20px rgba(15,23,42,0.12)":F?"0 1px 2px rgba(15,23,42,0.05)":"0 2px 8px rgba(15,23,42,0.08)";return e.jsxs("div",{onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1),style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#FFFFFF",border:b?"1.5px solid #94A3B8":`1px solid ${D?m+"9A":"#CBD5E1"}`,...b?{}:{borderTop:`3px solid ${m}`},borderRadius:b?10:8,boxShadow:T,transition:"box-shadow 150ms ease, border-color 150ms ease",position:"relative"},children:[!b&&e.jsx(St,{nodeId:t,isVisible:n,minWidth:180,minHeight:100,color:"#2563EB",lineStyle:{borderWidth:1},handleStyle:{width:10,height:10,borderRadius:2}}),e.jsx(C,{type:"target",position:j.Top,id:"top",style:gt}),e.jsx(C,{type:"source",position:j.Bottom,id:"bottom",style:gt}),e.jsx(C,{type:"target",position:j.Left,id:"left",style:gt}),e.jsx(C,{type:"source",position:j.Right,id:"right",style:gt}),b?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:m,color:"#FFFFFF",fontSize:9,fontWeight:800,letterSpacing:"0.08em"},children:"IBD"}),e.jsx(hn,{name:l,kind:u,nameColor:"#0F172A",typeColor:"#64748B",frame:!0}),f&&E&&e.jsx(gn,{label:l,isCollapsed:k,onToggle:E,color:m})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minHeight:58,padding:"7px 10px 6px",background:"#FFFFFF",borderBottom:f?"1px solid #E2E8F0":"none",borderRadius:"7px 7px 0 0",overflow:"hidden"},children:[e.jsx(hn,{name:l,kind:u,nameColor:"#0F172A",typeColor:F?m:"#64748B"}),f&&E&&e.jsx(gn,{label:l,isCollapsed:k,onToggle:E,color:m})]}),I.map(A=>e.jsx(Ci,{port:A,onMove:v?K=>{const Z=A.size??to,_=(b||F?70:62)-Z/2,z=Math.max(_,(a??_+Z+18)-Z-18);v(A.id,Math.min(Math.max(K,_),z))}:void 0},A.id)),p&&e.jsx(xn,{side:"left",direction:"in"}),y&&e.jsx(xn,{side:"right",direction:"out"})]})}const Di=d.memo(Ii);function fn(t,i){const n=t.map(r=>({...r}));let a=i;for(;n.length>=2&&a>0;){const r=n[0],l=n[1],u=Math.hypot(l.x-r.x,l.y-r.y);if(u<=a)a-=u,n.shift();else{const m=a/u;n[0]={x:r.x+(l.x-r.x)*m,y:r.y+(l.y-r.y)*m},a=0}}return n}function Ni(t,i){const n=fn(t,i);return fn([...n].reverse(),i).reverse()}const Ai=t=>t.slice(1).reduce((i,n,a)=>i+Math.hypot(n.x-t[a].x,n.y-t[a].y),0);function ft(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],u=t[r],m=t[r+1],F=Math.hypot(u.x-l.x,u.y-l.y),b=Math.hypot(m.x-u.x,m.y-u.y),I=Math.min(i,F/2,b/2),p=u.x-Math.sign(u.x-l.x)*I,y=u.y-Math.sign(u.y-l.y)*I,v=u.x+Math.sign(m.x-u.x)*I,f=u.y+Math.sign(m.y-u.y)*I;n+=` L ${p},${y} Q ${u.x},${u.y} ${v},${f}`}const a=t[t.length-1];return`${n} L ${a.x},${a.y}`}function Ri(t){let i=0,n=-1;for(let u=1;u<t.length;u++){const m=Math.abs(t[u].x-t[u-1].x)+Math.abs(t[u].y-t[u-1].y);m>n&&(n=m,i=u)}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 Bi(t){var k,E,D,O,T,A,K,Z,_,z,re;const{getZoom:i}=eo(),n=In(t.id,[t.source,t.target,(k=t.data)==null?void 0:k.sourcePortId,(E=t.data)==null?void 0:E.targetPortId]),a=oo()&&!n,r=((D=t.data)==null?void 0:D.points)??[];if(r.length<2)return null;const l=String(((O=t.style)==null?void 0:O.stroke)??"#2563EB"),u=Number(((T=t.style)==null?void 0:T.strokeWidth)??2),m=n?{...t.style,strokeWidth:u+1.4}:t.style,F=((A=t.data)==null?void 0:A.labelPoint)??Ri(r),b=Math.min(28/Math.max(i(),.1),Ai(r)*.3),I=Ni(r,b),p=(K=t.data)==null?void 0:K.onRouteChange,y=(Z=t.data)==null?void 0:Z.onSelect,v=!!((_=t.data)!=null&&_.flowAnimation),f=r.length===2?[{index:1,a:r[0],b:r[1],straight:!0}]:r.slice(1).map((w,pe)=>({index:pe+1,a:r[pe],b:w,straight:!1})).filter(w=>w.index>=2&&w.index<=r.length-2);return e.jsxs(e.Fragment,{children:[n&&e.jsx("path",{d:ft(r),fill:"none",stroke:l,strokeOpacity:.22,strokeWidth:u+9,strokeLinecap:"round",pointerEvents:"none"}),e.jsx(Sn,{id:t.id,path:ft(r),style:m,markerEnd:t.markerEnd}),v&&e.jsx("path",{d:ft(r),fill:"none",stroke:String(((z=t.style)==null?void 0:z.stroke)??"#2563EB"),strokeWidth:Math.max(2,Number(((re=t.style)==null?void 0:re.strokeWidth)??2)),className:"memo-ibd-flow"}),I.length>=2&&e.jsx("path",{d:ft(I),fill:"none",stroke:"transparent",strokeWidth:18/Math.max(i(),.1),pointerEvents:"stroke",cursor:"pointer",onClick:w=>y==null?void 0:y(w)}),t.label?e.jsx(Qt,{children:e.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${F.x}px, ${F.y}px)`,fontSize:N.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&&p?f.map(w=>{const pe=(w.a.x+w.b.x)/2,ee=(w.a.y+w.b.y)/2;return e.jsx(Qt,{children:e.jsx("div",{className:"nodrag nopan",title:"Drag connector segment",onPointerDown:U=>{U.preventDefault(),U.stopPropagation();const Ge=U.clientX,qe=U.clientY,ye=Ee=>{const ne=(Ee.clientX-Ge)/i(),ue=(Ee.clientY-qe)/i();if(w.straight){if(Math.abs(ue)>=Math.abs(ne)){const se=w.a.y+ue;p([w.a,{x:w.a.x,y:se},{x:w.b.x,y:se},w.b])}else{const se=(w.a.x+w.b.x)/2+ne;p([w.a,{x:se,y:w.a.y},{x:se,y:w.b.y},w.b])}return}const G=r.map(se=>({...se}));w.a.y===w.b.y?(G[w.index-1].y=w.a.y+ue,G[w.index].y=w.b.y+ue):(G[w.index-1].x=w.a.x+ne,G[w.index].x=w.b.x+ne),p(G)},ke=()=>{window.removeEventListener("pointermove",ye),window.removeEventListener("pointerup",ke)};window.addEventListener("pointermove",ye),window.addEventListener("pointerup",ke,{once:!0})},style:{position:"absolute",transform:`translate(-50%, -50%) translate(${pe}px, ${ee}px)`,width:12,height:12,borderRadius:3,background:"#FFFFFF",border:"2px solid #2563EB",boxShadow:"0 1px 4px rgba(15,23,42,0.22)",cursor:w.a.y===w.b.y?"ns-resize":"ew-resize",pointerEvents:"all",touchAction:"none",zIndex:20}})},`route-${w.index}`)}):null]})}const Mi=d.memo(Bi);function Ti({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 Li({data:t,selected:i}){const n=t,{nodeType:a,label:r,laneColor:l,layerColor:u,inPorts:m,outPorts:F}=n,[b,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:ie.sm},children:e.jsx(C,{type:"source",position:n.flowDirection==="vertical"?j.Bottom:j.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:ie.sm},children:[e.jsx("div",{style:{width:14,height:14,borderRadius:"50%",background:"#374151"}}),e.jsx(C,{type:"target",position:n.flowDirection==="vertical"?j.Top:j.Left,style:{background:"#374151",width:6,height:6}})]});if(a==="fork"||a==="join"){const f=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:ie.sm},children:[e.jsx(C,{type:"target",position:f?j.Top:j.Left,style:{background:"#374151",width:6,height:6,border:"none"}}),e.jsx(C,{type:"source",position:f?j.Bottom:j.Right,style:{background:"#374151",width:6,height:6,border:"none"}})]})}const p=l||u||"#9CA3AF";if(n.isFrame)return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:`${p}08`,border:`1.5px solid ${p}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:f=>{f.stopPropagation(),n.onToggleExpand()},onDoubleClick:f=>f.stopPropagation(),style:{width:16,height:16,flexShrink:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${p}66`,borderRadius:4,background:"#FFFFFF",color:p,fontSize:11,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"−"}),n.onDrillIn&&e.jsx(Ti,{onDrillIn:n.onDrillIn,color:p,label:r}),e.jsx("span",{style:{fontSize:N.md,fontWeight:700,color:p,whiteSpace:"nowrap"},children:r}),n.allocatedTo&&e.jsxs("span",{style:{fontSize:"9px",color:"#9CA3AF",whiteSpace:"nowrap"},children:["→"," ",n.allocatedTo]})]}),e.jsx(C,{type:"target",position:n.flowDirection==="vertical"?j.Top:j.Left,style:{background:p,width:8,height:8,border:"2px solid #FFFFFF"}}),e.jsx(C,{type:"source",position:n.flowDirection==="vertical"?j.Bottom:j.Right,style:{background:p,width:8,height:8,border:"2px solid #FFFFFF"}})]});const y=18,v=Math.max(m.length*y,F.length*y,0);return e.jsxs("div",{onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),style:{background:"#FFFFFF",border:`1.5px solid ${p}`,borderRadius:3,minWidth:"140px",boxShadow:i?"0 0 0 3px #2DD4A8, 0 4px 12px rgba(45, 212, 168, 0.35)":b?`0 0 0 2px ${p}22`:"none",transition:"box-shadow 150ms ease",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"8px 14px",fontSize:N.md,fontWeight:600,color:"#1a1a1a",background:`${p}0D`,borderBottom:v>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:f=>{f.stopPropagation(),n.onDrillIn()},onDoubleClick:f=>f.stopPropagation(),style:{float:"right",marginLeft:4,width:18,height:18,padding:0,border:`1px solid ${p}`,borderRadius:2,background:"#FFFFFF",color:p,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:f=>{f.stopPropagation(),n.onToggleExpand()},style:{float:"right",marginLeft:8,width:18,height:18,padding:0,border:`1px solid ${p}`,borderRadius:2,background:"#FFFFFF",color:p,fontSize:13,fontWeight:700,lineHeight:"16px",cursor:"pointer"},children:n.isExpanded?"−":"+"})]}),v>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:m.map(f=>e.jsxs("div",{style:{fontSize:N.badge,color:"#6B7280",paddingLeft:"8px",display:"flex",alignItems:"center",height:`${y}px`,gap:"4px"},children:[e.jsx("span",{style:{width:"6px",height:"6px",borderRadius:"50%",background:"#3498DB",flexShrink:0}}),f]},`in-${f}`))}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px",alignItems:"flex-end"},children:F.map(f=>e.jsxs("div",{style:{fontSize:N.badge,color:"#6B7280",paddingRight:"8px",display:"flex",alignItems:"center",height:`${y}px`,gap:"4px"},children:[f,e.jsx("span",{style:{width:"6px",height:"6px",borderRadius:"50%",background:"#E67E22",flexShrink:0}})]},`out-${f}`))})]}),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(C,{type:"target",position:n.flowDirection==="vertical"?j.Top:j.Left,style:{background:p,width:8,height:8,border:"2px solid #FFFFFF"}}),e.jsx(C,{type:"source",position:n.flowDirection==="vertical"?j.Bottom:j.Right,style:{background:p,width:8,height:8,border:"2px solid #FFFFFF"}})]})}const zi=d.memo(Li);function $i({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:zs.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:N.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 Wi=d.memo($i);function mn({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 bn({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 mt={width:8,height:8,border:"none",background:"transparent",opacity:0};function Ut(){return e.jsxs(e.Fragment,{children:[e.jsx(C,{type:"target",position:j.Top,id:"top",style:mt}),e.jsx(C,{type:"source",position:j.Bottom,id:"bottom",style:mt}),e.jsx(C,{type:"target",position:j.Left,id:"left",style:mt}),e.jsx(C,{type:"source",position:j.Right,id:"right",style:mt})]})}function Oi({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:ie.sm,display:"flex",flexDirection:"column",justifyContent:"center"},title:n.kind,children:[e.jsx(Ut,{}),e.jsx("span",{style:{fontSize:N.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?ie.selected:"none",position:"relative"},children:[e.jsx(Ut,{}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px 0"},children:[n.onToggleCollapse&&!n.isMachine&&e.jsx(bn,{collapsed:!1,onToggle:n.onToggleCollapse,color:n.color}),n.onDrillIn&&!n.isMachine&&e.jsx(mn,{onDrillIn:n.onDrillIn,color:n.color,label:n.label}),e.jsx("span",{style:{fontSize:N.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?ie.selected:a?"0 8px 20px rgba(15,23,42,0.12)":ie.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(Ut,{}),e.jsx("span",{style:{fontSize:N.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(bn,{collapsed:!0,onToggle:n.onToggleCollapse,color:n.color}),n.onDrillIn&&e.jsx(mn,{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 Pi=d.memo(Oi),Jt="#3498DB";function _i({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 ${Jt}`,borderRadius:8,boxShadow:ie.md,textAlign:"center",fontSize:N.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 ${Jt}66`}})]})}const Hi=d.memo(_i);function Ki({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:N.sm,fontWeight:700,color:"#1B3A4B"},children:i.label}),i.scenario&&e.jsxs("span",{style:{fontSize:N.xs,color:"#6B7280"},children:["realizes ",i.scenario]})]})})}const Vi=d.memo(Ki),bt={width:6,height:6,border:"none",background:"transparent",opacity:0};function Yi({data:t,selected:i}){const n=t;return e.jsxs("div",{style:{width:14,height:14,borderRadius:"50%",background:"#FFFFFF",border:`3px solid ${Jt}`,boxShadow:i?ie.selected:ie.sm,position:"relative"},title:n.kind,children:[e.jsx(C,{type:"source",id:"right",position:j.Right,style:bt}),e.jsx(C,{type:"target",id:"right",position:j.Right,style:bt}),e.jsx(C,{type:"source",id:"left",position:j.Left,style:bt}),e.jsx(C,{type:"target",id:"left",position:j.Left,style:bt}),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 Ui=d.memo(Yi),jt={opacity:0,width:1,height:1},Xi=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(C,{type:"target",position:j.Left,style:jt}),e.jsx(C,{type:"source",position:j.Right,style:jt})]})}),Gi=d.memo(function({data:i}){const n=i,a=n.side==="right"?j.Left:j.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.jsxs("svg",{width:"38",height:"54",viewBox:"0 0 38 54","aria-hidden":"true",fill:"none",stroke:n.color??"#334155",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"})]}),e.jsx("span",{children:n.label}),e.jsx(C,{type:"source",position:a,style:jt}),e.jsx(C,{type:"target",position:a,style:jt})]})}),qi=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 Zi(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],u=t[r],m=t[r+1],F=Math.min(i,Math.abs(u.x-l.x)/2+Math.abs(u.y-l.y)/2),b=Math.min(i,Math.abs(m.x-u.x)/2+Math.abs(m.y-u.y)/2),I={x:u.x+Math.sign(l.x-u.x)*F,y:u.y+Math.sign(l.y-u.y)*F},p={x:u.x+Math.sign(m.x-u.x)*b,y:u.y+Math.sign(m.y-u.y)*b};n+=` L ${I.x},${I.y} Q ${u.x},${u.y} ${p.x},${p.y}`}const a=t[t.length-1];return`${n} L ${a.x},${a.y}`}const Qi=d.memo(function(i){var y,v,f,k,E;const n=In(i.id,[i.source,i.target]),a=oo()&&!n,r=((y=i.data)==null?void 0:y.routing)??"rounded",l=Array.isArray((v=i.data)==null?void 0:v.points)?i.data.points:[],u=l.length>=2?l:[{x:i.sourceX,y:i.sourceY},{x:i.targetX,y:i.targetY}],F=r==="straight"?`M ${i.sourceX},${i.sourceY} L ${i.targetX},${i.targetY}`:Zi(u,r==="elbow"?0:r==="rounded"?16:r==="curved"?30:42),b=((f=i.data)==null?void 0:f.labelPoint)??u[Math.floor(u.length/2)]??{x:(i.sourceX+i.targetX)/2,y:(i.sourceY+i.targetY)/2},I=String(((k=i.style)==null?void 0:k.stroke)??"#64748B"),p=Number(((E=i.style)==null?void 0:E.strokeWidth)??1.5);return e.jsxs(e.Fragment,{children:[n&&e.jsx("path",{d:F,fill:"none",stroke:I,strokeOpacity:.22,strokeWidth:p+9,strokeLinecap:"round",pointerEvents:"none"}),e.jsx(Sn,{path:F,style:n?{...i.style,strokeWidth:p+1.4}:i.style}),i.label&&e.jsx(Qt,{children:e.jsx("div",{className:"nodrag nopan",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${b.x}px,${b.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})})]})}),yt={opacity:0,width:1,height:1};function Rn(){return e.jsxs(e.Fragment,{children:[e.jsx(C,{type:"target",position:j.Left,style:yt}),e.jsx(C,{type:"source",position:j.Right,style:yt}),e.jsx(C,{type:"target",position:j.Top,style:yt}),e.jsx(C,{type:"source",position:j.Bottom,style:yt})]})}const Ji=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(Rn,{})]})}),er=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:"grid",placeItems:"center",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:[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(Rn,{})]})}),tr=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 T;const r=n,[l,u]=d.useState(!1),[m,F]=d.useState(""),[b,I]=d.useState(!1),p=d.useRef(null),y=d.useCallback(()=>{F(r.label),u(!0),setTimeout(()=>{var A;(A=p.current)==null||A.select()},10)},[r.label]),v=d.useCallback(()=>{var K;u(!1);const A=m.trim();A&&A!==r.label&&((K=r.onInlineEdit)==null||K.call(r,i,A))},[m,r,i]),f=d.useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),v()),A.key==="Escape"&&u(!1)},[v]),k=d.useCallback(A=>{var K;A.preventDefault(),(K=r.onContextMenu)==null||K.call(r,A,i)},[r,i]),E=r.bgColor??"#FFFFFF",D=r.color,O={background:D,border:"2px solid #FFFFFF",width:10,height:10,opacity:b||a?1:0,transition:"opacity 0.15s"};return e.jsxs("div",{onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),onContextMenu:k,onDoubleClick:y,style:{minWidth:120,minHeight:40,background:E,borderLeft:`3px solid ${D}`,borderRadius:8,boxShadow:a?`0 0 0 2px ${D}, 0 4px 12px ${D}44`:b?"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(St,{minWidth:80,minHeight:36,maxWidth:600,maxHeight:400,color:D,lineStyle:{borderColor:D},handleStyle:{background:D,border:"2px solid #fff",width:10,height:10,borderRadius:2}}),e.jsxs("div",{style:{padding:"8px 12px",userSelect:"none"},children:[e.jsx("div",{style:{fontSize:"9px",fontWeight:700,color:D,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:2},children:r.kind}),l?e.jsx("input",{ref:p,value:m,onChange:A=>F(A.target.value),onBlur:v,onKeyDown:f,onClick:A=>A.stopPropagation(),autoFocus:!0,style:{fontSize:N.sm,fontWeight:500,color:"#1a1a1a",background:"transparent",border:"none",outline:"none",width:"100%",padding:0}}):e.jsx("div",{style:{fontSize:N.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…"})]}),!!((T=r.compartments)!=null&&T.length)&&e.jsx("div",{style:{borderTop:"1px solid #EDEDEA",padding:"5px 12px 7px",userSelect:"none"},children:r.compartments.map(A=>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:A.key}),e.jsx("span",{style:{color:"#4B5563",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis"},children:A.value})]},A.key))}),e.jsx(C,{type:"target",position:j.Top,style:{...O,top:-5}}),e.jsx(C,{type:"source",position:j.Bottom,style:{...O,bottom:-5},id:"bottom"}),e.jsx(C,{type:"source",position:j.Right,style:{...O,right:-5},id:"right"}),e.jsx(C,{type:"target",position:j.Left,style:{...O,left:-5}})]})});function Xt({collapsed:t,onToggleCollapse:i,elementIds:n=[]}){const a=L(y=>y.model),r=L(y=>y.selectedElementId),l=L(y=>y.inspectElement),[u,m]=d.useState(""),[F,b]=d.useState(new Set),I=d.useMemo(()=>{var k;if(!a)return[];const y=u.trim().toLowerCase(),v=new Map,f=new Set(n);for(const E of n){const D=(k=a.elements[E])==null?void 0:k.allocatedTo;D&&f.add(D)}for(const E of f){const D=a.elements[E];D&&(y&&!D.name.toLowerCase().includes(y)&&!D.kind.toLowerCase().includes(y)||(v.has(D.kind)||v.set(D.kind,[]),v.get(D.kind).push(D)))}return[...v.entries()].map(([E,D])=>({kind:E,elements:D.sort((O,T)=>O.name.localeCompare(T.name))})).sort((E,D)=>E.kind.localeCompare(D.kind))},[a,n,u]),p=y=>b(v=>{const f=new Set(v);return f.has(y)?f.delete(y):f.add(y),f});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:N.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:u,onChange:y=>m(y.target.value),placeholder:"Search elements…",className:"w-full px-2 py-1 rounded focus:outline-none",style:{fontSize:N.xs,background:"#F0F0ED",border:"1px solid #E5E5E0",color:"#374151"}})}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[I.map(y=>{var k;const v=F.has(y.kind),f=kn[(k=y.elements[0])==null?void 0:k.layer]??"#6B7280";return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>p(y.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:f},children:v?"▶":"▼"}),e.jsx("span",{className:"truncate",style:{fontSize:10,color:f,fontWeight:700},children:y.kind}),e.jsx("span",{style:{fontSize:9,color:"#9CA3AF",marginLeft:"auto"},children:y.elements.length})]}),!v&&y.elements.map(E=>{const D=r===E.id;return e.jsxs("button",{onClick:()=>l(E.id),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left",style:{border:"none",cursor:"pointer",fontSize:N.xs,background:D?"#DDF7EF":"transparent",color:D?"#116149":"#374151",fontWeight:D?600:400},title:`Highlight ${E.name} in diagram`,children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2,background:f,flexShrink:0}}),e.jsx("span",{className:"truncate flex-1",children:E.name})]},E.id)})]},y.kind)}),I.length===0&&e.jsx("div",{className:"p-3 text-center",style:{color:"#9CA3AF",fontSize:N.xs},children:u?"No matching elements":"No elements in this diagram"})]})]})}function J({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:N.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 wt(){return e.jsx("div",{style:{height:1,background:"#E5E5E0",margin:"2px 0"}})}function Bn({x:t,y:i,onClose:n,children:a}){const r=d.useRef(null);d.useEffect(()=>{const F=I=>{r.current&&!r.current.contains(I.target)&&n()},b=I=>{I.key==="Escape"&&n()};return document.addEventListener("mousedown",F),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",F),document.removeEventListener("keydown",b)}},[n]);const l=210,u=Math.min(t,window.innerWidth-l-8),m=Math.min(i,window.innerHeight-200);return e.jsx("div",{ref:r,className:"fixed z-50 rounded-xl overflow-hidden py-1",style:{left:u,top:m,minWidth:l,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.14)"},children:a})}const nr=[{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 sr({x:t,y:i,nodeId:n,nodeKind:a,onClose:r,onEditName:l,onChangeColor:u,onRemoveFromDiagram:m,onDeleteFromModel:F,onLinkRisk:b,onLinkRequirement:I,onShowProperties:p,onFocusElement:y,onShowInCatalog:v,onShowRelMatrix:f,onOpenSource:k,onViewKindInOntology:E}){const[D,O]=d.useState(!1);return e.jsxs(Bn,{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})]}),p&&e.jsx(J,{label:"Show Properties",icon:"ℹ",onClick:()=>{r(),p()}}),v&&e.jsx(J,{label:"Show in Catalog",icon:"☰",onClick:()=>{r(),v()}}),y&&e.jsx(J,{label:"Focus on Element",icon:"◎",onClick:()=>{r(),y()}}),f&&e.jsx(J,{label:"Show Relationship Matrix",icon:"☷",onClick:()=>{r(),f()}}),E&&e.jsx(J,{label:"View Kind in Ontology",icon:"⬡",onClick:()=>{r(),E()}}),k&&e.jsx(J,{label:"Open Source File",icon:"⟨/⟩",onClick:()=>{r(),k()}}),(p||v||y||f||E||k)&&e.jsx(wt,{}),e.jsx(J,{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:N.xs},onMouseEnter:T=>{O(!0),T.currentTarget.style.background="#F7F7F5"},onMouseLeave:T=>{T.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:"▶"})]}),D&&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:()=>O(!0),onMouseLeave:()=>O(!1),children:nr.map(T=>e.jsxs("button",{onClick:()=>{r(),u(T.value)},className:"w-full flex items-center gap-2.5 px-3 py-1.5",style:{background:"none",border:"none",cursor:"pointer"},onMouseEnter:A=>{A.currentTarget.style.background="#F7F7F5"},onMouseLeave:A=>{A.currentTarget.style.background="none"},children:[e.jsx("div",{style:{width:14,height:14,borderRadius:3,flexShrink:0,background:T.value||"#E5E5E0",border:"1px solid #D1D5DB"}}),e.jsx("span",{style:{fontSize:N.xs,color:"#374151"},children:T.label})]},T.value))})]}),e.jsx(wt,{}),b&&e.jsx(J,{label:"Link Risk",icon:"⚠️",onClick:()=>{r(),b()}}),I&&e.jsx(J,{label:"Link Requirement",icon:"📋",onClick:()=>{r(),I()}}),(b||I)&&e.jsx(wt,{}),e.jsx(J,{label:"Remove from diagram",icon:"↩️",onClick:()=>{r(),m()}}),e.jsx(J,{label:"Delete from model",icon:"🗑️",danger:!0,onClick:()=>{window.confirm(`Delete ${n} from the model? This cannot be undone.`)&&(r(),F())}})]})}const ir=[{label:"Auto",value:""},{label:"Red",value:"#EF4444"},{label:"Blue",value:"#3B82F6"},{label:"Green",value:"#10B981"},{label:"Orange",value:"#F59E0B"},{label:"Gray",value:"#6B7280"}];function rr({x:t,y:i,edgeId:n,relType:a,onClose:r,onChangeStyle:l,onChangeColor:u,onToggleLabel:m,onDelete:F}){return e.jsxs(Bn,{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(b=>e.jsx("button",{onClick:()=>{r(),l(b)},style:{fontSize:"10px",padding:"2px 8px",border:"1px solid #E5E5E0",borderRadius:4,cursor:"pointer",background:"#F7F7F5",color:"#374151"},children:b},b))]}),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"}),ir.map(b=>e.jsx("button",{onClick:()=>{r(),u(b.value)},title:b.label,style:{width:16,height:16,borderRadius:"50%",background:b.value||"#E5E5E0",border:"1px solid #D1D5DB",cursor:"pointer"}},b.value))]}),e.jsx(wt,{}),e.jsx(J,{label:"Toggle label",icon:"🏷️",onClick:()=>{r(),m()}}),e.jsx(J,{label:"Delete edge",icon:"🗑️",danger:!0,onClick:()=>{r(),F()}})]})}const ar=d.memo(function({id:i,data:n,selected:a}){const r=n,l=r.color??r.layerColor??"#E67E22",u=80,m=d.useCallback(F=>{var b;F.preventDefault(),(b=r.onContextMenu)==null||b.call(r,F,i)},[r,i]);return e.jsxs("div",{style:{width:u,height:u,position:"relative"},onContextMenu:m,children:[a&&e.jsx(St,{minWidth:60,minHeight:60}),e.jsx("svg",{width:u,height:u,style:{position:"absolute",top:0,left:0},children:e.jsx("polygon",{points:`${u/2},4 ${u-4},${u/2} ${u/2},${u-4} 4,${u/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(C,{type:"target",position:j.Top,style:{background:l,border:"2px solid #fff"}}),e.jsx(C,{type:"source",position:j.Right,style:{background:l,border:"2px solid #fff"},id:"right"}),e.jsx(C,{type:"source",position:j.Bottom,style:{background:l,border:"2px solid #fff"},id:"bottom"}),e.jsx(C,{type:"target",position:j.Left,style:{background:l,border:"2px solid #fff"}})]})}),lr=d.memo(function({id:i,data:n,selected:a}){const r=n,l=(r.orientation??"horizontal")==="horizontal",u=l?120:8,m=l?8:60,F=d.useCallback(b=>{var I;b.preventDefault(),(I=r.onContextMenu)==null||I.call(r,b,i)},[r,i]);return e.jsxs("div",{style:{width:u,height:m,background:"#1a1a1a",borderRadius:4,position:"relative"},title:r.nodeType==="join"?"Join (synchronization)":"Fork (parallel)",onContextMenu:F,children:[a&&e.jsx(St,{minWidth:40,minHeight:6}),l?e.jsxs(e.Fragment,{children:[e.jsx(C,{type:"target",position:j.Left,style:{background:"#2DD4A8",border:"2px solid #fff",left:-1}}),e.jsx(C,{type:"source",position:j.Top,style:{background:"#2DD4A8",border:"2px solid #fff",top:-1},id:"top"}),e.jsx(C,{type:"source",position:j.Bottom,style:{background:"#2DD4A8",border:"2px solid #fff",bottom:-1},id:"bottom"}),e.jsx(C,{type:"source",position:j.Right,style:{background:"#2DD4A8",border:"2px solid #fff",right:-1},id:"right"})]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{type:"target",position:j.Top,style:{background:"#2DD4A8",border:"2px solid #fff",top:-1}}),e.jsx(C,{type:"source",position:j.Left,style:{background:"#2DD4A8",border:"2px solid #fff",left:-1},id:"left"}),e.jsx(C,{type:"source",position:j.Right,style:{background:"#2DD4A8",border:"2px solid #fff",right:-1},id:"right"}),e.jsx(C,{type:"source",position:j.Bottom,style:{background:"#2DD4A8",border:"2px solid #fff",bottom:-1},id:"bottom"})]})]})}),dr=d.memo(function({id:i,data:n}){const a=n,r=a.nodeType==="start",l=32,u=d.useCallback(m=>{var F;m.preventDefault(),(F=a.onContextMenu)==null||F.call(a,m,i)},[a,i]);return e.jsxs("div",{style:{width:l,height:l,position:"relative"},onContextMenu:u,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(C,{type:"source",position:j.Bottom,style:{background:"#1a1a1a",border:"2px solid #fff"}}):e.jsx(C,{type:"target",position:j.Top,style:{background:"#1a1a1a",border:"2px solid #fff"}})]})}),cr="#ECEBE6",vt="#1B3A4B",no="#5B6470",pr="0 1px 2px rgba(0,0,0,0.16), 0 0 0 0.5px rgba(0,0,0,0.05)",be=(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}),H={arrowRight:({size:t=16})=>be(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})=>be(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})=>be(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})=>be(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})=>be(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})=>be(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})=>be(t,e.jsx("path",{d:"M4 5h16l-6.2 7.4V19l-3.6 1.8v-8.4z"})),back:({size:t=16})=>be(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M11 5l-6 7 6 7"}),e.jsx("path",{d:"M5 12h14"})]}))};function ce(){return e.jsx("span",{"aria-hidden":"true",style:{width:1,height:18,background:"#E2E1DB",margin:"0 3px",borderRadius:1}})}function Gt({options:t,value:i,onChange:n}){return e.jsx("div",{role:"tablist",style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,background:cr,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?vt:no,background:r?"#FFFFFF":"transparent",boxShadow:r?pr:"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 ur({children:t}){return e.jsx("div",{style:{display:"inline-flex",alignItems:"center",background:"#FFFFFF",border:"1px solid #E2E1DB",borderRadius:9,overflow:"hidden"},children:on.Children.toArray(t).map((i,n)=>e.jsxs(on.Fragment,{children:[n>0&&e.jsx("span",{"aria-hidden":"true",style:{width:1,alignSelf:"stretch",background:"#EDECE7"}}),i]},n))})}function oe({icon:t,label:i,onClick:n,active:a=!1,title:r,ariaExpanded:l,ariaLabel:u}){return e.jsxs("button",{onClick:n,title:r,"aria-label":u,"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":no,background:a?vt:"transparent",transition:"background 140ms ease, color 140ms ease"},children:[t,i&&e.jsx("span",{children:i})]})}function Ye({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?vt:"#E2E1DB"}`,cursor:"pointer",color:a?"#FFFFFF":no,background:a?vt:"#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 yn="memo-layout-progress";if(typeof document<"u"&&!document.getElementById(yn)){const t=document.createElement("style");t.id=yn,t.textContent="@keyframes memo-layout-progress { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }",document.head.appendChild(t)}const xr={background:"#F7F7F5"},hr={padding:.08,maxZoom:2},gr={background:"#FFFFFF"},fr={hideAttribution:!0},mr=[20,20],br=50,Fn=8e3,yr=90;function Fr(t,i){return new Promise((n,a)=>{const r=window.setTimeout(()=>a(new Error(`${i} layout exceeded ${Fn/1e3}s`)),Fn);t.then(l=>{window.clearTimeout(r),n(l)},l=>{window.clearTimeout(r),a(l)})})}function wn(t,i){const n=new Map(t.map(p=>[p.id,p])),a=new Map,r=p=>{const y=a.get(p);if(y)return y;const v=n.get(p),f=v.parentId?r(v.parentId):{x:0,y:0},k={x:f.x+v.position.x,y:f.y+v.position.y};return a.set(p,k),k},l=p=>{var y,v;return{width:Number(p.width??((y=p.style)==null?void 0:y.width)??0),height:Number(p.height??((v=p.style)==null?void 0:v.height)??0)}},u=i.flatMap(p=>{var D,O,T,A,K,Z;const y=(_,z,re)=>{var w,pe;if(typeof z=="string"){const ee=(((pe=(w=n.get(_))==null?void 0:w.data)==null?void 0:pe.ports)??[]).find(U=>U.id===z);if(ee){const U=ee.size??20;return{x:ee.x+U/2,y:ee.y+U/2}}}return re},v=y(p.source,(D=p.data)==null?void 0:D.sourcePortId,(O=p.data)==null?void 0:O.sourceOffset),f=y(p.target,(T=p.data)==null?void 0:T.targetPortId,(A=p.data)==null?void 0:A.targetOffset);if(!v||!f||!n.has(p.source)||!n.has(p.target))return[];const k=r(p.source),E=r(p.target);return[{id:p.id,source:{x:k.x+v.x,y:k.y+v.y},target:{x:E.x+f.x,y:E.y+f.y},sourceNodeId:p.source,targetNodeId:p.target,sourceSide:(K=p.data)==null?void 0:K.sourceSide,targetSide:(Z=p.data)==null?void 0:Z.targetSide}]});if(u.length===0)return i;const m=t.filter(p=>!p.data.isFrame).map(p=>({id:p.id,...r(p.id),...l(p)})),F=new Map(u.map(p=>[p.id,p])),b=u.filter(p=>{var y,v;return!((v=(y=i.find(f=>f.id===p.id))==null?void 0:y.data)!=null&&v.manualRoute)}),I=hi(b,m);return i.map(p=>{var v;const y=F.get(p.id);if(!y)return p;if((v=p.data)!=null&&v.manualRoute){const f=[...p.data.points??[]];if(f.length>=2)return f[0]=y.source,f[f.length-1]=y.target,{...p,data:{...p.data,points:f}}}return I.has(p.id)?{...p,data:{...p.data,points:I.get(p.id)}}:p})}function wr({x:t,y:i,onConfirm:n,onCancel:a}){const[r,l]=d.useState(""),u=d.useRef(null);d.useEffect(()=>{var b;(b=u.current)==null||b.focus()},[]),d.useEffect(()=>{const b=I=>{const p=document.getElementById("quick-create-popup");p&&!p.contains(I.target)&&a()};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[a]);const m=Math.min(t,window.innerWidth-220),F=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:m,top:F,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:N.xs,color:"#9CA3AF",fontWeight:600},children:"New Element"}),e.jsxs("div",{className:"px-2 py-2",children:[e.jsx("input",{ref:u,value:r,onChange:b=>l(b.target.value),placeholder:"Element name…",className:"w-full px-2 py-1.5 rounded focus:outline-none",style:{fontSize:N.xs,border:"1px solid #E5E5E0",background:"#F7F7F5",color:"#1a1a1a"},onKeyDown:b=>{b.key==="Enter"&&r.trim()&&(b.preventDefault(),n(r.trim())),b.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:N.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:N.xs,padding:"4px 8px",background:"#F7F7F5",color:"#6B7280",border:"1px solid #E5E5E0",borderRadius:6,cursor:"pointer"},children:"Cancel"})]})]})]})}function qt({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 jn(t,i){if(!t||!i)return[];const n=new Map;for(const u of t.relationships)En.has(u.type)&&!n.has(u.targetId)&&n.set(u.targetId,u.sourceId);const a=[i],r=new Set(a);let l=i;for(;n.has(l);){const u=n.get(l);if(r.has(u))break;a.unshift(u),r.add(u),l=u}return a}function Zt({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(ce,{}),e.jsx(Ye,{icon:e.jsx(H.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,u)=>{const m=u===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:m,className:"text-xs font-medium",style:{color:m?"#1a1a1a":"#2563EB",fontWeight:m?700:500,cursor:m?"default":"pointer"},title:m?void 0:`Focus ${i(l)}`,children:i(l)})]},l)})]})}function jr(){var Ho,Ko,Vo,Yo,Uo,Xo,Go,qo,Zo;const t=L(o=>o.model),i=L(o=>o.createRelationship),n=d.useMemo(()=>$s(t),[t]),a=L(o=>o.selectedElementId),r=L(o=>o.selectedViewpointId),l=L(o=>o.selectedDiagramId),u=L(o=>o.hiddenLayers),m=L(o=>o.selectElement),F=L(o=>o.inspectElement),b=L(o=>o.inspectRelationship),I=L(o=>o.setActiveMode),p=L(o=>o.setActiveView),y=L(o=>o.setExplorerTab),v=L(o=>o.availableOntologies),f=L(o=>o.setSelectedOntologyKind),k=L(o=>o.diagramLayouts),E=L(o=>o.setNodeLayout),D=L(o=>o.mergeDiagramLayouts),O=L(o=>o.updateDiagramElementIds),{fitView:T,screenToFlowPosition:A,getViewport:K,setViewport:Z}=eo(),[_,z]=Cs([]),[re,w,pe]=Is([]),ee=d.useRef([]),U=d.useRef([]),Ge=d.useRef(t),qe=d.useRef(l),ye=d.useRef(null),ke=d.useRef(null),Ee=d.useRef(null),ne=d.useRef(0);d.useEffect(()=>{ee.current=_},[_]),d.useEffect(()=>{U.current=re},[re]);const ue=d.useCallback(o=>{ee.current=o,ke.current===null&&(ke.current=requestAnimationFrame(()=>{ke.current=null;const s=ee.current,c=wn(s,U.current);U.current=c,z(s),w(c)}))},[z,w]),[G,se]=d.useState(!1),[so,Ce]=d.useState(0),[io,ro]=d.useState(null),[ao,Mn]=d.useState(0),[Tn,kt]=d.useState(0),[Ne,Et]=d.useState(!0),[Ln,lo]=d.useState(!0),[co,zn]=d.useState(!0),[Ct,$n]=d.useState("horizontal"),[Ze,po]=d.useState("allocation"),[It,uo]=d.useState("all"),[xo,Wn]=d.useState(!1),[ge,On]=d.useState(new Set(["control","data","energy","material"])),[te,Ae]=d.useState(null),[fe,Qe]=d.useState(null),[q,Re]=d.useState(null),[xe,Je]=d.useState(null),[Be,ho]=d.useState(null),[et,Pn]=d.useState(2),[tt,go]=d.useState(null),Me=d.useRef([]),Dt=d.useRef([]),fo=d.useCallback(o=>{Me.current.push(o),Me.current.length>br&&Me.current.shift(),Dt.current=[]},[]),x=Ws(t,l),Te=x?nn[x.diagramType]:null,ot=!!((Ho=x==null?void 0:x.properties)!=null&&Ho.layoutStyle),Fe=((Ko=x==null?void 0:x.properties)==null?void 0:Ko.layoutStyle)==="fbs",we=l?k[l]:void 0,je=ei(we),he=((Vo=we==null?void 0:we.canvas)==null?void 0:Vo.autoLayout)!==!1,me=((Yo=we==null?void 0:we.canvas)==null?void 0:Yo.flowAnimation)===!0,ae=d.useCallback(()=>{var s;if(!l)return;const o=L.getState().diagramLayouts[l]??{nodes:{},edges:{}};((s=o.canvas)==null?void 0:s.autoLayout)!==!1&&D({[l]:{...o,canvas:{...o.canvas,autoLayout:!1}}})},[l,D]);d.useEffect(()=>{if(!l||he||G||_.length===0||so===0)return;const o=window.setTimeout(()=>{const s=L.getState().diagramLayouts[l]??{nodes:{},edges:{}},c=K(),h={nodes:Object.fromEntries(_.map(g=>[g.id,{...s.nodes[g.id]??{},x:g.position.x,y:g.position.y,...g.width?{width:g.width}:{},...g.height?{height:g.height}:{},ports:Object.fromEntries((g.data.ports??[]).map(S=>[S.id,{x:S.x,y:S.y,side:S.side}]))}])),edges:Object.fromEntries(re.map(g=>{var S,$,R,W,V,M;return[g.id,{...(()=>{var P;const{points:X,...Y}=((P=s.edges)==null?void 0:P[g.id])??{};return Y})(),...(S=g.data)!=null&&S.manualRoute&&((R=($=g.data)==null?void 0:$.points)!=null&&R.length)?{points:(W=g.data)==null?void 0:W.points,source:g.source,target:g.target,sourcePortId:(V=g.data)==null?void 0:V.sourcePortId,targetPortId:(M=g.data)==null?void 0:M.targetPortId}:{}}]})),canvas:{...s.canvas,zoom:c.zoom,pan:{x:c.x,y:c.y},autoLayout:!1}};D({[l]:h}),Ve(l,h),Ce(0)},350);return()=>window.clearTimeout(o)},[l,he,G,so,_,re,K,D]);const B=x?x.viewKind??(Te==null?void 0:Te.viewKind)??"general":void 0,ve=B==="interconnection"?.72:.1,Le=B?an[B]:null,Ie=B==="general"&&!ot&&!Fe,Nt=(x==null?void 0:x.diagramType)==="ucd",[Se,mo]=d.useState("graph"),[At,bo]=d.useState("all"),[Rt,yo]=d.useState("rounded"),[ze,Fo]=d.useState(new Set),_n=d.useMemo(()=>t?ti(t):0,[t]),wo=d.useMemo(()=>t?oi(t):[],[t]),Bt=(Uo=x==null?void 0:x.properties)==null?void 0:Uo.modes,Hn=d.useMemo(()=>{if(!Bt)return Vt;const o=new Set(Bt.split(",").map(c=>c.trim())),s=Vt.filter(c=>o.has(c));return s.length?s:Vt},[Bt]),[$e,jo]=d.useState(!0),vo=d.useMemo(()=>{if(!t||!x)return[];const o=new Set(x.elementIds),s=Object.values(t.elements).filter(c=>o.has(c.id)&&c.allocatedTo).map(c=>c.allocatedTo);return ni(s,t)},[t,x]),Kn=d.useMemo(()=>{if(!t||!x)return"Activity Diagram";const o=Os(x);return nn[o].fullName},[t,x]),Vn=d.useMemo(()=>{if(!t||!x)return!1;const o=new Set(x.elementIds);return Object.values(t.elements).some(s=>o.has(s.id)&&!!(s.attributes.stage||s.attributes.phase))},[t,x]),nt=d.useMemo(()=>{if(!t||!x||B!=="actionflow")return[];const o=(x.elementIds??[]).map(s=>t.elements[s]).filter(s=>!!s&&s.construct==="action");return si(o,t)},[t,x,B]),[We,Yn]=d.useState("containment"),[Oe,st]=d.useState(new Set),[So,Pe]=d.useState(new Set),[it,Mt]=d.useState(null),[_e,ko]=d.useState("all"),[Eo,Co]=d.useState(!1),[Io,He]=d.useState(new Set),[De,Tt]=d.useState(null),[Lt,Do]=d.useState("flat"),[No,Ke]=d.useState(new Set),[rt,zt]=d.useState(null),[at,Un]=d.useState(new Map),le=d.useRef(new Map),Xn=d.useMemo(()=>jn(t,it),[t,it]),Gn=d.useMemo(()=>jn(t,rt),[t,rt]),qn=d.useMemo(()=>{var h;if(!t||!De)return[];const o=[De],s=new Set(o);let c=De;for(;c;){const g=(h=t.elements[c])==null?void 0:h.parentAction;if(!g||s.has(g)||!t.elements[g])break;o.unshift(g),s.add(g),c=g}return o},[t,De]),lt=d.useMemo(()=>{if(!t||B!=="statetransition")return[];const o=new Set;for(const s of t.relationships){if(!En.has(s.type))continue;const c=t.elements[s.sourceId];!c||!t.elements[s.targetId]||!ii(c)||c.kind.endsWith("Machine")||o.add(c.id)}return[...o]},[t,B]),dt=d.useMemo(()=>t?[...new Set(t.relationships.filter(o=>["composes","composedof","aggregation","decomposedby"].includes(o.type.toLowerCase())).map(o=>o.sourceId))]:[],[t]);d.useEffect(()=>{var s,c;Ce(0),mo(ri(x==null?void 0:x.properties)),bo(Yt(x==null?void 0:x.properties).level??"all"),yo(Yt(x==null?void 0:x.properties).edgeStyle??"rounded"),Fo(new Set),jo(!0),po("allocation"),uo("all");const o=(c=(s=x==null?void 0:x.properties)==null?void 0:s.styleHint)!=null&&c.startsWith("expanded:")?x.properties.styleHint.slice(9).split(",").map(h=>h.trim()).filter(Boolean):[];st(new Set(o)),Mt(null),ko("all"),Co(!1),He(new Set),Tt(null),Do("flat"),zt(null),le.current.clear()},[l,(Xo=x==null?void 0:x.properties)==null?void 0:Xo.layoutHint,(Go=x==null?void 0:x.properties)==null?void 0:Go.styleHint]);const Ao=d.useRef(null);d.useEffect(()=>{if(!t)return;const o=`${l??""}|${B??""}`;if(Ao.current!==o){if(B==="statetransition"){if(lt.length===0)return;Ke(new Set(lt))}else if(B==="interconnection"){if(dt.length===0)return;Pe(new Set(dt))}Ao.current=o}},[t,l,B,lt,dt]);const Zn=d.useMemo(()=>({decompositionNode:vi,interconnectionNode:Di,actionFlowNode:zi,actionFlowLane:Wi,stateNode:Pi,seqLifeline:Hi,seqSection:Vi,seqOccurrence:Ui,useCase:Xi,useCaseActor:Gi,useCaseBoundary:qi,contextSystem:Ji,contextExternal:er,contextBoundary:tr,diagramNode:or,decisionNode:ar,forkNode:lr,startEndNode:dr}),[]),Qn=d.useMemo(()=>({interconnectionEdge:Mi,useCaseEdge:Qi}),[]),Jn=d.useCallback(o=>{var s,c;return((s=o.data)==null?void 0:s.color)||((c=o.data)==null?void 0:c.layerColor)||"#ccc"},[]),Q=d.useMemo(()=>{const o=(x==null?void 0:x.viewpointId)==="__model"?null:(x==null?void 0:x.viewpointId)||r,s=o&&(t==null?void 0:t.viewpoints),c=u.size>0,h=x!=null&&x.elementIds?new Set(x.elementIds):void 0;if(!s&&!c&&!h)return;const g=s?t.viewpoints.find(R=>R.id===o):void 0,S=g?new Set(g.visibleKinds):void 0,$=g?new Set(g.visibleLayers):void 0;return R=>u.has(R.layer)?!1:h?h.has(R.id):S&&$?S.has(R.kind)||$.has(R.layer):!0},[r,x,t==null?void 0:t.viewpoints,u]),ct=d.useMemo(()=>!t||!x||x.diagramType!=="bdd"?null:ai(dn(t,Q)),[t,x,Q]),Ro=d.useCallback(()=>{if(t)return Fe?li(t):Ie?dn(t,Q):di(t)},[t,Fe,Ie,Q]),$t=d.useCallback(o=>{st(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),Bo=d.useCallback(o=>{Pe(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),Mo=d.useCallback(o=>{He(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),pt=d.useCallback(o=>{zt(o),Ke(new Set),F(null)},[F]),ut=d.useCallback(o=>{Tt(o),He(new Set),F(null)},[F]),To=d.useCallback(o=>{Ke(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),Lo=d.useCallback(o=>{le.current.clear(),Un(s=>{const c=new Map(s),h=c.get(o)||"vertical";return c.set(o,h==="vertical"?"horizontal":"vertical"),c})},[]),Wt=d.useCallback(()=>{const o=Ro();if(!o)return;const s=new Set,c=h=>{s.add(h);for(const g of o.childrenMap.get(h)||[])o.elements.has(g)&&c(g)};for(const h of o.roots)o.elements.has(h)&&c(h);st(s)},[Ro]),Ot=d.useCallback(()=>st(new Set),[]),Pt=d.useCallback(()=>{le.current.clear(),kt(o=>o+1)},[]),es=d.useCallback(()=>{if(!l)return;const o=L.getState().diagramLayouts[l]??{},{pan:s,zoom:c,...h}=o.canvas??{},g={nodes:{},edges:{},canvas:{...h,autoLayout:!0}};ye.current=null,D({[l]:g}),Ve(l,g),le.current.clear(),kt(S=>S+1),window.setTimeout(()=>T({padding:.08,minZoom:ve,maxZoom:2,duration:300}),250)},[l,D,T,ve]),zo=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:(h,g)=>{Re({x:h.clientX,y:h.clientY,nodeId:g,nodeKind:s.data.kind??""})},onInlineEdit:(h,g)=>{if(!c)return;const S={...c,name:g};sn(S)}}}}),[t]),$o=d.useCallback((o,s)=>{const c=o.map(g=>{const S=s.nodes[g.id];return S?{...g,position:{x:S.x,y:S.y},...S.width?{width:S.width}:{},...S.height?{height:S.height}:{},data:{...g.data,bgColor:S.color||void 0,...S.ports?{ports:(g.data.ports??[]).map($=>{var R;return{...$,...((R=S.ports)==null?void 0:R[$.id])??{}}})}:{}}}:g}),h=new Map(c.map(g=>[g.id,g]));return c.map(g=>{if(g.type!=="actionFlowLane")return g;const S=g.data,$=(S.memberIds??[]).map(Y=>h.get(Y)).filter(Boolean);if($.length===0)return g;const R=Math.min(...$.map(Y=>Y.position.x)),W=Math.min(...$.map(Y=>Y.position.y)),V=Math.max(...$.map(Y=>{var P;return Y.position.x+Number(Y.width??((P=Y.style)==null?void 0:P.width)??180)})),M=Math.max(...$.map(Y=>{var P;return Y.position.y+Number(Y.height??((P=Y.style)==null?void 0:P.height)??96)})),X=S.orientation==="column";return{...g,position:{x:X?R-36:R-120,y:X?W-32:W-36},style:{...g.style,width:V-R+(X?72:156),height:M-W+(X?68:72)}}})},[]),Wo=d.useCallback((o,s,c)=>{ne.current=Date.now()+250,ae(),Ce(S=>S+1);const h=U.current.map(S=>{var M,X;if(!(((M=S.data)==null?void 0:M.sourcePortId)===s||((X=S.data)==null?void 0:X.targetPortId)===s))return S;const{points:R,manualRoute:W,...V}=S.data??{};return{...S,data:V}});U.current=h;const g=ee.current.map(S=>S.id!==o?S:{...S,data:{...S.data,ports:(S.data.ports??[]).map($=>$.id===s?{...$,y:c}:$)}});ue(g)},[ue,ae]),Oo=d.useCallback((o,s)=>{ne.current=Date.now()+250,ae(),Ce(c=>c+1),w(c=>{const h=c.map(g=>g.id===o?{...g,data:{...g.data,points:s,manualRoute:!0}}:g);return U.current=h,h})},[ae,w]);d.useEffect(()=>{if(!t)return;const o=Ge.current!==t&&qe.current===l;if(ye.current=o?K():null,Ge.current=t,qe.current=l,B==="grid"||B==="browser"||B==="geometry")return;let s=!1;const c=({nodes:R,edges:W},V=!0)=>{if(s)return;const M=l?L.getState().diagramLayouts[l]:void 0,X=M&&Object.keys(M.nodes).length>0?$o(R,M):R,Y=W.map(P=>{var Qo,Jo,en;const de=(Qo=M==null?void 0:M.edges)==null?void 0:Qo[P.id],xt=!(de!=null&&de.source)||de.source===P.source&&de.target===P.target&&de.sourcePortId===((Jo=P.data)==null?void 0:Jo.sourcePortId)&&de.targetPortId===((en=P.data)==null?void 0:en.targetPortId)?de==null?void 0:de.points:void 0;return{...P,data:{...P.data,...xt!=null&&xt.length?{points:xt,manualRoute:!0}:{},flowAnimation:me,onRouteChange:_t=>Oo(P.id,_t),onSelect:_t=>{_t.stopPropagation(),!(Date.now()<ne.current)&&(w(Ht=>Ht.map(tn=>({...tn,selected:tn.id===P.id}))),t.relationships.some(Ht=>Ht.id===P.id)&&b(P.id))}}}});z(V?zo(X):X),w(wn(X,Y)),se(!1),Mn(P=>P+1)},h=R=>W=>{s||(console.error(`${R} layout error:`,W),se(!1),ro(`${R} layout could not be completed. Try resetting the layout or reducing the visible hierarchy.`))},g=(R,W,V=!0)=>{se(!0),ro(null),Fr(W,R).then(M=>c(M,V)).catch(h(R))},S=()=>{const R=Dn.select({viewKind:B,diagramType:x==null?void 0:x.diagramType,isFBSDiagram:Fe,isDecompDiagram:ot,isGeneralTemplate:Ie,generalMode:Se,layoutStyle:We}),W={onToggleExpand:$t,onToggleDirection:Lo},V={fbs:{expandedNodes:Oe,nodeDirections:at,callbacks:W,layoutProviderId:je},decomposition:{expandedNodes:Oe,nodeDirections:at,callbacks:W,positionCache:le.current},containment:{expandedNodes:Oe,callbacks:{onToggleExpand:$t}},useCase:{viewpointFilter:void 0,systemName:x==null?void 0:x.name,...x?Yt(x.properties):{},level:At,edgeStyle:Rt,hiddenActorIds:ze},contextSystemName:x==null?void 0:x.name,interconnection:{viewpointFilter:Q,relationshipTypes:x==null?void 0:x.relationshipTypes,collapsedNodes:So,onToggleCollapse:Bo,focusId:it??void 0,portDisplay:_e,onPortMove:Wo,layoutProviderId:je},actionflow:{viewpointFilter:Q,swimlanes:$e,laneGrouping:Ze,displayLevel:It,expandedActionIds:Io,onToggleAction:Mo,onDrillInAction:ut,focusActionId:De??void 0,visibleFlowKinds:ge,direction:Ct,nesting:Lt,layoutProviderId:je},statetransition:{viewpointFilter:Q,collapsedStateIds:No,onToggleCollapse:To,onDrillIn:pt,focusStateId:rt??void 0,layoutProviderId:je},sequence:{viewpointFilter:Q},general:{mode:Se,viewpointFilter:Q,expandedNodes:Oe,nodeDirections:at,callbacks:W,positionCache:le.current,layoutProviderId:je},standard:{viewpointFilter:Q,relationshipTypes:x==null?void 0:x.relationshipTypes,compartments:Ie,layoutProviderId:je}},M=R.compute(t,V);M instanceof Promise?g(R.descriptor.label,M,R.descriptor.interactive):c(M,R.descriptor.interactive)},$=window.setTimeout(S,yr);return()=>{s=!0,window.clearTimeout($)}},[t,Q,ot,Fe,We,B,Ie,Se,$e,Tn,x==null?void 0:x.relationshipTypes,x==null?void 0:x.diagramType,x==null?void 0:x.name,At,Rt,ze,je,Oe,So,it,_e,Io,De,ge,Ct,Ze,It,Lt,at,No,rt,To,pt,ut,$t,Bo,Mo,Lo,l,$o,zo,Wo,Oo,b,K]),d.useEffect(()=>{if(ao===0)return;const o=setTimeout(()=>{var h;const s=ye.current;if(ye.current=null,s){Z(s);return}const c=l?(h=L.getState().diagramLayouts[l])==null?void 0:h.canvas:void 0;(c==null?void 0:c.zoom)!==void 0&&c.pan?Z({x:c.pan.x,y:c.pan.y,zoom:c.zoom},{duration:300}):T({padding:.08,minZoom:ve,maxZoom:2,duration:500})},200);return()=>clearTimeout(o)},[ao,l,T,ve,Z]),d.useEffect(()=>{z(o=>o.map(s=>{const c=s.type==="actionFlowLane"?s.data.inspectElementId:void 0,h=!!a&&(s.id===a||c===a);return{...s,selected:h,style:{...s.style,boxShadow:h?"0 0 0 2px #2DD4A8, 0 4px 12px rgba(45, 212, 168, 0.3)":void 0,opacity:a?h?1:.5:1}}}))},[a,z]),d.useEffect(()=>{if(!Be||!t)return;const o=gi(t,Be,"both",et),s=new Set(o.nodes.map(c=>c.elementId));s.add(Be),z(c=>c.map(h=>({...h,style:{...h.style,opacity:s.has(h.id)?1:.08,pointerEvents:s.has(h.id)?"all":"none"}}))),w(c=>c.map(h=>({...h,style:{...h.style,opacity:s.has(h.source)&&s.has(h.target)?1:.05}})))},[Be,et,t,z,w]),d.useEffect(()=>{if(!tt)return;const o=setTimeout(()=>go(null),2500);return()=>clearTimeout(o)},[tt]),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 h=Me.current.pop();h&&(h.undo(),Dt.current.push(h))}if((s.metaKey||s.ctrlKey)&&(s.key==="Z"||s.key==="z"&&s.shiftKey)){s.preventDefault();const h=Dt.current.pop();h&&(h.do(),Me.current.push(h))}s.key==="g"&&(s.metaKey||s.ctrlKey)&&s.shiftKey&&(s.preventDefault(),lo(h=>!h)),s.key==="0"&&(s.metaKey||s.ctrlKey)&&(s.preventDefault(),T({padding:.08,minZoom:ve,maxZoom:2,duration:400}))}};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[T,ve]);const ts=d.useCallback(o=>{o.preventDefault(),o.dataTransfer.dropEffect="copy"},[]),os=d.useCallback(o=>{o.preventDefault();const s=o.dataTransfer.getData("application/memo-kind");if(s)try{const c=JSON.parse(s),h=A({x:o.clientX,y:o.clientY});Ae({x:o.clientX,y:o.clientY,flowX:h.x,flowY:h.y,kind:c.kind,layer:c.layer,construct:c.construct})}catch{}},[A]),ns=d.useCallback(o=>{const s=A({x:o.clientX,y:o.clientY});Ae({x:o.clientX,y:o.clientY,flowX:s.x,flowY:s.y})},[A]),ss=d.useCallback(o=>{if(!te||!l){Ae(null);return}const s=te.kind??"Part",c=te.layer??"logical",h=te.construct??"part",g=kn[c]??"#6B7280",S=`_new_${Date.now()}`,$={id:S,type:"diagramNode",position:{x:te.flowX,y:te.flowY},data:{label:o,kind:s,layer:c,construct:h,color:g,isNew:!0,onContextMenu:(M,X)=>{Re({x:M.clientX,y:M.clientY,nodeId:X,nodeKind:s})},onInlineEdit:(M,X)=>{sn({id:S,name:X,kind:s,construct:h,layer:c})}}};z(M=>[...M,$]),Ps({name:o,kind:s,construct:h,attributes:{_layer:c}});const R=(x==null?void 0:x.elementIds)??[];O(l,[...R,S]);const W=l,V={nodes:{...(k[W]??{}).nodes??{},[S]:{x:te.flowX,y:te.flowY}},edges:(k[W]??{}).edges??{}};D({[W]:V}),Ve(W,V),Ae(null)},[te,l,x,k,D,O,z]),is=d.useCallback(()=>{Re(null),Je(null)},[]),rs=d.useCallback((o,s)=>{s!=null&&s.isValid},[]),as=d.useCallback(o=>{const{source:s,target:c}=o;if(!s||!c)return;const h=t==null?void 0:t.elements[s],g=t==null?void 0:t.elements[c];!h||!g||Qe({x:window.innerWidth/2-130,y:window.innerHeight/2-160,sourceElement:h,targetElement:g})},[t]),ls=d.useCallback(async o=>{if(!fe||!l){Qe(null);return}const s=fe.sourceElement.id;Qe(null);const c=await i({type:o.type,sourceId:o.sourceId,targetId:o.targetId,direction:o.direction,selectedElementId:s,diagramId:l});if(!c.success){console.warn(`[MEMO] Relationship rejected: ${c.error}`);return}const h=rn[o.type]??"#6B7280",g={id:c.relationshipId??`e_${o.sourceId}_${o.targetId}_${o.type}`,source:o.sourceId,target:o.targetId,label:o.type,type:"default",style:{stroke:h,strokeWidth:2},labelStyle:{fontSize:"10px",fill:"#374151"},labelBgStyle:{fill:"#FFFFFF",fillOpacity:.9},labelBgPadding:[4,2],labelBgBorderRadius:4,markerEnd:{type:"arrowclosed",color:h}};w(S=>Ds(g,S))},[fe,l,w,i]),ds=d.useCallback((o,s)=>{Ee.current={id:s.id,x:s.position.x,y:s.position.y}},[]),cs=d.useCallback((o,s)=>{const c=Ee.current;if(Ee.current=null,!((c==null?void 0:c.id)===s.id&&Math.hypot(s.position.x-c.x,s.position.y-c.y)>2)||(ne.current=Date.now()+250,Ce(R=>R+1),!l))return;ae();const{x:g,y:S}=s.position,$=le.current.get(s.id);if(le.current.set(s.id,{x:g,y:S}),E(l,s.id,{x:g,y:S}),$){const R=s.id,W=l;fo({do:()=>E(W,R,{x:g,y:S}),undo:()=>{E(W,R,$),z(V=>V.map(M=>M.id===R?{...M,position:$}:M))}})}},[l,E,fo,z,ae]),ps=d.useCallback(o=>{o.some(s=>s.type==="position"&&s.dragging)&&ae(),o.some(s=>s.type==="dimensions"&&s.resizing)&&(ae(),Ce(s=>s+1)),ue(Ns(o,ee.current))},[ue,ae]),us=d.useCallback((o,s)=>{},[]),xs=d.useCallback((o,s)=>{o.preventDefault(),Je({x:o.clientX,y:o.clientY,edgeId:s.id,relType:String(s.label??"edge")})},[]),hs=d.useCallback((o,s)=>{if(Date.now()<ne.current)return;const c=s.type==="actionFlowLane"?s.data.inspectElementId:void 0;!c&&(s.id.startsWith("__")||s.id.includes("__start")||s.id.includes("__done"))||(F(c??s.id),l&&p({type:"diagram",diagramId:l}))},[F,l,p]),gs=d.useCallback((o,s)=>{var c;if((c=o==null?void 0:o.stopPropagation)==null||c.call(o),B==="actionflow"){if(!Object.values((t==null?void 0:t.elements)??{}).some(g=>g.parentAction===s.id))return;ut(s.id);return}if(B==="statetransition"){const h=s.data;if(!h.hasChildren||h.isMachine){F(s.id);return}pt(s.id);return}if(B==="interconnection"){if(!!!s.data.isContainer){F(s.id);return}Mt(s.id),Pe(new Set),F(null)}},[B,t==null?void 0:t.elements,F,ut,pt]),fs=d.useCallback(()=>{m(null),b(null),Re(null),Je(null),z(o=>o.map(s=>({...s,style:{...s.style,opacity:1,boxShadow:void 0}}))),w(o=>o.map(s=>s.selected?{...s,selected:!1}:s))},[m,b,z,w]),ms=d.useCallback((o,s)=>{var c;(c=o==null?void 0:o.stopPropagation)==null||c.call(o),!(Date.now()<ne.current)&&(w(h=>h.map(g=>({...g,selected:g.id===s.id}))),t!=null&&t.relationships.some(h=>h.id===s.id)?b(s.id):t!=null&&t.elements[s.id]&&F(s.id))},[t,F,b,w]),bs=d.useCallback((o,s)=>{Ue({endpointIds:[s.id]})},[]),ys=d.useCallback((o,s)=>{Ue({edgeId:s.id,endpointIds:Cn(s)})},[]),Po=d.useCallback(()=>Ue(null),[]),Fs=d.useCallback((o,s)=>{var c;l&&(E(l,o,{...((c=k[l])==null?void 0:c.nodes[o])??{x:0,y:0},color:s||void 0}),z(h=>h.map(g=>g.id===o?{...g,data:{...g.data,bgColor:s||void 0}}:g)))},[l,k,E,z]),_o=d.useCallback(o=>{if(!l||!x)return;const s=(x.elementIds??[]).filter(c=>c!==o);O(l,s),z(c=>c.filter(h=>h.id!==o))},[l,x,O,z]),ws=d.useCallback((o,s)=>{const c=s==="dashed"?"6 3":s==="dotted"?"2 3":void 0;w(h=>h.map(g=>g.id===o?{...g,style:{...g.style,strokeDasharray:c}}:g))},[w]),js=d.useCallback((o,s)=>{w(c=>c.map(h=>h.id===o?{...h,style:{...h.style,stroke:s||(rn[String(h.label??"")]??"#6B7280")}}:h))},[w]),vs=d.useCallback(o=>{w(s=>s.map(c=>c.id===o?{...c,label:c.label?"":o.split("_")[3]??""}:c))},[w]);if(x&&t&&B==="grid")return e.jsx(ci,{diagram:x,model:t,viewpointFilter:Q});if(x&&t&&B==="browser")return e.jsx(pi,{diagram:x,model:t,viewpointFilter:Q});if(x&&B==="geometry"){const o=an.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:N.badge,marginBottom:"12px"},children:o.label}),e.jsx("h3",{style:{fontSize:N.lg,fontWeight:600,color:"#374151",marginBottom:"8px"},children:x.name}),e.jsx("p",{style:{fontSize:N.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!x&&_.length===0&&!G?e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!Ne&&e.jsx(Xt,{collapsed:Ne,onToggleCollapse:()=>Et(!0)}),Ne&&e.jsx(Xt,{collapsed:!0,onToggleCollapse:()=>Et(!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:N.lg,fontWeight:600,color:"#374151",marginBottom:"8px"},children:"Select a Diagram"}),e.jsx("p",{style:{fontSize:N.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(Xt,{collapsed:Ne,onToggleCollapse:()=>Et(!Ne),elementIds:x==null?void 0:x.elementIds,eligibleKinds:x!=null&&x.viewpointId&&(t!=null&&t.viewpoints)?new Set(((qo=t.viewpoints.find(o=>o.id===x.viewpointId))==null?void 0:qo.visibleKinds)??[]):void 0}),e.jsxs("div",{className:"flex-1 relative",onDragOver:ts,onDrop:os,onDoubleClick:ns,children:[x&&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:[Le&&e.jsx("span",{className:"px-1.5 py-0.5 rounded font-semibold",style:{background:Le.color+"20",color:Le.color,fontSize:N.badge},title:`${Le.fullName}${Te?` · ${Te.fullName}`:""}`,children:B==="actionflow"?Kn:Le.label}),e.jsx("span",{className:"font-medium",style:{color:"#1a1a1a"},children:x.name}),x.auto&&e.jsx("span",{style:{color:"#9CA3AF",fontSize:"9px"},children:"auto"}),e.jsx(ce,{}),e.jsx(Ye,{icon:e.jsx(H.grid,{}),label:"Grid",active:co,onClick:()=>{zn(o=>{const s=!o;return lo(s),s})},title:"Show or hide the canvas grid and snapping (⌘⇧G)"}),Fe&&e.jsxs(e.Fragment,{children:[e.jsx(ce,{}),e.jsx(oe,{icon:e.jsx(H.expand,{}),onClick:Wt,title:"Expand all nodes",ariaLabel:"Expand all"}),e.jsx(oe,{icon:e.jsx(H.collapse,{}),onClick:Ot,title:"Collapse all nodes",ariaLabel:"Collapse all"})]}),B==="actionflow"&&e.jsxs(e.Fragment,{children:[e.jsx(Ye,{icon:e.jsx(H.lanes,{}),active:$e,onClick:()=>jo(o=>!o),title:"Toggle allocation swimlanes"}),$e&&Vn&&e.jsx(Ye,{icon:e.jsx(H.lanes,{}),label:"Stage",active:Ze==="stage",onClick:()=>po(o=>o==="stage"?"allocation":"stage"),title:"Group this flow by its modeled stages"}),$e&&Ze==="allocation"&&vo.length>0&&e.jsxs("select",{"aria-label":"Display hierarchy level",title:"Display responsibility lanes at a hierarchy level; the SysML allocation is unchanged",value:It,onChange:o=>uo(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"}),vo.map(o=>e.jsxs("option",{value:o,children:["L",o]},o))]}),e.jsx(ce,{}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:N.xs,fontWeight:600},children:"Steps"}),e.jsx(Gt,{value:Lt,onChange:Do,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(ce,{}),e.jsx(Gt,{value:Ct,onChange:$n,options:[{value:"horizontal",icon:e.jsx(H.arrowRight,{}),title:"Left-to-right flow"},{value:"vertical",icon:e.jsx(H.arrowDown,{}),title:"Top-to-bottom flow"}]}),e.jsx(ce,{}),e.jsxs(ur,{children:[e.jsx(oe,{icon:e.jsx(H.expand,{}),title:"Expand all sub-actions",onClick:()=>He(new Set(Object.values((t==null?void 0:t.elements)??{}).map(o=>o.parentAction).filter(o=>!!o)))}),e.jsx(oe,{icon:e.jsx(H.collapse,{}),title:"Collapse all sub-actions",onClick:()=>He(new Set)})]}),e.jsx(ce,{}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Ye,{icon:e.jsx(H.filter,{}),active:xo,badge:`${ge.size}/4`,onClick:()=>Wn(o=>!o),title:"Choose which modeled connection categories are visible"}),xo&&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:N.xs},children:"Show connection categories"}),e.jsx("div",{style:{color:"#6B7280",fontSize:N.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=ge.has(o),c=o==="control"?"#4B5563":o==="data"?"#3498DB":o==="energy"?"#D97706":"#16A34A";return e.jsxs("button",{role:"switch","aria-checked":s,onClick:()=>On(h=>{const g=new Set(h);return g.has(o)?g.delete(o):g.add(o),g}),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(Zt,{path:qn,nameOf:o=>{var s;return((s=t==null?void 0:t.elements[o])==null?void 0:s.name)??o},onFocus:Tt,rootLabel:"Back to the whole action flow"})]}),B==="interconnection"&&e.jsxs(e.Fragment,{children:[e.jsx(ce,{}),e.jsx(oe,{icon:e.jsx(H.expand,{}),onClick:()=>Pe(new Set),title:"Expand all parts",ariaLabel:"Expand all"}),e.jsx(oe,{icon:e.jsx(H.collapse,{}),onClick:()=>Pe(new Set(dt)),title:"Collapse all parts",ariaLabel:"Collapse all"}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:N.xs,fontWeight:600},children:"Ports"}),e.jsx(Gt,{value:_e,onChange:ko,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(Zt,{path:Xn,nameOf:o=>{var s;return((s=t==null?void 0:t.elements[o])==null?void 0:s.name)??o},onFocus:Mt,rootLabel:"Back to the whole diagram"})]}),B==="statetransition"&&e.jsxs(e.Fragment,{children:[e.jsx(ce,{}),e.jsx(oe,{icon:e.jsx(H.expand,{}),onClick:()=>Ke(new Set),title:"Show all substates",ariaLabel:"Expand all substates"}),e.jsx(oe,{icon:e.jsx(H.collapse,{}),onClick:()=>Ke(new Set(lt)),title:"Fold every composite state",ariaLabel:"Collapse all substates"}),e.jsx(Zt,{path:Gn,nameOf:o=>{var s;return((s=t==null?void 0:t.elements[o])==null?void 0:s.name)??o},onFocus:zt,rootLabel:"Back to the whole machine"})]}),Nt&&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:At,onChange:o=>bo(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:_n+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:Rt,onChange:o=>yo(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:es,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"}),wo.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",ze.size?`: ${ze.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"}),wo.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:ze.has(o.id),onChange:()=>Fo(s=>{const c=new Set(s);return c.has(o.id)?c.delete(o.id):c.add(o.id),c})}),o.name]},o.id))]})]})]}),Ie&&!Nt&&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:Hn.map(o=>e.jsx("button",{onClick:()=>{mo(o),le.current.clear()},className:"px-2 py-0.5 text-xs font-medium capitalize",style:{background:Se===o?"#1B3A4B":"#FFFFFF",color:Se===o?"#FFFFFF":"#6B7280"},title:o==="graph"?"Relationship graph with compartments":o==="tree"?"Decomposition tree with expand/collapse":"Nested containment blocks",children:o},o))}),Se!=="graph"&&e.jsxs(e.Fragment,{children:[e.jsx(oe,{icon:e.jsx(H.expand,{}),onClick:Wt,title:"Expand all nodes",ariaLabel:"Expand all"}),e.jsx(oe,{icon:e.jsx(H.collapse,{}),onClick:Ot,title:"Collapse all nodes",ariaLabel:"Collapse all"}),Se==="tree"&&e.jsx("button",{onClick:Pt,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"})]})]}),ot&&!Fe&&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:()=>{Yn(o),le.current.clear()},className:"px-2 py-0.5 text-xs font-medium",style:{background:We===o?"#1B3A4B":"#FFFFFF",color:We===o?"#FFFFFF":"#6B7280"},children:o==="containment"?"Containment":"Decomposition"},o))}),e.jsx(ce,{}),e.jsx(oe,{icon:e.jsx(H.expand,{}),onClick:Wt,title:"Expand all nodes",ariaLabel:"Expand all"}),e.jsx(oe,{icon:e.jsx(H.collapse,{}),onClick:Ot,title:"Collapse all nodes",ariaLabel:"Collapse all"}),We==="decomposition"&&e.jsx("button",{onClick:Pt,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:"|"}),!Nt&&e.jsxs("button",{"aria-pressed":he,onClick:()=>{if(he)ae();else{const o=L.getState().diagramLayouts[l],s={nodes:{},edges:{},canvas:{...o==null?void 0:o.canvas,autoLayout:!0}};D({[l]:s}),Ve(l,s),kt(c=>c+1)}},className:"px-2 py-0.5 text-xs font-semibold rounded",style:{background:he?"#ECFDF5":"#FFF7ED",color:he?"#047857":"#C2410C",border:`1px solid ${he?"#A7F3D0":"#FED7AA"}`},title:he?"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: ",he?"On":"Off"]})]}),l&&B==="interconnection"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsxs("button",{"aria-pressed":me,onClick:()=>{const o=L.getState().diagramLayouts[l]??{nodes:{},edges:{}},s={...o,canvas:{...o.canvas,flowAnimation:!me}};D({[l]:s}),Ve(l,s),w(c=>c.map(h=>({...h,data:{...h.data,flowAnimation:!me}})))},className:"px-2 py-0.5 text-xs font-semibold rounded",style:{background:me?"#EFF6FF":"#F8FAFC",color:me?"#1D4ED8":"#64748B",border:`1px solid ${me?"#93C5FD":"#CBD5E1"}`},title:"Toggle animated source-to-target flow on IBD connectors",children:["Flow: ",me?"On":"Off"]}),e.jsx("button",{"aria-pressed":Eo,onClick:()=>Co(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"})]})]}),Be&&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:()=>Pn(o),style:{width:20,height:20,borderRadius:4,cursor:"pointer",background:et===o?"#2DD4A8":"rgba(255,255,255,0.15)",color:et===o?"#1B3A4B":"#FFFFFF",fontWeight:700,fontSize:"11px",border:"none"},children:o},o)),e.jsx("button",{onClick:()=>{ho(null),z(o=>o.map(s=>({...s,style:{...s.style,opacity:1,pointerEvents:"all"}}))),w(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"})]}),tt&&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: ",tt]}),G&&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…"}),io&&!G&&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:N.xs},children:[e.jsx("span",{children:io}),e.jsx("button",{onClick:Pt,style:{border:"1px solid #B58A12",borderRadius:3,background:"#FFFFFF",color:"#5F4300",padding:"3px 8px",fontWeight:700,whiteSpace:"nowrap"},children:"Retry"})]}),nt.length>0&&!G&&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:N.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"Diagram error:"})," ",nt.length," floating ",nt.length===1?"action has":"actions have"," no flow or succession connection:"," ",nt.map((o,s)=>e.jsxs("span",{children:[s>0&&", ",e.jsx("button",{onClick:()=>F(o.id),style:{color:"#991B1B",textDecoration:"underline",fontWeight:700},children:o.name})]},o.id))]}),ct&&!G&&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:N.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"BDD error:"})," ","expected one connected hierarchy, but found ",ct.rootIds.length," roots",ct.disconnectedIds.length>0&&e.jsxs(e.Fragment,{children:[" and ",ct.disconnectedIds.length," disconnected/floating elements"]}),"."]}),B==="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:N.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"Legend"}),ge.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"]}),ge.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"]}),ge.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"]}),ge.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"]})]}),B==="interconnection"&&_.length>0&&Eo&&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:N.xs},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{style:{fontWeight:700},children:"Ports"}),_e!=="none"?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qt,{color:Ft.in,glyph:"→"})," in"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qt,{color:Ft.out,glyph:"→"})," out"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qt,{color:Ft.inout,glyph:"⇄"})," inout"]}),_e==="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 ${ui[o]}`}}),o]},o))]})]}),!G&&_.length===0&&x&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",style:{zIndex:1},children:x.auto&&((Zo=x.elementIds)==null?void 0:Zo.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:N.sm,color:"#374151",fontWeight:600,marginBottom:4},children:"This view selects no elements"}),e.jsx("div",{style:{fontSize:N.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:N.sm,color:"#6B7280"},children:"Drag from palette or double-click to create elements"})]})}),G&&e.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",zIndex:20,background:`linear-gradient(90deg, ${ln.accent} 0%, ${ln.accent}80 50%, transparent 100%)`,backgroundSize:"200% 100%",animation:"memo-layout-progress 1.2s linear infinite"}}),e.jsxs(As,{nodes:_,edges:re,nodeTypes:Zn,edgeTypes:Qn,onNodesChange:ps,onEdgesChange:pe,onNodeClick:hs,onNodeDoubleClick:gs,onEdgeClick:ms,onPaneClick:fs,onNodeDragStart:ds,onNodeDragStop:cs,onNodeContextMenu:us,onEdgeContextMenu:xs,onNodeMouseEnter:bs,onNodeMouseLeave:Po,onEdgeMouseEnter:ys,onEdgeMouseLeave:Po,onConnect:as,onConnectStart:is,onConnectEnd:rs,connectionMode:Rs.Loose,defaultEdgeOptions:{interactionWidth:24},snapToGrid:Ln,snapGrid:mr,fitView:!0,fitViewOptions:{...hr,minZoom:ve},minZoom:.1,maxZoom:3,zoomOnScroll:!0,panOnScroll:!0,panOnScrollMode:"free",selectionOnDrag:!1,proOptions:fr,style:xr,children:[co&&e.jsx(Bs,{color:"#C5C7C2",gap:20,size:1.5}),e.jsx(yi,{}),e.jsx(Ms,{}),_.length>20&&e.jsx(Ts,{style:gr,nodeColor:Jn,maskColor:"rgba(247, 247, 245, 0.7)"})]})]}),te&&e.jsx(wr,{x:te.x,y:te.y,onConfirm:ss,onCancel:()=>Ae(null)}),fe&&e.jsx(xi,{x:fe.x,y:fe.y,sourceElement:fe.sourceElement,targetElement:fe.targetElement,registries:n,onSelect:ls,onCancel:()=>Qe(null)}),q&&e.jsx(sr,{x:q.x,y:q.y,nodeId:q.nodeId,nodeKind:q.nodeKind,onClose:()=>Re(null),onEditName:()=>{z(o=>o.map(s=>s.id===q.nodeId?{...s,data:{...s.data,_triggerEdit:!0}}:s))},onChangeColor:o=>Fs(q.nodeId,o),onRemoveFromDiagram:()=>_o(q.nodeId),onDeleteFromModel:()=>{_o(q.nodeId)},onShowProperties:()=>{m(q.nodeId)},onShowInCatalog:()=>{m(q.nodeId),I("catalog")},onFocusElement:()=>{ho(q.nodeId)},onShowRelMatrix:()=>{p({type:"traceability"})},onOpenSource:()=>{const o=t==null?void 0:t.elements[q.nodeId];o!=null&&o.file&&(navigator.clipboard.writeText(o.file).catch(()=>{}),go(o.file))},onViewKindInOntology:()=>{const o=q.nodeKind;let s=null,c=null;for(const h of v){for(const g of h.layers)if(g.kinds.some(S=>S.name===o)){s=h.name,c=g.id;break}if(s)break}s&&(f(o),y("ontologies"),I("ontology"),p({type:"ontology-detail",packageName:s,layerId:c??void 0}))}}),xe&&e.jsx(rr,{x:xe.x,y:xe.y,edgeId:xe.edgeId,relType:xe.relType,onClose:()=>Je(null),onChangeStyle:o=>ws(xe.edgeId,o),onChangeColor:o=>js(xe.edgeId,o),onToggleLabel:()=>vs(xe.edgeId),onDelete:()=>w(o=>o.filter(s=>s.id!==xe.edgeId))})]})}function Br(){return e.jsx(Es,{children:e.jsx(jr,{})})}export{Br as DiagramCanvas};
@@ -0,0 +1,4 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiagramCanvas-IINBJE7R.js","assets/reactflow-CX-HDacK.js","assets/zustand-qbFpP9Up.js","assets/index-CRFOCEAK.js","assets/index-DPzXL4uF.css","assets/layout-selection-CtqXOAtf.js","assets/layout-providers-BFnfta4Z.js","assets/elk-B75IRfCd.js","assets/style-BZV40eAE.css","assets/MaxGraphCanvas-BH29OQf7.js","assets/SysmlCodeEditor-CGOcUFE7.js","assets/SysmlCodeEditor-BwKcXIZw.css"])))=>i.map(i=>d[i]);
2
+ var me=Object.defineProperty;var xe=(r,t,o)=>t in r?me(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o;var V=(r,t,o)=>xe(r,typeof t!="symbol"?t+"":t,o);import{_ as Y,u as C,g as pe,a as ge,l as ve,s as Se,b as ye,c as be,F as d,C as a,d as Fe,L as Ee,e as we,f as Re}from"./index-CRFOCEAK.js";import{j as e}from"./reactflow-CX-HDacK.js";import{a as n}from"./zustand-qbFpP9Up.js";const $="memo.renderer.reactflow";class je{constructor(){V(this,"providers",new Map);V(this,"components",new Map)}register(t){const o=this.providers.get(t.descriptor.id);if(o&&o!==t)throw new Error(`Renderer provider already registered: ${t.descriptor.id}`);this.providers.set(t.descriptor.id,t)}unregister(t){return this.components.delete(t),this.providers.delete(t)}get(t){return this.providers.get(t)}has(t){return this.providers.has(t)}list(t=[]){return[...this.providers.values()].map(o=>o.descriptor).filter(o=>t.every(i=>o.capabilities.includes(i))).sort((o,i)=>o.name.localeCompare(i.name))}loadComponent(t){const o=this.providers.get(t)??this.providers.get($);if(!o)throw new Error(`Renderer provider not found: ${t} (no default registered)`);const i=o.descriptor.id;let s=this.components.get(i);return s||(s=o.loadComponent(),this.components.set(i,s)),s}}const Ce={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:()=>Y(()=>import("./DiagramCanvas-IINBJE7R.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(r=>r.DiagramCanvas)},Ae={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:()=>Y(()=>import("./MaxGraphCanvas-BH29OQf7.js"),__vite__mapDeps([9,1,2,3,4,5,6,7])).then(r=>r.MaxGraphCanvas)},A=new je;A.register(Ce);A.register(Ae);const ke={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},ie="memo.diagram.renderer.v3",G="renderer",_e="memo.renderer.",U=new Set;function O(r){const t=r==null?void 0:r.trim();if(t)return t.includes(".")?t:`${_e}${t}`}function De(){if(!(typeof window>"u"))try{return O(new URLSearchParams(window.location.search).get(G))}catch{return}}function Te(){if(!(typeof window>"u"))try{return O(window.localStorage.getItem(ie))}catch{return}}function Le(){try{const r=ke;return O(r==null?void 0:r.VITE_MEMO_DIAGRAM_RENDERER)}catch{return}}function ne(){return De()??Te()??Le()??$}function Me(r){const t=O(r)??$;try{window.localStorage.setItem(ie,t)}catch{}try{const o=new URL(window.location.href);o.searchParams.has(G)&&(o.searchParams.delete(G),window.history.replaceState(window.history.state,"",o))}catch{}for(const o of[...U])o()}function Ne(r){return U.add(r),()=>U.delete(r)}function ze(){return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5",color:"#9CA3AF",fontSize:13},children:"Loading renderer…"})}function Ie(){const r=n.useSyncExternalStore(Ne,ne,ne),t=A.has(r)?r:$,o=n.useMemo(()=>n.lazy(()=>A.loadComponent(t).then(s=>({default:s}))),[t]),i=A.list();return e.jsxs("div",{className:"relative flex flex-1 overflow-hidden",children:[e.jsx(n.Suspense,{fallback:e.jsx(ze,{}),children:e.jsx(o,{})}),i.length>1&&e.jsxs("div",{role:"group","aria-label":"Diagram renderer",className:"absolute bottom-3 left-1/2 z-10 flex items-center overflow-hidden rounded-lg",style:{transform:"translateX(-50%)",border:"1px solid #E5E5E0",background:"#FFFFFF",boxShadow:"0 2px 8px rgba(15,23,42,0.10)"},children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"#9CA3AF",padding:"0 8px"},children:"Renderer"}),i.map(s=>{const u=s.id===t;return e.jsx("button",{onClick:()=>Me(s.id),"aria-pressed":u,title:s.description,style:{fontSize:12,fontWeight:600,padding:"5px 12px",border:"none",cursor:"pointer",background:u?"#1B3A4B":"transparent",color:u?"#FFFFFF":"#6B7280"},children:s.name},s.id)})]})]})}const $e=n.lazy(()=>Y(()=>import("./SysmlCodeEditor-CGOcUFE7.js"),__vite__mapDeps([10,1,2,11])).then(r=>({default:r.SysmlCodeEditor})));function Oe(r,t){const o=(r.elementIds??[]).map(i=>t[i]).filter(Boolean).map(i=>` ${i.construct??"part"} ${i.id} : ${i.kind};`).join(`
3
+ `);return[`package '${r.name}' {`,` // Diagram: ${r.diagramType.toUpperCase()} | Viewpoint: ${r.viewpointId}`,o||" // No elements selected","}"].join(`
4
+ `)}function Be({diagram:r}){const t=C(c=>c.model),o=C(c=>c.updateDiagramElementIds),[i,s]=n.useState(""),u=n.useMemo(()=>Fe(t),[t]),B=n.useCallback(c=>{const m=new Set(r.elementIds??[]);m.has(c)?m.delete(c):m.add(c),o(r.id,[...m])},[r.id,r.elementIds,o]),w=n.useMemo(()=>new Set(r.elementIds??[]),[r.elementIds]),F=Ee.filter(c=>u.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:i,onChange:c=>s(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:F.map(c=>{const m=(u.get(c)??[]).filter(f=>!i||f.name.toLowerCase().includes(i.toLowerCase())||f.id.toLowerCase().includes(i.toLowerCase()));if(m.length===0)return null;const P=Re[c]??a.muted;return e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1 font-semibold",style:{color:P,fontSize:d.badge},children:we[c]??c}),m.map(f=>e.jsxs("label",{className:"flex items-center gap-2 px-3 py-0.5 cursor-pointer",style:{fontSize:d.xs},onMouseEnter:x=>x.currentTarget.style.background="#F0F0ED",onMouseLeave:x=>x.currentTarget.style.background="transparent",children:[e.jsx("input",{type:"checkbox",checked:w.has(f.id),onChange:()=>B(f.id),style:{accentColor:a.accent}}),e.jsx("span",{className:"truncate",style:{color:a.primary},title:f.id,children:f.name||f.id})]},f.id))]},c)})})]})}function oe({tone:r,message:t,actions:o}){const i=r==="conflict";return e.jsxs("div",{role:"alert",className:"flex items-center gap-2 px-3 py-1.5 flex-wrap",style:{background:i?"#FEF2F2":"#FFFBEB",borderBottom:`1px solid ${i?"#FECACA":"#FDE68A"}`,color:i?"#B91C1C":"#92400E",fontSize:d.xs,flexShrink:0},children:[e.jsx("span",{className:"flex-1",style:{minWidth:180},children:t}),o.map(s=>e.jsx("button",{onClick:s.onClick,title:s.hint,style:{fontSize:d.xs,padding:"2px 8px",borderRadius:5,cursor:"pointer",background:"#FFFFFF",border:`1px solid ${i?"#FECACA":"#FDE68A"}`,color:"inherit",fontWeight:600,whiteSpace:"nowrap"},children:s.label},s.label))]})}const Pe=4e3;function Ve({at:r}){const[t,o]=n.useState(!1);return n.useEffect(()=>{if(!r)return;o(!0);const i=setTimeout(()=>o(!1),Pe);return()=>clearTimeout(i)},[r]),t?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 Ge=[];function Ke({diagramId:r}){const t=C(l=>l.model),o=C(l=>l.diagramParseErrors[r]??Ge),i=C(l=>l.lastSourceChange),s=pe(t,r),[u,B]=n.useState("visual"),[w,F]=n.useState(""),[c,m]=n.useState(!1),[P,f]=n.useState(!1),[x,q]=n.useState(!1),[p,k]=n.useState(!1),[R,y]=n.useState(null),[le,W]=n.useState(null),[_,j]=n.useState(null),[D,T]=n.useState(null),[ae,ce]=n.useState(null),[K,X]=n.useState([]),[L,de]=n.useState(()=>localStorage.getItem("memo.diagramEditor.autoSave")==="true"),b=n.useRef(),v=n.useRef(""),H=n.useRef(0),M=n.useRef(void 0),N=n.useRef(0),Q=n.useRef(!1);n.useEffect(()=>{Q.current=p},[p]);const J=n.useMemo(()=>ge(t,r),[t,r]),z=n.useCallback(async()=>{const l=++N.current,g=r;m(!0);try{const S=await ve(g);if(N.current!==l)return!1;const h=S.text??"";return v.current=h,M.current=S.revision,F(h),f(!0),k(!1),y(null),T(null),j(null),!0}catch(S){return N.current===l&&y(S instanceof Error?S.message:String(S)),!1}finally{N.current===l&&m(!1)}},[r]);n.useEffect(()=>{if(clearTimeout(b.current),y(null),W(null),k(!1),j(null),T(null),X([]),M.current=void 0,!(!s||!t)){if(!s.sourceFile||window.__MEMO_DATA__){const l=Oe(s,t.elements);v.current=l,F(l),m(!1),f(!1);return}F(""),v.current="",f(!1),z()}},[r,s==null?void 0:s.sourceFile]),n.useEffect(()=>{if(!i||!(s!=null&&s.sourceFile)||window.__MEMO_DATA__||!Se(i,J))return;ce(i.at);const l=i.files.includes(s.sourceFile);if(l){if(Q.current){j({files:i.files.filter(g=>J.includes(g)),at:i.at,touchesOwnSource:l});return}z()}},[i==null?void 0:i.seq]);const ue=l=>{v.current=l,F(l),k(!0),y(null)},E=n.useCallback(async(l,g)=>{if(!s)return;const S=++H.current;q(!0),y(null);try{if(s.sourceFile){const h=await ye(r,l,g!=null&&g.force?void 0:M.current);if(h.conflict){T({theirs:h.text??"",revision:h.revision,at:Date.now()}),y(h.error??"The file changed on disk since this edit began.");return}M.current=h.revision,T(null),j(null),X(h.parseErrors??[])}else be(r,l);v.current===l&&k(!1),W(Date.now())}catch(h){y(h instanceof Error?h.message:String(h))}finally{H.current===S&&q(!1)}},[s,r]),Z=n.useCallback(()=>{clearTimeout(b.current),z()},[z]),fe=n.useCallback(()=>{clearTimeout(b.current),E(v.current,{force:!0})},[E]);n.useEffect(()=>(localStorage.setItem("memo.diagramEditor.autoSave",String(L)),clearTimeout(b.current),L&&p&&!c&&!D&&(b.current=setTimeout(()=>void E(v.current),800)),()=>clearTimeout(b.current)),[L,p,c,w,E,D]);const ee=n.useCallback(()=>{clearTimeout(b.current),E(v.current)},[E]),he=n.useMemo(()=>Object.values((t==null?void 0:t.elements)??{}).map(l=>({id:l.id,name:l.name,kind:l.kind})),[t==null?void 0:t.elements]);if(!s)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:a.faint,fontSize:d.sm},children:"Diagram not found"});const te=s.auto,I=!te||!!s.sourceFile&&P,re=e.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden",children:[D&&e.jsx(oe,{tone:"conflict",message:`${s.sourceFile} changed on disk while you were editing. Saving now would discard those changes.`,actions:[{label:"Reload from disk",onClick:Z,hint:"Discards your unsaved edits"},{label:"Overwrite with mine",onClick:fe,hint:"Discards the changes on disk"}]}),!D&&_&&e.jsx(oe,{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:Z,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(n.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:s.sourceFile,readOnly:!I||c,symbols:he,onChange:ue,onSave:()=>{I&&p&&ee()}})})}),K.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:K.join(" · ")}),o.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:o.join(" · ")}),R&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C0A0A",color:"#FCA5A5",borderTop:"1px solid #3B0A0A"},children:R}),!I&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#F9F9F8",color:a.faint,borderTop:`1px solid ${a.border}`},children:s.sourceFile&&window.__MEMO_DATA__?"Static build — run memo-architect dev to edit the SysML source":s.sourceFile?"The SysML source could not be loaded":"Generated model view — no editable SysML source file"})]}),se=e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:e.jsx(Ie,{})}),!te&&e.jsx(Be,{diagram:s})]});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:s.name}),s.sourceFile&&e.jsx("span",{className:"truncate",title:s.sourceFile,style:{maxWidth:"220px",color:a.faint,fontSize:d.xs},children:s.sourceFile}),(u==="text"||u==="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(Ve,{at:ae}),c&&e.jsx("span",{style:{color:a.faint,fontSize:d.xs},children:"Loading source…"}),x&&e.jsx("span",{style:{color:a.faint,fontSize:d.xs},children:"Saving…"}),!x&&R&&e.jsx("span",{title:R,style:{color:"#EF4444",fontSize:d.xs},children:"Save failed"}),!x&&!R&&p&&e.jsx("span",{style:{color:"#B45309",fontSize:d.xs},children:"Unsaved"}),!x&&!p&&le&&e.jsx("span",{style:{color:"#15803D",fontSize:d.xs},children:"Saved"}),!x&&o.length>0&&e.jsxs("span",{style:{color:"#EF4444",fontSize:d.xs},children:[o.length," error",o.length>1?"s":""]}),I&&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:L,onChange:l=>de(l.target.checked),style:{accentColor:a.accent}}),"Auto-save"]}),e.jsx("button",{onClick:ee,disabled:!p||x||c,title:"Save SysML (Ctrl/Cmd+S)",style:{fontSize:d.xs,padding:"3px 10px",borderRadius:"5px",border:`1px solid ${a.border}`,cursor:!p||x||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:()=>B(l),style:{fontSize:d.xs,padding:"3px 10px",border:"none",cursor:"pointer",background:u===l?a.accent:"transparent",color:u===l?"#FFFFFF":a.secondary,fontWeight:u===l?600:400},children:g},l))})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[u==="visual"&&se,u==="text"&&re,u==="split"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"50%",borderRight:`1px solid ${a.border}`,display:"flex",flexDirection:"column",overflow:"hidden"},children:re}),e.jsx("div",{style:{width:"50%",display:"flex",overflow:"hidden"},children:se})]})]})]})}export{Ke as DiagramEditor};
@@ -1,2 +1,2 @@
1
- import{j as e}from"./reactflow-WKyu73tD.js";import{a as v}from"./zustand-qbFpP9Up.js";import{u as d,e as B,C as t,F as n,d as A,K,S as z}from"./index-CgRwea72.js";const R=new Set(["Scenario","UseCase","UserActivity"]);function W(i){return i?i.split(`
2
- `).filter(o=>o.trim()).map((o,c)=>{const p=o.match(/^\d+\.\s*(.*)/);return{index:c,text:p?p[1].trim():o.trim()}}):[]}function V({element:i,layerColor:o}){const c=v.useMemo(()=>W(i.doc||""),[i.doc]),[p,u]=v.useState(!1),S=d(r=>r.updateElementField),f=d(r=>r.applyEdit),y=d(r=>r.pendingEdits).get(i.id),l=(y==null?void 0:y.doc)??i.doc??"";if(c.length===0&&!p)return e.jsx("div",{className:"rounded-lg p-4 cursor-pointer text-center",style:{background:o+"08",border:`1px dashed ${o}40`,color:t.faint,fontSize:n.sm},onClick:()=>u(!0),children:"No steps defined. Click to add scenario steps (one per line, numbered)."});if(p){const r=()=>{f(i.id),u(!1)};return e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:n.xs,color:t.faint,marginBottom:"6px"},children:["Enter numbered steps, one per line: ",e.jsx("code",{children:"1. User does something"})]}),e.jsx("textarea",{value:l,onChange:b=>S(i.id,"doc",b.target.value),className:"w-full rounded-lg p-3 focus:outline-none",style:{border:`1px solid ${t.accent}`,background:t.surface,color:t.primary,fontSize:n.sm,minHeight:"120px",resize:"vertical",fontFamily:"monospace",lineHeight:1.7},autoFocus:!0}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("button",{onClick:r,className:"px-3 py-1.5 rounded-md font-medium",style:{background:t.accent,color:t.accentDark,fontSize:n.xs},children:"Save"}),e.jsx("button",{onClick:()=>u(!1),className:"px-3 py-1.5 rounded-md",style:{color:t.muted,fontSize:n.xs,border:`1px solid ${t.border}`},children:"Cancel"})]})]})}return e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>u(!0),style:{position:"absolute",top:0,right:0,fontSize:n.xs,color:t.faint,padding:"2px 8px",border:`1px solid ${t.border}`,borderRadius:"6px",background:t.surface,cursor:"pointer"},onMouseEnter:r=>r.currentTarget.style.borderColor=t.accent,onMouseLeave:r=>r.currentTarget.style.borderColor=t.border,children:"Edit steps"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:0,paddingTop:"4px"},children:[e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:n.xs,fontWeight:700,background:o,color:"#fff",letterSpacing:"0.06em",textTransform:"uppercase"},children:"Start"}),c.map((r,b)=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:[e.jsx("div",{style:{width:"2px",height:"20px",background:o+"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 ${o}80`}})}),e.jsxs("div",{style:{width:"100%",maxWidth:"560px",display:"flex",alignItems:"flex-start",gap:"12px",background:t.surface,border:`1px solid ${o}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:o+"18",color:o,fontSize:n.xs,fontWeight:700},children:b+1}),e.jsx("span",{style:{fontSize:n.sm,color:t.primary,lineHeight:1.5,paddingTop:"3px"},children:r.text})]})]},b)),e.jsx("div",{style:{width:"2px",height:"20px",background:o+"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 ${o}80`}})}),e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:n.xs,fontWeight:700,background:o+"20",color:o,letterSpacing:"0.06em",textTransform:"uppercase",border:`1px solid ${o}40`},children:"End"})]})]})}function X(){const i=d(s=>s.activeView),o=d(s=>s.model),c=d(s=>s.validation),p=d(s=>s.selectElement),u=d(s=>s.updateElementField),S=d(s=>s.updateElementAttribute),f=d(s=>s.cancelEdit),x=d(s=>s.applyEdit),y=d(s=>s.pendingEdits),l=i.type==="element-detail"?i.elementId:null,r=l&&o?o.elements[l]:null,[b,w]=v.useState(!1),[L,k]=v.useState(null),m=v.useMemo(()=>{if(!o||!l)return{incoming:[],outgoing:[]};const s=B(o,l);return{incoming:s.filter(a=>a.targetId===l),outgoing:s.filter(a=>a.sourceId===l)}},[o,l]),E=v.useMemo(()=>!c||!l?[]:c.violations.filter(s=>s.elementId===l),[c,l]);if(!r||!l)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:t.surfaceAlt},children:e.jsxs("div",{className:"text-center",style:{color:t.faint},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"12px",opacity:.5},children:"📄"}),e.jsx("p",{style:{fontSize:n.md},children:"Select an element to view details"})]})});const C=A[r.layer]||t.muted,h=K[r.kind],j=y.get(l),F=(j==null?void 0:j.doc)??r.doc??"",O=y.has(l),T=()=>{x(l),w(!1),k(null)},D=s=>{if(!o)return s;const a=o.elements[s];return a?a.name:s};return e.jsx("div",{className:"flex-1 overflow-y-auto",style:{background:t.surfaceAlt},children:e.jsxs("div",{style:{maxWidth:"900px",margin:"0 auto",padding:"32px 40px"},children:[e.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"px-2 py-1 rounded font-semibold",style:{background:C+"18",color:C,fontSize:n.sm},children:r.kind}),e.jsx("span",{className:"px-2 py-1 rounded",style:{background:((h==null?void 0:h.color)||t.muted)+"12",color:(h==null?void 0:h.color)||t.muted,fontSize:n.xs},children:r.layer}),h&&e.jsx("span",{style:{color:t.faint,fontSize:n.xs},children:h.label})]}),e.jsx("h1",{style:{fontSize:"24px",fontWeight:700,color:t.primary,lineHeight:1.3},children:r.name}),e.jsx("p",{className:"mt-1",style:{color:t.faint,fontSize:n.xs,fontFamily:"monospace"},children:r.id})]}),O&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>f(l),className:"px-4 py-2 rounded-lg font-medium transition-all",style:{background:t.surface,color:t.muted,fontSize:n.sm,border:`1px solid ${t.border}`},onMouseEnter:s=>s.currentTarget.style.borderColor=t.accent,onMouseLeave:s=>s.currentTarget.style.borderColor=t.border,children:"Cancel"}),e.jsx("button",{onClick:T,className:"px-4 py-2 rounded-lg font-medium transition-all",style:{background:t.accent,color:t.accentDark,fontSize:n.sm,boxShadow:z.sm},onMouseEnter:s=>s.currentTarget.style.boxShadow=z.md,onMouseLeave:s=>s.currentTarget.style.boxShadow=z.sm,children:"Save Changes"})]})]}),E.length>0&&e.jsxs("div",{className:"rounded-lg mb-6 overflow-hidden",style:{border:"1px solid #FEE2E2",background:"#FEF2F2"},children:[e.jsxs("div",{className:"px-4 py-2 font-medium",style:{color:"#DC2626",fontSize:n.sm,borderBottom:"1px solid #FEE2E2"},children:[E.length," violation",E.length!==1?"s":""]}),E.map((s,a)=>e.jsxs("div",{className:"px-4 py-2 flex items-center gap-2",style:{fontSize:n.xs},children:[e.jsx("span",{style:{color:"#DC2626"},children:"✖"}),e.jsxs("span",{style:{color:t.faint},children:["[",s.ruleId,"]"]}),e.jsx("span",{style:{color:"#991B1B"},children:s.description})]},a))]}),R.has(r.kind)&&e.jsx(N,{title:"Flow",children:e.jsx(V,{element:r,layerColor:C})}),!R.has(r.kind)&&e.jsx(N,{title:"Description",children:b?e.jsxs("div",{children:[e.jsx("textarea",{value:F,onChange:s=>u(l,"doc",s.target.value),className:"w-full rounded-lg p-3 focus:outline-none focus:ring-2",style:{border:`1px solid ${t.border}`,background:t.surface,color:t.primary,fontSize:n.md,minHeight:"120px",resize:"vertical",fontFamily:"inherit",lineHeight:1.6,"--tw-ring-color":t.accent},autoFocus:!0}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("button",{onClick:T,className:"px-3 py-1.5 rounded-md font-medium",style:{background:t.accent,color:t.accentDark,fontSize:n.xs},children:"Save"}),e.jsx("button",{onClick:()=>w(!1),className:"px-3 py-1.5 rounded-md",style:{color:t.muted,fontSize:n.xs,border:`1px solid ${t.border}`},children:"Cancel"})]})]}):e.jsx("div",{className:"rounded-lg p-4 cursor-pointer transition-all",style:{background:t.surface,border:`1px solid ${t.border}`,minHeight:"60px",color:F?t.primary:t.faint,fontSize:n.md,lineHeight:1.6},onClick:()=>w(!0),onMouseEnter:s=>s.currentTarget.style.borderColor=t.accent,onMouseLeave:s=>s.currentTarget.style.borderColor=t.border,title:"Click to edit",children:F||"Click to add a description..."})}),e.jsx(N,{title:"Attributes",children:e.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:`1px solid ${t.border}`,background:t.surface},children:e.jsxs("table",{className:"w-full",style:{fontSize:n.sm},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:`1px solid ${t.border}`,background:t.surfaceAlt},children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:t.secondary,width:"35%"},children:"Key"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:t.secondary},children:"Value"})]})}),e.jsxs("tbody",{children:[Object.entries(r.attributes).length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:2,className:"px-4 py-3 text-center",style:{color:t.faint},children:"No attributes"})}),Object.entries(r.attributes).map(([s,a])=>{var I;const $=((I=j==null?void 0:j.attributes)==null?void 0:I[s])??a,H=L===s;return e.jsxs("tr",{style:{borderBottom:`1px solid ${t.borderLight}`},children:[e.jsx("td",{className:"px-4 py-2",style:{color:t.secondary,fontFamily:"monospace",fontSize:n.xs},children:s}),e.jsx("td",{className:"px-4 py-2",children:H?e.jsx("input",{type:"text",value:$,onChange:g=>S(l,s,g.target.value),onBlur:()=>k(null),onKeyDown:g=>{g.key==="Enter"&&k(null)},className:"w-full px-2 py-1 rounded focus:outline-none",style:{border:`1px solid ${t.accent}`,color:t.primary,fontSize:n.sm},autoFocus:!0}):e.jsx("span",{className:"cursor-pointer block px-2 py-1 rounded",style:{color:t.primary},onClick:()=>k(s),onMouseEnter:g=>g.currentTarget.style.background=t.surfaceAlt,onMouseLeave:g=>g.currentTarget.style.background="transparent",title:"Click to edit",children:$||e.jsx("span",{style:{color:t.faint},children:"—"})})})]},s)})]})]})})}),(m.outgoing.length>0||m.incoming.length>0)&&e.jsxs(N,{title:"Relationships",children:[m.outgoing.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("h4",{className:"font-medium mb-2",style:{color:t.secondary,fontSize:n.sm},children:["Outgoing (",m.outgoing.length,")"]}),e.jsx("div",{className:"space-y-1",children:m.outgoing.map((s,a)=>e.jsx(M,{rel:s,direction:"out",resolveName:D,onNavigate:p},a))})]}),m.incoming.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",style:{color:t.secondary,fontSize:n.sm},children:["Incoming (",m.incoming.length,")"]}),e.jsx("div",{className:"space-y-1",children:m.incoming.map((s,a)=>e.jsx(M,{rel:s,direction:"in",resolveName:D,onNavigate:p},a))})]})]}),r.file&&e.jsx(N,{title:"Source",children:e.jsx("div",{className:"rounded-lg px-4 py-3",style:{background:t.surface,border:`1px solid ${t.border}`,fontSize:n.xs,fontFamily:"monospace",color:t.secondary},children:r.file})})]})})}function N({title:i,children:o}){return e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"font-semibold mb-3",style:{color:t.primary,fontSize:n.lg,letterSpacing:"-0.01em"},children:i}),o]})}function M({rel:i,direction:o,resolveName:c,onNavigate:p}){const u=o==="out"?i.targetId:i.sourceId,S=c(u),f=A[i.type]||t.accent;return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg cursor-pointer transition-all",style:{background:t.surface,border:`1px solid ${t.border}`,fontSize:n.sm},onClick:()=>p(u),onMouseEnter:x=>{x.currentTarget.style.borderColor=t.accent,x.currentTarget.style.boxShadow=z.sm},onMouseLeave:x=>{x.currentTarget.style.borderColor=t.border,x.currentTarget.style.boxShadow="none"},children:[e.jsx("span",{style:{color:t.faint,fontSize:n.xs},children:o==="out"?"→":"←"}),e.jsx("span",{className:"px-1.5 py-0.5 rounded font-medium",style:{background:f+"15",color:f,fontSize:n.badge},children:i.type}),e.jsx("span",{className:"flex-1 truncate font-medium",style:{color:t.accentDark},children:S}),e.jsx("span",{style:{color:t.faint,fontSize:n.xs},children:"›"})]})}export{X as ElementDetailView};
1
+ import{j as e}from"./reactflow-CX-HDacK.js";import{a as v}from"./zustand-qbFpP9Up.js";import{u as c,h as B,C as t,F as n,f as A,K,S as z}from"./index-CRFOCEAK.js";const R=new Set(["Scenario","UseCase","UserActivity"]);function W(i){return i?i.split(`
2
+ `).filter(o=>o.trim()).map((o,d)=>{const p=o.match(/^\d+\.\s*(.*)/);return{index:d,text:p?p[1].trim():o.trim()}}):[]}function V({element:i,layerColor:o}){const d=v.useMemo(()=>W(i.doc||""),[i.doc]),[p,u]=v.useState(!1),S=c(r=>r.updateElementField),g=c(r=>r.applyEdit),y=c(r=>r.pendingEdits).get(i.id),l=(y==null?void 0:y.doc)??i.doc??"";if(d.length===0&&!p)return e.jsx("div",{className:"rounded-lg p-4 cursor-pointer text-center",style:{background:o+"08",border:`1px dashed ${o}40`,color:t.faint,fontSize:n.sm},onClick:()=>u(!0),children:"No steps defined. Click to add scenario steps (one per line, numbered)."});if(p){const r=()=>{g(i.id),u(!1)};return e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:n.xs,color:t.faint,marginBottom:"6px"},children:["Enter numbered steps, one per line: ",e.jsx("code",{children:"1. User does something"})]}),e.jsx("textarea",{value:l,onChange:b=>S(i.id,"doc",b.target.value),className:"w-full rounded-lg p-3 focus:outline-none",style:{border:`1px solid ${t.accent}`,background:t.surface,color:t.primary,fontSize:n.sm,minHeight:"120px",resize:"vertical",fontFamily:"monospace",lineHeight:1.7},autoFocus:!0}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("button",{onClick:r,className:"px-3 py-1.5 rounded-md font-medium",style:{background:t.accent,color:t.accentDark,fontSize:n.xs},children:"Save"}),e.jsx("button",{onClick:()=>u(!1),className:"px-3 py-1.5 rounded-md",style:{color:t.muted,fontSize:n.xs,border:`1px solid ${t.border}`},children:"Cancel"})]})]})}return e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>u(!0),style:{position:"absolute",top:0,right:0,fontSize:n.xs,color:t.faint,padding:"2px 8px",border:`1px solid ${t.border}`,borderRadius:"6px",background:t.surface,cursor:"pointer"},onMouseEnter:r=>r.currentTarget.style.borderColor=t.accent,onMouseLeave:r=>r.currentTarget.style.borderColor=t.border,children:"Edit steps"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:0,paddingTop:"4px"},children:[e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:n.xs,fontWeight:700,background:o,color:"#fff",letterSpacing:"0.06em",textTransform:"uppercase"},children:"Start"}),d.map((r,b)=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:[e.jsx("div",{style:{width:"2px",height:"20px",background:o+"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 ${o}80`}})}),e.jsxs("div",{style:{width:"100%",maxWidth:"560px",display:"flex",alignItems:"flex-start",gap:"12px",background:t.surface,border:`1px solid ${o}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:o+"18",color:o,fontSize:n.xs,fontWeight:700},children:b+1}),e.jsx("span",{style:{fontSize:n.sm,color:t.primary,lineHeight:1.5,paddingTop:"3px"},children:r.text})]})]},b)),e.jsx("div",{style:{width:"2px",height:"20px",background:o+"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 ${o}80`}})}),e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:n.xs,fontWeight:700,background:o+"20",color:o,letterSpacing:"0.06em",textTransform:"uppercase",border:`1px solid ${o}40`},children:"End"})]})]})}function X(){const i=c(s=>s.activeView),o=c(s=>s.model),d=c(s=>s.validation),p=c(s=>s.selectElement),u=c(s=>s.updateElementField),S=c(s=>s.updateElementAttribute),g=c(s=>s.cancelEdit),x=c(s=>s.applyEdit),y=c(s=>s.pendingEdits),l=i.type==="element-detail"?i.elementId:null,r=l&&o?o.elements[l]:null,[b,w]=v.useState(!1),[L,k]=v.useState(null),m=v.useMemo(()=>{if(!o||!l)return{incoming:[],outgoing:[]};const s=B(o,l);return{incoming:s.filter(a=>a.targetId===l),outgoing:s.filter(a=>a.sourceId===l)}},[o,l]),E=v.useMemo(()=>!d||!l?[]:d.violations.filter(s=>s.elementId===l),[d,l]);if(!r||!l)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:t.surfaceAlt},children:e.jsxs("div",{className:"text-center",style:{color:t.faint},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"12px",opacity:.5},children:"📄"}),e.jsx("p",{style:{fontSize:n.md},children:"Select an element to view details"})]})});const C=A[r.layer]||t.muted,h=K[r.kind],j=y.get(l),F=(j==null?void 0:j.doc)??r.doc??"",O=y.has(l),T=()=>{x(l),w(!1),k(null)},D=s=>{if(!o)return s;const a=o.elements[s];return a?a.name:s};return e.jsx("div",{className:"flex-1 overflow-y-auto",style:{background:t.surfaceAlt},children:e.jsxs("div",{style:{maxWidth:"900px",margin:"0 auto",padding:"32px 40px"},children:[e.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"px-2 py-1 rounded font-semibold",style:{background:C+"18",color:C,fontSize:n.sm},children:r.kind}),e.jsx("span",{className:"px-2 py-1 rounded",style:{background:((h==null?void 0:h.color)||t.muted)+"12",color:(h==null?void 0:h.color)||t.muted,fontSize:n.xs},children:r.layer}),h&&e.jsx("span",{style:{color:t.faint,fontSize:n.xs},children:h.label})]}),e.jsx("h1",{style:{fontSize:"24px",fontWeight:700,color:t.primary,lineHeight:1.3},children:r.name}),e.jsx("p",{className:"mt-1",style:{color:t.faint,fontSize:n.xs,fontFamily:"monospace"},children:r.id})]}),O&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>g(l),className:"px-4 py-2 rounded-lg font-medium transition-all",style:{background:t.surface,color:t.muted,fontSize:n.sm,border:`1px solid ${t.border}`},onMouseEnter:s=>s.currentTarget.style.borderColor=t.accent,onMouseLeave:s=>s.currentTarget.style.borderColor=t.border,children:"Cancel"}),e.jsx("button",{onClick:T,className:"px-4 py-2 rounded-lg font-medium transition-all",style:{background:t.accent,color:t.accentDark,fontSize:n.sm,boxShadow:z.sm},onMouseEnter:s=>s.currentTarget.style.boxShadow=z.md,onMouseLeave:s=>s.currentTarget.style.boxShadow=z.sm,children:"Save Changes"})]})]}),E.length>0&&e.jsxs("div",{className:"rounded-lg mb-6 overflow-hidden",style:{border:"1px solid #FEE2E2",background:"#FEF2F2"},children:[e.jsxs("div",{className:"px-4 py-2 font-medium",style:{color:"#DC2626",fontSize:n.sm,borderBottom:"1px solid #FEE2E2"},children:[E.length," violation",E.length!==1?"s":""]}),E.map((s,a)=>e.jsxs("div",{className:"px-4 py-2 flex items-center gap-2",style:{fontSize:n.xs},children:[e.jsx("span",{style:{color:"#DC2626"},children:"✖"}),e.jsxs("span",{style:{color:t.faint},children:["[",s.ruleId,"]"]}),e.jsx("span",{style:{color:"#991B1B"},children:s.description})]},a))]}),R.has(r.kind)&&e.jsx(N,{title:"Flow",children:e.jsx(V,{element:r,layerColor:C})}),!R.has(r.kind)&&e.jsx(N,{title:"Description",children:b?e.jsxs("div",{children:[e.jsx("textarea",{value:F,onChange:s=>u(l,"doc",s.target.value),className:"w-full rounded-lg p-3 focus:outline-none focus:ring-2",style:{border:`1px solid ${t.border}`,background:t.surface,color:t.primary,fontSize:n.md,minHeight:"120px",resize:"vertical",fontFamily:"inherit",lineHeight:1.6,"--tw-ring-color":t.accent},autoFocus:!0}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("button",{onClick:T,className:"px-3 py-1.5 rounded-md font-medium",style:{background:t.accent,color:t.accentDark,fontSize:n.xs},children:"Save"}),e.jsx("button",{onClick:()=>w(!1),className:"px-3 py-1.5 rounded-md",style:{color:t.muted,fontSize:n.xs,border:`1px solid ${t.border}`},children:"Cancel"})]})]}):e.jsx("div",{className:"rounded-lg p-4 cursor-pointer transition-all",style:{background:t.surface,border:`1px solid ${t.border}`,minHeight:"60px",color:F?t.primary:t.faint,fontSize:n.md,lineHeight:1.6},onClick:()=>w(!0),onMouseEnter:s=>s.currentTarget.style.borderColor=t.accent,onMouseLeave:s=>s.currentTarget.style.borderColor=t.border,title:"Click to edit",children:F||"Click to add a description..."})}),e.jsx(N,{title:"Attributes",children:e.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:`1px solid ${t.border}`,background:t.surface},children:e.jsxs("table",{className:"w-full",style:{fontSize:n.sm},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:`1px solid ${t.border}`,background:t.surfaceAlt},children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:t.secondary,width:"35%"},children:"Key"}),e.jsx("th",{className:"text-left px-4 py-2 font-medium",style:{color:t.secondary},children:"Value"})]})}),e.jsxs("tbody",{children:[Object.entries(r.attributes).length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:2,className:"px-4 py-3 text-center",style:{color:t.faint},children:"No attributes"})}),Object.entries(r.attributes).map(([s,a])=>{var I;const $=((I=j==null?void 0:j.attributes)==null?void 0:I[s])??a,H=L===s;return e.jsxs("tr",{style:{borderBottom:`1px solid ${t.borderLight}`},children:[e.jsx("td",{className:"px-4 py-2",style:{color:t.secondary,fontFamily:"monospace",fontSize:n.xs},children:s}),e.jsx("td",{className:"px-4 py-2",children:H?e.jsx("input",{type:"text",value:$,onChange:f=>S(l,s,f.target.value),onBlur:()=>k(null),onKeyDown:f=>{f.key==="Enter"&&k(null)},className:"w-full px-2 py-1 rounded focus:outline-none",style:{border:`1px solid ${t.accent}`,color:t.primary,fontSize:n.sm},autoFocus:!0}):e.jsx("span",{className:"cursor-pointer block px-2 py-1 rounded",style:{color:t.primary},onClick:()=>k(s),onMouseEnter:f=>f.currentTarget.style.background=t.surfaceAlt,onMouseLeave:f=>f.currentTarget.style.background="transparent",title:"Click to edit",children:$||e.jsx("span",{style:{color:t.faint},children:"—"})})})]},s)})]})]})})}),(m.outgoing.length>0||m.incoming.length>0)&&e.jsxs(N,{title:"Relationships",children:[m.outgoing.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("h4",{className:"font-medium mb-2",style:{color:t.secondary,fontSize:n.sm},children:["Outgoing (",m.outgoing.length,")"]}),e.jsx("div",{className:"space-y-1",children:m.outgoing.map((s,a)=>e.jsx(M,{rel:s,direction:"out",resolveName:D,onNavigate:p},a))})]}),m.incoming.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-2",style:{color:t.secondary,fontSize:n.sm},children:["Incoming (",m.incoming.length,")"]}),e.jsx("div",{className:"space-y-1",children:m.incoming.map((s,a)=>e.jsx(M,{rel:s,direction:"in",resolveName:D,onNavigate:p},a))})]})]}),r.file&&e.jsx(N,{title:"Source",children:e.jsx("div",{className:"rounded-lg px-4 py-3",style:{background:t.surface,border:`1px solid ${t.border}`,fontSize:n.xs,fontFamily:"monospace",color:t.secondary},children:r.file})})]})})}function N({title:i,children:o}){return e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"font-semibold mb-3",style:{color:t.primary,fontSize:n.lg,letterSpacing:"-0.01em"},children:i}),o]})}function M({rel:i,direction:o,resolveName:d,onNavigate:p}){const u=o==="out"?i.targetId:i.sourceId,S=d(u),g=A[i.type]||t.accent;return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg cursor-pointer transition-all",style:{background:t.surface,border:`1px solid ${t.border}`,fontSize:n.sm},onClick:()=>p(u),onMouseEnter:x=>{x.currentTarget.style.borderColor=t.accent,x.currentTarget.style.boxShadow=z.sm},onMouseLeave:x=>{x.currentTarget.style.borderColor=t.border,x.currentTarget.style.boxShadow="none"},children:[e.jsx("span",{style:{color:t.faint,fontSize:n.xs},children:o==="out"?"→":"←"}),e.jsx("span",{className:"px-1.5 py-0.5 rounded font-medium",style:{background:g+"15",color:g,fontSize:n.badge},children:i.type}),e.jsx("span",{className:"flex-1 truncate font-medium",style:{color:t.accentDark},children:S}),e.jsx("span",{style:{color:t.faint,fontSize:n.xs},children:"›"})]})}export{X as ElementDetailView};
@@ -1 +1 @@
1
- import{j as e}from"./reactflow-WKyu73tD.js";import{u as n}from"./index-CgRwea72.js";import"./zustand-qbFpP9Up.js";function p(){const i=n(t=>t.setBulkImportOpen),s=n(t=>t.connected),a=[{icon:"📄",title:"Import Elements from CSV",description:"Import model elements from a CSV or tab-separated file. Supports column mapping, artifact type presets, and batch preview before committing.",action:()=>i(!0),requiresConnection:!0}];return e.jsx("div",{style:{flex:1,overflow:"auto",padding:"40px 48px",background:"linear-gradient(135deg, #F0F4F7 0%, #E8EFF3 100%)",minHeight:0},children:e.jsxs("div",{style:{maxWidth:720,margin:"0 auto"},children:[e.jsx("h1",{style:{fontSize:"22px",fontWeight:700,color:"#1B3A4B",marginBottom:6},children:"Import"}),e.jsx("p",{style:{fontSize:"14px",color:"#6B7280",marginBottom:36},children:"Bring data into your model from external sources."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:16},children:a.map(t=>{const r=t.requiresConnection&&!s;return e.jsxs("button",{onClick:r?void 0:t.action,disabled:r,style:{display:"flex",alignItems:"flex-start",gap:20,padding:"20px 24px",borderRadius:12,textAlign:"left",background:r?"rgba(255,255,255,0.4)":"rgba(255,255,255,0.75)",border:`1px solid ${r?"rgba(255,255,255,0.6)":"rgba(255,255,255,0.95)"}`,boxShadow:r?"none":"0 2px 8px rgba(0,0,0,0.06)",cursor:r?"not-allowed":"pointer",transition:"all 0.15s",opacity:r?.55:1},onMouseEnter:o=>{r||(o.currentTarget.style.background="rgba(255,255,255,0.95)",o.currentTarget.style.boxShadow="0 4px 16px rgba(0,0,0,0.1)",o.currentTarget.style.transform="translateY(-1px)")},onMouseLeave:o=>{r||(o.currentTarget.style.background="rgba(255,255,255,0.75)",o.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.06)",o.currentTarget.style.transform="none")},children:[e.jsx("div",{style:{fontSize:28,lineHeight:1,flexShrink:0,marginTop:2},children:t.icon}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"#1B3A4B",marginBottom:4},children:t.title}),e.jsx("div",{style:{fontSize:"13px",color:"#6B7280",lineHeight:1.55},children:t.description}),r&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:8},children:"Connect to the dev server to use this import."})]})]},t.title)})})]})})}export{p as ImportView};
1
+ import{j as e}from"./reactflow-CX-HDacK.js";import{u as n}from"./index-CRFOCEAK.js";import"./zustand-qbFpP9Up.js";function p(){const i=n(t=>t.setBulkImportOpen),s=n(t=>t.connected),a=[{icon:"📄",title:"Import Elements from CSV",description:"Import model elements from a CSV or tab-separated file. Supports column mapping, artifact type presets, and batch preview before committing.",action:()=>i(!0),requiresConnection:!0}];return e.jsx("div",{style:{flex:1,overflow:"auto",padding:"40px 48px",background:"linear-gradient(135deg, #F0F4F7 0%, #E8EFF3 100%)",minHeight:0},children:e.jsxs("div",{style:{maxWidth:720,margin:"0 auto"},children:[e.jsx("h1",{style:{fontSize:"22px",fontWeight:700,color:"#1B3A4B",marginBottom:6},children:"Import"}),e.jsx("p",{style:{fontSize:"14px",color:"#6B7280",marginBottom:36},children:"Bring data into your model from external sources."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:16},children:a.map(t=>{const r=t.requiresConnection&&!s;return e.jsxs("button",{onClick:r?void 0:t.action,disabled:r,style:{display:"flex",alignItems:"flex-start",gap:20,padding:"20px 24px",borderRadius:12,textAlign:"left",background:r?"rgba(255,255,255,0.4)":"rgba(255,255,255,0.75)",border:`1px solid ${r?"rgba(255,255,255,0.6)":"rgba(255,255,255,0.95)"}`,boxShadow:r?"none":"0 2px 8px rgba(0,0,0,0.06)",cursor:r?"not-allowed":"pointer",transition:"all 0.15s",opacity:r?.55:1},onMouseEnter:o=>{r||(o.currentTarget.style.background="rgba(255,255,255,0.95)",o.currentTarget.style.boxShadow="0 4px 16px rgba(0,0,0,0.1)",o.currentTarget.style.transform="translateY(-1px)")},onMouseLeave:o=>{r||(o.currentTarget.style.background="rgba(255,255,255,0.75)",o.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.06)",o.currentTarget.style.transform="none")},children:[e.jsx("div",{style:{fontSize:28,lineHeight:1,flexShrink:0,marginTop:2},children:t.icon}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"#1B3A4B",marginBottom:4},children:t.title}),e.jsx("div",{style:{fontSize:"13px",color:"#6B7280",lineHeight:1.55},children:t.description}),r&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:8},children:"Connect to the dev server to use this import."})]})]},t.title)})})]})})}export{p as ImportView};
@@ -1 +1 @@
1
- import{j as t}from"./reactflow-WKyu73tD.js";import{a as f}from"./zustand-qbFpP9Up.js";import{L as M}from"./index-CgRwea72.js";const $={"purpose-operational":{bg:"#f0f7ff",header:"#cce5ff",text:"#1e40af",border:"#93c5fd"},requirements:{bg:"#f0f6ff",header:"#dae8fc",text:"#1d4ed8",border:"#93c5fd"},architecture:{bg:"#f0faf0",header:"#d5e8d4",text:"#166534",border:"#86efac"},risk:{bg:"#fff5f5",header:"#f8cecc",text:"#991b1b",border:"#fca5a5"},"vv-evidence":{bg:"#faf5ff",header:"#e1d5e7",text:"#6b21a8",border:"#c4b5fd"},"dhf-outputs":{bg:"#fffbeb",header:"#fff2cc",text:"#92400e",border:"#fcd34d"},other:{bg:"#f9fafb",header:"#f3f4f6",text:"#374151",border:"#d1d5db"}},F=[{id:"purpose-operational",label:"Purpose & Operational",abbr:"PUR",layerIds:["purpose","business","operational"]},{id:"requirements",label:"Requirements",abbr:"REQ",layerIds:["requirements"]},{id:"architecture",label:"Architecture",abbr:"ARCH",layerIds:["functional","behavior","logical","physical","software","interfaces","ui"],subGroups:[{label:"Functional",layerIds:["functional","behavior"]},{label:"Logical",layerIds:["logical"]},{label:"Physical",layerIds:["physical"]},{label:"Software",layerIds:["software"]},{label:"Interfaces",layerIds:["interfaces","ui"]}]},{id:"risk",label:"Risk",abbr:"RISK",layerIds:["risk","safety","cybersecurity"]},{id:"vv-evidence",label:"V&V & Evidence",abbr:"V&V",layerIds:["verification","analysis"]},{id:"dhf-outputs",label:"DHF Outputs",abbr:"DHF",layerIds:["design-control","qms","software-lifecycle","operations","clinical","privacy"]}],A=Object.fromEntries(M.map((n,r)=>[n,r]));function O(n){return[...n].sort((r,d)=>(A[r.id]??99)-(A[d.id]??99))}function T(n){return[...n].sort((r,d)=>{const a=r.derivesFrom?1:0,x=d.derivesFrom?1:0;return a!==x?a-x:r.name.localeCompare(d.name)})}function B({kind:n,layerColor:r,domainBg:d,selected:a,onClick:x,onContextMenu:N,isFlashing:p,flashTick:R}){const[b,g]=f.useState(!1),[v,j]=f.useState(!1);f.useEffect(()=>{if(!p)return;j(!0);const w=setTimeout(()=>j(!1),700);return()=>clearTimeout(w)},[p,R]);const m=a?`${r}18`:b?`${r}0C`:"#ffffff",I=a?r:"transparent",k=r;return t.jsxs("button",{"data-kind":n.name,onClick:x,onContextMenu:N,onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),className:"text-left transition-all",style:{width:"130px",minHeight:"55px",background:m,border:`1px solid ${I}`,borderLeft:`3px solid ${k}`,borderRadius:"6px",padding:"6px 8px",cursor:"pointer",transform:v?"scale(1.04)":"scale(1)",boxShadow:v?`0 0 0 2px ${r}, 0 0 12px ${r}60`:a?`0 0 0 1px ${r}40`:b?"0 1px 3px rgba(0,0,0,0.08)":"none",flexShrink:0},children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{style:{fontSize:"9px",fontFamily:"monospace",color:r,opacity:.8,textTransform:"uppercase",letterSpacing:"0.02em",lineHeight:1},children:n.construct.replace("part def","pd").replace("connection def","cd").replace("attribute def","ad")}),n.instanceCount>0&&t.jsx("span",{style:{fontSize:"9px",color:"#6B7280",background:`${r}15`,borderRadius:"8px",padding:"0 4px",lineHeight:"14px"},children:n.instanceCount})]}),t.jsx("div",{style:{fontSize:"11px",fontWeight:n.derivesFrom?400:600,color:a?r:"#1F2937",lineHeight:1.3,wordBreak:"break-word"},children:n.name}),n.derivesFrom&&t.jsxs("div",{style:{fontSize:"9px",color:"#9CA3AF",marginTop:"2px",lineHeight:1},children:["↳ ",n.derivesFrom]})]})}function z({layers:n,selectedKind:r,onKindClick:d,activeLayerId:a,flashKindName:x,flashTick:N}){const p=f.useRef({}),[R,b]=f.useState(null),[g,v]=f.useState(()=>new Set(F.map(e=>e.id).concat(["other"])));if(f.useEffect(()=>{if(!a)return;const e=p.current[a];if(e){e.scrollIntoView({behavior:"smooth",block:"start"}),b(a);const o=setTimeout(()=>b(null),1200);return()=>clearTimeout(o)}},[a]),n.length===0)return t.jsx("div",{className:"flex items-center justify-center py-12",style:{color:"#9CA3AF"},children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-2xl mb-2",children:"⬡"}),t.jsx("div",{className:"text-xs",children:"No layers found in this ontology"})]})});const j=new Set(F.flatMap(e=>e.layerIds)),m=O(n.filter(e=>!j.has(e.id)));function I(e,o){e.preventDefault()}function k(e){v(o=>{const s=new Set(o);return s.has(e)?s.delete(e):s.add(e),s})}const w=(e,o,s)=>T(e).map(l=>t.jsx(B,{kind:l,layerColor:o,domainBg:s,selected:r===l.name,onClick:()=>d(r===l.name?null:l.name),onContextMenu:u=>I(u,l.name),isFlashing:x===l.name,flashTick:N},l.name)),C=(e,o)=>{const s=$[e.id]??$.other,L=o.reduce((i,c)=>i+c.kindCount,0),l=L===0,u=g.has(e.id),E=O(o);return t.jsxs("div",{ref:i=>{p.current[e.id]=i},className:"rounded-xl overflow-hidden transition-all",style:{border:`1px solid ${s.border}`,background:s.bg,outline:R===e.id?`2px solid ${s.border}`:"none",outlineOffset:"2px"},children:[t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 cursor-pointer select-none",style:{background:s.header,borderBottom:u?"none":`1px solid ${s.border}`},onClick:()=>k(e.id),title:u?"Expand":"Collapse",children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",style:{transition:"transform 150ms ease",transform:u?"rotate(-90deg)":"rotate(0deg)",flexShrink:0},children:t.jsx("path",{d:"M4 6L8 10L12 6",stroke:s.text,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),t.jsx("span",{style:{fontSize:"10px",fontWeight:700,color:s.text,letterSpacing:"0.08em",textTransform:"uppercase",minWidth:"32px",textAlign:"center"},children:e.abbr}),t.jsx("span",{style:{width:"1px",height:"14px",background:`${s.border}`,opacity:.5}}),t.jsx("span",{className:"text-xs font-semibold flex-1",style:{color:s.text},children:e.label}),t.jsx("span",{className:"text-xs",style:{color:s.text,opacity:.7},children:l?"no kinds":`${L} kinds`})]}),!u&&(l?t.jsx("div",{className:"px-4 py-1.5 text-xs italic",style:{color:s.text,opacity:.4},children:"(no elements)"}):t.jsx("div",{className:"p-3 space-y-3",children:e.subGroups?e.subGroups.map(i=>{const c=E.filter(y=>i.layerIds.includes(y.id));if(c.length===0)return null;const h=c.flatMap(y=>y.kinds);if(h.length===0)return null;const S=c[0].color??s.text;return t.jsxs("div",{children:[t.jsxs("div",{className:"text-xs font-medium mb-1.5 flex items-center gap-1.5",style:{color:s.text,opacity:.75},ref:y=>{c.forEach(H=>{p.current[H.id]=y})},children:[t.jsx("span",{className:"inline-block w-2 h-2 rounded-sm flex-shrink-0",style:{background:S}}),i.label]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:w(h,S,s.bg)})]},i.label)}):(()=>{var h;const i=E.flatMap(S=>S.kinds),c=((h=E[0])==null?void 0:h.color)??s.text;return t.jsx("div",{className:"flex flex-wrap gap-2",children:w(i,c,s.bg)})})()}))]},e.id)};return t.jsxs("div",{className:"space-y-3 mb-6",children:[F.map(e=>{const o=n.filter(s=>e.layerIds.includes(s.id));return o.length===0?null:C(e,o)}),m.length>0&&C({id:"other",label:"Other",abbr:"EXT",layerIds:m.map(e=>e.id)},m)]})}export{z as LayerGrid};
1
+ import{j as t}from"./reactflow-CX-HDacK.js";import{a as f}from"./zustand-qbFpP9Up.js";import{L as M}from"./index-CRFOCEAK.js";const $={"purpose-operational":{bg:"#f0f7ff",header:"#cce5ff",text:"#1e40af",border:"#93c5fd"},requirements:{bg:"#f0f6ff",header:"#dae8fc",text:"#1d4ed8",border:"#93c5fd"},architecture:{bg:"#f0faf0",header:"#d5e8d4",text:"#166534",border:"#86efac"},risk:{bg:"#fff5f5",header:"#f8cecc",text:"#991b1b",border:"#fca5a5"},"vv-evidence":{bg:"#faf5ff",header:"#e1d5e7",text:"#6b21a8",border:"#c4b5fd"},"dhf-outputs":{bg:"#fffbeb",header:"#fff2cc",text:"#92400e",border:"#fcd34d"},other:{bg:"#f9fafb",header:"#f3f4f6",text:"#374151",border:"#d1d5db"}},F=[{id:"purpose-operational",label:"Purpose & Operational",abbr:"PUR",layerIds:["purpose","business","operational"]},{id:"requirements",label:"Requirements",abbr:"REQ",layerIds:["requirements"]},{id:"architecture",label:"Architecture",abbr:"ARCH",layerIds:["functional","behavior","logical","physical","software","interfaces","ui"],subGroups:[{label:"Functional",layerIds:["functional","behavior"]},{label:"Logical",layerIds:["logical"]},{label:"Physical",layerIds:["physical"]},{label:"Software",layerIds:["software"]},{label:"Interfaces",layerIds:["interfaces","ui"]}]},{id:"risk",label:"Risk",abbr:"RISK",layerIds:["risk","safety","cybersecurity"]},{id:"vv-evidence",label:"V&V & Evidence",abbr:"V&V",layerIds:["verification","analysis"]},{id:"dhf-outputs",label:"DHF Outputs",abbr:"DHF",layerIds:["design-control","qms","software-lifecycle","operations","clinical","privacy"]}],A=Object.fromEntries(M.map((n,r)=>[n,r]));function O(n){return[...n].sort((r,d)=>(A[r.id]??99)-(A[d.id]??99))}function T(n){return[...n].sort((r,d)=>{const a=r.derivesFrom?1:0,x=d.derivesFrom?1:0;return a!==x?a-x:r.name.localeCompare(d.name)})}function B({kind:n,layerColor:r,domainBg:d,selected:a,onClick:x,onContextMenu:N,isFlashing:p,flashTick:R}){const[b,g]=f.useState(!1),[v,j]=f.useState(!1);f.useEffect(()=>{if(!p)return;j(!0);const w=setTimeout(()=>j(!1),700);return()=>clearTimeout(w)},[p,R]);const m=a?`${r}18`:b?`${r}0C`:"#ffffff",I=a?r:"transparent",k=r;return t.jsxs("button",{"data-kind":n.name,onClick:x,onContextMenu:N,onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),className:"text-left transition-all",style:{width:"130px",minHeight:"55px",background:m,border:`1px solid ${I}`,borderLeft:`3px solid ${k}`,borderRadius:"6px",padding:"6px 8px",cursor:"pointer",transform:v?"scale(1.04)":"scale(1)",boxShadow:v?`0 0 0 2px ${r}, 0 0 12px ${r}60`:a?`0 0 0 1px ${r}40`:b?"0 1px 3px rgba(0,0,0,0.08)":"none",flexShrink:0},children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{style:{fontSize:"9px",fontFamily:"monospace",color:r,opacity:.8,textTransform:"uppercase",letterSpacing:"0.02em",lineHeight:1},children:n.construct.replace("part def","pd").replace("connection def","cd").replace("attribute def","ad")}),n.instanceCount>0&&t.jsx("span",{style:{fontSize:"9px",color:"#6B7280",background:`${r}15`,borderRadius:"8px",padding:"0 4px",lineHeight:"14px"},children:n.instanceCount})]}),t.jsx("div",{style:{fontSize:"11px",fontWeight:n.derivesFrom?400:600,color:a?r:"#1F2937",lineHeight:1.3,wordBreak:"break-word"},children:n.name}),n.derivesFrom&&t.jsxs("div",{style:{fontSize:"9px",color:"#9CA3AF",marginTop:"2px",lineHeight:1},children:["↳ ",n.derivesFrom]})]})}function z({layers:n,selectedKind:r,onKindClick:d,activeLayerId:a,flashKindName:x,flashTick:N}){const p=f.useRef({}),[R,b]=f.useState(null),[g,v]=f.useState(()=>new Set(F.map(e=>e.id).concat(["other"])));if(f.useEffect(()=>{if(!a)return;const e=p.current[a];if(e){e.scrollIntoView({behavior:"smooth",block:"start"}),b(a);const o=setTimeout(()=>b(null),1200);return()=>clearTimeout(o)}},[a]),n.length===0)return t.jsx("div",{className:"flex items-center justify-center py-12",style:{color:"#9CA3AF"},children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-2xl mb-2",children:"⬡"}),t.jsx("div",{className:"text-xs",children:"No layers found in this ontology"})]})});const j=new Set(F.flatMap(e=>e.layerIds)),m=O(n.filter(e=>!j.has(e.id)));function I(e,o){e.preventDefault()}function k(e){v(o=>{const s=new Set(o);return s.has(e)?s.delete(e):s.add(e),s})}const w=(e,o,s)=>T(e).map(l=>t.jsx(B,{kind:l,layerColor:o,domainBg:s,selected:r===l.name,onClick:()=>d(r===l.name?null:l.name),onContextMenu:u=>I(u,l.name),isFlashing:x===l.name,flashTick:N},l.name)),C=(e,o)=>{const s=$[e.id]??$.other,L=o.reduce((i,c)=>i+c.kindCount,0),l=L===0,u=g.has(e.id),E=O(o);return t.jsxs("div",{ref:i=>{p.current[e.id]=i},className:"rounded-xl overflow-hidden transition-all",style:{border:`1px solid ${s.border}`,background:s.bg,outline:R===e.id?`2px solid ${s.border}`:"none",outlineOffset:"2px"},children:[t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 cursor-pointer select-none",style:{background:s.header,borderBottom:u?"none":`1px solid ${s.border}`},onClick:()=>k(e.id),title:u?"Expand":"Collapse",children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",style:{transition:"transform 150ms ease",transform:u?"rotate(-90deg)":"rotate(0deg)",flexShrink:0},children:t.jsx("path",{d:"M4 6L8 10L12 6",stroke:s.text,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),t.jsx("span",{style:{fontSize:"10px",fontWeight:700,color:s.text,letterSpacing:"0.08em",textTransform:"uppercase",minWidth:"32px",textAlign:"center"},children:e.abbr}),t.jsx("span",{style:{width:"1px",height:"14px",background:`${s.border}`,opacity:.5}}),t.jsx("span",{className:"text-xs font-semibold flex-1",style:{color:s.text},children:e.label}),t.jsx("span",{className:"text-xs",style:{color:s.text,opacity:.7},children:l?"no kinds":`${L} kinds`})]}),!u&&(l?t.jsx("div",{className:"px-4 py-1.5 text-xs italic",style:{color:s.text,opacity:.4},children:"(no elements)"}):t.jsx("div",{className:"p-3 space-y-3",children:e.subGroups?e.subGroups.map(i=>{const c=E.filter(y=>i.layerIds.includes(y.id));if(c.length===0)return null;const h=c.flatMap(y=>y.kinds);if(h.length===0)return null;const S=c[0].color??s.text;return t.jsxs("div",{children:[t.jsxs("div",{className:"text-xs font-medium mb-1.5 flex items-center gap-1.5",style:{color:s.text,opacity:.75},ref:y=>{c.forEach(H=>{p.current[H.id]=y})},children:[t.jsx("span",{className:"inline-block w-2 h-2 rounded-sm flex-shrink-0",style:{background:S}}),i.label]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:w(h,S,s.bg)})]},i.label)}):(()=>{var h;const i=E.flatMap(S=>S.kinds),c=((h=E[0])==null?void 0:h.color)??s.text;return t.jsx("div",{className:"flex flex-wrap gap-2",children:w(i,c,s.bg)})})()}))]},e.id)};return t.jsxs("div",{className:"space-y-3 mb-6",children:[F.map(e=>{const o=n.filter(s=>e.layerIds.includes(s.id));return o.length===0?null:C(e,o)}),m.length>0&&C({id:"other",label:"Other",abbr:"EXT",layerIds:m.map(e=>e.id)},m)]})}export{z as LayerGrid};
@@ -1,2 +1,2 @@
1
- import{j as t}from"./reactflow-WKyu73tD.js";import{a}from"./zustand-qbFpP9Up.js";import{d as A}from"./index-CgRwea72.js";function q({layers:p,selectedKind:L,onKindClick:S}){const[F,D]=a.useState("name"),[g,j]=a.useState("asc"),[h,M]=a.useState(""),[c,T]=a.useState(!1),[i,v]=a.useState("all"),[d,E]=a.useState("all"),[B,f]=a.useState(!1),[N,b]=a.useState(!1),y=a.useMemo(()=>p.flatMap(e=>e.kinds.map(s=>({...s,layerLabel:e.label,layerColor:A[e.id]??e.color??"#6B7280"}))),[p]),R=a.useMemo(()=>[...new Set(p.map(e=>e.id))],[p]),K=a.useMemo(()=>[...new Set(y.map(e=>e.construct))],[y]),C=a.useMemo(()=>{let e=y;if(h.trim()){const s=h.toLowerCase();e=e.filter(o=>{var l,r;return o.name.toLowerCase().includes(s)||o.label.toLowerCase().includes(s)||o.layer.toLowerCase().includes(s)||(((l=o.description)==null?void 0:l.toLowerCase().includes(s))??!1)||(((r=o.derivesFrom)==null?void 0:r.toLowerCase().includes(s))??!1)})}return i!=="all"&&(e=e.filter(s=>s.layer===i)),d!=="all"&&(e=e.filter(s=>s.construct===d)),e},[y,h,i,d]),x=a.useMemo(()=>[...C].sort((e,s)=>{var l,r;let o=0;switch(F){case"name":o=e.name.localeCompare(s.name);break;case"layer":o=e.layer.localeCompare(s.layer);break;case"construct":o=e.construct.localeCompare(s.construct);break;case"instanceCount":o=e.instanceCount-s.instanceCount;break;case"derivesFrom":o=(e.derivesFrom??"").localeCompare(s.derivesFrom??"");break;case"derivedByCount":o=(((l=e.derivedBy)==null?void 0:l.length)??0)-(((r=s.derivedBy)==null?void 0:r.length)??0);break}return g==="asc"?o:-o}),[C,F,g]),k=a.useMemo(()=>{if(c)return null;const e=new Map;for(const s of x)e.has(s.layer)||e.set(s.layer,[]),e.get(s.layer).push(s);return e},[x,c]);function u(e){F===e?j(s=>s==="asc"?"desc":"asc"):(D(e),j("asc"))}const z=a.useCallback(()=>{const e=[["Name","Layer","Construct","Instances","Derives From","Derived By","Description"]];for(const n of x)e.push([n.name,n.layer,n.construct,String(n.instanceCount),n.derivesFrom??"",(n.derivedBy??[]).join("; "),n.description??""]);const s=e.map(n=>n.map($=>`"${$.replace(/"/g,'""')}"`).join(",")).join(`
2
- `),o=new Blob([s],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(o),r=document.createElement("a");r.href=l,r.download="ontology-kinds.csv",r.click(),URL.revokeObjectURL(l)},[x]),m=({k:e})=>t.jsx("span",{style:{fontSize:"10px",color:F===e?"#1B3A4B":"#D1D5DB",marginLeft:"3px"},children:F===e?g==="asc"?"▲":"▼":"⇅"}),w=(e,s)=>{var l,r;const o=L===e.name;return t.jsxs("div",{className:"grid items-center cursor-pointer text-xs",style:{gridTemplateColumns:"1.5fr 100px 90px 60px 120px 60px",padding:"7px 16px",background:o?"#EFF6FF":s%2===0?"#FAFAF8":"#FFFFFF",borderLeft:o?`3px solid ${e.layerColor}`:"3px solid transparent",transition:"background 100ms ease"},onClick:()=>S(o?null:e.name),onMouseEnter:n=>{o||(n.currentTarget.style.background="#F0F7FF")},onMouseLeave:n=>{o||(n.currentTarget.style.background=o?"#EFF6FF":s%2===0?"#FAFAF8":"#FFFFFF")},children:[t.jsxs("div",{className:"flex items-center gap-2 truncate",children:[t.jsx("span",{className:"w-2 h-2 rounded flex-shrink-0",style:{backgroundColor:e.layerColor}}),t.jsx("span",{style:{color:"#1a1a1a",fontWeight:o?600:400},children:e.name})]}),t.jsx("span",{className:"capitalize",style:{color:"#6B7280"},children:e.layer}),t.jsx("span",{className:"font-mono",style:{color:"#9CA3AF"},children:e.construct}),t.jsx("span",{className:"text-right",style:{color:e.instanceCount>0?"#1B3A4B":"#D1D5DB"},children:e.instanceCount>0?e.instanceCount:"—"}),t.jsx("span",{className:"truncate",style:{color:e.derivesFrom?"#2563EB":"#D1D5DB"},children:e.derivesFrom??"—"}),t.jsx("span",{className:"text-right",style:{color:(((l=e.derivedBy)==null?void 0:l.length)??0)>0?"#374151":"#D1D5DB"},children:(((r=e.derivedBy)==null?void 0:r.length)??0)>0?e.derivedBy.length:"—"})]},`${e.layer}:${e.name}`)};return t.jsxs("div",{className:"mb-6",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[t.jsx("input",{type:"text",placeholder:"Search kinds...",value:h,onChange:e=>M(e.target.value),className:"px-2.5 py-1.5 text-xs rounded-md flex-1 min-w-[140px]",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151",outline:"none",maxWidth:"240px"},onFocus:e=>e.currentTarget.style.borderColor="#2563EB",onBlur:e=>e.currentTarget.style.borderColor="#E5E7EB"}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{onClick:()=>{f(!B),b(!1)},className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:i!=="all"?"#EFF6FF":"#F9FAFB",color:"#374151"},children:["Layer: ",i==="all"?"All":i]}),B&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 rounded-lg shadow-lg py-1 z-20",style:{background:"#FFFFFF",border:"1px solid #E5E7EB",minWidth:"120px"},children:[t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50",style:{color:"#374151"},onClick:()=>{v("all"),f(!1)},children:"All"}),R.map(e=>t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50 capitalize",style:{color:"#374151"},onClick:()=>{v(e),f(!1)},children:e},e))]})]}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{onClick:()=>{b(!N),f(!1)},className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:d!=="all"?"#EFF6FF":"#F9FAFB",color:"#374151"},children:["Construct: ",d==="all"?"All":d]}),N&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 rounded-lg shadow-lg py-1 z-20",style:{background:"#FFFFFF",border:"1px solid #E5E7EB",minWidth:"140px"},children:[t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50",style:{color:"#374151"},onClick:()=>{E("all"),b(!1)},children:"All"}),K.map(e=>t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50 font-mono",style:{color:"#374151"},onClick:()=>{E(e),b(!1)},children:e},e))]})]}),t.jsx("button",{onClick:()=>T(!c),className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:c?"#1B3A4B":"#F9FAFB",color:c?"#2DD4A8":"#374151"},children:c?"Grouped":"Flatten"}),t.jsx("button",{onClick:z,className:"px-2.5 py-1.5 text-xs rounded-md ml-auto",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151"},title:"Export as CSV",children:"Export CSV"}),t.jsxs("span",{className:"text-xs",style:{color:"#9CA3AF"},children:[C.length," / ",y.length," kinds"]})]}),t.jsxs("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid #E5E5E0"},children:[t.jsxs("div",{className:"grid text-xs font-medium",style:{gridTemplateColumns:"1.5fr 100px 90px 60px 120px 60px",background:"#F7F7F5",borderBottom:"1px solid #E5E5E0",padding:"8px 16px",color:"#6B7280",position:"sticky",top:0,zIndex:5},children:[t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("name"),children:["Kind ",t.jsx(m,{k:"name"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("layer"),children:["Layer ",t.jsx(m,{k:"layer"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("construct"),children:["Construct ",t.jsx(m,{k:"construct"})]}),t.jsxs("button",{className:"text-right flex items-center justify-end",onClick:()=>u("instanceCount"),children:["# ",t.jsx(m,{k:"instanceCount"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("derivesFrom"),children:["Derives From ",t.jsx(m,{k:"derivesFrom"})]}),t.jsxs("button",{className:"text-right flex items-center justify-end",onClick:()=>u("derivedByCount"),children:["Subs ",t.jsx(m,{k:"derivedByCount"})]})]}),c?x.map((e,s)=>w(e,s)):k&&[...k.entries()].map(([e,s])=>{const o=p.find(r=>r.id===e),l=A[e]??"#6B7280";return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 text-xs font-semibold",style:{background:`${l}08`,borderTop:"1px solid #E5E5E0",color:l},children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded flex-shrink-0",style:{backgroundColor:l}}),(o==null?void 0:o.label)??e,t.jsxs("span",{className:"font-normal",style:{color:"#9CA3AF"},children:["(",s.length,")"]})]}),s.map((r,n)=>w(r,n))]},e)}),x.length===0&&t.jsx("div",{className:"py-8 text-center text-xs",style:{color:"#9CA3AF"},children:"No kinds match the current filters"})]})]})}export{q as LayerTable};
1
+ import{j as t}from"./reactflow-CX-HDacK.js";import{a}from"./zustand-qbFpP9Up.js";import{f as A}from"./index-CRFOCEAK.js";function q({layers:p,selectedKind:L,onKindClick:S}){const[F,D]=a.useState("name"),[g,j]=a.useState("asc"),[f,M]=a.useState(""),[c,T]=a.useState(!1),[i,v]=a.useState("all"),[d,E]=a.useState("all"),[B,h]=a.useState(!1),[N,b]=a.useState(!1),y=a.useMemo(()=>p.flatMap(e=>e.kinds.map(s=>({...s,layerLabel:e.label,layerColor:A[e.id]??e.color??"#6B7280"}))),[p]),R=a.useMemo(()=>[...new Set(p.map(e=>e.id))],[p]),K=a.useMemo(()=>[...new Set(y.map(e=>e.construct))],[y]),C=a.useMemo(()=>{let e=y;if(f.trim()){const s=f.toLowerCase();e=e.filter(o=>{var l,r;return o.name.toLowerCase().includes(s)||o.label.toLowerCase().includes(s)||o.layer.toLowerCase().includes(s)||(((l=o.description)==null?void 0:l.toLowerCase().includes(s))??!1)||(((r=o.derivesFrom)==null?void 0:r.toLowerCase().includes(s))??!1)})}return i!=="all"&&(e=e.filter(s=>s.layer===i)),d!=="all"&&(e=e.filter(s=>s.construct===d)),e},[y,f,i,d]),x=a.useMemo(()=>[...C].sort((e,s)=>{var l,r;let o=0;switch(F){case"name":o=e.name.localeCompare(s.name);break;case"layer":o=e.layer.localeCompare(s.layer);break;case"construct":o=e.construct.localeCompare(s.construct);break;case"instanceCount":o=e.instanceCount-s.instanceCount;break;case"derivesFrom":o=(e.derivesFrom??"").localeCompare(s.derivesFrom??"");break;case"derivedByCount":o=(((l=e.derivedBy)==null?void 0:l.length)??0)-(((r=s.derivedBy)==null?void 0:r.length)??0);break}return g==="asc"?o:-o}),[C,F,g]),k=a.useMemo(()=>{if(c)return null;const e=new Map;for(const s of x)e.has(s.layer)||e.set(s.layer,[]),e.get(s.layer).push(s);return e},[x,c]);function u(e){F===e?j(s=>s==="asc"?"desc":"asc"):(D(e),j("asc"))}const z=a.useCallback(()=>{const e=[["Name","Layer","Construct","Instances","Derives From","Derived By","Description"]];for(const n of x)e.push([n.name,n.layer,n.construct,String(n.instanceCount),n.derivesFrom??"",(n.derivedBy??[]).join("; "),n.description??""]);const s=e.map(n=>n.map($=>`"${$.replace(/"/g,'""')}"`).join(",")).join(`
2
+ `),o=new Blob([s],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(o),r=document.createElement("a");r.href=l,r.download="ontology-kinds.csv",r.click(),URL.revokeObjectURL(l)},[x]),m=({k:e})=>t.jsx("span",{style:{fontSize:"10px",color:F===e?"#1B3A4B":"#D1D5DB",marginLeft:"3px"},children:F===e?g==="asc"?"▲":"▼":"⇅"}),w=(e,s)=>{var l,r;const o=L===e.name;return t.jsxs("div",{className:"grid items-center cursor-pointer text-xs",style:{gridTemplateColumns:"1.5fr 100px 90px 60px 120px 60px",padding:"7px 16px",background:o?"#EFF6FF":s%2===0?"#FAFAF8":"#FFFFFF",borderLeft:o?`3px solid ${e.layerColor}`:"3px solid transparent",transition:"background 100ms ease"},onClick:()=>S(o?null:e.name),onMouseEnter:n=>{o||(n.currentTarget.style.background="#F0F7FF")},onMouseLeave:n=>{o||(n.currentTarget.style.background=o?"#EFF6FF":s%2===0?"#FAFAF8":"#FFFFFF")},children:[t.jsxs("div",{className:"flex items-center gap-2 truncate",children:[t.jsx("span",{className:"w-2 h-2 rounded flex-shrink-0",style:{backgroundColor:e.layerColor}}),t.jsx("span",{style:{color:"#1a1a1a",fontWeight:o?600:400},children:e.name})]}),t.jsx("span",{className:"capitalize",style:{color:"#6B7280"},children:e.layer}),t.jsx("span",{className:"font-mono",style:{color:"#9CA3AF"},children:e.construct}),t.jsx("span",{className:"text-right",style:{color:e.instanceCount>0?"#1B3A4B":"#D1D5DB"},children:e.instanceCount>0?e.instanceCount:"—"}),t.jsx("span",{className:"truncate",style:{color:e.derivesFrom?"#2563EB":"#D1D5DB"},children:e.derivesFrom??"—"}),t.jsx("span",{className:"text-right",style:{color:(((l=e.derivedBy)==null?void 0:l.length)??0)>0?"#374151":"#D1D5DB"},children:(((r=e.derivedBy)==null?void 0:r.length)??0)>0?e.derivedBy.length:"—"})]},`${e.layer}:${e.name}`)};return t.jsxs("div",{className:"mb-6",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[t.jsx("input",{type:"text",placeholder:"Search kinds...",value:f,onChange:e=>M(e.target.value),className:"px-2.5 py-1.5 text-xs rounded-md flex-1 min-w-[140px]",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151",outline:"none",maxWidth:"240px"},onFocus:e=>e.currentTarget.style.borderColor="#2563EB",onBlur:e=>e.currentTarget.style.borderColor="#E5E7EB"}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{onClick:()=>{h(!B),b(!1)},className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:i!=="all"?"#EFF6FF":"#F9FAFB",color:"#374151"},children:["Layer: ",i==="all"?"All":i]}),B&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 rounded-lg shadow-lg py-1 z-20",style:{background:"#FFFFFF",border:"1px solid #E5E7EB",minWidth:"120px"},children:[t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50",style:{color:"#374151"},onClick:()=>{v("all"),h(!1)},children:"All"}),R.map(e=>t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50 capitalize",style:{color:"#374151"},onClick:()=>{v(e),h(!1)},children:e},e))]})]}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{onClick:()=>{b(!N),h(!1)},className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:d!=="all"?"#EFF6FF":"#F9FAFB",color:"#374151"},children:["Construct: ",d==="all"?"All":d]}),N&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 rounded-lg shadow-lg py-1 z-20",style:{background:"#FFFFFF",border:"1px solid #E5E7EB",minWidth:"140px"},children:[t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50",style:{color:"#374151"},onClick:()=>{E("all"),b(!1)},children:"All"}),K.map(e=>t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50 font-mono",style:{color:"#374151"},onClick:()=>{E(e),b(!1)},children:e},e))]})]}),t.jsx("button",{onClick:()=>T(!c),className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:c?"#1B3A4B":"#F9FAFB",color:c?"#2DD4A8":"#374151"},children:c?"Grouped":"Flatten"}),t.jsx("button",{onClick:z,className:"px-2.5 py-1.5 text-xs rounded-md ml-auto",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151"},title:"Export as CSV",children:"Export CSV"}),t.jsxs("span",{className:"text-xs",style:{color:"#9CA3AF"},children:[C.length," / ",y.length," kinds"]})]}),t.jsxs("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid #E5E5E0"},children:[t.jsxs("div",{className:"grid text-xs font-medium",style:{gridTemplateColumns:"1.5fr 100px 90px 60px 120px 60px",background:"#F7F7F5",borderBottom:"1px solid #E5E5E0",padding:"8px 16px",color:"#6B7280",position:"sticky",top:0,zIndex:5},children:[t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("name"),children:["Kind ",t.jsx(m,{k:"name"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("layer"),children:["Layer ",t.jsx(m,{k:"layer"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("construct"),children:["Construct ",t.jsx(m,{k:"construct"})]}),t.jsxs("button",{className:"text-right flex items-center justify-end",onClick:()=>u("instanceCount"),children:["# ",t.jsx(m,{k:"instanceCount"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("derivesFrom"),children:["Derives From ",t.jsx(m,{k:"derivesFrom"})]}),t.jsxs("button",{className:"text-right flex items-center justify-end",onClick:()=>u("derivedByCount"),children:["Subs ",t.jsx(m,{k:"derivedByCount"})]})]}),c?x.map((e,s)=>w(e,s)):k&&[...k.entries()].map(([e,s])=>{const o=p.find(r=>r.id===e),l=A[e]??"#6B7280";return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 text-xs font-semibold",style:{background:`${l}08`,borderTop:"1px solid #E5E5E0",color:l},children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded flex-shrink-0",style:{backgroundColor:l}}),(o==null?void 0:o.label)??e,t.jsxs("span",{className:"font-normal",style:{color:"#9CA3AF"},children:["(",s.length,")"]})]}),s.map((r,n)=>w(r,n))]},e)}),x.length===0&&t.jsx("div",{className:"py-8 text-center text-xs",style:{color:"#9CA3AF"},children:"No kinds match the current filters"})]})]})}export{q as LayerTable};