@memoarchitect/architect 0.11.2 → 0.11.3

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 (36) hide show
  1. package/dist/assets/{AiWorkspace-GFHs046m.js → AiWorkspace-DRN1NVMU.js} +1 -1
  2. package/dist/assets/{AnalysisWorkspace-BfZ4GYza.js → AnalysisWorkspace-BGdkl3PU.js} +1 -1
  3. package/dist/assets/{ComplianceWizard-CYBizPbC.js → ComplianceWizard-BktwMgJe.js} +1 -1
  4. package/dist/assets/{DSMView-BsjhUbpW.js → DSMView-Em0sO2Uj.js} +1 -1
  5. package/dist/assets/{Dashboard-rdbfFJYx.js → Dashboard-CXbU-BFU.js} +1 -1
  6. package/dist/assets/{DhfDashboard-BdhBA4OL.js → DhfDashboard-DcZw_zNy.js} +1 -1
  7. package/dist/assets/{DhfWorkbench-tnIpEFmu.js → DhfWorkbench-ClLIypQX.js} +3 -3
  8. package/dist/assets/DiagramCanvas-wDamEqea.js +4 -0
  9. package/dist/assets/{DiagramEditor-icnDwdxM.js → DiagramEditor-BSJuk0w6.js} +2 -2
  10. package/dist/assets/{ElementDetailView-Crpltlrz.js → ElementDetailView-BMgTV4b7.js} +1 -1
  11. package/dist/assets/{ExplorerTreeRow-DG8T31JS.js → ExplorerTreeRow-CX2kYnaJ.js} +1 -1
  12. package/dist/assets/{ImportView-1vrZ1CGB.js → ImportView-Dwl7KYVo.js} +1 -1
  13. package/dist/assets/{LayerGrid-DnP2smgG.js → LayerGrid-wfRIaj8M.js} +1 -1
  14. package/dist/assets/{LayerTable-97qPfMD3.js → LayerTable-DUhcLrAE.js} +1 -1
  15. package/dist/assets/{MaxGraphCanvas-BJss9LYp.js → MaxGraphCanvas-zFgc11zx.js} +1 -1
  16. package/dist/assets/{ModelDiff-H5nxOavB.js → ModelDiff-Br7XLC74.js} +1 -1
  17. package/dist/assets/{OntologyDecompositionDiagram-D0G3A7-R.js → OntologyDecompositionDiagram-BbpIVZLr.js} +1 -1
  18. package/dist/assets/{OntologyViewer-0BJ2jMZ8.js → OntologyViewer-610n8iwf.js} +2 -2
  19. package/dist/assets/{ReviewDashboard-Dl-YTC4_.js → ReviewDashboard-aDWpLpkb.js} +1 -1
  20. package/dist/assets/{ScenarioEditor-CiHaTvVY.js → ScenarioEditor-cLJenHgj.js} +1 -1
  21. package/dist/assets/{StatisticsDashboard-w2dtCD94.js → StatisticsDashboard-DOJHl1sB.js} +1 -1
  22. package/dist/assets/{TabularView-CFy0PK1L.js → TabularView-C-bodzPd.js} +1 -1
  23. package/dist/assets/{TraceabilityMatrix-DDoHYsCP.js → TraceabilityMatrix-Bp0KSjVP.js} +1 -1
  24. package/dist/assets/UiScreensWorkspace-CcV0r4cA.js +1 -0
  25. package/dist/assets/{WorkflowWizard-Br1zPSLC.js → WorkflowWizard-St0tA37H.js} +1 -1
  26. package/dist/assets/{index-DEVvBtNh.js → index-BYfHEpXT.js} +68 -68
  27. package/dist/assets/{index-BVySIRo1.css → index-X7EXuNCl.css} +1 -1
  28. package/dist/assets/{index.es-D0WykKwq.js → index.es-D_igLMWe.js} +1 -1
  29. package/dist/assets/{jspdf.es.min-DZ4wvU_9.js → jspdf.es.min-B7e0_lrE.js} +3 -3
  30. package/dist/assets/notation-scene-BLpi6R_E.js +1 -0
  31. package/dist/index.html +2 -2
  32. package/dist-standalone/index.html +184 -184
  33. package/package.json +1 -1
  34. package/dist/assets/DiagramCanvas-BmVByLcM.js +0 -4
  35. package/dist/assets/UiScreensWorkspace-DOxjCMG9.js +0 -1
  36. package/dist/assets/notation-scene-HbscVJH5.js +0 -1
