@memoarchitect/architect 0.4.5 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.md +44 -3
  2. package/dist/assets/AskPanel-CbZrbBeK.js +1 -0
  3. package/dist/assets/ComplianceWizard-s0BYP9sH.js +1 -0
  4. package/dist/assets/{DSMView-B4IEz19F.js → DSMView-C55GKPeE.js} +1 -1
  5. package/dist/assets/{Dashboard-DNRzU1Hk.js → Dashboard-DGiiwpMx.js} +1 -1
  6. package/dist/assets/DhfDashboard-BE5JabB1.js +1 -0
  7. package/dist/assets/{DhfSettingsPanel-C89T0dv7.js → DhfSettingsPanel-BYTUIoK4.js} +1 -1
  8. package/dist/assets/{DhfWorkbench-4gHayn-l.js → DhfWorkbench-CUzn_SQo.js} +3 -3
  9. package/dist/assets/DiagramCanvas-IINBJE7R.js +1 -0
  10. package/dist/assets/DiagramEditor-Ce5_o4RB.js +4 -0
  11. package/dist/assets/{ElementDetailView-AclSjurg.js → ElementDetailView-CZ8SUxsc.js} +2 -2
  12. package/dist/assets/{ImportView-t1dIoZF5.js → ImportView-CdHzpWCe.js} +1 -1
  13. package/dist/assets/{LayerGrid-fSGvqSEj.js → LayerGrid-Bnv8Ww8p.js} +1 -1
  14. package/dist/assets/{LayerTable-D8QCFY1b.js → LayerTable-CeO0t2NX.js} +2 -2
  15. package/dist/assets/{MaxGraphCanvas-DYs6MPuP.js → MaxGraphCanvas-BH29OQf7.js} +6 -6
  16. package/dist/assets/{ModelDiff-CLFqnELG.js → ModelDiff-DoGTGDhy.js} +1 -1
  17. package/dist/assets/OntologyDecompositionDiagram-CerdFGpm.js +1 -0
  18. package/dist/assets/{OntologyViewer-72jTw72H.js → OntologyViewer-BGl9FWMx.js} +2 -2
  19. package/dist/assets/{RelationshipOverlay-BDrBRSPP.js → RelationshipOverlay-DSzjs5U7.js} +1 -1
  20. package/dist/assets/{RelationshipsSection-D1-tuVYo.js → RelationshipsSection-2CEoiF6o.js} +1 -1
  21. package/dist/assets/{ReviewDashboard-BVOe2I5w.js → ReviewDashboard-Du0bEgrG.js} +1 -1
  22. package/dist/assets/ScenarioEditor-BjLWOYwL.js +3 -0
  23. package/dist/assets/{StatisticsDashboard-Dn6lsnKe.js → StatisticsDashboard-BdrXtbp4.js} +1 -1
  24. package/dist/assets/{SysmlCodeEditor-BLcw6hdp.js → SysmlCodeEditor-CGOcUFE7.js} +1 -1
  25. package/dist/assets/SysmlGenerator-CxtxOJ9I.js +1 -0
  26. package/dist/assets/{TabularView-B99xy3H3.js → TabularView-BJQSVDMO.js} +1 -1
  27. package/dist/assets/TraceabilityMatrix-BhDLjHki.js +1 -0
  28. package/dist/assets/{WorkflowWizard-C38DZKOe.js → WorkflowWizard-BWKNcz03.js} +1 -1
  29. package/dist/assets/index-CRFOCEAK.js +3277 -0
  30. package/dist/assets/index-DPzXL4uF.css +1 -0
  31. package/dist/assets/{layout-providers-BAUgp0nu.js → layout-providers-BFnfta4Z.js} +13 -13
  32. package/dist/assets/layout-selection-CtqXOAtf.js +1 -0
  33. package/dist/assets/{reactflow-WKyu73tD.js → reactflow-CX-HDacK.js} +1 -1
  34. package/dist/index.html +3 -3
  35. package/lib/bin/memo-architect.js +39 -3
  36. package/lib/bin/memo-architect.js.map +1 -1
  37. package/lib/commands/dev.d.ts.map +1 -1
  38. package/lib/commands/dev.js +9 -0
  39. package/lib/commands/dev.js.map +1 -1
  40. package/lib/commands/example.d.ts +16 -0
  41. package/lib/commands/example.d.ts.map +1 -0
  42. package/lib/commands/example.js +143 -0
  43. package/lib/commands/example.js.map +1 -0
  44. package/package.json +16 -16
  45. package/dist/assets/AskPanel-D9_AKyYt.js +0 -1
  46. package/dist/assets/ComplianceWizard-BNvT_ic6.js +0 -1
  47. package/dist/assets/DhfDashboard-DguH-rDT.js +0 -1
  48. package/dist/assets/DiagramCanvas-BgfO0AtP.js +0 -1
  49. package/dist/assets/DiagramEditor-CEr6iqBf.js +0 -4
  50. package/dist/assets/DiagramSurface-B_lfUNzV.js +0 -2
  51. package/dist/assets/OntologyDecompositionDiagram-cpmTTMRH.js +0 -1
  52. package/dist/assets/ScenarioEditor-CvOkiRC6.js +0 -3
  53. package/dist/assets/SysmlGenerator-CfBQWovl.js +0 -1
  54. package/dist/assets/TraceabilityMatrix-BAJb0X7G.js +0 -1
  55. package/dist/assets/index-CgRwea72.js +0 -3277
  56. package/dist/assets/index-CnFhl4_e.css +0 -1
  57. package/dist/assets/layout-selection-BQ2WuAEB.js +0 -1
