@memoarchitect/architect 0.4.6 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -3
- package/dist/assets/AskPanel-Dqc6aaqg.js +1 -0
- package/dist/assets/ComplianceWizard-Bi9PLmJH.js +1 -0
- package/dist/assets/{DSMView-B4IEz19F.js → DSMView-DbC_fUKT.js} +1 -1
- package/dist/assets/{Dashboard-DNRzU1Hk.js → Dashboard-6Dgma4kY.js} +1 -1
- package/dist/assets/DhfDashboard-BPXIYJnw.js +1 -0
- package/dist/assets/{DhfSettingsPanel-C89T0dv7.js → DhfSettingsPanel-jQ5mh_50.js} +1 -1
- package/dist/assets/{DhfWorkbench-4gHayn-l.js → DhfWorkbench-CgFdQIts.js} +3 -3
- package/dist/assets/DiagramCanvas-CIfN1ybl.js +1 -0
- package/dist/assets/DiagramEditor-Y4sSx9nO.js +4 -0
- package/dist/assets/ElementDetailView-B946aM3p.js +2 -0
- package/dist/assets/{ImportView-t1dIoZF5.js → ImportView-HCDzL9Xx.js} +1 -1
- package/dist/assets/{LayerGrid-fSGvqSEj.js → LayerGrid-DSxAFwPk.js} +1 -1
- package/dist/assets/{LayerTable-D8QCFY1b.js → LayerTable-C5VBpm6T.js} +2 -2
- package/dist/assets/{MaxGraphCanvas-DYs6MPuP.js → MaxGraphCanvas-B7tAFvDf.js} +6 -6
- package/dist/assets/{ModelDiff-CLFqnELG.js → ModelDiff-MM5NKKXK.js} +1 -1
- package/dist/assets/OntologyDecompositionDiagram-CAzu3z_q.js +1 -0
- package/dist/assets/{OntologyViewer-72jTw72H.js → OntologyViewer-C5ik2Kmi.js} +2 -2
- package/dist/assets/{RelationshipOverlay-BDrBRSPP.js → RelationshipOverlay-DSzjs5U7.js} +1 -1
- package/dist/assets/{RelationshipsSection-D1-tuVYo.js → RelationshipsSection-2CEoiF6o.js} +1 -1
- package/dist/assets/{ReviewDashboard-BVOe2I5w.js → ReviewDashboard-DwlsAVBa.js} +1 -1
- package/dist/assets/ScenarioEditor-BRWvcD2f.js +3 -0
- package/dist/assets/{StatisticsDashboard-Dn6lsnKe.js → StatisticsDashboard-C67W4pb0.js} +1 -1
- package/dist/assets/{SysmlCodeEditor-BLcw6hdp.js → SysmlCodeEditor-CGOcUFE7.js} +1 -1
- package/dist/assets/SysmlGenerator-BwRhtec-.js +1 -0
- package/dist/assets/{TabularView-B99xy3H3.js → TabularView-CTQgMG25.js} +1 -1
- package/dist/assets/TraceabilityMatrix-Bw5ej-So.js +1 -0
- package/dist/assets/{WorkflowWizard-C38DZKOe.js → WorkflowWizard-BwGWzMkE.js} +1 -1
- package/dist/assets/index-D0i9ua6F.js +3277 -0
- package/dist/assets/index-DPzXL4uF.css +1 -0
- package/dist/assets/{layout-providers-BAUgp0nu.js → layout-providers-BFnfta4Z.js} +13 -13
- package/dist/assets/layout-selection-BTId1JyG.js +1 -0
- package/dist/assets/{reactflow-WKyu73tD.js → reactflow-CX-HDacK.js} +1 -1
- package/dist/index.html +3 -3
- package/lib/bin/memo-architect.js +39 -3
- package/lib/bin/memo-architect.js.map +1 -1
- package/lib/commands/dev.d.ts.map +1 -1
- package/lib/commands/dev.js +9 -0
- package/lib/commands/dev.js.map +1 -1
- package/lib/commands/example.d.ts +16 -0
- package/lib/commands/example.d.ts.map +1 -0
- package/lib/commands/example.js +143 -0
- package/lib/commands/example.js.map +1 -0
- package/package.json +5 -4
- package/dist/assets/AskPanel-D9_AKyYt.js +0 -1
- package/dist/assets/ComplianceWizard-BNvT_ic6.js +0 -1
- package/dist/assets/DhfDashboard-DguH-rDT.js +0 -1
- package/dist/assets/DiagramCanvas-BgfO0AtP.js +0 -1
- package/dist/assets/DiagramEditor-CEr6iqBf.js +0 -4
- package/dist/assets/DiagramSurface-B_lfUNzV.js +0 -2
- package/dist/assets/ElementDetailView-AclSjurg.js +0 -2
- package/dist/assets/OntologyDecompositionDiagram-cpmTTMRH.js +0 -1
- package/dist/assets/ScenarioEditor-CvOkiRC6.js +0 -3
- package/dist/assets/SysmlGenerator-CfBQWovl.js +0 -1
- package/dist/assets/TraceabilityMatrix-BAJb0X7G.js +0 -1
- package/dist/assets/index-CgRwea72.js +0 -3277
- package/dist/assets/index-CnFhl4_e.css +0 -1
- package/dist/assets/layout-selection-BQ2WuAEB.js +0 -1
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { accessSync, constants, cpSync, existsSync, mkdtempSync, readFileSync, realpathSync, rmSync, } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { dirname, relative, resolve, sep } from 'node:path';
|
|
5
|
+
import { architectDevCommand } from './dev.js';
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
/** Locate the installed `@memoarchitect/ontology` package that bundles the examples. */
|
|
8
|
+
function resolveOntologyRoot() {
|
|
9
|
+
return dirname(require.resolve('@memoarchitect/ontology/package.json'));
|
|
10
|
+
}
|
|
11
|
+
/** Return whether a resolved path is contained by the bundled examples directory. */
|
|
12
|
+
function isBundledExample(examplesRoot, candidate) {
|
|
13
|
+
const pathFromExamples = relative(examplesRoot, candidate);
|
|
14
|
+
return pathFromExamples !== '' &&
|
|
15
|
+
pathFromExamples !== '..' &&
|
|
16
|
+
!pathFromExamples.startsWith(`..${sep}`) &&
|
|
17
|
+
!pathFromExamples.startsWith('/') &&
|
|
18
|
+
!pathFromExamples.startsWith('\\');
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Resolve an example by name. Accepts a manifest example key
|
|
22
|
+
* (`gpca`, `standard-sysml-diagrams`) or a direct examples/<dir> name
|
|
23
|
+
* (`gpca-pump`). Returns the source directory to copy from.
|
|
24
|
+
*/
|
|
25
|
+
function resolveExampleDir(ontologyRoot, name) {
|
|
26
|
+
const examplesRoot = resolve(ontologyRoot, 'examples');
|
|
27
|
+
const manifestPath = resolve(ontologyRoot, 'memo.manifest.yaml');
|
|
28
|
+
if (existsSync(manifestPath)) {
|
|
29
|
+
const manifest = readFileSync(manifestPath, 'utf-8');
|
|
30
|
+
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
31
|
+
// Match ` <name>: ./examples/<dir>` under the `examples:` mapping.
|
|
32
|
+
const match = manifest.match(new RegExp(`^\\s+${escaped}:\\s*(\\S+)`, 'm'));
|
|
33
|
+
if (match) {
|
|
34
|
+
const mapped = resolve(ontologyRoot, match[1]);
|
|
35
|
+
if (isBundledExample(examplesRoot, mapped) && existsSync(mapped))
|
|
36
|
+
return mapped;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (!/^[A-Za-z0-9._-]+$/.test(name)) {
|
|
40
|
+
throw new Error(`Example '${name}' is not a valid bundled example name.`);
|
|
41
|
+
}
|
|
42
|
+
const direct = resolve(examplesRoot, name);
|
|
43
|
+
if (existsSync(direct))
|
|
44
|
+
return direct;
|
|
45
|
+
throw new Error(`Example '${name}' not found. Expected a manifest example key or an examples/<dir> ` +
|
|
46
|
+
`under @memoarchitect/ontology (looked in ${ontologyRoot}).`);
|
|
47
|
+
}
|
|
48
|
+
/** List the example keys the manifest advertises, for a helpful error/usage hint. */
|
|
49
|
+
function listExampleKeys(ontologyRoot) {
|
|
50
|
+
const manifestPath = resolve(ontologyRoot, 'memo.manifest.yaml');
|
|
51
|
+
if (!existsSync(manifestPath))
|
|
52
|
+
return [];
|
|
53
|
+
const lines = readFileSync(manifestPath, 'utf-8').split(/\r?\n/);
|
|
54
|
+
const keys = [];
|
|
55
|
+
let inExamples = false;
|
|
56
|
+
for (const line of lines) {
|
|
57
|
+
if (/^examples:\s*$/.test(line)) {
|
|
58
|
+
inExamples = true;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (!inExamples)
|
|
62
|
+
continue;
|
|
63
|
+
if (/^\S/.test(line))
|
|
64
|
+
break; // dedent ends the mapping
|
|
65
|
+
const m = line.match(/^\s+([A-Za-z0-9._-]+):/);
|
|
66
|
+
if (m)
|
|
67
|
+
keys.push(m[1]);
|
|
68
|
+
}
|
|
69
|
+
return keys;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Whether an example lives in an installed package rather than a working
|
|
73
|
+
* checkout. Installed content is somebody else's artifact — editing it would
|
|
74
|
+
* mutate a dependency — so those examples are served from a disposable copy.
|
|
75
|
+
* A sibling checkout is the user's own source and is served in place.
|
|
76
|
+
*
|
|
77
|
+
* Node resolves symlinked dependencies to their real path, so a workspace link
|
|
78
|
+
* such as node_modules/@memoarchitect/ontology -> ../../memo already reports
|
|
79
|
+
* the checkout, not the link.
|
|
80
|
+
*/
|
|
81
|
+
function isInstalledPackage(exampleDir) {
|
|
82
|
+
const real = existsSync(exampleDir) ? realpathSync(exampleDir) : resolve(exampleDir);
|
|
83
|
+
return real.split(sep).includes('node_modules');
|
|
84
|
+
}
|
|
85
|
+
/** Whether the process can actually write to a directory. */
|
|
86
|
+
function isWritable(dir) {
|
|
87
|
+
try {
|
|
88
|
+
accessSync(dir, constants.W_OK);
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Open a bundled example.
|
|
97
|
+
*
|
|
98
|
+
* A checkout you own is served in place, so edits are real and can be
|
|
99
|
+
* committed. An example inside an installed package is copied to a disposable
|
|
100
|
+
* directory first and the copy is discarded on exit, so a dependency is never
|
|
101
|
+
* modified.
|
|
102
|
+
*/
|
|
103
|
+
export async function architectExampleCommand(options) {
|
|
104
|
+
const ontologyRoot = resolveOntologyRoot();
|
|
105
|
+
let exampleDir;
|
|
106
|
+
try {
|
|
107
|
+
exampleDir = resolveExampleDir(ontologyRoot, options.name);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
const keys = listExampleKeys(ontologyRoot);
|
|
111
|
+
const hint = keys.length ? `\nAvailable examples: ${keys.join(', ')}` : '';
|
|
112
|
+
throw new Error(`${error.message}${hint}`);
|
|
113
|
+
}
|
|
114
|
+
const editInPlace = !options.readOnly
|
|
115
|
+
&& !isInstalledPackage(exampleDir)
|
|
116
|
+
&& isWritable(exampleDir);
|
|
117
|
+
if (editInPlace) {
|
|
118
|
+
const target = realpathSync(exampleDir);
|
|
119
|
+
console.log(`Opening example '${options.name}' from ${target}`);
|
|
120
|
+
console.log('Edits are saved to that directory.');
|
|
121
|
+
process.chdir(target);
|
|
122
|
+
await architectDevCommand({ port: options.port, open: options.open });
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const slug = options.name.replace(/[^A-Za-z0-9]+/g, '-');
|
|
126
|
+
const tempRoot = mkdtempSync(resolve(tmpdir(), `memo-example-${slug}-`));
|
|
127
|
+
cpSync(exampleDir, tempRoot, { recursive: true });
|
|
128
|
+
const cleanup = () => {
|
|
129
|
+
try {
|
|
130
|
+
rmSync(tempRoot, { recursive: true, force: true });
|
|
131
|
+
}
|
|
132
|
+
catch { /* best effort */ }
|
|
133
|
+
};
|
|
134
|
+
process.on('exit', cleanup);
|
|
135
|
+
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
136
|
+
process.on(signal, () => { cleanup(); process.exit(0); });
|
|
137
|
+
}
|
|
138
|
+
const why = options.readOnly ? '--read-only' : 'installed package';
|
|
139
|
+
console.log(`Opening example '${options.name}' read-only (${why}: disposable copy; edits are discarded on exit).`);
|
|
140
|
+
process.chdir(tempRoot);
|
|
141
|
+
await architectDevCommand({ port: options.port, open: options.open });
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=example.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.js","sourceRoot":"","sources":["../../src/commands/example.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EACtD,YAAY,EAAE,YAAY,EAAE,MAAM,GACrC,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,wFAAwF;AACxF,SAAS,mBAAmB;IACxB,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,qFAAqF;AACrF,SAAS,gBAAgB,CAAC,YAAoB,EAAE,SAAiB;IAC7D,MAAM,gBAAgB,GAAG,QAAQ,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IAC3D,OAAO,gBAAgB,KAAK,EAAE;QAC1B,gBAAgB,KAAK,IAAI;QACzB,CAAC,gBAAgB,CAAC,UAAU,CAAC,KAAK,GAAG,EAAE,CAAC;QACxC,CAAC,gBAAgB,CAAC,UAAU,CAAC,GAAG,CAAC;QACjC,CAAC,gBAAgB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,YAAoB,EAAE,IAAY;IACzD,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IACvD,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,EAAE,oBAAoB,CAAC,CAAC;IACjE,IAAI,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACrD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;QAC5D,oEAAoE;QACpE,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,QAAQ,OAAO,aAAa,EAAE,GAAG,CAAC,CAAC,CAAC;QAC5E,IAAI,KAAK,EAAE,CAAC;YACR,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/C,IAAI,gBAAgB,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC;gBAAE,OAAO,MAAM,CAAC;QACpF,CAAC;IACL,CAAC;IACD,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,YAAY,IAAI,wCAAwC,CAAC,CAAC;IAC9E,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAC3C,IAAI,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IACtC,MAAM,IAAI,KAAK,CACX,YAAY,IAAI,oEAAoE;QACpF,4CAA4C,YAAY,IAAI,CAC/D,CAAC;AACN,CAAC;AAED,qFAAqF;AACrF,SAAS,eAAe,CAAC,YAAoB;IACzC,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,EAAE,oBAAoB,CAAC,CAAC;IACjE,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjE,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,UAAU,GAAG,KAAK,CAAC;IACvB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAAC,UAAU,GAAG,IAAI,CAAC;YAAC,SAAS;QAAC,CAAC;QACjE,IAAI,CAAC,UAAU;YAAE,SAAS;QAC1B,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,MAAM,CAAC,0BAA0B;QACvD,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC/C,IAAI,CAAC;YAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,kBAAkB,CAAC,UAAkB;IAC1C,MAAM,IAAI,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACrF,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;AACpD,CAAC;AAED,6DAA6D;AAC7D,SAAS,UAAU,CAAC,GAAW;IAC3B,IAAI,CAAC;QACD,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,OAM7C;IACG,MAAM,YAAY,GAAG,mBAAmB,EAAE,CAAC;IAE3C,IAAI,UAAkB,CAAC;IACvB,IAAI,CAAC;QACD,UAAU,GAAG,iBAAiB,CAAC,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,IAAI,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,yBAAyB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3E,MAAM,IAAI,KAAK,CAAC,GAAI,KAAe,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,WAAW,GAAG,CAAC,OAAO,CAAC,QAAQ;WAC9B,CAAC,kBAAkB,CAAC,UAAU,CAAC;WAC/B,UAAU,CAAC,UAAU,CAAC,CAAC;IAE9B,IAAI,WAAW,EAAE,CAAC;QACd,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,oBAAoB,OAAO,CAAC,IAAI,UAAU,MAAM,EAAE,CAAC,CAAC;QAChE,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;QAClD,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACtB,MAAM,mBAAmB,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACtE,OAAO;IACX,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;IACzD,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,gBAAgB,IAAI,GAAG,CAAC,CAAC,CAAC;IACzE,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAElD,MAAM,OAAO,GAAG,GAAG,EAAE;QACjB,IAAI,CAAC;YAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAC3F,CAAC,CAAC;IACF,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5B,KAAK,MAAM,MAAM,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAU,EAAE,CAAC;QAClD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,mBAAmB,CAAC;IACnE,OAAO,CAAC,GAAG,CAAC,oBAAoB,OAAO,CAAC,IAAI,gBAAgB,GAAG,kDAAkD,CAAC,CAAC;IACnH,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACxB,MAAM,mBAAmB,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;AAC1E,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memoarchitect/architect",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "MEMO Architect — interactive workbench and distributable viewer for medical device systems engineering",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
20
|
"build": "pnpm run check:cache && pnpm run build:client && pnpm run build:cli",
|
|
21
|
+
"prepack": "pnpm run clean && pnpm run build",
|
|
21
22
|
"build:client": "vite build --config packages/web/vite.config.ts",
|
|
22
23
|
"build:cli": "tsc -p tsconfig.architect.json",
|
|
23
24
|
"check:cache": "bash scripts/check-no-ontology-cache.sh",
|
|
@@ -33,8 +34,8 @@
|
|
|
33
34
|
"setup": "pnpm install && pnpm run build && pdm install"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@memoarchitect/tools": "0.
|
|
37
|
-
"@memoarchitect/ontology": "0.
|
|
37
|
+
"@memoarchitect/tools": "0.6.3",
|
|
38
|
+
"@memoarchitect/ontology": "0.6.2",
|
|
38
39
|
"commander": "^12.1.0"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
@@ -73,6 +74,6 @@
|
|
|
73
74
|
},
|
|
74
75
|
"packageManager": "pnpm@9.15.0",
|
|
75
76
|
"engines": {
|
|
76
|
-
"node": ">=
|
|
77
|
+
"node": ">=26.0.0"
|
|
77
78
|
}
|
|
78
79
|
}
|
|
@@ -1 +0,0 @@
|
|
|
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-CgRwea72.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};
|
|
@@ -1 +0,0 @@
|
|
|
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-CgRwea72.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};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./reactflow-WKyu73tD.js";import{a as m}from"./zustand-qbFpP9Up.js";import{u as b}from"./index-CgRwea72.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};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,H as A,P as N,N as ct,u as zt,a as Mn,B as On,E as Io,R as Wn,b as $n,c as Pn,d as _n,e as Hn,i as Kn,C as Vn,f as Yn,g as Gn,M as Xn}from"./reactflow-WKyu73tD.js";import{a as l,W as No}from"./zustand-qbFpP9Up.js";/* empty css */import{F as C,S as ee,m as qn,u as M,d as Xo,R as je,g as Un,D as Do,n as We,r as Zn,f as Ao,o as Qn,h as Jn,V as Ro,C as To}from"./index-CgRwea72.js";import{I as Mt,a as es,P as at,s as ts,G as Nt,c as os,f as ns,C as ss,r as is,v as rs,b as Lo,d as as,e as ls,g as ds,B as cs,w as ps,h as us,i as xs,j as hs,k as fs,l as gs,m as ms,n as ys,o as bs,p as Fs,q as ws,t as js}from"./layout-selection-BQ2WuAEB.js";import{l as vs}from"./layout-providers-BAUgp0nu.js";import"./elk-B75IRfCd.js";import"web-worker";function Es(o,d,r="both",s=10){const i=o.elements[d];if(!i)return{rootId:d,rootName:"(unknown)",rootKind:"",nodes:[],edges:[]};const u=new Map,h=new Map;for(const x of o.relationships)u.has(x.sourceId)||u.set(x.sourceId,[]),u.get(x.sourceId).push(x),h.has(x.targetId)||h.set(x.targetId,[]),h.get(x.targetId).push(x);const F=new Set;F.add(d);const S=[],b=[],j=[[d,0]];for(;j.length>0;){const[x,y]=j.shift();if(y>=s)continue;const w=y+1;if(r==="downstream"||r==="both")for(const g of u.get(x)||[]){const E=g.targetId;if(b.push({fromId:x,toId:E,relType:g.type,relId:g.id}),!F.has(E)){F.add(E);const m=o.elements[E];m&&(S.push({elementId:E,name:m.name,kind:m.kind,layer:m.layer,depth:w,viaRelType:g.type,direction:"downstream"}),j.push([E,w]))}}if(r==="upstream"||r==="both")for(const g of h.get(x)||[]){const E=g.sourceId;if(b.push({fromId:E,toId:x,relType:g.type,relId:g.id}),!F.has(E)){F.add(E);const m=o.elements[E];m&&(S.push({elementId:E,name:m.name,kind:m.kind,layer:m.layer,depth:w,viaRelType:g.type,direction:"upstream"}),j.push([E,w]))}}}return S.sort((x,y)=>x.depth-y.depth||x.name.localeCompare(y.name)),{rootId:d,rootName:i.name,rootKind:i.kind,nodes:S,edges:b}}function ks({data:o}){const d=o,{element:r,layerColor:s,isExpanded:i,hasChildren:u,childCount:h,direction:F,onToggleExpand:S,onToggleDirection:b,showDirectionButton:j,depthBgColor:x,isContainer:y}=d,w=F==="vertical"?"V":"H",g=y&&i;return e.jsxs("div",{style:{background:g?x||"#FAFAF9":"#FFFFFF",borderLeft:g?`2px solid ${s}40`:`3px solid ${s}`,borderTop:`1px solid ${g?s+"30":"#E5E5E0"}`,borderRight:`1px solid ${g?s+"30":"#E5E5E0"}`,borderBottom:`1px solid ${g?s+"30":"#E5E5E0"}`,borderRadius:3,padding:g?"0":"8px 12px",minWidth:g?void 0:"200px",boxShadow:"none",width:"100%",height:"100%",boxSizing:"border-box"},children:[e.jsx(A,{type:"target",position:N.Top,id:"top",style:nt}),e.jsx(A,{type:"source",position:N.Bottom,id:"bottom",style:nt}),e.jsx(A,{type:"target",position:N.Left,id:"left",style:nt}),e.jsx(A,{type:"source",position:N.Right,id:"right",style:nt}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:g?"8px 12px":"0"},children:[u&&e.jsx("button",{onClick:E=>{E.stopPropagation(),S()},style:{width:"20px",height:"20px",borderRadius:2,border:`1px solid ${s}`,background:i?s+"12":"#FFFFFF",color:s,fontSize:C.md,fontWeight:700,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0,flexShrink:0,transition:"background 200ms ease, color 200ms ease"},title:i?"Collapse":"Expand",children:i?"−":"+"}),u&&j&&e.jsx("button",{onClick:E=>{E.stopPropagation(),b()},style:{width:"20px",height:"20px",borderRadius:"4px",border:"1.5px solid #10b981",background:"transparent",color:"#10b981",fontSize:"9px",fontWeight:700,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0,flexShrink:0,transition:"background 200ms ease"},title:`Direction: ${F}. Click to toggle`,children:w}),e.jsx("span",{style:{fontSize:C.md,fontWeight:600,color:g?s:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r.name})]}),!g&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"3px",paddingLeft:u?"26px":"14px"},children:[e.jsx("span",{style:{fontSize:C.badge,color:"#9CA3AF"},children:r.kind}),u&&e.jsxs("span",{style:{fontSize:"9px",color:"#6B7280",background:"#F0F0ED",padding:"1px 5px",borderRadius:2,fontWeight:600},children:[h," parts",i?"":" (collapsed)"]})]})]})}const nt={width:"8px",height:"8px",background:"#2DD4A8",border:"1.5px solid #FFFFFF",opacity:0},Ss=l.memo(ks),Bo={top:N.Top,bottom:N.Bottom,left:N.Left,right:N.Right},Cs={top:"bottom",bottom:"top",left:"right",right:"left"},Is="#6B7280",qo=o=>o?at[o]:Is;function Uo(o,d){if(o==="inout")return"⇄";if(!o)return"";const r=o==="in";switch(d){case"left":return r?"→":"←";case"right":return r?"←":"→";case"top":return r?"↓":"↑";default:return r?"↑":"↓"}}const Ns=104,Dt=40,zo=o=>({opacity:0,width:o,height:o,top:"50%",left:"50%",transform:"translate(-50%, -50%)",border:"none",background:"transparent",pointerEvents:"none"});function Ds({port:o,onMove:d}){const{getZoom:r}=zt(),s=Mn(j=>j.transform[2]),i=o.size??Mt,u=(Dt-i)/2,h=i+5,F=qo(o.direction),S=o.side==="left"||o.side==="right",b={position:"absolute",fontSize:o.nested?"9.5px":"10.5px",fontWeight:o.nested?600:650,color:o.nested?"#6B7280":"#374151",whiteSpace:"normal",pointerEvents:"none",overflow:"hidden",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:2,width:S?Ns:72,background:"rgba(255,255,255,0.94)",padding:"1px 3px",borderRadius:4,lineHeight:1.12,...o.side==="left"?{left:h,bottom:"50%",marginBottom:2}:o.side==="right"?{right:h,bottom:"50%",marginBottom:2,textAlign:"right"}:o.side==="top"?{top:h,left:"50%",transform:"translateX(-50%)"}:{bottom:h,left:"50%",transform:"translateX(-50%)"}};return e.jsx("div",{className:"nodrag nopan",onPointerDown:d?j=>{j.preventDefault(),j.stopPropagation();const x=j.clientY,y=o.y,w=E=>d(y+(E.clientY-x)/r()),g=()=>{window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",g)};window.addEventListener("pointermove",w),window.addEventListener("pointerup",g,{once:!0})}:void 0,style:{position:"absolute",left:o.x-u,top:o.y-u,width:Dt,height:Dt,display:"flex",alignItems:"center",justifyContent:"center",zIndex:o.nested?11:10,cursor:d?"grab":"default",touchAction:"none",transform:`scale(${1/Math.max(s,.1)})`,transformOrigin:"center"},title:`${o.name}${o.direction?` (${o.direction})`:""}`,children:e.jsxs("div",{style:{position:"relative",width:i,height:i,boxSizing:"border-box",background:"#FFFFFF",border:`2px solid ${F}`,borderRadius:5,boxShadow:"0 1px 3px rgba(15,23,42,0.18)",display:"flex",alignItems:"center",justifyContent:"center",color:F,fontSize:o.nested?"10px":"12px",fontWeight:800,lineHeight:1,pointerEvents:"none"},children:[Uo(o.direction,o.side),e.jsx("span",{style:b,children:o.name.replace(/([a-z0-9])([A-Z])/g,"$1$2")}),[{suffix:"",pos:Bo[o.side]},{suffix:es,pos:Bo[Cs[o.side]]}].flatMap(j=>[e.jsx(A,{className:"ibd-port-anchor",type:"source",id:`${o.id}${j.suffix}`,position:j.pos,style:zo(i),isConnectable:!1},`s${j.suffix}`),e.jsx(A,{className:"ibd-port-anchor",type:"target",id:`${o.id}${j.suffix}`,position:j.pos,style:zo(i),isConnectable:!1},`t${j.suffix}`)])]})})}function Mo({side:o,direction:d}){const r=qo(d),s=Mt;return e.jsx("div",{"aria-label":`implicit ${d} port`,title:`Implicit ${d} port — relationship targets the part directly`,style:{position:"absolute",top:"50%",left:o==="left"?-s/2:void 0,right:o==="right"?-s/2:void 0,transform:"translateY(-50%)",width:s,height:s,boxSizing:"border-box",background:"#FFFFFF",border:`2px solid ${r}`,borderRadius:4,boxShadow:"0 1px 3px rgba(15,23,42,0.18)",display:"flex",alignItems:"center",justifyContent:"center",color:r,fontSize:11,fontWeight:800,lineHeight:1,zIndex:4,pointerEvents:"none"},children:Uo(d,o)})}const st={width:8,height:8,background:"#2DD4A8",border:"1.5px solid #FFFFFF",opacity:0};function Oo({name:o,kind:d,nameColor:r,typeColor:s,frame:i=!1}){return e.jsxs("span",{title:`${o} : ${d}`,style:{display:"flex",flexDirection:i?"row":"column",alignItems:i?"baseline":"flex-start",gap:i?6:1,minWidth:0,overflow:"hidden",flex:1},children:[e.jsx("span",{style:{display:i?"block":"-webkit-box",width:"100%",minWidth:0,fontSize:i?C.md:C.sm,lineHeight:1.2,fontWeight:700,color:r,whiteSpace:i?"nowrap":"normal",overflow:"hidden",textOverflow:"ellipsis",WebkitBoxOrient:"vertical",WebkitLineClamp:i?void 0:2,overflowWrap:"anywhere"},children:o}),e.jsx("span",{style:{display:"block",maxWidth:"100%",fontSize:"9px",lineHeight:1.15,fontWeight:650,letterSpacing:"0.055em",textTransform:"uppercase",color:s,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i?`: ${d}`:`«${d}»`})]})}function Wo({label:o,isCollapsed:d,onToggle:r,color:s,onColor:i}){return e.jsx("button",{"aria-label":d?`Expand ${o}`:`Collapse ${o}`,onClick:u=>{u.stopPropagation(),r()},style:{marginLeft:"auto",width:18,height:18,padding:0,borderRadius:3,border:i?"1px solid rgba(255,255,255,0.7)":`1px solid ${s}88`,background:i?"rgba(255,255,255,0.18)":"#FFFFFF",color:i?"#FFFFFF":s,fontSize:13,lineHeight:"15px",cursor:"pointer",fontWeight:700,flexShrink:0},children:d?"+":"−"})}function As({id:o,data:d,selected:r,height:s}){const i=d,{label:u,kind:h,color:F,isContainer:S,isFrame:b,ports:j,implicitIn:x,implicitOut:y,onPortMove:w,hasChildren:g,isCollapsed:E,onToggleCollapse:m}=i,[D,O]=l.useState(!1),v=r?ee.selected:b?"none":D?"0 8px 20px rgba(15,23,42,0.12)":S?"0 1px 2px rgba(15,23,42,0.05)":"0 2px 8px rgba(15,23,42,0.08)";return e.jsxs("div",{onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1),style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#FFFFFF",border:b?"1.5px solid #94A3B8":`1px solid ${D?F+"9A":"#CBD5E1"}`,...b?{}:{borderTop:`3px solid ${F}`},borderRadius:b?10:8,boxShadow:v,transition:"box-shadow 150ms ease, border-color 150ms ease",position:"relative"},children:[!b&&e.jsx(ct,{nodeId:o,isVisible:r,minWidth:180,minHeight:100,color:"#2563EB",lineStyle:{borderWidth:1},handleStyle:{width:10,height:10,borderRadius:2}}),e.jsx(A,{type:"target",position:N.Top,id:"top",style:st}),e.jsx(A,{type:"source",position:N.Bottom,id:"bottom",style:st}),e.jsx(A,{type:"target",position:N.Left,id:"left",style:st}),e.jsx(A,{type:"source",position:N.Right,id:"right",style:st}),b?e.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,height:38,display:"flex",alignItems:"center",gap:8,padding:"0 10px",background:"#F8FAFC",borderBottom:"1px solid #E2E8F0",borderRadius:"9px 9px 0 0"},children:[e.jsx("span",{style:{padding:"2px 6px",borderRadius:4,background:F,color:"#FFFFFF",fontSize:9,fontWeight:800,letterSpacing:"0.08em"},children:"IBD"}),e.jsx(Oo,{name:u,kind:h,nameColor:"#0F172A",typeColor:"#64748B",frame:!0}),g&&m&&e.jsx(Wo,{label:u,isCollapsed:E,onToggle:m,color:F})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minHeight:58,padding:"7px 10px 6px",background:"#FFFFFF",borderBottom:g?"1px solid #E2E8F0":"none",borderRadius:"7px 7px 0 0",overflow:"hidden"},children:[e.jsx(Oo,{name:u,kind:h,nameColor:"#0F172A",typeColor:S?F:"#64748B"}),g&&m&&e.jsx(Wo,{label:u,isCollapsed:E,onToggle:m,color:F})]}),j.map(I=>e.jsx(Ds,{port:I,onMove:w?$=>{const z=I.size??Mt,X=(b||S?70:62)-z/2,T=Math.max(X,(s??X+z+18)-z-18);w(I.id,Math.min(Math.max($,X),T))}:void 0},I.id)),x&&e.jsx(Mo,{side:"left",direction:"in"}),y&&e.jsx(Mo,{side:"right",direction:"out"})]})}const Rs=l.memo(As);function $o(o,d){const r=o.map(i=>({...i}));let s=d;for(;r.length>=2&&s>0;){const i=r[0],u=r[1],h=Math.hypot(u.x-i.x,u.y-i.y);if(h<=s)s-=h,r.shift();else{const F=s/h;r[0]={x:i.x+(u.x-i.x)*F,y:i.y+(u.y-i.y)*F},s=0}}return r}function Ts(o,d){const r=$o(o,d);return $o([...r].reverse(),d).reverse()}const Ls=o=>o.slice(1).reduce((d,r,s)=>d+Math.hypot(r.x-o[s].x,r.y-o[s].y),0);function At(o,d=7){if(o.length<2)return"";let r=`M ${o[0].x},${o[0].y}`;for(let i=1;i<o.length-1;i++){const u=o[i-1],h=o[i],F=o[i+1],S=Math.hypot(h.x-u.x,h.y-u.y),b=Math.hypot(F.x-h.x,F.y-h.y),j=Math.min(d,S/2,b/2),x=h.x-Math.sign(h.x-u.x)*j,y=h.y-Math.sign(h.y-u.y)*j,w=h.x+Math.sign(F.x-h.x)*j,g=h.y+Math.sign(F.y-h.y)*j;r+=` L ${x},${y} Q ${h.x},${h.y} ${w},${g}`}const s=o[o.length-1];return`${r} L ${s.x},${s.y}`}function Bs(o){const d=o.slice(1).map((i,u)=>Math.abs(i.x-o[u].x)+Math.abs(i.y-o[u].y)),r=d.reduce((i,u)=>i+u,0)/2;let s=0;for(let i=0;i<d.length;i++){if(s+d[i]>=r){const u=d[i]?(r-s)/d[i]:0;return{x:o[i].x+(o[i+1].x-o[i].x)*u,y:o[i].y+(o[i+1].y-o[i].y)*u}}s+=d[i]}return o[o.length-1]}function zs(o){var j,x,y,w,g,E;const{getZoom:d}=zt(),r=((j=o.data)==null?void 0:j.points)??[];if(r.length<2)return null;const s=Bs(r),i=Math.min(28/Math.max(d(),.1),Ls(r)*.3),u=Ts(r,i),h=(x=o.data)==null?void 0:x.onRouteChange,F=(y=o.data)==null?void 0:y.onSelect,S=!!((w=o.data)!=null&&w.flowAnimation),b=r.length===2?[{index:1,a:r[0],b:r[1],straight:!0}]:r.slice(1).map((m,D)=>({index:D+1,a:r[D],b:m,straight:!1})).filter(m=>m.index>=2&&m.index<=r.length-2);return e.jsxs(e.Fragment,{children:[e.jsx(On,{id:o.id,path:At(r),style:o.style,markerEnd:o.markerEnd}),S&&e.jsx("path",{d:At(r),fill:"none",stroke:String(((g=o.style)==null?void 0:g.stroke)??"#2563EB"),strokeWidth:Math.max(2,Number(((E=o.style)==null?void 0:E.strokeWidth)??2)),className:"memo-ibd-flow"}),u.length>=2&&e.jsx("path",{d:At(u),fill:"none",stroke:"transparent",strokeWidth:18/Math.max(d(),.1),pointerEvents:"stroke",cursor:"pointer",onClick:m=>F==null?void 0:F(m)}),o.label?e.jsx(Io,{children:e.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${s.x}px, ${s.y}px)`,fontSize:C.badge,fontWeight:600,color:"#475569",background:"rgba(255,255,255,0.96)",border:"1px solid #E2E8F0",padding:"1px 4px",borderRadius:4,pointerEvents:"none"},children:o.label})}):null,o.selected&&h?b.map(m=>{const D=(m.a.x+m.b.x)/2,O=(m.a.y+m.b.y)/2;return e.jsx(Io,{children:e.jsx("div",{className:"nodrag nopan",title:"Drag connector segment",onPointerDown:v=>{v.preventDefault(),v.stopPropagation();const I=v.clientX,$=v.clientY,z=T=>{const le=(T.clientX-I)/d(),U=(T.clientY-$)/d();if(m.straight){if(Math.abs(U)>=Math.abs(le)){const G=m.a.y+U;h([m.a,{x:m.a.x,y:G},{x:m.b.x,y:G},m.b])}else{const G=(m.a.x+m.b.x)/2+le;h([m.a,{x:G,y:m.a.y},{x:G,y:m.b.y},m.b])}return}const Y=r.map(G=>({...G}));m.a.y===m.b.y?(Y[m.index-1].y=m.a.y+U,Y[m.index].y=m.b.y+U):(Y[m.index-1].x=m.a.x+le,Y[m.index].x=m.b.x+le),h(Y)},X=()=>{window.removeEventListener("pointermove",z),window.removeEventListener("pointerup",X)};window.addEventListener("pointermove",z),window.addEventListener("pointerup",X,{once:!0})},style:{position:"absolute",transform:`translate(-50%, -50%) translate(${D}px, ${O}px)`,width:12,height:12,borderRadius:3,background:"#FFFFFF",border:"2px solid #2563EB",boxShadow:"0 1px 4px rgba(15,23,42,0.22)",cursor:m.a.y===m.b.y?"ns-resize":"ew-resize",pointerEvents:"all",touchAction:"none",zIndex:20}})},`route-${m.index}`)}):null]})}const Ms=l.memo(zs);function Os({data:o,selected:d}){const r=o,{nodeType:s,label:i,laneColor:u,layerColor:h,inPorts:F,outPorts:S}=r,[b,j]=l.useState(!1);if(s==="start")return e.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:"#374151",border:"2px solid #374151",boxShadow:ee.sm},children:e.jsx(A,{type:"source",position:r.flowDirection==="vertical"?N.Bottom:N.Right,style:{background:"#374151",width:6,height:6}})});if(s==="done")return e.jsxs("div",{style:{width:28,height:28,borderRadius:"50%",background:"#FFFFFF",border:"3px solid #374151",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:ee.sm},children:[e.jsx("div",{style:{width:14,height:14,borderRadius:"50%",background:"#374151"}}),e.jsx(A,{type:"target",position:r.flowDirection==="vertical"?N.Top:N.Left,style:{background:"#374151",width:6,height:6}})]});if(s==="fork"||s==="join"){const g=r.flowDirection==="vertical";return e.jsxs("div",{title:s==="fork"?"Fork — split into concurrent flows":"Join — synchronize concurrent flows",style:{width:"100%",height:"100%",background:"#374151",borderRadius:3,boxShadow:ee.sm},children:[e.jsx(A,{type:"target",position:g?N.Top:N.Left,style:{background:"#374151",width:6,height:6,border:"none"}}),e.jsx(A,{type:"source",position:g?N.Bottom:N.Right,style:{background:"#374151",width:6,height:6,border:"none"}})]})}const x=u||h||"#9CA3AF",y=18,w=Math.max(F.length*y,S.length*y,0);return e.jsxs("div",{onMouseEnter:()=>j(!0),onMouseLeave:()=>j(!1),style:{background:"#FFFFFF",border:`1.5px solid ${x}`,borderRadius:3,minWidth:"140px",boxShadow:d?"0 0 0 3px #2DD4A8, 0 4px 12px rgba(45, 212, 168, 0.35)":b?`0 0 0 2px ${x}22`:"none",transition:"box-shadow 150ms ease",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"8px 14px",fontSize:C.md,fontWeight:600,color:"#1a1a1a",background:`${x}0D`,borderBottom:w>0?"1px solid #E5E5E0":"none",textAlign:"center",whiteSpace:"nowrap"},children:[i,r.hasChildren&&r.onToggleExpand&&e.jsx("button",{"aria-label":r.isExpanded?`Collapse ${i}`:`Expand ${i}`,onClick:g=>{g.stopPropagation(),r.onToggleExpand()},style:{float:"right",marginLeft:8,width:18,height:18,padding:0,border:`1px solid ${x}`,borderRadius:2,background:"#FFFFFF",color:x,fontSize:13,fontWeight:700,lineHeight:"16px",cursor:"pointer"},children:r.isExpanded?"−":"+"})]}),w>0&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"4px 0"},children:[e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:F.map(g=>e.jsxs("div",{style:{fontSize:C.badge,color:"#6B7280",paddingLeft:"8px",display:"flex",alignItems:"center",height:`${y}px`,gap:"4px"},children:[e.jsx("span",{style:{width:"6px",height:"6px",borderRadius:"50%",background:"#3498DB",flexShrink:0}}),g]},`in-${g}`))}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px",alignItems:"flex-end"},children:S.map(g=>e.jsxs("div",{style:{fontSize:C.badge,color:"#6B7280",paddingRight:"8px",display:"flex",alignItems:"center",height:`${y}px`,gap:"4px"},children:[g,e.jsx("span",{style:{width:"6px",height:"6px",borderRadius:"50%",background:"#E67E22",flexShrink:0}})]},`out-${g}`))})]}),r.allocatedTo&&e.jsxs("div",{style:{fontSize:"9px",color:"#9CA3AF",textAlign:"center",padding:"2px 6px",borderTop:"1px solid #F3F4F6",background:"#FAFAFA"},children:["→"," ",r.allocatedTo]}),e.jsx(A,{type:"target",position:r.flowDirection==="vertical"?N.Top:N.Left,style:{background:x,width:8,height:8,border:"2px solid #FFFFFF"}}),e.jsx(A,{type:"source",position:r.flowDirection==="vertical"?N.Bottom:N.Right,style:{background:x,width:8,height:8,border:"2px solid #FFFFFF"}})]})}const Ws=l.memo(Os);function $s({data:o,selected:d}){const r=o,s=r.orientation==="column";return e.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:`${r.color}08`,border:d?"3px solid #2DD4A8":`1px solid ${r.color}30`,borderLeft:d?"3px solid #2DD4A8":s?`1px solid ${r.color}30`:`3px solid ${r.color}`,borderTop:d?"3px solid #2DD4A8":s?`3px solid ${r.color}`:`1px solid ${r.color}30`,borderRadius:qn.md,pointerEvents:"auto",cursor:r.inspectElementId?"pointer":"default",display:"flex"},children:e.jsx("div",{style:{writingMode:s?"horizontal-tb":"vertical-rl",transform:s?void 0:"rotate(180deg)",padding:s?"7px 10px":"10px 6px",fontSize:C.xs,fontWeight:700,color:r.color,letterSpacing:"0.04em",textTransform:"uppercase",alignSelf:s?"flex-start":"center",width:s?"100%":void 0,textAlign:s?"center":void 0,whiteSpace:"nowrap"},children:r.label})})}const Ps=l.memo($s),it={width:8,height:8,border:"none",background:"transparent",opacity:0};function Rt(){return e.jsxs(e.Fragment,{children:[e.jsx(A,{type:"target",position:N.Top,id:"top",style:it}),e.jsx(A,{type:"source",position:N.Bottom,id:"bottom",style:it}),e.jsx(A,{type:"target",position:N.Left,id:"left",style:it}),e.jsx(A,{type:"source",position:N.Right,id:"right",style:it})]})}function _s({data:o,selected:d}){const r=o;return r.isNote?e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#FFFDF5",border:`1px solid ${r.color}66`,borderRadius:4,padding:"6px 10px",boxShadow:ee.sm,display:"flex",flexDirection:"column",justifyContent:"center"},title:r.kind,children:[e.jsx(Rt,{}),e.jsx("span",{style:{fontSize:C.xs,fontWeight:600,color:"#374151",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r.label}),e.jsx("span",{style:{fontSize:"8px",fontWeight:700,color:r.color,textTransform:"uppercase",letterSpacing:"0.05em"},children:r.kind})]}):r.isContainer?e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:r.isMachine?"transparent":`${r.color}06`,border:r.isMachine?`1.5px dashed ${r.color}88`:`1.5px solid ${r.color}55`,borderRadius:14,boxShadow:d?ee.selected:"none",position:"relative"},children:[e.jsx(Rt,{}),e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,padding:"10px 14px 0"},children:[e.jsx("span",{style:{fontSize:C.md,fontWeight:700,color:r.color,whiteSpace:"nowrap"},children:r.label}),e.jsx("span",{style:{fontSize:"8px",fontWeight:700,color:`${r.color}AA`,textTransform:"uppercase",letterSpacing:"0.06em"},children:r.kind})]})]}):e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#FFFFFF",border:`1.5px solid ${r.color}`,borderRadius:12,boxShadow:d?ee.selected:ee.md,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,padding:"4px 12px"},children:[e.jsx(Rt,{}),e.jsx("span",{style:{fontSize:C.md,fontWeight:600,color:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:r.label}),r.subtitle&&e.jsx("span",{style:{fontSize:"8px",fontWeight:600,color:"#9CA3AF",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:r.subtitle})]})}const Hs=l.memo(_s),Bt="#3498DB";function Ks({data:o}){const d=o;return e.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",pointerEvents:"none"},children:[e.jsx("div",{style:{position:"absolute",top:0,left:"50%",transform:"translateX(-50%)",minWidth:140,maxWidth:"90%",padding:"10px 16px",background:"#FFFFFF",border:`1.5px solid ${Bt}`,borderRadius:8,boxShadow:ee.md,textAlign:"center",fontSize:C.md,fontWeight:600,color:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:d.label}),e.jsx("div",{style:{position:"absolute",top:44,bottom:0,left:"50%",borderLeft:`1.5px dashed ${Bt}66`}})]})}const Vs=l.memo(Ks);function Ys({data:o}){const d=o;return e.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#1B3A4B06",border:"1px solid #1B3A4B22",borderRadius:10,pointerEvents:"none"},children:e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,padding:"8px 14px"},children:[e.jsx("span",{style:{fontSize:C.sm,fontWeight:700,color:"#1B3A4B"},children:d.label}),d.scenario&&e.jsxs("span",{style:{fontSize:C.xs,color:"#6B7280"},children:["realizes ",d.scenario]})]})})}const Gs=l.memo(Ys),rt={width:6,height:6,border:"none",background:"transparent",opacity:0};function Xs({data:o,selected:d}){const r=o;return e.jsxs("div",{style:{width:14,height:14,borderRadius:"50%",background:"#FFFFFF",border:`3px solid ${Bt}`,boxShadow:d?ee.selected:ee.sm,position:"relative"},title:r.kind,children:[e.jsx(A,{type:"source",id:"right",position:N.Right,style:rt}),e.jsx(A,{type:"target",id:"right",position:N.Right,style:rt}),e.jsx(A,{type:"source",id:"left",position:N.Left,style:rt}),e.jsx(A,{type:"target",id:"left",position:N.Left,style:rt}),e.jsx("span",{style:{position:"absolute",top:-20,left:"50%",transform:"translateX(-50%)",fontSize:"9px",fontWeight:600,color:"#374151",whiteSpace:"nowrap",background:"#FFFFFFCC",padding:"1px 5px",borderRadius:4},children:r.label})]})}const qs=l.memo(Xs),Us=l.memo(function({id:d,data:r,selected:s}){var v;const i=r,[u,h]=l.useState(!1),[F,S]=l.useState(""),[b,j]=l.useState(!1),x=l.useRef(null),y=l.useCallback(()=>{S(i.label),h(!0),setTimeout(()=>{var I;(I=x.current)==null||I.select()},10)},[i.label]),w=l.useCallback(()=>{var $;h(!1);const I=F.trim();I&&I!==i.label&&(($=i.onInlineEdit)==null||$.call(i,d,I))},[F,i,d]),g=l.useCallback(I=>{I.key==="Enter"&&(I.preventDefault(),w()),I.key==="Escape"&&h(!1)},[w]),E=l.useCallback(I=>{var $;I.preventDefault(),($=i.onContextMenu)==null||$.call(i,I,d)},[i,d]),m=i.bgColor??"#FFFFFF",D=i.color,O={background:D,border:"2px solid #FFFFFF",width:10,height:10,opacity:b||s?1:0,transition:"opacity 0.15s"};return e.jsxs("div",{onMouseEnter:()=>j(!0),onMouseLeave:()=>j(!1),onContextMenu:E,onDoubleClick:y,style:{minWidth:120,minHeight:40,background:m,borderLeft:`3px solid ${D}`,borderRadius:8,boxShadow:s?`0 0 0 2px ${D}, 0 4px 12px ${D}44`:b?"0 4px 16px rgba(0,0,0,0.14)":"0 1px 4px rgba(0,0,0,0.08)",cursor:u?"text":"grab",position:"relative",transition:"box-shadow 0.15s",opacity:i.isNew?.7:1},children:[s&&e.jsx(ct,{minWidth:80,minHeight:36,maxWidth:600,maxHeight:400,color:D,lineStyle:{borderColor:D},handleStyle:{background:D,border:"2px solid #fff",width:10,height:10,borderRadius:2}}),e.jsxs("div",{style:{padding:"8px 12px",userSelect:"none"},children:[e.jsx("div",{style:{fontSize:"9px",fontWeight:700,color:D,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:2},children:i.kind}),u?e.jsx("input",{ref:x,value:F,onChange:I=>S(I.target.value),onBlur:w,onKeyDown:g,onClick:I=>I.stopPropagation(),autoFocus:!0,style:{fontSize:C.sm,fontWeight:500,color:"#1a1a1a",background:"transparent",border:"none",outline:"none",width:"100%",padding:0}}):e.jsx("div",{style:{fontSize:C.sm,fontWeight:500,color:"#1a1a1a",lineHeight:1.3,wordBreak:"break-word"},children:i.label||i.kind}),i.isNew&&e.jsx("div",{style:{fontSize:"9px",color:"#9CA3AF",marginTop:2},children:"saving…"})]}),!!((v=i.compartments)!=null&&v.length)&&e.jsx("div",{style:{borderTop:"1px solid #EDEDEA",padding:"5px 12px 7px",userSelect:"none"},children:i.compartments.map(I=>e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"baseline",fontSize:"10px",lineHeight:"15px",whiteSpace:"nowrap",overflow:"hidden"},children:[e.jsx("span",{style:{color:"#9CA3AF"},children:I.key}),e.jsx("span",{style:{color:"#4B5563",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis"},children:I.value})]},I.key))}),e.jsx(A,{type:"target",position:N.Top,style:{...O,top:-5}}),e.jsx(A,{type:"source",position:N.Bottom,style:{...O,bottom:-5},id:"bottom"}),e.jsx(A,{type:"source",position:N.Right,style:{...O,right:-5},id:"right"}),e.jsx(A,{type:"target",position:N.Left,style:{...O,left:-5}})]})});function Tt({collapsed:o,onToggleCollapse:d,elementIds:r=[]}){const s=M(y=>y.model),i=M(y=>y.selectedElementId),u=M(y=>y.inspectElement),[h,F]=l.useState(""),[S,b]=l.useState(new Set),j=l.useMemo(()=>{var E;if(!s)return[];const y=h.trim().toLowerCase(),w=new Map,g=new Set(r);for(const m of r){const D=(E=s.elements[m])==null?void 0:E.allocatedTo;D&&g.add(D)}for(const m of g){const D=s.elements[m];D&&(y&&!D.name.toLowerCase().includes(y)&&!D.kind.toLowerCase().includes(y)||(w.has(D.kind)||w.set(D.kind,[]),w.get(D.kind).push(D)))}return[...w.entries()].map(([m,D])=>({kind:m,elements:D.sort((O,v)=>O.name.localeCompare(v.name))})).sort((m,D)=>m.kind.localeCompare(D.kind))},[s,r,h]),x=y=>b(w=>{const g=new Set(w);return g.has(y)?g.delete(y):g.add(y),g});return o?e.jsxs("button",{className:"flex flex-col items-center py-2 gap-1 cursor-pointer",style:{width:36,border:0,borderRight:"1px solid #E5E5E0",background:"#FAFAF8",flexShrink:0},onClick:d,title:"Expand diagram elements","aria-label":"Expand diagram elements",children:[e.jsx("span",{style:{color:"#6B7280",fontSize:18},children:"›"}),e.jsx("span",{style:{fontSize:10,color:"#6B7280",writingMode:"vertical-rl"},children:"Diagram Elements"})]}):e.jsxs("div",{className:"flex flex-col overflow-hidden",style:{width:240,borderRight:"1px solid #E5E5E0",background:"#FAFAF8",flexShrink:0},children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",style:{borderBottom:"1px solid #E5E5E0",flexShrink:0},children:[e.jsx("span",{style:{fontSize:C.xs,fontWeight:600,color:"#374151"},children:"Diagram Elements"}),e.jsx("button",{onClick:d,title:"Collapse diagram elements","aria-label":"Collapse diagram elements",style:{background:"none",border:"none",cursor:"pointer",color:"#6B7280",fontSize:18,lineHeight:1},children:"‹"})]}),e.jsx("div",{className:"px-2 pt-2 pb-1",style:{flexShrink:0},children:e.jsx("input",{value:h,onChange:y=>F(y.target.value),placeholder:"Search elements…",className:"w-full px-2 py-1 rounded focus:outline-none",style:{fontSize:C.xs,background:"#F0F0ED",border:"1px solid #E5E5E0",color:"#374151"}})}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[j.map(y=>{var E;const w=S.has(y.kind),g=Xo[(E=y.elements[0])==null?void 0:E.layer]??"#6B7280";return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>x(y.kind),className:"w-full flex items-center gap-1.5 px-2 py-1",style:{background:"none",border:"none",cursor:"pointer",textAlign:"left"},children:[e.jsx("span",{style:{fontSize:10,color:g},children:w?"▶":"▼"}),e.jsx("span",{className:"truncate",style:{fontSize:10,color:g,fontWeight:700},children:y.kind}),e.jsx("span",{style:{fontSize:9,color:"#9CA3AF",marginLeft:"auto"},children:y.elements.length})]}),!w&&y.elements.map(m=>{const D=i===m.id;return e.jsxs("button",{onClick:()=>u(m.id),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left",style:{border:"none",cursor:"pointer",fontSize:C.xs,background:D?"#DDF7EF":"transparent",color:D?"#116149":"#374151",fontWeight:D?600:400},title:`Highlight ${m.name} in diagram`,children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2,background:g,flexShrink:0}}),e.jsx("span",{className:"truncate flex-1",children:m.name})]},m.id)})]},y.kind)}),j.length===0&&e.jsx("div",{className:"p-3 text-center",style:{color:"#9CA3AF",fontSize:C.xs},children:h?"No matching elements":"No elements in this diagram"})]})]})}const Po=[{type:"mitigates",label:"Mitigates",desc:"Risk control → Hazard"},{type:"causes",label:"Causes",desc:"Hazard → Hazardous Situation"},{type:"leadsTo",label:"Leads To",desc:"Situation → Harm"},{type:"identifies",label:"Identifies",desc:"Analysis → Risk"},{type:"traceTo",label:"Traces To",desc:"Requirement → Requirement"},{type:"satisfy",label:"Satisfies",desc:"Function → Requirement"},{type:"verify",label:"Verifies",desc:"Test → Requirement"},{type:"allocateTo",label:"Allocates To",desc:"Function → Component"},{type:"composedOf",label:"Composed Of",desc:"Parent → Child"},{type:"decomposedBy",label:"Decomposed By",desc:"Function → Sub-function"},{type:"flow",label:"Flow",desc:"Data / material flow"},{type:"succession",label:"Succession",desc:"Action sequence"},{type:"aggregation",label:"Aggregation",desc:"Logical grouping"}];function Zs({x:o,y:d,sourceKind:r,targetKind:s,closureRules:i,onSelect:u,onCancel:h}){const F=l.useRef(null),[S,b]=l.useState(""),j=l.useRef(null);l.useEffect(()=>{var v;(v=j.current)==null||v.focus()},[]),l.useEffect(()=>{const v=I=>{F.current&&!F.current.contains(I.target)&&h()};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[h]),l.useEffect(()=>{const v=I=>{I.key==="Escape"&&h()};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[h]);const x=i?i[r]??Object.keys(je):Object.keys(je),y=Po.filter(v=>x.includes(v.type)&&(!S||v.label.toLowerCase().includes(S.toLowerCase())||v.type.toLowerCase().includes(S.toLowerCase()))),w=new Set(Po.map(v=>v.type)),g=x.filter(v=>!w.has(v)&&(!S||v.toLowerCase().includes(S.toLowerCase()))),E=240,m=320,D=Math.min(o,window.innerWidth-E-8),O=Math.min(d,window.innerHeight-m-8);return e.jsxs("div",{ref:F,className:"fixed z-50 flex flex-col shadow-xl rounded-xl overflow-hidden",style:{left:D,top:O,width:E,maxHeight:m,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.16)"},children:[e.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid #E5E5E0",flexShrink:0},children:[e.jsx("div",{style:{fontSize:C.xs,fontWeight:600,color:"#374151",marginBottom:4},children:"Relationship Type"}),e.jsxs("div",{style:{fontSize:"10px",color:"#9CA3AF",marginBottom:4},children:[r," → ",s]}),e.jsx("input",{ref:j,value:S,onChange:v=>b(v.target.value),placeholder:"Search…",className:"w-full px-2 py-1 rounded focus:outline-none",style:{fontSize:C.xs,background:"#F7F7F5",border:"1px solid #E5E5E0",color:"#374151"}})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[y.map(v=>e.jsxs("button",{onClick:()=>u(v.type),className:"w-full flex items-center gap-2.5 px-3 py-1.5 text-left",style:{background:"none",border:"none",cursor:"pointer"},onMouseEnter:I=>{I.currentTarget.style.background="#F7F7F5"},onMouseLeave:I=>{I.currentTarget.style.background="none"},children:[e.jsx("div",{style:{width:10,height:10,borderRadius:"50%",flexShrink:0,background:je[v.type]??"#6B7280"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:C.xs,fontWeight:500,color:"#1a1a1a"},children:v.label}),e.jsx("div",{style:{fontSize:"10px",color:"#9CA3AF"},children:v.desc})]})]},v.type)),g.map(v=>e.jsxs("button",{onClick:()=>u(v),className:"w-full flex items-center gap-2.5 px-3 py-1.5 text-left",style:{background:"none",border:"none",cursor:"pointer"},onMouseEnter:I=>{I.currentTarget.style.background="#F7F7F5"},onMouseLeave:I=>{I.currentTarget.style.background="none"},children:[e.jsx("div",{style:{width:10,height:10,borderRadius:"50%",flexShrink:0,background:je[v]??"#6B7280"}}),e.jsx("span",{style:{fontSize:C.xs,color:"#1a1a1a"},children:v})]},v)),y.length===0&&g.length===0&&e.jsx("div",{className:"p-3 text-center",style:{color:"#9CA3AF",fontSize:C.xs},children:"No matching types"})]})]})}function Q({label:o,icon:d,danger:r,onClick:s}){return e.jsxs("button",{onClick:s,className:"w-full flex items-center gap-2 px-3 py-1.5 text-left",style:{background:"none",border:"none",cursor:"pointer",fontSize:C.xs},onMouseEnter:i=>{i.currentTarget.style.background=r?"#FEF2F2":"#F7F7F5"},onMouseLeave:i=>{i.currentTarget.style.background="none"},children:[d&&e.jsx("span",{style:{fontSize:"12px",width:16,textAlign:"center"},children:d}),e.jsx("span",{style:{color:r?"#DC2626":"#1a1a1a"},children:o})]})}function lt(){return e.jsx("div",{style:{height:1,background:"#E5E5E0",margin:"2px 0"}})}function Zo({x:o,y:d,onClose:r,children:s}){const i=l.useRef(null);l.useEffect(()=>{const S=j=>{i.current&&!i.current.contains(j.target)&&r()},b=j=>{j.key==="Escape"&&r()};return document.addEventListener("mousedown",S),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",S),document.removeEventListener("keydown",b)}},[r]);const u=210,h=Math.min(o,window.innerWidth-u-8),F=Math.min(d,window.innerHeight-200);return e.jsx("div",{ref:i,className:"fixed z-50 rounded-xl overflow-hidden py-1",style:{left:h,top:F,minWidth:u,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.14)"},children:s})}const Qs=[{label:"Layer default",value:""},{label:"Mint",value:"#E8F5E9"},{label:"Sky",value:"#E3F2FD"},{label:"Amber",value:"#FFF8E1"},{label:"Rose",value:"#FFF0F0"},{label:"Lavender",value:"#F3E5F5"},{label:"Peach",value:"#FBE9E7"}];function Js({x:o,y:d,nodeId:r,nodeKind:s,onClose:i,onEditName:u,onChangeColor:h,onRemoveFromDiagram:F,onDeleteFromModel:S,onLinkRisk:b,onLinkRequirement:j,onShowProperties:x,onFocusElement:y,onShowInCatalog:w,onShowRelMatrix:g,onOpenSource:E,onViewKindInOntology:m}){const[D,O]=l.useState(!1);return e.jsxs(Zo,{x:o,y:d,onClose:i,children:[e.jsxs("div",{className:"px-3 py-1.5",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"#9CA3AF"},children:s}),e.jsx("div",{style:{fontSize:"9px",color:"#D1D5DB",fontFamily:"monospace"},children:r})]}),x&&e.jsx(Q,{label:"Show Properties",icon:"ℹ",onClick:()=>{i(),x()}}),w&&e.jsx(Q,{label:"Show in Catalog",icon:"☰",onClick:()=>{i(),w()}}),y&&e.jsx(Q,{label:"Focus on Element",icon:"◎",onClick:()=>{i(),y()}}),g&&e.jsx(Q,{label:"Show Relationship Matrix",icon:"☷",onClick:()=>{i(),g()}}),m&&e.jsx(Q,{label:"View Kind in Ontology",icon:"⬡",onClick:()=>{i(),m()}}),E&&e.jsx(Q,{label:"Open Source File",icon:"⟨/⟩",onClick:()=>{i(),E()}}),(x||w||y||g||m||E)&&e.jsx(lt,{}),e.jsx(Q,{label:"Edit name",icon:"✏️",onClick:()=>{i(),u()}}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{className:"w-full flex items-center gap-2 px-3 py-1.5",style:{background:"none",border:"none",cursor:"pointer",fontSize:C.xs},onMouseEnter:v=>{O(!0),v.currentTarget.style.background="#F7F7F5"},onMouseLeave:v=>{v.currentTarget.style.background="none"},children:[e.jsx("span",{style:{fontSize:"12px",width:16,textAlign:"center"},children:"🎨"}),e.jsx("span",{style:{flex:1,textAlign:"left",color:"#1a1a1a"},children:"Change color"}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:"10px"},children:"▶"})]}),D&&e.jsx("div",{className:"absolute left-full top-0 rounded-xl overflow-hidden py-1",style:{background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",minWidth:160},onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1),children:Qs.map(v=>e.jsxs("button",{onClick:()=>{i(),h(v.value)},className:"w-full flex items-center gap-2.5 px-3 py-1.5",style:{background:"none",border:"none",cursor:"pointer"},onMouseEnter:I=>{I.currentTarget.style.background="#F7F7F5"},onMouseLeave:I=>{I.currentTarget.style.background="none"},children:[e.jsx("div",{style:{width:14,height:14,borderRadius:3,flexShrink:0,background:v.value||"#E5E5E0",border:"1px solid #D1D5DB"}}),e.jsx("span",{style:{fontSize:C.xs,color:"#374151"},children:v.label})]},v.value))})]}),e.jsx(lt,{}),b&&e.jsx(Q,{label:"Link Risk",icon:"⚠️",onClick:()=>{i(),b()}}),j&&e.jsx(Q,{label:"Link Requirement",icon:"📋",onClick:()=>{i(),j()}}),(b||j)&&e.jsx(lt,{}),e.jsx(Q,{label:"Remove from diagram",icon:"↩️",onClick:()=>{i(),F()}}),e.jsx(Q,{label:"Delete from model",icon:"🗑️",danger:!0,onClick:()=>{window.confirm(`Delete ${r} from the model? This cannot be undone.`)&&(i(),S())}})]})}const ei=[{label:"Auto",value:""},{label:"Red",value:"#EF4444"},{label:"Blue",value:"#3B82F6"},{label:"Green",value:"#10B981"},{label:"Orange",value:"#F59E0B"},{label:"Gray",value:"#6B7280"}];function ti({x:o,y:d,edgeId:r,relType:s,onClose:i,onChangeStyle:u,onChangeColor:h,onToggleLabel:F,onDelete:S}){return e.jsxs(Zo,{x:o,y:d,onClose:i,children:[e.jsxs("div",{className:"px-3 py-1.5",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"#9CA3AF"},children:s}),e.jsx("div",{style:{fontSize:"9px",color:"#D1D5DB",fontFamily:"monospace"},children:r})]}),e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-2",children:[e.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF",minWidth:40},children:"Style"}),["solid","dashed","dotted"].map(b=>e.jsx("button",{onClick:()=>{i(),u(b)},style:{fontSize:"10px",padding:"2px 8px",border:"1px solid #E5E5E0",borderRadius:4,cursor:"pointer",background:"#F7F7F5",color:"#374151"},children:b},b))]}),e.jsxs("div",{className:"px-3 py-1.5 flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{style:{fontSize:"10px",color:"#9CA3AF",minWidth:40,flexShrink:0},children:"Color"}),ei.map(b=>e.jsx("button",{onClick:()=>{i(),h(b.value)},title:b.label,style:{width:16,height:16,borderRadius:"50%",background:b.value||"#E5E5E0",border:"1px solid #D1D5DB",cursor:"pointer"}},b.value))]}),e.jsx(lt,{}),e.jsx(Q,{label:"Toggle label",icon:"🏷️",onClick:()=>{i(),F()}}),e.jsx(Q,{label:"Delete edge",icon:"🗑️",danger:!0,onClick:()=>{i(),S()}})]})}const oi=l.memo(function({id:d,data:r,selected:s}){const i=r,u=i.color??i.layerColor??"#E67E22",h=80,F=l.useCallback(S=>{var b;S.preventDefault(),(b=i.onContextMenu)==null||b.call(i,S,d)},[i,d]);return e.jsxs("div",{style:{width:h,height:h,position:"relative"},onContextMenu:F,children:[s&&e.jsx(ct,{minWidth:60,minHeight:60}),e.jsx("svg",{width:h,height:h,style:{position:"absolute",top:0,left:0},children:e.jsx("polygon",{points:`${h/2},4 ${h-4},${h/2} ${h/2},${h-4} 4,${h/2}`,fill:i.color?i.color+"44":"#FFF8E1",stroke:u,strokeWidth:s?2.5:1.5})}),e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:600,color:"#374151",textAlign:"center",padding:"4px 8px",pointerEvents:"none"},children:i.condition||i.label||"?"}),e.jsx(A,{type:"target",position:N.Top,style:{background:u,border:"2px solid #fff"}}),e.jsx(A,{type:"source",position:N.Right,style:{background:u,border:"2px solid #fff"},id:"right"}),e.jsx(A,{type:"source",position:N.Bottom,style:{background:u,border:"2px solid #fff"},id:"bottom"}),e.jsx(A,{type:"target",position:N.Left,style:{background:u,border:"2px solid #fff"}})]})}),ni=l.memo(function({id:d,data:r,selected:s}){const i=r,u=(i.orientation??"horizontal")==="horizontal",h=u?120:8,F=u?8:60,S=l.useCallback(b=>{var j;b.preventDefault(),(j=i.onContextMenu)==null||j.call(i,b,d)},[i,d]);return e.jsxs("div",{style:{width:h,height:F,background:"#1a1a1a",borderRadius:4,position:"relative"},title:i.nodeType==="join"?"Join (synchronization)":"Fork (parallel)",onContextMenu:S,children:[s&&e.jsx(ct,{minWidth:40,minHeight:6}),u?e.jsxs(e.Fragment,{children:[e.jsx(A,{type:"target",position:N.Left,style:{background:"#2DD4A8",border:"2px solid #fff",left:-1}}),e.jsx(A,{type:"source",position:N.Top,style:{background:"#2DD4A8",border:"2px solid #fff",top:-1},id:"top"}),e.jsx(A,{type:"source",position:N.Bottom,style:{background:"#2DD4A8",border:"2px solid #fff",bottom:-1},id:"bottom"}),e.jsx(A,{type:"source",position:N.Right,style:{background:"#2DD4A8",border:"2px solid #fff",right:-1},id:"right"})]}):e.jsxs(e.Fragment,{children:[e.jsx(A,{type:"target",position:N.Top,style:{background:"#2DD4A8",border:"2px solid #fff",top:-1}}),e.jsx(A,{type:"source",position:N.Left,style:{background:"#2DD4A8",border:"2px solid #fff",left:-1},id:"left"}),e.jsx(A,{type:"source",position:N.Right,style:{background:"#2DD4A8",border:"2px solid #fff",right:-1},id:"right"}),e.jsx(A,{type:"source",position:N.Bottom,style:{background:"#2DD4A8",border:"2px solid #fff",bottom:-1},id:"bottom"})]})]})}),si=l.memo(function({id:d,data:r}){const s=r,i=s.nodeType==="start",u=32,h=l.useCallback(F=>{var S;F.preventDefault(),(S=s.onContextMenu)==null||S.call(s,F,d)},[s,d]);return e.jsxs("div",{style:{width:u,height:u,position:"relative"},onContextMenu:h,children:[e.jsx("svg",{width:u,height:u,children:i?e.jsx("circle",{cx:u/2,cy:u/2,r:u/2-2,fill:"#1a1a1a"}):e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:u/2,cy:u/2,r:u/2-2,fill:"#1a1a1a"}),e.jsx("circle",{cx:u/2,cy:u/2,r:u/2-6,fill:"#FFFFFF"}),e.jsx("circle",{cx:u/2,cy:u/2,r:u/2-10,fill:"#1a1a1a"})]})}),i?e.jsx(A,{type:"source",position:N.Bottom,style:{background:"#1a1a1a",border:"2px solid #fff"}}):e.jsx(A,{type:"target",position:N.Top,style:{background:"#1a1a1a",border:"2px solid #fff"}})]})}),ii="#ECEBE6",dt="#1B3A4B",Ot="#5B6470",ri="0 1px 2px rgba(0,0,0,0.16), 0 0 0 0.5px rgba(0,0,0,0.05)",fe=(o,d)=>e.jsx("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{display:"block"},children:d}),ae={arrowRight:({size:o=16})=>fe(o,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M4 12h14"}),e.jsx("path",{d:"M13 6l6 6-6 6"})]})),arrowDown:({size:o=16})=>fe(o,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 4v14"}),e.jsx("path",{d:"M6 13l6 6 6-6"})]})),lanes:({size:o=16})=>fe(o,e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"5",width:"18",height:"3.4",rx:"1.3"}),e.jsx("rect",{x:"3",y:"10.3",width:"18",height:"3.4",rx:"1.3"}),e.jsx("rect",{x:"3",y:"15.6",width:"18",height:"3.4",rx:"1.3"})]})),grid:({size:o=16})=>fe(o,e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3.5",y:"3.5",width:"17",height:"17",rx:"2.5"}),e.jsx("path",{d:"M9.2 3.5v17M14.8 3.5v17M3.5 9.2h17M3.5 14.8h17"})]})),expand:({size:o=16})=>fe(o,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M15 4h5v5"}),e.jsx("path",{d:"M9 20H4v-5"}),e.jsx("path",{d:"M20 4l-7 7"}),e.jsx("path",{d:"M4 20l7-7"})]})),collapse:({size:o=16})=>fe(o,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M14 10h5"}),e.jsx("path",{d:"M19 10V5"}),e.jsx("path",{d:"M10 14H5"}),e.jsx("path",{d:"M5 14v5"}),e.jsx("path",{d:"M20 4l-6 6"}),e.jsx("path",{d:"M4 20l6-6"})]})),filter:({size:o=16})=>fe(o,e.jsx("path",{d:"M4 5h16l-6.2 7.4V19l-3.6 1.8v-8.4z"})),back:({size:o=16})=>fe(o,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M11 5l-6 7 6 7"}),e.jsx("path",{d:"M5 12h14"})]}))};function $e(){return e.jsx("span",{"aria-hidden":"true",style:{width:1,height:18,background:"#E2E1DB",margin:"0 3px",borderRadius:1}})}function _o({options:o,value:d,onChange:r}){return e.jsx("div",{role:"tablist",style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,background:ii,borderRadius:9},children:o.map(s=>{const i=s.value===d;return e.jsxs("button",{role:"tab","aria-selected":i,onClick:()=>r(s.value),title:s.title,className:"flex items-center gap-1.5 text-xs font-semibold",style:{padding:s.label?"3px 9px":"4px 7px",borderRadius:7,border:"none",cursor:"pointer",color:i?dt:Ot,background:i?"#FFFFFF":"transparent",boxShadow:i?ri:"none",transition:"background 140ms ease, color 140ms ease, box-shadow 140ms ease"},children:[s.icon,s.label&&e.jsx("span",{children:s.label})]},s.value)})})}function ai({children:o}){return e.jsx("div",{style:{display:"inline-flex",alignItems:"center",background:"#FFFFFF",border:"1px solid #E2E1DB",borderRadius:9,overflow:"hidden"},children:No.Children.toArray(o).map((d,r)=>e.jsxs(No.Fragment,{children:[r>0&&e.jsx("span",{"aria-hidden":"true",style:{width:1,alignSelf:"stretch",background:"#EDECE7"}}),d]},r))})}function Ho({icon:o,label:d,onClick:r,active:s=!1,title:i,ariaExpanded:u}){return e.jsxs("button",{onClick:r,title:i,"aria-pressed":s,"aria-expanded":u,className:"flex items-center gap-1.5 text-xs font-semibold",style:{padding:d?"5px 9px":"5px 7px",border:"none",cursor:"pointer",color:s?"#FFFFFF":Ot,background:s?dt:"transparent",transition:"background 140ms ease, color 140ms ease"},children:[o,d&&e.jsx("span",{children:d})]})}function Pe({icon:o,label:d,onClick:r,active:s=!1,title:i,badge:u}){return e.jsxs("button",{onClick:r,title:i,"aria-pressed":s,className:"flex items-center gap-1.5 text-xs font-semibold",style:{padding:u!=null||d!=null?"5px 9px":"5px 7px",borderRadius:9,border:`1px solid ${s?dt:"#E2E1DB"}`,cursor:"pointer",color:s?"#FFFFFF":Ot,background:s?dt:"#FFFFFF",transition:"background 140ms ease, color 140ms ease, border-color 140ms ease"},children:[o,d!=null&&e.jsx("span",{children:d}),u!=null&&e.jsx("span",{style:{fontSize:11,fontWeight:700,lineHeight:1,padding:"2px 5px",borderRadius:6,background:s?"rgba(255,255,255,0.22)":"#F0EFEA",color:s?"#FFFFFF":"#6B7280"},children:u})]})}const Ko="memo-layout-progress";if(typeof document<"u"&&!document.getElementById(Ko)){const o=document.createElement("style");o.id=Ko,o.textContent="@keyframes memo-layout-progress { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }",document.head.appendChild(o)}const li={background:"#F7F7F5"},di={padding:.08,maxZoom:2},ci={background:"#FFFFFF"},pi={hideAttribution:!0},ui=[20,20],xi=50,Vo=8e3,hi=90;function Yo(o,d){return new Promise((r,s)=>{const i=window.setTimeout(()=>s(new Error(`${d} layout exceeded ${Vo/1e3}s`)),Vo);o.then(u=>{window.clearTimeout(i),r(u)},u=>{window.clearTimeout(i),s(u)})})}function Go(o,d){const r=new Map(o.map(x=>[x.id,x])),s=new Map,i=x=>{const y=s.get(x);if(y)return y;const w=r.get(x),g=w.parentId?i(w.parentId):{x:0,y:0},E={x:g.x+w.position.x,y:g.y+w.position.y};return s.set(x,E),E},u=x=>{var y,w;return{width:Number(x.width??((y=x.style)==null?void 0:y.width)??0),height:Number(x.height??((w=x.style)==null?void 0:w.height)??0)}},h=d.flatMap(x=>{var D,O,v,I,$,z;const y=(X,T,le)=>{var U,Y;if(typeof T=="string"){const G=(((Y=(U=r.get(X))==null?void 0:U.data)==null?void 0:Y.ports)??[]).find(ge=>ge.id===T);if(G){const ge=G.size??20;return{x:G.x+ge/2,y:G.y+ge/2}}}return le},w=y(x.source,(D=x.data)==null?void 0:D.sourcePortId,(O=x.data)==null?void 0:O.sourceOffset),g=y(x.target,(v=x.data)==null?void 0:v.targetPortId,(I=x.data)==null?void 0:I.targetOffset);if(!w||!g||!r.has(x.source)||!r.has(x.target))return[];const E=i(x.source),m=i(x.target);return[{id:x.id,source:{x:E.x+w.x,y:E.y+w.y},target:{x:m.x+g.x,y:m.y+g.y},sourceNodeId:x.source,targetNodeId:x.target,sourceSide:($=x.data)==null?void 0:$.sourceSide,targetSide:(z=x.data)==null?void 0:z.targetSide}]});if(h.length===0)return d;const F=o.filter(x=>!x.data.isFrame).map(x=>({id:x.id,...i(x.id),...u(x)})),S=new Map(h.map(x=>[x.id,x])),b=h.filter(x=>{var y,w;return!((w=(y=d.find(g=>g.id===x.id))==null?void 0:y.data)!=null&&w.manualRoute)}),j=xs(b,F);return d.map(x=>{var w;const y=S.get(x.id);if(!y)return x;if((w=x.data)!=null&&w.manualRoute){const g=[...x.data.points??[]];if(g.length>=2)return g[0]=y.source,g[g.length-1]=y.target,{...x,data:{...x.data,points:g}}}return j.has(x.id)?{...x,data:{...x.data,points:j.get(x.id)}}:x})}function fi({x:o,y:d,onConfirm:r,onCancel:s}){const[i,u]=l.useState(""),h=l.useRef(null);l.useEffect(()=>{var b;(b=h.current)==null||b.focus()},[]),l.useEffect(()=>{const b=j=>{const x=document.getElementById("quick-create-popup");x&&!x.contains(j.target)&&s()};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[s]);const F=Math.min(o,window.innerWidth-220),S=Math.min(d,window.innerHeight-80);return e.jsxs("div",{id:"quick-create-popup",className:"fixed z-50 rounded-xl shadow-xl overflow-hidden",style:{left:F,top:S,width:200,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.14)"},children:[e.jsx("div",{className:"px-3 py-2",style:{borderBottom:"1px solid #E5E5E0",fontSize:C.xs,color:"#9CA3AF",fontWeight:600},children:"New Element"}),e.jsxs("div",{className:"px-2 py-2",children:[e.jsx("input",{ref:h,value:i,onChange:b=>u(b.target.value),placeholder:"Element name…",className:"w-full px-2 py-1.5 rounded focus:outline-none",style:{fontSize:C.xs,border:"1px solid #E5E5E0",background:"#F7F7F5",color:"#1a1a1a"},onKeyDown:b=>{b.key==="Enter"&&i.trim()&&(b.preventDefault(),r(i.trim())),b.key==="Escape"&&s()}}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("button",{onClick:()=>i.trim()&&r(i.trim()),style:{flex:1,fontSize:C.xs,padding:"4px 8px",background:"#2DD4A8",color:"#FFFFFF",border:"none",borderRadius:6,cursor:"pointer",fontWeight:600},children:"Create"}),e.jsx("button",{onClick:s,style:{fontSize:C.xs,padding:"4px 8px",background:"#F7F7F5",color:"#6B7280",border:"1px solid #E5E5E0",borderRadius:6,cursor:"pointer"},children:"Cancel"})]})]})]})}function Lt({color:o,glyph:d}){return e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:13,height:13,borderRadius:2,background:o+"22",border:`1.5px solid ${o}`,color:o,fontSize:9,fontWeight:800,lineHeight:1},children:d})}function gi(){var ho,fo,go,mo,yo,bo,Fo,wo,jo,vo;const o=M(t=>t.model),d=M(t=>t.selectedElementId),r=M(t=>t.selectedViewpointId),s=M(t=>t.selectedDiagramId),i=M(t=>t.hiddenLayers),u=M(t=>t.selectElement),h=M(t=>t.inspectElement),F=M(t=>t.inspectRelationship),S=M(t=>t.setActiveMode),b=M(t=>t.setActiveView),j=M(t=>t.setExplorerTab),x=M(t=>t.availableOntologies),y=M(t=>t.setSelectedOntologyKind),w=M(t=>t.diagramLayouts),g=M(t=>t.setNodeLayout),E=M(t=>t.mergeDiagramLayouts),m=M(t=>t.updateDiagramElementIds),{fitView:D,screenToFlowPosition:O,getViewport:v,setViewport:I}=zt(),[$,z]=$n([]),[X,T,le]=Pn([]),U=l.useRef([]),Y=l.useRef([]),G=l.useRef(o),ge=l.useRef(s),pt=l.useRef(null),ut=l.useRef(null),xt=l.useRef(null),be=l.useRef(0);l.useEffect(()=>{U.current=$},[$]),l.useEffect(()=>{Y.current=X},[X]);const _e=l.useCallback(t=>{U.current=t,ut.current===null&&(ut.current=requestAnimationFrame(()=>{ut.current=null;const n=U.current,a=Go(n,Y.current);Y.current=a,z(n),T(a)}))},[z,T]),[te,He]=l.useState(!1),[Wt,Fe]=l.useState(0),[$t,ht]=l.useState(null),[Pt,Qo]=l.useState(0),[Jo,ft]=l.useState(0),[ve,gt]=l.useState(!0),[en,_t]=l.useState(!0),[Ht,tn]=l.useState(!0),[mt,on]=l.useState("horizontal"),[Ke,Kt]=l.useState("allocation"),[yt,Vt]=l.useState("all"),[Yt,nn]=l.useState(!1),[de,sn]=l.useState(new Set(["control","data","energy","material"])),[J,Ee]=l.useState(null),[ce,Ve]=l.useState(null),[q,ke]=l.useState(null),[ie,Ye]=l.useState(null),[Se,Gt]=l.useState(null),[Ge,rn]=l.useState(2),[Xe,Xt]=l.useState(null),Ce=l.useRef([]),bt=l.useRef([]),qt=l.useCallback(t=>{Ce.current.push(t),Ce.current.length>xi&&Ce.current.shift(),bt.current=[]},[]),f=Un(o,s),Ie=f?Do[f.diagramType]:null,qe=!!((ho=f==null?void 0:f.properties)!=null&&ho.layoutStyle),pe=((fo=f==null?void 0:f.properties)==null?void 0:fo.layoutStyle)==="fbs",me=s?w[s]:void 0,ue=ts(me),re=((go=me==null?void 0:me.canvas)==null?void 0:go.autoLayout)!==!1,xe=((mo=me==null?void 0:me.canvas)==null?void 0:mo.flowAnimation)===!0,oe=l.useCallback(()=>{var n;if(!s)return;const t=M.getState().diagramLayouts[s]??{nodes:{},edges:{}};((n=t.canvas)==null?void 0:n.autoLayout)!==!1&&E({[s]:{...t,canvas:{...t.canvas,autoLayout:!1}}})},[s,E]);l.useEffect(()=>{if(!s||re||te||$.length===0||Wt===0)return;const t=window.setTimeout(()=>{const n=M.getState().diagramLayouts[s]??{nodes:{},edges:{}},a=v(),p={nodes:Object.fromEntries($.map(c=>[c.id,{...n.nodes[c.id]??{},x:c.position.x,y:c.position.y,...c.width?{width:c.width}:{},...c.height?{height:c.height}:{},ports:Object.fromEntries((c.data.ports??[]).map(k=>[k.id,{x:k.x,y:k.y,side:k.side}]))}])),edges:Object.fromEntries(X.map(c=>{var k,B,R,P,H,W;return[c.id,{...(()=>{var _;const{points:V,...K}=((_=n.edges)==null?void 0:_[c.id])??{};return K})(),...(k=c.data)!=null&&k.manualRoute&&((R=(B=c.data)==null?void 0:B.points)!=null&&R.length)?{points:(P=c.data)==null?void 0:P.points,source:c.source,target:c.target,sourcePortId:(H=c.data)==null?void 0:H.sourcePortId,targetPortId:(W=c.data)==null?void 0:W.targetPortId}:{}}]})),canvas:{...n.canvas,zoom:a.zoom,pan:{x:a.x,y:a.y},autoLayout:!1}};E({[s]:p}),We(s,p),Fe(0)},350);return()=>window.clearTimeout(t)},[s,re,te,Wt,$,X,v,E]);const L=f?f.viewKind??(Ie==null?void 0:Ie.viewKind)??"general":void 0,Ne=L==="interconnection"?.72:.1,De=L?Ro[L]:null,ye=L==="general"&&!qe&&!pe,[he,Ut]=l.useState("graph"),Zt=l.useMemo(()=>L==="statetransition"?["compound-graph"]:["flat-graph"],[L]),Ft=l.useMemo(()=>vs(Zt).filter(t=>t.mode==="automatic"),[Zt]),an=pe||ye&&he==="graph"||L==="interconnection"||L==="actionflow"||L==="statetransition",wt=(yo=f==null?void 0:f.properties)==null?void 0:yo.modes,ln=l.useMemo(()=>{if(!wt)return Nt;const t=new Set(wt.split(",").map(a=>a.trim())),n=Nt.filter(a=>t.has(a));return n.length?n:Nt},[wt]),[Ae,Qt]=l.useState(!0),Jt=l.useMemo(()=>{if(!o||!f)return[];const t=new Set(f.elementIds),n=Object.values(o.elements).filter(a=>t.has(a.id)&&a.allocatedTo).map(a=>a.allocatedTo);return os(n,o)},[o,f]),dn=l.useMemo(()=>{if(!o||!f)return"Activity Diagram";const t=Zn(f);return Do[t].fullName},[o,f]),cn=l.useMemo(()=>{if(!o||!f)return!1;const t=new Set(f.elementIds);return Object.values(o.elements).some(n=>t.has(n.id)&&!!(n.attributes.stage||n.attributes.phase))},[o,f]),Ue=l.useMemo(()=>{if(!o||!f||L!=="actionflow")return[];const t=(f.elementIds??[]).map(n=>o.elements[n]).filter(n=>!!n&&n.construct==="action");return ns(t,o)},[o,f,L]),[Re,pn]=l.useState("containment"),[Te,Ze]=l.useState(new Set),[eo,Le]=l.useState(new Set),[we,Qe]=l.useState(null),[Be,to]=l.useState("all"),[oo,no]=l.useState(!1),[so,ze]=l.useState(new Set),[Me,jt]=l.useState(null),[Je,un]=l.useState(new Map),ne=l.useRef(new Map),vt=l.useMemo(()=>{if(!o||!we)return[];const t=new Map;for(const c of o.relationships)ss.has(c.type)&&!t.has(c.targetId)&&t.set(c.targetId,c.sourceId);const n=[we],a=new Set(n);let p=we;for(;t.has(p);){const c=t.get(p);if(a.has(c))break;n.unshift(c),a.add(c),p=c}return n},[o,we]);l.useEffect(()=>{var n,a;Fe(0),Ut(is(f==null?void 0:f.properties)),Qt(!0),Kt("allocation"),Vt("all");const t=(a=(n=f==null?void 0:f.properties)==null?void 0:n.styleHint)!=null&&a.startsWith("expanded:")?f.properties.styleHint.slice(9).split(",").map(p=>p.trim()).filter(Boolean):[];Ze(new Set(t)),Le(new Set),Qe(null),to("all"),no(!1),ze(new Set),jt(null),ne.current.clear()},[s,(bo=f==null?void 0:f.properties)==null?void 0:bo.layoutHint,(Fo=f==null?void 0:f.properties)==null?void 0:Fo.styleHint]);const xn=l.useMemo(()=>({decompositionNode:Ss,interconnectionNode:Rs,actionFlowNode:Ws,actionFlowLane:Ps,stateNode:Hs,seqLifeline:Vs,seqSection:Gs,seqOccurrence:qs,diagramNode:Us,decisionNode:oi,forkNode:ni,startEndNode:si}),[]),hn=l.useMemo(()=>({interconnectionEdge:Ms}),[]),fn=l.useCallback(t=>{var n,a;return((n=t.data)==null?void 0:n.color)||((a=t.data)==null?void 0:a.layerColor)||"#ccc"},[]),Z=l.useMemo(()=>{const t=(f==null?void 0:f.viewpointId)==="__model"?null:(f==null?void 0:f.viewpointId)||r,n=t&&(o==null?void 0:o.viewpoints),a=i.size>0,p=f!=null&&f.elementIds?new Set(f.elementIds):void 0;if(!n&&!a&&!p)return;const c=n?o.viewpoints.find(R=>R.id===t):void 0,k=c?new Set(c.visibleKinds):void 0,B=c?new Set(c.visibleLayers):void 0;return R=>i.has(R.layer)?!1:p?p.has(R.id):k&&B?k.has(R.kind)||B.has(R.layer):!0},[r,f,o==null?void 0:o.viewpoints,i]),et=l.useMemo(()=>!o||!f||f.diagramType!=="bdd"?null:rs(Lo(o,Z)),[o,f,Z]),io=l.useCallback(()=>{if(o)return pe?as(o):ye?Lo(o,Z):ls(o)},[o,pe,ye,Z]),Oe=l.useCallback(t=>{Ze(n=>{const a=new Set(n);return a.has(t)?a.delete(t):a.add(t),a})},[]),ro=l.useCallback(t=>{Le(n=>{const a=new Set(n);return a.has(t)?a.delete(t):a.add(t),a})},[]),ao=l.useCallback(t=>{ze(n=>{const a=new Set(n);return a.has(t)?a.delete(t):a.add(t),a})},[]),tt=l.useCallback(t=>{ne.current.clear(),un(n=>{const a=new Map(n),p=a.get(t)||"vertical";return a.set(t,p==="vertical"?"horizontal":"vertical"),a})},[]),Et=l.useCallback(()=>{const t=io();if(!t)return;const n=new Set,a=p=>{n.add(p);for(const c of t.childrenMap.get(p)||[])t.elements.has(c)&&a(c)};for(const p of t.roots)t.elements.has(p)&&a(p);Ze(n)},[io]),kt=l.useCallback(()=>Ze(new Set),[]),St=l.useCallback(()=>{ne.current.clear(),ft(t=>t+1)},[]),lo=l.useCallback(t=>t.map(n=>{if(n.type!=="diagramNode")return n;const a=o==null?void 0:o.elements[n.id];return{...n,data:{...n.data,onContextMenu:(p,c)=>{ke({x:p.clientX,y:p.clientY,nodeId:c,nodeKind:n.data.kind??""})},onInlineEdit:(p,c)=>{if(!a)return;const k={...a,name:c};Ao(k)}}}}),[o]),co=l.useCallback((t,n)=>{const a=t.map(c=>{const k=n.nodes[c.id];return k?{...c,position:{x:k.x,y:k.y},...k.width?{width:k.width}:{},...k.height?{height:k.height}:{},data:{...c.data,bgColor:k.color||void 0,...k.ports?{ports:(c.data.ports??[]).map(B=>{var R;return{...B,...((R=k.ports)==null?void 0:R[B.id])??{}}})}:{}}}:c}),p=new Map(a.map(c=>[c.id,c]));return a.map(c=>{if(c.type!=="actionFlowLane")return c;const k=c.data,B=(k.memberIds??[]).map(K=>p.get(K)).filter(Boolean);if(B.length===0)return c;const R=Math.min(...B.map(K=>K.position.x)),P=Math.min(...B.map(K=>K.position.y)),H=Math.max(...B.map(K=>{var _;return K.position.x+Number(K.width??((_=K.style)==null?void 0:_.width)??180)})),W=Math.max(...B.map(K=>{var _;return K.position.y+Number(K.height??((_=K.style)==null?void 0:_.height)??96)})),V=k.orientation==="column";return{...c,position:{x:V?R-36:R-120,y:V?P-32:P-36},style:{...c.style,width:H-R+(V?72:156),height:W-P+(V?68:72)}}})},[]),po=l.useCallback((t,n,a)=>{be.current=Date.now()+250,oe(),Fe(k=>k+1);const p=Y.current.map(k=>{var W,V;if(!(((W=k.data)==null?void 0:W.sourcePortId)===n||((V=k.data)==null?void 0:V.targetPortId)===n))return k;const{points:R,manualRoute:P,...H}=k.data??{};return{...k,data:H}});Y.current=p;const c=U.current.map(k=>k.id!==t?k:{...k,data:{...k.data,ports:(k.data.ports??[]).map(B=>B.id===n?{...B,y:a}:B)}});_e(c)},[_e,oe]),uo=l.useCallback((t,n)=>{be.current=Date.now()+250,oe(),Fe(a=>a+1),T(a=>{const p=a.map(c=>c.id===t?{...c,data:{...c.data,points:n,manualRoute:!0}}:c);return Y.current=p,p})},[oe,T]);l.useEffect(()=>{if(!o)return;const t=G.current!==o&&ge.current===s;if(pt.current=t?v():null,G.current=o,ge.current=s,L==="grid"||L==="browser"||L==="geometry")return;let n=!1;const a=({nodes:R,edges:P},H=!0)=>{if(n)return;const W=s?M.getState().diagramLayouts[s]:void 0,V=W&&Object.keys(W.nodes).length>0?co(R,W):R,K=P.map(_=>{var Eo,ko,So;const se=(Eo=W==null?void 0:W.edges)==null?void 0:Eo[_.id],ot=!(se!=null&&se.source)||se.source===_.source&&se.target===_.target&&se.sourcePortId===((ko=_.data)==null?void 0:ko.sourcePortId)&&se.targetPortId===((So=_.data)==null?void 0:So.targetPortId)?se==null?void 0:se.points:void 0;return{..._,data:{..._.data,...ot!=null&&ot.length?{points:ot,manualRoute:!0}:{},flowAnimation:xe,onRouteChange:Ct=>uo(_.id,Ct),onSelect:Ct=>{Ct.stopPropagation(),!(Date.now()<be.current)&&(T(It=>It.map(Co=>({...Co,selected:Co.id===_.id}))),o.relationships.some(It=>It.id===_.id)&&F(_.id))}}}});z(H?lo(V):V),T(Go(V,K)),He(!1),Qo(_=>_+1)},p=R=>P=>{n||(console.error(`${R} layout error:`,P),He(!1),ht(`${R} layout could not be completed. Try resetting the layout or reducing the visible hierarchy.`))},c=(R,P,H=!0)=>{He(!0),ht(null),Yo(P,R).then(W=>a(W,H)).catch(p(R))},k=()=>{if(pe)c("FBS",hs(o,{expandedNodes:Te,nodeDirections:Je,callbacks:{onToggleExpand:Oe,onToggleDirection:tt},layoutProviderId:ue}));else if(qe)Re==="decomposition"?c("Decomposition",fs(o,{expandedNodes:Te,nodeDirections:Je,callbacks:{onToggleExpand:Oe,onToggleDirection:tt},positionCache:ne.current})):a(gs(o,{expandedNodes:Te,callbacks:{onToggleExpand:Oe}}));else if(L==="interconnection")c("Interconnection",ms(o,{viewpointFilter:Z,relationshipTypes:f==null?void 0:f.relationshipTypes,collapsedNodes:eo,onToggleCollapse:ro,focusId:we??void 0,portDisplay:Be,onPortMove:po,layoutProviderId:ue}),!1);else if(L==="actionflow")c("Action flow",ys(o,{viewpointFilter:Z,swimlanes:Ae,laneGrouping:Ke,displayLevel:yt,expandedActionIds:so,onToggleAction:ao,focusActionId:Me??void 0,visibleFlowKinds:de,direction:mt,layoutProviderId:ue}),!1);else if(L==="statetransition")c("State transition",bs(o,{viewpointFilter:Z,layoutProviderId:ue}),!1);else if(L==="sequence")a(Fs(o,{viewpointFilter:Z}),!1);else if(ye&&he!=="graph")c("General",ws(o,{mode:he,viewpointFilter:Z,expandedNodes:Te,nodeDirections:Je,callbacks:{onToggleExpand:Oe,onToggleDirection:tt},positionCache:ne.current,layoutProviderId:ue}));else{const R=f==null?void 0:f.relationshipTypes,P=ye;He(!0),ht(null),Yo(js(o,{viewpointFilter:Z,relationshipTypes:R,compartments:P,layoutProviderId:ue}),"Standard").then(({nodes:H,edges:W})=>{a({nodes:H,edges:W})}).catch(p("Standard"))}},B=window.setTimeout(k,hi);return()=>{n=!0,window.clearTimeout(B)}},[o,Z,qe,pe,Re,L,ye,he,Ae,Jo,f==null?void 0:f.relationshipTypes,ue,Te,eo,we,Be,so,Me,de,mt,Ke,yt,Je,Oe,ro,ao,tt,s,co,lo,po,uo,F,v]),l.useEffect(()=>{if(Pt===0)return;const t=setTimeout(()=>{var p;const n=pt.current;if(pt.current=null,n){I(n);return}const a=s?(p=M.getState().diagramLayouts[s])==null?void 0:p.canvas:void 0;(a==null?void 0:a.zoom)!==void 0&&a.pan?I({x:a.pan.x,y:a.pan.y,zoom:a.zoom},{duration:300}):D({padding:.08,minZoom:Ne,maxZoom:2,duration:500})},200);return()=>clearTimeout(t)},[Pt,s,D,Ne,I]),l.useEffect(()=>{z(t=>t.map(n=>{const a=n.type==="actionFlowLane"?n.data.inspectElementId:void 0,p=!!d&&(n.id===d||a===d);return{...n,selected:p,style:{...n.style,boxShadow:p?"0 0 0 2px #2DD4A8, 0 4px 12px rgba(45, 212, 168, 0.3)":void 0,opacity:d?p?1:.5:1}}}))},[d,z]),l.useEffect(()=>{if(!Se||!o)return;const t=Es(o,Se,"both",Ge),n=new Set(t.nodes.map(a=>a.elementId));n.add(Se),z(a=>a.map(p=>({...p,style:{...p.style,opacity:n.has(p.id)?1:.08,pointerEvents:n.has(p.id)?"all":"none"}}))),T(a=>a.map(p=>({...p,style:{...p.style,opacity:n.has(p.source)&&n.has(p.target)?1:.05}})))},[Se,Ge,o,z,T]),l.useEffect(()=>{if(!Xe)return;const t=setTimeout(()=>Xt(null),2500);return()=>clearTimeout(t)},[Xe]),l.useEffect(()=>{const t=n=>{const a=n.target;if(!(a.tagName==="INPUT"||a.tagName==="TEXTAREA")){if((n.metaKey||n.ctrlKey)&&n.key==="z"&&!n.shiftKey){n.preventDefault();const p=Ce.current.pop();p&&(p.undo(),bt.current.push(p))}if((n.metaKey||n.ctrlKey)&&(n.key==="Z"||n.key==="z"&&n.shiftKey)){n.preventDefault();const p=bt.current.pop();p&&(p.do(),Ce.current.push(p))}n.key==="g"&&(n.metaKey||n.ctrlKey)&&n.shiftKey&&(n.preventDefault(),_t(p=>!p)),n.key==="0"&&(n.metaKey||n.ctrlKey)&&(n.preventDefault(),D({padding:.08,minZoom:Ne,maxZoom:2,duration:400}))}};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[D,Ne]);const gn=l.useCallback(t=>{t.preventDefault(),t.dataTransfer.dropEffect="copy"},[]),mn=l.useCallback(t=>{t.preventDefault();const n=t.dataTransfer.getData("application/memo-kind");if(n)try{const a=JSON.parse(n),p=O({x:t.clientX,y:t.clientY});Ee({x:t.clientX,y:t.clientY,flowX:p.x,flowY:p.y,kind:a.kind,layer:a.layer,construct:a.construct})}catch{}},[O]),yn=l.useCallback(t=>{const n=O({x:t.clientX,y:t.clientY});Ee({x:t.clientX,y:t.clientY,flowX:n.x,flowY:n.y})},[O]),bn=l.useCallback(t=>{if(!J||!s){Ee(null);return}const n=J.kind??"Part",a=J.layer??"logical",p=J.construct??"part",c=Xo[a]??"#6B7280",k=`_new_${Date.now()}`,B={id:k,type:"diagramNode",position:{x:J.flowX,y:J.flowY},data:{label:t,kind:n,layer:a,construct:p,color:c,isNew:!0,onContextMenu:(W,V)=>{ke({x:W.clientX,y:W.clientY,nodeId:V,nodeKind:n})},onInlineEdit:(W,V)=>{Ao({id:k,name:V,kind:n,construct:p,layer:a})}}};z(W=>[...W,B]),Qn({name:t,kind:n,construct:p,attributes:{_layer:a}});const R=(f==null?void 0:f.elementIds)??[];m(s,[...R,k]);const P=s,H={nodes:{...(w[P]??{}).nodes??{},[k]:{x:J.flowX,y:J.flowY}},edges:(w[P]??{}).edges??{}};E({[P]:H}),We(P,H),Ee(null)},[J,s,f,w,E,m,z]),Fn=l.useCallback(()=>{ke(null),Ye(null)},[]),wn=l.useCallback((t,n)=>{n!=null&&n.isValid},[]),jn=l.useCallback(t=>{const{source:n,target:a}=t;if(!n||!a)return;const p=o==null?void 0:o.elements[n],c=o==null?void 0:o.elements[a];Ve({x:window.innerWidth/2-120,y:window.innerHeight/2-160,sourceId:n,targetId:a,sourceKind:(p==null?void 0:p.kind)??"",targetKind:(c==null?void 0:c.kind)??""})},[o]),vn=l.useCallback(t=>{if(!ce||!s){Ve(null);return}const{sourceId:n,targetId:a}=ce,p=je[t]??"#6B7280",k={id:`e_${n}_${a}_${t}_${Date.now()}`,source:n,target:a,label:t,type:"default",style:{stroke:p,strokeWidth:2},labelStyle:{fontSize:"10px",fill:"#374151"},labelBgStyle:{fill:"#FFFFFF",fillOpacity:.9},labelBgPadding:[4,2],labelBgBorderRadius:4,markerEnd:{type:"arrowclosed",color:p}};T(B=>_n(k,B)),Jn(n,a,t),Ve(null)},[ce,s,T]),En=l.useCallback((t,n)=>{xt.current={id:n.id,x:n.position.x,y:n.position.y}},[]),kn=l.useCallback((t,n)=>{const a=xt.current;if(xt.current=null,(a==null?void 0:a.id)===n.id&&Math.hypot(n.position.x-a.x,n.position.y-a.y)>2&&(be.current=Date.now()+250,Fe(B=>B+1)),!s)return;oe();const{x:p,y:c}=n.position,k=ne.current.get(n.id);if(ne.current.set(n.id,{x:p,y:c}),g(s,n.id,{x:p,y:c}),k){const B=n.id,R=s;qt({do:()=>g(R,B,{x:p,y:c}),undo:()=>{g(R,B,k),z(P=>P.map(H=>H.id===B?{...H,position:k}:H))}})}},[s,g,qt,z,oe]),Sn=l.useCallback(t=>{t.some(n=>n.type==="position")&&oe(),t.some(n=>n.type==="dimensions"&&n.resizing)&&(oe(),Fe(n=>n+1)),_e(Hn(t,U.current))},[_e,oe]),Cn=l.useCallback((t,n)=>{},[]),In=l.useCallback((t,n)=>{t.preventDefault(),Ye({x:t.clientX,y:t.clientY,edgeId:n.id,relType:String(n.label??"edge")})},[]),Nn=l.useCallback((t,n)=>{if(Date.now()<be.current)return;const a=n.type==="actionFlowLane"?n.data.inspectElementId:void 0;!a&&(n.id.startsWith("__")||n.id.includes("__start")||n.id.includes("__done"))||(h(a??n.id),s&&b({type:"diagram",diagramId:s}))},[h,s,b]),Dn=l.useCallback((t,n)=>{var a;if((a=t==null?void 0:t.stopPropagation)==null||a.call(t),L==="actionflow"){if(!Object.values((o==null?void 0:o.elements)??{}).some(c=>c.parentAction===n.id))return;jt(n.id),ze(new Set),h(null);return}if(L==="interconnection"){if(!!!n.data.isContainer){h(n.id);return}Qe(n.id),Le(new Set),h(null)}},[L,o==null?void 0:o.elements,h]),An=l.useCallback(()=>{u(null),F(null),ke(null),Ye(null),z(t=>t.map(n=>({...n,style:{...n.style,opacity:1,boxShadow:void 0}}))),T(t=>t.map(n=>n.selected?{...n,selected:!1}:n))},[u,F,z,T]),Rn=l.useCallback((t,n)=>{var a;(a=t==null?void 0:t.stopPropagation)==null||a.call(t),!(Date.now()<be.current)&&(T(p=>p.map(c=>({...c,selected:c.id===n.id}))),o!=null&&o.relationships.some(p=>p.id===n.id)?F(n.id):o!=null&&o.elements[n.id]&&h(n.id))},[o,h,F,T]),Tn=l.useCallback((t,n)=>{var a;s&&(g(s,t,{...((a=w[s])==null?void 0:a.nodes[t])??{x:0,y:0},color:n||void 0}),z(p=>p.map(c=>c.id===t?{...c,data:{...c.data,bgColor:n||void 0}}:c)))},[s,w,g,z]),xo=l.useCallback(t=>{if(!s||!f)return;const n=(f.elementIds??[]).filter(a=>a!==t);m(s,n),z(a=>a.filter(p=>p.id!==t))},[s,f,m,z]),Ln=l.useCallback((t,n)=>{const a=n==="dashed"?"6 3":n==="dotted"?"2 3":void 0;T(p=>p.map(c=>c.id===t?{...c,style:{...c.style,strokeDasharray:a}}:c))},[T]),Bn=l.useCallback((t,n)=>{T(a=>a.map(p=>p.id===t?{...p,style:{...p.style,stroke:n||(je[String(p.label??"")]??"#6B7280")}}:p))},[T]),zn=l.useCallback(t=>{T(n=>n.map(a=>a.id===t?{...a,label:a.label?"":t.split("_")[3]??""}:a))},[T]);if(f&&o&&L==="grid")return e.jsx(ds,{diagram:f,model:o,viewpointFilter:Z});if(f&&o&&L==="browser")return e.jsx(cs,{diagram:f,model:o,viewpointFilter:Z});if(f&&L==="geometry"){const t=Ro.geometry;return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"text-center",style:{maxWidth:"380px"},children:[e.jsx("span",{className:"inline-block px-2 py-0.5 rounded font-semibold",style:{background:t.color+"20",color:t.color,fontSize:C.badge,marginBottom:"12px"},children:t.label}),e.jsx("h3",{style:{fontSize:C.lg,fontWeight:600,color:"#374151",marginBottom:"8px"},children:f.name}),e.jsx("p",{style:{fontSize:C.md,color:"#9CA3AF",lineHeight:1.6},children:"Geometry View rendering is deferred (ADR-1-19): the ontology carries no spatial data to draw. This view is recognized and validated, but has no renderer yet."})]})})}return!f&&$.length===0&&!te?e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!ve&&e.jsx(Tt,{collapsed:ve,onToggleCollapse:()=>gt(!0)}),ve&&e.jsx(Tt,{collapsed:!0,onToggleCollapse:()=>gt(!1)}),e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"text-center",style:{maxWidth:"320px"},children:[e.jsx("div",{style:{fontSize:"40px",marginBottom:"16px",opacity:.4},children:"📊"}),e.jsx("h3",{style:{fontSize:C.lg,fontWeight:600,color:"#374151",marginBottom:"8px"},children:"Select a Diagram"}),e.jsx("p",{style:{fontSize:C.md,color:"#9CA3AF",lineHeight:1.6},children:"Choose a diagram from the sidebar or drag elements from the palette."})]})})]}):e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx(Tt,{collapsed:ve,onToggleCollapse:()=>gt(!ve),elementIds:f==null?void 0:f.elementIds,eligibleKinds:f!=null&&f.viewpointId&&(o!=null&&o.viewpoints)?new Set(((wo=o.viewpoints.find(t=>t.id===f.viewpointId))==null?void 0:wo.visibleKinds)??[]):void 0}),e.jsxs("div",{className:"flex-1 relative",onDragOver:gn,onDrop:mn,onDoubleClick:yn,children:[f&&e.jsxs("div",{className:"absolute top-3 left-3 z-10 flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs relative",style:{background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:[De&&e.jsx("span",{className:"px-1.5 py-0.5 rounded font-semibold",style:{background:De.color+"20",color:De.color,fontSize:C.badge},title:`${De.fullName}${Ie?` · ${Ie.fullName}`:""}`,children:L==="actionflow"?dn:De.label}),e.jsx("span",{className:"font-medium",style:{color:"#1a1a1a"},children:f.name}),f.auto&&e.jsx("span",{style:{color:"#9CA3AF",fontSize:"9px"},children:"auto"}),e.jsx($e,{}),e.jsx(Pe,{icon:e.jsx(ae.grid,{}),label:"Grid",active:Ht,onClick:()=>{tn(t=>{const n=!t;return _t(n),n})},title:"Show or hide the canvas grid and snapping (⌘⇧G)"}),pe&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsx("button",{onClick:Et,className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#374151",border:"1px solid #E5E5E0"},children:"Expand All"}),e.jsx("button",{onClick:kt,className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#374151",border:"1px solid #E5E5E0"},children:"Collapse All"})]}),L==="actionflow"&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{icon:e.jsx(ae.lanes,{}),active:Ae,onClick:()=>Qt(t=>!t),title:"Toggle allocation swimlanes"}),Ae&&cn&&e.jsx(Pe,{icon:e.jsx(ae.lanes,{}),label:"Stage",active:Ke==="stage",onClick:()=>Kt(t=>t==="stage"?"allocation":"stage"),title:"Group this flow by its modeled stages"}),Ae&&Ke==="allocation"&&Jt.length>0&&e.jsxs("select",{"aria-label":"Display hierarchy level",title:"Display responsibility lanes at a hierarchy level; the SysML allocation is unchanged",value:yt,onChange:t=>Vt(t.target.value==="all"?"all":Number(t.target.value)),className:"text-xs font-semibold rounded-lg px-2 py-1",style:{color:"#5B6470",background:"#FFFFFF",border:"1px solid #E2E1DB"},children:[e.jsx("option",{value:"all",children:"All levels"}),Jt.map(t=>e.jsxs("option",{value:t,children:["L",t]},t))]}),e.jsx($e,{}),e.jsx(_o,{value:mt,onChange:on,options:[{value:"horizontal",icon:e.jsx(ae.arrowRight,{}),title:"Left-to-right flow"},{value:"vertical",icon:e.jsx(ae.arrowDown,{}),title:"Top-to-bottom flow"}]}),e.jsx($e,{}),e.jsxs(ai,{children:[e.jsx(Ho,{icon:e.jsx(ae.expand,{}),title:"Expand all sub-actions",onClick:()=>ze(new Set(Object.values((o==null?void 0:o.elements)??{}).map(t=>t.parentAction).filter(t=>!!t)))}),e.jsx(Ho,{icon:e.jsx(ae.collapse,{}),title:"Collapse all sub-actions",onClick:()=>ze(new Set)})]}),e.jsx($e,{}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Pe,{icon:e.jsx(ae.filter,{}),active:Yt,badge:`${de.size}/4`,onClick:()=>nn(t=>!t),title:"Choose which modeled connection categories are visible"}),Yt&&e.jsxs("div",{className:"absolute top-full right-0 mt-2 p-3 rounded-lg",style:{width:264,background:"#FFFFFF",border:"1px solid #D1D5DB",boxShadow:"0 8px 24px rgba(0,0,0,0.14)",zIndex:30},children:[e.jsx("div",{style:{color:"#1F2937",fontWeight:700,fontSize:C.xs},children:"Show connection categories"}),e.jsx("div",{style:{color:"#6B7280",fontSize:C.xs,lineHeight:1.4,marginTop:3,marginBottom:8},children:"Changes this diagram view only; the SysML model is not modified."}),["control","data","energy","material"].map(t=>{const n=de.has(t),a=t==="control"?"#4B5563":t==="data"?"#3498DB":t==="energy"?"#D97706":"#16A34A";return e.jsxs("button",{role:"switch","aria-checked":n,onClick:()=>sn(p=>{const c=new Set(p);return c.has(t)?c.delete(t):c.add(t),c}),className:"w-full flex items-center justify-between px-1 py-1.5 rounded",style:{color:"#374151",textTransform:"capitalize"},title:`${n?"Hide":"Show"} ${t} connections`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:a}}),t]}),e.jsx("span",{"aria-hidden":"true",style:{width:32,height:18,borderRadius:9,background:n?"#2563EB":"#D1D5DB",padding:2,transition:"background 160ms ease"},children:e.jsx("span",{style:{display:"block",width:14,height:14,borderRadius:"50%",background:"#FFFFFF",boxShadow:"0 1px 2px rgba(0,0,0,0.22)",transform:n?"translateX(14px)":"translateX(0)",transition:"transform 160ms ease"}})})]},t)})]})]}),Me&&e.jsxs(e.Fragment,{children:[e.jsx($e,{}),e.jsx(Pe,{icon:e.jsx(ae.back,{}),label:"Parent",onClick:()=>jt(null),title:"Return to the parent action flow"}),e.jsx("span",{style:{color:"#6B7280",fontSize:C.xs},children:((jo=o==null?void 0:o.elements[Me])==null?void 0:jo.name)??Me})]})]}),L==="interconnection"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsx("button",{onClick:()=>Le(new Set),className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#374151",border:"1px solid #E5E5E0"},children:"Expand All"}),e.jsx("button",{onClick:()=>Le(new Set((o==null?void 0:o.relationships.filter(t=>["composes","composedof","aggregation","decomposedby"].includes(t.type.toLowerCase())).map(t=>t.sourceId))??[])),className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#374151",border:"1px solid #E5E5E0"},children:"Collapse All"}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:C.xs,fontWeight:600},children:"Ports"}),e.jsx(_o,{value:Be,onChange:to,options:[{value:"all",label:"Nested",title:"Show ports and their nested ports"},{value:"ports",label:"Top",title:"Show top-level ports only (nested connectors lift to the parent port)"},{value:"none",label:"Off",title:"Hide ports; connectors run part to part"}]}),vt.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsx("button",{onClick:()=>Qe(null),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#2563EB",border:"1px solid #E5E5E0"},title:"Back to the whole diagram",children:"⌂ All"}),vt.map((t,n)=>{var p,c;const a=n===vt.length-1;return e.jsxs("span",{className:"flex items-center gap-1",style:{color:"#9CA3AF"},children:[e.jsx("span",{children:"›"}),e.jsx("button",{onClick:()=>Qe(t),disabled:a,className:"text-xs font-medium",style:{color:a?"#1a1a1a":"#2563EB",fontWeight:a?700:500,cursor:a?"default":"pointer"},title:a?void 0:`Focus ${((p=o==null?void 0:o.elements[t])==null?void 0:p.name)??t}`,children:((c=o==null?void 0:o.elements[t])==null?void 0:c.name)??t})]},t)})]})]}),ye&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #E5E5E0"},children:ln.map(t=>e.jsx("button",{onClick:()=>{Ut(t),ne.current.clear()},className:"px-2 py-0.5 text-xs font-medium capitalize",style:{background:he===t?"#1B3A4B":"#FFFFFF",color:he===t?"#FFFFFF":"#6B7280"},title:t==="graph"?"Relationship graph with compartments":t==="tree"?"Decomposition tree with expand/collapse":"Nested containment blocks",children:t},t))}),he!=="graph"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:Et,className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#374151",border:"1px solid #E5E5E0"},children:"Expand All"}),e.jsx("button",{onClick:kt,className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#374151",border:"1px solid #E5E5E0"},children:"Collapse All"}),he==="tree"&&e.jsx("button",{onClick:St,className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#374151",border:"1px solid #E5E5E0"},title:"Re-layout the tree from scratch",children:"↻ Reset"})]})]}),qe&&!pe&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsx("div",{className:"flex rounded overflow-hidden",style:{border:"1px solid #E5E5E0"},children:["containment","decomposition"].map(t=>e.jsx("button",{onClick:()=>{pn(t),ne.current.clear()},className:"px-2 py-0.5 text-xs font-medium",style:{background:Re===t?"#1B3A4B":"#FFFFFF",color:Re===t?"#FFFFFF":"#6B7280"},children:t==="containment"?"Containment":"Decomposition"},t))}),e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsx("button",{onClick:Et,className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#374151",border:"1px solid #E5E5E0"},children:"Expand All"}),e.jsx("button",{onClick:kt,className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#374151",border:"1px solid #E5E5E0"},children:"Collapse All"}),Re==="decomposition"&&e.jsx("button",{onClick:St,className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#374151",border:"1px solid #E5E5E0"},title:"Re-layout the tree from scratch",children:"↻ Reset"})]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),an&&Ft.length>0&&e.jsx("select",{"aria-label":"Layout provider",value:ue,disabled:te,onChange:t=>{const n=Ft.find(c=>c.id===t.target.value);if(!n)return;const a=M.getState().diagramLayouts[s],p=ps({...a??{nodes:{},edges:{}},nodes:{},edges:{},canvas:{...a==null?void 0:a.canvas,autoLayout:!0}},n);E({[s]:p}),We(s,p),ne.current.clear(),ft(c=>c+1)},title:"Choose an installed layout provider for this diagram",className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{color:"#374151",background:"#FFFFFF",border:"1px solid #D1D5DB"},children:Ft.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))}),e.jsxs("button",{"aria-pressed":re,onClick:()=>{if(re)oe();else{const t=M.getState().diagramLayouts[s],n={nodes:{},edges:{},canvas:{...t==null?void 0:t.canvas,autoLayout:!0}};E({[s]:n}),We(s,n),ft(a=>a+1)}},className:"px-2 py-0.5 text-xs font-semibold rounded",style:{background:re?"#ECFDF5":"#FFF7ED",color:re?"#047857":"#C2410C",border:`1px solid ${re?"#A7F3D0":"#FED7AA"}`},title:re?"Auto layout is on. Drag any item to switch it off and preserve your changes automatically.":"Auto layout is off. Your changes are saved automatically; click to discard overrides and recalculate.",children:["Auto layout: ",re?"On":"Off"]})]}),s&&L==="interconnection"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsxs("button",{"aria-pressed":xe,onClick:()=>{const t=M.getState().diagramLayouts[s]??{nodes:{},edges:{}},n={...t,canvas:{...t.canvas,flowAnimation:!xe}};E({[s]:n}),We(s,n),T(a=>a.map(p=>({...p,data:{...p.data,flowAnimation:!xe}})))},className:"px-2 py-0.5 text-xs font-semibold rounded",style:{background:xe?"#EFF6FF":"#F8FAFC",color:xe?"#1D4ED8":"#64748B",border:`1px solid ${xe?"#93C5FD":"#CBD5E1"}`},title:"Toggle animated source-to-target flow on IBD connectors",children:["Flow: ",xe?"On":"Off"]}),e.jsx("button",{"aria-pressed":oo,onClick:()=>no(t=>!t),className:"px-2 py-0.5 text-xs font-medium rounded",style:{background:"#F8FAFC",color:"#475569",border:"1px solid #CBD5E1"},title:"Show or hide the IBD notation legend",children:"Legend"})]})]}),Se&&e.jsxs("div",{className:"absolute top-3 right-3 z-10 flex items-center gap-2 px-3 py-1.5 rounded-lg text-xs",style:{background:"#1B3A4B",color:"#FFFFFF",boxShadow:"0 2px 8px rgba(0,0,0,0.18)"},children:[e.jsx("span",{style:{color:"#2DD4A8",fontWeight:700},children:"◎ Focus"}),e.jsx("span",{style:{color:"rgba(255,255,255,0.5)"},children:"Depth"}),[1,2,3].map(t=>e.jsx("button",{onClick:()=>rn(t),style:{width:20,height:20,borderRadius:4,cursor:"pointer",background:Ge===t?"#2DD4A8":"rgba(255,255,255,0.15)",color:Ge===t?"#1B3A4B":"#FFFFFF",fontWeight:700,fontSize:"11px",border:"none"},children:t},t)),e.jsx("button",{onClick:()=>{Gt(null),z(t=>t.map(n=>({...n,style:{...n.style,opacity:1,pointerEvents:"all"}}))),T(t=>t.map(n=>({...n,style:{...n.style,opacity:1}})))},style:{marginLeft:4,padding:"2px 8px",borderRadius:4,cursor:"pointer",background:"rgba(255,255,255,0.15)",color:"#FFFFFF",fontSize:"11px",border:"none"},children:"Exit Focus"})]}),Xe&&e.jsxs("div",{className:"absolute bottom-12 left-1/2 -translate-x-1/2 z-50 px-4 py-2 rounded-lg text-xs font-mono",style:{background:"#1B3A4B",color:"#2DD4A8",boxShadow:"0 4px 16px rgba(0,0,0,0.2)",whiteSpace:"nowrap"},children:["Copied: ",Xe]}),te&&e.jsx("div",{className:"absolute top-3 left-1/2 -translate-x-1/2 z-10 px-4 py-1.5 rounded-full text-xs font-medium",style:{background:"#FFFFFF",color:"#6B7280",border:"1px solid #E5E5E0",boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:"Computing layout…"}),$t&&!te&&e.jsxs("div",{role:"alert",className:"absolute top-3 left-1/2 -translate-x-1/2 z-20 flex items-center gap-3 px-3 py-2",style:{maxWidth:620,background:"#FFFDF7",color:"#5F4300",border:"1px solid #E7C35A",borderRadius:4,boxShadow:"0 2px 8px rgba(31,41,55,0.10)",fontSize:C.xs},children:[e.jsx("span",{children:$t}),e.jsx("button",{onClick:St,style:{border:"1px solid #B58A12",borderRadius:3,background:"#FFFFFF",color:"#5F4300",padding:"3px 8px",fontWeight:700,whiteSpace:"nowrap"},children:"Retry"})]}),Ue.length>0&&!te&&e.jsxs("div",{role:"alert",className:"absolute top-16 left-1/2 -translate-x-1/2 z-20 px-3 py-2",style:{maxWidth:720,background:"#FEF2F2",color:"#991B1B",border:"1px solid #FCA5A5",borderRadius:4,boxShadow:"0 2px 8px rgba(31,41,55,0.10)",fontSize:C.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"Diagram error:"})," ",Ue.length," floating ",Ue.length===1?"action has":"actions have"," no flow or succession connection:"," ",Ue.map((t,n)=>e.jsxs("span",{children:[n>0&&", ",e.jsx("button",{onClick:()=>h(t.id),style:{color:"#991B1B",textDecoration:"underline",fontWeight:700},children:t.name})]},t.id))]}),et&&!te&&e.jsxs("div",{role:"alert",className:"absolute top-16 left-1/2 -translate-x-1/2 z-20 px-3 py-2",style:{maxWidth:720,background:"#FEF2F2",color:"#991B1B",border:"1px solid #FCA5A5",borderRadius:4,boxShadow:"0 2px 8px rgba(31,41,55,0.10)",fontSize:C.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"BDD error:"})," ","expected one connected hierarchy, but found ",et.rootIds.length," roots",et.disconnectedIds.length>0&&e.jsxs(e.Fragment,{children:[" and ",et.disconnectedIds.length," disconnected/floating elements"]}),"."]}),L==="actionflow"&&e.jsxs("div",{"aria-label":"Action flow legend",className:"absolute right-3 bottom-3 z-10 flex items-center gap-4 px-3 py-2",style:{background:"rgba(255,255,255,0.96)",border:"1px solid #D1D5DB",borderRadius:3,color:"#374151",fontSize:C.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"Legend"}),de.has("control")&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:24,height:0,borderTop:"2px solid #4B5563"}}),"Control flow"]}),de.has("data")&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #3498DB"}}),"Object flow"]}),de.has("energy")&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #D97706"}}),"Energy flow"]}),de.has("material")&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:24,height:0,borderTop:"2.5px solid #16A34A"}}),"Material flow"]})]}),L==="interconnection"&&$.length>0&&oo&&e.jsxs("div",{"aria-label":"Interconnection legend",className:"absolute right-3 bottom-3 z-10 flex flex-col gap-1.5 px-3 py-2",style:{background:"rgba(255,255,255,0.96)",border:"1px solid #D1D5DB",borderRadius:4,color:"#374151",fontSize:C.xs},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{style:{fontWeight:700},children:"Ports"}),Be!=="none"?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Lt,{color:at.in,glyph:"→"})," in"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Lt,{color:at.out,glyph:"→"})," out"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Lt,{color:at.inout,glyph:"⇄"})," inout"]}),Be==="all"&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{style:{width:9,height:9,borderRadius:2,flexShrink:0,background:"#6B728022",border:"1.5px solid #6B7280"}}),"nested"]})]}):e.jsx("span",{style:{color:"#9CA3AF"},children:"hidden"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{style:{fontWeight:700},children:"Flow"}),["data","energy","material"].map(t=>e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:20,height:0,borderTop:`2.5px solid ${us[t]}`}}),t]},t))]})]}),!te&&$.length===0&&f&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",style:{zIndex:1},children:f.auto&&((vo=f.elementIds)==null?void 0:vo.length)===0?e.jsxs("div",{className:"text-center",style:{maxWidth:420},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:8},children:"🔍"}),e.jsx("div",{style:{fontSize:C.sm,color:"#374151",fontWeight:600,marginBottom:4},children:"This view selects no elements"}),e.jsx("div",{style:{fontSize:C.xs,color:"#6B7280",lineHeight:1.6},children:"The view is auto-populated from its selectionQuery in the model. Add includeElementKinds / includeLayers to its SysML definition, or link elements to it with IncludedIn relationships."})]}):e.jsxs("div",{className:"text-center",style:{opacity:.4},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:8},children:"🖱️"}),e.jsx("div",{style:{fontSize:C.sm,color:"#6B7280"},children:"Drag from palette or double-click to create elements"})]})}),te&&e.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",zIndex:20,background:`linear-gradient(90deg, ${To.accent} 0%, ${To.accent}80 50%, transparent 100%)`,backgroundSize:"200% 100%",animation:"memo-layout-progress 1.2s linear infinite"}}),e.jsxs(Kn,{nodes:$,edges:X,nodeTypes:xn,edgeTypes:hn,onNodesChange:Sn,onEdgesChange:le,onNodeClick:Nn,onNodeDoubleClick:Dn,onEdgeClick:Rn,onPaneClick:An,onNodeDragStart:En,onNodeDragStop:kn,onNodeContextMenu:Cn,onEdgeContextMenu:In,onConnect:jn,onConnectStart:Fn,onConnectEnd:wn,connectionMode:Vn.Loose,defaultEdgeOptions:{interactionWidth:24},snapToGrid:en,snapGrid:ui,fitView:!0,fitViewOptions:{...di,minZoom:Ne},minZoom:.1,maxZoom:3,zoomOnScroll:!0,panOnScroll:!0,panOnScrollMode:"free",selectionOnDrag:!1,proOptions:pi,style:li,children:[Ht&&e.jsx(Yn,{color:"#C5C7C2",gap:20,size:1.5}),e.jsx(Gn,{}),$.length>20&&e.jsx(Xn,{style:ci,nodeColor:fn,maskColor:"rgba(247, 247, 245, 0.7)"})]})]}),J&&e.jsx(fi,{x:J.x,y:J.y,onConfirm:bn,onCancel:()=>Ee(null)}),ce&&e.jsx(Zs,{x:ce.x,y:ce.y,sourceKind:ce.sourceKind,targetKind:ce.targetKind,onSelect:vn,onCancel:()=>Ve(null)}),q&&e.jsx(Js,{x:q.x,y:q.y,nodeId:q.nodeId,nodeKind:q.nodeKind,onClose:()=>ke(null),onEditName:()=>{z(t=>t.map(n=>n.id===q.nodeId?{...n,data:{...n.data,_triggerEdit:!0}}:n))},onChangeColor:t=>Tn(q.nodeId,t),onRemoveFromDiagram:()=>xo(q.nodeId),onDeleteFromModel:()=>{xo(q.nodeId)},onShowProperties:()=>{u(q.nodeId)},onShowInCatalog:()=>{u(q.nodeId),S("catalog")},onFocusElement:()=>{Gt(q.nodeId)},onShowRelMatrix:()=>{b({type:"traceability"})},onOpenSource:()=>{const t=o==null?void 0:o.elements[q.nodeId];t!=null&&t.file&&(navigator.clipboard.writeText(t.file).catch(()=>{}),Xt(t.file))},onViewKindInOntology:()=>{const t=q.nodeKind;let n=null,a=null;for(const p of x){for(const c of p.layers)if(c.kinds.some(k=>k.name===t)){n=p.name,a=c.id;break}if(n)break}n&&(y(t),j("ontologies"),S("ontology"),b({type:"ontology-detail",packageName:n,layerId:a??void 0}))}}),ie&&e.jsx(ti,{x:ie.x,y:ie.y,edgeId:ie.edgeId,relType:ie.relType,onClose:()=>Ye(null),onChangeStyle:t=>Ln(ie.edgeId,t),onChangeColor:t=>Bn(ie.edgeId,t),onToggleLabel:()=>zn(ie.edgeId),onDelete:()=>T(t=>t.filter(n=>n.id!==ie.edgeId))})]})}function Si(){return e.jsx(Wn,{children:e.jsx(gi,{})})}export{Si as DiagramCanvas};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SysmlCodeEditor-BLcw6hdp.js","assets/reactflow-WKyu73tD.js","assets/zustand-qbFpP9Up.js","assets/SysmlCodeEditor-BwKcXIZw.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{u as k,g as P,l as Y,s as V,a as W,F as a,C as o,_ as q,b as G,L as U,c as H,d as J}from"./index-CgRwea72.js";import{j as e}from"./reactflow-WKyu73tD.js";import{a as r}from"./zustand-qbFpP9Up.js";import{DiagramSurface as K}from"./DiagramSurface-B_lfUNzV.js";const Q=r.lazy(()=>q(()=>import("./SysmlCodeEditor-BLcw6hdp.js"),__vite__mapDeps([0,1,2,3])).then(l=>({default:l.SysmlCodeEditor})));function X(l,c){const u=(l.elementIds??[]).map(s=>c[s]).filter(Boolean).map(s=>` ${s.construct??"part"} ${s.id} : ${s.kind};`).join(`
|
|
3
|
-
`);return[`package '${l.name}' {`,` // Diagram: ${l.diagramType.toUpperCase()} | Viewpoint: ${l.viewpointId}`,u||" // No elements selected","}"].join(`
|
|
4
|
-
`)}function Z({diagram:l}){const c=k(n=>n.model),u=k(n=>n.updateDiagramElementIds),[s,x]=r.useState(""),E=r.useMemo(()=>G(c),[c]),w=r.useCallback(n=>{const f=new Set(l.elementIds??[]);f.has(n)?f.delete(n):f.add(n),u(l.id,[...f])},[l.id,l.elementIds,u]),h=r.useMemo(()=>new Set(l.elementIds??[]),[l.elementIds]),p=U.filter(n=>E.has(n));return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",style:{width:"220px",borderLeft:`1px solid ${o.border}`,background:"#FAFAF8",flexShrink:0},children:[e.jsxs("div",{className:"px-2 py-1.5",style:{borderBottom:`1px solid ${o.border}`},children:[e.jsxs("div",{className:"font-semibold mb-1",style:{color:o.primary,fontSize:a.xs},children:["Elements (",h.size," selected)"]}),e.jsx("input",{value:s,onChange:n=>x(n.target.value),placeholder:"Filter…",className:"w-full px-2 py-1 rounded focus:outline-none",style:{background:"#F0F0ED",border:`1px solid ${o.border}`,color:o.primary,fontSize:a.xs}})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:p.map(n=>{const f=(E.get(n)??[]).filter(i=>!s||i.name.toLowerCase().includes(s.toLowerCase())||i.id.toLowerCase().includes(s.toLowerCase()));if(f.length===0)return null;const g=J[n]??o.muted;return e.jsxs("div",{children:[e.jsx("div",{className:"px-2 py-1 font-semibold",style:{color:g,fontSize:a.badge},children:H[n]??n}),f.map(i=>e.jsxs("label",{className:"flex items-center gap-2 px-3 py-0.5 cursor-pointer",style:{fontSize:a.xs},onMouseEnter:S=>S.currentTarget.style.background="#F0F0ED",onMouseLeave:S=>S.currentTarget.style.background="transparent",children:[e.jsx("input",{type:"checkbox",checked:h.has(i.id),onChange:()=>w(i.id),style:{accentColor:o.accent}}),e.jsx("span",{className:"truncate",style:{color:o.primary},title:i.id,children:i.name||i.id})]},i.id))]},n)})})]})}const ee=[];function le({diagramId:l}){const c=k(t=>t.model),u=k(t=>t.diagramParseErrors[l]??ee),s=P(c,l),[x,E]=r.useState("visual"),[w,h]=r.useState(""),[p,n]=r.useState(!1),[f,g]=r.useState(!1),[i,S]=r.useState(!1),[m,N]=r.useState(!1),[b,j]=r.useState(null),[$,T]=r.useState(null),[C,O]=r.useState(()=>localStorage.getItem("memo.diagramEditor.autoSave")==="true"),F=r.useRef(),y=r.useRef(""),D=r.useRef(0);r.useEffect(()=>{let t=!1;if(clearTimeout(F.current),j(null),T(null),N(!1),!(!s||!c)){if(!s.sourceFile||window.__MEMO_DATA__){const d=X(s,c.elements);y.current=d,h(d),n(!1),g(!1);return}return h(""),y.current="",n(!0),g(!1),Y(l).then(d=>{if(t)return;const v=d.text??"";y.current=v,h(v),g(!0)}).catch(d=>{t||j(d instanceof Error?d.message:String(d))}).finally(()=>{t||n(!1)}),()=>{t=!0}}},[l,s==null?void 0:s.sourceFile]);const B=t=>{y.current=t,h(t),N(!0),j(null)},A=r.useCallback(async t=>{if(!s)return;const d=++D.current;S(!0),j(null);try{s.sourceFile?await V(l,t):W(l,t),y.current===t&&N(!1),T(Date.now())}catch(v){j(v instanceof Error?v.message:String(v))}finally{D.current===d&&S(!1)}},[s,l]);r.useEffect(()=>(localStorage.setItem("memo.diagramEditor.autoSave",String(C)),clearTimeout(F.current),C&&m&&!p&&(F.current=setTimeout(()=>void A(y.current),800)),()=>clearTimeout(F.current)),[C,m,p,w,A]);const M=r.useCallback(()=>{clearTimeout(F.current),A(y.current)},[A]),I=r.useMemo(()=>Object.values((c==null?void 0:c.elements)??{}).map(t=>({id:t.id,name:t.name,kind:t.kind})),[c==null?void 0:c.elements]);if(!s)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{color:o.faint,fontSize:a.sm},children:"Diagram not found"});const _=s.auto,L=!_||!!s.sourceFile&&f,z=e.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden",children:[e.jsx("div",{className:"flex-1 overflow-hidden",style:{background:"#1E1E1E"},children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"h-full flex items-center justify-center",style:{color:"#9CA3AF",fontSize:a.xs},children:"Loading SysML editor…"}),children:e.jsx(Q,{value:w,sourceFile:s.sourceFile,readOnly:!L||p,symbols:I,onChange:B,onSave:()=>{L&&m&&M()}})})}),u.length>0&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C0A0A",color:"#F87171",borderTop:"1px solid #3B0A0A",fontFamily:"monospace"},children:u.join(" · ")}),b&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#1C0A0A",color:"#FCA5A5",borderTop:"1px solid #3B0A0A"},children:b}),!L&&e.jsx("div",{className:"px-3 py-1.5 text-xs",style:{background:"#F9F9F8",color:o.faint,borderTop:`1px solid ${o.border}`},children:s.sourceFile&&window.__MEMO_DATA__?"Static build — run memo-architect dev to edit the SysML source":s.sourceFile?"The SysML source could not be loaded":"Generated model view — no editable SysML source file"})]}),R=e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:e.jsx(K,{})}),!_&&e.jsx(Z,{diagram:s})]});return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5",style:{borderBottom:`1px solid ${o.border}`,background:"#FAFAF8",flexShrink:0},children:[e.jsx("span",{className:"font-semibold truncate flex-1",style:{color:o.primary,fontSize:a.sm},children:s.name}),s.sourceFile&&e.jsx("span",{className:"truncate",title:s.sourceFile,style:{maxWidth:"220px",color:o.faint,fontSize:a.xs},children:s.sourceFile}),(x==="text"||x==="split")&&e.jsx("span",{title:"Local, public Monaco editor with SysML highlighting and model-aware completion",style:{color:"#4B6E80",fontSize:a.badge},children:"Monaco · SysML"}),p&&e.jsx("span",{style:{color:o.faint,fontSize:a.xs},children:"Loading source…"}),i&&e.jsx("span",{style:{color:o.faint,fontSize:a.xs},children:"Saving…"}),!i&&b&&e.jsx("span",{title:b,style:{color:"#EF4444",fontSize:a.xs},children:"Save failed"}),!i&&!b&&m&&e.jsx("span",{style:{color:"#B45309",fontSize:a.xs},children:"Unsaved"}),!i&&!m&&$&&e.jsx("span",{style:{color:"#15803D",fontSize:a.xs},children:"Saved"}),!i&&u.length>0&&e.jsxs("span",{style:{color:"#EF4444",fontSize:a.xs},children:[u.length," error",u.length>1?"s":""]}),L&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-center gap-1",style:{color:o.secondary,fontSize:a.xs},title:"Save changes 800ms after typing",children:[e.jsx("input",{type:"checkbox",checked:C,onChange:t=>O(t.target.checked),style:{accentColor:o.accent}}),"Auto-save"]}),e.jsx("button",{onClick:M,disabled:!m||i||p,title:"Save SysML (Ctrl/Cmd+S)",style:{fontSize:a.xs,padding:"3px 10px",borderRadius:"5px",border:`1px solid ${o.border}`,cursor:!m||i||p?"default":"pointer",background:m?o.accent:"#F0F0ED",color:m?"#FFFFFF":o.faint,fontWeight:600},children:"Save"})]}),e.jsx("div",{className:"flex overflow-hidden",style:{border:`1px solid ${o.border}`,borderRadius:"6px"},children:[["visual","⬜ Visual"],["split","⧉ Split"],["text","</> Text"]].map(([t,d])=>e.jsx("button",{onClick:()=>E(t),style:{fontSize:a.xs,padding:"3px 10px",border:"none",cursor:"pointer",background:x===t?o.accent:"transparent",color:x===t?"#FFFFFF":o.secondary,fontWeight:x===t?600:400},children:d},t))})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[x==="visual"&&R,x==="text"&&z,x==="split"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"50%",borderRight:`1px solid ${o.border}`,display:"flex",flexDirection:"column",overflow:"hidden"},children:z}),e.jsx("div",{style:{width:"50%",display:"flex",overflow:"hidden"},children:R})]})]})]})}export{le as DiagramEditor};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiagramCanvas-BgfO0AtP.js","assets/reactflow-WKyu73tD.js","assets/zustand-qbFpP9Up.js","assets/index-CgRwea72.js","assets/index-CnFhl4_e.css","assets/layout-selection-BQ2WuAEB.js","assets/layout-providers-BAUgp0nu.js","assets/elk-B75IRfCd.js","assets/style-BZV40eAE.css","assets/MaxGraphCanvas-DYs6MPuP.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var R=Object.defineProperty;var w=(t,e,r)=>e in t?R(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var l=(t,e,r)=>w(t,typeof e!="symbol"?e+"":e,r);import{j as o}from"./reactflow-WKyu73tD.js";import{a as s}from"./zustand-qbFpP9Up.js";import{_ as f,F as h}from"./index-CgRwea72.js";const d="memo.renderer.reactflow";class E{constructor(){l(this,"providers",new Map);l(this,"components",new Map)}register(e){const r=this.providers.get(e.descriptor.id);if(r&&r!==e)throw new Error(`Renderer provider already registered: ${e.descriptor.id}`);this.providers.set(e.descriptor.id,e)}unregister(e){return this.components.delete(e),this.providers.delete(e)}get(e){return this.providers.get(e)}has(e){return this.providers.has(e)}list(e=[]){return[...this.providers.values()].map(r=>r.descriptor).filter(r=>e.every(n=>r.capabilities.includes(n))).sort((r,n)=>r.name.localeCompare(n.name))}loadComponent(e){const r=this.providers.get(e)??this.providers.get(d);if(!r)throw new Error(`Renderer provider not found: ${e} (no default registered)`);const n=r.descriptor.id;let a=this.components.get(n);return a||(a=r.loadComponent(),this.components.set(n,a)),a}}const v={descriptor:{id:"memo.renderer.reactflow",name:"ReactFlow",engine:"ReactFlow (@xyflow/react 12)",version:"12",contractVersion:"1",license:"MIT",description:"Default authoring canvas — React node components, palette, full editing.",capabilities:["interactive-editing","all-view-kinds","manual-layout","undo-redo","minimap","orthogonal-routes"]},loadComponent:()=>f(()=>import("./DiagramCanvas-BgfO0AtP.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8])).then(t=>t.DiagramCanvas)},x={descriptor:{id:"memo.renderer.maxgraph",name:"maxGraph",engine:"maxGraph (@maxgraph/core — draw.io rendering engine lineage)",version:"0.x",contractVersion:"1",license:"Apache-2.0",description:"draw.io-style retained-mode canvas — SVG cells, rubberband selection, image export.",capabilities:["all-view-kinds","manual-layout","export-image"]},loadComponent:()=>f(()=>import("./MaxGraphCanvas-DYs6MPuP.js"),__vite__mapDeps([9,1,2,3,4,5,6,7])).then(t=>t.MaxGraphCanvas)},i=new E;i.register(v);i.register(x);function _(t=[]){return i.list(t)}const y={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1},g="memo.diagram.renderer.v3",m="renderer",F="memo.renderer.",u=new Set;function c(t){const e=t==null?void 0:t.trim();if(e)return e.includes(".")?e:`${F}${e}`}function S(){if(!(typeof window>"u"))try{return c(new URLSearchParams(window.location.search).get(m))}catch{return}}function b(){if(!(typeof window>"u"))try{return c(window.localStorage.getItem(g))}catch{return}}function D(){try{const t=y;return c(t==null?void 0:t.VITE_MEMO_DIAGRAM_RENDERER)}catch{return}}function p(){return S()??b()??D()??d}function I(t){const e=c(t)??d;try{window.localStorage.setItem(g,e)}catch{}try{const r=new URL(window.location.href);r.searchParams.has(m)&&(r.searchParams.delete(m),window.history.replaceState(window.history.state,"",r))}catch{}for(const r of[...u])r()}function A(t){return u.add(t),()=>u.delete(t)}function C(){return o.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5",color:"#9CA3AF",fontSize:h.sm},children:"Loading renderer…"})}function j({activeId:t}){const e=_();return e.length<2?null:o.jsx("div",{className:"absolute bottom-3 right-3 z-10 flex items-center overflow-hidden rounded-lg",style:{border:"1px solid #E5E5E0",background:"#FFFFFF",boxShadow:"0 2px 8px rgba(0,0,0,0.08)"},title:"Diagram rendering engine",children:e.map(r=>{const n=r.id===t;return o.jsx("button",{onClick:()=>I(r.id),title:`${r.engine} — ${r.description}`,style:{fontSize:h.xs,padding:"4px 10px",fontWeight:600,border:"none",cursor:n?"default":"pointer",background:n?"#2DD4A8":"transparent",color:n?"#FFFFFF":"#6B7280"},children:r.name},r.id)})})}function L(){const t=s.useSyncExternalStore(A,p,p),e=i.has(t)?t:d,r=s.useMemo(()=>s.lazy(()=>i.loadComponent(e).then(n=>({default:n}))),[e]);return o.jsxs("div",{className:"relative flex flex-1 overflow-hidden",children:[o.jsx(s.Suspense,{fallback:o.jsx(C,{}),children:o.jsx(r,{})}),o.jsx(j,{activeId:e})]})}export{L as DiagramSurface};
|