@@ -0,0 +1,4 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jspdf.es.min-B7e0_lrE.js","assets/index-BYfHEpXT.js","assets/reactflow-C9OlmOYw.js","assets/zustand-CrhqMOHB.js","assets/index-X7EXuNCl.css"])))=>i.map(i=>d[i]);
2
+ var ha=Object.defineProperty;var ma=(e,t,s)=>t in e?ha(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var ln=(e,t,s)=>ma(e,typeof t!="symbol"?t+"":t,s);import{j as o,u as Fr,H as ne,P as K,b as fa,N as xt,c as jn,B as Sr,E as wn,R as ga,d as xa,e as ba,f as ya,g as wa,h as va,i as ka,k as Fa,C as Sa,l as Ca,m as ja,n as Xt,M as Ea}from"./reactflow-C9OlmOYw.js";import{b as Ia,a as u}from"./zustand-CrhqMOHB.js";/* empty css */import{F as Y,S as rt,u as ee,i as Cr,h as vn,_ as Aa,g as Ra,D as za,W as Le,q as Gs,X as Ma,Y as Ta,Z as Us,C as Xs}from"./index-BYfHEpXT.js";import{c as La,a as Na,b as Da,d as Ba,e as Pa,f as $a,g as Oa,h as Wa,i as _a,j as Ha,k as Va,I as gt,N as jr,P as Ga,l as Ua,m as Xa,n as No,o as Ya,s as Ka,u as qa,p as Za,G as cn,q as Ja,r as Qa,C as Do,t as el,v as tl,w as dn,A as ol,x as nl,y as sl,z as rl,B as Ys,D as il,E as al,F as ll,H as cl,J as dl,K as ul,R as pl,L as hl,M as ml,O as fl,Q as gl,S as xl}from"./notation-scene-BLpi6R_E.js";import{S as bl}from"./ExplorerTreeRow-CX2kYnaJ.js";import{I as V,a as ke,c as Ue,b as _e,S as Ks}from"./DiagramToolbarControls-XMGLx08e.js";import"./layout-providers-BSDYNZu0.js";import"./elk-6l8mIQnQ.js";function yl(e,t,s="both",r=10){const i=e.elements[t];if(!i)return{rootId:t,rootName:"(unknown)",rootKind:"",nodes:[],edges:[]};const c=new Map,a=new Map;for(const C of e.relationships)c.has(C.sourceId)||c.set(C.sourceId,[]),c.get(C.sourceId).push(C),a.has(C.targetId)||a.set(C.targetId,[]),a.get(C.targetId).push(C);const p=new Set;p.add(t);const b=[],g=[],j=[[t,0]];for(;j.length>0;){const[C,O]=j.shift();if(O>=r)continue;const L=O+1;if(s==="downstream"||s==="both")for(const N of c.get(C)||[]){const D=N.targetId;if(g.push({fromId:C,toId:D,relType:N.type,relId:N.id}),!p.has(D)){p.add(D);const m=e.elements[D];m&&(b.push({elementId:D,name:m.name,kind:m.kind,layer:m.layer,depth:L,viaRelType:N.type,direction:"downstream"}),j.push([D,L]))}}if(s==="upstream"||s==="both")for(const N of a.get(C)||[]){const D=N.sourceId;if(g.push({fromId:D,toId:C,relType:N.type,relId:N.id}),!p.has(D)){p.add(D);const m=e.elements[D];m&&(b.push({elementId:D,name:m.name,kind:m.kind,layer:m.layer,depth:L,viaRelType:N.type,direction:"upstream"}),j.push([D,L]))}}}return b.sort((C,O)=>C.depth-O.depth||C.name.localeCompare(O.name)),{rootId:t,rootName:i.name,rootKind:i.kind,nodes:b,edges:g}}function wl(e,t=[]){let r=e.replace(/[^A-Za-z0-9]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().split(/\s+/).filter(Boolean).map((a,p)=>p===0?a.charAt(0).toLowerCase()+a.slice(1):a.charAt(0).toUpperCase()+a.slice(1)).join("");r||(r="element"),/^[0-9]/.test(r)&&(r=`n${r}`);const i=new Set(t);if(!i.has(r))return r;let c=2;for(;i.has(`${r}${c}`);)c++;return`${r}${c}`}function vl(e){return e&&e.replace(/\s+(def|usage)$/,"").trim()||"part"}const un={display:"flex",alignItems:"center",gap:2},pn={width:1,height:18,background:"#E2E8F0",margin:"0 4px",flexShrink:0};function He({title:e,label:t,onClick:s}){return o.jsx("button",{title:e,"aria-label":e,onClick:s,style:{minWidth:26,height:26,padding:"0 5px",borderRadius:5,border:"1px solid #E2E8F0",background:"#FFFFFF",color:"#374151",fontSize:13,lineHeight:1,cursor:"pointer",fontWeight:600},children:t})}function kl({count:e,onClose:t,onAlign:s,onMatchSize:r,onDistribute:i}){return o.jsxs("div",{className:"nodrag nopan",style:{position:"absolute",top:10,left:"50%",transform:"translateX(-50%)",zIndex:25,display:"flex",alignItems:"center",gap:4,padding:"6px 8px",borderRadius:9,background:"#FFFFFF",border:"1px solid #E2E8F0",boxShadow:"0 6px 20px rgba(15,23,42,0.14)",flexWrap:"wrap",maxWidth:"calc(100% - 24px)"},children:[o.jsxs("span",{style:{fontSize:Y.xs,color:"#6B7280",fontWeight:700,paddingRight:2},children:[e," selected"]}),o.jsx("button",{type:"button",title:"Close selection tools (Esc)","aria-label":"Close selection tools",onClick:t,style:{width:24,height:24,padding:0,borderRadius:5,border:"1px solid #E2E8F0",background:"#FFFFFF",color:"#475569",cursor:"pointer",fontSize:17,lineHeight:1},children:"×"}),o.jsx("span",{style:pn}),o.jsxs("div",{style:un,children:[o.jsx(He,{title:"Align left edges",label:"⇤",onClick:()=>s("left")}),o.jsx(He,{title:"Align horizontal centres",label:"⇹",onClick:()=>s("centerX")}),o.jsx(He,{title:"Align right edges",label:"⇥",onClick:()=>s("right")}),o.jsx(He,{title:"Align top edges",label:"⤒",onClick:()=>s("top")}),o.jsx(He,{title:"Align vertical centres",label:"⇳",onClick:()=>s("centerY")}),o.jsx(He,{title:"Align bottom edges",label:"⤓",onClick:()=>s("bottom")})]}),o.jsx("span",{style:pn}),o.jsxs("div",{style:un,children:[o.jsx(He,{title:"Match width to the widest",label:"↔",onClick:()=>r("width")}),o.jsx(He,{title:"Match height to the tallest",label:"↕",onClick:()=>r("height")}),o.jsx(He,{title:"Match width and height",label:"⤢",onClick:()=>r("both")})]}),o.jsx("span",{style:pn}),o.jsxs("div",{style:un,children:[o.jsx(He,{title:e>=3?"Even horizontal gaps":"Even horizontal gaps (needs 3 blocks)",label:"⇿",onClick:()=>i("horizontal")}),o.jsx(He,{title:e>=3?"Even vertical gaps":"Even vertical gaps (needs 3 blocks)",label:"⇕",onClick:()=>i("vertical")})]})]})}function Fl(e,t){if(e.length===0)return;const s=r=>e.reduce((i,c)=>r(c,i)?c:i);switch(t){case"left":return s((r,i)=>r.x<i.x);case"right":return s((r,i)=>r.x+r.width>i.x+i.width);case"top":return s((r,i)=>r.y<i.y);case"bottom":return s((r,i)=>r.y+r.height>i.y+i.height);case"centerX":return s((r,i)=>r.width>i.width);case"centerY":return s((r,i)=>r.height>i.height)}}function Sl(e,t){const s=new Map,r=Fl(e,t);if(!r||e.length<2)return s;for(const i of e){let c;switch(t){case"left":c=r.x;break;case"right":c=r.x+r.width-i.width;break;case"centerX":c=r.x+r.width/2-i.width/2;break;case"top":c=r.y;break;case"bottom":c=r.y+r.height-i.height;break;case"centerY":c=r.y+r.height/2-i.height/2;break}const a=t==="left"||t==="right"||t==="centerX",p=a?i.x:i.y;Math.abs(p-c)<.5||s.set(i.id,a?{x:c}:{y:c})}return s}function Cl(e,t){const s=new Map;if(e.length<2)return s;const r=Math.max(...e.map(c=>c.width)),i=Math.max(...e.map(c=>c.height));for(const c of e){const a={};t!=="height"&&Math.abs(c.width-r)>=.5&&(a.width=r),t!=="width"&&Math.abs(c.height-i)>=.5&&(a.height=i),Object.keys(a).length>0&&s.set(c.id,a)}return s}function jl(e,t){const s=new Map;if(e.length<3)return s;const r=t==="horizontal",i=L=>r?L.x:L.y,c=L=>r?L.width:L.height,a=[...e].sort((L,N)=>i(L)-i(N)),p=a[0],b=a[a.length-1],g=i(b)+c(b)-i(p),j=a.reduce((L,N)=>L+c(N),0),C=(g-j)/(a.length-1);if(!Number.isFinite(C)||C<0)return s;let O=i(p)+c(p)+C;for(const L of a.slice(1,-1))Math.abs(i(L)-O)>=.5&&s.set(L.id,r?{x:O}:{y:O}),O+=c(L)+C;return s}const qt=Ia(e=>({subject:null,publish:t=>e({subject:t})})),Kt=e=>qt.getState().publish(e),Er=e=>{var t,s;return[e.source,e.target,(t=e.data)==null?void 0:t.sourcePortId,(s=e.data)==null?void 0:s.targetPortId].filter(r=>!!r)},El=(e,t)=>e.edgeId===t.id||Er(t).some(s=>e.endpointIds.includes(s)),En=()=>qt(e=>e.subject!==null),Il=e=>qt(t=>{var s;return((s=t.subject)==null?void 0:s.endpointIds.includes(e))??!1}),Ir=(e,t)=>qt(s=>{const r=s.subject;return r?r.edgeId===e||t.some(i=>i!==void 0&&r.endpointIds.includes(i)):!1}),Al=e=>`.react-flow__edge[data-id="${CSS.escape(e)}"]`;function Rl(){const e=qt(r=>r.subject),t=Fr(r=>e?r.edges.filter(i=>El(e,i)).map(i=>i.id).join("\0"):"");if(!e)return null;const s=t?t.split("\0").map(Al).join(","):"";return o.jsxs("style",{children:[".react-flow__edge{opacity:0.22;transition:opacity 120ms ease}",s?`${s}{opacity:1}`:""]})}class zl{constructor(){ln(this,"providers",[]);ln(this,"byId",new Map)}register(t,s){const r=this.byId.get(t.descriptor.id);if(r&&r!==t)throw new Error(`Template provider already registered: ${t.descriptor.id}`);if(r)return;this.byId.set(t.descriptor.id,t);const i=s?this.providers.findIndex(c=>c.descriptor.id===s):-1;i>=0?this.providers.splice(i,0,t):this.providers.push(t)}unregister(t){const s=this.byId.get(t);return s?(this.byId.delete(t),this.providers.splice(this.providers.indexOf(s),1),!0):!1}get(t){return this.byId.get(t)}has(t){return this.byId.has(t)}list(){return this.providers.map(t=>t.descriptor)}select(t){const s=this.providers.find(r=>r.matches(t));if(!s)throw new Error("No diagram template matches this view — register a catch-all provider");return s}}const Ar=new zl,Ml=[{descriptor:{id:"memo.template.fbs",name:"Functional Breakdown",label:"FBS",contractVersion:"1",interactive:!0,description:"Functional breakdown structure — functions per realising component."},matches:e=>e.isFBSDiagram,compute:(e,t)=>La(e,t.fbs)},{descriptor:{id:"memo.template.decomposition",name:"Decomposition Tree",label:"Decomposition",contractVersion:"1",interactive:!0,description:"Expandable decomposition tree over composition relationships."},matches:e=>e.isDecompDiagram&&e.layoutStyle==="decomposition",compute:(e,t)=>Na(e,t.decomposition)},{descriptor:{id:"memo.template.containment",name:"Containment Blocks",label:"Containment",contractVersion:"1",interactive:!0,description:"Nested containment blocks over composition relationships."},matches:e=>e.isDecompDiagram,compute:(e,t)=>Da(e,t.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:e=>e.diagramType==="ucd",compute:(e,t)=>Ba(e,t.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:e=>e.diagramType==="context",compute:(e,t)=>Pa(e,t.context.systemName,t.context)},{descriptor:{id:"memo.template.interconnection",name:"Interconnection",label:"Interconnection",contractVersion:"1",interactive:!1,description:"IBD — parts with boundary ports, typed connectors, nested containment (KK-3)."},matches:e=>e.viewKind==="interconnection",compute:(e,t)=>$a(e,t.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:e=>e.viewKind==="actionflow",compute:(e,t)=>Oa(e,t.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:e=>e.viewKind==="statetransition",compute:(e,t)=>Wa(e,t.statetransition)},{descriptor:{id:"memo.template.sequence",name:"Sequence",label:"Sequence",contractVersion:"1",interactive:!1,description:"Lifelines with chronological messages (KK-6)."},matches:e=>e.viewKind==="sequence",compute:(e,t)=>_a(e,t.sequence)},{descriptor:{id:"memo.template.general",name:"General (structured)",label:"General",contractVersion:"1",interactive:!0,description:"General template tree/containment modes (KK-2)."},matches:e=>e.isGeneralTemplate&&e.generalMode!=="graph",compute:(e,t)=>Ha(e,t.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:(e,t)=>Va(e,t.standard)}];for(const e of Ml)Ar.register(e);const Rr="context-child-v1";function Tl(e){var t;return((t=e==null?void 0:e.canvas)==null?void 0:t.coordinateSpace)===Rr}function Ll(e){return{...e,canvas:{...e.canvas,coordinateSpace:Rr}}}function Nl(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Dl(e,t,s){const r={x:e.x,y:e.y};if(e.parent===void 0)return r;const i=e.parent??null;if(i===t)return r;let c=r;if(i){const p=s(i);p&&(c={x:r.x+p.x,y:r.y+p.y})}if(!t)return c;const a=s(t);return a?{x:c.x-a.x,y:c.y-a.y}:c}function Zt({color:e="#334155",size:t=38}){const s=Math.round(t*1.42);return o.jsxs("svg",{width:t,height:s,viewBox:"0 0 38 54","aria-hidden":"true",fill:"none",stroke:e,strokeWidth:"2",children:[o.jsx("circle",{cx:"19",cy:"8",r:"6",fill:"#FFFFFF"}),o.jsx("path",{d:"M19 14v18M6 23h26M19 32L8 49M19 32l11 17",strokeLinecap:"round"})]})}const In=e=>e==="Actor"||e==="User";function Bl({data:e}){const t=e,{element:s,layerColor:r,isExpanded:i,hasChildren:c,childCount:a,direction:p,onToggleExpand:b,onToggleDirection:g,showDirectionButton:j,depthBgColor:C,isContainer:O}=t,L=p==="vertical"?"V":"H",N=O&&i;return o.jsxs("div",{style:{background:N?C||"#FAFAF9":"#FFFFFF",borderLeft:N?`2px solid ${r}40`:`3px solid ${r}`,borderTop:`1px solid ${N?r+"30":"#E5E5E0"}`,borderRight:`1px solid ${N?r+"30":"#E5E5E0"}`,borderBottom:`1px solid ${N?r+"30":"#E5E5E0"}`,borderRadius:3,padding:N?"0":"8px 12px",minWidth:N?void 0:"200px",boxShadow:"none",width:"100%",height:"100%",boxSizing:"border-box"},children:[o.jsx(ne,{type:"target",position:K.Top,id:"top",style:jo}),o.jsx(ne,{type:"source",position:K.Bottom,id:"bottom",style:jo}),o.jsx(ne,{type:"target",position:K.Left,id:"left",style:jo}),o.jsx(ne,{type:"source",position:K.Right,id:"right",style:jo}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:N?"8px 12px":"0"},children:[In(s.kind)&&o.jsx(Zt,{size:24,color:r}),c&&o.jsx("button",{onClick:D=>{D.stopPropagation(),b()},style:{width:"20px",height:"20px",borderRadius:2,border:`1px solid ${r}`,background:i?r+"12":"#FFFFFF",color:r,fontSize:Y.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:i?"Collapse":"Expand",children:i?"−":"+"}),c&&j&&o.jsx("button",{onClick:D=>{D.stopPropagation(),g()},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: ${p}. Click to toggle`,children:L}),o.jsx("span",{style:{fontSize:Y.md,fontWeight:600,color:N?r:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.name})]}),!N&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"3px",paddingLeft:c?"26px":"14px"},children:[o.jsx("span",{style:{fontSize:Y.badge,color:"#9CA3AF"},children:s.kind}),c&&o.jsxs("span",{style:{fontSize:"9px",color:"#6B7280",background:"#F0F0ED",padding:"1px 5px",borderRadius:2,fontWeight:600},children:[a," parts",i?"":" (collapsed)"]})]})]})}const jo={width:"8px",height:"8px",background:"#2DD4A8",border:"1.5px solid #FFFFFF",opacity:0},Pl=u.memo(Bl);function zr(e){var t,s,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(s=zr(e[t]))&&(r&&(r+=" "),r+=s)}else for(s in e)e[s]&&(r&&(r+=" "),r+=s);return r}function $l(){for(var e,t,s=0,r="",i=arguments.length;s<i;s++)(e=arguments[s])&&(t=zr(e))&&(r&&(r+=" "),r+=t);return r}const Ol=(e,t)=>{const s=new Array(e.length+t.length);for(let r=0;r<e.length;r++)s[r]=e[r];for(let r=0;r<t.length;r++)s[e.length+r]=t[r];return s},Wl=(e,t)=>({classGroupId:e,validator:t}),Mr=(e=new Map,t=null,s)=>({nextPart:e,validators:t,classGroupId:s}),Po="-",qs=[],_l="arbitrary..",Hl=e=>{const t=Gl(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:a=>{if(a.startsWith("[")&&a.endsWith("]"))return Vl(a);const p=a.split(Po),b=p[0]===""&&p.length>1?1:0;return Tr(p,b,t)},getConflictingClassGroupIds:(a,p)=>{if(p){const b=r[a],g=s[a];return b?g?Ol(g,b):b:g||qs}return s[a]||qs}}},Tr=(e,t,s)=>{if(e.length-t===0)return s.classGroupId;const i=e[t],c=s.nextPart.get(i);if(c){const g=Tr(e,t+1,c);if(g)return g}const a=s.validators;if(a===null)return;const p=t===0?e.join(Po):e.slice(t).join(Po),b=a.length;for(let g=0;g<b;g++){const j=a[g];if(j.validator(p))return j.classGroupId}},Vl=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),s=t.indexOf(":"),r=t.slice(0,s);return r?_l+r:void 0})(),Gl=e=>{const{theme:t,classGroups:s}=e;return Ul(s,t)},Ul=(e,t)=>{const s=Mr();for(const r in e){const i=e[r];An(i,s,r,t)}return s},An=(e,t,s,r)=>{const i=e.length;for(let c=0;c<i;c++){const a=e[c];Xl(a,t,s,r)}},Xl=(e,t,s,r)=>{if(typeof e=="string"){Yl(e,t,s);return}if(typeof e=="function"){Kl(e,t,s,r);return}ql(e,t,s,r)},Yl=(e,t,s)=>{const r=e===""?t:Lr(t,e);r.classGroupId=s},Kl=(e,t,s,r)=>{if(Zl(e)){An(e(r),t,s,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Wl(s,e))},ql=(e,t,s,r)=>{const i=Object.entries(e),c=i.length;for(let a=0;a<c;a++){const[p,b]=i[a];An(b,Lr(t,p),s,r)}},Lr=(e,t)=>{let s=e;const r=t.split(Po),i=r.length;for(let c=0;c<i;c++){const a=r[c];let p=s.nextPart.get(a);p||(p=Mr(),s.nextPart.set(a,p)),s=p}return s},Zl=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Jl=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,s=Object.create(null),r=Object.create(null);const i=(c,a)=>{s[c]=a,t++,t>e&&(t=0,r=s,s=Object.create(null))};return{get(c){let a=s[c];if(a!==void 0)return a;if((a=r[c])!==void 0)return i(c,a),a},set(c,a){c in s?s[c]=a:i(c,a)}}},kn="!",Zs=":",Ql=[],Js=(e,t,s,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:s,maybePostfixModifierPosition:r,isExternal:i}),ec=e=>{const{prefix:t,experimentalParseClassName:s}=e;let r=i=>{const c=[];let a=0,p=0,b=0,g;const j=i.length;for(let D=0;D<j;D++){const m=i[D];if(a===0&&p===0){if(m===Zs){c.push(i.slice(b,D)),b=D+1;continue}if(m==="/"){g=D;continue}}m==="["?a++:m==="]"?a--:m==="("?p++:m===")"&&p--}const C=c.length===0?i:i.slice(b);let O=C,L=!1;C.endsWith(kn)?(O=C.slice(0,-1),L=!0):C.startsWith(kn)&&(O=C.slice(1),L=!0);const N=g&&g>b?g-b:void 0;return Js(c,L,O,N)};if(t){const i=t+Zs,c=r;r=a=>a.startsWith(i)?c(a.slice(i.length)):Js(Ql,!1,a,void 0,!0)}if(s){const i=r;r=c=>s({className:c,parseClassName:i})}return r},tc=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((s,r)=>{t.set(s,1e6+r)}),s=>{const r=[];let i=[];for(let c=0;c<s.length;c++){const a=s[c],p=a[0]==="[",b=t.has(a);p||b?(i.length>0&&(i.sort(),r.push(...i),i=[]),r.push(a)):i.push(a)}return i.length>0&&(i.sort(),r.push(...i)),r}},oc=e=>({cache:Jl(e.cacheSize),parseClassName:ec(e),sortModifiers:tc(e),postfixLookupClassGroupIds:nc(e),...Hl(e)}),nc=e=>{const t=Object.create(null),s=e.postfixLookupClassGroups;if(s)for(let r=0;r<s.length;r++)t[s[r]]=!0;return t},sc=/\s+/,rc=(e,t)=>{const{parseClassName:s,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:c,postfixLookupClassGroupIds:a}=t,p=[],b=e.trim().split(sc);let g="";for(let j=b.length-1;j>=0;j-=1){const C=b[j],{isExternal:O,modifiers:L,hasImportantModifier:N,baseClassName:D,maybePostfixModifierPosition:m}=s(C);if(O){g=C+(g.length>0?" "+g:g);continue}let k=!!m,w;if(k){const q=D.substring(0,m);w=r(q);const v=w&&a[w]?r(D):void 0;v&&v!==w&&(w=v,k=!1)}else w=r(D);if(!w){if(!k){g=C+(g.length>0?" "+g:g);continue}if(w=r(D),!w){g=C+(g.length>0?" "+g:g);continue}k=!1}const W=L.length===0?"":L.length===1?L[0]:c(L).join(":"),A=N?W+kn:W,_=A+w;if(p.indexOf(_)>-1)continue;p.push(_);const M=i(w,k);for(let q=0;q<M.length;++q){const v=M[q];p.push(A+v)}g=C+(g.length>0?" "+g:g)}return g},ic=(...e)=>{let t=0,s,r,i="";for(;t<e.length;)(s=e[t++])&&(r=Nr(s))&&(i&&(i+=" "),i+=r);return i},Nr=e=>{if(typeof e=="string")return e;let t,s="";for(let r=0;r<e.length;r++)e[r]&&(t=Nr(e[r]))&&(s&&(s+=" "),s+=t);return s},ac=(e,...t)=>{let s,r,i,c;const a=b=>{const g=t.reduce((j,C)=>C(j),e());return s=oc(g),r=s.cache.get,i=s.cache.set,c=p,p(b)},p=b=>{const g=r(b);if(g)return g;const j=rc(b,s);return i(b,j),j};return c=a,(...b)=>c(ic(...b))},lc=[],Ce=e=>{const t=s=>s[e]||lc;return t.isThemeGetter=!0,t},Dr=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Br=/^\((?:(\w[\w-]*):)?(.+)\)$/i,cc=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,dc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,uc=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,pc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,hc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,mc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,st=e=>cc.test(e),oe=e=>!!e&&!Number.isNaN(Number(e)),Ge=e=>!!e&&Number.isInteger(Number(e)),hn=e=>e.endsWith("%")&&oe(e.slice(0,-1)),Ke=e=>dc.test(e),Pr=()=>!0,fc=e=>uc.test(e)&&!pc.test(e),Rn=()=>!1,gc=e=>hc.test(e),xc=e=>mc.test(e),bc=e=>!R(e)&&!z(e),yc=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),wc=e=>at(e,Wr,Rn),R=e=>Dr.test(e),ft=e=>at(e,_r,fc),Qs=e=>at(e,Ic,oe),vc=e=>at(e,Vr,Pr),kc=e=>at(e,Hr,Rn),er=e=>at(e,$r,Rn),Fc=e=>at(e,Or,xc),Eo=e=>at(e,Gr,gc),z=e=>Br.test(e),Yt=e=>bt(e,_r),Sc=e=>bt(e,Hr),tr=e=>bt(e,$r),Cc=e=>bt(e,Wr),jc=e=>bt(e,Or),Io=e=>bt(e,Gr,!0),Ec=e=>bt(e,Vr,!0),at=(e,t,s)=>{const r=Dr.exec(e);return r?r[1]?t(r[1]):s(r[2]):!1},bt=(e,t,s=!1)=>{const r=Br.exec(e);return r?r[1]?t(r[1]):s:!1},$r=e=>e==="position"||e==="percentage",Or=e=>e==="image"||e==="url",Wr=e=>e==="length"||e==="size"||e==="bg-size",_r=e=>e==="length",Ic=e=>e==="number",Hr=e=>e==="family-name",Vr=e=>e==="number"||e==="weight",Gr=e=>e==="shadow",Ac=()=>{const e=Ce("color"),t=Ce("font"),s=Ce("text"),r=Ce("font-weight"),i=Ce("tracking"),c=Ce("leading"),a=Ce("breakpoint"),p=Ce("container"),b=Ce("spacing"),g=Ce("radius"),j=Ce("shadow"),C=Ce("inset-shadow"),O=Ce("text-shadow"),L=Ce("drop-shadow"),N=Ce("blur"),D=Ce("perspective"),m=Ce("aspect"),k=Ce("ease"),w=Ce("animate"),W=()=>["auto","avoid","all","avoid-page","page","left","right","column"],A=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],_=()=>[...A(),z,R],M=()=>["auto","hidden","clip","visible","scroll"],q=()=>["auto","contain","none"],v=()=>[z,R,b],T=()=>[st,"full","auto",...v()],xe=()=>[Ge,"none","subgrid",z,R],H=()=>["auto",{span:["full",Ge,z,R]},Ge,z,R],me=()=>[Ge,"auto",z,R],ie=()=>["auto","min","max","fr",z,R],ue=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],be=()=>["start","end","center","stretch","center-safe","end-safe"],P=()=>["auto",...v()],$=()=>[st,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...v()],le=()=>[st,"screen","full","dvw","lvw","svw","min","max","fit",...v()],ye=()=>[st,"screen","full","lh","dvh","lvh","svh","min","max","fit",...v()],E=()=>[e,z,R],te=()=>[...A(),tr,er,{position:[z,R]}],we=()=>["no-repeat",{repeat:["","x","y","space","round"]}],fe=()=>["auto","cover","contain",Cc,wc,{size:[z,R]}],J=()=>[hn,Yt,ft],re=()=>["","none","full",g,z,R],ae=()=>["",oe,Yt,ft],ve=()=>["solid","dashed","dotted","double"],Ie=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],he=()=>[oe,hn,tr,er],De=()=>["","none",N,z,R],qe=()=>["none",oe,z,R],lt=()=>["none",oe,z,R],je=()=>[oe,z,R],ct=()=>[st,"full",...v()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Ke],breakpoint:[Ke],color:[Pr],container:[Ke],"drop-shadow":[Ke],ease:["in","out","in-out"],font:[bc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Ke],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Ke],shadow:[Ke],spacing:["px",oe],text:[Ke],"text-shadow":[Ke],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",st,R,z,m]}],container:["container"],"container-type":[{"@container":["","normal","size",z,R]}],"container-named":[yc],columns:[{columns:[oe,R,z,p]}],"break-after":[{"break-after":W()}],"break-before":[{"break-before":W()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:_()}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:q()}],"overscroll-x":[{"overscroll-x":q()}],"overscroll-y":[{"overscroll-y":q()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:["visible","invisible","collapse"],z:[{z:[Ge,"auto",z,R]}],basis:[{basis:[st,"full","auto",p,...v()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[oe,st,"auto","initial","none",R]}],grow:[{grow:["",oe,z,R]}],shrink:[{shrink:["",oe,z,R]}],order:[{order:[Ge,"first","last","none",z,R]}],"grid-cols":[{"grid-cols":xe()}],"col-start-end":[{col:H()}],"col-start":[{"col-start":me()}],"col-end":[{"col-end":me()}],"grid-rows":[{"grid-rows":xe()}],"row-start-end":[{row:H()}],"row-start":[{"row-start":me()}],"row-end":[{"row-end":me()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ie()}],"auto-rows":[{"auto-rows":ie()}],gap:[{gap:v()}],"gap-x":[{"gap-x":v()}],"gap-y":[{"gap-y":v()}],"justify-content":[{justify:[...ue(),"normal"]}],"justify-items":[{"justify-items":[...be(),"normal"]}],"justify-self":[{"justify-self":["auto",...be()]}],"align-content":[{content:["normal",...ue()]}],"align-items":[{items:[...be(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...be(),{baseline:["","last"]}]}],"place-content":[{"place-content":ue()}],"place-items":[{"place-items":[...be(),"baseline"]}],"place-self":[{"place-self":["auto",...be()]}],p:[{p:v()}],px:[{px:v()}],py:[{py:v()}],ps:[{ps:v()}],pe:[{pe:v()}],pbs:[{pbs:v()}],pbe:[{pbe:v()}],pt:[{pt:v()}],pr:[{pr:v()}],pb:[{pb:v()}],pl:[{pl:v()}],m:[{m:P()}],mx:[{mx:P()}],my:[{my:P()}],ms:[{ms:P()}],me:[{me:P()}],mbs:[{mbs:P()}],mbe:[{mbe:P()}],mt:[{mt:P()}],mr:[{mr:P()}],mb:[{mb:P()}],ml:[{ml:P()}],"space-x":[{"space-x":v()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":v()}],"space-y-reverse":["space-y-reverse"],size:[{size:$()}],"inline-size":[{inline:["auto",...le()]}],"min-inline-size":[{"min-inline":["auto",...le()]}],"max-inline-size":[{"max-inline":["none",...le()]}],"block-size":[{block:["auto",...ye()]}],"min-block-size":[{"min-block":["auto",...ye()]}],"max-block-size":[{"max-block":["none",...ye()]}],w:[{w:[p,"screen",...$()]}],"min-w":[{"min-w":[p,"screen","none",...$()]}],"max-w":[{"max-w":[p,"screen","none","prose",{screen:[a]},...$()]}],h:[{h:["screen","lh",...$()]}],"min-h":[{"min-h":["screen","lh","none",...$()]}],"max-h":[{"max-h":["screen","lh",...$()]}],"font-size":[{text:["base",s,Yt,ft]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Ec,vc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",hn,R]}],"font-family":[{font:[Sc,kc,t]}],"font-features":[{"font-features":[R]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,z,R]}],"line-clamp":[{"line-clamp":[oe,"none",z,Qs]}],leading:[{leading:[c,...v()]}],"list-image":[{"list-image":["none",z,R]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",z,R]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:E()}],"text-color":[{text:E()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ve(),"wavy"]}],"text-decoration-thickness":[{decoration:[oe,"from-font","auto",z,ft]}],"text-decoration-color":[{decoration:E()}],"underline-offset":[{"underline-offset":[oe,"auto",z,R]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:v()}],"tab-size":[{tab:[Ge,z,R]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",z,R]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",z,R]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:te()}],"bg-repeat":[{bg:we()}],"bg-size":[{bg:fe()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ge,z,R],radial:["",z,R],conic:[Ge,z,R]},jc,Fc]}],"bg-color":[{bg:E()}],"gradient-from-pos":[{from:J()}],"gradient-via-pos":[{via:J()}],"gradient-to-pos":[{to:J()}],"gradient-from":[{from:E()}],"gradient-via":[{via:E()}],"gradient-to":[{to:E()}],rounded:[{rounded:re()}],"rounded-s":[{"rounded-s":re()}],"rounded-e":[{"rounded-e":re()}],"rounded-t":[{"rounded-t":re()}],"rounded-r":[{"rounded-r":re()}],"rounded-b":[{"rounded-b":re()}],"rounded-l":[{"rounded-l":re()}],"rounded-ss":[{"rounded-ss":re()}],"rounded-se":[{"rounded-se":re()}],"rounded-ee":[{"rounded-ee":re()}],"rounded-es":[{"rounded-es":re()}],"rounded-tl":[{"rounded-tl":re()}],"rounded-tr":[{"rounded-tr":re()}],"rounded-br":[{"rounded-br":re()}],"rounded-bl":[{"rounded-bl":re()}],"border-w":[{border:ae()}],"border-w-x":[{"border-x":ae()}],"border-w-y":[{"border-y":ae()}],"border-w-s":[{"border-s":ae()}],"border-w-e":[{"border-e":ae()}],"border-w-bs":[{"border-bs":ae()}],"border-w-be":[{"border-be":ae()}],"border-w-t":[{"border-t":ae()}],"border-w-r":[{"border-r":ae()}],"border-w-b":[{"border-b":ae()}],"border-w-l":[{"border-l":ae()}],"divide-x":[{"divide-x":ae()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ae()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ve(),"hidden","none"]}],"divide-style":[{divide:[...ve(),"hidden","none"]}],"border-color":[{border:E()}],"border-color-x":[{"border-x":E()}],"border-color-y":[{"border-y":E()}],"border-color-s":[{"border-s":E()}],"border-color-e":[{"border-e":E()}],"border-color-bs":[{"border-bs":E()}],"border-color-be":[{"border-be":E()}],"border-color-t":[{"border-t":E()}],"border-color-r":[{"border-r":E()}],"border-color-b":[{"border-b":E()}],"border-color-l":[{"border-l":E()}],"divide-color":[{divide:E()}],"outline-style":[{outline:[...ve(),"none","hidden"]}],"outline-offset":[{"outline-offset":[oe,z,R]}],"outline-w":[{outline:["",oe,Yt,ft]}],"outline-color":[{outline:E()}],shadow:[{shadow:["","none",j,Io,Eo]}],"shadow-color":[{shadow:E()}],"inset-shadow":[{"inset-shadow":["none",C,Io,Eo]}],"inset-shadow-color":[{"inset-shadow":E()}],"ring-w":[{ring:ae()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:E()}],"ring-offset-w":[{"ring-offset":[oe,ft]}],"ring-offset-color":[{"ring-offset":E()}],"inset-ring-w":[{"inset-ring":ae()}],"inset-ring-color":[{"inset-ring":E()}],"text-shadow":[{"text-shadow":["none",O,Io,Eo]}],"text-shadow-color":[{"text-shadow":E()}],opacity:[{opacity:[oe,z,R]}],"mix-blend":[{"mix-blend":[...Ie(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Ie()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[oe]}],"mask-image-linear-from-pos":[{"mask-linear-from":he()}],"mask-image-linear-to-pos":[{"mask-linear-to":he()}],"mask-image-linear-from-color":[{"mask-linear-from":E()}],"mask-image-linear-to-color":[{"mask-linear-to":E()}],"mask-image-t-from-pos":[{"mask-t-from":he()}],"mask-image-t-to-pos":[{"mask-t-to":he()}],"mask-image-t-from-color":[{"mask-t-from":E()}],"mask-image-t-to-color":[{"mask-t-to":E()}],"mask-image-r-from-pos":[{"mask-r-from":he()}],"mask-image-r-to-pos":[{"mask-r-to":he()}],"mask-image-r-from-color":[{"mask-r-from":E()}],"mask-image-r-to-color":[{"mask-r-to":E()}],"mask-image-b-from-pos":[{"mask-b-from":he()}],"mask-image-b-to-pos":[{"mask-b-to":he()}],"mask-image-b-from-color":[{"mask-b-from":E()}],"mask-image-b-to-color":[{"mask-b-to":E()}],"mask-image-l-from-pos":[{"mask-l-from":he()}],"mask-image-l-to-pos":[{"mask-l-to":he()}],"mask-image-l-from-color":[{"mask-l-from":E()}],"mask-image-l-to-color":[{"mask-l-to":E()}],"mask-image-x-from-pos":[{"mask-x-from":he()}],"mask-image-x-to-pos":[{"mask-x-to":he()}],"mask-image-x-from-color":[{"mask-x-from":E()}],"mask-image-x-to-color":[{"mask-x-to":E()}],"mask-image-y-from-pos":[{"mask-y-from":he()}],"mask-image-y-to-pos":[{"mask-y-to":he()}],"mask-image-y-from-color":[{"mask-y-from":E()}],"mask-image-y-to-color":[{"mask-y-to":E()}],"mask-image-radial":[{"mask-radial":[z,R]}],"mask-image-radial-from-pos":[{"mask-radial-from":he()}],"mask-image-radial-to-pos":[{"mask-radial-to":he()}],"mask-image-radial-from-color":[{"mask-radial-from":E()}],"mask-image-radial-to-color":[{"mask-radial-to":E()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":A()}],"mask-image-conic-pos":[{"mask-conic":[oe]}],"mask-image-conic-from-pos":[{"mask-conic-from":he()}],"mask-image-conic-to-pos":[{"mask-conic-to":he()}],"mask-image-conic-from-color":[{"mask-conic-from":E()}],"mask-image-conic-to-color":[{"mask-conic-to":E()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:te()}],"mask-repeat":[{mask:we()}],"mask-size":[{mask:fe()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",z,R]}],filter:[{filter:["","none",z,R]}],blur:[{blur:De()}],brightness:[{brightness:[oe,z,R]}],contrast:[{contrast:[oe,z,R]}],"drop-shadow":[{"drop-shadow":["","none",L,Io,Eo]}],"drop-shadow-color":[{"drop-shadow":E()}],grayscale:[{grayscale:["",oe,z,R]}],"hue-rotate":[{"hue-rotate":[oe,z,R]}],invert:[{invert:["",oe,z,R]}],saturate:[{saturate:[oe,z,R]}],sepia:[{sepia:["",oe,z,R]}],"backdrop-filter":[{"backdrop-filter":["","none",z,R]}],"backdrop-blur":[{"backdrop-blur":De()}],"backdrop-brightness":[{"backdrop-brightness":[oe,z,R]}],"backdrop-contrast":[{"backdrop-contrast":[oe,z,R]}],"backdrop-grayscale":[{"backdrop-grayscale":["",oe,z,R]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[oe,z,R]}],"backdrop-invert":[{"backdrop-invert":["",oe,z,R]}],"backdrop-opacity":[{"backdrop-opacity":[oe,z,R]}],"backdrop-saturate":[{"backdrop-saturate":[oe,z,R]}],"backdrop-sepia":[{"backdrop-sepia":["",oe,z,R]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":v()}],"border-spacing-x":[{"border-spacing-x":v()}],"border-spacing-y":[{"border-spacing-y":v()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",z,R]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[oe,"initial",z,R]}],ease:[{ease:["linear","initial",k,z,R]}],delay:[{delay:[oe,z,R]}],animate:[{animate:["none",w,z,R]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[D,z,R]}],"perspective-origin":[{"perspective-origin":_()}],rotate:[{rotate:qe()}],"rotate-x":[{"rotate-x":qe()}],"rotate-y":[{"rotate-y":qe()}],"rotate-z":[{"rotate-z":qe()}],scale:[{scale:lt()}],"scale-x":[{"scale-x":lt()}],"scale-y":[{"scale-y":lt()}],"scale-z":[{"scale-z":lt()}],"scale-3d":["scale-3d"],skew:[{skew:je()}],"skew-x":[{"skew-x":je()}],"skew-y":[{"skew-y":je()}],transform:[{transform:[z,R,"","none","gpu","cpu"]}],"transform-origin":[{origin:_()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ct()}],"translate-x":[{"translate-x":ct()}],"translate-y":[{"translate-y":ct()}],"translate-z":[{"translate-z":ct()}],"translate-none":["translate-none"],zoom:[{zoom:[Ge,z,R]}],accent:[{accent:E()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:E()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",z,R]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":E()}],"scrollbar-track-color":[{"scrollbar-track":E()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":v()}],"scroll-mx":[{"scroll-mx":v()}],"scroll-my":[{"scroll-my":v()}],"scroll-ms":[{"scroll-ms":v()}],"scroll-me":[{"scroll-me":v()}],"scroll-mbs":[{"scroll-mbs":v()}],"scroll-mbe":[{"scroll-mbe":v()}],"scroll-mt":[{"scroll-mt":v()}],"scroll-mr":[{"scroll-mr":v()}],"scroll-mb":[{"scroll-mb":v()}],"scroll-ml":[{"scroll-ml":v()}],"scroll-p":[{"scroll-p":v()}],"scroll-px":[{"scroll-px":v()}],"scroll-py":[{"scroll-py":v()}],"scroll-ps":[{"scroll-ps":v()}],"scroll-pe":[{"scroll-pe":v()}],"scroll-pbs":[{"scroll-pbs":v()}],"scroll-pbe":[{"scroll-pbe":v()}],"scroll-pt":[{"scroll-pt":v()}],"scroll-pr":[{"scroll-pr":v()}],"scroll-pb":[{"scroll-pb":v()}],"scroll-pl":[{"scroll-pl":v()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",z,R]}],fill:[{fill:["none",...E()]}],"stroke-w":[{stroke:[oe,Yt,ft,Qs]}],stroke:[{stroke:["none",...E()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Rc=ac(Ac);function zc(...e){return Rc($l(e))}function or({className:e,children:t,...s}){return o.jsx(ne,{...s,className:zc("dark:border-secondary dark:bg-secondary h-[11px] w-[11px] rounded-full border border-slate-300 bg-slate-100 transition",e),children:t})}const nr={top:K.Top,bottom:K.Bottom,left:K.Left,right:K.Right},Mc={top:"bottom",bottom:"top",left:"right",right:"left"},Tc="#6B7280",Ur=e=>e?No[e]:Tc;function Xr(e,t){if(e==="inout")return"⇄";if(!e)return"";const s=e==="in";switch(t){case"left":return s?"→":"←";case"right":return s?"←":"→";case"top":return s?"↓":"↑";default:return s?"↑":"↓"}}const sr=40,Yr=e=>({opacity:0,width:e,height:e,top:"50%",left:"50%",transform:"translate(-50%, -50%)",border:"none",background:"transparent",pointerEvents:"none"}),Lc=e=>({...Yr(e),pointerEvents:"auto",cursor:"pointer",zIndex:12}),Ao=7;function Nc({port:e}){const t=e.size??gt,s=e.side==="left"||e.side==="right",r=s?e.y:e.x,c=r+t/2+jr*(e.nestedCount??0)+t/2-r+Ao*2,a=t+Ao*2;return o.jsx("div",{"aria-hidden":!0,style:{position:"absolute",left:e.x-Ao,top:e.y-Ao,width:s?a:c,height:s?c:a,background:"rgba(148,163,184,0.30)",border:"1px solid rgba(100,116,139,0.45)",borderRadius:9,pointerEvents:"none",zIndex:0}})}function Dc({port:e,onMove:t,onResize:s,onSelect:r,showText:i=!0}){const{getZoom:c}=jn(),a=Fr(M=>M.transform[2]),p=Il(e.id),b=ee(M=>M.selectedElementId===e.id),g=u.useRef(!1),j=En()&&!p,C=e.size??gt,O=C+Ya,L=Ur(e.direction),N=t?M=>{M.preventDefault(),M.stopPropagation();const q=M.clientY,v=e.y;let T;const xe=me=>{T=me,!(Math.hypot(me.clientX-M.clientX,me.clientY-M.clientY)<=2)&&(g.current=!0,t(v+(me.clientY-q)/c()))},H=()=>{if(T){const me=T.clientX-M.clientX,ie=T.clientY-M.clientY;if(Math.hypot(me,ie)>18){const ue=Math.abs(me)>Math.abs(ie)?me<0?"left":"right":ie<0?"top":"bottom";t(v+ie/c(),ue)}}window.removeEventListener("pointermove",xe),window.removeEventListener("pointerup",H),window.setTimeout(()=>{g.current=!1},0)};window.addEventListener("pointermove",xe),window.addEventListener("pointerup",H,{once:!0})}:void 0,D=M=>{M.stopPropagation(),!g.current&&(r==null||r(e.id))},m=M=>{const q=M.clientX,v=M.clientY;g.current=!1;const T=H=>{Math.hypot(H.clientX-q,H.clientY-v)>2&&(g.current=!0)},xe=()=>{window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",xe),window.setTimeout(()=>{g.current=!1},0)};window.addEventListener("pointermove",T),window.addEventListener("pointerup",xe,{once:!0})},k=M=>q=>{if(!s)return;q.preventDefault(),q.stopPropagation();const v=q.clientX,T=q.clientY,xe=C;g.current=!0;const H=ie=>{const ue=(ie.clientX-v)/c(),be=(ie.clientY-T)/c(),P=M.includes("e")?ue:M.includes("w")?-ue:void 0,$=M.includes("s")?be:M.includes("n")?-be:void 0,le=P!==void 0&&$!==void 0?(P+$)/2:P??$??0;s(Math.min(48,Math.max(10,xe+le)),M)},me=()=>{window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",me),window.setTimeout(()=>{g.current=!1},0)};window.addEventListener("pointermove",H),window.addEventListener("pointerup",me,{once:!0})},w=e.side==="left"||e.side==="right",W={position:"absolute",fontSize:e.nested?"9.5px":"10.5px",fontWeight:p||b?750:e.nested?600:650,color:p||b?"#0F172A":e.nested?"#6B7280":"#374151",opacity:j?.45:1,transition:"color 120ms ease, opacity 120ms ease",whiteSpace:"normal",pointerEvents:t?"auto":"none",cursor:r?"pointer":"default",touchAction:"none",overflow:"hidden",display:"flex",flexDirection:"column",width:w?e.labelWidth??Ga:Ua,background:"rgba(255,255,255,0.94)",padding:"1px 3px",borderRadius:4,lineHeight:1.12,...e.side==="left"?{left:O,bottom:"50%",marginBottom:2}:e.side==="right"?{right:O,bottom:"50%",marginBottom:2,textAlign:"right"}:{bottom:O,left:"50%",transform:"translateX(-50%)",textAlign:"center"}},A={overflow:"hidden",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:e.connectorType?1:2},_={fontSize:e.nested?"8.5px":"9px",fontWeight:500,color:p?"#475569":"#94A3B8",letterSpacing:"0.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"};return o.jsxs("div",{className:"nodrag nopan",style:{position:"absolute",left:e.x,top:e.y,width:C,height:C,zIndex:e.nested?11:10},children:[o.jsx("div",{onPointerEnter:()=>Kt({endpointIds:[e.id]}),onPointerLeave:()=>Kt(null),onPointerDown:N,onClick:D,title:`${e.name}${e.direction?` (${e.direction})`:""}${e.connectorType?`
3
+ ${e.connectorType}`:""}`,style:{position:"absolute",left:"50%",top:"50%",width:sr,height:sr,transform:`translate(-50%, -50%) scale(${1/Math.max(a,.1)})`,cursor:r?"pointer":"default",touchAction:"none"}}),o.jsxs("div",{style:{position:"absolute",inset:0,boxSizing:"border-box",background:"#FFFFFF",border:`2px solid ${L}`,borderRadius:5,boxShadow:b?"0 0 0 3px #2563EB, 0 2px 8px rgba(15,23,42,0.24)":p?`0 0 0 4px ${L}33, 0 2px 8px rgba(15,23,42,0.24)`:"0 1px 3px rgba(15,23,42,0.18)",opacity:j?.5:1,display:"flex",alignItems:"center",justifyContent:"center",color:L,fontSize:e.nested?"10px":"12px",fontWeight:800,lineHeight:1,pointerEvents:"none",transition:"box-shadow 120ms ease, opacity 120ms ease"},children:[Xr(e.direction,e.side),i&&o.jsxs("span",{onPointerDown:N,onClick:D,style:W,children:[o.jsx("span",{style:A,children:e.name.replace(/([a-z0-9])([A-Z])/g,"$1​$2")}),e.connectorType&&o.jsx("span",{style:_,children:e.connectorType})]}),[{suffix:"",pos:nr[e.side],connectable:!0},{suffix:Xa,pos:nr[Mc[e.side]],connectable:!1}].flatMap(M=>{const q=M.connectable?"ibd-port-connect":"ibd-port-anchor",v=M.connectable?Lc(C):Yr(C);return[o.jsx(or,{className:q,type:"source",id:`${e.id}${M.suffix}`,position:M.pos,style:v,isConnectable:M.connectable,onPointerDownCapture:M.connectable?m:void 0,onClick:M.connectable?D:void 0},`s${M.suffix}`),o.jsx(or,{className:q,type:"target",id:`${e.id}${M.suffix}`,position:M.pos,style:v,isConnectable:M.connectable,onPointerDownCapture:M.connectable?m:void 0,onClick:M.connectable?D:void 0},`t${M.suffix}`)]})]}),s&&[["n",{top:-5,left:5,right:5,height:10,cursor:"ns-resize"}],["e",{top:5,right:-5,bottom:5,width:10,cursor:"ew-resize"}],["s",{bottom:-5,left:5,right:5,height:10,cursor:"ns-resize"}],["w",{top:5,left:-5,bottom:5,width:10,cursor:"ew-resize"}],["nw",{top:-5,left:-5,width:10,height:10,cursor:"nwse-resize"}],["ne",{top:-5,right:-5,width:10,height:10,cursor:"nesw-resize"}],["se",{bottom:-5,right:-5,width:10,height:10,cursor:"nwse-resize"}],["sw",{bottom:-5,left:-5,width:10,height:10,cursor:"nesw-resize"}]].map(([M,q])=>o.jsx("div",{className:`ibd-port-resize-handle ibd-port-resize-handle--${M}`,onPointerDown:k(M),style:{position:"absolute",zIndex:20,touchAction:"none",...q}},M))]})}function rr({side:e,direction:t}){const s=Ur(t),r=gt;return o.jsx("div",{"aria-label":`implicit ${t} port`,title:`Implicit ${t} port — relationship targets the part directly`,style:{position:"absolute",top:"50%",left:e==="left"?-r/2:void 0,right:e==="right"?-r/2:void 0,transform:"translateY(-50%)",width:r,height:r,boxSizing:"border-box",background:"#FFFFFF",border:`2px solid ${s}`,borderRadius:4,boxShadow:"0 1px 3px rgba(15,23,42,0.18)",display:"flex",alignItems:"center",justifyContent:"center",color:s,fontSize:11,fontWeight:800,lineHeight:1,zIndex:4,pointerEvents:"none"},children:Xr(t,e)})}function ir({name:e,kind:t,nameColor:s,typeColor:r,frame:i=!1,style:c}){const a=(c==null?void 0:c.textAlign)??"left";return o.jsxs("span",{title:`${e} : ${t}`,style:{display:"flex",flexDirection:i?"row":"column",alignItems:a==="right"?"flex-end":a==="center"?"center":i?"baseline":"flex-start",gap:i?6:1,minWidth:0,overflow:"hidden",flex:1,textAlign:a},children:[o.jsx("span",{style:{display:i?"block":"-webkit-box",width:"100%",minWidth:0,fontSize:(c==null?void 0:c.fontSize)??(i?Y.md:Y.sm),lineHeight:1.2,fontWeight:(c==null?void 0:c.fontWeight)??700,color:(c==null?void 0:c.textColor)??s,whiteSpace:i?"nowrap":"normal",overflow:"hidden",textOverflow:"ellipsis",WebkitBoxOrient:"vertical",WebkitLineClamp:i?void 0:2,overflowWrap:"anywhere"},children:e}),o.jsx("span",{style:{display:"block",maxWidth:"100%",fontSize:"9px",lineHeight:1.15,fontWeight:650,letterSpacing:"0.055em",textTransform:"uppercase",color:(c==null?void 0:c.textColor)??r,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i?`: ${t}`:`«${t}»`})]})}function Bc({label:e,onDrillIn:t,color:s,onColor:r}){return o.jsx("button",{"aria-label":`Drill into ${e}`,title:`Open ${e} as its own internal block diagram`,className:"nodrag",onClick:i=>{i.stopPropagation(),t()},onDoubleClick:i=>i.stopPropagation(),style:{width:18,height:18,padding:0,borderRadius:3,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",border:r?"1px solid rgba(255,255,255,0.7)":`1px solid ${s}88`,background:r?"rgba(255,255,255,0.18)":"#FFFFFF",color:r?"#FFFFFF":s,fontSize:11,lineHeight:1,cursor:"pointer",fontWeight:700},children:"↳"})}function ar({label:e,isCollapsed:t,onToggle:s,color:r,onColor:i}){return o.jsx("button",{"aria-label":t?`Expand ${e}`:`Collapse ${e}`,onClick:c=>{c.stopPropagation(),s()},style:{marginLeft:"auto",width:18,height:18,padding:0,borderRadius:3,border:i?"1px solid rgba(255,255,255,0.7)":`1px solid ${r}88`,background:i?"rgba(255,255,255,0.18)":"#FFFFFF",color:i?"#FFFFFF":r,fontSize:13,lineHeight:"15px",cursor:"pointer",fontWeight:700,flexShrink:0},children:t?"+":"−"})}function Pc({id:e,data:t,selected:s,height:r}){const i=fa(),c=t,{label:a,kind:p,color:b,isContainer:g,isFrame:j,ports:C,implicitIn:O,implicitOut:L,onPortMove:N,onPortResize:D,onPortSelect:m,showPortText:k,hasChildren:w,isCollapsed:W,onToggleCollapse:A,onDrillIn:_,minWidth:M,minHeight:q,bgColor:v,fillOpacity:T,borderColor:xe,textColor:H,fontSize:me,fontWeight:ie,textAlign:ue,verticalAlign:be}=c,[P,$]=u.useState(!1),le=s?rt.selected:j?"none":P?"0 8px 20px rgba(15,23,42,0.12)":g?"0 1px 2px rgba(15,23,42,0.05)":"0 2px 8px rgba(15,23,42,0.08)",ye=(E,te)=>{const we=i.getState().nodeLookup.get(e);if(!we)return!0;const fe=4;return[...i.getState().nodeLookup.values()].every(J=>{if(J.id===e||J.parentId!==we.parentId||J.hidden)return!0;const re=J.measured.width??J.width??0,ae=J.measured.height??J.height??0;if(re<=0||ae<=0)return!0;const ve=J.internals.positionAbsolute;return te.x+te.width+fe<=ve.x||ve.x+re+fe<=te.x||te.y+te.height+fe<=ve.y||ve.y+ae+fe<=te.y})};return o.jsxs("div",{onMouseEnter:()=>$(!0),onMouseLeave:()=>$(!1),style:{width:"100%",height:"100%",boxSizing:"border-box",background:v||"#FFFFFF",opacity:T??1,border:j?`1.5px solid ${xe??"#94A3B8"}`:`1px solid ${xe??(P?b+"9A":"#CBD5E1")}`,...j?{}:{borderTop:`3px solid ${xe??b}`},borderRadius:j?10:8,boxShadow:le,transition:"box-shadow 150ms ease, border-color 150ms ease",position:"relative"},children:[o.jsx(xt,{nodeId:e,isVisible:s||P,minWidth:M??180,minHeight:q??100,color:"#2563EB",lineStyle:{borderWidth:1},handleStyle:{width:10,height:10,borderRadius:2},shouldResize:ye}),j?o.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,height:38,display:"flex",alignItems:be==="top"?"flex-start":be==="bottom"?"flex-end":"center",gap:8,padding:"0 10px",background:"#F8FAFC",borderBottom:"1px solid #E2E8F0",borderRadius:"9px 9px 0 0"},children:[o.jsx("span",{style:{padding:"2px 6px",borderRadius:4,background:b,color:"#FFFFFF",fontSize:9,fontWeight:800,letterSpacing:"0.08em"},children:"IBD"}),o.jsx(ir,{name:a,kind:p,nameColor:"#0F172A",typeColor:"#64748B",frame:!0,style:{textColor:H,fontSize:me,fontWeight:ie,textAlign:ue}}),w&&A&&o.jsx(ar,{label:a,isCollapsed:W,onToggle:A,color:b})]}):o.jsxs("div",{style:{display:"flex",alignItems:be==="top"?"flex-start":be==="bottom"?"flex-end":"center",gap:6,minHeight:58,padding:"7px 10px 6px",background:"#FFFFFF",borderBottom:w?"1px solid #E2E8F0":"none",borderRadius:"7px 7px 0 0",overflow:"hidden"},children:[In(p)&&o.jsx(Zt,{size:24,color:b}),o.jsx(ir,{name:a,kind:p,nameColor:"#0F172A",typeColor:g?b:"#64748B",style:{textColor:H,fontSize:me,fontWeight:ie,textAlign:ue}}),w&&_&&o.jsx(Bc,{label:a,onDrillIn:_,color:b}),w&&A&&o.jsx(ar,{label:a,isCollapsed:W,onToggle:A,color:b})]}),C.filter(E=>E.nestedCount).map(E=>o.jsx(Nc,{port:E},`${E.id}__group`)),C.map(E=>o.jsx(Dc,{port:E,onMove:N?(te,we)=>{const fe=E.size??gt,J=(j||g?70:62)-fe/2,re=Math.max(J,(r??J+fe+18)-fe-18);N(E.id,Math.min(Math.max(te,J),re),we)}:void 0,onResize:D?(te,we)=>D(E.id,te,we):void 0,onSelect:m,showText:k},E.id)),O&&o.jsx(rr,{side:"left",direction:"in"}),L&&o.jsx(rr,{side:"right",direction:"out"})]})}const $c=u.memo(Pc);function lr(e,t){const s=e.map(i=>({...i}));let r=t;for(;s.length>=2&&r>0;){const i=s[0],c=s[1],a=Math.hypot(c.x-i.x,c.y-i.y);if(a<=r)r-=a,s.shift();else{const p=r/a;s[0]={x:i.x+(c.x-i.x)*p,y:i.y+(c.y-i.y)*p},r=0}}return s}function Oc(e,t){const s=lr(e,t);return lr([...s].reverse(),t).reverse()}const Wc=e=>e.slice(1).reduce((t,s,r)=>t+Math.hypot(s.x-e[r].x,s.y-e[r].y),0);function Ro(e,t=7){if(e.length<2)return"";let s=`M ${e[0].x},${e[0].y}`;for(let i=1;i<e.length-1;i++){const c=e[i-1],a=e[i],p=e[i+1],b=Math.hypot(a.x-c.x,a.y-c.y),g=Math.hypot(p.x-a.x,p.y-a.y),j=Math.min(t,b/2,g/2),C=a.x-Math.sign(a.x-c.x)*j,O=a.y-Math.sign(a.y-c.y)*j,L=a.x+Math.sign(p.x-a.x)*j,N=a.y+Math.sign(p.y-a.y)*j;s+=` L ${C},${O} Q ${a.x},${a.y} ${L},${N}`}const r=e[e.length-1];return`${s} L ${r.x},${r.y}`}function _c(e){let t=0,s=-1;for(let a=1;a<e.length;a++){const p=Math.abs(e[a].x-e[a-1].x)+Math.abs(e[a].y-e[a-1].y);p>s&&(s=p,t=a)}const r=e[t-1],i=e[t],c=Math.abs(i.x-r.x)>=Math.abs(i.y-r.y)?{x:0,y:-14}:{x:14,y:0};return{x:(r.x+i.x)/2+c.x,y:(r.y+i.y)/2+c.y}}function Hc(e){var W,A,_,M,q,v,T,xe,H,me,ie,ue,be;const{getZoom:t,screenToFlowPosition:s}=jn(),r=Ir(e.id,[e.source,e.target,(W=e.data)==null?void 0:W.sourcePortId,(A=e.data)==null?void 0:A.targetPortId]),i=En()&&!r,c=((_=e.data)==null?void 0:_.points)??[];if(c.length<2)return null;const a=String(((M=e.style)==null?void 0:M.stroke)??"#2563EB"),p=Number(((q=e.style)==null?void 0:q.strokeWidth)??2),b=r?{...e.style,strokeWidth:p+1.4}:e.style,g=((v=e.data)==null?void 0:v.labelPoint)??_c(c),j=Math.min(28/Math.max(t(),.1),Wc(c)*.3),C=Oc(c,j),O=(T=e.data)==null?void 0:T.onRouteChange,L=(xe=e.data)==null?void 0:xe.onRouteChangeComplete,N=(H=e.data)==null?void 0:H.onSelect,D=!!((me=e.data)!=null&&me.flowAnimation),m=c.length===2?[{index:1,a:c[0],b:c[1],straight:!0}]:c.slice(1).map((P,$)=>({index:$+1,a:c[$],b:P,straight:!1})).filter(P=>P.index>=2&&P.index<=c.length-2),k=(P,$)=>{if(!O)return;P.preventDefault(),P.stopPropagation();const le=c.map(J=>({...J})),ye=P.clientX,E=P.clientY;let te=le;const we=J=>{const re=(J.clientX-ye)/t(),ae=(J.clientY-E)/t();if($.straight)if(Math.abs(ae)>=Math.abs(re)){const ve=$.a.y+ae;te=[$.a,{x:$.a.x,y:ve},{x:$.b.x,y:ve},$.b]}else{const ve=($.a.x+$.b.x)/2+re;te=[$.a,{x:ve,y:$.a.y},{x:ve,y:$.b.y},$.b]}else te=c.map(ve=>({...ve})),$.a.y===$.b.y?(te[$.index-1].y=$.a.y+ae,te[$.index].y=$.b.y+ae):(te[$.index-1].x=$.a.x+re,te[$.index].x=$.b.x+re);O(te)},fe=()=>{window.removeEventListener("pointermove",we),L==null||L(le,te)};window.addEventListener("pointermove",we),window.addEventListener("pointerup",fe,{once:!0})},w=P=>{const $=le=>{const ye=le.b.x-le.a.x,E=le.b.y-le.a.y,te=ye*ye+E*E,we=te===0?0:Math.max(0,Math.min(1,((P.x-le.a.x)*ye+(P.y-le.a.y)*E)/te)),fe=le.a.x+we*ye,J=le.a.y+we*E;return(P.x-fe)**2+(P.y-J)**2};return m.reduce((le,ye)=>!le||$(ye)<$(le)?ye:le,void 0)};return o.jsxs(o.Fragment,{children:[r&&o.jsx("path",{d:Ro(c),fill:"none",stroke:a,strokeOpacity:.22,strokeWidth:p+9,strokeLinecap:"round",pointerEvents:"none"}),o.jsx(Sr,{id:e.id,path:Ro(c),style:b,markerEnd:e.markerEnd}),D&&o.jsx("path",{d:Ro(c),fill:"none",stroke:String(((ie=e.style)==null?void 0:ie.stroke)??"#2563EB"),strokeWidth:Math.max(2,Number(((ue=e.style)==null?void 0:ue.strokeWidth)??2)),className:"memo-ibd-flow"}),C.length>=2&&o.jsx("path",{d:Ro(C),fill:"none",stroke:"transparent",strokeWidth:18/Math.max(t(),.1),pointerEvents:"stroke",cursor:"pointer",onClick:P=>N==null?void 0:N(P),onPointerDown:P=>{if(!e.selected||!O||m.length===0)return;const $=w(s({x:P.clientX,y:P.clientY}));$&&k(P,$)}}),e.label&&((be=e.data)==null?void 0:be.showLabel)!==!1?o.jsx(wn,{children:o.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${g.x}px, ${g.y}px)`,fontSize:Y.badge,fontWeight:r?700:600,color:r?"#0F172A":"#475569",background:"rgba(255,255,255,0.96)",border:`1px solid ${r?a:"#E2E8F0"}`,opacity:i?.25:1,padding:"1px 4px",borderRadius:4,pointerEvents:"none"},children:e.label})}):null,e.selected&&O?m.map(P=>{const $=(P.a.x+P.b.x)/2,le=(P.a.y+P.b.y)/2;return o.jsx(wn,{children:o.jsx("div",{className:"nodrag nopan",title:"Drag connector segment",onPointerDown:ye=>k(ye,P),style:{position:"absolute",transform:`translate(-50%, -50%) translate(${$}px, ${le}px)`,width:12,height:12,borderRadius:3,background:"#FFFFFF",border:"2px solid #2563EB",boxShadow:"0 1px 4px rgba(15,23,42,0.22)",cursor:P.a.y===P.b.y?"ns-resize":"ew-resize",pointerEvents:"all",touchAction:"none",zIndex:20}})},`route-${P.index}`)}):null]})}const Vc=u.memo(Hc);function cr({onDrillIn:e,color:t,label:s}){return o.jsx("button",{onClick:r=>{r.stopPropagation(),e()},onDoubleClick:r=>r.stopPropagation(),className:"nodrag",title:`Open ${s} as its own diagram`,"aria-label":`Drill into ${s}`,style:{width:16,height:16,flexShrink:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${t}66`,borderRadius:4,background:"#FFFFFF",color:t,fontSize:10,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"↳"})}function dr({collapsed:e,onToggle:t,color:s}){return o.jsx("button",{onClick:r=>{r.stopPropagation(),t()},onDoubleClick:r=>r.stopPropagation(),className:"nodrag",title:e?"Show substates":"Hide substates","aria-label":e?"Show substates":"Hide substates",style:{width:16,height:16,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${s}66`,borderRadius:4,background:"#FFFFFF",color:s,fontSize:11,fontWeight:700,lineHeight:1,cursor:"pointer"},children:e?"+":"−"})}const zo={width:8,height:8,border:"none",background:"transparent",opacity:0};function mn(){return o.jsxs(o.Fragment,{children:[o.jsx(ne,{type:"target",position:K.Top,id:"top",style:zo}),o.jsx(ne,{type:"source",position:K.Bottom,id:"bottom",style:zo}),o.jsx(ne,{type:"target",position:K.Left,id:"left",style:zo}),o.jsx(ne,{type:"source",position:K.Right,id:"right",style:zo})]})}function Gc({data:e,selected:t}){const s=e,[r,i]=u.useState(!1);if(s.isNote)return o.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#FFFDF5",border:`1px solid ${s.color}66`,borderRadius:4,padding:"6px 10px",boxShadow:rt.sm,display:"flex",flexDirection:"column",justifyContent:"center"},title:s.kind,children:[o.jsx(mn,{}),o.jsx("span",{style:{fontSize:Y.xs,fontWeight:600,color:"#374151",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.label}),o.jsx("span",{style:{fontSize:"8px",fontWeight:700,color:s.color,textTransform:"uppercase",letterSpacing:"0.05em"},children:s.kind})]});if(s.isContainer)return o.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:s.isMachine?"transparent":`${s.color}06`,borderTop:s.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${s.color}55`,borderRight:s.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${s.color}55`,borderBottom:s.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${s.color}55`,borderLeft:s.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${s.color}55`,borderRadius:14,boxShadow:t?rt.selected:"none",position:"relative"},children:[o.jsx(mn,{}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px 0"},children:[s.onToggleCollapse&&!s.isMachine&&o.jsx(dr,{collapsed:!1,onToggle:s.onToggleCollapse,color:s.color}),s.onDrillIn&&!s.isMachine&&o.jsx(cr,{onDrillIn:s.onDrillIn,color:s.color,label:s.label}),o.jsx("span",{style:{fontSize:Y.md,fontWeight:700,color:s.isMachine?"#334155":s.color,whiteSpace:"nowrap"},children:s.label}),o.jsx("span",{style:{fontSize:"8px",fontWeight:700,color:s.isMachine?"#94A3B8":`${s.color}AA`,textTransform:"uppercase",letterSpacing:"0.06em"},children:s.kind})]})]});const c=!!s.hasChildren;return o.jsxs("div",{onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),title:c?`${s.hiddenCount??0} substate${s.hiddenCount===1?"":"s"} hidden — double-click to drill in`:void 0,style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#FFFFFF",borderTop:`3px solid ${s.color}`,borderRight:`1px solid ${r?`${s.color}9A`:"#CBD5E1"}`,borderBottom:`1px solid ${r?`${s.color}9A`:"#CBD5E1"}`,borderLeft:`1px solid ${r?`${s.color}9A`:"#CBD5E1"}`,borderRadius:12,boxShadow:t?rt.selected:r?"0 8px 20px rgba(15,23,42,0.12)":rt.md,transition:"box-shadow 150ms ease, border-color 150ms ease",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,padding:"4px 12px"},children:[o.jsx(mn,{}),o.jsx("span",{style:{fontSize:Y.md,fontWeight:600,color:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:s.label}),s.subtitle&&o.jsx("span",{style:{fontSize:"8px",fontWeight:600,color:"#9CA3AF",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:s.subtitle}),c&&o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5},children:[s.onToggleCollapse&&o.jsx(dr,{collapsed:!0,onToggle:s.onToggleCollapse,color:s.color}),s.onDrillIn&&o.jsx(cr,{onDrillIn:s.onDrillIn,color:s.color,label:s.label}),o.jsxs("span",{style:{fontSize:"8px",fontWeight:700,color:s.color,letterSpacing:"0.05em"},children:["⊞ ",s.hiddenCount??0]})]})]})}const Uc=u.memo(Gc),Fn="#3498DB";function Xc({data:e}){const t=e;return o.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",pointerEvents:"none"},children:[o.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 ${Fn}`,borderRadius:8,boxShadow:rt.md,textAlign:"center",fontSize:Y.md,fontWeight:600,color:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.label}),o.jsx("div",{style:{position:"absolute",top:44,bottom:0,left:"50%",borderLeft:`1.5px dashed ${Fn}66`}})]})}const Yc=u.memo(Xc);function Kc({data:e}){const t=e;return o.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#1B3A4B06",border:"1px solid #1B3A4B22",borderRadius:10,pointerEvents:"none"},children:o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,padding:"8px 14px"},children:[o.jsx("span",{style:{fontSize:Y.sm,fontWeight:700,color:"#1B3A4B"},children:t.label}),t.scenario&&o.jsxs("span",{style:{fontSize:Y.xs,color:"#6B7280"},children:["realizes ",t.scenario]})]})})}const qc=u.memo(Kc),Mo={width:6,height:6,border:"none",background:"transparent",opacity:0};function Zc({data:e,selected:t}){const s=e;return o.jsxs("div",{style:{width:14,height:14,borderRadius:"50%",background:"#FFFFFF",border:`3px solid ${Fn}`,boxShadow:t?rt.selected:rt.sm,position:"relative"},title:s.kind,children:[o.jsx(ne,{type:"source",id:"right",position:K.Right,style:Mo}),o.jsx(ne,{type:"target",id:"right",position:K.Right,style:Mo}),o.jsx(ne,{type:"source",id:"left",position:K.Left,style:Mo}),o.jsx(ne,{type:"target",id:"left",position:K.Left,style:Mo}),o.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:s.label})]})}const Jc=u.memo(Zc),$o={opacity:0,width:1,height:1},Qc=u.memo(function({data:t}){const s=t;return o.jsxs("div",{style:{width:"100%",height:"100%",display:"grid",placeItems:"center",textAlign:"center",padding:"12px 22px",border:`2px solid ${s.color??"#E67E22"}`,borderRadius:"50%",background:"#FFF9F2",color:"#2D3748",fontSize:13,fontWeight:600,lineHeight:1.25},children:[s.label,o.jsx(ne,{type:"target",position:K.Left,style:$o}),o.jsx(ne,{type:"source",position:K.Right,style:$o})]})}),ed=u.memo(function({data:t}){const s=t,r=s.side==="right"?K.Left:K.Right;return o.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:[o.jsx(Zt,{color:s.color??"#334155"}),o.jsx("span",{children:s.label}),o.jsx(ne,{type:"source",position:r,style:$o}),o.jsx(ne,{type:"target",position:r,style:$o})]})}),td=u.memo(function({data:t}){const s=t;return o.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:s.label})});u.memo(function({data:t}){const s=t;return o.jsx("div",{style:{width:"100%",textAlign:"center",color:"#64748B",fontSize:11,fontWeight:700,letterSpacing:".03em"},children:s.label})});function od(e,t=0){if(e.length<2)return"";if(t===0||e.length===2)return`M ${e.map(i=>`${i.x},${i.y}`).join(" L ")}`;let s=`M ${e[0].x},${e[0].y}`;for(let i=1;i<e.length-1;i++){const c=e[i-1],a=e[i],p=e[i+1],b=Math.min(t,Math.abs(a.x-c.x)/2+Math.abs(a.y-c.y)/2),g=Math.min(t,Math.abs(p.x-a.x)/2+Math.abs(p.y-a.y)/2),j={x:a.x+Math.sign(c.x-a.x)*b,y:a.y+Math.sign(c.y-a.y)*b},C={x:a.x+Math.sign(p.x-a.x)*g,y:a.y+Math.sign(p.y-a.y)*g};s+=` L ${j.x},${j.y} Q ${a.x},${a.y} ${C.x},${C.y}`}const r=e[e.length-1];return`${s} L ${r.x},${r.y}`}const nd=u.memo(function(t){var O,L,N,D,m;const s=Ir(t.id,[t.source,t.target]),r=En()&&!s,i=((O=t.data)==null?void 0:O.routing)??"rounded",c=Array.isArray((L=t.data)==null?void 0:L.points)?t.data.points:[],a=c.length>=2?c:[{x:t.sourceX,y:t.sourceY},{x:t.targetX,y:t.targetY}],b=i==="straight"?`M ${t.sourceX},${t.sourceY} L ${t.targetX},${t.targetY}`:od(a,i==="elbow"?0:i==="rounded"?16:i==="curved"?30:42),g=((N=t.data)==null?void 0:N.labelPoint)??a[Math.floor(a.length/2)]??{x:(t.sourceX+t.targetX)/2,y:(t.sourceY+t.targetY)/2},j=String(((D=t.style)==null?void 0:D.stroke)??"#64748B"),C=Number(((m=t.style)==null?void 0:m.strokeWidth)??1.5);return o.jsxs(o.Fragment,{children:[s&&o.jsx("path",{d:b,fill:"none",stroke:j,strokeOpacity:.22,strokeWidth:C+9,strokeLinecap:"round",pointerEvents:"none"}),o.jsx(Sr,{path:b,style:s?{...t.style,strokeWidth:C+1.4}:t.style}),t.label&&o.jsx(wn,{children:o.jsx("div",{className:"nodrag nopan",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${g.x}px,${g.y}px)`,background:"#FFFFFF",padding:"2px 5px",borderRadius:3,color:s?"#0F172A":"#334155",fontSize:12,pointerEvents:"all",fontWeight:s?700:void 0,opacity:r?.25:1},children:t.label})})]})}),To={opacity:0,width:1,height:1};function Kr({nodeId:e,selected:t,data:s}){return o.jsx(xt,{nodeId:e,isVisible:t,minWidth:s.minWidth??140,minHeight:s.minHeight??64,color:"#0F766E",lineStyle:{borderWidth:1},handleStyle:{width:10,height:10,borderRadius:2}})}function qr(){return o.jsxs(o.Fragment,{children:[o.jsx(ne,{type:"target",position:K.Left,style:To}),o.jsx(ne,{type:"source",position:K.Right,style:To}),o.jsx(ne,{type:"target",position:K.Top,style:To}),o.jsx(ne,{type:"source",position:K.Bottom,style:To})]})}const sd=u.memo(function({id:t,data:s,selected:r}){const i=s;return o.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:[o.jsx(Kr,{nodeId:t,selected:!!r,data:i}),o.jsxs("span",{children:[o.jsx("small",{style:{display:"block",marginBottom:5,color:"#0F766E",fontSize:10,letterSpacing:".08em"},children:"SYSTEM OF INTEREST"}),i.label]}),o.jsx(qr,{})]})}),rd=u.memo(function({id:t,data:s,selected:r}){const i=s,c=i.category==="environment"?{border:"#7C3AED",fill:"#F5F3FF",text:"#4C1D95",tag:"ENVIRONMENT"}:i.category==="person"?{border:"#2563EB",fill:"#EFF6FF",text:"#1E3A8A",tag:"ACTOR"}:{border:"#64748B",fill:"#F8FAFC",text:"#334155",tag:"EXTERNAL SYSTEM"};return o.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:3,padding:"10px 14px",textAlign:"center",border:`1.5px solid ${c.border}`,borderRadius:7,background:c.fill,color:c.text,fontSize:13,fontWeight:650,lineHeight:1.25},children:[o.jsx(Kr,{nodeId:t,selected:!!r,data:i}),i.category==="person"&&o.jsx(Zt,{size:26,color:c.border}),o.jsxs("span",{children:[o.jsx("small",{style:{display:"block",marginBottom:4,color:c.border,fontSize:9,letterSpacing:".07em"},children:c.tag}),i.label]}),o.jsx(qr,{})]})}),id=u.memo(function({id:t,data:s,selected:r}){const i=s;return o.jsxs("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:[o.jsx(xt,{nodeId:t,isVisible:!!r,minWidth:i.minWidth??240,minHeight:i.minHeight??140,color:"#0F766E",lineStyle:{borderWidth:1},handleStyle:{width:10,height:10,borderRadius:2}}),i.label]})}),ad=u.memo(function({id:t,data:s,selected:r}){var W;const i=s,[c,a]=u.useState(!1),[p,b]=u.useState(""),[g,j]=u.useState(!1),C=u.useRef(null),O=u.useCallback(()=>{b(i.label),a(!0),setTimeout(()=>{var A;(A=C.current)==null||A.select()},10)},[i.label]),L=u.useCallback(()=>{var _;a(!1);const A=p.trim();A&&A!==i.label&&((_=i.onInlineEdit)==null||_.call(i,t,A))},[p,i,t]),N=u.useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),L()),A.key==="Escape"&&a(!1)},[L]),D=u.useCallback(A=>{var _;A.preventDefault(),(_=i.onContextMenu)==null||_.call(i,A,t)},[i,t]),m=i.bgColor??"#FFFFFF",k=i.color,w={background:k,border:"2px solid #FFFFFF",width:10,height:10,opacity:g||r?1:0,transition:"opacity 0.15s"};return o.jsxs("div",{onMouseEnter:()=>j(!0),onMouseLeave:()=>j(!1),onContextMenu:D,onDoubleClick:O,style:{minWidth:120,minHeight:40,background:m,borderLeft:`3px solid ${k}`,borderRadius:8,boxShadow:r?`0 0 0 2px ${k}, 0 4px 12px ${k}44`:g?"0 4px 16px rgba(0,0,0,0.14)":"0 1px 4px rgba(0,0,0,0.08)",cursor:c?"text":"default",position:"relative",transition:"box-shadow 0.15s",opacity:i.isNew?.7:1},children:[r&&o.jsx(xt,{minWidth:80,minHeight:36,maxWidth:600,maxHeight:400,color:k,lineStyle:{borderColor:k},handleStyle:{background:k,border:"2px solid #fff",width:10,height:10,borderRadius:2}}),o.jsxs("div",{style:{padding:"8px 12px",userSelect:"none",display:"flex",gap:8,alignItems:"center"},children:[In(i.kind)&&o.jsx(Zt,{size:26,color:k}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:"9px",fontWeight:700,color:k,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:2},children:i.kind}),c?o.jsx("input",{ref:C,value:p,onChange:A=>b(A.target.value),onBlur:L,onKeyDown:N,onClick:A=>A.stopPropagation(),autoFocus:!0,style:{fontSize:Y.sm,fontWeight:500,color:"#1a1a1a",background:"transparent",border:"none",outline:"none",width:"100%",padding:0}}):o.jsx("div",{style:{fontSize:Y.sm,fontWeight:500,color:"#1a1a1a",lineHeight:1.3,wordBreak:"break-word"},children:i.label||i.kind}),i.isNew&&o.jsx("div",{style:{fontSize:"9px",color:"#9CA3AF",marginTop:2},children:"saving…"})]})]}),!!((W=i.compartments)!=null&&W.length)&&o.jsx("div",{style:{borderTop:"1px solid #EDEDEA",padding:"5px 12px 7px",userSelect:"none"},children:i.compartments.map(A=>o.jsxs("div",{style:{display:"flex",gap:6,alignItems:"baseline",fontSize:"10px",lineHeight:"15px",whiteSpace:"nowrap",overflow:"hidden"},children:[o.jsx("span",{style:{color:"#9CA3AF"},children:A.key}),o.jsx("span",{style:{color:"#4B5563",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis"},children:A.value})]},A.key))}),o.jsx(ne,{type:"target",position:K.Top,style:{...w,top:-5}}),o.jsx(ne,{type:"source",position:K.Bottom,style:{...w,bottom:-5},id:"bottom"}),o.jsx(ne,{type:"source",position:K.Right,style:{...w,right:-5},id:"right"}),o.jsx(ne,{type:"target",position:K.Left,style:{...w,left:-5}})]})}),Zr="application/memo-kind";function fn({collapsed:e,onToggleCollapse:t,elementIds:s=[],eligibleKinds:r}){const i=ee(m=>m.model),c=ee(m=>m.selectedElementId),a=ee(m=>m.inspectElement),[p,b]=u.useState(""),[g,j]=u.useState(new Set),[C,O]=u.useState(!0),L=u.useMemo(()=>{if(!(r!=null&&r.size))return[];const m=p.trim().toLowerCase();return Cr(i).kinds.filter(k=>r.has(k.name)&&!k.isAbstract).filter(k=>!m||k.name.toLowerCase().includes(m)||(k.label??"").toLowerCase().includes(m)).map(k=>({name:k.name,label:k.label||k.name,layer:k.layer??"",construct:vl(k.construct)})).sort((k,w)=>k.label.localeCompare(w.label))},[i,r,p]),N=u.useMemo(()=>{var W;if(!i)return[];const m=p.trim().toLowerCase(),k=new Map,w=new Set(s);for(const A of s){const _=(W=i.elements[A])==null?void 0:W.allocatedTo;_&&w.add(_)}for(const A of w){const _=i.elements[A];_&&(m&&!_.name.toLowerCase().includes(m)&&!_.kind.toLowerCase().includes(m)||(k.has(_.kind)||k.set(_.kind,[]),k.get(_.kind).push(_)))}return[...k.entries()].map(([A,_])=>({kind:A,elements:_.sort((M,q)=>M.name.localeCompare(q.name))})).sort((A,_)=>A.kind.localeCompare(_.kind))},[i,s,p]),D=m=>j(k=>{const w=new Set(k);return w.has(m)?w.delete(m):w.add(m),w});return e?null:o.jsxs("div",{className:"flex flex-col overflow-hidden",style:{width:240,borderRight:"1px solid #E5E5E0",background:"#FAFAF8",flexShrink:0},children:[o.jsxs("div",{className:"flex items-center justify-between px-3 py-2",style:{background:"#F0F0ED",borderBottom:"1px solid #E5E5E0",flexShrink:0},children:[o.jsx("span",{style:{fontSize:Y.xs,fontWeight:600,color:"#374151"},children:"Diagram Elements"}),o.jsx("button",{onClick:t,title:"Hide Diagram Elements","aria-label":"Hide Diagram Elements",style:{width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:5,cursor:"pointer",color:"#6B7280",fontSize:20,lineHeight:1},children:"×"})]}),o.jsx("div",{className:"px-2 pt-2 pb-1",style:{flexShrink:0},children:o.jsx("input",{value:p,onChange:m=>b(m.target.value),placeholder:"Search elements…",className:"w-full px-2 py-1 rounded focus:outline-none",style:{fontSize:Y.xs,background:"#F0F0ED",border:"1px solid #E5E5E0",color:"#374151"}})}),o.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[L.length>0&&o.jsxs("div",{style:{borderBottom:"1px solid #E5E5E0",paddingBottom:4,marginBottom:4},children:[o.jsxs("button",{onClick:()=>O(m=>!m),className:"w-full flex items-center gap-1.5 px-2 py-1",style:{background:"none",border:"none",cursor:"pointer",textAlign:"left"},children:[o.jsx("span",{style:{fontSize:10,color:"#6B7280"},children:C?"▼":"▶"}),o.jsx("span",{style:{fontSize:10,color:"#374151",fontWeight:700,letterSpacing:"0.04em"},children:"SHAPES"}),o.jsx("span",{style:{fontSize:9,color:"#9CA3AF",marginLeft:"auto"},children:L.length})]}),C&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"px-3 pb-1",style:{fontSize:9,color:"#9CA3AF"},children:"Drag onto the canvas to create"}),L.map(m=>{const k=vn[m.layer]??"#6B7280";return o.jsxs("div",{draggable:!0,onDragStart:w=>{w.dataTransfer.setData(Zr,JSON.stringify({kind:m.name,layer:m.layer,construct:m.construct})),w.dataTransfer.effectAllowed="copy"},title:`Drag to create a ${m.label} (${m.construct})`,className:"flex items-center gap-2 px-3 py-1.5",style:{cursor:"grab",fontSize:Y.xs,color:"#374151"},children:[o.jsx("span",{style:{width:12,height:12,flexShrink:0,borderRadius:m.construct==="port"?2:3,border:`2px solid ${k}`,background:m.construct==="port"?"#FFFFFF":`${k}22`}}),o.jsx("span",{className:"truncate flex-1",children:m.label})]},m.name)})]})]}),N.map(m=>{var W;const k=g.has(m.kind),w=vn[(W=m.elements[0])==null?void 0:W.layer]??"#6B7280";return o.jsxs("div",{children:[o.jsxs("button",{onClick:()=>D(m.kind),className:"w-full flex items-center gap-1.5 px-2 py-1",style:{background:"none",border:"none",cursor:"pointer",textAlign:"left"},children:[o.jsx("span",{style:{fontSize:10,color:w},children:k?"▶":"▼"}),o.jsx("span",{className:"truncate",style:{fontSize:10,color:w,fontWeight:700},children:m.kind}),o.jsx("span",{style:{fontSize:9,color:"#9CA3AF",marginLeft:"auto"},children:m.elements.length})]}),!k&&m.elements.map(A=>{const _=c===A.id;return o.jsxs("button",{onClick:()=>a(A.id),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left",style:{border:"none",cursor:"pointer",fontSize:Y.xs,background:_?"#DDF7EF":"transparent",color:_?"#116149":"#374151",fontWeight:_?600:400},title:`Highlight ${A.name} in diagram`,children:[o.jsx("span",{style:{width:8,height:8,borderRadius:2,background:w,flexShrink:0}}),o.jsx("span",{className:"truncate flex-1",children:A.name})]},A.id)})]},m.kind)}),N.length===0&&o.jsx("div",{className:"p-3 text-center",style:{color:"#9CA3AF",fontSize:Y.xs},children:p?"No matching elements":"No elements in this diagram"})]})]})}function Ne({label:e,icon:t,danger:s,onClick:r}){return o.jsxs("button",{onClick:r,className:"w-full flex items-center gap-2 px-3 py-1.5 text-left",style:{background:"none",border:"none",cursor:"pointer",fontSize:Y.xs},onMouseEnter:i=>{i.currentTarget.style.background=s?"#FEF2F2":"#F7F7F5"},onMouseLeave:i=>{i.currentTarget.style.background="none"},children:[t&&o.jsx("span",{style:{fontSize:"12px",width:16,textAlign:"center"},children:t}),o.jsx("span",{style:{color:s?"#DC2626":"#1a1a1a"},children:e})]})}function Bo(){return o.jsx("div",{style:{height:1,background:"#E5E5E0",margin:"2px 0"}})}function Jr({x:e,y:t,onClose:s,children:r}){const i=u.useRef(null);u.useEffect(()=>{const b=j=>{i.current&&!i.current.contains(j.target)&&s()},g=j=>{j.key==="Escape"&&s()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",g),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",g)}},[s]);const c=210,a=Math.min(e,window.innerWidth-c-8),p=Math.min(t,window.innerHeight-200);return o.jsx("div",{ref:i,className:"fixed z-50 rounded-xl overflow-hidden py-1",style:{left:a,top:p,minWidth:c,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.14)"},children:r})}const ld=[{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 cd({x:e,y:t,nodeId:s,nodeKind:r,onClose:i,onEditName:c,onChangeColor:a,onRemoveFromDiagram:p,onDeleteFromModel:b,onLinkRisk:g,onLinkRequirement:j,onShowProperties:C,onFocusElement:O,onShowInCatalog:L,onShowRelMatrix:N,onOpenSource:D,onViewKindInOntology:m}){const[k,w]=u.useState(!1);return o.jsxs(Jr,{x:e,y:t,onClose:i,children:[o.jsxs("div",{className:"px-3 py-1.5",style:{borderBottom:"1px solid #E5E5E0"},children:[o.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"#9CA3AF"},children:r}),o.jsx("div",{style:{fontSize:"9px",color:"#D1D5DB",fontFamily:"monospace"},children:s})]}),C&&o.jsx(Ne,{label:"Show Properties",icon:"ℹ",onClick:()=>{i(),C()}}),L&&o.jsx(Ne,{label:"Show in Catalog",icon:"☰",onClick:()=>{i(),L()}}),O&&o.jsx(Ne,{label:"Focus on Element",icon:"◎",onClick:()=>{i(),O()}}),N&&o.jsx(Ne,{label:"Show Relationship Matrix",icon:"☷",onClick:()=>{i(),N()}}),m&&o.jsx(Ne,{label:"View Kind in Ontology",icon:"⬡",onClick:()=>{i(),m()}}),D&&o.jsx(Ne,{label:"Open Source File",icon:"⟨/⟩",onClick:()=>{i(),D()}}),(C||L||O||N||m||D)&&o.jsx(Bo,{}),o.jsx(Ne,{label:"Edit name",icon:"✏️",onClick:()=>{i(),c()}}),o.jsxs("div",{className:"relative",children:[o.jsxs("button",{className:"w-full flex items-center gap-2 px-3 py-1.5",style:{background:"none",border:"none",cursor:"pointer",fontSize:Y.xs},onMouseEnter:W=>{w(!0),W.currentTarget.style.background="#F7F7F5"},onMouseLeave:W=>{W.currentTarget.style.background="none"},children:[o.jsx("span",{style:{fontSize:"12px",width:16,textAlign:"center"},children:"🎨"}),o.jsx("span",{style:{flex:1,textAlign:"left",color:"#1a1a1a"},children:"Change color"}),o.jsx("span",{style:{color:"#9CA3AF",fontSize:"10px"},children:"▶"})]}),k&&o.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:()=>w(!0),onMouseLeave:()=>w(!1),children:ld.map(W=>o.jsxs("button",{onClick:()=>{i(),a(W.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:[o.jsx("div",{style:{width:14,height:14,borderRadius:3,flexShrink:0,background:W.value||"#E5E5E0",border:"1px solid #D1D5DB"}}),o.jsx("span",{style:{fontSize:Y.xs,color:"#374151"},children:W.label})]},W.value))})]}),o.jsx(Bo,{}),g&&o.jsx(Ne,{label:"Link Risk",icon:"⚠️",onClick:()=>{i(),g()}}),j&&o.jsx(Ne,{label:"Link Requirement",icon:"📋",onClick:()=>{i(),j()}}),(g||j)&&o.jsx(Bo,{}),o.jsx(Ne,{label:"Remove from diagram",icon:"↩️",onClick:()=>{i(),p()}}),o.jsx(Ne,{label:"Delete from model",icon:"🗑️",danger:!0,onClick:()=>{window.confirm(`Delete ${s} from the model? This cannot be undone.`)&&(i(),b())}})]})}const dd=[{label:"Auto",value:""},{label:"Red",value:"#EF4444"},{label:"Blue",value:"#3B82F6"},{label:"Green",value:"#10B981"},{label:"Orange",value:"#F59E0B"},{label:"Gray",value:"#6B7280"}];function ud({x:e,y:t,edgeId:s,relType:r,onClose:i,onChangeStyle:c,onChangeColor:a,onToggleLabel:p,onDelete:b}){return o.jsxs(Jr,{x:e,y:t,onClose:i,children:[o.jsxs("div",{className:"px-3 py-1.5",style:{borderBottom:"1px solid #E5E5E0"},children:[o.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"#9CA3AF"},children:r}),o.jsx("div",{style:{fontSize:"9px",color:"#D1D5DB",fontFamily:"monospace"},children:s})]}),o.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2",children:[o.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF",minWidth:40},children:"Style"}),["solid","dashed","dotted"].map(g=>o.jsx("button",{onClick:()=>{i(),c(g)},style:{fontSize:"10px",padding:"2px 8px",border:"1px solid #E5E5E0",borderRadius:4,cursor:"pointer",background:"#F7F7F5",color:"#374151"},children:g},g))]}),o.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-1.5 flex-wrap",children:[o.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF",minWidth:40,flexShrink:0},children:"Color"}),dd.map(g=>o.jsx("button",{onClick:()=>{i(),a(g.value)},title:g.label,style:{width:16,height:16,borderRadius:"50%",background:g.value||"#E5E5E0",border:"1px solid #D1D5DB",cursor:"pointer"}},g.value))]}),o.jsx(Bo,{}),o.jsx(Ne,{label:"Toggle label",icon:"🏷️",onClick:()=>{i(),p()}}),o.jsx(Ne,{label:"Delete edge",icon:"🗑️",danger:!0,onClick:()=>{i(),b()}})]})}const pd=u.memo(function({id:t,data:s,selected:r}){const i=s,c=i.color??i.layerColor??"#E67E22",a=80,p=u.useCallback(b=>{var g;b.preventDefault(),(g=i.onContextMenu)==null||g.call(i,b,t)},[i,t]);return o.jsxs("div",{style:{width:a,height:a,position:"relative"},onContextMenu:p,children:[r&&o.jsx(xt,{minWidth:60,minHeight:60}),o.jsx("svg",{width:a,height:a,style:{position:"absolute",top:0,left:0},children:o.jsx("polygon",{points:`${a/2},4 ${a-4},${a/2} ${a/2},${a-4} 4,${a/2}`,fill:i.color?i.color+"44":"#FFF8E1",stroke:c,strokeWidth:r?2.5:1.5})}),o.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:i.condition||i.label||"?"}),o.jsx(ne,{type:"target",position:K.Top,style:{background:c,border:"2px solid #fff"}}),o.jsx(ne,{type:"source",position:K.Right,style:{background:c,border:"2px solid #fff"},id:"right"}),o.jsx(ne,{type:"source",position:K.Bottom,style:{background:c,border:"2px solid #fff"},id:"bottom"}),o.jsx(ne,{type:"target",position:K.Left,style:{background:c,border:"2px solid #fff"}})]})}),hd=u.memo(function({id:t,data:s,selected:r}){const i=s,c=(i.orientation??"horizontal")==="horizontal",a=c?120:8,p=c?8:60,b=u.useCallback(g=>{var j;g.preventDefault(),(j=i.onContextMenu)==null||j.call(i,g,t)},[i,t]);return o.jsxs("div",{style:{width:a,height:p,background:"#1a1a1a",borderRadius:4,position:"relative"},title:i.nodeType==="join"?"Join (synchronization)":"Fork (parallel)",onContextMenu:b,children:[r&&o.jsx(xt,{minWidth:40,minHeight:6}),c?o.jsxs(o.Fragment,{children:[o.jsx(ne,{type:"target",position:K.Left,style:{background:"#2DD4A8",border:"2px solid #fff",left:-1}}),o.jsx(ne,{type:"source",position:K.Top,style:{background:"#2DD4A8",border:"2px solid #fff",top:-1},id:"top"}),o.jsx(ne,{type:"source",position:K.Bottom,style:{background:"#2DD4A8",border:"2px solid #fff",bottom:-1},id:"bottom"}),o.jsx(ne,{type:"source",position:K.Right,style:{background:"#2DD4A8",border:"2px solid #fff",right:-1},id:"right"})]}):o.jsxs(o.Fragment,{children:[o.jsx(ne,{type:"target",position:K.Top,style:{background:"#2DD4A8",border:"2px solid #fff",top:-1}}),o.jsx(ne,{type:"source",position:K.Left,style:{background:"#2DD4A8",border:"2px solid #fff",left:-1},id:"left"}),o.jsx(ne,{type:"source",position:K.Right,style:{background:"#2DD4A8",border:"2px solid #fff",right:-1},id:"right"}),o.jsx(ne,{type:"source",position:K.Bottom,style:{background:"#2DD4A8",border:"2px solid #fff",bottom:-1},id:"bottom"})]})]})}),md=u.memo(function({id:t,data:s}){const r=s,i=r.nodeType==="start",c=32,a=u.useCallback(p=>{var b;p.preventDefault(),(b=r.onContextMenu)==null||b.call(r,p,t)},[r,t]);return o.jsxs("div",{style:{width:c,height:c,position:"relative"},onContextMenu:a,children:[o.jsx("svg",{width:c,height:c,children:i?o.jsx("circle",{cx:c/2,cy:c/2,r:c/2-2,fill:"#1a1a1a"}):o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:c/2,cy:c/2,r:c/2-2,fill:"#1a1a1a"}),o.jsx("circle",{cx:c/2,cy:c/2,r:c/2-6,fill:"#FFFFFF"}),o.jsx("circle",{cx:c/2,cy:c/2,r:c/2-10,fill:"#1a1a1a"})]})}),i?o.jsx(ne,{type:"source",position:K.Bottom,style:{background:"#1a1a1a",border:"2px solid #fff"}}):o.jsx(ne,{type:"target",position:K.Top,style:{background:"#1a1a1a",border:"2px solid #fff"}})]})}),fd=["grid","route","export","autoLayout"],gd={actionflow:["expandCollapse","flowSwimlanes","flowHierarchy","flowNesting","flowDirection","flowLegend","flowFilters"],interconnection:["expandCollapse","interconnectionPorts","interconnectionConnections"],statetransition:["expandCollapse"],general:["expandCollapse","generalMode","useCaseOptions"]};function xd(e){return new Set([...fd,...e?gd[e]??[]:[]])}function bd(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const s=document.implementation.createHTMLDocument(),r=s.createElement("base"),i=s.createElement("a");return s.head.appendChild(r),s.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}const yd=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function it(e){const t=[];for(let s=0,r=e.length;s<r;s++)t.push(e[s]);return t}let Ct=null;function Qr(e={}){return Ct||(e.includeStyleProperties?(Ct=e.includeStyleProperties,Ct):(Ct=it(window.getComputedStyle(document.documentElement)),Ct))}function Oo(e,t){const r=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function wd(e){const t=Oo(e,"border-left-width"),s=Oo(e,"border-right-width");return e.clientWidth+t+s}function vd(e){const t=Oo(e,"border-top-width"),s=Oo(e,"border-bottom-width");return e.clientHeight+t+s}function kd(e,t={}){const s=t.width||wd(e),r=t.height||vd(e);return{width:s,height:r}}function Sn(e){return new Promise((t,s)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=s,r.crossOrigin="anonymous",r.decoding="async",r.src=e})}async function Fd(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function Sd(e,t,s){const r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),c=document.createElementNS(r,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${s}`),i.setAttribute("viewBox",`0 0 ${t} ${s}`),c.setAttribute("width","100%"),c.setAttribute("height","100%"),c.setAttribute("x","0"),c.setAttribute("y","0"),c.setAttribute("externalResourcesRequired","true"),i.appendChild(c),c.appendChild(e),Fd(i)}const Me=(e,t)=>{if(e instanceof t)return!0;const s=Object.getPrototypeOf(e);return s===null?!1:s.constructor.name===t.name||Me(s,t)};function Cd(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function jd(e,t){return Qr(t).map(s=>{const r=e.getPropertyValue(s),i=e.getPropertyPriority(s);return`${s}: ${r}${i?" !important":""};`}).join(" ")}function Ed(e,t,s,r){const i=`.${e}:${t}`,c=s.cssText?Cd(s):jd(s,r);return document.createTextNode(`${i}{${c}}`)}function ur(e,t,s,r){const i=window.getComputedStyle(e,s),c=i.getPropertyValue("content");if(c===""||c==="none")return;const a=yd();try{t.className=`${t.className} ${a}`}catch{return}const p=document.createElement("style");p.appendChild(Ed(a,s,i,r)),t.appendChild(p)}function Id(e,t,s){ur(e,t,":before",s),ur(e,t,":after",s)}const pr="application/font-woff",hr="image/jpeg",Ad={woff:pr,woff2:pr,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:hr,jpeg:hr,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Rd(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function zn(e){const t=Rd(e).toLowerCase();return Ad[t]||""}function zd(e){return e.split(/,/)[1]}function Cn(e){return e.search(/^(data:)/)!==-1}function Md(e,t){return`data:${t};base64,${e}`}async function ei(e,t,s){const r=await fetch(e,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const i=await r.blob();return new Promise((c,a)=>{const p=new FileReader;p.onerror=a,p.onloadend=()=>{try{c(s({res:r,result:p.result}))}catch(b){a(b)}},p.readAsDataURL(i)})}const gn={};function Td(e,t,s){let r=e.replace(/\?.*/,"");return s&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function Mn(e,t,s){const r=Td(e,t,s.includeQueryParams);if(gn[r]!=null)return gn[r];s.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let i;try{const c=await ei(e,s.fetchRequestInit,({res:a,result:p})=>(t||(t=a.headers.get("Content-Type")||""),zd(p)));i=Md(c,t)}catch(c){i=s.imagePlaceholder||"";let a=`Failed to fetch resource: ${e}`;c&&(a=typeof c=="string"?c:c.message),a&&console.warn(a)}return gn[r]=i,i}async function Ld(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):Sn(t)}async function Nd(e,t){if(e.currentSrc){const c=document.createElement("canvas"),a=c.getContext("2d");c.width=e.clientWidth,c.height=e.clientHeight,a==null||a.drawImage(e,0,0,c.width,c.height);const p=c.toDataURL();return Sn(p)}const s=e.poster,r=zn(s),i=await Mn(s,r,t);return Sn(i)}async function Dd(e,t){var s;try{if(!((s=e==null?void 0:e.contentDocument)===null||s===void 0)&&s.body)return await Wo(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function Bd(e,t){return Me(e,HTMLCanvasElement)?Ld(e):Me(e,HTMLVideoElement)?Nd(e,t):Me(e,HTMLIFrameElement)?Dd(e,t):e.cloneNode(ti(e))}const Pd=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",ti=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function $d(e,t,s){var r,i;if(ti(t))return t;let c=[];return Pd(e)&&e.assignedNodes?c=it(e.assignedNodes()):Me(e,HTMLIFrameElement)&&(!((r=e.contentDocument)===null||r===void 0)&&r.body)?c=it(e.contentDocument.body.childNodes):c=it(((i=e.shadowRoot)!==null&&i!==void 0?i:e).childNodes),c.length===0||Me(e,HTMLVideoElement)||await c.reduce((a,p)=>a.then(()=>Wo(p,s)).then(b=>{b&&t.appendChild(b)}),Promise.resolve()),t}function Od(e,t,s){const r=t.style;if(!r)return;const i=window.getComputedStyle(e);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):Qr(s).forEach(c=>{let a=i.getPropertyValue(c);c==="font-size"&&a.endsWith("px")&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),Me(e,HTMLIFrameElement)&&c==="display"&&a==="inline"&&(a="block"),c==="d"&&t.getAttribute("d")&&(a=`path(${t.getAttribute("d")})`),r.setProperty(c,a,i.getPropertyPriority(c))})}function Wd(e,t){Me(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),Me(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function _d(e,t){if(Me(e,HTMLSelectElement)){const r=Array.from(t.children).find(i=>e.value===i.getAttribute("value"));r&&r.setAttribute("selected","")}}function Hd(e,t,s){return Me(t,Element)&&(Od(e,t,s),Id(e,t,s),Wd(e,t),_d(e,t)),t}async function Vd(e,t){const s=e.querySelectorAll?e.querySelectorAll("use"):[];if(s.length===0)return e;const r={};for(let c=0;c<s.length;c++){const p=s[c].getAttribute("xlink:href");if(p){const b=e.querySelector(p),g=document.querySelector(p);!b&&g&&!r[p]&&(r[p]=await Wo(g,t,!0))}}const i=Object.values(r);if(i.length){const c="http://www.w3.org/1999/xhtml",a=document.createElementNS(c,"svg");a.setAttribute("xmlns",c),a.style.position="absolute",a.style.width="0",a.style.height="0",a.style.overflow="hidden",a.style.display="none";const p=document.createElementNS(c,"defs");a.appendChild(p);for(let b=0;b<i.length;b++)p.appendChild(i[b]);e.appendChild(a)}return e}async function Wo(e,t,s){return!s&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(r=>Bd(r,t)).then(r=>$d(e,r,t)).then(r=>Hd(e,r,t)).then(r=>Vd(r,t))}const oi=/url\((['"]?)([^'"]+?)\1\)/g,Gd=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Ud=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Xd(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function Yd(e){const t=[];return e.replace(oi,(s,r,i)=>(t.push(i),s)),t.filter(s=>!Cn(s))}async function Kd(e,t,s,r,i){try{const c=s?bd(t,s):t,a=zn(t);let p;return i||(p=await Mn(c,a,r)),e.replace(Xd(t),`$1${p}$3`)}catch{}return e}function qd(e,{preferredFontFormat:t}){return t?e.replace(Ud,s=>{for(;;){const[r,,i]=Gd.exec(s)||[];if(!i)return"";if(i===t)return`src: ${r};`}}):e}function ni(e){return e.search(oi)!==-1}async function si(e,t,s){if(!ni(e))return e;const r=qd(e,s);return Yd(r).reduce((c,a)=>c.then(p=>Kd(p,a,t,s)),Promise.resolve(r))}async function jt(e,t,s){var r;const i=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(e);if(i){const c=await si(i,null,s);return t.style.setProperty(e,c,t.style.getPropertyPriority(e)),!0}return!1}async function Zd(e,t){await jt("background",e,t)||await jt("background-image",e,t),await jt("mask",e,t)||await jt("-webkit-mask",e,t)||await jt("mask-image",e,t)||await jt("-webkit-mask-image",e,t)}async function Jd(e,t){const s=Me(e,HTMLImageElement);if(!(s&&!Cn(e.src))&&!(Me(e,SVGImageElement)&&!Cn(e.href.baseVal)))return;const r=s?e.src:e.href.baseVal,i=await Mn(r,zn(r),t);await new Promise((c,a)=>{e.onload=c,e.onerror=t.onImageErrorHandler?(...b)=>{try{c(t.onImageErrorHandler(...b))}catch(g){a(g)}}:a;const p=e;p.decode&&(p.decode=c),p.loading==="lazy"&&(p.loading="eager"),s?(e.srcset="",e.src=i):e.href.baseVal=i})}async function Qd(e,t){const r=it(e.childNodes).map(i=>ri(i,t));await Promise.all(r).then(()=>e)}async function ri(e,t){Me(e,Element)&&(await Zd(e,t),await Jd(e,t),await Qd(e,t))}function eu(e,t){const{style:s}=e;t.backgroundColor&&(s.backgroundColor=t.backgroundColor),t.width&&(s.width=`${t.width}px`),t.height&&(s.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(i=>{s[i]=r[i]}),e}const mr={};async function fr(e){let t=mr[e];if(t!=null)return t;const r=await(await fetch(e)).text();return t={url:e,cssText:r},mr[e]=t,t}async function gr(e,t){let s=e.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,c=(s.match(/url\([^)]+\)/g)||[]).map(async a=>{let p=a.replace(r,"$1");return p.startsWith("https://")||(p=new URL(p,e.url).href),ei(p,t.fetchRequestInit,({result:b})=>(s=s.replace(a,`url(${b})`),[a,b]))});return Promise.all(c).then(()=>s)}function xr(e){if(e==null)return[];const t=[],s=/(\/\*[\s\S]*?\*\/)/gi;let r=e.replace(s,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const b=i.exec(r);if(b===null)break;t.push(b[0])}r=r.replace(i,"");const c=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",p=new RegExp(a,"gi");for(;;){let b=c.exec(r);if(b===null){if(b=p.exec(r),b===null)break;c.lastIndex=p.lastIndex}else p.lastIndex=c.lastIndex;t.push(b[0])}return t}async function tu(e,t){const s=[],r=[];return e.forEach(i=>{if("cssRules"in i)try{it(i.cssRules||[]).forEach((c,a)=>{if(c.type===CSSRule.IMPORT_RULE){let p=a+1;const b=c.href,g=fr(b).then(j=>gr(j,t)).then(j=>xr(j).forEach(C=>{try{i.insertRule(C,C.startsWith("@import")?p+=1:i.cssRules.length)}catch(O){console.error("Error inserting rule from remote css",{rule:C,error:O})}})).catch(j=>{console.error("Error loading remote css",j.toString())});r.push(g)}})}catch(c){const a=e.find(p=>p.href==null)||document.styleSheets[0];i.href!=null&&r.push(fr(i.href).then(p=>gr(p,t)).then(p=>xr(p).forEach(b=>{a.insertRule(b,a.cssRules.length)})).catch(p=>{console.error("Error loading remote stylesheet",p)})),console.error("Error inlining remote css file",c)}}),Promise.all(r).then(()=>(e.forEach(i=>{if("cssRules"in i)try{it(i.cssRules||[]).forEach(c=>{s.push(c)})}catch(c){console.error(`Error while reading CSS rules from ${i.href}`,c)}}),s))}function ou(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>ni(t.style.getPropertyValue("src")))}async function nu(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const s=it(e.ownerDocument.styleSheets),r=await tu(s,t);return ou(r)}function ii(e){return e.trim().replace(/["']/g,"")}function su(e){const t=new Set;function s(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(c=>{t.add(ii(c))}),Array.from(r.children).forEach(c=>{c instanceof HTMLElement&&s(c)})}return s(e),t}async function ru(e,t){const s=await nu(e,t),r=su(e);return(await Promise.all(s.filter(c=>r.has(ii(c.style.fontFamily))).map(c=>{const a=c.parentStyleSheet?c.parentStyleSheet.href:null;return si(c.cssText,a,t)}))).join(`
4
+ `)}async function iu(e,t){const s=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await ru(e,t);if(s){const r=document.createElement("style"),i=document.createTextNode(s);r.appendChild(i),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}async function au(e,t={}){const{width:s,height:r}=kd(e,t),i=await Wo(e,t,!0);return await iu(i,t),await ri(i,t),eu(i,t),await Sd(i,s,r)}const ai="#FFFFFF",Lo=24,lu=2;function cu(e){const t=/translate\(\s*(-?[\d.]+)px[,\s]+(-?[\d.]+)px/.exec(e.style.transform);return t?[Number(t[1]),Number(t[2])]:[0,0]}function du(e){const t=[...e.querySelectorAll(".react-flow__node")];let s=1/0,r=1/0,i=-1/0,c=-1/0;for(const a of t){const[p,b]=cu(a);s=Math.min(s,p),r=Math.min(r,b),i=Math.max(i,p+a.offsetWidth),c=Math.max(c,b+a.offsetHeight)}return Number.isFinite(s)?{x:s,y:r,width:i-s,height:c-r}:{x:0,y:0,width:e.scrollWidth||1,height:e.scrollHeight||1}}async function uu(e){const t=e.querySelector(".react-flow__viewport");if(!t)throw new Error("No diagram canvas to export");const s=du(t),r=Math.max(1,Math.ceil(s.width)+Lo*2),i=Math.max(1,Math.ceil(s.height)+Lo*2);return{dataUrl:await au(t,{width:r,height:i,backgroundColor:ai,skipFonts:!0,filter:a=>!(a instanceof Element&&(a.classList.contains("react-flow__controls")||a.classList.contains("react-flow__minimap")||a.classList.contains("react-flow__background")||a.classList.contains("react-flow__attribution"))),style:{width:`${r}px`,height:`${i}px`,transform:`translate(${Lo-s.x}px, ${Lo-s.y}px) scale(1)`}}),width:r,height:i}}async function pu(e,t,s,r){const i=new Image;i.src=e,await i.decode();const c=document.createElement("canvas");c.width=Math.max(1,Math.round(t*r)),c.height=Math.max(1,Math.round(s*r));const a=c.getContext("2d");if(!a)throw new Error("Canvas 2D context unavailable");return a.fillStyle=ai,a.fillRect(0,0,c.width,c.height),a.drawImage(i,0,0,c.width,c.height),c}function br(e,t){const s=document.createElement("a");s.href=e,s.download=t,s.click()}function hu(e,t){return`${(e??"diagram").replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").toLowerCase()||"diagram"}.${t}`}async function mu(e,t,s){const r=hu(s,t),{dataUrl:i,width:c,height:a}=await uu(e);if(t==="svg"){br(i,r);return}const p=await pu(i,c,a,lu);if(t==="png"){br(p.toDataURL("image/png"),r);return}const{jsPDF:b}=await Aa(async()=>{const{jsPDF:j}=await import("./jspdf.es.min-B7e0_lrE.js").then(C=>C.j);return{jsPDF:j}},__vite__mapDeps([0,1,2,3,4])),g=new b({orientation:c>=a?"landscape":"portrait",unit:"px",format:[c,a],compress:!0});g.addImage(p.toDataURL("image/png"),"PNG",0,0,c,a),g.save(r)}const yr="memo-layout-progress";if(typeof document<"u"&&!document.getElementById(yr)){const e=document.createElement("style");e.id=yr,e.textContent="@keyframes memo-layout-progress { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }",document.head.appendChild(e)}const wr={background:"#F7F7F5"},fu={padding:.08,maxZoom:2},gu={background:"#FFFFFF"},xu={hideAttribution:!0},bu=[20,20],yu=50,vr=8e3,wu=90;function vu(e,t){return new Promise((s,r)=>{const i=window.setTimeout(()=>r(new Error(`${t} layout exceeded ${vr/1e3}s`)),vr);e.then(c=>{window.clearTimeout(i),s(c)},c=>{window.clearTimeout(i),r(c)})})}function ku({data:e,selected:t}){const s=e.kind,r=s==="note",i=s==="constraint";return o.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",padding:r?"12px 14px":i?"10px 12px":"4px",background:r?String(e.color??"#FEF3C7"):i?"#FFFFFF":"transparent",border:i?"1.5px dashed #7C3AED":r?"1px solid #F59E0B":"1px solid transparent",borderRadius:r?3:i?5:0,boxShadow:r?"0 2px 6px rgba(0,0,0,.12)":"none",color:"#292524",fontSize:12,lineHeight:1.4},children:[o.jsx(xt,{isVisible:t,minWidth:100,minHeight:48,color:"#2563EB"}),o.jsx("button",{className:"nodrag","aria-label":"Delete annotation",title:"Delete annotation",onPointerDown:c=>{var a;c.preventDefault(),c.stopPropagation(),(a=e.onDelete)==null||a.call(e)},onClick:c=>{var a;c.stopPropagation(),(a=e.onDelete)==null||a.call(e)},style:{position:"absolute",top:3,right:5,border:0,background:"transparent",color:"#64748B",cursor:"pointer",fontSize:14,lineHeight:1,pointerEvents:"all",zIndex:30},children:"×"}),i&&o.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#7C3AED",marginBottom:4},children:"constraint"}),o.jsx("div",{contentEditable:!0,suppressContentEditableWarning:!0,className:"nodrag",style:{outline:"none",whiteSpace:"pre-wrap",minHeight:20},onBlur:c=>{var a;return(a=e.onTextChange)==null?void 0:a.call(e,c.currentTarget.textContent??"")},children:String(e.text??"")})]})}const Fu={left:"right",right:"left",top:"bottom",bottom:"top"};function xn(e,t,s="direct"){const r=new Map(e.map(m=>[m.id,m])),i=new Map,c=m=>{const k=i.get(m);if(k)return k;const w=r.get(m),W=w.parentId?c(w.parentId):{x:0,y:0},A={x:W.x+w.position.x,y:W.y+w.position.y};return i.set(m,A),A},a=m=>{var k,w;return{width:Number(m.width??((k=m.style)==null?void 0:k.width)??0),height:Number(m.height??((w=m.style)==null?void 0:w.height)??0)}},p=t.flatMap(m=>{var T,xe,H,me,ie,ue,be,P;const k=($,le,ye,E)=>{var te,we;if(typeof le=="string"){const fe=(((we=(te=r.get($))==null?void 0:te.data)==null?void 0:we.ports)??[]).find(J=>J.id===le);if(fe){const J=fe.size??gt,re=fe.x+J/2,ae=fe.y+J/2+(fe.nestedCount??0)*jr/2;return E==="left"?{x:re-J/2,y:ae}:E==="right"?{x:re+J/2,y:ae}:E==="top"?{x:re,y:ae-J/2}:E==="bottom"?{x:re,y:ae+J/2}:{x:re,y:ae}}}return ye},w=($,le,ye)=>{var we,fe;const E=r.get($);if(!E||typeof le!="string")return ye;const te=(((we=E.data)==null?void 0:we.ports)??[]).find(J=>J.id===le);return te!=null&&te.side?(fe=E.data)!=null&&fe.isFrame?Fu[te.side]:te.side:ye},W=w(m.source,(T=m.data)==null?void 0:T.sourcePortId,(xe=m.data)==null?void 0:xe.sourceSide),A=w(m.target,(H=m.data)==null?void 0:H.targetPortId,(me=m.data)==null?void 0:me.targetSide),_=k(m.source,(ie=m.data)==null?void 0:ie.sourcePortId,(ue=m.data)==null?void 0:ue.sourceOffset,W),M=k(m.target,(be=m.data)==null?void 0:be.targetPortId,(P=m.data)==null?void 0:P.targetOffset,A);if(!_||!M||!r.has(m.source)||!r.has(m.target))return[];const q=c(m.source),v=c(m.target);return[{id:m.id,source:{x:q.x+_.x,y:q.y+_.y},target:{x:v.x+M.x,y:v.y+M.y},sourceNodeId:m.source,targetNodeId:m.target,sourceSide:W,targetSide:A}]});if(p.length===0)return t;const b=e.filter(m=>{const k=m.data;return!k.isFrame&&!k.isContainer&&!k.hasChildren}).map(m=>({id:m.id,...c(m.id),...a(m)})),g=new Map(p.map(m=>[m.id,m])),j=new Set(t.filter(m=>{var k;return(k=m.data)==null?void 0:k.manualRoute}).map(m=>m.id)),C=p.filter(m=>!j.has(m.id)),O=s==="tidy"?hl(C,b):ml(C),L=(m,k)=>{const{labelPoint:w,...W}=m.data??{};return{...m,data:{...W,points:k}}},N=t.map(m=>{var W;const k=g.get(m.id);if(!k)return m;if((W=m.data)!=null&&W.manualRoute){const A=[...m.data.points??[]];if(A.length>=2)return A[0]=k.source,A[A.length-1]=k.target,L(m,A)}const w=O.get(m.id);return w?L(m,w):m});if(s!=="tidy")return N;const D=fl(N.flatMap(m=>{var W;const k=(W=m.data)==null?void 0:W.points,w=typeof m.label=="string"?m.label:"";return k&&k.length>=2&&w?[{id:m.id,points:k,width:w.length*6.2+16,height:18}]:[]}),b);return N.map(m=>D.has(m.id)?{...m,data:{...m.data,labelPoint:D.get(m.id)}}:m)}function Su({x:e,y:t,onConfirm:s,onCancel:r}){const[i,c]=u.useState(""),a=u.useRef(null);u.useEffect(()=>{var g;(g=a.current)==null||g.focus()},[]),u.useEffect(()=>{const g=j=>{const C=document.getElementById("quick-create-popup");C&&!C.contains(j.target)&&r()};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[r]);const p=Math.min(e,window.innerWidth-220),b=Math.min(t,window.innerHeight-80);return o.jsxs("div",{id:"quick-create-popup",className:"fixed z-50 rounded-xl shadow-xl overflow-hidden",style:{left:p,top:b,width:200,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.14)"},children:[o.jsx("div",{className:"px-3 py-2",style:{borderBottom:"1px solid #E5E5E0",fontSize:Y.xs,color:"#9CA3AF",fontWeight:600},children:"New Element"}),o.jsxs("div",{className:"px-2 py-2",children:[o.jsx("input",{ref:a,value:i,onChange:g=>c(g.target.value),placeholder:"Element name…",className:"w-full px-2 py-1.5 rounded focus:outline-none",style:{fontSize:Y.xs,border:"1px solid #E5E5E0",background:"#F7F7F5",color:"#1a1a1a"},onKeyDown:g=>{g.key==="Enter"&&i.trim()&&(g.preventDefault(),s(i.trim())),g.key==="Escape"&&r()}}),o.jsxs("div",{className:"flex gap-2 mt-2",children:[o.jsx("button",{onClick:()=>i.trim()&&s(i.trim()),style:{flex:1,fontSize:Y.xs,padding:"4px 8px",background:"#2DD4A8",color:"#FFFFFF",border:"none",borderRadius:6,cursor:"pointer",fontWeight:600},children:"Create"}),o.jsx("button",{onClick:r,style:{fontSize:Y.xs,padding:"4px 8px",background:"#F7F7F5",color:"#6B7280",border:"1px solid #E5E5E0",borderRadius:6,cursor:"pointer"},children:"Cancel"})]})]})]})}function bn({color:e,glyph:t}){return o.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:13,height:13,borderRadius:2,background:e+"22",border:`1.5px solid ${e}`,color:e,fontSize:9,fontWeight:800,lineHeight:1},children:t})}function kr(e,t){if(!e||!t)return[];const s=new Map;for(const a of e.relationships)Do.has(a.type)&&!s.has(a.targetId)&&s.set(a.targetId,a.sourceId);const r=[t],i=new Set(r);let c=t;for(;s.has(c);){const a=s.get(c);if(i.has(a))break;r.unshift(a),i.add(a),c=a}return r}function yn({path:e,nameOf:t,onFocus:s,rootLabel:r}){if(e.length===0)return null;const i=e.length>1?e[e.length-2]:null;return o.jsxs(o.Fragment,{children:[o.jsx(Ue,{}),o.jsx(ke,{icon:o.jsx(V.back,{}),label:"Parent",onClick:()=>s(i),title:i?`Back to ${t(i)}`:r}),o.jsx("button",{onClick:()=>s(null),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#2563EB",border:"1px solid #E5E5E0"},title:r,children:"⌂ All"}),e.map((c,a)=>{const p=a===e.length-1;return o.jsxs("span",{className:"flex items-center gap-1",style:{color:"#9CA3AF"},children:[o.jsx("span",{children:"›"}),o.jsx("button",{onClick:()=>s(c),disabled:p,className:"text-xs font-medium",style:{color:p?"#1a1a1a":"#2563EB",fontWeight:p?700:500,cursor:p?"default":"pointer"},title:p?void 0:`Focus ${t(c)}`,children:t(c)})]},c)})]})}function Cu(){var Ss,Cs,js,Es,Is,As,Rs,zs,Ms,Ts,Ls,Ns,Ds,Bs,Ps,$s;const e=xa(),t=ee(n=>n.model),s=ee(n=>n.createRelationship),r=u.useMemo(()=>Cr(t),[t]),i=ee(n=>n.selectedElementId),c=ee(n=>n.selectedViewpointId),a=ee(n=>n.selectedDiagramId),p=ee(n=>n.hiddenLayers),b=ee(n=>n.selectElement),g=ee(n=>n.inspectElement),j=ee(n=>n.inspectRelationship),C=ee(n=>n.setActiveMode),O=ee(n=>n.setActiveView),L=ee(n=>n.setExplorerTab),N=ee(n=>n.availableOntologies),D=ee(n=>n.setSelectedOntologyKind),m=ee(n=>n.diagramLayouts),k=ee(n=>n.setNodeLayout),w=ee(n=>n.mergeDiagramLayouts),W=ee(n=>n.updateDiagramElementIds),{fitView:A,screenToFlowPosition:_,getViewport:M,setViewport:q}=jn(),[v,T]=ba([]),[xe,H,me]=ya([]),ie=u.useRef([]),ue=u.useRef([]),be=u.useRef(null),[P,$]=u.useState(!1),[le,ye]=u.useState(null),[E,te]=u.useState(null),we=u.useRef(t),fe=u.useRef(a),J=u.useRef(null),re=u.useRef(null),ae=u.useRef(!1),ve=u.useRef(null),Ie=u.useRef(0);u.useEffect(()=>{re.current===null&&(ie.current=v)},[v]),u.useEffect(()=>{ue.current=xe},[xe]);const he=u.useCallback((n,l=!0)=>{ie.current=n,ae.current||(ae.current=l),re.current===null&&(re.current=requestAnimationFrame(()=>{re.current=null;const d=ie.current,h=ae.current;if(ae.current=!1,!h){T(d);return}const f=xn(d,ue.current);ue.current=f,T(d),H(f)}))},[T,H]),[De,qe]=u.useState(!1),[lt,je]=u.useState(0),[ct,Tn]=u.useState(null),[Jt,li]=u.useState(0),[Et,ci]=u.useState(()=>localStorage.getItem("memo.minimap.open")!=="false"),[di,It]=u.useState(0),[At,Qt]=u.useState(!0),[eo,_o]=u.useState(!1),[Ho,ui]=u.useState(!1),Be="left",[pi,Ln]=u.useState(!0),[Vo,hi]=u.useState(!0),[Ze,Nn]=u.useState(!0),[Je,mi]=u.useState("horizontal"),[Qe,fi]=u.useState(!0),[et,gi]=u.useState("overlay"),[to,Dn]=u.useState("allocation"),[Rt,Bn]=u.useState("all"),[Pn,$n]=u.useState(!1),[On,xi]=u.useState(!1),[tt,bi]=u.useState(new Set(["control","data","energy","material"]));u.useEffect(()=>{const n=()=>_o(d=>!d),l=()=>Qt(d=>!d);return window.addEventListener("memo:toggle-diagram-toolbar",n),window.addEventListener("memo:toggle-diagram-elements",l),()=>{window.removeEventListener("memo:toggle-diagram-toolbar",n),window.removeEventListener("memo:toggle-diagram-elements",l)}},[]),u.useEffect(()=>{const n=()=>{var d;const l=document.fullscreenElement;ui(!!(l&&((d=be.current)!=null&&d.contains(l))))};return document.addEventListener("fullscreenchange",n),()=>document.removeEventListener("fullscreenchange",n)},[]);const[Pe,zt]=u.useState(null),[ot,oo]=u.useState(null),[Ae,yt]=u.useState(null),[Xe,Mt]=u.useState(null),[Tt,Wn]=u.useState(null),[no,yi]=u.useState(2),[so,_n]=u.useState(null),Lt=u.useRef([]),Go=u.useRef([]),ro=u.useCallback(n=>{Lt.current.push(n),Lt.current.length>yu&&Lt.current.shift(),Go.current=[]},[]),x=Ra(t,a),Uo=x?za[x.diagramType]:null,io=!!((Ss=x==null?void 0:x.properties)!=null&&Ss.layoutStyle),dt=((Cs=x==null?void 0:x.properties)==null?void 0:Cs.layoutStyle)==="fbs",ce=a?m[a]:void 0,ut=Ka(ce),Nt=((js=ce==null?void 0:ce.canvas)==null?void 0:js.autoLayout)!==!1,ao=((Es=ce==null?void 0:ce.canvas)==null?void 0:Es.flowAnimation)===!0,lo=((Is=ce==null?void 0:ce.canvas)==null?void 0:Is.showPortText)!==!1,co=((As=ce==null?void 0:ce.canvas)==null?void 0:As.showConnectionText)!==!1,Hn=(Rs=ce==null?void 0:ce.canvas)==null?void 0:Rs.portWalls,Vn=u.useMemo(()=>{const n=Object.entries(Hn??{}).flatMap(([l,d])=>{const h=gl(d);return h?[[l,h]]:[]});return n.length>0?new Map(n):void 0},[Hn]),Dt=u.useMemo(()=>{var h,f;const n=(h=ce==null?void 0:ce.canvas)==null?void 0:h.legend;if(!(n!=null&&n.enum)||!n.attribute)return;const l=(f=t==null?void 0:t.enumerations)==null?void 0:f.find(F=>F.name===n.enum);if(!l)return;const d=new Map(l.literals.flatMap(F=>{var S;const y=(S=n.colors)==null?void 0:S[F];return y?[[F,y]]:[]}));return{attribute:n.attribute,colors:d,name:l.name}},[(zs=ce==null?void 0:ce.canvas)==null?void 0:zs.legend,t==null?void 0:t.enumerations]),Gn=u.useCallback((n,l)=>{var F;if(!a)return;const d=ee.getState().diagramLayouts[a]??{nodes:{},edges:{}},h=(F=d.annotations)==null?void 0:F[n];if(!h)return;const f={...d,annotations:{...d.annotations,[n]:{...h,text:l}}};w({[a]:f}),Le(a,f),T(y=>y.map(S=>S.id===n?{...S,data:{...S.data,text:l}}:S))},[a,w,T]),Un=u.useCallback(n=>{if(!a)return;const l=ee.getState().diagramLayouts[a]??{nodes:{},edges:{}},d={...l.annotations};delete d[n];const h={...l,annotations:d};w({[a]:h}),Le(a,h),T(f=>f.filter(F=>F.id!==n))},[a,w,T]),uo=u.useCallback(n=>Object.entries((n==null?void 0:n.annotations)??{}).map(([l,d])=>({id:l,type:"annotationNode",zIndex:1e3,position:{x:d.x,y:d.y},style:{width:d.width??180,height:d.height??92},data:{kind:d.kind,text:d.text,color:d.color,onTextChange:h=>Gn(l,h),onDelete:()=>Un(l)}})),[Gn,Un]),wi=u.useCallback(n=>{if(!a)return;const l=`annotation-${Date.now().toString(36)}`,d=_({x:window.innerWidth/2,y:window.innerHeight/2}),h=n==="constraint"?"{constraint}":n==="note"?"Note":"Text",f=ee.getState().diagramLayouts[a]??{nodes:{},edges:{}},F={kind:n,x:d.x,y:d.y,width:180,height:n==="text"?56:92,text:h},y={...f,annotations:{...f.annotations,[l]:F}};w({[a]:y}),Le(a,y),T(S=>[...S,...uo(y).filter(I=>I.id===l)])},[a,_,w,T,uo]),Xn=u.useCallback(()=>{if(!a)return;const n=ee.getState().diagramLayouts[a],l={nodes:{},edges:{},canvas:{...n==null?void 0:n.canvas,autoLayout:!0}};w({[a]:l}),Le(a,l),It(d=>d+1)},[a,w]),vi=u.useCallback(n=>{mi(n),requestAnimationFrame(()=>e(ie.current.map(l=>l.id))),Xn()},[Xn,e]),Fe=u.useCallback(()=>{var l;if(!a)return;const n=ee.getState().diagramLayouts[a]??{nodes:{},edges:{}};((l=n.canvas)==null?void 0:l.autoLayout)!==!1&&w({[a]:{...n,canvas:{...n.canvas,autoLayout:!1}}})},[a,w]);u.useEffect(()=>{if(!a||Nt||De||v.length===0||lt===0)return;const n=window.setTimeout(()=>{const l=ee.getState().diagramLayouts[a]??{nodes:{},edges:{}},d=M(),h=Ll({nodes:Object.fromEntries(v.filter(f=>f.type!=="annotationNode").map(f=>[f.id,{...l.nodes[f.id]??{},x:f.position.x,y:f.position.y,parent:f.parentId??null,...f.width?{width:f.width}:{},...f.height?{height:f.height}:{},ports:Object.fromEntries((f.data.ports??[]).map(F=>[F.id,{x:F.x,y:F.y,side:F.side,...F.size?{size:F.size}:{}}]))}])),edges:Object.fromEntries(xe.map(f=>{var F,y,S,I,Z,Q;return[f.id,{...(()=>{var se;const{points:de,...ge}=((se=l.edges)==null?void 0:se[f.id])??{};return ge})(),...(F=f.data)!=null&&F.manualRoute&&((S=(y=f.data)==null?void 0:y.points)!=null&&S.length)?{points:(I=f.data)==null?void 0:I.points,source:f.source,target:f.target,sourcePortId:(Z=f.data)==null?void 0:Z.sourcePortId,targetPortId:(Q=f.data)==null?void 0:Q.targetPortId}:{}}]})),annotations:Object.fromEntries(v.filter(f=>f.type==="annotationNode").map(f=>{var F,y;return[f.id,{kind:f.data.kind,text:String(f.data.text??""),color:f.data.color,x:f.position.x,y:f.position.y,width:Number(f.width??((F=f.style)==null?void 0:F.width)??180),height:Number(f.height??((y=f.style)==null?void 0:y.height)??92)}]})),canvas:{...l.canvas,zoom:d.zoom,pan:{x:d.x,y:d.y},autoLayout:!1}});w({[a]:h}),Le(a,h),je(0)},350);return()=>window.clearTimeout(n)},[a,Nt,De,lt,v,xe,M,w]);const U=x?x.viewKind??(Uo==null?void 0:Uo.viewKind)??"general":void 0,Yn=u.useMemo(()=>xd(U),[U]),Se=u.useCallback(n=>Yn.has(n),[Yn]),po=U==="interconnection"?.72:.8,Oe=u.useCallback((n=0)=>{const l=be.current,d=ie.current.filter(se=>!se.hidden);if(!l||d.length===0)return;const{width:h,height:f}=l.getBoundingClientRect(),F=U==="actionflow"&&Qe&&et==="above"?112:0,y=h,S=f-F,I=wa(d);if(y<=0||S<=0||I.width<=0||I.height<=0)return;if(U==="actionflow"&&Ze){if(Je==="horizontal"){const se=Math.max(.1,Math.min(2,S*.72/I.height));q({x:y*.05-I.x*se,y:(S-I.height*se)/2-I.y*se,zoom:se},{duration:n})}else{const se=Math.max(.1,Math.min(2,y*.78/I.width));q({x:(y-I.width*se)/2-I.x*se,y:S*.06-I.y*se,zoom:se},{duration:n})}return}const Z=.08,Q=.08;if(Math.min(y*(1-Z*2)/I.width,S*(1-Q*2)/I.height,2)>=po){A({padding:Z,minZoom:po,maxZoom:2,duration:n});return}const ge=Math.max(.1,Math.min(2,y*(1-Z*2)/I.width));q({x:y*Z-I.x*ge,y:S*Q-I.y*ge,zoom:ge},{duration:n})},[Je,Qe,et,Be,po,A,Ho,q,Ze,eo,U]),wt=U==="general"&&!io&&!dt,Kn=(x==null?void 0:x.diagramType)==="ucd",[pt,qn]=u.useState("graph"),[Xo,Zn]=u.useState("all"),[Yo,Jn]=u.useState("straight"),[Bt,Qn]=u.useState(new Set),ki=u.useMemo(()=>t?qa(t):0,[t]),es=u.useMemo(()=>t?Za(t):[],[t]),Ko=(Ms=x==null?void 0:x.properties)==null?void 0:Ms.modes,Fi=u.useMemo(()=>{if(!Ko)return cn;const n=new Set(Ko.split(",").map(d=>d.trim())),l=cn.filter(d=>n.has(d));return l.length?l:cn},[Ko]),ts=u.useMemo(()=>{if(!t||!x)return[];const n=new Set(x.elementIds),l=Object.values(t.elements).filter(d=>n.has(d.id)&&d.allocatedTo).map(d=>d.allocatedTo);return Ja(l,t)},[t,x]),Si=u.useMemo(()=>{if(!t||!x)return!1;const n=new Set(x.elementIds);return Object.values(t.elements).some(l=>n.has(l.id)&&!!(l.attributes.stage||l.attributes.phase))},[t,x]),ho=u.useMemo(()=>{if(!t||!x||U!=="actionflow")return[];const n=(x.elementIds??[]).map(l=>t.elements[l]).filter(l=>!!l&&l.construct==="action");return Qa(n,t)},[t,x,U]),[Pt,Ci]=u.useState("containment"),[$t,mo]=u.useState(new Set),[os,Ot]=u.useState(new Set),[fo,qo]=u.useState(null),[Ve,Zo]=u.useState("all"),[nt,Jo]=u.useState("summary"),[ns,ss]=u.useState(!1),[rs,Wt]=u.useState(new Set),go=u.useCallback(n=>{if(!a)return;const l=ee.getState().diagramLayouts[a]??{nodes:{},edges:{}},d={...l,canvas:{...l.canvas,...n}};w({[a]:d}),Le(a,d)},[a,w]),[vt,Qo]=u.useState(null),[_t,is]=u.useState("flat"),[as,Ht]=u.useState(new Set),[xo,en]=u.useState(null),[bo,ji]=u.useState(new Map),We=u.useRef(new Map),Ei=u.useMemo(()=>kr(t,fo),[t,fo]),Ii=u.useMemo(()=>kr(t,xo),[t,xo]),Ai=u.useMemo(()=>{var h;if(!t||!vt)return[];const n=[vt],l=new Set(n);let d=vt;for(;d;){const f=(h=t.elements[d])==null?void 0:h.parentAction;if(!f||l.has(f)||!t.elements[f])break;n.unshift(f),l.add(f),d=f}return n},[t,vt]),yo=u.useMemo(()=>{if(!t||U!=="statetransition")return[];const n=new Set;for(const l of t.relationships){if(!Do.has(l.type))continue;const d=t.elements[l.sourceId];!d||!t.elements[l.targetId]||!el(d)||d.kind.endsWith("Machine")||n.add(d.id)}return[...n]},[t,U]),Ri=u.useMemo(()=>t?[...new Set(t.relationships.filter(n=>Do.has(n.type)).map(n=>n.sourceId))]:[],[t]);u.useEffect(()=>{var l,d,h,f;je(0),qn(tl(x==null?void 0:x.properties)),Zn(dn(x==null?void 0:x.properties).level??"all"),Jn(dn(x==null?void 0:x.properties).edgeStyle??"straight"),Qn(new Set),Nn(!0),Dn("allocation"),Bn("all");const n=(d=(l=x==null?void 0:x.properties)==null?void 0:l.styleHint)!=null&&d.startsWith("expanded:")?x.properties.styleHint.slice(9).split(",").map(F=>F.trim()).filter(Boolean):[];mo(new Set(n)),qo(null),Zo(((h=ce==null?void 0:ce.canvas)==null?void 0:h.portDisplay)??"all"),Jo(((f=ce==null?void 0:ce.canvas)==null?void 0:f.connectionDisplay)??"summary"),ss(!1),Wt(new Set),Qo(null),is("flat"),en(null),We.current.clear()},[a,(Ts=x==null?void 0:x.properties)==null?void 0:Ts.layoutHint,(Ls=x==null?void 0:x.properties)==null?void 0:Ls.styleHint,(Ns=ce==null?void 0:ce.canvas)==null?void 0:Ns.portDisplay,(Ds=ce==null?void 0:ce.canvas)==null?void 0:Ds.connectionDisplay]);const zi=u.useMemo(()=>({decompositionNode:Pl,interconnectionNode:$c,actionFlowNode:sl,actionFlowLane:nl,actionFlowLaneLabel:ol,stateNode:Uc,seqLifeline:Yc,seqSection:qc,seqOccurrence:Jc,useCase:Qc,useCaseActor:ed,useCaseBoundary:td,contextSystem:sd,contextExternal:rd,contextBoundary:id,diagramNode:ad,annotationNode:ku,decisionNode:pd,forkNode:hd,startEndNode:md}),[]),Mi=u.useMemo(()=>({interconnectionEdge:Vc,useCaseEdge:nd}),[]),Ti=u.useCallback(n=>{var l,d;return((l=n.data)==null?void 0:l.color)||((d=n.data)==null?void 0:d.layerColor)||"#ccc"},[]),Ee=u.useMemo(()=>{var S;const n=(x==null?void 0:x.viewpointId)==="__model"?null:(x==null?void 0:x.viewpointId)||c,l=n&&(t==null?void 0:t.viewpoints),d=p.size>0,h=(S=x==null?void 0:x.elementIds)!=null&&S.length?new Set(x.elementIds):void 0;if(!l&&!d&&!h)return;const f=l?t.viewpoints.find(I=>I.id===n):void 0,F=f?new Set(f.visibleKinds):void 0,y=f?new Set(f.visibleLayers):void 0;return I=>p.has(I.layer)?!1:h?h.has(I.id):((F==null?void 0:F.size)??0)>0||((y==null?void 0:y.size)??0)>0?!!(F!=null&&F.has(I.kind))||!!(y!=null&&y.has(I.layer)):!0},[c,x,t==null?void 0:t.viewpoints,p]),ls=u.useRef(null);u.useEffect(()=>{if(!t)return;const n=`${a??""}|${U??""}`;if(ls.current!==n){if(U==="statetransition"){if(yo.length===0)return;Ht(new Set(yo))}else U==="interconnection"&&Ot(new Set);ls.current=n}},[t,a,U,yo]);const wo=u.useMemo(()=>{if(!t||!x||x.diagramType!=="bdd")return null;const n=x.relationshipTypes??[];return n.length===0||n.every(d=>Do.has(d.charAt(0).toLowerCase()+d.slice(1)))?rl(Ys(t,Ee,x.relationshipTypes)):null},[t,x,Ee]),cs=u.useCallback(()=>{if(t)return dt?il(t):wt?Ys(t,Ee,x==null?void 0:x.relationshipTypes):al(t)},[t,dt,wt,Ee,x==null?void 0:x.relationshipTypes]),tn=u.useCallback(n=>{mo(l=>{const d=new Set(l);return d.has(n)?d.delete(n):d.add(n),d})},[]),ds=u.useCallback(n=>{Ot(l=>{const d=new Set(l);return d.has(n)?d.delete(n):d.add(n),d})},[]),us=u.useCallback(n=>{Wt(l=>{const d=new Set(l);return d.has(n)?d.delete(n):d.add(n),d})},[]),vo=u.useCallback(n=>{en(n),Ht(new Set),g(null)},[g]),ko=u.useCallback(n=>{Qo(n),Wt(new Set),g(null)},[g]),Fo=u.useCallback(n=>{qo(n),Ot(new Set),g(null)},[g]),ps=u.useCallback(n=>{Ht(l=>{const d=new Set(l);return d.has(n)?d.delete(n):d.add(n),d})},[]),hs=u.useCallback(n=>{We.current.clear(),ji(l=>{const d=new Map(l),h=d.get(n)||"vertical";return d.set(n,h==="vertical"?"horizontal":"vertical"),d})},[]),on=u.useCallback(()=>{const n=cs();if(!n)return;const l=new Set,d=h=>{l.add(h);for(const f of n.childrenMap.get(h)||[])n.elements.has(f)&&d(f)};for(const h of n.roots)n.elements.has(h)&&d(h);mo(l)},[cs]),nn=u.useCallback(()=>mo(new Set),[]),sn=u.useCallback(()=>{We.current.clear(),It(n=>n+1)},[]),Li=u.useCallback(()=>{if(!a)return;const n=ee.getState().diagramLayouts[a]??{},{pan:l,zoom:d,...h}=n.canvas??{},f={nodes:{},edges:{},canvas:{...h,autoLayout:!0}};J.current=null,w({[a]:f}),Le(a,f),We.current.clear(),It(F=>F+1),window.setTimeout(()=>Oe(300),250)},[a,w,Oe]),Ni=u.useCallback(()=>{if(!a)return;const n=ee.getState().diagramLayouts[a]??{},{pan:l,zoom:d,...h}=n.canvas??{},f={nodes:{},edges:{},canvas:{...h,autoLayout:!0}};J.current=null,w({[a]:f}),Le(a,f),We.current.clear(),It(F=>F+1),window.setTimeout(()=>Oe(300),250)},[a,w,Oe]),ms=u.useCallback(n=>n.map(l=>{if(l.type!=="diagramNode")return l;const d=t==null?void 0:t.elements[l.id];return{...l,data:{...l.data,onContextMenu:(h,f)=>{yt({x:h.clientX,y:h.clientY,nodeId:f,nodeKind:l.data.kind??""})},onInlineEdit:(h,f)=>{if(!d)return;const F={...d,name:f};Gs(F)}}}}),[t]),fs=u.useCallback((n,l)=>{const d=!Tl(l),h=new Map(n.map(B=>[B.id,B])),f=n.map(B=>{const G=l.nodes[B.id];if(!G)return B;const ze=B.parentId?h.get(B.parentId):void 0,$e=d&&B.type==="contextSystem"&&(ze==null?void 0:ze.type)==="contextBoundary"?Nl(G,ze.position):Dl(G,B.parentId??null,X=>{var pe;return(pe=h.get(X))==null?void 0:pe.position});return{...B,position:$e,...G.width?{width:G.width}:{},...G.height?{height:G.height}:{},...G.width||G.height?{style:{...B.style,...G.width?{width:G.width}:{},...G.height?{height:G.height}:{}}}:{},data:{...B.data,bgColor:G.color||void 0,...G.opacity!==void 0?{fillOpacity:G.opacity}:{},...G.borderColor!==void 0?{borderColor:G.borderColor||void 0}:{},...G.textColor!==void 0?{textColor:G.textColor||void 0}:{},...G.fontSize!==void 0?{fontSize:G.fontSize||void 0}:{},...G.fontWeight!==void 0?{fontWeight:G.fontWeight||void 0}:{},...G.textAlign!==void 0?{textAlign:G.textAlign}:{},...G.verticalAlign!==void 0?{verticalAlign:G.verticalAlign}:{},...G.ports?{ports:(B.data.ports??[]).map(X=>{var pe;return{...X,...((pe=G.ports)==null?void 0:pe[X.id])??{}}})}:{}}}}),F=new Map(f.map(B=>[B.id,B])),y=f.filter(B=>B.type==="actionFlowLane"),S=B=>(B.data.memberIds??[]).map(G=>F.get(G)).filter(Boolean),I=B=>B.position.x,Z=B=>B.position.y,Q=B=>{var G;return B.position.x+Number(B.width??((G=B.style)==null?void 0:G.width)??180)},de=B=>{var G;return B.position.y+Number(B.height??((G=B.style)==null?void 0:G.height)??96)},ge=y.flatMap(S),se=ge.length>0?{x:Math.min(...ge.map(I)),y:Math.min(...ge.map(Z))}:void 0,Re=ge.length>0?{x:Math.max(...ge.map(Q)),y:Math.max(...ge.map(de))}:void 0,Vt=new Map;return f.map(B=>{if(B.type!=="actionFlowLane")return B;const G=B.data,ze=S(B);if(ze.length===0||!se||!Re)return B;const $e=G.orientation==="column",X=$e?Math.min(...ze.map(I)):se.x,pe=$e?Math.max(...ze.map(Q)):Re.x,ht=$e?se.y:Math.min(...ze.map(Z)),Ws=$e?Re.y:Math.max(...ze.map(de)),Ye={position:{x:$e?X-36:X-120,y:$e?ht-32:ht-36},width:pe-X+($e?72:156),height:Ws-ht+($e?68:72)};return Vt.set(B.id,Ye),{...B,position:Ye.position,style:{...B.style,width:Ye.width,height:Ye.height}}}).map(B=>{if(B.type!=="actionFlowLaneLabel")return B;const G=Vt.get(B.id.replace("__lane_label_","__lane_"));return G?{...B,position:G.position,style:{...B.style,width:G.width,height:G.height}}:B})},[]),gs=u.useCallback((n,l,d,h)=>{var y;Ie.current=Date.now()+250,Fe(),je(S=>S+1);const f=ue.current.map(S=>{var ge,se;if(!(((ge=S.data)==null?void 0:ge.sourcePortId)===l||((se=S.data)==null?void 0:se.targetPortId)===l))return S;const{points:Z,manualRoute:Q,...de}=S.data??{};return{...S,data:de}});if(ue.current=f,h&&a){const S=ee.getState().diagramLayouts[a]??{nodes:{},edges:{}};w({[a]:{...S,canvas:{...S.canvas,autoLayout:!1,portWalls:{...(y=S.canvas)==null?void 0:y.portWalls,[l]:h}}}})}const F=ie.current.map(S=>S.id!==n?S:{...S,data:{...S.data,ports:(S.data.ports??[]).map(I=>I.id===l?{...I,y:d}:I)}});he(F)},[he,Fe,a,w]),xs=u.useCallback((n,l,d,h)=>{Ie.current=Date.now()+250,Fe(),je(F=>F+1);const f=ie.current.map(F=>{if(F.id!==n)return F;const y=F.data.ports??[],S=y.find(se=>se.id===l);if(!S)return F;const I=S.size??gt,Z=d-I,Q={...S,x:S.x+(h.includes("w")?-Z:h.includes("e")?0:-Z/2),y:S.y+(h.includes("n")?-Z:h.includes("s")?0:-Z/2),size:d},de=2;return y.some(se=>{if(se.id===l)return!1;const Re=se.size??gt;return Q.x<se.x+Re+de&&Q.x+d+de>se.x&&Q.y<se.y+Re+de&&Q.y+d+de>se.y})?F:{...F,data:{...F.data,ports:y.map(se=>se.id===l?Q:se)}}});he(f)},[he,Fe]),bs=u.useCallback((n,l)=>{Ie.current=Date.now()+250,Fe(),je(d=>d+1),H(d=>{const h=d.map(f=>f.id===n?{...f,data:{...f.data,points:l,manualRoute:!0}}:f);return ue.current=h,h})},[Fe,H]),ys=u.useCallback((n,l,d,h)=>{if(JSON.stringify(l)===JSON.stringify(d))return;const f=(F,y)=>{Fe(),je(S=>S+1),H(S=>{const I=S.map(Z=>{if(Z.id!==n)return Z;if(y)return{...Z,data:{...Z.data,points:F,manualRoute:!0}};const{points:Q,manualRoute:de,...ge}=Z.data??{};return{...Z,data:ge}});return ue.current=I,I}),he(ie.current)};ro({do:()=>f(d,!0),undo:()=>f(l,h)})},[Fe,ro,he,H]),Di=u.useCallback(async n=>{const l=be.current;if(l){$(!1),te(null),ye(n);try{await mu(l,n,x==null?void 0:x.name)}catch(d){te(d instanceof Error?d.message:String(d))}finally{ye(null)}}},[x==null?void 0:x.name]),Bi=u.useCallback(()=>{if(ue.current.some(d=>{var h;return(h=d.data)==null?void 0:h.manualRoute})&&!window.confirm("Re-route connectors? This replaces the hand-drawn bends on this diagram. Node positions will be kept."))return;Fe(),je(d=>d+1);const n=ue.current.map(d=>{var y;if(!((y=d.data)!=null&&y.manualRoute))return d;const{points:h,manualRoute:f,...F}=d.data;return{...d,data:F}}),l=xn(ie.current,n,"tidy");ue.current=l,H(l)},[Fe,H]);u.useEffect(()=>{if(!t)return;const n=we.current!==t&&fe.current===a;if(J.current=n?M():null,we.current=t,fe.current=a,U==="grid"||U==="browser"||U==="geometry")return;let l=!1;const d=({nodes:S,edges:I},Z=!0)=>{if(l)return;const Q=xl(S,I),de=new Map(Q.nodes.map(X=>[X.id,X])),ge=new Map(Q.edges.map(X=>[X.id,X])),se=S.map(X=>{const pe=de.get(X.id);return pe?{...X,position:{x:pe.x,y:pe.y},style:{...X.style,width:pe.width,height:pe.height},parentId:pe.parentId,...pe.parentId?{extent:"parent"}:{}}:X}),Re=I.filter(X=>ge.has(X.id)).map(X=>{const pe=ge.get(X.id);return{...X,source:pe.sourceId,target:pe.targetId,label:pe.label??X.label}}),Vt=se,Os=Re,B=a?ee.getState().diagramLayouts[a]:void 0,ze=[...B&&Object.keys(B.nodes).length>0?fs(Vt,B):Vt,...uo(B)],$e=Os.map(X=>{var _s,Hs,Vs;const pe=(_s=B==null?void 0:B.edges)==null?void 0:_s[X.id],ht=t.relationships.find(mt=>mt.id===X.id),Ye=!(pe!=null&&pe.source)||pe.source===X.source&&pe.target===X.target&&pe.sourcePortId===((Hs=X.data)==null?void 0:Hs.sourcePortId)&&pe.targetPortId===((Vs=X.data)==null?void 0:Vs.targetPortId)?pe==null?void 0:pe.points:void 0;return{...X,reconnectable:!!(ht!=null&&ht.sourceRange),data:{...X.data,...Ye!=null&&Ye.length?{points:Ye,manualRoute:!0}:{},flowAnimation:ao,onRouteChange:mt=>bs(X.id,mt),onRouteChangeComplete:(mt,Gt)=>{var Ut;return ys(X.id,mt,Gt,!!((Ut=X.data)!=null&&Ut.manualRoute))},onSelect:mt=>{mt.stopPropagation(),!(Date.now()<Ie.current)&&(H(Gt=>Gt.map(Ut=>({...Ut,selected:Ut.id===X.id}))),t.relationships.some(Gt=>Gt.id===X.id)&&j(X.id))}}}});T(Z?ms(ze):ze),H(xn(ze,$e)),qe(!1),li(X=>X+1)},h=S=>I=>{l||(console.error(`${S} layout error:`,I),qe(!1),Tn(`${S} layout could not be completed. Try resetting the layout or reducing the visible hierarchy.`))},f=(S,I,Z=!0)=>{qe(!0),Tn(null),vu(I,S).then(Q=>d(Q,Z)).catch(h(S))},F=()=>{const S=Ar.select({viewKind:U,diagramType:x==null?void 0:x.diagramType,isFBSDiagram:dt,isDecompDiagram:io,isGeneralTemplate:wt,generalMode:pt,layoutStyle:Pt}),I={onToggleExpand:tn,onToggleDirection:hs},Z={fbs:{expandedNodes:$t,nodeDirections:bo,callbacks:I,layoutProviderId:ut},decomposition:{expandedNodes:$t,nodeDirections:bo,callbacks:I,positionCache:We.current},containment:{expandedNodes:$t,callbacks:{onToggleExpand:tn}},useCase:{viewpointFilter:void 0,systemName:x==null?void 0:x.name,...x?dn(x.properties):{},level:Xo,edgeStyle:Yo,hiddenActorIds:Bt},context:{systemName:x==null?void 0:x.name,viewpointFilter:Ee,relationshipTypes:x==null?void 0:x.relationshipTypes},interconnection:{viewpointFilter:Ee,relationshipTypes:x==null?void 0:x.relationshipTypes,collapsedNodes:os,onDrillIn:Fo,onToggleCollapse:ds,focusId:fo??void 0,portDisplay:Ve,connectionDisplay:nt,showPortText:lo,showConnectionText:co,portWalls:Vn,legend:Dt,onPortMove:gs,onPortResize:xs,onPortSelect:de=>{j(null),g(de)},layoutProviderId:ut},actionflow:{viewpointFilter:Ee,swimlanes:Ze,laneGrouping:to,displayLevel:Rt,expandedActionIds:rs,onToggleAction:us,onDrillInAction:ko,focusActionId:vt??void 0,visibleFlowKinds:tt,direction:Je,nesting:_t,layoutProviderId:ut},statetransition:{viewpointFilter:Ee,collapsedStateIds:as,onToggleCollapse:ps,onDrillIn:vo,focusStateId:xo??void 0,layoutProviderId:ut},sequence:{viewpointFilter:Ee},general:{mode:pt,viewpointFilter:Ee,expandedNodes:$t,nodeDirections:bo,callbacks:I,positionCache:We.current,hierarchyRelationshipTypes:x==null?void 0:x.relationshipTypes,layoutProviderId:ut},standard:{viewpointFilter:Ee,relationshipTypes:x==null?void 0:x.relationshipTypes,compartments:wt,layoutProviderId:ut}},Q=S.compute(t,Z);Q instanceof Promise?f(S.descriptor.label,Q,S.descriptor.interactive):d(Q,S.descriptor.interactive)},y=window.setTimeout(F,wu);return()=>{l=!0,window.clearTimeout(y)}},[t,Ee,io,dt,Pt,U,wt,pt,Ze,di,x==null?void 0:x.relationshipTypes,x==null?void 0:x.diagramType,x==null?void 0:x.name,Xo,Yo,Bt,ut,$t,os,fo,Ve,nt,lo,co,Vn,Dt,rs,vt,tt,Je,to,Rt,_t,bo,as,xo,ps,vo,ko,tn,ds,us,hs,a,Fo,fs,ms,uo,gs,xs,bs,ys,g,j,M]),u.useEffect(()=>{if(Jt===0)return;const n=setTimeout(()=>{var h;const l=J.current;if(J.current=null,l){q(l);return}const d=a?(h=ee.getState().diagramLayouts[a])==null?void 0:h.canvas:void 0;U!=="actionflow"&&(d==null?void 0:d.zoom)!==void 0&&d.pan?q({x:d.pan.x,y:d.pan.y,zoom:d.zoom},{duration:300}):Oe(500)},200);return()=>clearTimeout(n)},[Jt,a,Oe,q,U]),u.useEffect(()=>{if(U!=="actionflow"||Jt===0)return;const n=requestAnimationFrame(()=>Oe(180));return()=>cancelAnimationFrame(n)},[Qe,et,Be,Oe,Ho,Jt,eo,U]),u.useEffect(()=>{T(n=>n.map(l=>{const d=l.type==="actionFlowLane"?l.data.inspectElementId:void 0,h=!!i&&(l.id===i||d===i);return{...l,selected:h,style:{...l.style,boxShadow:h?"0 0 0 2px #2DD4A8, 0 4px 12px rgba(45, 212, 168, 0.3)":void 0,opacity:i?h?1:.5:1}}}))},[i,T]),u.useEffect(()=>{if(!Tt||!t)return;const n=yl(t,Tt,"both",no),l=new Set(n.nodes.map(d=>d.elementId));l.add(Tt),T(d=>d.map(h=>({...h,style:{...h.style,opacity:l.has(h.id)?1:.08,pointerEvents:l.has(h.id)?"all":"none"}}))),H(d=>d.map(h=>({...h,style:{...h.style,opacity:l.has(h.source)&&l.has(h.target)?1:.05}})))},[Tt,no,t,T,H]),u.useEffect(()=>{if(!so)return;const n=setTimeout(()=>_n(null),2500);return()=>clearTimeout(n)},[so]);const So=u.useCallback(()=>{b(null),j(null),yt(null),Mt(null),T(n=>n.map(l=>({...l,selected:!1,style:{...l.style,opacity:1,boxShadow:void 0}}))),H(n=>n.map(l=>({...l,selected:!1})))},[b,j,T,H]),rn=u.useCallback(()=>{const n=Lt.current.pop();n&&(n.undo(),Go.current.push(n))},[]),an=u.useCallback(()=>{const n=Go.current.pop();n&&(n.do(),Lt.current.push(n))},[]);u.useEffect(()=>{const n=l=>{const d=l.target;d.tagName==="INPUT"||d.tagName==="TEXTAREA"||((l.metaKey||l.ctrlKey)&&l.key==="z"&&!l.shiftKey&&(l.preventDefault(),rn()),(l.metaKey||l.ctrlKey)&&(l.key==="Z"||l.key==="z"&&l.shiftKey)&&(l.preventDefault(),an()),l.key==="Escape"&&So(),l.key==="g"&&(l.metaKey||l.ctrlKey)&&l.shiftKey&&(l.preventDefault(),Ln(h=>!h)),l.key==="0"&&(l.metaKey||l.ctrlKey)&&(l.preventDefault(),Oe(400)))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[Oe,So,rn,an]);const Pi=u.useCallback(n=>{n.preventDefault(),n.dataTransfer.dropEffect="copy"},[]),$i=u.useCallback(n=>{n.preventDefault();const l=n.dataTransfer.getData(Zr);if(l)try{const d=JSON.parse(l),h=_({x:n.clientX,y:n.clientY});zt({x:n.clientX,y:n.clientY,flowX:h.x,flowY:h.y,kind:d.kind,layer:d.layer,construct:d.construct})}catch{}},[_]),Oi=u.useCallback(n=>{const l=_({x:n.clientX,y:n.clientY});zt({x:n.clientX,y:n.clientY,flowX:l.x,flowY:l.y})},[_]),Wi=u.useCallback(n=>{if(!Pe||!a){zt(null);return}const l=Pe.kind??"Part",d=Pe.layer??"logical",h=Pe.construct??"part",f=vn[d]??"#6B7280",F=wl(n,Object.keys((t==null?void 0:t.elements)??{})),y={id:F,type:"diagramNode",position:{x:Pe.flowX,y:Pe.flowY},data:{label:n,kind:l,layer:d,construct:h,color:f,isNew:!0,onContextMenu:(Q,de)=>{yt({x:Q.clientX,y:Q.clientY,nodeId:de,nodeKind:l})},onInlineEdit:(Q,de)=>{Gs({id:F,name:de,kind:l,construct:h,layer:d})}}};T(Q=>[...Q,y]),Ma({id:F,name:n,kind:l,construct:h,layer:d,attributes:{_layer:d}});const S=(x==null?void 0:x.elementIds)??[];W(a,[...S,F]);const I=a,Z={nodes:{...(m[I]??{}).nodes??{},[F]:{x:Pe.flowX,y:Pe.flowY}},edges:(m[I]??{}).edges??{}};w({[I]:Z}),Le(I,Z),zt(null)},[Pe,a,x,m,w,W,T]),_i=u.useCallback(()=>{yt(null),Mt(null)},[]),Hi=u.useCallback((n,l)=>{l!=null&&l.isValid},[]),kt=u.useCallback((n,l)=>{const d=ll(l);return(d?t==null?void 0:t.elements[d]:void 0)??(t==null?void 0:t.elements[n])},[t]),Vi=u.useCallback(n=>{const{source:l,target:d,sourceHandle:h,targetHandle:f}=n;if(!l||!d)return;const F=kt(l,h),y=kt(d,f);!F||!y||F.id!==y.id&&oo({x:window.innerWidth/2-130,y:window.innerHeight/2-160,sourceElement:F,targetElement:y})},[kt]),Gi=u.useCallback(async(n,l)=>{Ie.current=Date.now()+500;const d=t==null?void 0:t.relationships.find(y=>y.id===n.id);if(!(d!=null&&d.sourceRange)||!l.source||!l.target)return;const h=kt(l.source,l.sourceHandle),f=kt(l.target,l.targetHandle);if(!h||!f||h.id===f.id||h.id===d.sourceId&&f.id===d.targetId)return;const F=await Ta({relationshipId:d.id,sourceId:h.id,targetId:f.id,diagramId:a??void 0});F.success||console.warn(`[MEMO] Connector endpoint update rejected: ${F.error}`)},[t,kt,a]),Ui=u.useCallback(()=>{Ie.current=Date.now()+500,yt(null),Mt(null)},[]),Xi=u.useCallback(()=>{Ie.current=Date.now()+250},[]),Yi=u.useCallback(async n=>{if(!ot||!a){oo(null);return}const l=ot.sourceElement.id;oo(null);const d=await s({type:n.type,sourceId:n.sourceId,targetId:n.targetId,direction:n.direction,flowItem:n.flowItem,selectedElementId:l,diagramId:a});if(!d.success){console.warn(`[MEMO] Relationship rejected: ${d.error}`);return}if(!(ie.current.some(y=>y.id===n.sourceId)&&ie.current.some(y=>y.id===n.targetId)))return;const f=Us[n.type]??"#6B7280",F={id:d.relationshipId??`e_${n.sourceId}_${n.targetId}_${n.type}`,source:n.sourceId,target:n.targetId,label:n.type,type:"default",style:{stroke:f,strokeWidth:2},labelStyle:{fontSize:"10px",fill:"#374151"},labelBgStyle:{fill:"#FFFFFF",fillOpacity:.9},labelBgPadding:[4,2],labelBgBorderRadius:4,markerEnd:{type:"arrowclosed",color:f}};H(y=>va(F,y))},[ot,a,H,s]),Ki=u.useCallback((n,l)=>{ve.current={id:l.id,x:l.position.x,y:l.position.y}},[]),qi=u.useCallback((n,l)=>{const d=ve.current;if(ve.current=null,!((d==null?void 0:d.id)===l.id&&Math.hypot(l.position.x-d.x,l.position.y-d.y)>2)||(Ie.current=Date.now()+250,je(I=>I+1),!a))return;const{x:f,y:F}=l.position;if(l.type==="annotationNode")return;Fe();const y=ue.current.map(I=>{var ge;if(!((ge=I.data)!=null&&ge.manualRoute)||I.source!==l.id&&I.target!==l.id)return I;const{points:Z,manualRoute:Q,...de}=I.data;return{...I,data:de}});ue.current=y,he(ie.current);const S=We.current.get(l.id);if(We.current.set(l.id,{x:f,y:F}),k(a,l.id,{x:f,y:F}),S){const I=l.id,Z=a;ro({do:()=>k(Z,I,{x:f,y:F}),undo:()=>{k(Z,I,S),T(Q=>Q.map(de=>de.id===I?{...de,position:S}:de))}})}},[a,k,ro,T,Fe,he]),Zi=u.useCallback(n=>{const l=y=>{var S;return"id"in y&&((S=ie.current.find(I=>I.id===y.id))==null?void 0:S.type)==="annotationNode"};n.some(y=>y.type==="position"&&y.dragging&&!l(y))&&Fe();const d=n.some(y=>y.type==="dimensions"&&y.resizing),h=n.some(y=>y.type==="dimensions"&&y.setAttributes);(d||h)&&(Ie.current=Date.now()+250),d&&n.some(y=>y.type==="dimensions"&&y.resizing&&!l(y))&&Fe(),h&&je(y=>y+1);const f=new Map(n.flatMap(y=>y.type==="dimensions"&&y.dimensions?[[y.id,y.dimensions]]:[])),F=ka(n,ie.current).map(y=>{var ge,se;const S=f.get(y.id);if(!S)return y;const I=Number(y.width??((ge=y.style)==null?void 0:ge.width)??S.width),Z=Number(y.height??((se=y.style)==null?void 0:se.height)??S.height),Q=y.data.ports,de=Q==null?void 0:Q.map(Re=>({...Re,...Re.side==="right"?{x:Re.x+S.width-I}:{},...Re.side==="bottom"?{y:Re.y+S.height-Z}:{}}));return{...y,style:{...y.style,width:S.width,height:S.height},...de?{data:{...y.data,ports:de}}:{}}});he(F,!d||h)},[he,Fe]),Ji=u.useCallback((n,l)=>{},[]),Qi=u.useCallback((n,l)=>{n.preventDefault(),Mt({x:n.clientX,y:n.clientY,edgeId:l.id,relType:String(l.label??"edge")})},[]),ea=u.useCallback((n,l)=>{var f,F,y,S,I,Z;if(Date.now()<Ie.current)return;if((n==null?void 0:n.shiftKey)||(n==null?void 0:n.metaKey)||(n==null?void 0:n.ctrlKey)||((f=n==null?void 0:n.nativeEvent)==null?void 0:f.shiftKey)||((F=n==null?void 0:n.nativeEvent)==null?void 0:F.metaKey)||((y=n==null?void 0:n.nativeEvent)==null?void 0:y.ctrlKey)||((S=n==null?void 0:n.getModifierState)==null?void 0:S.call(n,"Shift"))||((I=n==null?void 0:n.getModifierState)==null?void 0:I.call(n,"Meta"))||((Z=n==null?void 0:n.getModifierState)==null?void 0:Z.call(n,"Control"))){window.setTimeout(()=>T(Q=>Q.map(de=>({...de,selected:de.selected||de.id===i||de.id===l.id}))),0);return}if(l.type==="annotationNode")return;const h=l.type==="actionFlowLane"?l.data.inspectElementId:void 0;!h&&(l.id.startsWith("__")||l.id.includes("__start")||l.id.includes("__done"))||(g(h??l.id),a&&O({type:"diagram",diagramId:a}))},[g,a,O,i,T]),ta=u.useCallback((n,l)=>{var d;if((d=n==null?void 0:n.stopPropagation)==null||d.call(n),U==="actionflow"){if(!Object.values((t==null?void 0:t.elements)??{}).some(f=>f.parentAction===l.id))return;ko(l.id);return}if(U==="statetransition"){const h=l.data;if(!h.hasChildren||h.isMachine){g(l.id);return}vo(l.id);return}if(U==="interconnection"){const h=l.data;if(!h.isContainer&&!h.hasChildren){g(l.id);return}Fo(l.id)}},[U,t==null?void 0:t.elements,g,ko,vo,Fo]),oa=So,na=u.useCallback((n,l)=>{var d;(d=n==null?void 0:n.stopPropagation)==null||d.call(n),!(Date.now()<Ie.current)&&(H(h=>h.map(f=>({...f,selected:f.id===l.id}))),t!=null&&t.relationships.some(h=>h.id===l.id)?j(l.id):t!=null&&t.elements[l.id]&&g(l.id))},[t,g,j,H]),sa=u.useCallback((n,l)=>{Kt({endpointIds:[l.id]})},[]),ra=u.useCallback((n,l)=>{Kt({edgeId:l.id,endpointIds:Er(l)})},[]),ws=u.useCallback(()=>Kt(null),[]),ia=u.useCallback((n,l)=>{var d;a&&(k(a,n,{...((d=m[a])==null?void 0:d.nodes[n])??{x:0,y:0},color:l||void 0}),T(h=>h.map(f=>f.id===n?{...f,data:{...f.data,bgColor:l||void 0}}:f)))},[a,m,k,T]),Te=u.useMemo(()=>v.filter(n=>n.selected&&n.type!=="actionFlowLane"&&!n.id.startsWith("__")),[v]),Ft=u.useCallback(()=>Te.map(n=>{var l,d,h,f;return{id:n.id,x:n.position.x,y:n.position.y,width:Number(n.width??((l=n.measured)==null?void 0:l.width)??((d=n.style)==null?void 0:d.width)??180),height:Number(n.height??((h=n.measured)==null?void 0:h.height)??((f=n.style)==null?void 0:f.height)??96)}}),[Te]),St=u.useCallback(n=>{n.size!==0&&(Fe(),T(l=>l.map(d=>{const h=n.get(d.id);return h?{...d,position:{x:h.x??d.position.x,y:h.y??d.position.y},...h.width!==void 0?{width:h.width}:{},...h.height!==void 0?{height:h.height}:{},...h.width!==void 0||h.height!==void 0?{style:{...d.style,...h.width!==void 0?{width:h.width}:{},...h.height!==void 0?{height:h.height}:{}}}:{}}:d})),je(l=>l+1))},[Fe,T]),aa=u.useCallback(n=>{St(Sl(Ft(),n))},[St,Ft]),la=u.useCallback(n=>{St(Cl(Ft(),n))},[St,Ft]),ca=u.useCallback(n=>{St(jl(Ft(),n))},[St,Ft]),vs=u.useCallback(n=>{if(!a||Te.length===0)return;Fe();const l=ee.getState().diagramLayouts[a];for(const h of Te){const f=(l==null?void 0:l.nodes[h.id])??{x:h.position.x,y:h.position.y};k(a,h.id,{...f,...n.color!==void 0?{color:n.color||void 0}:{},...n.opacity!==void 0?{opacity:n.opacity}:{},...n.borderColor!==void 0?{borderColor:n.borderColor||void 0}:{},...n.textColor!==void 0?{textColor:n.textColor||void 0}:{},...n.fontSize!==void 0?{fontSize:n.fontSize||void 0}:{},...n.fontWeight!==void 0?{fontWeight:n.fontWeight||void 0}:{},...n.textAlign!==void 0?{textAlign:n.textAlign}:{},...n.verticalAlign!==void 0?{verticalAlign:n.verticalAlign}:{}})}const d=new Set(Te.map(h=>h.id));T(h=>h.map(f=>d.has(f.id)?{...f,data:{...f.data,...n.color!==void 0?{bgColor:n.color||void 0}:{},...n.opacity!==void 0?{fillOpacity:n.opacity}:{},...n.borderColor!==void 0?{borderColor:n.borderColor||void 0}:{},...n.textColor!==void 0?{textColor:n.textColor||void 0}:{},...n.fontSize!==void 0?{fontSize:n.fontSize||void 0}:{},...n.fontWeight!==void 0?{fontWeight:n.fontWeight||void 0}:{},...n.textAlign!==void 0?{textAlign:n.textAlign}:{},...n.verticalAlign!==void 0?{verticalAlign:n.verticalAlign}:{}}}:f)),je(h=>h+1)},[a,Te,Fe,k,T]),ks=u.useMemo(()=>{const n=Te.map(l=>Number(l.data.fillOpacity??1));return n.length===0?1:n.every(l=>l===n[0])?n[0]:1},[Te]),Co=ee(n=>n.setSelectionStyle);u.useEffect(()=>{Co(Te.length>0?{count:Te.length,opacity:ks,apply:vs}:null)},[Te.length,ks,vs,Co]),u.useEffect(()=>()=>Co(null),[Co]);const Fs=u.useCallback(n=>{if(!a||!x)return;const l=(x.elementIds??[]).filter(d=>d!==n);W(a,l),T(d=>d.filter(h=>h.id!==n))},[a,x,W,T]),da=u.useCallback((n,l)=>{const d=l==="dashed"?"6 3":l==="dotted"?"2 3":void 0;H(h=>h.map(f=>f.id===n?{...f,style:{...f.style,strokeDasharray:d}}:f))},[H]),ua=u.useCallback((n,l)=>{H(d=>d.map(h=>h.id===n?{...h,style:{...h.style,stroke:l||(Us[String(h.label??"")]??"#6B7280")}}:h))},[H]),pa=u.useCallback(n=>{H(l=>l.map(d=>d.id===n?{...d,label:d.label?"":n.split("_")[3]??""}:d))},[H]);return x&&t&&U==="grid"?o.jsx(cl,{diagram:x,model:t,viewpointFilter:Ee}):x&&t&&U==="browser"?o.jsx(dl,{diagram:x,model:t,viewpointFilter:Ee}):x&&t&&U==="geometry"?o.jsx(bl,{diagram:x,model:t,viewpointFilter:Ee}):!x&&v.length===0&&!De?o.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!At&&o.jsx(fn,{collapsed:At,onToggleCollapse:()=>Qt(!0)}),At&&o.jsx(fn,{collapsed:!0,onToggleCollapse:()=>Qt(!1)}),o.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:o.jsxs("div",{className:"text-center",style:{maxWidth:"320px"},children:[o.jsx("div",{style:{fontSize:"40px",marginBottom:"16px",opacity:.4},children:"📊"}),o.jsx("h3",{style:{fontSize:Y.lg,fontWeight:600,color:"#374151",marginBottom:"8px"},children:"Select a Diagram"}),o.jsx("p",{style:{fontSize:Y.md,color:"#9CA3AF",lineHeight:1.6},children:"Choose a diagram from the sidebar or drag elements from the palette."})]})})]}):o.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[o.jsx(fn,{collapsed:At,onToggleCollapse:()=>Qt(!At),elementIds:x==null?void 0:x.elementIds,eligibleKinds:(Bs=x==null?void 0:x.elementKinds)!=null&&Bs.length?new Set(x.elementKinds):x!=null&&x.viewpointId&&(t!=null&&t.viewpoints)?new Set(((Ps=t.viewpoints.find(n=>n.id===x.viewpointId))==null?void 0:Ps.visibleKinds)??[]):void 0}),o.jsxs("div",{className:"flex-1 flex min-w-0",children:[!eo&&o.jsxs("aside",{"aria-label":"Diagram tools",className:"flex shrink-0 flex-col border-r",style:{width:126,background:"#FAFAF8",borderColor:"#E5E5E0"},children:[o.jsxs("div",{className:"flex items-center justify-between px-3 py-2",style:{background:"#F0F0ED",borderBottom:"1px solid #E5E5E0"},children:[o.jsx("span",{style:{fontSize:Y.xs,fontWeight:600,color:"#374151"},children:"Toolbar"}),o.jsx("button",{type:"button",onClick:()=>_o(!0),title:"Hide Toolbar","aria-label":"Hide Toolbar",style:{width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:5,cursor:"pointer",color:"#6B7280",fontSize:20,lineHeight:1},children:"×"})]}),x&&!Ho&&(eo?o.jsx("button",{type:"button",className:"m-3 flex items-center justify-center rounded-lg",onClick:()=>_o(!1),title:"Show diagram tools","aria-label":"Show diagram tools",style:{width:36,height:36,background:"#FFFFFF",color:"#1B3A4B",border:"1px solid #D8E0E4",boxShadow:"0 1px 4px rgba(0,0,0,0.10)"},children:o.jsx(V.lanes,{})}):o.jsxs("div",{className:"memo-diagram-tools memo-diagram-tools--left m-3 grid content-start items-stretch justify-items-stretch rounded-lg text-xs",style:{width:94,padding:6,gap:6,overflow:"visible",gridTemplateColumns:"repeat(2, 38px)",gridAutoRows:"min-content",gridAutoFlow:"row dense",background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},children:[Se("grid")&&o.jsx(ke,{icon:Vo?o.jsx(V.grid,{}):o.jsx(V.gridOff,{}),active:Vo,onClick:()=>{hi(n=>{const l=!n;return Ln(l),l})},title:"Show or hide the canvas grid and snapping (⌘⇧G)"}),Se("export")&&o.jsxs("div",{className:"memo-diagram-tools__document-action",style:{position:"relative"},children:[o.jsx(ke,{icon:o.jsx(V.download,{}),active:P,onClick:()=>{te(null),$(n=>!n)},title:"Download this diagram as an image"}),P&&o.jsx("div",{role:"menu","aria-label":"Export diagram",className:"absolute z-20 rounded-lg overflow-hidden",style:{top:"calc(100% + 6px)",left:0,minWidth:128,background:"#FFFFFF",border:"1px solid #E2E1DB",boxShadow:"0 4px 14px rgba(0,0,0,0.12)"},children:["png","svg","pdf"].map(n=>o.jsx("button",{role:"menuitem",onClick:()=>{Di(n)},disabled:le!==null,className:"w-full text-left px-3 py-1.5 text-xs font-medium",style:{background:"#FFFFFF",color:"#374151",border:0,cursor:le?"default":"pointer"},children:n.toUpperCase()},n))}),E&&o.jsxs("div",{role:"alert",className:"absolute z-20 rounded-lg px-3 py-1.5 text-xs",style:{top:"calc(100% + 6px)",left:0,minWidth:200,background:"#FEF2F2",color:"#B91C1C",border:"1px solid #FECACA"},children:["Export failed: ",E]})]}),o.jsx("div",{className:"memo-diagram-tools__layout-divider memo-diagram-tools__document-actions-divider","aria-hidden":"true"}),Se("route")&&o.jsx("div",{className:U==="interconnection"?"memo-diagram-tools__layout-reset":void 0,style:{display:"contents"},children:o.jsx(ke,{icon:o.jsx(V.tidy,{}),active:!1,onClick:Bi,title:"Layout: re-route connectors. Warns before replacing hand-drawn bends."})}),a&&Se("autoLayout")&&o.jsx("div",{className:U==="interconnection"?"memo-diagram-tools__layout-reset":void 0,style:{display:"contents"},children:o.jsx(ke,{icon:o.jsx(V.arrange,{}),active:Nt,onClick:()=>{if(Nt)Fe();else{if(!window.confirm("Recalculate the layout? This replaces saved manual positions and hand-routed connectors for this diagram."))return;const n=ee.getState().diagramLayouts[a],l={nodes:{},edges:{},canvas:{...n==null?void 0:n.canvas,autoLayout:!0}};w({[a]:l}),Le(a,l),It(d=>d+1)}},title:Nt?"Auto layout is on. Drag an item to preserve a manual layout.":"Layout: recalculate. Replaces saved manual positions after confirmation."})}),dt&&Se("expandCollapse")&&o.jsxs(o.Fragment,{children:[o.jsx(Ue,{hidden:Be==="left"}),o.jsx(_e,{icon:o.jsx(V.expand,{}),onClick:on,title:"Expand all nodes",ariaLabel:"Expand all"}),o.jsx(_e,{icon:o.jsx(V.collapse,{}),onClick:nn,title:"Collapse all nodes",ariaLabel:"Collapse all"})]}),U==="actionflow"&&Se("flowSwimlanes")&&o.jsxs(o.Fragment,{children:[o.jsx(ke,{icon:Ze?o.jsx(V.lanes,{}):o.jsx(V.lanesOff,{}),active:Ze,onClick:()=>Nn(n=>!n),title:"Toggle allocation swimlanes"}),Se("flowSwimlanes")&&Ze&&Si&&o.jsx(ke,{icon:o.jsx(V.lanes,{}),label:void 0,active:to==="stage",onClick:()=>Dn(n=>n==="stage"?"allocation":"stage"),title:"Group this flow by its modeled stages"}),Se("flowHierarchy")&&Ze&&to==="allocation"&&ts.length>0&&o.jsxs("div",{style:{position:"relative"},children:[o.jsx(ke,{icon:o.jsx(V.library,{}),active:Pn,onClick:()=>$n(n=>!n),title:`Responsibility hierarchy level: ${Rt==="all"?"all levels":`level ${Rt}`}`}),Pn&&o.jsx("div",{className:"absolute z-30 rounded-lg p-1",style:{top:"calc(100% + 5px)",left:0,width:112,background:"#FFFFFF",border:"1px solid #D1D5DB",boxShadow:"0 4px 14px rgba(0,0,0,0.12)"},children:["all",...ts].map(n=>{const l=Rt===n;return o.jsx("button",{type:"button",className:"w-full rounded px-2 py-1 text-left text-xs font-semibold",style:{background:l?"#E8FBF5":"transparent",color:l?"#0F766E":"#475569"},onClick:()=>{Bn(n),$n(!1)},children:n==="all"?"All levels":`Level ${n}`},String(n))})})]}),o.jsx(Ue,{hidden:Be==="left"}),Se("flowNesting")&&o.jsx(ke,{icon:_t==="flat"?o.jsx(V.split,{}):o.jsx(V.rectangle,{}),active:_t==="nested",onClick:()=>is(n=>n==="flat"?"nested":"flat"),title:_t==="flat"?"Steps: inline. Click to show nested steps.":"Steps: nested. Click to show inline steps."}),o.jsx(Ue,{hidden:Be==="left"}),Se("flowDirection")&&o.jsx(ke,{icon:Je==="horizontal"?o.jsx(V.arrowRight,{}):o.jsx(V.arrowDown,{}),active:Je==="vertical",onClick:()=>vi(Je==="horizontal"?"vertical":"horizontal"),title:Je==="horizontal"?"Flow direction: left to right. Click for top to bottom.":"Flow direction: top to bottom. Click for left to right."}),o.jsx(Ue,{hidden:Be==="left"}),Se("flowLegend")&&o.jsx(ke,{icon:o.jsx(V.lanes,{}),active:Qe,onClick:()=>fi(n=>!n),title:Qe?"Hide flow legend":"Show flow legend"}),Se("flowLegend")&&Qe&&o.jsx(ke,{icon:et==="overlay"?o.jsx(V.overlay,{}):o.jsx(V.arrowUp,{}),active:et==="above",onClick:()=>gi(n=>n==="overlay"?"above":"overlay"),title:et==="overlay"?"Legend over diagram. Click to place it above.":"Legend above diagram. Click to overlay it."}),o.jsx(Ue,{hidden:Be==="left"}),o.jsx(ke,{icon:o.jsx(V.expand,{}),title:"Expand all sub-actions",onClick:()=>Wt(new Set(Object.values((t==null?void 0:t.elements)??{}).map(n=>n.parentAction).filter(n=>!!n)))}),o.jsx(ke,{icon:o.jsx(V.collapse,{}),title:"Collapse all sub-actions",onClick:()=>Wt(new Set)}),o.jsx(Ue,{hidden:Be==="left"}),Se("flowFilters")&&o.jsxs("div",{style:{position:"relative"},children:[o.jsx(ke,{icon:o.jsx(V.filter,{}),active:On,badge:`${tt.size}/4`,fullWidth:!1,onClick:()=>xi(n=>!n),title:"Choose which modeled connection categories are visible"}),On&&o.jsxs("div",{className:"absolute p-3 rounded-lg",style:{width:264,top:0,left:"calc(100% + 8px)",background:"#FFFFFF",border:"1px solid #D1D5DB",boxShadow:"0 8px 24px rgba(0,0,0,0.14)",zIndex:30},children:[o.jsx("div",{style:{color:"#1F2937",fontWeight:700,fontSize:Y.xs},children:"Show connection categories"}),o.jsx("div",{style:{color:"#6B7280",fontSize:Y.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(n=>{const l=tt.has(n),d=n==="control"?"#4B5563":n==="data"?"#3498DB":n==="energy"?"#D97706":"#16A34A";return o.jsxs("button",{role:"switch","aria-checked":l,onClick:()=>bi(h=>{const f=new Set(h);return f.has(n)?f.delete(n):f.add(n),f}),className:"w-full flex items-center justify-between px-1 py-1.5 rounded",style:{color:"#374151",textTransform:"capitalize"},title:`${l?"Hide":"Show"} ${n} connections`,children:[o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:d}}),n]}),o.jsx("span",{"aria-hidden":"true",style:{width:32,height:18,borderRadius:9,background:l?"#2563EB":"#D1D5DB",padding:2,transition:"background 160ms ease"},children:o.jsx("span",{style:{display:"block",width:14,height:14,borderRadius:"50%",background:"#FFFFFF",boxShadow:"0 1px 2px rgba(0,0,0,0.22)",transform:l?"translateX(14px)":"translateX(0)",transition:"transform 160ms ease"}})})]},n)})]})]}),o.jsx(yn,{path:Ai,nameOf:n=>{var l;return((l=t==null?void 0:t.elements[n])==null?void 0:l.name)??n},onFocus:Qo,rootLabel:"Back to the whole action flow"})]}),U==="interconnection"&&Se("expandCollapse")&&o.jsxs(o.Fragment,{children:[o.jsx(Ue,{hidden:Be==="left"}),o.jsxs("div",{className:"memo-diagram-tools__layout-reset",style:{display:"contents"},children:[o.jsx(_e,{icon:o.jsx(V.expand,{}),onClick:()=>Ot(new Set),title:"Expand all parts",ariaLabel:"Expand all"}),o.jsx(_e,{icon:o.jsx(V.collapse,{}),onClick:()=>Ot(new Set(Ri)),title:"Collapse all parts",ariaLabel:"Collapse all"})]}),o.jsx("div",{className:"memo-diagram-tools__layout-divider memo-diagram-tools__layout-reset-divider","aria-hidden":"true"}),Se("interconnectionPorts")&&Se("interconnectionConnections")&&Be==="left"?o.jsxs(o.Fragment,{children:[o.jsx(ke,{icon:Ve==="all"?o.jsx(V.library,{}):Ve==="ports"?o.jsx(V.rectangle,{}):o.jsx(V.minus,{}),active:Ve!=="none",onClick:()=>Zo(n=>{const l=n==="all"?"ports":n==="ports"?"none":"all";return go({portDisplay:l}),l}),title:Ve==="all"?"Ports: nested. Click for top-level ports.":Ve==="ports"?"Ports: top-level only. Click to hide ports.":"Ports: hidden. Click to show nested ports."}),o.jsx(ke,{icon:nt==="summary"?o.jsx(V.tidy,{}):nt==="all"?o.jsx(V.lanes,{}):o.jsx(V.minus,{}),active:nt!=="none",onClick:()=>Jo(n=>{const l=n==="summary"?"all":n==="all"?"none":"summary";return go({connectionDisplay:l}),l}),title:nt==="summary"?"Connections: summary. Click to show all.":nt==="all"?"Connections: all. Click to hide them.":"Connections: hidden. Click for summary."})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"#9CA3AF",fontSize:Y.xs,fontWeight:600},children:"Ports"}),o.jsx(Ks,{value:Ve,onChange:n=>{Zo(n),go({portDisplay:n})},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"}]}),o.jsx("span",{style:{color:"#9CA3AF",fontSize:Y.xs,fontWeight:600},children:"Connections"}),o.jsx(Ks,{value:nt,onChange:n=>{Jo(n),go({connectionDisplay:n})},options:[{value:"summary",label:"Summary",title:"Show focused-subsystem boundary flows and bundle repeated rendered endpoint pairs"},{value:"all",label:"All",title:"Show every model connector"},{value:"none",label:"Off",title:"Hide connectors while inspecting block structure"}]})]}),o.jsx(yn,{path:Ei,nameOf:n=>{var l;return((l=t==null?void 0:t.elements[n])==null?void 0:l.name)??n},onFocus:qo,rootLabel:"Back to the whole diagram"})]}),U==="statetransition"&&Se("expandCollapse")&&o.jsxs(o.Fragment,{children:[o.jsx(Ue,{}),o.jsx(_e,{icon:o.jsx(V.expand,{}),onClick:()=>Ht(new Set),title:"Show all substates",ariaLabel:"Expand all substates"}),o.jsx(_e,{icon:o.jsx(V.collapse,{}),onClick:()=>Ht(new Set(yo)),title:"Fold every composite state",ariaLabel:"Collapse all substates"}),o.jsx(yn,{path:Ii,nameOf:n=>{var l;return((l=t==null?void 0:t.elements[n])==null?void 0:l.name)??n},onFocus:en,rootLabel:"Back to the whole machine"})]}),Kn&&Se("useCaseOptions")&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),o.jsxs("label",{className:"flex items-center gap-1 text-xs font-semibold",style:{color:"#475569"},children:["Level",o.jsxs("select",{"aria-label":"Use case hierarchy level",value:Xo,onChange:n=>Zn(n.target.value==="all"?"all":Number(n.target.value)),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{color:"#374151",background:"#FFFFFF",border:"1px solid #D1D5DB"},children:[o.jsx("option",{value:"all",children:"All levels"}),Array.from({length:ki+1},(n,l)=>o.jsxs("option",{value:l,children:["L",l]},l))]})]}),o.jsxs("label",{className:"flex items-center gap-1 text-xs font-semibold",style:{color:"#475569"},children:["Routing",o.jsxs("select",{"aria-label":"Use case connector routing",value:Yo,onChange:n=>Jn(n.target.value),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{color:"#374151",background:"#FFFFFF",border:"1px solid #D1D5DB"},children:[o.jsx("option",{value:"straight",children:"Straight"}),o.jsx("option",{value:"elbow",children:"Elbow"}),o.jsx("option",{value:"rounded",children:"Rounded"}),o.jsx("option",{value:"curved",children:"Curved"}),o.jsx("option",{value:"arc",children:"Arc"})]})]}),o.jsx("button",{onClick:Ni,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"}),es.length>0&&o.jsxs("details",{className:"relative",children:[o.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",Bt.size?`: ${Bt.size} hidden`:""]}),o.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:[o.jsx("div",{className:"mb-1 text-xs",style:{color:"#64748B"},children:"Hide related use cases"}),es.map(n=>o.jsxs("label",{className:"flex items-center gap-2 py-1 text-xs",style:{color:"#374151"},children:[o.jsx("input",{type:"checkbox",checked:Bt.has(n.id),onChange:()=>Qn(l=>{const d=new Set(l);return d.has(n.id)?d.delete(n.id):d.add(n.id),d})}),n.name]},n.id))]})]})]}),wt&&!Kn&&Se("generalMode")&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),o.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #E5E5E0"},children:Fi.map(n=>o.jsx("button",{onClick:()=>{qn(n),We.current.clear()},className:"px-2 py-0.5 text-xs font-medium capitalize",style:{background:pt===n?"#1B3A4B":"#FFFFFF",color:pt===n?"#FFFFFF":"#6B7280"},title:n==="graph"?"Relationship graph with compartments":n==="tree"?"Decomposition tree with expand/collapse":"Nested containment blocks",children:n==="graph"?o.jsx(V.tidy,{}):n==="tree"?o.jsx(V.library,{}):o.jsx(V.rectangle,{})},n))}),pt!=="graph"&&o.jsxs(o.Fragment,{children:[o.jsx(_e,{icon:o.jsx(V.expand,{}),onClick:on,title:"Expand all nodes",ariaLabel:"Expand all"}),o.jsx(_e,{icon:o.jsx(V.collapse,{}),onClick:nn,title:"Collapse all nodes",ariaLabel:"Collapse all"}),pt==="tree"&&o.jsx("button",{onClick:sn,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"})]})]}),io&&!dt&&Se("expandCollapse")&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),o.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #E5E5E0"},children:["containment","decomposition"].map(n=>o.jsx("button",{onClick:()=>{Ci(n),We.current.clear()},className:"px-2 py-0.5 text-xs font-medium",style:{background:Pt===n?"#1B3A4B":"#FFFFFF",color:Pt===n?"#FFFFFF":"#6B7280"},children:n==="containment"?o.jsx(V.rectangle,{}):o.jsx(V.library,{})},n))}),o.jsx(Ue,{}),o.jsx(_e,{icon:o.jsx(V.expand,{}),onClick:on,title:"Expand all nodes",ariaLabel:"Expand all"}),o.jsx(_e,{icon:o.jsx(V.collapse,{}),onClick:nn,title:"Collapse all nodes",ariaLabel:"Collapse all"}),Pt==="decomposition"&&o.jsx("button",{onClick:sn,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"})]}),a&&o.jsxs(o.Fragment,{children:[U!=="actionflow"&&Be!=="left",o.jsx("div",{id:"memo-diagram-editor-controls","data-compact-diagram-tools":"true",style:{display:"contents"}})]}),a&&U==="interconnection"&&o.jsxs(o.Fragment,{children:[Be!=="left",o.jsx(_e,{icon:o.jsx(V.plus,{}),onClick:()=>wi("note"),title:"Add an editable note",ariaLabel:"Add note"}),o.jsx(ke,{icon:o.jsx(V.arrowRight,{}),active:ao,onClick:()=>{const n=ee.getState().diagramLayouts[a]??{nodes:{},edges:{}},l={...n,canvas:{...n.canvas,flowAnimation:!ao}};w({[a]:l}),Le(a,l),H(d=>d.map(h=>({...h,data:{...h.data,flowAnimation:!ao}})))},title:"Toggle animated source-to-target flow"}),o.jsx(ke,{icon:o.jsx(V.library,{}),active:ns,onClick:()=>ss(n=>!n),title:"Show or hide the IBD notation legend"}),o.jsx(ke,{icon:o.jsx(V.elements,{}),active:lo,onClick:()=>{const n=ee.getState().diagramLayouts[a]??{nodes:{},edges:{}},l={...n,canvas:{...n.canvas,showPortText:!lo}};w({[a]:l}),Le(a,l)},title:"Show or hide port captions"}),o.jsx(ke,{icon:o.jsx(V.code,{}),active:co,onClick:()=>{const n=ee.getState().diagramLayouts[a]??{nodes:{},edges:{}},l={...n,canvas:{...n.canvas,showConnectionText:!co}};w({[a]:l}),Le(a,l)},title:"Show or hide connector labels"})]})]}))]}),o.jsxs("div",{ref:be,className:"flex-1 relative min-h-0",onDragOver:Pi,onDrop:$i,onDoubleClick:Oi,children:[Tt&&o.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:[o.jsx("span",{style:{color:"#2DD4A8",fontWeight:700},children:"◎ Focus"}),o.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Depth"}),[1,2,3].map(n=>o.jsx("button",{onClick:()=>yi(n),style:{width:20,height:20,borderRadius:4,cursor:"pointer",background:no===n?"#2DD4A8":"rgba(255,255,255,0.15)",color:no===n?"#1B3A4B":"#FFFFFF",fontWeight:700,fontSize:"11px",border:"none"},children:n},n)),o.jsx("button",{onClick:()=>{Wn(null),T(n=>n.map(l=>({...l,style:{...l.style,opacity:1,pointerEvents:"all"}}))),H(n=>n.map(l=>({...l,style:{...l.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"})]}),so&&o.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: ",so]}),De&&o.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…"}),ct&&!De&&o.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:Y.xs},children:[o.jsx("span",{children:ct}),o.jsx("button",{onClick:sn,style:{border:"1px solid #B58A12",borderRadius:3,background:"#FFFFFF",color:"#5F4300",padding:"3px 8px",fontWeight:700,whiteSpace:"nowrap"},children:"Retry"})]}),ho.length>0&&!De&&o.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:Y.xs},children:[o.jsx("span",{style:{fontWeight:700},children:"Diagram error:"})," ",ho.length," floating ",ho.length===1?"action has":"actions have"," no flow or succession connection:"," ",ho.map((n,l)=>o.jsxs("span",{children:[l>0&&", ",o.jsx("button",{onClick:()=>g(n.id),style:{color:"#991B1B",textDecoration:"underline",fontWeight:700},children:n.name})]},n.id))]}),wo&&!De&&o.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:Y.xs},children:[o.jsx("span",{style:{fontWeight:700},children:"BDD error:"})," ","expected one connected hierarchy, but found ",wo.rootIds.length," roots",wo.disconnectedIds.length>0&&o.jsxs(o.Fragment,{children:[" and ",wo.disconnectedIds.length," disconnected/floating elements"]}),"."]}),U==="actionflow"&&Qe&&o.jsxs("div",{"aria-label":"Action flow legend",className:"absolute z-10 flex flex-col gap-2 px-3 py-2.5",style:{top:et==="above"?8:12,right:12,minWidth:154,background:"rgba(255,255,255,0.96)",border:"1px solid #D1D5DB",borderRadius:12,color:"#374151",fontSize:Y.xs,boxShadow:"0 2px 8px rgba(31,41,55,0.10)"},children:[o.jsx("div",{className:"flex items-center gap-4",children:o.jsx("span",{style:{fontWeight:700},children:"Flow legend"})}),tt.has("control")&&o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{style:{width:24,height:0,borderTop:"2px solid #4B5563"}}),"Control flow"]}),tt.has("data")&&o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #3498DB"}}),"Object flow"]}),tt.has("energy")&&o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #D97706"}}),"Energy flow"]}),tt.has("material")&&o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #16A34A"}}),"Material flow"]})]}),U==="interconnection"&&v.length>0&&ns&&o.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:Y.xs},children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{style:{fontWeight:700},children:"Ports"}),Ve!=="none"?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(bn,{color:No.in,glyph:"→"})," in"]}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(bn,{color:No.out,glyph:"→"})," out"]}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(bn,{color:No.inout,glyph:"⇄"})," inout"]}),Ve==="all"&&o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx("span",{style:{width:9,height:9,borderRadius:2,flexShrink:0,background:"#6B728022",border:"1.5px solid #6B7280"}}),"nested"]})]}):o.jsx("span",{style:{color:"#9CA3AF"},children:"hidden"})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{style:{fontWeight:700},children:"Flow"}),["data","energy","material"].map(n=>o.jsxs("span",{className:"flex items-center gap-1.5",children:[o.jsx("span",{style:{width:20,height:0,borderTop:`2.5px solid ${ul[n]}`}}),n]},n))]}),Dt&&o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("span",{style:{fontWeight:700},children:Dt.name}),o.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[...Dt.colors.entries()].map(([n,l])=>o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx("span",{style:{width:11,height:11,borderRadius:2,background:l,border:"1px solid rgba(15,23,42,0.25)"}}),n]},n))})]})]}),!De&&v.length===0&&x&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",style:{zIndex:1},children:x.auto&&(($s=x.elementIds)==null?void 0:$s.length)===0?o.jsxs("div",{className:"text-center",style:{maxWidth:420},children:[o.jsx("div",{style:{fontSize:"32px",marginBottom:8},children:"🔍"}),o.jsx("div",{style:{fontSize:Y.sm,color:"#374151",fontWeight:600,marginBottom:4},children:"This view selects no elements"}),o.jsx("div",{style:{fontSize:Y.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 add an `expose` member for the elements you want visible."})]}):o.jsxs("div",{className:"text-center",style:{opacity:.4},children:[o.jsx("div",{style:{fontSize:"32px",marginBottom:8},children:"🖱️"}),o.jsx("div",{style:{fontSize:Y.sm,color:"#6B7280"},children:"Drag from palette or double-click to create elements"})]})}),Te.length>=1&&o.jsx(kl,{count:Te.length,onClose:So,onAlign:aa,onMatchSize:la,onDistribute:ca}),De&&o.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",zIndex:20,background:`linear-gradient(90deg, ${Xs.accent} 0%, ${Xs.accent}80 50%, transparent 100%)`,backgroundSize:"200% 100%",animation:"memo-layout-progress 1.2s linear infinite"}}),o.jsxs(Fa,{className:"memo-diagram-canvas",nodes:v,edges:xe,nodeTypes:zi,edgeTypes:Mi,onNodesChange:Zi,onEdgesChange:me,onNodeClick:ea,onNodeDoubleClick:ta,onEdgeClick:na,onPaneClick:oa,onNodeDragStart:Ki,onNodeDragStop:qi,onNodeContextMenu:Ji,onEdgeContextMenu:Qi,onNodeMouseEnter:sa,onNodeMouseLeave:ws,onEdgeMouseEnter:ra,onEdgeMouseLeave:ws,onConnect:Vi,onConnectStart:_i,onConnectEnd:Hi,onReconnect:Gi,onReconnectStart:Ui,onReconnectEnd:Xi,reconnectRadius:10,connectionMode:Sa.Loose,defaultEdgeOptions:{interactionWidth:24},snapToGrid:pi,snapGrid:bu,fitView:U!=="actionflow",fitViewOptions:{...fu,minZoom:po},minZoom:.1,maxZoom:3,zoomOnScroll:!0,panOnScroll:!0,panOnScrollMode:"free",selectionOnDrag:!0,panOnDrag:[1,2],multiSelectionKeyCode:["Shift","Meta","Control"],selectionKeyCode:null,proOptions:xu,style:U==="actionflow"?{...wr,position:"absolute",left:0,top:Qe&&et==="above"?112:0,right:0,bottom:0,width:"auto",height:"auto"}:wr,children:[Vo&&o.jsx(Ca,{color:"#C5C7C2",gap:20,size:1.5}),o.jsx(Rl,{}),o.jsxs(ja,{position:"bottom-right",showFitView:!1,style:{zIndex:6},children:[o.jsx(Xt,{title:"Reset this view to its default layout","aria-label":"Reset this view to its default layout",onClick:Li,children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),o.jsx("path",{d:"M3 3v5h5"})]})}),o.jsx(Xt,{title:"Undo last diagram edit (⌘Z)","aria-label":"Undo last diagram edit",onClick:rn,children:"↶"}),o.jsx(Xt,{title:"Redo last diagram edit (⌘⇧Z)","aria-label":"Redo last diagram edit",onClick:an,children:"↷"}),o.jsx(Xt,{title:"Fit diagram to view","aria-label":"Fit diagram to view",onClick:()=>Oe(250),children:o.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M8 3H3v5M16 3h5v5M21 16v5h-5M3 16v5h5"}),o.jsx("path",{d:"M3 8l5-5M21 8l-5-5M21 16l-5 5M3 16l5 5"})]})}),o.jsx(Xt,{title:"Toggle fullscreen canvas","aria-label":"Toggle fullscreen canvas",onClick:n=>{var d;const l=n.currentTarget.closest(".react-flow");l&&(document.fullscreenElement?document.exitFullscreen():(d=l.requestFullscreen)==null||d.call(l))},children:"⛶"})]}),v.length>20&&(Et?o.jsx(Ea,{position:"bottom-left",style:gu,nodeColor:Ti,maskColor:"rgba(247, 247, 245, 0.7)",onClick:void 0,pannable:!0,zoomable:!0}):null),v.length>20&&o.jsx("button",{type:"button",title:Et?"Hide the overview map":"Show the overview map","aria-label":Et?"Hide the overview map":"Show the overview map","aria-pressed":Et,onClick:()=>ci(n=>(localStorage.setItem("memo.minimap.open",String(!n)),!n)),style:{position:"absolute",left:"8px",bottom:"8px",zIndex:7,width:"22px",height:"22px",lineHeight:"20px",textAlign:"center",borderRadius:"4px",border:"1px solid #E5E5E1",background:"#FFFFFF",color:"#6B6B66",fontSize:"13px",cursor:"pointer"},children:Et?"–":"▢"})]})]})]}),Pe&&o.jsx(Su,{x:Pe.x,y:Pe.y,onConfirm:Wi,onCancel:()=>zt(null)}),ot&&o.jsx(pl,{x:ot.x,y:ot.y,sourceElement:ot.sourceElement,targetElement:ot.targetElement,registries:r,allowedTypes:x==null?void 0:x.relationshipTypes,onSelect:Yi,onCancel:()=>oo(null)}),Ae&&o.jsx(cd,{x:Ae.x,y:Ae.y,nodeId:Ae.nodeId,nodeKind:Ae.nodeKind,onClose:()=>yt(null),onEditName:()=>{T(n=>n.map(l=>l.id===Ae.nodeId?{...l,data:{...l.data,_triggerEdit:!0}}:l))},onChangeColor:n=>ia(Ae.nodeId,n),onRemoveFromDiagram:()=>Fs(Ae.nodeId),onDeleteFromModel:()=>{Fs(Ae.nodeId)},onShowProperties:()=>{b(Ae.nodeId)},onShowInCatalog:()=>{b(Ae.nodeId),C("catalog")},onFocusElement:()=>{Wn(Ae.nodeId)},onShowRelMatrix:()=>{O({type:"traceability"})},onOpenSource:()=>{const n=t==null?void 0:t.elements[Ae.nodeId];n!=null&&n.file&&(navigator.clipboard.writeText(n.file).catch(()=>{}),_n(n.file))},onViewKindInOntology:()=>{const n=Ae.nodeKind;let l=null,d=null;for(const h of N){for(const f of h.layers)if(f.kinds.some(F=>F.name===n)){l=h.name,d=f.id;break}if(l)break}l&&(D(n),L("ontologies"),C("ontology"),O({type:"ontology-detail",packageName:l,layerId:d??void 0}))}}),Xe&&o.jsx(ud,{x:Xe.x,y:Xe.y,edgeId:Xe.edgeId,relType:Xe.relType,onClose:()=>Mt(null),onChangeStyle:n=>da(Xe.edgeId,n),onChangeColor:n=>ua(Xe.edgeId,n),onToggleLabel:()=>pa(Xe.edgeId),onDelete:()=>H(n=>n.filter(l=>l.id!==Xe.edgeId))})]})}function Du(){return o.jsx(ga,{children:o.jsx(Cu,{})})}export{Du as DiagramCanvas};
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiagramCanvas-BmVByLcM.js","assets/reactflow-C9OlmOYw.js","assets/zustand-CrhqMOHB.js","assets/index-DEVvBtNh.js","assets/index-BVySIRo1.css","assets/notation-scene-HbscVJH5.js","assets/layout-providers-BSDYNZu0.js","assets/elk-6l8mIQnQ.js","assets/ExplorerTreeRow-DG8T31JS.js","assets/DiagramToolbarControls-XMGLx08e.js","assets/style-BZV40eAE.css","assets/MaxGraphCanvas-BJss9LYp.js","assets/SysmlCodeEditor-i0BHj3of.js","assets/SysmlCodeEditor-BwKcXIZw.css"])))=>i.map(i=>d[i]);
2
- var Se=Object.defineProperty;var Ee=(t,r,a)=>r in t?Se(t,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[r]=a;var U=(t,r,a)=>Ee(t,typeof r!="symbol"?r+"":r,a);import{_ as G,u as _,g as we,a as je,l as Re,s as Ce,b as ke,c as De,F as u,C as l,d as Ae,e as _e,L as Le,f as Te,h as $e}from"./index-DEVvBtNh.js";import{j as e,a as Me}from"./reactflow-C9OlmOYw.js";import{a as o}from"./zustand-CrhqMOHB.js";import{I as E}from"./DiagramToolbarControls-XMGLx08e.js";const Y="memo.renderer.reactflow";class Ne{constructor(){U(this,"providers",new Map);U(this,"components",new Map)}register(r){const a=this.providers.get(r.descriptor.id);if(a&&a!==r)throw new Error(`Renderer provider already registered: ${r.descriptor.id}`);this.providers.set(r.descriptor.id,r)}unregister(r){return this.components.delete(r),this.providers.delete(r)}get(r){return this.providers.get(r)}has(r){return this.providers.has(r)}list(r=[]){return[...this.providers.values()].map(a=>a.descriptor).filter(a=>r.every(s=>a.capabilities.includes(s))).sort((a,s)=>a.name.localeCompare(s.name))}loadComponent(r){const a=this.providers.get(r)??this.providers.get(Y);if(!a)throw new Error(`Renderer provider not found: ${r} (no default registered)`);const s=a.descriptor.id;let i=this.components.get(s);return i||(i=a.loadComponent(),this.components.set(s,i)),i}}const ze={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:()=>G(()=>import("./DiagramCanvas-BmVByLcM.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(t=>t.DiagramCanvas)},Ie={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:()=>G(()=>import("./MaxGraphCanvas-BJss9LYp.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8])).then(t=>t.MaxGraphCanvas)},B=new Ne;B.register(ze);B.register(Ie);const Be={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Oe="memo.diagram.renderer.v3",Pe="renderer",Ve="memo.renderer.",le=new Set;function W(t){const r=t==null?void 0:t.trim();if(r)return r.includes(".")?r:`${Ve}${r}`}function Ue(){if(!(typeof window>"u"))try{return W(new URLSearchParams(window.location.search).get(Pe))}catch{return}}function Ge(){if(!(typeof window>"u"))try{return W(window.localStorage.getItem(Oe))}catch{return}}function Ye(){try{const t=Be;return W(t==null?void 0:t.VITE_MEMO_DIAGRAM_RENDERER)}catch{return}}function ae(){return Ue()??Ge()??Ye()??Y}function We(t){return le.add(t),()=>le.delete(t)}function qe(){return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5",color:"#9CA3AF",fontSize:13},children:"Loading renderer…"})}function He(){const t=o.useSyncExternalStore(We,ae,ae),r=B.has(t)?t:Y,a=o.useMemo(()=>o.lazy(()=>B.loadComponent(r).then(s=>({default:s}))),[r]);return e.jsx("div",{className:"relative flex flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(qe,{}),children:e.jsx(a,{})})})}const Ke={error:{badge:"#7F1D1D",border:"#EF4444",text:"#FEE2E2",mark:"#FCA5A5"},warning:{badge:"#78350F",border:"#F59E0B",text:"#FEF3C7",mark:"#FCD34D"}};function ce({messages:t,severity:r="error",title:a}){const[s,i]=o.useState(!1),f=o.useRef(null),h=Ke[r];if(o.useEffect(()=>{if(!s)return;const p=c=>{var m;(m=f.current)!=null&&m.contains(c.target)||i(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[s]),t.length===0)return null;const S=`${t.length} ${r}${t.length===1?"":"s"} — click for detail`;return e.jsxs("div",{ref:f,style:{position:"relative",display:"flex",alignItems:"center"},children:[e.jsxs("button",{type:"button",role:"status","aria-live":"polite","aria-expanded":s,"aria-label":S,title:S,onClick:()=>i(p=>!p),style:{display:"flex",alignItems:"center",gap:5,background:h.badge,border:`1px solid ${h.border}`,borderRadius:999,padding:"2px 9px",color:h.text,cursor:"pointer",fontSize:"11px",fontWeight:700,lineHeight:1.6},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:h.mark,strokeWidth:"2"}),e.jsx("path",{d:"M12 7v6",stroke:h.mark,strokeWidth:"2",strokeLinecap:"round"}),e.jsx("circle",{cx:"12",cy:"16.5",r:"1.1",fill:h.mark})]}),t.length]}),s&&e.jsxs("div",{role:"dialog","aria-label":a,style:{position:"absolute",bottom:"calc(100% + 8px)",right:0,zIndex:9100,width:"min(560px, calc(100vw - 48px))",maxHeight:"40vh",overflowY:"auto",background:"#1E293B",border:`1px solid ${h.border}`,borderRadius:10,padding:"11px 14px",boxShadow:"0 12px 32px rgba(0,0,0,0.35)"},children:[e.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:h.mark,marginBottom:6},children:a}),t.map((p,c)=>e.jsx("div",{style:{fontSize:"0.7rem",color:"#CBD5E1",fontFamily:"monospace",lineHeight:1.55},children:p},`${c}:${p}`))]})]})}const Qe=o.lazy(()=>G(()=>import("./SysmlCodeEditor-i0BHj3of.js"),__vite__mapDeps([12,1,2,13])).then(t=>({default:t.SysmlCodeEditor})));function Xe(t,r){const a=(t.elementIds??[]).map(s=>r[s]).filter(Boolean).map(s=>` ${s.construct??"part"} ${s.id} : ${s.kind};`).join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiagramCanvas-wDamEqea.js","assets/reactflow-C9OlmOYw.js","assets/zustand-CrhqMOHB.js","assets/index-BYfHEpXT.js","assets/index-X7EXuNCl.css","assets/notation-scene-BLpi6R_E.js","assets/layout-providers-BSDYNZu0.js","assets/elk-6l8mIQnQ.js","assets/ExplorerTreeRow-CX2kYnaJ.js","assets/DiagramToolbarControls-XMGLx08e.js","assets/style-BZV40eAE.css","assets/MaxGraphCanvas-zFgc11zx.js","assets/SysmlCodeEditor-i0BHj3of.js","assets/SysmlCodeEditor-BwKcXIZw.css"])))=>i.map(i=>d[i]);
2
+ var Se=Object.defineProperty;var Ee=(t,r,a)=>r in t?Se(t,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[r]=a;var U=(t,r,a)=>Ee(t,typeof r!="symbol"?r+"":r,a);import{_ as G,u as _,g as we,a as je,l as Re,s as Ce,b as ke,c as De,F as u,C as l,d as Ae,e as _e,L as Le,f as Te,h as $e}from"./index-BYfHEpXT.js";import{j as e,a as Me}from"./reactflow-C9OlmOYw.js";import{a as o}from"./zustand-CrhqMOHB.js";import{I as E}from"./DiagramToolbarControls-XMGLx08e.js";const Y="memo.renderer.reactflow";class Ne{constructor(){U(this,"providers",new Map);U(this,"components",new Map)}register(r){const a=this.providers.get(r.descriptor.id);if(a&&a!==r)throw new Error(`Renderer provider already registered: ${r.descriptor.id}`);this.providers.set(r.descriptor.id,r)}unregister(r){return this.components.delete(r),this.providers.delete(r)}get(r){return this.providers.get(r)}has(r){return this.providers.has(r)}list(r=[]){return[...this.providers.values()].map(a=>a.descriptor).filter(a=>r.every(s=>a.capabilities.includes(s))).sort((a,s)=>a.name.localeCompare(s.name))}loadComponent(r){const a=this.providers.get(r)??this.providers.get(Y);if(!a)throw new Error(`Renderer provider not found: ${r} (no default registered)`);const s=a.descriptor.id;let i=this.components.get(s);return i||(i=a.loadComponent(),this.components.set(s,i)),i}}const ze={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:()=>G(()=>import("./DiagramCanvas-wDamEqea.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(t=>t.DiagramCanvas)},Ie={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:()=>G(()=>import("./MaxGraphCanvas-zFgc11zx.js"),__vite__mapDeps([11,1,2,3,4,5,6,7,8])).then(t=>t.MaxGraphCanvas)},B=new Ne;B.register(ze);B.register(Ie);const Be={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Oe="memo.diagram.renderer.v3",Pe="renderer",Ve="memo.renderer.",le=new Set;function W(t){const r=t==null?void 0:t.trim();if(r)return r.includes(".")?r:`${Ve}${r}`}function Ue(){if(!(typeof window>"u"))try{return W(new URLSearchParams(window.location.search).get(Pe))}catch{return}}function Ge(){if(!(typeof window>"u"))try{return W(window.localStorage.getItem(Oe))}catch{return}}function Ye(){try{const t=Be;return W(t==null?void 0:t.VITE_MEMO_DIAGRAM_RENDERER)}catch{return}}function ae(){return Ue()??Ge()??Ye()??Y}function We(t){return le.add(t),()=>le.delete(t)}function qe(){return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5",color:"#9CA3AF",fontSize:13},children:"Loading renderer…"})}function He(){const t=o.useSyncExternalStore(We,ae,ae),r=B.has(t)?t:Y,a=o.useMemo(()=>o.lazy(()=>B.loadComponent(r).then(s=>({default:s}))),[r]);return e.jsx("div",{className:"relative flex flex-1 overflow-hidden",children:e.jsx(o.Suspense,{fallback:e.jsx(qe,{}),children:e.jsx(a,{})})})}const Ke={error:{badge:"#7F1D1D",border:"#EF4444",text:"#FEE2E2",mark:"#FCA5A5"},warning:{badge:"#78350F",border:"#F59E0B",text:"#FEF3C7",mark:"#FCD34D"}};function ce({messages:t,severity:r="error",title:a}){const[s,i]=o.useState(!1),f=o.useRef(null),h=Ke[r];if(o.useEffect(()=>{if(!s)return;const p=c=>{var m;(m=f.current)!=null&&m.contains(c.target)||i(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[s]),t.length===0)return null;const S=`${t.length} ${r}${t.length===1?"":"s"} — click for detail`;return e.jsxs("div",{ref:f,style:{position:"relative",display:"flex",alignItems:"center"},children:[e.jsxs("button",{type:"button",role:"status","aria-live":"polite","aria-expanded":s,"aria-label":S,title:S,onClick:()=>i(p=>!p),style:{display:"flex",alignItems:"center",gap:5,background:h.badge,border:`1px solid ${h.border}`,borderRadius:999,padding:"2px 9px",color:h.text,cursor:"pointer",fontSize:"11px",fontWeight:700,lineHeight:1.6},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:h.mark,strokeWidth:"2"}),e.jsx("path",{d:"M12 7v6",stroke:h.mark,strokeWidth:"2",strokeLinecap:"round"}),e.jsx("circle",{cx:"12",cy:"16.5",r:"1.1",fill:h.mark})]}),t.length]}),s&&e.jsxs("div",{role:"dialog","aria-label":a,style:{position:"absolute",bottom:"calc(100% + 8px)",right:0,zIndex:9100,width:"min(560px, calc(100vw - 48px))",maxHeight:"40vh",overflowY:"auto",background:"#1E293B",border:`1px solid ${h.border}`,borderRadius:10,padding:"11px 14px",boxShadow:"0 12px 32px rgba(0,0,0,0.35)"},children:[e.jsx("div",{style:{fontSize:"0.8rem",fontWeight:600,color:h.mark,marginBottom:6},children:a}),t.map((p,c)=>e.jsx("div",{style:{fontSize:"0.7rem",color:"#CBD5E1",fontFamily:"monospace",lineHeight:1.55},children:p},`${c}:${p}`))]})]})}const Qe=o.lazy(()=>G(()=>import("./SysmlCodeEditor-i0BHj3of.js"),__vite__mapDeps([12,1,2,13])).then(t=>({default:t.SysmlCodeEditor})));function Xe(t,r){const a=(t.elementIds??[]).map(s=>r[s]).filter(Boolean).map(s=>` ${s.construct??"part"} ${s.id} : ${s.kind};`).join(`
3
3
  `);return[`package '${t.name}' {`,` // Diagram: ${t.diagramType.toUpperCase()} | Viewpoint: ${t.viewpointId}`,a||" // No elements selected","}"].join(`
4
4
  `)}function Je({diagram:t}){const r=_(c=>c.model),a=_(c=>c.updateDiagramElementIds),[s,i]=o.useState(""),f=o.useMemo(()=>_e(r),[r]),h=o.useCallback(c=>{const m=new Set(t.elementIds??[]);m.has(c)?m.delete(c):m.add(c),a(t.id,[...m])},[t.id,t.elementIds,a]),S=o.useMemo(()=>new Set(t.elementIds??[]),[t.elementIds]),p=Le.filter(c=>f.has(c));return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",style:{width:"220px",borderLeft:`1px solid ${l.border}`,background:"#FAFAF8",flexShrink:0},children:[e.jsxs("div",{className:"px-2 py-1.5",style:{borderBottom:`1px solid ${l.border}`},children:[e.jsxs("div",{className:"font-semibold mb-1",style:{color:l.primary,fontSize:u.xs},children:["Elements (",S.size," selected)"]}),e.jsx("input",{value:s,onChange:c=>i(c.target.value),placeholder:"Filter…",className:"w-full px-2 py-1 rounded focus:outline-none",style:{background:"#F0F0ED",border:`1px solid ${l.border}`,color:l.primary,fontSize:u.xs}})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:p.map(c=>{const m=(f.get(c)??[]).filter(g=>!s||g.name.toLowerCase().includes(s.toLowerCase())||g.id.toLowerCase().includes(s.toLowerCase()));if(m.length===0)return null;const O=$e[c]??l.muted;return e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1 font-semibold",style:{color:O,fontSize:u.badge},children:Te[c]??c}),m.map(g=>e.jsxs("label",{className:"flex items-center gap-2 px-3 py-0.5 cursor-pointer",style:{fontSize:u.xs},onMouseEnter:b=>b.currentTarget.style.background="#F0F0ED",onMouseLeave:b=>b.currentTarget.style.background="transparent",children:[e.jsx("input",{type:"checkbox",checked:S.has(g.id),onChange:()=>h(g.id),style:{accentColor:l.accent}}),e.jsx("span",{className:"truncate",style:{color:l.primary},title:g.id,children:g.name||g.id})]},g.id))]},c)})})]})}function de({tone:t,message:r,actions:a}){const s=t==="conflict";return e.jsxs("div",{role:"alert",className:"flex items-center gap-2 px-3 py-1.5 flex-wrap",style:{background:s?"#FEF2F2":"#FFFBEB",borderBottom:`1px solid ${s?"#FECACA":"#FDE68A"}`,color:s?"#B91C1C":"#92400E",fontSize:u.xs,flexShrink:0},children:[e.jsx("span",{className:"flex-1",style:{minWidth:180},children:r}),a.map(i=>e.jsx("button",{onClick:i.onClick,title:i.hint,style:{fontSize:u.xs,padding:"2px 8px",borderRadius:5,cursor:"pointer",background:"#FFFFFF",border:`1px solid ${s?"#FECACA":"#FDE68A"}`,color:"inherit",fontWeight:600,whiteSpace:"nowrap"},children:i.label},i.label))]})}const Ze=4e3;function et({at:t}){const[r,a]=o.useState(!1);return o.useEffect(()=>{if(!t)return;a(!0);const s=setTimeout(()=>a(!1),Ze);return()=>clearTimeout(s)},[t]),r?e.jsx("span",{title:"A source file this view depends on changed; the view was rebuilt",style:{fontSize:u.badge,padding:"1px 6px",borderRadius:999,background:"#ECFDF5",color:"#047857",border:"1px solid #A7F3D0",whiteSpace:"nowrap"},children:"↻ Refreshed from source"}):null}const tt=[];function lt({diagramId:t}){const r=_(n=>n.model),a=_(n=>n.diagramParseErrors[t]??tt),s=_(n=>n.lastSourceChange),i=we(r,t),[f,h]=o.useState("visual"),[S,p]=o.useState(""),[c,m]=o.useState(!1),[O,g]=o.useState(!1),[b,q]=o.useState(!1),[x,L]=o.useState(!1),[k,w]=o.useState(null),[ue,H]=o.useState(null),[T,D]=o.useState(null),[$,M]=o.useState(null),[fe,he]=o.useState(null),[xe,K]=o.useState([]),[v,Q]=o.useState(()=>localStorage.getItem("memo.diagramEditor.autoSave")==="true"),[j,pe]=o.useState(null),R=o.useRef(),F=o.useRef(""),X=o.useRef(0),A=o.useRef(void 0),N=o.useRef(0),J=o.useRef(!1);o.useEffect(()=>{J.current=x},[x]),o.useEffect(()=>{const n=()=>pe(document.getElementById("memo-diagram-editor-controls"));n();const y=new MutationObserver(n);return y.observe(document.body,{childList:!0,subtree:!0}),()=>y.disconnect()},[]);const Z=o.useMemo(()=>je(r,t),[r,t]),z=o.useCallback(async()=>{const n=++N.current,y=t;m(!0);try{const d=await Re(y);if(N.current!==n)return!1;const ie=d.text??"";return F.current=ie,A.current=d.revision,p(ie),g(!0),L(!1),w(null),M(null),D(null),!0}catch(d){return N.current===n&&w(d instanceof Error?d.message:String(d)),!1}finally{N.current===n&&m(!1)}},[t]);o.useEffect(()=>{if(clearTimeout(R.current),w(null),H(null),L(!1),D(null),M(null),K([]),A.current=void 0,!(!i||!r)){if(!i.sourceFile||window.__MEMO_DATA__){const n=Xe(i,r.elements);F.current=n,p(n),m(!1),g(!1);return}p(""),F.current="",g(!1),z()}},[t,i==null?void 0:i.sourceFile]),o.useEffect(()=>{if(!s||!(i!=null&&i.sourceFile)||window.__MEMO_DATA__||!Ce(s,Z))return;he(s.at);const n=s.files.includes(i.sourceFile);if(n){if(J.current){D({files:s.files.filter(y=>Z.includes(y)),at:s.at,touchesOwnSource:n});return}z()}},[s==null?void 0:s.seq]);const me=n=>{F.current=n,p(n),L(!0),w(null)},I=o.useCallback(async n=>{if(!i)return;const y=++X.current;q(!0),w(null);try{if(i.sourceFile){if(!A.current)throw new Error("Reload the source before saving this edit.");const d=await ke(t,n,A.current);if(d.conflict){M({theirs:d.text??"",revision:d.revision,at:Date.now()}),w(d.error??"The file changed on disk since this edit began.");return}A.current=d.revision,M(null),D(null),K(d.parseErrors??[])}else De(t,n);F.current===n&&L(!1),H(Date.now())}catch(d){w(d instanceof Error?d.message:String(d))}finally{X.current===y&&q(!1)}},[i,t]),ee=o.useCallback(()=>{clearTimeout(R.current),z()},[z]),ge=o.useCallback(()=>{navigator.clipboard.writeText(F.current)},[]),be=o.useCallback(()=>{const n=new Blob([F.current],{type:"text/plain;charset=utf-8"}),y=URL.createObjectURL(n),d=document.createElement("a");d.href=y,d.download=`${t}-rejected.sysml`,d.click(),URL.revokeObjectURL(y)},[t]);o.useEffect(()=>(localStorage.setItem("memo.diagramEditor.autoSave",String(v)),clearTimeout(R.current),v&&x&&!c&&!$&&(R.current=setTimeout(()=>void I(F.current),800)),()=>clearTimeout(R.current)),[v,x,c,S,I,$]);const P=o.useCallback(()=>{clearTimeout(R.current),I(F.current)},[I]),ve=o.useMemo(()=>Object.values((r==null?void 0:r.elements)??{}).map(n=>({id:n.id,name:n.name,kind:n.kind})),[r==null?void 0:r.elements]);if(!i)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:l.faint,fontSize:u.sm},children:"Diagram not found"});const te=i.auto,C=!te||!!i.sourceFile&&O,re=e.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden",children:[$&&e.jsx(de,{tone:"conflict",message:`${i.sourceFile} changed on disk. Your rejected edit remains in this buffer and was not written.`,actions:[{label:"Copy draft",onClick:ge,hint:"Copy the rejected SysML edit"},{label:"Download rejected edit",onClick:be,hint:"Export the rejected SysML edit"},{label:"Reveal file",onClick:()=>Ae(i.sourceFile),hint:"Open the changed source file"},{label:"Reload from disk",onClick:ee,hint:"Discard the draft and load current disk content"}]}),!$&&T&&e.jsx(de,{tone:"notice",message:T.files.length>1?`${T.files.length} source files changed on disk. Your unsaved edits are untouched.`:`${T.files[0]} changed on disk. Your unsaved edits are untouched.`,actions:[{label:"Reload from disk",onClick:ee,hint:"Discards your unsaved edits"},{label:"Keep editing",onClick:()=>D(null),hint:"Dismiss until the next change"}]}),e.jsx("div",{className:"flex-1 overflow-hidden",style:{background:"#1E1E1E"},children:e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"h-full flex items-center justify-center",style:{color:"#9CA3AF",fontSize:u.xs},children:"Loading SysML editor…"}),children:e.jsx(Qe,{value:S,sourceFile:i.sourceFile,readOnly:!C||c,symbols:ve,onChange:me,onSave:()=>{C&&x&&P()}})})}),k&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C0A0A",color:"#FCA5A5",borderTop:"1px solid #3B0A0A"},children:k}),!C&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#F9F9F8",color:l.faint,borderTop:`1px solid ${l.border}`},children:i.sourceFile&&window.__MEMO_DATA__?"Static build — run memo-architect dev to edit the SysML source":i.sourceFile?"The SysML source could not be loaded":"Generated model view — no editable SysML source file"})]}),oe=e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:e.jsx(He,{})}),!te&&e.jsx(Je,{diagram:i})]}),se=(j==null?void 0:j.dataset.compactDiagramTools)==="true",ne={visual:"split",split:"text",text:"visual"},V={visual:"Visual",split:"Both",text:"Text"},ye=f==="visual"?e.jsx(E.eye,{}):f==="split"?e.jsx(E.split,{}):e.jsx(E.code,{}),Fe=j?e.jsxs(e.Fragment,{children:[C&&e.jsx("button",{type:"button","aria-label":`Auto-save ${v?"on":"off"}`,"aria-pressed":v,onClick:()=>Q(n=>!n),title:`Auto-save ${v?"on":"off"}. Click to turn it ${v?"off":"on"}.`,style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",padding:0,borderRadius:5,border:`1px solid ${v?"#A7F3D0":l.border}`,cursor:"pointer",background:v?"#ECFDF5":"#FFFFFF",color:v?"#047857":l.secondary},children:e.jsx(E.clock,{})}),C&&e.jsx("button",{"aria-label":"Save SysML",onClick:P,disabled:!x||b||c,title:"Save SysML (Ctrl/Cmd+S)",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",padding:0,borderRadius:5,border:`1px solid ${l.border}`,cursor:!x||b||c?"default":"pointer",background:x?l.accent:"#F0F0ED",color:x?"#FFFFFF":l.faint},children:e.jsx(E.save,{})}),se?e.jsx("button",{type:"button","aria-label":`Editor mode: ${V[f]}`,title:`Editor mode: ${V[f]}. Click to switch to ${V[ne[f]]}.`,onClick:()=>h(ne[f]),style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",borderRadius:5,border:"1px solid #1B3A4B",cursor:"pointer",background:"#1B3A4B",color:"#FFFFFF"},children:ye}):e.jsxs("select",{"aria-label":"Diagram editor view",title:"Choose editor view",value:f,onChange:n=>h(n.target.value),style:{fontSize:u.xs,height:28,padding:"0 6px",borderRadius:5,border:`1px solid ${l.border}`,background:"#FFFFFF",color:l.primary},children:[e.jsx("option",{value:"visual",children:"Visual"}),e.jsx("option",{value:"split",children:"Both"}),e.jsx("option",{value:"text",children:"Text"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(et,{at:fe}),c&&e.jsx("span",{style:{color:l.faint,fontSize:u.xs},children:"Loading source…"}),b&&e.jsx("span",{style:{color:l.faint,fontSize:u.xs},children:"Saving…"}),!b&&k&&e.jsx("span",{title:k,style:{color:"#EF4444",fontSize:u.xs},children:"Save failed"}),!b&&!k&&x&&e.jsx("span",{style:{color:"#B45309",fontSize:u.xs},children:"Unsaved"}),!b&&!x&&ue&&e.jsx("span",{style:{color:"#15803D",fontSize:u.xs},children:"Saved"}),!b&&e.jsx(ce,{messages:a,title:"This diagram's source does not parse"}),e.jsx(ce,{messages:xe,severity:"warning",title:"Saved, but the file does not parse — the model keeps its last good state for this file"}),C&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-center gap-1",style:{color:l.secondary,fontSize:u.xs},title:"Save changes 800ms after typing",children:[e.jsx("input",{type:"checkbox",checked:v,onChange:n=>Q(n.target.checked),style:{accentColor:l.accent}}),"Auto-save"]}),e.jsx("button",{onClick:P,disabled:!x||b||c,title:"Save SysML (Ctrl/Cmd+S)",style:{fontSize:u.xs,padding:"3px 10px",borderRadius:"5px",border:`1px solid ${l.border}`,cursor:!x||b||c?"default":"pointer",background:x?l.accent:"#F0F0ED",color:x?"#FFFFFF":l.faint,fontWeight:600},children:"Save"})]}),e.jsxs("label",{className:"flex items-center gap-1",style:{color:l.secondary,fontSize:u.xs},children:["View",e.jsxs("select",{"aria-label":"Diagram editor view",value:f,onChange:n=>h(n.target.value),style:{fontSize:u.xs,padding:"3px 8px",borderRadius:"5px",border:`1px solid ${l.border}`,background:"#FFFFFF",color:l.primary},children:[e.jsx("option",{value:"visual",children:"Visual"}),e.jsx("option",{value:"split",children:"Both"}),e.jsx("option",{value:"text",children:"Text"})]})]})]});return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"relative flex items-center justify-center px-3 py-2",style:{borderBottom:`1px solid ${l.border}`,background:"#FAFAF8",flexShrink:0},children:[f!=="visual"&&e.jsxs("button",{type:"button",onClick:()=>h("visual"),title:"Return to the visual diagram",className:"absolute left-3 flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-semibold",style:{border:`1px solid ${l.border}`,background:"#FFFFFF",color:l.primary},children:[e.jsx(E.eye,{}),"Return to diagram"]}),e.jsx("span",{className:"truncate",style:{color:l.primary,fontSize:u.md,fontWeight:700},children:i.name}),f==="visual"&&e.jsxs("div",{className:"absolute right-3 flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>window.dispatchEvent(new Event("memo:toggle-diagram-elements")),title:"Show or hide Diagram Elements","aria-label":"Show or hide Diagram Elements",style:{width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${l.border}`,borderRadius:5,background:"#FFFFFF",color:l.secondary,cursor:"pointer"},children:e.jsx(E.elements,{size:18})}),e.jsx("button",{type:"button",onClick:()=>window.dispatchEvent(new Event("memo:toggle-diagram-toolbar")),title:"Show or hide Toolbar","aria-label":"Show or hide Toolbar",style:{width:28,height:28,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${l.border}`,borderRadius:5,background:"#FFFFFF",color:l.secondary,cursor:"pointer"},children:e.jsx(E.tools,{size:18})})]})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[f==="visual"&&oe,f==="text"&&re,f==="split"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"50%",borderRight:`1px solid ${l.border}`,display:"flex",flexDirection:"column",overflow:"hidden"},children:re}),e.jsx("div",{style:{width:"50%",display:"flex",overflow:"hidden"},children:oe})]})]}),j&&Me.createPortal(e.jsx("div",{className:se?"contents":"flex flex-wrap items-center gap-2",children:Fe}),j)]})}export{lt as DiagramEditor};