@@ -1,4 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SysmlCodeEditor-BLcw6hdp.js","assets/reactflow-WKyu73tD.js","assets/zustand-qbFpP9Up.js","assets/SysmlCodeEditor-BwKcXIZw.css"])))=>i.map(i=>d[i]);
2
- import{u as k,g as P,l as Y,s as V,a as W,F as a,C as o,_ as q,b as G,L as U,c as H,d as J}from"./index-CgRwea72.js";import{j as e}from"./reactflow-WKyu73tD.js";import{a as r}from"./zustand-qbFpP9Up.js";import{DiagramSurface as K}from"./DiagramSurface-B_lfUNzV.js";const Q=r.lazy(()=>q(()=>import("./SysmlCodeEditor-BLcw6hdp.js"),__vite__mapDeps([0,1,2,3])).then(l=>({default:l.SysmlCodeEditor})));function X(l,c){const u=(l.elementIds??[]).map(s=>c[s]).filter(Boolean).map(s=>` ${s.construct??"part"} ${s.id} : ${s.kind};`).join(`
3
- `);return[`package '${l.name}' {`,` // Diagram: ${l.diagramType.toUpperCase()} | Viewpoint: ${l.viewpointId}`,u||" // No elements selected","}"].join(`
4
- `)}function Z({diagram:l}){const c=k(n=>n.model),u=k(n=>n.updateDiagramElementIds),[s,x]=r.useState(""),E=r.useMemo(()=>G(c),[c]),w=r.useCallback(n=>{const f=new Set(l.elementIds??[]);f.has(n)?f.delete(n):f.add(n),u(l.id,[...f])},[l.id,l.elementIds,u]),h=r.useMemo(()=>new Set(l.elementIds??[]),[l.elementIds]),p=U.filter(n=>E.has(n));return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",style:{width:"220px",borderLeft:`1px solid ${o.border}`,background:"#FAFAF8",flexShrink:0},children:[e.jsxs("div",{className:"px-2 py-1.5",style:{borderBottom:`1px solid ${o.border}`},children:[e.jsxs("div",{className:"font-semibold mb-1",style:{color:o.primary,fontSize:a.xs},children:["Elements (",h.size," selected)"]}),e.jsx("input",{value:s,onChange:n=>x(n.target.value),placeholder:"Filter…",className:"w-full px-2 py-1 rounded focus:outline-none",style:{background:"#F0F0ED",border:`1px solid ${o.border}`,color:o.primary,fontSize:a.xs}})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:p.map(n=>{const f=(E.get(n)??[]).filter(i=>!s||i.name.toLowerCase().includes(s.toLowerCase())||i.id.toLowerCase().includes(s.toLowerCase()));if(f.length===0)return null;const g=J[n]??o.muted;return e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1 font-semibold",style:{color:g,fontSize:a.badge},children:H[n]??n}),f.map(i=>e.jsxs("label",{className:"flex items-center gap-2 px-3 py-0.5 cursor-pointer",style:{fontSize:a.xs},onMouseEnter:S=>S.currentTarget.style.background="#F0F0ED",onMouseLeave:S=>S.currentTarget.style.background="transparent",children:[e.jsx("input",{type:"checkbox",checked:h.has(i.id),onChange:()=>w(i.id),style:{accentColor:o.accent}}),e.jsx("span",{className:"truncate",style:{color:o.primary},title:i.id,children:i.name||i.id})]},i.id))]},n)})})]})}const ee=[];function le({diagramId:l}){const c=k(t=>t.model),u=k(t=>t.diagramParseErrors[l]??ee),s=P(c,l),[x,E]=r.useState("visual"),[w,h]=r.useState(""),[p,n]=r.useState(!1),[f,g]=r.useState(!1),[i,S]=r.useState(!1),[m,N]=r.useState(!1),[b,j]=r.useState(null),[$,T]=r.useState(null),[C,O]=r.useState(()=>localStorage.getItem("memo.diagramEditor.autoSave")==="true"),F=r.useRef(),y=r.useRef(""),D=r.useRef(0);r.useEffect(()=>{let t=!1;if(clearTimeout(F.current),j(null),T(null),N(!1),!(!s||!c)){if(!s.sourceFile||window.__MEMO_DATA__){const d=X(s,c.elements);y.current=d,h(d),n(!1),g(!1);return}return h(""),y.current="",n(!0),g(!1),Y(l).then(d=>{if(t)return;const v=d.text??"";y.current=v,h(v),g(!0)}).catch(d=>{t||j(d instanceof Error?d.message:String(d))}).finally(()=>{t||n(!1)}),()=>{t=!0}}},[l,s==null?void 0:s.sourceFile]);const B=t=>{y.current=t,h(t),N(!0),j(null)},A=r.useCallback(async t=>{if(!s)return;const d=++D.current;S(!0),j(null);try{s.sourceFile?await V(l,t):W(l,t),y.current===t&&N(!1),T(Date.now())}catch(v){j(v instanceof Error?v.message:String(v))}finally{D.current===d&&S(!1)}},[s,l]);r.useEffect(()=>(localStorage.setItem("memo.diagramEditor.autoSave",String(C)),clearTimeout(F.current),C&&m&&!p&&(F.current=setTimeout(()=>void A(y.current),800)),()=>clearTimeout(F.current)),[C,m,p,w,A]);const M=r.useCallback(()=>{clearTimeout(F.current),A(y.current)},[A]),I=r.useMemo(()=>Object.values((c==null?void 0:c.elements)??{}).map(t=>({id:t.id,name:t.name,kind:t.kind})),[c==null?void 0:c.elements]);if(!s)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:o.faint,fontSize:a.sm},children:"Diagram not found"});const _=s.auto,L=!_||!!s.sourceFile&&f,z=e.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden",children:[e.jsx("div",{className:"flex-1 overflow-hidden",style:{background:"#1E1E1E"},children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"h-full flex items-center justify-center",style:{color:"#9CA3AF",fontSize:a.xs},children:"Loading SysML editor…"}),children:e.jsx(Q,{value:w,sourceFile:s.sourceFile,readOnly:!L||p,symbols:I,onChange:B,onSave:()=>{L&&m&&M()}})})}),u.length>0&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C0A0A",color:"#F87171",borderTop:"1px solid #3B0A0A",fontFamily:"monospace"},children:u.join(" · ")}),b&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C0A0A",color:"#FCA5A5",borderTop:"1px solid #3B0A0A"},children:b}),!L&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#F9F9F8",color:o.faint,borderTop:`1px solid ${o.border}`},children:s.sourceFile&&window.__MEMO_DATA__?"Static build — run memo-architect dev to edit the SysML source":s.sourceFile?"The SysML source could not be loaded":"Generated model view — no editable SysML source file"})]}),R=e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:e.jsx(K,{})}),!_&&e.jsx(Z,{diagram:s})]});return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5",style:{borderBottom:`1px solid ${o.border}`,background:"#FAFAF8",flexShrink:0},children:[e.jsx("span",{className:"font-semibold truncate flex-1",style:{color:o.primary,fontSize:a.sm},children:s.name}),s.sourceFile&&e.jsx("span",{className:"truncate",title:s.sourceFile,style:{maxWidth:"220px",color:o.faint,fontSize:a.xs},children:s.sourceFile}),(x==="text"||x==="split")&&e.jsx("span",{title:"Local, public Monaco editor with SysML highlighting and model-aware completion",style:{color:"#4B6E80",fontSize:a.badge},children:"Monaco · SysML"}),p&&e.jsx("span",{style:{color:o.faint,fontSize:a.xs},children:"Loading source…"}),i&&e.jsx("span",{style:{color:o.faint,fontSize:a.xs},children:"Saving…"}),!i&&b&&e.jsx("span",{title:b,style:{color:"#EF4444",fontSize:a.xs},children:"Save failed"}),!i&&!b&&m&&e.jsx("span",{style:{color:"#B45309",fontSize:a.xs},children:"Unsaved"}),!i&&!m&&$&&e.jsx("span",{style:{color:"#15803D",fontSize:a.xs},children:"Saved"}),!i&&u.length>0&&e.jsxs("span",{style:{color:"#EF4444",fontSize:a.xs},children:[u.length," error",u.length>1?"s":""]}),L&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-center gap-1",style:{color:o.secondary,fontSize:a.xs},title:"Save changes 800ms after typing",children:[e.jsx("input",{type:"checkbox",checked:C,onChange:t=>O(t.target.checked),style:{accentColor:o.accent}}),"Auto-save"]}),e.jsx("button",{onClick:M,disabled:!m||i||p,title:"Save SysML (Ctrl/Cmd+S)",style:{fontSize:a.xs,padding:"3px 10px",borderRadius:"5px",border:`1px solid ${o.border}`,cursor:!m||i||p?"default":"pointer",background:m?o.accent:"#F0F0ED",color:m?"#FFFFFF":o.faint,fontWeight:600},children:"Save"})]}),e.jsx("div",{className:"flex overflow-hidden",style:{border:`1px solid ${o.border}`,borderRadius:"6px"},children:[["visual","⬜ Visual"],["split","⧉ Split"],["text","</> Text"]].map(([t,d])=>e.jsx("button",{onClick:()=>E(t),style:{fontSize:a.xs,padding:"3px 10px",border:"none",cursor:"pointer",background:x===t?o.accent:"transparent",color:x===t?"#FFFFFF":o.secondary,fontWeight:x===t?600:400},children:d},t))})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[x==="visual"&&R,x==="text"&&z,x==="split"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"50%",borderRight:`1px solid ${o.border}`,display:"flex",flexDirection:"column",overflow:"hidden"},children:z}),e.jsx("div",{style:{width:"50%",display:"flex",overflow:"hidden"},children:R})]})]})]})}export{le as DiagramEditor};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiagramCanvas-BgfO0AtP.js","assets/reactflow-WKyu73tD.js","assets/zustand-qbFpP9Up.js","assets/index-CgRwea72.js","assets/index-CnFhl4_e.css","assets/layout-selection-BQ2WuAEB.js","assets/layout-providers-BAUgp0nu.js","assets/elk-B75IRfCd.js","assets/style-BZV40eAE.css","assets/MaxGraphCanvas-DYs6MPuP.js"])))=>i.map(i=>d[i]);
2
- var R=Object.defineProperty;var w=(t,e,r)=>e in t?R(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var l=(t,e,r)=>w(t,typeof e!="symbol"?e+"":e,r);import{j as o}from"./reactflow-WKyu73tD.js";import{a as s}from"./zustand-qbFpP9Up.js";import{_ as f,F as h}from"./index-CgRwea72.js";const d="memo.renderer.reactflow";class E{constructor(){l(this,"providers",new Map);l(this,"components",new Map)}register(e){const r=this.providers.get(e.descriptor.id);if(r&&r!==e)throw new Error(`Renderer provider already registered: ${e.descriptor.id}`);this.providers.set(e.descriptor.id,e)}unregister(e){return this.components.delete(e),this.providers.delete(e)}get(e){return this.providers.get(e)}has(e){return this.providers.has(e)}list(e=[]){return[...this.providers.values()].map(r=>r.descriptor).filter(r=>e.every(n=>r.capabilities.includes(n))).sort((r,n)=>r.name.localeCompare(n.name))}loadComponent(e){const r=this.providers.get(e)??this.providers.get(d);if(!r)throw new Error(`Renderer provider not found: ${e} (no default registered)`);const n=r.descriptor.id;let a=this.components.get(n);return a||(a=r.loadComponent(),this.components.set(n,a)),a}}const v={descriptor:{id:"memo.renderer.reactflow",name:"ReactFlow",engine:"ReactFlow (@xyflow/react 12)",version:"12",contractVersion:"1",license:"MIT",description:"Default authoring canvas — React node components, palette, full editing.",capabilities:["interactive-editing","all-view-kinds","manual-layout","undo-redo","minimap","orthogonal-routes"]},loadComponent:()=>f(()=>import("./DiagramCanvas-BgfO0AtP.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(t=>t.DiagramCanvas)},x={descriptor:{id:"memo.renderer.maxgraph",name:"maxGraph",engine:"maxGraph (@maxgraph/core — draw.io rendering engine lineage)",version:"0.x",contractVersion:"1",license:"Apache-2.0",description:"draw.io-style retained-mode canvas — SVG cells, rubberband selection, image export.",capabilities:["all-view-kinds","manual-layout","export-image"]},loadComponent:()=>f(()=>import("./MaxGraphCanvas-DYs6MPuP.js"),__vite__mapDeps([9,1,2,3,4,5,6,7])).then(t=>t.MaxGraphCanvas)},i=new E;i.register(v);i.register(x);function _(t=[]){return i.list(t)}const y={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},g="memo.diagram.renderer.v3",m="renderer",F="memo.renderer.",u=new Set;function c(t){const e=t==null?void 0:t.trim();if(e)return e.includes(".")?e:`${F}${e}`}function S(){if(!(typeof window>"u"))try{return c(new URLSearchParams(window.location.search).get(m))}catch{return}}function b(){if(!(typeof window>"u"))try{return c(window.localStorage.getItem(g))}catch{return}}function D(){try{const t=y;return c(t==null?void 0:t.VITE_MEMO_DIAGRAM_RENDERER)}catch{return}}function p(){return S()??b()??D()??d}function I(t){const e=c(t)??d;try{window.localStorage.setItem(g,e)}catch{}try{const r=new URL(window.location.href);r.searchParams.has(m)&&(r.searchParams.delete(m),window.history.replaceState(window.history.state,"",r))}catch{}for(const r of[...u])r()}function A(t){return u.add(t),()=>u.delete(t)}function C(){return o.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5",color:"#9CA3AF",fontSize:h.sm},children:"Loading renderer…"})}function j({activeId:t}){const e=_();return e.length<2?null:o.jsx("div",{className:"absolute bottom-3 right-3 z-10 flex items-center overflow-hidden rounded-lg",style:{border:"1px solid #E5E5E0",background:"#FFFFFF",boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},title:"Diagram rendering engine",children:e.map(r=>{const n=r.id===t;return o.jsx("button",{onClick:()=>I(r.id),title:`${r.engine} — ${r.description}`,style:{fontSize:h.xs,padding:"4px 10px",fontWeight:600,border:"none",cursor:n?"default":"pointer",background:n?"#2DD4A8":"transparent",color:n?"#FFFFFF":"#6B7280"},children:r.name},r.id)})})}function L(){const t=s.useSyncExternalStore(A,p,p),e=i.has(t)?t:d,r=s.useMemo(()=>s.lazy(()=>i.loadComponent(e).then(n=>({default:n}))),[e]);return o.jsxs("div",{className:"relative flex flex-1 overflow-hidden",children:[o.jsx(s.Suspense,{fallback:o.jsx(C,{}),children:o.jsx(r,{})}),o.jsx(j,{activeId:e})]})}export{L as DiagramSurface};
@@ -1 +0,0 @@
1
- import{j as e,H as C,P as k,R as D,u as S,i as O,f as R,g as T}from"./reactflow-WKyu73tD.js";import{a as p}from"./zustand-qbFpP9Up.js";/* empty css */import{r as I}from"./layout-providers-BAUgp0nu.js";import{d as L,u as h,t as P,v as M,w as z}from"./index-CgRwea72.js";import"./elk-B75IRfCd.js";import"web-worker";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 (@memo/...), 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,V=180;async function K(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:V})),edges:i.filter(t=>t.extends&&s.has(t.extends)).map((t,x)=>({id:`e-${x}`,sources:[t.extends],targets:[t.name]}))},d=await I(l),n=new Map;for(const t of d.children??[])n.set(t.id,{x:t.x??0,y:t.y??0});const c={ontology:"#3B82F6",profile:"#10B981",extension:"#F59E0B"},r=i.map(t=>({id:t.name,type:"ontologyPackage",position:n.get(t.name)??{x:0,y:0},data:{name:t.name,type:t.type,version:t.version,description:t.description,kindCount:t.kindCount,layerCount:t.layers.length,layers:t.layers.map(x=>({id:x.id,label:x.label,color:x.color,kindCount:x.kindCount})),selected:t.selected,onClick:()=>{}}})),g=[];for(const t of i)if(t.extends&&s.has(t.extends)){const x=c[t.type]??"#94A3B8";g.push({id:`${t.extends}->${t.name}`,source:t.extends,target:t.name,type:"smoothstep",data:{edgeType:"extends"},style:{stroke:x,strokeWidth:2,strokeDasharray:"6 3"},animated:!1,label:"extends",labelStyle:{fontSize:9,fill:x,fontWeight:500},labelBgStyle:{fill:"#F7F7F5",fillOpacity:.9},labelBgPadding:[4,2],markerEnd:{type:"arrowclosed",color:x,width:14,height:14}})}return{nodes:r,edges:g}}function G(i,s){const l=new Map;for(const c of s)c.extends&&(l.has(c.extends)||l.set(c.extends,[]),l.get(c.extends).push(c.name));const d=new Set([i]),n=[i];for(;n.length;){const c=n.shift();for(const r of l.get(c)??[])d.has(r)||(d.add(r),n.push(r))}return d}function U(){const i=h(a=>a.availableOntologies),s=h(a=>a.setActiveView),l=h(a=>a.hiddenEdgeTypes),d=h(a=>a.toggleHiddenEdgeType),[n,c]=p.useState(!1),[r,g]=p.useState({nodes:[],edges:[]}),[t,x]=p.useState(null),{fitView:o}=S();p.useEffect(()=>{let a=!1;return K(i).then(u=>{a||g(u)}).catch(u=>{console.error("[OntologyDiagram] ELK layout failed:",u)}),()=>{a=!0}},[i]);const F=p.useCallback(a=>{s({type:"ontology-detail",packageName:a})},[s]),E=p.useCallback(a=>{const u=G(a,i),m=r.nodes.filter(y=>u.has(y.id));m.length!==0&&o({nodes:m.map(y=>({id:y.id})),duration:400,padding:.2})},[i,r.nodes,o]),v=p.useCallback((a,u)=>{a.preventDefault(),x({x:a.clientX,y:a.clientY,packageName:u})},[]);p.useEffect(()=>{const a=u=>{if(u.key==="Escape"){if(t){x(null);return}o({padding:.1,duration:300})}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,o]);const{nodes:N,edges:B}=p.useMemo(()=>{const a=r.nodes.map(m=>({...m,data:{...m.data,onClick:()=>E(m.id),onDoubleClick:()=>F(m.id),onContextMenu:y=>v(y,m.id)}})),u=r.edges.filter(m=>{var j;const y=(j=m.data)==null?void 0:j.edgeType;return!y||!l.has(y)});return{nodes:a,edges:u}},[r,E,F,v,l]),f=p.useRef(null);p.useEffect(()=>{if(!t)return;const a=u=>{f.current&&!f.current.contains(u.target)&&x(null)};return window.addEventListener("mousedown",a),()=>window.removeEventListener("mousedown",a)},[t]);const b=l.has("extends");return i.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"text-center",style:{color:"#9CA3AF"},children:[e.jsx("div",{className:"text-3xl mb-3",children:"◉"}),e.jsx("div",{className:"text-sm font-medium mb-1",style:{color:"#374151"},children:"No ontology packages found"}),e.jsx("div",{className:"text-xs",children:"Start the dev server to load ontology packages"})]})}):e.jsxs("div",{className:"flex-1",style:{background:"#F7F7F5"},children:[e.jsxs("div",{className:"flex items-start justify-between px-6 pt-5 pb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",style:{color:"#1a1a1a"},children:"Ontology Library"}),e.jsxs("p",{className:"text-xs mt-1",style:{color:"#9CA3AF"},children:[i.length," package",i.length!==1?"s":""," available. Click to zoom, double-click to open, right-click for source."]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{"data-testid":"toggle-tracing",onClick:()=>d("extends"),title:b?"Show extends tracing edges":"Hide extends tracing edges",className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:b?{background:"#F0F0ED",color:"#6B7280",border:"1px solid #E5E5E0"}:{background:"#1B3A4B",color:"#2DD4A8",border:"1px solid transparent"},children:b?"Show Tracing":"Hide Tracing"}),e.jsx("button",{onClick:()=>c(!0),className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:{background:"#1B3A4B",color:"#2DD4A8"},children:"+ Add Ontology"})]})]}),n&&e.jsx($,{onClose:()=>c(!1)}),e.jsx("div",{style:{flex:1,height:"calc(100% - 72px)"},children:e.jsxs(O,{nodes:N,edges:B,nodeTypes:_,fitView:!0,fitViewOptions:{padding:.1},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!0,zoomOnDoubleClick:!1,minZoom:.2,maxZoom:2.5,proOptions:{hideAttribution:!0},children:[e.jsx(R,{color:"#E5E5E0",gap:24,size:1}),e.jsx(T,{showInteractive:!1})]})}),t&&e.jsx(Z,{menuRef:f,state:t,onClose:()=>x(null),packages:i})]})}const Z=({state:i,onClose:s,packages:l,menuRef:d})=>{const n=l.find(r=>r.name===i.packageName);function c(){if(!n)return;const r=n.rootDir?`${n.rootDir}/memo.package.yaml`:"";r?z(r):window.open(`vscode://file/${encodeURIComponent(n.name)}`),s()}return e.jsxs("div",{ref:d,style:{position:"fixed",top:i.y,left:i.x,zIndex:1e3,background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"8px",boxShadow:"0 6px 16px rgba(0,0,0,0.12)",padding:"4px",minWidth:"180px",fontSize:"12px"},children:[e.jsx("div",{style:{padding:"6px 10px",color:"#9CA3AF",fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.4px"},children:i.packageName}),e.jsx("button",{onClick:c,disabled:!(n!=null&&n.rootDir),style:{display:"block",width:"100%",textAlign:"left",padding:"6px 10px",border:"none",background:"transparent",cursor:n!=null&&n.rootDir?"pointer":"not-allowed",color:n!=null&&n.rootDir?"#1a1a1a":"#9CA3AF",borderRadius:"4px"},onMouseEnter:r=>{n!=null&&n.rootDir&&(r.currentTarget.style.background="#F0F0ED")},onMouseLeave:r=>{r.currentTarget.style.background="transparent"},children:"Open source"})]})};function ne(){return e.jsx(D,{children:e.jsx(U,{})})}export{ne as OntologyDecompositionDiagram,ne as default};
@@ -1,3 +0,0 @@
1
- import{j as s}from"./reactflow-WKyu73tD.js";import{a}from"./zustand-qbFpP9Up.js";import{u as j,e as U,f as $,d as F,h as z}from"./index-CgRwea72.js";function w(d){return d?d.split(`
2
- `).filter(o=>o.trim()).map((o,p)=>{const h=o.match(/^\d+\.\s*(.*)/);return{index:p,text:h?h[1]:o}}):[]}function _(d){return d.map((m,o)=>`${o+1}. ${m.text}`).join(`
3
- `)}function q(){const d=j(e=>e.model),m=j(e=>e.selectElement),o=j(e=>e.selectedElementId),[p,h]=a.useState(""),[r,u]=a.useState(null),[y,k]=a.useState(""),[b,v]=a.useState(null),[g,N]=a.useState(""),f=a.useMemo(()=>d?Object.values(d.elements).filter(e=>e.kind==="Scenario"||e.kind==="UseCase"||e.kind==="UserActivity"):[],[d]),E=a.useMemo(()=>{if(!p)return f;const e=p.toLowerCase();return f.filter(t=>t.name.toLowerCase().includes(e)||t.kind.toLowerCase().includes(e))},[f,p]),C=a.useMemo(()=>{const e=new Map;for(const t of E)e.has(t.kind)||e.set(t.kind,[]),e.get(t.kind).push(t);return[...e.entries()].sort((t,n)=>t[0].localeCompare(n[0]))},[E]),c=o&&d?d.elements[o]:null,A=a.useMemo(()=>U(d,o||""),[d,o]),i=a.useMemo(()=>r||(c?w(c.doc||""):[]),[c,r]),M=a.useCallback(()=>{c&&u(w(c.doc||""))},[c]),B=a.useCallback(()=>{if(!c||!r)return;const e=_(r);$({...c,doc:e}),u(null)},[c,r]),S=a.useCallback(()=>{if(!y.trim())return;const e=[...r||i,{index:i.length,text:y.trim()}];u(e),k("")},[y,r,i]),L=a.useCallback(e=>{const t=(r||i).filter((n,l)=>l!==e);u(t)},[r,i]),D=a.useCallback((e,t)=>{const n=[...r||i],l=e+t;l<0||l>=n.length||([n[e],n[l]]=[n[l],n[e]],u(n))},[r,i]),T=a.useCallback((e,t)=>{const n=[...r||i];n[e]={...n[e],text:t},u(n)},[r,i]),R=a.useMemo(()=>{if(!d||!g)return[];const e=g.toLowerCase();return Object.values(d.elements).filter(t=>t.id!==o&&t.name.toLowerCase().includes(e)).slice(0,10)},[d,g,o]),[I,O]=a.useState(new Set),G=e=>{O(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return s.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[s.jsxs("div",{className:"w-72 flex flex-col overflow-hidden",style:{background:"#FFFFFF",borderRight:"1px solid #E5E5E0"},children:[s.jsx("div",{className:"px-3 py-2",style:{borderBottom:"1px solid #E5E5E0"},children:s.jsx("input",{type:"text",placeholder:`Search ${f.length} scenarios...`,value:p,onChange:e=>h(e.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"}})}),s.jsxs("div",{className:"flex-1 overflow-y-auto text-xs py-1",children:[C.map(([e,t])=>{const n=I.has(e);return s.jsxs("div",{className:"mb-0.5",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 cursor-pointer",style:{borderRadius:"6px",margin:"0 4px"},onMouseEnter:l=>l.currentTarget.style.background="#F0F0ED",onMouseLeave:l=>l.currentTarget.style.background="transparent",onClick:()=>G(e),children:[s.jsx("span",{className:"w-2.5 h-2.5 rounded flex-shrink-0",style:{backgroundColor:F.functional,borderRadius:"3px"}}),s.jsx("span",{className:"font-medium flex-1",style:{color:"#374151"},children:e}),s.jsx("span",{style:{color:"#9CA3AF"},children:t.length}),s.jsx("span",{style:{color:"#D1D5DB"},children:n?"▸":"▾"})]}),!n&&t.map(l=>s.jsx("div",{className:"px-3 py-1 ml-6 cursor-pointer flex items-center gap-1.5",style:{borderRadius:"6px",background:o===l.id?"#2DD4A818":"transparent",color:o===l.id?"#1B3A4B":"#374151",fontWeight:o===l.id?500:400},onMouseEnter:x=>{o!==l.id&&(x.currentTarget.style.background="#F0F0ED")},onMouseLeave:x=>{o!==l.id&&(x.currentTarget.style.background="transparent")},onClick:()=>{m(l.id),u(null)},children:s.jsx("span",{className:"truncate",children:l.name})},l.id))]},e)}),C.length===0&&s.jsx("div",{className:"px-4 py-8 text-center",style:{color:"#9CA3AF"},children:"No scenarios found."})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-6",style:{background:"#F7F7F5"},children:[!c&&s.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"#9CA3AF"},children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{style:{fontSize:"32px",marginBottom:"8px",opacity:.5},children:"▶"}),s.jsx("div",{className:"text-sm",children:"Select a scenario to edit steps and link elements"})]})}),c&&s.jsxs("div",{className:"max-w-2xl",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("h2",{className:"text-lg font-semibold",style:{color:"#1a1a1a"},children:c.name}),s.jsx("span",{className:"px-2 py-0.5 text-xs rounded-md font-medium",style:{background:"#E67E2218",color:"#E67E22"},children:c.kind})]}),s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"#6B7280"},children:"Steps"}),!r&&s.jsx("button",{onClick:M,className:"px-2 py-0.5 text-xs rounded",style:{background:"#2DD4A815",color:"#1B3A4B",border:"1px solid #2DD4A840"},children:"Edit"}),r&&s.jsxs("div",{className:"flex gap-1",children:[s.jsx("button",{onClick:B,className:"px-2 py-0.5 text-xs rounded font-medium",style:{background:"#2DD4A8",color:"#FFFFFF"},children:"Save"}),s.jsx("button",{onClick:()=>u(null),className:"px-2 py-0.5 text-xs rounded",style:{background:"#F3F4F6",color:"#6B7280"},children:"Cancel"})]})]}),s.jsx("div",{className:"space-y-1",children:i.map((e,t)=>s.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[s.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:t+1}),r?s.jsx("input",{type:"text",value:e.text,onChange:n=>T(t,n.target.value),className:"flex-1 text-sm px-2 py-1 rounded focus:outline-none",style:{border:"1px solid #E5E5E0",color:"#374151"}}):s.jsx("span",{className:"flex-1 text-sm",style:{color:"#374151"},children:e.text}),r&&s.jsxs("div",{className:"flex gap-0.5",children:[s.jsx("button",{onClick:()=>D(t,-1),className:"px-1 text-xs",style:{color:"#9CA3AF"},title:"Move up",children:"▲"}),s.jsx("button",{onClick:()=>D(t,1),className:"px-1 text-xs",style:{color:"#9CA3AF"},title:"Move down",children:"▼"}),s.jsx("button",{onClick:()=>L(t),className:"px-1 text-xs",style:{color:"#E74C3C"},title:"Remove",children:"✕"})]})]},t))}),r&&s.jsxs("div",{className:"flex gap-2 mt-2",children:[s.jsx("input",{type:"text",value:y,onChange:e=>k(e.target.value),onKeyDown:e=>e.key==="Enter"&&S(),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"}}),s.jsx("button",{onClick:S,className:"px-3 py-2 text-xs rounded-lg font-medium",style:{background:"#2DD4A815",color:"#1B3A4B",border:"1px solid #2DD4A840"},children:"+ Add"})]}),i.length===0&&!r&&s.jsx("div",{className:"text-xs p-3 rounded-lg",style:{background:"#F3F4F6",color:"#9CA3AF"},children:"No steps defined. Click Edit to add scenario steps."})]}),s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"#6B7280"},children:["Linked Elements (",A.length,")"]}),s.jsx("button",{onClick:()=>v(b===null?0:null),className:"px-2 py-0.5 text-xs rounded",style:{background:"#4A90D915",color:"#4A90D9",border:"1px solid #4A90D940"},children:b!==null?"Done":"+ Link"})]}),b!==null&&s.jsxs("div",{className:"mb-2 p-2 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #4A90D940"},children:[s.jsx("input",{type:"text",value:g,onChange:e=>N(e.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"}}),R.map(e=>s.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 text-xs rounded cursor-pointer",onMouseEnter:t=>t.currentTarget.style.background="#F0F0ED",onMouseLeave:t=>t.currentTarget.style.background="transparent",onClick:()=>{z(c.id,e.id,"traceTo"),N(""),v(null)},children:[s.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:F[e.layer]||"#95A5A6"}}),s.jsx("span",{style:{color:"#374151"},children:e.name}),s.jsx("span",{style:{color:"#9CA3AF"},children:e.kind})]},e.id))]}),s.jsx("div",{className:"space-y-1",children:A.map(e=>{const t=e.sourceId===c.id?e.targetId:e.sourceId,n=d.elements[t],l=e.sourceId===c.id?"→":"←";return s.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:x=>x.currentTarget.style.background="#F0F0ED",onMouseLeave:x=>x.currentTarget.style.background="#FFFFFF",onClick:()=>m(t),children:[s.jsx("span",{style:{color:"#9CA3AF"},children:l}),s.jsx("span",{className:"font-medium",style:{color:"#2563EB"},children:e.type}),s.jsx("span",{style:{color:"#374151"},children:(n==null?void 0:n.name)||t}),n&&s.jsx("span",{className:"ml-auto px-1.5 py-0.5 rounded text-xs",style:{background:(F[n.layer]||"#95A5A6")+"18",color:F[n.layer]||"#95A5A6"},children:n.kind})]},e.id)})})]}),s.jsx("div",{className:"text-xs",style:{color:"#D1D5DB"},children:c.file})]})]})]})}export{q as ScenarioEditor};
@@ -1 +0,0 @@
1
- import{j as e}from"./reactflow-WKyu73tD.js";import{a as s}from"./zustand-qbFpP9Up.js";import{u as a,k as C}from"./index-CgRwea72.js";const A=["Add a PressureSensor component with a USB interface and a power port.","Create a hazard: AlarmFailure that causes patient harm in ICU setting.","Define a software item InfusionController with a requirement for dose limit checking.","Add a RiskControl that mitigates OverInfusion by adding a flow rate sensor."];function F(){const r=a(o=>o.llmAvailable),v=a(o=>o.llmProvider),S=a(o=>o.llmModel),f=a(o=>o.registerLlmRequest),[l,p]=s.useState(""),[n,g]=s.useState(!1),[t,c]=s.useState(null),[u,m]=s.useState(null),[y,x]=s.useState(!1),h=s.useCallback(async o=>{if(!o.trim()||n)return;g(!0),c(null),m(null),x(!1);const i=`gen-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{const d=await new Promise((E,b)=>{f(i,E,b),C(i,o.trim()),setTimeout(()=>b(new Error("Request timed out after 60 seconds.")),6e4)});c(d)}catch(d){m((d==null?void 0:d.message)??"Unknown error")}finally{g(!1)}},[n,f]),j=()=>{t!=null&&t.sysml&&navigator.clipboard.writeText(t.sysml).then(()=>{x(!0),setTimeout(()=>x(!1),2e3)})};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"#F7F7F5",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"14px 20px 10px",borderBottom:"1px solid #E5E5E0",background:"#fff",flexShrink:0},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx("span",{style:{fontSize:"16px"},children:"⟨/⟩"}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:700,color:"#1B3A4B"},children:"SysML Generator"}),e.jsx("div",{style:{fontSize:"11px",color:r?"#059669":"#dc2626",marginTop:"1px"},children:r?`${v??"LLM"} · ${S??"unknown model"} · natural language → SysML v2`:"No LLM provider — set ANTHROPIC_API_KEY or OPENAI_API_KEY"})]})]})}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px"},children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:{fontSize:"12px",fontWeight:600,color:"#374151",display:"block",marginBottom:"6px"},children:"Describe what to generate"}),e.jsx("textarea",{value:l,onChange:o=>p(o.target.value),disabled:!r||n,rows:4,placeholder:"Describe the element(s) to generate in plain English…",style:{width:"100%",padding:"10px 12px",border:"1px solid #E5E5E0",borderRadius:"8px",fontSize:"13px",resize:"vertical",fontFamily:"inherit",outline:"none",background:"#fff",color:"#1B3A4B",lineHeight:"1.5",boxSizing:"border-box",opacity:r?1:.5},onFocus:o=>{o.target.style.borderColor="#2DD4A8"},onBlur:o=>{o.target.style.borderColor="#E5E5E0"},onKeyDown:o=>{o.key==="Enter"&&(o.metaKey||o.ctrlKey)&&(o.preventDefault(),h(l))}}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",color:"#9CA3AF"},children:"Cmd+Enter to generate"}),e.jsx("button",{onClick:()=>h(l),disabled:!r||n||!l.trim(),style:{padding:"6px 16px",borderRadius:"8px",border:"none",background:"#1B3A4B",color:"#fff",fontSize:"12px",fontWeight:600,cursor:"pointer",opacity:!r||!l.trim()?.4:1},children:n?"Generating…":"Generate SysML"})]})]}),!t&&!n&&e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"#9CA3AF",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:"8px"},children:"Examples"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"5px"},children:A.map(o=>e.jsx("button",{onClick:()=>{p(o)},disabled:!r,style:{textAlign:"left",padding:"7px 11px",borderRadius:"6px",background:"#fff",border:"1px solid #E5E5E0",fontSize:"12px",color:"#374151",cursor:"pointer",opacity:r?1:.5},onMouseEnter:i=>{r&&(i.currentTarget.style.borderColor="#2DD4A8")},onMouseLeave:i=>{i.currentTarget.style.borderColor="#E5E5E0"},children:o},o))})]}),n&&e.jsxs("div",{style:{background:"#fff",border:"1px solid #E5E5E0",borderRadius:"10px",padding:"20px",textAlign:"center",color:"#9CA3AF",fontSize:"13px"},children:[e.jsx("div",{style:{marginBottom:"8px",fontSize:"20px"},children:"⟨/⟩"}),"Generating SysML v2…"]}),u&&e.jsxs("div",{style:{background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",padding:"12px",color:"#dc2626",fontSize:"13px"},children:[e.jsx("strong",{children:"Error:"})," ",u]}),t&&!n&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.jsxs("div",{style:{background:"#F0FDF9",border:"1px solid #A7F3D0",borderRadius:"8px",padding:"12px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"#065F46",marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.06em"},children:"Explanation"}),e.jsx("p",{style:{fontSize:"13px",color:"#1B3A4B",margin:0,lineHeight:"1.6"},children:t.explanation}),t.suggestedFile&&e.jsxs("div",{style:{marginTop:"8px",fontSize:"11px",color:"#6B7280"},children:["Suggested file: ",e.jsx("code",{style:{background:"#D1FAE5",padding:"1px 5px",borderRadius:"3px"},children:t.suggestedFile})]})]}),e.jsxs("div",{style:{background:"#1e293b",borderRadius:"10px",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 14px",borderBottom:"1px solid #334155"},children:[e.jsx("span",{style:{fontSize:"11px",color:"#94a3b8",fontWeight:600},children:"SysML v2"}),e.jsx("button",{onClick:j,style:{padding:"3px 10px",borderRadius:"4px",border:"none",background:y?"#059669":"#334155",color:"#fff",fontSize:"11px",cursor:"pointer",fontWeight:500},children:y?"Copied!":"Copy"})]}),e.jsx("pre",{style:{margin:0,padding:"14px 16px",fontSize:"12px",lineHeight:"1.6",color:"#e2e8f0",overflowX:"auto",fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace"},children:e.jsx("code",{children:t.sysml})})]}),e.jsxs("div",{style:{fontSize:"11px",color:"#9CA3AF",padding:"4px 0"},children:["Review the generated SysML before saving. Copy it into your project's ",e.jsx("code",{children:".sysml"})," files. The dev server will pick up the changes automatically."]}),e.jsx("button",{onClick:()=>{c(null),p("")},style:{padding:"6px 14px",borderRadius:"6px",border:"1px solid #E5E5E0",background:"#fff",color:"#374151",fontSize:"12px",cursor:"pointer",alignSelf:"flex-start"},children:"Generate another"})]})]})]})}export{F as SysmlGenerator};
@@ -1 +0,0 @@
1
- import{j as s}from"./reactflow-WKyu73tD.js";import{a as p}from"./zustand-qbFpP9Up.js";import{u as j,d as w}from"./index-CgRwea72.js";const F=[{id:"risk-control",label:"ISO 14971: Risk → Control",description:"Hazards and hazardous situations traced to risk controls",rowKinds:["Hazard","HazardousSituation"],colKinds:["RiskControl","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};