@memoarchitect/architect 0.7.2 → 0.8.27

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 (73) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/{AiWorkspace-Bu9TlIWg.js → AiWorkspace-Dp5oBDww.js} +1 -1
  3. package/dist/assets/{AnalysisWorkspace-CodmoI-v.js → AnalysisWorkspace-CNHTkSRD.js} +1 -1
  4. package/dist/assets/{ComplianceWizard-CTihkUi-.js → ComplianceWizard-CAJDtLdv.js} +1 -1
  5. package/dist/assets/DSMView-Bv9j1Vk_.js +5 -0
  6. package/dist/assets/Dashboard-BnOwnA1R.js +1 -0
  7. package/dist/assets/DhfDashboard-CQpiYHtW.js +1 -0
  8. package/dist/assets/DhfWorkbench-DHxWuiiL.js +69 -0
  9. package/dist/assets/DiagramCanvas-DtLlTvJf.js +4 -0
  10. package/dist/assets/{DiagramEditor-UJDHcAUF.js → DiagramEditor-DP_PiI7K.js} +2 -2
  11. package/dist/assets/DiagramToolbarControls-XMGLx08e.js +1 -0
  12. package/dist/assets/{ElementDetailView-10U0rr33.js → ElementDetailView-BQsWfbPD.js} +1 -1
  13. package/dist/assets/ExplorerTreeRow-CmGPHRI8.js +3 -0
  14. package/dist/assets/{ImportView-D8svP04Q.js → ImportView-YFBlvgF_.js} +1 -1
  15. package/dist/assets/{LayerGrid-DEe0Ryz-.js → LayerGrid-KXyuibWY.js} +1 -1
  16. package/dist/assets/{LayerTable-CN_b2rDr.js → LayerTable-CGsFJsKs.js} +1 -1
  17. package/dist/assets/{MaxGraphCanvas-bo8oPBct.js → MaxGraphCanvas-BNn0Jxr6.js} +1 -1
  18. package/dist/assets/{ModelDiff-xe95oVua.js → ModelDiff-CJCXuz_h.js} +1 -1
  19. package/dist/assets/{OntologyDecompositionDiagram-BL9R8bdB.js → OntologyDecompositionDiagram-5JWUI_PB.js} +1 -1
  20. package/dist/assets/{OntologyViewer-CtqNkkCn.js → OntologyViewer-DxIWCcJM.js} +2 -2
  21. package/dist/assets/{RelationshipOverlay-DL0N8Vmk.js → RelationshipOverlay-B3AN-bM-.js} +1 -1
  22. package/dist/assets/{RelationshipsSection-BoJ0aUXe.js → RelationshipsSection-DggeGBKP.js} +1 -1
  23. package/dist/assets/{ReviewDashboard-DeTge2oC.js → ReviewDashboard-Qyj8RRFp.js} +1 -1
  24. package/dist/assets/{ScenarioEditor-FAEYTHgP.js → ScenarioEditor-BIAh6tLX.js} +1 -1
  25. package/dist/assets/{StatisticsDashboard-BAZRqIPN.js → StatisticsDashboard-CtI1hlfO.js} +1 -1
  26. package/dist/assets/{SysmlCodeEditor-BBfup_Ni.js → SysmlCodeEditor-i0BHj3of.js} +117 -117
  27. package/dist/assets/{TabularView-I4LjHhoH.js → TabularView-DXxpRshk.js} +1 -1
  28. package/dist/assets/TraceabilityMatrix-qEKmDy8z.js +3 -0
  29. package/dist/assets/UiScreensWorkspace-BHhs5tcY.js +1 -0
  30. package/dist/assets/{WorkflowWizard-VwpEHt3R.js → WorkflowWizard-BjtGPRsS.js} +1 -1
  31. package/dist/assets/index-Cdkjp-H4.css +1 -0
  32. package/dist/assets/index-a2rpMs5Y.js +4067 -0
  33. package/dist/assets/{index.es-ClbJxlAQ.js → index.es-BwDQ0kmQ.js} +1 -1
  34. package/dist/assets/{jspdf.es.min-DZ68BGxk.js → jspdf.es.min-KfOikWO5.js} +3 -3
  35. package/dist/assets/{layout-providers-Dr743WlP.js → layout-providers-BSDYNZu0.js} +1 -1
  36. package/dist/assets/notation-scene-CxT28i2i.js +1 -0
  37. package/dist/assets/{reactflow-s7jmJtXx.js → reactflow-C9OlmOYw.js} +1 -1
  38. package/dist/assets/xlsx-CkFp8p6R.js +105 -0
  39. package/dist/index.html +3 -3
  40. package/dist-standalone/index.html +5504 -0
  41. package/lib/__tests__/standalone-distribution.test.d.ts +2 -0
  42. package/lib/__tests__/standalone-distribution.test.d.ts.map +1 -0
  43. package/lib/__tests__/standalone-distribution.test.js +51 -0
  44. package/lib/__tests__/standalone-distribution.test.js.map +1 -0
  45. package/lib/__tests__/supervised-child-args.test.js +21 -1
  46. package/lib/__tests__/supervised-child-args.test.js.map +1 -1
  47. package/lib/bin/memo-architect.js +15 -6
  48. package/lib/bin/memo-architect.js.map +1 -1
  49. package/lib/commands/build.d.ts.map +1 -1
  50. package/lib/commands/build.js +15 -18
  51. package/lib/commands/build.js.map +1 -1
  52. package/lib/commands/dev.d.ts +14 -0
  53. package/lib/commands/dev.d.ts.map +1 -1
  54. package/lib/commands/dev.js +40 -1
  55. package/lib/commands/dev.js.map +1 -1
  56. package/lib/feature-grants.d.ts.map +1 -1
  57. package/lib/feature-grants.js +3 -1
  58. package/lib/feature-grants.js.map +1 -1
  59. package/package.json +10 -6
  60. package/dist/assets/DSMView-BiC845df.js +0 -1
  61. package/dist/assets/Dashboard-CgnNLhKq.js +0 -1
  62. package/dist/assets/DhfDashboard-w-dJoJHU.js +0 -1
  63. package/dist/assets/DhfWorkbench-o6B_MT-0.js +0 -69
  64. package/dist/assets/DiagramCanvas-CqGqDbgT.js +0 -3
  65. package/dist/assets/DiagramToolbarControls-B2gZFJlg.js +0 -1
  66. package/dist/assets/ExplorerTreeRow-DqhF_qoO.js +0 -3
  67. package/dist/assets/TraceabilityMatrix-DbrvjqLN.js +0 -3
  68. package/dist/assets/UiScreensWorkspace-DDD_PyJs.js +0 -1
  69. package/dist/assets/editor.worker-DyuDvpVp.js +0 -26
  70. package/dist/assets/element-options-B7AgTB8R.js +0 -3
  71. package/dist/assets/index-BWMNo4wW.css +0 -1
  72. package/dist/assets/index-Bij8Q4Kg.js +0 -45
  73. package/dist/assets/notation-scene-DT8LpWVK.js +0 -1
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  </p>
10
10
 
11
11
  <p align="center">
12
- <code>memo-architect 0.7.2</code> &middot; MIT &middot; SysML v2 &middot;
12
+ <code>memo-architect 0.8.27</code> &middot; MIT &middot; SysML v2 &middot;
13
13
  ISO 14971 &middot; IEC 62304 &middot; ISO/IEC/IEEE 42010
14
14
  </p>
15
15
 
