@memoarchitect/architect 0.6.4 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -7
- package/dist/assets/AiWorkspace-DS79vBOT.js +3 -0
- package/dist/assets/AnalysisWorkspace-D_u4shRY.js +39 -0
- package/dist/assets/{ComplianceWizard-CVidRUY4.js → ComplianceWizard-k98NZ2ec.js} +1 -1
- package/dist/assets/{DSMView-DdcRG9Te.js → DSMView-DGheBwZ0.js} +1 -1
- package/dist/assets/{Dashboard-DxOueCqW.js → Dashboard-BRUQvUFK.js} +1 -1
- package/dist/assets/{DhfDashboard-CpDAP41S.js → DhfDashboard-B9V_n7kg.js} +1 -1
- package/dist/assets/{DhfSettingsPanel-C2vyewXY.js → DhfSettingsPanel-B8aLsWn6.js} +1 -1
- package/dist/assets/{DhfWorkbench-BGaEk0Qi.js → DhfWorkbench-TOnZkdUU.js} +3 -3
- package/dist/assets/DiagramCanvas-B9d4aLKt.js +1 -0
- package/dist/assets/{DiagramEditor-v6VJ5o2f.js → DiagramEditor-CJ7OG2IC.js} +2 -2
- package/dist/assets/ElementDetailView-CDcm1rvf.js +2 -0
- package/dist/assets/{ImportView-C8lcbof7.js → ImportView-CyMm-tSP.js} +1 -1
- package/dist/assets/{LayerGrid-BB30kAyl.js → LayerGrid-DNPZYTsD.js} +1 -1
- package/dist/assets/{LayerTable-BN9IZPbM.js → LayerTable-DhOq1DHo.js} +1 -1
- package/dist/assets/{MaxGraphCanvas-CfoIuwsi.js → MaxGraphCanvas-DqKU1PTY.js} +6 -6
- package/dist/assets/{ModelDiff-D6IR9kzb.js → ModelDiff-BbqIoesG.js} +1 -1
- package/dist/assets/OntologyDecompositionDiagram-DkxTe2C_.js +1 -0
- package/dist/assets/{OntologyViewer-cI3zi95S.js → OntologyViewer-BIpJC66j.js} +2 -2
- package/dist/assets/{ReviewDashboard-BTqze9-C.js → ReviewDashboard-DKoExM8K.js} +1 -1
- package/dist/assets/ScenarioEditor-JQ3huCnz.js +3 -0
- package/dist/assets/{StatisticsDashboard-BC1JkdTl.js → StatisticsDashboard-B8BduIDz.js} +1 -1
- package/dist/assets/{TabularView-Bn_WEMpm.js → TabularView-BXfFSluC.js} +1 -1
- package/dist/assets/{TraceabilityMatrix-BEEPlOQq.js → TraceabilityMatrix-CHZHFucA.js} +1 -1
- package/dist/assets/{WorkflowWizard-CFx5KVUH.js → WorkflowWizard-7--f9OH2.js} +1 -1
- package/dist/assets/index-CVW92JY7.js +3280 -0
- package/dist/assets/index-Y1UZTZg-.css +1 -0
- package/dist/assets/layout-selection-ClQ295Xc.js +1 -0
- package/dist/index.html +2 -2
- package/lib/__tests__/feature-grants.test.d.ts +2 -0
- package/lib/__tests__/feature-grants.test.d.ts.map +1 -0
- package/lib/__tests__/feature-grants.test.js +34 -0
- package/lib/__tests__/feature-grants.test.js.map +1 -0
- package/lib/bin/memo-architect.js +20 -3
- package/lib/bin/memo-architect.js.map +1 -1
- package/lib/commands/build.d.ts +3 -0
- package/lib/commands/build.d.ts.map +1 -1
- package/lib/commands/build.js +3 -0
- package/lib/commands/build.js.map +1 -1
- package/lib/commands/dev.d.ts +2 -0
- package/lib/commands/dev.d.ts.map +1 -1
- package/lib/commands/dev.js +5 -0
- package/lib/commands/dev.js.map +1 -1
- package/lib/commands/example.d.ts +2 -0
- package/lib/commands/example.d.ts.map +1 -1
- package/lib/commands/example.js +6 -2
- package/lib/commands/example.js.map +1 -1
- package/lib/feature-grants.d.ts +29 -0
- package/lib/feature-grants.d.ts.map +1 -0
- package/lib/feature-grants.js +31 -0
- package/lib/feature-grants.js.map +1 -0
- package/package.json +9 -5
- package/dist/assets/ChatPanel-DSjWi7UI.js +0 -3
- package/dist/assets/DiagramCanvas-DybZNdxw.js +0 -1
- package/dist/assets/ElementDetailView-9EkxZAaF.js +0 -2
- package/dist/assets/OntologyDecompositionDiagram-DjhvdWh5.js +0 -1
- package/dist/assets/ScenarioEditor-BL835I2V.js +0 -3
- package/dist/assets/SysmlGenerator-B_Me_xGE.js +0 -1
- package/dist/assets/index-BMgENwvO.js +0 -3280
- package/dist/assets/index-XtCtnAfF.css +0 -1
- package/dist/assets/layout-selection-ClQts3bC.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DhfSettingsPanel-
|
|
2
|
-
import{u as w,
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DhfSettingsPanel-B8aLsWn6.js","assets/reactflow-CsCqNKB-.js","assets/zustand-CrhqMOHB.js","assets/index-CVW92JY7.js","assets/index-Y1UZTZg-.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as w,k as te,_ as oe}from"./index-CVW92JY7.js";import{j as e}from"./reactflow-CsCqNKB-.js";import{a as x}from"./zustand-CrhqMOHB.js";const ne=/<div class="memo-doc-diagram" data-diagram-id="([^"]*)"><\/div>/;function m(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function H(t,r){const n=t.split(`
|
|
3
3
|
`).map(o=>o.trim()).filter(Boolean);return n.length===0?`<tr><td colspan="4" style="color:#9CA3AF;font-style:italic">No ${r.toLowerCase()}s defined</td></tr>`:n.map(o=>{const[i="",d=""]=o.split("|").map(a=>a.trim());return`<tr><td>${m(i)}</td><td>${m(d||r)}</td><td style="color:#9CA3AF">—</td><td style="color:#9CA3AF">—</td></tr>`}).join("")}function re(t){const r=t.authors.trim().length>0,n=t.approvers.trim().length>0,o="<thead><tr><th>Name</th><th>Role</th><th>Signature</th><th>Date</th></tr></thead>";return`
|
|
4
4
|
<h2>Authors</h2>
|
|
5
5
|
<table>${o}<tbody>${H(t.authors,"Author")}</tbody></table>
|
|
@@ -60,7 +60,7 @@ ${o.word?'<meta name="ProgId" content="Word.Document"><!--[if gte mso 9]><xml><w
|
|
|
60
60
|
<style>${K(n)}${ae}${o.word?ce:""}</style>
|
|
61
61
|
</head>
|
|
62
62
|
<body>${d}</body>
|
|
63
|
-
</html>`}function N(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function _(t,r,n){const o=new Blob([r],{type:n}),i=URL.createObjectURL(o),d=document.createElement("a");d.href=i,d.download=t,d.click(),URL.revokeObjectURL(i)}function me(t,r,n){_(`${t.id}.html`,T(t,r,n),"text/html;charset=utf-8")}function xe(t,r,n){_(`${t.id}.doc`,T(t,r,n,{word:!0}),"application/msword")}function he(t){_(`${t.id}.md`,t.content,"text/markdown;charset=utf-8")}function fe(t,r,n){const o=window.open("","_blank");o&&(o.document.write(T(t,r,n)),o.document.close(),o.setTimeout(()=>{o.focus(),o.print()},150))}const U=x.lazy(()=>oe(()=>import("./DhfSettingsPanel-
|
|
63
|
+
</html>`}function N(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function _(t,r,n){const o=new Blob([r],{type:n}),i=URL.createObjectURL(o),d=document.createElement("a");d.href=i,d.download=t,d.click(),URL.revokeObjectURL(i)}function me(t,r,n){_(`${t.id}.html`,T(t,r,n),"text/html;charset=utf-8")}function xe(t,r,n){_(`${t.id}.doc`,T(t,r,n,{word:!0}),"application/msword")}function he(t){_(`${t.id}.md`,t.content,"text/markdown;charset=utf-8")}function fe(t,r,n){const o=window.open("","_blank");o&&(o.document.write(T(t,r,n)),o.document.close(),o.setTimeout(()=>{o.focus(),o.print()},150))}const U=x.lazy(()=>oe(()=>import("./DhfSettingsPanel-B8aLsWn6.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.DhfSettingsPanel}))),V=[{id:"q-hazards",label:"Hazard Table",description:"All hazards in the risk layer",category:"query",code:'```memo-query\nkind: Hazard\ndisplay: table\ncolumns: name, layer, doc\nsort: name\nempty: "No hazards defined."\n```'},{id:"q-hazardous-situations",label:"Hazardous Situations",description:"All hazardous situations",category:"query",code:"```memo-query\nkind: HazardousSituation\ndisplay: table\ncolumns: name, layer, doc\nsort: name\n```"},{id:"q-risk-controls",label:"Risk Controls",description:"All risk control measures",category:"query",code:"```memo-query\nkind: RiskControlMeasure\ndisplay: table\ncolumns: name, layer, doc\nsort: name\n```"},{id:"q-requirements",label:"Requirements",description:"All system requirements",category:"query",code:"```memo-query\nkind: Requirement\ndisplay: table\ncolumns: name, layer, doc\nsort: name\n```"},{id:"q-soup",label:"SOUP List",description:"All SOUP components",category:"query",code:"```memo-query\nkind: SOUPComponent\ndisplay: table\ncolumns: name, layer, doc\n```"},{id:"q-sw-items",label:"Software Items",description:"All software items",category:"query",code:"```memo-query\nkind: SoftwareItem\ndisplay: table\ncolumns: name, layer, doc\n```"},{id:"q-test-cases",label:"Test Cases",description:"All test cases",category:"query",code:"```memo-query\nkind: TestCase\ndisplay: table\ncolumns: name, layer, doc\n```"},{id:"q-hazard-count",label:"Hazard Count (metric)",description:"Metric badge with hazard count",category:"query",code:"```memo-query\nkind: Hazard\ndisplay: count\nlabel: Total hazards\n```"},{id:"s-unmitigated",label:"Unmitigated Hazards",description:"Hazards without risk controls",category:"script",code:"```memo-script\nconst hazards = query({ kind: 'Hazard' });\nconst unmitigated = hazards.filter(h => h.mitigatedBy?.length === 0);\nif (unmitigated.length === 0) return 'All hazards have associated risk controls.';\nreturn table(unmitigated, ['name', 'layer', 'doc']);\n```"},{id:"s-coverage",label:"Requirements Coverage",description:"Requirements with/without test cases",category:"script",code:"```memo-script\nconst reqs = query({ kind: 'Requirement' });\nconst covered = reqs.filter(r => r.verifiedBy?.length > 0);\nreturn count(covered, `covered of ${reqs.length} requirements`);\n```"},{id:"i-doc-header",label:"Document Control Header",description:"Standard doc control table",category:"include",code:"{{include:shared/snippets/document-control-header.md}}"},{id:"i-approval",label:"Approval Block",description:"Reviewer/approver signature table",category:"include",code:"{{include:shared/snippets/approval-block.md}}"},{id:"i-revision",label:"Revision History",description:"Revision history table",category:"include",code:"{{include:shared/snippets/revision-history-table.md}}"},{id:"i-references",label:"References Section",description:"Normative references block",category:"include",code:"{{include:shared/snippets/references-section.md}}"},{id:"d-toc",label:"Table of Contents",description:"Auto-generated TOC (on export)",category:"directive",code:"{{toc}}"},{id:"d-glossary",label:"Glossary",description:"Auto-generated glossary (on export)",category:"directive",code:"{{glossary}}"}],J={query:"#2563eb",script:"#7c3aed",include:"#0891b2",directive:"#6B7280"},Q={query:"Query",script:"Script",include:"Snippet",directive:"Directive"};function Ae(){const t=w(s=>s.model),r=w(s=>s.activeView),n=w(s=>s.dhfDocuments),o=w(s=>s.updateDhfDocumentContent),i=w(s=>s.updateDhfDocumentMeta),d=w(s=>s.llmAvailable),a=w(s=>s.registerLlmRequest),l=w(s=>s.dhfSettings),[p,h]=x.useState("split"),c=x.useRef(null),[S,u]=x.useState(!1),[k,g]=x.useState(null),[f,b]=x.useState(!1),[y,$]=x.useState(!1),[C,v]=x.useState(!1),[E,R]=x.useState("all"),X=x.useCallback(async(s,A)=>{u(!0),g(null);const z=`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`,q=A.split("/").pop()??A;try{const B=await new Promise((W,D)=>{a(z,W,D),te(z,q),setTimeout(()=>D(new Error("Request timed out after 120 seconds.")),12e4)});o(s,B.markdown)}catch(B){g((B==null?void 0:B.message)??"Unknown error")}finally{u(!1)}},[a,o]),Z=x.useCallback(s=>{if(!c.current)return;const A=c.current,z=A.selectionStart,q=A.selectionEnd,B=`
|
|
64
64
|
|
|
65
65
|
${s.code}
|
|
66
66
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var qs=Object.defineProperty;var Zs=(t,i,n)=>i in t?qs(t,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[i]=n;var no=(t,i,n)=>Zs(t,typeof i!="symbol"?i+"":i,n);import{j as e,u as Hn,H as N,P as k,N as tt,a as xo,B as _n,E as po,R as Qs,b as Js,c as ei,d as ti,e as oi,i as ni,C as si,f as ii,g as ri,M as ai}from"./reactflow-CsCqNKB-.js";import{b as li,a as d,W as Sn}from"./zustand-CrhqMOHB.js";/* empty css */import{F as D,S as ce,z as ci,u as O,A as Kn,f as uo,g as di,D as vn,B as je,r as pi,i as kn,G as ui,R as Cn,V as En,C as In}from"./index-CVW92JY7.js";import{c as hi,a as xi,b as gi,d as fi,e as mi,f as yi,g as bi,h as Fi,i as wi,j as ji,k as Si,I as go,l as vi,P as At,s as ki,u as Ci,m as Ei,G as so,n as Ii,o as Di,C as Mt,p as Ni,r as Ai,q as io,t as Mi,v as Bi,w as zi,x as Dn,y as Ti,z as Ri,A as Li,B as $i,D as Wi,E as Oi,R as Pi,F as Hi}from"./layout-selection-ClQ295Xc.js";import"./layout-providers-Dr743WlP.js";import"./elk-6l8mIQnQ.js";function _i(t,i,n="both",a=10){const r=t.elements[i];if(!r)return{rootId:i,rootName:"(unknown)",rootKind:"",nodes:[],edges:[]};const l=new Map,p=new Map;for(const h of t.relationships)l.has(h.sourceId)||l.set(h.sourceId,[]),l.get(h.sourceId).push(h),p.has(h.targetId)||p.set(h.targetId,[]),p.get(h.targetId).push(h);const f=new Set;f.add(i);const w=[],F=[],I=[[i,0]];for(;I.length>0;){const[h,C]=I.shift();if(C>=a)continue;const j=C+1;if(n==="downstream"||n==="both")for(const m of l.get(h)||[]){const A=m.targetId;if(F.push({fromId:h,toId:A,relType:m.type,relId:m.id}),!f.has(A)){f.add(A);const b=t.elements[A];b&&(w.push({elementId:A,name:b.name,kind:b.kind,layer:b.layer,depth:j,viaRelType:m.type,direction:"downstream"}),I.push([A,j]))}}if(n==="upstream"||n==="both")for(const m of p.get(h)||[]){const A=m.sourceId;if(F.push({fromId:A,toId:h,relType:m.type,relId:m.id}),!f.has(A)){f.add(A);const b=t.elements[A];b&&(w.push({elementId:A,name:b.name,kind:b.kind,layer:b.layer,depth:j,viaRelType:m.type,direction:"upstream"}),I.push([A,j]))}}}return w.sort((h,C)=>h.depth-C.depth||h.name.localeCompare(C.name)),{rootId:i,rootName:r.name,rootKind:r.kind,nodes:w,edges:F}}function Ki(t,i=[]){let a=t.replace(/[^A-Za-z0-9]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim().split(/\s+/).filter(Boolean).map((p,f)=>f===0?p.charAt(0).toLowerCase()+p.slice(1):p.charAt(0).toUpperCase()+p.slice(1)).join("");a||(a="element"),/^[0-9]/.test(a)&&(a=`n${a}`);const r=new Set(i);if(!r.has(a))return a;let l=2;for(;r.has(`${a}${l}`);)l++;return`${a}${l}`}function Vi(t){return t&&t.replace(/\s+(def|usage)$/,"").trim()||"part"}const Yi=[{value:"",label:"Default"},{value:"#FEF3C7",label:"Amber"},{value:"#DCFCE7",label:"Green"},{value:"#DBEAFE",label:"Blue"},{value:"#FCE7F3",label:"Pink"},{value:"#E5E7EB",label:"Grey"}],Ze={display:"flex",alignItems:"center",gap:2},Qe={width:1,height:18,background:"#E2E8F0",margin:"0 4px",flexShrink:0};function le({title:t,label:i,onClick:n}){return e.jsx("button",{title:t,"aria-label":t,onClick:n,style:{minWidth:26,height:26,padding:"0 5px",borderRadius:5,border:"1px solid #E2E8F0",background:"#FFFFFF",color:"#374151",fontSize:13,lineHeight:1,cursor:"pointer",fontWeight:600},children:i})}function Xi({count:t,onAlign:i,onMatchSize:n,onDistribute:a,onFill:r,onOpacity:l,opacity:p}){return e.jsxs("div",{className:"nodrag nopan",style:{position:"absolute",top:10,left:"50%",transform:"translateX(-50%)",zIndex:25,display:"flex",alignItems:"center",gap:4,padding:"6px 8px",borderRadius:9,background:"#FFFFFF",border:"1px solid #E2E8F0",boxShadow:"0 6px 20px rgba(15,23,42,0.14)",flexWrap:"wrap",maxWidth:"calc(100% - 24px)"},children:[e.jsxs("span",{style:{fontSize:D.xs,color:"#6B7280",fontWeight:700,paddingRight:2},children:[t," selected"]}),e.jsx("span",{style:Qe}),e.jsxs("div",{style:Ze,children:[e.jsx(le,{title:"Align left edges",label:"⇤",onClick:()=>i("left")}),e.jsx(le,{title:"Align horizontal centres",label:"⇹",onClick:()=>i("centerX")}),e.jsx(le,{title:"Align right edges",label:"⇥",onClick:()=>i("right")}),e.jsx(le,{title:"Align top edges",label:"⤒",onClick:()=>i("top")}),e.jsx(le,{title:"Align vertical centres",label:"⇳",onClick:()=>i("centerY")}),e.jsx(le,{title:"Align bottom edges",label:"⤓",onClick:()=>i("bottom")})]}),e.jsx("span",{style:Qe}),e.jsxs("div",{style:Ze,children:[e.jsx(le,{title:"Match width to the widest",label:"↔",onClick:()=>n("width")}),e.jsx(le,{title:"Match height to the tallest",label:"↕",onClick:()=>n("height")}),e.jsx(le,{title:"Match width and height",label:"⤢",onClick:()=>n("both")})]}),e.jsx("span",{style:Qe}),e.jsxs("div",{style:Ze,children:[e.jsx(le,{title:t>=3?"Even horizontal gaps":"Even horizontal gaps (needs 3 blocks)",label:"⇿",onClick:()=>a("horizontal")}),e.jsx(le,{title:t>=3?"Even vertical gaps":"Even vertical gaps (needs 3 blocks)",label:"⇕",onClick:()=>a("vertical")})]}),e.jsx("span",{style:Qe}),e.jsx("div",{style:Ze,children:Yi.map(f=>e.jsx("button",{title:`Fill: ${f.label}`,"aria-label":`Fill ${f.label}`,onClick:()=>r(f.value),style:{width:20,height:20,padding:0,borderRadius:4,cursor:"pointer",border:"1px solid #CBD5E1",background:f.value||"#FFFFFF",color:"#94A3B8",fontSize:11,lineHeight:1,fontWeight:700},children:f.value?"":"⌫"},f.label))}),e.jsx("span",{style:Qe}),e.jsxs("label",{title:"Fill opacity",style:{display:"flex",alignItems:"center",gap:5,fontSize:D.xs,color:"#6B7280"},children:[e.jsx("span",{style:{fontWeight:700},children:"Opacity"}),e.jsx("input",{type:"range",min:20,max:100,step:5,value:Math.round(p*100),onChange:f=>l(Number(f.target.value)/100),style:{width:72,accentColor:"#2DD4A8"}}),e.jsxs("span",{style:{width:30,textAlign:"right",fontVariantNumeric:"tabular-nums"},children:[Math.round(p*100),"%"]})]}),e.jsx("div",{style:Ze,"aria-label":"Opacity presets",children:[1,.75,.5].map(f=>e.jsx("button",{"aria-label":`Set opacity to ${Math.round(f*100)}%`,title:`Set opacity to ${Math.round(f*100)}%`,onClick:()=>l(f),style:{height:22,minWidth:30,padding:"0 4px",borderRadius:4,border:"1px solid #CBD5E1",background:"#FFFFFF",color:"#475569",cursor:"pointer",fontSize:10,fontWeight:700},children:Math.round(f*100)},f))})]})}function Gi(t,i){if(t.length===0)return;const n=a=>t.reduce((r,l)=>a(l,r)?l:r);switch(i){case"left":return n((a,r)=>a.x<r.x);case"right":return n((a,r)=>a.x+a.width>r.x+r.width);case"top":return n((a,r)=>a.y<r.y);case"bottom":return n((a,r)=>a.y+a.height>r.y+r.height);case"centerX":return n((a,r)=>a.width>r.width);case"centerY":return n((a,r)=>a.height>r.height)}}function Ui(t,i){const n=new Map,a=Gi(t,i);if(!a||t.length<2)return n;for(const r of t){let l;switch(i){case"left":l=a.x;break;case"right":l=a.x+a.width-r.width;break;case"centerX":l=a.x+a.width/2-r.width/2;break;case"top":l=a.y;break;case"bottom":l=a.y+a.height-r.height;break;case"centerY":l=a.y+a.height/2-r.height/2;break}const p=i==="left"||i==="right"||i==="centerX",f=p?r.x:r.y;Math.abs(f-l)<.5||n.set(r.id,p?{x:l}:{y:l})}return n}function qi(t,i){const n=new Map;if(t.length<2)return n;const a=Math.max(...t.map(l=>l.width)),r=Math.max(...t.map(l=>l.height));for(const l of t){const p={};i!=="height"&&Math.abs(l.width-a)>=.5&&(p.width=a),i!=="width"&&Math.abs(l.height-r)>=.5&&(p.height=r),Object.keys(p).length>0&&n.set(l.id,p)}return n}function Zi(t,i){const n=new Map;if(t.length<3)return n;const a=i==="horizontal",r=j=>a?j.x:j.y,l=j=>a?j.width:j.height,p=[...t].sort((j,m)=>r(j)-r(m)),f=p[0],w=p[p.length-1],F=r(w)+l(w)-r(f),I=p.reduce((j,m)=>j+l(m),0),h=(F-I)/(p.length-1);if(!Number.isFinite(h)||h<0)return n;let C=r(f)+l(f)+h;for(const j of p.slice(1,-1))Math.abs(r(j)-C)>=.5&&n.set(j.id,a?{x:C}:{y:C}),C+=l(j)+h;return n}const ot=li(t=>({subject:null,publish:i=>t({subject:i})})),et=t=>ot.getState().publish(t),Vn=t=>{var i,n;return[t.source,t.target,(i=t.data)==null?void 0:i.sourcePortId,(n=t.data)==null?void 0:n.targetPortId].filter(a=>!!a)},Qi=(t,i)=>t.edgeId===i.id||Vn(i).some(n=>t.endpointIds.includes(n)),fo=()=>ot(t=>t.subject!==null),Ji=t=>ot(i=>{var n;return((n=i.subject)==null?void 0:n.endpointIds.includes(t))??!1}),Yn=(t,i)=>ot(n=>{const a=n.subject;return a?a.edgeId===t||i.some(r=>r!==void 0&&a.endpointIds.includes(r)):!1}),er=t=>`.react-flow__edge[data-id="${CSS.escape(t)}"]`;function tr(){const t=ot(a=>a.subject),i=Hn(a=>t?a.edges.filter(r=>Qi(t,r)).map(r=>r.id).join("\0"):"");if(!t)return null;const n=i?i.split("\0").map(er).join(","):"";return e.jsxs("style",{children:[".react-flow__edge{opacity:0.22;transition:opacity 120ms ease}",n?`${n}{opacity:1}`:""]})}class or{constructor(){no(this,"providers",[]);no(this,"byId",new Map)}register(i,n){const a=this.byId.get(i.descriptor.id);if(a&&a!==i)throw new Error(`Template provider already registered: ${i.descriptor.id}`);if(a)return;this.byId.set(i.descriptor.id,i);const r=n?this.providers.findIndex(l=>l.descriptor.id===n):-1;r>=0?this.providers.splice(r,0,i):this.providers.push(i)}unregister(i){const n=this.byId.get(i);return n?(this.byId.delete(i),this.providers.splice(this.providers.indexOf(n),1),!0):!1}get(i){return this.byId.get(i)}has(i){return this.byId.has(i)}list(){return this.providers.map(i=>i.descriptor)}select(i){const n=this.providers.find(a=>a.matches(i));if(!n)throw new Error("No diagram template matches this view — register a catch-all provider");return n}}const Xn=new or,nr=[{descriptor:{id:"memo.template.fbs",name:"Functional Breakdown",label:"FBS",contractVersion:"1",interactive:!0,description:"Functional breakdown structure — functions per realising component."},matches:t=>t.isFBSDiagram,compute:(t,i)=>hi(t,i.fbs)},{descriptor:{id:"memo.template.decomposition",name:"Decomposition Tree",label:"Decomposition",contractVersion:"1",interactive:!0,description:"Expandable decomposition tree over composition relationships."},matches:t=>t.isDecompDiagram&&t.layoutStyle==="decomposition",compute:(t,i)=>xi(t,i.decomposition)},{descriptor:{id:"memo.template.containment",name:"Containment Blocks",label:"Containment",contractVersion:"1",interactive:!0,description:"Nested containment blocks over composition relationships."},matches:t=>t.isDecompDiagram,compute:(t,i)=>gi(t,i.containment)},{descriptor:{id:"memo.template.usecase",name:"Use Case",label:"Use case",contractVersion:"1",interactive:!1,description:"Actors outside a system boundary, use cases inside (KK-7)."},matches:t=>t.diagramType==="ucd",compute:(t,i)=>fi(t,i.useCase)},{descriptor:{id:"memo.template.context",name:"System Context",label:"Context",contractVersion:"1",interactive:!1,description:"Black-box system of interest with external actors and peer systems."},matches:t=>t.diagramType==="context",compute:(t,i)=>mi(t,i.context.systemName,i.context)},{descriptor:{id:"memo.template.interconnection",name:"Interconnection",label:"Interconnection",contractVersion:"1",interactive:!1,description:"IBD — parts with boundary ports, typed connectors, nested containment (KK-3)."},matches:t=>t.viewKind==="interconnection",compute:(t,i)=>yi(t,i.interconnection)},{descriptor:{id:"memo.template.actionflow",name:"Action Flow",label:"Action flow",contractVersion:"1",interactive:!1,description:"Actions with parameter ports, item flows, successions, optional swimlanes (KK-4)."},matches:t=>t.viewKind==="actionflow",compute:(t,i)=>bi(t,i.actionflow)},{descriptor:{id:"memo.template.statetransition",name:"State Transition",label:"State transition",contractVersion:"1",interactive:!1,description:"Nested states with routed transition edges and trigger [guard] labels (KK-5)."},matches:t=>t.viewKind==="statetransition",compute:(t,i)=>Fi(t,i.statetransition)},{descriptor:{id:"memo.template.sequence",name:"Sequence",label:"Sequence",contractVersion:"1",interactive:!1,description:"Lifelines with chronological messages (KK-6)."},matches:t=>t.viewKind==="sequence",compute:(t,i)=>wi(t,i.sequence)},{descriptor:{id:"memo.template.general",name:"General (structured)",label:"General",contractVersion:"1",interactive:!0,description:"General template tree/containment modes (KK-2)."},matches:t=>t.isGeneralTemplate&&t.generalMode!=="graph",compute:(t,i)=>ji(t,i.general)},{descriptor:{id:"memo.template.standard",name:"Standard Graph",label:"Standard",contractVersion:"1",interactive:!0,description:"Relationship graph with optional compartments — the catch-all."},matches:()=>!0,compute:(t,i)=>Si(t,i.standard)}];for(const t of nr)Xn.register(t);function nt({color:t="#334155",size:i=38}){const n=Math.round(i*1.42);return e.jsxs("svg",{width:i,height:n,viewBox:"0 0 38 54","aria-hidden":"true",fill:"none",stroke:t,strokeWidth:"2",children:[e.jsx("circle",{cx:"19",cy:"8",r:"6",fill:"#FFFFFF"}),e.jsx("path",{d:"M19 14v18M6 23h26M19 32L8 49M19 32l11 17",strokeLinecap:"round"})]})}const mo=t=>t==="Actor"||t==="User";function sr({data:t}){const i=t,{element:n,layerColor:a,isExpanded:r,hasChildren:l,childCount:p,direction:f,onToggleExpand:w,onToggleDirection:F,showDirectionButton:I,depthBgColor:h,isContainer:C}=i,j=f==="vertical"?"V":"H",m=C&&r;return e.jsxs("div",{style:{background:m?h||"#FAFAF9":"#FFFFFF",borderLeft:m?`2px solid ${a}40`:`3px solid ${a}`,borderTop:`1px solid ${m?a+"30":"#E5E5E0"}`,borderRight:`1px solid ${m?a+"30":"#E5E5E0"}`,borderBottom:`1px solid ${m?a+"30":"#E5E5E0"}`,borderRadius:3,padding:m?"0":"8px 12px",minWidth:m?void 0:"200px",boxShadow:"none",width:"100%",height:"100%",boxSizing:"border-box"},children:[e.jsx(N,{type:"target",position:k.Top,id:"top",style:vt}),e.jsx(N,{type:"source",position:k.Bottom,id:"bottom",style:vt}),e.jsx(N,{type:"target",position:k.Left,id:"left",style:vt}),e.jsx(N,{type:"source",position:k.Right,id:"right",style:vt}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:m?"8px 12px":"0"},children:[mo(n.kind)&&e.jsx(nt,{size:24,color:a}),l&&e.jsx("button",{onClick:A=>{A.stopPropagation(),w()},style:{width:"20px",height:"20px",borderRadius:2,border:`1px solid ${a}`,background:r?a+"12":"#FFFFFF",color:a,fontSize:D.md,fontWeight:700,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0,flexShrink:0,transition:"background 200ms ease, color 200ms ease"},title:r?"Collapse":"Expand",children:r?"−":"+"}),l&&I&&e.jsx("button",{onClick:A=>{A.stopPropagation(),F()},style:{width:"20px",height:"20px",borderRadius:"4px",border:"1.5px solid #10b981",background:"transparent",color:"#10b981",fontSize:"9px",fontWeight:700,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0,flexShrink:0,transition:"background 200ms ease"},title:`Direction: ${f}. Click to toggle`,children:j}),e.jsx("span",{style:{fontSize:D.md,fontWeight:600,color:m?a:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n.name})]}),!m&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"3px",paddingLeft:l?"26px":"14px"},children:[e.jsx("span",{style:{fontSize:D.badge,color:"#9CA3AF"},children:n.kind}),l&&e.jsxs("span",{style:{fontSize:"9px",color:"#6B7280",background:"#F0F0ED",padding:"1px 5px",borderRadius:2,fontWeight:600},children:[p," parts",r?"":" (collapsed)"]})]})]})}const vt={width:"8px",height:"8px",background:"#2DD4A8",border:"1.5px solid #FFFFFF",opacity:0},ir=d.memo(sr),Nn={top:k.Top,bottom:k.Bottom,left:k.Left,right:k.Right},rr={top:"bottom",bottom:"top",left:"right",right:"left"},ar="#6B7280",Gn=t=>t?At[t]:ar;function Un(t,i){if(t==="inout")return"⇄";if(!t)return"";const n=t==="in";switch(i){case"left":return n?"→":"←";case"right":return n?"←":"→";case"top":return n?"↓":"↑";default:return n?"↑":"↓"}}const lr=104,An=40,qn=t=>({opacity:0,width:t,height:t,top:"50%",left:"50%",transform:"translate(-50%, -50%)",border:"none",background:"transparent",pointerEvents:"none"}),cr=t=>({...qn(t),pointerEvents:"auto",cursor:"crosshair",zIndex:12});function dr({port:t,onMove:i}){const{getZoom:n}=xo(),a=Hn(h=>h.transform[2]),r=Ji(t.id),l=fo()&&!r,p=t.size??go,f=p+5,w=Gn(t.direction),F=t.side==="left"||t.side==="right",I={position:"absolute",fontSize:t.nested?"9.5px":"10.5px",fontWeight:r?750:t.nested?600:650,color:r?"#0F172A":t.nested?"#6B7280":"#374151",opacity:l?.45:1,transition:"color 120ms ease, opacity 120ms ease",whiteSpace:"normal",pointerEvents:"none",overflow:"hidden",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:2,width:F?lr:72,background:"rgba(255,255,255,0.94)",padding:"1px 3px",borderRadius:4,lineHeight:1.12,...t.side==="left"?{left:f,bottom:"50%",marginBottom:2}:t.side==="right"?{right:f,bottom:"50%",marginBottom:2,textAlign:"right"}:t.side==="top"?{top:f,left:"50%",transform:"translateX(-50%)"}:{bottom:f,left:"50%",transform:"translateX(-50%)"}};return e.jsxs("div",{className:"nodrag nopan",style:{position:"absolute",left:t.x,top:t.y,width:p,height:p,zIndex:t.nested?11:10},children:[e.jsx("div",{onPointerEnter:()=>et({endpointIds:[t.id]}),onPointerLeave:()=>et(null),onPointerDown:i?h=>{h.preventDefault(),h.stopPropagation();const C=h.clientY,j=t.y,m=b=>i(j+(b.clientY-C)/n()),A=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",A)};window.addEventListener("pointermove",m),window.addEventListener("pointerup",A,{once:!0})}:void 0,title:`${t.name}${t.direction?` (${t.direction})`:""}`,style:{position:"absolute",left:"50%",top:"50%",width:An,height:An,transform:`translate(-50%, -50%) scale(${1/Math.max(a,.1)})`,cursor:i?"grab":"default",touchAction:"none"}}),e.jsxs("div",{style:{position:"absolute",inset:0,boxSizing:"border-box",background:"#FFFFFF",border:`2px solid ${w}`,borderRadius:5,boxShadow:r?`0 0 0 4px ${w}33, 0 2px 8px rgba(15,23,42,0.24)`:"0 1px 3px rgba(15,23,42,0.18)",opacity:l?.5:1,display:"flex",alignItems:"center",justifyContent:"center",color:w,fontSize:t.nested?"10px":"12px",fontWeight:800,lineHeight:1,pointerEvents:"none",transition:"box-shadow 120ms ease, opacity 120ms ease"},children:[Un(t.direction,t.side),e.jsx("span",{style:I,children:t.name.replace(/([a-z0-9])([A-Z])/g,"$1$2")}),[{suffix:"",pos:Nn[t.side],connectable:!0},{suffix:vi,pos:Nn[rr[t.side]],connectable:!1}].flatMap(h=>{const C=h.connectable?"ibd-port-connect":"ibd-port-anchor",j=h.connectable?cr(p):qn(p);return[e.jsx(N,{className:C,type:"source",id:`${t.id}${h.suffix}`,position:h.pos,style:j,isConnectable:h.connectable},`s${h.suffix}`),e.jsx(N,{className:C,type:"target",id:`${t.id}${h.suffix}`,position:h.pos,style:j,isConnectable:h.connectable},`t${h.suffix}`)]})]})]})}function Mn({side:t,direction:i}){const n=Gn(i),a=go;return e.jsx("div",{"aria-label":`implicit ${i} port`,title:`Implicit ${i} port — relationship targets the part directly`,style:{position:"absolute",top:"50%",left:t==="left"?-a/2:void 0,right:t==="right"?-a/2:void 0,transform:"translateY(-50%)",width:a,height:a,boxSizing:"border-box",background:"#FFFFFF",border:`2px solid ${n}`,borderRadius:4,boxShadow:"0 1px 3px rgba(15,23,42,0.18)",display:"flex",alignItems:"center",justifyContent:"center",color:n,fontSize:11,fontWeight:800,lineHeight:1,zIndex:4,pointerEvents:"none"},children:Un(i,t)})}const kt={width:8,height:8,background:"#2DD4A8",border:"1.5px solid #FFFFFF",opacity:0};function Bn({name:t,kind:i,nameColor:n,typeColor:a,frame:r=!1}){return e.jsxs("span",{title:`${t} : ${i}`,style:{display:"flex",flexDirection:r?"row":"column",alignItems:r?"baseline":"flex-start",gap:r?6:1,minWidth:0,overflow:"hidden",flex:1},children:[e.jsx("span",{style:{display:r?"block":"-webkit-box",width:"100%",minWidth:0,fontSize:r?D.md:D.sm,lineHeight:1.2,fontWeight:700,color:n,whiteSpace:r?"nowrap":"normal",overflow:"hidden",textOverflow:"ellipsis",WebkitBoxOrient:"vertical",WebkitLineClamp:r?void 0:2,overflowWrap:"anywhere"},children:t}),e.jsx("span",{style:{display:"block",maxWidth:"100%",fontSize:"9px",lineHeight:1.15,fontWeight:650,letterSpacing:"0.055em",textTransform:"uppercase",color:a,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r?`: ${i}`:`«${i}»`})]})}function pr({label:t,onDrillIn:i,color:n,onColor:a}){return e.jsx("button",{"aria-label":`Drill into ${t}`,title:`Open ${t} as its own internal block diagram`,className:"nodrag",onClick:r=>{r.stopPropagation(),i()},onDoubleClick:r=>r.stopPropagation(),style:{width:18,height:18,padding:0,borderRadius:3,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",border:a?"1px solid rgba(255,255,255,0.7)":`1px solid ${n}88`,background:a?"rgba(255,255,255,0.18)":"#FFFFFF",color:a?"#FFFFFF":n,fontSize:11,lineHeight:1,cursor:"pointer",fontWeight:700},children:"↳"})}function zn({label:t,isCollapsed:i,onToggle:n,color:a,onColor:r}){return e.jsx("button",{"aria-label":i?`Expand ${t}`:`Collapse ${t}`,onClick:l=>{l.stopPropagation(),n()},style:{marginLeft:"auto",width:18,height:18,padding:0,borderRadius:3,border:r?"1px solid rgba(255,255,255,0.7)":`1px solid ${a}88`,background:r?"rgba(255,255,255,0.18)":"#FFFFFF",color:r?"#FFFFFF":a,fontSize:13,lineHeight:"15px",cursor:"pointer",fontWeight:700,flexShrink:0},children:i?"+":"−"})}function ur({id:t,data:i,selected:n,height:a}){const r=i,{label:l,kind:p,color:f,isContainer:w,isFrame:F,ports:I,implicitIn:h,implicitOut:C,onPortMove:j,hasChildren:m,isCollapsed:A,onToggleCollapse:b,onDrillIn:v,minWidth:T,minHeight:W,bgColor:E,fillOpacity:R}=r,[Q,H]=d.useState(!1),z=n?ce.selected:F?"none":Q?"0 8px 20px rgba(15,23,42,0.12)":w?"0 1px 2px rgba(15,23,42,0.05)":"0 2px 8px rgba(15,23,42,0.08)";return e.jsxs("div",{onMouseEnter:()=>H(!0),onMouseLeave:()=>H(!1),style:{width:"100%",height:"100%",boxSizing:"border-box",background:E||"#FFFFFF",opacity:R??1,border:F?"1.5px solid #94A3B8":`1px solid ${Q?f+"9A":"#CBD5E1"}`,...F?{}:{borderTop:`3px solid ${f}`},borderRadius:F?10:8,boxShadow:z,transition:"box-shadow 150ms ease, border-color 150ms ease",position:"relative"},children:[!F&&e.jsx(tt,{nodeId:t,isVisible:n,minWidth:T??180,minHeight:W??100,color:"#2563EB",lineStyle:{borderWidth:1},handleStyle:{width:10,height:10,borderRadius:2}}),e.jsx(N,{type:"target",position:k.Top,id:"top",style:kt}),e.jsx(N,{type:"source",position:k.Bottom,id:"bottom",style:kt}),e.jsx(N,{type:"target",position:k.Left,id:"left",style:kt}),e.jsx(N,{type:"source",position:k.Right,id:"right",style:kt}),F?e.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,height:38,display:"flex",alignItems:"center",gap:8,padding:"0 10px",background:"#F8FAFC",borderBottom:"1px solid #E2E8F0",borderRadius:"9px 9px 0 0"},children:[e.jsx("span",{style:{padding:"2px 6px",borderRadius:4,background:f,color:"#FFFFFF",fontSize:9,fontWeight:800,letterSpacing:"0.08em"},children:"IBD"}),e.jsx(Bn,{name:l,kind:p,nameColor:"#0F172A",typeColor:"#64748B",frame:!0}),m&&b&&e.jsx(zn,{label:l,isCollapsed:A,onToggle:b,color:f})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minHeight:58,padding:"7px 10px 6px",background:"#FFFFFF",borderBottom:m?"1px solid #E2E8F0":"none",borderRadius:"7px 7px 0 0",overflow:"hidden"},children:[mo(p)&&e.jsx(nt,{size:24,color:f}),e.jsx(Bn,{name:l,kind:p,nameColor:"#0F172A",typeColor:w?f:"#64748B"}),m&&v&&e.jsx(pr,{label:l,onDrillIn:v,color:f}),m&&b&&e.jsx(zn,{label:l,isCollapsed:A,onToggle:b,color:f})]}),I.map(q=>e.jsx(dr,{port:q,onMove:j?S=>{const te=q.size??go,K=(F||w?70:62)-te/2,X=Math.max(K,(a??K+te+18)-te-18);j(q.id,Math.min(Math.max(S,K),X))}:void 0},q.id)),h&&e.jsx(Mn,{side:"left",direction:"in"}),C&&e.jsx(Mn,{side:"right",direction:"out"})]})}const hr=d.memo(ur);function Tn(t,i){const n=t.map(r=>({...r}));let a=i;for(;n.length>=2&&a>0;){const r=n[0],l=n[1],p=Math.hypot(l.x-r.x,l.y-r.y);if(p<=a)a-=p,n.shift();else{const f=a/p;n[0]={x:r.x+(l.x-r.x)*f,y:r.y+(l.y-r.y)*f},a=0}}return n}function xr(t,i){const n=Tn(t,i);return Tn([...n].reverse(),i).reverse()}const gr=t=>t.slice(1).reduce((i,n,a)=>i+Math.hypot(n.x-t[a].x,n.y-t[a].y),0);function Ct(t,i=7){if(t.length<2)return"";let n=`M ${t[0].x},${t[0].y}`;for(let r=1;r<t.length-1;r++){const l=t[r-1],p=t[r],f=t[r+1],w=Math.hypot(p.x-l.x,p.y-l.y),F=Math.hypot(f.x-p.x,f.y-p.y),I=Math.min(i,w/2,F/2),h=p.x-Math.sign(p.x-l.x)*I,C=p.y-Math.sign(p.y-l.y)*I,j=p.x+Math.sign(f.x-p.x)*I,m=p.y+Math.sign(f.y-p.y)*I;n+=` L ${h},${C} Q ${p.x},${p.y} ${j},${m}`}const a=t[t.length-1];return`${n} L ${a.x},${a.y}`}function fr(t){let i=0,n=-1;for(let p=1;p<t.length;p++){const f=Math.abs(t[p].x-t[p-1].x)+Math.abs(t[p].y-t[p-1].y);f>n&&(n=f,i=p)}const a=t[i-1],r=t[i],l=Math.abs(r.x-a.x)>=Math.abs(r.y-a.y)?{x:0,y:-14}:{x:14,y:0};return{x:(a.x+r.x)/2+l.x,y:(a.y+r.y)/2+l.y}}function mr(t){var A,b,v,T,W,E,R,Q,H,z,q;const{getZoom:i}=xo(),n=Yn(t.id,[t.source,t.target,(A=t.data)==null?void 0:A.sourcePortId,(b=t.data)==null?void 0:b.targetPortId]),a=fo()&&!n,r=((v=t.data)==null?void 0:v.points)??[];if(r.length<2)return null;const l=String(((T=t.style)==null?void 0:T.stroke)??"#2563EB"),p=Number(((W=t.style)==null?void 0:W.strokeWidth)??2),f=n?{...t.style,strokeWidth:p+1.4}:t.style,w=((E=t.data)==null?void 0:E.labelPoint)??fr(r),F=Math.min(28/Math.max(i(),.1),gr(r)*.3),I=xr(r,F),h=(R=t.data)==null?void 0:R.onRouteChange,C=(Q=t.data)==null?void 0:Q.onSelect,j=!!((H=t.data)!=null&&H.flowAnimation),m=r.length===2?[{index:1,a:r[0],b:r[1],straight:!0}]:r.slice(1).map((S,te)=>({index:te+1,a:r[te],b:S,straight:!1})).filter(S=>S.index>=2&&S.index<=r.length-2);return e.jsxs(e.Fragment,{children:[n&&e.jsx("path",{d:Ct(r),fill:"none",stroke:l,strokeOpacity:.22,strokeWidth:p+9,strokeLinecap:"round",pointerEvents:"none"}),e.jsx(_n,{id:t.id,path:Ct(r),style:f,markerEnd:t.markerEnd}),j&&e.jsx("path",{d:Ct(r),fill:"none",stroke:String(((z=t.style)==null?void 0:z.stroke)??"#2563EB"),strokeWidth:Math.max(2,Number(((q=t.style)==null?void 0:q.strokeWidth)??2)),className:"memo-ibd-flow"}),I.length>=2&&e.jsx("path",{d:Ct(I),fill:"none",stroke:"transparent",strokeWidth:18/Math.max(i(),.1),pointerEvents:"stroke",cursor:"pointer",onClick:S=>C==null?void 0:C(S)}),t.label?e.jsx(po,{children:e.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${w.x}px, ${w.y}px)`,fontSize:D.badge,fontWeight:n?700:600,color:n?"#0F172A":"#475569",background:"rgba(255,255,255,0.96)",border:`1px solid ${n?l:"#E2E8F0"}`,opacity:a?.25:1,padding:"1px 4px",borderRadius:4,pointerEvents:"none"},children:t.label})}):null,t.selected&&h?m.map(S=>{const te=(S.a.x+S.b.x)/2,K=(S.a.y+S.b.y)/2;return e.jsx(po,{children:e.jsx("div",{className:"nodrag nopan",title:"Drag connector segment",onPointerDown:X=>{X.preventDefault(),X.stopPropagation();const st=X.clientX,it=X.clientY,ve=Ae=>{const re=(Ae.clientX-st)/i(),ge=(Ae.clientY-it)/i();if(S.straight){if(Math.abs(ge)>=Math.abs(re)){const ae=S.a.y+ge;h([S.a,{x:S.a.x,y:ae},{x:S.b.x,y:ae},S.b])}else{const ae=(S.a.x+S.b.x)/2+re;h([S.a,{x:ae,y:S.a.y},{x:ae,y:S.b.y},S.b])}return}const Z=r.map(ae=>({...ae}));S.a.y===S.b.y?(Z[S.index-1].y=S.a.y+ge,Z[S.index].y=S.b.y+ge):(Z[S.index-1].x=S.a.x+re,Z[S.index].x=S.b.x+re),h(Z)},Ne=()=>{window.removeEventListener("pointermove",ve),window.removeEventListener("pointerup",Ne)};window.addEventListener("pointermove",ve),window.addEventListener("pointerup",Ne,{once:!0})},style:{position:"absolute",transform:`translate(-50%, -50%) translate(${te}px, ${K}px)`,width:12,height:12,borderRadius:3,background:"#FFFFFF",border:"2px solid #2563EB",boxShadow:"0 1px 4px rgba(15,23,42,0.22)",cursor:S.a.y===S.b.y?"ns-resize":"ew-resize",pointerEvents:"all",touchAction:"none",zIndex:20}})},`route-${S.index}`)}):null]})}const yr=d.memo(mr);function br({onDrillIn:t,color:i,label:n}){return e.jsx("button",{onClick:a=>{a.stopPropagation(),t()},onDoubleClick:a=>a.stopPropagation(),className:"nodrag",title:`Open ${n} as its own diagram`,"aria-label":`Drill into ${n}`,style:{width:16,height:16,flexShrink:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${i}66`,borderRadius:4,background:"#FFFFFF",color:i,fontSize:10,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"↳"})}function Fr({data:t,selected:i}){const n=t,{nodeType:a,label:r,laneColor:l,layerColor:p,inPorts:f,outPorts:w}=n,[F,I]=d.useState(!1);if(a==="start")return e.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:"#374151",border:"2px solid #374151",boxShadow:ce.sm},children:e.jsx(N,{type:"source",position:n.flowDirection==="vertical"?k.Bottom:k.Right,style:{background:"#374151",width:6,height:6}})});if(a==="done")return e.jsxs("div",{style:{width:28,height:28,borderRadius:"50%",background:"#FFFFFF",border:"3px solid #374151",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:ce.sm},children:[e.jsx("div",{style:{width:14,height:14,borderRadius:"50%",background:"#374151"}}),e.jsx(N,{type:"target",position:n.flowDirection==="vertical"?k.Top:k.Left,style:{background:"#374151",width:6,height:6}})]});if(a==="fork"||a==="join"){const m=n.flowDirection==="vertical";return e.jsxs("div",{title:a==="fork"?"Fork — split into concurrent flows":"Join — synchronize concurrent flows",style:{width:"100%",height:"100%",background:"#374151",borderRadius:3,boxShadow:ce.sm},children:[e.jsx(N,{type:"target",position:m?k.Top:k.Left,style:{background:"#374151",width:6,height:6,border:"none"}}),e.jsx(N,{type:"source",position:m?k.Bottom:k.Right,style:{background:"#374151",width:6,height:6,border:"none"}})]})}const h=l||p||"#9CA3AF";if(n.isFrame)return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:`${h}08`,border:`1.5px solid ${h}66`,borderRadius:10,boxShadow:i?"0 0 0 3px #2DD4A8":"none",position:"relative"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px 0"},children:[n.onToggleExpand&&e.jsx("button",{"aria-label":`Collapse ${r}`,className:"nodrag",onClick:m=>{m.stopPropagation(),n.onToggleExpand()},onDoubleClick:m=>m.stopPropagation(),style:{width:16,height:16,flexShrink:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${h}66`,borderRadius:4,background:"#FFFFFF",color:h,fontSize:11,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"−"}),n.onDrillIn&&e.jsx(br,{onDrillIn:n.onDrillIn,color:h,label:r}),e.jsx("span",{style:{fontSize:D.md,fontWeight:700,color:h,whiteSpace:"nowrap"},children:r}),n.allocatedTo&&e.jsxs("span",{style:{fontSize:"9px",color:"#9CA3AF",whiteSpace:"nowrap"},children:["→"," ",n.allocatedTo]})]}),e.jsx(N,{type:"target",position:n.flowDirection==="vertical"?k.Top:k.Left,style:{background:h,width:8,height:8,border:"2px solid #FFFFFF"}}),e.jsx(N,{type:"source",position:n.flowDirection==="vertical"?k.Bottom:k.Right,style:{background:h,width:8,height:8,border:"2px solid #FFFFFF"}})]});const C=18,j=Math.max(f.length*C,w.length*C,0);return e.jsxs("div",{onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),style:{background:"#FFFFFF",border:`1.5px solid ${h}`,borderRadius:3,minWidth:"140px",boxShadow:i?"0 0 0 3px #2DD4A8, 0 4px 12px rgba(45, 212, 168, 0.35)":F?`0 0 0 2px ${h}22`:"none",transition:"box-shadow 150ms ease",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"8px 14px",fontSize:D.md,fontWeight:600,color:"#1a1a1a",background:`${h}0D`,borderBottom:j>0?"1px solid #E5E5E0":"none",textAlign:"center",whiteSpace:"nowrap"},children:[r,n.hasChildren&&n.onDrillIn&&e.jsx("button",{"aria-label":`Drill into ${r}`,title:`Open ${r} as its own diagram`,className:"nodrag",onClick:m=>{m.stopPropagation(),n.onDrillIn()},onDoubleClick:m=>m.stopPropagation(),style:{float:"right",marginLeft:4,width:18,height:18,padding:0,border:`1px solid ${h}`,borderRadius:2,background:"#FFFFFF",color:h,fontSize:11,fontWeight:700,lineHeight:"16px",cursor:"pointer"},children:"↳"}),n.hasChildren&&n.onToggleExpand&&e.jsx("button",{"aria-label":n.isExpanded?`Collapse ${r}`:`Expand ${r}`,onClick:m=>{m.stopPropagation(),n.onToggleExpand()},style:{float:"right",marginLeft:8,width:18,height:18,padding:0,border:`1px solid ${h}`,borderRadius:2,background:"#FFFFFF",color:h,fontSize:13,fontWeight:700,lineHeight:"16px",cursor:"pointer"},children:n.isExpanded?"−":"+"})]}),j>0&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"4px 0"},children:[e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:f.map(m=>e.jsxs("div",{style:{fontSize:D.badge,color:"#6B7280",paddingLeft:"8px",display:"flex",alignItems:"center",height:`${C}px`,gap:"4px"},children:[e.jsx("span",{style:{width:"6px",height:"6px",borderRadius:"50%",background:"#3498DB",flexShrink:0}}),m]},`in-${m}`))}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px",alignItems:"flex-end"},children:w.map(m=>e.jsxs("div",{style:{fontSize:D.badge,color:"#6B7280",paddingRight:"8px",display:"flex",alignItems:"center",height:`${C}px`,gap:"4px"},children:[m,e.jsx("span",{style:{width:"6px",height:"6px",borderRadius:"50%",background:"#E67E22",flexShrink:0}})]},`out-${m}`))})]}),n.allocatedTo&&e.jsxs("div",{style:{fontSize:"9px",color:"#9CA3AF",textAlign:"center",padding:"2px 6px",borderTop:"1px solid #F3F4F6",background:"#FAFAFA"},children:["→"," ",n.allocatedTo]}),e.jsx(N,{type:"target",position:n.flowDirection==="vertical"?k.Top:k.Left,style:{background:h,width:8,height:8,border:"2px solid #FFFFFF"}}),e.jsx(N,{type:"source",position:n.flowDirection==="vertical"?k.Bottom:k.Right,style:{background:h,width:8,height:8,border:"2px solid #FFFFFF"}})]})}const wr=d.memo(Fr);function jr({data:t,selected:i}){const n=t,a=n.orientation==="column";return e.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:`${n.color}08`,border:i?"3px solid #2DD4A8":`1px solid ${n.color}30`,borderLeft:i?"3px solid #2DD4A8":a?`1px solid ${n.color}30`:`3px solid ${n.color}`,borderTop:i?"3px solid #2DD4A8":a?`3px solid ${n.color}`:`1px solid ${n.color}30`,borderRadius:ci.md,pointerEvents:"auto",cursor:n.inspectElementId?"pointer":"default",display:"flex"},children:e.jsx("div",{style:{writingMode:a?"horizontal-tb":"vertical-rl",transform:a?void 0:"rotate(180deg)",padding:a?"7px 10px":"10px 6px",fontSize:D.xs,fontWeight:700,color:n.color,letterSpacing:"0.04em",textTransform:"uppercase",alignSelf:a?"flex-start":"center",width:a?"100%":void 0,textAlign:a?"center":void 0,whiteSpace:"nowrap"},children:n.label})})}const Sr=d.memo(jr);function Rn({onDrillIn:t,color:i,label:n}){return e.jsx("button",{onClick:a=>{a.stopPropagation(),t()},onDoubleClick:a=>a.stopPropagation(),className:"nodrag",title:`Open ${n} as its own diagram`,"aria-label":`Drill into ${n}`,style:{width:16,height:16,flexShrink:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${i}66`,borderRadius:4,background:"#FFFFFF",color:i,fontSize:10,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"↳"})}function Ln({collapsed:t,onToggle:i,color:n}){return e.jsx("button",{onClick:a=>{a.stopPropagation(),i()},onDoubleClick:a=>a.stopPropagation(),className:"nodrag",title:t?"Show substates":"Hide substates","aria-label":t?"Show substates":"Hide substates",style:{width:16,height:16,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${n}66`,borderRadius:4,background:"#FFFFFF",color:n,fontSize:11,fontWeight:700,lineHeight:1,cursor:"pointer"},children:t?"+":"−"})}const Et={width:8,height:8,border:"none",background:"transparent",opacity:0};function ro(){return e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"target",position:k.Top,id:"top",style:Et}),e.jsx(N,{type:"source",position:k.Bottom,id:"bottom",style:Et}),e.jsx(N,{type:"target",position:k.Left,id:"left",style:Et}),e.jsx(N,{type:"source",position:k.Right,id:"right",style:Et})]})}function vr({data:t,selected:i}){const n=t,[a,r]=d.useState(!1);if(n.isNote)return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#FFFDF5",border:`1px solid ${n.color}66`,borderRadius:4,padding:"6px 10px",boxShadow:ce.sm,display:"flex",flexDirection:"column",justifyContent:"center"},title:n.kind,children:[e.jsx(ro,{}),e.jsx("span",{style:{fontSize:D.xs,fontWeight:600,color:"#374151",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n.label}),e.jsx("span",{style:{fontSize:"8px",fontWeight:700,color:n.color,textTransform:"uppercase",letterSpacing:"0.05em"},children:n.kind})]});if(n.isContainer)return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:n.isMachine?"transparent":`${n.color}06`,borderTop:n.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${n.color}55`,borderRight:n.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${n.color}55`,borderBottom:n.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${n.color}55`,borderLeft:n.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${n.color}55`,borderRadius:14,boxShadow:i?ce.selected:"none",position:"relative"},children:[e.jsx(ro,{}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px 0"},children:[n.onToggleCollapse&&!n.isMachine&&e.jsx(Ln,{collapsed:!1,onToggle:n.onToggleCollapse,color:n.color}),n.onDrillIn&&!n.isMachine&&e.jsx(Rn,{onDrillIn:n.onDrillIn,color:n.color,label:n.label}),e.jsx("span",{style:{fontSize:D.md,fontWeight:700,color:n.isMachine?"#334155":n.color,whiteSpace:"nowrap"},children:n.label}),e.jsx("span",{style:{fontSize:"8px",fontWeight:700,color:n.isMachine?"#94A3B8":`${n.color}AA`,textTransform:"uppercase",letterSpacing:"0.06em"},children:n.kind})]})]});const l=!!n.hasChildren;return e.jsxs("div",{onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),title:l?`${n.hiddenCount??0} substate${n.hiddenCount===1?"":"s"} hidden — double-click to drill in`:void 0,style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#FFFFFF",borderTop:`3px solid ${n.color}`,borderRight:`1px solid ${a?`${n.color}9A`:"#CBD5E1"}`,borderBottom:`1px solid ${a?`${n.color}9A`:"#CBD5E1"}`,borderLeft:`1px solid ${a?`${n.color}9A`:"#CBD5E1"}`,borderRadius:12,boxShadow:i?ce.selected:a?"0 8px 20px rgba(15,23,42,0.12)":ce.md,transition:"box-shadow 150ms ease, border-color 150ms ease",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,padding:"4px 12px"},children:[e.jsx(ro,{}),e.jsx("span",{style:{fontSize:D.md,fontWeight:600,color:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:n.label}),n.subtitle&&e.jsx("span",{style:{fontSize:"8px",fontWeight:600,color:"#9CA3AF",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:n.subtitle}),l&&e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5},children:[n.onToggleCollapse&&e.jsx(Ln,{collapsed:!0,onToggle:n.onToggleCollapse,color:n.color}),n.onDrillIn&&e.jsx(Rn,{onDrillIn:n.onDrillIn,color:n.color,label:n.label}),e.jsxs("span",{style:{fontSize:"8px",fontWeight:700,color:n.color,letterSpacing:"0.05em"},children:["⊞ ",n.hiddenCount??0]})]})]})}const kr=d.memo(vr),ho="#3498DB";function Cr({data:t}){const i=t;return e.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",pointerEvents:"none"},children:[e.jsx("div",{style:{position:"absolute",top:0,left:"50%",transform:"translateX(-50%)",minWidth:140,maxWidth:"90%",padding:"10px 16px",background:"#FFFFFF",border:`1.5px solid ${ho}`,borderRadius:8,boxShadow:ce.md,textAlign:"center",fontSize:D.md,fontWeight:600,color:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i.label}),e.jsx("div",{style:{position:"absolute",top:44,bottom:0,left:"50%",borderLeft:`1.5px dashed ${ho}66`}})]})}const Er=d.memo(Cr);function Ir({data:t}){const i=t;return e.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#1B3A4B06",border:"1px solid #1B3A4B22",borderRadius:10,pointerEvents:"none"},children:e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,padding:"8px 14px"},children:[e.jsx("span",{style:{fontSize:D.sm,fontWeight:700,color:"#1B3A4B"},children:i.label}),i.scenario&&e.jsxs("span",{style:{fontSize:D.xs,color:"#6B7280"},children:["realizes ",i.scenario]})]})})}const Dr=d.memo(Ir),It={width:6,height:6,border:"none",background:"transparent",opacity:0};function Nr({data:t,selected:i}){const n=t;return e.jsxs("div",{style:{width:14,height:14,borderRadius:"50%",background:"#FFFFFF",border:`3px solid ${ho}`,boxShadow:i?ce.selected:ce.sm,position:"relative"},title:n.kind,children:[e.jsx(N,{type:"source",id:"right",position:k.Right,style:It}),e.jsx(N,{type:"target",id:"right",position:k.Right,style:It}),e.jsx(N,{type:"source",id:"left",position:k.Left,style:It}),e.jsx(N,{type:"target",id:"left",position:k.Left,style:It}),e.jsx("span",{style:{position:"absolute",top:-20,left:"50%",transform:"translateX(-50%)",fontSize:"9px",fontWeight:600,color:"#374151",whiteSpace:"nowrap",background:"#FFFFFFCC",padding:"1px 5px",borderRadius:4},children:n.label})]})}const Ar=d.memo(Nr),zt={opacity:0,width:1,height:1},Mr=d.memo(function({data:i}){const n=i;return e.jsxs("div",{style:{width:"100%",height:"100%",display:"grid",placeItems:"center",textAlign:"center",padding:"12px 22px",border:`2px solid ${n.color??"#E67E22"}`,borderRadius:"50%",background:"#FFF9F2",color:"#2D3748",fontSize:13,fontWeight:600,lineHeight:1.25},children:[n.label,e.jsx(N,{type:"target",position:k.Left,style:zt}),e.jsx(N,{type:"source",position:k.Right,style:zt})]})}),Br=d.memo(function({data:i}){const n=i,a=n.side==="right"?k.Left:k.Right;return e.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#334155",fontSize:12,fontWeight:600,textAlign:"center",gap:3},children:[e.jsx(nt,{color:n.color??"#334155"}),e.jsx("span",{children:n.label}),e.jsx(N,{type:"source",position:a,style:zt}),e.jsx(N,{type:"target",position:a,style:zt})]})}),zr=d.memo(function({data:i}){const n=i;return e.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",border:"1.5px solid #64748B",background:"rgba(255,255,255,0.32)",padding:"10px 14px",color:"#475569",fontSize:12,fontWeight:700},children:n.label})});d.memo(function({data:i}){const n=i;return e.jsx("div",{style:{width:"100%",textAlign:"center",color:"#64748B",fontSize:11,fontWeight:700,letterSpacing:".03em"},children:n.label})});function Tr(t,i=0){if(t.length<2)return"";if(i===0||t.length===2)return`M ${t.map(r=>`${r.x},${r.y}`).join(" L ")}`;let n=`M ${t[0].x},${t[0].y}`;for(let r=1;r<t.length-1;r++){const l=t[r-1],p=t[r],f=t[r+1],w=Math.min(i,Math.abs(p.x-l.x)/2+Math.abs(p.y-l.y)/2),F=Math.min(i,Math.abs(f.x-p.x)/2+Math.abs(f.y-p.y)/2),I={x:p.x+Math.sign(l.x-p.x)*w,y:p.y+Math.sign(l.y-p.y)*w},h={x:p.x+Math.sign(f.x-p.x)*F,y:p.y+Math.sign(f.y-p.y)*F};n+=` L ${I.x},${I.y} Q ${p.x},${p.y} ${h.x},${h.y}`}const a=t[t.length-1];return`${n} L ${a.x},${a.y}`}const Rr=d.memo(function(i){var C,j,m,A,b;const n=Yn(i.id,[i.source,i.target]),a=fo()&&!n,r=((C=i.data)==null?void 0:C.routing)??"rounded",l=Array.isArray((j=i.data)==null?void 0:j.points)?i.data.points:[],p=l.length>=2?l:[{x:i.sourceX,y:i.sourceY},{x:i.targetX,y:i.targetY}],w=r==="straight"?`M ${i.sourceX},${i.sourceY} L ${i.targetX},${i.targetY}`:Tr(p,r==="elbow"?0:r==="rounded"?16:r==="curved"?30:42),F=((m=i.data)==null?void 0:m.labelPoint)??p[Math.floor(p.length/2)]??{x:(i.sourceX+i.targetX)/2,y:(i.sourceY+i.targetY)/2},I=String(((A=i.style)==null?void 0:A.stroke)??"#64748B"),h=Number(((b=i.style)==null?void 0:b.strokeWidth)??1.5);return e.jsxs(e.Fragment,{children:[n&&e.jsx("path",{d:w,fill:"none",stroke:I,strokeOpacity:.22,strokeWidth:h+9,strokeLinecap:"round",pointerEvents:"none"}),e.jsx(_n,{path:w,style:n?{...i.style,strokeWidth:h+1.4}:i.style}),i.label&&e.jsx(po,{children:e.jsx("div",{className:"nodrag nopan",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${F.x}px,${F.y}px)`,background:"#FFFFFF",padding:"2px 5px",borderRadius:3,color:n?"#0F172A":"#334155",fontSize:12,pointerEvents:"all",fontWeight:n?700:void 0,opacity:a?.25:1},children:i.label})})]})}),Dt={opacity:0,width:1,height:1};function Zn(){return e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"target",position:k.Left,style:Dt}),e.jsx(N,{type:"source",position:k.Right,style:Dt}),e.jsx(N,{type:"target",position:k.Top,style:Dt}),e.jsx(N,{type:"source",position:k.Bottom,style:Dt})]})}const Lr=d.memo(function({data:i}){const n=i;return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",display:"grid",placeItems:"center",padding:"14px 18px",textAlign:"center",border:"2px solid #0F766E",borderRadius:8,background:"#F0FDFA",color:"#134E4A",fontSize:15,fontWeight:700,lineHeight:1.25,boxShadow:"0 2px 7px rgba(15, 118, 110, 0.16)"},children:[e.jsxs("span",{children:[e.jsx("small",{style:{display:"block",marginBottom:5,color:"#0F766E",fontSize:10,letterSpacing:".08em"},children:"SYSTEM OF INTEREST"}),n.label]}),e.jsx(Zn,{})]})}),$r=d.memo(function({data:i}){const n=i,a=n.category==="environment"?{border:"#7C3AED",fill:"#F5F3FF",text:"#4C1D95",tag:"ENVIRONMENT"}:n.category==="person"?{border:"#2563EB",fill:"#EFF6FF",text:"#1E3A8A",tag:"ACTOR"}:{border:"#64748B",fill:"#F8FAFC",text:"#334155",tag:"EXTERNAL SYSTEM"};return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:3,padding:"10px 14px",textAlign:"center",border:`1.5px solid ${a.border}`,borderRadius:7,background:a.fill,color:a.text,fontSize:13,fontWeight:650,lineHeight:1.25},children:[n.category==="person"&&e.jsx(nt,{size:26,color:a.border}),e.jsxs("span",{children:[e.jsx("small",{style:{display:"block",marginBottom:4,color:a.border,fontSize:9,letterSpacing:".07em"},children:a.tag}),n.label]}),e.jsx(Zn,{})]})}),Wr=d.memo(function({data:i}){const n=i;return e.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",border:"2px solid #0F766E",borderRadius:12,background:"rgba(240, 253, 250, 0.34)",padding:"12px 16px",color:"#0F766E",fontSize:12,fontWeight:750,letterSpacing:".04em"},children:n.label})}),Or=d.memo(function({id:i,data:n,selected:a}){var W;const r=n,[l,p]=d.useState(!1),[f,w]=d.useState(""),[F,I]=d.useState(!1),h=d.useRef(null),C=d.useCallback(()=>{w(r.label),p(!0),setTimeout(()=>{var E;(E=h.current)==null||E.select()},10)},[r.label]),j=d.useCallback(()=>{var R;p(!1);const E=f.trim();E&&E!==r.label&&((R=r.onInlineEdit)==null||R.call(r,i,E))},[f,r,i]),m=d.useCallback(E=>{E.key==="Enter"&&(E.preventDefault(),j()),E.key==="Escape"&&p(!1)},[j]),A=d.useCallback(E=>{var R;E.preventDefault(),(R=r.onContextMenu)==null||R.call(r,E,i)},[r,i]),b=r.bgColor??"#FFFFFF",v=r.color,T={background:v,border:"2px solid #FFFFFF",width:10,height:10,opacity:F||a?1:0,transition:"opacity 0.15s"};return e.jsxs("div",{onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),onContextMenu:A,onDoubleClick:C,style:{minWidth:120,minHeight:40,background:b,borderLeft:`3px solid ${v}`,borderRadius:8,boxShadow:a?`0 0 0 2px ${v}, 0 4px 12px ${v}44`:F?"0 4px 16px rgba(0,0,0,0.14)":"0 1px 4px rgba(0,0,0,0.08)",cursor:l?"text":"grab",position:"relative",transition:"box-shadow 0.15s",opacity:r.isNew?.7:1},children:[a&&e.jsx(tt,{minWidth:80,minHeight:36,maxWidth:600,maxHeight:400,color:v,lineStyle:{borderColor:v},handleStyle:{background:v,border:"2px solid #fff",width:10,height:10,borderRadius:2}}),e.jsxs("div",{style:{padding:"8px 12px",userSelect:"none",display:"flex",gap:8,alignItems:"center"},children:[mo(r.kind)&&e.jsx(nt,{size:26,color:v}),e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsx("div",{style:{fontSize:"9px",fontWeight:700,color:v,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:2},children:r.kind}),l?e.jsx("input",{ref:h,value:f,onChange:E=>w(E.target.value),onBlur:j,onKeyDown:m,onClick:E=>E.stopPropagation(),autoFocus:!0,style:{fontSize:D.sm,fontWeight:500,color:"#1a1a1a",background:"transparent",border:"none",outline:"none",width:"100%",padding:0}}):e.jsx("div",{style:{fontSize:D.sm,fontWeight:500,color:"#1a1a1a",lineHeight:1.3,wordBreak:"break-word"},children:r.label||r.kind}),r.isNew&&e.jsx("div",{style:{fontSize:"9px",color:"#9CA3AF",marginTop:2},children:"saving…"})]})]}),!!((W=r.compartments)!=null&&W.length)&&e.jsx("div",{style:{borderTop:"1px solid #EDEDEA",padding:"5px 12px 7px",userSelect:"none"},children:r.compartments.map(E=>e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"baseline",fontSize:"10px",lineHeight:"15px",whiteSpace:"nowrap",overflow:"hidden"},children:[e.jsx("span",{style:{color:"#9CA3AF"},children:E.key}),e.jsx("span",{style:{color:"#4B5563",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis"},children:E.value})]},E.key))}),e.jsx(N,{type:"target",position:k.Top,style:{...T,top:-5}}),e.jsx(N,{type:"source",position:k.Bottom,style:{...T,bottom:-5},id:"bottom"}),e.jsx(N,{type:"source",position:k.Right,style:{...T,right:-5},id:"right"}),e.jsx(N,{type:"target",position:k.Left,style:{...T,left:-5}})]})}),Qn="application/memo-kind";function ao({collapsed:t,onToggleCollapse:i,elementIds:n=[],eligibleKinds:a}){const r=O(b=>b.model),l=O(b=>b.selectedElementId),p=O(b=>b.inspectElement),[f,w]=d.useState(""),[F,I]=d.useState(new Set),[h,C]=d.useState(!0),j=d.useMemo(()=>{if(!(a!=null&&a.size))return[];const b=f.trim().toLowerCase();return Kn(r).kinds.filter(v=>a.has(v.name)&&!v.isAbstract).filter(v=>!b||v.name.toLowerCase().includes(b)||(v.label??"").toLowerCase().includes(b)).map(v=>({name:v.name,label:v.label||v.name,layer:v.layer??"",construct:Vi(v.construct)})).sort((v,T)=>v.label.localeCompare(T.label))},[r,a,f]),m=d.useMemo(()=>{var W;if(!r)return[];const b=f.trim().toLowerCase(),v=new Map,T=new Set(n);for(const E of n){const R=(W=r.elements[E])==null?void 0:W.allocatedTo;R&&T.add(R)}for(const E of T){const R=r.elements[E];R&&(b&&!R.name.toLowerCase().includes(b)&&!R.kind.toLowerCase().includes(b)||(v.has(R.kind)||v.set(R.kind,[]),v.get(R.kind).push(R)))}return[...v.entries()].map(([E,R])=>({kind:E,elements:R.sort((Q,H)=>Q.name.localeCompare(H.name))})).sort((E,R)=>E.kind.localeCompare(R.kind))},[r,n,f]),A=b=>I(v=>{const T=new Set(v);return T.has(b)?T.delete(b):T.add(b),T});return t?e.jsxs("button",{className:"flex flex-col items-center py-2 gap-1 cursor-pointer",style:{width:36,border:0,borderRight:"1px solid #E5E5E0",background:"#FAFAF8",flexShrink:0},onClick:i,title:"Expand diagram elements","aria-label":"Expand diagram elements",children:[e.jsx("span",{style:{color:"#6B7280",fontSize:18},children:"›"}),e.jsx("span",{style:{fontSize:10,color:"#6B7280",writingMode:"vertical-rl"},children:"Diagram Elements"})]}):e.jsxs("div",{className:"flex flex-col overflow-hidden",style:{width:240,borderRight:"1px solid #E5E5E0",background:"#FAFAF8",flexShrink:0},children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",style:{borderBottom:"1px solid #E5E5E0",flexShrink:0},children:[e.jsx("span",{style:{fontSize:D.xs,fontWeight:600,color:"#374151"},children:"Diagram Elements"}),e.jsx("button",{onClick:i,title:"Collapse diagram elements","aria-label":"Collapse diagram elements",style:{background:"none",border:"none",cursor:"pointer",color:"#6B7280",fontSize:18,lineHeight:1},children:"‹"})]}),e.jsx("div",{className:"px-2 pt-2 pb-1",style:{flexShrink:0},children:e.jsx("input",{value:f,onChange:b=>w(b.target.value),placeholder:"Search elements…",className:"w-full px-2 py-1 rounded focus:outline-none",style:{fontSize:D.xs,background:"#F0F0ED",border:"1px solid #E5E5E0",color:"#374151"}})}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[j.length>0&&e.jsxs("div",{style:{borderBottom:"1px solid #E5E5E0",paddingBottom:4,marginBottom:4},children:[e.jsxs("button",{onClick:()=>C(b=>!b),className:"w-full flex items-center gap-1.5 px-2 py-1",style:{background:"none",border:"none",cursor:"pointer",textAlign:"left"},children:[e.jsx("span",{style:{fontSize:10,color:"#6B7280"},children:h?"▼":"▶"}),e.jsx("span",{style:{fontSize:10,color:"#374151",fontWeight:700,letterSpacing:"0.04em"},children:"SHAPES"}),e.jsx("span",{style:{fontSize:9,color:"#9CA3AF",marginLeft:"auto"},children:j.length})]}),h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pb-1",style:{fontSize:9,color:"#9CA3AF"},children:"Drag onto the canvas to create"}),j.map(b=>{const v=uo[b.layer]??"#6B7280";return e.jsxs("div",{draggable:!0,onDragStart:T=>{T.dataTransfer.setData(Qn,JSON.stringify({kind:b.name,layer:b.layer,construct:b.construct})),T.dataTransfer.effectAllowed="copy"},title:`Drag to create a ${b.label} (${b.construct})`,className:"flex items-center gap-2 px-3 py-1.5",style:{cursor:"grab",fontSize:D.xs,color:"#374151"},children:[e.jsx("span",{style:{width:12,height:12,flexShrink:0,borderRadius:b.construct==="port"?2:3,border:`2px solid ${v}`,background:b.construct==="port"?"#FFFFFF":`${v}22`}}),e.jsx("span",{className:"truncate flex-1",children:b.label})]},b.name)})]})]}),m.map(b=>{var W;const v=F.has(b.kind),T=uo[(W=b.elements[0])==null?void 0:W.layer]??"#6B7280";return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>A(b.kind),className:"w-full flex items-center gap-1.5 px-2 py-1",style:{background:"none",border:"none",cursor:"pointer",textAlign:"left"},children:[e.jsx("span",{style:{fontSize:10,color:T},children:v?"▶":"▼"}),e.jsx("span",{className:"truncate",style:{fontSize:10,color:T,fontWeight:700},children:b.kind}),e.jsx("span",{style:{fontSize:9,color:"#9CA3AF",marginLeft:"auto"},children:b.elements.length})]}),!v&&b.elements.map(E=>{const R=l===E.id;return e.jsxs("button",{onClick:()=>p(E.id),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left",style:{border:"none",cursor:"pointer",fontSize:D.xs,background:R?"#DDF7EF":"transparent",color:R?"#116149":"#374151",fontWeight:R?600:400},title:`Highlight ${E.name} in diagram`,children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2,background:T,flexShrink:0}}),e.jsx("span",{className:"truncate flex-1",children:E.name})]},E.id)})]},b.kind)}),m.length===0&&e.jsx("div",{className:"p-3 text-center",style:{color:"#9CA3AF",fontSize:D.xs},children:f?"No matching elements":"No elements in this diagram"})]})]})}function ne({label:t,icon:i,danger:n,onClick:a}){return e.jsxs("button",{onClick:a,className:"w-full flex items-center gap-2 px-3 py-1.5 text-left",style:{background:"none",border:"none",cursor:"pointer",fontSize:D.xs},onMouseEnter:r=>{r.currentTarget.style.background=n?"#FEF2F2":"#F7F7F5"},onMouseLeave:r=>{r.currentTarget.style.background="none"},children:[i&&e.jsx("span",{style:{fontSize:"12px",width:16,textAlign:"center"},children:i}),e.jsx("span",{style:{color:n?"#DC2626":"#1a1a1a"},children:t})]})}function Bt(){return e.jsx("div",{style:{height:1,background:"#E5E5E0",margin:"2px 0"}})}function Jn({x:t,y:i,onClose:n,children:a}){const r=d.useRef(null);d.useEffect(()=>{const w=I=>{r.current&&!r.current.contains(I.target)&&n()},F=I=>{I.key==="Escape"&&n()};return document.addEventListener("mousedown",w),document.addEventListener("keydown",F),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",F)}},[n]);const l=210,p=Math.min(t,window.innerWidth-l-8),f=Math.min(i,window.innerHeight-200);return e.jsx("div",{ref:r,className:"fixed z-50 rounded-xl overflow-hidden py-1",style:{left:p,top:f,minWidth:l,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.14)"},children:a})}const Pr=[{label:"Layer default",value:""},{label:"Mint",value:"#E8F5E9"},{label:"Sky",value:"#E3F2FD"},{label:"Amber",value:"#FFF8E1"},{label:"Rose",value:"#FFF0F0"},{label:"Lavender",value:"#F3E5F5"},{label:"Peach",value:"#FBE9E7"}];function Hr({x:t,y:i,nodeId:n,nodeKind:a,onClose:r,onEditName:l,onChangeColor:p,onRemoveFromDiagram:f,onDeleteFromModel:w,onLinkRisk:F,onLinkRequirement:I,onShowProperties:h,onFocusElement:C,onShowInCatalog:j,onShowRelMatrix:m,onOpenSource:A,onViewKindInOntology:b}){const[v,T]=d.useState(!1);return e.jsxs(Jn,{x:t,y:i,onClose:r,children:[e.jsxs("div",{className:"px-3 py-1.5",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"#9CA3AF"},children:a}),e.jsx("div",{style:{fontSize:"9px",color:"#D1D5DB",fontFamily:"monospace"},children:n})]}),h&&e.jsx(ne,{label:"Show Properties",icon:"ℹ",onClick:()=>{r(),h()}}),j&&e.jsx(ne,{label:"Show in Catalog",icon:"☰",onClick:()=>{r(),j()}}),C&&e.jsx(ne,{label:"Focus on Element",icon:"◎",onClick:()=>{r(),C()}}),m&&e.jsx(ne,{label:"Show Relationship Matrix",icon:"☷",onClick:()=>{r(),m()}}),b&&e.jsx(ne,{label:"View Kind in Ontology",icon:"⬡",onClick:()=>{r(),b()}}),A&&e.jsx(ne,{label:"Open Source File",icon:"⟨/⟩",onClick:()=>{r(),A()}}),(h||j||C||m||b||A)&&e.jsx(Bt,{}),e.jsx(ne,{label:"Edit name",icon:"✏️",onClick:()=>{r(),l()}}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{className:"w-full flex items-center gap-2 px-3 py-1.5",style:{background:"none",border:"none",cursor:"pointer",fontSize:D.xs},onMouseEnter:W=>{T(!0),W.currentTarget.style.background="#F7F7F5"},onMouseLeave:W=>{W.currentTarget.style.background="none"},children:[e.jsx("span",{style:{fontSize:"12px",width:16,textAlign:"center"},children:"🎨"}),e.jsx("span",{style:{flex:1,textAlign:"left",color:"#1a1a1a"},children:"Change color"}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:"10px"},children:"▶"})]}),v&&e.jsx("div",{className:"absolute left-full top-0 rounded-xl overflow-hidden py-1",style:{background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",minWidth:160},onMouseEnter:()=>T(!0),onMouseLeave:()=>T(!1),children:Pr.map(W=>e.jsxs("button",{onClick:()=>{r(),p(W.value)},className:"w-full flex items-center gap-2.5 px-3 py-1.5",style:{background:"none",border:"none",cursor:"pointer"},onMouseEnter:E=>{E.currentTarget.style.background="#F7F7F5"},onMouseLeave:E=>{E.currentTarget.style.background="none"},children:[e.jsx("div",{style:{width:14,height:14,borderRadius:3,flexShrink:0,background:W.value||"#E5E5E0",border:"1px solid #D1D5DB"}}),e.jsx("span",{style:{fontSize:D.xs,color:"#374151"},children:W.label})]},W.value))})]}),e.jsx(Bt,{}),F&&e.jsx(ne,{label:"Link Risk",icon:"⚠️",onClick:()=>{r(),F()}}),I&&e.jsx(ne,{label:"Link Requirement",icon:"📋",onClick:()=>{r(),I()}}),(F||I)&&e.jsx(Bt,{}),e.jsx(ne,{label:"Remove from diagram",icon:"↩️",onClick:()=>{r(),f()}}),e.jsx(ne,{label:"Delete from model",icon:"🗑️",danger:!0,onClick:()=>{window.confirm(`Delete ${n} from the model? This cannot be undone.`)&&(r(),w())}})]})}const _r=[{label:"Auto",value:""},{label:"Red",value:"#EF4444"},{label:"Blue",value:"#3B82F6"},{label:"Green",value:"#10B981"},{label:"Orange",value:"#F59E0B"},{label:"Gray",value:"#6B7280"}];function Kr({x:t,y:i,edgeId:n,relType:a,onClose:r,onChangeStyle:l,onChangeColor:p,onToggleLabel:f,onDelete:w}){return e.jsxs(Jn,{x:t,y:i,onClose:r,children:[e.jsxs("div",{className:"px-3 py-1.5",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"#9CA3AF"},children:a}),e.jsx("div",{style:{fontSize:"9px",color:"#D1D5DB",fontFamily:"monospace"},children:n})]}),e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2",children:[e.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF",minWidth:40},children:"Style"}),["solid","dashed","dotted"].map(F=>e.jsx("button",{onClick:()=>{r(),l(F)},style:{fontSize:"10px",padding:"2px 8px",border:"1px solid #E5E5E0",borderRadius:4,cursor:"pointer",background:"#F7F7F5",color:"#374151"},children:F},F))]}),e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF",minWidth:40,flexShrink:0},children:"Color"}),_r.map(F=>e.jsx("button",{onClick:()=>{r(),p(F.value)},title:F.label,style:{width:16,height:16,borderRadius:"50%",background:F.value||"#E5E5E0",border:"1px solid #D1D5DB",cursor:"pointer"}},F.value))]}),e.jsx(Bt,{}),e.jsx(ne,{label:"Toggle label",icon:"🏷️",onClick:()=>{r(),f()}}),e.jsx(ne,{label:"Delete edge",icon:"🗑️",danger:!0,onClick:()=>{r(),w()}})]})}const Vr=d.memo(function({id:i,data:n,selected:a}){const r=n,l=r.color??r.layerColor??"#E67E22",p=80,f=d.useCallback(w=>{var F;w.preventDefault(),(F=r.onContextMenu)==null||F.call(r,w,i)},[r,i]);return e.jsxs("div",{style:{width:p,height:p,position:"relative"},onContextMenu:f,children:[a&&e.jsx(tt,{minWidth:60,minHeight:60}),e.jsx("svg",{width:p,height:p,style:{position:"absolute",top:0,left:0},children:e.jsx("polygon",{points:`${p/2},4 ${p-4},${p/2} ${p/2},${p-4} 4,${p/2}`,fill:r.color?r.color+"44":"#FFF8E1",stroke:l,strokeWidth:a?2.5:1.5})}),e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:600,color:"#374151",textAlign:"center",padding:"4px 8px",pointerEvents:"none"},children:r.condition||r.label||"?"}),e.jsx(N,{type:"target",position:k.Top,style:{background:l,border:"2px solid #fff"}}),e.jsx(N,{type:"source",position:k.Right,style:{background:l,border:"2px solid #fff"},id:"right"}),e.jsx(N,{type:"source",position:k.Bottom,style:{background:l,border:"2px solid #fff"},id:"bottom"}),e.jsx(N,{type:"target",position:k.Left,style:{background:l,border:"2px solid #fff"}})]})}),Yr=d.memo(function({id:i,data:n,selected:a}){const r=n,l=(r.orientation??"horizontal")==="horizontal",p=l?120:8,f=l?8:60,w=d.useCallback(F=>{var I;F.preventDefault(),(I=r.onContextMenu)==null||I.call(r,F,i)},[r,i]);return e.jsxs("div",{style:{width:p,height:f,background:"#1a1a1a",borderRadius:4,position:"relative"},title:r.nodeType==="join"?"Join (synchronization)":"Fork (parallel)",onContextMenu:w,children:[a&&e.jsx(tt,{minWidth:40,minHeight:6}),l?e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"target",position:k.Left,style:{background:"#2DD4A8",border:"2px solid #fff",left:-1}}),e.jsx(N,{type:"source",position:k.Top,style:{background:"#2DD4A8",border:"2px solid #fff",top:-1},id:"top"}),e.jsx(N,{type:"source",position:k.Bottom,style:{background:"#2DD4A8",border:"2px solid #fff",bottom:-1},id:"bottom"}),e.jsx(N,{type:"source",position:k.Right,style:{background:"#2DD4A8",border:"2px solid #fff",right:-1},id:"right"})]}):e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"target",position:k.Top,style:{background:"#2DD4A8",border:"2px solid #fff",top:-1}}),e.jsx(N,{type:"source",position:k.Left,style:{background:"#2DD4A8",border:"2px solid #fff",left:-1},id:"left"}),e.jsx(N,{type:"source",position:k.Right,style:{background:"#2DD4A8",border:"2px solid #fff",right:-1},id:"right"}),e.jsx(N,{type:"source",position:k.Bottom,style:{background:"#2DD4A8",border:"2px solid #fff",bottom:-1},id:"bottom"})]})]})}),Xr=d.memo(function({id:i,data:n}){const a=n,r=a.nodeType==="start",l=32,p=d.useCallback(f=>{var w;f.preventDefault(),(w=a.onContextMenu)==null||w.call(a,f,i)},[a,i]);return e.jsxs("div",{style:{width:l,height:l,position:"relative"},onContextMenu:p,children:[e.jsx("svg",{width:l,height:l,children:r?e.jsx("circle",{cx:l/2,cy:l/2,r:l/2-2,fill:"#1a1a1a"}):e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:l/2,cy:l/2,r:l/2-2,fill:"#1a1a1a"}),e.jsx("circle",{cx:l/2,cy:l/2,r:l/2-6,fill:"#FFFFFF"}),e.jsx("circle",{cx:l/2,cy:l/2,r:l/2-10,fill:"#1a1a1a"})]})}),r?e.jsx(N,{type:"source",position:k.Bottom,style:{background:"#1a1a1a",border:"2px solid #fff"}}):e.jsx(N,{type:"target",position:k.Top,style:{background:"#1a1a1a",border:"2px solid #fff"}})]})}),Gr="#ECEBE6",Tt="#1B3A4B",yo="#5B6470",Ur="0 1px 2px rgba(0,0,0,0.16), 0 0 0 0.5px rgba(0,0,0,0.05)",Se=(t,i)=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{display:"block"},children:i}),Y={arrowRight:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M4 12h14"}),e.jsx("path",{d:"M13 6l6 6-6 6"})]})),arrowDown:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 4v14"}),e.jsx("path",{d:"M6 13l6 6 6-6"})]})),lanes:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"5",width:"18",height:"3.4",rx:"1.3"}),e.jsx("rect",{x:"3",y:"10.3",width:"18",height:"3.4",rx:"1.3"}),e.jsx("rect",{x:"3",y:"15.6",width:"18",height:"3.4",rx:"1.3"})]})),grid:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3.5",y:"3.5",width:"17",height:"17",rx:"2.5"}),e.jsx("path",{d:"M9.2 3.5v17M14.8 3.5v17M3.5 9.2h17M3.5 14.8h17"})]})),expand:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M15 4h5v5"}),e.jsx("path",{d:"M9 20H4v-5"}),e.jsx("path",{d:"M20 4l-7 7"}),e.jsx("path",{d:"M4 20l7-7"})]})),collapse:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M14 10h5"}),e.jsx("path",{d:"M19 10V5"}),e.jsx("path",{d:"M10 14H5"}),e.jsx("path",{d:"M5 14v5"}),e.jsx("path",{d:"M20 4l-6 6"}),e.jsx("path",{d:"M4 20l6-6"})]})),filter:({size:t=16})=>Se(t,e.jsx("path",{d:"M4 5h16l-6.2 7.4V19l-3.6 1.8v-8.4z"})),back:({size:t=16})=>Se(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M11 5l-6 7 6 7"}),e.jsx("path",{d:"M5 12h14"})]}))};function xe(){return e.jsx("span",{"aria-hidden":"true",style:{width:1,height:18,background:"#E2E1DB",margin:"0 3px",borderRadius:1}})}function Nt({options:t,value:i,onChange:n}){return e.jsx("div",{role:"tablist",style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,background:Gr,borderRadius:9},children:t.map(a=>{const r=a.value===i;return e.jsxs("button",{role:"tab","aria-selected":r,onClick:()=>n(a.value),title:a.title,className:"flex items-center gap-1.5 text-xs font-semibold",style:{padding:a.label?"3px 9px":"4px 7px",borderRadius:7,border:"none",cursor:"pointer",color:r?Tt:yo,background:r?"#FFFFFF":"transparent",boxShadow:r?Ur:"none",transition:"background 140ms ease, color 140ms ease, box-shadow 140ms ease"},children:[a.icon,a.label&&e.jsx("span",{children:a.label})]},a.value)})})}function qr({children:t}){return e.jsx("div",{style:{display:"inline-flex",alignItems:"center",background:"#FFFFFF",border:"1px solid #E2E1DB",borderRadius:9,overflow:"hidden"},children:Sn.Children.toArray(t).map((i,n)=>e.jsxs(Sn.Fragment,{children:[n>0&&e.jsx("span",{"aria-hidden":"true",style:{width:1,alignSelf:"stretch",background:"#EDECE7"}}),i]},n))})}function ie({icon:t,label:i,onClick:n,active:a=!1,title:r,ariaExpanded:l,ariaLabel:p}){return e.jsxs("button",{onClick:n,title:r,"aria-label":p,"aria-pressed":a,"aria-expanded":l,className:"flex items-center gap-1.5 text-xs font-semibold",style:{padding:i?"5px 9px":"5px 7px",border:"none",cursor:"pointer",color:a?"#FFFFFF":yo,background:a?Tt:"transparent",transition:"background 140ms ease, color 140ms ease"},children:[t,i&&e.jsx("span",{children:i})]})}function Je({icon:t,label:i,onClick:n,active:a=!1,title:r,badge:l}){return e.jsxs("button",{onClick:n,title:r,"aria-pressed":a,className:"flex items-center gap-1.5 text-xs font-semibold",style:{padding:l!=null||i!=null?"5px 9px":"5px 7px",borderRadius:9,border:`1px solid ${a?Tt:"#E2E1DB"}`,cursor:"pointer",color:a?"#FFFFFF":yo,background:a?Tt:"#FFFFFF",transition:"background 140ms ease, color 140ms ease, border-color 140ms ease"},children:[t,i!=null&&e.jsx("span",{children:i}),l!=null&&e.jsx("span",{style:{fontSize:11,fontWeight:700,lineHeight:1,padding:"2px 5px",borderRadius:6,background:a?"rgba(255,255,255,0.22)":"#F0EFEA",color:a?"#FFFFFF":"#6B7280"},children:l})]})}const Zr=1,$n="memo-layout-progress";if(typeof document<"u"&&!document.getElementById($n)){const t=document.createElement("style");t.id=$n,t.textContent="@keyframes memo-layout-progress { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }",document.head.appendChild(t)}const Qr={background:"#F7F7F5"},Jr={padding:.08,maxZoom:2},ea={background:"#FFFFFF"},ta={hideAttribution:!0},oa=[20,20],na=50,Wn=8e3,sa=90;function ia(t,i){return new Promise((n,a)=>{const r=window.setTimeout(()=>a(new Error(`${i} layout exceeded ${Wn/1e3}s`)),Wn);t.then(l=>{window.clearTimeout(r),n(l)},l=>{window.clearTimeout(r),a(l)})})}function ra({data:t,selected:i}){const n=t.kind,a=n==="note",r=n==="constraint";return e.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",padding:a?"12px 14px":r?"10px 12px":"4px",background:a?String(t.color??"#FEF3C7"):r?"#FFFFFF":"transparent",border:r?"1.5px dashed #7C3AED":a?"1px solid #F59E0B":"1px solid transparent",borderRadius:a?3:r?5:0,boxShadow:a?"0 2px 6px rgba(0,0,0,.12)":"none",color:"#292524",fontSize:12,lineHeight:1.4},children:[e.jsx(tt,{isVisible:i,minWidth:100,minHeight:48,color:"#2563EB"}),e.jsx("button",{className:"nodrag","aria-label":"Delete annotation",title:"Delete annotation",onPointerDown:l=>{var p;l.preventDefault(),l.stopPropagation(),(p=t.onDelete)==null||p.call(t)},onClick:l=>{var p;l.stopPropagation(),(p=t.onDelete)==null||p.call(t)},style:{position:"absolute",top:3,right:5,border:0,background:"transparent",color:"#64748B",cursor:"pointer",fontSize:14,lineHeight:1,pointerEvents:"all",zIndex:30},children:"×"}),r&&e.jsx("div",{style:{fontSize:10,fontWeight:700,color:"#7C3AED",marginBottom:4},children:"constraint"}),e.jsx("div",{contentEditable:!0,suppressContentEditableWarning:!0,className:"nodrag",style:{outline:"none",whiteSpace:"pre-wrap",minHeight:20},onBlur:l=>{var p;return(p=t.onTextChange)==null?void 0:p.call(t,l.currentTarget.textContent??"")},children:String(t.text??"")})]})}function On(t,i){const n=new Map(t.map(h=>[h.id,h])),a=new Map,r=h=>{const C=a.get(h);if(C)return C;const j=n.get(h),m=j.parentId?r(j.parentId):{x:0,y:0},A={x:m.x+j.position.x,y:m.y+j.position.y};return a.set(h,A),A},l=h=>{var C,j;return{width:Number(h.width??((C=h.style)==null?void 0:C.width)??0),height:Number(h.height??((j=h.style)==null?void 0:j.height)??0)}},p=i.flatMap(h=>{var v,T,W,E,R,Q;const C=(H,z,q)=>{var S,te;if(typeof z=="string"){const K=(((te=(S=n.get(H))==null?void 0:S.data)==null?void 0:te.ports)??[]).find(X=>X.id===z);if(K){const X=K.size??20;return{x:K.x+X/2,y:K.y+X/2}}}return q},j=C(h.source,(v=h.data)==null?void 0:v.sourcePortId,(T=h.data)==null?void 0:T.sourceOffset),m=C(h.target,(W=h.data)==null?void 0:W.targetPortId,(E=h.data)==null?void 0:E.targetOffset);if(!j||!m||!n.has(h.source)||!n.has(h.target))return[];const A=r(h.source),b=r(h.target);return[{id:h.id,source:{x:A.x+j.x,y:A.y+j.y},target:{x:b.x+m.x,y:b.y+m.y},sourceNodeId:h.source,targetNodeId:h.target,sourceSide:(R=h.data)==null?void 0:R.sourceSide,targetSide:(Q=h.data)==null?void 0:Q.targetSide}]});if(p.length===0)return i;const f=t.filter(h=>!h.data.isFrame).map(h=>({id:h.id,...r(h.id),...l(h)})),w=new Map(p.map(h=>[h.id,h])),F=p.filter(h=>{var C,j;return!((j=(C=i.find(m=>m.id===h.id))==null?void 0:C.data)!=null&&j.manualRoute)}),I=Hi(F,f);return i.map(h=>{var j;const C=w.get(h.id);if(!C)return h;if((j=h.data)!=null&&j.manualRoute){const m=[...h.data.points??[]];if(m.length>=2)return m[0]=C.source,m[m.length-1]=C.target,{...h,data:{...h.data,points:m}}}return I.has(h.id)?{...h,data:{...h.data,points:I.get(h.id)}}:h})}function aa({x:t,y:i,onConfirm:n,onCancel:a}){const[r,l]=d.useState(""),p=d.useRef(null);d.useEffect(()=>{var F;(F=p.current)==null||F.focus()},[]),d.useEffect(()=>{const F=I=>{const h=document.getElementById("quick-create-popup");h&&!h.contains(I.target)&&a()};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[a]);const f=Math.min(t,window.innerWidth-220),w=Math.min(i,window.innerHeight-80);return e.jsxs("div",{id:"quick-create-popup",className:"fixed z-50 rounded-xl shadow-xl overflow-hidden",style:{left:f,top:w,width:200,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.14)"},children:[e.jsx("div",{className:"px-3 py-2",style:{borderBottom:"1px solid #E5E5E0",fontSize:D.xs,color:"#9CA3AF",fontWeight:600},children:"New Element"}),e.jsxs("div",{className:"px-2 py-2",children:[e.jsx("input",{ref:p,value:r,onChange:F=>l(F.target.value),placeholder:"Element name…",className:"w-full px-2 py-1.5 rounded focus:outline-none",style:{fontSize:D.xs,border:"1px solid #E5E5E0",background:"#F7F7F5",color:"#1a1a1a"},onKeyDown:F=>{F.key==="Enter"&&r.trim()&&(F.preventDefault(),n(r.trim())),F.key==="Escape"&&a()}}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("button",{onClick:()=>r.trim()&&n(r.trim()),style:{flex:1,fontSize:D.xs,padding:"4px 8px",background:"#2DD4A8",color:"#FFFFFF",border:"none",borderRadius:6,cursor:"pointer",fontWeight:600},children:"Create"}),e.jsx("button",{onClick:a,style:{fontSize:D.xs,padding:"4px 8px",background:"#F7F7F5",color:"#6B7280",border:"1px solid #E5E5E0",borderRadius:6,cursor:"pointer"},children:"Cancel"})]})]})]})}function lo({color:t,glyph:i}){return e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:13,height:13,borderRadius:2,background:t+"22",border:`1.5px solid ${t}`,color:t,fontSize:9,fontWeight:800,lineHeight:1},children:i})}function Pn(t,i){if(!t||!i)return[];const n=new Map;for(const p of t.relationships)Mt.has(p.type)&&!n.has(p.targetId)&&n.set(p.targetId,p.sourceId);const a=[i],r=new Set(a);let l=i;for(;n.has(l);){const p=n.get(l);if(r.has(p))break;a.unshift(p),r.add(p),l=p}return a}function co({path:t,nameOf:i,onFocus:n,rootLabel:a}){if(t.length===0)return null;const r=t.length>1?t[t.length-2]:null;return e.jsxs(e.Fragment,{children:[e.jsx(xe,{}),e.jsx(Je,{icon:e.jsx(Y.back,{}),label:"Parent",onClick:()=>n(r),title:r?`Back to ${i(r)}`:a}),e.jsx("button",{onClick:()=>n(null),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#2563EB",border:"1px solid #E5E5E0"},title:a,children:"⌂ All"}),t.map((l,p)=>{const f=p===t.length-1;return e.jsxs("span",{className:"flex items-center gap-1",style:{color:"#9CA3AF"},children:[e.jsx("span",{children:"›"}),e.jsx("button",{onClick:()=>n(l),disabled:f,className:"text-xs font-medium",style:{color:f?"#1a1a1a":"#2563EB",fontWeight:f?700:500,cursor:f?"default":"pointer"},title:f?void 0:`Focus ${i(l)}`,children:i(l)})]},l)})]})}function la(){var cn,dn,pn,un,hn,xn,gn,fn,mn,yn;const t=O(o=>o.model),i=O(o=>o.createRelationship),n=d.useMemo(()=>Kn(t),[t]),a=O(o=>o.selectedElementId),r=O(o=>o.selectedViewpointId),l=O(o=>o.selectedDiagramId),p=O(o=>o.hiddenLayers),f=O(o=>o.selectElement),w=O(o=>o.inspectElement),F=O(o=>o.inspectRelationship),I=O(o=>o.setActiveMode),h=O(o=>o.setActiveView),C=O(o=>o.setExplorerTab),j=O(o=>o.availableOntologies),m=O(o=>o.setSelectedOntologyKind),A=O(o=>o.diagramLayouts),b=O(o=>o.setNodeLayout),v=O(o=>o.mergeDiagramLayouts),T=O(o=>o.updateDiagramElementIds),{fitView:W,screenToFlowPosition:E,getViewport:R,setViewport:Q}=xo(),[H,z]=Js([]),[q,S,te]=ei([]),K=d.useRef([]),X=d.useRef([]),st=d.useRef(t),it=d.useRef(l),ve=d.useRef(null),Ne=d.useRef(null),Ae=d.useRef(null),re=d.useRef(0);d.useEffect(()=>{K.current=H},[H]),d.useEffect(()=>{X.current=q},[q]);const ge=d.useCallback(o=>{K.current=o,Ne.current===null&&(Ne.current=requestAnimationFrame(()=>{Ne.current=null;const s=K.current,c=On(s,X.current);X.current=c,z(s),S(c)}))},[z,S]),[Z,ae]=d.useState(!1),[bo,ye]=d.useState(0),[Fo,wo]=d.useState(null),[jo,es]=d.useState(0),[ts,Rt]=d.useState(0),[Re,Lt]=d.useState(!0),[os,So]=d.useState(!0),[vo,ns]=d.useState(!0),[$t,ss]=d.useState("horizontal"),[rt,ko]=d.useState("allocation"),[Wt,Co]=d.useState("all"),[Eo,is]=d.useState(!1),[be,rs]=d.useState(new Set(["control","data","energy","material"])),[se,Le]=d.useState(null),[Fe,at]=d.useState(null),[J,$e]=d.useState(null),[fe,lt]=d.useState(null),[We,Io]=d.useState(null),[ct,as]=d.useState(2),[dt,Do]=d.useState(null),Oe=d.useRef([]),Ot=d.useRef([]),No=d.useCallback(o=>{Oe.current.push(o),Oe.current.length>na&&Oe.current.shift(),Ot.current=[]},[]),g=di(t,l),Pe=g?vn[g.diagramType]:null,pt=!!((cn=g==null?void 0:g.properties)!=null&&cn.layoutStyle),ke=((dn=g==null?void 0:g.properties)==null?void 0:dn.layoutStyle)==="fbs",Ce=l?A[l]:void 0,Ee=ki(Ce),me=((pn=Ce==null?void 0:Ce.canvas)==null?void 0:pn.autoLayout)!==!1,we=((un=Ce==null?void 0:Ce.canvas)==null?void 0:un.flowAnimation)===!0,Ao=d.useCallback((o,s)=>{var y;if(!l)return;const c=O.getState().diagramLayouts[l]??{nodes:{},edges:{}},u=(y=c.annotations)==null?void 0:y[o];if(!u)return;const x={...c,annotations:{...c.annotations,[o]:{...u,text:s}}};v({[l]:x}),je(l,x),z(M=>M.map(B=>B.id===o?{...B,data:{...B.data,text:s}}:B))},[l,v,z]),Mo=d.useCallback(o=>{if(!l)return;const s=O.getState().diagramLayouts[l]??{nodes:{},edges:{}},c={...s.annotations};delete c[o];const u={...s,annotations:c};v({[l]:u}),je(l,u),z(x=>x.filter(y=>y.id!==o))},[l,v,z]),ut=d.useCallback(o=>Object.entries((o==null?void 0:o.annotations)??{}).map(([s,c])=>({id:s,type:"annotationNode",zIndex:1e3,position:{x:c.x,y:c.y},style:{width:c.width??180,height:c.height??92},data:{kind:c.kind,text:c.text,color:c.color,onTextChange:u=>Ao(s,u),onDelete:()=>Mo(s)}})),[Ao,Mo]),ls=d.useCallback(o=>{if(!l)return;const s=`annotation-${Date.now().toString(36)}`,c=E({x:window.innerWidth/2,y:window.innerHeight/2}),u=o==="constraint"?"{constraint}":o==="note"?"Note":"Text",x=O.getState().diagramLayouts[l]??{nodes:{},edges:{}},y={kind:o,x:c.x,y:c.y,width:180,height:o==="text"?56:92,text:u},M={...x,annotations:{...x.annotations,[s]:y}};v({[l]:M}),je(l,M),z(B=>[...B,...ut(M).filter(P=>P.id===s)])},[l,E,v,z,ut]),ee=d.useCallback(()=>{var s;if(!l)return;const o=O.getState().diagramLayouts[l]??{nodes:{},edges:{}};((s=o.canvas)==null?void 0:s.autoLayout)!==!1&&v({[l]:{...o,canvas:{...o.canvas,autoLayout:!1}}})},[l,v]);d.useEffect(()=>{if(!l||me||Z||H.length===0||bo===0)return;const o=window.setTimeout(()=>{const s=O.getState().diagramLayouts[l]??{nodes:{},edges:{}},c=R(),u={nodes:Object.fromEntries(H.filter(x=>x.type!=="annotationNode").map(x=>[x.id,{...s.nodes[x.id]??{},x:x.position.x,y:x.position.y,...x.width?{width:x.width}:{},...x.height?{height:x.height}:{},ports:Object.fromEntries((x.data.ports??[]).map(y=>[y.id,{x:y.x,y:y.y,side:y.side}]))}])),edges:Object.fromEntries(q.map(x=>{var y,M,B,P,_,$;return[x.id,{...(()=>{var ue;const{points:G,...V}=((ue=s.edges)==null?void 0:ue[x.id])??{};return V})(),...(y=x.data)!=null&&y.manualRoute&&((B=(M=x.data)==null?void 0:M.points)!=null&&B.length)?{points:(P=x.data)==null?void 0:P.points,source:x.source,target:x.target,sourcePortId:(_=x.data)==null?void 0:_.sourcePortId,targetPortId:($=x.data)==null?void 0:$.targetPortId}:{}}]})),annotations:Object.fromEntries(H.filter(x=>x.type==="annotationNode").map(x=>{var y,M;return[x.id,{kind:x.data.kind,text:String(x.data.text??""),color:x.data.color,x:x.position.x,y:x.position.y,width:Number(x.width??((y=x.style)==null?void 0:y.width)??180),height:Number(x.height??((M=x.style)==null?void 0:M.height)??92)}]})),canvas:{...s.canvas,zoom:c.zoom,pan:{x:c.x,y:c.y},autoLayout:!1}};v({[l]:u}),je(l,u),ye(0)},350);return()=>window.clearTimeout(o)},[l,me,Z,bo,H,q,R,v]);const L=g?g.viewKind??(Pe==null?void 0:Pe.viewKind)??"general":void 0,Ie=L==="interconnection"?.72:.1,He=L?En[L]:null,Me=L==="general"&&!pt&&!ke,Pt=(g==null?void 0:g.diagramType)==="ucd",[De,Bo]=d.useState("graph"),[Ht,zo]=d.useState("all"),[_t,To]=d.useState("straight"),[_e,Ro]=d.useState(new Set),cs=d.useMemo(()=>t?Ci(t):0,[t]),Lo=d.useMemo(()=>t?Ei(t):[],[t]),Kt=(hn=g==null?void 0:g.properties)==null?void 0:hn.modes,ds=d.useMemo(()=>{if(!Kt)return so;const o=new Set(Kt.split(",").map(c=>c.trim())),s=so.filter(c=>o.has(c));return s.length?s:so},[Kt]),[Ke,$o]=d.useState(!0),Wo=d.useMemo(()=>{if(!t||!g)return[];const o=new Set(g.elementIds),s=Object.values(t.elements).filter(c=>o.has(c.id)&&c.allocatedTo).map(c=>c.allocatedTo);return Ii(s,t)},[t,g]),ps=d.useMemo(()=>{if(!t||!g)return"Activity Diagram";const o=pi(g);return vn[o].fullName},[t,g]),us=d.useMemo(()=>{if(!t||!g)return!1;const o=new Set(g.elementIds);return Object.values(t.elements).some(s=>o.has(s.id)&&!!(s.attributes.stage||s.attributes.phase))},[t,g]),ht=d.useMemo(()=>{if(!t||!g||L!=="actionflow")return[];const o=(g.elementIds??[]).map(s=>t.elements[s]).filter(s=>!!s&&s.construct==="action");return Di(o,t)},[t,g,L]),[Ve,hs]=d.useState("containment"),[Ye,xt]=d.useState(new Set),[Oo,Xe]=d.useState(new Set),[gt,Vt]=d.useState(null),[Ge,Po]=d.useState("all"),[Yt,Ho]=d.useState("summary"),[_o,Ko]=d.useState(!1),[Vo,Ue]=d.useState(new Set),[Be,Xt]=d.useState(null),[Gt,Yo]=d.useState("flat"),[Xo,qe]=d.useState(new Set),[ft,Ut]=d.useState(null),[mt,xs]=d.useState(new Map),de=d.useRef(new Map),gs=d.useMemo(()=>Pn(t,gt),[t,gt]),fs=d.useMemo(()=>Pn(t,ft),[t,ft]),ms=d.useMemo(()=>{var u;if(!t||!Be)return[];const o=[Be],s=new Set(o);let c=Be;for(;c;){const x=(u=t.elements[c])==null?void 0:u.parentAction;if(!x||s.has(x)||!t.elements[x])break;o.unshift(x),s.add(x),c=x}return o},[t,Be]),yt=d.useMemo(()=>{if(!t||L!=="statetransition")return[];const o=new Set;for(const s of t.relationships){if(!Mt.has(s.type))continue;const c=t.elements[s.sourceId];!c||!t.elements[s.targetId]||!Ni(c)||c.kind.endsWith("Machine")||o.add(c.id)}return[...o]},[t,L]),ys=d.useMemo(()=>t?[...new Set(t.relationships.filter(o=>Mt.has(o.type)).map(o=>o.sourceId))]:[],[t]);d.useEffect(()=>{var s,c;ye(0),Bo(Ai(g==null?void 0:g.properties)),zo(io(g==null?void 0:g.properties).level??"all"),To(io(g==null?void 0:g.properties).edgeStyle??"straight"),Ro(new Set),$o(!0),ko("allocation"),Co("all");const o=(c=(s=g==null?void 0:g.properties)==null?void 0:s.styleHint)!=null&&c.startsWith("expanded:")?g.properties.styleHint.slice(9).split(",").map(u=>u.trim()).filter(Boolean):[];xt(new Set(o)),Vt(null),Po("all"),Ho("summary"),Ko(!1),Ue(new Set),Xt(null),Yo("flat"),Ut(null),de.current.clear()},[l,(xn=g==null?void 0:g.properties)==null?void 0:xn.layoutHint,(gn=g==null?void 0:g.properties)==null?void 0:gn.styleHint]);const bs=d.useMemo(()=>({decompositionNode:ir,interconnectionNode:hr,actionFlowNode:wr,actionFlowLane:Sr,stateNode:kr,seqLifeline:Er,seqSection:Dr,seqOccurrence:Ar,useCase:Mr,useCaseActor:Br,useCaseBoundary:zr,contextSystem:Lr,contextExternal:$r,contextBoundary:Wr,diagramNode:Or,annotationNode:ra,decisionNode:Vr,forkNode:Yr,startEndNode:Xr}),[]),Fs=d.useMemo(()=>({interconnectionEdge:yr,useCaseEdge:Rr}),[]),ws=d.useCallback(o=>{var s,c;return((s=o.data)==null?void 0:s.color)||((c=o.data)==null?void 0:c.layerColor)||"#ccc"},[]),U=d.useMemo(()=>{const o=(g==null?void 0:g.viewpointId)==="__model"?null:(g==null?void 0:g.viewpointId)||r,s=o&&(t==null?void 0:t.viewpoints),c=p.size>0,u=g!=null&&g.elementIds?new Set(g.elementIds):void 0;if(!s&&!c&&!u)return;const x=s?t.viewpoints.find(B=>B.id===o):void 0,y=x?new Set(x.visibleKinds):void 0,M=x?new Set(x.visibleLayers):void 0;return B=>p.has(B.layer)?!1:u?u.has(B.id):y&&M?y.has(B.kind)||M.has(B.layer):!0},[r,g,t==null?void 0:t.viewpoints,p]),Go=d.useMemo(()=>{if(!t||L!=="interconnection")return[];const o=Object.values(t.elements),s=U?o.filter(U):o;return Mi(Bi(s,t.relationships),Zr)},[t,L,U]),Uo=d.useRef(null);d.useEffect(()=>{if(!t)return;const o=`${l??""}|${L??""}`;if(Uo.current!==o){if(L==="statetransition"){if(yt.length===0)return;qe(new Set(yt))}else L==="interconnection"&&Xe(new Set(Go));Uo.current=o}},[t,l,L,yt,Go]);const bt=d.useMemo(()=>{if(!t||!g||g.diagramType!=="bdd")return null;const o=g.relationshipTypes??[];return o.length===0||o.every(c=>Mt.has(c.charAt(0).toLowerCase()+c.slice(1)))?zi(Dn(t,U,g.relationshipTypes)):null},[t,g,U]),qo=d.useCallback(()=>{if(t)return ke?Ti(t):Me?Dn(t,U,g==null?void 0:g.relationshipTypes):Ri(t)},[t,ke,Me,U,g==null?void 0:g.relationshipTypes]),qt=d.useCallback(o=>{xt(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),Zo=d.useCallback(o=>{Xe(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),Qo=d.useCallback(o=>{Ue(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),Ft=d.useCallback(o=>{Ut(o),qe(new Set),w(null)},[w]),wt=d.useCallback(o=>{Xt(o),Ue(new Set),w(null)},[w]),jt=d.useCallback(o=>{Vt(o),Xe(new Set),w(null)},[w]),Jo=d.useCallback(o=>{qe(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),en=d.useCallback(o=>{de.current.clear(),xs(s=>{const c=new Map(s),u=c.get(o)||"vertical";return c.set(o,u==="vertical"?"horizontal":"vertical"),c})},[]),Zt=d.useCallback(()=>{const o=qo();if(!o)return;const s=new Set,c=u=>{s.add(u);for(const x of o.childrenMap.get(u)||[])o.elements.has(x)&&c(x)};for(const u of o.roots)o.elements.has(u)&&c(u);xt(s)},[qo]),Qt=d.useCallback(()=>xt(new Set),[]),Jt=d.useCallback(()=>{de.current.clear(),Rt(o=>o+1)},[]),js=d.useCallback(()=>{if(!l)return;const o=O.getState().diagramLayouts[l]??{},{pan:s,zoom:c,...u}=o.canvas??{},x={nodes:{},edges:{},canvas:{...u,autoLayout:!0}};ve.current=null,v({[l]:x}),je(l,x),de.current.clear(),Rt(y=>y+1),window.setTimeout(()=>W({padding:.08,minZoom:Ie,maxZoom:2,duration:300}),250)},[l,v,W,Ie]),tn=d.useCallback(o=>o.map(s=>{if(s.type!=="diagramNode")return s;const c=t==null?void 0:t.elements[s.id];return{...s,data:{...s.data,onContextMenu:(u,x)=>{$e({x:u.clientX,y:u.clientY,nodeId:x,nodeKind:s.data.kind??""})},onInlineEdit:(u,x)=>{if(!c)return;const y={...c,name:x};kn(y)}}}}),[t]),on=d.useCallback((o,s)=>{const c=o.map(x=>{const y=s.nodes[x.id];return y?{...x,position:{x:y.x,y:y.y},...y.width?{width:y.width}:{},...y.height?{height:y.height}:{},...y.width||y.height?{style:{...x.style,...y.width?{width:y.width}:{},...y.height?{height:y.height}:{}}}:{},data:{...x.data,bgColor:y.color||void 0,...y.opacity!==void 0?{fillOpacity:y.opacity}:{},...y.ports?{ports:(x.data.ports??[]).map(M=>{var B;return{...M,...((B=y.ports)==null?void 0:B[M.id])??{}}})}:{}}}:x}),u=new Map(c.map(x=>[x.id,x]));return c.map(x=>{if(x.type!=="actionFlowLane")return x;const y=x.data,M=(y.memberIds??[]).map(V=>u.get(V)).filter(Boolean);if(M.length===0)return x;const B=Math.min(...M.map(V=>V.position.x)),P=Math.min(...M.map(V=>V.position.y)),_=Math.max(...M.map(V=>{var ue;return V.position.x+Number(V.width??((ue=V.style)==null?void 0:ue.width)??180)})),$=Math.max(...M.map(V=>{var ue;return V.position.y+Number(V.height??((ue=V.style)==null?void 0:ue.height)??96)})),G=y.orientation==="column";return{...x,position:{x:G?B-36:B-120,y:G?P-32:P-36},style:{...x.style,width:_-B+(G?72:156),height:$-P+(G?68:72)}}})},[]),nn=d.useCallback((o,s,c)=>{re.current=Date.now()+250,ee(),ye(y=>y+1);const u=X.current.map(y=>{var $,G;if(!((($=y.data)==null?void 0:$.sourcePortId)===s||((G=y.data)==null?void 0:G.targetPortId)===s))return y;const{points:B,manualRoute:P,..._}=y.data??{};return{...y,data:_}});X.current=u;const x=K.current.map(y=>y.id!==o?y:{...y,data:{...y.data,ports:(y.data.ports??[]).map(M=>M.id===s?{...M,y:c}:M)}});ge(x)},[ge,ee]),sn=d.useCallback((o,s)=>{re.current=Date.now()+250,ee(),ye(c=>c+1),S(c=>{const u=c.map(x=>x.id===o?{...x,data:{...x.data,points:s,manualRoute:!0}}:x);return X.current=u,u})},[ee,S]);d.useEffect(()=>{if(!t)return;const o=st.current!==t&&it.current===l;if(ve.current=o?R():null,st.current=t,it.current=l,L==="grid"||L==="browser"||L==="geometry")return;let s=!1;const c=({nodes:B,edges:P},_=!0)=>{if(s)return;const $=l?O.getState().diagramLayouts[l]:void 0,V=[...$&&Object.keys($.nodes).length>0?on(B,$):B,...ut($)],ue=P.map(oe=>{var bn,Fn,wn;const he=(bn=$==null?void 0:$.edges)==null?void 0:bn[oe.id],St=!(he!=null&&he.source)||he.source===oe.source&&he.target===oe.target&&he.sourcePortId===((Fn=oe.data)==null?void 0:Fn.sourcePortId)&&he.targetPortId===((wn=oe.data)==null?void 0:wn.targetPortId)?he==null?void 0:he.points:void 0;return{...oe,data:{...oe.data,...St!=null&&St.length?{points:St,manualRoute:!0}:{},flowAnimation:we,onRouteChange:to=>sn(oe.id,to),onSelect:to=>{to.stopPropagation(),!(Date.now()<re.current)&&(S(oo=>oo.map(jn=>({...jn,selected:jn.id===oe.id}))),t.relationships.some(oo=>oo.id===oe.id)&&F(oe.id))}}}});z(_?tn(V):V),S(On(V,ue)),ae(!1),es(oe=>oe+1)},u=B=>P=>{s||(console.error(`${B} layout error:`,P),ae(!1),wo(`${B} layout could not be completed. Try resetting the layout or reducing the visible hierarchy.`))},x=(B,P,_=!0)=>{ae(!0),wo(null),ia(P,B).then($=>c($,_)).catch(u(B))},y=()=>{const B=Xn.select({viewKind:L,diagramType:g==null?void 0:g.diagramType,isFBSDiagram:ke,isDecompDiagram:pt,isGeneralTemplate:Me,generalMode:De,layoutStyle:Ve}),P={onToggleExpand:qt,onToggleDirection:en},_={fbs:{expandedNodes:Ye,nodeDirections:mt,callbacks:P,layoutProviderId:Ee},decomposition:{expandedNodes:Ye,nodeDirections:mt,callbacks:P,positionCache:de.current},containment:{expandedNodes:Ye,callbacks:{onToggleExpand:qt}},useCase:{viewpointFilter:void 0,systemName:g==null?void 0:g.name,...g?io(g.properties):{},level:Ht,edgeStyle:_t,hiddenActorIds:_e},context:{systemName:g==null?void 0:g.name,viewpointFilter:U,relationshipTypes:g==null?void 0:g.relationshipTypes},interconnection:{viewpointFilter:U,relationshipTypes:g==null?void 0:g.relationshipTypes,collapsedNodes:Oo,onDrillIn:jt,onToggleCollapse:Zo,focusId:gt??void 0,portDisplay:Ge,connectionDisplay:Yt,onPortMove:nn,layoutProviderId:Ee},actionflow:{viewpointFilter:U,swimlanes:Ke,laneGrouping:rt,displayLevel:Wt,expandedActionIds:Vo,onToggleAction:Qo,onDrillInAction:wt,focusActionId:Be??void 0,visibleFlowKinds:be,direction:$t,nesting:Gt,layoutProviderId:Ee},statetransition:{viewpointFilter:U,collapsedStateIds:Xo,onToggleCollapse:Jo,onDrillIn:Ft,focusStateId:ft??void 0,layoutProviderId:Ee},sequence:{viewpointFilter:U},general:{mode:De,viewpointFilter:U,expandedNodes:Ye,nodeDirections:mt,callbacks:P,positionCache:de.current,hierarchyRelationshipTypes:g==null?void 0:g.relationshipTypes,layoutProviderId:Ee},standard:{viewpointFilter:U,relationshipTypes:g==null?void 0:g.relationshipTypes,compartments:Me,layoutProviderId:Ee}},$=B.compute(t,_);$ instanceof Promise?x(B.descriptor.label,$,B.descriptor.interactive):c($,B.descriptor.interactive)},M=window.setTimeout(y,sa);return()=>{s=!0,window.clearTimeout(M)}},[t,U,pt,ke,Ve,L,Me,De,Ke,ts,g==null?void 0:g.relationshipTypes,g==null?void 0:g.diagramType,g==null?void 0:g.name,Ht,_t,_e,Ee,Ye,Oo,gt,Ge,Yt,Vo,Be,be,$t,rt,Wt,Gt,mt,Xo,ft,Jo,Ft,wt,qt,Zo,Qo,en,l,jt,on,tn,ut,nn,sn,F,R]),d.useEffect(()=>{if(jo===0)return;const o=setTimeout(()=>{var u;const s=ve.current;if(ve.current=null,s){Q(s);return}const c=l?(u=O.getState().diagramLayouts[l])==null?void 0:u.canvas:void 0;(c==null?void 0:c.zoom)!==void 0&&c.pan?Q({x:c.pan.x,y:c.pan.y,zoom:c.zoom},{duration:300}):W({padding:.08,minZoom:Ie,maxZoom:2,duration:500})},200);return()=>clearTimeout(o)},[jo,l,W,Ie,Q]),d.useEffect(()=>{z(o=>o.map(s=>{const c=s.type==="actionFlowLane"?s.data.inspectElementId:void 0,u=!!a&&(s.id===a||c===a);return{...s,selected:u,style:{...s.style,boxShadow:u?"0 0 0 2px #2DD4A8, 0 4px 12px rgba(45, 212, 168, 0.3)":void 0,opacity:a?u?1:.5:1}}}))},[a,z]),d.useEffect(()=>{if(!We||!t)return;const o=_i(t,We,"both",ct),s=new Set(o.nodes.map(c=>c.elementId));s.add(We),z(c=>c.map(u=>({...u,style:{...u.style,opacity:s.has(u.id)?1:.08,pointerEvents:s.has(u.id)?"all":"none"}}))),S(c=>c.map(u=>({...u,style:{...u.style,opacity:s.has(u.source)&&s.has(u.target)?1:.05}})))},[We,ct,t,z,S]),d.useEffect(()=>{if(!dt)return;const o=setTimeout(()=>Do(null),2500);return()=>clearTimeout(o)},[dt]),d.useEffect(()=>{const o=s=>{const c=s.target;if(!(c.tagName==="INPUT"||c.tagName==="TEXTAREA")){if((s.metaKey||s.ctrlKey)&&s.key==="z"&&!s.shiftKey){s.preventDefault();const u=Oe.current.pop();u&&(u.undo(),Ot.current.push(u))}if((s.metaKey||s.ctrlKey)&&(s.key==="Z"||s.key==="z"&&s.shiftKey)){s.preventDefault();const u=Ot.current.pop();u&&(u.do(),Oe.current.push(u))}s.key==="g"&&(s.metaKey||s.ctrlKey)&&s.shiftKey&&(s.preventDefault(),So(u=>!u)),s.key==="0"&&(s.metaKey||s.ctrlKey)&&(s.preventDefault(),W({padding:.08,minZoom:Ie,maxZoom:2,duration:400}))}};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[W,Ie]);const Ss=d.useCallback(o=>{o.preventDefault(),o.dataTransfer.dropEffect="copy"},[]),vs=d.useCallback(o=>{o.preventDefault();const s=o.dataTransfer.getData(Qn);if(s)try{const c=JSON.parse(s),u=E({x:o.clientX,y:o.clientY});Le({x:o.clientX,y:o.clientY,flowX:u.x,flowY:u.y,kind:c.kind,layer:c.layer,construct:c.construct})}catch{}},[E]),ks=d.useCallback(o=>{const s=E({x:o.clientX,y:o.clientY});Le({x:o.clientX,y:o.clientY,flowX:s.x,flowY:s.y})},[E]),Cs=d.useCallback(o=>{if(!se||!l){Le(null);return}const s=se.kind??"Part",c=se.layer??"logical",u=se.construct??"part",x=uo[c]??"#6B7280",y=Ki(o,Object.keys((t==null?void 0:t.elements)??{})),M={id:y,type:"diagramNode",position:{x:se.flowX,y:se.flowY},data:{label:o,kind:s,layer:c,construct:u,color:x,isNew:!0,onContextMenu:($,G)=>{$e({x:$.clientX,y:$.clientY,nodeId:G,nodeKind:s})},onInlineEdit:($,G)=>{kn({id:y,name:G,kind:s,construct:u,layer:c})}}};z($=>[...$,M]),ui({id:y,name:o,kind:s,construct:u,layer:c,attributes:{_layer:c}});const B=(g==null?void 0:g.elementIds)??[];T(l,[...B,y]);const P=l,_={nodes:{...(A[P]??{}).nodes??{},[y]:{x:se.flowX,y:se.flowY}},edges:(A[P]??{}).edges??{}};v({[P]:_}),je(P,_),Le(null)},[se,l,g,A,v,T,z]),Es=d.useCallback(()=>{$e(null),lt(null)},[]),Is=d.useCallback((o,s)=>{s!=null&&s.isValid},[]),eo=d.useCallback((o,s)=>{const c=Li(s);return(c?t==null?void 0:t.elements[c]:void 0)??(t==null?void 0:t.elements[o])},[t]),Ds=d.useCallback(o=>{const{source:s,target:c,sourceHandle:u,targetHandle:x}=o;if(!s||!c)return;const y=eo(s,u),M=eo(c,x);!y||!M||y.id!==M.id&&at({x:window.innerWidth/2-130,y:window.innerHeight/2-160,sourceElement:y,targetElement:M})},[eo]),Ns=d.useCallback(async o=>{if(!Fe||!l){at(null);return}const s=Fe.sourceElement.id;at(null);const c=await i({type:o.type,sourceId:o.sourceId,targetId:o.targetId,direction:o.direction,flowItem:o.flowItem,selectedElementId:s,diagramId:l});if(!c.success){console.warn(`[MEMO] Relationship rejected: ${c.error}`);return}if(!(K.current.some(M=>M.id===o.sourceId)&&K.current.some(M=>M.id===o.targetId)))return;const x=Cn[o.type]??"#6B7280",y={id:c.relationshipId??`e_${o.sourceId}_${o.targetId}_${o.type}`,source:o.sourceId,target:o.targetId,label:o.type,type:"default",style:{stroke:x,strokeWidth:2},labelStyle:{fontSize:"10px",fill:"#374151"},labelBgStyle:{fill:"#FFFFFF",fillOpacity:.9},labelBgPadding:[4,2],labelBgBorderRadius:4,markerEnd:{type:"arrowclosed",color:x}};S(M=>ti(y,M))},[Fe,l,S,i]),As=d.useCallback((o,s)=>{Ae.current={id:s.id,x:s.position.x,y:s.position.y}},[]),Ms=d.useCallback((o,s)=>{const c=Ae.current;if(Ae.current=null,!((c==null?void 0:c.id)===s.id&&Math.hypot(s.position.x-c.x,s.position.y-c.y)>2)||(re.current=Date.now()+250,ye(B=>B+1),!l))return;const{x,y}=s.position;if(s.type==="annotationNode")return;ee();const M=de.current.get(s.id);if(de.current.set(s.id,{x,y}),b(l,s.id,{x,y}),M){const B=s.id,P=l;No({do:()=>b(P,B,{x,y}),undo:()=>{b(P,B,M),z(_=>_.map($=>$.id===B?{...$,position:M}:$))}})}},[l,b,No,z,ee]),Bs=d.useCallback(o=>{const s=c=>{var u;return"id"in c&&((u=K.current.find(x=>x.id===c.id))==null?void 0:u.type)==="annotationNode"};o.some(c=>c.type==="position"&&c.dragging&&!s(c))&&ee(),o.some(c=>c.type==="dimensions"&&c.resizing)&&(o.some(c=>c.type==="dimensions"&&c.resizing&&!s(c))&&ee(),ye(c=>c+1)),ge(oi(o,K.current))},[ge,ee]),zs=d.useCallback((o,s)=>{},[]),Ts=d.useCallback((o,s)=>{o.preventDefault(),lt({x:o.clientX,y:o.clientY,edgeId:s.id,relType:String(s.label??"edge")})},[]),Rs=d.useCallback((o,s)=>{var x,y,M,B,P,_;if(Date.now()<re.current)return;if((o==null?void 0:o.shiftKey)||(o==null?void 0:o.metaKey)||(o==null?void 0:o.ctrlKey)||((x=o==null?void 0:o.nativeEvent)==null?void 0:x.shiftKey)||((y=o==null?void 0:o.nativeEvent)==null?void 0:y.metaKey)||((M=o==null?void 0:o.nativeEvent)==null?void 0:M.ctrlKey)||((B=o==null?void 0:o.getModifierState)==null?void 0:B.call(o,"Shift"))||((P=o==null?void 0:o.getModifierState)==null?void 0:P.call(o,"Meta"))||((_=o==null?void 0:o.getModifierState)==null?void 0:_.call(o,"Control"))){window.setTimeout(()=>z($=>$.map(G=>({...G,selected:G.selected||G.id===a||G.id===s.id}))),0);return}if(s.type==="annotationNode")return;const u=s.type==="actionFlowLane"?s.data.inspectElementId:void 0;!u&&(s.id.startsWith("__")||s.id.includes("__start")||s.id.includes("__done"))||(w(u??s.id),l&&h({type:"diagram",diagramId:l}))},[w,l,h,a,z]),Ls=d.useCallback((o,s)=>{var c;if((c=o==null?void 0:o.stopPropagation)==null||c.call(o),L==="actionflow"){if(!Object.values((t==null?void 0:t.elements)??{}).some(x=>x.parentAction===s.id))return;wt(s.id);return}if(L==="statetransition"){const u=s.data;if(!u.hasChildren||u.isMachine){w(s.id);return}Ft(s.id);return}if(L==="interconnection"){const u=s.data;if(!u.isContainer&&!u.hasChildren){w(s.id);return}jt(s.id)}},[L,t==null?void 0:t.elements,w,wt,Ft,jt]),$s=d.useCallback(()=>{f(null),F(null),$e(null),lt(null),z(o=>o.map(s=>({...s,style:{...s.style,opacity:1,boxShadow:void 0}}))),S(o=>o.map(s=>s.selected?{...s,selected:!1}:s))},[f,F,z,S]),Ws=d.useCallback((o,s)=>{var c;(c=o==null?void 0:o.stopPropagation)==null||c.call(o),!(Date.now()<re.current)&&(S(u=>u.map(x=>({...x,selected:x.id===s.id}))),t!=null&&t.relationships.some(u=>u.id===s.id)?F(s.id):t!=null&&t.elements[s.id]&&w(s.id))},[t,w,F,S]),Os=d.useCallback((o,s)=>{et({endpointIds:[s.id]})},[]),Ps=d.useCallback((o,s)=>{et({edgeId:s.id,endpointIds:Vn(s)})},[]),rn=d.useCallback(()=>et(null),[]),Hs=d.useCallback((o,s)=>{var c;l&&(b(l,o,{...((c=A[l])==null?void 0:c.nodes[o])??{x:0,y:0},color:s||void 0}),z(u=>u.map(x=>x.id===o?{...x,data:{...x.data,bgColor:s||void 0}}:x)))},[l,A,b,z]),pe=d.useMemo(()=>H.filter(o=>o.selected&&o.type!=="actionFlowLane"&&!o.id.startsWith("__")),[H]),ze=d.useCallback(()=>pe.map(o=>{var s,c,u,x;return{id:o.id,x:o.position.x,y:o.position.y,width:Number(o.width??((s=o.measured)==null?void 0:s.width)??((c=o.style)==null?void 0:c.width)??180),height:Number(o.height??((u=o.measured)==null?void 0:u.height)??((x=o.style)==null?void 0:x.height)??96)}}),[pe]),Te=d.useCallback(o=>{o.size!==0&&(ee(),z(s=>s.map(c=>{const u=o.get(c.id);return u?{...c,position:{x:u.x??c.position.x,y:u.y??c.position.y},...u.width!==void 0?{width:u.width}:{},...u.height!==void 0?{height:u.height}:{},...u.width!==void 0||u.height!==void 0?{style:{...c.style,...u.width!==void 0?{width:u.width}:{},...u.height!==void 0?{height:u.height}:{}}}:{}}:c})),ye(s=>s+1))},[ee,z]),_s=d.useCallback(o=>{Te(Ui(ze(),o))},[Te,ze]),Ks=d.useCallback(o=>{Te(qi(ze(),o))},[Te,ze]),Vs=d.useCallback(o=>{Te(Zi(ze(),o))},[Te,ze]),an=d.useCallback(o=>{if(!l||pe.length===0)return;ee();const s=O.getState().diagramLayouts[l];for(const u of pe){const x=(s==null?void 0:s.nodes[u.id])??{x:u.position.x,y:u.position.y};b(l,u.id,{...x,...o.color!==void 0?{color:o.color||void 0}:{},...o.opacity!==void 0?{opacity:o.opacity}:{}})}const c=new Set(pe.map(u=>u.id));z(u=>u.map(x=>c.has(x.id)?{...x,data:{...x.data,...o.color!==void 0?{bgColor:o.color||void 0}:{},...o.opacity!==void 0?{fillOpacity:o.opacity}:{}}}:x)),ye(u=>u+1)},[l,pe,ee,b,z]),Ys=d.useMemo(()=>{const o=pe.map(s=>Number(s.data.fillOpacity??1));return o.length===0?1:o.every(s=>s===o[0])?o[0]:1},[pe]),ln=d.useCallback(o=>{if(!l||!g)return;const s=(g.elementIds??[]).filter(c=>c!==o);T(l,s),z(c=>c.filter(u=>u.id!==o))},[l,g,T,z]),Xs=d.useCallback((o,s)=>{const c=s==="dashed"?"6 3":s==="dotted"?"2 3":void 0;S(u=>u.map(x=>x.id===o?{...x,style:{...x.style,strokeDasharray:c}}:x))},[S]),Gs=d.useCallback((o,s)=>{S(c=>c.map(u=>u.id===o?{...u,style:{...u.style,stroke:s||(Cn[String(u.label??"")]??"#6B7280")}}:u))},[S]),Us=d.useCallback(o=>{S(s=>s.map(c=>c.id===o?{...c,label:c.label?"":o.split("_")[3]??""}:c))},[S]);if(g&&t&&L==="grid")return e.jsx($i,{diagram:g,model:t,viewpointFilter:U});if(g&&t&&L==="browser")return e.jsx(Wi,{diagram:g,model:t,viewpointFilter:U});if(g&&L==="geometry"){const o=En.geometry;return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"text-center",style:{maxWidth:"380px"},children:[e.jsx("span",{className:"inline-block px-2 py-0.5 rounded font-semibold",style:{background:o.color+"20",color:o.color,fontSize:D.badge,marginBottom:"12px"},children:o.label}),e.jsx("h3",{style:{fontSize:D.lg,fontWeight:600,color:"#374151",marginBottom:"8px"},children:g.name}),e.jsx("p",{style:{fontSize:D.md,color:"#9CA3AF",lineHeight:1.6},children:"Geometry View rendering is deferred (ADR-1-19): the ontology carries no spatial data to draw. This view is recognized and validated, but has no renderer yet."})]})})}return!g&&H.length===0&&!Z?e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!Re&&e.jsx(ao,{collapsed:Re,onToggleCollapse:()=>Lt(!0)}),Re&&e.jsx(ao,{collapsed:!0,onToggleCollapse:()=>Lt(!1)}),e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"text-center",style:{maxWidth:"320px"},children:[e.jsx("div",{style:{fontSize:"40px",marginBottom:"16px",opacity:.4},children:"📊"}),e.jsx("h3",{style:{fontSize:D.lg,fontWeight:600,color:"#374151",marginBottom:"8px"},children:"Select a Diagram"}),e.jsx("p",{style:{fontSize:D.md,color:"#9CA3AF",lineHeight:1.6},children:"Choose a diagram from the sidebar or drag elements from the palette."})]})})]}):e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx(ao,{collapsed:Re,onToggleCollapse:()=>Lt(!Re),elementIds:g==null?void 0:g.elementIds,eligibleKinds:(fn=g==null?void 0:g.elementKinds)!=null&&fn.length?new Set(g.elementKinds):g!=null&&g.viewpointId&&(t!=null&&t.viewpoints)?new Set(((mn=t.viewpoints.find(o=>o.id===g.viewpointId))==null?void 0:mn.visibleKinds)??[]):void 0}),e.jsxs("div",{className:"flex-1 relative",onDragOver:Ss,onDrop:vs,onDoubleClick:ks,children:[g&&e.jsxs("div",{className:"absolute top-3 left-3 z-10 flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs relative",style:{background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:[He&&e.jsx("span",{className:"px-1.5 py-0.5 rounded font-semibold",style:{background:He.color+"20",color:He.color,fontSize:D.badge},title:`${He.fullName}${Pe?` · ${Pe.fullName}`:""}`,children:L==="actionflow"?ps:He.label}),e.jsx("span",{className:"font-medium",style:{color:"#1a1a1a"},children:g.name}),g.auto&&e.jsx("span",{style:{color:"#9CA3AF",fontSize:"9px"},children:"auto"}),e.jsx(xe,{}),e.jsx(Je,{icon:e.jsx(Y.grid,{}),label:"Grid",active:vo,onClick:()=>{ns(o=>{const s=!o;return So(s),s})},title:"Show or hide the canvas grid and snapping (⌘⇧G)"}),ke&&e.jsxs(e.Fragment,{children:[e.jsx(xe,{}),e.jsx(ie,{icon:e.jsx(Y.expand,{}),onClick:Zt,title:"Expand all nodes",ariaLabel:"Expand all"}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),onClick:Qt,title:"Collapse all nodes",ariaLabel:"Collapse all"})]}),L==="actionflow"&&e.jsxs(e.Fragment,{children:[e.jsx(Je,{icon:e.jsx(Y.lanes,{}),active:Ke,onClick:()=>$o(o=>!o),title:"Toggle allocation swimlanes"}),Ke&&us&&e.jsx(Je,{icon:e.jsx(Y.lanes,{}),label:"Stage",active:rt==="stage",onClick:()=>ko(o=>o==="stage"?"allocation":"stage"),title:"Group this flow by its modeled stages"}),Ke&&rt==="allocation"&&Wo.length>0&&e.jsxs("select",{"aria-label":"Display hierarchy level",title:"Display responsibility lanes at a hierarchy level; the SysML allocation is unchanged",value:Wt,onChange:o=>Co(o.target.value==="all"?"all":Number(o.target.value)),className:"text-xs font-semibold rounded-lg px-2 py-1",style:{color:"#5B6470",background:"#FFFFFF",border:"1px solid #E2E1DB"},children:[e.jsx("option",{value:"all",children:"All levels"}),Wo.map(o=>e.jsxs("option",{value:o,children:["L",o]},o))]}),e.jsx(xe,{}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:D.xs,fontWeight:600},children:"Steps"}),e.jsx(Nt,{value:Gt,onChange:Yo,options:[{value:"flat",label:"Inline",title:"Expanded steps join the parent flow in place"},{value:"nested",label:"Nested",title:"Expanded steps are drawn inside their composite action (swimlanes off)"}]}),e.jsx(xe,{}),e.jsx(Nt,{value:$t,onChange:ss,options:[{value:"horizontal",icon:e.jsx(Y.arrowRight,{}),title:"Left-to-right flow"},{value:"vertical",icon:e.jsx(Y.arrowDown,{}),title:"Top-to-bottom flow"}]}),e.jsx(xe,{}),e.jsxs(qr,{children:[e.jsx(ie,{icon:e.jsx(Y.expand,{}),title:"Expand all sub-actions",onClick:()=>Ue(new Set(Object.values((t==null?void 0:t.elements)??{}).map(o=>o.parentAction).filter(o=>!!o)))}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),title:"Collapse all sub-actions",onClick:()=>Ue(new Set)})]}),e.jsx(xe,{}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Je,{icon:e.jsx(Y.filter,{}),active:Eo,badge:`${be.size}/4`,onClick:()=>is(o=>!o),title:"Choose which modeled connection categories are visible"}),Eo&&e.jsxs("div",{className:"absolute top-full right-0 mt-2 p-3 rounded-lg",style:{width:264,background:"#FFFFFF",border:"1px solid #D1D5DB",boxShadow:"0 8px 24px rgba(0,0,0,0.14)",zIndex:30},children:[e.jsx("div",{style:{color:"#1F2937",fontWeight:700,fontSize:D.xs},children:"Show connection categories"}),e.jsx("div",{style:{color:"#6B7280",fontSize:D.xs,lineHeight:1.4,marginTop:3,marginBottom:8},children:"Changes this diagram view only; the SysML model is not modified."}),["control","data","energy","material"].map(o=>{const s=be.has(o),c=o==="control"?"#4B5563":o==="data"?"#3498DB":o==="energy"?"#D97706":"#16A34A";return e.jsxs("button",{role:"switch","aria-checked":s,onClick:()=>rs(u=>{const x=new Set(u);return x.has(o)?x.delete(o):x.add(o),x}),className:"w-full flex items-center justify-between px-1 py-1.5 rounded",style:{color:"#374151",textTransform:"capitalize"},title:`${s?"Hide":"Show"} ${o} connections`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:c}}),o]}),e.jsx("span",{"aria-hidden":"true",style:{width:32,height:18,borderRadius:9,background:s?"#2563EB":"#D1D5DB",padding:2,transition:"background 160ms ease"},children:e.jsx("span",{style:{display:"block",width:14,height:14,borderRadius:"50%",background:"#FFFFFF",boxShadow:"0 1px 2px rgba(0,0,0,0.22)",transform:s?"translateX(14px)":"translateX(0)",transition:"transform 160ms ease"}})})]},o)})]})]}),e.jsx(co,{path:ms,nameOf:o=>{var s;return((s=t==null?void 0:t.elements[o])==null?void 0:s.name)??o},onFocus:Xt,rootLabel:"Back to the whole action flow"})]}),L==="interconnection"&&e.jsxs(e.Fragment,{children:[e.jsx(xe,{}),e.jsx(ie,{icon:e.jsx(Y.expand,{}),onClick:()=>Xe(new Set),title:"Expand all parts",ariaLabel:"Expand all"}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),onClick:()=>Xe(new Set(ys)),title:"Collapse all parts",ariaLabel:"Collapse all"}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:D.xs,fontWeight:600},children:"Ports"}),e.jsx(Nt,{value:Ge,onChange:Po,options:[{value:"all",label:"Nested",title:"Show ports and their nested ports"},{value:"ports",label:"Top",title:"Show top-level ports only (nested connectors lift to the parent port)"},{value:"none",label:"Off",title:"Hide ports; connectors run part to part"}]}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:D.xs,fontWeight:600},children:"Connections"}),e.jsx(Nt,{value:Yt,onChange:Ho,options:[{value:"summary",label:"Summary",title:"Show focused-subsystem boundary flows and bundle repeated rendered endpoint pairs"},{value:"all",label:"All",title:"Show every model connector"},{value:"none",label:"Off",title:"Hide connectors while inspecting block structure"}]}),e.jsx(co,{path:gs,nameOf:o=>{var s;return((s=t==null?void 0:t.elements[o])==null?void 0:s.name)??o},onFocus:Vt,rootLabel:"Back to the whole diagram"})]}),L==="statetransition"&&e.jsxs(e.Fragment,{children:[e.jsx(xe,{}),e.jsx(ie,{icon:e.jsx(Y.expand,{}),onClick:()=>qe(new Set),title:"Show all substates",ariaLabel:"Expand all substates"}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),onClick:()=>qe(new Set(yt)),title:"Fold every composite state",ariaLabel:"Collapse all substates"}),e.jsx(co,{path:fs,nameOf:o=>{var s;return((s=t==null?void 0:t.elements[o])==null?void 0:s.name)??o},onFocus:Ut,rootLabel:"Back to the whole machine"})]}),Pt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsxs("label",{className:"flex items-center gap-1 text-xs font-semibold",style:{color:"#475569"},children:["Level",e.jsxs("select",{"aria-label":"Use case hierarchy level",value:Ht,onChange:o=>zo(o.target.value==="all"?"all":Number(o.target.value)),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{color:"#374151",background:"#FFFFFF",border:"1px solid #D1D5DB"},children:[e.jsx("option",{value:"all",children:"All levels"}),Array.from({length:cs+1},(o,s)=>e.jsxs("option",{value:s,children:["L",s]},s))]})]}),e.jsxs("label",{className:"flex items-center gap-1 text-xs font-semibold",style:{color:"#475569"},children:["Routing",e.jsxs("select",{"aria-label":"Use case connector routing",value:_t,onChange:o=>To(o.target.value),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{color:"#374151",background:"#FFFFFF",border:"1px solid #D1D5DB"},children:[e.jsx("option",{value:"straight",children:"Straight"}),e.jsx("option",{value:"elbow",children:"Elbow"}),e.jsx("option",{value:"rounded",children:"Rounded"}),e.jsx("option",{value:"curved",children:"Curved"}),e.jsx("option",{value:"arc",children:"Arc"})]})]}),e.jsx("button",{onClick:js,className:"px-2 py-0.5 text-xs font-semibold rounded",style:{color:"#047857",background:"#ECFDF5",border:"1px solid #A7F3D0"},title:"Reapply the constrained hierarchy layout and obstacle-aware routes",children:"Auto arrange"}),Lo.length>0&&e.jsxs("details",{className:"relative",children:[e.jsxs("summary",{className:"px-2 py-0.5 text-xs font-semibold rounded cursor-pointer",style:{color:"#374151",background:"#FFFFFF",border:"1px solid #D1D5DB"},children:["Actors",_e.size?`: ${_e.size} hidden`:""]}),e.jsxs("div",{className:"absolute top-7 left-0 z-30 min-w-48 p-2 rounded shadow-lg",style:{background:"#FFFFFF",border:"1px solid #D1D5DB"},children:[e.jsx("div",{className:"mb-1 text-xs",style:{color:"#64748B"},children:"Hide related use cases"}),Lo.map(o=>e.jsxs("label",{className:"flex items-center gap-2 py-1 text-xs",style:{color:"#374151"},children:[e.jsx("input",{type:"checkbox",checked:_e.has(o.id),onChange:()=>Ro(s=>{const c=new Set(s);return c.has(o.id)?c.delete(o.id):c.add(o.id),c})}),o.name]},o.id))]})]})]}),Me&&!Pt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #E5E5E0"},children:ds.map(o=>e.jsx("button",{onClick:()=>{Bo(o),de.current.clear()},className:"px-2 py-0.5 text-xs font-medium capitalize",style:{background:De===o?"#1B3A4B":"#FFFFFF",color:De===o?"#FFFFFF":"#6B7280"},title:o==="graph"?"Relationship graph with compartments":o==="tree"?"Decomposition tree with expand/collapse":"Nested containment blocks",children:o},o))}),De!=="graph"&&e.jsxs(e.Fragment,{children:[e.jsx(ie,{icon:e.jsx(Y.expand,{}),onClick:Zt,title:"Expand all nodes",ariaLabel:"Expand all"}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),onClick:Qt,title:"Collapse all nodes",ariaLabel:"Collapse all"}),De==="tree"&&e.jsx("button",{onClick:Jt,className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#374151",border:"1px solid #E5E5E0"},title:"Re-layout the tree from scratch",children:"↻ Reset"})]})]}),pt&&!ke&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #E5E5E0"},children:["containment","decomposition"].map(o=>e.jsx("button",{onClick:()=>{hs(o),de.current.clear()},className:"px-2 py-0.5 text-xs font-medium",style:{background:Ve===o?"#1B3A4B":"#FFFFFF",color:Ve===o?"#FFFFFF":"#6B7280"},children:o==="containment"?"Containment":"Decomposition"},o))}),e.jsx(xe,{}),e.jsx(ie,{icon:e.jsx(Y.expand,{}),onClick:Zt,title:"Expand all nodes",ariaLabel:"Expand all"}),e.jsx(ie,{icon:e.jsx(Y.collapse,{}),onClick:Qt,title:"Collapse all nodes",ariaLabel:"Collapse all"}),Ve==="decomposition"&&e.jsx("button",{onClick:Jt,className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#374151",border:"1px solid #E5E5E0"},title:"Re-layout the tree from scratch",children:"↻ Reset"})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),!Pt&&e.jsxs("button",{"aria-pressed":me,onClick:()=>{if(me)ee();else{const o=O.getState().diagramLayouts[l],s={nodes:{},edges:{},canvas:{...o==null?void 0:o.canvas,autoLayout:!0}};v({[l]:s}),je(l,s),Rt(c=>c+1)}},className:"px-2 py-0.5 text-xs font-semibold rounded",style:{background:me?"#ECFDF5":"#FFF7ED",color:me?"#047857":"#C2410C",border:`1px solid ${me?"#A7F3D0":"#FED7AA"}`},title:me?"Auto layout is on. Drag any item to switch it off and preserve your changes automatically.":"Auto layout is off. Your changes are saved automatically; click to discard overrides and recalculate.",children:["Auto layout: ",me?"On":"Off"]})]}),l&&L==="interconnection"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #CBD5E1"},children:["note","text","constraint"].map(o=>e.jsxs("button",{onClick:()=>ls(o),className:"px-2 py-0.5 text-xs font-medium capitalize",style:{background:"#FFFFFF",color:"#475569",border:0},title:`Add an editable ${o} annotation to this IBD`,children:["+ ",o]},o))}),e.jsxs("button",{"aria-pressed":we,onClick:()=>{const o=O.getState().diagramLayouts[l]??{nodes:{},edges:{}},s={...o,canvas:{...o.canvas,flowAnimation:!we}};v({[l]:s}),je(l,s),S(c=>c.map(u=>({...u,data:{...u.data,flowAnimation:!we}})))},className:"px-2 py-0.5 text-xs font-semibold rounded",style:{background:we?"#EFF6FF":"#F8FAFC",color:we?"#1D4ED8":"#64748B",border:`1px solid ${we?"#93C5FD":"#CBD5E1"}`},title:"Toggle animated source-to-target flow on IBD connectors",children:["Flow: ",we?"On":"Off"]}),e.jsx("button",{"aria-pressed":_o,onClick:()=>Ko(o=>!o),className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F8FAFC",color:"#475569",border:"1px solid #CBD5E1"},title:"Show or hide the IBD notation legend",children:"Legend"})]})]}),We&&e.jsxs("div",{className:"absolute top-3 right-3 z-10 flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs",style:{background:"#1B3A4B",color:"#FFFFFF",boxShadow:"0 2px 8px rgba(0,0,0,0.18)"},children:[e.jsx("span",{style:{color:"#2DD4A8",fontWeight:700},children:"◎ Focus"}),e.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Depth"}),[1,2,3].map(o=>e.jsx("button",{onClick:()=>as(o),style:{width:20,height:20,borderRadius:4,cursor:"pointer",background:ct===o?"#2DD4A8":"rgba(255,255,255,0.15)",color:ct===o?"#1B3A4B":"#FFFFFF",fontWeight:700,fontSize:"11px",border:"none"},children:o},o)),e.jsx("button",{onClick:()=>{Io(null),z(o=>o.map(s=>({...s,style:{...s.style,opacity:1,pointerEvents:"all"}}))),S(o=>o.map(s=>({...s,style:{...s.style,opacity:1}})))},style:{marginLeft:4,padding:"2px 8px",borderRadius:4,cursor:"pointer",background:"rgba(255,255,255,0.15)",color:"#FFFFFF",fontSize:"11px",border:"none"},children:"Exit Focus"})]}),dt&&e.jsxs("div",{className:"absolute bottom-12 left-1/2 -translate-x-1/2 z-50 px-4 py-2 rounded-lg text-xs font-mono",style:{background:"#1B3A4B",color:"#2DD4A8",boxShadow:"0 4px 16px rgba(0,0,0,0.2)",whiteSpace:"nowrap"},children:["Copied: ",dt]}),Z&&e.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-10 px-4 py-1.5 rounded-full text-xs font-medium",style:{background:"#FFFFFF",color:"#6B7280",border:"1px solid #E5E5E0",boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:"Computing layout…"}),Fo&&!Z&&e.jsxs("div",{role:"alert",className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 flex items-center gap-3 px-3 py-2",style:{maxWidth:620,background:"#FFFDF7",color:"#5F4300",border:"1px solid #E7C35A",borderRadius:4,boxShadow:"0 2px 8px rgba(31,41,55,0.10)",fontSize:D.xs},children:[e.jsx("span",{children:Fo}),e.jsx("button",{onClick:Jt,style:{border:"1px solid #B58A12",borderRadius:3,background:"#FFFFFF",color:"#5F4300",padding:"3px 8px",fontWeight:700,whiteSpace:"nowrap"},children:"Retry"})]}),ht.length>0&&!Z&&e.jsxs("div",{role:"alert",className:"absolute top-16 left-1/2 -translate-x-1/2 z-20 px-3 py-2",style:{maxWidth:720,background:"#FEF2F2",color:"#991B1B",border:"1px solid #FCA5A5",borderRadius:4,boxShadow:"0 2px 8px rgba(31,41,55,0.10)",fontSize:D.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"Diagram error:"})," ",ht.length," floating ",ht.length===1?"action has":"actions have"," no flow or succession connection:"," ",ht.map((o,s)=>e.jsxs("span",{children:[s>0&&", ",e.jsx("button",{onClick:()=>w(o.id),style:{color:"#991B1B",textDecoration:"underline",fontWeight:700},children:o.name})]},o.id))]}),bt&&!Z&&e.jsxs("div",{role:"alert",className:"absolute top-16 left-1/2 -translate-x-1/2 z-20 px-3 py-2",style:{maxWidth:720,background:"#FEF2F2",color:"#991B1B",border:"1px solid #FCA5A5",borderRadius:4,boxShadow:"0 2px 8px rgba(31,41,55,0.10)",fontSize:D.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"BDD error:"})," ","expected one connected hierarchy, but found ",bt.rootIds.length," roots",bt.disconnectedIds.length>0&&e.jsxs(e.Fragment,{children:[" and ",bt.disconnectedIds.length," disconnected/floating elements"]}),"."]}),L==="actionflow"&&e.jsxs("div",{"aria-label":"Action flow legend",className:"absolute right-3 bottom-3 z-10 flex items-center gap-4 px-3 py-2",style:{background:"rgba(255,255,255,0.96)",border:"1px solid #D1D5DB",borderRadius:3,color:"#374151",fontSize:D.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"Legend"}),be.has("control")&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:24,height:0,borderTop:"2px solid #4B5563"}}),"Control flow"]}),be.has("data")&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #3498DB"}}),"Object flow"]}),be.has("energy")&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #D97706"}}),"Energy flow"]}),be.has("material")&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #16A34A"}}),"Material flow"]})]}),L==="interconnection"&&H.length>0&&_o&&e.jsxs("div",{"aria-label":"Interconnection legend",className:"absolute right-3 bottom-3 z-10 flex flex-col gap-1.5 px-3 py-2",style:{background:"rgba(255,255,255,0.96)",border:"1px solid #D1D5DB",borderRadius:4,color:"#374151",fontSize:D.xs},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{style:{fontWeight:700},children:"Ports"}),Ge!=="none"?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(lo,{color:At.in,glyph:"→"})," in"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(lo,{color:At.out,glyph:"→"})," out"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(lo,{color:At.inout,glyph:"⇄"})," inout"]}),Ge==="all"&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{width:9,height:9,borderRadius:2,flexShrink:0,background:"#6B728022",border:"1.5px solid #6B7280"}}),"nested"]})]}):e.jsx("span",{style:{color:"#9CA3AF"},children:"hidden"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{style:{fontWeight:700},children:"Flow"}),["data","energy","material"].map(o=>e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:20,height:0,borderTop:`2.5px solid ${Oi[o]}`}}),o]},o))]})]}),!Z&&H.length===0&&g&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",style:{zIndex:1},children:g.auto&&((yn=g.elementIds)==null?void 0:yn.length)===0?e.jsxs("div",{className:"text-center",style:{maxWidth:420},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:8},children:"🔍"}),e.jsx("div",{style:{fontSize:D.sm,color:"#374151",fontWeight:600,marginBottom:4},children:"This view selects no elements"}),e.jsx("div",{style:{fontSize:D.xs,color:"#6B7280",lineHeight:1.6},children:"The view is auto-populated from its selectionQuery in the model. Add includeElementKinds / includeLayers to its SysML definition, or link elements to it with IncludedIn relationships."})]}):e.jsxs("div",{className:"text-center",style:{opacity:.4},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:8},children:"🖱️"}),e.jsx("div",{style:{fontSize:D.sm,color:"#6B7280"},children:"Drag from palette or double-click to create elements"})]})}),pe.length>=2&&e.jsx(Xi,{count:pe.length,opacity:Ys,onAlign:_s,onMatchSize:Ks,onDistribute:Vs,onFill:o=>an({color:o}),onOpacity:o=>an({opacity:o})}),Z&&e.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",zIndex:20,background:`linear-gradient(90deg, ${In.accent} 0%, ${In.accent}80 50%, transparent 100%)`,backgroundSize:"200% 100%",animation:"memo-layout-progress 1.2s linear infinite"}}),e.jsxs(ni,{nodes:H,edges:q,nodeTypes:bs,edgeTypes:Fs,onNodesChange:Bs,onEdgesChange:te,onNodeClick:Rs,onNodeDoubleClick:Ls,onEdgeClick:Ws,onPaneClick:$s,onNodeDragStart:As,onNodeDragStop:Ms,onNodeContextMenu:zs,onEdgeContextMenu:Ts,onNodeMouseEnter:Os,onNodeMouseLeave:rn,onEdgeMouseEnter:Ps,onEdgeMouseLeave:rn,onConnect:Ds,onConnectStart:Es,onConnectEnd:Is,connectionMode:si.Loose,defaultEdgeOptions:{interactionWidth:24},snapToGrid:os,snapGrid:oa,fitView:!0,fitViewOptions:{...Jr,minZoom:Ie},minZoom:.1,maxZoom:3,zoomOnScroll:!0,panOnScroll:!0,panOnScrollMode:"free",selectionOnDrag:!0,panOnDrag:[1,2],multiSelectionKeyCode:["Shift","Meta","Control"],selectionKeyCode:null,proOptions:ta,style:Qr,children:[vo&&e.jsx(ii,{color:"#C5C7C2",gap:20,size:1.5}),e.jsx(tr,{}),e.jsx(ri,{}),H.length>20&&e.jsx(ai,{style:ea,nodeColor:ws,maskColor:"rgba(247, 247, 245, 0.7)"})]})]}),se&&e.jsx(aa,{x:se.x,y:se.y,onConfirm:Cs,onCancel:()=>Le(null)}),Fe&&e.jsx(Pi,{x:Fe.x,y:Fe.y,sourceElement:Fe.sourceElement,targetElement:Fe.targetElement,registries:n,allowedTypes:g==null?void 0:g.relationshipTypes,onSelect:Ns,onCancel:()=>at(null)}),J&&e.jsx(Hr,{x:J.x,y:J.y,nodeId:J.nodeId,nodeKind:J.nodeKind,onClose:()=>$e(null),onEditName:()=>{z(o=>o.map(s=>s.id===J.nodeId?{...s,data:{...s.data,_triggerEdit:!0}}:s))},onChangeColor:o=>Hs(J.nodeId,o),onRemoveFromDiagram:()=>ln(J.nodeId),onDeleteFromModel:()=>{ln(J.nodeId)},onShowProperties:()=>{f(J.nodeId)},onShowInCatalog:()=>{f(J.nodeId),I("catalog")},onFocusElement:()=>{Io(J.nodeId)},onShowRelMatrix:()=>{h({type:"traceability"})},onOpenSource:()=>{const o=t==null?void 0:t.elements[J.nodeId];o!=null&&o.file&&(navigator.clipboard.writeText(o.file).catch(()=>{}),Do(o.file))},onViewKindInOntology:()=>{const o=J.nodeKind;let s=null,c=null;for(const u of j){for(const x of u.layers)if(x.kinds.some(y=>y.name===o)){s=u.name,c=x.id;break}if(s)break}s&&(m(o),C("ontologies"),I("ontology"),h({type:"ontology-detail",packageName:s,layerId:c??void 0}))}}),fe&&e.jsx(Kr,{x:fe.x,y:fe.y,edgeId:fe.edgeId,relType:fe.relType,onClose:()=>lt(null),onChangeStyle:o=>Xs(fe.edgeId,o),onChangeColor:o=>Gs(fe.edgeId,o),onToggleLabel:()=>Us(fe.edgeId),onDelete:()=>S(o=>o.filter(s=>s.id!==fe.edgeId))})]})}function ya(){return e.jsx(Qs,{children:e.jsx(la,{})})}export{ya as DiagramCanvas};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiagramCanvas-
|
|
2
|
-
var fe=Object.defineProperty;var me=(t,s,i)=>s in t?fe(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i;var B=(t,s,i)=>me(t,typeof s!="symbol"?s+"":s,i);import{_ as P,u as C,g as xe,a as he,l as pe,s as ge,b as ve,c as Se,F as d,C as a,d as ye,L as be,e as Ee,f as Fe}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiagramCanvas-B9d4aLKt.js","assets/reactflow-CsCqNKB-.js","assets/zustand-CrhqMOHB.js","assets/index-CVW92JY7.js","assets/index-Y1UZTZg-.css","assets/layout-selection-ClQ295Xc.js","assets/layout-providers-Dr743WlP.js","assets/elk-6l8mIQnQ.js","assets/style-BZV40eAE.css","assets/MaxGraphCanvas-DqKU1PTY.js","assets/SysmlCodeEditor-Die2RUsz.js","assets/SysmlCodeEditor-BwKcXIZw.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var fe=Object.defineProperty;var me=(t,s,i)=>s in t?fe(t,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[s]=i;var B=(t,s,i)=>me(t,typeof s!="symbol"?s+"":s,i);import{_ as P,u as C,g as xe,a as he,l as pe,s as ge,b as ve,c as Se,F as d,C as a,d as ye,L as be,e as Ee,f as Fe}from"./index-CVW92JY7.js";import{j as e}from"./reactflow-CsCqNKB-.js";import{a as r}from"./zustand-CrhqMOHB.js";const V="memo.renderer.reactflow";class we{constructor(){B(this,"providers",new Map);B(this,"components",new Map)}register(s){const i=this.providers.get(s.descriptor.id);if(i&&i!==s)throw new Error(`Renderer provider already registered: ${s.descriptor.id}`);this.providers.set(s.descriptor.id,s)}unregister(s){return this.components.delete(s),this.providers.delete(s)}get(s){return this.providers.get(s)}has(s){return this.providers.has(s)}list(s=[]){return[...this.providers.values()].map(i=>i.descriptor).filter(i=>s.every(o=>i.capabilities.includes(o))).sort((i,o)=>i.name.localeCompare(o.name))}loadComponent(s){const i=this.providers.get(s)??this.providers.get(V);if(!i)throw new Error(`Renderer provider not found: ${s} (no default registered)`);const o=i.descriptor.id;let n=this.components.get(o);return n||(n=i.loadComponent(),this.components.set(o,n)),n}}const Re={descriptor:{id:"memo.renderer.reactflow",name:"ReactFlow",engine:"ReactFlow (@xyflow/react 12)",version:"12",contractVersion:"1",license:"MIT",description:"Default authoring canvas — React node components, palette, full editing.",capabilities:["interactive-editing","all-view-kinds","manual-layout","undo-redo","minimap","orthogonal-routes"]},loadComponent:()=>P(()=>import("./DiagramCanvas-B9d4aLKt.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(t=>t.DiagramCanvas)},je={descriptor:{id:"memo.renderer.maxgraph",name:"maxGraph",engine:"maxGraph (@maxgraph/core — draw.io rendering engine lineage)",version:"0.x",contractVersion:"1",license:"Apache-2.0",description:"draw.io-style retained-mode canvas — SVG cells, rubberband selection, image export.",capabilities:["all-view-kinds","manual-layout","export-image"]},loadComponent:()=>P(()=>import("./MaxGraphCanvas-DqKU1PTY.js"),__vite__mapDeps([9,1,2,3,4,5,6,7])).then(t=>t.MaxGraphCanvas)},$=new we;$.register(Re);$.register(je);const Ce={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},Ae="memo.diagram.renderer.v3",_e="renderer",ke="memo.renderer.",se=new Set;function G(t){const s=t==null?void 0:t.trim();if(s)return s.includes(".")?s:`${ke}${s}`}function De(){if(!(typeof window>"u"))try{return G(new URLSearchParams(window.location.search).get(_e))}catch{return}}function Te(){if(!(typeof window>"u"))try{return G(window.localStorage.getItem(Ae))}catch{return}}function Le(){try{const t=Ce;return G(t==null?void 0:t.VITE_MEMO_DIAGRAM_RENDERER)}catch{return}}function re(){return De()??Te()??Le()??V}function Me(t){return se.add(t),()=>se.delete(t)}function Ne(){return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5",color:"#9CA3AF",fontSize:13},children:"Loading renderer…"})}function ze(){const t=r.useSyncExternalStore(Me,re,re),s=$.has(t)?t:V,i=r.useMemo(()=>r.lazy(()=>$.loadComponent(s).then(o=>({default:o}))),[s]);return e.jsx("div",{className:"relative flex flex-1 overflow-hidden",children:e.jsx(r.Suspense,{fallback:e.jsx(Ne,{}),children:e.jsx(i,{})})})}const $e=r.lazy(()=>P(()=>import("./SysmlCodeEditor-Die2RUsz.js"),__vite__mapDeps([10,1,2,11])).then(t=>({default:t.SysmlCodeEditor})));function Oe(t,s){const i=(t.elementIds??[]).map(o=>s[o]).filter(Boolean).map(o=>` ${o.construct??"part"} ${o.id} : ${o.kind};`).join(`
|
|
3
3
|
`);return[`package '${t.name}' {`,` // Diagram: ${t.diagramType.toUpperCase()} | Viewpoint: ${t.viewpointId}`,i||" // No elements selected","}"].join(`
|
|
4
4
|
`)}function Ie({diagram:t}){const s=C(c=>c.model),i=C(c=>c.updateDiagramElementIds),[o,n]=r.useState(""),m=r.useMemo(()=>ye(s),[s]),O=r.useCallback(c=>{const x=new Set(t.elementIds??[]);x.has(c)?x.delete(c):x.add(c),i(t.id,[...x])},[t.id,t.elementIds,i]),w=r.useMemo(()=>new Set(t.elementIds??[]),[t.elementIds]),E=be.filter(c=>m.has(c));return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",style:{width:"220px",borderLeft:`1px solid ${a.border}`,background:"#FAFAF8",flexShrink:0},children:[e.jsxs("div",{className:"px-2 py-1.5",style:{borderBottom:`1px solid ${a.border}`},children:[e.jsxs("div",{className:"font-semibold mb-1",style:{color:a.primary,fontSize:d.xs},children:["Elements (",w.size," selected)"]}),e.jsx("input",{value:o,onChange:c=>n(c.target.value),placeholder:"Filter…",className:"w-full px-2 py-1 rounded focus:outline-none",style:{background:"#F0F0ED",border:`1px solid ${a.border}`,color:a.primary,fontSize:d.xs}})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:E.map(c=>{const x=(m.get(c)??[]).filter(u=>!o||u.name.toLowerCase().includes(o.toLowerCase())||u.id.toLowerCase().includes(o.toLowerCase()));if(x.length===0)return null;const I=Fe[c]??a.muted;return e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1 font-semibold",style:{color:I,fontSize:d.badge},children:Ee[c]??c}),x.map(u=>e.jsxs("label",{className:"flex items-center gap-2 px-3 py-0.5 cursor-pointer",style:{fontSize:d.xs},onMouseEnter:h=>h.currentTarget.style.background="#F0F0ED",onMouseLeave:h=>h.currentTarget.style.background="transparent",children:[e.jsx("input",{type:"checkbox",checked:w.has(u.id),onChange:()=>O(u.id),style:{accentColor:a.accent}}),e.jsx("span",{className:"truncate",style:{color:a.primary},title:u.id,children:u.name||u.id})]},u.id))]},c)})})]})}function ne({tone:t,message:s,actions:i}){const o=t==="conflict";return e.jsxs("div",{role:"alert",className:"flex items-center gap-2 px-3 py-1.5 flex-wrap",style:{background:o?"#FEF2F2":"#FFFBEB",borderBottom:`1px solid ${o?"#FECACA":"#FDE68A"}`,color:o?"#B91C1C":"#92400E",fontSize:d.xs,flexShrink:0},children:[e.jsx("span",{className:"flex-1",style:{minWidth:180},children:s}),i.map(n=>e.jsx("button",{onClick:n.onClick,title:n.hint,style:{fontSize:d.xs,padding:"2px 8px",borderRadius:5,cursor:"pointer",background:"#FFFFFF",border:`1px solid ${o?"#FECACA":"#FDE68A"}`,color:"inherit",fontWeight:600,whiteSpace:"nowrap"},children:n.label},n.label))]})}const Be=4e3;function Pe({at:t}){const[s,i]=r.useState(!1);return r.useEffect(()=>{if(!t)return;i(!0);const o=setTimeout(()=>i(!1),Be);return()=>clearTimeout(o)},[t]),s?e.jsx("span",{title:"A source file this view depends on changed; the view was rebuilt",style:{fontSize:d.badge,padding:"1px 6px",borderRadius:999,background:"#ECFDF5",color:"#047857",border:"1px solid #A7F3D0",whiteSpace:"nowrap"},children:"↻ Refreshed from source"}):null}const Ve=[];function We({diagramId:t}){const s=C(l=>l.model),i=C(l=>l.diagramParseErrors[t]??Ve),o=C(l=>l.lastSourceChange),n=xe(s,t),[m,O]=r.useState("visual"),[w,E]=r.useState(""),[c,x]=r.useState(!1),[I,u]=r.useState(!1),[h,Y]=r.useState(!1),[p,A]=r.useState(!1),[R,y]=r.useState(null),[oe,q]=r.useState(null),[_,j]=r.useState(null),[k,D]=r.useState(null),[ie,le]=r.useState(null),[U,W]=r.useState([]),[T,ae]=r.useState(()=>localStorage.getItem("memo.diagramEditor.autoSave")==="true"),b=r.useRef(),v=r.useRef(""),K=r.useRef(0),L=r.useRef(void 0),M=r.useRef(0),H=r.useRef(!1);r.useEffect(()=>{H.current=p},[p]);const Q=r.useMemo(()=>he(s,t),[s,t]),N=r.useCallback(async()=>{const l=++M.current,g=t;x(!0);try{const S=await pe(g);if(M.current!==l)return!1;const f=S.text??"";return v.current=f,L.current=S.revision,E(f),u(!0),A(!1),y(null),D(null),j(null),!0}catch(S){return M.current===l&&y(S instanceof Error?S.message:String(S)),!1}finally{M.current===l&&x(!1)}},[t]);r.useEffect(()=>{if(clearTimeout(b.current),y(null),q(null),A(!1),j(null),D(null),W([]),L.current=void 0,!(!n||!s)){if(!n.sourceFile||window.__MEMO_DATA__){const l=Oe(n,s.elements);v.current=l,E(l),x(!1),u(!1);return}E(""),v.current="",u(!1),N()}},[t,n==null?void 0:n.sourceFile]),r.useEffect(()=>{if(!o||!(n!=null&&n.sourceFile)||window.__MEMO_DATA__||!ge(o,Q))return;le(o.at);const l=o.files.includes(n.sourceFile);if(l){if(H.current){j({files:o.files.filter(g=>Q.includes(g)),at:o.at,touchesOwnSource:l});return}N()}},[o==null?void 0:o.seq]);const ce=l=>{v.current=l,E(l),A(!0),y(null)},F=r.useCallback(async(l,g)=>{if(!n)return;const S=++K.current;Y(!0),y(null);try{if(n.sourceFile){const f=await ve(t,l,g!=null&&g.force?void 0:L.current);if(f.conflict){D({theirs:f.text??"",revision:f.revision,at:Date.now()}),y(f.error??"The file changed on disk since this edit began.");return}L.current=f.revision,D(null),j(null),W(f.parseErrors??[])}else Se(t,l);v.current===l&&A(!1),q(Date.now())}catch(f){y(f instanceof Error?f.message:String(f))}finally{K.current===S&&Y(!1)}},[n,t]),X=r.useCallback(()=>{clearTimeout(b.current),N()},[N]),de=r.useCallback(()=>{clearTimeout(b.current),F(v.current,{force:!0})},[F]);r.useEffect(()=>(localStorage.setItem("memo.diagramEditor.autoSave",String(T)),clearTimeout(b.current),T&&p&&!c&&!k&&(b.current=setTimeout(()=>void F(v.current),800)),()=>clearTimeout(b.current)),[T,p,c,w,F,k]);const J=r.useCallback(()=>{clearTimeout(b.current),F(v.current)},[F]),ue=r.useMemo(()=>Object.values((s==null?void 0:s.elements)??{}).map(l=>({id:l.id,name:l.name,kind:l.kind})),[s==null?void 0:s.elements]);if(!n)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:a.faint,fontSize:d.sm},children:"Diagram not found"});const Z=n.auto,z=!Z||!!n.sourceFile&&I,ee=e.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden",children:[k&&e.jsx(ne,{tone:"conflict",message:`${n.sourceFile} changed on disk while you were editing. Saving now would discard those changes.`,actions:[{label:"Reload from disk",onClick:X,hint:"Discards your unsaved edits"},{label:"Overwrite with mine",onClick:de,hint:"Discards the changes on disk"}]}),!k&&_&&e.jsx(ne,{tone:"notice",message:_.files.length>1?`${_.files.length} source files changed on disk. Your unsaved edits are untouched.`:`${_.files[0]} changed on disk. Your unsaved edits are untouched.`,actions:[{label:"Reload from disk",onClick:X,hint:"Discards your unsaved edits"},{label:"Keep editing",onClick:()=>j(null),hint:"Dismiss until the next change"}]}),e.jsx("div",{className:"flex-1 overflow-hidden",style:{background:"#1E1E1E"},children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"h-full flex items-center justify-center",style:{color:"#9CA3AF",fontSize:d.xs},children:"Loading SysML editor…"}),children:e.jsx($e,{value:w,sourceFile:n.sourceFile,readOnly:!z||c,symbols:ue,onChange:ce,onSave:()=>{z&&p&&J()}})})}),U.length>0&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C1407",color:"#FCD34D",borderTop:"1px solid #3B2A0A",fontFamily:"monospace"},title:"Saved, but the file does not parse — the model keeps its last good state for this file",children:U.join(" · ")}),i.length>0&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C0A0A",color:"#F87171",borderTop:"1px solid #3B0A0A",fontFamily:"monospace"},children:i.join(" · ")}),R&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C0A0A",color:"#FCA5A5",borderTop:"1px solid #3B0A0A"},children:R}),!z&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#F9F9F8",color:a.faint,borderTop:`1px solid ${a.border}`},children:n.sourceFile&&window.__MEMO_DATA__?"Static build — run memo-architect dev to edit the SysML source":n.sourceFile?"The SysML source could not be loaded":"Generated model view — no editable SysML source file"})]}),te=e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:e.jsx(ze,{})}),!Z&&e.jsx(Ie,{diagram:n})]});return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5",style:{borderBottom:`1px solid ${a.border}`,background:"#FAFAF8",flexShrink:0},children:[e.jsx("span",{className:"font-semibold truncate flex-1",style:{color:a.primary,fontSize:d.sm},children:n.name}),n.sourceFile&&e.jsx("span",{className:"truncate",title:n.sourceFile,style:{maxWidth:"220px",color:a.faint,fontSize:d.xs},children:n.sourceFile}),(m==="text"||m==="split")&&e.jsx("span",{title:"Local, public Monaco editor with SysML highlighting and model-aware completion",style:{color:"#4B6E80",fontSize:d.badge},children:"Monaco · SysML"}),e.jsx(Pe,{at:ie}),c&&e.jsx("span",{style:{color:a.faint,fontSize:d.xs},children:"Loading source…"}),h&&e.jsx("span",{style:{color:a.faint,fontSize:d.xs},children:"Saving…"}),!h&&R&&e.jsx("span",{title:R,style:{color:"#EF4444",fontSize:d.xs},children:"Save failed"}),!h&&!R&&p&&e.jsx("span",{style:{color:"#B45309",fontSize:d.xs},children:"Unsaved"}),!h&&!p&&oe&&e.jsx("span",{style:{color:"#15803D",fontSize:d.xs},children:"Saved"}),!h&&i.length>0&&e.jsxs("span",{style:{color:"#EF4444",fontSize:d.xs},children:[i.length," error",i.length>1?"s":""]}),z&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-center gap-1",style:{color:a.secondary,fontSize:d.xs},title:"Save changes 800ms after typing",children:[e.jsx("input",{type:"checkbox",checked:T,onChange:l=>ae(l.target.checked),style:{accentColor:a.accent}}),"Auto-save"]}),e.jsx("button",{onClick:J,disabled:!p||h||c,title:"Save SysML (Ctrl/Cmd+S)",style:{fontSize:d.xs,padding:"3px 10px",borderRadius:"5px",border:`1px solid ${a.border}`,cursor:!p||h||c?"default":"pointer",background:p?a.accent:"#F0F0ED",color:p?"#FFFFFF":a.faint,fontWeight:600},children:"Save"})]}),e.jsx("div",{className:"flex overflow-hidden",style:{border:`1px solid ${a.border}`,borderRadius:"6px"},children:[["visual","⬜ Visual"],["split","⧉ Split"],["text","</> Text"]].map(([l,g])=>e.jsx("button",{onClick:()=>O(l),style:{fontSize:d.xs,padding:"3px 10px",border:"none",cursor:"pointer",background:m===l?a.accent:"transparent",color:m===l?"#FFFFFF":a.secondary,fontWeight:m===l?600:400},children:g},l))})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[m==="visual"&&te,m==="text"&&ee,m==="split"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"50%",borderRight:`1px solid ${a.border}`,display:"flex",flexDirection:"column",overflow:"hidden"},children:ee}),e.jsx("div",{style:{width:"50%",display:"flex",overflow:"hidden"},children:te})]})]})]})}export{We as DiagramEditor};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{j as e}from"./reactflow-CsCqNKB-.js";import{a as b}from"./zustand-CrhqMOHB.js";import{u,h as W,C as i,F as o,f as B,q as C,P as v,t as S,v as M,w as O,x as $,y as k}from"./index-CVW92JY7.js";const p="page",D=new Set(["Scenario","UseCase","UserActivity"]);function V(d){return d?d.split(`
|
|
2
|
+
`).filter(n=>n.trim()).map((n,l)=>{const x=n.match(/^\d+\.\s*(.*)/);return{index:l,text:x?x[1].trim():n.trim()}}):[]}function U({element:d,layerColor:n,onSave:l}){const x=b.useMemo(()=>V(d.doc||""),[d.doc]),[j,h]=b.useState(!1);return j||x.length===0?e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:o.xs,color:i.faint,marginBottom:6,marginTop:0},children:["One step per line, numbered: ",e.jsx("code",{children:"1. User does something"})]}),e.jsx(S,{value:d.doc||"",onSave:c=>{l(c),h(!1)},density:p,multiline:!0,placeholder:"Click to add scenario steps…"})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>h(!0),style:{position:"absolute",top:0,right:0,fontSize:o.xs,color:i.muted,padding:"2px 9px",border:`1px solid ${i.border}`,borderRadius:"6px",background:i.surface,cursor:"pointer"},onMouseEnter:c=>{c.currentTarget.style.borderColor=i.accent},onMouseLeave:c=>{c.currentTarget.style.borderColor=i.border},children:"✎ Edit steps"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",paddingTop:4},children:[e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:o.xs,fontWeight:700,background:n,color:"#fff",letterSpacing:"0.06em",textTransform:"uppercase"},children:"Start"}),x.map((c,s)=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:[e.jsx(N,{color:n}),e.jsxs("div",{style:{width:"100%",maxWidth:"560px",display:"flex",alignItems:"flex-start",gap:"12px",background:i.surface,border:`1px solid ${n}30`,borderRadius:"8px",padding:"10px 14px",boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},children:[e.jsx("span",{style:{flexShrink:0,width:"24px",height:"24px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:n+"18",color:n,fontSize:o.xs,fontWeight:700},children:s+1}),e.jsx("span",{style:{fontSize:o.sm,color:i.primary,lineHeight:1.5,paddingTop:"3px"},children:c.text})]})]},s)),e.jsx(N,{color:n}),e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:o.xs,fontWeight:700,background:n+"20",color:n,letterSpacing:"0.06em",textTransform:"uppercase",border:`1px solid ${n}40`},children:"End"})]})]})}function N({color:d}){return e.jsx("div",{style:{width:"2px",height:"20px",background:d+"50",position:"relative"},children:e.jsx("div",{style:{position:"absolute",bottom:-5,left:"50%",transform:"translateX(-50%)",width:0,height:0,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderTop:`6px solid ${d}80`}})})}function Y({elementId:d}={}){var I,R,T;const n=u(t=>t.activeView),l=u(t=>t.model),x=u(t=>t.validation),j=u(t=>t.updateElementField),h=u(t=>t.updateElementAttribute),c=u(t=>t.applyEdit),s=d??(n.type==="element-detail"?n.elementId:null),r=s&&l?l.elements[s]:null,E=b.useMemo(()=>{if(!l||!s)return{incoming:[],outgoing:[]};const t=W(l,s);return{incoming:t.filter(a=>a.targetId===s),outgoing:t.filter(a=>a.sourceId===s)}},[l,s]),g=b.useMemo(()=>!x||!s?[]:x.violations.filter(t=>t.elementId===s),[x,s]);if(!r||!s)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:i.surfaceAlt},children:e.jsxs("div",{className:"text-center",style:{color:i.faint},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"12px",opacity:.5},children:"📄"}),e.jsx("p",{style:{fontSize:o.md},children:"Select an element to view details"})]})});const f=B[r.layer]||i.muted,m=(I=l==null?void 0:l.registries)==null?void 0:I.kinds.find(t=>t.name===r.kind),w=((R=m==null?void 0:m.namespace)==null?void 0:R[1])??((T=m==null?void 0:m.namespace)==null?void 0:T[0]),z=(t,a)=>{j(s,t,a),c(s)},L=(t,a)=>{h(s,t,a),c(s)},y=Object.entries(r.attributes).filter(([t])=>t!=="id"&&t!=="name"),F=D.has(r.kind);return e.jsx("div",{className:"flex-1 overflow-y-auto",style:{background:"#EEF4F7"},children:e.jsxs("div",{style:{maxWidth:"1040px",margin:"0 auto",padding:"20px 28px 48px"},children:[e.jsxs("header",{style:{background:i.surface,border:"1px solid rgba(60,60,67,0.12)",borderLeft:`4px solid ${f}`,borderRadius:"16px",padding:"14px 18px",marginBottom:16,boxShadow:"0 1px 3px rgba(15,23,42,0.05)"},children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",style:{marginBottom:8},children:[e.jsx("span",{className:"px-2 py-0.5 rounded-md font-semibold",style:{background:f+"18",color:f,fontSize:o.xs},children:r.kind}),e.jsx("span",{className:"px-2 py-0.5 rounded-md",style:{background:i.surfaceAlt,color:i.muted,fontSize:o.xs},children:r.layer}),w&&e.jsx("span",{style:{color:i.faint,fontSize:o.xs},children:w.replace(/[_-]/g," ").replace(/\b\w/g,t=>t.toUpperCase())}),r.shortId&&e.jsx("span",{style:{marginLeft:"auto",color:i.faint,fontSize:o.xs,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:r.shortId})]}),e.jsx("h1",{style:{fontSize:"24px",fontWeight:700,color:i.primary,lineHeight:1.2,margin:0},children:r.name}),e.jsx("div",{style:{marginTop:9,paddingTop:8,borderTop:`1px solid ${i.borderLight}`},children:e.jsx(C,{density:p})})]}),g.length>0&&e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid #FEE2E2",background:"#FEF2F2",marginBottom:20},children:[e.jsxs("div",{className:"px-4 py-2 font-semibold",style:{color:"#DC2626",fontSize:o.sm,borderBottom:"1px solid #FEE2E2"},children:[g.length," violation",g.length!==1?"s":""]}),g.map((t,a)=>e.jsxs("div",{className:"px-4 py-2 flex items-center gap-2",style:{fontSize:o.xs},children:[e.jsx("span",{style:{color:"#DC2626"},children:"✖"}),e.jsxs("span",{style:{color:i.faint},children:["[",t.ruleId,"]"]}),e.jsx("span",{style:{color:"#991B1B"},children:t.description})]},a))]}),e.jsx(v,{title:F?"Flow":"Description",density:p,collapsible:!1,children:F?e.jsx(U,{element:r,layerColor:f,onSave:t=>z("doc",t)}):e.jsx(S,{value:r.doc||"",onSave:t=>z("doc",t),density:p,multiline:!0,placeholder:"Click to add a description…"})}),e.jsxs(v,{title:"Attributes",count:y.length,density:p,collapsible:!1,children:[y.length===0&&e.jsx("p",{style:{fontSize:o.sm,color:i.faint,margin:0},children:"This element defines no attributes."}),y.length>0&&e.jsx("div",{style:{borderTop:`1px solid ${i.border}`,maxWidth:900},children:y.map(([t,a])=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(150px, 24%) minmax(0, 1fr)",gap:16,alignItems:"center",padding:"7px 0",borderBottom:`1px solid ${i.borderLight}`},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{color:i.secondary,fontSize:o.sm,fontWeight:600},children:t}),e.jsx("div",{style:{color:i.faint,fontSize:"10px"},children:"Editable"})]}),e.jsx(S,{value:String(a??""),onSave:A=>L(t,A),density:p,placeholder:"Add value…",compact:!0})]},t))})]}),e.jsx(M,{element:r,outgoing:E.outgoing,incoming:E.incoming,density:p}),e.jsx(v,{title:"Source",density:p,collapsible:!1,children:e.jsx("div",{style:{maxWidth:720},children:e.jsx(O,{label:"SysML source file",editability:k("file"),density:p,children:e.jsx($,{value:r.file??"—",editability:k("file"),density:p,mono:!0})})})})]})})}export{Y as ElementDetailView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./reactflow-CsCqNKB-.js";import{u as n}from"./index-
|
|
1
|
+
import{j as e}from"./reactflow-CsCqNKB-.js";import{u as n}from"./index-CVW92JY7.js";import"./zustand-CrhqMOHB.js";function p(){const i=n(t=>t.setBulkImportOpen),s=n(t=>t.connected),a=[{icon:"📄",title:"Import Elements from CSV",description:"Import model elements from a CSV or tab-separated file. Supports column mapping, artifact type presets, and batch preview before committing.",action:()=>i(!0),requiresConnection:!0}];return e.jsx("div",{style:{flex:1,overflow:"auto",padding:"40px 48px",background:"linear-gradient(135deg, #F0F4F7 0%, #E8EFF3 100%)",minHeight:0},children:e.jsxs("div",{style:{maxWidth:720,margin:"0 auto"},children:[e.jsx("h1",{style:{fontSize:"22px",fontWeight:700,color:"#1B3A4B",marginBottom:6},children:"Import"}),e.jsx("p",{style:{fontSize:"14px",color:"#6B7280",marginBottom:36},children:"Bring data into your model from external sources."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:16},children:a.map(t=>{const r=t.requiresConnection&&!s;return e.jsxs("button",{onClick:r?void 0:t.action,disabled:r,style:{display:"flex",alignItems:"flex-start",gap:20,padding:"20px 24px",borderRadius:12,textAlign:"left",background:r?"rgba(255,255,255,0.4)":"rgba(255,255,255,0.75)",border:`1px solid ${r?"rgba(255,255,255,0.6)":"rgba(255,255,255,0.95)"}`,boxShadow:r?"none":"0 2px 8px rgba(0,0,0,0.06)",cursor:r?"not-allowed":"pointer",transition:"all 0.15s",opacity:r?.55:1},onMouseEnter:o=>{r||(o.currentTarget.style.background="rgba(255,255,255,0.95)",o.currentTarget.style.boxShadow="0 4px 16px rgba(0,0,0,0.1)",o.currentTarget.style.transform="translateY(-1px)")},onMouseLeave:o=>{r||(o.currentTarget.style.background="rgba(255,255,255,0.75)",o.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.06)",o.currentTarget.style.transform="none")},children:[e.jsx("div",{style:{fontSize:28,lineHeight:1,flexShrink:0,marginTop:2},children:t.icon}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"#1B3A4B",marginBottom:4},children:t.title}),e.jsx("div",{style:{fontSize:"13px",color:"#6B7280",lineHeight:1.55},children:t.description}),r&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:8},children:"Connect to the dev server to use this import."})]})]},t.title)})})]})})}export{p as ImportView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t}from"./reactflow-CsCqNKB-.js";import{a as f}from"./zustand-CrhqMOHB.js";import{L as M}from"./index-
|
|
1
|
+
import{j as t}from"./reactflow-CsCqNKB-.js";import{a as f}from"./zustand-CrhqMOHB.js";import{L as M}from"./index-CVW92JY7.js";const $={"purpose-operational":{bg:"#f0f7ff",header:"#cce5ff",text:"#1e40af",border:"#93c5fd"},requirements:{bg:"#f0f6ff",header:"#dae8fc",text:"#1d4ed8",border:"#93c5fd"},architecture:{bg:"#f0faf0",header:"#d5e8d4",text:"#166534",border:"#86efac"},risk:{bg:"#fff5f5",header:"#f8cecc",text:"#991b1b",border:"#fca5a5"},"vv-evidence":{bg:"#faf5ff",header:"#e1d5e7",text:"#6b21a8",border:"#c4b5fd"},"dhf-outputs":{bg:"#fffbeb",header:"#fff2cc",text:"#92400e",border:"#fcd34d"},other:{bg:"#f9fafb",header:"#f3f4f6",text:"#374151",border:"#d1d5db"}},F=[{id:"purpose-operational",label:"Purpose & Operational",abbr:"PUR",layerIds:["purpose","business","operational"]},{id:"requirements",label:"Requirements",abbr:"REQ",layerIds:["requirements"]},{id:"architecture",label:"Architecture",abbr:"ARCH",layerIds:["functional","behavior","logical","physical","software","interfaces","ui"],subGroups:[{label:"Functional",layerIds:["functional","behavior"]},{label:"Logical",layerIds:["logical"]},{label:"Physical",layerIds:["physical"]},{label:"Software",layerIds:["software"]},{label:"Interfaces",layerIds:["interfaces","ui"]}]},{id:"risk",label:"Risk",abbr:"RISK",layerIds:["risk","safety","cybersecurity"]},{id:"vv-evidence",label:"V&V & Evidence",abbr:"V&V",layerIds:["verification","analysis"]},{id:"dhf-outputs",label:"DHF Outputs",abbr:"DHF",layerIds:["design-control","qms","software-lifecycle","operations","clinical","privacy"]}],A=Object.fromEntries(M.map((n,r)=>[n,r]));function O(n){return[...n].sort((r,d)=>(A[r.id]??99)-(A[d.id]??99))}function T(n){return[...n].sort((r,d)=>{const a=r.derivesFrom?1:0,x=d.derivesFrom?1:0;return a!==x?a-x:r.name.localeCompare(d.name)})}function B({kind:n,layerColor:r,domainBg:d,selected:a,onClick:x,onContextMenu:N,isFlashing:p,flashTick:R}){const[b,g]=f.useState(!1),[v,j]=f.useState(!1);f.useEffect(()=>{if(!p)return;j(!0);const w=setTimeout(()=>j(!1),700);return()=>clearTimeout(w)},[p,R]);const m=a?`${r}18`:b?`${r}0C`:"#ffffff",I=a?r:"transparent",k=r;return t.jsxs("button",{"data-kind":n.name,onClick:x,onContextMenu:N,onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),className:"text-left transition-all",style:{width:"130px",minHeight:"55px",background:m,border:`1px solid ${I}`,borderLeft:`3px solid ${k}`,borderRadius:"6px",padding:"6px 8px",cursor:"pointer",transform:v?"scale(1.04)":"scale(1)",boxShadow:v?`0 0 0 2px ${r}, 0 0 12px ${r}60`:a?`0 0 0 1px ${r}40`:b?"0 1px 3px rgba(0,0,0,0.08)":"none",flexShrink:0},children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{style:{fontSize:"9px",fontFamily:"monospace",color:r,opacity:.8,textTransform:"uppercase",letterSpacing:"0.02em",lineHeight:1},children:n.construct.replace("part def","pd").replace("connection def","cd").replace("attribute def","ad")}),n.instanceCount>0&&t.jsx("span",{style:{fontSize:"9px",color:"#6B7280",background:`${r}15`,borderRadius:"8px",padding:"0 4px",lineHeight:"14px"},children:n.instanceCount})]}),t.jsx("div",{style:{fontSize:"11px",fontWeight:n.derivesFrom?400:600,color:a?r:"#1F2937",lineHeight:1.3,wordBreak:"break-word"},children:n.name}),n.derivesFrom&&t.jsxs("div",{style:{fontSize:"9px",color:"#9CA3AF",marginTop:"2px",lineHeight:1},children:["↳ ",n.derivesFrom]})]})}function z({layers:n,selectedKind:r,onKindClick:d,activeLayerId:a,flashKindName:x,flashTick:N}){const p=f.useRef({}),[R,b]=f.useState(null),[g,v]=f.useState(()=>new Set(F.map(e=>e.id).concat(["other"])));if(f.useEffect(()=>{if(!a)return;const e=p.current[a];if(e){e.scrollIntoView({behavior:"smooth",block:"start"}),b(a);const o=setTimeout(()=>b(null),1200);return()=>clearTimeout(o)}},[a]),n.length===0)return t.jsx("div",{className:"flex items-center justify-center py-12",style:{color:"#9CA3AF"},children:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-2xl mb-2",children:"⬡"}),t.jsx("div",{className:"text-xs",children:"No layers found in this ontology"})]})});const j=new Set(F.flatMap(e=>e.layerIds)),m=O(n.filter(e=>!j.has(e.id)));function I(e,o){e.preventDefault()}function k(e){v(o=>{const s=new Set(o);return s.has(e)?s.delete(e):s.add(e),s})}const w=(e,o,s)=>T(e).map(l=>t.jsx(B,{kind:l,layerColor:o,domainBg:s,selected:r===l.name,onClick:()=>d(r===l.name?null:l.name),onContextMenu:u=>I(u,l.name),isFlashing:x===l.name,flashTick:N},l.name)),C=(e,o)=>{const s=$[e.id]??$.other,L=o.reduce((i,c)=>i+c.kindCount,0),l=L===0,u=g.has(e.id),E=O(o);return t.jsxs("div",{ref:i=>{p.current[e.id]=i},className:"rounded-xl overflow-hidden transition-all",style:{border:`1px solid ${s.border}`,background:s.bg,outline:R===e.id?`2px solid ${s.border}`:"none",outlineOffset:"2px"},children:[t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 cursor-pointer select-none",style:{background:s.header,borderBottom:u?"none":`1px solid ${s.border}`},onClick:()=>k(e.id),title:u?"Expand":"Collapse",children:[t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",style:{transition:"transform 150ms ease",transform:u?"rotate(-90deg)":"rotate(0deg)",flexShrink:0},children:t.jsx("path",{d:"M4 6L8 10L12 6",stroke:s.text,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),t.jsx("span",{style:{fontSize:"10px",fontWeight:700,color:s.text,letterSpacing:"0.08em",textTransform:"uppercase",minWidth:"32px",textAlign:"center"},children:e.abbr}),t.jsx("span",{style:{width:"1px",height:"14px",background:`${s.border}`,opacity:.5}}),t.jsx("span",{className:"text-xs font-semibold flex-1",style:{color:s.text},children:e.label}),t.jsx("span",{className:"text-xs",style:{color:s.text,opacity:.7},children:l?"no kinds":`${L} kinds`})]}),!u&&(l?t.jsx("div",{className:"px-4 py-1.5 text-xs italic",style:{color:s.text,opacity:.4},children:"(no elements)"}):t.jsx("div",{className:"p-3 space-y-3",children:e.subGroups?e.subGroups.map(i=>{const c=E.filter(y=>i.layerIds.includes(y.id));if(c.length===0)return null;const h=c.flatMap(y=>y.kinds);if(h.length===0)return null;const S=c[0].color??s.text;return t.jsxs("div",{children:[t.jsxs("div",{className:"text-xs font-medium mb-1.5 flex items-center gap-1.5",style:{color:s.text,opacity:.75},ref:y=>{c.forEach(H=>{p.current[H.id]=y})},children:[t.jsx("span",{className:"inline-block w-2 h-2 rounded-sm flex-shrink-0",style:{background:S}}),i.label]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:w(h,S,s.bg)})]},i.label)}):(()=>{var h;const i=E.flatMap(S=>S.kinds),c=((h=E[0])==null?void 0:h.color)??s.text;return t.jsx("div",{className:"flex flex-wrap gap-2",children:w(i,c,s.bg)})})()}))]},e.id)};return t.jsxs("div",{className:"space-y-3 mb-6",children:[F.map(e=>{const o=n.filter(s=>e.layerIds.includes(s.id));return o.length===0?null:C(e,o)}),m.length>0&&C({id:"other",label:"Other",abbr:"EXT",layerIds:m.map(e=>e.id)},m)]})}export{z as LayerGrid};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as t}from"./reactflow-CsCqNKB-.js";import{a}from"./zustand-CrhqMOHB.js";import{f as A}from"./index-
|
|
1
|
+
import{j as t}from"./reactflow-CsCqNKB-.js";import{a}from"./zustand-CrhqMOHB.js";import{f as A}from"./index-CVW92JY7.js";function q({layers:p,selectedKind:L,onKindClick:S}){const[F,D]=a.useState("name"),[g,j]=a.useState("asc"),[f,M]=a.useState(""),[c,T]=a.useState(!1),[i,v]=a.useState("all"),[d,E]=a.useState("all"),[B,h]=a.useState(!1),[N,b]=a.useState(!1),y=a.useMemo(()=>p.flatMap(e=>e.kinds.map(s=>({...s,layerLabel:e.label,layerColor:A[e.id]??e.color??"#6B7280"}))),[p]),R=a.useMemo(()=>[...new Set(p.map(e=>e.id))],[p]),K=a.useMemo(()=>[...new Set(y.map(e=>e.construct))],[y]),C=a.useMemo(()=>{let e=y;if(f.trim()){const s=f.toLowerCase();e=e.filter(o=>{var l,r;return o.name.toLowerCase().includes(s)||o.label.toLowerCase().includes(s)||o.layer.toLowerCase().includes(s)||(((l=o.description)==null?void 0:l.toLowerCase().includes(s))??!1)||(((r=o.derivesFrom)==null?void 0:r.toLowerCase().includes(s))??!1)})}return i!=="all"&&(e=e.filter(s=>s.layer===i)),d!=="all"&&(e=e.filter(s=>s.construct===d)),e},[y,f,i,d]),x=a.useMemo(()=>[...C].sort((e,s)=>{var l,r;let o=0;switch(F){case"name":o=e.name.localeCompare(s.name);break;case"layer":o=e.layer.localeCompare(s.layer);break;case"construct":o=e.construct.localeCompare(s.construct);break;case"instanceCount":o=e.instanceCount-s.instanceCount;break;case"derivesFrom":o=(e.derivesFrom??"").localeCompare(s.derivesFrom??"");break;case"derivedByCount":o=(((l=e.derivedBy)==null?void 0:l.length)??0)-(((r=s.derivedBy)==null?void 0:r.length)??0);break}return g==="asc"?o:-o}),[C,F,g]),k=a.useMemo(()=>{if(c)return null;const e=new Map;for(const s of x)e.has(s.layer)||e.set(s.layer,[]),e.get(s.layer).push(s);return e},[x,c]);function u(e){F===e?j(s=>s==="asc"?"desc":"asc"):(D(e),j("asc"))}const z=a.useCallback(()=>{const e=[["Name","Layer","Construct","Instances","Derives From","Derived By","Description"]];for(const n of x)e.push([n.name,n.layer,n.construct,String(n.instanceCount),n.derivesFrom??"",(n.derivedBy??[]).join("; "),n.description??""]);const s=e.map(n=>n.map($=>`"${$.replace(/"/g,'""')}"`).join(",")).join(`
|
|
2
2
|
`),o=new Blob([s],{type:"text/csv;charset=utf-8;"}),l=URL.createObjectURL(o),r=document.createElement("a");r.href=l,r.download="ontology-kinds.csv",r.click(),URL.revokeObjectURL(l)},[x]),m=({k:e})=>t.jsx("span",{style:{fontSize:"10px",color:F===e?"#1B3A4B":"#D1D5DB",marginLeft:"3px"},children:F===e?g==="asc"?"▲":"▼":"⇅"}),w=(e,s)=>{var l,r;const o=L===e.name;return t.jsxs("div",{className:"grid items-center cursor-pointer text-xs",style:{gridTemplateColumns:"1.5fr 100px 90px 60px 120px 60px",padding:"7px 16px",background:o?"#EFF6FF":s%2===0?"#FAFAF8":"#FFFFFF",borderLeft:o?`3px solid ${e.layerColor}`:"3px solid transparent",transition:"background 100ms ease"},onClick:()=>S(o?null:e.name),onMouseEnter:n=>{o||(n.currentTarget.style.background="#F0F7FF")},onMouseLeave:n=>{o||(n.currentTarget.style.background=o?"#EFF6FF":s%2===0?"#FAFAF8":"#FFFFFF")},children:[t.jsxs("div",{className:"flex items-center gap-2 truncate",children:[t.jsx("span",{className:"w-2 h-2 rounded flex-shrink-0",style:{backgroundColor:e.layerColor}}),t.jsx("span",{style:{color:"#1a1a1a",fontWeight:o?600:400},children:e.name})]}),t.jsx("span",{className:"capitalize",style:{color:"#6B7280"},children:e.layer}),t.jsx("span",{className:"font-mono",style:{color:"#9CA3AF"},children:e.construct}),t.jsx("span",{className:"text-right",style:{color:e.instanceCount>0?"#1B3A4B":"#D1D5DB"},children:e.instanceCount>0?e.instanceCount:"—"}),t.jsx("span",{className:"truncate",style:{color:e.derivesFrom?"#2563EB":"#D1D5DB"},children:e.derivesFrom??"—"}),t.jsx("span",{className:"text-right",style:{color:(((l=e.derivedBy)==null?void 0:l.length)??0)>0?"#374151":"#D1D5DB"},children:(((r=e.derivedBy)==null?void 0:r.length)??0)>0?e.derivedBy.length:"—"})]},`${e.layer}:${e.name}`)};return t.jsxs("div",{className:"mb-6",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[t.jsx("input",{type:"text",placeholder:"Search kinds...",value:f,onChange:e=>M(e.target.value),className:"px-2.5 py-1.5 text-xs rounded-md flex-1 min-w-[140px]",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151",outline:"none",maxWidth:"240px"},onFocus:e=>e.currentTarget.style.borderColor="#2563EB",onBlur:e=>e.currentTarget.style.borderColor="#E5E7EB"}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{onClick:()=>{h(!B),b(!1)},className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:i!=="all"?"#EFF6FF":"#F9FAFB",color:"#374151"},children:["Layer: ",i==="all"?"All":i]}),B&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 rounded-lg shadow-lg py-1 z-20",style:{background:"#FFFFFF",border:"1px solid #E5E7EB",minWidth:"120px"},children:[t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50",style:{color:"#374151"},onClick:()=>{v("all"),h(!1)},children:"All"}),R.map(e=>t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50 capitalize",style:{color:"#374151"},onClick:()=>{v(e),h(!1)},children:e},e))]})]}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{onClick:()=>{b(!N),h(!1)},className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:d!=="all"?"#EFF6FF":"#F9FAFB",color:"#374151"},children:["Construct: ",d==="all"?"All":d]}),N&&t.jsxs("div",{className:"absolute top-full left-0 mt-1 rounded-lg shadow-lg py-1 z-20",style:{background:"#FFFFFF",border:"1px solid #E5E7EB",minWidth:"140px"},children:[t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50",style:{color:"#374151"},onClick:()=>{E("all"),b(!1)},children:"All"}),K.map(e=>t.jsx("button",{className:"block w-full text-left px-3 py-1.5 text-xs hover:bg-gray-50 font-mono",style:{color:"#374151"},onClick:()=>{E(e),b(!1)},children:e},e))]})]}),t.jsx("button",{onClick:()=>T(!c),className:"px-2.5 py-1.5 text-xs rounded-md",style:{border:"1px solid #E5E7EB",background:c?"#1B3A4B":"#F9FAFB",color:c?"#2DD4A8":"#374151"},children:c?"Grouped":"Flatten"}),t.jsx("button",{onClick:z,className:"px-2.5 py-1.5 text-xs rounded-md ml-auto",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151"},title:"Export as CSV",children:"Export CSV"}),t.jsxs("span",{className:"text-xs",style:{color:"#9CA3AF"},children:[C.length," / ",y.length," kinds"]})]}),t.jsxs("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid #E5E5E0"},children:[t.jsxs("div",{className:"grid text-xs font-medium",style:{gridTemplateColumns:"1.5fr 100px 90px 60px 120px 60px",background:"#F7F7F5",borderBottom:"1px solid #E5E5E0",padding:"8px 16px",color:"#6B7280",position:"sticky",top:0,zIndex:5},children:[t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("name"),children:["Kind ",t.jsx(m,{k:"name"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("layer"),children:["Layer ",t.jsx(m,{k:"layer"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("construct"),children:["Construct ",t.jsx(m,{k:"construct"})]}),t.jsxs("button",{className:"text-right flex items-center justify-end",onClick:()=>u("instanceCount"),children:["# ",t.jsx(m,{k:"instanceCount"})]}),t.jsxs("button",{className:"text-left flex items-center",onClick:()=>u("derivesFrom"),children:["Derives From ",t.jsx(m,{k:"derivesFrom"})]}),t.jsxs("button",{className:"text-right flex items-center justify-end",onClick:()=>u("derivedByCount"),children:["Subs ",t.jsx(m,{k:"derivedByCount"})]})]}),c?x.map((e,s)=>w(e,s)):k&&[...k.entries()].map(([e,s])=>{const o=p.find(r=>r.id===e),l=A[e]??"#6B7280";return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 text-xs font-semibold",style:{background:`${l}08`,borderTop:"1px solid #E5E5E0",color:l},children:[t.jsx("span",{className:"w-2.5 h-2.5 rounded flex-shrink-0",style:{backgroundColor:l}}),(o==null?void 0:o.label)??e,t.jsxs("span",{className:"font-normal",style:{color:"#9CA3AF"},children:["(",s.length,")"]})]}),s.map((r,n)=>w(r,n))]},e)}),x.length===0&&t.jsx("div",{className:"py-8 text-center text-xs",style:{color:"#9CA3AF"},children:"No kinds match the current filters"})]})]})}export{q as LayerTable};
|