@memoarchitect/architect 0.6.3 → 0.6.5
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 +21 -7
- package/dist/assets/AiWorkspace-DHZ6a9HJ.js +3 -0
- package/dist/assets/{ComplianceWizard-CgtKjuZp.js → ComplianceWizard-DWolzleI.js} +1 -1
- package/dist/assets/{DSMView-DTUyQHSu.js → DSMView-TdC3EADB.js} +1 -1
- package/dist/assets/{Dashboard-CwosozE0.js → Dashboard-DBfAOCJv.js} +1 -1
- package/dist/assets/{DhfDashboard-Dp6ryOII.js → DhfDashboard-D9JxRAbD.js} +1 -1
- package/dist/assets/{DhfSettingsPanel-Bx2t0sXQ.js → DhfSettingsPanel-Firov0IF.js} +1 -1
- package/dist/assets/{DhfWorkbench-BN3gpDz4.js → DhfWorkbench-BQv2WQ9o.js} +3 -3
- package/dist/assets/DiagramCanvas-BfwO8YE5.js +1 -0
- package/dist/assets/{DiagramEditor-CNhwdNh3.js → DiagramEditor-Cp9ORYoN.js} +2 -2
- package/dist/assets/{ElementDetailView-rciRq5HA.js → ElementDetailView-DOrG8v7V.js} +1 -1
- package/dist/assets/{ImportView-BbzZ5hbB.js → ImportView-33dFwj6A.js} +1 -1
- package/dist/assets/{LayerGrid-DAIv9DZ6.js → LayerGrid-B3MBWswK.js} +1 -1
- package/dist/assets/{LayerTable-BnOya4yd.js → LayerTable-DyIzIt5M.js} +1 -1
- package/dist/assets/{MaxGraphCanvas-BaVQOtM7.js → MaxGraphCanvas-BS5wYazZ.js} +2 -2
- package/dist/assets/{ModelDiff-Mm8cCWYb.js → ModelDiff-BoFREnpg.js} +1 -1
- package/dist/assets/{OntologyDecompositionDiagram-COmPilyD.js → OntologyDecompositionDiagram-IG1gj1c3.js} +1 -1
- package/dist/assets/{OntologyViewer-esGC-MHX.js → OntologyViewer-CQTEg-GI.js} +2 -2
- package/dist/assets/{ReviewDashboard-CAZFVV_h.js → ReviewDashboard-BJ_smBGS.js} +1 -1
- package/dist/assets/ScenarioEditor-D06nbX4h.js +3 -0
- package/dist/assets/{StatisticsDashboard-DBs1LLID.js → StatisticsDashboard-CBYJGUPH.js} +1 -1
- package/dist/assets/{TabularView-_BN5T3rn.js → TabularView-BLzDtgmK.js} +1 -1
- package/dist/assets/{TraceabilityMatrix-CKZyOf1u.js → TraceabilityMatrix-DbL_FkAC.js} +1 -1
- package/dist/assets/{WorkflowWizard-DaqQTLpd.js → WorkflowWizard-CbkDyd1W.js} +1 -1
- package/dist/assets/index-B8HDzVLs.css +1 -0
- package/dist/assets/index-D0vtjNjX.js +3280 -0
- package/dist/assets/layout-selection-DIQaaOIC.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 +10 -6
- package/dist/assets/ChatPanel-Dp_E5vjj.js +0 -3
- package/dist/assets/DiagramCanvas-O_19DfTS.js +0 -1
- package/dist/assets/ScenarioEditor-B68Qn6c9.js +0 -3
- package/dist/assets/SysmlGenerator-C8TebOjb.js +0 -1
- package/dist/assets/index-C8UZrEP-.js +0 -3277
- package/dist/assets/index-XtCtnAfF.css +0 -1
- package/dist/assets/layout-selection-CpBDhXjU.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./reactflow-CsCqNKB-.js";import{a as y}from"./zustand-CrhqMOHB.js";import{u as F,f as j}from"./index-
|
|
1
|
+
import{j as e}from"./reactflow-CsCqNKB-.js";import{a as y}from"./zustand-CrhqMOHB.js";import{u as F,f as j}from"./index-D0vtjNjX.js";function N(l,u){const o=[],i=[],m=[],g=new Set(Object.keys(l.elements)),x=new Set(Object.keys(u.elements));for(const a of x)g.has(a)||o.push(u.elements[a]);for(const a of g)x.has(a)||i.push(l.elements[a]);for(const a of g){if(!x.has(a))continue;const p=l.elements[a],t=u.elements[a],c=[];p.name!==t.name&&c.push(`name: "${p.name}" → "${t.name}"`),p.kind!==t.kind&&c.push(`kind: ${p.kind} → ${t.kind}`),p.layer!==t.layer&&c.push(`layer: ${p.layer} → ${t.layer}`),p.doc!==t.doc&&c.push("doc changed");const s=JSON.stringify(p.attributes),n=JSON.stringify(t.attributes);s!==n&&c.push("attributes changed"),c.length>0&&m.push({element:t,changes:c})}const v=new Set(l.relationships.map(a=>a.id)),h=new Set(u.relationships.map(a=>a.id)),f=u.relationships.filter(a=>!v.has(a.id)),d=l.relationships.filter(a=>!h.has(a.id));return{added:o,removed:i,changed:m,addedRels:f,removedRels:d,summary:{added:o.length,removed:i.length,changed:m.length,addedRels:f.length,removedRels:d.length}}}function A(){const l=F(s=>s.model),u=F(s=>s.selectElement),[o,i]=y.useState(null),[m,g]=y.useState(""),[x,v]=y.useState([]),[h,f]=y.useState(null),[d,a]=y.useState("all"),p=y.useCallback(()=>{if(!l)return;const s=m.trim()||`Snapshot ${x.length+1}`;v(n=>[...n,{name:s,model:JSON.parse(JSON.stringify(l)),timestamp:Date.now()}]),g("")},[l,m,x.length]);y.useEffect(()=>{h!==null&&x[h]&&i(x[h].model)},[h,x]);const t=y.useMemo(()=>!o||!l?null:N(o,l),[o,l]),c=t?t.summary.added+t.summary.removed+t.summary.changed:0;return e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsxs("div",{className:"w-64 flex flex-col overflow-hidden",style:{background:"#FFFFFF",borderRight:"1px solid #E5E5E0"},children:[e.jsxs("div",{className:"px-4 py-3",style:{background:"linear-gradient(135deg, #1B3A4B, #2D6A7A)"},children:[e.jsx("h2",{className:"text-sm font-bold tracking-wide",style:{color:"#2DD4A8"},children:"Model Diff"}),e.jsx("p",{className:"text-xs mt-0.5",style:{color:"rgba(255,255,255,0.6)"},children:"Compare model states"})]}),e.jsx("div",{className:"px-3 py-2.5",style:{borderBottom:"1px solid #E5E5E0"},children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("input",{type:"text",value:m,onChange:s=>g(s.target.value),placeholder:"Snapshot name...",className:"flex-1 text-xs px-2 py-1.5 rounded focus:outline-none",style:{background:"#F7F7F5",border:"1px solid #E5E5E0",color:"#1a1a1a"},onKeyDown:s=>s.key==="Enter"&&p()}),e.jsx("button",{onClick:p,className:"px-2 py-1.5 text-xs rounded font-medium",style:{background:"#2DD4A8",color:"#FFFFFF"},children:"Snap"})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto text-xs py-1",children:[x.length===0&&e.jsx("div",{className:"px-4 py-8 text-center",style:{color:"#9CA3AF"},children:"Take a snapshot to create a baseline for comparison."}),x.map((s,n)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer mx-1 rounded-lg",style:{background:h===n?"#2DD4A818":"transparent",fontWeight:h===n?500:400},onMouseEnter:r=>{h!==n&&(r.currentTarget.style.background="#F0F0ED")},onMouseLeave:r=>{h!==n&&(r.currentTarget.style.background=h===n?"#2DD4A818":"transparent")},onClick:()=>f(n),children:[e.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:"#2DD4A8"}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"truncate",style:{color:"#374151"},children:s.name}),e.jsxs("div",{style:{color:"#9CA3AF",fontSize:"10px"},children:[new Date(s.timestamp).toLocaleTimeString()," · ",Object.keys(s.model.elements).length," elements"]})]})]},n))]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",style:{background:"#F7F7F5"},children:[!t&&e.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"#9CA3AF"},children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"8px",opacity:.5},children:"↔"}),e.jsx("div",{className:"text-sm",children:"Take a snapshot, then make changes to see the diff"}),e.jsx("div",{className:"text-xs mt-2",style:{color:"#D1D5DB"},children:"Snapshots capture the current model state for comparison"})]})}),t&&e.jsxs("div",{className:"max-w-3xl",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("h2",{className:"text-sm font-semibold",style:{color:"#374151"},children:c===0?"No changes":`${c} element changes`}),t.summary.addedRels+t.summary.removedRels>0&&e.jsxs("span",{className:"text-xs",style:{color:"#9CA3AF"},children:["+ ",t.summary.addedRels+t.summary.removedRels," relationship changes"]})]}),e.jsx("div",{className:"flex gap-2 mb-4",children:[{key:"all",label:"All",count:c,color:"#6B7280"},{key:"added",label:"Added",count:t.summary.added,color:"#2ECC71"},{key:"removed",label:"Removed",count:t.summary.removed,color:"#E74C3C"},{key:"changed",label:"Changed",count:t.summary.changed,color:"#F39C12"}].map(s=>e.jsxs("button",{onClick:()=>a(s.key),className:"px-2.5 py-1 text-xs rounded-full font-medium",style:{background:d===s.key?s.color+"20":"#F3F4F6",color:d===s.key?s.color:"#9CA3AF",border:`1px solid ${d===s.key?s.color+"40":"#E5E5E0"}`},children:[s.label," (",s.count,")"]},s.key))}),(d==="all"||d==="added")&&t.added.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"#2ECC71"},children:["Added (",t.added.length,")"]}),e.jsx("div",{className:"space-y-1",children:t.added.map(s=>e.jsx(b,{element:s,type:"added",onClick:()=>u(s.id)},s.id))})]}),(d==="all"||d==="removed")&&t.removed.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"#E74C3C"},children:["Removed (",t.removed.length,")"]}),e.jsx("div",{className:"space-y-1",children:t.removed.map(s=>e.jsx(b,{element:s,type:"removed",onClick:()=>{}},s.id))})]}),(d==="all"||d==="changed")&&t.changed.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"#F39C12"},children:["Changed (",t.changed.length,")"]}),e.jsx("div",{className:"space-y-1",children:t.changed.map(({element:s,changes:n})=>e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded-lg cursor-pointer",style:{background:"#FFFFFF",border:"1px solid #F39C1240"},onMouseEnter:r=>r.currentTarget.style.background="#FDF8F0",onMouseLeave:r=>r.currentTarget.style.background="#FFFFFF",onClick:()=>u(s.id),children:[e.jsx("span",{className:"text-xs mt-0.5",style:{color:"#F39C12"},children:"●"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium truncate",style:{color:"#374151"},children:s.name}),e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded",style:{background:(j[s.layer]||"#95A5A6")+"18",color:j[s.layer]||"#95A5A6"},children:s.kind})]}),e.jsx("div",{className:"text-xs mt-0.5",style:{color:"#9CA3AF"},children:n.join(", ")})]})]},s.id))})]}),(t.addedRels.length>0||t.removedRels.length>0)&&e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"#6B7280"},children:"Relationship Changes"}),e.jsxs("div",{className:"space-y-1",children:[t.addedRels.map(s=>{var n,r;return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded-lg",style:{background:"#F0FDF4",border:"1px solid #BBF7D0"},children:[e.jsx("span",{style:{color:"#2ECC71"},children:"+"}),e.jsx("span",{style:{color:"#374151"},children:((n=l==null?void 0:l.elements[s.sourceId])==null?void 0:n.name)||s.sourceId}),e.jsx("span",{style:{color:"#2563EB"},children:s.type}),e.jsx("span",{style:{color:"#374151"},children:((r=l==null?void 0:l.elements[s.targetId])==null?void 0:r.name)||s.targetId})]},s.id)}),t.removedRels.map(s=>{var n,r;return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded-lg",style:{background:"#FEF2F2",border:"1px solid #FECACA"},children:[e.jsx("span",{style:{color:"#E74C3C"},children:"-"}),e.jsx("span",{style:{color:"#374151"},children:((n=o==null?void 0:o.elements[s.sourceId])==null?void 0:n.name)||s.sourceId}),e.jsx("span",{style:{color:"#2563EB"},children:s.type}),e.jsx("span",{style:{color:"#374151"},children:((r=o==null?void 0:o.elements[s.targetId])==null?void 0:r.name)||s.targetId})]},s.id)})]})]}),c===0&&t.addedRels.length===0&&t.removedRels.length===0&&e.jsxs("div",{className:"text-center py-8",style:{color:"#9CA3AF"},children:[e.jsx("div",{style:{fontSize:"24px",marginBottom:"8px"},children:"✓"}),e.jsx("div",{className:"text-sm",children:"No differences between snapshot and current model"})]})]})]})]})}function b({element:l,type:u,onClick:o}){const i=u==="added"?{bg:"#F0FDF4",border:"#BBF7D0",dot:"#2ECC71",hoverBg:"#DCFCE7"}:{bg:"#FEF2F2",border:"#FECACA",dot:"#E74C3C",hoverBg:"#FEE2E2"};return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg cursor-pointer text-xs",style:{background:i.bg,border:`1px solid ${i.border}`},onMouseEnter:m=>m.currentTarget.style.background=i.hoverBg,onMouseLeave:m=>m.currentTarget.style.background=i.bg,onClick:o,children:[e.jsx("span",{style:{color:i.dot},children:"●"}),e.jsx("span",{className:"font-medium truncate",style:{color:"#374151"},children:l.name}),e.jsx("span",{className:"ml-auto px-1.5 py-0.5 rounded",style:{background:(j[l.layer]||"#95A5A6")+"18",color:j[l.layer]||"#95A5A6"},children:l.kind})]})}export{A as ModelDiff,N as computeModelDiff};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,H as C,P as k,R as D,a as S,i as O,f as R,g as I}from"./reactflow-CsCqNKB-.js";import{a as p}from"./zustand-CrhqMOHB.js";/* empty css */import{r as T}from"./layout-providers-Dr743WlP.js";import{f as L,u as h,I as P,J as M,K as z}from"./index-C8UZrEP-.js";import"./elk-6l8mIQnQ.js";const A={ontology:{bg:"#EFF6FF",fg:"#2563EB",border:"#BFDBFE"},profile:{bg:"#F0FDF4",fg:"#16A34A",border:"#BBF7D0"},extension:{bg:"#FFF7ED",fg:"#EA580C",border:"#FED7AA"}};function H({data:i}){const s=i,l=A[s.type]??A.ontology;return e.jsxs("div",{"data-testid":`ontology-package-node-${s.name}`,onClick:s.onClick,onDoubleClick:s.onDoubleClick,onContextMenu:s.onContextMenu,style:{background:"#FFFFFF",border:s.selected?"2px solid #2563EB":"1px solid #E5E5E0",borderRadius:"12px",padding:"16px",minWidth:"240px",maxWidth:"300px",cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.06)",transition:"box-shadow 200ms ease, transform 200ms ease"},children:[e.jsx(C,{type:"target",position:k.Top,id:"top",style:w}),e.jsx(C,{type:"source",position:k.Bottom,id:"bottom",style:w}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"8px"},children:[e.jsx("span",{style:{padding:"1px 8px",fontSize:"10px",borderRadius:"9999px",fontWeight:600,background:l.bg,color:l.fg,border:`1px solid ${l.border}`},children:s.type}),e.jsxs("span",{style:{fontSize:"10px",color:"#9CA3AF"},children:["v",s.version]})]}),e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"#1a1a1a",marginBottom:"4px"},children:s.name}),s.description&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginBottom:"10px",lineHeight:"1.4"},children:s.description.length>80?s.description.slice(0,80)+"…":s.description}),e.jsx("div",{style:{display:"flex",gap:"2px",marginBottom:"8px",height:"6px",borderRadius:"3px",overflow:"hidden"},children:s.layers.slice(0,12).map(d=>{const n=L[d.id]??d.color??"#6B7280";return e.jsx("div",{style:{flex:Math.max(d.kindCount,1),background:n,borderRadius:"1px"},title:`${d.label}: ${d.kindCount} kinds`},d.id)})}),e.jsxs("div",{style:{display:"flex",gap:"12px",fontSize:"11px",color:"#6B7280"},children:[e.jsxs("span",{children:[e.jsx("strong",{style:{color:"#1B3A4B"},children:s.kindCount})," kinds"]}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"#1B3A4B"},children:s.layerCount})," layers"]})]})]})}const w={width:"8px",height:"8px",background:"#2563EB",border:"2px solid #FFFFFF",opacity:0},W=p.memo(H);function $({onClose:i}){const s=h(o=>o.availableOntologies),l=h(o=>o.ontologyInstallStatus),d=h(o=>o.setOntologyInstallStatus),[n,c]=p.useState(""),[r,g]=p.useState(null);function t(){n.trim()&&(d({installing:!0}),P(n.trim()),c(""))}function x(o){M(o),g(null)}return e.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50",style:{background:"rgba(0,0,0,0.4)"},onClick:i,children:e.jsxs("div",{className:"rounded-xl shadow-2xl overflow-hidden",style:{background:"#FFFFFF",width:"520px",maxHeight:"600px",border:"1px solid #E5E5E0"},onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("h2",{className:"text-sm font-semibold",style:{color:"#1a1a1a"},children:"Manage Ontology Library"}),e.jsx("button",{onClick:i,className:"text-sm px-2 py-0.5 rounded hover:bg-gray-100",style:{color:"#9CA3AF"},children:"x"})]}),e.jsxs("div",{className:"p-5 space-y-5 overflow-y-auto",style:{maxHeight:"480px"},children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium block mb-1.5",style:{color:"#374151"},children:"Add Ontology"}),e.jsx("p",{className:"text-xs mb-2",style:{color:"#9CA3AF"},children:"Enter a git URL (https://...git), npm package name (@memoarchitect/...), or local path."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"https://gitlab.com/org/my-ontology.git",value:n,onChange:o=>c(o.target.value),onKeyDown:o=>o.key==="Enter"&&t(),className:"flex-1 px-3 py-2 text-xs rounded-lg",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151",outline:"none"},onFocus:o=>o.currentTarget.style.borderColor="#2563EB",onBlur:o=>o.currentTarget.style.borderColor="#E5E7EB",disabled:l.installing}),e.jsx("button",{onClick:t,disabled:!n.trim()||l.installing,className:"px-4 py-2 text-xs rounded-lg font-medium",style:{background:l.installing?"#9CA3AF":"#1B3A4B",color:"#FFFFFF",opacity:!n.trim()||l.installing?.5:1,cursor:!n.trim()||l.installing?"not-allowed":"pointer"},children:l.installing?"Installing...":"Install"})]}),l.error&&e.jsx("div",{className:"mt-2 px-3 py-2 rounded-lg text-xs",style:{background:"#FEF2F2",color:"#DC2626",border:"1px solid #FECACA"},children:l.error}),l.lastInstalled&&!l.error&&e.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-xs",style:{background:"#F0FDF4",color:"#16A34A",border:"1px solid #BBF7D0"},children:["Installed ",l.lastInstalled]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-medium block mb-2",style:{color:"#374151"},children:["Installed Packages (",s.length,")"]}),e.jsxs("div",{className:"space-y-1.5",children:[s.map(o=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{border:"1px solid #E5E5E0",background:"#FAFAF8"},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium truncate",style:{color:"#1a1a1a"},children:o.name}),e.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded",style:{background:o.type==="ontology"?"#EFF6FF":o.type==="profile"?"#F0FDF4":"#FFF7ED",color:o.type==="ontology"?"#2563EB":o.type==="profile"?"#16A34A":"#EA580C",fontSize:"10px"},children:o.type})]}),e.jsxs("div",{className:"text-xs mt-0.5",style:{color:"#9CA3AF"},children:["v",o.version," · ",o.kindCount," kinds · ",o.layers.length," layers"]})]}),r===o.name?e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>x(o.name),className:"px-2 py-1 text-xs rounded",style:{background:"#DC2626",color:"#FFFFFF"},children:"Confirm"}),e.jsx("button",{onClick:()=>g(null),className:"px-2 py-1 text-xs rounded",style:{background:"#F3F4F6",color:"#374151"},children:"Cancel"})]}):e.jsx("button",{onClick:()=>g(o.name),className:"text-xs px-2 py-1 rounded hover:bg-red-50",style:{color:"#DC2626",border:"1px solid #FECACA"},children:"Remove"})]},o.name)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-xs",style:{color:"#9CA3AF"},children:"No ontology packages installed"})]})]})]})]})})}const _={ontologyPackage:W},Y=260,K=180;async function V(i){const s=new Map(i.map(t=>[t.name,t])),l={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.layered.nodePlacement.strategy":"BRANDES_KOEPF","elk.layered.spacing.nodeNodeBetweenLayers":"100","elk.spacing.nodeNode":"32","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.padding":"[top=24, left=24, bottom=24, right=24]"},children:i.map(t=>({id:t.name,width:Y,height:K})),edges:i.filter(t=>t.extends&&s.has(t.extends)).map((t,x)=>({id:`e-${x}`,sources:[t.extends],targets:[t.name]}))},d=await T(l),n=new Map;for(const t of d.children??[])n.set(t.id,{x:t.x??0,y:t.y??0});const c={ontology:"#3B82F6",profile:"#10B981",extension:"#F59E0B"},r=i.map(t=>({id:t.name,type:"ontologyPackage",position:n.get(t.name)??{x:0,y:0},data:{name:t.name,type:t.type,version:t.version,description:t.description,kindCount:t.kindCount,layerCount:t.layers.length,layers:t.layers.map(x=>({id:x.id,label:x.label,color:x.color,kindCount:x.kindCount})),selected:t.selected,onClick:()=>{}}})),g=[];for(const t of i)if(t.extends&&s.has(t.extends)){const x=c[t.type]??"#94A3B8";g.push({id:`${t.extends}->${t.name}`,source:t.extends,target:t.name,type:"smoothstep",data:{edgeType:"extends"},style:{stroke:x,strokeWidth:2,strokeDasharray:"6 3"},animated:!1,label:"extends",labelStyle:{fontSize:9,fill:x,fontWeight:500},labelBgStyle:{fill:"#F7F7F5",fillOpacity:.9},labelBgPadding:[4,2],markerEnd:{type:"arrowclosed",color:x,width:14,height:14}})}return{nodes:r,edges:g}}function G(i,s){const l=new Map;for(const c of s)c.extends&&(l.has(c.extends)||l.set(c.extends,[]),l.get(c.extends).push(c.name));const d=new Set([i]),n=[i];for(;n.length;){const c=n.shift();for(const r of l.get(c)??[])d.has(r)||(d.add(r),n.push(r))}return d}function U(){const i=h(a=>a.availableOntologies),s=h(a=>a.setActiveView),l=h(a=>a.hiddenEdgeTypes),d=h(a=>a.toggleHiddenEdgeType),[n,c]=p.useState(!1),[r,g]=p.useState({nodes:[],edges:[]}),[t,x]=p.useState(null),{fitView:o}=S();p.useEffect(()=>{let a=!1;return V(i).then(u=>{a||g(u)}).catch(u=>{console.error("[OntologyDiagram] ELK layout failed:",u)}),()=>{a=!0}},[i]);const F=p.useCallback(a=>{s({type:"ontology-detail",packageName:a})},[s]),E=p.useCallback(a=>{const u=G(a,i),m=r.nodes.filter(y=>u.has(y.id));m.length!==0&&o({nodes:m.map(y=>({id:y.id})),duration:400,padding:.2})},[i,r.nodes,o]),v=p.useCallback((a,u)=>{a.preventDefault(),x({x:a.clientX,y:a.clientY,packageName:u})},[]);p.useEffect(()=>{const a=u=>{if(u.key==="Escape"){if(t){x(null);return}o({padding:.1,duration:300})}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,o]);const{nodes:N,edges:B}=p.useMemo(()=>{const a=r.nodes.map(m=>({...m,data:{...m.data,onClick:()=>E(m.id),onDoubleClick:()=>F(m.id),onContextMenu:y=>v(y,m.id)}})),u=r.edges.filter(m=>{var j;const y=(j=m.data)==null?void 0:j.edgeType;return!y||!l.has(y)});return{nodes:a,edges:u}},[r,E,F,v,l]),f=p.useRef(null);p.useEffect(()=>{if(!t)return;const a=u=>{f.current&&!f.current.contains(u.target)&&x(null)};return window.addEventListener("mousedown",a),()=>window.removeEventListener("mousedown",a)},[t]);const b=l.has("extends");return i.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"text-center",style:{color:"#9CA3AF"},children:[e.jsx("div",{className:"text-3xl mb-3",children:"◉"}),e.jsx("div",{className:"text-sm font-medium mb-1",style:{color:"#374151"},children:"No ontology packages found"}),e.jsx("div",{className:"text-xs",children:"Start the dev server to load ontology packages"})]})}):e.jsxs("div",{className:"flex-1",style:{background:"#F7F7F5"},children:[e.jsxs("div",{className:"flex items-start justify-between px-6 pt-5 pb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",style:{color:"#1a1a1a"},children:"Ontology Library"}),e.jsxs("p",{className:"text-xs mt-1",style:{color:"#9CA3AF"},children:[i.length," package",i.length!==1?"s":""," available. Click to zoom, double-click to open, right-click for source."]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{"data-testid":"toggle-tracing",onClick:()=>d("extends"),title:b?"Show extends tracing edges":"Hide extends tracing edges",className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:b?{background:"#F0F0ED",color:"#6B7280",border:"1px solid #E5E5E0"}:{background:"#1B3A4B",color:"#2DD4A8",border:"1px solid transparent"},children:b?"Show Tracing":"Hide Tracing"}),e.jsx("button",{onClick:()=>c(!0),className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:{background:"#1B3A4B",color:"#2DD4A8"},children:"+ Add Ontology"})]})]}),n&&e.jsx($,{onClose:()=>c(!1)}),e.jsx("div",{style:{flex:1,height:"calc(100% - 72px)"},children:e.jsxs(O,{nodes:N,edges:B,nodeTypes:_,fitView:!0,fitViewOptions:{padding:.1},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!0,zoomOnDoubleClick:!1,minZoom:.2,maxZoom:2.5,proOptions:{hideAttribution:!0},children:[e.jsx(R,{color:"#E5E5E0",gap:24,size:1}),e.jsx(I,{showInteractive:!1})]})}),t&&e.jsx(Z,{menuRef:f,state:t,onClose:()=>x(null),packages:i})]})}const Z=({state:i,onClose:s,packages:l,menuRef:d})=>{const n=l.find(r=>r.name===i.packageName);function c(){if(!n)return;const r=n.rootDir?`${n.rootDir}/memo.package.yaml`:"";r?z(r):window.open(`vscode://file/${encodeURIComponent(n.name)}`),s()}return e.jsxs("div",{ref:d,style:{position:"fixed",top:i.y,left:i.x,zIndex:1e3,background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"8px",boxShadow:"0 6px 16px rgba(0,0,0,0.12)",padding:"4px",minWidth:"180px",fontSize:"12px"},children:[e.jsx("div",{style:{padding:"6px 10px",color:"#9CA3AF",fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.4px"},children:i.packageName}),e.jsx("button",{onClick:c,disabled:!(n!=null&&n.rootDir),style:{display:"block",width:"100%",textAlign:"left",padding:"6px 10px",border:"none",background:"transparent",cursor:n!=null&&n.rootDir?"pointer":"not-allowed",color:n!=null&&n.rootDir?"#1a1a1a":"#9CA3AF",borderRadius:"4px"},onMouseEnter:r=>{n!=null&&n.rootDir&&(r.currentTarget.style.background="#F0F0ED")},onMouseLeave:r=>{r.currentTarget.style.background="transparent"},children:"Open source"})]})};function oe(){return e.jsx(D,{children:e.jsx(U,{})})}export{oe as OntologyDecompositionDiagram,oe as default};
|
|
1
|
+
import{j as e,H as C,P as k,R as D,a as S,i as O,f as R,g as I}from"./reactflow-CsCqNKB-.js";import{a as p}from"./zustand-CrhqMOHB.js";/* empty css */import{r as T}from"./layout-providers-Dr743WlP.js";import{f as L,u as h,I as P,J as M,K as z}from"./index-D0vtjNjX.js";import"./elk-6l8mIQnQ.js";const A={ontology:{bg:"#EFF6FF",fg:"#2563EB",border:"#BFDBFE"},profile:{bg:"#F0FDF4",fg:"#16A34A",border:"#BBF7D0"},extension:{bg:"#FFF7ED",fg:"#EA580C",border:"#FED7AA"}};function H({data:i}){const s=i,l=A[s.type]??A.ontology;return e.jsxs("div",{"data-testid":`ontology-package-node-${s.name}`,onClick:s.onClick,onDoubleClick:s.onDoubleClick,onContextMenu:s.onContextMenu,style:{background:"#FFFFFF",border:s.selected?"2px solid #2563EB":"1px solid #E5E5E0",borderRadius:"12px",padding:"16px",minWidth:"240px",maxWidth:"300px",cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.06)",transition:"box-shadow 200ms ease, transform 200ms ease"},children:[e.jsx(C,{type:"target",position:k.Top,id:"top",style:w}),e.jsx(C,{type:"source",position:k.Bottom,id:"bottom",style:w}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"8px"},children:[e.jsx("span",{style:{padding:"1px 8px",fontSize:"10px",borderRadius:"9999px",fontWeight:600,background:l.bg,color:l.fg,border:`1px solid ${l.border}`},children:s.type}),e.jsxs("span",{style:{fontSize:"10px",color:"#9CA3AF"},children:["v",s.version]})]}),e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"#1a1a1a",marginBottom:"4px"},children:s.name}),s.description&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginBottom:"10px",lineHeight:"1.4"},children:s.description.length>80?s.description.slice(0,80)+"…":s.description}),e.jsx("div",{style:{display:"flex",gap:"2px",marginBottom:"8px",height:"6px",borderRadius:"3px",overflow:"hidden"},children:s.layers.slice(0,12).map(d=>{const n=L[d.id]??d.color??"#6B7280";return e.jsx("div",{style:{flex:Math.max(d.kindCount,1),background:n,borderRadius:"1px"},title:`${d.label}: ${d.kindCount} kinds`},d.id)})}),e.jsxs("div",{style:{display:"flex",gap:"12px",fontSize:"11px",color:"#6B7280"},children:[e.jsxs("span",{children:[e.jsx("strong",{style:{color:"#1B3A4B"},children:s.kindCount})," kinds"]}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"#1B3A4B"},children:s.layerCount})," layers"]})]})]})}const w={width:"8px",height:"8px",background:"#2563EB",border:"2px solid #FFFFFF",opacity:0},W=p.memo(H);function $({onClose:i}){const s=h(o=>o.availableOntologies),l=h(o=>o.ontologyInstallStatus),d=h(o=>o.setOntologyInstallStatus),[n,c]=p.useState(""),[r,g]=p.useState(null);function t(){n.trim()&&(d({installing:!0}),P(n.trim()),c(""))}function x(o){M(o),g(null)}return e.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50",style:{background:"rgba(0,0,0,0.4)"},onClick:i,children:e.jsxs("div",{className:"rounded-xl shadow-2xl overflow-hidden",style:{background:"#FFFFFF",width:"520px",maxHeight:"600px",border:"1px solid #E5E5E0"},onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("h2",{className:"text-sm font-semibold",style:{color:"#1a1a1a"},children:"Manage Ontology Library"}),e.jsx("button",{onClick:i,className:"text-sm px-2 py-0.5 rounded hover:bg-gray-100",style:{color:"#9CA3AF"},children:"x"})]}),e.jsxs("div",{className:"p-5 space-y-5 overflow-y-auto",style:{maxHeight:"480px"},children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium block mb-1.5",style:{color:"#374151"},children:"Add Ontology"}),e.jsx("p",{className:"text-xs mb-2",style:{color:"#9CA3AF"},children:"Enter a git URL (https://...git), npm package name (@memoarchitect/...), or local path."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"https://gitlab.com/org/my-ontology.git",value:n,onChange:o=>c(o.target.value),onKeyDown:o=>o.key==="Enter"&&t(),className:"flex-1 px-3 py-2 text-xs rounded-lg",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151",outline:"none"},onFocus:o=>o.currentTarget.style.borderColor="#2563EB",onBlur:o=>o.currentTarget.style.borderColor="#E5E7EB",disabled:l.installing}),e.jsx("button",{onClick:t,disabled:!n.trim()||l.installing,className:"px-4 py-2 text-xs rounded-lg font-medium",style:{background:l.installing?"#9CA3AF":"#1B3A4B",color:"#FFFFFF",opacity:!n.trim()||l.installing?.5:1,cursor:!n.trim()||l.installing?"not-allowed":"pointer"},children:l.installing?"Installing...":"Install"})]}),l.error&&e.jsx("div",{className:"mt-2 px-3 py-2 rounded-lg text-xs",style:{background:"#FEF2F2",color:"#DC2626",border:"1px solid #FECACA"},children:l.error}),l.lastInstalled&&!l.error&&e.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-xs",style:{background:"#F0FDF4",color:"#16A34A",border:"1px solid #BBF7D0"},children:["Installed ",l.lastInstalled]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-medium block mb-2",style:{color:"#374151"},children:["Installed Packages (",s.length,")"]}),e.jsxs("div",{className:"space-y-1.5",children:[s.map(o=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{border:"1px solid #E5E5E0",background:"#FAFAF8"},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium truncate",style:{color:"#1a1a1a"},children:o.name}),e.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded",style:{background:o.type==="ontology"?"#EFF6FF":o.type==="profile"?"#F0FDF4":"#FFF7ED",color:o.type==="ontology"?"#2563EB":o.type==="profile"?"#16A34A":"#EA580C",fontSize:"10px"},children:o.type})]}),e.jsxs("div",{className:"text-xs mt-0.5",style:{color:"#9CA3AF"},children:["v",o.version," · ",o.kindCount," kinds · ",o.layers.length," layers"]})]}),r===o.name?e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>x(o.name),className:"px-2 py-1 text-xs rounded",style:{background:"#DC2626",color:"#FFFFFF"},children:"Confirm"}),e.jsx("button",{onClick:()=>g(null),className:"px-2 py-1 text-xs rounded",style:{background:"#F3F4F6",color:"#374151"},children:"Cancel"})]}):e.jsx("button",{onClick:()=>g(o.name),className:"text-xs px-2 py-1 rounded hover:bg-red-50",style:{color:"#DC2626",border:"1px solid #FECACA"},children:"Remove"})]},o.name)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-xs",style:{color:"#9CA3AF"},children:"No ontology packages installed"})]})]})]})]})})}const _={ontologyPackage:W},Y=260,K=180;async function V(i){const s=new Map(i.map(t=>[t.name,t])),l={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.layered.nodePlacement.strategy":"BRANDES_KOEPF","elk.layered.spacing.nodeNodeBetweenLayers":"100","elk.spacing.nodeNode":"32","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.padding":"[top=24, left=24, bottom=24, right=24]"},children:i.map(t=>({id:t.name,width:Y,height:K})),edges:i.filter(t=>t.extends&&s.has(t.extends)).map((t,x)=>({id:`e-${x}`,sources:[t.extends],targets:[t.name]}))},d=await T(l),n=new Map;for(const t of d.children??[])n.set(t.id,{x:t.x??0,y:t.y??0});const c={ontology:"#3B82F6",profile:"#10B981",extension:"#F59E0B"},r=i.map(t=>({id:t.name,type:"ontologyPackage",position:n.get(t.name)??{x:0,y:0},data:{name:t.name,type:t.type,version:t.version,description:t.description,kindCount:t.kindCount,layerCount:t.layers.length,layers:t.layers.map(x=>({id:x.id,label:x.label,color:x.color,kindCount:x.kindCount})),selected:t.selected,onClick:()=>{}}})),g=[];for(const t of i)if(t.extends&&s.has(t.extends)){const x=c[t.type]??"#94A3B8";g.push({id:`${t.extends}->${t.name}`,source:t.extends,target:t.name,type:"smoothstep",data:{edgeType:"extends"},style:{stroke:x,strokeWidth:2,strokeDasharray:"6 3"},animated:!1,label:"extends",labelStyle:{fontSize:9,fill:x,fontWeight:500},labelBgStyle:{fill:"#F7F7F5",fillOpacity:.9},labelBgPadding:[4,2],markerEnd:{type:"arrowclosed",color:x,width:14,height:14}})}return{nodes:r,edges:g}}function G(i,s){const l=new Map;for(const c of s)c.extends&&(l.has(c.extends)||l.set(c.extends,[]),l.get(c.extends).push(c.name));const d=new Set([i]),n=[i];for(;n.length;){const c=n.shift();for(const r of l.get(c)??[])d.has(r)||(d.add(r),n.push(r))}return d}function U(){const i=h(a=>a.availableOntologies),s=h(a=>a.setActiveView),l=h(a=>a.hiddenEdgeTypes),d=h(a=>a.toggleHiddenEdgeType),[n,c]=p.useState(!1),[r,g]=p.useState({nodes:[],edges:[]}),[t,x]=p.useState(null),{fitView:o}=S();p.useEffect(()=>{let a=!1;return V(i).then(u=>{a||g(u)}).catch(u=>{console.error("[OntologyDiagram] ELK layout failed:",u)}),()=>{a=!0}},[i]);const F=p.useCallback(a=>{s({type:"ontology-detail",packageName:a})},[s]),E=p.useCallback(a=>{const u=G(a,i),m=r.nodes.filter(y=>u.has(y.id));m.length!==0&&o({nodes:m.map(y=>({id:y.id})),duration:400,padding:.2})},[i,r.nodes,o]),v=p.useCallback((a,u)=>{a.preventDefault(),x({x:a.clientX,y:a.clientY,packageName:u})},[]);p.useEffect(()=>{const a=u=>{if(u.key==="Escape"){if(t){x(null);return}o({padding:.1,duration:300})}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,o]);const{nodes:N,edges:B}=p.useMemo(()=>{const a=r.nodes.map(m=>({...m,data:{...m.data,onClick:()=>E(m.id),onDoubleClick:()=>F(m.id),onContextMenu:y=>v(y,m.id)}})),u=r.edges.filter(m=>{var j;const y=(j=m.data)==null?void 0:j.edgeType;return!y||!l.has(y)});return{nodes:a,edges:u}},[r,E,F,v,l]),f=p.useRef(null);p.useEffect(()=>{if(!t)return;const a=u=>{f.current&&!f.current.contains(u.target)&&x(null)};return window.addEventListener("mousedown",a),()=>window.removeEventListener("mousedown",a)},[t]);const b=l.has("extends");return i.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"text-center",style:{color:"#9CA3AF"},children:[e.jsx("div",{className:"text-3xl mb-3",children:"◉"}),e.jsx("div",{className:"text-sm font-medium mb-1",style:{color:"#374151"},children:"No ontology packages found"}),e.jsx("div",{className:"text-xs",children:"Start the dev server to load ontology packages"})]})}):e.jsxs("div",{className:"flex-1",style:{background:"#F7F7F5"},children:[e.jsxs("div",{className:"flex items-start justify-between px-6 pt-5 pb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",style:{color:"#1a1a1a"},children:"Ontology Library"}),e.jsxs("p",{className:"text-xs mt-1",style:{color:"#9CA3AF"},children:[i.length," package",i.length!==1?"s":""," available. Click to zoom, double-click to open, right-click for source."]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{"data-testid":"toggle-tracing",onClick:()=>d("extends"),title:b?"Show extends tracing edges":"Hide extends tracing edges",className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:b?{background:"#F0F0ED",color:"#6B7280",border:"1px solid #E5E5E0"}:{background:"#1B3A4B",color:"#2DD4A8",border:"1px solid transparent"},children:b?"Show Tracing":"Hide Tracing"}),e.jsx("button",{onClick:()=>c(!0),className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:{background:"#1B3A4B",color:"#2DD4A8"},children:"+ Add Ontology"})]})]}),n&&e.jsx($,{onClose:()=>c(!1)}),e.jsx("div",{style:{flex:1,height:"calc(100% - 72px)"},children:e.jsxs(O,{nodes:N,edges:B,nodeTypes:_,fitView:!0,fitViewOptions:{padding:.1},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!0,zoomOnDoubleClick:!1,minZoom:.2,maxZoom:2.5,proOptions:{hideAttribution:!0},children:[e.jsx(R,{color:"#E5E5E0",gap:24,size:1}),e.jsx(I,{showInteractive:!1})]})}),t&&e.jsx(Z,{menuRef:f,state:t,onClose:()=>x(null),packages:i})]})}const Z=({state:i,onClose:s,packages:l,menuRef:d})=>{const n=l.find(r=>r.name===i.packageName);function c(){if(!n)return;const r=n.rootDir?`${n.rootDir}/memo.package.yaml`:"";r?z(r):window.open(`vscode://file/${encodeURIComponent(n.name)}`),s()}return e.jsxs("div",{ref:d,style:{position:"fixed",top:i.y,left:i.x,zIndex:1e3,background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"8px",boxShadow:"0 6px 16px rgba(0,0,0,0.12)",padding:"4px",minWidth:"180px",fontSize:"12px"},children:[e.jsx("div",{style:{padding:"6px 10px",color:"#9CA3AF",fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.4px"},children:i.packageName}),e.jsx("button",{onClick:c,disabled:!(n!=null&&n.rootDir),style:{display:"block",width:"100%",textAlign:"left",padding:"6px 10px",border:"none",background:"transparent",cursor:n!=null&&n.rootDir?"pointer":"not-allowed",color:n!=null&&n.rootDir?"#1a1a1a":"#9CA3AF",borderRadius:"4px"},onMouseEnter:r=>{n!=null&&n.rootDir&&(r.currentTarget.style.background="#F0F0ED")},onMouseLeave:r=>{r.currentTarget.style.background="transparent"},children:"Open source"})]})};function oe(){return e.jsx(D,{children:e.jsx(U,{})})}export{oe as OntologyDecompositionDiagram,oe as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LayerGrid-
|
|
2
|
-
import{f as _,u as y,_ as O,L as X}from"./index-C8UZrEP-.js";import{j as e}from"./reactflow-CsCqNKB-.js";import{a}from"./zustand-CrhqMOHB.js";function G({ontology:s}){const i=s.layers.reduce((r,f)=>r+f.kinds.reduce((d,l)=>d+l.instanceCount,0),0);return e.jsxs("div",{className:"rounded-xl p-5 mb-5",style:{background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[e.jsx("div",{className:"flex items-start justify-between gap-3 mb-3",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"px-2 py-0.5 text-xs rounded-full font-medium",style:{background:"#EFF6FF",color:"#2563EB",border:"1px solid #BFDBFE"},children:s.type}),s.extends&&e.jsxs("span",{className:"text-xs",style:{color:"#9CA3AF"},children:["extends ",s.extends]})]}),e.jsx("h2",{className:"text-base font-semibold truncate",style:{color:"#1a1a1a"},children:s.name}),e.jsxs("div",{className:"text-xs mt-0.5",style:{color:"#9CA3AF"},children:["v",s.version]})]})}),s.description&&e.jsx("p",{className:"text-sm mb-4",style:{color:"#6B7280",lineHeight:"1.5"},children:s.description}),e.jsxs("div",{className:"flex gap-5 text-xs",style:{color:"#6B7280"},children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-sm",style:{color:"#1B3A4B"},children:s.kindCount})," ","kinds"]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-sm",style:{color:"#1B3A4B"},children:s.layers.length})," ","layers"]}),i>0&&e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-sm",style:{color:"#1B3A4B"},children:i})," ","model instances"]})]})]})}function J({kind:s,layers:i,onKindClick:r,onClose:f,allOntologies:d,onNavigate:l}){const o=_[s.layer]??"#6B7280",c=i.flatMap(t=>t.kinds),m=s.derivesFrom?c.find(t=>t.name===s.derivesFrom):null;function p(t){if(i.some(x=>x.kinds.some(h=>h.name===t)))return null;for(const x of d??[])if(x.layers.some(h=>h.kinds.some(N=>N.name===t)))return x.name;return null}function v(t){const x=p(t);x&&l?l(x,t):r(t)}return e.jsxs("div",{className:"flex flex-col border-l overflow-y-auto",style:{width:320,minWidth:320,background:"#FFFFFF",borderColor:"#E5E5E0"},children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",style:{borderColor:"#E5E5E0"},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"w-3 h-3 rounded flex-shrink-0",style:{backgroundColor:o}}),e.jsx("h3",{className:"text-sm font-semibold truncate",style:{color:"#1a1a1a"},children:s.label})]}),e.jsx("button",{onClick:f,className:"text-sm px-1.5 rounded hover:bg-gray-100",style:{color:"#9CA3AF"},children:"✕"})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"px-2 py-0.5 text-xs rounded font-mono",style:{background:"#F3F4F6",color:"#4B5563",border:"1px solid #E5E7EB"},children:s.construct}),e.jsx("span",{className:"px-2 py-0.5 text-xs rounded font-medium",style:{background:`${o}15`,color:o,border:`1px solid ${o}30`},children:s.layer})]}),s.description&&e.jsx(S,{title:"Description",children:e.jsx("p",{className:"text-xs leading-relaxed",style:{color:"#6B7280"},children:s.description})}),s.derivesFrom&&e.jsx(S,{title:"Derives From",children:e.jsx(I,{name:s.derivesFrom,layer:m==null?void 0:m.layer,crossOntology:p(s.derivesFrom)!==null,onClick:()=>v(s.derivesFrom)})}),s.derivedBy&&s.derivedBy.length>0&&e.jsx(S,{title:`Derived By (${s.derivedBy.length})`,children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.derivedBy.map(t=>{const x=c.find(h=>h.name===t);return e.jsx(I,{name:t,layer:x==null?void 0:x.layer,crossOntology:p(t)!==null,onClick:()=>v(t)},t)})})}),s.relationships&&s.relationships.length>0&&e.jsx(S,{title:`Relationships (${s.relationships.length})`,children:e.jsx("div",{className:"space-y-1",children:s.relationships.map((t,x)=>e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",style:{color:"#6B7280"},children:[e.jsx("span",{style:{color:t.direction==="outgoing"?"#10B981":"#8B5CF6"},children:t.direction==="outgoing"?"→":"←"}),e.jsx("span",{className:"font-medium",style:{color:"#374151"},children:t.type}),e.jsx("button",{className:"hover:underline",style:{color:"#2563EB"},onClick:()=>v(t.targetKind),children:t.targetKind})]},x))})}),e.jsxs(S,{title:"Usage",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(V,{label:"Instances",value:s.instanceCount}),e.jsx(V,{label:"Viewpoints",value:s.viewpoints.length})]}),s.viewpoints.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:s.viewpoints.map(t=>e.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded",style:{background:"#F3F4F6",color:"#6B7280"},children:t},t))})]})]})]})}function S({title:s,children:i}){return e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium mb-1.5",style:{color:"#9CA3AF",textTransform:"uppercase",letterSpacing:"0.05em"},children:s}),i]})}function I({name:s,layer:i,crossOntology:r,onClick:f}){const d=i?_[i]??"#6B7280":"#6B7280";return e.jsxs("button",{onClick:f,className:"inline-flex items-center gap-1.5 px-2 py-1 text-xs rounded-md hover:bg-gray-50",style:{border:"1px solid #E5E7EB",color:"#374151"},title:r?"Navigate to this kind in another ontology package":void 0,children:[e.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:d}}),s.replace(/([A-Z])/g," $1").trim(),r&&e.jsx("span",{style:{color:"#9CA3AF",fontSize:"9px"},children:"↗"})]})}function V({label:s,value:i}){return e.jsxs("div",{className:"rounded-lg p-2",style:{background:"#F9FAFB",border:"1px solid #F3F4F6"},children:[e.jsx("div",{className:"text-sm font-semibold",style:{color:"#1B3A4B"},children:i}),e.jsx("div",{className:"text-xs",style:{color:"#9CA3AF"},children:s})]})}const P={"part def":{label:"Part Definition",shorthand:"pd",description:"Defines a structural classifier (composite part)"},"connection def":{label:"Connection Definition",shorthand:"cd",description:"Defines a connector type between parts"},"attribute def":{label:"Attribute Definition",shorthand:"ad",description:"Defines a typed value property"},"item def":{label:"Item Definition",shorthand:"id",description:"Defines a flow item type"},"action def":{label:"Action Definition",shorthand:"acd",description:"Defines a behavioral action"},"state def":{label:"State Definition",shorthand:"sd",description:"Defines a state machine type"},"requirement def":{label:"Requirement Definition",shorthand:"rd",description:"Defines a requirement type"},"use case def":{label:"Use Case Definition",shorthand:"ucd",description:"Defines a use case type"},"occurrence def":{label:"Occurrence Definition",shorthand:"od",description:"Defines an occurrence (event or snapshot)"},"interface def":{label:"Interface Definition",shorthand:"ifd",description:"Defines a port interface type"},"port def":{label:"Port Definition",shorthand:"ptd",description:"Defines a port type for system interfaces"},"metadata def":{label:"Metadata Definition",shorthand:"md",description:"Defines a metadata annotation type"}},Q={purpose:"#cce5ff",business:"#cce5ff",operational:"#cce5ff",requirements:"#dae8fc",functional:"#d5e8d4",behavior:"#d5e8d4",logical:"#d5e8d4",physical:"#ffe6cc",software:"#d5e8d4",interfaces:"#d5e8d4",ui:"#d5e8d4",risk:"#f8cecc",safety:"#f8cecc",cybersecurity:"#f8cecc",verification:"#e1d5e7",analysis:"#e1d5e7","design-control":"#fff2cc",qms:"#fff2cc","software-lifecycle":"#fff2cc",operations:"#fff2cc",clinical:"#fff2cc",privacy:"#fff2cc"};function ee({layers:s}){const i=[],r=new Map;for(const l of s)for(const o of l.kinds){const c=o.construct||"part def";r.has(c)||r.set(c,[]),r.get(c).push({kindName:o.name,layer:l.id,layerLabel:l.label,layerColor:Q[l.id]??"#f3f4f6",derivesFrom:o.derivesFrom,description:o.description})}const f=Object.keys(P),d=[...r.keys()].sort((l,o)=>{const c=f.indexOf(l),m=f.indexOf(o);return c===-1&&m===-1?l.localeCompare(o):c===-1?1:m===-1?-1:c-m});for(const l of d){const o=r.get(l).sort((m,p)=>m.kindName.localeCompare(p.kindName)),c=P[l];i.push({construct:l,label:(c==null?void 0:c.label)??l,shorthand:(c==null?void 0:c.shorthand)??l,description:(c==null?void 0:c.description)??"",kinds:o})}return i.length===0?e.jsx("div",{className:"py-8 text-center text-sm",style:{color:"#9CA3AF"},children:"No kinds found in the selected viewpoint."}):e.jsxs("div",{style:{fontFamily:"inherit"},children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",style:{color:"#1a1a1a"},children:"SysML v2 Construct Mapping"}),e.jsx("p",{className:"text-xs",style:{color:"#9CA3AF"},children:"Each SysML v2 construct keyword and the MEMO kinds that use it. Shorthand codes appear on kind cards throughout the viewer."})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:i.map(l=>e.jsx(se,{group:l},l.construct))})]})}function se({group:s}){return e.jsxs("div",{style:{border:"1px solid #E5E5E0",borderRadius:"10px",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"8px 12px",background:"#F7F7F5",borderBottom:"1px solid #E5E5E0"},children:[e.jsx("code",{style:{fontSize:"11px",fontFamily:"monospace",background:"#1B3A4B",color:"#2DD4A8",padding:"2px 6px",borderRadius:"4px",letterSpacing:"0.02em"},children:s.construct}),e.jsx("span",{className:"text-sm font-semibold",style:{color:"#1a1a1a"},children:s.label}),e.jsx("span",{style:{fontSize:"10px",color:"#6B7280",fontFamily:"monospace",background:"#EBEBEB",padding:"1px 5px",borderRadius:"3px"},children:s.shorthand}),s.description&&e.jsxs("span",{className:"text-xs ml-1",style:{color:"#9CA3AF"},children:["— ",s.description]}),e.jsxs("span",{className:"ml-auto text-xs",style:{color:"#9CA3AF"},children:[s.kinds.length," kind",s.kinds.length!==1?"s":""]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"10px 12px"},children:s.kinds.map(i=>e.jsx(te,{kind:i},i.kindName))})]})}function te({kind:s}){return e.jsxs("div",{title:s.description??s.kindName,style:{display:"inline-flex",alignItems:"center",gap:"5px",padding:"3px 8px",background:s.layerColor,borderRadius:"5px",fontSize:"11px",fontWeight:500,color:"#1a1a1a",border:"1px solid rgba(0,0,0,0.06)",whiteSpace:"nowrap"},children:[e.jsx("span",{style:{fontWeight:600},children:s.kindName}),e.jsx("span",{style:{fontSize:"9px",color:"#6B7280",background:"rgba(255,255,255,0.55)",padding:"1px 4px",borderRadius:"3px"},children:s.layerLabel}),s.derivesFrom&&e.jsxs("span",{style:{fontSize:"9px",color:"#9CA3AF",fontStyle:"italic"},title:`Specializes ${s.derivesFrom}`,children:[":> ",s.derivesFrom]})]})}const ne=a.lazy(()=>O(()=>import("./LayerGrid-DAIv9DZ6.js"),__vite__mapDeps([0,1,2,3,4])).then(s=>({default:s.LayerGrid}))),ie=a.lazy(()=>O(()=>import("./LayerTable-BnOya4yd.js"),__vite__mapDeps([5,1,2,3,4])).then(s=>({default:s.LayerTable}))),K=a.lazy(()=>O(()=>import("./RelationshipsSection-DttMvF2i.js"),__vite__mapDeps([6,1,2,7])).then(s=>({default:s.RelationshipsSection}))),le=a.lazy(()=>O(()=>import("./RelationshipOverlay-B9bqt4zl.js"),__vite__mapDeps([8,1,2,7])).then(s=>({default:s.RelationshipOverlay}))),L=[{id:"all",label:"All Layers",layerIds:null,description:"All architecture layers in swimlane view"},{id:"software",label:"Software Views",layerIds:["functional","behavior","logical","software","interfaces","ui"],description:"Software architecture: Logical/Service, Runtime, Module/Code, Deployment"},{id:"hardware",label:"Hardware Views",layerIds:["logical","physical","interfaces"],description:"Hardware architecture: Logical, Physical/Embodiment, Compute/Electronics, Cross-domain"},{id:"risk",label:"Risk Chain",layerIds:["requirements","risk","safety","cybersecurity","verification","analysis"],description:"Risk trace chain: Hazard → HazardousSituation → Harm → RiskControlMeasure → verification"},{id:"traceability",label:"Traceability",layerIds:["purpose","business","operational","requirements","risk","safety","functional","software","software-lifecycle","verification","analysis"],description:"Full trace: clinical, risk, software, and hardware chains"},{id:"sysml-mapping",label:"SysML Mapping",layerIds:null,type:"sysml-mapping",description:"SysML v2 construct → MEMO kind reference table"}],ae=.3,oe=2.5,R=.15;function re({children:s}){const[i,r]=a.useState(1),[f,d]=a.useState({x:0,y:0}),l=a.useRef(!1),o=a.useRef({x:0,y:0}),c=a.useRef(null),m=u=>Math.max(ae,Math.min(oe,u)),p=a.useCallback(u=>{u.preventDefault();const F=u.deltaY<0?R:-R;r(C=>m(C+F))},[]),v=a.useCallback(u=>{u.target.closest("button, input, a")||(l.current=!0,o.current={x:u.clientX,y:u.clientY},u.currentTarget.setAttribute("data-panning","true"))},[]),t=a.useCallback(u=>{if(!l.current)return;const F=u.clientX-o.current.x,C=u.clientY-o.current.y;o.current={x:u.clientX,y:u.clientY},d(k=>({x:k.x+F,y:k.y+C}))},[]),x=a.useCallback(u=>{l.current=!1,u.currentTarget.removeAttribute("data-panning")},[]),h=a.useCallback(u=>{l.current=!1,u.currentTarget.removeAttribute("data-panning")},[]);function N(){r(1),d({x:0,y:0})}return e.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[e.jsxs("div",{style:{position:"absolute",top:"10px",right:"10px",zIndex:10,display:"flex",gap:"4px",background:"rgba(255,255,255,0.92)",border:"1px solid #E5E5E0",borderRadius:"8px",padding:"4px",boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},children:[e.jsx(T,{title:"Zoom in",onClick:()=>r(u=>m(u+R)),children:"+"}),e.jsxs("span",{style:{fontSize:"10px",color:"#6B7280",lineHeight:"26px",minWidth:"34px",textAlign:"center"},children:[Math.round(i*100),"%"]}),e.jsx(T,{title:"Zoom out",onClick:()=>r(u=>m(u-R)),children:"−"}),e.jsx("div",{style:{width:"1px",background:"#E5E5E0",margin:"2px 0"}}),e.jsx(T,{title:"Fit to view",onClick:N,children:"⊡"})]}),e.jsx("div",{ref:c,onWheel:p,onMouseDown:v,onMouseMove:t,onMouseUp:x,onMouseLeave:h,style:{width:"100%",height:"100%",overflow:"hidden",cursor:l.current?"grabbing":"grab",userSelect:"none"},children:e.jsx("div",{style:{transform:`translate(${f.x}px, ${f.y}px) scale(${i})`,transformOrigin:"0 0",willChange:"transform",padding:"16px"},children:s})})]})}function T({onClick:s,title:i,children:r}){return e.jsx("button",{onClick:s,title:i,style:{width:"26px",height:"26px",border:"none",borderRadius:"5px",background:"transparent",cursor:"pointer",fontSize:"14px",color:"#374151",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},onMouseEnter:f=>{f.currentTarget.style.background="#F0F0ED"},onMouseLeave:f=>{f.currentTarget.style.background="transparent"},children:r})}function ce({ontology:s,onBack:i}){const r=y(n=>n.ontologyViewMode),f=y(n=>n.setOntologyViewMode),d=y(n=>n.selectedOntologyKind),l=y(n=>n.setSelectedOntologyKind),o=y(n=>n.showOntologyRelationships),c=y(n=>n.toggleOntologyRelationships),m=y(n=>n.model),p=y(n=>n.activeView),v=y(n=>n.setActiveView),t=y(n=>n.availableOntologies),x=a.useRef(null),[h,N]=a.useState(new Set),[u,F]=a.useState("all"),[C,k]=a.useState(!1),[H,W]=a.useState(null),[Z,Y]=a.useState(0);a.useEffect(()=>{d&&(k(!0),W(d),Y(n=>n+1))},[d]);const g=a.useMemo(()=>({...s,layers:s.layers.map(n=>({...n,kinds:n.kinds.map(b=>{var M;return{...b,instanceCount:m?Object.values(m.elements).filter(A=>A.kind===b.name).length:0,viewpoints:((M=m==null?void 0:m.viewpoints)==null?void 0:M.filter(A=>A.visibleKinds.includes(b.name)).map(A=>A.id))??[]}})}))}),[s,m]),E=L.find(n=>n.id===u)??L[0],j=a.useMemo(()=>{if(!E.layerIds)return g.layers;const n=new Set(E.layerIds);return g.layers.filter(b=>n.has(b.id))},[g.layers,E.layerIds]),w=a.useMemo(()=>{if(!d)return null;for(const n of g.layers){const b=n.kinds.find(M=>M.name===d);if(b)return{kind:b,layerInfo:n}}return null},[d,g]);function q(n,b){l(b),v({type:"ontology-detail",packageName:n})}function U(n){v({type:"ontology-detail",packageName:s.name,layerId:n})}const B={background:"#1B3A4B",color:"#2DD4A8",border:"1px solid transparent"},D={background:"#F0F0ED",color:"#6B7280",border:"1px solid transparent"};return e.jsxs("div",{className:"flex flex-1 overflow-hidden",style:{background:"#F7F7F5"},children:[e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("div",{className:"px-6 pt-5 pb-3",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-3 text-xs flex-wrap",style:{color:"#9CA3AF"},children:[i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:i,className:"hover:underline",style:{color:"#2563EB"},children:"Ontology Library"}),e.jsx("span",{children:"/"})]}),e.jsx("button",{onClick:()=>l(null),className:"hover:underline",style:{color:w?"#2563EB":"#374151",fontWeight:w?400:500},children:s.name}),w&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"/"}),e.jsx("button",{onClick:()=>U(w.layerInfo.id),className:"hover:underline",style:{color:"#2563EB"},children:w.layerInfo.label}),e.jsx("span",{children:"/"}),e.jsx("span",{style:{color:"#1a1a1a",fontWeight:600},children:d})]})]}),e.jsx(G,{ontology:g}),e.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[e.jsx("span",{className:"text-xs",style:{color:"#9CA3AF"},children:"Layers:"}),e.jsx("button",{onClick:()=>f("visual"),className:"px-2.5 py-1 text-xs rounded-md font-medium",style:r==="visual"?B:D,children:"Visual"}),e.jsx("button",{onClick:()=>f("table"),className:"px-2.5 py-1 text-xs rounded-md font-medium",style:r==="table"?B:D,children:"Table"}),e.jsx("span",{style:{width:"1px",height:"16px",background:"#E5E5E0",margin:"0 4px"}}),e.jsxs("button",{onClick:c,className:"px-2.5 py-1 text-xs rounded-md font-medium",style:o?B:D,children:[o?"Hide":"Show"," Relationships"]})]}),e.jsxs("div",{className:"flex items-center gap-0 mt-3 -mx-6 px-6",style:{borderTop:"1px solid #E5E5E0",paddingTop:"10px"},children:[e.jsx("span",{className:"text-xs mr-2",style:{color:"#9CA3AF",whiteSpace:"nowrap"},children:"View:"}),e.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:L.map(n=>{const b=u===n.id;return e.jsx("button",{onClick:()=>F(n.id),title:n.description,className:"px-2.5 py-1 text-xs rounded-md font-medium transition-all",style:b?B:D,children:n.label},n.id)})}),j.length!==g.layers.length&&E.type!=="sysml-mapping"&&e.jsxs("span",{className:"ml-auto text-xs",style:{color:"#9CA3AF",whiteSpace:"nowrap"},children:[j.length," of ",g.layers.length," layers"]})]})]}),E.type==="sysml-mapping"?e.jsx("div",{className:"px-6 py-4",children:e.jsx(ee,{layers:g.layers})}):r==="visual"?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{height:"280px",position:"relative",borderBottom:"1px solid #E5E5E0"},children:e.jsx(re,{children:e.jsxs("div",{ref:x,style:{position:"relative"},children:[e.jsx(a.Suspense,{fallback:e.jsx(z,{layers:j}),children:e.jsx(ne,{layers:j,selectedKind:d,onKindClick:l,activeLayerId:p.layerId??null,flashKindName:H,flashTick:Z})}),o&&e.jsx(a.Suspense,{fallback:null,children:e.jsx(le,{containerRef:x,ontology:{...g,layers:j},activeTypes:h})})]})})}),o&&e.jsx("div",{className:"px-6 py-4",children:e.jsx(a.Suspense,{fallback:null,children:e.jsx(K,{ontology:{...g,layers:j},activeTypes:h,onActiveTypesChange:N})})})]}):e.jsxs("div",{className:"px-6 py-4",children:[e.jsx(a.Suspense,{fallback:e.jsx(z,{layers:j}),children:e.jsx(ie,{layers:j,selectedKind:d,onKindClick:l})}),o&&e.jsx(a.Suspense,{fallback:null,children:e.jsx(K,{ontology:{...g,layers:j},activeTypes:h,onActiveTypesChange:N})})]})]}),C&&w&&e.jsx(J,{kind:w.kind,layers:g.layers,allOntologies:t,onKindClick:l,onNavigate:q,onClose:()=>{l(null),k(!1)}})]})}function z({layers:s}){return e.jsx("div",{className:"grid gap-3 mb-6",style:{gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))"},children:s.map(i=>{const r=_[i.id]??i.color??"#6B7280";return e.jsxs("div",{className:"rounded-xl p-4",style:{background:"#FFFFFF",border:`2px solid ${r}30`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"w-3 h-3 rounded",style:{backgroundColor:r}}),e.jsx("span",{className:"text-sm font-medium",style:{color:"#1a1a1a"},children:i.label})]}),e.jsxs("div",{className:"text-xs",style:{color:"#9CA3AF"},children:[i.kindCount," kinds"]})]},i.id)})})}const de=a.lazy(()=>O(()=>import("./OntologyDecompositionDiagram-COmPilyD.js"),__vite__mapDeps([9,1,2,10,11,3,4,12]))),$=Object.fromEntries(X.map((s,i)=>[s,i]));function me(){const s=y(p=>p.activeView),i=y(p=>p.availableOntologies),r=y(p=>p.setActiveView),f=y(p=>p.model),d=s.type==="ontology-detail",l=d?s.packageName:null,o=l?i.find(p=>p.name===l):null,c=a.useMemo(()=>{if(o||!d||!f)return null;const p=new Map;for(const t of Object.values(f.elements))p.has(t.layer)||p.set(t.layer,[]),p.get(t.layer).includes(t.kind)||p.get(t.layer).push(t.kind);const v=[...p.entries()].sort(([t],[x])=>($[t]??99)-($[x]??99)).map(([t,x])=>({id:t,label:t.charAt(0).toUpperCase()+t.slice(1),color:"#6B7280",kindCount:x.length,kinds:x.map(h=>({name:h,label:h.replace(/([A-Z])/g," $1").trim(),construct:"part def",layer:t,instanceCount:0,viewpoints:[]}))}));return{name:"@memo/model (inferred)",version:"–",type:"ontology",description:"Ontology inferred from loaded model elements.",layers:v,kindCount:v.reduce((t,x)=>t+x.kindCount,0),relationshipCount:0,relationshipTypes:[],selected:!0}},[o,d,f]),m=o??c;return d&&m?e.jsx(ce,{ontology:m,onBack:()=>r({type:"ontology"})}):e.jsx(a.Suspense,{fallback:e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsx("span",{className:"text-sm",style:{color:"#9CA3AF"},children:"Loading ontology library..."})}),children:e.jsx(de,{})})}export{me as OntologyViewer,me as default};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/LayerGrid-B3MBWswK.js","assets/reactflow-CsCqNKB-.js","assets/zustand-CrhqMOHB.js","assets/index-D0vtjNjX.js","assets/index-B8HDzVLs.css","assets/LayerTable-DyIzIt5M.js","assets/RelationshipsSection-DttMvF2i.js","assets/sysml-edge-styles-ByJeCWqa.js","assets/RelationshipOverlay-B9bqt4zl.js","assets/OntologyDecompositionDiagram-IG1gj1c3.js","assets/layout-providers-Dr743WlP.js","assets/elk-6l8mIQnQ.js","assets/style-BZV40eAE.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{f as _,u as y,_ as O,L as X}from"./index-D0vtjNjX.js";import{j as e}from"./reactflow-CsCqNKB-.js";import{a}from"./zustand-CrhqMOHB.js";function G({ontology:s}){const i=s.layers.reduce((r,f)=>r+f.kinds.reduce((d,l)=>d+l.instanceCount,0),0);return e.jsxs("div",{className:"rounded-xl p-5 mb-5",style:{background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 1px 3px rgba(0,0,0,0.04)"},children:[e.jsx("div",{className:"flex items-start justify-between gap-3 mb-3",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"px-2 py-0.5 text-xs rounded-full font-medium",style:{background:"#EFF6FF",color:"#2563EB",border:"1px solid #BFDBFE"},children:s.type}),s.extends&&e.jsxs("span",{className:"text-xs",style:{color:"#9CA3AF"},children:["extends ",s.extends]})]}),e.jsx("h2",{className:"text-base font-semibold truncate",style:{color:"#1a1a1a"},children:s.name}),e.jsxs("div",{className:"text-xs mt-0.5",style:{color:"#9CA3AF"},children:["v",s.version]})]})}),s.description&&e.jsx("p",{className:"text-sm mb-4",style:{color:"#6B7280",lineHeight:"1.5"},children:s.description}),e.jsxs("div",{className:"flex gap-5 text-xs",style:{color:"#6B7280"},children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-sm",style:{color:"#1B3A4B"},children:s.kindCount})," ","kinds"]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-sm",style:{color:"#1B3A4B"},children:s.layers.length})," ","layers"]}),i>0&&e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-sm",style:{color:"#1B3A4B"},children:i})," ","model instances"]})]})]})}function J({kind:s,layers:i,onKindClick:r,onClose:f,allOntologies:d,onNavigate:l}){const o=_[s.layer]??"#6B7280",c=i.flatMap(t=>t.kinds),m=s.derivesFrom?c.find(t=>t.name===s.derivesFrom):null;function p(t){if(i.some(x=>x.kinds.some(h=>h.name===t)))return null;for(const x of d??[])if(x.layers.some(h=>h.kinds.some(N=>N.name===t)))return x.name;return null}function v(t){const x=p(t);x&&l?l(x,t):r(t)}return e.jsxs("div",{className:"flex flex-col border-l overflow-y-auto",style:{width:320,minWidth:320,background:"#FFFFFF",borderColor:"#E5E5E0"},children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",style:{borderColor:"#E5E5E0"},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"w-3 h-3 rounded flex-shrink-0",style:{backgroundColor:o}}),e.jsx("h3",{className:"text-sm font-semibold truncate",style:{color:"#1a1a1a"},children:s.label})]}),e.jsx("button",{onClick:f,className:"text-sm px-1.5 rounded hover:bg-gray-100",style:{color:"#9CA3AF"},children:"✕"})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"px-2 py-0.5 text-xs rounded font-mono",style:{background:"#F3F4F6",color:"#4B5563",border:"1px solid #E5E7EB"},children:s.construct}),e.jsx("span",{className:"px-2 py-0.5 text-xs rounded font-medium",style:{background:`${o}15`,color:o,border:`1px solid ${o}30`},children:s.layer})]}),s.description&&e.jsx(S,{title:"Description",children:e.jsx("p",{className:"text-xs leading-relaxed",style:{color:"#6B7280"},children:s.description})}),s.derivesFrom&&e.jsx(S,{title:"Derives From",children:e.jsx(I,{name:s.derivesFrom,layer:m==null?void 0:m.layer,crossOntology:p(s.derivesFrom)!==null,onClick:()=>v(s.derivesFrom)})}),s.derivedBy&&s.derivedBy.length>0&&e.jsx(S,{title:`Derived By (${s.derivedBy.length})`,children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.derivedBy.map(t=>{const x=c.find(h=>h.name===t);return e.jsx(I,{name:t,layer:x==null?void 0:x.layer,crossOntology:p(t)!==null,onClick:()=>v(t)},t)})})}),s.relationships&&s.relationships.length>0&&e.jsx(S,{title:`Relationships (${s.relationships.length})`,children:e.jsx("div",{className:"space-y-1",children:s.relationships.map((t,x)=>e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",style:{color:"#6B7280"},children:[e.jsx("span",{style:{color:t.direction==="outgoing"?"#10B981":"#8B5CF6"},children:t.direction==="outgoing"?"→":"←"}),e.jsx("span",{className:"font-medium",style:{color:"#374151"},children:t.type}),e.jsx("button",{className:"hover:underline",style:{color:"#2563EB"},onClick:()=>v(t.targetKind),children:t.targetKind})]},x))})}),e.jsxs(S,{title:"Usage",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(V,{label:"Instances",value:s.instanceCount}),e.jsx(V,{label:"Viewpoints",value:s.viewpoints.length})]}),s.viewpoints.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:s.viewpoints.map(t=>e.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded",style:{background:"#F3F4F6",color:"#6B7280"},children:t},t))})]})]})]})}function S({title:s,children:i}){return e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium mb-1.5",style:{color:"#9CA3AF",textTransform:"uppercase",letterSpacing:"0.05em"},children:s}),i]})}function I({name:s,layer:i,crossOntology:r,onClick:f}){const d=i?_[i]??"#6B7280":"#6B7280";return e.jsxs("button",{onClick:f,className:"inline-flex items-center gap-1.5 px-2 py-1 text-xs rounded-md hover:bg-gray-50",style:{border:"1px solid #E5E7EB",color:"#374151"},title:r?"Navigate to this kind in another ontology package":void 0,children:[e.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:d}}),s.replace(/([A-Z])/g," $1").trim(),r&&e.jsx("span",{style:{color:"#9CA3AF",fontSize:"9px"},children:"↗"})]})}function V({label:s,value:i}){return e.jsxs("div",{className:"rounded-lg p-2",style:{background:"#F9FAFB",border:"1px solid #F3F4F6"},children:[e.jsx("div",{className:"text-sm font-semibold",style:{color:"#1B3A4B"},children:i}),e.jsx("div",{className:"text-xs",style:{color:"#9CA3AF"},children:s})]})}const P={"part def":{label:"Part Definition",shorthand:"pd",description:"Defines a structural classifier (composite part)"},"connection def":{label:"Connection Definition",shorthand:"cd",description:"Defines a connector type between parts"},"attribute def":{label:"Attribute Definition",shorthand:"ad",description:"Defines a typed value property"},"item def":{label:"Item Definition",shorthand:"id",description:"Defines a flow item type"},"action def":{label:"Action Definition",shorthand:"acd",description:"Defines a behavioral action"},"state def":{label:"State Definition",shorthand:"sd",description:"Defines a state machine type"},"requirement def":{label:"Requirement Definition",shorthand:"rd",description:"Defines a requirement type"},"use case def":{label:"Use Case Definition",shorthand:"ucd",description:"Defines a use case type"},"occurrence def":{label:"Occurrence Definition",shorthand:"od",description:"Defines an occurrence (event or snapshot)"},"interface def":{label:"Interface Definition",shorthand:"ifd",description:"Defines a port interface type"},"port def":{label:"Port Definition",shorthand:"ptd",description:"Defines a port type for system interfaces"},"metadata def":{label:"Metadata Definition",shorthand:"md",description:"Defines a metadata annotation type"}},Q={purpose:"#cce5ff",business:"#cce5ff",operational:"#cce5ff",requirements:"#dae8fc",functional:"#d5e8d4",behavior:"#d5e8d4",logical:"#d5e8d4",physical:"#ffe6cc",software:"#d5e8d4",interfaces:"#d5e8d4",ui:"#d5e8d4",risk:"#f8cecc",safety:"#f8cecc",cybersecurity:"#f8cecc",verification:"#e1d5e7",analysis:"#e1d5e7","design-control":"#fff2cc",qms:"#fff2cc","software-lifecycle":"#fff2cc",operations:"#fff2cc",clinical:"#fff2cc",privacy:"#fff2cc"};function ee({layers:s}){const i=[],r=new Map;for(const l of s)for(const o of l.kinds){const c=o.construct||"part def";r.has(c)||r.set(c,[]),r.get(c).push({kindName:o.name,layer:l.id,layerLabel:l.label,layerColor:Q[l.id]??"#f3f4f6",derivesFrom:o.derivesFrom,description:o.description})}const f=Object.keys(P),d=[...r.keys()].sort((l,o)=>{const c=f.indexOf(l),m=f.indexOf(o);return c===-1&&m===-1?l.localeCompare(o):c===-1?1:m===-1?-1:c-m});for(const l of d){const o=r.get(l).sort((m,p)=>m.kindName.localeCompare(p.kindName)),c=P[l];i.push({construct:l,label:(c==null?void 0:c.label)??l,shorthand:(c==null?void 0:c.shorthand)??l,description:(c==null?void 0:c.description)??"",kinds:o})}return i.length===0?e.jsx("div",{className:"py-8 text-center text-sm",style:{color:"#9CA3AF"},children:"No kinds found in the selected viewpoint."}):e.jsxs("div",{style:{fontFamily:"inherit"},children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",style:{color:"#1a1a1a"},children:"SysML v2 Construct Mapping"}),e.jsx("p",{className:"text-xs",style:{color:"#9CA3AF"},children:"Each SysML v2 construct keyword and the MEMO kinds that use it. Shorthand codes appear on kind cards throughout the viewer."})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:i.map(l=>e.jsx(se,{group:l},l.construct))})]})}function se({group:s}){return e.jsxs("div",{style:{border:"1px solid #E5E5E0",borderRadius:"10px",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"8px 12px",background:"#F7F7F5",borderBottom:"1px solid #E5E5E0"},children:[e.jsx("code",{style:{fontSize:"11px",fontFamily:"monospace",background:"#1B3A4B",color:"#2DD4A8",padding:"2px 6px",borderRadius:"4px",letterSpacing:"0.02em"},children:s.construct}),e.jsx("span",{className:"text-sm font-semibold",style:{color:"#1a1a1a"},children:s.label}),e.jsx("span",{style:{fontSize:"10px",color:"#6B7280",fontFamily:"monospace",background:"#EBEBEB",padding:"1px 5px",borderRadius:"3px"},children:s.shorthand}),s.description&&e.jsxs("span",{className:"text-xs ml-1",style:{color:"#9CA3AF"},children:["— ",s.description]}),e.jsxs("span",{className:"ml-auto text-xs",style:{color:"#9CA3AF"},children:[s.kinds.length," kind",s.kinds.length!==1?"s":""]})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"10px 12px"},children:s.kinds.map(i=>e.jsx(te,{kind:i},i.kindName))})]})}function te({kind:s}){return e.jsxs("div",{title:s.description??s.kindName,style:{display:"inline-flex",alignItems:"center",gap:"5px",padding:"3px 8px",background:s.layerColor,borderRadius:"5px",fontSize:"11px",fontWeight:500,color:"#1a1a1a",border:"1px solid rgba(0,0,0,0.06)",whiteSpace:"nowrap"},children:[e.jsx("span",{style:{fontWeight:600},children:s.kindName}),e.jsx("span",{style:{fontSize:"9px",color:"#6B7280",background:"rgba(255,255,255,0.55)",padding:"1px 4px",borderRadius:"3px"},children:s.layerLabel}),s.derivesFrom&&e.jsxs("span",{style:{fontSize:"9px",color:"#9CA3AF",fontStyle:"italic"},title:`Specializes ${s.derivesFrom}`,children:[":> ",s.derivesFrom]})]})}const ne=a.lazy(()=>O(()=>import("./LayerGrid-B3MBWswK.js"),__vite__mapDeps([0,1,2,3,4])).then(s=>({default:s.LayerGrid}))),ie=a.lazy(()=>O(()=>import("./LayerTable-DyIzIt5M.js"),__vite__mapDeps([5,1,2,3,4])).then(s=>({default:s.LayerTable}))),K=a.lazy(()=>O(()=>import("./RelationshipsSection-DttMvF2i.js"),__vite__mapDeps([6,1,2,7])).then(s=>({default:s.RelationshipsSection}))),le=a.lazy(()=>O(()=>import("./RelationshipOverlay-B9bqt4zl.js"),__vite__mapDeps([8,1,2,7])).then(s=>({default:s.RelationshipOverlay}))),L=[{id:"all",label:"All Layers",layerIds:null,description:"All architecture layers in swimlane view"},{id:"software",label:"Software Views",layerIds:["functional","behavior","logical","software","interfaces","ui"],description:"Software architecture: Logical/Service, Runtime, Module/Code, Deployment"},{id:"hardware",label:"Hardware Views",layerIds:["logical","physical","interfaces"],description:"Hardware architecture: Logical, Physical/Embodiment, Compute/Electronics, Cross-domain"},{id:"risk",label:"Risk Chain",layerIds:["requirements","risk","safety","cybersecurity","verification","analysis"],description:"Risk trace chain: Hazard → HazardousSituation → Harm → RiskControlMeasure → verification"},{id:"traceability",label:"Traceability",layerIds:["purpose","business","operational","requirements","risk","safety","functional","software","software-lifecycle","verification","analysis"],description:"Full trace: clinical, risk, software, and hardware chains"},{id:"sysml-mapping",label:"SysML Mapping",layerIds:null,type:"sysml-mapping",description:"SysML v2 construct → MEMO kind reference table"}],ae=.3,oe=2.5,R=.15;function re({children:s}){const[i,r]=a.useState(1),[f,d]=a.useState({x:0,y:0}),l=a.useRef(!1),o=a.useRef({x:0,y:0}),c=a.useRef(null),m=u=>Math.max(ae,Math.min(oe,u)),p=a.useCallback(u=>{u.preventDefault();const F=u.deltaY<0?R:-R;r(C=>m(C+F))},[]),v=a.useCallback(u=>{u.target.closest("button, input, a")||(l.current=!0,o.current={x:u.clientX,y:u.clientY},u.currentTarget.setAttribute("data-panning","true"))},[]),t=a.useCallback(u=>{if(!l.current)return;const F=u.clientX-o.current.x,C=u.clientY-o.current.y;o.current={x:u.clientX,y:u.clientY},d(k=>({x:k.x+F,y:k.y+C}))},[]),x=a.useCallback(u=>{l.current=!1,u.currentTarget.removeAttribute("data-panning")},[]),h=a.useCallback(u=>{l.current=!1,u.currentTarget.removeAttribute("data-panning")},[]);function N(){r(1),d({x:0,y:0})}return e.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[e.jsxs("div",{style:{position:"absolute",top:"10px",right:"10px",zIndex:10,display:"flex",gap:"4px",background:"rgba(255,255,255,0.92)",border:"1px solid #E5E5E0",borderRadius:"8px",padding:"4px",boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},children:[e.jsx(T,{title:"Zoom in",onClick:()=>r(u=>m(u+R)),children:"+"}),e.jsxs("span",{style:{fontSize:"10px",color:"#6B7280",lineHeight:"26px",minWidth:"34px",textAlign:"center"},children:[Math.round(i*100),"%"]}),e.jsx(T,{title:"Zoom out",onClick:()=>r(u=>m(u-R)),children:"−"}),e.jsx("div",{style:{width:"1px",background:"#E5E5E0",margin:"2px 0"}}),e.jsx(T,{title:"Fit to view",onClick:N,children:"⊡"})]}),e.jsx("div",{ref:c,onWheel:p,onMouseDown:v,onMouseMove:t,onMouseUp:x,onMouseLeave:h,style:{width:"100%",height:"100%",overflow:"hidden",cursor:l.current?"grabbing":"grab",userSelect:"none"},children:e.jsx("div",{style:{transform:`translate(${f.x}px, ${f.y}px) scale(${i})`,transformOrigin:"0 0",willChange:"transform",padding:"16px"},children:s})})]})}function T({onClick:s,title:i,children:r}){return e.jsx("button",{onClick:s,title:i,style:{width:"26px",height:"26px",border:"none",borderRadius:"5px",background:"transparent",cursor:"pointer",fontSize:"14px",color:"#374151",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},onMouseEnter:f=>{f.currentTarget.style.background="#F0F0ED"},onMouseLeave:f=>{f.currentTarget.style.background="transparent"},children:r})}function ce({ontology:s,onBack:i}){const r=y(n=>n.ontologyViewMode),f=y(n=>n.setOntologyViewMode),d=y(n=>n.selectedOntologyKind),l=y(n=>n.setSelectedOntologyKind),o=y(n=>n.showOntologyRelationships),c=y(n=>n.toggleOntologyRelationships),m=y(n=>n.model),p=y(n=>n.activeView),v=y(n=>n.setActiveView),t=y(n=>n.availableOntologies),x=a.useRef(null),[h,N]=a.useState(new Set),[u,F]=a.useState("all"),[C,k]=a.useState(!1),[H,W]=a.useState(null),[Z,Y]=a.useState(0);a.useEffect(()=>{d&&(k(!0),W(d),Y(n=>n+1))},[d]);const g=a.useMemo(()=>({...s,layers:s.layers.map(n=>({...n,kinds:n.kinds.map(b=>{var M;return{...b,instanceCount:m?Object.values(m.elements).filter(A=>A.kind===b.name).length:0,viewpoints:((M=m==null?void 0:m.viewpoints)==null?void 0:M.filter(A=>A.visibleKinds.includes(b.name)).map(A=>A.id))??[]}})}))}),[s,m]),E=L.find(n=>n.id===u)??L[0],j=a.useMemo(()=>{if(!E.layerIds)return g.layers;const n=new Set(E.layerIds);return g.layers.filter(b=>n.has(b.id))},[g.layers,E.layerIds]),w=a.useMemo(()=>{if(!d)return null;for(const n of g.layers){const b=n.kinds.find(M=>M.name===d);if(b)return{kind:b,layerInfo:n}}return null},[d,g]);function q(n,b){l(b),v({type:"ontology-detail",packageName:n})}function U(n){v({type:"ontology-detail",packageName:s.name,layerId:n})}const B={background:"#1B3A4B",color:"#2DD4A8",border:"1px solid transparent"},D={background:"#F0F0ED",color:"#6B7280",border:"1px solid transparent"};return e.jsxs("div",{className:"flex flex-1 overflow-hidden",style:{background:"#F7F7F5"},children:[e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("div",{className:"px-6 pt-5 pb-3",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-3 text-xs flex-wrap",style:{color:"#9CA3AF"},children:[i&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:i,className:"hover:underline",style:{color:"#2563EB"},children:"Ontology Library"}),e.jsx("span",{children:"/"})]}),e.jsx("button",{onClick:()=>l(null),className:"hover:underline",style:{color:w?"#2563EB":"#374151",fontWeight:w?400:500},children:s.name}),w&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"/"}),e.jsx("button",{onClick:()=>U(w.layerInfo.id),className:"hover:underline",style:{color:"#2563EB"},children:w.layerInfo.label}),e.jsx("span",{children:"/"}),e.jsx("span",{style:{color:"#1a1a1a",fontWeight:600},children:d})]})]}),e.jsx(G,{ontology:g}),e.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[e.jsx("span",{className:"text-xs",style:{color:"#9CA3AF"},children:"Layers:"}),e.jsx("button",{onClick:()=>f("visual"),className:"px-2.5 py-1 text-xs rounded-md font-medium",style:r==="visual"?B:D,children:"Visual"}),e.jsx("button",{onClick:()=>f("table"),className:"px-2.5 py-1 text-xs rounded-md font-medium",style:r==="table"?B:D,children:"Table"}),e.jsx("span",{style:{width:"1px",height:"16px",background:"#E5E5E0",margin:"0 4px"}}),e.jsxs("button",{onClick:c,className:"px-2.5 py-1 text-xs rounded-md font-medium",style:o?B:D,children:[o?"Hide":"Show"," Relationships"]})]}),e.jsxs("div",{className:"flex items-center gap-0 mt-3 -mx-6 px-6",style:{borderTop:"1px solid #E5E5E0",paddingTop:"10px"},children:[e.jsx("span",{className:"text-xs mr-2",style:{color:"#9CA3AF",whiteSpace:"nowrap"},children:"View:"}),e.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:L.map(n=>{const b=u===n.id;return e.jsx("button",{onClick:()=>F(n.id),title:n.description,className:"px-2.5 py-1 text-xs rounded-md font-medium transition-all",style:b?B:D,children:n.label},n.id)})}),j.length!==g.layers.length&&E.type!=="sysml-mapping"&&e.jsxs("span",{className:"ml-auto text-xs",style:{color:"#9CA3AF",whiteSpace:"nowrap"},children:[j.length," of ",g.layers.length," layers"]})]})]}),E.type==="sysml-mapping"?e.jsx("div",{className:"px-6 py-4",children:e.jsx(ee,{layers:g.layers})}):r==="visual"?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{height:"280px",position:"relative",borderBottom:"1px solid #E5E5E0"},children:e.jsx(re,{children:e.jsxs("div",{ref:x,style:{position:"relative"},children:[e.jsx(a.Suspense,{fallback:e.jsx(z,{layers:j}),children:e.jsx(ne,{layers:j,selectedKind:d,onKindClick:l,activeLayerId:p.layerId??null,flashKindName:H,flashTick:Z})}),o&&e.jsx(a.Suspense,{fallback:null,children:e.jsx(le,{containerRef:x,ontology:{...g,layers:j},activeTypes:h})})]})})}),o&&e.jsx("div",{className:"px-6 py-4",children:e.jsx(a.Suspense,{fallback:null,children:e.jsx(K,{ontology:{...g,layers:j},activeTypes:h,onActiveTypesChange:N})})})]}):e.jsxs("div",{className:"px-6 py-4",children:[e.jsx(a.Suspense,{fallback:e.jsx(z,{layers:j}),children:e.jsx(ie,{layers:j,selectedKind:d,onKindClick:l})}),o&&e.jsx(a.Suspense,{fallback:null,children:e.jsx(K,{ontology:{...g,layers:j},activeTypes:h,onActiveTypesChange:N})})]})]}),C&&w&&e.jsx(J,{kind:w.kind,layers:g.layers,allOntologies:t,onKindClick:l,onNavigate:q,onClose:()=>{l(null),k(!1)}})]})}function z({layers:s}){return e.jsx("div",{className:"grid gap-3 mb-6",style:{gridTemplateColumns:"repeat(auto-fill, minmax(220px, 1fr))"},children:s.map(i=>{const r=_[i.id]??i.color??"#6B7280";return e.jsxs("div",{className:"rounded-xl p-4",style:{background:"#FFFFFF",border:`2px solid ${r}30`},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"w-3 h-3 rounded",style:{backgroundColor:r}}),e.jsx("span",{className:"text-sm font-medium",style:{color:"#1a1a1a"},children:i.label})]}),e.jsxs("div",{className:"text-xs",style:{color:"#9CA3AF"},children:[i.kindCount," kinds"]})]},i.id)})})}const de=a.lazy(()=>O(()=>import("./OntologyDecompositionDiagram-IG1gj1c3.js"),__vite__mapDeps([9,1,2,10,11,3,4,12]))),$=Object.fromEntries(X.map((s,i)=>[s,i]));function me(){const s=y(p=>p.activeView),i=y(p=>p.availableOntologies),r=y(p=>p.setActiveView),f=y(p=>p.model),d=s.type==="ontology-detail",l=d?s.packageName:null,o=l?i.find(p=>p.name===l):null,c=a.useMemo(()=>{if(o||!d||!f)return null;const p=new Map;for(const t of Object.values(f.elements))p.has(t.layer)||p.set(t.layer,[]),p.get(t.layer).includes(t.kind)||p.get(t.layer).push(t.kind);const v=[...p.entries()].sort(([t],[x])=>($[t]??99)-($[x]??99)).map(([t,x])=>({id:t,label:t.charAt(0).toUpperCase()+t.slice(1),color:"#6B7280",kindCount:x.length,kinds:x.map(h=>({name:h,label:h.replace(/([A-Z])/g," $1").trim(),construct:"part def",layer:t,instanceCount:0,viewpoints:[]}))}));return{name:"@memo/model (inferred)",version:"–",type:"ontology",description:"Ontology inferred from loaded model elements.",layers:v,kindCount:v.reduce((t,x)=>t+x.kindCount,0),relationshipCount:0,relationshipTypes:[],selected:!0}},[o,d,f]),m=o??c;return d&&m?e.jsx(ce,{ontology:m,onBack:()=>r({type:"ontology"})}):e.jsx(a.Suspense,{fallback:e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsx("span",{className:"text-sm",style:{color:"#9CA3AF"},children:"Loading ontology library..."})}),children:e.jsx(de,{})})}export{me as OntologyViewer,me as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./reactflow-CsCqNKB-.js";import{a as j}from"./zustand-CrhqMOHB.js";import{u as g,f as F}from"./index-C8UZrEP-.js";function z({model:n}){const i=g(t=>t.setActiveView),s=g(t=>t.setExplorerTab),l=j.useMemo(()=>Object.values(n.elements).filter(t=>["system","subsystem","logicalcomponent","softwarecomponent","physicalcomponent"].includes(t.kind.toLowerCase())).slice(0,8),[n]),a=j.useMemo(()=>{const t={};for(const o of Object.values(n.elements))t[o.layer]=(t[o.layer]||0)+1;return t},[n]),x=Object.entries(a).sort((t,o)=>o[1]-t[1]).slice(0,5),p=Object.keys(n.elements).length;return e.jsxs("div",{style:w,children:[e.jsx(k,{icon:"🏗️",title:"System Architecture",badge:`${p} elements`,onExpand:()=>{s("model")}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[e.jsxs("div",{children:[e.jsx("div",{style:E,children:"Layer distribution"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:x.map(([t,o])=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:F[t]||"#95A5A6",flexShrink:0}}),e.jsx("span",{style:{fontSize:"12px",color:"#374151",flex:1,textTransform:"capitalize"},children:t}),e.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:"#6B7280"},children:o}),e.jsx("div",{style:{width:"60px",height:"4px",background:"#F3F4F6",borderRadius:"2px"},children:e.jsx("div",{style:{height:"100%",borderRadius:"2px",background:F[t]||"#95A5A6",width:`${Math.round(o/p*100)}%`}})})]},t))})]}),e.jsxs("div",{children:[e.jsx("div",{style:E,children:"Key components"}),l.length>0?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:l.map(t=>e.jsxs("button",{onClick:()=>i({type:"element-detail",elementId:t.id}),style:{textAlign:"left",background:"none",border:"none",cursor:"pointer",padding:"3px 0",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF",fontFamily:"monospace"},children:t.kind}),e.jsx("span",{style:{fontSize:"12px",color:"#374151",fontWeight:500},children:t.name})]},t.id))}):e.jsx(C,{text:"No System or Subsystem elements yet"})]})]}),n.diagrams&&n.diagrams.length>0&&e.jsxs("div",{style:{marginTop:"12px",display:"flex",gap:"8px",flexWrap:"wrap"},children:[n.diagrams.slice(0,4).map(t=>e.jsxs("button",{onClick:()=>i({type:"diagram",diagramId:t.id}),style:q,onMouseEnter:o=>o.currentTarget.style.background="#E5E5E0",onMouseLeave:o=>o.currentTarget.style.background="#F3F4F6",children:["⊟ ",t.name]},t.id)),n.diagrams.length>4&&e.jsxs("span",{style:{fontSize:"11px",color:"#9CA3AF",alignSelf:"center"},children:["+",n.diagrams.length-4," more"]})]})]})}function R({model:n}){const i=g(t=>t.setActiveView),{reqs:s,withTestLink:l,withArchLink:a}=j.useMemo(()=>{const t=Object.values(n.elements),o=t.filter(d=>["systemrequirement","requirement","userneed"].includes(d.kind.toLowerCase())),f=new Set;for(const d of n.relationships)f.add(d.sourceId),f.add(d.targetId);const u=new Set(["test","verification","validationtest"]),y=new Set(["system","subsystem","logicalcomponent","softwarecomponent"]),c=new Set(t.filter(d=>u.has(d.kind.toLowerCase())).map(d=>d.id)),b=new Set(t.filter(d=>y.has(d.kind.toLowerCase())).map(d=>d.id));let r=0,S=0;for(const d of o){const A=n.relationships.filter(h=>h.sourceId===d.id||h.targetId===d.id).flatMap(h=>[h.sourceId,h.targetId]);A.some(h=>c.has(h))&&r++,A.some(h=>b.has(h))&&S++}return{reqs:o,withTestLink:r,withArchLink:S}},[n]),x=s.length>0?Math.round(l/s.length*100):0,p=s.length>0?Math.round(a/s.length*100):0;return e.jsxs("div",{style:w,children:[e.jsx(k,{icon:"📋",title:"Requirements",badge:`${s.length} total`,onExpand:()=>i({type:"traceability"})}),s.length===0?e.jsx(C,{text:"No requirements found. Add Requirement elements to your model."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsx(v,{label:"Verified by tests",percent:x,count:l,total:s.length,color:"#2DD4A8"}),e.jsx(v,{label:"Linked to architecture",percent:p,count:a,total:s.length,color:"#4A90D9"})]})]})}function I({model:n}){const i=g(t=>t.setActiveView),{hazards:s,riskControls:l,mitigatesCount:a,residualRiskCount:x}=j.useMemo(()=>{const t=Object.values(n.elements),o=t.filter(r=>r.kind.toLowerCase()==="hazard"),f=t.filter(r=>r.kind.toLowerCase()==="riskcontrol"),u=n.relationships.filter(r=>r.type.toLowerCase()==="mitigates"),y=u.length,c=new Set(u.map(r=>r.targetId)),b=o.filter(r=>!c.has(r.id)).length;return{hazards:o,riskControls:f,mitigatesCount:y,residualRiskCount:b}},[n]),p=s.length>0?Math.round((s.length-x)/s.length*100):0;return e.jsxs("div",{style:w,children:[e.jsx(k,{icon:"⚠️",title:"Risk Chain (ISO 14971)",badge:`${s.length} hazards`,onExpand:()=>i({type:"traceability"}),badgeColor:x>0?"#E74C3C":"#2ECC71"}),s.length===0?e.jsx(C,{text:"No hazards found. Add Hazard elements to start your ISO 14971 risk analysis."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsx(v,{label:"Hazards mitigated",percent:p,count:s.length-x,total:s.length,color:"#2ECC71",warningThreshold:80}),e.jsxs("div",{style:{display:"flex",gap:"16px"},children:[e.jsx(m,{label:"Risk controls",value:l.length}),e.jsx(m,{label:"Mitigates links",value:a}),x>0&&e.jsx(m,{label:"Unmitigated hazards",value:x,alert:!0})]})]})]})}function L({model:n}){const i=g(p=>p.setActiveView),{tests:s,passing:l,withReqLink:a}=j.useMemo(()=>{const p=Object.values(n.elements),t=p.filter(c=>c.kind.toLowerCase()==="test"),o=p.filter(c=>["systemrequirement","requirement"].includes(c.kind.toLowerCase())),f=new Set(o.map(c=>c.id));let u=0;for(const c of t)n.relationships.filter(r=>r.sourceId===c.id||r.targetId===c.id).flatMap(r=>[r.sourceId,r.targetId]).some(r=>f.has(r))&&u++;const y=t.filter(c=>(c.attributes.status||"").toLowerCase()==="pass").length;return{tests:t,passing:y,withReqLink:u}},[n]),x=s.length>0?Math.round(a/s.length*100):0;return e.jsxs("div",{style:w,children:[e.jsx(k,{icon:"🧪",title:"Verification",badge:`${s.length} tests`,onExpand:()=>i({type:"traceability"})}),s.length===0?e.jsx(C,{text:"No tests found. Add Test elements and link them to requirements."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsx(v,{label:"Tests linked to requirements",percent:x,count:a,total:s.length,color:"#2DD4A8"}),e.jsxs("div",{style:{display:"flex",gap:"16px"},children:[e.jsx(m,{label:"Tests",value:s.length}),l>0&&e.jsx(m,{label:"Passing",value:l}),s.length-l>0&&e.jsx(m,{label:"Unverified",value:s.length-l,alert:s.length-l>0&&l>0})]})]})]})}function k({icon:n,title:i,badge:s,onExpand:l,badgeColor:a}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"14px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"16px"},children:n}),e.jsx("span",{style:{fontSize:"14px",fontWeight:700,color:"#1B3A4B"},children:i}),e.jsx("span",{style:{fontSize:"11px",fontWeight:600,padding:"2px 8px",borderRadius:"999px",background:a?a+"20":"#F3F4F6",color:a||"#6B7280"},children:s})]}),e.jsx("button",{onClick:l,style:{fontSize:"11px",color:"#4A90D9",background:"none",border:"none",cursor:"pointer",fontWeight:600},children:"Expand →"})]})}function v({label:n,percent:i,count:s,total:l,color:a,warningThreshold:x=100}){const p=i>=x?a:i>=50?"#F39C12":"#E74C3C";return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"},children:[e.jsx("span",{style:{fontSize:"12px",color:"#374151"},children:n}),e.jsxs("span",{style:{fontSize:"12px",fontWeight:600,color:i>=80?"#2ECC71":"#374151"},children:[s,"/",l," (",i,"%)"]})]}),e.jsx("div",{style:{height:"6px",background:"#F3F4F6",borderRadius:"3px"},children:e.jsx("div",{style:{height:"100%",borderRadius:"3px",background:p,width:`${i}%`,transition:"width 0.4s ease"}})})]})}function m({label:n,value:i,alert:s}){return e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"baseline"},children:[e.jsx("span",{style:{fontSize:"16px",fontWeight:700,color:s?"#E74C3C":"#1B3A4B"},children:i}),e.jsx("span",{style:{fontSize:"11px",color:"#9CA3AF"},children:n})]})}function C({text:n}){return e.jsx("div",{style:{fontSize:"12px",color:"#9CA3AF",fontStyle:"italic",padding:"8px 0"},children:n})}const w={background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"20px"},E={fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"#9CA3AF",marginBottom:"8px"},q={fontSize:"11px",color:"#374151",background:"#F3F4F6",border:"1px solid #E5E5E0",borderRadius:"6px",padding:"4px 10px",cursor:"pointer",transition:"background 0.1s",fontWeight:500};function D(){const n=g(s=>s.model),i=g(s=>s.setActiveView);return n?e.jsx("div",{style:{flex:1,overflowY:"auto",background:"#F7F7F5",padding:"28px 40px"},children:e.jsxs("div",{style:{maxWidth:"960px",margin:"0 auto"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"24px"},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:"20px",fontWeight:800,color:"#1B3A4B",margin:"0 0 4px 0"},children:"Design Review Dashboard"}),e.jsx("p",{style:{fontSize:"12px",color:"#6B7280",margin:0},children:"Architecture · Requirements · Risk · Verification — in one view"})]}),e.jsx("button",{onClick:()=>i({type:"dashboard"}),style:{fontSize:"12px",color:"#6B7280",background:"#F3F4F6",border:"1px solid #E5E5E0",borderRadius:"6px",padding:"6px 12px",cursor:"pointer",fontWeight:500},children:"← Back to Dashboard"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[e.jsx(z,{model:n}),e.jsx(R,{model:n}),e.jsx(I,{model:n}),e.jsx(L,{model:n})]})]})}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"#F7F7F5"},children:e.jsx("div",{style:{fontSize:"13px",color:"#9CA3AF"},children:"No model data"})})}export{D as ReviewDashboard};
|
|
1
|
+
import{j as e}from"./reactflow-CsCqNKB-.js";import{a as j}from"./zustand-CrhqMOHB.js";import{u as g,f as F}from"./index-D0vtjNjX.js";function z({model:n}){const i=g(t=>t.setActiveView),s=g(t=>t.setExplorerTab),l=j.useMemo(()=>Object.values(n.elements).filter(t=>["system","subsystem","logicalcomponent","softwarecomponent","physicalcomponent"].includes(t.kind.toLowerCase())).slice(0,8),[n]),a=j.useMemo(()=>{const t={};for(const o of Object.values(n.elements))t[o.layer]=(t[o.layer]||0)+1;return t},[n]),x=Object.entries(a).sort((t,o)=>o[1]-t[1]).slice(0,5),p=Object.keys(n.elements).length;return e.jsxs("div",{style:w,children:[e.jsx(k,{icon:"🏗️",title:"System Architecture",badge:`${p} elements`,onExpand:()=>{s("model")}}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[e.jsxs("div",{children:[e.jsx("div",{style:E,children:"Layer distribution"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:x.map(([t,o])=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:F[t]||"#95A5A6",flexShrink:0}}),e.jsx("span",{style:{fontSize:"12px",color:"#374151",flex:1,textTransform:"capitalize"},children:t}),e.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:"#6B7280"},children:o}),e.jsx("div",{style:{width:"60px",height:"4px",background:"#F3F4F6",borderRadius:"2px"},children:e.jsx("div",{style:{height:"100%",borderRadius:"2px",background:F[t]||"#95A5A6",width:`${Math.round(o/p*100)}%`}})})]},t))})]}),e.jsxs("div",{children:[e.jsx("div",{style:E,children:"Key components"}),l.length>0?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:l.map(t=>e.jsxs("button",{onClick:()=>i({type:"element-detail",elementId:t.id}),style:{textAlign:"left",background:"none",border:"none",cursor:"pointer",padding:"3px 0",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF",fontFamily:"monospace"},children:t.kind}),e.jsx("span",{style:{fontSize:"12px",color:"#374151",fontWeight:500},children:t.name})]},t.id))}):e.jsx(C,{text:"No System or Subsystem elements yet"})]})]}),n.diagrams&&n.diagrams.length>0&&e.jsxs("div",{style:{marginTop:"12px",display:"flex",gap:"8px",flexWrap:"wrap"},children:[n.diagrams.slice(0,4).map(t=>e.jsxs("button",{onClick:()=>i({type:"diagram",diagramId:t.id}),style:q,onMouseEnter:o=>o.currentTarget.style.background="#E5E5E0",onMouseLeave:o=>o.currentTarget.style.background="#F3F4F6",children:["⊟ ",t.name]},t.id)),n.diagrams.length>4&&e.jsxs("span",{style:{fontSize:"11px",color:"#9CA3AF",alignSelf:"center"},children:["+",n.diagrams.length-4," more"]})]})]})}function R({model:n}){const i=g(t=>t.setActiveView),{reqs:s,withTestLink:l,withArchLink:a}=j.useMemo(()=>{const t=Object.values(n.elements),o=t.filter(d=>["systemrequirement","requirement","userneed"].includes(d.kind.toLowerCase())),f=new Set;for(const d of n.relationships)f.add(d.sourceId),f.add(d.targetId);const u=new Set(["test","verification","validationtest"]),y=new Set(["system","subsystem","logicalcomponent","softwarecomponent"]),c=new Set(t.filter(d=>u.has(d.kind.toLowerCase())).map(d=>d.id)),b=new Set(t.filter(d=>y.has(d.kind.toLowerCase())).map(d=>d.id));let r=0,S=0;for(const d of o){const A=n.relationships.filter(h=>h.sourceId===d.id||h.targetId===d.id).flatMap(h=>[h.sourceId,h.targetId]);A.some(h=>c.has(h))&&r++,A.some(h=>b.has(h))&&S++}return{reqs:o,withTestLink:r,withArchLink:S}},[n]),x=s.length>0?Math.round(l/s.length*100):0,p=s.length>0?Math.round(a/s.length*100):0;return e.jsxs("div",{style:w,children:[e.jsx(k,{icon:"📋",title:"Requirements",badge:`${s.length} total`,onExpand:()=>i({type:"traceability"})}),s.length===0?e.jsx(C,{text:"No requirements found. Add Requirement elements to your model."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsx(v,{label:"Verified by tests",percent:x,count:l,total:s.length,color:"#2DD4A8"}),e.jsx(v,{label:"Linked to architecture",percent:p,count:a,total:s.length,color:"#4A90D9"})]})]})}function I({model:n}){const i=g(t=>t.setActiveView),{hazards:s,riskControls:l,mitigatesCount:a,residualRiskCount:x}=j.useMemo(()=>{const t=Object.values(n.elements),o=t.filter(r=>r.kind.toLowerCase()==="hazard"),f=t.filter(r=>r.kind.toLowerCase()==="riskcontrol"),u=n.relationships.filter(r=>r.type.toLowerCase()==="mitigates"),y=u.length,c=new Set(u.map(r=>r.targetId)),b=o.filter(r=>!c.has(r.id)).length;return{hazards:o,riskControls:f,mitigatesCount:y,residualRiskCount:b}},[n]),p=s.length>0?Math.round((s.length-x)/s.length*100):0;return e.jsxs("div",{style:w,children:[e.jsx(k,{icon:"⚠️",title:"Risk Chain (ISO 14971)",badge:`${s.length} hazards`,onExpand:()=>i({type:"traceability"}),badgeColor:x>0?"#E74C3C":"#2ECC71"}),s.length===0?e.jsx(C,{text:"No hazards found. Add Hazard elements to start your ISO 14971 risk analysis."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsx(v,{label:"Hazards mitigated",percent:p,count:s.length-x,total:s.length,color:"#2ECC71",warningThreshold:80}),e.jsxs("div",{style:{display:"flex",gap:"16px"},children:[e.jsx(m,{label:"Risk controls",value:l.length}),e.jsx(m,{label:"Mitigates links",value:a}),x>0&&e.jsx(m,{label:"Unmitigated hazards",value:x,alert:!0})]})]})]})}function L({model:n}){const i=g(p=>p.setActiveView),{tests:s,passing:l,withReqLink:a}=j.useMemo(()=>{const p=Object.values(n.elements),t=p.filter(c=>c.kind.toLowerCase()==="test"),o=p.filter(c=>["systemrequirement","requirement"].includes(c.kind.toLowerCase())),f=new Set(o.map(c=>c.id));let u=0;for(const c of t)n.relationships.filter(r=>r.sourceId===c.id||r.targetId===c.id).flatMap(r=>[r.sourceId,r.targetId]).some(r=>f.has(r))&&u++;const y=t.filter(c=>(c.attributes.status||"").toLowerCase()==="pass").length;return{tests:t,passing:y,withReqLink:u}},[n]),x=s.length>0?Math.round(a/s.length*100):0;return e.jsxs("div",{style:w,children:[e.jsx(k,{icon:"🧪",title:"Verification",badge:`${s.length} tests`,onExpand:()=>i({type:"traceability"})}),s.length===0?e.jsx(C,{text:"No tests found. Add Test elements and link them to requirements."}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:[e.jsx(v,{label:"Tests linked to requirements",percent:x,count:a,total:s.length,color:"#2DD4A8"}),e.jsxs("div",{style:{display:"flex",gap:"16px"},children:[e.jsx(m,{label:"Tests",value:s.length}),l>0&&e.jsx(m,{label:"Passing",value:l}),s.length-l>0&&e.jsx(m,{label:"Unverified",value:s.length-l,alert:s.length-l>0&&l>0})]})]})]})}function k({icon:n,title:i,badge:s,onExpand:l,badgeColor:a}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"14px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"16px"},children:n}),e.jsx("span",{style:{fontSize:"14px",fontWeight:700,color:"#1B3A4B"},children:i}),e.jsx("span",{style:{fontSize:"11px",fontWeight:600,padding:"2px 8px",borderRadius:"999px",background:a?a+"20":"#F3F4F6",color:a||"#6B7280"},children:s})]}),e.jsx("button",{onClick:l,style:{fontSize:"11px",color:"#4A90D9",background:"none",border:"none",cursor:"pointer",fontWeight:600},children:"Expand →"})]})}function v({label:n,percent:i,count:s,total:l,color:a,warningThreshold:x=100}){const p=i>=x?a:i>=50?"#F39C12":"#E74C3C";return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"},children:[e.jsx("span",{style:{fontSize:"12px",color:"#374151"},children:n}),e.jsxs("span",{style:{fontSize:"12px",fontWeight:600,color:i>=80?"#2ECC71":"#374151"},children:[s,"/",l," (",i,"%)"]})]}),e.jsx("div",{style:{height:"6px",background:"#F3F4F6",borderRadius:"3px"},children:e.jsx("div",{style:{height:"100%",borderRadius:"3px",background:p,width:`${i}%`,transition:"width 0.4s ease"}})})]})}function m({label:n,value:i,alert:s}){return e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"baseline"},children:[e.jsx("span",{style:{fontSize:"16px",fontWeight:700,color:s?"#E74C3C":"#1B3A4B"},children:i}),e.jsx("span",{style:{fontSize:"11px",color:"#9CA3AF"},children:n})]})}function C({text:n}){return e.jsx("div",{style:{fontSize:"12px",color:"#9CA3AF",fontStyle:"italic",padding:"8px 0"},children:n})}const w={background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"20px"},E={fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"#9CA3AF",marginBottom:"8px"},q={fontSize:"11px",color:"#374151",background:"#F3F4F6",border:"1px solid #E5E5E0",borderRadius:"6px",padding:"4px 10px",cursor:"pointer",transition:"background 0.1s",fontWeight:500};function D(){const n=g(s=>s.model),i=g(s=>s.setActiveView);return n?e.jsx("div",{style:{flex:1,overflowY:"auto",background:"#F7F7F5",padding:"28px 40px"},children:e.jsxs("div",{style:{maxWidth:"960px",margin:"0 auto"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"24px"},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:"20px",fontWeight:800,color:"#1B3A4B",margin:"0 0 4px 0"},children:"Design Review Dashboard"}),e.jsx("p",{style:{fontSize:"12px",color:"#6B7280",margin:0},children:"Architecture · Requirements · Risk · Verification — in one view"})]}),e.jsx("button",{onClick:()=>i({type:"dashboard"}),style:{fontSize:"12px",color:"#6B7280",background:"#F3F4F6",border:"1px solid #E5E5E0",borderRadius:"6px",padding:"6px 12px",cursor:"pointer",fontWeight:500},children:"← Back to Dashboard"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[e.jsx(z,{model:n}),e.jsx(R,{model:n}),e.jsx(I,{model:n}),e.jsx(L,{model:n})]})]})}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"#F7F7F5"},children:e.jsx("div",{style:{fontSize:"13px",color:"#9CA3AF"},children:"No model data"})})}export{D as ReviewDashboard};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{j as e}from"./reactflow-CsCqNKB-.js";import{a as p}from"./zustand-CrhqMOHB.js";import{u as E,h as xe,i as fe,f as R}from"./index-D0vtjNjX.js";const he=[{label:"Activity diagram",types:new Set(["act"])},{label:"Operative flow",types:new Set(["afd","ofd"])},{label:"Function flow",types:new Set(["ffd"])},{label:"Sequence diagram",types:new Set(["seq"])}];function ye(r){return he.map(v=>{const m=r.filter(b=>v.types.has(b.diagramType.toLowerCase()));return{label:v.label,items:m}}).filter(v=>v.items.length>0)}function Z(r){return r?r.split(`
|
|
2
|
+
`).filter(m=>m.trim()).map((m,b)=>{const I=m.match(/^\d+\.\s*(.*)/);return{index:b,text:I?I[1]:m}}):[]}function ge(r){return r.map((v,m)=>`${m+1}. ${v.text}`).join(`
|
|
3
|
+
`)}function ke(){const r=E(s=>s.model),v=E(s=>s.createRelationship),m=E(s=>s.inspectElement),b=E(s=>s.selectedElementId),I=E(s=>s.setActiveMode),ee=E(s=>s.setActiveView),[N,se]=p.useState(""),[c,y]=p.useState(null),[B,q]=p.useState(""),[T,K]=p.useState(null),[D,P]=p.useState(""),z=p.useMemo(()=>{if(!r)return[];const s=Object.values(r.elements),n=r.elements,l=(...t)=>{const i=new Set(t.map(u=>u.toLowerCase()));return r.relationships.filter(u=>i.has(u.type.toLowerCase()))},x=(t,i)=>{var u;return typeof t=="string"&&((u=t.split("::").at(-1))==null?void 0:u.trim())===i},j=s.filter(t=>t.kind.endsWith("UseCase")),w=new Set(j.map(t=>t.id)),f=new Map,S=new Set;for(const t of l("Includes")){if(!w.has(t.sourceId)||!w.has(t.targetId))continue;const i=f.get(t.sourceId)??[];i.push(t.targetId),f.set(t.sourceId,i),S.add(t.targetId)}const C=new Map,L=[],A=(t,i)=>{if(!C.has(t)){C.set(t,i),L.push(t);for(const u of f.get(t)??[])A(u,i+1)}};for(const t of j)S.has(t.id)||A(t.id,0);for(const t of j)A(t.id,0);const U=L.map(t=>n[t]).filter(t=>!!t),k=t=>!N||t.name.toLowerCase().includes(N.toLowerCase())||t.kind.toLowerCase().includes(N.toLowerCase());return U.map(t=>{var J;const i=l("Supports","supportsUseCase").filter(a=>a.targetId===t.id).map(a=>n[a.sourceId]).filter(a=>!!a&&a.kind==="OperationalWorkflow"),u=s.filter(a=>a.kind.endsWith("Scenario")).filter(a=>x(a.attributes.parentUseCase,t.id)||l("Realizes","scenarioRealizesUseCase").some(F=>F.sourceId===a.id&&F.targetId===t.id)),W=u.map(a=>s.find(F=>x(a.attributes.parentWorkflow,F.id))).filter(a=>!!a),O=[...new Map([...i,...W].map(a=>[a.id,a])).values()],G=u.map(a=>{const F=l("Composes","scenarioComprisesActivity").filter(o=>o.sourceId===a.id).map(o=>n[o.targetId]).filter(o=>!!o),de=String(a.attributes.activities??"").split(",").map(o=>{var h;return(h=o.split("::").at(-1))==null?void 0:h.trim()}).map(o=>o?n[o]:void 0).filter(o=>!!o),Q=[...new Map([...F,...de].map(o=>[o.id,o])).values()],X=l("Realizes","functionalRealizesOperative").filter(o=>o.targetId===a.id).map(o=>n[o.sourceId]).filter(o=>!!o&&o.layer==="functional"),ue=X.flatMap(o=>l("Realizes","uIRealizesFunctional").filter(h=>h.targetId===o.id).map(h=>n[h.sourceId]).filter(h=>!!h&&h.layer==="usability")),M=new Set([a.id,...Q.map(o=>o.id)]);let _=!0;for(;_;){_=!1;for(const o of s)o.parentAction&&M.has(o.parentAction)&&!M.has(o.id)&&(M.add(o.id),_=!0)}const pe=(r.diagrams??[]).filter(o=>{var h;return((h=o.elementIds)==null?void 0:h.some(me=>M.has(me)))||o.name.toLowerCase().includes(a.name.toLowerCase())});return{scenario:a,activities:Q,functionalScenarios:X,uiScenarios:ue,views:pe}}),V=O.map(a=>({workflow:a,scenarios:G.filter(({scenario:F})=>x(F.attributes.parentWorkflow,a.id))}));return{useCase:t,workflows:V,depth:C.get(t.id)??0,hasChildren:(((J=f.get(t.id))==null?void 0:J.length)??0)>0}}).filter(t=>k(t.useCase)||t.workflows.some(({workflow:i,scenarios:u})=>k(i)||u.some(({scenario:W,activities:O,functionalScenarios:G,uiScenarios:V})=>k(W)||O.some(k)||G.some(k)||V.some(k))))},[r,N]),d=b&&r?r.elements[b]:null,$=p.useMemo(()=>xe(r,b||""),[r,b]),g=p.useMemo(()=>c||(d?Z(d.doc||""):[]),[d,c]),te=p.useCallback(()=>{d&&y(Z(d.doc||""))},[d]),le=p.useCallback(()=>{if(!d||!c)return;const s=ge(c);fe({...d,doc:s}),y(null)},[d,c]),H=p.useCallback(()=>{if(!B.trim())return;const s=[...c||g,{index:g.length,text:B.trim()}];y(s),q("")},[B,c,g]),ne=p.useCallback(s=>{const n=(c||g).filter((l,x)=>x!==s);y(n)},[c,g]),Y=p.useCallback((s,n)=>{const l=[...c||g],x=s+n;x<0||x>=l.length||([l[s],l[x]]=[l[x],l[s]],y(l))},[c,g]),oe=p.useCallback((s,n)=>{const l=[...c||g];l[s]={...l[s],text:n},y(l)},[c,g]),ae=p.useMemo(()=>{if(!r||!D)return[];const s=D.toLowerCase();return Object.values(r.elements).filter(n=>n.id!==b&&n.name.toLowerCase().includes(s)).slice(0,10)},[r,D,b]),[re,ce]=p.useState(new Set),ie=s=>{ce(n=>{const l=new Set(n);return l.has(s)?l.delete(s):l.add(s),l})};return e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsxs("div",{className:"w-72 flex flex-col overflow-hidden",style:{background:"#FFFFFF",borderRight:"1px solid #E5E5E0"},children:[e.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("div",{style:{color:"#1B3A4B",fontSize:"12px",fontWeight:700,marginBottom:7},children:"Use-Case Hierarchy"}),e.jsx("input",{type:"text",placeholder:"Search "+z.length+" use cases...",value:N,onChange:s=>se(s.target.value),className:"w-full px-3 py-2 text-sm rounded-lg focus:outline-none",style:{background:"#F7F7F5",border:"1px solid #E5E5E0",color:"#1a1a1a"}})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto text-xs py-1",children:[z.map(({useCase:s,workflows:n,depth:l,hasChildren:x})=>{const j="use-case:"+s.id,w=re.has(j);return e.jsxs("div",{className:"mb-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 cursor-pointer",style:{borderRadius:"6px",margin:"0 4px",marginLeft:4+l*14},onMouseEnter:f=>f.currentTarget.style.background="#F0F0ED",onMouseLeave:f=>f.currentTarget.style.background="transparent",onClick:()=>{m(s.id),y(null),ie(j)},children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded flex-shrink-0",style:{backgroundColor:R.functional,borderRadius:"3px"}}),e.jsx("span",{className:"font-medium flex-1",style:{color:"#374151"},children:s.name}),e.jsx("span",{style:{color:"#9CA3AF"},children:x?"Parent use case":"Leaf use case"}),e.jsx("span",{style:{color:"#D1D5DB"},children:w?"▸":"▾"})]}),!w&&e.jsx("div",{className:"ml-5 border-l pl-2",style:{borderColor:"#E5E5E0"},children:n.map(({workflow:f,scenarios:S})=>e.jsxs("div",{className:"mb-1",children:[e.jsx("button",{onClick:()=>{m(f.id),y(null)},className:"block w-full px-2 py-1 text-left truncate rounded",style:{color:"#374151",fontWeight:600},children:f.name}),e.jsxs("div",{className:"ml-3 border-l pl-2",style:{borderColor:"#D8E2E9"},children:[S.map(({scenario:C,activities:L,functionalScenarios:A,uiScenarios:U,views:k})=>e.jsxs("div",{className:"mb-1",children:[e.jsx("button",{onClick:()=>{m(C.id),y(null)},className:"block w-full px-2 py-1 text-left truncate rounded",style:{color:"#1B3A4B",fontWeight:500},children:C.name}),e.jsxs("div",{className:"ml-3 border-l pl-2",style:{borderColor:"#E5E5E0"},children:[[["Activity diagram",L],["Function flow",A],["Interaction sequence",U]].filter(([,t])=>t.length>0).map(([t,i])=>e.jsxs("div",{children:[e.jsx("div",{className:"pt-1",style:{color:"#6B7280",fontSize:"10px"},children:t}),i.map(u=>e.jsx("button",{onClick:()=>{m(u.id),y(null)},className:"block w-full px-1 py-0.5 text-left truncate rounded",style:{color:"#4B5563"},children:u.name},u.id))]},t)),ye(k).map(t=>e.jsxs("div",{children:[e.jsx("div",{className:"pt-1",style:{color:"#6B7280",fontSize:"10px"},children:t.label}),t.items.map(i=>e.jsx("button",{onClick:()=>{I("diagram"),ee({type:"diagram",diagramId:i.id})},className:"block w-full px-1 py-0.5 text-left truncate rounded",style:{color:"#2563EB"},children:i.name},i.id))]},t.label))]})]},C.id)),S.length===0&&e.jsx("div",{className:"px-2 py-1",style:{color:"#9CA3AF",fontSize:"10px"},children:"No scenarios"})]})]},f.id))})]},s.id)}),z.length===0&&e.jsx("div",{className:"px-4 py-8 text-center",style:{color:"#9CA3AF"},children:"No use-case scenario chains found."})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",style:{background:"#F7F7F5"},children:[!d&&e.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"#9CA3AF"},children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"8px",opacity:.5},children:"▶"}),e.jsx("div",{className:"text-sm",children:"Select a scenario to edit steps and link elements"})]})}),d&&e.jsxs("div",{className:"max-w-2xl",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold",style:{color:"#1a1a1a"},children:d.name}),e.jsx("span",{className:"px-2 py-0.5 text-xs rounded-md font-medium",style:{background:"#E67E2218",color:"#E67E22"},children:d.kind})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"#6B7280"},children:"Steps"}),!c&&e.jsx("button",{onClick:te,className:"px-2 py-0.5 text-xs rounded",style:{background:"#2DD4A815",color:"#1B3A4B",border:"1px solid #2DD4A840"},children:"Edit"}),c&&e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:le,className:"px-2 py-0.5 text-xs rounded font-medium",style:{background:"#2DD4A8",color:"#FFFFFF"},children:"Save"}),e.jsx("button",{onClick:()=>y(null),className:"px-2 py-0.5 text-xs rounded",style:{background:"#F3F4F6",color:"#6B7280"},children:"Cancel"})]})]}),e.jsx("div",{className:"space-y-1",children:g.map((s,n)=>e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("span",{className:"flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium",style:{background:"#2DD4A815",color:"#1B3A4B"},children:n+1}),c?e.jsx("input",{type:"text",value:s.text,onChange:l=>oe(n,l.target.value),className:"flex-1 text-sm px-2 py-1 rounded focus:outline-none",style:{border:"1px solid #E5E5E0",color:"#374151"}}):e.jsx("span",{className:"flex-1 text-sm",style:{color:"#374151"},children:s.text}),c&&e.jsxs("div",{className:"flex gap-0.5",children:[e.jsx("button",{onClick:()=>Y(n,-1),className:"px-1 text-xs",style:{color:"#9CA3AF"},title:"Move up",children:"▲"}),e.jsx("button",{onClick:()=>Y(n,1),className:"px-1 text-xs",style:{color:"#9CA3AF"},title:"Move down",children:"▼"}),e.jsx("button",{onClick:()=>ne(n),className:"px-1 text-xs",style:{color:"#E74C3C"},title:"Remove",children:"✕"})]})]},n))}),c&&e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("input",{type:"text",value:B,onChange:s=>q(s.target.value),onKeyDown:s=>s.key==="Enter"&&H(),placeholder:"Add a step...",className:"flex-1 text-sm px-3 py-2 rounded-lg focus:outline-none",style:{background:"#FFFFFF",border:"1px solid #E5E5E0",color:"#374151"}}),e.jsx("button",{onClick:H,className:"px-3 py-2 text-xs rounded-lg font-medium",style:{background:"#2DD4A815",color:"#1B3A4B",border:"1px solid #2DD4A840"},children:"+ Add"})]}),g.length===0&&!c&&e.jsx("div",{className:"text-xs p-3 rounded-lg",style:{background:"#F3F4F6",color:"#9CA3AF"},children:"No steps defined. Click Edit to add scenario steps."})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"#6B7280"},children:["Linked Elements (",$.length,")"]}),e.jsx("button",{onClick:()=>K(T===null?0:null),className:"px-2 py-0.5 text-xs rounded",style:{background:"#4A90D915",color:"#4A90D9",border:"1px solid #4A90D940"},children:T!==null?"Done":"+ Link"})]}),T!==null&&e.jsxs("div",{className:"mb-2 p-2 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #4A90D940"},children:[e.jsx("input",{type:"text",value:D,onChange:s=>P(s.target.value),placeholder:"Search elements to link...",className:"w-full text-sm px-2 py-1 rounded focus:outline-none mb-1",style:{border:"1px solid #E5E5E0",color:"#374151"}}),ae.map(s=>e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 text-xs rounded cursor-pointer",onMouseEnter:n=>n.currentTarget.style.background="#F0F0ED",onMouseLeave:n=>n.currentTarget.style.background="transparent",onClick:()=>{v({type:"traceTo",sourceId:d.id,targetId:s.id,direction:"outgoing",selectedElementId:d.id}),P(""),K(null)},children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:R[s.layer]||"#95A5A6"}}),e.jsx("span",{style:{color:"#374151"},children:s.name}),e.jsx("span",{style:{color:"#9CA3AF"},children:s.kind})]},s.id))]}),e.jsx("div",{className:"space-y-1",children:$.map(s=>{const n=s.sourceId===d.id?s.targetId:s.sourceId,l=r.elements[n],x=s.sourceId===d.id?"→":"←";return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded-lg cursor-pointer",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},onMouseEnter:j=>j.currentTarget.style.background="#F0F0ED",onMouseLeave:j=>j.currentTarget.style.background="#FFFFFF",onClick:()=>m(n),children:[e.jsx("span",{style:{color:"#9CA3AF"},children:x}),e.jsx("span",{className:"font-medium",style:{color:"#2563EB"},children:s.type}),e.jsx("span",{style:{color:"#374151"},children:(l==null?void 0:l.name)||n}),l&&e.jsx("span",{className:"ml-auto px-1.5 py-0.5 rounded text-xs",style:{background:(R[l.layer]||"#95A5A6")+"18",color:R[l.layer]||"#95A5A6"},children:l.kind})]},s.id)})})]}),e.jsx("div",{className:"text-xs",style:{color:"#D1D5DB"},children:d.file})]})]})]})}export{ke as ScenarioEditor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./reactflow-CsCqNKB-.js";import{a as A}from"./zustand-CrhqMOHB.js";import{u as f,L as y,f as u,e as b}from"./index-
|
|
1
|
+
import{j as e}from"./reactflow-CsCqNKB-.js";import{a as A}from"./zustand-CrhqMOHB.js";import{u as f,L as y,f as u,e as b}from"./index-D0vtjNjX.js";function w(a){var F;const c=Object.values(a.elements),n=c.length,t=a.relationships.length,i=((F=a.diagrams)==null?void 0:F.length)??0,d=new Map;for(const s of c){const o=d.get(s.layer)||{count:0,kinds:new Map};o.count++,o.kinds.set(s.kind,(o.kinds.get(s.kind)||0)+1),d.set(s.layer,o)}const m=y.filter(s=>d.has(s)).map(s=>({layer:s,label:b[s]||s,color:u[s]||"#95A5A6",count:d.get(s).count,kinds:d.get(s).kinds}));for(const[s,o]of d)y.includes(s)||m.push({layer:s,label:b[s]||s,color:u[s]||"#95A5A6",count:o.count,kinds:o.kinds});const l=new Map;for(const s of c){const o=l.get(s.kind)||{count:0,layer:s.layer};o.count++,l.set(s.kind,o)}const r=[...l.entries()].map(([s,{count:o,layer:C}])=>({kind:s,count:o,layer:C})).sort((s,o)=>o.count-s.count).slice(0,15),x=new Map;for(const s of a.relationships)x.set(s.type,(x.get(s.type)||0)+1);const j=[...x.entries()].map(([s,o])=>({type:s,count:o})).sort((s,o)=>o.count-s.count),p=new Set;for(const s of a.relationships)p.add(s.sourceId),p.add(s.targetId);const N=c.filter(s=>!p.has(s.id)).length;Math.max(...m.map(s=>s.count),1);const v=m.map(s=>({layer:s.layer,label:s.label,color:s.color,percent:Math.round(s.count/n*100)})),E=n>0?t/n:0,k=n>0?t/n:0;return{totalElements:n,totalRelationships:t,totalDiagrams:i,layers:m,topKinds:r,relTypes:j,avgRelsPerElement:Math.round(k*10)/10,orphanCount:N,coverage:v,density:Math.round(E*100)/100}}function B(){var d,m;const a=f(l=>l.model),c=f(l=>l.validation),n=f(l=>l.completeness),t=A.useMemo(()=>a?w(a):null,[a]);if(!t)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5",color:"#9CA3AF"},children:e.jsx("div",{className:"text-sm",children:"No model data"})});const i=((d=c==null?void 0:c.violations)==null?void 0:d.length)??0;return e.jsx("div",{className:"flex-1 overflow-y-auto p-6",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"max-w-5xl mx-auto",children:[e.jsx("h2",{className:"text-lg font-semibold mb-1",style:{color:"#374151"},children:"Model Statistics"}),e.jsx("p",{className:"text-xs mb-6",style:{color:"#9CA3AF"},children:"Quick health check for your model"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-6",children:[e.jsx(h,{label:"Elements",value:t.totalElements,color:"#1B3A4B"}),e.jsx(h,{label:"Relationships",value:t.totalRelationships,color:"#4A90D9"}),e.jsx(h,{label:"Diagrams",value:t.totalDiagrams,color:"#7B68EE"}),e.jsx(h,{label:"Violations",value:i,color:i>0?"#E74C3C":"#2ECC71"})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-6",children:[e.jsx(g,{label:"Rel. Density",value:`${t.avgRelsPerElement}`,unit:"per element",status:t.avgRelsPerElement>=1.5?"good":t.avgRelsPerElement>=.5?"ok":"low"}),e.jsx(g,{label:"Orphans",value:`${t.orphanCount}`,unit:"unlinked",status:t.orphanCount===0?"good":t.orphanCount<=5?"ok":"low"}),e.jsx(g,{label:"Layers Used",value:`${t.layers.length}`,unit:`of ${y.length}`,status:t.layers.length>=6?"good":t.layers.length>=3?"ok":"low"}),e.jsx(g,{label:"Kinds Used",value:`${t.topKinds.length}`,unit:"types",status:t.topKinds.length>=8?"good":t.topKinds.length>=4?"ok":"low"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"#6B7280"},children:"Elements by Layer"}),e.jsx("div",{className:"space-y-2",children:t.layers.map((l,r)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-20 text-xs truncate",style:{color:"#374151"},children:l.label}),e.jsx("div",{className:"flex-1 h-4 rounded-full overflow-hidden",style:{background:"#F3F4F6"},children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Math.max(l.count/t.totalElements*100,2)}%`,background:l.color,opacity:.8}})}),e.jsx("span",{className:"w-8 text-right text-xs font-medium",style:{color:"#374151"},children:l.count})]},`${l.layer}-${r}`))})]}),e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"#6B7280"},children:"Layer Coverage"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:y.map(l=>{const r=t.coverage.find(p=>p.layer===l),x=(r==null?void 0:r.percent)??0,j=x>0?Math.max(.15,x/100):.05;return e.jsxs("div",{className:"p-2 rounded-lg text-center",style:{background:`${u[l]||"#95A5A6"}${Math.round(j*255).toString(16).padStart(2,"0")}`,border:`1px solid ${u[l]||"#95A5A6"}30`},children:[e.jsx("div",{className:"text-xs font-medium truncate",style:{color:"#374151"},children:b[l]||l}),e.jsxs("div",{className:"text-lg font-bold",style:{color:u[l]||"#95A5A6"},children:[x,"%"]})]},l)})})]}),e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"#6B7280"},children:"Top Element Types"}),e.jsx("div",{className:"space-y-1",children:t.topKinds.map((l,r)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:u[l.layer]||"#95A5A6"}}),e.jsx("span",{className:"flex-1 truncate",style:{color:"#374151"},children:l.kind}),e.jsx("span",{className:"font-medium",style:{color:"#6B7280"},children:l.count})]},`${l.kind}-${r}`))})]}),e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"#6B7280"},children:"Relationship Types"}),e.jsxs("div",{className:"space-y-1",children:[t.relTypes.map((l,r)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:"#4A90D9"}}),e.jsx("span",{className:"flex-1 truncate",style:{color:"#374151"},children:l.type}),e.jsx("span",{className:"font-medium",style:{color:"#6B7280"},children:l.count})]},`${l.type}-${r}`)),t.relTypes.length===0&&e.jsx("div",{className:"text-xs",style:{color:"#9CA3AF"},children:"No relationships"})]})]})]}),n&&e.jsxs("div",{className:"mt-4 p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-3",style:{color:"#6B7280"},children:"Completeness by Layer"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:(m=n.layers)==null?void 0:m.map((l,r)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:u[l.layer]||"#95A5A6"}}),e.jsx("span",{className:"flex-1 truncate",style:{color:"#374151"},children:l.layer}),e.jsxs("span",{className:"font-medium",style:{color:l.completeness>=80?"#2ECC71":l.completeness>=50?"#F39C12":"#E74C3C"},children:[Math.round(l.completeness),"%"]})]},`${l.layer}-${r}`))})]})]})})}function h({label:a,value:c,color:n}){return e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("div",{className:"text-2xl font-bold",style:{color:n},children:c.toLocaleString()}),e.jsx("div",{className:"text-xs mt-0.5",style:{color:"#9CA3AF"},children:a})]})}function g({label:a,value:c,unit:n,status:t}){const i=t==="good"?"#2ECC71":t==="ok"?"#F39C12":"#E74C3C";return e.jsxs("div",{className:"p-4 rounded-lg",style:{background:"#FFFFFF",border:`1px solid ${i}30`},children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{className:"text-lg font-bold",style:{color:i},children:c}),e.jsx("span",{className:"text-xs",style:{color:"#9CA3AF"},children:n})]}),e.jsx("div",{className:"text-xs mt-0.5",style:{color:"#6B7280"},children:a})]})}export{B as StatisticsDashboard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t}from"./reactflow-CsCqNKB-.js";import{a as u}from"./zustand-CrhqMOHB.js";import{u as w,F as j,e as D,f as T}from"./index-
|
|
1
|
+
import{j as t}from"./reactflow-CsCqNKB-.js";import{a as u}from"./zustand-CrhqMOHB.js";import{u as w,F as j,e as D,f as T}from"./index-D0vtjNjX.js";function R({element:r}){var f;const i=!!((f=r.doc)!=null&&f.trim()),d=Object.keys(r.attributes).length,S=i&&d>=1,v=i||d>=1,p=S?"#2DD4A8":v?"#F39C12":"#E5E5E0",A=S?"Complete":v?"Partial":"Empty";return t.jsx("span",{className:"inline-block rounded-full flex-shrink-0",style:{width:8,height:8,backgroundColor:p,cursor:"default"},title:A})}function Y({col:r,sortKey:i,sortDir:d}){return r!==i?t.jsx("span",{style:{color:"#D1D5DB",fontSize:"10px",marginLeft:3},children:"⇅"}):t.jsx("span",{style:{color:"#1B3A4B",fontSize:"10px",marginLeft:3},children:d==="asc"?"↑":"↓"})}function P(){const r=w(e=>e.model),i=w(e=>e.activeView),d=w(e=>e.selectedViewpointId),S=w(e=>e.selectElement),v=w(e=>e.selectedElementId),[p,A]=u.useState("name"),[f,C]=u.useState("asc"),[E,B]=u.useState(""),[g,I]=u.useState(""),[b,M]=u.useState(""),h=u.useMemo(()=>{var o,s,n,c,l;if(!r)return[];const e=Object.values(r.elements);if(i.type==="tabular"&&i.diagramId){const a=(o=r.diagrams)==null?void 0:o.find(x=>x.id===i.diagramId);if((s=a==null?void 0:a.elementIds)!=null&&s.length){const x=new Set(a.elementIds);return e.filter(m=>x.has(m.id))}}if(d){const a=(n=r.viewpoints)==null?void 0:n.find(x=>x.id===d);if(a){const x=(c=a.visibleLayers)!=null&&c.length?new Set(a.visibleLayers):null,m=(l=a.visibleKinds)!=null&&l.length?new Set(a.visibleKinds):null;return e.filter(F=>(!x||x.has(F.layer))&&(!m||m.has(F.kind)))}}return e},[r,i,d]),k=u.useMemo(()=>{const e=new Map;for(const s of h)for(const n of Object.keys(s.attributes))e.set(n,(e.get(n)??0)+1);const o=Math.max(1,h.length*.1);return[...e.entries()].filter(([,s])=>s>=o).sort((s,n)=>n[1]-s[1]).slice(0,4).map(([s])=>s)},[h]),O=u.useMemo(()=>[...new Set(h.map(e=>e.layer))].sort(),[h]),V=u.useMemo(()=>[...new Set(h.map(e=>e.kind))].sort(),[h]),N=u.useMemo(()=>{const e=E.toLowerCase();let o=h.filter(s=>!(e&&!s.name.toLowerCase().includes(e)&&!s.kind.toLowerCase().includes(e)||g&&s.layer!==g||b&&s.kind!==b));return o.sort((s,n)=>{let c="",l="";if(p==="name")c=s.name,l=n.name;else if(p==="kind")c=s.kind,l=n.kind;else if(p==="layer")c=s.layer,l=n.layer;else if(p==="status"){const x=m=>{var L;const F=!!((L=m.doc)!=null&&L.trim()),z=Object.keys(m.attributes).length>=1;return F&&z?2:F||z?1:0};c=String(x(s)),l=String(x(n))}else c=s.attributes[p]??"",l=n.attributes[p]??"";const a=c.localeCompare(l,void 0,{numeric:!0});return f==="asc"?a:-a}),o},[h,E,g,b,p,f]);function K(e){p===e?C(o=>o==="asc"?"desc":"asc"):(A(e),C("asc"))}const W=u.useMemo(()=>{var e,o;if(!r)return"";if(i.type==="tabular"&&i.diagramId){const s=(e=r.diagrams)==null?void 0:e.find(n=>n.id===i.diagramId);return s?`Diagram: ${s.name}`:"Diagram"}if(d){const s=(o=r.viewpoints)==null?void 0:o.find(n=>n.id===d);return s?`Viewpoint: ${s.label}`:"Viewpoint"}return"All Elements"},[r,i,d]),y=({col:e,label:o,width:s})=>t.jsxs("th",{onClick:()=>K(e),className:"px-3 py-2 text-left cursor-pointer select-none",style:{fontSize:"11px",fontWeight:600,color:"#374151",background:"#F7F7F5",borderBottom:"1px solid #E5E5E0",whiteSpace:"nowrap",width:s,position:"sticky",top:0,zIndex:1},children:[o,t.jsx(Y,{col:e,sortKey:p,sortDir:f})]});return t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",style:{background:"#FFFFFF"},children:[t.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 flex-shrink-0",style:{borderBottom:"1px solid #E5E5E0",background:"#FAFAF8"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:700,color:"#1B3A4B"},children:"Tabular View"}),t.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF"},children:W})]}),t.jsx("div",{className:"flex-1"}),t.jsx("input",{type:"text",placeholder:"Search elements…",value:E,onChange:e=>B(e.target.value),className:"px-3 py-1.5 rounded-lg focus:outline-none",style:{width:220,fontSize:j.xs,color:"#1a1a1a",border:"1px solid #E5E5E0",background:"#FFFFFF"}}),t.jsxs("select",{value:g,onChange:e=>I(e.target.value),className:"px-2 py-1.5 rounded-lg focus:outline-none",style:{fontSize:j.xs,color:"#374151",border:"1px solid #E5E5E0",background:"#FFFFFF",cursor:"pointer"},children:[t.jsx("option",{value:"",children:"All layers"}),O.map(e=>t.jsx("option",{value:e,children:D[e]??e},e))]}),t.jsxs("select",{value:b,onChange:e=>M(e.target.value),className:"px-2 py-1.5 rounded-lg focus:outline-none",style:{fontSize:j.xs,color:"#374151",border:"1px solid #E5E5E0",background:"#FFFFFF",cursor:"pointer"},children:[t.jsx("option",{value:"",children:"All kinds"}),V.map(e=>t.jsx("option",{value:e,children:e},e))]}),t.jsxs("div",{style:{fontSize:"11px",color:"#9CA3AF",whiteSpace:"nowrap"},children:[N.length," / ",h.length," elements"]})]}),t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsxs("table",{className:"w-full border-collapse",style:{tableLayout:"fixed"},children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:28}}),t.jsx("col",{style:{width:"30%"}}),t.jsx("col",{style:{width:"13%"}}),t.jsx("col",{style:{width:"13%"}}),t.jsx("col",{style:{width:40}}),t.jsx("col",{style:{width:"20%"}}),k.map(e=>t.jsx("col",{style:{width:"10%"}},e))]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{style:{background:"#F7F7F5",borderBottom:"1px solid #E5E5E0",position:"sticky",top:0,zIndex:1}}),t.jsx(y,{col:"name",label:"Name"}),t.jsx(y,{col:"kind",label:"Kind"}),t.jsx(y,{col:"layer",label:"Layer"}),t.jsx(y,{col:"status",label:"",width:40}),t.jsx(y,{col:"doc",label:"Description"}),k.map(e=>t.jsx(y,{col:e,label:e},e))]})}),t.jsxs("tbody",{children:[N.length===0&&t.jsx("tr",{children:t.jsx("td",{colSpan:6+k.length,className:"py-16 text-center",style:{fontSize:"13px",color:"#9CA3AF"},children:E||g||b?"No elements match the current filters":"No elements in scope"})}),N.map(e=>{var c;const o=e.id===v,s=T[e.layer]??"#9CA3AF",n=((c=e.doc)==null?void 0:c.trim().slice(0,100))??"";return t.jsxs("tr",{onClick:()=>S(e.id),className:"cursor-pointer",style:{background:o?"#2DD4A812":"transparent",borderBottom:"1px solid #F0F0ED"},onMouseEnter:l=>{o||(l.currentTarget.style.background="#F7F7F5")},onMouseLeave:l=>{o||(l.currentTarget.style.background="transparent")},children:[t.jsx("td",{className:"px-2",children:o&&t.jsx("span",{style:{color:"#2DD4A8",fontSize:"10px"},children:"▶"})}),t.jsxs("td",{className:"px-3 py-2",children:[t.jsx("div",{style:{fontSize:j.xs,fontWeight:500,color:"#1B3A4B",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.name}),e.shortId&&t.jsx("div",{style:{fontSize:"10px",color:"#9CA3AF",fontFamily:"monospace"},children:e.shortId})]}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{style:{fontSize:"10px",fontWeight:600,color:"#374151"},children:e.kind})}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{className:"px-1.5 py-0.5 rounded",style:{fontSize:"10px",fontWeight:600,background:s+"1A",color:s,whiteSpace:"nowrap"},children:D[e.layer]??e.layer})}),t.jsx("td",{className:"px-3 py-2 text-center",children:t.jsx(R,{element:e})}),t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{style:{fontSize:j.xs,color:"#6B7280",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:n})}),k.map(l=>t.jsx("td",{className:"px-3 py-2",children:t.jsx("span",{style:{fontSize:j.xs,color:"#374151",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"block"},children:e.attributes[l]??""})},l))]},e.id)})]})]})})]})}export{P as TabularView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./reactflow-CsCqNKB-.js";import{a as p}from"./zustand-CrhqMOHB.js";import{u as j,f as w}from"./index-
|
|
1
|
+
import{j as s}from"./reactflow-CsCqNKB-.js";import{a as p}from"./zustand-CrhqMOHB.js";import{u as j,f as w}from"./index-D0vtjNjX.js";const F=[{id:"risk-control",label:"ISO 14971: Risk → Control",description:"Hazards and hazardous situations traced to risk controls",rowKinds:["Hazard","HazardousSituation"],colKinds:["RiskControlMeasure","SafetyGoal"],relationshipTypes:["mitigates","traceTo","causes","leadsTo"]},{id:"req-test",label:"IEC 62304: Requirement → Test",description:"Software requirements traced to verification tests",rowKinds:["Requirement","Requirement","Requirement"],colKinds:["Test"],relationshipTypes:["verify","satisfy","traceTo"]},{id:"req-function",label:"Requirement → Function",description:"Requirements traced to system/component functions",rowKinds:["Requirement","Requirement","Requirement"],colKinds:["Function","Function"],relationshipTypes:["satisfy","traceTo","allocateTo"]},{id:"function-component",label:"Function → Component",description:"Functions allocated to logical/physical components",rowKinds:["Function","Function"],colKinds:["System","Subsystem","Component","LogicalComponent","SoftwareComponent","PhysicalComponent"],relationshipTypes:["allocateTo","traceTo","composedOf"]},{id:"all",label:"All Elements",description:"Full N×N matrix of all elements and relationships",rowKinds:[],colKinds:[],relationshipTypes:[]}];function N({cell:n,onClick:m}){if(!n||n.rels.length===0)return s.jsx("td",{className:"border",style:{borderColor:"#E5E5E0",width:"28px",height:"28px"}});const u=[...new Set(n.rels.map(f=>f.type))],h=n.rels.length>1?"#2DD4A830":"#2DD4A818";return s.jsx("td",{className:"border text-center cursor-pointer",style:{borderColor:"#E5E5E0",background:h,width:"28px",height:"28px"},title:u.join(", "),onClick:m,children:s.jsx("span",{className:"text-xs font-semibold",style:{color:"#1B3A4B",fontSize:"10px"},children:n.rels.length})})}function K(){const n=j(e=>e.model),m=j(e=>e.selectElement),[u,h]=p.useState("risk-control"),[f,g]=p.useState(null),[v,E]=p.useState(null),d=F.find(e=>e.id===u)||F[0],{rows:c,cols:x,matrix:y}=p.useMemo(()=>{if(!n)return{rows:[],cols:[],matrix:new Map};const e=Object.values(n.elements);let i,r;if(d.rowKinds.length===0&&d.colKinds.length===0)i=e,r=e;else{const t=new Set(d.rowKinds),o=new Set(d.colKinds);i=e.filter(l=>t.has(l.kind)),r=e.filter(l=>o.has(l.kind))}i.sort((t,o)=>t.kind.localeCompare(o.kind)||t.name.localeCompare(o.name)),r.sort((t,o)=>t.kind.localeCompare(o.kind)||t.name.localeCompare(o.name));const a=new Map,k=d.relationshipTypes.length>0?new Set(d.relationshipTypes):null,C=new Set(i.map(t=>t.id)),S=new Set(r.map(t=>t.id));for(const t of n.relationships)if(!(k&&!k.has(t.type))){if(C.has(t.sourceId)&&S.has(t.targetId)){const o=`${t.sourceId}:${t.targetId}`,l=a.get(o);l?l.rels.push(t):a.set(o,{rels:[t]})}if(C.has(t.targetId)&&S.has(t.sourceId)){const o=`${t.targetId}:${t.sourceId}`,l=a.get(o);l?l.rels.push(t):a.set(o,{rels:[t]})}}return{rows:i,cols:r,matrix:a}},[n,d]),b=p.useMemo(()=>{const e=new Set;for(const[i]of y){const r=i.split(":")[0];e.add(r)}return e.size},[y]);return n?s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",style:{background:"#FAFAF8"},children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2",style:{borderBottom:"1px solid #E5E5E0",background:"#FFFFFF"},children:[s.jsx("span",{className:"text-xs font-medium",style:{color:"#6B7280"},children:"Preset:"}),F.map(e=>s.jsx("button",{onClick:()=>h(e.id),className:"px-2 py-1 text-xs rounded-md transition-colors",style:u===e.id?{background:"#2DD4A818",color:"#1B3A4B",fontWeight:600}:{color:"#6B7280"},title:e.description,children:e.label},e.id)),s.jsx("div",{className:"flex-1"}),s.jsxs("span",{className:"text-xs",style:{color:"#9CA3AF"},children:[c.length," rows × ",x.length," cols · ",b,"/",c.length," traced (",c.length>0?Math.round(b/c.length*100):0,"%)"]})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4",children:c.length===0||x.length===0?s.jsx("div",{className:"flex items-center justify-center h-full text-xs",style:{color:"#9CA3AF"},children:"No elements match the selected preset. Try a different preset or add more model elements."}):s.jsxs("table",{className:"border-collapse text-xs",style:{borderColor:"#E5E5E0"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:"border px-2 py-1 sticky left-0 z-10",style:{borderColor:"#E5E5E0",background:"#FFFFFF",minWidth:"140px"}}),x.map(e=>(w[e.layer],s.jsx("th",{className:"border px-1 py-1",style:{borderColor:"#E5E5E0",background:v===e.id?"#F0F0ED":"#FFFFFF",writingMode:"vertical-rl",textOrientation:"mixed",maxWidth:"28px",fontSize:"10px",color:"#374151",cursor:"pointer"},onMouseEnter:()=>E(e.id),onMouseLeave:()=>E(null),onClick:()=>m(e.id),title:`${e.name} (${e.kind})`,children:s.jsx("span",{className:"truncate",style:{maxHeight:"100px",display:"block",overflow:"hidden"},children:e.name})},e.id)))]})}),s.jsx("tbody",{children:c.map(e=>{const i=w[e.layer]||"#6B7280";return s.jsxs("tr",{children:[s.jsx("td",{className:"border px-2 py-1 sticky left-0 z-10 cursor-pointer truncate",style:{borderColor:"#E5E5E0",background:f===e.id?"#F0F0ED":"#FFFFFF",maxWidth:"180px",fontSize:"11px",color:"#374151",borderLeft:`3px solid ${i}`},onMouseEnter:()=>g(e.id),onMouseLeave:()=>g(null),onClick:()=>m(e.id),title:`${e.name} (${e.kind})`,children:e.name}),x.map(r=>{const a=y.get(`${e.id}:${r.id}`)||null;return s.jsx(N,{cell:a,onClick:a?()=>m(e.id):void 0},r.id)})]},e.id)})})]})})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center text-xs",style:{color:"#9CA3AF"},children:"No model loaded"})}export{K as TraceabilityMatrix};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t}from"./reactflow-CsCqNKB-.js";import{a as x}from"./zustand-CrhqMOHB.js";import{u as p}from"./index-
|
|
1
|
+
import{j as t}from"./reactflow-CsCqNKB-.js";import{a as x}from"./zustand-CrhqMOHB.js";import{u as p}from"./index-D0vtjNjX.js";const l=[{id:"setup",icon:"🎯",title:"Set Up Your Device",description:"Define who your device is for, what it does, and who uses it. Start with actors and intended use.",standard:"IEC 62366 · ISO 14971 §4",getCount:e=>Object.values(e.elements).filter(s=>["actor","stakeholder","usecase","goal"].includes(s.kind.toLowerCase())).length,getTarget:()=>3,actionLabel:"Browse Model",actionView:"model",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="actor").length,i=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="usecase").length;return`${s} actor(s) · ${i} use case(s)`}},{id:"requirements",icon:"📋",title:"Define Requirements",description:"Capture user needs and system requirements. These form the basis of your V&V plan.",standard:"IEC 62304 §5.2 · 21 CFR 820.30(c)",getCount:e=>Object.values(e.elements).filter(s=>["systemrequirement","requirement","userneed"].includes(s.kind.toLowerCase())).length,getTarget:()=>5,actionLabel:"View Catalog",actionView:"catalog",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="userneed").length,i=Object.values(e.elements).filter(n=>["systemrequirement","requirement"].includes(n.kind.toLowerCase())).length;return`${s} user need(s) · ${i} system requirement(s)`}},{id:"hazards",icon:"⚠️",title:"Identify Hazards",description:"List all hazards your device could cause. Add hazardous situations and potential harms.",standard:"ISO 14971 §5–6",getCount:e=>Object.values(e.elements).filter(s=>["hazard","hazardoussituation","harm"].includes(s.kind.toLowerCase())).length,getTarget:()=>3,actionLabel:"Browse Risk Layer",actionView:"model",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="hazard").length,i=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="harm").length;return`${s} hazard(s) · ${i} harm(s)`}},{id:"risk-controls",icon:"🔗",title:"Connect Risk Chain",description:"Add risk controls and connect them to hazards with Mitigates relationships. Verify the ISO 14971 chain.",standard:"ISO 14971 §7–8",getCount:e=>e.relationships.filter(s=>s.type.toLowerCase()==="mitigates").length,getTarget:()=>2,actionLabel:"Traceability Matrix",actionView:"traceability",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="riskcontrol").length,i=e.relationships.filter(n=>n.type.toLowerCase()==="mitigates").length;return`${s} risk control(s) · ${i} mitigates link(s)`}},{id:"architecture",icon:"🏗️",title:"Define Architecture",description:"Add system and subsystem elements. This grounds requirements to real components.",standard:"IEC 62304 §5.3 · ISO 14971 §9",getCount:e=>Object.values(e.elements).filter(s=>["system","subsystem","logicalcomponent","softwarecomponent"].includes(s.kind.toLowerCase())).length,getTarget:()=>3,actionLabel:"Browse Model",actionView:"model",getDetails:e=>{const s=Object.values(e.elements).filter(n=>["system","subsystem"].includes(n.kind.toLowerCase())).length,i=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="softwarecomponent").length;return`${s} system/subsystem · ${i} software component(s)`}},{id:"verification",icon:"🧪",title:"Link Verification",description:"Add tests and link them to requirements. This closes the V&V loop and prepares your design review package.",standard:"IEC 62304 §5.7–5.8 · 21 CFR 820.30(g)",getCount:e=>Object.values(e.elements).filter(s=>s.kind.toLowerCase()==="test").length,getTarget:()=>3,actionLabel:"Traceability Matrix",actionView:"traceability",getDetails:e=>{const s=Object.values(e.elements).filter(n=>n.kind.toLowerCase()==="test").length,i=e.relationships.filter(n=>["satisfies","refines","traces","verifies"].includes(n.type.toLowerCase())).length;return`${s} test(s) · ${i} traceability link(s)`}}];function m({step:e,index:s,isActive:i,model:n,onSelect:d,onAction:c}){const r=e.getCount(n),o=e.getTarget(),a=r>=o,u=Math.min(100,Math.round(r/o*100)),h=e.getDetails(n),g=a?"#2ECC71":r>0?"#F39C12":"#E5E5E0";return t.jsxs("button",{onClick:d,style:{textAlign:"left",background:i?"#FFFFFF":"transparent",border:`1px solid ${i?"#1B3A4B20":"transparent"}`,borderRadius:"10px",padding:"14px 16px",cursor:"pointer",width:"100%",transition:"all 0.15s",boxShadow:i?"0 2px 8px rgba(0,0,0,0.06)":"none"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[t.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",flexShrink:0,background:a?"#2ECC71":i?"#1B3A4B":"#F3F4F6",color:a||i?"#FFFFFF":"#6B7280",display:"flex",alignItems:"center",justifyContent:"center",fontSize:a?"14px":"12px",fontWeight:700},children:a?"✓":s+1}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[t.jsxs("span",{style:{fontSize:"13px",fontWeight:700,color:i?"#1B3A4B":"#374151"},children:[e.icon," ",e.title]}),r>0&&t.jsx("span",{style:{fontSize:"10px",fontWeight:600,padding:"1px 6px",borderRadius:"999px",background:g+"20",color:g},children:r})]}),h&&t.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"2px"},children:h})]}),t.jsxs("div",{style:{width:"40px",textAlign:"right",fontSize:"10px",color:"#9CA3AF",flexShrink:0},children:[u,"%"]})]}),t.jsx("div",{style:{marginTop:"8px",height:"3px",background:"#F3F4F6",borderRadius:"2px",marginLeft:"38px"},children:t.jsx("div",{style:{height:"100%",borderRadius:"2px",background:g,width:`${u}%`,transition:"width 0.4s ease"}})})]})}function f({step:e,model:s,onAction:i}){const n=e.getCount(s),d=e.getTarget(),c=n>=d;return t.jsxs("div",{style:{background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"24px"},children:[t.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:e.icon}),t.jsx("h2",{style:{fontSize:"18px",fontWeight:800,color:"#1B3A4B",margin:"0 0 6px 0"},children:e.title}),t.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"#9CA3AF",marginBottom:"12px",fontFamily:"monospace"},children:e.standard}),t.jsx("p",{style:{fontSize:"13px",color:"#4B6E80",lineHeight:"1.7",margin:"0 0 20px 0"},children:e.description}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px 16px",borderRadius:"8px",background:c?"#2ECC7110":n>0?"#F39C1210":"#F3F4F6",marginBottom:"20px"},children:[t.jsx("div",{style:{fontSize:"24px",fontWeight:800,color:c?"#2ECC71":n>0?"#F39C12":"#9CA3AF"},children:n}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"#374151"},children:c?`✓ Target reached (${d}+ recommended)`:`${d-n} more recommended`}),t.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF"},children:e.getDetails(s)})]})]}),t.jsxs("button",{onClick:()=>i(e.actionView),style:{width:"100%",padding:"12px",borderRadius:"8px",background:"#1B3A4B",color:"#FFFFFF",border:"none",fontSize:"13px",fontWeight:600,cursor:"pointer",transition:"background 0.15s"},onMouseEnter:r=>r.currentTarget.style.background="#244D63",onMouseLeave:r=>r.currentTarget.style.background="#1B3A4B",children:[e.actionLabel," →"]})]})}function y({model:e}){const s=l.filter(n=>n.getCount(e)>=n.getTarget()).length,i=Math.round(s/l.length*100);return t.jsxs("div",{style:{padding:"16px 20px",background:"#FFFFFF",borderRadius:"12px",border:"1px solid #E5E5E0",marginBottom:"16px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px"},children:[t.jsx("span",{style:{fontSize:"13px",fontWeight:700,color:"#1B3A4B"},children:"Golden Path Progress"}),t.jsxs("span",{style:{fontSize:"13px",fontWeight:700,color:"#1B3A4B"},children:[s,"/",l.length," steps"]})]}),t.jsx("div",{style:{height:"6px",background:"#F3F4F6",borderRadius:"3px"},children:t.jsx("div",{style:{height:"100%",borderRadius:"3px",background:i>=100?"#2ECC71":"#2DD4A8",width:`${i}%`,transition:"width 0.4s ease"}})})]})}function j(){const e=p(o=>o.model),s=p(o=>o.setActiveView),i=p(o=>o.setExplorerTab),n=x.useMemo(()=>{if(!e)return 0;for(let o=0;o<l.length;o++)if(l[o].getCount(e)<l[o].getTarget())return o;return l.length-1},[e]),[d,c]=x.useState(n);if(!e)return t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"#F7F7F5"},children:t.jsx("div",{style:{fontSize:"13px",color:"#9CA3AF"},children:"No model data"})});function r(o){switch(o){case"model":i("model"),s({type:"dashboard"});break;case"traceability":s({type:"traceability"});break;case"statistics":s({type:"statistics"});break;case"catalog":i("model"),s({type:"dashboard"});break}}return t.jsx("div",{style:{flex:1,overflowY:"auto",background:"#F7F7F5",padding:"28px 40px"},children:t.jsxs("div",{style:{maxWidth:"960px",margin:"0 auto"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"20px"},children:[t.jsxs("div",{children:[t.jsx("h1",{style:{fontSize:"20px",fontWeight:800,color:"#1B3A4B",margin:"0 0 4px 0"},children:"Workflow Wizard"}),t.jsx("p",{style:{fontSize:"12px",color:"#6B7280",margin:0},children:"Follow the golden path to a complete, review-ready device model"})]}),t.jsx("button",{onClick:()=>s({type:"dashboard"}),style:{fontSize:"12px",color:"#6B7280",background:"#F3F4F6",border:"1px solid #E5E5E0",borderRadius:"6px",padding:"6px 12px",cursor:"pointer",fontWeight:500},children:"← Back to Dashboard"})]}),t.jsx(y,{model:e}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"380px 1fr",gap:"16px"},children:[t.jsx("div",{style:{background:"#F9FAFB",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"8px",display:"flex",flexDirection:"column",gap:"2px"},children:l.map((o,a)=>t.jsx(m,{step:o,index:a,isActive:a===d,model:e,onSelect:()=>c(a),onAction:r},o.id))}),t.jsx(f,{step:l[d],model:e,onAction:r})]})]})})}export{j as WorkflowWizard};
|