@@ -1,4 +1,4 @@
1
- import{j as e}from"./reactflow-s7jmJtXx.js";import{u as v,q as L,t as _,v as G,w as U}from"./index-Bij8Q4Kg.js";import{a}from"./zustand-CrhqMOHB.js";const V={env:"an environment variable","env-file":"the project .env file","project-settings":"project settings","user-credentials":"your saved credentials",default:"the default"},Y={anthropic:"claude-opus-5",openai:"gpt-4o"};function Q({onClose:t}){const r=v(n=>n.llmSettings),f=v(n=>n.registerLlmRequest),[s,p]=a.useState((r==null?void 0:r.provider)??"anthropic"),[u,d]=a.useState((r==null?void 0:r.model)??""),[x,l]=a.useState(""),[y,S]=a.useState(!1),[b,j]=a.useState(null),k=a.useCallback(async()=>{S(!0),j(null);const n=`llmset-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{await new Promise((c,m)=>{f(n,c,m),L(n,{provider:s,model:u.trim()||void 0,...x?{apiKey:x}:{}}),setTimeout(()=>m(new Error("The save timed out.")),2e4)}),l(""),j("Saved.")}catch(c){j((c==null?void 0:c.message)??"The settings could not be saved.")}finally{S(!1)}},[s,u,x,f]),C=a.useCallback(async()=>{S(!0),j(null);const n=`llmclear-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{await new Promise((c,m)=>{f(n,c,m),L(n,{provider:s,apiKey:""}),setTimeout(()=>m(new Error("The request timed out.")),2e4)}),j("Key removed.")}catch(c){j((c==null?void 0:c.message)??"The key could not be removed.")}finally{S(!1)}},[s,f]),w={fontSize:"11px",fontWeight:600,color:"#374151",display:"block",marginBottom:"4px"},E={width:"100%",padding:"6px 10px",border:"1px solid #E5E5E0",borderRadius:"6px",fontSize:"12px",outline:"none",background:"#fff",color:"#1B3A4B",fontFamily:"inherit"};return e.jsxs("div",{style:{padding:"14px 20px",background:"#fff",borderBottom:"1px solid #E5E5E0",display:"flex",flexDirection:"column",gap:"12px",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx("div",{style:{flex:1,fontSize:"12px",fontWeight:700,color:"#1B3A4B"},children:"LLM settings"}),e.jsx("button",{onClick:t,style:{background:"none",border:"none",color:"#9CA3AF",fontSize:"14px",cursor:"pointer"},children:"✕"})]}),e.jsxs("div",{style:{display:"flex",gap:"10px"},children:[e.jsxs("div",{style:{flex:"0 0 130px"},children:[e.jsx("label",{style:w,children:"Provider"}),e.jsxs("select",{value:s,onChange:n=>p(n.target.value),style:{...E,cursor:"pointer"},children:[e.jsx("option",{value:"anthropic",children:"Anthropic"}),e.jsx("option",{value:"openai",children:"OpenAI-compatible"})]})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:w,children:"Model"}),e.jsx("input",{value:u,onChange:n=>d(n.target.value),placeholder:Y[s]??"",style:E})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:w,children:"API key"}),r&&!r.keyEditable&&r.configured?e.jsxs("div",{style:{fontSize:"11px",color:"#6B7280",lineHeight:1.6},children:["A key is already supplied by ",V[r.keyOrigin??"default"],", which takes precedence over anything saved here. Remove it there to set a key from this screen."]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"password",value:x,onChange:n=>l(n.target.value),placeholder:r!=null&&r.configured?"Saved — type a new key to replace it":"sk-…",autoComplete:"off",style:E}),e.jsxs("div",{style:{fontSize:"10px",color:"#9CA3AF",marginTop:"4px",lineHeight:1.5},children:["Stored in ",e.jsx("code",{children:"~/.memo/credentials.json"})," with owner-only permissions — outside this project, so it is never committed. You can also set"," ",e.jsx("code",{children:"ANTHROPIC_API_KEY"})," in the environment or a project ",e.jsx("code",{children:".env"}),"."]})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx("button",{onClick:k,disabled:y,style:{padding:"6px 14px",borderRadius:"6px",border:"none",background:"#1B3A4B",color:"#fff",fontSize:"11px",fontWeight:600,cursor:y?"default":"pointer",opacity:y?.5:1},children:y?"Saving…":"Save"}),(r==null?void 0:r.configured)&&r.keyEditable&&e.jsx("button",{onClick:C,disabled:y,style:{padding:"6px 12px",borderRadius:"6px",border:"1px solid #E5E5E0",background:"transparent",color:"#dc2626",fontSize:"11px",cursor:"pointer"},children:"Remove saved key"}),b&&e.jsx("span",{style:{fontSize:"11px",color:"#6B7280"},children:b})]})]})}const X=["What hazards have no risk controls?","Show trace from requirements to verification.","Which layers have the most gaps?","How many unmitigated hazards are there?","List all SOUP components."],J=12e4;function Z(){const t=v(o=>o.llmAvailable),r=v(o=>o.llmProvider),f=v(o=>o.llmModel),s=v(o=>o.model),p=v(o=>o.registerLlmRequest),[u,d]=a.useState([]),[x,l]=a.useState([]),[y,S]=a.useState(""),[b,j]=a.useState(!1),[k,C]=a.useState(!1),[w,E]=a.useState(!1),[n,c]=a.useState(!1),[m,B]=a.useState(new Set),[D,F]=a.useState(null),M=a.useRef(null),W=a.useRef(null);a.useEffect(()=>{var o;(o=M.current)==null||o.scrollIntoView({behavior:"smooth"})},[u,b]);const I=a.useCallback((o,h)=>new Promise((g,i)=>{p(o,g,i),h(),setTimeout(()=>i(new Error("The request timed out after 2 minutes.")),J)}),[p]),T=a.useCallback(async o=>{if(!o.trim()||b)return;const h=o.trim();S(""),d(i=>[...i,{role:"user",content:h}]),j(!0),F(null);const g=`chat-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{const i=await I(g,()=>_(g,h,x,k));l(i.messages),d(A=>[...A,{role:"assistant",content:i.truncated?`${i.answer}
1
+ import{j as e}from"./reactflow-C9OlmOYw.js";import{u as v,q as L,t as _,v as G,w as U}from"./index-a2rpMs5Y.js";import{a}from"./zustand-CrhqMOHB.js";const V={env:"an environment variable","env-file":"the project .env file","project-settings":"project settings","user-credentials":"your saved credentials",default:"the default"},Y={anthropic:"claude-opus-5",openai:"gpt-4o"};function Q({onClose:t}){const r=v(n=>n.llmSettings),f=v(n=>n.registerLlmRequest),[s,p]=a.useState((r==null?void 0:r.provider)??"anthropic"),[u,d]=a.useState((r==null?void 0:r.model)??""),[x,l]=a.useState(""),[y,S]=a.useState(!1),[b,j]=a.useState(null),k=a.useCallback(async()=>{S(!0),j(null);const n=`llmset-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{await new Promise((c,m)=>{f(n,c,m),L(n,{provider:s,model:u.trim()||void 0,...x?{apiKey:x}:{}}),setTimeout(()=>m(new Error("The save timed out.")),2e4)}),l(""),j("Saved.")}catch(c){j((c==null?void 0:c.message)??"The settings could not be saved.")}finally{S(!1)}},[s,u,x,f]),C=a.useCallback(async()=>{S(!0),j(null);const n=`llmclear-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{await new Promise((c,m)=>{f(n,c,m),L(n,{provider:s,apiKey:""}),setTimeout(()=>m(new Error("The request timed out.")),2e4)}),j("Key removed.")}catch(c){j((c==null?void 0:c.message)??"The key could not be removed.")}finally{S(!1)}},[s,f]),w={fontSize:"11px",fontWeight:600,color:"#374151",display:"block",marginBottom:"4px"},E={width:"100%",padding:"6px 10px",border:"1px solid #E5E5E0",borderRadius:"6px",fontSize:"12px",outline:"none",background:"#fff",color:"#1B3A4B",fontFamily:"inherit"};return e.jsxs("div",{style:{padding:"14px 20px",background:"#fff",borderBottom:"1px solid #E5E5E0",display:"flex",flexDirection:"column",gap:"12px",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx("div",{style:{flex:1,fontSize:"12px",fontWeight:700,color:"#1B3A4B"},children:"LLM settings"}),e.jsx("button",{onClick:t,style:{background:"none",border:"none",color:"#9CA3AF",fontSize:"14px",cursor:"pointer"},children:"✕"})]}),e.jsxs("div",{style:{display:"flex",gap:"10px"},children:[e.jsxs("div",{style:{flex:"0 0 130px"},children:[e.jsx("label",{style:w,children:"Provider"}),e.jsxs("select",{value:s,onChange:n=>p(n.target.value),style:{...E,cursor:"pointer"},children:[e.jsx("option",{value:"anthropic",children:"Anthropic"}),e.jsx("option",{value:"openai",children:"OpenAI-compatible"})]})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:w,children:"Model"}),e.jsx("input",{value:u,onChange:n=>d(n.target.value),placeholder:Y[s]??"",style:E})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:w,children:"API key"}),r&&!r.keyEditable&&r.configured?e.jsxs("div",{style:{fontSize:"11px",color:"#6B7280",lineHeight:1.6},children:["A key is already supplied by ",V[r.keyOrigin??"default"],", which takes precedence over anything saved here. Remove it there to set a key from this screen."]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"password",value:x,onChange:n=>l(n.target.value),placeholder:r!=null&&r.configured?"Saved — type a new key to replace it":"sk-…",autoComplete:"off",style:E}),e.jsxs("div",{style:{fontSize:"10px",color:"#9CA3AF",marginTop:"4px",lineHeight:1.5},children:["Stored in ",e.jsx("code",{children:"~/.memo/credentials.json"})," with owner-only permissions — outside this project, so it is never committed. You can also set"," ",e.jsx("code",{children:"ANTHROPIC_API_KEY"})," in the environment or a project ",e.jsx("code",{children:".env"}),"."]})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx("button",{onClick:k,disabled:y,style:{padding:"6px 14px",borderRadius:"6px",border:"none",background:"#1B3A4B",color:"#fff",fontSize:"11px",fontWeight:600,cursor:y?"default":"pointer",opacity:y?.5:1},children:y?"Saving…":"Save"}),(r==null?void 0:r.configured)&&r.keyEditable&&e.jsx("button",{onClick:C,disabled:y,style:{padding:"6px 12px",borderRadius:"6px",border:"1px solid #E5E5E0",background:"transparent",color:"#dc2626",fontSize:"11px",cursor:"pointer"},children:"Remove saved key"}),b&&e.jsx("span",{style:{fontSize:"11px",color:"#6B7280"},children:b})]})]})}const X=["What hazards have no risk controls?","Show trace from requirements to verification.","Which layers have the most gaps?","How many unmitigated hazards are there?","List all SOUP components."],J=12e4;function Z(){const t=v(o=>o.llmAvailable),r=v(o=>o.llmProvider),f=v(o=>o.llmModel),s=v(o=>o.model),p=v(o=>o.registerLlmRequest),[u,d]=a.useState([]),[x,l]=a.useState([]),[y,S]=a.useState(""),[b,j]=a.useState(!1),[k,C]=a.useState(!1),[w,E]=a.useState(!1),[n,c]=a.useState(!1),[m,B]=a.useState(new Set),[D,F]=a.useState(null),M=a.useRef(null),W=a.useRef(null);a.useEffect(()=>{var o;(o=M.current)==null||o.scrollIntoView({behavior:"smooth"})},[u,b]);const I=a.useCallback((o,h)=>new Promise((g,i)=>{p(o,g,i),h(),setTimeout(()=>i(new Error("The request timed out after 2 minutes.")),J)}),[p]),T=a.useCallback(async o=>{if(!o.trim()||b)return;const h=o.trim();S(""),d(i=>[...i,{role:"user",content:h}]),j(!0),F(null);const g=`chat-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{const i=await I(g,()=>_(g,h,x,k));l(i.messages),d(A=>[...A,{role:"assistant",content:i.truncated?`${i.answer}
2
2
 
3
3
  _(Stopped at the tool-call limit for one turn — ask again to continue.)_`:i.answer,changes:i.proposedChanges.length?i.proposedChanges:void 0}]),i.proposedChanges.length&&B(A=>{const z=new Set(A);for(const R of i.proposedChanges)z.add(R.id);return z})}catch(i){d(A=>[...A,{role:"assistant",content:(i==null?void 0:i.message)??"Unknown error",error:!0}])}finally{j(!1)}},[b,x,k,I]),P=o=>{o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),T(y))},q=o=>{B(h=>{const g=new Set(h);return g.has(o)?g.delete(o):g.add(o),g})},O=a.useCallback(async o=>{const h=o.filter(i=>m.has(i.id));if(h.length===0||n)return;c(!0),F(null);const g=`apply-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{const i=await I(g,()=>G(g,h)),A=new Set(i.applied);d(z=>z.map(R=>R.changes?{...R,changes:R.changes.filter(N=>!A.has(N.id))}:R)),F(i.failed.length?`Applied ${i.applied.length}. Failed: ${i.failed.map(z=>z.error).join("; ")}`:`Applied ${i.applied.length} change${i.applied.length===1?"":"s"} to the model source.`)}catch(i){F((i==null?void 0:i.message)??"The changes could not be applied.")}finally{c(!1)}},[m,n,I]),K=o=>{const h=new Set(o.map(g=>g.id));d(g=>g.map(i=>i.changes?{...i,changes:i.changes.filter(A=>!h.has(A.id))}:i))},H=()=>{d([]),l([]),B(new Set),F(null)};return s?e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"#F7F7F5",overflow:"hidden"},children:[e.jsxs("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",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:700,color:"#1B3A4B"},children:"Model Assistant"}),e.jsx("div",{style:{fontSize:"11px",color:t?"#059669":"#dc2626",marginTop:"1px"},children:t?`${r??"LLM"} · ${f??"unknown model"}`:"No API key configured"})]}),e.jsx("button",{onClick:()=>E(o=>!o),title:"LLM settings",style:{background:w?"#F3F4F6":"none",border:"1px solid #E5E5E0",borderRadius:"6px",padding:"4px 8px",fontSize:"12px",color:"#374151",cursor:"pointer"},children:"⚙ Settings"})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"8px",fontSize:"11px",color:"#6B7280",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:k,onChange:o=>C(o.target.checked),style:{cursor:"pointer"}}),"Suggest edits — the assistant may propose model changes for your approval"]})]}),w&&e.jsx(Q,{onClose:()=>E(!1)}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px",display:"flex",flexDirection:"column",gap:"12px"},children:[u.length===0&&e.jsxs("div",{style:{paddingTop:"8px"},children:[e.jsx("div",{style:{fontSize:"12px",color:"#9CA3AF",marginBottom:"12px"},children:"Ask about your model in plain English. The assistant can look up any element, follow traceability chains, and read validation gaps."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:X.map(o=>e.jsx("button",{onClick:()=>T(o),disabled:!t||b,style:{textAlign:"left",padding:"8px 12px",borderRadius:"8px",background:"#fff",border:"1px solid #E5E5E0",fontSize:"12px",color:"#374151",cursor:"pointer",transition:"border-color 0.1s",opacity:t?1:.5},onMouseEnter:h=>{t&&(h.currentTarget.style.borderColor="#2DD4A8")},onMouseLeave:h=>{h.currentTarget.style.borderColor="#E5E5E0"},children:o},o))})]}),u.map((o,h)=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:o.role==="user"?"row-reverse":"row",gap:"8px",alignItems:"flex-start"},children:[e.jsx("div",{style:{width:"24px",height:"24px",borderRadius:"50%",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:o.role==="user"?"#1B3A4B":"#2DD4A815",fontSize:"10px",fontWeight:700,color:o.role==="user"?"#fff":"#2DD4A8",marginTop:"2px"},children:o.role==="user"?"U":"✦"}),e.jsx("div",{style:{maxWidth:"85%",padding:"10px 12px",borderRadius:"10px",background:o.role==="user"?"#1B3A4B":o.error?"#fef2f2":"#fff",color:o.role==="user"?"#fff":o.error?"#dc2626":"#1B3A4B",fontSize:"13px",lineHeight:"1.6",border:o.role==="assistant"?`1px solid ${o.error?"#fecaca":"#E5E5E0"}`:"none",whiteSpace:"pre-wrap"},children:o.content})]}),o.changes&&o.changes.length>0&&e.jsx(ee,{changes:o.changes,approved:m,onToggle:q,onApply:()=>O(o.changes),onDiscard:()=>K(o.changes),applying:n})]},h)),D&&e.jsx("div",{style:{fontSize:"11px",color:"#374151",background:"#fff",border:"1px solid #E5E5E0",borderRadius:"8px",padding:"8px 12px"},children:D}),b&&e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"flex-start"},children:[e.jsx("div",{style:{width:"24px",height:"24px",borderRadius:"50%",background:"#2DD4A815",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",color:"#2DD4A8",fontWeight:700},children:"✦"}),e.jsx("div",{style:{padding:"10px 14px",borderRadius:"10px",background:"#fff",border:"1px solid #E5E5E0",display:"flex",gap:"4px",alignItems:"center"},children:e.jsx(ne,{})})]}),e.jsx("div",{ref:M})]}),e.jsxs("div",{style:{padding:"12px 16px",borderTop:"1px solid #E5E5E0",background:"#fff",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"flex-end"},children:[e.jsx("textarea",{ref:W,value:y,onChange:o=>S(o.target.value),onKeyDown:P,disabled:!t||b,placeholder:t?"Ask a question… (Enter to send, Shift+Enter for newline)":"Add an API key in Settings to start",rows:2,style:{flex:1,padding:"8px 12px",border:"1px solid #E5E5E0",borderRadius:"8px",fontSize:"13px",resize:"none",fontFamily:"inherit",outline:"none",background:"#F7F7F5",color:"#1B3A4B",lineHeight:"1.5",opacity:t?1:.5},onFocus:o=>{o.target.style.borderColor="#2DD4A8"},onBlur:o=>{o.target.style.borderColor="#E5E5E0"}}),e.jsx("button",{onClick:()=>T(y),disabled:!t||b||!y.trim(),style:{padding:"8px 14px",borderRadius:"8px",border:"none",background:"#1B3A4B",color:"#fff",fontSize:"12px",fontWeight:600,cursor:"pointer",flexShrink:0,opacity:!t||!y.trim()?.4:1,transition:"opacity 0.15s"},children:"Send"})]}),u.length>0&&e.jsx("button",{onClick:H,style:{marginTop:"6px",background:"none",border:"none",color:"#9CA3AF",fontSize:"11px",cursor:"pointer",padding:0},children:"Clear conversation"})]})]}):e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#9CA3AF"},children:"Waiting for model data…"})}function ee({changes:t,approved:r,onToggle:f,onApply:s,onDiscard:p,applying:u}){const d=t.filter(x=>r.has(x.id)).length;return e.jsxs("div",{style:{marginLeft:"32px",border:"1px solid #FCD34D",borderRadius:"10px",background:"#FFFBEB",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid #FDE68A",fontSize:"11px",fontWeight:700,color:"#92400E"},children:[t.length," proposed change",t.length===1?"":"s"," — nothing is written until you apply"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:t.map(x=>e.jsxs("label",{style:{display:"flex",gap:"8px",alignItems:"flex-start",padding:"8px 12px",borderBottom:"1px solid #FDE68A",cursor:"pointer",fontSize:"12px"},children:[e.jsx("input",{type:"checkbox",checked:r.has(x.id),onChange:()=>f(x.id),style:{marginTop:"2px",cursor:"pointer"}}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:600,color:"#1B3A4B"},children:te(x)}),e.jsx("div",{style:{color:"#92400E",marginTop:"2px"},children:x.summary}),e.jsx(oe,{change:x})]})]},x.id))}),e.jsxs("div",{style:{padding:"8px 12px",display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx("button",{onClick:s,disabled:d===0||u,style:{padding:"6px 12px",borderRadius:"6px",border:"none",background:"#92400E",color:"#fff",fontSize:"11px",fontWeight:600,cursor:d===0||u?"default":"pointer",opacity:d===0||u?.4:1},children:u?"Applying…":`Apply ${d} selected`}),e.jsx("button",{onClick:p,disabled:u,style:{padding:"6px 12px",borderRadius:"6px",border:"1px solid #FDE68A",background:"transparent",color:"#92400E",fontSize:"11px",cursor:"pointer"},children:"Discard all"})]})]})}function te(t){switch(t.kind){case"create-element":return`Create ${t.elementKind} · ${t.elementId}`;case"update-element":return`Update · ${t.elementId}`;case"create-relationship":return`Relate · ${t.sourceId} → ${t.targetId}`;case"delete-relationship":return`Remove relationship · ${t.relationshipId}`}}function oe({change:t}){const r={fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"11px",color:"#374151",marginTop:"4px"};if(t.kind==="create-element"){const f=Object.entries(t.attributes??{});return e.jsxs("div",{style:r,children:[e.jsxs("div",{children:["name = ",t.name]}),t.layer&&e.jsxs("div",{children:["layer = ",t.layer]}),f.map(([s,p])=>e.jsxs("div",{children:[s," = ",p]},s))]})}if(t.kind==="update-element"){const f=new Set([...Object.keys(t.changes.attributes??{}),...t.changes.name!==void 0?["name"]:[],...t.changes.doc!==void 0?["doc"]:[]]);return e.jsx("div",{style:r,children:[...f].map(s=>{var d,x;const p=s==="name"?t.before.name:s==="doc"?t.before.doc:(d=t.before.attributes)==null?void 0:d[s],u=s==="name"?t.changes.name:s==="doc"?t.changes.doc:(x=t.changes.attributes)==null?void 0:x[s];return e.jsxs("div",{children:[s,": ",e.jsx("span",{style:{color:"#dc2626",textDecoration:"line-through"},children:p||"∅"})," → ",e.jsx("span",{style:{color:"#059669"},children:u})]},s)})})}return t.kind==="create-relationship"?e.jsxs("div",{style:r,children:[t.sourceId," —",t.relationshipType,"→ ",t.targetId]}):e.jsxs("div",{style:r,children:[t.sourceId," —",t.relationshipType,"→ ",t.targetId]})}function ne(){return e.jsxs("span",{style:{display:"inline-flex",gap:"3px",alignItems:"center"},children:[[0,1,2].map(t=>e.jsx("span",{style:{width:"5px",height:"5px",borderRadius:"50%",background:"#9CA3AF",animation:"llm-pulse 1.2s ease-in-out infinite",animationDelay:`${t*.2}s`}},t)),e.jsx("style",{children:"@keyframes llm-pulse{0%,80%,100%{opacity:0.3}40%{opacity:1}}"})]})}const re=["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 RiskControlMeasure that mitigates OverInfusion by adding a flow rate sensor."];function se(){const t=v(n=>n.llmAvailable),r=v(n=>n.llmProvider),f=v(n=>n.llmModel),s=v(n=>n.registerLlmRequest),[p,u]=a.useState(""),[d,x]=a.useState(!1),[l,y]=a.useState(null),[S,b]=a.useState(null),[j,k]=a.useState(!1),C=a.useCallback(async n=>{if(!n.trim()||d)return;x(!0),y(null),b(null),k(!1);const c=`gen-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{const m=await new Promise((B,D)=>{s(c,B,D),U(c,n.trim()),setTimeout(()=>D(new Error("Request timed out after 60 seconds.")),6e4)});y(m)}catch(m){b((m==null?void 0:m.message)??"Unknown error")}finally{x(!1)}},[d,s]),w=()=>{l!=null&&l.sysml&&navigator.clipboard.writeText(l.sysml).then(()=>{k(!0),setTimeout(()=>k(!1),2e3)})},E=n=>(l==null?void 0:l.diagnostics.filter(c=>c.domain===n))??[];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:t?"#059669":"#dc2626",marginTop:"1px"},children:t?`${r??"LLM"} · ${f??"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:p,onChange:n=>u(n.target.value),disabled:!t||d,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:t?1:.5},onFocus:n=>{n.target.style.borderColor="#2DD4A8"},onBlur:n=>{n.target.style.borderColor="#E5E5E0"},onKeyDown:n=>{n.key==="Enter"&&(n.metaKey||n.ctrlKey)&&(n.preventDefault(),C(p))}}),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:()=>C(p),disabled:!t||d||!p.trim(),style:{padding:"6px 16px",borderRadius:"8px",border:"none",background:"#1B3A4B",color:"#fff",fontSize:"12px",fontWeight:600,cursor:"pointer",opacity:!t||!p.trim()?.4:1},children:d?"Generating…":"Generate SysML"})]})]}),!l&&!d&&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:re.map(n=>e.jsx("button",{onClick:()=>{u(n)},disabled:!t,style:{textAlign:"left",padding:"7px 11px",borderRadius:"6px",background:"#fff",border:"1px solid #E5E5E0",fontSize:"12px",color:"#374151",cursor:"pointer",opacity:t?1:.5},onMouseEnter:c=>{t&&(c.currentTarget.style.borderColor="#2DD4A8")},onMouseLeave:c=>{c.currentTarget.style.borderColor="#E5E5E0"},children:n},n))})]}),d&&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…"]}),S&&e.jsxs("div",{style:{background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",padding:"12px",color:"#dc2626",fontSize:"13px"},children:[e.jsx("strong",{children:"Error:"})," ",S]}),l&&!d&&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:l.explanation}),l.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:l.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:w,style:{padding:"3px 10px",borderRadius:"4px",border:"none",background:j?"#059669":"#334155",color:"#fff",fontSize:"11px",cursor:"pointer",fontWeight:500},children:j?"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:l.sysml})})]}),e.jsxs("details",{style:{background:"#fff",border:"1px solid #E5E5E0",borderRadius:"8px",padding:"10px 12px"},children:[e.jsxs("summary",{style:{cursor:"pointer",fontSize:"12px",fontWeight:600},children:["Source diff",l.initialSysml===l.sysml?" (no repair changes)":""]}),e.jsxs("pre",{style:{margin:"8px 0 0",fontSize:"11px",whiteSpace:"pre-wrap"},children:[l.initialSysml??l.sysml,l.initialSysml!==l.sysml?`
4
4
 
@@ -1,4 +1,4 @@
1
- import{j as e}from"./reactflow-s7jmJtXx.js";import{a as l}from"./zustand-CrhqMOHB.js";import{u as O,M as N}from"./index-Bij8Q4Kg.js";const _="memo.analysis.notebooks.v1",I="root",k={folders:[{id:I,name:"Notebooks"}],notebooks:[]};function R(){try{const n=localStorage.getItem(_);if(!n)return k;const o=JSON.parse(n);return!Array.isArray(o.folders)||!Array.isArray(o.notebooks)?k:o}catch{return k}}const C=[{template:"part-inventory",title:"Part inventory",description:"List part usages and their owners.",icon:"▦"},{template:"requirements-review",title:"Requirements review",description:"List requirements and their declared text.",icon:"☑"},{template:"ownership-tree",title:"Ownership tree",description:"Print the model hierarchy for review.",icon:"⌘"},{template:"syside-part-api",title:"Syside live model API",description:"Query typed PartUsage elements directly from SysML v2 files.",icon:"⌁"}];function z(n){switch(n){case"part-inventory":return[`# Part inventory from the current MEMO model snapshot
1
+ import{j as e}from"./reactflow-C9OlmOYw.js";import{a as l}from"./zustand-CrhqMOHB.js";import{u as O,M as N}from"./index-a2rpMs5Y.js";const _="memo.analysis.notebooks.v1",I="root",k={folders:[{id:I,name:"Notebooks"}],notebooks:[]};function R(){try{const n=localStorage.getItem(_);if(!n)return k;const o=JSON.parse(n);return!Array.isArray(o.folders)||!Array.isArray(o.notebooks)?k:o}catch{return k}}const C=[{template:"part-inventory",title:"Part inventory",description:"List part usages and their owners.",icon:"▦"},{template:"requirements-review",title:"Requirements review",description:"List requirements and their declared text.",icon:"☑"},{template:"ownership-tree",title:"Ownership tree",description:"Print the model hierarchy for review.",icon:"⌘"},{template:"syside-part-api",title:"Syside live model API",description:"Query typed PartUsage elements directly from SysML v2 files.",icon:"⌁"}];function z(n){switch(n){case"part-inventory":return[`# Part inventory from the current MEMO model snapshot
2
2
  `,`parts = [element for element in elements if 'part' in (element.get('kind', '') + ' ' + element.get('construct', '')).lower()]
3
3
  `,`[(part.get('shortId'), part.get('name'), part.get('kind')) for part in parts[:100]]
4
4
  `];case"requirements-review":return[`# Requirements review from the current MEMO model snapshot
@@ -1 +1 @@
1
- import{j as e}from"./reactflow-s7jmJtXx.js";import{a as g}from"./zustand-CrhqMOHB.js";import{u as j,h as k}from"./index-Bij8Q4Kg.js";const C=[{id:"iso-14971",name:"ISO 14971",description:"Risk Management for Medical Devices",steps:[{id:"hazard-identification",label:"Hazard Identification",description:"Identify hazards and hazardous situations"},{id:"risk-estimation",label:"Risk Estimation",description:"Estimate severity and probability for each hazardous situation"},{id:"control-measures",label:"Risk Controls",description:"Define risk control measures and link to hazards"},{id:"verification",label:"Verification",description:"Verify risk control effectiveness"},{id:"summary",label:"Summary",description:"Review compliance status"}],requiredKinds:["Hazard","HazardousSituation","Harm","RiskControlMeasure"],requiredRelationships:["causes","leadsTo","mitigates"]},{id:"iec-62304",name:"IEC 62304",description:"Software Lifecycle for Medical Devices",steps:[{id:"hazard-identification",label:"Software Items",description:"Identify software items and their safety classification"},{id:"risk-estimation",label:"Architecture",description:"Review software architecture decomposition"},{id:"control-measures",label:"Requirements Tracing",description:"Trace software requirements to system requirements"},{id:"verification",label:"Verification",description:"Verify test coverage for software items"},{id:"summary",label:"Summary",description:"Review compliance status"}],requiredKinds:["SoftwareComponent","SoftwareModule","Requirement","Test"],requiredRelationships:["decomposedBy","traceTo","verify"]}];function w(i){if(!i)return[];const d=Object.values(i.elements),a=[],o=d.filter(n=>n.kind==="Hazard"),l=d.filter(n=>n.kind==="HazardousSituation"),u=d.filter(n=>n.kind==="Harm"),p=d.filter(n=>n.kind==="RiskControlMeasure");a.push({label:"Hazards identified",status:o.length>0?"pass":"fail",detail:`${o.length} hazards found`,elementIds:o.map(n=>n.id)}),a.push({label:"Hazardous situations linked",status:l.length>0?"pass":"warning",detail:`${l.length} hazardous situations`,elementIds:l.map(n=>n.id)}),a.push({label:"Harms documented",status:u.length>0?"pass":"warning",detail:`${u.length} harms identified`,elementIds:u.map(n=>n.id)});const c=new Set(i.relationships.filter(n=>n.type==="mitigates").map(n=>n.targetId)),t=o.filter(n=>!c.has(n.id));a.push({label:"Risk controls applied",status:t.length===0&&o.length>0?"pass":t.length>0?"fail":"warning",detail:t.length>0?`${t.length} hazards without controls`:`${p.length} controls applied`,elementIds:t.map(n=>n.id)});const h=new Set(i.relationships.filter(n=>n.type==="verify").map(n=>n.targetId)),f=p.filter(n=>!h.has(n.id));return a.push({label:"Controls verified",status:f.length===0&&p.length>0?"pass":f.length>0?"warning":"fail",detail:f.length>0?`${f.length} controls not verified`:`All ${p.length} controls verified`,elementIds:f.map(n=>n.id)}),a}function E(i){if(!i)return[];const d=Object.values(i.elements),a=[],o=d.filter(t=>t.kind==="SoftwareComponent"||t.kind==="SoftwareModule"),l=d.filter(t=>t.kind==="Requirement"),u=d.filter(t=>t.kind==="Test");a.push({label:"Software items identified",status:o.length>0?"pass":"fail",detail:`${o.length} software items`,elementIds:o.map(t=>t.id)}),a.push({label:"Software requirements defined",status:l.length>0?"pass":"fail",detail:`${l.length} software requirements`,elementIds:l.map(t=>t.id)});const p=new Set(i.relationships.filter(t=>t.type==="traceTo").map(t=>t.sourceId)),c=l.filter(t=>!p.has(t.id));return a.push({label:"Requirements traced",status:c.length===0&&l.length>0?"pass":c.length>0?"warning":"fail",detail:c.length>0?`${c.length} requirements not traced`:"All requirements traced",elementIds:c.map(t=>t.id)}),a.push({label:"Test coverage",status:u.length>0?"pass":"warning",detail:`${u.length} tests defined`,elementIds:u.map(t=>t.id)}),a}function A(){const i=j(d=>d.availableOntologies);return g.useMemo(()=>{const d=new Map;for(const a of i)for(const o of a.layers)for(const l of o.kinds)l.standard&&d.set(l.standard,(d.get(l.standard)??0)+1);return Array.from(d.entries()).map(([a,o])=>({standard:a,label:a.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase()),kindCount:o})).sort((a,o)=>a.standard.localeCompare(o.standard))},[i])}function z(){const i=j(s=>s.model),d=j(s=>s.selectElement),[a,o]=g.useState(null),[l,u]=g.useState(0),p=A(),c=C.find(s=>s.id===a),t=c==null?void 0:c.steps[l],h=g.useMemo(()=>!a||!i?[]:a==="iso-14971"?w(i):a==="iec-62304"?E(i):[],[a,i]),f=h.filter(s=>s.status==="pass").length,n=h.length,x=n>0?Math.round(f/n*100):0,v={pass:"#2ECC71",warning:"#F39C12",fail:"#E74C3C"},N={pass:"✓",warning:"⚠",fail:"✗"},y=g.useMemo(()=>{if(!i||!t)return[];const s=Object.values(i.elements);switch(t.id){case"hazard-identification":return a==="iso-14971"?s.filter(r=>r.kind==="Hazard"||r.kind==="HazardousSituation"):s.filter(r=>r.kind==="SoftwareComponent"||r.kind==="SoftwareModule");case"risk-estimation":return a==="iso-14971"?s.filter(r=>r.kind==="HazardousSituation"||r.kind==="Harm"):s.filter(r=>r.kind==="SoftwareComponent"||r.kind==="Subsystem"||r.kind==="Component");case"control-measures":return a==="iso-14971"?s.filter(r=>r.kind==="RiskControlMeasure"):s.filter(r=>r.kind==="Requirement"||r.kind==="Requirement");case"verification":return s.filter(r=>r.kind==="Test");default:return[]}},[i,t,a]);return a?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.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{o(null),u(0)},className:"text-xs px-1.5 py-0.5 rounded",style:{color:"rgba(255,255,255,0.6)",background:"rgba(255,255,255,0.1)"},children:"←"}),e.jsx("h2",{className:"text-sm font-bold tracking-wide",style:{color:"#2DD4A8"},children:c.name})]}),e.jsx("p",{className:"text-xs mt-0.5",style:{color:"rgba(255,255,255,0.6)"},children:c.description})]}),e.jsxs("div",{className:"px-4 py-3",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-xs font-medium",style:{color:"#374151"},children:"Compliance"}),e.jsxs("span",{className:"text-xs font-bold",style:{color:x>=80?"#2ECC71":x>=50?"#F39C12":"#E74C3C"},children:[x,"%"]})]}),e.jsx("div",{className:"w-full h-1.5 rounded-full",style:{background:"#F3F4F6"},children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${x}%`,background:x>=80?"#2ECC71":x>=50?"#F39C12":"#E74C3C"}})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:c.steps.map((s,r)=>{const m=l===r,b=r<l;return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer mx-1 rounded-lg",style:{background:m?"#2DD4A818":"transparent",fontWeight:m?500:400},onMouseEnter:F=>{m||(F.currentTarget.style.background="#F0F0ED")},onMouseLeave:F=>{m||(F.currentTarget.style.background=m?"#2DD4A818":"transparent")},onClick:()=>u(r),children:[e.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-xs flex-shrink-0",style:{background:m?"#2DD4A8":b?"#2ECC7130":"#F3F4F6",color:m?"#FFFFFF":b?"#2ECC71":"#9CA3AF"},children:b?"✓":r+1}),e.jsx("span",{className:"text-xs",style:{color:m?"#1B3A4B":"#6B7280"},children:s.label})]},s.id)})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",style:{background:"#F7F7F5"},children:e.jsx("div",{className:"max-w-3xl",children:t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("h2",{className:"text-lg font-semibold",style:{color:"#374151"},children:t.label}),e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"#F3F4F6",color:"#9CA3AF"},children:["Step ",l+1," of ",c.steps.length]})]}),e.jsx("p",{className:"text-sm mb-6",style:{color:"#9CA3AF"},children:t.description}),t.id==="summary"?e.jsx("div",{className:"space-y-2",children:h.map((s,r)=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg",style:{background:"#FFFFFF",border:`1px solid ${v[s.status]}40`},children:[e.jsx("span",{className:"text-sm font-bold",style:{color:v[s.status]},children:N[s.status]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-xs font-medium",style:{color:"#374151"},children:s.label}),e.jsx("div",{className:"text-xs",style:{color:"#9CA3AF"},children:s.detail})]}),s.elementIds&&s.elementIds.length>0&&s.status!=="pass"&&e.jsx("button",{onClick:()=>d(s.elementIds[0]),className:"text-xs px-2 py-0.5 rounded",style:{background:"#4A90D915",color:"#4A90D9"},children:"View"})]},r))}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"mb-4",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"#6B7280"},children:["Relevant Elements (",y.length,")"]}),y.length===0&&e.jsx("div",{className:"p-4 rounded-lg text-center text-xs",style:{background:"#FEF2F2",border:"1px solid #FECACA",color:"#E74C3C"},children:"No elements found for this step. Create the required element types in your .sysml files."}),e.jsx("div",{className:"space-y-1",children:y.map(s=>{const r=i.relationships.filter(m=>m.sourceId===s.id||m.targetId===s.id);return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg cursor-pointer text-xs",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},onMouseEnter:m=>m.currentTarget.style.background="#F0F0ED",onMouseLeave:m=>m.currentTarget.style.background="#FFFFFF",onClick:()=>d(s.id),children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:k[s.layer]||"#95A5A6"}}),e.jsx("span",{className:"font-medium flex-1 truncate",style:{color:"#374151"},children:s.name}),e.jsx("span",{className:"px-1.5 py-0.5 rounded",style:{background:(k[s.layer]||"#95A5A6")+"18",color:k[s.layer]||"#95A5A6"},children:s.kind}),e.jsxs("span",{style:{color:"#9CA3AF"},children:[r.length," rels"]})]},s.id)})})]})}),e.jsxs("div",{className:"flex items-center gap-2 mt-6 pt-4",style:{borderTop:"1px solid #E5E5E0"},children:[l>0&&e.jsxs("button",{onClick:()=>u(l-1),className:"px-4 py-2 text-xs rounded-lg",style:{background:"#F3F4F6",color:"#6B7280"},children:["←"," Previous"]}),e.jsx("div",{className:"flex-1"}),l<c.steps.length-1&&e.jsxs("button",{onClick:()=>u(l+1),className:"px-4 py-2 text-xs rounded-lg font-medium",style:{background:"#2DD4A8",color:"#FFFFFF"},children:["Next ","→"]})]})]})})})]}):e.jsx("div",{className:"flex-1 overflow-y-auto p-8",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"max-w-2xl mx-auto",children:[e.jsx("h2",{className:"text-lg font-semibold mb-1",style:{color:"#374151"},children:"Compliance Wizard"}),e.jsx("p",{className:"text-sm mb-6",style:{color:"#9CA3AF"},children:"Select a standard to walk through compliance requirements step by step."}),e.jsx("div",{className:"space-y-3",children:C.map(s=>e.jsxs("button",{onClick:()=>{o(s.id),u(0)},className:"w-full text-left p-4 rounded-lg transition-colors",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},onMouseEnter:r=>r.currentTarget.style.borderColor="#2DD4A8",onMouseLeave:r=>r.currentTarget.style.borderColor="#E5E5E0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-semibold",style:{color:"#1B3A4B"},children:s.name}),e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"#F3F4F6",color:"#6B7280"},children:[s.steps.length," steps"]})]}),e.jsx("p",{className:"text-xs mt-1",style:{color:"#6B7280"},children:s.description})]},s.id))}),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mt-8 mb-3",style:{color:"#6B7280"},children:"Discovered Standards"}),e.jsx("div",{className:"space-y-2",children:p.map(s=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:"#7C3AED"}}),e.jsx("span",{className:"text-sm font-medium flex-1",style:{color:"#374151"},children:s.label}),e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"#F3F4F6",color:"#6B7280"},children:[s.kindCount," ",s.kindCount===1?"kind":"kinds"]})]},s.standard))})]})]})})}export{z as ComplianceWizard};
1
+ import{j as e}from"./reactflow-C9OlmOYw.js";import{a as g}from"./zustand-CrhqMOHB.js";import{u as j,h as k}from"./index-a2rpMs5Y.js";const C=[{id:"iso-14971",name:"ISO 14971",description:"Risk Management for Medical Devices",steps:[{id:"hazard-identification",label:"Hazard Identification",description:"Identify hazards and hazardous situations"},{id:"risk-estimation",label:"Risk Estimation",description:"Estimate severity and probability for each hazardous situation"},{id:"control-measures",label:"Risk Controls",description:"Define risk control measures and link to hazards"},{id:"verification",label:"Verification",description:"Verify risk control effectiveness"},{id:"summary",label:"Summary",description:"Review compliance status"}],requiredKinds:["Hazard","HazardousSituation","Harm","RiskControlMeasure"],requiredRelationships:["causes","leadsTo","mitigates"]},{id:"iec-62304",name:"IEC 62304",description:"Software Lifecycle for Medical Devices",steps:[{id:"hazard-identification",label:"Software Items",description:"Identify software items and their safety classification"},{id:"risk-estimation",label:"Architecture",description:"Review software architecture decomposition"},{id:"control-measures",label:"Requirements Tracing",description:"Trace software requirements to system requirements"},{id:"verification",label:"Verification",description:"Verify test coverage for software items"},{id:"summary",label:"Summary",description:"Review compliance status"}],requiredKinds:["SoftwareComponent","SoftwareModule","Requirement","Test"],requiredRelationships:["decomposedBy","traceTo","verify"]}];function w(i){if(!i)return[];const d=Object.values(i.elements),a=[],o=d.filter(n=>n.kind==="Hazard"),l=d.filter(n=>n.kind==="HazardousSituation"),u=d.filter(n=>n.kind==="Harm"),p=d.filter(n=>n.kind==="RiskControlMeasure");a.push({label:"Hazards identified",status:o.length>0?"pass":"fail",detail:`${o.length} hazards found`,elementIds:o.map(n=>n.id)}),a.push({label:"Hazardous situations linked",status:l.length>0?"pass":"warning",detail:`${l.length} hazardous situations`,elementIds:l.map(n=>n.id)}),a.push({label:"Harms documented",status:u.length>0?"pass":"warning",detail:`${u.length} harms identified`,elementIds:u.map(n=>n.id)});const c=new Set(i.relationships.filter(n=>n.type==="mitigates").map(n=>n.targetId)),t=o.filter(n=>!c.has(n.id));a.push({label:"Risk controls applied",status:t.length===0&&o.length>0?"pass":t.length>0?"fail":"warning",detail:t.length>0?`${t.length} hazards without controls`:`${p.length} controls applied`,elementIds:t.map(n=>n.id)});const h=new Set(i.relationships.filter(n=>n.type==="verify").map(n=>n.targetId)),f=p.filter(n=>!h.has(n.id));return a.push({label:"Controls verified",status:f.length===0&&p.length>0?"pass":f.length>0?"warning":"fail",detail:f.length>0?`${f.length} controls not verified`:`All ${p.length} controls verified`,elementIds:f.map(n=>n.id)}),a}function E(i){if(!i)return[];const d=Object.values(i.elements),a=[],o=d.filter(t=>t.kind==="SoftwareComponent"||t.kind==="SoftwareModule"),l=d.filter(t=>t.kind==="Requirement"),u=d.filter(t=>t.kind==="Test");a.push({label:"Software items identified",status:o.length>0?"pass":"fail",detail:`${o.length} software items`,elementIds:o.map(t=>t.id)}),a.push({label:"Software requirements defined",status:l.length>0?"pass":"fail",detail:`${l.length} software requirements`,elementIds:l.map(t=>t.id)});const p=new Set(i.relationships.filter(t=>t.type==="traceTo").map(t=>t.sourceId)),c=l.filter(t=>!p.has(t.id));return a.push({label:"Requirements traced",status:c.length===0&&l.length>0?"pass":c.length>0?"warning":"fail",detail:c.length>0?`${c.length} requirements not traced`:"All requirements traced",elementIds:c.map(t=>t.id)}),a.push({label:"Test coverage",status:u.length>0?"pass":"warning",detail:`${u.length} tests defined`,elementIds:u.map(t=>t.id)}),a}function A(){const i=j(d=>d.availableOntologies);return g.useMemo(()=>{const d=new Map;for(const a of i)for(const o of a.layers)for(const l of o.kinds)l.standard&&d.set(l.standard,(d.get(l.standard)??0)+1);return Array.from(d.entries()).map(([a,o])=>({standard:a,label:a.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase()),kindCount:o})).sort((a,o)=>a.standard.localeCompare(o.standard))},[i])}function z(){const i=j(s=>s.model),d=j(s=>s.selectElement),[a,o]=g.useState(null),[l,u]=g.useState(0),p=A(),c=C.find(s=>s.id===a),t=c==null?void 0:c.steps[l],h=g.useMemo(()=>!a||!i?[]:a==="iso-14971"?w(i):a==="iec-62304"?E(i):[],[a,i]),f=h.filter(s=>s.status==="pass").length,n=h.length,x=n>0?Math.round(f/n*100):0,v={pass:"#2ECC71",warning:"#F39C12",fail:"#E74C3C"},N={pass:"✓",warning:"⚠",fail:"✗"},y=g.useMemo(()=>{if(!i||!t)return[];const s=Object.values(i.elements);switch(t.id){case"hazard-identification":return a==="iso-14971"?s.filter(r=>r.kind==="Hazard"||r.kind==="HazardousSituation"):s.filter(r=>r.kind==="SoftwareComponent"||r.kind==="SoftwareModule");case"risk-estimation":return a==="iso-14971"?s.filter(r=>r.kind==="HazardousSituation"||r.kind==="Harm"):s.filter(r=>r.kind==="SoftwareComponent"||r.kind==="Subsystem"||r.kind==="Component");case"control-measures":return a==="iso-14971"?s.filter(r=>r.kind==="RiskControlMeasure"):s.filter(r=>r.kind==="Requirement"||r.kind==="Requirement");case"verification":return s.filter(r=>r.kind==="Test");default:return[]}},[i,t,a]);return a?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.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{o(null),u(0)},className:"text-xs px-1.5 py-0.5 rounded",style:{color:"rgba(255,255,255,0.6)",background:"rgba(255,255,255,0.1)"},children:"←"}),e.jsx("h2",{className:"text-sm font-bold tracking-wide",style:{color:"#2DD4A8"},children:c.name})]}),e.jsx("p",{className:"text-xs mt-0.5",style:{color:"rgba(255,255,255,0.6)"},children:c.description})]}),e.jsxs("div",{className:"px-4 py-3",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-xs font-medium",style:{color:"#374151"},children:"Compliance"}),e.jsxs("span",{className:"text-xs font-bold",style:{color:x>=80?"#2ECC71":x>=50?"#F39C12":"#E74C3C"},children:[x,"%"]})]}),e.jsx("div",{className:"w-full h-1.5 rounded-full",style:{background:"#F3F4F6"},children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${x}%`,background:x>=80?"#2ECC71":x>=50?"#F39C12":"#E74C3C"}})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:c.steps.map((s,r)=>{const m=l===r,b=r<l;return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer mx-1 rounded-lg",style:{background:m?"#2DD4A818":"transparent",fontWeight:m?500:400},onMouseEnter:F=>{m||(F.currentTarget.style.background="#F0F0ED")},onMouseLeave:F=>{m||(F.currentTarget.style.background=m?"#2DD4A818":"transparent")},onClick:()=>u(r),children:[e.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-xs flex-shrink-0",style:{background:m?"#2DD4A8":b?"#2ECC7130":"#F3F4F6",color:m?"#FFFFFF":b?"#2ECC71":"#9CA3AF"},children:b?"✓":r+1}),e.jsx("span",{className:"text-xs",style:{color:m?"#1B3A4B":"#6B7280"},children:s.label})]},s.id)})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",style:{background:"#F7F7F5"},children:e.jsx("div",{className:"max-w-3xl",children:t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("h2",{className:"text-lg font-semibold",style:{color:"#374151"},children:t.label}),e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"#F3F4F6",color:"#9CA3AF"},children:["Step ",l+1," of ",c.steps.length]})]}),e.jsx("p",{className:"text-sm mb-6",style:{color:"#9CA3AF"},children:t.description}),t.id==="summary"?e.jsx("div",{className:"space-y-2",children:h.map((s,r)=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg",style:{background:"#FFFFFF",border:`1px solid ${v[s.status]}40`},children:[e.jsx("span",{className:"text-sm font-bold",style:{color:v[s.status]},children:N[s.status]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-xs font-medium",style:{color:"#374151"},children:s.label}),e.jsx("div",{className:"text-xs",style:{color:"#9CA3AF"},children:s.detail})]}),s.elementIds&&s.elementIds.length>0&&s.status!=="pass"&&e.jsx("button",{onClick:()=>d(s.elementIds[0]),className:"text-xs px-2 py-0.5 rounded",style:{background:"#4A90D915",color:"#4A90D9"},children:"View"})]},r))}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"mb-4",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider mb-2",style:{color:"#6B7280"},children:["Relevant Elements (",y.length,")"]}),y.length===0&&e.jsx("div",{className:"p-4 rounded-lg text-center text-xs",style:{background:"#FEF2F2",border:"1px solid #FECACA",color:"#E74C3C"},children:"No elements found for this step. Create the required element types in your .sysml files."}),e.jsx("div",{className:"space-y-1",children:y.map(s=>{const r=i.relationships.filter(m=>m.sourceId===s.id||m.targetId===s.id);return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg cursor-pointer text-xs",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},onMouseEnter:m=>m.currentTarget.style.background="#F0F0ED",onMouseLeave:m=>m.currentTarget.style.background="#FFFFFF",onClick:()=>d(s.id),children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:k[s.layer]||"#95A5A6"}}),e.jsx("span",{className:"font-medium flex-1 truncate",style:{color:"#374151"},children:s.name}),e.jsx("span",{className:"px-1.5 py-0.5 rounded",style:{background:(k[s.layer]||"#95A5A6")+"18",color:k[s.layer]||"#95A5A6"},children:s.kind}),e.jsxs("span",{style:{color:"#9CA3AF"},children:[r.length," rels"]})]},s.id)})})]})}),e.jsxs("div",{className:"flex items-center gap-2 mt-6 pt-4",style:{borderTop:"1px solid #E5E5E0"},children:[l>0&&e.jsxs("button",{onClick:()=>u(l-1),className:"px-4 py-2 text-xs rounded-lg",style:{background:"#F3F4F6",color:"#6B7280"},children:["←"," Previous"]}),e.jsx("div",{className:"flex-1"}),l<c.steps.length-1&&e.jsxs("button",{onClick:()=>u(l+1),className:"px-4 py-2 text-xs rounded-lg font-medium",style:{background:"#2DD4A8",color:"#FFFFFF"},children:["Next ","→"]})]})]})})})]}):e.jsx("div",{className:"flex-1 overflow-y-auto p-8",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"max-w-2xl mx-auto",children:[e.jsx("h2",{className:"text-lg font-semibold mb-1",style:{color:"#374151"},children:"Compliance Wizard"}),e.jsx("p",{className:"text-sm mb-6",style:{color:"#9CA3AF"},children:"Select a standard to walk through compliance requirements step by step."}),e.jsx("div",{className:"space-y-3",children:C.map(s=>e.jsxs("button",{onClick:()=>{o(s.id),u(0)},className:"w-full text-left p-4 rounded-lg transition-colors",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},onMouseEnter:r=>r.currentTarget.style.borderColor="#2DD4A8",onMouseLeave:r=>r.currentTarget.style.borderColor="#E5E5E0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-semibold",style:{color:"#1B3A4B"},children:s.name}),e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"#F3F4F6",color:"#6B7280"},children:[s.steps.length," steps"]})]}),e.jsx("p",{className:"text-xs mt-1",style:{color:"#6B7280"},children:s.description})]},s.id))}),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider mt-8 mb-3",style:{color:"#6B7280"},children:"Discovered Standards"}),e.jsx("div",{className:"space-y-2",children:p.map(s=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{background:"#7C3AED"}}),e.jsx("span",{className:"text-sm font-medium flex-1",style:{color:"#374151"},children:s.label}),e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"#F3F4F6",color:"#6B7280"},children:[s.kindCount," ",s.kindCount===1?"kind":"kinds"]})]},s.standard))})]})]})})}export{z as ComplianceWizard};
@@ -0,0 +1,5 @@
1
+ import{j as t}from"./reactflow-C9OlmOYw.js";import{a as w}from"./zustand-CrhqMOHB.js";import{_ as at,C as d,F as z,h as Se,S as Ke,T as ge,u as ue,i as lt,r as ae,j as dt}from"./index-a2rpMs5Y.js";import{I as G,a as ct,T as pt,b as Oe}from"./DiagramToolbarControls-XMGLx08e.js";const ut=["composes","composedOf","decomposedBy","aggregation","includes","includesStep","containsEvent","moduleUses"];function ye(e){const a=new Set(e.relationships.map(n=>n.type));return ut.filter(n=>a.has(n))}function Ve(e){return[...new Set(e.relationships.map(a=>a.type))].sort()}function qe(e){const a=new Map;for(const n of Object.values(e.elements)){const o=n.layer||"unassigned";let s=a.get(o);s||(s=new Map,a.set(o,s)),s.set(n.kind,(s.get(n.kind)??0)+1)}return[...a.entries()].map(([n,o])=>({layer:n,elementCount:[...o.values()].reduce((s,i)=>s+i,0),kinds:[...o.entries()].map(([s,i])=>({kind:s,elementCount:i})).sort((s,i)=>i.elementCount-s.elementCount||s.kind.localeCompare(i.kind))})).sort((n,o)=>o.elementCount-n.elementCount||n.layer.localeCompare(o.layer))}function Ye(e,a){const n=new Set(a??ye(e)),o=new Map;for(const i of e.relationships){if(n.has(i.type))continue;const p=e.elements[i.sourceId],l=e.elements[i.targetId];!p||!l||p.layer!==l.layer||o.set(p.layer,(o.get(p.layer)??0)+1)}const s=qe(e);if(s.length!==0)return[...s].sort((i,p)=>(o.get(p.layer)??0)-(o.get(i.layer)??0)||p.elementCount-i.elementCount||i.layer.localeCompare(p.layer))[0].layer}function Dt(e,a){const n=new Set(ye(e)),o=new Map;for(const l of e.relationships){if(n.has(l.type))continue;const u=e.elements[l.sourceId],f=e.elements[l.targetId];if(!u||!f||u.layer===f.layer)continue;const k=`${u.layer}>${f.layer}`;o.set(k,(o.get(k)??0)+1)}const s=[...o.entries()].sort((l,u)=>u[1]-l[1]||l[0].localeCompare(u[0]))[0];if(!s){const l=Ye(e,a);return{rows:l,columns:l}}const[i,p]=s[0].split(">");return{rows:i,columns:p}}function ht(e,a){const n=new Map;for(const s of Object.values(e.elements)){const i=s.parentAction??s.owner;i&&e.elements[i]&&n.set(s.id,i)}const o=new Set(a);for(const s of e.relationships)o.has(s.type)&&(!e.elements[s.sourceId]||!e.elements[s.targetId]||s.sourceId!==s.targetId&&n.set(s.targetId,s.sourceId));for(const s of[...n.keys()]){const i=new Set([s]);let p=n.get(s);for(;p;){if(i.has(p)){n.delete(p);break}i.add(p),p=n.get(p)}}return n}function ft(e,a){const n=[],o=new Set([e]);let s=a.get(e);for(;s&&!o.has(s);)n.push(s),o.add(s),s=a.get(s);return n}function ze(e,a,n,o,s){const i=new Set((o==null?void 0:o.kinds)??[]),p=new Set((o==null?void 0:o.elementIds)??[]),l=b=>(!(o!=null&&o.layer)||b.layer===o.layer)&&(i.size===0||i.has(b.kind))&&(p.size===0||p.has(b.id)),u=new Set;for(const b of Object.values(e.elements))if(l(b)){u.add(b.id);for(const v of ft(b.id,a))u.add(v)}const f=new Map,k=b=>{const v=f.get(b);if(v)return v;const R=[b];f.set(b,R);for(const A of n.get(b)??[])A!==b&&R.push(...k(A));return R},c=new Map,x=(b,v)=>{const R=c.get(b);if(R)return R;const A=e.elements[b],P={id:b,name:(A==null?void 0:A.name)??b,kind:(A==null?void 0:A.kind)??"Unknown",layer:(A==null?void 0:A.layer)??"",isElement:!0,children:[],members:k(b),depth:v};return c.set(b,P),P.children=(n.get(b)??[]).filter(D=>u.has(D)&&D!==b).map(D=>x(D,v+1)),P};let g=[...u].filter(b=>{const v=a.get(b);return!v||!u.has(v)}).map(b=>x(b,0));s&&(g=xt(g,e));const S=new Map,m=new Map,C=(b,v)=>{v&&m.set(b.id,v),b.children.forEach(R=>C(R,b));for(const R of b.members)S.has(R)||S.set(R,b)};return g.forEach(b=>C(b,void 0)),{roots:g,ownerOf:S,parentNodeOf:m}}function xt(e,a){var p;const n=[],o=new Map,s=l=>{const u=l.join("::"),f=o.get(u);if(f)return f;const k={id:`pkg:${u}`,name:l[l.length-1],kind:"Package",layer:"",isElement:!1,children:[],members:[],depth:l.length-1};return o.set(u,k),l.length===1?n.push(k):s(l.slice(0,-1)).children.push(k),k};for(const l of e){const u=(p=a.elements[l.id])==null?void 0:p.package;if(!u){n.push(l);continue}s(u.split("::")).children.push(l)}const i=(l,u)=>{l.depth=u,l.children.forEach(f=>i(f,u+1)),l.isElement||(l.members=l.children.flatMap(f=>f.members))};return n.forEach(l=>i(l,0)),n}function De(e,a,n){const o=(l,u)=>l.name.localeCompare(u.name),s=(l,u)=>l.kind.localeCompare(u.kind)||o(l,u),i=l=>l.length<2?l:a==="natural"?[...l].sort(o):a==="kind"?[...l].sort(s):a==="partition"?gt(l,n):mt(l,n),p=l=>{const u=i(l);for(const f of u)f.children=p(f.children);return u};return p(e)}function gt(e,a){const n=[...e].sort((s,i)=>s.name.localeCompare(i.name)),o=[];for(;n.length>0;){const s=n.filter(i=>!n.some(p=>p!==i&&a(p,i)));if(s.length===0){o.push(...n);break}for(const i of s)o.push(i),n.splice(n.indexOf(i),1)}return o}function mt(e,a){const n=e.map((i,p)=>p),o=i=>n[i]===i?i:n[i]=o(n[i]);for(let i=0;i<e.length;i++)for(let p=i+1;p<e.length;p++)(a(e[i],e[p])||a(e[p],e[i]))&&(n[o(i)]=o(p));const s=new Map;return e.forEach((i,p)=>{const l=o(p),u=s.get(l);u?u.push(i):s.set(l,[i])}),[...s.values()].map(i=>i.sort((p,l)=>p.name.localeCompare(l.name))).sort((i,p)=>p.length-i.length||i[0].name.localeCompare(p[0].name)).flat()}function Ne(e,a){const n=[],o=(s,i,p)=>{const l=s.children.length>0,u=l&&a.has(s.id);if(n.push({node:s,index:n.length+1,depth:i,expandable:l,expanded:u,ancestorIds:p,memberCount:s.members.length}),!u)return;const f=[...p,s.id];for(const k of s.children)o(k,i+1,f)};return e.forEach(s=>o(s,0,[])),n}function he(e,a=1/0){const n=[],o=(s,i)=>{i>=a||(s.children.length>0&&n.push(s.id),s.children.forEach(p=>o(p,i+1)))};return e.forEach(s=>o(s,0)),n}function Be(e,a={}){var Q,K,Y,V;const n=a.containmentTypes??ye(e),o=ht(e,n),s=new Map;for(const[h,$]of o){const O=s.get($);O?O.push(h):s.set($,[h])}const i=new Set(a.dependencyTypes??[]),p=h=>(i.size===0||i.has(h.type))&&!n.includes(h.type),l=e.relationships.filter(p),u=a.groupByPackage??!1,f=ze(e,o,s,a.rows,u),k=ze(e,o,s,a.columns,u),c=h=>{const $=new Set,O=E=>{const L=[];let T=h.ownerOf.get(E);for(;T;)L.push(T.id),T=h.parentNodeOf.get(T.id);return L},F=(E,L)=>{for(const T of O(E))for(const W of O(L))T!==W&&$.add(`${T}>${W}`)};for(const E of l)F(E.sourceId,E.targetId),a.symmetric&&F(E.targetId,E.sourceId);return(E,L)=>E!==L&&$.has(`${E.id}>${L.id}`)},x=a.ordering??"natural",j=De(f.roots,((Q=a.rows)==null?void 0:Q.ordering)??x,c(f)),g=De(k.roots,((K=a.columns)==null?void 0:K.ordering)??x,c(k)),S=Ne(j,((Y=a.rows)==null?void 0:Y.expanded)??new Set),m=Ne(g,((V=a.columns)==null?void 0:V.expanded)??new Set),C=new Map;S.forEach((h,$)=>C.set(h.node.id,$));const b=new Map;m.forEach((h,$)=>b.set(h.node.id,$));const v=(h,$,O)=>{let F=$.ownerOf.get(h);const E=new Set;for(;F&&!E.has(F.id);){E.add(F.id);const L=O.get(F.id);if(L!==void 0)return L;F=$.parentNodeOf.get(F.id)}},R=Array.from({length:S.length},()=>Array.from({length:m.length},()=>null));let A=0,P=0;const D=(h,$,O)=>{const F=v($,f,C),E=v(O,k,b);if(F===void 0||E===void 0)return;const L=S[F],T=m[E],W=L.node.id===T.node.id;let _=R[F][E];_||(_={strength:0,types:[],relationshipIds:[],diagonal:W,aggregated:L.node.id!==$||T.node.id!==O},R[F][E]=_),_.strength++,(L.node.id!==$||T.node.id!==O)&&(_.aggregated=!0),_.types.includes(h.type)||_.types.push(h.type),_.relationshipIds.push(h.id),W?P++:A++};for(const h of l)D(h,h.sourceId,h.targetId),a.symmetric&&D(h,h.targetId,h.sourceId);return{rowRoots:j,columnRoots:g,rows:S,columns:m,matrix:R,totalDependencies:A,candidateDependencies:l.length,elementCount:Object.keys(e.elements).length,stats:yt(S,m,R,P),availableDependencyTypes:Ve(e)}}function yt(e,a,n,o){const s=new Map;a.forEach((k,c)=>s.set(k.node.id,c));let i=0,p=0,l=0,u=0;const f=new Array(a.length).fill(0);e.forEach((k,c)=>{let x=0;n[c].forEach((j,g)=>{if(!j||j.diagonal)return;x+=j.strength,f[g]+=j.strength;const S=s.get(k.node.id);S!==void 0&&g<S&&(i+=j.strength)}),u=Math.max(u,x)}),e.forEach((k,c)=>{const x=n[c].some(S=>S&&!S.diagonal),j=s.get(k.node.id),g=j!==void 0&&n.some(S=>S[j]&&!S[j].diagonal);!x&&!g&&l++});for(let k=0;k<e.length;k++){const c=s.get(e[k].node.id);if(c!==void 0)for(let x=0;x<a.length;x++){const j=n[k][x];if(!j||j.diagonal||x>=c)continue;const g=e.findIndex(S=>S.node.id===a[x].node.id);g>=0&&n[g][c]&&p++}}return f.forEach(k=>{u=Math.max(u,k)}),{feedback:i,couplings:p,isolated:l,maxDegree:u,internal:o}}const We=new Set(["Function","Function","UserActivity"]),_e=new Set(["System","Subsystem","Component","LogicalComponent","SoftwareComponent","SoftwareModule","Software"]);function bt(e){var f,k;const a=[],n=[];for(const c of Object.values(e.elements))We.has(c.kind)&&a.push(c),_e.has(c.kind)&&n.push(c);const o=[],s=new Set,i=new Map;for(const c of n)i.set(c.id,[]);for(const c of e.relationships){if(c.type!=="allocatedTo")continue;const x=e.elements[c.sourceId],j=e.elements[c.targetId];!x||!j||We.has(x.kind)&&_e.has(j.kind)&&(o.push({functionId:x.id,functionName:x.name,targetId:j.id,targetName:j.name}),s.add(x.id),i.has(j.id)||i.set(j.id,[]),i.get(j.id).push(x.id))}for(const c of a)if(c.allocatedTo&&!s.has(c.id)){const x=n.find(j=>j.name===c.allocatedTo||j.id===c.allocatedTo);x&&(o.push({functionId:c.id,functionName:c.name,targetId:x.id,targetName:x.name}),s.add(c.id),i.has(x.id)||i.set(x.id,[]),i.get(x.id).push(c.id))}const p=[];let l=0;for(const c of a)s.has(c.id)||p.push({id:`ci-${l++}`,type:"unallocated-function",severity:"warning",elementId:c.id,elementName:c.name,message:`Function "${c.name}" is not allocated to any component`});for(const c of n){const x=i.get(c.id);(!x||x.length===0)&&p.push({id:`ci-${l++}`,type:"no-functions-allocated",severity:"info",elementId:c.id,elementName:c.name,message:`Component "${c.name}" has no functions allocated to it`})}const u=new Map;for(const c of o)u.set(c.functionId,c.targetId);for(const c of e.relationships){if(c.type!=="flow")continue;const x=u.get(c.sourceId),j=u.get(c.targetId);if(x&&j&&x!==j){const g=e.elements[c.sourceId],S=e.elements[c.targetId];g&&S&&p.push({id:`ci-${l++}`,type:"cross-component-flow",severity:"info",elementId:c.sourceId,elementName:g.name,message:`Flow from "${g.name}" to "${S.name}" crosses component boundary (${(f=e.elements[x])==null?void 0:f.name} → ${(k=e.elements[j])==null?void 0:k.name})`,relatedIds:[c.targetId,x,j]})}}return{allocations:o,componentFunctions:i,issues:p,functions:a,structures:n}}function wt(e){const a=String(e);return/[",\r\n]/.test(a)?`"${a.replace(/"/g,'""')}"`:a}function Ze(e){return e?String(e.strength):""}function kt(e){const n=[["Row","Element type","Row index",...e.columns.map(o=>`${o.index}. ${o.node.name}`)]];return e.rows.forEach((o,s)=>{const i=[`${" ".repeat(o.depth)}${o.node.name}`,o.node.kind,o.index];e.columns.forEach((p,l)=>{const u=e.matrix[s][l];i.push(o.node.id===p.node.id?Ze(u):u?String(u.strength):"")}),n.push(i)}),`\uFEFF${n.map(o=>o.map(wt).join(",")).join(`\r
2
+ `)}\r
3
+ `}function jt(e,a="memo-dsm.csv"){const n=new Blob([kt(e)],{type:"text/csv;charset=utf-8"}),o=URL.createObjectURL(n),s=document.createElement("a");s.href=o,s.download=a,s.click(),URL.revokeObjectURL(o)}async function vt(e,a="memo-dsm.xlsx"){const n=await at(()=>import("./xlsx-CkFp8p6R.js"),[]),o=[["Row","Element type","Row index",...e.columns.map(f=>`${f.index}. ${f.node.name}`)]];e.rows.forEach((f,k)=>{const c=[`${" ".repeat(f.depth)}${f.node.name}`,f.node.kind,f.index];e.columns.forEach((x,j)=>{const g=e.matrix[k][j];c.push(f.node.id===x.node.id?Ze(g):g?g.strength:"")}),o.push(c)});const s=n.utils.aoa_to_sheet(o);s["!rows"]=[{hpx:24},...e.rows.map(f=>({level:Math.min(7,f.depth),hidden:f.depth>0}))],s["!cols"]=[{wch:34},{wch:22},{wch:11},...e.columns.map(f=>({wch:Math.max(8,Math.min(26,f.node.name.length+2)),level:Math.min(7,f.depth),hidden:f.depth>0}))];const i=n.utils.book_new();n.utils.book_append_sheet(i,s,"DSM");const p=n.write(i,{bookType:"xlsx",type:"array",compression:!0}),l=URL.createObjectURL(new Blob([p],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})),u=document.createElement("a");u.href=l,u.download=a,u.click(),URL.revokeObjectURL(l)}const Qe=300,ve=24,St=9e4;function oe(e){return e<=0?"2px solid #94A3B8":e===1?"1px solid #B6C4D0":`1px solid ${d.borderLight}`}function Pe(e){return e.map((a,n)=>{if(n===0)return null;const o=e[n-1];return a.ancestorIds.includes(o.node.id)?null:Math.min(a.depth,o.depth)})}function Ct({result:e,onToggleRow:a,onToggleColumn:n,onSelectElement:o,selectedElementId:s,renderCell:i,onCellClick:p,onCellDoubleClick:l,cellSize:u=26,showColumnNames:f=!1,onHideRow:k,onHideColumn:c,cornerHeader:x,footer:j}){const[g,S]=w.useState(null),{rows:m,columns:C,matrix:b}=e,v=w.useMemo(()=>Pe(m),[m]),R=w.useMemo(()=>Pe(C),[C]),A=Math.max(10,Math.round(u*.34)),P=Math.max(11,Math.round(u*.34)),D=h=>h.ancestorIds[0]??h.node.id,Q=h=>h.length>ve?`${h.slice(0,ve-1)}…`:h,K=Math.min(ve,Math.max(0,...C.map(h=>h.node.name.length))),Y=Math.max(x?76:0,f?42+(K+2)*P*.62:44);if(m.length===0||C.length===0)return t.jsx("div",{className:"flex-1 flex items-center justify-center",style:{padding:"40px"},children:t.jsxs("div",{style:{textAlign:"center",maxWidth:"340px"},children:[t.jsx("div",{style:{fontSize:"34px",opacity:.35,marginBottom:"10px"},children:"▦"}),t.jsx("h3",{style:{fontSize:z.md,fontWeight:600,color:d.secondary,marginBottom:"6px"},children:"Nothing to plot"}),t.jsx("p",{style:{fontSize:z.xs,color:d.faint,lineHeight:1.6},children:"No element matches the chosen row and column types. Widen either axis, or clear the type filter to see the whole model."})]})});const V=m.length*C.length>St;return t.jsxs("div",{style:{padding:"14px",overflow:"auto",flex:1},children:[V&&t.jsxs("div",{style:{marginBottom:"10px",padding:"8px 10px",borderRadius:"6px",background:"#FEF3C7",border:"1px solid #FCD34D",fontSize:z.xs,color:"#92400E"},children:[m.length.toLocaleString()," × ",C.length.toLocaleString()," is past what stays responsive to draw. Collapse a few subsystems, or narrow the row and column types."]}),!V&&t.jsxs("div",{style:{display:"inline-block",minWidth:"100%"},children:[t.jsxs("div",{style:{display:"flex",position:"sticky",top:0,zIndex:20,background:d.surface},children:[t.jsx("div",{style:{width:Qe,flexShrink:0,height:Y,display:"flex",alignItems:x?"stretch":"flex-end",justifyContent:"flex-end",gap:"5px",padding:x?"8px 12px":"0 8px 3px 0",fontSize:"10px",color:d.faint,background:x?d.surfaceAlt:void 0,borderRight:x?`1px solid ${d.border}`:void 0,borderBottom:`1px solid ${d.border}`},children:x??t.jsxs("span",{children:[m.length," rows ","×"," ",C.length," cols"]})}),C.map((h,$)=>{const O=(g==null?void 0:g.column)===$;return t.jsxs("div",{onClick:()=>h.expandable?n(h.node.id):o==null?void 0:o(h.node.id),onMouseEnter:()=>S({row:m.findIndex(F=>F.node.id===h.node.id),column:$}),onMouseLeave:()=>S(null),title:`${h.index}. ${h.node.name} (${h.node.kind})${h.expandable?" — click to expand":""}`,style:{width:u,flexShrink:0,height:Y,position:"relative",cursor:"pointer",borderLeft:R[$]===null?void 0:oe(R[$]),borderRight:$===C.length-1?oe(0):void 0,borderBottom:`1px solid ${d.border}`,background:O?"#EAF7F3":"transparent"},children:[f&&t.jsxs("div",{style:{position:"absolute",top:"42px",bottom:"4px",left:0,right:0,display:"flex",alignItems:"center",justifyContent:"flex-start",writingMode:"vertical-rl",transform:"rotate(180deg)",overflow:"hidden",fontSize:`${P}px`,lineHeight:1,color:O?d.primary:d.muted,fontWeight:600},children:[h.expandable?h.expanded?"− ":"+ ":"",Q(h.node.name)]}),t.jsx("div",{style:{position:"absolute",top:"3px",width:"100%",left:0,display:"block",textAlign:"center",fontSize:`${Math.max(10,A-2)}px`,color:O?d.primary:d.faint,fontWeight:O?700:400},children:t.jsx("span",{children:h.index})}),h.node.isElement&&c&&t.jsx("span",{style:{position:"absolute",top:"22px",left:"50%",transform:"translateX(-50%)"},children:t.jsx(Je,{title:`Hide ${h.node.name} column`,ariaLabel:`Hide ${h.node.name} column`,onClick:()=>c(h.node.id)})})]},h.node.id)})]}),m.map((h,$)=>{const O=(g==null?void 0:g.row)===$,F=s===h.node.id;return t.jsxs("div",{style:{display:"flex",borderTop:v[$]===null?void 0:oe(v[$]),borderBottom:$===m.length-1?oe(0):void 0},children:[t.jsx($t,{entry:h,height:u,fontSize:P,onHide:h.node.isElement&&k?()=>k(h.node.id):void 0,hovered:O,selected:F,onToggle:()=>a(h.node.id),onSelect:()=>o==null?void 0:o(h.node.id)}),C.map((E,L)=>{const T=b[$][L],W=i?i(T,h,E):It(T),_=(g==null?void 0:g.row)===$||(g==null?void 0:g.column)===L,de=D(h)===D(E),J=h.node.id===E.node.id,H=W.background??(J?"#E3E8EE":_?"#F1F7F5":de?"#FAFBFC":d.surface),ce=W.text,ee=!!T||W.actionable;return t.jsx("div",{onMouseEnter:()=>S({row:$,column:L}),onMouseLeave:()=>S(null),onClick:ee?()=>p==null?void 0:p(h,E,T):void 0,onDoubleClick:ee?()=>l==null?void 0:l(h,E,T):void 0,title:W.title??Et(T,h,E),style:{width:u,height:u,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${A}px`,fontWeight:600,color:W.color??(J?d.faint:d.secondary),background:H,borderRight:L===C.length-1?oe(0):`1px solid ${d.borderLight}`,borderBottom:`1px solid ${d.borderLight}`,borderLeft:R[L]===null?void 0:oe(R[L]),cursor:ee?"pointer":"default",outline:(g==null?void 0:g.row)===$&&(g==null?void 0:g.column)===L?`2px solid ${d.accent}`:void 0,outlineOffset:"-2px"},children:ce},E.node.id)})]},h.node.id)})]}),j]})}function Je({title:e,ariaLabel:a,onClick:n}){return t.jsx("button",{type:"button",title:e,"aria-label":a,onClick:o=>{o.stopPropagation(),n()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"18px",height:"18px",padding:0,border:"none",borderRadius:"4px",background:"rgba(255,255,255,0.82)",color:d.muted,cursor:"pointer"},children:t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M1.5 8s2.3-4 6.5-4 6.5 4 6.5 4-2.3 4-6.5 4-6.5-4-6.5-4Z"}),t.jsx("circle",{cx:"8",cy:"8",r:"2"})]})})}function $t({entry:e,height:a,fontSize:n,hovered:o,selected:s,onToggle:i,onSelect:p,onHide:l}){const u=e.depth*14,f={width:Qe,flexShrink:0,height:a,display:"flex",alignItems:"center",gap:"5px",paddingLeft:`${6+u}px`,paddingRight:"7px",position:"sticky",left:0,zIndex:10,background:s?"#E8F8F3":o?"#F1F7F5":d.surface,borderRight:`1px solid ${d.border}`,borderBottom:`1px solid ${d.borderLight}`,fontSize:`${n}px`,color:o||s?d.primary:d.secondary,fontWeight:e.expandable?600:400};return t.jsxs("div",{style:f,children:[t.jsx("span",{style:{fontSize:`${Math.max(10,n-3)}px`,color:d.faint,width:"18px",textAlign:"center",flexShrink:0},children:e.index}),t.jsx("span",{style:{width:"18px",height:"18px",flexShrink:0},children:l&&t.jsx(Je,{title:`Hide ${e.node.name} row`,ariaLabel:`Hide ${e.node.name} row`,onClick:l})}),t.jsx("button",{type:"button",onClick:e.expandable?i:void 0,"aria-label":e.expandable?`${e.expanded?"Collapse":"Expand"} ${e.node.name}`:void 0,disabled:!e.expandable,style:{width:"13px",height:"13px",flexShrink:0,padding:0,lineHeight:"11px",borderRadius:"3px",fontSize:`${Math.max(11,n-2)}px`,border:e.expandable?`1px solid ${d.border}`:"1px solid transparent",background:e.expandable?d.surface:"transparent",color:d.muted,cursor:e.expandable?"pointer":"default"},children:e.expandable?e.expanded?"−":"+":""}),t.jsx("span",{style:{width:"3px",height:"13px",borderRadius:"2px",flexShrink:0,background:e.node.isElement?Se[e.node.layer]||"#9CA3AF":"#CBD5E1"}}),t.jsx("span",{onClick:p,title:`${e.node.name} (${e.node.kind})`,style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"},children:e.node.name}),e.expandable&&!e.expanded&&e.memberCount>1&&t.jsx("span",{style:{fontSize:`${Math.max(10,n-3)}px`,color:d.faint},title:`${e.memberCount} elements rolled up`,children:e.memberCount})]})}function It(e){return e?e.diagonal?{text:String(e.strength),color:d.muted}:{text:String(e.strength),color:d.primary}:{}}function Et(e,a,n){const o=`${a.node.name} → ${n.node.name}`;if(!e)return a.node.id===n.node.id?`${a.node.name}: no internal dependencies`:o;if(e.diagonal)return`${a.node.name}: ${e.strength} internal dependenc${e.strength===1?"y":"ies"}`;const s=e.types.join(", ");return`${o}
4
+ ${e.strength} dependenc${e.strength===1?"y":"ies"} (${s})${e.aggregated?`
5
+ rolled up from collapsed parts`:""}`}function le({label:e,ariaLabel:a,children:n,badge:o,title:s,width:i=260,open:p,onOpenChange:l,fullWidth:u=!1}){const[f,k]=w.useState(!1),c=p??f,x=g=>{const S=typeof g=="function"?g(c):g;p===void 0&&k(S),l==null||l(S)},j=w.useRef(null);return w.useEffect(()=>{if(!c)return;const g=m=>{var C;(C=j.current)!=null&&C.contains(m.target)||x(!1)},S=m=>{m.key==="Escape"&&x(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",S),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",S)}},[c]),t.jsxs("div",{ref:j,style:{position:"relative",width:u?"100%":void 0},children:[t.jsxs("button",{type:"button","aria-haspopup":"dialog","aria-expanded":c,"aria-label":a,title:s,onClick:()=>x(g=>!g),style:{display:"flex",alignItems:"center",gap:"5px",width:u?"100%":void 0,justifyContent:u?"center":void 0,padding:"3px 8px",borderRadius:"5px",border:`1px solid ${c||o?d.accent:d.border}`,background:c?"#E8F8F3":d.surface,fontSize:z.xs,color:d.secondary,cursor:"pointer",whiteSpace:"nowrap"},children:[e,o&&t.jsx("span",{style:{fontSize:"10px",padding:"0 4px",borderRadius:"7px",background:d.accent,color:"#08331F",fontWeight:700},children:o}),t.jsx("span",{style:{fontSize:"9px",color:d.faint},children:"▾"})]}),c&&t.jsx("div",{role:"dialog","aria-label":a??(typeof e=="string"?e:"Options"),style:{position:"absolute",top:"calc(100% + 4px)",right:0,zIndex:60,width:i,padding:"10px 12px",background:d.surface,border:`1px solid ${d.border}`,borderRadius:"7px",boxShadow:Ke.lg,display:"flex",flexDirection:"column",gap:"9px"},children:n})]})}function Ce(e){const a=e.replace(/[_-]+/g," ").trim();return a.charAt(0).toUpperCase()+a.slice(1)}function Mt(e,a){if(e.kind)return e.kind;if(e.layer){const n=a.find(o=>o.layer===e.layer);return n&&n.kinds.length===1?n.kinds[0].kind:Ce(e.layer)}return"Everything"}function He({label:e,layers:a,value:n,onChange:o,width:s=165,title:i,describedAs:p}){const[l,u]=w.useState(!1),[f,k]=w.useState(""),c=w.useRef(null),x=w.useRef(null);w.useEffect(()=>{if(!l)return;const m=C=>{var b;(b=c.current)!=null&&b.contains(C.target)||(u(!1),k(""))};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[l]),w.useEffect(()=>{var m;l&&((m=x.current)==null||m.focus())},[l]);const j=w.useMemo(()=>{const m=f.trim().toLowerCase().split(/\s+/).filter(Boolean);if(m.length===0)return a;const C=b=>m.every(v=>b.toLowerCase().includes(v));return a.map(b=>{if(C(Ce(b.layer)))return b;const v=b.kinds.filter(R=>C(`${R.kind} ${b.layer}`));return v.length>0?{...b,kinds:v}:null}).filter(b=>b!==null)},[a,f]),g=m=>{o(m),u(!1),k("")},S=(m,C)=>({display:"flex",alignItems:"center",gap:"7px",padding:C?"4px 9px 4px 26px":"5px 9px",cursor:"pointer",fontSize:z.xs,background:m?"#E8F8F3":"transparent",color:d.primary,fontWeight:m?600:400});return t.jsxs("div",{ref:c,style:{position:"relative",display:"flex",alignItems:"center",gap:"5px"},children:[t.jsx("span",{style:{fontSize:z.xs,color:d.muted,whiteSpace:"nowrap"},children:e}),t.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":l,title:i,onClick:()=>u(m=>!m),style:{width:s,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",padding:"3px 7px",borderRadius:"5px",border:`1px solid ${d.accent}`,background:d.surface,fontSize:z.xs,color:d.primary,cursor:"pointer",textAlign:"left"},children:[t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"6px",overflow:"hidden"},children:[n.layer&&t.jsx("span",{style:{width:"3px",height:"12px",borderRadius:"2px",flexShrink:0,background:Se[n.layer]||"#9CA3AF"}}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Mt(n,a)})]}),t.jsx("span",{style:{fontSize:"9px",color:d.faint},children:"▼"})]}),l&&t.jsxs("div",{role:"listbox",style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:60,width:Math.max(s+60,240),background:d.surface,border:`1px solid ${d.border}`,borderRadius:"7px",boxShadow:Ke.lg,overflow:"hidden"},children:[t.jsx("input",{ref:x,value:f,onChange:m=>k(m.target.value),onKeyDown:m=>{m.key==="Escape"&&(u(!1),k(""))},placeholder:"Filter layers and types…","aria-label":`Filter ${p??e}`,style:{width:"100%",padding:"7px 9px",border:"none",borderBottom:`1px solid ${d.borderLight}`,fontSize:z.xs,outline:"none",color:d.primary}}),t.jsxs("div",{style:{maxHeight:"300px",overflowY:"auto"},children:[j.length===0&&t.jsxs("div",{style:{padding:"10px",fontSize:z.xs,color:d.faint},children:["Nothing matches ","“",f,"”"]}),j.map(m=>t.jsxs("div",{children:[t.jsxs("div",{role:"option","aria-selected":n.layer===m.layer&&!n.kind,onClick:()=>g({layer:m.layer}),style:S(n.layer===m.layer&&!n.kind,!1),children:[t.jsx("span",{style:{width:"3px",height:"12px",borderRadius:"2px",flexShrink:0,background:Se[m.layer]||"#9CA3AF"}}),t.jsx("span",{style:{flex:1},children:Ce(m.layer)}),t.jsx("span",{style:{color:d.faint,fontSize:"11px"},children:m.elementCount})]}),m.kinds.length>1&&m.kinds.map(C=>t.jsxs("div",{role:"option","aria-selected":n.kind===C.kind,onClick:()=>g({layer:m.layer,kind:C.kind}),style:S(n.kind===C.kind,!0),children:[t.jsx("span",{style:{flex:1,color:d.secondary},children:C.kind}),t.jsx("span",{style:{color:d.faint,fontSize:"11px"},children:C.elementCount})]},C.kind))]},m.layer))]})]})]})}function Ue(e,a){return e?Object.values(e.elements).filter(n=>(!a.layer||n.layer===a.layer)&&(!a.kind||n.kind===a.kind)).sort((n,o)=>n.kind.localeCompare(o.kind)||n.name.localeCompare(o.name)).map(n=>({value:n.id,label:n.name,group:n.kind,hint:n.shortId,keywords:`${n.id} ${n.shortId??""} ${n.package??""}`})):[]}const fe=[{value:"natural",label:"Name",title:"Alphabetical inside every parent"},{value:"kind",label:"Element type",title:"Grouped by element type, then name"},{value:"partition",label:"Partition",title:"Sequence siblings so dependencies sit above the diagonal, leaving only real cycles as feedback"},{value:"cluster",label:"Cluster",title:"Keep mutually dependent siblings adjacent"}];function Rt(e){return e.types.length>0?ae(e.types[0]):"#475569"}function Lt(){const e=ue(r=>r.model),a=ue(r=>r.selectElement),n=ue(r=>r.selectedElementId),o=ue(r=>r.setAnalysisIssues),s=w.useMemo(()=>lt(e),[e]),[i,p]=w.useState({}),[l,u]=w.useState({}),[f,k]=w.useState([]),[c,x]=w.useState([]),[j,g]=w.useState([]),[S,m]=w.useState(null),[C,b]=w.useState(!1),[v,R]=w.useState("natural"),[A,P]=w.useState("natural"),[D,Q]=w.useState(!1),[K,Y]=w.useState(!0),[V,h]=w.useState(39),[$,O]=w.useState(!0),[F,E]=w.useState("top"),[L,T]=w.useState(null),[W,_]=w.useState(new Set),[de,J]=w.useState(new Set),[H,ce]=w.useState(null),ee=w.useMemo(()=>e?qe(e):[],[e]),be=w.useMemo(()=>{if(!e)return[];const r=new Map;for(const y of e.relationships)r.set(y.type,(r.get(y.type)??0)+1);return Ve(e).map(y=>({value:y,hint:String(r.get(y)??0),color:ae(y)}))},[e]),ie=w.useMemo(()=>Ue(e,i),[e,i]),re=w.useMemo(()=>Ue(e,l),[e,l]),Ie=w.useMemo(()=>{if(!e||!s)return[];const r=(N,X,Z)=>(!X.layer||N.layer===X.layer)&&(!X.kind||N.kind===X.kind)&&(Z.length===0||Z.includes(N.id)),y=Object.values(e.elements).filter(N=>r(N,i,f)),I=Object.values(e.elements).filter(N=>r(N,l,c)),q=new Set;for(const N of y)for(const X of I)if(N.id!==X.id)for(const Z of dt(N,X,s))q.add(Z.definition.name);return be.filter(N=>q.has(N.value))},[e,s,i,l,f,c,be]);w.useEffect(()=>{const r=new Set(ie.map(y=>y.value));k(y=>y.length===0||y.every(I=>r.has(I))?y:y.filter(I=>r.has(I)))},[ie]),w.useEffect(()=>{const r=new Set(re.map(y=>y.value));x(y=>y.length===0||y.every(I=>r.has(I))?y:y.filter(I=>r.has(I)))},[re]);const U=w.useMemo(()=>S??(e?ye(e):[]),[S,e]),Ee=w.useMemo(()=>{const r=new Map;if(!e)return r;for(const I of Object.values(e.elements)){const q=I.parentAction??I.owner;q&&e.elements[q]&&r.set(I.id,q)}const y=new Set(U);for(const I of e.relationships)y.has(I.type)&&I.sourceId!==I.targetId&&e.elements[I.sourceId]&&e.elements[I.targetId]&&r.set(I.targetId,I.sourceId);return r},[e,U]),we=w.useMemo(()=>{const r=new Set(U);return Ie.map(y=>r.has(y.value)?{...y,label:`${y.value} (nesting)`,hint:"builds the tree"}:y)},[Ie,U]);w.useEffect(()=>{const r=new Set(we.map(y=>y.value));g(y=>y.every(I=>r.has(I))?y:y.filter(I=>r.has(I)))},[we]);const Me=[S!==null,!$,!K,C,D].filter(Boolean).length,M=w.useMemo(()=>e?Be(e,{rows:{layer:i.layer,kinds:i.kind?[i.kind]:[],elementIds:f,expanded:W,ordering:v},columns:{layer:l.layer,kinds:l.kind?[l.kind]:[],elementIds:c,expanded:de,ordering:A},dependencyTypes:j,containmentTypes:U,groupByPackage:C,symmetric:D}):null,[e,i,l,f,c,j,U,C,v,A,D,W,de]),[Re,tt]=w.useState(!1);w.useEffect(()=>{if(Re||!e)return;const r=Ye(e,U);r&&(p({layer:r}),u({layer:r}),tt(!0))},[e,U,Re]);const nt=w.useCallback(r=>{_(y=>xe(y,r)),$&&J(y=>xe(y,r))},[$]),ot=w.useCallback(r=>{J(y=>xe(y,r)),$&&_(y=>xe(y,r))},[$]),te=w.useCallback((r,y)=>{r==="rows"?_(y):J(y)},[]),Le=w.useCallback(r=>{M&&te(r,new Set(he(r==="rows"?M.rowRoots:M.columnRoots)))},[M,te]),Ae=w.useCallback(r=>{te(r,new Set)},[te]),Fe=w.useCallback((r,y)=>{M&&te(r,new Set(he(r==="rows"?M.rowRoots:M.columnRoots,y)))},[M,te]),Te=w.useCallback((r,y)=>{var Z;const I=r==="rows"?ie:re,q=r==="rows"?k:x,N=r==="rows"?M==null?void 0:M.rows:M==null?void 0:M.columns,X=new Set(((Z=N==null?void 0:N.find(pe=>pe.node.id===y))==null?void 0:Z.node.members)??[y]);q(pe=>(pe.length===0?I.map(je=>je.value):pe).filter(je=>!X.has(je)))},[M,ie,re]),st=w.useCallback(async()=>{if(!e||!M)return;const r=Be(e,{rows:{layer:i.layer,kinds:i.kind?[i.kind]:[],elementIds:f,ordering:v,expanded:new Set(he(M.rowRoots))},columns:{layer:l.layer,kinds:l.kind?[l.kind]:[],elementIds:c,ordering:A,expanded:new Set(he(M.columnRoots))},dependencyTypes:j,containmentTypes:U,groupByPackage:C,symmetric:D});await vt(r)},[e,M,i,l,f,c,j,U,C,v,A,D]),ke=w.useMemo(()=>e?bt(e):null,[e]);w.useEffect(()=>{if(ke)return o(ke.issues.map(r=>({id:r.id,source:"DSM",severity:r.severity,elementId:r.elementId,elementName:r.elementName,message:r.message,tag:r.type==="unallocated-function"?"unallocated":r.type==="cross-component-flow"?"cross-boundary":"no functions"}))),()=>o([])},[ke,o]);const it=w.useCallback(r=>{if(!r)return{};if(r.diagonal)return{text:String(r.strength),color:d.muted,background:"#E3E8EE"};const y=Rt(r),I=Math.min(.14+r.strength*.13,.55);return{text:String(r.strength),color:y,background:`${y}${Math.round(I*255).toString(16).padStart(2,"0")}`}},[]);if(!e||!M)return t.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:d.faint,fontSize:z.sm},children:"No model loaded"});const{stats:ne}=M,B=F==="left",rt=B?{display:"grid",gap:"8px",width:"100%"}:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"nowrap",marginTop:"2px"};return t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",style:{background:"#F7F7F5",position:"relative"},children:[t.jsx("div",{style:F==="top"?{borderBottom:`1px solid ${d.border}`,background:d.surface,position:"relative"}:{position:"absolute",inset:"0 auto 0 0",width:"250px",zIndex:30,overflowY:"auto",overflowX:"hidden",borderRight:`1px solid ${d.border}`,background:d.surface,boxShadow:"2px 0 10px rgba(15, 23, 42, 0.06)"},children:t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",style:B?{flexDirection:"column",alignItems:"stretch",gap:"10px",position:"relative",minHeight:"100%",padding:"54px 12px 14px",boxSizing:"border-box"}:{flexWrap:"wrap",rowGap:"2px",position:"relative",paddingRight:"52px"},children:[t.jsx("span",{style:{position:"absolute",top:"9px",right:"12px"},children:t.jsx(ct,{icon:B?t.jsx(G.arrowUp,{}):t.jsx(G.panelCollapse,{}),onClick:()=>E(r=>r==="top"?"left":"top"),title:B?"Move toolbar to top":"Move toolbar to left"})}),t.jsxs("div",{style:rt,children:[t.jsx($e,{axis:"rows",layers:ee,scope:i,onScopeChange:p,elements:f,onElementsChange:k,elementOptions:ie,ordering:v,onOrderingChange:R,onExpandAll:Le,onCollapseAll:Ae,onExpandToDepth:Fe,leftDock:B,filterOpen:L==="rows",onFilterOpenChange:r=>T(r?"rows":null),parentOf:Ee}),t.jsx($e,{axis:"columns",layers:ee,scope:l,onScopeChange:u,elements:c,onElementsChange:x,elementOptions:re,ordering:A,onOrderingChange:P,onExpandAll:Le,onCollapseAll:Ae,onExpandToDepth:Fe,leftDock:B,filterOpen:L==="columns",onFilterOpenChange:r=>T(r?"columns":null),parentOf:Ee})]}),t.jsxs("div",{className:"flex items-center gap-3",style:B?{width:"100%",display:"grid",gridTemplateColumns:"repeat(3, minmax(0, 1fr))",gridTemplateRows:"auto auto",alignItems:"center",columnGap:"10px",rowGap:"8px",padding:"8px",boxSizing:"border-box",border:`1px solid ${d.border}`,borderRadius:"9px",background:"#FAFBFC"}:{flex:"0 0 auto",alignSelf:"stretch",alignContent:"space-between",display:"grid",gridTemplateColumns:"max-content max-content max-content",gridTemplateRows:"auto auto",alignItems:"center",columnGap:"10px",rowGap:"5px",boxSizing:"border-box",padding:"6px 8px",border:`1px solid ${d.border}`,borderRadius:"9px",background:"#FAFBFC"},children:[t.jsx(le,{label:B?t.jsxs(t.Fragment,{children:[t.jsx(G.filter,{})," Rel."]}):t.jsxs(t.Fragment,{children:[t.jsx(G.filter,{})," Relations"]}),ariaLabel:"Filter dependency relationships",title:"Relationships that put a mark in a cell",width:260,fullWidth:B,children:t.jsx(ge,{label:"Dependency",allLabel:"Any relationship",options:we,width:180,selected:j,onChange:g,describedAs:"dependency relationships",title:"Relationships that put a mark in a cell — flow, trace, allocation, …"})}),t.jsxs(le,{label:t.jsx(G.tools,{}),ariaLabel:"DSM options",badge:Me>0?String(Me):void 0,title:"Settings you set once: how nesting is derived, how the axes are grouped, what the header shows",fullWidth:B,children:[t.jsx(ge,{label:"Nesting",allLabel:"Auto (composition)",options:be,width:150,selected:S??[],onChange:r=>m(r.length===0?null:r),describedAs:"nesting relationships",title:"Relationships read as parent → child containment, which is what builds the tree"}),t.jsxs("label",{style:se,title:"Expanding a subsystem on one axis expands the same one on the other",children:[t.jsx("input",{type:"checkbox",checked:$,onChange:r=>O(r.target.checked),style:{accentColor:d.accent}}),"Linked axes"]}),t.jsxs("label",{style:se,title:"Show column names above the grid as well as their numbers",children:[t.jsx("input",{type:"checkbox",checked:K,onChange:r=>Y(r.target.checked),style:{accentColor:d.accent}}),"Column names"]}),t.jsxs("label",{style:se,title:"Group top-level elements under their SysML package",children:[t.jsx("input",{type:"checkbox",checked:C,onChange:r=>b(r.target.checked),style:{accentColor:d.accent}}),"Group by package"]}),t.jsxs("label",{style:se,title:"Count every dependency in both directions, making the matrix symmetric",children:[t.jsx("input",{type:"checkbox",checked:D,onChange:r=>Q(r.target.checked),style:{accentColor:d.accent}}),"Both directions"]})]}),t.jsxs(le,{label:t.jsx(G.download,{}),ariaLabel:"Export DSM",title:"Export the DSM",width:220,fullWidth:B,children:[t.jsxs("button",{onClick:()=>jt(M),style:Xe,children:["CSV ",t.jsx("span",{style:{color:d.faint},children:"current visible matrix"})]}),t.jsxs("button",{onClick:()=>{st()},style:Xe,children:["Excel (.xlsx) ",t.jsx("span",{style:{color:d.faint},children:"with expandable hierarchy"})]})]}),t.jsxs("label",{style:{...se,gap:"5px",gridColumn:B?"1 / -1":void 0,justifyContent:B?"center":void 0},title:"Cell size",children:["Zoom",t.jsx("input",{type:"range",min:14,max:44,step:2,value:V,onChange:r=>h(Number(r.target.value)),style:{width:"76px",accentColor:d.accent}})]})]})]})}),t.jsx("div",{style:{display:"flex",flex:1,minHeight:0,minWidth:0,marginLeft:B?"250px":0,width:B?"calc(100% - 250px)":void 0},children:t.jsx(Ct,{result:M,onToggleRow:nt,onToggleColumn:ot,onSelectElement:a,selectedElementId:n,renderCell:it,onCellClick:(r,y,I)=>{I&&ce({row:r,column:y,cell:I}),a(r.node.id)},cellSize:V,showColumnNames:K,onHideRow:r=>Te("rows",r),onHideColumn:r=>Te("columns",r),cornerHeader:t.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"flex-end",height:"100%"},children:[t.jsx("span",{style:{fontSize:z.sm,fontWeight:600,color:d.primary},children:"Design Structure Matrix"}),t.jsxs("span",{style:{fontSize:"11px",color:d.faint,marginTop:"2px"},children:[M.rows.length," ","×"," ",M.columns.length," ","·"," ",M.totalDependencies," dependencies",ne.internal>0&&` · ${ne.internal} internal`]}),t.jsx("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap",fontSize:"10px",color:d.muted,borderTop:`1px solid ${d.border}`,marginTop:"5px",paddingTop:"4px"},children:[["feedback",ne.feedback,"Marks below the diagonal — candidates for rework loops"],["coupled",ne.couplings,"Pairs that depend on each other in both directions"],["isolated",ne.isolated,"Lines with no dependency either way"],["max degree",ne.maxDegree,"Most dependencies touching one line"]].map(([r,y,I])=>t.jsxs("span",{title:I,children:[t.jsx("strong",{style:{color:d.primary},children:y})," ",r]},r))})]}),footer:t.jsxs("div",{style:{marginTop:"18px",display:"flex",gap:"14px",flexWrap:"wrap",fontSize:"11px",color:d.muted},children:[[...new Set(M.matrix.flat().flatMap(r=>(r==null?void 0:r.types)??[]))].sort().map(r=>t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{style:{width:"10px",height:"10px",borderRadius:"2px",background:ae(r)}}),r]},r)),t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{style:{width:"10px",height:"10px",borderRadius:"2px",background:"#E3E8EE"}}),"diagonal: dependencies inside the subsystem"]}),t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("span",{style:{width:"10px",height:"2px",background:"#94A3B8"}}),"subsystem boundary"]})]})})}),H&&t.jsxs("div",{style:{position:"fixed",bottom:"76px",right:"20px",zIndex:100,width:"300px",padding:"12px 14px",borderRadius:"9px",background:d.surface,border:`1px solid ${d.border}`,boxShadow:"0 6px 22px rgba(0,0,0,0.14)",fontSize:z.xs},children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{style:{fontWeight:600,color:d.primary},children:[H.row.node.name," ","→"," ",H.column.node.name]}),t.jsx("button",{onClick:()=>ce(null),style:{color:d.faint,background:"none",border:"none",cursor:"pointer"},children:"✕"})]}),t.jsxs("div",{style:{color:d.muted,margin:"6px 0"},children:[H.cell.strength," dependenc",H.cell.strength===1?"y":"ies",H.cell.aggregated&&" · rolled up from collapsed parts",H.cell.diagonal&&" · internal to this subsystem"]}),t.jsx("div",{style:{display:"flex",gap:"4px",flexWrap:"wrap"},children:H.cell.types.map(r=>t.jsx("span",{style:{fontSize:"10px",padding:"2px 6px",borderRadius:"4px",background:`${ae(r)}20`,color:ae(r),fontWeight:500},children:r},r))}),H.cell.aggregated&&t.jsx("div",{style:{marginTop:"8px",fontSize:"11px",color:d.faint},children:"Expand both sides to see which parts are actually joined."})]})]})}function xe(e,a){const n=new Set(e);return n.has(a)?n.delete(a):n.add(a),n}function $e({axis:e,layers:a,scope:n,onScopeChange:o,elements:s,onElementsChange:i,elementOptions:p,ordering:l,onOrderingChange:u,onExpandAll:f,onCollapseAll:k,onExpandToDepth:c,leftDock:x,filterOpen:j,onFilterOpenChange:g,parentOf:S}){var C,b;const m=e==="rows"?"Rows":"Columns";return x?t.jsxs("section",{style:{display:"grid",gap:"5px",padding:"6px 8px",borderRadius:"8px",border:`1px solid ${d.borderLight}`,background:d.surfaceAlt},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"7px"},children:[t.jsx("span",{style:{fontSize:z.xs,fontWeight:700,color:d.secondary},children:m}),t.jsx(He,{label:"",layers:a,value:n,onChange:o,width:138,describedAs:`${e} scope`,title:`What the ${e} list — one architecture layer, or one element type within it.`})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"7px"},children:[t.jsx(le,{label:t.jsx(G.filter,{}),ariaLabel:`Filter ${e} elements`,title:`Filter elements on the ${e} axis`,width:255,open:j,onOpenChange:g,children:t.jsx(ge,{label:"Elements",allLabel:`all ${p.length}`,options:p,selected:s,onChange:i,width:170,describedAs:`${e} elements`,placeholder:"Filter by name, kind or id…",parentOf:S})}),t.jsx(Ge,{axis:e,onExpandAll:f,onCollapseAll:k,onExpandToDepth:c,showLabel:!1,showDepth:!1})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"7px"},children:[t.jsx(et,{axis:e,onExpandToDepth:c,compact:!0}),t.jsx("select",{value:l,onChange:v=>u(v.target.value),"aria-label":`Sort ${e} siblings`,title:(C=fe.find(v=>v.value===l))==null?void 0:C.title,style:{...me,width:"112px"},children:fe.map(v=>t.jsx("option",{value:v.value,title:v.title,children:v.label},v.value))})]})]}):t.jsxs("section",{style:{display:"grid",gridTemplateRows:"auto auto",gap:"4px",boxSizing:"border-box",padding:"6px 8px",border:`1px solid ${d.border}`,borderRadius:"9px",background:"#FAFBFC"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"7px"},children:[t.jsx("span",{style:{fontSize:z.xs,fontWeight:700,color:d.secondary},children:m}),t.jsx(He,{label:"",layers:a,value:n,onChange:o,width:150,describedAs:`${e} scope`,title:`What the ${e} list — one architecture layer, or one element type within it.`}),t.jsx(le,{label:t.jsx(G.filter,{}),ariaLabel:`Filter ${e} elements`,title:`Filter elements on the ${e} axis`,width:255,open:j,onOpenChange:g,children:t.jsx(ge,{label:"Elements",allLabel:`all ${p.length}`,options:p,selected:s,onChange:i,width:170,describedAs:`${e} elements`,placeholder:"Filter by name, kind or id…",parentOf:S})})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"7px",flexWrap:"wrap"},children:[t.jsx(Ge,{axis:e,onExpandAll:f,onCollapseAll:k,onExpandToDepth:c,showLabel:!1}),t.jsxs("label",{style:{...se,gap:"5px"},title:`Sort ${e} siblings`,children:["Sort",t.jsx("select",{value:l,onChange:v=>u(v.target.value),"aria-label":`Sort ${e} siblings`,title:(b=fe.find(v=>v.value===l))==null?void 0:b.title,style:me,children:fe.map(v=>t.jsx("option",{value:v.value,title:v.title,children:v.label},v.value))})]})]})]})}function Ge({axis:e,onExpandAll:a,onCollapseAll:n,onExpandToDepth:o,showLabel:s=!0,showDepth:i=!0,compact:p=!1}){const l=e==="rows"?"row":"column",u=e==="rows"?"Rows":"Columns";return t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:"5px"},children:[s&&t.jsx("span",{style:{fontSize:z.xs,color:d.muted,fontWeight:600},children:u}),t.jsxs(pt,{children:[t.jsx(Oe,{icon:t.jsx(G.expand,{}),onClick:()=>a(e),title:`Expand every ${l} subsystem`,ariaLabel:`Expand all ${e}`}),t.jsx(Oe,{icon:t.jsx(G.collapse,{}),onClick:()=>n(e),title:`Collapse ${e} to their top-level subsystems`,ariaLabel:`Collapse all ${e}`})]}),i&&t.jsx(et,{axis:e,onExpandToDepth:o,compact:p})]})}function et({axis:e,onExpandToDepth:a,compact:n=!1}){return t.jsxs("select",{defaultValue:"","aria-label":`Expand ${e} to depth`,title:`Expand ${e} to a specific depth`,onChange:o=>{const s=Number(o.target.value);s>0&&a(e,s),o.currentTarget.value=""},style:n?{...me,width:"82px"}:me,children:[t.jsx("option",{value:"",children:"Depth…"}),t.jsx("option",{value:"1",children:"Level 1"}),t.jsx("option",{value:"2",children:"Level 2"}),t.jsx("option",{value:"3",children:"Level 3"})]})}const se={display:"flex",alignItems:"center",gap:"6px",fontSize:z.xs,color:d.muted,whiteSpace:"nowrap"},me={border:`1px solid ${d.border}`,borderRadius:"5px",padding:"2px 5px",background:d.surface,fontSize:z.xs,color:d.primary},Xe={display:"flex",justifyContent:"space-between",gap:"12px",width:"100%",padding:"6px 7px",border:"none",borderRadius:"5px",background:"transparent",cursor:"pointer",fontSize:z.xs,color:d.primary,textAlign:"left"},Nt=Object.freeze(Object.defineProperty({__proto__:null,AxisControlGroup:$e,DSMView:Lt},Symbol.toStringTag,{value:"Module"}));export{$e as A,Nt as D,Ct as H,le as T,he as a,Be as c,Ue as e,qe as l,Ve as r,Dt as s};
@@ -0,0 +1 @@
1
+ import{j as e}from"./reactflow-C9OlmOYw.js";import{a as f}from"./zustand-CrhqMOHB.js";import{u as g,H as j,h}from"./index-a2rpMs5Y.js";function k(i,d,s){var u,p;const n=Object.values(i.elements),o={},r={};for(const t of n)o[t.layer]=(o[t.layer]||0)+1,r[t.kind.toLowerCase()]=(r[t.kind.toLowerCase()]||0)+1;const c={};for(const t of i.relationships)c[t.type.toLowerCase()]=(c[t.type.toLowerCase()]||0)+1;return{totalElements:n.length,totalRelationships:i.relationships.length,violations:d,completenessPercent:s,riskCount:(o.risk||0)+(o.analysis||0),requirementsCount:o.requirements||0,architectureCount:["logical","physical","functional","logical_structure","software_structure","hardware_structure","functions","interfaces","system","context","operational","behavior"].reduce((t,a)=>t+(o[a]||0),0),verificationCount:(o.verification||0)+(o.assurance||0),hazardCount:r.hazard||0,requirementCount:Object.entries(r).filter(([t])=>t.endsWith("requirement")).reduce((t,[,a])=>t+a,0),riskControlCount:r.riskcontrol||0,systemCount:(r.system||0)+(r.subsystem||0)+(r.softwaresystem||0)+(r.logicalcomponent||0)+(r.hardwareassembly||0)+(r.softwarecomponent||0)+(r.processingnode||0),testCount:(r.verificationcase||0)+(r.validationcase||0)+(r.testartifact||0)+(r.test||0),mitigatesCount:Object.entries(c).filter(([t])=>t.startsWith("mitigat")).reduce((t,[,a])=>t+a,0),verificationLinkCount:Object.entries(c).filter(([t])=>t.startsWith("verif")||t.startsWith("validate")||t==="testedbyusability").reduce((t,[,a])=>t+a,0),diagramCount:((u=i.diagrams)==null?void 0:u.length)??0,projectName:((p=i.metadata)==null?void 0:p.projectName)||i.projectName||i.name||"My Device Project"}}function F(i){return i.totalElements===0?{icon:"🚀",title:"Add your first model elements",description:"Start with intended use, actors, and a system requirement. Or use the Workflow Wizard to guide you step by step.",urgency:"high"}:i.requirementCount===0?{icon:"📋",title:"Define your first requirement",description:"Your model has elements but no system requirements yet. Add a Requirement in the Model Explorer.",urgency:"high"}:i.hazardCount===0?{icon:"⚠️",title:"Add your first hazard",description:`You have ${i.requirementCount} requirement(s) but no hazard analysis yet. ISO 14971 requires hazard identification early.`,urgency:"high"}:i.hazardCount>0&&i.mitigatesCount===0?{icon:"🔗",title:"Connect hazards to risk controls",description:`You have ${i.hazardCount} hazard(s) but no MitigatesHazard relationships. Connect hazards to risk controls to complete the ISO 14971 chain.`,urgency:"high"}:i.systemCount===0?{icon:"🏗️",title:"Define your system architecture",description:"No architecture components found (SoftwareSystem, LogicalComponent, HardwareAssembly, …). Add an architecture layer to ground your requirements and risk analysis.",urgency:"medium"}:i.testCount===0?{icon:"🧪",title:"Add verification tests",description:`${i.requirementCount} requirement(s) have no verification tests yet. Add VerificationCases and link them to requirements with VerifiedBy.`,urgency:"medium"}:i.verificationLinkCount===0&&i.testCount>0?{icon:"↔️",title:"Link tests to requirements",description:"Verification cases exist but no VerifiedBy links found. Open the Traceability Matrix to connect tests to their requirements.",urgency:"medium"}:{icon:"✅",title:"Good coverage so far",description:"Requirements, hazards, and risk controls are in place. Check the GapBar (⌘⇧P) for completeness gaps before your review.",urgency:"low"}}function m({label:i,value:d,color:s,subtitle:n}){return e.jsxs("div",{style:{background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"12px",padding:"20px 24px",display:"flex",flexDirection:"column",gap:"4px"},children:[e.jsx("div",{style:{fontSize:"28px",fontWeight:800,color:s,lineHeight:1},children:d}),e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"#374151"},children:i}),n&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF"},children:n})]})}function y({layer:i,label:d,count:s,color:n,onClick:o}){const r=s>0;return e.jsxs("button",{onClick:o,style:{background:r?`${n}12`:"#F9FAFB",border:`1px solid ${r?n+"30":"#E5E5E0"}`,borderRadius:"12px",padding:"16px",cursor:"pointer",textAlign:"left",transition:"all 0.15s"},onMouseEnter:c=>{c.currentTarget.style.background=r?`${n}20`:"#F3F4F6",c.currentTarget.style.transform="translateY(-1px)",c.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.08)"},onMouseLeave:c=>{c.currentTarget.style.background=r?`${n}12`:"#F9FAFB",c.currentTarget.style.transform="none",c.currentTarget.style.boxShadow="none"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:r?n:"#9CA3AF"},children:d}),e.jsxs("span",{style:{fontSize:"10px",fontWeight:600,padding:"2px 8px",borderRadius:"999px",background:r?n+"20":"#F3F4F6",color:r?n:"#9CA3AF"},children:[s," elements"]})]}),e.jsx("div",{style:{width:"100%",height:"4px",background:"#F3F4F6",borderRadius:"2px"},children:e.jsx("div",{style:{height:"100%",borderRadius:"2px",background:r?n:"transparent",width:r?`${Math.min(100,s/10*100)}%`:"0",transition:"width 0.4s ease"}})}),e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"8px"},children:r?"Click to explore →":"Not started"})]})}function x({icon:i,label:d,onClick:s,variant:n="secondary"}){const o=n==="primary";return e.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 16px",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:600,border:"none",background:o?"#1B3A4B":"rgba(255,255,255,0.7)",color:o?"#FFFFFF":"#374151",backdropFilter:"blur(4px)",transition:"all 0.15s"},onMouseEnter:r=>{r.currentTarget.style.background=o?"#244D63":"rgba(255,255,255,0.95)",r.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.1)"},onMouseLeave:r=>{r.currentTarget.style.background=o?"#1B3A4B":"rgba(255,255,255,0.7)",r.currentTarget.style.boxShadow="none"},children:[e.jsx("span",{children:i}),e.jsx("span",{children:d})]})}function E(){var b;const i=g(l=>l.model),d=g(l=>l.validation),s=g(l=>l.completeness),n=g(l=>l.setActiveView),o=g(l=>l.setExplorerTab),r=j(),c=g(l=>l.toggleGapBar),u=((b=d==null?void 0:d.violations)==null?void 0:b.length)??0,p=f.useMemo(()=>{if(typeof(s==null?void 0:s.overall)=="number")return Math.round(s.overall);if(!(s!=null&&s.layers)||s.layers.length===0)return 0;const l=s.layers.reduce((C,v)=>C+(v.completeness||0),0)/s.layers.length;return Math.round(l)},[s]),t=f.useMemo(()=>i?k(i,u,p):null,[i,u,p]),a=f.useMemo(()=>t?F(t):null,[t]);return!t||!i?e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",background:"#F7F7F5"},children:e.jsx("div",{style:{fontSize:"13px",color:"#9CA3AF"},children:"Loading dashboard…"})}):e.jsx("div",{style:{flex:1,overflowY:"auto",background:"linear-gradient(135deg, #EEF7F3 0%, #EAF2F8 55%, #F2EEF8 100%)",padding:"32px 40px"},children:e.jsxs("div",{style:{maxWidth:"960px",margin:"0 auto"},children:[e.jsxs("div",{style:{marginBottom:"28px"},children:[e.jsxs("div",{style:{position:"relative",width:260,height:154,overflow:"hidden",margin:"0 auto -10px",opacity:.62},title:"MEMO Architect","aria-label":"MEMO Architect",children:[e.jsx("img",{src:"/logo.png",alt:"","aria-hidden":"true",style:{width:260,height:260,objectFit:"contain",transform:"translateY(-32px)",mixBlendMode:"multiply"}}),e.jsx("span",{style:{position:"absolute",left:"59%",top:115,color:"#8B949E",fontSize:20,fontWeight:600,letterSpacing:"0.02em",whiteSpace:"nowrap"},children:"Architect"})]}),e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:"22px",fontWeight:800,color:"#1B3A4B",margin:"0 0 4px 0"},children:t.projectName}),e.jsxs("p",{style:{fontSize:"13px",color:"#4B6E80",margin:0},children:["Model dashboard · ",new Date().toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})]})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"12px",marginBottom:"24px"},children:[e.jsx(m,{label:"Elements",value:t.totalElements,color:"#1B3A4B"}),e.jsx(m,{label:"Relationships",value:t.totalRelationships,color:"#4A90D9"}),e.jsx(m,{label:"Completeness",value:`${p}%`,color:p>=70?"#2ECC71":p>=40?"#F39C12":"#E74C3C"}),e.jsx(m,{label:"Violations",value:u,color:u===0?"#2ECC71":"#E74C3C",subtitle:u===0?"All rules passing":"Open the GapBar"})]}),e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h2",{style:{fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:"#7A9BAA",margin:"0 0 12px 0"},children:"Layer Coverage"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"12px"},children:[e.jsx(y,{layer:"requirements",label:"Requirements",count:t.requirementsCount,color:h.requirements,onClick:()=>{o("model"),n({type:"welcome"})}}),e.jsx(y,{layer:"risk",label:"Risk",count:t.riskCount,color:h.risk,onClick:()=>{o("model"),n({type:"welcome"})}}),e.jsx(y,{layer:"logical",label:"Architecture",count:t.architectureCount,color:h.logical,onClick:()=>{o("views"),n({type:"welcome"})}}),e.jsx(y,{layer:"verification",label:"Verification",count:t.verificationCount,color:h.verification,onClick:()=>n({type:"traceability"})})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px",marginBottom:"24px"},children:[a&&e.jsxs("div",{style:{background:a.urgency==="high"?"rgba(231,76,60,0.06)":a.urgency==="medium"?"rgba(243,156,18,0.06)":"rgba(46,204,113,0.06)",border:`1px solid ${a.urgency==="high"?"#E74C3C30":a.urgency==="medium"?"#F39C1230":"#2ECC7130"}`,borderRadius:"12px",padding:"20px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:"#7A9BAA",marginBottom:"10px"},children:"💡 Suggested Next Step"}),e.jsx("div",{style:{fontSize:"16px",marginBottom:"6px"},children:a.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:700,color:"#1B3A4B",marginBottom:"6px"},children:a.title}),e.jsx("div",{style:{fontSize:"12px",color:"#4B6E80",lineHeight:"1.6"},children:a.description}),a.urgency!=="low"&&e.jsx("button",{onClick:()=>n({type:"workflow-wizard"}),style:{marginTop:"14px",padding:"8px 14px",fontSize:"12px",fontWeight:600,background:"#1B3A4B",color:"#FFFFFF",border:"none",borderRadius:"6px",cursor:"pointer"},onMouseEnter:l=>l.currentTarget.style.background="#244D63",onMouseLeave:l=>l.currentTarget.style.background="#1B3A4B",children:"Open Workflow Wizard →"})]}),e.jsxs("div",{style:{background:"rgba(255,255,255,0.6)",border:"1px solid rgba(255,255,255,0.9)",borderRadius:"12px",padding:"20px",backdropFilter:"blur(4px)"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:"#7A9BAA",marginBottom:"14px"},children:"Quick Actions"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx(x,{icon:"🗂️",label:"Browse Model",onClick:()=>{o("model"),r("/catalog")}}),e.jsx(x,{icon:"📊",label:"Open Viewpoints",onClick:()=>{o("views"),r("/diagrams")}}),e.jsx(x,{icon:"↔️",label:"Traceability Matrix",onClick:()=>n({type:"traceability"})}),e.jsx(x,{icon:"📋",label:"First Review Dashboard",onClick:()=>n({type:"review-dashboard"})}),e.jsx(x,{icon:"✅",label:"Check Completeness",onClick:()=>c()}),e.jsx(x,{icon:"📈",label:"Full Statistics",onClick:()=>n({type:"statistics"})})]})]})]}),t.diagramCount>0&&e.jsx("div",{style:{background:"rgba(255,255,255,0.6)",border:"1px solid rgba(255,255,255,0.9)",borderRadius:"12px",padding:"16px 20px",backdropFilter:"blur(4px)"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{fontSize:"13px",fontWeight:600,color:"#374151"},children:[t.diagramCount," model view",t.diagramCount!==1?"s":""," in this project"]}),e.jsx("button",{onClick:()=>o("views"),style:{fontSize:"12px",color:"#4A90D9",background:"none",border:"none",cursor:"pointer",fontWeight:600},children:"Browse viewpoints →"})]})})]})})}export{E as Dashboard};
@@ -0,0 +1 @@
1
+ import{j as e}from"./reactflow-C9OlmOYw.js";import{a as g}from"./zustand-CrhqMOHB.js";import{u as S}from"./index-a2rpMs5Y.js";const y=[{id:"rmp",title:"Risk Management Plan",standards:["ISO 14971:2019 §4.4"],layers:["risk"],relevantKinds:["Hazard","HazardousSituation","Harm","RiskControlMeasure","RiskAcceptabilityCriteria"],group:"risk"},{id:"har",title:"Hazard Analysis Report",standards:["ISO 14971:2019 §5","ISO 14971:2019 §6"],layers:["risk"],relevantKinds:["Hazard","HazardousSituation","Harm","RiskControlMeasure"],group:"risk"},{id:"fmea",title:"Failure Mode and Effects Analysis",standards:["IEC 60812:2018"],layers:["risk","functional","physical"],relevantKinds:["Hazard","RiskControlMeasure","Function","Component","Subsystem"],group:"risk"},{id:"rtm",title:"Requirements Traceability Matrix",standards:["IEC 62304:2006 §5.1.1"],layers:["requirements","functional","verification"],relevantKinds:["Requirement","Requirement","DesignInput","DesignOutput","TestCase","VerificationActivity"],group:"design"},{id:"sad",title:"System Architecture Description",standards:["ISO/IEC/IEEE 42010:2022"],layers:["functional","logical","physical","software","interfaces"],relevantKinds:["Function","Component","Subsystem","Interface","Port","SoftwareElement","SOUPComponent"],group:"design"},{id:"sds",title:"Software Design Specification",standards:["IEC 62304:2006 §5.4"],layers:["software"],relevantKinds:["SoftwareElement","SoftwareUnit","SoftwareSystem","SOUPComponent","Interface"],group:"design"},{id:"soup",title:"SOUP List",standards:["IEC 62304:2006 §8.1.2"],layers:["software"],relevantKinds:["SOUPComponent"],group:"design"},{id:"dip",title:"Design Input Plan",standards:["ISO 13485:2016 §7.3.3"],layers:["requirements","business"],relevantKinds:["DesignInput","Requirement","Need","UseCase"],group:"design"},{id:"dop",title:"Design Output Plan",standards:["ISO 13485:2016 §7.3.4"],layers:["functional","physical","software"],relevantKinds:["DesignOutput","Component","SoftwareElement","Function"],group:"design"},{id:"vvp",title:"Verification & Validation Plan",standards:["ISO 13485:2016 §7.3.6"],layers:["verification"],relevantKinds:["TestCase","VerificationActivity","ValidationActivity","TestProtocol"],group:"verification"},{id:"vvr",title:"Verification & Validation Report",standards:["ISO 13485:2016 §7.3.7"],layers:["verification"],relevantKinds:["TestCase","VerificationActivity","ValidationActivity","TestResult"],group:"verification"},{id:"sdp",title:"Software Development Plan",standards:["IEC 62304:2006 §5.1"],layers:["software","verification"],relevantKinds:["SoftwareElement","SoftwareUnit","SoftwareSystem","TestCase"],group:"compliance"},{id:"csr",title:"Clinical Safety Report",standards:["ISO 14971:2019 §10"],layers:["risk","verification"],relevantKinds:["Hazard","RiskControlMeasure","ClinicalEvidence","ValidationActivity"],group:"compliance"},{id:"uer",title:"Usability Engineering Report",standards:["IEC 62366-1:2015"],layers:["ui","requirements"],relevantKinds:["UseCase","UserActivity","UserInterface","UsabilityRequirement"],group:"compliance"},{id:"cybersecurity",title:"Cybersecurity Documentation",standards:["IEC 81001-5-1:2021"],layers:["software","interfaces"],relevantKinds:["ThreatModel","SecurityControl","Interface","SOUPComponent"],group:"compliance"},{id:"labeling",title:"Labeling Specification",standards:["21 CFR 801"],layers:["requirements","ui"],relevantKinds:["LabelingRequirement","Requirement"],group:"compliance"},{id:"dhf-index",title:"Design History File Index",standards:["ISO 13485:2016 §4.2.4"],layers:[],relevantKinds:[],group:"all"},{id:"change-log",title:"Design Change Log",standards:["ISO 13485:2016 §7.3.9"],layers:[],relevantKinds:[],group:"all"}],k={risk:"Risk Management",design:"Design & Architecture",verification:"Verification & Validation",compliance:"Compliance & Standards",all:"General"},C={risk:"#E74C3C",design:"#4A90D9",verification:"#2ECC71",compliance:"#8E44AD",all:"#6B7280"};function I(s,i,r){const a=Object.values(i.elements).filter(l=>s.relevantKinds.includes(l.kind)),x=((r==null?void 0:r.violations)||[]).filter(l=>s.relevantKinds.includes(l.elementKind)||s.layers.includes(l.layer)),p=x.filter(l=>l.severity==="error").length;return{elementCount:a.length,gapCount:p,status:a.length===0?"empty":p===0?"complete":"partial",violations:x}}function M(){const s=S(t=>t.model),i=S(t=>t.validation),r=S(t=>t.completeness),[a,x]=g.useState(null),[p,l]=g.useState(null),[n,c]=g.useState(!1),f=s==null?void 0:s.standardsReport,b=g.useMemo(()=>{const t=new Map;if(!f)return t;for(const o of f.standards){const d=o.totals.gaps;if(d!==0)for(const u of y)for(const j of u.standards)j.startsWith(o.designation.split(":")[0])&&t.set(u.id,(t.get(u.id)??0)+d)}return t},[f]),v=g.useMemo(()=>{if(!s)return new Map;const t=new Map;for(const o of y)t.set(o.id,I(o,s,i));return t},[s,i]),B=g.useMemo(()=>{let t=y;return p&&(t=t.filter(o=>o.group===p||o.group==="all")),n&&(t=t.filter(o=>(b.get(o.id)??0)>0)),t},[p,n,b]),w=g.useMemo(()=>{const t=new Map;for(const o of B){const d=o.group;t.has(d)||t.set(d,[]),t.get(d).push(o)}return t},[B]),m=g.useMemo(()=>{let t=0,o=0,d=0;for(const u of v.values())u.status==="complete"?t++:u.status==="partial"?o++:d++;return{complete:t,partial:o,empty:d,total:y.length}},[v]);if(!s)return e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#9CA3AF"},children:"Waiting for model data..."});const R=a?y.find(t=>t.id===a):null,D=a?v.get(a):null;return e.jsxs("div",{style:{height:"100%",overflow:"auto",background:"#F7F7F5",padding:"24px"},children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h2",{style:{fontSize:"20px",fontWeight:700,color:"#1B3A4B",margin:0},children:"Documents"}),e.jsxs("p",{style:{color:"#6B7280",fontSize:"13px",marginTop:"4px"},children:["Design history file · ",m.total," documents | ",m.complete," complete | ",m.partial," partial | ",m.empty," empty",r&&` | Overall completeness: ${r.overall}%`]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:"12px",marginBottom:"24px"},children:[e.jsx(h,{label:"Complete",value:m.complete,color:"#059669"}),e.jsx(h,{label:"Partial",value:m.partial,color:"#d97706"}),e.jsx(h,{label:"Empty",value:m.empty,color:"#dc2626"}),e.jsx(h,{label:"Completeness",value:`${(r==null?void 0:r.overall)||0}%`,color:"#2563eb"})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"20px",flexWrap:"wrap"},children:[e.jsx(A,{label:"All",active:!p&&!n,onClick:()=>{l(null),c(!1)}}),Object.entries(k).filter(([t])=>t!=="all").map(([t,o])=>e.jsx(A,{label:o,active:p===t,onClick:()=>{l(p===t?null:t),c(!1)},color:C[t]},t)),f&&e.jsx(A,{label:`Has gaps (${b.size})`,active:n,onClick:()=>{c(!n),l(null)},color:"#dc2626"})]}),a?e.jsx(E,{doc:R,status:D,model:s,validation:i,onBack:()=>x(null)}):Array.from(w.entries()).map(([t,o])=>e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:C[t]||"#374151",marginBottom:"12px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:C[t]||"#6B7280",display:"inline-block"}}),k[t]||t]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:"12px"},children:o.map(d=>{const u=v.get(d.id),j=b.get(d.id)??0;return e.jsx(z,{doc:d,status:u,standardsGap:j,onClick:()=>x(d.id)},d.id)})})]},t))]})}function h({label:s,value:i,color:r}){return e.jsxs("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:"8px",padding:"14px 16px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"24px",fontWeight:700,color:r},children:i}),e.jsx("div",{style:{fontSize:"11px",color:"#6B7280",marginTop:"2px"},children:s})]})}function A({label:s,active:i,onClick:r,color:a}){return e.jsx("button",{onClick:r,style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:500,border:`1px solid ${i?a||"#2DD4A8":"#e5e7eb"}`,background:i?(a||"#2DD4A8")+"15":"#fff",color:i?a||"#1B3A4B":"#6B7280",cursor:"pointer"},children:s})}function z({doc:s,status:i,standardsGap:r=0,onClick:a}){const x=i.status==="complete"?"#059669":i.status==="partial"?"#d97706":"#dc2626",p=i.status==="complete"?"#ecfdf5":i.status==="partial"?"#fffbeb":"#fef2f2",l=i.status==="complete"?"Complete":i.status==="partial"?"Partial":"Empty";return e.jsxs("div",{onClick:a,style:{background:"#fff",border:`1px solid ${r>0?"#fecaca":"#e5e7eb"}`,borderRadius:"8px",padding:"16px",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s"},onMouseEnter:n=>{n.currentTarget.style.borderColor="#2DD4A8",n.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.06)"},onMouseLeave:n=>{n.currentTarget.style.borderColor=r>0?"#fecaca":"#e5e7eb",n.currentTarget.style.boxShadow="none"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:600,color:"#6B7280",fontFamily:"monospace"},children:s.id.toUpperCase()}),e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[r>0&&e.jsxs("span",{style:{fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",background:"#fef2f2",color:"#dc2626"},title:`${r} standard clause${r!==1?"s":""} unclaimed`,children:[r," clauses"]}),e.jsx("span",{style:{fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",background:p,color:x},children:l})]})]}),e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:"#1B3A4B",marginBottom:"6px"},children:s.title}),e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginBottom:"8px"},children:s.standards[0]}),e.jsxs("div",{style:{display:"flex",gap:"16px",fontSize:"12px",color:"#6B7280"},children:[e.jsxs("span",{children:[i.elementCount," elements"]}),i.gapCount>0&&e.jsxs("span",{style:{color:"#dc2626"},children:[i.gapCount," gaps"]})]})]})}function E({doc:s,status:i,model:r,validation:a,onBack:x}){const p=Object.values(r.elements).filter(n=>s.relevantKinds.includes(n.kind)),l=new Map;for(const n of p)l.has(n.kind)||l.set(n.kind,[]),l.get(n.kind).push(n);return e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("button",{onClick:x,style:{background:"none",border:"none",color:"#2563eb",cursor:"pointer",fontSize:"13px",padding:0,marginBottom:"8px"},children:"← Back to dashboard"}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:700,color:"#1B3A4B",margin:0},children:s.title}),e.jsxs("p",{style:{color:"#6B7280",fontSize:"12px",marginTop:"4px"},children:[s.id.toUpperCase()," | ",s.standards.join(", ")]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:"12px",marginBottom:"20px"},children:[e.jsx(h,{label:"Elements",value:i.elementCount,color:"#2563eb"}),e.jsx(h,{label:"Gaps",value:i.gapCount,color:i.gapCount>0?"#dc2626":"#059669"}),e.jsx(h,{label:"Status",value:i.status,color:i.status==="complete"?"#059669":i.status==="partial"?"#d97706":"#dc2626"})]}),Array.from(l.entries()).sort().map(([n,c])=>e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("h4",{style:{fontSize:"13px",fontWeight:600,color:"#374151",marginBottom:"8px"},children:[n," (",c.length,")"]}),e.jsxs("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:"6px",overflow:"hidden"},children:[e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f3f4f6"},children:[e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#374151"},children:"Name"}),e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#374151"},children:"Layer"}),e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600,color:"#374151"},children:"Description"})]})}),e.jsx("tbody",{children:c.slice(0,50).map(f=>e.jsxs("tr",{style:{borderTop:"1px solid #e5e7eb"},children:[e.jsx("td",{style:{padding:"6px 10px",color:"#2563eb",fontWeight:500},children:f.name}),e.jsx("td",{style:{padding:"6px 10px",color:"#6B7280"},children:f.layer}),e.jsx("td",{style:{padding:"6px 10px",color:"#6B7280",maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.doc||"—"})]},f.id))})]}),c.length>50&&e.jsxs("div",{style:{padding:"8px 10px",fontSize:"11px",color:"#9CA3AF",background:"#f9fafb"},children:["...and ",c.length-50," more"]})]})]},n)),i.violations.length>0&&e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("h4",{style:{fontSize:"13px",fontWeight:600,color:"#dc2626",marginBottom:"8px"},children:["Validation Issues (",i.violations.length,")"]}),e.jsx("div",{style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:"6px",overflow:"hidden"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"#f3f4f6"},children:[e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600},children:"Severity"}),e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600},children:"Rule"}),e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600},children:"Element"}),e.jsx("th",{style:{padding:"6px 10px",textAlign:"left",fontWeight:600},children:"Description"})]})}),e.jsx("tbody",{children:i.violations.slice(0,50).map((n,c)=>e.jsxs("tr",{style:{borderTop:"1px solid #e5e7eb"},children:[e.jsx("td",{style:{padding:"6px 10px"},children:e.jsx("span",{style:{fontSize:"10px",fontWeight:600,padding:"1px 6px",borderRadius:"3px",background:n.severity==="error"?"#fef2f2":"#fffbeb",color:n.severity==="error"?"#dc2626":"#d97706"},children:n.severity})}),e.jsx("td",{style:{padding:"6px 10px",color:"#6B7280",fontFamily:"monospace",fontSize:"11px"},children:n.ruleId}),e.jsx("td",{style:{padding:"6px 10px",color:"#2563eb"},children:n.elementName}),e.jsx("td",{style:{padding:"6px 10px",color:"#6B7280"},children:n.description})]},c))})]})})]}),p.length===0&&e.jsxs("div",{style:{padding:"40px",textAlign:"center",color:"#9CA3AF",background:"#fff",border:"1px solid #e5e7eb",borderRadius:"8px"},children:[e.jsx("p",{style:{fontSize:"14px",marginBottom:"4px"},children:"No model elements found for this document type."}),e.jsxs("p",{style:{fontSize:"12px"},children:["Add elements of kinds: ",s.relevantKinds.join(", ")]})]})]})}export{M as DhfDashboard};
@@ -0,0 +1,69 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-a2rpMs5Y.js","assets/reactflow-C9OlmOYw.js","assets/zustand-CrhqMOHB.js","assets/index-Cdkjp-H4.css"])))=>i.map(i=>d[i]);
2
+ import{u as $,p as te,M as oe,_ as ne}from"./index-a2rpMs5Y.js";import{j as e}from"./reactflow-C9OlmOYw.js";import{a as f}from"./zustand-CrhqMOHB.js";const re=/<div class="memo-doc-diagram" data-diagram-id="([^"]*)"><\/div>/;function m(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function U(t,r){const n=t.split(`
3
+ `).map(o=>o.trim()).filter(Boolean);return n.length===0?`<tr><td colspan="4" style="color:#9CA3AF;font-style:italic">No ${r.toLowerCase()}s defined</td></tr>`:n.map(o=>{const[s="",a=""]=o.split("|").map(u=>u.trim());return`<tr><td>${m(s)}</td><td>${m(a||r)}</td><td style="color:#9CA3AF">—</td><td style="color:#9CA3AF">—</td></tr>`}).join("")}function ie(t){const r=t.authors.trim().length>0,n=t.approvers.trim().length>0,o="<thead><tr><th>Name</th><th>Role</th><th>Signature</th><th>Date</th></tr></thead>";return`
4
+ <h2>Authors</h2>
5
+ <table>${o}<tbody>${U(t.authors,"Author")}</tbody></table>
6
+ ${r?"":'<p style="font-size:11px;color:#dc2626">⚠ No authors set — open Document Properties to add authors.</p>'}
7
+ <h2>Approvers</h2>
8
+ <table>${o}<tbody>${U(t.approvers,"Approver")}</tbody></table>
9
+ ${n?"":'<p style="font-size:11px;color:#dc2626">⚠ No approvers set — open Document Properties to add approvers.</p>'}`}function se(t){const r=[],n=/^(#{2,4})\s+(.+)$/gm;let o;for(;(o=n.exec(t))!==null;){const s=(o[1].length-2)*18;r.push(`<div style="margin-left:${s}px">${m(o[2].trim())}</div>`)}return r.length===0?"":`<h2>Table of Contents</h2><div class="memo-doc-toc">${r.join("")}</div>`}function le(t,r,n,o,s){t=t.replace(/\{\{include:shared\/snippets\/approval-block\.md\}\}/g,()=>ie(o)),t=t.replace(/\{\{include:([^}]+)\}\}/g,(l,d)=>`<span class="directive-placeholder">[Snippet: ${m(d)} — rendered on export]</span>`);const a={company:n.company,product:n.product,device_type:n.deviceType,version:n.version,phase:n.phase};t=t.replace(/\{\{project\.([^}]+)\}\}/g,(l,d)=>{const x=a[d];return x&&x.trim()?m(x):`<span class="directive-error">⚠ {{project.${m(d)}}} — not set</span>`}),t=t.replace(/\{\{ref:([^.}]+)(?:\.(\w+))?\}\}/g,(l,d,x)=>{if(!r)return`<code>${m(d)}</code>`;const p=r.elements[d];return p?m(!x||x==="name"?p.name:String(p[x]??p.name)):`<em>[${m(d)} not found]</em>`}),t=t.replace(/\{\{diagram:([^}]+)\}\}/g,(l,d)=>s.diagrams==="note"?`<p><strong>[Diagram: ${m(d.trim())}]</strong> <em>— view in MEMO Architect</em></p>`:`<div class="memo-doc-diagram" data-diagram-id="${m(d.trim())}"></div>`),t=t.replace(/\{\{toc\}\}/g,()=>s.resolveToc?se(t):'<span class="directive-placeholder">[TOC — generated on export]</span>'),t=t.replace(/\{\{glossary\}\}/g,'<span class="directive-placeholder">[Glossary — generated on export]</span>'),t=t.replace(/\{\{[^}]+\}\}/g,l=>`<span class="directive-placeholder">${m(l)}</span>`);const u=[];for(const l of t.matchAll(/<!--[\s\S]*?-->/g))u.push([l.index,l.index+l[0].length]);return t=t.replace(/```memo-query\r?\n([\s\S]*?)```/g,(l,d,x)=>{if(u.some(([h,C])=>x>=h&&x<C))return l;const p=d.split(`
10
+ `).filter(Boolean),j=h=>(p.find(C=>C.startsWith(h))??"").replace(h,"").trim(),c=j("kind:")||"?",k=j("display:")||"table",y=j("empty:").replace(/^['"]|['"]$/g,"")||"No results found.",b=j("label:")||c;if(!r)return`<div class="query-preview">⟳ <em>memo-query: ${m(c)} (${m(k)})</em></div>`;const w=c.startsWith("[")||c.startsWith("-")?c.replace(/[\[\]]/g,"").split(/[,\n]/).map(h=>h.replace("-","").trim()).filter(Boolean):[c];if(j("select:")==="relationships"){const h=(r.relationships??[]).filter(S=>c==="?"||w.includes(S.type));if(h.length===0)return`<div class="query-preview empty"><em>${m(y)}</em></div>`;if(k==="count")return`<div class="query-preview count"><strong>${h.length}</strong><span>${m(b)}</span></div>`;const C=["source","type","target"],R=C.map(S=>`<th>${S}</th>`).join(""),q=S=>{var i;return((i=r.elements[S])==null?void 0:i.name)??S},v=h.slice(0,10).map(S=>`<tr>${[q(S.sourceId),S.type,q(S.targetId)].map(A=>`<td>${m(String(A))}</td>`).join("")}</tr>`).join(""),T=h.length>10?`<tr><td colspan="${C.length}" style="color:#9CA3AF;font-size:11px">…and ${h.length-10} more</td></tr>`:"";return`<div class="query-preview"><table><thead><tr>${R}</tr></thead><tbody>${v}${T}</tbody></table></div>`}const g=Object.values(r.elements).filter(h=>w.includes(h.kind));if(g.length===0)return`<div class="query-preview empty"><em>${m(y)}</em></div>`;if(k==="count")return`<div class="query-preview count"><strong>${g.length}</strong><span>${m(b)}</span></div>`;const B=["name","kind","layer"],F=B.map(h=>`<th>${h}</th>`).join(""),M=g.slice(0,10).map(h=>`<tr>${B.map(R=>`<td>${m(String(h[R]??"—"))}</td>`).join("")}</tr>`).join(""),z=g.length>10?`<tr><td colspan="${B.length}" style="color:#9CA3AF;font-size:11px">…and ${g.length-10} more</td></tr>`:"";return`<div class="query-preview"><table><thead><tr>${F}</tr></thead><tbody>${M}${z}</tbody></table></div>`}),t=t.replace(/```memo-script\r?\n([\s\S]*?)```/g,'<div class="query-preview script"><em>memo-script — executed on export</em></div>'),t}function D(t){return t.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*([^*]+)\*/g,"<em>$1</em>").replace(/_([^_]+)_/g,"<em>$1</em>").replace(/`([^`]+)`/g,(r,n)=>`<code>${m(n)}</code>`).replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>')}const V=/^\|\s*:?-{2,}.*\|$/;function ae(t){const r=[],n=t.split(/\r?\n/);let o=0,s=[];const a=()=>{s.length>0&&(r.push(`<p>${D(s.join(" "))}</p>`),s=[])};for(;o<n.length;){const u=n[o],l=u.trim();if(l===""){a(),o++;continue}if(l.startsWith("<")){a(),r.push(u),o++;continue}if(l.match(/^```(\w[\w-]*)?/)){a();const c=[];for(o++;o<n.length&&!n[o].trim().startsWith("```");)c.push(n[o]),o++;o++,r.push(`<pre><code>${m(c.join(`
11
+ `))}</code></pre>`);continue}const x=l.match(/^(#{1,6})\s+(.+)$/);if(x){a();const c=x[1].length;r.push(`<h${c}>${D(x[2])}</h${c}>`),o++;continue}if(/^(-{3,}|\*{3,})$/.test(l)){a(),r.push("<hr>"),o++;continue}if(l.startsWith("> ")||l===">"){a();const c=[];for(;o<n.length&&(n[o].trim().startsWith("> ")||n[o].trim()===">");)c.push(n[o].trim().replace(/^>\s?/,"")),o++;r.push(`<blockquote>${D(c.join(" "))}</blockquote>`);continue}if(l.startsWith("|")&&l.endsWith("|")){a();const c=[];for(;o<n.length&&n[o].trim().startsWith("|")&&n[o].trim().endsWith("|");)c.push(n[o].trim()),o++;const k=g=>g.slice(1,-1).split("|").map(B=>B.trim()),y=c.length>1&&V.test(c[1]),b=y?c.slice(2):c;let w="<table>";y&&(w+=`<thead><tr>${k(c[0]).map(g=>`<th>${D(g)}</th>`).join("")}</tr></thead>`),w+=`<tbody>${b.filter(g=>!V.test(g)).map(g=>`<tr>${k(g).map(B=>`<td>${D(B)}</td>`).join("")}</tr>`).join("")}</tbody></table>`,r.push(w);continue}const p=/^[-*]\s+/.test(l),j=/^\d+\.\s+/.test(l);if(p||j){a();const c=p?"ul":"ol",k=p?/^[-*]\s+/:/^\d+\.\s+/,y=[];for(;o<n.length;){const b=n[o].trim();if(k.test(b))y.push(b.replace(k,"")),o++;else if(b!==""&&/^\s{2,}/.test(n[o])&&y.length>0)y[y.length-1]+=` ${b}`,o++;else break}r.push(`<${c}>${y.map(b=>`<li>${D(b)}</li>`).join("")}</${c}>`);continue}s.push(l),o++}return a(),r.join(`
12
+ `)}function Q(t,r,n,o,s={}){const a=t.replace(/^---[\s\S]*?---\r?\n/,""),u=le(a,r,n,o,s);return ae(u)}const de="#2DD4A8";function X(t){const r=t.primaryColor||"#1B3A4B",n=de,o=t.compactMode?.9:1,s=a=>`${Math.round(a*o)}px`;return`
13
+ .memo-doc{font-size:${s(14)};line-height:1.7;color:#1B3A4B;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
14
+ .memo-doc h1{font-size:${s(22)};font-weight:700;color:${r};border-bottom:2px solid ${n};padding-bottom:8px;margin:0 0 20px}
15
+ .memo-doc h2{font-size:${s(17)};font-weight:700;color:${r};margin:28px 0 12px}
16
+ .memo-doc h3{font-size:${s(14)};font-weight:600;color:#374151;margin:20px 0 8px}
17
+ .memo-doc h4{font-size:${s(13)};font-weight:600;color:#6B7280;margin:12px 0 6px}
18
+ .memo-doc h5,.memo-doc h6{font-size:${s(12)};font-weight:600;color:#6B7280;margin:10px 0 5px}
19
+ .memo-doc p{margin:8px 0}
20
+ .memo-doc ul,.memo-doc ol{margin:8px 0;padding-left:24px}
21
+ .memo-doc li{margin:3px 0}
22
+ .memo-doc table{border-collapse:collapse;width:100%;margin:12px 0;font-size:${s(12)}}
23
+ .memo-doc th,.memo-doc td{border:1px solid #e5e7eb;padding:6px 10px;text-align:left;vertical-align:top}
24
+ .memo-doc th{background:#f3f4f6;font-weight:600}
25
+ .memo-doc code{background:#f3f4f6;padding:1px 5px;border-radius:3px;font-family:monospace;font-size:${s(12)}}
26
+ .memo-doc pre{background:#1e293b;color:#e2e8f0;padding:14px;border-radius:6px;overflow-x:auto}
27
+ .memo-doc pre code{background:none;color:inherit;padding:0}
28
+ .memo-doc blockquote{border-left:3px solid ${n};margin:12px 0;padding:6px 14px;background:#f0fdf9;font-style:italic;color:#374151}
29
+ .memo-doc hr{border:none;border-top:1px solid #e5e7eb;margin:24px 0}
30
+ .memo-doc a{color:${r};text-decoration:underline}
31
+ .memo-doc .directive-placeholder{color:#8B5CF6;font-style:normal;font-size:${s(12)};background:#F5F3FF;padding:1px 5px;border-radius:3px;display:inline-block}
32
+ .memo-doc .directive-error{color:#DC2626;font-size:${s(12)};background:#FEF2F2;border:1px solid #FECACA;padding:1px 6px;border-radius:3px;display:inline-block;font-family:monospace}
33
+ .memo-doc .query-preview{background:#f8fafc;border:1px solid #e2e8f0;border-radius:6px;padding:10px 14px;margin:10px 0;font-size:${s(12)}}
34
+ .memo-doc .query-preview.empty{color:#9CA3AF}
35
+ .memo-doc .query-preview.count{display:flex;align-items:baseline;gap:6px}
36
+ .memo-doc .query-preview.count strong{font-size:${s(24)};color:#2563eb;font-weight:700}
37
+ .memo-doc .query-preview.count span{font-size:${s(13)};color:#6B7280}
38
+ .memo-doc .query-preview.script{color:#7c3aed;font-style:italic}
39
+ @media print {
40
+ .memo-doc{font-size:11pt;color:#000}
41
+ .memo-doc .query-preview{border:1px solid #ccc;background:#fff}
42
+ .memo-doc .directive-placeholder,.memo-doc .directive-error{background:#fff;border:1px dashed #999;color:#555}
43
+ .memo-doc h2{break-after:avoid}
44
+ .memo-doc table{break-inside:avoid}
45
+ }`}const ce=`
46
+ body{margin:0;padding:40px;background:#fff}
47
+ .memo-doc{max-width:800px;margin:0 auto}
48
+ @media print{body{padding:0}}
49
+ `,pe=`
50
+ @page WordSection1{size:8.5in 11.0in;margin:1.0in;mso-header-margin:0.5in;mso-footer-margin:0.5in;mso-footer:f1}
51
+ div.WordSection1{page:WordSection1}
52
+ p.MsoFooter{font-size:9pt;color:#6B7280}
53
+ `;function P(t,r){return`<!--[if supportFields]><span style="mso-element:field-begin"></span><span> ${t} </span><span style="mso-element:field-separator"></span><![endif]-->${r}<!--[if supportFields]><span style="mso-element:field-end"></span><![endif]-->`}const ue=`<h2>Table of Contents</h2><p>${P('TOC \\o "1-3" \\h \\z \\u','<span style="color:#6B7280"><i>Right-click here and choose "Update Field" (or press F9) to generate the table of contents.</i></span>')}</p>`,me=`<div style="mso-element:footer" id="f1"><p class="MsoFooter" align="center" style="text-align:center">Page ${P("PAGE","1")} of ${P("NUMPAGES","1")}</p></div>`;function H(t,r,n,o={}){let s=Q(t.content,r,n,t,{resolveToc:!0,diagrams:"note"});o.word&&(s=s.replace(/<h2>Table of Contents<\/h2><div class="memo-doc-toc">[\s\S]*?<\/div>/,ue));const a=o.word?`<div class="WordSection1"><div class="memo-doc">${s}</div></div>
54
+ ${me}`:`<div class="memo-doc">${s}</div>`;return`<!DOCTYPE html>
55
+ <html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word">
56
+ <head>
57
+ <meta charset="utf-8">
58
+ <title>${G(t.id)} — ${G(t.title)}</title>
59
+ ${o.word?'<meta name="ProgId" content="Word.Document"><!--[if gte mso 9]><xml><w:WordDocument><w:View>Print</w:View></w:WordDocument></xml><![endif]-->':""}
60
+ <style>${X(n)}${ce}${o.word?pe:""}</style>
61
+ </head>
62
+ <body>${a}</body>
63
+ </html>`}function G(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function L(t,r,n){const o=new Blob([r],{type:n}),s=URL.createObjectURL(o),a=document.createElement("a");a.href=s,a.download=t,a.click(),URL.revokeObjectURL(s)}function he(t,r,n){L(`${t.id}.html`,H(t,r,n),"text/html;charset=utf-8")}function xe(t,r,n){L(`${t.id}.doc`,H(t,r,n,{word:!0}),"application/msword")}function fe(t){L(`${t.id}.md`,t.content,"text/markdown;charset=utf-8")}function ge(t,r,n){const o=window.open("","_blank");o&&(o.document.write(H(t,r,n)),o.document.close(),o.setTimeout(()=>{o.focus(),o.print()},150))}const Y=f.lazy(()=>ne(()=>import("./index-a2rpMs5Y.js").then(t=>t.a0),__vite__mapDeps([0,1,2,3])).then(t=>({default:t.DhfSettingsPanel}))),K=[{id:"q-hazards",label:"Hazard Table",description:"All hazards in the risk layer",category:"query",code:'```memo-query\nkind: Hazard\ndisplay: table\ncolumns: name, layer, doc\nsort: name\nempty: "No hazards defined."\n```'},{id:"q-hazardous-situations",label:"Hazardous Situations",description:"All hazardous situations",category:"query",code:"```memo-query\nkind: HazardousSituation\ndisplay: table\ncolumns: name, layer, doc\nsort: name\n```"},{id:"q-risk-controls",label:"Risk Controls",description:"All risk control measures",category:"query",code:"```memo-query\nkind: RiskControlMeasure\ndisplay: table\ncolumns: name, layer, doc\nsort: name\n```"},{id:"q-requirements",label:"Requirements",description:"All system requirements",category:"query",code:"```memo-query\nkind: Requirement\ndisplay: table\ncolumns: name, layer, doc\nsort: name\n```"},{id:"q-soup",label:"SOUP List",description:"All SOUP components",category:"query",code:"```memo-query\nkind: SOUPComponent\ndisplay: table\ncolumns: name, layer, doc\n```"},{id:"q-sw-items",label:"Software Items",description:"All software items",category:"query",code:"```memo-query\nkind: SoftwareElement\ndisplay: table\ncolumns: name, layer, doc\n```"},{id:"q-test-cases",label:"Test Cases",description:"All test cases",category:"query",code:"```memo-query\nkind: TestCase\ndisplay: table\ncolumns: name, layer, doc\n```"},{id:"q-hazard-count",label:"Hazard Count (metric)",description:"Metric badge with hazard count",category:"query",code:"```memo-query\nkind: Hazard\ndisplay: count\nlabel: Total hazards\n```"},{id:"s-unmitigated",label:"Unmitigated Hazards",description:"Hazards without risk controls",category:"script",code:"```memo-script\nconst hazards = query({ kind: 'Hazard' });\nconst unmitigated = hazards.filter(h => h.mitigatedBy?.length === 0);\nif (unmitigated.length === 0) return 'All hazards have associated risk controls.';\nreturn table(unmitigated, ['name', 'layer', 'doc']);\n```"},{id:"s-coverage",label:"Requirements Coverage",description:"Requirements with/without test cases",category:"script",code:"```memo-script\nconst reqs = query({ kind: 'Requirement' });\nconst covered = reqs.filter(r => r.verifiedBy?.length > 0);\nreturn count(covered, `covered of ${reqs.length} requirements`);\n```"},{id:"i-doc-header",label:"Document Control Header",description:"Standard doc control table",category:"include",code:"{{include:shared/snippets/document-control-header.md}}"},{id:"i-approval",label:"Approval Block",description:"Reviewer/approver signature table",category:"include",code:"{{include:shared/snippets/approval-block.md}}"},{id:"i-revision",label:"Revision History",description:"Revision history table",category:"include",code:"{{include:shared/snippets/revision-history-table.md}}"},{id:"i-references",label:"References Section",description:"Normative references block",category:"include",code:"{{include:shared/snippets/references-section.md}}"},{id:"d-toc",label:"Table of Contents",description:"Auto-generated TOC (on export)",category:"directive",code:"{{toc}}"},{id:"d-glossary",label:"Glossary",description:"Auto-generated glossary (on export)",category:"directive",code:"{{glossary}}"}],Z={query:"#2563eb",script:"#7c3aed",include:"#0891b2",directive:"#6B7280"},ee={query:"Query",script:"Script",include:"Snippet",directive:"Directive"};function $e(){const t=$(i=>i.model),r=$(i=>i.activeView),n=$(i=>i.dhfDocuments),o=$(i=>i.updateDhfDocumentContent),s=$(i=>i.updateDhfDocumentMeta),a=$(i=>i.llmAvailable),u=$(i=>i.registerLlmRequest),l=$(i=>i.dhfSettings),[d,x]=f.useState("split"),p=f.useRef(null),[j,c]=f.useState(!1),[k,y]=f.useState(null),[b,w]=f.useState(!1),[g,B]=f.useState(!1),[F,M]=f.useState(!1),[z,h]=f.useState("all"),C=f.useCallback(async(i,A)=>{c(!0),y(null);const W=`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`,_=A.split("/").pop()??A;try{const E=await new Promise((O,I)=>{u(W,O,I),te(W,_),setTimeout(()=>I(new Error("Request timed out after 120 seconds.")),12e4)});o(i,E.markdown)}catch(E){y((E==null?void 0:E.message)??"Unknown error")}finally{c(!1)}},[u,o]),R=f.useCallback(i=>{if(!p.current)return;const A=p.current,W=A.selectionStart,_=A.selectionEnd,E=`
64
+
65
+ ${i.code}
66
+
67
+ `,O=A.value.slice(0,W)+E+A.value.slice(_),I=r.type==="dhf-document"?r.docId:null;I&&o(I,O),requestAnimationFrame(()=>{A.focus();const N=W+E.length;A.setSelectionRange(N,N)})},[r,o]),q=r.type==="dhf-document"?r.docId:null,v=q?n.find(i=>i.id===q):null,T=f.useMemo(()=>{const i=[];return l.company||i.push("company"),l.product||i.push("product"),i},[l]);if(!v)return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",background:"#F7F7F5",color:"#9CA3AF",gap:"12px"},children:[e.jsx(oe,{size:190}),e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:"#6B7280",marginBottom:"6px"},children:"No document selected"}),e.jsxs("div",{style:{fontSize:"12px",color:"#9CA3AF",maxWidth:"280px",lineHeight:"1.6"},children:["Use ",e.jsx("strong",{children:"+ New Document"})," in the explorer to create one, then click it to open."]})]}),e.jsxs("button",{onClick:()=>w(!0),style:{marginTop:"8px",padding:"7px 16px",borderRadius:"6px",border:"1px solid #E5E7EB",background:"#fff",fontSize:"12px",color:"#6B7280",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(J,{size:13})," DHF Settings"]})]}),b&&e.jsx(f.Suspense,{fallback:null,children:e.jsx(Y,{onClose:()=>w(!1)})})]});const S=z==="all"?K:K.filter(i=>i.category===z);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"#fff",overflow:"hidden"},children:[e.jsxs("div",{style:{height:"40px",display:"flex",alignItems:"center",gap:"6px",padding:"0 12px",borderBottom:"1px solid #e5e7eb",background:"#fff",flexShrink:0},children:[e.jsxs("div",{style:{flex:1,display:"flex",alignItems:"baseline",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"12px",fontWeight:700,color:"#6B7280",fontFamily:"monospace"},children:v.id}),e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"#1B3A4B"},children:v.title})]}),e.jsxs("button",{onClick:()=>M(i=>!i),title:"Document properties (authors, approvers)",style:{padding:"3px 10px",borderRadius:"6px",border:"1px solid",borderColor:F?"#6366F1":"#E5E7EB",background:F?"#EEF2FF":"#fff",color:F?"#4338CA":"#6B7280",fontSize:"11px",fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"12",cy:"7",r:"4"})]}),"Authors"]}),e.jsxs("button",{onClick:()=>B(i=>!i),title:"Scriptlets & snippets library",style:{padding:"3px 10px",borderRadius:"6px",border:"1px solid",borderColor:g?"#2DD4A8":"#E5E7EB",background:g?"#F0FDF9":"#fff",color:g?"#065F46":"#6B7280",fontSize:"11px",fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("polyline",{points:"16 18 22 12 16 6"}),e.jsx("polyline",{points:"8 6 2 12 8 18"})]}),"Snippets"]}),e.jsxs("button",{onClick:()=>C(v.id,v.templateId),disabled:!a||j,title:a?"Use AI to draft empty sections from model data":"Set ANTHROPIC_API_KEY or OPENAI_API_KEY to enable AI drafting",style:{padding:"3px 10px",borderRadius:"6px",border:"none",background:a?"#2DD4A815":"#f3f4f6",color:a?"#065F46":"#9CA3AF",fontSize:"11px",fontWeight:600,cursor:a&&!j?"pointer":"not-allowed",display:"flex",alignItems:"center",gap:"4px",opacity:j?.6:1},children:[e.jsx("span",{children:"✦"}),j?"Drafting…":"Draft with AI"]}),e.jsx(ye,{doc:v,model:t,settings:l}),e.jsx("div",{style:{display:"flex",gap:"2px",background:"#f3f4f6",borderRadius:"6px",padding:"2px"},children:["edit","split","preview"].map(i=>e.jsx("button",{onClick:()=>x(i),style:{padding:"3px 10px",borderRadius:"4px",border:"none",fontSize:"11px",fontWeight:500,cursor:"pointer",background:d===i?"#fff":"transparent",color:d===i?"#1B3A4B":"#6B7280",boxShadow:d===i?"0 1px 2px rgba(0,0,0,0.08)":"none"},children:i.charAt(0).toUpperCase()+i.slice(1)},i))}),e.jsx("button",{onClick:()=>w(!0),title:"DHF global settings",style:{padding:"4px",borderRadius:"6px",border:"1px solid #E5E7EB",background:"#fff",cursor:"pointer",color:"#6B7280",display:"flex",alignItems:"center"},children:e.jsx(J,{size:14})})]}),k&&e.jsxs("div",{style:{padding:"6px 16px",background:"#fef2f2",borderBottom:"1px solid #fecaca",fontSize:"12px",color:"#dc2626",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},children:[e.jsxs("span",{children:["AI draft failed: ",k]}),e.jsx("button",{onClick:()=>y(null),style:{background:"none",border:"none",color:"#dc2626",cursor:"pointer",fontSize:"14px"},children:"✕"})]}),T.length>0&&e.jsxs("div",{style:{padding:"5px 16px",background:"#FFFBEB",borderBottom:"1px solid #FDE68A",fontSize:"11px",color:"#92400E",display:"flex",alignItems:"center",gap:"8px",flexShrink:0},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsxs("span",{children:["Project settings incomplete — ",e.jsx("strong",{children:T.join(", ")})," not set. ",e.jsx("code",{style:{background:"#FEF3C7",padding:"0 3px",borderRadius:"2px"},children:"{{project.*}}"})," will show as errors in preview."]}),e.jsx("button",{onClick:()=>w(!0),style:{background:"none",border:"none",color:"#92400E",cursor:"pointer",fontWeight:700,fontSize:"11px",padding:0,textDecoration:"underline"},children:"Configure"})]}),F&&e.jsx(be,{doc:v,onUpdate:i=>s(v.id,i)}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[(d==="edit"||d==="split")&&e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",borderRight:d==="split"?"1px solid #e5e7eb":"none"},children:e.jsx("textarea",{ref:p,value:v.content,onChange:i=>o(v.id,i.target.value),spellCheck:!1,style:{flex:1,padding:"20px",fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace",fontSize:"13px",lineHeight:"1.7",border:"none",outline:"none",resize:"none",background:"#fafafa",color:"#1B3A4B",tabSize:2},placeholder:"Start writing your DHF document here..."})}),(d==="preview"||d==="split")&&e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"20px 32px",background:"#fff"},children:e.jsx(je,{content:v.content,model:t,settings:l,doc:v})}),g&&e.jsxs("div",{style:{width:"260px",borderLeft:"1px solid #E5E7EB",display:"flex",flexDirection:"column",background:"#FAFAFA",flexShrink:0,overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"10px 12px",borderBottom:"1px solid #E5E7EB",flexShrink:0},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:700,color:"#1B3A4B",marginBottom:"8px"},children:"Scriptlets & Snippets"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:["all","query","script","include","directive"].map(i=>e.jsx("button",{onClick:()=>h(i),style:{padding:"2px 8px",borderRadius:"10px",border:"none",fontSize:"10px",fontWeight:600,cursor:"pointer",background:z===i?i==="all"?"#1B3A4B":Z[i]:"#E5E7EB",color:z===i?"#fff":"#6B7280"},children:i==="all"?"All":ee[i]},i))})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"8px"},children:[S.map(i=>e.jsx(ve,{snippet:i,onInsert:()=>R(i)},i.id)),e.jsxs("div",{style:{fontSize:"11px",color:"#9CA3AF",padding:"8px 4px",lineHeight:"1.5"},children:["Custom scriptlets can be added to ",e.jsx("code",{style:{background:"#E5E7EB",padding:"1px 3px",borderRadius:"2px"},children:"shared/snippets/"}),"."]})]})]})]})]}),b&&e.jsx(f.Suspense,{fallback:null,children:e.jsx(Y,{onClose:()=>w(!1)})})]})}function ye({doc:t,model:r,settings:n}){const[o,s]=f.useState(!1),a=[{label:"Word (.doc)",hint:"Opens in Word / Pages",run:()=>xe(t,r,n)},{label:"PDF",hint:"Via the print dialog",run:()=>ge(t,r,n)},{label:"HTML",hint:"Standalone web page",run:()=>he(t,r,n)},{label:"Markdown",hint:"Raw document source",run:()=>fe(t)}];return e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{onClick:()=>s(u=>!u),title:"Export this document",style:{padding:"3px 10px",borderRadius:"6px",border:"1px solid",borderColor:o?"#1B3A4B":"#E5E7EB",background:o?"#F1F5F9":"#fff",color:"#1B3A4B",fontSize:"11px",fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Export"]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"fixed",inset:0,zIndex:9997},onClick:()=>s(!1)}),e.jsx("div",{style:{position:"absolute",top:"28px",right:0,zIndex:9998,background:"#fff",borderRadius:"8px",border:"1px solid #E5E7EB",boxShadow:"0 8px 24px rgba(0,0,0,0.12)",padding:"4px 0",minWidth:"200px"},children:a.map(u=>e.jsxs("button",{onClick:()=>{s(!1),u.run()},style:{display:"flex",flexDirection:"column",width:"100%",padding:"7px 14px",background:"none",border:"none",textAlign:"left",cursor:"pointer"},onMouseEnter:l=>l.currentTarget.style.background="#F3F4F6",onMouseLeave:l=>l.currentTarget.style.background="none",children:[e.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:"#1B3A4B"},children:u.label}),e.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF"},children:u.hint})]},u.label))})]})]})}function be({doc:t,onUpdate:r}){return e.jsxs("div",{style:{borderBottom:"1px solid #E5E7EB",background:"#F9FAFB",padding:"10px 16px",display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",flexShrink:0},children:[e.jsxs("div",{children:[e.jsxs("label",{style:{fontSize:"10px",fontWeight:700,color:"#6B7280",textTransform:"uppercase",letterSpacing:"0.05em",display:"block",marginBottom:"4px"},children:["Authors ",e.jsx("span",{style:{color:"#9CA3AF",textTransform:"none",fontWeight:400},children:"(Name | Role, one per line)"})]}),e.jsx("textarea",{value:t.authors,onChange:n=>r({authors:n.target.value}),placeholder:`Jane Smith | Lead Engineer
68
+ Bob Jones | Quality Assurance`,rows:3,style:{width:"100%",padding:"6px 8px",border:"1px solid #D1D5DB",borderRadius:"5px",fontSize:"12px",color:"#1B3A4B",resize:"none",fontFamily:"inherit",background:"#fff",outline:"none",boxSizing:"border-box",lineHeight:"1.5"}})]}),e.jsxs("div",{children:[e.jsxs("label",{style:{fontSize:"10px",fontWeight:700,color:"#6B7280",textTransform:"uppercase",letterSpacing:"0.05em",display:"block",marginBottom:"4px"},children:["Approvers ",e.jsx("span",{style:{color:"#9CA3AF",textTransform:"none",fontWeight:400},children:"(Name | Role, one per line)"})]}),e.jsx("textarea",{value:t.approvers,onChange:n=>r({approvers:n.target.value}),placeholder:`Alice Brown | Regulatory Affairs
69
+ Dr. Carol White | Clinical Safety`,rows:3,style:{width:"100%",padding:"6px 8px",border:"1px solid #D1D5DB",borderRadius:"5px",fontSize:"12px",color:"#1B3A4B",resize:"none",fontFamily:"inherit",background:"#fff",outline:"none",boxSizing:"border-box",lineHeight:"1.5"}})]}),e.jsxs("div",{style:{gridColumn:"1 / -1",fontSize:"11px",color:"#9CA3AF",marginTop:"-4px"},children:["These populate ",e.jsx("code",{style:{background:"#E5E7EB",padding:"0 3px",borderRadius:"2px"},children:"{{include:shared/snippets/approval-block.md}}"})," in the preview and exported document."]})]})}function ve({snippet:t,onInsert:r}){const[n,o]=f.useState(!1),s=Z[t.category];return e.jsxs("div",{onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{padding:"8px 10px",borderRadius:"6px",marginBottom:"4px",border:`1px solid ${n?s+"60":"#E5E7EB"}`,background:n?s+"08":"#fff",cursor:"default"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"2px"},children:[e.jsx("span",{style:{fontSize:"9px",fontWeight:700,padding:"1px 5px",borderRadius:"3px",background:s+"18",color:s},children:ee[t.category]}),e.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:"#1B3A4B",flex:1},children:t.label})]}),e.jsx("div",{style:{fontSize:"11px",color:"#6B7280",marginBottom:"6px",lineHeight:"1.4"},children:t.description}),e.jsx("button",{onClick:r,style:{padding:"3px 10px",borderRadius:"4px",border:"none",background:s,color:"#fff",fontSize:"10px",fontWeight:600,cursor:"pointer",opacity:n?1:.7},children:"Insert"})]})}function J({size:t}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function je({content:t,model:r,settings:n,doc:o}){const s=f.useMemo(()=>Q(t,r,n,o),[t,r,n,o]),a=f.useMemo(()=>X(n),[n]),u=f.useMemo(()=>s.split(new RegExp(re,"g")),[s]);return e.jsxs("div",{className:"memo-doc",children:[e.jsx("style",{children:a}),u.map((l,d)=>d%2===0?e.jsx("div",{dangerouslySetInnerHTML:{__html:l}},d):e.jsx(ke,{diagramRef:l,model:r},d))]})}function ke({diagramRef:t,model:r}){var x;const n=$(p=>p.setActiveView),o=$(p=>p.selectDiagram),s=p=>p.toLowerCase().replace(/[^a-z0-9]/g,"").replace(/view$/,""),a=s(t),u=(r==null?void 0:r.diagrams)??[],l=u.find(p=>p.id===t)??u.find(p=>s(p.id)===a||s(p.name)===a)??u.find(p=>a.length>=6&&(s(p.name).includes(a)||s(p.id).includes(a)));if(!l)return e.jsxs("div",{style:{margin:"10px 0",padding:"10px 14px",borderRadius:"6px",border:"1px dashed #FCA5A5",background:"#FEF2F2",fontSize:"12px",color:"#DC2626"},children:["⚠ Diagram ",e.jsx("code",{style:{background:"#FEE2E2",padding:"0 4px",borderRadius:"3px"},children:t})," not found in the model — check the id in ",e.jsx("code",{style:{background:"#FEE2E2",padding:"0 4px",borderRadius:"3px"},children:"{{diagram:…}}"}),"."]});const d=()=>{o(l.id),n({type:"diagram",diagramId:l.id})};return e.jsx("div",{style:{margin:"10px 0",borderRadius:"8px",border:"1px solid #E2E8F0",background:"#F8FAFC",overflow:"hidden"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px"},children:[e.jsxs("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",stroke:"#2DD4A8",strokeWidth:"1.8",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"5",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"5",rx:"1"}),e.jsx("rect",{x:"8.5",y:"16",width:"7",height:"5",rx:"1"}),e.jsx("path",{d:"M6.5 8v4h11V8M12 12v4"})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"#1B3A4B"},children:l.name}),e.jsxs("div",{style:{fontSize:"11px",color:"#6B7280"},children:[l.viewKind||l.diagramType,(x=l.elementIds)!=null&&x.length?` · ${l.elementIds.length} elements`:""]})]}),e.jsx("button",{onClick:d,style:{padding:"5px 12px",borderRadius:"6px",border:"none",background:"#1B3A4B",color:"#fff",fontSize:"11px",fontWeight:600,cursor:"pointer"},children:"Open diagram →"})]})})}export{$e as DhfWorkbench};