@memoarchitect/architect 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -0
- package/README.md +105 -0
- package/dist/assets/AskPanel-BpFRMop9.js +1 -0
- package/dist/assets/ComplianceWizard-DCcV-q6X.js +1 -0
- package/dist/assets/DSMView-OMMwi76e.js +1 -0
- package/dist/assets/Dashboard-Dl5KU656.js +1 -0
- package/dist/assets/DhfDashboard-agI5JdAZ.js +1 -0
- package/dist/assets/DhfSettingsPanel-CKvGmNGe.js +1 -0
- package/dist/assets/DhfWorkbench-BD_buvXh.js +69 -0
- package/dist/assets/DiagramCanvas-CUYbaLjV.js +1 -0
- package/dist/assets/DiagramEditor-DZAocSs_.js +4 -0
- package/dist/assets/DiagramSurface-BIK9fV8R.js +2 -0
- package/dist/assets/ElementDetailView-R_Nob9E0.js +2 -0
- package/dist/assets/ImportView-yxS8JfX4.js +1 -0
- package/dist/assets/LayerGrid-DdEtHyAu.js +1 -0
- package/dist/assets/LayerTable-dOCvwCEb.js +2 -0
- package/dist/assets/MaxGraphCanvas-CDdlW8h_.js +13 -0
- package/dist/assets/ModelDiff-BbdzLhXe.js +1 -0
- package/dist/assets/OntologyDecompositionDiagram-BW07CXuV.js +1 -0
- package/dist/assets/OntologyViewer-DaRXEQoq.js +2 -0
- package/dist/assets/RelationshipOverlay-BDrBRSPP.js +33 -0
- package/dist/assets/RelationshipsSection-D1-tuVYo.js +1 -0
- package/dist/assets/ReviewDashboard-CipgA5-r.js +1 -0
- package/dist/assets/ScenarioEditor-BfewgrrJ.js +3 -0
- package/dist/assets/StatisticsDashboard-CLww46qL.js +1 -0
- package/dist/assets/SysmlCodeEditor-BLcw6hdp.js +850 -0
- package/dist/assets/SysmlCodeEditor-BwKcXIZw.css +1 -0
- package/dist/assets/SysmlGenerator-DnsaN-ey.js +1 -0
- package/dist/assets/TabularView-Bp-yKFPV.js +1 -0
- package/dist/assets/TraceabilityMatrix-B-dn_i5a.js +1 -0
- package/dist/assets/WorkflowWizard-C6p5e2IT.js +1 -0
- package/dist/assets/editor.worker-DyuDvpVp.js +26 -0
- package/dist/assets/elk-B75IRfCd.js +1 -0
- package/dist/assets/elk-worker.min-BgEwn2y-.js +24 -0
- package/dist/assets/index-BZhRuk7M.css +1 -0
- package/dist/assets/index-c27kHB43.js +3277 -0
- package/dist/assets/layout-providers-BAUgp0nu.js +26 -0
- package/dist/assets/layout-selection-DvOsyJH9.js +1 -0
- package/dist/assets/react-vendor-l0sNRNKZ.js +1 -0
- package/dist/assets/reactflow-WKyu73tD.js +54 -0
- package/dist/assets/style-BZV40eAE.css +1 -0
- package/dist/assets/sysml-edge-styles-ByJeCWqa.js +1 -0
- package/dist/assets/zustand-qbFpP9Up.js +9 -0
- package/dist/favicon.svg +6 -0
- package/dist/index.html +19 -0
- package/dist/logo.png +0 -0
- package/dist/memo-top.png +0 -0
- package/lib/bin/memo-architect.d.ts +3 -0
- package/lib/bin/memo-architect.d.ts.map +1 -0
- package/lib/bin/memo-architect.js +27 -0
- package/lib/bin/memo-architect.js.map +1 -0
- package/lib/commands/build.d.ts +5 -0
- package/lib/commands/build.d.ts.map +1 -0
- package/lib/commands/build.js +45 -0
- package/lib/commands/build.js.map +1 -0
- package/lib/commands/dev.d.ts +5 -0
- package/lib/commands/dev.d.ts.map +1 -0
- package/lib/commands/dev.js +20 -0
- package/lib/commands/dev.js.map +1 -0
- package/package.json +77 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 memoarchitect
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE.
|
package/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<strong>meMO Architect</strong><br>
|
|
3
|
+
<em>Visual workbench for the Medical Engineering Modelling Ontology</em>
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
<p align="center">
|
|
7
|
+
An optional visual workbench over the same model the <code>memo</code> CLI reads.
|
|
8
|
+
SysML source remains the single source of truth and stays usable without the UI.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<code>memo-architect 0.4.4</code> · MIT · SysML v2 ·
|
|
13
|
+
ISO 14971 · IEC 62304 · ISO/IEC/IEEE 42010
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
> **Status: work in progress.** APIs, views, and model semantics may change
|
|
19
|
+
> before the first stable release.
|
|
20
|
+
|
|
21
|
+
## Adopt only what you need
|
|
22
|
+
|
|
23
|
+
| Layer | Capability | Repository |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| 01–02 | Portable ontology and methodology for any SysML v2 editor | [memo](https://github.com/memoarchitect/memo) |
|
|
26
|
+
| 03 | Reusable engine libraries and the `memo` CLI | [memo-tools](https://github.com/memoarchitect/memo-tools) |
|
|
27
|
+
| 04 | Complete visual workbench | **memo-architect** (this repository) |
|
|
28
|
+
|
|
29
|
+
All three products share a `MAJOR.MINOR` compatibility line. Any `0.4.x`
|
|
30
|
+
release is intended to work with the other `0.4.x` products; patch versions
|
|
31
|
+
may advance independently for fixes and additive changes.
|
|
32
|
+
|
|
33
|
+
Architect reuses the parser, semantic model, validation, document, and project
|
|
34
|
+
operations from Memo Tools. The React application provides presentation and user
|
|
35
|
+
interaction; it does not maintain a second engineering model.
|
|
36
|
+
|
|
37
|
+
## Capabilities
|
|
38
|
+
|
|
39
|
+
- Explore architecture layers, catalog elements, and typed relationships.
|
|
40
|
+
- Review requirements, risk, software, verification, and assurance traceability.
|
|
41
|
+
- Render BDD, IBD, action-flow, sequence, state, tree, DSM, and tabular views.
|
|
42
|
+
- Author and export Design History File documents from the versioned model.
|
|
43
|
+
- Run the same validation and export operations through the CLI or the workbench.
|
|
44
|
+
|
|
45
|
+
## Repository layout
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
package.json @memoarchitect/architect — the sole package in this repo
|
|
49
|
+
packages/web/ internal React workbench source
|
|
50
|
+
src/ Architect CLI and composition commands
|
|
51
|
+
memo-tools/ submodule → @memoarchitect/tools
|
|
52
|
+
memo/ nested submodule → @memoarchitect/ontology
|
|
53
|
+
docs/ public user, developer, architecture, and design docs
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Development quick start
|
|
57
|
+
|
|
58
|
+
Requires Node.js 24 LTS and pnpm 9 or later.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
git clone --recurse-submodules https://github.com/memoarchitect/memo-architect.git
|
|
62
|
+
cd memo-architect
|
|
63
|
+
corepack enable
|
|
64
|
+
pnpm install
|
|
65
|
+
pnpm run build
|
|
66
|
+
pnpm run test
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Run the bundled GPCA reference model:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pnpm run example:dev
|
|
73
|
+
# http://localhost:3000
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Run headless Tools commands:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pnpm memo -- validate
|
|
80
|
+
pnpm memo -- export json
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Run Architect commands:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pnpm architect -- dev
|
|
87
|
+
pnpm architect -- build --output dist
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Documentation
|
|
91
|
+
|
|
92
|
+
- [Start here](docs/src/index.md)
|
|
93
|
+
- [Layers and their questions](docs/src/users/layers.md)
|
|
94
|
+
- [Choosing elements](docs/src/users/elements.md)
|
|
95
|
+
- [Connecting elements](docs/src/users/relationships.md)
|
|
96
|
+
- [Worked GPCA example](docs/src/users/gpca-example.md)
|
|
97
|
+
- [Documentation source index](docs/README.md)
|
|
98
|
+
- [Platform architecture](docs/architecture/platform.md)
|
|
99
|
+
- [SysML v2 authoring rules](docs/design/sysmlv2-rulebook.md)
|
|
100
|
+
- [Architecture decisions](docs/decisions/index.md)
|
|
101
|
+
- [Contributing](CONTRIBUTING.md)
|
|
102
|
+
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
MIT © 2026 memoarchitect
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as t}from"./reactflow-WKyu73tD.js";import{a as i}from"./zustand-qbFpP9Up.js";import{u as d,j as k}from"./index-c27kHB43.js";const S=["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."];function I(){const o=d(e=>e.llmAvailable),b=d(e=>e.llmProvider),E=d(e=>e.llmModel),v=d(e=>e.model),f=d(e=>e.registerLlmRequest),[p,c]=i.useState([]),[l,u]=i.useState(""),[s,h]=i.useState(!1),g=i.useRef(null),j=i.useRef(null);i.useEffect(()=>{var e;(e=g.current)==null||e.scrollIntoView({behavior:"smooth"})},[p]);const x=i.useCallback(async e=>{if(!e.trim()||s)return;const r=e.trim();u(""),c(n=>[...n,{role:"user",content:r}]),h(!0);const y=`ask-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{const n=await new Promise((a,m)=>{f(y,a,m),k(y,r),setTimeout(()=>m(new Error("Request timed out after 60 seconds.")),6e4)});c(a=>[...a,{role:"assistant",content:n}])}catch(n){c(a=>[...a,{role:"assistant",content:(n==null?void 0:n.message)??"Unknown error",error:!0}])}finally{h(!1)}},[s,f]),A=e=>{e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),x(l))};return v?t.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"#F7F7F5",overflow:"hidden"},children:[t.jsx("div",{style:{padding:"14px 20px 10px",borderBottom:"1px solid #E5E5E0",background:"#fff",flexShrink:0},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[t.jsx("span",{style:{fontSize:"16px"},children:"✦"}),t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"14px",fontWeight:700,color:"#1B3A4B"},children:"Model Q&A"}),t.jsx("div",{style:{fontSize:"11px",color:o?"#059669":"#dc2626",marginTop:"1px"},children:o?`${b??"LLM"} · ${E??"unknown model"}`:"No LLM provider — set ANTHROPIC_API_KEY or OPENAI_API_KEY"})]})]})}),t.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px",display:"flex",flexDirection:"column",gap:"12px"},children:[p.length===0&&t.jsxs("div",{style:{paddingTop:"8px"},children:[t.jsx("div",{style:{fontSize:"12px",color:"#9CA3AF",marginBottom:"12px"},children:"Ask questions about your model in plain English."}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:S.map(e=>t.jsx("button",{onClick:()=>x(e),disabled:!o||s,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:o?1:.5},onMouseEnter:r=>{o&&(r.currentTarget.style.borderColor="#2DD4A8")},onMouseLeave:r=>{r.currentTarget.style.borderColor="#E5E5E0"},children:e},e))})]}),p.map((e,r)=>t.jsxs("div",{style:{display:"flex",flexDirection:e.role==="user"?"row-reverse":"row",gap:"8px",alignItems:"flex-start"},children:[t.jsx("div",{style:{width:"24px",height:"24px",borderRadius:"50%",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:e.role==="user"?"#1B3A4B":"#2DD4A815",fontSize:"10px",fontWeight:700,color:e.role==="user"?"#fff":"#2DD4A8",marginTop:"2px"},children:e.role==="user"?"U":"✦"}),t.jsx("div",{style:{maxWidth:"85%",padding:"10px 12px",borderRadius:"10px",background:e.role==="user"?"#1B3A4B":e.error?"#fef2f2":"#fff",color:e.role==="user"?"#fff":e.error?"#dc2626":"#1B3A4B",fontSize:"13px",lineHeight:"1.6",border:e.role==="assistant"?`1px solid ${e.error?"#fecaca":"#E5E5E0"}`:"none",whiteSpace:"pre-wrap"},children:e.content})]},r)),s&&t.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"flex-start"},children:[t.jsx("div",{style:{width:"24px",height:"24px",borderRadius:"50%",background:"#2DD4A815",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",color:"#2DD4A8",fontWeight:700},children:"✦"}),t.jsx("div",{style:{padding:"10px 14px",borderRadius:"10px",background:"#fff",border:"1px solid #E5E5E0",display:"flex",gap:"4px",alignItems:"center"},children:t.jsx(w,{})})]}),t.jsx("div",{ref:g})]}),t.jsxs("div",{style:{padding:"12px 16px",borderTop:"1px solid #E5E5E0",background:"#fff",flexShrink:0},children:[t.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"flex-end"},children:[t.jsx("textarea",{ref:j,value:l,onChange:e=>u(e.target.value),onKeyDown:A,disabled:!o||s,placeholder:o?"Ask a question… (Enter to send, Shift+Enter for newline)":"LLM not configured",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:o?1:.5},onFocus:e=>{e.target.style.borderColor="#2DD4A8"},onBlur:e=>{e.target.style.borderColor="#E5E5E0"}}),t.jsx("button",{onClick:()=>x(l),disabled:!o||s||!l.trim(),style:{padding:"8px 14px",borderRadius:"8px",border:"none",background:"#1B3A4B",color:"#fff",fontSize:"12px",fontWeight:600,cursor:"pointer",flexShrink:0,opacity:!o||!l.trim()?.4:1,transition:"opacity 0.15s"},children:"Send"})]}),p.length>0&&t.jsx("button",{onClick:()=>c([]),style:{marginTop:"6px",background:"none",border:"none",color:"#9CA3AF",fontSize:"11px",cursor:"pointer",padding:0},children:"Clear conversation"})]})]}):t.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#9CA3AF"},children:"Waiting for model data…"})}function w(){return t.jsxs("span",{style:{display:"inline-flex",gap:"3px",alignItems:"center"},children:[[0,1,2].map(o=>t.jsx("span",{style:{width:"5px",height:"5px",borderRadius:"50%",background:"#9CA3AF",animation:"llm-pulse 1.2s ease-in-out infinite",animationDelay:`${o*.2}s`}},o)),t.jsx("style",{children:"@keyframes llm-pulse{0%,80%,100%{opacity:0.3}40%{opacity:1}}"})]})}export{I as AskPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./reactflow-WKyu73tD.js";import{a as g}from"./zustand-qbFpP9Up.js";import{u as j,d as k}from"./index-c27kHB43.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","RiskControl"],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==="RiskControl");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==="RiskControl"):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 @@
|
|
|
1
|
+
import{j as s}from"./reactflow-WKyu73tD.js";import{a as b}from"./zustand-qbFpP9Up.js";import{u as C,d as _,R as v}from"./index-c27kHB43.js";const U=["Function","Function","ActionDefinition","ActionUsage"],H=["flow","decomposedBy","composedOf","allocateTo","succession"];function K(o,c){const m=new Set((c==null?void 0:c.kinds)??U),u=new Set((c==null?void 0:c.relationshipTypes)??H),p=(c==null?void 0:c.cluster)??!0,d=[];for(const e of Object.values(o.elements))m.has(e.kind)&&d.push(e);d.sort((e,h)=>{const g=e.kind.localeCompare(h.kind);return g!==0?g:e.name.localeCompare(h.name)});const a=d.map(e=>e.id),f=new Map;for(let e=0;e<a.length;e++)f.set(a[e],e);const r=a.length,y={};for(const e of d)y[e.id]={name:e.name,kind:e.kind,layer:e.layer,allocatedTo:e.allocatedTo};const l=Array.from({length:r},()=>Array.from({length:r},()=>null));let t=0;for(const e of o.relationships){if(!u.has(e.type))continue;const h=f.get(e.sourceId),g=f.get(e.targetId);if(h===void 0||g===void 0||h===g)continue;let F=l[h][g];F||(F={count:0,types:[],flowItems:[]},l[h][g]=F),F.count++,F.types.includes(e.type)||F.types.push(e.type),e.flowItem&&!F.flowItems.includes(e.flowItem)&&F.flowItems.push(e.flowItem),t++}const i=p?Y(a,l):new Map;return{elementIds:a,elements:y,matrix:l,clusters:i,totalDependencies:t}}function Y(o,c){const m=o.length,u=Array.from({length:m},(l,t)=>t),p=new Array(m).fill(0);function d(l){return u[l]!==l&&(u[l]=d(u[l])),u[l]}function a(l,t){const i=d(l),e=d(t);i!==e&&(p[i]<p[e]?u[i]=e:p[i]>p[e]?u[e]=i:(u[e]=i,p[i]++))}for(let l=0;l<m;l++)for(let t=0;t<m;t++)l!==t&&(c[l][t]||c[t][l])&&a(l,t);const f=new Map;for(let l=0;l<m;l++){const t=d(l);f.has(t)||f.set(t,[]),f.get(t).push(o[l])}const r=new Map;let y=0;for(const l of f.values())r.set(y++,l);return r}function P(o){const c=[],m=new Set;for(const[,a]of o.clusters)for(const f of a)m.has(f)||(c.push(f),m.add(f));for(const a of o.elementIds)m.has(a)||c.push(a);const u=c.length,p=new Map;for(let a=0;a<o.elementIds.length;a++)p.set(o.elementIds[a],a);const d=Array.from({length:u},()=>Array.from({length:u},()=>null));for(let a=0;a<u;a++)for(let f=0;f<u;f++)d[a][f]=o.matrix[p.get(c[a])][p.get(c[f])];return{...o,elementIds:c,matrix:d}}const R=new Set(["Function","Function","UserActivity"]),z=new Set(["System","Subsystem","Component","LogicalComponent","SoftwareComponent","SoftwareModule","Software"]);function V(o){var y,l;const c=[],m=[];for(const t of Object.values(o.elements))R.has(t.kind)&&c.push(t),z.has(t.kind)&&m.push(t);const u=[],p=new Set,d=new Map;for(const t of m)d.set(t.id,[]);for(const t of o.relationships){if(t.type!=="allocateTo")continue;const i=o.elements[t.sourceId],e=o.elements[t.targetId];!i||!e||R.has(i.kind)&&z.has(e.kind)&&(u.push({functionId:i.id,functionName:i.name,targetId:e.id,targetName:e.name}),p.add(i.id),d.has(e.id)||d.set(e.id,[]),d.get(e.id).push(i.id))}for(const t of c)if(t.allocatedTo&&!p.has(t.id)){const i=m.find(e=>e.name===t.allocatedTo||e.id===t.allocatedTo);i&&(u.push({functionId:t.id,functionName:t.name,targetId:i.id,targetName:i.name}),p.add(t.id),d.has(i.id)||d.set(i.id,[]),d.get(i.id).push(t.id))}const a=[];let f=0;for(const t of c)p.has(t.id)||a.push({id:`ci-${f++}`,type:"unallocated-function",severity:"warning",elementId:t.id,elementName:t.name,message:`Function "${t.name}" is not allocated to any component`});for(const t of m){const i=d.get(t.id);(!i||i.length===0)&&a.push({id:`ci-${f++}`,type:"no-functions-allocated",severity:"info",elementId:t.id,elementName:t.name,message:`Component "${t.name}" has no functions allocated to it`})}const r=new Map;for(const t of u)r.set(t.functionId,t.targetId);for(const t of o.relationships){if(t.type!=="flow")continue;const i=r.get(t.sourceId),e=r.get(t.targetId);if(i&&e&&i!==e){const h=o.elements[t.sourceId],g=o.elements[t.targetId];h&&g&&a.push({id:`ci-${f++}`,type:"cross-component-flow",severity:"info",elementId:t.sourceId,elementName:h.name,message:`Flow from "${h.name}" to "${g.name}" crosses component boundary (${(y=o.elements[i])==null?void 0:y.name} → ${(l=o.elements[e])==null?void 0:l.name})`,relatedIds:[t.targetId,i,e]})}}return{allocations:u,componentFunctions:d,issues:a,functions:c,structures:m}}function N(o){for(const c of o.types)if(v[c])return v[c];return"#6B7280"}function Z(o){const c=N(o),m=Math.min(.15+o.count*.15,.6);return`${c}${Math.round(m*255).toString(16).padStart(2,"0")}`}const E=36,D=160;function Q(){const o=C(n=>n.model),c=C(n=>n.selectElement),m=C(n=>n.selectedElementId),u=C(n=>n.setAnalysisIssues),[p,d]=b.useState(!0),[a,f]=b.useState(!1),[r,y]=b.useState(null),[l,t]=b.useState("functional"),i=b.useMemo(()=>{switch(l){case"functional":return["Function","Function"];case"behavior":return["ActionDefinition","ActionUsage"];case"all":return["Function","Function","ActionDefinition","ActionUsage"]}},[l]),e=b.useMemo(()=>{if(!o)return null;const n=K(o,{kinds:i});return p?P(n):n},[o,p,i]),h=b.useMemo(()=>o?V(o):null,[o]);b.useEffect(()=>{if(h)return u(h.issues.map(n=>({id:n.id,source:"DSM",severity:n.severity,elementId:n.elementId,elementName:n.elementName,message:n.message,tag:n.type==="unallocated-function"?"unallocated":n.type==="cross-component-flow"?"cross-boundary":"no functions"}))),()=>u([])},[h,u]);const g=b.useCallback((n,x)=>{y({row:n,col:x})},[]),F=b.useCallback(()=>{y(null)},[]);if(!o||!e)return s.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:"#9CA3AF"},children:s.jsx("p",{children:"No model loaded"})});if(e.elementIds.length===0)return s.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:s.jsxs("div",{className:"text-center",style:{maxWidth:"320px"},children:[s.jsx("div",{style:{fontSize:"40px",marginBottom:"16px",opacity:.4},children:"▤"}),s.jsx("h3",{style:{fontSize:"15px",fontWeight:600,color:"#374151",marginBottom:"8px"},children:"No Functional Elements"}),s.jsx("p",{style:{fontSize:"13px",color:"#9CA3AF",lineHeight:1.6},children:"Add Function or Function elements to your model to see the DSM."})]})});const B=e.elementIds.length,k=new Set;if(p&&e.clusters.size>1){let n=0;for(const[,x]of e.clusters)n+=x.length,n<B&&k.add(n)}const j=r?(()=>{const n=e.matrix[r.row][r.col],x=e.elements[e.elementIds[r.row]],w=e.elements[e.elementIds[r.col]];return{cell:n,rowEl:x,colEl:w}})():null;return s.jsxs("div",{className:"flex-1 flex flex-col",style:{background:"#F7F7F5"},children:[s.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",style:{borderBottom:"1px solid #E5E5E0",background:"#FFFFFF"},children:[s.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"#374151"},children:"Design Structure Matrix"}),s.jsxs("span",{style:{fontSize:"11px",color:"#9CA3AF"},children:[B," elements, ",e.totalDependencies," dependencies"]}),s.jsx("div",{className:"flex-1"}),s.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #E5E5E0"},children:["functional","behavior","all"].map(n=>s.jsx("button",{onClick:()=>t(n),className:"px-2 py-0.5 text-xs font-medium",style:{background:l===n?"#1B3A4B":"#FFFFFF",color:l===n?"#FFFFFF":"#6B7280"},children:n==="functional"?"Functions":n==="behavior"?"Behavior":"All"},n))}),s.jsxs("label",{className:"flex items-center gap-1.5 text-xs",style:{color:"#6B7280"},children:[s.jsx("input",{type:"checkbox",checked:p,onChange:n=>d(n.target.checked),style:{accentColor:"#2DD4A8"}}),"Cluster"]}),s.jsxs("label",{className:"flex items-center gap-1.5 text-xs",style:{color:"#6B7280"},children:[s.jsx("input",{type:"checkbox",checked:a,onChange:n=>f(n.target.checked),style:{accentColor:"#E67E22"}}),"Allocation"]})]}),s.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[s.jsxs("div",{style:{display:"inline-block",position:"relative"},children:[s.jsx("div",{style:{display:"flex",marginLeft:D,marginBottom:"4px"},children:e.elementIds.map((n,x)=>{const w=e.elements[n],A=(r==null?void 0:r.col)===x;return s.jsx("div",{style:{width:E,height:D-20,position:"relative",borderRight:k.has(x+1)?"2px solid #2DD4A8":void 0},children:s.jsx("div",{style:{position:"absolute",bottom:0,left:E/2,transformOrigin:"bottom left",transform:"rotate(-60deg)",whiteSpace:"nowrap",fontSize:"11px",fontWeight:A?600:400,color:A?"#1a1a1a":"#6B7280",cursor:"pointer"},onClick:()=>c(n),children:w.name})},n)})}),e.elementIds.map((n,x)=>{const w=e.elements[n],A=(r==null?void 0:r.row)===x,M=m===n,L=k.has(x);return s.jsxs("div",{style:{display:"flex",alignItems:"center",borderTop:L?"2px solid #2DD4A8":void 0},children:[s.jsxs("div",{style:{width:D,paddingRight:"8px",fontSize:"11px",fontWeight:A||M?600:400,color:A||M?"#1a1a1a":"#6B7280",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",textAlign:"right",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"6px",height:E},onClick:()=>c(n),title:`${w.name} (${w.kind})`,children:[a&&w.allocatedTo&&s.jsx("span",{style:{fontSize:"9px",padding:"1px 4px",borderRadius:"3px",background:"#E67E2220",color:"#E67E22",fontWeight:500},children:w.allocatedTo}),s.jsx("span",{style:{width:"3px",height:"14px",borderRadius:"2px",background:_[w.layer]||"#9CA3AF",flexShrink:0}}),w.name]}),e.elementIds.map(($,I)=>{const S=e.matrix[x][I],T=x===I,W=(r==null?void 0:r.row)===x&&(r==null?void 0:r.col)===I,O=(r==null?void 0:r.row)===x||(r==null?void 0:r.col)===I;return s.jsx("div",{onMouseEnter:()=>g(x,I),onMouseLeave:F,onClick:()=>{S&&c(n)},style:{width:E,height:E,border:"1px solid #E5E5E0",borderRight:k.has(I+1)?"2px solid #2DD4A8":"1px solid #E5E5E0",background:T?"#F3F4F6":S?Z(S):O?"#FAFAFA":"#FFFFFF",display:"flex",alignItems:"center",justifyContent:"center",cursor:S?"pointer":"default",transition:"background 100ms ease",outline:W&&S?`2px solid ${N(S)}`:void 0,outlineOffset:"-2px"},children:S&&!T&&s.jsx("span",{style:{fontSize:"10px",fontWeight:600,color:N(S)},children:S.count>1?S.count:"●"})},$)})]},n)})]}),(j==null?void 0:j.cell)&&s.jsxs("div",{style:{position:"fixed",bottom:"80px",right:"20px",background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",fontSize:"12px",zIndex:100,maxWidth:"280px"},children:[s.jsx("div",{style:{fontWeight:600,color:"#1a1a1a",marginBottom:"6px"},children:j.rowEl.name}),s.jsxs("div",{style:{color:"#6B7280",marginBottom:"4px"},children:["→"," ",j.colEl.name]}),s.jsx("div",{style:{display:"flex",gap:"4px",flexWrap:"wrap"},children:j.cell.types.map(n=>s.jsx("span",{style:{fontSize:"10px",padding:"2px 6px",borderRadius:"4px",background:(v[n]||"#6B7280")+"20",color:v[n]||"#6B7280",fontWeight:500},children:n},n))}),j.cell.flowItems.length>0&&s.jsxs("div",{style:{marginTop:"4px",color:"#9CA3AF",fontSize:"11px"},children:["Items: ",j.cell.flowItems.join(", ")]})]}),s.jsxs("div",{style:{marginTop:"20px",display:"flex",gap:"16px",flexWrap:"wrap",fontSize:"11px",color:"#6B7280"},children:[["flow","decomposedBy","composedOf","allocateTo","succession"].map(n=>s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[s.jsx("span",{style:{width:"10px",height:"10px",borderRadius:"2px",background:v[n]||"#6B7280"}}),n]},n)),p&&e.clusters.size>1&&s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[s.jsx("span",{style:{width:"10px",height:"2px",background:"#2DD4A8"}}),"cluster boundary"]})]})]})]})}export{Q as DSMView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./reactflow-WKyu73tD.js";import{a as f}from"./zustand-qbFpP9Up.js";import{u as g,d as m}from"./index-c27kHB43.js";function j(i,d,s){var u,l;const n=Object.values(i.elements),o={},t={};for(const r of n)o[r.layer]=(o[r.layer]||0)+1,t[r.kind.toLowerCase()]=(t[r.kind.toLowerCase()]||0)+1;const a={};for(const r of i.relationships)a[r.type.toLowerCase()]=(a[r.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((r,p)=>r+(o[p]||0),0),verificationCount:(o.verification||0)+(o.assurance||0),hazardCount:t.hazard||0,requirementCount:Object.entries(t).filter(([r])=>r.endsWith("requirement")).reduce((r,[,p])=>r+p,0),riskControlCount:t.riskcontrol||0,systemCount:(t.system||0)+(t.subsystem||0)+(t.softwaresystem||0)+(t.logicalcomponent||0)+(t.hardwareassembly||0)+(t.softwarecomponent||0)+(t.processingnode||0),testCount:(t.verificationcase||0)+(t.validationcase||0)+(t.testartifact||0)+(t.test||0),mitigatesCount:Object.entries(a).filter(([r])=>r.startsWith("mitigat")).reduce((r,[,p])=>r+p,0),verificationLinkCount:Object.entries(a).filter(([r])=>r.startsWith("verif")||r.startsWith("validate")||r==="testedbyusability").reduce((r,[,p])=>r+p,0),diagramCount:((u=i.diagrams)==null?void 0:u.length)??0,projectName:((l=i.metadata)==null?void 0:l.projectName)||i.projectName||i.name||"My Device Project"}}function k(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 h({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 t=s>0;return e.jsxs("button",{onClick:o,style:{background:t?`${n}12`:"#F9FAFB",border:`1px solid ${t?n+"30":"#E5E5E0"}`,borderRadius:"12px",padding:"16px",cursor:"pointer",textAlign:"left",transition:"all 0.15s"},onMouseEnter:a=>{a.currentTarget.style.background=t?`${n}20`:"#F3F4F6",a.currentTarget.style.transform="translateY(-1px)",a.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.08)"},onMouseLeave:a=>{a.currentTarget.style.background=t?`${n}12`:"#F9FAFB",a.currentTarget.style.transform="none",a.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:t?n:"#9CA3AF"},children:d}),e.jsxs("span",{style:{fontSize:"10px",fontWeight:600,padding:"2px 8px",borderRadius:"999px",background:t?n+"20":"#F3F4F6",color:t?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:t?n:"transparent",width:t?`${Math.min(100,s/10*100)}%`:"0",transition:"width 0.4s ease"}})}),e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"8px"},children:t?"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:t=>{t.currentTarget.style.background=o?"#244D63":"rgba(255,255,255,0.95)",t.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.1)"},onMouseLeave:t=>{t.currentTarget.style.background=o?"#1B3A4B":"rgba(255,255,255,0.7)",t.currentTarget.style.boxShadow="none"},children:[e.jsx("span",{children:i}),e.jsx("span",{children:d})]})}function S(){var b;const i=g(c=>c.model),d=g(c=>c.validation),s=g(c=>c.completeness),n=g(c=>c.setActiveView),o=g(c=>c.setExplorerTab),t=g(c=>c.toggleGapBar),a=((b=d==null?void 0:d.violations)==null?void 0:b.length)??0,u=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 c=s.layers.reduce((C,v)=>C+(v.completeness||0),0)/s.layers.length;return Math.round(c)},[s]),l=f.useMemo(()=>i?j(i,a,u):null,[i,a,u]),r=f.useMemo(()=>l?k(l):null,[l]);return!l||!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.jsx("h1",{style:{fontSize:"22px",fontWeight:800,color:"#1B3A4B",margin:"0 0 4px 0"},children:l.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(h,{label:"Elements",value:l.totalElements,color:"#1B3A4B"}),e.jsx(h,{label:"Relationships",value:l.totalRelationships,color:"#4A90D9"}),e.jsx(h,{label:"Completeness",value:`${u}%`,color:u>=70?"#2ECC71":u>=40?"#F39C12":"#E74C3C"}),e.jsx(h,{label:"Violations",value:a,color:a===0?"#2ECC71":"#E74C3C",subtitle:a===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:l.requirementsCount,color:m.requirements,onClick:()=>{o("model"),n({type:"welcome"})}}),e.jsx(y,{layer:"risk",label:"Risk",count:l.riskCount,color:m.risk,onClick:()=>{o("model"),n({type:"welcome"})}}),e.jsx(y,{layer:"logical",label:"Architecture",count:l.architectureCount,color:m.logical,onClick:()=>{o("views"),n({type:"welcome"})}}),e.jsx(y,{layer:"verification",label:"Verification",count:l.verificationCount,color:m.verification,onClick:()=>n({type:"traceability"})})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px",marginBottom:"24px"},children:[r&&e.jsxs("div",{style:{background:r.urgency==="high"?"rgba(231,76,60,0.06)":r.urgency==="medium"?"rgba(243,156,18,0.06)":"rgba(46,204,113,0.06)",border:`1px solid ${r.urgency==="high"?"#E74C3C30":r.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:r.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:700,color:"#1B3A4B",marginBottom:"6px"},children:r.title}),e.jsx("div",{style:{fontSize:"12px",color:"#4B6E80",lineHeight:"1.6"},children:r.description}),r.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:c=>c.currentTarget.style.background="#244D63",onMouseLeave:c=>c.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")}}),e.jsx(x,{icon:"📊",label:"View Diagrams",onClick:()=>o("views")}),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:()=>t()}),e.jsx(x,{icon:"📈",label:"Full Statistics",onClick:()=>n({type:"statistics"})})]})]})]}),l.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:[l.diagramCount," diagram",l.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 diagrams →"})]})})]})})}export{S as Dashboard};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./reactflow-WKyu73tD.js";import{a as m}from"./zustand-qbFpP9Up.js";import{u as b}from"./index-c27kHB43.js";const h=[{id:"rmp",title:"Risk Management Plan",standards:["ISO 14971:2019 §4.4"],layers:["risk"],relevantKinds:["Hazard","HazardousSituation","Harm","RiskControl","RiskAcceptabilityCriteria"],group:"risk"},{id:"har",title:"Hazard Analysis Report",standards:["ISO 14971:2019 §5","ISO 14971:2019 §6"],layers:["risk"],relevantKinds:["Hazard","HazardousSituation","Harm","RiskControl"],group:"risk"},{id:"fmea",title:"Failure Mode and Effects Analysis",standards:["IEC 60812:2018"],layers:["risk","functional","physical"],relevantKinds:["Hazard","RiskControl","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","SoftwareItem","SOUPComponent"],group:"design"},{id:"sds",title:"Software Design Specification",standards:["IEC 62304:2006 §5.4"],layers:["software"],relevantKinds:["SoftwareItem","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","StakeholderNeed","UseCase"],group:"design"},{id:"dop",title:"Design Output Plan",standards:["ISO 13485:2016 §7.3.4"],layers:["functional","physical","software"],relevantKinds:["DesignOutput","Component","SoftwareItem","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:["SoftwareItem","SoftwareUnit","SoftwareSystem","TestCase"],group:"compliance"},{id:"csr",title:"Clinical Safety Report",standards:["ISO 14971:2019 §10"],layers:["risk","verification"],relevantKinds:["Hazard","RiskControl","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"}],j={risk:"Risk Management",design:"Design & Architecture",verification:"Verification & Validation",compliance:"Compliance & Standards",all:"General"},v={risk:"#E74C3C",design:"#4A90D9",verification:"#2ECC71",compliance:"#8E44AD",all:"#6B7280"};function B(n,i,o){const l=Object.values(i.elements).filter(s=>n.relevantKinds.includes(s.kind)),c=((o==null?void 0:o.violations)||[]).filter(s=>n.relevantKinds.includes(s.elementKind)||n.layers.includes(s.layer)),a=c.filter(s=>s.severity==="error").length;return{elementCount:l.length,gapCount:a,status:l.length===0?"empty":a===0?"complete":"partial",violations:c}}function z(){const n=b(t=>t.model),i=b(t=>t.validation),o=b(t=>t.completeness),[l,c]=m.useState(null),[a,s]=m.useState(null),r=m.useMemo(()=>{if(!n)return new Map;const t=new Map;for(const d of h)t.set(d.id,B(d,n,i));return t},[n,i]),x=m.useMemo(()=>a?h.filter(t=>t.group===a||t.group==="all"):h,[a]),g=m.useMemo(()=>{const t=new Map;for(const d of x){const p=d.group;t.has(p)||t.set(p,[]),t.get(p).push(d)}return t},[x]),f=m.useMemo(()=>{let t=0,d=0,p=0;for(const y of r.values())y.status==="complete"?t++:y.status==="partial"?d++:p++;return{complete:t,partial:d,empty:p,total:h.length}},[r]);if(!n)return e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#9CA3AF"},children:"Waiting for model data..."});const C=l?h.find(t=>t.id===l):null,A=l?r.get(l):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:"Design History File Dashboard"}),e.jsxs("p",{style:{color:"#6B7280",fontSize:"13px",marginTop:"4px"},children:[f.total," documents | ",f.complete," complete | ",f.partial," partial | ",f.empty," empty",o&&` | Overall completeness: ${o.overall}%`]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:"12px",marginBottom:"24px"},children:[e.jsx(u,{label:"Complete",value:f.complete,color:"#059669"}),e.jsx(u,{label:"Partial",value:f.partial,color:"#d97706"}),e.jsx(u,{label:"Empty",value:f.empty,color:"#dc2626"}),e.jsx(u,{label:"Completeness",value:`${(o==null?void 0:o.overall)||0}%`,color:"#2563eb"})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"20px",flexWrap:"wrap"},children:[e.jsx(S,{label:"All",active:!a,onClick:()=>s(null)}),Object.entries(j).filter(([t])=>t!=="all").map(([t,d])=>e.jsx(S,{label:d,active:a===t,onClick:()=>s(a===t?null:t),color:v[t]},t))]}),l?e.jsx(w,{doc:C,status:A,model:n,validation:i,onBack:()=>c(null)}):Array.from(g.entries()).map(([t,d])=>e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:v[t]||"#374151",marginBottom:"12px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:v[t]||"#6B7280",display:"inline-block"}}),j[t]||t]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:"12px"},children:d.map(p=>{const y=r.get(p.id);return e.jsx(k,{doc:p,status:y,onClick:()=>c(p.id)},p.id)})})]},t))]})}function u({label:n,value:i,color:o}){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:o},children:i}),e.jsx("div",{style:{fontSize:"11px",color:"#6B7280",marginTop:"2px"},children:n})]})}function S({label:n,active:i,onClick:o,color:l}){return e.jsx("button",{onClick:o,style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:500,border:`1px solid ${i?l||"#2DD4A8":"#e5e7eb"}`,background:i?(l||"#2DD4A8")+"15":"#fff",color:i?l||"#1B3A4B":"#6B7280",cursor:"pointer"},children:n})}function k({doc:n,status:i,onClick:o}){const l=i.status==="complete"?"#059669":i.status==="partial"?"#d97706":"#dc2626",c=i.status==="complete"?"#ecfdf5":i.status==="partial"?"#fffbeb":"#fef2f2",a=i.status==="complete"?"Complete":i.status==="partial"?"Partial":"Empty";return e.jsxs("div",{onClick:o,style:{background:"#fff",border:"1px solid #e5e7eb",borderRadius:"8px",padding:"16px",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s"},onMouseEnter:s=>{s.currentTarget.style.borderColor="#2DD4A8",s.currentTarget.style.boxShadow="0 2px 8px rgba(0,0,0,0.06)"},onMouseLeave:s=>{s.currentTarget.style.borderColor="#e5e7eb",s.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:n.id.toUpperCase()}),e.jsx("span",{style:{fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",background:c,color:l},children:a})]}),e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:"#1B3A4B",marginBottom:"6px"},children:n.title}),e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginBottom:"8px"},children:n.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 w({doc:n,status:i,model:o,validation:l,onBack:c}){const a=Object.values(o.elements).filter(r=>n.relevantKinds.includes(r.kind)),s=new Map;for(const r of a)s.has(r.kind)||s.set(r.kind,[]),s.get(r.kind).push(r);return e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("button",{onClick:c,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:n.title}),e.jsxs("p",{style:{color:"#6B7280",fontSize:"12px",marginTop:"4px"},children:[n.id.toUpperCase()," | ",n.standards.join(", ")]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:"12px",marginBottom:"20px"},children:[e.jsx(u,{label:"Elements",value:i.elementCount,color:"#2563eb"}),e.jsx(u,{label:"Gaps",value:i.gapCount,color:i.gapCount>0?"#dc2626":"#059669"}),e.jsx(u,{label:"Status",value:i.status,color:i.status==="complete"?"#059669":i.status==="partial"?"#d97706":"#dc2626"})]}),Array.from(s.entries()).sort().map(([r,x])=>e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("h4",{style:{fontSize:"13px",fontWeight:600,color:"#374151",marginBottom:"8px"},children:[r," (",x.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:x.slice(0,50).map(g=>e.jsxs("tr",{style:{borderTop:"1px solid #e5e7eb"},children:[e.jsx("td",{style:{padding:"6px 10px",color:"#2563eb",fontWeight:500},children:g.name}),e.jsx("td",{style:{padding:"6px 10px",color:"#6B7280"},children:g.layer}),e.jsx("td",{style:{padding:"6px 10px",color:"#6B7280",maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:g.doc||"—"})]},g.id))})]}),x.length>50&&e.jsxs("div",{style:{padding:"8px 10px",fontSize:"11px",color:"#9CA3AF",background:"#f9fafb"},children:["...and ",x.length-50," more"]})]})]},r)),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((r,x)=>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:r.severity==="error"?"#fef2f2":"#fffbeb",color:r.severity==="error"?"#dc2626":"#d97706"},children:r.severity})}),e.jsx("td",{style:{padding:"6px 10px",color:"#6B7280",fontFamily:"monospace",fontSize:"11px"},children:r.ruleId}),e.jsx("td",{style:{padding:"6px 10px",color:"#2563eb"},children:r.elementName}),e.jsx("td",{style:{padding:"6px 10px",color:"#6B7280"},children:r.description})]},x))})]})})]}),a.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: ",n.relevantKinds.join(", ")]})]})]})}export{z as DhfDashboard};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./reactflow-WKyu73tD.js";import{a as d}from"./zustand-qbFpP9Up.js";import{u as p}from"./index-c27kHB43.js";const y=[{value:"",label:"— Select phase —"},{value:"concept",label:"Concept"},{value:"design",label:"Design & Development"},{value:"verification",label:"Verification & Validation"},{value:"production",label:"Production"}],i={width:"100%",padding:"7px 10px",border:"1px solid #D1D5DB",borderRadius:"6px",fontSize:"13px",color:"#1B3A4B",background:"#fff",boxSizing:"border-box",outline:"none",fontFamily:"inherit"},n={fontSize:"11px",fontWeight:600,color:"#6B7280",textTransform:"uppercase",letterSpacing:"0.04em",display:"block",marginBottom:"4px"},s={fontSize:"12px",fontWeight:700,color:"#1B3A4B",paddingBottom:"6px",borderBottom:"1px solid #E5E7EB",marginBottom:"12px",marginTop:"4px"},j={display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"};function C({onClose:a}){const c=p(o=>o.dhfSettings),x=p(o=>o.updateDhfSettings),[l,g]=d.useState({...c}),[r,h]=d.useState("identity");function t(o,m){g(f=>({...f,[o]:m}))}function u(){x(l),a()}return e.jsx("div",{style:{position:"fixed",inset:0,zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.45)"},onClick:o=>{o.target===o.currentTarget&&a()},children:e.jsxs("div",{style:{background:"#fff",borderRadius:"12px",width:"560px",maxHeight:"86vh",display:"flex",flexDirection:"column",boxShadow:"0 24px 60px rgba(0,0,0,0.22)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"16px 20px",borderBottom:"1px solid #E5E7EB",flexShrink:0},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#6B7280",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"})]}),e.jsx("span",{style:{fontSize:"15px",fontWeight:700,color:"#1B3A4B",flex:1},children:"DHF Global Settings"}),e.jsx("button",{onClick:a,style:{background:"none",border:"none",cursor:"pointer",color:"#9CA3AF",fontSize:"20px",lineHeight:1,padding:"0 2px"},children:"×"})]}),e.jsx("div",{style:{display:"flex",borderBottom:"1px solid #E5E7EB",flexShrink:0,padding:"0 20px"},children:["identity","branding","layout"].map(o=>e.jsx("button",{onClick:()=>h(o),style:{padding:"10px 14px",border:"none",background:"none",fontSize:"12px",fontWeight:600,cursor:"pointer",color:r===o?"#1B3A4B":"#9CA3AF",borderBottom:`2px solid ${r===o?"#2DD4A8":"transparent"}`,marginBottom:"-1px",textTransform:"capitalize"},children:o==="identity"?"Project":o==="branding"?"Branding":"Layout"},o))}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px"},children:[r==="identity"&&e.jsxs("div",{children:[e.jsx("p",{style:s,children:"Project Identity"}),e.jsxs("p",{style:{fontSize:"12px",color:"#6B7280",marginBottom:"16px",lineHeight:"1.5"},children:["These values resolve ",e.jsx("code",{style:{background:"#F3F4F6",padding:"1px 4px",borderRadius:"3px"},children:"{{project.*}}"})," directives in all templates and the AI drafting context."]}),e.jsxs("div",{style:j,children:[e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Company / Manufacturer"}),e.jsx("input",{style:i,value:l.company,onChange:o=>t("company",o.target.value),placeholder:"Acme Medical Devices Inc."})]}),e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Product / Device Name"}),e.jsx("input",{style:i,value:l.product,onChange:o=>t("product",o.target.value),placeholder:"InfuSafe IV Pump"})]}),e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Device Type"}),e.jsx("input",{style:i,value:l.deviceType,onChange:o=>t("deviceType",o.target.value),placeholder:"Class II active implantable"})]}),e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Document Version"}),e.jsx("input",{style:i,value:l.version,onChange:o=>t("version",o.target.value),placeholder:"1.0.0"})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("label",{style:n,children:"Development Phase"}),e.jsx("select",{style:i,value:l.phase,onChange:o=>t("phase",o.target.value),children:y.map(o=>e.jsx("option",{value:o.value,children:o.label},o.value))})]}),e.jsxs("div",{style:{gridColumn:"1 / -1"},children:[e.jsx("label",{style:n,children:"Document ID Prefix"}),e.jsx("input",{style:{...i,fontFamily:"monospace"},value:l.documentNumberingPrefix,onChange:o=>t("documentNumberingPrefix",o.target.value),placeholder:"DOC"}),e.jsxs("p",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"4px"},children:["Used in document IDs, e.g. ",e.jsxs("code",{children:[l.documentNumberingPrefix||"DOC","-RMP-001"]})]})]})]})]}),r==="branding"&&e.jsxs("div",{children:[e.jsx("p",{style:s,children:"Branding"}),e.jsx("p",{style:{fontSize:"12px",color:"#6B7280",marginBottom:"16px",lineHeight:"1.5"},children:"Branding applied to exported HTML and DOCX documents. Per-document overrides can be set in the document's frontmatter."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"14px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Full Logo URL"}),e.jsx("input",{style:i,value:l.logoUrl,onChange:o=>t("logoUrl",o.target.value),placeholder:"https://... or data:image/png;base64,..."}),e.jsx("p",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"4px"},children:"Shown in document cover pages and report headers."}),l.logoUrl&&e.jsx("img",{src:l.logoUrl,alt:"Logo preview",style:{maxHeight:"48px",maxWidth:"200px",marginTop:"8px",border:"1px solid #E5E7EB",borderRadius:"4px",padding:"4px"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Compact Logo URL"}),e.jsx("input",{style:i,value:l.compactLogoUrl,onChange:o=>t("compactLogoUrl",o.target.value),placeholder:"https://... or data:image/png;base64,..."}),e.jsx("p",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"4px"},children:"Shown in page headers (small). Falls back to Full Logo if empty."}),l.compactLogoUrl&&e.jsx("img",{src:l.compactLogoUrl,alt:"Compact logo preview",style:{maxHeight:"28px",maxWidth:"120px",marginTop:"8px",border:"1px solid #E5E7EB",borderRadius:"4px",padding:"4px"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Primary Color"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx("input",{type:"color",value:l.primaryColor,onChange:o=>t("primaryColor",o.target.value),style:{width:"40px",height:"32px",padding:"2px",border:"1px solid #D1D5DB",borderRadius:"6px",cursor:"pointer"}}),e.jsx("input",{style:{...i,flex:1,fontFamily:"monospace"},value:l.primaryColor,onChange:o=>t("primaryColor",o.target.value),placeholder:"#1B3A4B"})]}),e.jsx("p",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"4px"},children:"Used for headings, table headers, and badges in exported documents."})]})]})]}),r==="layout"&&e.jsxs("div",{children:[e.jsx("p",{style:s,children:"Document Layout"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[e.jsxs("div",{children:[e.jsxs("label",{style:{...n,display:"flex",alignItems:"center",gap:"8px",textTransform:"none",fontSize:"13px",fontWeight:600,color:"#1B3A4B",marginBottom:0},children:[e.jsx("input",{type:"checkbox",checked:l.compactMode,onChange:o=>t("compactMode",o.target.checked),style:{accentColor:"#2DD4A8"}}),"Compact mode"]}),e.jsx("p",{style:{fontSize:"12px",color:"#6B7280",marginTop:"4px",marginLeft:"20px"},children:"Tighter line spacing and smaller heading sizes. Useful for regulatory submissions."})]}),e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Page Header Template"}),e.jsx("input",{style:{...i,fontFamily:"monospace",fontSize:"12px"},value:l.headerTemplate,onChange:o=>t("headerTemplate",o.target.value)}),e.jsxs("p",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"4px"},children:["Tokens: ",e.jsx("code",{children:"{{id}}"}),", ",e.jsx("code",{children:"{{title}}"}),", ",e.jsx("code",{children:"{{project.product}}"}),", ",e.jsx("code",{children:"{{project.version}}"}),", ",e.jsx("code",{children:"{{date}}"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:n,children:"Page Footer Template"}),e.jsx("input",{style:{...i,fontFamily:"monospace",fontSize:"12px"},value:l.footerTemplate,onChange:o=>t("footerTemplate",o.target.value)}),e.jsxs("p",{style:{fontSize:"11px",color:"#9CA3AF",marginTop:"4px"},children:["Tokens: same as header, plus ",e.jsx("code",{children:"{{page}}"})," and ",e.jsx("code",{children:"{{pages}}"})]})]})]})]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px",padding:"14px 20px",borderTop:"1px solid #E5E7EB",flexShrink:0,background:"#FAFAFA"},children:[e.jsx("button",{onClick:a,style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid #D1D5DB",background:"#fff",fontSize:"13px",cursor:"pointer",color:"#374151"},children:"Cancel"}),e.jsx("button",{onClick:u,style:{padding:"8px 20px",borderRadius:"6px",border:"none",background:"#2DD4A8",fontSize:"13px",fontWeight:600,cursor:"pointer",color:"#065F46"},children:"Save Settings"})]})]})})}export{C as DhfSettingsPanel};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DhfSettingsPanel-CKvGmNGe.js","assets/reactflow-WKyu73tD.js","assets/zustand-qbFpP9Up.js","assets/index-c27kHB43.js","assets/index-BZhRuk7M.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as w,i as te,_ as oe}from"./index-c27kHB43.js";import{j as e}from"./reactflow-WKyu73tD.js";import{a as x}from"./zustand-qbFpP9Up.js";const ne=/<div class="memo-doc-diagram" data-diagram-id="([^"]*)"><\/div>/;function m(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function H(t,r){const n=t.split(`
|
|
3
|
+
`).map(o=>o.trim()).filter(Boolean);return n.length===0?`<tr><td colspan="4" style="color:#9CA3AF;font-style:italic">No ${r.toLowerCase()}s defined</td></tr>`:n.map(o=>{const[i="",d=""]=o.split("|").map(a=>a.trim());return`<tr><td>${m(i)}</td><td>${m(d||r)}</td><td style="color:#9CA3AF">—</td><td style="color:#9CA3AF">—</td></tr>`}).join("")}function re(t){const r=t.authors.trim().length>0,n=t.approvers.trim().length>0,o="<thead><tr><th>Name</th><th>Role</th><th>Signature</th><th>Date</th></tr></thead>";return`
|
|
4
|
+
<h2>Authors</h2>
|
|
5
|
+
<table>${o}<tbody>${H(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>${H(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 ie(t){const r=[],n=/^(#{2,4})\s+(.+)$/gm;let o;for(;(o=n.exec(t))!==null;){const i=(o[1].length-2)*18;r.push(`<div style="margin-left:${i}px">${m(o[2].trim())}</div>`)}return r.length===0?"":`<h2>Table of Contents</h2><div class="memo-doc-toc">${r.join("")}</div>`}function se(t,r,n,o,i){t=t.replace(/\{\{include:shared\/snippets\/approval-block\.md\}\}/g,()=>re(o)),t=t.replace(/\{\{include:([^}]+)\}\}/g,(a,l)=>`<span class="directive-placeholder">[Snippet: ${m(l)} — rendered on export]</span>`);const d={company:n.company,product:n.product,device_type:n.deviceType,version:n.version,phase:n.phase};return t=t.replace(/\{\{project\.([^}]+)\}\}/g,(a,l)=>{const p=d[l];return p&&p.trim()?m(p):`<span class="directive-error">⚠ {{project.${m(l)}}} — not set</span>`}),t=t.replace(/\{\{ref:([^.}]+)(?:\.(\w+))?\}\}/g,(a,l,p)=>{if(!r)return`<code>${m(l)}</code>`;const h=r.elements[l];return h?m(!p||p==="name"?h.name:String(h[p]??h.name)):`<em>[${m(l)} not found]</em>`}),t=t.replace(/\{\{diagram:([^}]+)\}\}/g,(a,l)=>i.diagrams==="note"?`<p><strong>[Diagram: ${m(l.trim())}]</strong> <em>— view in MEMO Architect</em></p>`:`<div class="memo-doc-diagram" data-diagram-id="${m(l.trim())}"></div>`),t=t.replace(/\{\{toc\}\}/g,()=>i.resolveToc?ie(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,a=>`<span class="directive-placeholder">${m(a)}</span>`),t=t.replace(/```memo-query\r?\n([\s\S]*?)```/g,(a,l)=>{const p=l.split(`
|
|
10
|
+
`).filter(Boolean),h=v=>(p.find(E=>E.startsWith(v))??"").replace(v,"").trim(),c=h("kind:")||"?",S=h("display:")||"table",u=h("empty:").replace(/^['"]|['"]$/g,"")||"No results found.",k=h("label:")||c;if(!r)return`<div class="query-preview">⟳ <em>memo-query: ${m(c)} (${m(S)})</em></div>`;const g=c.startsWith("[")||c.startsWith("-")?c.replace(/[\[\]]/g,"").split(/[,\n]/).map(v=>v.replace("-","").trim()).filter(Boolean):[c],f=Object.values(r.elements).filter(v=>g.includes(v.kind));if(f.length===0)return`<div class="query-preview empty"><em>${m(u)}</em></div>`;if(S==="count")return`<div class="query-preview count"><strong>${f.length}</strong><span>${m(k)}</span></div>`;const b=["name","kind","layer"],y=b.map(v=>`<th>${v}</th>`).join(""),$=f.slice(0,10).map(v=>`<tr>${b.map(R=>`<td>${m(String(v[R]??"—"))}</td>`).join("")}</tr>`).join(""),C=f.length>10?`<tr><td colspan="${b.length}" style="color:#9CA3AF;font-size:11px">…and ${f.length-10} more</td></tr>`:"";return`<div class="query-preview"><table><thead><tr>${y}</tr></thead><tbody>${$}${C}</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 F(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 L=/^\|\s*:?-{2,}.*\|$/;function le(t){const r=[],n=t.split(/\r?\n/);let o=0,i=[];const d=()=>{i.length>0&&(r.push(`<p>${F(i.join(" "))}</p>`),i=[])};for(;o<n.length;){const a=n[o],l=a.trim();if(l===""){d(),o++;continue}if(l.startsWith("<")){d(),r.push(a),o++;continue}if(l.match(/^```(\w[\w-]*)?/)){d();const u=[];for(o++;o<n.length&&!n[o].trim().startsWith("```");)u.push(n[o]),o++;o++,r.push(`<pre><code>${m(u.join(`
|
|
11
|
+
`))}</code></pre>`);continue}const h=l.match(/^(#{1,6})\s+(.+)$/);if(h){d();const u=h[1].length;r.push(`<h${u}>${F(h[2])}</h${u}>`),o++;continue}if(/^(-{3,}|\*{3,})$/.test(l)){d(),r.push("<hr>"),o++;continue}if(l.startsWith("> ")||l===">"){d();const u=[];for(;o<n.length&&(n[o].trim().startsWith("> ")||n[o].trim()===">");)u.push(n[o].trim().replace(/^>\s?/,"")),o++;r.push(`<blockquote>${F(u.join(" "))}</blockquote>`);continue}if(l.startsWith("|")&&l.endsWith("|")){d();const u=[];for(;o<n.length&&n[o].trim().startsWith("|")&&n[o].trim().endsWith("|");)u.push(n[o].trim()),o++;const k=y=>y.slice(1,-1).split("|").map($=>$.trim()),g=u.length>1&&L.test(u[1]),f=g?u.slice(2):u;let b="<table>";g&&(b+=`<thead><tr>${k(u[0]).map(y=>`<th>${F(y)}</th>`).join("")}</tr></thead>`),b+=`<tbody>${f.filter(y=>!L.test(y)).map(y=>`<tr>${k(y).map($=>`<td>${F($)}</td>`).join("")}</tr>`).join("")}</tbody></table>`,r.push(b);continue}const c=/^[-*]\s+/.test(l),S=/^\d+\.\s+/.test(l);if(c||S){d();const u=c?"ul":"ol",k=c?/^[-*]\s+/:/^\d+\.\s+/,g=[];for(;o<n.length;){const f=n[o].trim();if(k.test(f))g.push(f.replace(k,"")),o++;else if(f!==""&&/^\s{2,}/.test(n[o])&&g.length>0)g[g.length-1]+=` ${f}`,o++;else break}r.push(`<${u}>${g.map(f=>`<li>${F(f)}</li>`).join("")}</${u}>`);continue}i.push(l),o++}return d(),r.join(`
|
|
12
|
+
`)}function Y(t,r,n,o,i={}){const d=t.replace(/^---[\s\S]*?---\r?\n/,""),a=se(d,r,n,o,i);return le(a)}const de="#2DD4A8";function K(t){const r=t.primaryColor||"#1B3A4B",n=de,o=t.compactMode?.9:1,i=d=>`${Math.round(d*o)}px`;return`
|
|
13
|
+
.memo-doc{font-size:${i(14)};line-height:1.7;color:#1B3A4B;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
|
|
14
|
+
.memo-doc h1{font-size:${i(22)};font-weight:700;color:${r};border-bottom:2px solid ${n};padding-bottom:8px;margin:0 0 20px}
|
|
15
|
+
.memo-doc h2{font-size:${i(17)};font-weight:700;color:${r};margin:28px 0 12px}
|
|
16
|
+
.memo-doc h3{font-size:${i(14)};font-weight:600;color:#374151;margin:20px 0 8px}
|
|
17
|
+
.memo-doc h4{font-size:${i(13)};font-weight:600;color:#6B7280;margin:12px 0 6px}
|
|
18
|
+
.memo-doc h5,.memo-doc h6{font-size:${i(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:${i(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:${i(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:${i(12)};background:#F5F3FF;padding:1px 5px;border-radius:3px;display:inline-block}
|
|
32
|
+
.memo-doc .directive-error{color:#DC2626;font-size:${i(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:${i(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:${i(24)};color:#2563eb;font-weight:700}
|
|
37
|
+
.memo-doc .query-preview.count span{font-size:${i(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 ae=`
|
|
46
|
+
body{margin:0;padding:40px;background:#fff}
|
|
47
|
+
.memo-doc{max-width:800px;margin:0 auto}
|
|
48
|
+
@media print{body{padding:0}}
|
|
49
|
+
`,ce=`
|
|
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 I(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 pe=`<h2>Table of Contents</h2><p>${I('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>`,ue=`<div style="mso-element:footer" id="f1"><p class="MsoFooter" align="center" style="text-align:center">Page ${I("PAGE","1")} of ${I("NUMPAGES","1")}</p></div>`;function T(t,r,n,o={}){let i=Y(t.content,r,n,t,{resolveToc:!0,diagrams:"note"});o.word&&(i=i.replace(/<h2>Table of Contents<\/h2><div class="memo-doc-toc">[\s\S]*?<\/div>/,pe));const d=o.word?`<div class="WordSection1"><div class="memo-doc">${i}</div></div>
|
|
54
|
+
${ue}`:`<div class="memo-doc">${i}</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>${N(t.id)} — ${N(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>${K(n)}${ae}${o.word?ce:""}</style>
|
|
61
|
+
</head>
|
|
62
|
+
<body>${d}</body>
|
|
63
|
+
</html>`}function N(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function _(t,r,n){const o=new Blob([r],{type:n}),i=URL.createObjectURL(o),d=document.createElement("a");d.href=i,d.download=t,d.click(),URL.revokeObjectURL(i)}function me(t,r,n){_(`${t.id}.html`,T(t,r,n),"text/html;charset=utf-8")}function xe(t,r,n){_(`${t.id}.doc`,T(t,r,n,{word:!0}),"application/msword")}function he(t){_(`${t.id}.md`,t.content,"text/markdown;charset=utf-8")}function fe(t,r,n){const o=window.open("","_blank");o&&(o.document.write(T(t,r,n)),o.document.close(),o.setTimeout(()=>{o.focus(),o.print()},150))}const U=x.lazy(()=>oe(()=>import("./DhfSettingsPanel-CKvGmNGe.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.DhfSettingsPanel}))),V=[{id:"q-hazards",label:"Hazard Table",description:"All hazards in the risk layer",category:"query",code:'```memo-query\nkind: Hazard\ndisplay: table\ncolumns: name, layer, doc\nsort: name\nempty: "No hazards defined."\n```'},{id:"q-hazardous-situations",label:"Hazardous Situations",description:"All hazardous situations",category:"query",code:"```memo-query\nkind: HazardousSituation\ndisplay: table\ncolumns: name, layer, doc\nsort: name\n```"},{id:"q-risk-controls",label:"Risk Controls",description:"All risk control measures",category:"query",code:"```memo-query\nkind: RiskControl\ndisplay: table\ncolumns: name, layer, doc\nsort: name\n```"},{id:"q-requirements",label:"Requirements",description:"All system requirements",category:"query",code:"```memo-query\nkind: Requirement\ndisplay: table\ncolumns: name, layer, doc\nsort: name\n```"},{id:"q-soup",label:"SOUP List",description:"All SOUP components",category:"query",code:"```memo-query\nkind: SOUPComponent\ndisplay: table\ncolumns: name, layer, doc\n```"},{id:"q-sw-items",label:"Software Items",description:"All software items",category:"query",code:"```memo-query\nkind: SoftwareItem\ndisplay: table\ncolumns: name, layer, doc\n```"},{id:"q-test-cases",label:"Test Cases",description:"All test cases",category:"query",code:"```memo-query\nkind: TestCase\ndisplay: table\ncolumns: name, layer, doc\n```"},{id:"q-hazard-count",label:"Hazard Count (metric)",description:"Metric badge with hazard count",category:"query",code:"```memo-query\nkind: Hazard\ndisplay: count\nlabel: Total hazards\n```"},{id:"s-unmitigated",label:"Unmitigated Hazards",description:"Hazards without risk controls",category:"script",code:"```memo-script\nconst hazards = query({ kind: 'Hazard' });\nconst unmitigated = hazards.filter(h => h.mitigatedBy?.length === 0);\nif (unmitigated.length === 0) return 'All hazards have associated risk controls.';\nreturn table(unmitigated, ['name', 'layer', 'doc']);\n```"},{id:"s-coverage",label:"Requirements Coverage",description:"Requirements with/without test cases",category:"script",code:"```memo-script\nconst reqs = query({ kind: 'Requirement' });\nconst covered = reqs.filter(r => r.verifiedBy?.length > 0);\nreturn count(covered, `covered of ${reqs.length} requirements`);\n```"},{id:"i-doc-header",label:"Document Control Header",description:"Standard doc control table",category:"include",code:"{{include:shared/snippets/document-control-header.md}}"},{id:"i-approval",label:"Approval Block",description:"Reviewer/approver signature table",category:"include",code:"{{include:shared/snippets/approval-block.md}}"},{id:"i-revision",label:"Revision History",description:"Revision history table",category:"include",code:"{{include:shared/snippets/revision-history-table.md}}"},{id:"i-references",label:"References Section",description:"Normative references block",category:"include",code:"{{include:shared/snippets/references-section.md}}"},{id:"d-toc",label:"Table of Contents",description:"Auto-generated TOC (on export)",category:"directive",code:"{{toc}}"},{id:"d-glossary",label:"Glossary",description:"Auto-generated glossary (on export)",category:"directive",code:"{{glossary}}"}],J={query:"#2563eb",script:"#7c3aed",include:"#0891b2",directive:"#6B7280"},Q={query:"Query",script:"Script",include:"Snippet",directive:"Directive"};function Ae(){const t=w(s=>s.model),r=w(s=>s.activeView),n=w(s=>s.dhfDocuments),o=w(s=>s.updateDhfDocumentContent),i=w(s=>s.updateDhfDocumentMeta),d=w(s=>s.llmAvailable),a=w(s=>s.registerLlmRequest),l=w(s=>s.dhfSettings),[p,h]=x.useState("split"),c=x.useRef(null),[S,u]=x.useState(!1),[k,g]=x.useState(null),[f,b]=x.useState(!1),[y,$]=x.useState(!1),[C,v]=x.useState(!1),[E,R]=x.useState("all"),X=x.useCallback(async(s,A)=>{u(!0),g(null);const z=`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`,q=A.split("/").pop()??A;try{const B=await new Promise((W,D)=>{a(z,W,D),te(z,q),setTimeout(()=>D(new Error("Request timed out after 120 seconds.")),12e4)});o(s,B.markdown)}catch(B){g((B==null?void 0:B.message)??"Unknown error")}finally{u(!1)}},[a,o]),Z=x.useCallback(s=>{if(!c.current)return;const A=c.current,z=A.selectionStart,q=A.selectionEnd,B=`
|
|
64
|
+
|
|
65
|
+
${s.code}
|
|
66
|
+
|
|
67
|
+
`,W=A.value.slice(0,z)+B+A.value.slice(q),D=r.type==="dhf-document"?r.docId:null;D&&o(D,W),requestAnimationFrame(()=>{A.focus();const P=z+B.length;A.setSelectionRange(P,P)})},[r,o]),M=r.type==="dhf-document"?r.docId:null,j=M?n.find(s=>s.id===M):null,O=x.useMemo(()=>{const s=[];return l.company||s.push("company"),l.product||s.push("product"),s},[l]);if(!j)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.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"#D1D5DB",strokeWidth:"1.5",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),e.jsx("polyline",{points:"10 9 9 9 8 9"})]}),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:()=>b(!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(G,{size:13})," DHF Settings"]})]}),f&&e.jsx(x.Suspense,{fallback:null,children:e.jsx(U,{onClose:()=>b(!1)})})]});const ee=E==="all"?V:V.filter(s=>s.category===E);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:j.id}),e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"#1B3A4B"},children:j.title})]}),e.jsxs("button",{onClick:()=>v(s=>!s),title:"Document properties (authors, approvers)",style:{padding:"3px 10px",borderRadius:"6px",border:"1px solid",borderColor:C?"#6366F1":"#E5E7EB",background:C?"#EEF2FF":"#fff",color:C?"#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:()=>$(s=>!s),title:"Scriptlets & snippets library",style:{padding:"3px 10px",borderRadius:"6px",border:"1px solid",borderColor:y?"#2DD4A8":"#E5E7EB",background:y?"#F0FDF9":"#fff",color:y?"#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:()=>X(j.id,j.templateId),disabled:!d||S,title:d?"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:d?"#2DD4A815":"#f3f4f6",color:d?"#065F46":"#9CA3AF",fontSize:"11px",fontWeight:600,cursor:d&&!S?"pointer":"not-allowed",display:"flex",alignItems:"center",gap:"4px",opacity:S?.6:1},children:[e.jsx("span",{children:"✦"}),S?"Drafting…":"Draft with AI"]}),e.jsx(ge,{doc:j,model:t,settings:l}),e.jsx("div",{style:{display:"flex",gap:"2px",background:"#f3f4f6",borderRadius:"6px",padding:"2px"},children:["edit","split","preview"].map(s=>e.jsx("button",{onClick:()=>h(s),style:{padding:"3px 10px",borderRadius:"4px",border:"none",fontSize:"11px",fontWeight:500,cursor:"pointer",background:p===s?"#fff":"transparent",color:p===s?"#1B3A4B":"#6B7280",boxShadow:p===s?"0 1px 2px rgba(0,0,0,0.08)":"none"},children:s.charAt(0).toUpperCase()+s.slice(1)},s))}),e.jsx("button",{onClick:()=>b(!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(G,{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:()=>g(null),style:{background:"none",border:"none",color:"#dc2626",cursor:"pointer",fontSize:"14px"},children:"✕"})]}),O.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:O.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:()=>b(!0),style:{background:"none",border:"none",color:"#92400E",cursor:"pointer",fontWeight:700,fontSize:"11px",padding:0,textDecoration:"underline"},children:"Configure"})]}),C&&e.jsx(ye,{doc:j,onUpdate:s=>i(j.id,s)}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[(p==="edit"||p==="split")&&e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",borderRight:p==="split"?"1px solid #e5e7eb":"none"},children:e.jsx("textarea",{ref:c,value:j.content,onChange:s=>o(j.id,s.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..."})}),(p==="preview"||p==="split")&&e.jsx("div",{style:{flex:1,overflowY:"auto",padding:"20px 32px",background:"#fff"},children:e.jsx(ve,{content:j.content,model:t,settings:l,doc:j})}),y&&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(s=>e.jsx("button",{onClick:()=>R(s),style:{padding:"2px 8px",borderRadius:"10px",border:"none",fontSize:"10px",fontWeight:600,cursor:"pointer",background:E===s?s==="all"?"#1B3A4B":J[s]:"#E5E7EB",color:E===s?"#fff":"#6B7280"},children:s==="all"?"All":Q[s]},s))})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"8px"},children:[ee.map(s=>e.jsx(be,{snippet:s,onInsert:()=>Z(s)},s.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/"}),"."]})]})]})]})]}),f&&e.jsx(x.Suspense,{fallback:null,children:e.jsx(U,{onClose:()=>b(!1)})})]})}function ge({doc:t,model:r,settings:n}){const[o,i]=x.useState(!1),d=[{label:"Word (.doc)",hint:"Opens in Word / Pages",run:()=>xe(t,r,n)},{label:"PDF",hint:"Via the print dialog",run:()=>fe(t,r,n)},{label:"HTML",hint:"Standalone web page",run:()=>me(t,r,n)},{label:"Markdown",hint:"Raw document source",run:()=>he(t)}];return e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("button",{onClick:()=>i(a=>!a),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:()=>i(!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:d.map(a=>e.jsxs("button",{onClick:()=>{i(!1),a.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:a.label}),e.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF"},children:a.hint})]},a.label))})]})]})}function ye({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 be({snippet:t,onInsert:r}){const[n,o]=x.useState(!1),i=J[t.category];return e.jsxs("div",{onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{padding:"8px 10px",borderRadius:"6px",marginBottom:"4px",border:`1px solid ${n?i+"60":"#E5E7EB"}`,background:n?i+"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:i+"18",color:i},children:Q[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:i,color:"#fff",fontSize:"10px",fontWeight:600,cursor:"pointer",opacity:n?1:.7},children:"Insert"})]})}function G({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 ve({content:t,model:r,settings:n,doc:o}){const i=x.useMemo(()=>Y(t,r,n,o),[t,r,n,o]),d=x.useMemo(()=>K(n),[n]),a=x.useMemo(()=>i.split(new RegExp(ne,"g")),[i]);return e.jsxs("div",{className:"memo-doc",children:[e.jsx("style",{children:d}),a.map((l,p)=>p%2===0?e.jsx("div",{dangerouslySetInnerHTML:{__html:l}},p):e.jsx(je,{diagramRef:l,model:r},p))]})}function je({diagramRef:t,model:r}){var h;const n=w(c=>c.setActiveView),o=w(c=>c.selectDiagram),i=c=>c.toLowerCase().replace(/[^a-z0-9]/g,"").replace(/view$/,""),d=i(t),a=(r==null?void 0:r.diagrams)??[],l=a.find(c=>c.id===t)??a.find(c=>i(c.id)===d||i(c.name)===d)??a.find(c=>d.length>=6&&(i(c.name).includes(d)||i(c.id).includes(d)));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 p=()=>{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,(h=l.elementIds)!=null&&h.length?` · ${l.elementIds.length} elements`:""]})]}),e.jsx("button",{onClick:p,style:{padding:"5px 12px",borderRadius:"6px",border:"none",background:"#1B3A4B",color:"#fff",fontSize:"11px",fontWeight:600,cursor:"pointer"},children:"Open diagram →"})]})})}export{Ae as DhfWorkbench};
|