@memoarchitect/architect 0.6.4 → 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +40 -7
  2. package/dist/assets/AiWorkspace-DS79vBOT.js +3 -0
  3. package/dist/assets/AnalysisWorkspace-D_u4shRY.js +39 -0
  4. package/dist/assets/{ComplianceWizard-CVidRUY4.js → ComplianceWizard-k98NZ2ec.js} +1 -1
  5. package/dist/assets/{DSMView-DdcRG9Te.js → DSMView-DGheBwZ0.js} +1 -1
  6. package/dist/assets/{Dashboard-DxOueCqW.js → Dashboard-BRUQvUFK.js} +1 -1
  7. package/dist/assets/{DhfDashboard-CpDAP41S.js → DhfDashboard-B9V_n7kg.js} +1 -1
  8. package/dist/assets/{DhfSettingsPanel-C2vyewXY.js → DhfSettingsPanel-B8aLsWn6.js} +1 -1
  9. package/dist/assets/{DhfWorkbench-BGaEk0Qi.js → DhfWorkbench-TOnZkdUU.js} +3 -3
  10. package/dist/assets/DiagramCanvas-B9d4aLKt.js +1 -0
  11. package/dist/assets/{DiagramEditor-v6VJ5o2f.js → DiagramEditor-CJ7OG2IC.js} +2 -2
  12. package/dist/assets/ElementDetailView-CDcm1rvf.js +2 -0
  13. package/dist/assets/{ImportView-C8lcbof7.js → ImportView-CyMm-tSP.js} +1 -1
  14. package/dist/assets/{LayerGrid-BB30kAyl.js → LayerGrid-DNPZYTsD.js} +1 -1
  15. package/dist/assets/{LayerTable-BN9IZPbM.js → LayerTable-DhOq1DHo.js} +1 -1
  16. package/dist/assets/{MaxGraphCanvas-CfoIuwsi.js → MaxGraphCanvas-DqKU1PTY.js} +6 -6
  17. package/dist/assets/{ModelDiff-D6IR9kzb.js → ModelDiff-BbqIoesG.js} +1 -1
  18. package/dist/assets/OntologyDecompositionDiagram-DkxTe2C_.js +1 -0
  19. package/dist/assets/{OntologyViewer-cI3zi95S.js → OntologyViewer-BIpJC66j.js} +2 -2
  20. package/dist/assets/{ReviewDashboard-BTqze9-C.js → ReviewDashboard-DKoExM8K.js} +1 -1
  21. package/dist/assets/ScenarioEditor-JQ3huCnz.js +3 -0
  22. package/dist/assets/{StatisticsDashboard-BC1JkdTl.js → StatisticsDashboard-B8BduIDz.js} +1 -1
  23. package/dist/assets/{TabularView-Bn_WEMpm.js → TabularView-BXfFSluC.js} +1 -1
  24. package/dist/assets/{TraceabilityMatrix-BEEPlOQq.js → TraceabilityMatrix-CHZHFucA.js} +1 -1
  25. package/dist/assets/{WorkflowWizard-CFx5KVUH.js → WorkflowWizard-7--f9OH2.js} +1 -1
  26. package/dist/assets/index-CVW92JY7.js +3280 -0
  27. package/dist/assets/index-Y1UZTZg-.css +1 -0
  28. package/dist/assets/layout-selection-ClQ295Xc.js +1 -0
  29. package/dist/index.html +2 -2
  30. package/lib/__tests__/feature-grants.test.d.ts +2 -0
  31. package/lib/__tests__/feature-grants.test.d.ts.map +1 -0
  32. package/lib/__tests__/feature-grants.test.js +34 -0
  33. package/lib/__tests__/feature-grants.test.js.map +1 -0
  34. package/lib/bin/memo-architect.js +20 -3
  35. package/lib/bin/memo-architect.js.map +1 -1
  36. package/lib/commands/build.d.ts +3 -0
  37. package/lib/commands/build.d.ts.map +1 -1
  38. package/lib/commands/build.js +3 -0
  39. package/lib/commands/build.js.map +1 -1
  40. package/lib/commands/dev.d.ts +2 -0
  41. package/lib/commands/dev.d.ts.map +1 -1
  42. package/lib/commands/dev.js +5 -0
  43. package/lib/commands/dev.js.map +1 -1
  44. package/lib/commands/example.d.ts +2 -0
  45. package/lib/commands/example.d.ts.map +1 -1
  46. package/lib/commands/example.js +6 -2
  47. package/lib/commands/example.js.map +1 -1
  48. package/lib/feature-grants.d.ts +29 -0
  49. package/lib/feature-grants.d.ts.map +1 -0
  50. package/lib/feature-grants.js +31 -0
  51. package/lib/feature-grants.js.map +1 -0
  52. package/package.json +9 -5
  53. package/dist/assets/ChatPanel-DSjWi7UI.js +0 -3
  54. package/dist/assets/DiagramCanvas-DybZNdxw.js +0 -1
  55. package/dist/assets/ElementDetailView-9EkxZAaF.js +0 -2
  56. package/dist/assets/OntologyDecompositionDiagram-DjhvdWh5.js +0 -1
  57. package/dist/assets/ScenarioEditor-BL835I2V.js +0 -3
  58. package/dist/assets/SysmlGenerator-B_Me_xGE.js +0 -1
  59. package/dist/assets/index-BMgENwvO.js +0 -3280
  60. package/dist/assets/index-XtCtnAfF.css +0 -1
  61. package/dist/assets/layout-selection-ClQts3bC.js +0 -1
@@ -1 +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,SAAS,gBAAgB,CAAC,YAAoB,EAAE,OAAiC;IAC7E,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,SAAS,GAAG,KAAK,CAAC;IACtB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,IAAI,KAAK,GAAG,OAAO,GAAG,EAAE,CAAC;YAAC,SAAS,GAAG,IAAI,CAAC;YAAC,SAAS;QAAC,CAAC;QAC3D,IAAI,CAAC,SAAS;YAAE,SAAS;QACzB,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,kDAAkD;AAClD,MAAM,UAAU,qBAAqB;IACjC,OAAO,gBAAgB,CAAC,mBAAmB,EAAE,EAAE,UAAU,CAAC,CAAC;AAC/D,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,sBAAsB;IAClC,OAAO,gBAAgB,CAAC,mBAAmB,EAAE,EAAE,WAAW,CAAC,CAAC;AAChE,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,gBAAgB,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QACxD,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"}
1
+ {"version":3,"file":"example.js","sourceRoot":"","sources":["../../src/commands/example.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Serialised into the client HTML as `window.__MEMO_FLAGS__`.
3
+ *
4
+ * The index signature keeps this assignable to the `Record<string, unknown>`
5
+ * the transport carries: Tools forwards grants opaquely and must not need a
6
+ * type update every time a stage is added.
7
+ */
8
+ export interface FeatureGrants {
9
+ experimental?: boolean;
10
+ [grant: string]: unknown;
11
+ }
12
+ export declare function resolveFeatureGrants(options: {
13
+ experimental?: boolean;
14
+ }): FeatureGrants;
15
+ /** Shared `--experimental` help text, so every subcommand says the same thing. */
16
+ export declare const EXPERIMENTAL_FLAG_DESCRIPTION: string;
17
+ /**
18
+ * Splice grants into the client HTML shell.
19
+ *
20
+ * This runs before the bundle so the first paint already knows which surfaces
21
+ * exist; delivering grants over the WebSocket instead would let gated nav
22
+ * render and then disappear. Idempotent — a static viewer built by
23
+ * `memo-architect build` already carries its grants and is left alone.
24
+ *
25
+ * Lives here rather than in Tools: the dev server hosts a client it does not
26
+ * own, so `__MEMO_FLAGS__` is Architect's vocabulary to define.
27
+ */
28
+ export declare function injectFeatureGrants(html: string, grants: FeatureGrants): string;
29
+ //# sourceMappingURL=feature-grants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature-grants.d.ts","sourceRoot":"","sources":["../src/feature-grants.ts"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,aAAa,CAEvF;AAED,kFAAkF;AAClF,eAAO,MAAM,6BAA6B,QAEyD,CAAC;AAEpG;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,CAI/E"}
@@ -0,0 +1,31 @@
1
+ // ─── Feature grants (CLI side) ───────────────────────────────────────────────
2
+ //
3
+ // The CLI grants a *stage*, not a feature list. Which surfaces a stage unlocks
4
+ // is decided by the client's registry in
5
+ // `packages/web/src/config/feature-flags.ts`, so adding an experimental feature
6
+ // never means touching the CLI.
7
+ // ─────────────────────────────────────────────────────────────────────────────
8
+ export function resolveFeatureGrants(options) {
9
+ return { experimental: options.experimental === true };
10
+ }
11
+ /** Shared `--experimental` help text, so every subcommand says the same thing. */
12
+ export const EXPERIMENTAL_FLAG_DESCRIPTION = 'Enable all experimental workbench surfaces (AI Tools, Ontology, Import, and Model Tools). '
13
+ + 'Off by default: advanced and generated content workflows carry no design-control provenance';
14
+ /**
15
+ * Splice grants into the client HTML shell.
16
+ *
17
+ * This runs before the bundle so the first paint already knows which surfaces
18
+ * exist; delivering grants over the WebSocket instead would let gated nav
19
+ * render and then disappear. Idempotent — a static viewer built by
20
+ * `memo-architect build` already carries its grants and is left alone.
21
+ *
22
+ * Lives here rather than in Tools: the dev server hosts a client it does not
23
+ * own, so `__MEMO_FLAGS__` is Architect's vocabulary to define.
24
+ */
25
+ export function injectFeatureGrants(html, grants) {
26
+ if (html.includes('__MEMO_FLAGS__'))
27
+ return html;
28
+ const tag = `<script>window.__MEMO_FLAGS__=${JSON.stringify(grants)};</script>`;
29
+ return html.includes('</head>') ? html.replace('</head>', `${tag}\n</head>`) : tag + html;
30
+ }
31
+ //# sourceMappingURL=feature-grants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature-grants.js","sourceRoot":"","sources":["../src/feature-grants.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,EAAE;AACF,+EAA+E;AAC/E,yCAAyC;AACzC,gFAAgF;AAChF,gCAAgC;AAChC,gFAAgF;AAchF,MAAM,UAAU,oBAAoB,CAAC,OAAmC;IACpE,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,KAAK,IAAI,EAAE,CAAC;AAC3D,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,MAAM,6BAA6B,GACtC,4FAA4F;MAC1F,6FAA6F,CAAC;AAEpG;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,MAAqB;IACnE,IAAI,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QAAE,OAAO,IAAI,CAAC;IACjD,MAAM,GAAG,GAAG,iCAAiC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC;IAChF,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC;AAC9F,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memoarchitect/architect",
3
- "version": "0.6.4",
3
+ "version": "0.6.6",
4
4
  "description": "MEMO Architect — interactive workbench and distributable viewer for medical device systems engineering",
5
5
  "type": "module",
6
6
  "bin": {
@@ -25,19 +25,23 @@
25
25
  "check:bundle": "bash scripts/check-no-bare-imports.sh",
26
26
  "dev": "pnpm run example:dev",
27
27
  "dev:web": "vite --config packages/web/vite.config.ts",
28
- "test": "cd packages/web && vitest run",
28
+ "test": "pnpm run test:web && pnpm run test:cli",
29
29
  "test:coverage": "cd packages/web && vitest run --coverage",
30
30
  "type-check": "tsc -p packages/web/tsconfig.json --noEmit && tsc -p tsconfig.architect.json --noEmit",
31
31
  "clean": "rm -rf dist lib",
32
32
  "docs:serve": "pdm run docs-serve",
33
33
  "docs:build": "pdm run docs-build",
34
+ "version:sync": "node scripts/sync-version.mjs",
35
+ "version:check": "node scripts/sync-version.mjs --check",
34
36
  "architect": "node lib/bin/memo-architect.js",
35
37
  "example:dev": "node scripts/run-gpca-example.mjs",
36
- "setup": "pnpm install && pnpm run build && pdm install"
38
+ "setup": "pnpm install && pnpm run build && pdm install",
39
+ "test:web": "cd packages/web && vitest run",
40
+ "test:cli": "vitest run --config vitest.cli.config.ts"
37
41
  },
38
42
  "dependencies": {
39
- "@memoarchitect/tools": "0.6.5",
40
- "@memoarchitect/ontology": "0.6.3",
43
+ "@memoarchitect/tools": "0.6.7",
44
+ "@memoarchitect/ontology": "0.6.5",
41
45
  "commander": "^12.1.0"
42
46
  },
43
47
  "devDependencies": {
@@ -1,3 +0,0 @@
1
- import{j as e}from"./reactflow-CsCqNKB-.js";import{a as i}from"./zustand-CrhqMOHB.js";import{u as S,k as $,m as H,n as N}from"./index-BMgENwvO.js";const U={env:"an environment variable","env-file":"the project .env file","project-settings":"project settings","user-credentials":"your saved credentials",default:"the default"},Q={anthropic:"claude-opus-5",openai:"gpt-4o"};function Y({onClose:o}){const s=S(a=>a.llmSettings),f=S(a=>a.registerLlmRequest),[r,y]=i.useState((s==null?void 0:s.provider)??"anthropic"),[c,p]=i.useState((s==null?void 0:s.model)??""),[l,C]=i.useState(""),[h,j]=i.useState(!1),[g,m]=i.useState(null),I=i.useCallback(async()=>{j(!0),m(null);const a=`llmset-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{await new Promise((u,b)=>{f(a,u,b),$(a,{provider:r,model:c.trim()||void 0,...l?{apiKey:l}:{}}),setTimeout(()=>b(new Error("The save timed out.")),2e4)}),C(""),m("Saved.")}catch(u){m((u==null?void 0:u.message)??"The settings could not be saved.")}finally{j(!1)}},[r,c,l,f]),B=i.useCallback(async()=>{j(!0),m(null);const a=`llmclear-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{await new Promise((u,b)=>{f(a,u,b),$(a,{provider:r,apiKey:""}),setTimeout(()=>b(new Error("The request timed out.")),2e4)}),m("Key removed.")}catch(u){m((u==null?void 0:u.message)??"The key could not be removed.")}finally{j(!1)}},[r,f]),E={fontSize:"11px",fontWeight:600,color:"#374151",display:"block",marginBottom:"4px"},k={width:"100%",padding:"6px 10px",border:"1px solid #E5E5E0",borderRadius:"6px",fontSize:"12px",outline:"none",background:"#fff",color:"#1B3A4B",fontFamily:"inherit"};return e.jsxs("div",{style:{padding:"14px 20px",background:"#fff",borderBottom:"1px solid #E5E5E0",display:"flex",flexDirection:"column",gap:"12px",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx("div",{style:{flex:1,fontSize:"12px",fontWeight:700,color:"#1B3A4B"},children:"LLM settings"}),e.jsx("button",{onClick:o,style:{background:"none",border:"none",color:"#9CA3AF",fontSize:"14px",cursor:"pointer"},children:"✕"})]}),e.jsxs("div",{style:{display:"flex",gap:"10px"},children:[e.jsxs("div",{style:{flex:"0 0 130px"},children:[e.jsx("label",{style:E,children:"Provider"}),e.jsxs("select",{value:r,onChange:a=>y(a.target.value),style:{...k,cursor:"pointer"},children:[e.jsx("option",{value:"anthropic",children:"Anthropic"}),e.jsx("option",{value:"openai",children:"OpenAI-compatible"})]})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:E,children:"Model"}),e.jsx("input",{value:c,onChange:a=>p(a.target.value),placeholder:Q[r]??"",style:k})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:E,children:"API key"}),s&&!s.keyEditable&&s.configured?e.jsxs("div",{style:{fontSize:"11px",color:"#6B7280",lineHeight:1.6},children:["A key is already supplied by ",U[s.keyOrigin??"default"],", which takes precedence over anything saved here. Remove it there to set a key from this screen."]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"password",value:l,onChange:a=>C(a.target.value),placeholder:s!=null&&s.configured?"Saved — type a new key to replace it":"sk-…",autoComplete:"off",style:k}),e.jsxs("div",{style:{fontSize:"10px",color:"#9CA3AF",marginTop:"4px",lineHeight:1.5},children:["Stored in ",e.jsx("code",{children:"~/.memo/credentials.json"})," with owner-only permissions — outside this project, so it is never committed. You can also set"," ",e.jsx("code",{children:"ANTHROPIC_API_KEY"})," in the environment or a project ",e.jsx("code",{children:".env"}),"."]})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx("button",{onClick:I,disabled:h,style:{padding:"6px 14px",borderRadius:"6px",border:"none",background:"#1B3A4B",color:"#fff",fontSize:"11px",fontWeight:600,cursor:h?"default":"pointer",opacity:h?.5:1},children:h?"Saving…":"Save"}),(s==null?void 0:s.configured)&&s.keyEditable&&e.jsx("button",{onClick:B,disabled:h,style:{padding:"6px 12px",borderRadius:"6px",border:"1px solid #E5E5E0",background:"transparent",color:"#dc2626",fontSize:"11px",cursor:"pointer"},children:"Remove saved key"}),g&&e.jsx("span",{style:{fontSize:"11px",color:"#6B7280"},children:g})]})]})}const G=["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."],V=12e4;function se(){const o=S(t=>t.llmAvailable),s=S(t=>t.llmProvider),f=S(t=>t.llmModel),r=S(t=>t.model),y=S(t=>t.registerLlmRequest),[c,p]=i.useState([]),[l,C]=i.useState([]),[h,j]=i.useState(""),[g,m]=i.useState(!1),[I,B]=i.useState(!1),[E,k]=i.useState(!1),[a,u]=i.useState(!1),[b,T]=i.useState(new Set),[F,D]=i.useState(null),L=i.useRef(null),M=i.useRef(null);i.useEffect(()=>{var t;(t=L.current)==null||t.scrollIntoView({behavior:"smooth"})},[c,g]);const R=i.useCallback((t,d)=>new Promise((x,n)=>{y(t,x,n),d(),setTimeout(()=>n(new Error("The request timed out after 2 minutes.")),V)}),[y]),z=i.useCallback(async t=>{if(!t.trim()||g)return;const d=t.trim();j(""),p(n=>[...n,{role:"user",content:d}]),m(!0),D(null);const x=`chat-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{const n=await R(x,()=>H(x,d,l,I));C(n.messages),p(v=>[...v,{role:"assistant",content:n.truncated?`${n.answer}
2
-
3
- _(Stopped at the tool-call limit for one turn — ask again to continue.)_`:n.answer,changes:n.proposedChanges.length?n.proposedChanges:void 0}]),n.proposedChanges.length&&T(v=>{const A=new Set(v);for(const w of n.proposedChanges)A.add(w.id);return A})}catch(n){p(v=>[...v,{role:"assistant",content:(n==null?void 0:n.message)??"Unknown error",error:!0}])}finally{m(!1)}},[g,l,I,R]),P=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),z(h))},W=t=>{T(d=>{const x=new Set(d);return x.has(t)?x.delete(t):x.add(t),x})},O=i.useCallback(async t=>{const d=t.filter(n=>b.has(n.id));if(d.length===0||a)return;u(!0),D(null);const x=`apply-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{const n=await R(x,()=>N(x,d)),v=new Set(n.applied);p(A=>A.map(w=>w.changes?{...w,changes:w.changes.filter(_=>!v.has(_.id))}:w)),D(n.failed.length?`Applied ${n.applied.length}. Failed: ${n.failed.map(A=>A.error).join("; ")}`:`Applied ${n.applied.length} change${n.applied.length===1?"":"s"} to the model source.`)}catch(n){D((n==null?void 0:n.message)??"The changes could not be applied.")}finally{u(!1)}},[b,a,R]),q=t=>{const d=new Set(t.map(x=>x.id));p(x=>x.map(n=>n.changes?{...n,changes:n.changes.filter(v=>!d.has(v.id))}:n))},K=()=>{p([]),C([]),T(new Set),D(null)};return r?e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"#F7F7F5",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"14px 20px 10px",borderBottom:"1px solid #E5E5E0",background:"#fff",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx("span",{style:{fontSize:"16px"},children:"✦"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:700,color:"#1B3A4B"},children:"Model Assistant"}),e.jsx("div",{style:{fontSize:"11px",color:o?"#059669":"#dc2626",marginTop:"1px"},children:o?`${s??"LLM"} · ${f??"unknown model"}`:"No API key configured"})]}),e.jsx("button",{onClick:()=>k(t=>!t),title:"LLM settings",style:{background:E?"#F3F4F6":"none",border:"1px solid #E5E5E0",borderRadius:"6px",padding:"4px 8px",fontSize:"12px",color:"#374151",cursor:"pointer"},children:"⚙ Settings"})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"8px",fontSize:"11px",color:"#6B7280",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:I,onChange:t=>B(t.target.checked),style:{cursor:"pointer"}}),"Suggest edits — the assistant may propose model changes for your approval"]})]}),E&&e.jsx(Y,{onClose:()=>k(!1)}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"16px 20px",display:"flex",flexDirection:"column",gap:"12px"},children:[c.length===0&&e.jsxs("div",{style:{paddingTop:"8px"},children:[e.jsx("div",{style:{fontSize:"12px",color:"#9CA3AF",marginBottom:"12px"},children:"Ask about your model in plain English. The assistant can look up any element, follow traceability chains, and read validation gaps."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:G.map(t=>e.jsx("button",{onClick:()=>z(t),disabled:!o||g,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:d=>{o&&(d.currentTarget.style.borderColor="#2DD4A8")},onMouseLeave:d=>{d.currentTarget.style.borderColor="#E5E5E0"},children:t},t))})]}),c.map((t,d)=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:t.role==="user"?"row-reverse":"row",gap:"8px",alignItems:"flex-start"},children:[e.jsx("div",{style:{width:"24px",height:"24px",borderRadius:"50%",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:t.role==="user"?"#1B3A4B":"#2DD4A815",fontSize:"10px",fontWeight:700,color:t.role==="user"?"#fff":"#2DD4A8",marginTop:"2px"},children:t.role==="user"?"U":"✦"}),e.jsx("div",{style:{maxWidth:"85%",padding:"10px 12px",borderRadius:"10px",background:t.role==="user"?"#1B3A4B":t.error?"#fef2f2":"#fff",color:t.role==="user"?"#fff":t.error?"#dc2626":"#1B3A4B",fontSize:"13px",lineHeight:"1.6",border:t.role==="assistant"?`1px solid ${t.error?"#fecaca":"#E5E5E0"}`:"none",whiteSpace:"pre-wrap"},children:t.content})]}),t.changes&&t.changes.length>0&&e.jsx(J,{changes:t.changes,approved:b,onToggle:W,onApply:()=>O(t.changes),onDiscard:()=>q(t.changes),applying:a})]},d)),F&&e.jsx("div",{style:{fontSize:"11px",color:"#374151",background:"#fff",border:"1px solid #E5E5E0",borderRadius:"8px",padding:"8px 12px"},children:F}),g&&e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"flex-start"},children:[e.jsx("div",{style:{width:"24px",height:"24px",borderRadius:"50%",background:"#2DD4A815",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",color:"#2DD4A8",fontWeight:700},children:"✦"}),e.jsx("div",{style:{padding:"10px 14px",borderRadius:"10px",background:"#fff",border:"1px solid #E5E5E0",display:"flex",gap:"4px",alignItems:"center"},children:e.jsx(ee,{})})]}),e.jsx("div",{ref:L})]}),e.jsxs("div",{style:{padding:"12px 16px",borderTop:"1px solid #E5E5E0",background:"#fff",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"flex-end"},children:[e.jsx("textarea",{ref:M,value:h,onChange:t=>j(t.target.value),onKeyDown:P,disabled:!o||g,placeholder:o?"Ask a question… (Enter to send, Shift+Enter for newline)":"Add an API key in Settings to start",rows:2,style:{flex:1,padding:"8px 12px",border:"1px solid #E5E5E0",borderRadius:"8px",fontSize:"13px",resize:"none",fontFamily:"inherit",outline:"none",background:"#F7F7F5",color:"#1B3A4B",lineHeight:"1.5",opacity:o?1:.5},onFocus:t=>{t.target.style.borderColor="#2DD4A8"},onBlur:t=>{t.target.style.borderColor="#E5E5E0"}}),e.jsx("button",{onClick:()=>z(h),disabled:!o||g||!h.trim(),style:{padding:"8px 14px",borderRadius:"8px",border:"none",background:"#1B3A4B",color:"#fff",fontSize:"12px",fontWeight:600,cursor:"pointer",flexShrink:0,opacity:!o||!h.trim()?.4:1,transition:"opacity 0.15s"},children:"Send"})]}),c.length>0&&e.jsx("button",{onClick:K,style:{marginTop:"6px",background:"none",border:"none",color:"#9CA3AF",fontSize:"11px",cursor:"pointer",padding:0},children:"Clear conversation"})]})]}):e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#9CA3AF"},children:"Waiting for model data…"})}function J({changes:o,approved:s,onToggle:f,onApply:r,onDiscard:y,applying:c}){const p=o.filter(l=>s.has(l.id)).length;return e.jsxs("div",{style:{marginLeft:"32px",border:"1px solid #FCD34D",borderRadius:"10px",background:"#FFFBEB",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid #FDE68A",fontSize:"11px",fontWeight:700,color:"#92400E"},children:[o.length," proposed change",o.length===1?"":"s"," — nothing is written until you apply"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:o.map(l=>e.jsxs("label",{style:{display:"flex",gap:"8px",alignItems:"flex-start",padding:"8px 12px",borderBottom:"1px solid #FDE68A",cursor:"pointer",fontSize:"12px"},children:[e.jsx("input",{type:"checkbox",checked:s.has(l.id),onChange:()=>f(l.id),style:{marginTop:"2px",cursor:"pointer"}}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:600,color:"#1B3A4B"},children:X(l)}),e.jsx("div",{style:{color:"#92400E",marginTop:"2px"},children:l.summary}),e.jsx(Z,{change:l})]})]},l.id))}),e.jsxs("div",{style:{padding:"8px 12px",display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx("button",{onClick:r,disabled:p===0||c,style:{padding:"6px 12px",borderRadius:"6px",border:"none",background:"#92400E",color:"#fff",fontSize:"11px",fontWeight:600,cursor:p===0||c?"default":"pointer",opacity:p===0||c?.4:1},children:c?"Applying…":`Apply ${p} selected`}),e.jsx("button",{onClick:y,disabled:c,style:{padding:"6px 12px",borderRadius:"6px",border:"1px solid #FDE68A",background:"transparent",color:"#92400E",fontSize:"11px",cursor:"pointer"},children:"Discard all"})]})]})}function X(o){switch(o.kind){case"create-element":return`Create ${o.elementKind} · ${o.elementId}`;case"update-element":return`Update · ${o.elementId}`;case"create-relationship":return`Relate · ${o.sourceId} → ${o.targetId}`;case"delete-relationship":return`Remove relationship · ${o.relationshipId}`}}function Z({change:o}){const s={fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"11px",color:"#374151",marginTop:"4px"};if(o.kind==="create-element"){const f=Object.entries(o.attributes??{});return e.jsxs("div",{style:s,children:[e.jsxs("div",{children:["name = ",o.name]}),o.layer&&e.jsxs("div",{children:["layer = ",o.layer]}),f.map(([r,y])=>e.jsxs("div",{children:[r," = ",y]},r))]})}if(o.kind==="update-element"){const f=new Set([...Object.keys(o.changes.attributes??{}),...o.changes.name!==void 0?["name"]:[],...o.changes.doc!==void 0?["doc"]:[]]);return e.jsx("div",{style:s,children:[...f].map(r=>{var p,l;const y=r==="name"?o.before.name:r==="doc"?o.before.doc:(p=o.before.attributes)==null?void 0:p[r],c=r==="name"?o.changes.name:r==="doc"?o.changes.doc:(l=o.changes.attributes)==null?void 0:l[r];return e.jsxs("div",{children:[r,": ",e.jsx("span",{style:{color:"#dc2626",textDecoration:"line-through"},children:y||"∅"})," → ",e.jsx("span",{style:{color:"#059669"},children:c})]},r)})})}return o.kind==="create-relationship"?e.jsxs("div",{style:s,children:[o.sourceId," —",o.relationshipType,"→ ",o.targetId]}):e.jsxs("div",{style:s,children:[o.sourceId," —",o.relationshipType,"→ ",o.targetId]})}function ee(){return e.jsxs("span",{style:{display:"inline-flex",gap:"3px",alignItems:"center"},children:[[0,1,2].map(o=>e.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)),e.jsx("style",{children:"@keyframes llm-pulse{0%,80%,100%{opacity:0.3}40%{opacity:1}}"})]})}export{se as ChatPanel};
@@ -1 +0,0 @@
1
- var Ss=Object.defineProperty;var ks=(t,i,n)=>i in t?Ss(t,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[i]=n;var Kt=(t,i,n)=>ks(t,typeof i!="symbol"?i+"":i,n);import{u as vn,j as e,H as C,P as j,N as St,a as eo,B as Sn,E as Qt,R as Es,b as Cs,c as Is,d as Ds,e as Ns,i as As,C as Rs,f as Bs,g as Ms,M as Ts}from"./reactflow-CsCqNKB-.js";import{b as Ls,a as d,W as on}from"./zustand-CrhqMOHB.js";/* empty css */import{F as N,S as ie,w as zs,u as L,f as kn,x as $s,g as Ws,D as nn,y as Ve,z as Os,i as sn,A as Ps,R as rn,V as an,C as ln}from"./index-BMgENwvO.js";import{c as _s,a as Hs,b as Ks,d as Vs,e as Ys,f as Us,g as Xs,h as Gs,i as qs,j as Zs,k as Qs,I as to,l as Js,P as Ft,s as ei,u as ti,m as oi,G as Vt,n as ni,o as si,C as En,p as ii,r as ri,q as Yt,v as ai,t as dn,w as li,x as di,y as ci,B as pi,z as ui,R as xi,A as hi}from"./layout-selection-ClQts3bC.js";import"./layout-providers-Dr743WlP.js";import"./elk-6l8mIQnQ.js";function gi(t,i,n="both",a=10){const r=t.elements[i];if(!r)return{rootId:i,rootName:"(unknown)",rootKind:"",nodes:[],edges:[]};const l=new Map,u=new Map;for(const p of t.relationships)l.has(p.sourceId)||l.set(p.sourceId,[]),l.get(p.sourceId).push(p),u.has(p.targetId)||u.set(p.targetId,[]),u.get(p.targetId).push(p);const m=new Set;m.add(i);const F=[],b=[],I=[[i,0]];for(;I.length>0;){const[p,y]=I.shift();if(y>=a)continue;const v=y+1;if(n==="downstream"||n==="both")for(const f of l.get(p)||[]){const k=f.targetId;if(b.push({fromId:p,toId:k,relType:f.type,relId:f.id}),!m.has(k)){m.add(k);const E=t.elements[k];E&&(F.push({elementId:k,name:E.name,kind:E.kind,layer:E.layer,depth:v,viaRelType:f.type,direction:"downstream"}),I.push([k,v]))}}if(n==="upstream"||n==="both")for(const f of u.get(p)||[]){const k=f.sourceId;if(b.push({fromId:k,toId:p,relType:f.type,relId:f.id}),!m.has(k)){m.add(k);const E=t.elements[k];E&&(F.push({elementId:k,name:E.name,kind:E.kind,layer:E.layer,depth:v,viaRelType:f.type,direction:"upstream"}),I.push([k,v]))}}}return F.sort((p,y)=>p.depth-y.depth||p.name.localeCompare(y.name)),{rootId:i,rootName:r.name,rootKind:r.kind,nodes:F,edges:b}}const Xe=Ls(t=>({subject:null,publish:i=>t({subject:i})})),Ue=t=>Xe.getState().publish(t),Cn=t=>{var i,n;return[t.source,t.target,(i=t.data)==null?void 0:i.sourcePortId,(n=t.data)==null?void 0:n.targetPortId].filter(a=>!!a)},fi=(t,i)=>t.edgeId===i.id||Cn(i).some(n=>t.endpointIds.includes(n)),oo=()=>Xe(t=>t.subject!==null),mi=t=>Xe(i=>{var n;return((n=i.subject)==null?void 0:n.endpointIds.includes(t))??!1}),In=(t,i)=>Xe(n=>{const a=n.subject;return a?a.edgeId===t||i.some(r=>r!==void 0&&a.endpointIds.includes(r)):!1}),bi=t=>`.react-flow__edge[data-id="${CSS.escape(t)}"]`;function yi(){const t=Xe(a=>a.subject),i=vn(a=>t?a.edges.filter(r=>fi(t,r)).map(r=>r.id).join("\0"):"");if(!t)return null;const n=i?i.split("\0").map(bi).join(","):"";return e.jsxs("style",{children:[".react-flow__edge{opacity:0.22;transition:opacity 120ms ease}",n?`${n}{opacity:1}`:""]})}class Fi{constructor(){Kt(this,"providers",[]);Kt(this,"byId",new Map)}register(i,n){const a=this.byId.get(i.descriptor.id);if(a&&a!==i)throw new Error(`Template provider already registered: ${i.descriptor.id}`);if(a)return;this.byId.set(i.descriptor.id,i);const r=n?this.providers.findIndex(l=>l.descriptor.id===n):-1;r>=0?this.providers.splice(r,0,i):this.providers.push(i)}unregister(i){const n=this.byId.get(i);return n?(this.byId.delete(i),this.providers.splice(this.providers.indexOf(n),1),!0):!1}get(i){return this.byId.get(i)}has(i){return this.byId.has(i)}list(){return this.providers.map(i=>i.descriptor)}select(i){const n=this.providers.find(a=>a.matches(i));if(!n)throw new Error("No diagram template matches this view — register a catch-all provider");return n}}const Dn=new Fi,wi=[{descriptor:{id:"memo.template.fbs",name:"Functional Breakdown",label:"FBS",contractVersion:"1",interactive:!0,description:"Functional breakdown structure — functions per realising component."},matches:t=>t.isFBSDiagram,compute:(t,i)=>_s(t,i.fbs)},{descriptor:{id:"memo.template.decomposition",name:"Decomposition Tree",label:"Decomposition",contractVersion:"1",interactive:!0,description:"Expandable decomposition tree over composition relationships."},matches:t=>t.isDecompDiagram&&t.layoutStyle==="decomposition",compute:(t,i)=>Hs(t,i.decomposition)},{descriptor:{id:"memo.template.containment",name:"Containment Blocks",label:"Containment",contractVersion:"1",interactive:!0,description:"Nested containment blocks over composition relationships."},matches:t=>t.isDecompDiagram,compute:(t,i)=>Ks(t,i.containment)},{descriptor:{id:"memo.template.usecase",name:"Use Case",label:"Use case",contractVersion:"1",interactive:!1,description:"Actors outside a system boundary, use cases inside (KK-7)."},matches:t=>t.diagramType==="ucd",compute:(t,i)=>Vs(t,i.useCase)},{descriptor:{id:"memo.template.context",name:"System Context",label:"Context",contractVersion:"1",interactive:!1,description:"Black-box system of interest with external actors and peer systems."},matches:t=>t.diagramType==="context",compute:(t,i)=>Ys(t,i.contextSystemName)},{descriptor:{id:"memo.template.interconnection",name:"Interconnection",label:"Interconnection",contractVersion:"1",interactive:!1,description:"IBD — parts with boundary ports, typed connectors, nested containment (KK-3)."},matches:t=>t.viewKind==="interconnection",compute:(t,i)=>Us(t,i.interconnection)},{descriptor:{id:"memo.template.actionflow",name:"Action Flow",label:"Action flow",contractVersion:"1",interactive:!1,description:"Actions with parameter ports, item flows, successions, optional swimlanes (KK-4)."},matches:t=>t.viewKind==="actionflow",compute:(t,i)=>Xs(t,i.actionflow)},{descriptor:{id:"memo.template.statetransition",name:"State Transition",label:"State transition",contractVersion:"1",interactive:!1,description:"Nested states with routed transition edges and trigger [guard] labels (KK-5)."},matches:t=>t.viewKind==="statetransition",compute:(t,i)=>Gs(t,i.statetransition)},{descriptor:{id:"memo.template.sequence",name:"Sequence",label:"Sequence",contractVersion:"1",interactive:!1,description:"Lifelines with chronological messages (KK-6)."},matches:t=>t.viewKind==="sequence",compute:(t,i)=>qs(t,i.sequence)},{descriptor:{id:"memo.template.general",name:"General (structured)",label:"General",contractVersion:"1",interactive:!0,description:"General template tree/containment modes (KK-2)."},matches:t=>t.isGeneralTemplate&&t.generalMode!=="graph",compute:(t,i)=>Zs(t,i.general)},{descriptor:{id:"memo.template.standard",name:"Standard Graph",label:"Standard",contractVersion:"1",interactive:!0,description:"Relationship graph with optional compartments — the catch-all."},matches:()=>!0,compute:(t,i)=>Qs(t,i.standard)}];for(const t of wi)Dn.register(t);function ji({data:t}){const i=t,{element:n,layerColor:a,isExpanded:r,hasChildren:l,childCount:u,direction:m,onToggleExpand:F,onToggleDirection:b,showDirectionButton:I,depthBgColor:p,isContainer:y}=i,v=m==="vertical"?"V":"H",f=y&&r;return e.jsxs("div",{style:{background:f?p||"#FAFAF9":"#FFFFFF",borderLeft:f?`2px solid ${a}40`:`3px solid ${a}`,borderTop:`1px solid ${f?a+"30":"#E5E5E0"}`,borderRight:`1px solid ${f?a+"30":"#E5E5E0"}`,borderBottom:`1px solid ${f?a+"30":"#E5E5E0"}`,borderRadius:3,padding:f?"0":"8px 12px",minWidth:f?void 0:"200px",boxShadow:"none",width:"100%",height:"100%",boxSizing:"border-box"},children:[e.jsx(C,{type:"target",position:j.Top,id:"top",style:ht}),e.jsx(C,{type:"source",position:j.Bottom,id:"bottom",style:ht}),e.jsx(C,{type:"target",position:j.Left,id:"left",style:ht}),e.jsx(C,{type:"source",position:j.Right,id:"right",style:ht}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:f?"8px 12px":"0"},children:[l&&e.jsx("button",{onClick:k=>{k.stopPropagation(),F()},style:{width:"20px",height:"20px",borderRadius:2,border:`1px solid ${a}`,background:r?a+"12":"#FFFFFF",color:a,fontSize:N.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:r?"Collapse":"Expand",children:r?"−":"+"}),l&&I&&e.jsx("button",{onClick:k=>{k.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: ${m}. Click to toggle`,children:v}),e.jsx("span",{style:{fontSize:N.md,fontWeight:600,color:f?a:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n.name})]}),!f&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginTop:"3px",paddingLeft:l?"26px":"14px"},children:[e.jsx("span",{style:{fontSize:N.badge,color:"#9CA3AF"},children:n.kind}),l&&e.jsxs("span",{style:{fontSize:"9px",color:"#6B7280",background:"#F0F0ED",padding:"1px 5px",borderRadius:2,fontWeight:600},children:[u," parts",r?"":" (collapsed)"]})]})]})}const ht={width:"8px",height:"8px",background:"#2DD4A8",border:"1.5px solid #FFFFFF",opacity:0},vi=d.memo(ji),cn={top:j.Top,bottom:j.Bottom,left:j.Left,right:j.Right},Si={top:"bottom",bottom:"top",left:"right",right:"left"},ki="#6B7280",Nn=t=>t?Ft[t]:ki;function An(t,i){if(t==="inout")return"⇄";if(!t)return"";const n=t==="in";switch(i){case"left":return n?"→":"←";case"right":return n?"←":"→";case"top":return n?"↓":"↑";default:return n?"↑":"↓"}}const Ei=104,pn=40,un=t=>({opacity:0,width:t,height:t,top:"50%",left:"50%",transform:"translate(-50%, -50%)",border:"none",background:"transparent",pointerEvents:"none"});function Ci({port:t,onMove:i}){const{getZoom:n}=eo(),a=vn(p=>p.transform[2]),r=mi(t.id),l=oo()&&!r,u=t.size??to,m=u+5,F=Nn(t.direction),b=t.side==="left"||t.side==="right",I={position:"absolute",fontSize:t.nested?"9.5px":"10.5px",fontWeight:r?750:t.nested?600:650,color:r?"#0F172A":t.nested?"#6B7280":"#374151",opacity:l?.45:1,transition:"color 120ms ease, opacity 120ms ease",whiteSpace:"normal",pointerEvents:"none",overflow:"hidden",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:2,width:b?Ei:72,background:"rgba(255,255,255,0.94)",padding:"1px 3px",borderRadius:4,lineHeight:1.12,...t.side==="left"?{left:m,bottom:"50%",marginBottom:2}:t.side==="right"?{right:m,bottom:"50%",marginBottom:2,textAlign:"right"}:t.side==="top"?{top:m,left:"50%",transform:"translateX(-50%)"}:{bottom:m,left:"50%",transform:"translateX(-50%)"}};return e.jsxs("div",{className:"nodrag nopan",style:{position:"absolute",left:t.x,top:t.y,width:u,height:u,zIndex:t.nested?11:10},children:[e.jsx("div",{onPointerEnter:()=>Ue({endpointIds:[t.id]}),onPointerLeave:()=>Ue(null),onPointerDown:i?p=>{p.preventDefault(),p.stopPropagation();const y=p.clientY,v=t.y,f=E=>i(v+(E.clientY-y)/n()),k=()=>{window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",k)};window.addEventListener("pointermove",f),window.addEventListener("pointerup",k,{once:!0})}:void 0,title:`${t.name}${t.direction?` (${t.direction})`:""}`,style:{position:"absolute",left:"50%",top:"50%",width:pn,height:pn,transform:`translate(-50%, -50%) scale(${1/Math.max(a,.1)})`,cursor:i?"grab":"default",touchAction:"none"}}),e.jsxs("div",{style:{position:"absolute",inset:0,boxSizing:"border-box",background:"#FFFFFF",border:`2px solid ${F}`,borderRadius:5,boxShadow:r?`0 0 0 4px ${F}33, 0 2px 8px rgba(15,23,42,0.24)`:"0 1px 3px rgba(15,23,42,0.18)",opacity:l?.5:1,display:"flex",alignItems:"center",justifyContent:"center",color:F,fontSize:t.nested?"10px":"12px",fontWeight:800,lineHeight:1,pointerEvents:"none",transition:"box-shadow 120ms ease, opacity 120ms ease"},children:[An(t.direction,t.side),e.jsx("span",{style:I,children:t.name.replace(/([a-z0-9])([A-Z])/g,"$1​$2")}),[{suffix:"",pos:cn[t.side]},{suffix:Js,pos:cn[Si[t.side]]}].flatMap(p=>[e.jsx(C,{className:"ibd-port-anchor",type:"source",id:`${t.id}${p.suffix}`,position:p.pos,style:un(u),isConnectable:!1},`s${p.suffix}`),e.jsx(C,{className:"ibd-port-anchor",type:"target",id:`${t.id}${p.suffix}`,position:p.pos,style:un(u),isConnectable:!1},`t${p.suffix}`)])]})]})}function xn({side:t,direction:i}){const n=Nn(i),a=to;return e.jsx("div",{"aria-label":`implicit ${i} port`,title:`Implicit ${i} port — relationship targets the part directly`,style:{position:"absolute",top:"50%",left:t==="left"?-a/2:void 0,right:t==="right"?-a/2:void 0,transform:"translateY(-50%)",width:a,height:a,boxSizing:"border-box",background:"#FFFFFF",border:`2px solid ${n}`,borderRadius:4,boxShadow:"0 1px 3px rgba(15,23,42,0.18)",display:"flex",alignItems:"center",justifyContent:"center",color:n,fontSize:11,fontWeight:800,lineHeight:1,zIndex:4,pointerEvents:"none"},children:An(i,t)})}const gt={width:8,height:8,background:"#2DD4A8",border:"1.5px solid #FFFFFF",opacity:0};function hn({name:t,kind:i,nameColor:n,typeColor:a,frame:r=!1}){return e.jsxs("span",{title:`${t} : ${i}`,style:{display:"flex",flexDirection:r?"row":"column",alignItems:r?"baseline":"flex-start",gap:r?6:1,minWidth:0,overflow:"hidden",flex:1},children:[e.jsx("span",{style:{display:r?"block":"-webkit-box",width:"100%",minWidth:0,fontSize:r?N.md:N.sm,lineHeight:1.2,fontWeight:700,color:n,whiteSpace:r?"nowrap":"normal",overflow:"hidden",textOverflow:"ellipsis",WebkitBoxOrient:"vertical",WebkitLineClamp:r?void 0:2,overflowWrap:"anywhere"},children:t}),e.jsx("span",{style:{display:"block",maxWidth:"100%",fontSize:"9px",lineHeight:1.15,fontWeight:650,letterSpacing:"0.055em",textTransform:"uppercase",color:a,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r?`: ${i}`:`«${i}»`})]})}function gn({label:t,isCollapsed:i,onToggle:n,color:a,onColor:r}){return e.jsx("button",{"aria-label":i?`Expand ${t}`:`Collapse ${t}`,onClick:l=>{l.stopPropagation(),n()},style:{marginLeft:"auto",width:18,height:18,padding:0,borderRadius:3,border:r?"1px solid rgba(255,255,255,0.7)":`1px solid ${a}88`,background:r?"rgba(255,255,255,0.18)":"#FFFFFF",color:r?"#FFFFFF":a,fontSize:13,lineHeight:"15px",cursor:"pointer",fontWeight:700,flexShrink:0},children:i?"+":"−"})}function Ii({id:t,data:i,selected:n,height:a}){const r=i,{label:l,kind:u,color:m,isContainer:F,isFrame:b,ports:I,implicitIn:p,implicitOut:y,onPortMove:v,hasChildren:f,isCollapsed:k,onToggleCollapse:E}=r,[D,O]=d.useState(!1),T=n?ie.selected:b?"none":D?"0 8px 20px rgba(15,23,42,0.12)":F?"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?m+"9A":"#CBD5E1"}`,...b?{}:{borderTop:`3px solid ${m}`},borderRadius:b?10:8,boxShadow:T,transition:"box-shadow 150ms ease, border-color 150ms ease",position:"relative"},children:[!b&&e.jsx(St,{nodeId:t,isVisible:n,minWidth:180,minHeight:100,color:"#2563EB",lineStyle:{borderWidth:1},handleStyle:{width:10,height:10,borderRadius:2}}),e.jsx(C,{type:"target",position:j.Top,id:"top",style:gt}),e.jsx(C,{type:"source",position:j.Bottom,id:"bottom",style:gt}),e.jsx(C,{type:"target",position:j.Left,id:"left",style:gt}),e.jsx(C,{type:"source",position:j.Right,id:"right",style:gt}),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:m,color:"#FFFFFF",fontSize:9,fontWeight:800,letterSpacing:"0.08em"},children:"IBD"}),e.jsx(hn,{name:l,kind:u,nameColor:"#0F172A",typeColor:"#64748B",frame:!0}),f&&E&&e.jsx(gn,{label:l,isCollapsed:k,onToggle:E,color:m})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minHeight:58,padding:"7px 10px 6px",background:"#FFFFFF",borderBottom:f?"1px solid #E2E8F0":"none",borderRadius:"7px 7px 0 0",overflow:"hidden"},children:[e.jsx(hn,{name:l,kind:u,nameColor:"#0F172A",typeColor:F?m:"#64748B"}),f&&E&&e.jsx(gn,{label:l,isCollapsed:k,onToggle:E,color:m})]}),I.map(A=>e.jsx(Ci,{port:A,onMove:v?K=>{const Z=A.size??to,_=(b||F?70:62)-Z/2,z=Math.max(_,(a??_+Z+18)-Z-18);v(A.id,Math.min(Math.max(K,_),z))}:void 0},A.id)),p&&e.jsx(xn,{side:"left",direction:"in"}),y&&e.jsx(xn,{side:"right",direction:"out"})]})}const Di=d.memo(Ii);function fn(t,i){const n=t.map(r=>({...r}));let a=i;for(;n.length>=2&&a>0;){const r=n[0],l=n[1],u=Math.hypot(l.x-r.x,l.y-r.y);if(u<=a)a-=u,n.shift();else{const m=a/u;n[0]={x:r.x+(l.x-r.x)*m,y:r.y+(l.y-r.y)*m},a=0}}return n}function Ni(t,i){const n=fn(t,i);return fn([...n].reverse(),i).reverse()}const Ai=t=>t.slice(1).reduce((i,n,a)=>i+Math.hypot(n.x-t[a].x,n.y-t[a].y),0);function ft(t,i=7){if(t.length<2)return"";let n=`M ${t[0].x},${t[0].y}`;for(let r=1;r<t.length-1;r++){const l=t[r-1],u=t[r],m=t[r+1],F=Math.hypot(u.x-l.x,u.y-l.y),b=Math.hypot(m.x-u.x,m.y-u.y),I=Math.min(i,F/2,b/2),p=u.x-Math.sign(u.x-l.x)*I,y=u.y-Math.sign(u.y-l.y)*I,v=u.x+Math.sign(m.x-u.x)*I,f=u.y+Math.sign(m.y-u.y)*I;n+=` L ${p},${y} Q ${u.x},${u.y} ${v},${f}`}const a=t[t.length-1];return`${n} L ${a.x},${a.y}`}function Ri(t){let i=0,n=-1;for(let u=1;u<t.length;u++){const m=Math.abs(t[u].x-t[u-1].x)+Math.abs(t[u].y-t[u-1].y);m>n&&(n=m,i=u)}const a=t[i-1],r=t[i],l=Math.abs(r.x-a.x)>=Math.abs(r.y-a.y)?{x:0,y:-14}:{x:14,y:0};return{x:(a.x+r.x)/2+l.x,y:(a.y+r.y)/2+l.y}}function Bi(t){var k,E,D,O,T,A,K,Z,_,z,re;const{getZoom:i}=eo(),n=In(t.id,[t.source,t.target,(k=t.data)==null?void 0:k.sourcePortId,(E=t.data)==null?void 0:E.targetPortId]),a=oo()&&!n,r=((D=t.data)==null?void 0:D.points)??[];if(r.length<2)return null;const l=String(((O=t.style)==null?void 0:O.stroke)??"#2563EB"),u=Number(((T=t.style)==null?void 0:T.strokeWidth)??2),m=n?{...t.style,strokeWidth:u+1.4}:t.style,F=((A=t.data)==null?void 0:A.labelPoint)??Ri(r),b=Math.min(28/Math.max(i(),.1),Ai(r)*.3),I=Ni(r,b),p=(K=t.data)==null?void 0:K.onRouteChange,y=(Z=t.data)==null?void 0:Z.onSelect,v=!!((_=t.data)!=null&&_.flowAnimation),f=r.length===2?[{index:1,a:r[0],b:r[1],straight:!0}]:r.slice(1).map((w,pe)=>({index:pe+1,a:r[pe],b:w,straight:!1})).filter(w=>w.index>=2&&w.index<=r.length-2);return e.jsxs(e.Fragment,{children:[n&&e.jsx("path",{d:ft(r),fill:"none",stroke:l,strokeOpacity:.22,strokeWidth:u+9,strokeLinecap:"round",pointerEvents:"none"}),e.jsx(Sn,{id:t.id,path:ft(r),style:m,markerEnd:t.markerEnd}),v&&e.jsx("path",{d:ft(r),fill:"none",stroke:String(((z=t.style)==null?void 0:z.stroke)??"#2563EB"),strokeWidth:Math.max(2,Number(((re=t.style)==null?void 0:re.strokeWidth)??2)),className:"memo-ibd-flow"}),I.length>=2&&e.jsx("path",{d:ft(I),fill:"none",stroke:"transparent",strokeWidth:18/Math.max(i(),.1),pointerEvents:"stroke",cursor:"pointer",onClick:w=>y==null?void 0:y(w)}),t.label?e.jsx(Qt,{children:e.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${F.x}px, ${F.y}px)`,fontSize:N.badge,fontWeight:n?700:600,color:n?"#0F172A":"#475569",background:"rgba(255,255,255,0.96)",border:`1px solid ${n?l:"#E2E8F0"}`,opacity:a?.25:1,padding:"1px 4px",borderRadius:4,pointerEvents:"none"},children:t.label})}):null,t.selected&&p?f.map(w=>{const pe=(w.a.x+w.b.x)/2,ee=(w.a.y+w.b.y)/2;return e.jsx(Qt,{children:e.jsx("div",{className:"nodrag nopan",title:"Drag connector segment",onPointerDown:U=>{U.preventDefault(),U.stopPropagation();const Ge=U.clientX,qe=U.clientY,ye=Ee=>{const ne=(Ee.clientX-Ge)/i(),ue=(Ee.clientY-qe)/i();if(w.straight){if(Math.abs(ue)>=Math.abs(ne)){const se=w.a.y+ue;p([w.a,{x:w.a.x,y:se},{x:w.b.x,y:se},w.b])}else{const se=(w.a.x+w.b.x)/2+ne;p([w.a,{x:se,y:w.a.y},{x:se,y:w.b.y},w.b])}return}const G=r.map(se=>({...se}));w.a.y===w.b.y?(G[w.index-1].y=w.a.y+ue,G[w.index].y=w.b.y+ue):(G[w.index-1].x=w.a.x+ne,G[w.index].x=w.b.x+ne),p(G)},ke=()=>{window.removeEventListener("pointermove",ye),window.removeEventListener("pointerup",ke)};window.addEventListener("pointermove",ye),window.addEventListener("pointerup",ke,{once:!0})},style:{position:"absolute",transform:`translate(-50%, -50%) translate(${pe}px, ${ee}px)`,width:12,height:12,borderRadius:3,background:"#FFFFFF",border:"2px solid #2563EB",boxShadow:"0 1px 4px rgba(15,23,42,0.22)",cursor:w.a.y===w.b.y?"ns-resize":"ew-resize",pointerEvents:"all",touchAction:"none",zIndex:20}})},`route-${w.index}`)}):null]})}const Mi=d.memo(Bi);function Ti({onDrillIn:t,color:i,label:n}){return e.jsx("button",{onClick:a=>{a.stopPropagation(),t()},onDoubleClick:a=>a.stopPropagation(),className:"nodrag",title:`Open ${n} as its own diagram`,"aria-label":`Drill into ${n}`,style:{width:16,height:16,flexShrink:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${i}66`,borderRadius:4,background:"#FFFFFF",color:i,fontSize:10,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"↳"})}function Li({data:t,selected:i}){const n=t,{nodeType:a,label:r,laneColor:l,layerColor:u,inPorts:m,outPorts:F}=n,[b,I]=d.useState(!1);if(a==="start")return e.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:"#374151",border:"2px solid #374151",boxShadow:ie.sm},children:e.jsx(C,{type:"source",position:n.flowDirection==="vertical"?j.Bottom:j.Right,style:{background:"#374151",width:6,height:6}})});if(a==="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:ie.sm},children:[e.jsx("div",{style:{width:14,height:14,borderRadius:"50%",background:"#374151"}}),e.jsx(C,{type:"target",position:n.flowDirection==="vertical"?j.Top:j.Left,style:{background:"#374151",width:6,height:6}})]});if(a==="fork"||a==="join"){const f=n.flowDirection==="vertical";return e.jsxs("div",{title:a==="fork"?"Fork — split into concurrent flows":"Join — synchronize concurrent flows",style:{width:"100%",height:"100%",background:"#374151",borderRadius:3,boxShadow:ie.sm},children:[e.jsx(C,{type:"target",position:f?j.Top:j.Left,style:{background:"#374151",width:6,height:6,border:"none"}}),e.jsx(C,{type:"source",position:f?j.Bottom:j.Right,style:{background:"#374151",width:6,height:6,border:"none"}})]})}const p=l||u||"#9CA3AF";if(n.isFrame)return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:`${p}08`,border:`1.5px solid ${p}66`,borderRadius:10,boxShadow:i?"0 0 0 3px #2DD4A8":"none",position:"relative"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px 0"},children:[n.onToggleExpand&&e.jsx("button",{"aria-label":`Collapse ${r}`,className:"nodrag",onClick:f=>{f.stopPropagation(),n.onToggleExpand()},onDoubleClick:f=>f.stopPropagation(),style:{width:16,height:16,flexShrink:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${p}66`,borderRadius:4,background:"#FFFFFF",color:p,fontSize:11,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"−"}),n.onDrillIn&&e.jsx(Ti,{onDrillIn:n.onDrillIn,color:p,label:r}),e.jsx("span",{style:{fontSize:N.md,fontWeight:700,color:p,whiteSpace:"nowrap"},children:r}),n.allocatedTo&&e.jsxs("span",{style:{fontSize:"9px",color:"#9CA3AF",whiteSpace:"nowrap"},children:["→"," ",n.allocatedTo]})]}),e.jsx(C,{type:"target",position:n.flowDirection==="vertical"?j.Top:j.Left,style:{background:p,width:8,height:8,border:"2px solid #FFFFFF"}}),e.jsx(C,{type:"source",position:n.flowDirection==="vertical"?j.Bottom:j.Right,style:{background:p,width:8,height:8,border:"2px solid #FFFFFF"}})]});const y=18,v=Math.max(m.length*y,F.length*y,0);return e.jsxs("div",{onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),style:{background:"#FFFFFF",border:`1.5px solid ${p}`,borderRadius:3,minWidth:"140px",boxShadow:i?"0 0 0 3px #2DD4A8, 0 4px 12px rgba(45, 212, 168, 0.35)":b?`0 0 0 2px ${p}22`:"none",transition:"box-shadow 150ms ease",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"8px 14px",fontSize:N.md,fontWeight:600,color:"#1a1a1a",background:`${p}0D`,borderBottom:v>0?"1px solid #E5E5E0":"none",textAlign:"center",whiteSpace:"nowrap"},children:[r,n.hasChildren&&n.onDrillIn&&e.jsx("button",{"aria-label":`Drill into ${r}`,title:`Open ${r} as its own diagram`,className:"nodrag",onClick:f=>{f.stopPropagation(),n.onDrillIn()},onDoubleClick:f=>f.stopPropagation(),style:{float:"right",marginLeft:4,width:18,height:18,padding:0,border:`1px solid ${p}`,borderRadius:2,background:"#FFFFFF",color:p,fontSize:11,fontWeight:700,lineHeight:"16px",cursor:"pointer"},children:"↳"}),n.hasChildren&&n.onToggleExpand&&e.jsx("button",{"aria-label":n.isExpanded?`Collapse ${r}`:`Expand ${r}`,onClick:f=>{f.stopPropagation(),n.onToggleExpand()},style:{float:"right",marginLeft:8,width:18,height:18,padding:0,border:`1px solid ${p}`,borderRadius:2,background:"#FFFFFF",color:p,fontSize:13,fontWeight:700,lineHeight:"16px",cursor:"pointer"},children:n.isExpanded?"−":"+"})]}),v>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:m.map(f=>e.jsxs("div",{style:{fontSize:N.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}}),f]},`in-${f}`))}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"2px",alignItems:"flex-end"},children:F.map(f=>e.jsxs("div",{style:{fontSize:N.badge,color:"#6B7280",paddingRight:"8px",display:"flex",alignItems:"center",height:`${y}px`,gap:"4px"},children:[f,e.jsx("span",{style:{width:"6px",height:"6px",borderRadius:"50%",background:"#E67E22",flexShrink:0}})]},`out-${f}`))})]}),n.allocatedTo&&e.jsxs("div",{style:{fontSize:"9px",color:"#9CA3AF",textAlign:"center",padding:"2px 6px",borderTop:"1px solid #F3F4F6",background:"#FAFAFA"},children:["→"," ",n.allocatedTo]}),e.jsx(C,{type:"target",position:n.flowDirection==="vertical"?j.Top:j.Left,style:{background:p,width:8,height:8,border:"2px solid #FFFFFF"}}),e.jsx(C,{type:"source",position:n.flowDirection==="vertical"?j.Bottom:j.Right,style:{background:p,width:8,height:8,border:"2px solid #FFFFFF"}})]})}const zi=d.memo(Li);function $i({data:t,selected:i}){const n=t,a=n.orientation==="column";return e.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:`${n.color}08`,border:i?"3px solid #2DD4A8":`1px solid ${n.color}30`,borderLeft:i?"3px solid #2DD4A8":a?`1px solid ${n.color}30`:`3px solid ${n.color}`,borderTop:i?"3px solid #2DD4A8":a?`3px solid ${n.color}`:`1px solid ${n.color}30`,borderRadius:zs.md,pointerEvents:"auto",cursor:n.inspectElementId?"pointer":"default",display:"flex"},children:e.jsx("div",{style:{writingMode:a?"horizontal-tb":"vertical-rl",transform:a?void 0:"rotate(180deg)",padding:a?"7px 10px":"10px 6px",fontSize:N.xs,fontWeight:700,color:n.color,letterSpacing:"0.04em",textTransform:"uppercase",alignSelf:a?"flex-start":"center",width:a?"100%":void 0,textAlign:a?"center":void 0,whiteSpace:"nowrap"},children:n.label})})}const Wi=d.memo($i);function mn({onDrillIn:t,color:i,label:n}){return e.jsx("button",{onClick:a=>{a.stopPropagation(),t()},onDoubleClick:a=>a.stopPropagation(),className:"nodrag",title:`Open ${n} as its own diagram`,"aria-label":`Drill into ${n}`,style:{width:16,height:16,flexShrink:0,padding:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${i}66`,borderRadius:4,background:"#FFFFFF",color:i,fontSize:10,fontWeight:700,lineHeight:1,cursor:"pointer"},children:"↳"})}function bn({collapsed:t,onToggle:i,color:n}){return e.jsx("button",{onClick:a=>{a.stopPropagation(),i()},onDoubleClick:a=>a.stopPropagation(),className:"nodrag",title:t?"Show substates":"Hide substates","aria-label":t?"Show substates":"Hide substates",style:{width:16,height:16,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${n}66`,borderRadius:4,background:"#FFFFFF",color:n,fontSize:11,fontWeight:700,lineHeight:1,cursor:"pointer"},children:t?"+":"−"})}const mt={width:8,height:8,border:"none",background:"transparent",opacity:0};function Ut(){return e.jsxs(e.Fragment,{children:[e.jsx(C,{type:"target",position:j.Top,id:"top",style:mt}),e.jsx(C,{type:"source",position:j.Bottom,id:"bottom",style:mt}),e.jsx(C,{type:"target",position:j.Left,id:"left",style:mt}),e.jsx(C,{type:"source",position:j.Right,id:"right",style:mt})]})}function Oi({data:t,selected:i}){const n=t,[a,r]=d.useState(!1);if(n.isNote)return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#FFFDF5",border:`1px solid ${n.color}66`,borderRadius:4,padding:"6px 10px",boxShadow:ie.sm,display:"flex",flexDirection:"column",justifyContent:"center"},title:n.kind,children:[e.jsx(Ut,{}),e.jsx("span",{style:{fontSize:N.xs,fontWeight:600,color:"#374151",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n.label}),e.jsx("span",{style:{fontSize:"8px",fontWeight:700,color:n.color,textTransform:"uppercase",letterSpacing:"0.05em"},children:n.kind})]});if(n.isContainer)return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",background:n.isMachine?"transparent":`${n.color}06`,borderTop:n.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${n.color}55`,borderRight:n.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${n.color}55`,borderBottom:n.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${n.color}55`,borderLeft:n.isMachine?"1.5px dashed #CBD5E1":`1.5px solid ${n.color}55`,borderRadius:14,boxShadow:i?ie.selected:"none",position:"relative"},children:[e.jsx(Ut,{}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px 0"},children:[n.onToggleCollapse&&!n.isMachine&&e.jsx(bn,{collapsed:!1,onToggle:n.onToggleCollapse,color:n.color}),n.onDrillIn&&!n.isMachine&&e.jsx(mn,{onDrillIn:n.onDrillIn,color:n.color,label:n.label}),e.jsx("span",{style:{fontSize:N.md,fontWeight:700,color:n.isMachine?"#334155":n.color,whiteSpace:"nowrap"},children:n.label}),e.jsx("span",{style:{fontSize:"8px",fontWeight:700,color:n.isMachine?"#94A3B8":`${n.color}AA`,textTransform:"uppercase",letterSpacing:"0.06em"},children:n.kind})]})]});const l=!!n.hasChildren;return e.jsxs("div",{onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),title:l?`${n.hiddenCount??0} substate${n.hiddenCount===1?"":"s"} hidden — double-click to drill in`:void 0,style:{width:"100%",height:"100%",boxSizing:"border-box",background:"#FFFFFF",borderTop:`3px solid ${n.color}`,borderRight:`1px solid ${a?`${n.color}9A`:"#CBD5E1"}`,borderBottom:`1px solid ${a?`${n.color}9A`:"#CBD5E1"}`,borderLeft:`1px solid ${a?`${n.color}9A`:"#CBD5E1"}`,borderRadius:12,boxShadow:i?ie.selected:a?"0 8px 20px rgba(15,23,42,0.12)":ie.md,transition:"box-shadow 150ms ease, border-color 150ms ease",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,padding:"4px 12px"},children:[e.jsx(Ut,{}),e.jsx("span",{style:{fontSize:N.md,fontWeight:600,color:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:n.label}),n.subtitle&&e.jsx("span",{style:{fontSize:"8px",fontWeight:600,color:"#9CA3AF",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:n.subtitle}),l&&e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5},children:[n.onToggleCollapse&&e.jsx(bn,{collapsed:!0,onToggle:n.onToggleCollapse,color:n.color}),n.onDrillIn&&e.jsx(mn,{onDrillIn:n.onDrillIn,color:n.color,label:n.label}),e.jsxs("span",{style:{fontSize:"8px",fontWeight:700,color:n.color,letterSpacing:"0.05em"},children:["⊞ ",n.hiddenCount??0]})]})]})}const Pi=d.memo(Oi),Jt="#3498DB";function _i({data:t}){const i=t;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 ${Jt}`,borderRadius:8,boxShadow:ie.md,textAlign:"center",fontSize:N.md,fontWeight:600,color:"#1a1a1a",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i.label}),e.jsx("div",{style:{position:"absolute",top:44,bottom:0,left:"50%",borderLeft:`1.5px dashed ${Jt}66`}})]})}const Hi=d.memo(_i);function Ki({data:t}){const i=t;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:N.sm,fontWeight:700,color:"#1B3A4B"},children:i.label}),i.scenario&&e.jsxs("span",{style:{fontSize:N.xs,color:"#6B7280"},children:["realizes ",i.scenario]})]})})}const Vi=d.memo(Ki),bt={width:6,height:6,border:"none",background:"transparent",opacity:0};function Yi({data:t,selected:i}){const n=t;return e.jsxs("div",{style:{width:14,height:14,borderRadius:"50%",background:"#FFFFFF",border:`3px solid ${Jt}`,boxShadow:i?ie.selected:ie.sm,position:"relative"},title:n.kind,children:[e.jsx(C,{type:"source",id:"right",position:j.Right,style:bt}),e.jsx(C,{type:"target",id:"right",position:j.Right,style:bt}),e.jsx(C,{type:"source",id:"left",position:j.Left,style:bt}),e.jsx(C,{type:"target",id:"left",position:j.Left,style:bt}),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:n.label})]})}const Ui=d.memo(Yi),jt={opacity:0,width:1,height:1},Xi=d.memo(function({data:i}){const n=i;return e.jsxs("div",{style:{width:"100%",height:"100%",display:"grid",placeItems:"center",textAlign:"center",padding:"12px 22px",border:`2px solid ${n.color??"#E67E22"}`,borderRadius:"50%",background:"#FFF9F2",color:"#2D3748",fontSize:13,fontWeight:600,lineHeight:1.25},children:[n.label,e.jsx(C,{type:"target",position:j.Left,style:jt}),e.jsx(C,{type:"source",position:j.Right,style:jt})]})}),Gi=d.memo(function({data:i}){const n=i,a=n.side==="right"?j.Left:j.Right;return e.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#334155",fontSize:12,fontWeight:600,textAlign:"center",gap:3},children:[e.jsxs("svg",{width:"38",height:"54",viewBox:"0 0 38 54","aria-hidden":"true",fill:"none",stroke:n.color??"#334155",strokeWidth:"2",children:[e.jsx("circle",{cx:"19",cy:"8",r:"6",fill:"#FFFFFF"}),e.jsx("path",{d:"M19 14v18M6 23h26M19 32L8 49M19 32l11 17",strokeLinecap:"round"})]}),e.jsx("span",{children:n.label}),e.jsx(C,{type:"source",position:a,style:jt}),e.jsx(C,{type:"target",position:a,style:jt})]})}),qi=d.memo(function({data:i}){const n=i;return e.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",border:"1.5px solid #64748B",background:"rgba(255,255,255,0.32)",padding:"10px 14px",color:"#475569",fontSize:12,fontWeight:700},children:n.label})});d.memo(function({data:i}){const n=i;return e.jsx("div",{style:{width:"100%",textAlign:"center",color:"#64748B",fontSize:11,fontWeight:700,letterSpacing:".03em"},children:n.label})});function Zi(t,i=0){if(t.length<2)return"";if(i===0||t.length===2)return`M ${t.map(r=>`${r.x},${r.y}`).join(" L ")}`;let n=`M ${t[0].x},${t[0].y}`;for(let r=1;r<t.length-1;r++){const l=t[r-1],u=t[r],m=t[r+1],F=Math.min(i,Math.abs(u.x-l.x)/2+Math.abs(u.y-l.y)/2),b=Math.min(i,Math.abs(m.x-u.x)/2+Math.abs(m.y-u.y)/2),I={x:u.x+Math.sign(l.x-u.x)*F,y:u.y+Math.sign(l.y-u.y)*F},p={x:u.x+Math.sign(m.x-u.x)*b,y:u.y+Math.sign(m.y-u.y)*b};n+=` L ${I.x},${I.y} Q ${u.x},${u.y} ${p.x},${p.y}`}const a=t[t.length-1];return`${n} L ${a.x},${a.y}`}const Qi=d.memo(function(i){var y,v,f,k,E;const n=In(i.id,[i.source,i.target]),a=oo()&&!n,r=((y=i.data)==null?void 0:y.routing)??"rounded",l=Array.isArray((v=i.data)==null?void 0:v.points)?i.data.points:[],u=l.length>=2?l:[{x:i.sourceX,y:i.sourceY},{x:i.targetX,y:i.targetY}],F=r==="straight"?`M ${i.sourceX},${i.sourceY} L ${i.targetX},${i.targetY}`:Zi(u,r==="elbow"?0:r==="rounded"?16:r==="curved"?30:42),b=((f=i.data)==null?void 0:f.labelPoint)??u[Math.floor(u.length/2)]??{x:(i.sourceX+i.targetX)/2,y:(i.sourceY+i.targetY)/2},I=String(((k=i.style)==null?void 0:k.stroke)??"#64748B"),p=Number(((E=i.style)==null?void 0:E.strokeWidth)??1.5);return e.jsxs(e.Fragment,{children:[n&&e.jsx("path",{d:F,fill:"none",stroke:I,strokeOpacity:.22,strokeWidth:p+9,strokeLinecap:"round",pointerEvents:"none"}),e.jsx(Sn,{path:F,style:n?{...i.style,strokeWidth:p+1.4}:i.style}),i.label&&e.jsx(Qt,{children:e.jsx("div",{className:"nodrag nopan",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${b.x}px,${b.y}px)`,background:"#FFFFFF",padding:"2px 5px",borderRadius:3,color:n?"#0F172A":"#334155",fontSize:12,pointerEvents:"all",fontWeight:n?700:void 0,opacity:a?.25:1},children:i.label})})]})}),yt={opacity:0,width:1,height:1};function Rn(){return e.jsxs(e.Fragment,{children:[e.jsx(C,{type:"target",position:j.Left,style:yt}),e.jsx(C,{type:"source",position:j.Right,style:yt}),e.jsx(C,{type:"target",position:j.Top,style:yt}),e.jsx(C,{type:"source",position:j.Bottom,style:yt})]})}const Ji=d.memo(function({data:i}){const n=i;return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",display:"grid",placeItems:"center",padding:"14px 18px",textAlign:"center",border:"2px solid #0F766E",borderRadius:8,background:"#F0FDFA",color:"#134E4A",fontSize:15,fontWeight:700,lineHeight:1.25,boxShadow:"0 2px 7px rgba(15, 118, 110, 0.16)"},children:[e.jsxs("span",{children:[e.jsx("small",{style:{display:"block",marginBottom:5,color:"#0F766E",fontSize:10,letterSpacing:".08em"},children:"SYSTEM OF INTEREST"}),n.label]}),e.jsx(Rn,{})]})}),er=d.memo(function({data:i}){const n=i,a=n.category==="environment"?{border:"#7C3AED",fill:"#F5F3FF",text:"#4C1D95",tag:"ENVIRONMENT"}:n.category==="person"?{border:"#2563EB",fill:"#EFF6FF",text:"#1E3A8A",tag:"ACTOR"}:{border:"#64748B",fill:"#F8FAFC",text:"#334155",tag:"EXTERNAL SYSTEM"};return e.jsxs("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",display:"grid",placeItems:"center",padding:"10px 14px",textAlign:"center",border:`1.5px solid ${a.border}`,borderRadius:7,background:a.fill,color:a.text,fontSize:13,fontWeight:650,lineHeight:1.25},children:[e.jsxs("span",{children:[e.jsx("small",{style:{display:"block",marginBottom:4,color:a.border,fontSize:9,letterSpacing:".07em"},children:a.tag}),n.label]}),e.jsx(Rn,{})]})}),tr=d.memo(function({data:i}){const n=i;return e.jsx("div",{style:{width:"100%",height:"100%",boxSizing:"border-box",border:"2px solid #0F766E",borderRadius:12,background:"rgba(240, 253, 250, 0.34)",padding:"12px 16px",color:"#0F766E",fontSize:12,fontWeight:750,letterSpacing:".04em"},children:n.label})}),or=d.memo(function({id:i,data:n,selected:a}){var T;const r=n,[l,u]=d.useState(!1),[m,F]=d.useState(""),[b,I]=d.useState(!1),p=d.useRef(null),y=d.useCallback(()=>{F(r.label),u(!0),setTimeout(()=>{var A;(A=p.current)==null||A.select()},10)},[r.label]),v=d.useCallback(()=>{var K;u(!1);const A=m.trim();A&&A!==r.label&&((K=r.onInlineEdit)==null||K.call(r,i,A))},[m,r,i]),f=d.useCallback(A=>{A.key==="Enter"&&(A.preventDefault(),v()),A.key==="Escape"&&u(!1)},[v]),k=d.useCallback(A=>{var K;A.preventDefault(),(K=r.onContextMenu)==null||K.call(r,A,i)},[r,i]),E=r.bgColor??"#FFFFFF",D=r.color,O={background:D,border:"2px solid #FFFFFF",width:10,height:10,opacity:b||a?1:0,transition:"opacity 0.15s"};return e.jsxs("div",{onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),onContextMenu:k,onDoubleClick:y,style:{minWidth:120,minHeight:40,background:E,borderLeft:`3px solid ${D}`,borderRadius:8,boxShadow:a?`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:l?"text":"grab",position:"relative",transition:"box-shadow 0.15s",opacity:r.isNew?.7:1},children:[a&&e.jsx(St,{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:r.kind}),l?e.jsx("input",{ref:p,value:m,onChange:A=>F(A.target.value),onBlur:v,onKeyDown:f,onClick:A=>A.stopPropagation(),autoFocus:!0,style:{fontSize:N.sm,fontWeight:500,color:"#1a1a1a",background:"transparent",border:"none",outline:"none",width:"100%",padding:0}}):e.jsx("div",{style:{fontSize:N.sm,fontWeight:500,color:"#1a1a1a",lineHeight:1.3,wordBreak:"break-word"},children:r.label||r.kind}),r.isNew&&e.jsx("div",{style:{fontSize:"9px",color:"#9CA3AF",marginTop:2},children:"saving…"})]}),!!((T=r.compartments)!=null&&T.length)&&e.jsx("div",{style:{borderTop:"1px solid #EDEDEA",padding:"5px 12px 7px",userSelect:"none"},children:r.compartments.map(A=>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:A.key}),e.jsx("span",{style:{color:"#4B5563",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis"},children:A.value})]},A.key))}),e.jsx(C,{type:"target",position:j.Top,style:{...O,top:-5}}),e.jsx(C,{type:"source",position:j.Bottom,style:{...O,bottom:-5},id:"bottom"}),e.jsx(C,{type:"source",position:j.Right,style:{...O,right:-5},id:"right"}),e.jsx(C,{type:"target",position:j.Left,style:{...O,left:-5}})]})});function Xt({collapsed:t,onToggleCollapse:i,elementIds:n=[]}){const a=L(y=>y.model),r=L(y=>y.selectedElementId),l=L(y=>y.inspectElement),[u,m]=d.useState(""),[F,b]=d.useState(new Set),I=d.useMemo(()=>{var k;if(!a)return[];const y=u.trim().toLowerCase(),v=new Map,f=new Set(n);for(const E of n){const D=(k=a.elements[E])==null?void 0:k.allocatedTo;D&&f.add(D)}for(const E of f){const D=a.elements[E];D&&(y&&!D.name.toLowerCase().includes(y)&&!D.kind.toLowerCase().includes(y)||(v.has(D.kind)||v.set(D.kind,[]),v.get(D.kind).push(D)))}return[...v.entries()].map(([E,D])=>({kind:E,elements:D.sort((O,T)=>O.name.localeCompare(T.name))})).sort((E,D)=>E.kind.localeCompare(D.kind))},[a,n,u]),p=y=>b(v=>{const f=new Set(v);return f.has(y)?f.delete(y):f.add(y),f});return t?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:i,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:N.xs,fontWeight:600,color:"#374151"},children:"Diagram Elements"}),e.jsx("button",{onClick:i,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:u,onChange:y=>m(y.target.value),placeholder:"Search elements…",className:"w-full px-2 py-1 rounded focus:outline-none",style:{fontSize:N.xs,background:"#F0F0ED",border:"1px solid #E5E5E0",color:"#374151"}})}),e.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[I.map(y=>{var k;const v=F.has(y.kind),f=kn[(k=y.elements[0])==null?void 0:k.layer]??"#6B7280";return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>p(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:f},children:v?"▶":"▼"}),e.jsx("span",{className:"truncate",style:{fontSize:10,color:f,fontWeight:700},children:y.kind}),e.jsx("span",{style:{fontSize:9,color:"#9CA3AF",marginLeft:"auto"},children:y.elements.length})]}),!v&&y.elements.map(E=>{const D=r===E.id;return e.jsxs("button",{onClick:()=>l(E.id),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left",style:{border:"none",cursor:"pointer",fontSize:N.xs,background:D?"#DDF7EF":"transparent",color:D?"#116149":"#374151",fontWeight:D?600:400},title:`Highlight ${E.name} in diagram`,children:[e.jsx("span",{style:{width:8,height:8,borderRadius:2,background:f,flexShrink:0}}),e.jsx("span",{className:"truncate flex-1",children:E.name})]},E.id)})]},y.kind)}),I.length===0&&e.jsx("div",{className:"p-3 text-center",style:{color:"#9CA3AF",fontSize:N.xs},children:u?"No matching elements":"No elements in this diagram"})]})]})}function J({label:t,icon:i,danger:n,onClick:a}){return e.jsxs("button",{onClick:a,className:"w-full flex items-center gap-2 px-3 py-1.5 text-left",style:{background:"none",border:"none",cursor:"pointer",fontSize:N.xs},onMouseEnter:r=>{r.currentTarget.style.background=n?"#FEF2F2":"#F7F7F5"},onMouseLeave:r=>{r.currentTarget.style.background="none"},children:[i&&e.jsx("span",{style:{fontSize:"12px",width:16,textAlign:"center"},children:i}),e.jsx("span",{style:{color:n?"#DC2626":"#1a1a1a"},children:t})]})}function wt(){return e.jsx("div",{style:{height:1,background:"#E5E5E0",margin:"2px 0"}})}function Bn({x:t,y:i,onClose:n,children:a}){const r=d.useRef(null);d.useEffect(()=>{const F=I=>{r.current&&!r.current.contains(I.target)&&n()},b=I=>{I.key==="Escape"&&n()};return document.addEventListener("mousedown",F),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",F),document.removeEventListener("keydown",b)}},[n]);const l=210,u=Math.min(t,window.innerWidth-l-8),m=Math.min(i,window.innerHeight-200);return e.jsx("div",{ref:r,className:"fixed z-50 rounded-xl overflow-hidden py-1",style:{left:u,top:m,minWidth:l,background:"#FFFFFF",border:"1px solid #E5E5E0",boxShadow:"0 8px 32px rgba(0,0,0,0.14)"},children:a})}const nr=[{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 sr({x:t,y:i,nodeId:n,nodeKind:a,onClose:r,onEditName:l,onChangeColor:u,onRemoveFromDiagram:m,onDeleteFromModel:F,onLinkRisk:b,onLinkRequirement:I,onShowProperties:p,onFocusElement:y,onShowInCatalog:v,onShowRelMatrix:f,onOpenSource:k,onViewKindInOntology:E}){const[D,O]=d.useState(!1);return e.jsxs(Bn,{x:t,y:i,onClose:r,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:a}),e.jsx("div",{style:{fontSize:"9px",color:"#D1D5DB",fontFamily:"monospace"},children:n})]}),p&&e.jsx(J,{label:"Show Properties",icon:"ℹ",onClick:()=>{r(),p()}}),v&&e.jsx(J,{label:"Show in Catalog",icon:"☰",onClick:()=>{r(),v()}}),y&&e.jsx(J,{label:"Focus on Element",icon:"◎",onClick:()=>{r(),y()}}),f&&e.jsx(J,{label:"Show Relationship Matrix",icon:"☷",onClick:()=>{r(),f()}}),E&&e.jsx(J,{label:"View Kind in Ontology",icon:"⬡",onClick:()=>{r(),E()}}),k&&e.jsx(J,{label:"Open Source File",icon:"⟨/⟩",onClick:()=>{r(),k()}}),(p||v||y||f||E||k)&&e.jsx(wt,{}),e.jsx(J,{label:"Edit name",icon:"✏️",onClick:()=>{r(),l()}}),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:N.xs},onMouseEnter:T=>{O(!0),T.currentTarget.style.background="#F7F7F5"},onMouseLeave:T=>{T.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:nr.map(T=>e.jsxs("button",{onClick:()=>{r(),u(T.value)},className:"w-full flex items-center gap-2.5 px-3 py-1.5",style:{background:"none",border:"none",cursor:"pointer"},onMouseEnter:A=>{A.currentTarget.style.background="#F7F7F5"},onMouseLeave:A=>{A.currentTarget.style.background="none"},children:[e.jsx("div",{style:{width:14,height:14,borderRadius:3,flexShrink:0,background:T.value||"#E5E5E0",border:"1px solid #D1D5DB"}}),e.jsx("span",{style:{fontSize:N.xs,color:"#374151"},children:T.label})]},T.value))})]}),e.jsx(wt,{}),b&&e.jsx(J,{label:"Link Risk",icon:"⚠️",onClick:()=>{r(),b()}}),I&&e.jsx(J,{label:"Link Requirement",icon:"📋",onClick:()=>{r(),I()}}),(b||I)&&e.jsx(wt,{}),e.jsx(J,{label:"Remove from diagram",icon:"↩️",onClick:()=>{r(),m()}}),e.jsx(J,{label:"Delete from model",icon:"🗑️",danger:!0,onClick:()=>{window.confirm(`Delete ${n} from the model? This cannot be undone.`)&&(r(),F())}})]})}const ir=[{label:"Auto",value:""},{label:"Red",value:"#EF4444"},{label:"Blue",value:"#3B82F6"},{label:"Green",value:"#10B981"},{label:"Orange",value:"#F59E0B"},{label:"Gray",value:"#6B7280"}];function rr({x:t,y:i,edgeId:n,relType:a,onClose:r,onChangeStyle:l,onChangeColor:u,onToggleLabel:m,onDelete:F}){return e.jsxs(Bn,{x:t,y:i,onClose:r,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:a}),e.jsx("div",{style:{fontSize:"9px",color:"#D1D5DB",fontFamily:"monospace"},children:n})]}),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:()=>{r(),l(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"}),ir.map(b=>e.jsx("button",{onClick:()=>{r(),u(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(wt,{}),e.jsx(J,{label:"Toggle label",icon:"🏷️",onClick:()=>{r(),m()}}),e.jsx(J,{label:"Delete edge",icon:"🗑️",danger:!0,onClick:()=>{r(),F()}})]})}const ar=d.memo(function({id:i,data:n,selected:a}){const r=n,l=r.color??r.layerColor??"#E67E22",u=80,m=d.useCallback(F=>{var b;F.preventDefault(),(b=r.onContextMenu)==null||b.call(r,F,i)},[r,i]);return e.jsxs("div",{style:{width:u,height:u,position:"relative"},onContextMenu:m,children:[a&&e.jsx(St,{minWidth:60,minHeight:60}),e.jsx("svg",{width:u,height:u,style:{position:"absolute",top:0,left:0},children:e.jsx("polygon",{points:`${u/2},4 ${u-4},${u/2} ${u/2},${u-4} 4,${u/2}`,fill:r.color?r.color+"44":"#FFF8E1",stroke:l,strokeWidth:a?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:r.condition||r.label||"?"}),e.jsx(C,{type:"target",position:j.Top,style:{background:l,border:"2px solid #fff"}}),e.jsx(C,{type:"source",position:j.Right,style:{background:l,border:"2px solid #fff"},id:"right"}),e.jsx(C,{type:"source",position:j.Bottom,style:{background:l,border:"2px solid #fff"},id:"bottom"}),e.jsx(C,{type:"target",position:j.Left,style:{background:l,border:"2px solid #fff"}})]})}),lr=d.memo(function({id:i,data:n,selected:a}){const r=n,l=(r.orientation??"horizontal")==="horizontal",u=l?120:8,m=l?8:60,F=d.useCallback(b=>{var I;b.preventDefault(),(I=r.onContextMenu)==null||I.call(r,b,i)},[r,i]);return e.jsxs("div",{style:{width:u,height:m,background:"#1a1a1a",borderRadius:4,position:"relative"},title:r.nodeType==="join"?"Join (synchronization)":"Fork (parallel)",onContextMenu:F,children:[a&&e.jsx(St,{minWidth:40,minHeight:6}),l?e.jsxs(e.Fragment,{children:[e.jsx(C,{type:"target",position:j.Left,style:{background:"#2DD4A8",border:"2px solid #fff",left:-1}}),e.jsx(C,{type:"source",position:j.Top,style:{background:"#2DD4A8",border:"2px solid #fff",top:-1},id:"top"}),e.jsx(C,{type:"source",position:j.Bottom,style:{background:"#2DD4A8",border:"2px solid #fff",bottom:-1},id:"bottom"}),e.jsx(C,{type:"source",position:j.Right,style:{background:"#2DD4A8",border:"2px solid #fff",right:-1},id:"right"})]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{type:"target",position:j.Top,style:{background:"#2DD4A8",border:"2px solid #fff",top:-1}}),e.jsx(C,{type:"source",position:j.Left,style:{background:"#2DD4A8",border:"2px solid #fff",left:-1},id:"left"}),e.jsx(C,{type:"source",position:j.Right,style:{background:"#2DD4A8",border:"2px solid #fff",right:-1},id:"right"}),e.jsx(C,{type:"source",position:j.Bottom,style:{background:"#2DD4A8",border:"2px solid #fff",bottom:-1},id:"bottom"})]})]})}),dr=d.memo(function({id:i,data:n}){const a=n,r=a.nodeType==="start",l=32,u=d.useCallback(m=>{var F;m.preventDefault(),(F=a.onContextMenu)==null||F.call(a,m,i)},[a,i]);return e.jsxs("div",{style:{width:l,height:l,position:"relative"},onContextMenu:u,children:[e.jsx("svg",{width:l,height:l,children:r?e.jsx("circle",{cx:l/2,cy:l/2,r:l/2-2,fill:"#1a1a1a"}):e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:l/2,cy:l/2,r:l/2-2,fill:"#1a1a1a"}),e.jsx("circle",{cx:l/2,cy:l/2,r:l/2-6,fill:"#FFFFFF"}),e.jsx("circle",{cx:l/2,cy:l/2,r:l/2-10,fill:"#1a1a1a"})]})}),r?e.jsx(C,{type:"source",position:j.Bottom,style:{background:"#1a1a1a",border:"2px solid #fff"}}):e.jsx(C,{type:"target",position:j.Top,style:{background:"#1a1a1a",border:"2px solid #fff"}})]})}),cr="#ECEBE6",vt="#1B3A4B",no="#5B6470",pr="0 1px 2px rgba(0,0,0,0.16), 0 0 0 0.5px rgba(0,0,0,0.05)",be=(t,i)=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{display:"block"},children:i}),H={arrowRight:({size:t=16})=>be(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M4 12h14"}),e.jsx("path",{d:"M13 6l6 6-6 6"})]})),arrowDown:({size:t=16})=>be(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M12 4v14"}),e.jsx("path",{d:"M6 13l6 6 6-6"})]})),lanes:({size:t=16})=>be(t,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:t=16})=>be(t,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:t=16})=>be(t,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:t=16})=>be(t,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:t=16})=>be(t,e.jsx("path",{d:"M4 5h16l-6.2 7.4V19l-3.6 1.8v-8.4z"})),back:({size:t=16})=>be(t,e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M11 5l-6 7 6 7"}),e.jsx("path",{d:"M5 12h14"})]}))};function ce(){return e.jsx("span",{"aria-hidden":"true",style:{width:1,height:18,background:"#E2E1DB",margin:"0 3px",borderRadius:1}})}function Gt({options:t,value:i,onChange:n}){return e.jsx("div",{role:"tablist",style:{display:"inline-flex",alignItems:"center",gap:2,padding:2,background:cr,borderRadius:9},children:t.map(a=>{const r=a.value===i;return e.jsxs("button",{role:"tab","aria-selected":r,onClick:()=>n(a.value),title:a.title,className:"flex items-center gap-1.5 text-xs font-semibold",style:{padding:a.label?"3px 9px":"4px 7px",borderRadius:7,border:"none",cursor:"pointer",color:r?vt:no,background:r?"#FFFFFF":"transparent",boxShadow:r?pr:"none",transition:"background 140ms ease, color 140ms ease, box-shadow 140ms ease"},children:[a.icon,a.label&&e.jsx("span",{children:a.label})]},a.value)})})}function ur({children:t}){return e.jsx("div",{style:{display:"inline-flex",alignItems:"center",background:"#FFFFFF",border:"1px solid #E2E1DB",borderRadius:9,overflow:"hidden"},children:on.Children.toArray(t).map((i,n)=>e.jsxs(on.Fragment,{children:[n>0&&e.jsx("span",{"aria-hidden":"true",style:{width:1,alignSelf:"stretch",background:"#EDECE7"}}),i]},n))})}function oe({icon:t,label:i,onClick:n,active:a=!1,title:r,ariaExpanded:l,ariaLabel:u}){return e.jsxs("button",{onClick:n,title:r,"aria-label":u,"aria-pressed":a,"aria-expanded":l,className:"flex items-center gap-1.5 text-xs font-semibold",style:{padding:i?"5px 9px":"5px 7px",border:"none",cursor:"pointer",color:a?"#FFFFFF":no,background:a?vt:"transparent",transition:"background 140ms ease, color 140ms ease"},children:[t,i&&e.jsx("span",{children:i})]})}function Ye({icon:t,label:i,onClick:n,active:a=!1,title:r,badge:l}){return e.jsxs("button",{onClick:n,title:r,"aria-pressed":a,className:"flex items-center gap-1.5 text-xs font-semibold",style:{padding:l!=null||i!=null?"5px 9px":"5px 7px",borderRadius:9,border:`1px solid ${a?vt:"#E2E1DB"}`,cursor:"pointer",color:a?"#FFFFFF":no,background:a?vt:"#FFFFFF",transition:"background 140ms ease, color 140ms ease, border-color 140ms ease"},children:[t,i!=null&&e.jsx("span",{children:i}),l!=null&&e.jsx("span",{style:{fontSize:11,fontWeight:700,lineHeight:1,padding:"2px 5px",borderRadius:6,background:a?"rgba(255,255,255,0.22)":"#F0EFEA",color:a?"#FFFFFF":"#6B7280"},children:l})]})}const yn="memo-layout-progress";if(typeof document<"u"&&!document.getElementById(yn)){const t=document.createElement("style");t.id=yn,t.textContent="@keyframes memo-layout-progress { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }",document.head.appendChild(t)}const xr={background:"#F7F7F5"},hr={padding:.08,maxZoom:2},gr={background:"#FFFFFF"},fr={hideAttribution:!0},mr=[20,20],br=50,Fn=8e3,yr=90;function Fr(t,i){return new Promise((n,a)=>{const r=window.setTimeout(()=>a(new Error(`${i} layout exceeded ${Fn/1e3}s`)),Fn);t.then(l=>{window.clearTimeout(r),n(l)},l=>{window.clearTimeout(r),a(l)})})}function wn(t,i){const n=new Map(t.map(p=>[p.id,p])),a=new Map,r=p=>{const y=a.get(p);if(y)return y;const v=n.get(p),f=v.parentId?r(v.parentId):{x:0,y:0},k={x:f.x+v.position.x,y:f.y+v.position.y};return a.set(p,k),k},l=p=>{var y,v;return{width:Number(p.width??((y=p.style)==null?void 0:y.width)??0),height:Number(p.height??((v=p.style)==null?void 0:v.height)??0)}},u=i.flatMap(p=>{var D,O,T,A,K,Z;const y=(_,z,re)=>{var w,pe;if(typeof z=="string"){const ee=(((pe=(w=n.get(_))==null?void 0:w.data)==null?void 0:pe.ports)??[]).find(U=>U.id===z);if(ee){const U=ee.size??20;return{x:ee.x+U/2,y:ee.y+U/2}}}return re},v=y(p.source,(D=p.data)==null?void 0:D.sourcePortId,(O=p.data)==null?void 0:O.sourceOffset),f=y(p.target,(T=p.data)==null?void 0:T.targetPortId,(A=p.data)==null?void 0:A.targetOffset);if(!v||!f||!n.has(p.source)||!n.has(p.target))return[];const k=r(p.source),E=r(p.target);return[{id:p.id,source:{x:k.x+v.x,y:k.y+v.y},target:{x:E.x+f.x,y:E.y+f.y},sourceNodeId:p.source,targetNodeId:p.target,sourceSide:(K=p.data)==null?void 0:K.sourceSide,targetSide:(Z=p.data)==null?void 0:Z.targetSide}]});if(u.length===0)return i;const m=t.filter(p=>!p.data.isFrame).map(p=>({id:p.id,...r(p.id),...l(p)})),F=new Map(u.map(p=>[p.id,p])),b=u.filter(p=>{var y,v;return!((v=(y=i.find(f=>f.id===p.id))==null?void 0:y.data)!=null&&v.manualRoute)}),I=hi(b,m);return i.map(p=>{var v;const y=F.get(p.id);if(!y)return p;if((v=p.data)!=null&&v.manualRoute){const f=[...p.data.points??[]];if(f.length>=2)return f[0]=y.source,f[f.length-1]=y.target,{...p,data:{...p.data,points:f}}}return I.has(p.id)?{...p,data:{...p.data,points:I.get(p.id)}}:p})}function wr({x:t,y:i,onConfirm:n,onCancel:a}){const[r,l]=d.useState(""),u=d.useRef(null);d.useEffect(()=>{var b;(b=u.current)==null||b.focus()},[]),d.useEffect(()=>{const b=I=>{const p=document.getElementById("quick-create-popup");p&&!p.contains(I.target)&&a()};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[a]);const m=Math.min(t,window.innerWidth-220),F=Math.min(i,window.innerHeight-80);return e.jsxs("div",{id:"quick-create-popup",className:"fixed z-50 rounded-xl shadow-xl overflow-hidden",style:{left:m,top:F,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:N.xs,color:"#9CA3AF",fontWeight:600},children:"New Element"}),e.jsxs("div",{className:"px-2 py-2",children:[e.jsx("input",{ref:u,value:r,onChange:b=>l(b.target.value),placeholder:"Element name…",className:"w-full px-2 py-1.5 rounded focus:outline-none",style:{fontSize:N.xs,border:"1px solid #E5E5E0",background:"#F7F7F5",color:"#1a1a1a"},onKeyDown:b=>{b.key==="Enter"&&r.trim()&&(b.preventDefault(),n(r.trim())),b.key==="Escape"&&a()}}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("button",{onClick:()=>r.trim()&&n(r.trim()),style:{flex:1,fontSize:N.xs,padding:"4px 8px",background:"#2DD4A8",color:"#FFFFFF",border:"none",borderRadius:6,cursor:"pointer",fontWeight:600},children:"Create"}),e.jsx("button",{onClick:a,style:{fontSize:N.xs,padding:"4px 8px",background:"#F7F7F5",color:"#6B7280",border:"1px solid #E5E5E0",borderRadius:6,cursor:"pointer"},children:"Cancel"})]})]})]})}function qt({color:t,glyph:i}){return e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:13,height:13,borderRadius:2,background:t+"22",border:`1.5px solid ${t}`,color:t,fontSize:9,fontWeight:800,lineHeight:1},children:i})}function jn(t,i){if(!t||!i)return[];const n=new Map;for(const u of t.relationships)En.has(u.type)&&!n.has(u.targetId)&&n.set(u.targetId,u.sourceId);const a=[i],r=new Set(a);let l=i;for(;n.has(l);){const u=n.get(l);if(r.has(u))break;a.unshift(u),r.add(u),l=u}return a}function Zt({path:t,nameOf:i,onFocus:n,rootLabel:a}){if(t.length===0)return null;const r=t.length>1?t[t.length-2]:null;return e.jsxs(e.Fragment,{children:[e.jsx(ce,{}),e.jsx(Ye,{icon:e.jsx(H.back,{}),label:"Parent",onClick:()=>n(r),title:r?`Back to ${i(r)}`:a}),e.jsx("button",{onClick:()=>n(null),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{background:"#F7F7F5",color:"#2563EB",border:"1px solid #E5E5E0"},title:a,children:"⌂ All"}),t.map((l,u)=>{const m=u===t.length-1;return e.jsxs("span",{className:"flex items-center gap-1",style:{color:"#9CA3AF"},children:[e.jsx("span",{children:"›"}),e.jsx("button",{onClick:()=>n(l),disabled:m,className:"text-xs font-medium",style:{color:m?"#1a1a1a":"#2563EB",fontWeight:m?700:500,cursor:m?"default":"pointer"},title:m?void 0:`Focus ${i(l)}`,children:i(l)})]},l)})]})}function jr(){var Ho,Ko,Vo,Yo,Uo,Xo,Go,qo,Zo;const t=L(o=>o.model),i=L(o=>o.createRelationship),n=d.useMemo(()=>$s(t),[t]),a=L(o=>o.selectedElementId),r=L(o=>o.selectedViewpointId),l=L(o=>o.selectedDiagramId),u=L(o=>o.hiddenLayers),m=L(o=>o.selectElement),F=L(o=>o.inspectElement),b=L(o=>o.inspectRelationship),I=L(o=>o.setActiveMode),p=L(o=>o.setActiveView),y=L(o=>o.setExplorerTab),v=L(o=>o.availableOntologies),f=L(o=>o.setSelectedOntologyKind),k=L(o=>o.diagramLayouts),E=L(o=>o.setNodeLayout),D=L(o=>o.mergeDiagramLayouts),O=L(o=>o.updateDiagramElementIds),{fitView:T,screenToFlowPosition:A,getViewport:K,setViewport:Z}=eo(),[_,z]=Cs([]),[re,w,pe]=Is([]),ee=d.useRef([]),U=d.useRef([]),Ge=d.useRef(t),qe=d.useRef(l),ye=d.useRef(null),ke=d.useRef(null),Ee=d.useRef(null),ne=d.useRef(0);d.useEffect(()=>{ee.current=_},[_]),d.useEffect(()=>{U.current=re},[re]);const ue=d.useCallback(o=>{ee.current=o,ke.current===null&&(ke.current=requestAnimationFrame(()=>{ke.current=null;const s=ee.current,c=wn(s,U.current);U.current=c,z(s),w(c)}))},[z,w]),[G,se]=d.useState(!1),[so,Ce]=d.useState(0),[io,ro]=d.useState(null),[ao,Mn]=d.useState(0),[Tn,kt]=d.useState(0),[Ne,Et]=d.useState(!0),[Ln,lo]=d.useState(!0),[co,zn]=d.useState(!0),[Ct,$n]=d.useState("horizontal"),[Ze,po]=d.useState("allocation"),[It,uo]=d.useState("all"),[xo,Wn]=d.useState(!1),[ge,On]=d.useState(new Set(["control","data","energy","material"])),[te,Ae]=d.useState(null),[fe,Qe]=d.useState(null),[q,Re]=d.useState(null),[xe,Je]=d.useState(null),[Be,ho]=d.useState(null),[et,Pn]=d.useState(2),[tt,go]=d.useState(null),Me=d.useRef([]),Dt=d.useRef([]),fo=d.useCallback(o=>{Me.current.push(o),Me.current.length>br&&Me.current.shift(),Dt.current=[]},[]),x=Ws(t,l),Te=x?nn[x.diagramType]:null,ot=!!((Ho=x==null?void 0:x.properties)!=null&&Ho.layoutStyle),Fe=((Ko=x==null?void 0:x.properties)==null?void 0:Ko.layoutStyle)==="fbs",we=l?k[l]:void 0,je=ei(we),he=((Vo=we==null?void 0:we.canvas)==null?void 0:Vo.autoLayout)!==!1,me=((Yo=we==null?void 0:we.canvas)==null?void 0:Yo.flowAnimation)===!0,ae=d.useCallback(()=>{var s;if(!l)return;const o=L.getState().diagramLayouts[l]??{nodes:{},edges:{}};((s=o.canvas)==null?void 0:s.autoLayout)!==!1&&D({[l]:{...o,canvas:{...o.canvas,autoLayout:!1}}})},[l,D]);d.useEffect(()=>{if(!l||he||G||_.length===0||so===0)return;const o=window.setTimeout(()=>{const s=L.getState().diagramLayouts[l]??{nodes:{},edges:{}},c=K(),h={nodes:Object.fromEntries(_.map(g=>[g.id,{...s.nodes[g.id]??{},x:g.position.x,y:g.position.y,...g.width?{width:g.width}:{},...g.height?{height:g.height}:{},ports:Object.fromEntries((g.data.ports??[]).map(S=>[S.id,{x:S.x,y:S.y,side:S.side}]))}])),edges:Object.fromEntries(re.map(g=>{var S,$,R,W,V,M;return[g.id,{...(()=>{var P;const{points:X,...Y}=((P=s.edges)==null?void 0:P[g.id])??{};return Y})(),...(S=g.data)!=null&&S.manualRoute&&((R=($=g.data)==null?void 0:$.points)!=null&&R.length)?{points:(W=g.data)==null?void 0:W.points,source:g.source,target:g.target,sourcePortId:(V=g.data)==null?void 0:V.sourcePortId,targetPortId:(M=g.data)==null?void 0:M.targetPortId}:{}}]})),canvas:{...s.canvas,zoom:c.zoom,pan:{x:c.x,y:c.y},autoLayout:!1}};D({[l]:h}),Ve(l,h),Ce(0)},350);return()=>window.clearTimeout(o)},[l,he,G,so,_,re,K,D]);const B=x?x.viewKind??(Te==null?void 0:Te.viewKind)??"general":void 0,ve=B==="interconnection"?.72:.1,Le=B?an[B]:null,Ie=B==="general"&&!ot&&!Fe,Nt=(x==null?void 0:x.diagramType)==="ucd",[Se,mo]=d.useState("graph"),[At,bo]=d.useState("all"),[Rt,yo]=d.useState("straight"),[ze,Fo]=d.useState(new Set),_n=d.useMemo(()=>t?ti(t):0,[t]),wo=d.useMemo(()=>t?oi(t):[],[t]),Bt=(Uo=x==null?void 0:x.properties)==null?void 0:Uo.modes,Hn=d.useMemo(()=>{if(!Bt)return Vt;const o=new Set(Bt.split(",").map(c=>c.trim())),s=Vt.filter(c=>o.has(c));return s.length?s:Vt},[Bt]),[$e,jo]=d.useState(!0),vo=d.useMemo(()=>{if(!t||!x)return[];const o=new Set(x.elementIds),s=Object.values(t.elements).filter(c=>o.has(c.id)&&c.allocatedTo).map(c=>c.allocatedTo);return ni(s,t)},[t,x]),Kn=d.useMemo(()=>{if(!t||!x)return"Activity Diagram";const o=Os(x);return nn[o].fullName},[t,x]),Vn=d.useMemo(()=>{if(!t||!x)return!1;const o=new Set(x.elementIds);return Object.values(t.elements).some(s=>o.has(s.id)&&!!(s.attributes.stage||s.attributes.phase))},[t,x]),nt=d.useMemo(()=>{if(!t||!x||B!=="actionflow")return[];const o=(x.elementIds??[]).map(s=>t.elements[s]).filter(s=>!!s&&s.construct==="action");return si(o,t)},[t,x,B]),[We,Yn]=d.useState("containment"),[Oe,st]=d.useState(new Set),[So,Pe]=d.useState(new Set),[it,Mt]=d.useState(null),[_e,ko]=d.useState("all"),[Eo,Co]=d.useState(!1),[Io,He]=d.useState(new Set),[De,Tt]=d.useState(null),[Lt,Do]=d.useState("flat"),[No,Ke]=d.useState(new Set),[rt,zt]=d.useState(null),[at,Un]=d.useState(new Map),le=d.useRef(new Map),Xn=d.useMemo(()=>jn(t,it),[t,it]),Gn=d.useMemo(()=>jn(t,rt),[t,rt]),qn=d.useMemo(()=>{var h;if(!t||!De)return[];const o=[De],s=new Set(o);let c=De;for(;c;){const g=(h=t.elements[c])==null?void 0:h.parentAction;if(!g||s.has(g)||!t.elements[g])break;o.unshift(g),s.add(g),c=g}return o},[t,De]),lt=d.useMemo(()=>{if(!t||B!=="statetransition")return[];const o=new Set;for(const s of t.relationships){if(!En.has(s.type))continue;const c=t.elements[s.sourceId];!c||!t.elements[s.targetId]||!ii(c)||c.kind.endsWith("Machine")||o.add(c.id)}return[...o]},[t,B]),dt=d.useMemo(()=>t?[...new Set(t.relationships.filter(o=>["composes","composedof","aggregation","decomposedby"].includes(o.type.toLowerCase())).map(o=>o.sourceId))]:[],[t]);d.useEffect(()=>{var s,c;Ce(0),mo(ri(x==null?void 0:x.properties)),bo(Yt(x==null?void 0:x.properties).level??"all"),yo(Yt(x==null?void 0:x.properties).edgeStyle??"straight"),Fo(new Set),jo(!0),po("allocation"),uo("all");const o=(c=(s=x==null?void 0:x.properties)==null?void 0:s.styleHint)!=null&&c.startsWith("expanded:")?x.properties.styleHint.slice(9).split(",").map(h=>h.trim()).filter(Boolean):[];st(new Set(o)),Mt(null),ko("all"),Co(!1),He(new Set),Tt(null),Do("flat"),zt(null),le.current.clear()},[l,(Xo=x==null?void 0:x.properties)==null?void 0:Xo.layoutHint,(Go=x==null?void 0:x.properties)==null?void 0:Go.styleHint]);const Ao=d.useRef(null);d.useEffect(()=>{if(!t)return;const o=`${l??""}|${B??""}`;if(Ao.current!==o){if(B==="statetransition"){if(lt.length===0)return;Ke(new Set(lt))}else if(B==="interconnection"){if(dt.length===0)return;Pe(new Set(dt))}Ao.current=o}},[t,l,B,lt,dt]);const Zn=d.useMemo(()=>({decompositionNode:vi,interconnectionNode:Di,actionFlowNode:zi,actionFlowLane:Wi,stateNode:Pi,seqLifeline:Hi,seqSection:Vi,seqOccurrence:Ui,useCase:Xi,useCaseActor:Gi,useCaseBoundary:qi,contextSystem:Ji,contextExternal:er,contextBoundary:tr,diagramNode:or,decisionNode:ar,forkNode:lr,startEndNode:dr}),[]),Qn=d.useMemo(()=>({interconnectionEdge:Mi,useCaseEdge:Qi}),[]),Jn=d.useCallback(o=>{var s,c;return((s=o.data)==null?void 0:s.color)||((c=o.data)==null?void 0:c.layerColor)||"#ccc"},[]),Q=d.useMemo(()=>{const o=(x==null?void 0:x.viewpointId)==="__model"?null:(x==null?void 0:x.viewpointId)||r,s=o&&(t==null?void 0:t.viewpoints),c=u.size>0,h=x!=null&&x.elementIds?new Set(x.elementIds):void 0;if(!s&&!c&&!h)return;const g=s?t.viewpoints.find(R=>R.id===o):void 0,S=g?new Set(g.visibleKinds):void 0,$=g?new Set(g.visibleLayers):void 0;return R=>u.has(R.layer)?!1:h?h.has(R.id):S&&$?S.has(R.kind)||$.has(R.layer):!0},[r,x,t==null?void 0:t.viewpoints,u]),ct=d.useMemo(()=>!t||!x||x.diagramType!=="bdd"?null:ai(dn(t,Q)),[t,x,Q]),Ro=d.useCallback(()=>{if(t)return Fe?li(t):Ie?dn(t,Q):di(t)},[t,Fe,Ie,Q]),$t=d.useCallback(o=>{st(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),Bo=d.useCallback(o=>{Pe(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),Mo=d.useCallback(o=>{He(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),pt=d.useCallback(o=>{zt(o),Ke(new Set),F(null)},[F]),ut=d.useCallback(o=>{Tt(o),He(new Set),F(null)},[F]),To=d.useCallback(o=>{Ke(s=>{const c=new Set(s);return c.has(o)?c.delete(o):c.add(o),c})},[]),Lo=d.useCallback(o=>{le.current.clear(),Un(s=>{const c=new Map(s),h=c.get(o)||"vertical";return c.set(o,h==="vertical"?"horizontal":"vertical"),c})},[]),Wt=d.useCallback(()=>{const o=Ro();if(!o)return;const s=new Set,c=h=>{s.add(h);for(const g of o.childrenMap.get(h)||[])o.elements.has(g)&&c(g)};for(const h of o.roots)o.elements.has(h)&&c(h);st(s)},[Ro]),Ot=d.useCallback(()=>st(new Set),[]),Pt=d.useCallback(()=>{le.current.clear(),kt(o=>o+1)},[]),es=d.useCallback(()=>{if(!l)return;const o=L.getState().diagramLayouts[l]??{},{pan:s,zoom:c,...h}=o.canvas??{},g={nodes:{},edges:{},canvas:{...h,autoLayout:!0}};ye.current=null,D({[l]:g}),Ve(l,g),le.current.clear(),kt(S=>S+1),window.setTimeout(()=>T({padding:.08,minZoom:ve,maxZoom:2,duration:300}),250)},[l,D,T,ve]),zo=d.useCallback(o=>o.map(s=>{if(s.type!=="diagramNode")return s;const c=t==null?void 0:t.elements[s.id];return{...s,data:{...s.data,onContextMenu:(h,g)=>{Re({x:h.clientX,y:h.clientY,nodeId:g,nodeKind:s.data.kind??""})},onInlineEdit:(h,g)=>{if(!c)return;const S={...c,name:g};sn(S)}}}}),[t]),$o=d.useCallback((o,s)=>{const c=o.map(g=>{const S=s.nodes[g.id];return S?{...g,position:{x:S.x,y:S.y},...S.width?{width:S.width}:{},...S.height?{height:S.height}:{},data:{...g.data,bgColor:S.color||void 0,...S.ports?{ports:(g.data.ports??[]).map($=>{var R;return{...$,...((R=S.ports)==null?void 0:R[$.id])??{}}})}:{}}}:g}),h=new Map(c.map(g=>[g.id,g]));return c.map(g=>{if(g.type!=="actionFlowLane")return g;const S=g.data,$=(S.memberIds??[]).map(Y=>h.get(Y)).filter(Boolean);if($.length===0)return g;const R=Math.min(...$.map(Y=>Y.position.x)),W=Math.min(...$.map(Y=>Y.position.y)),V=Math.max(...$.map(Y=>{var P;return Y.position.x+Number(Y.width??((P=Y.style)==null?void 0:P.width)??180)})),M=Math.max(...$.map(Y=>{var P;return Y.position.y+Number(Y.height??((P=Y.style)==null?void 0:P.height)??96)})),X=S.orientation==="column";return{...g,position:{x:X?R-36:R-120,y:X?W-32:W-36},style:{...g.style,width:V-R+(X?72:156),height:M-W+(X?68:72)}}})},[]),Wo=d.useCallback((o,s,c)=>{ne.current=Date.now()+250,ae(),Ce(S=>S+1);const h=U.current.map(S=>{var M,X;if(!(((M=S.data)==null?void 0:M.sourcePortId)===s||((X=S.data)==null?void 0:X.targetPortId)===s))return S;const{points:R,manualRoute:W,...V}=S.data??{};return{...S,data:V}});U.current=h;const g=ee.current.map(S=>S.id!==o?S:{...S,data:{...S.data,ports:(S.data.ports??[]).map($=>$.id===s?{...$,y:c}:$)}});ue(g)},[ue,ae]),Oo=d.useCallback((o,s)=>{ne.current=Date.now()+250,ae(),Ce(c=>c+1),w(c=>{const h=c.map(g=>g.id===o?{...g,data:{...g.data,points:s,manualRoute:!0}}:g);return U.current=h,h})},[ae,w]);d.useEffect(()=>{if(!t)return;const o=Ge.current!==t&&qe.current===l;if(ye.current=o?K():null,Ge.current=t,qe.current=l,B==="grid"||B==="browser"||B==="geometry")return;let s=!1;const c=({nodes:R,edges:W},V=!0)=>{if(s)return;const M=l?L.getState().diagramLayouts[l]:void 0,X=M&&Object.keys(M.nodes).length>0?$o(R,M):R,Y=W.map(P=>{var Qo,Jo,en;const de=(Qo=M==null?void 0:M.edges)==null?void 0:Qo[P.id],xt=!(de!=null&&de.source)||de.source===P.source&&de.target===P.target&&de.sourcePortId===((Jo=P.data)==null?void 0:Jo.sourcePortId)&&de.targetPortId===((en=P.data)==null?void 0:en.targetPortId)?de==null?void 0:de.points:void 0;return{...P,data:{...P.data,...xt!=null&&xt.length?{points:xt,manualRoute:!0}:{},flowAnimation:me,onRouteChange:_t=>Oo(P.id,_t),onSelect:_t=>{_t.stopPropagation(),!(Date.now()<ne.current)&&(w(Ht=>Ht.map(tn=>({...tn,selected:tn.id===P.id}))),t.relationships.some(Ht=>Ht.id===P.id)&&b(P.id))}}}});z(V?zo(X):X),w(wn(X,Y)),se(!1),Mn(P=>P+1)},h=R=>W=>{s||(console.error(`${R} layout error:`,W),se(!1),ro(`${R} layout could not be completed. Try resetting the layout or reducing the visible hierarchy.`))},g=(R,W,V=!0)=>{se(!0),ro(null),Fr(W,R).then(M=>c(M,V)).catch(h(R))},S=()=>{const R=Dn.select({viewKind:B,diagramType:x==null?void 0:x.diagramType,isFBSDiagram:Fe,isDecompDiagram:ot,isGeneralTemplate:Ie,generalMode:Se,layoutStyle:We}),W={onToggleExpand:$t,onToggleDirection:Lo},V={fbs:{expandedNodes:Oe,nodeDirections:at,callbacks:W,layoutProviderId:je},decomposition:{expandedNodes:Oe,nodeDirections:at,callbacks:W,positionCache:le.current},containment:{expandedNodes:Oe,callbacks:{onToggleExpand:$t}},useCase:{viewpointFilter:void 0,systemName:x==null?void 0:x.name,...x?Yt(x.properties):{},level:At,edgeStyle:Rt,hiddenActorIds:ze},contextSystemName:x==null?void 0:x.name,interconnection:{viewpointFilter:Q,relationshipTypes:x==null?void 0:x.relationshipTypes,collapsedNodes:So,onToggleCollapse:Bo,focusId:it??void 0,portDisplay:_e,onPortMove:Wo,layoutProviderId:je},actionflow:{viewpointFilter:Q,swimlanes:$e,laneGrouping:Ze,displayLevel:It,expandedActionIds:Io,onToggleAction:Mo,onDrillInAction:ut,focusActionId:De??void 0,visibleFlowKinds:ge,direction:Ct,nesting:Lt,layoutProviderId:je},statetransition:{viewpointFilter:Q,collapsedStateIds:No,onToggleCollapse:To,onDrillIn:pt,focusStateId:rt??void 0,layoutProviderId:je},sequence:{viewpointFilter:Q},general:{mode:Se,viewpointFilter:Q,expandedNodes:Oe,nodeDirections:at,callbacks:W,positionCache:le.current,layoutProviderId:je},standard:{viewpointFilter:Q,relationshipTypes:x==null?void 0:x.relationshipTypes,compartments:Ie,layoutProviderId:je}},M=R.compute(t,V);M instanceof Promise?g(R.descriptor.label,M,R.descriptor.interactive):c(M,R.descriptor.interactive)},$=window.setTimeout(S,yr);return()=>{s=!0,window.clearTimeout($)}},[t,Q,ot,Fe,We,B,Ie,Se,$e,Tn,x==null?void 0:x.relationshipTypes,x==null?void 0:x.diagramType,x==null?void 0:x.name,At,Rt,ze,je,Oe,So,it,_e,Io,De,ge,Ct,Ze,It,Lt,at,No,rt,To,pt,ut,$t,Bo,Mo,Lo,l,$o,zo,Wo,Oo,b,K]),d.useEffect(()=>{if(ao===0)return;const o=setTimeout(()=>{var h;const s=ye.current;if(ye.current=null,s){Z(s);return}const c=l?(h=L.getState().diagramLayouts[l])==null?void 0:h.canvas:void 0;(c==null?void 0:c.zoom)!==void 0&&c.pan?Z({x:c.pan.x,y:c.pan.y,zoom:c.zoom},{duration:300}):T({padding:.08,minZoom:ve,maxZoom:2,duration:500})},200);return()=>clearTimeout(o)},[ao,l,T,ve,Z]),d.useEffect(()=>{z(o=>o.map(s=>{const c=s.type==="actionFlowLane"?s.data.inspectElementId:void 0,h=!!a&&(s.id===a||c===a);return{...s,selected:h,style:{...s.style,boxShadow:h?"0 0 0 2px #2DD4A8, 0 4px 12px rgba(45, 212, 168, 0.3)":void 0,opacity:a?h?1:.5:1}}}))},[a,z]),d.useEffect(()=>{if(!Be||!t)return;const o=gi(t,Be,"both",et),s=new Set(o.nodes.map(c=>c.elementId));s.add(Be),z(c=>c.map(h=>({...h,style:{...h.style,opacity:s.has(h.id)?1:.08,pointerEvents:s.has(h.id)?"all":"none"}}))),w(c=>c.map(h=>({...h,style:{...h.style,opacity:s.has(h.source)&&s.has(h.target)?1:.05}})))},[Be,et,t,z,w]),d.useEffect(()=>{if(!tt)return;const o=setTimeout(()=>go(null),2500);return()=>clearTimeout(o)},[tt]),d.useEffect(()=>{const o=s=>{const c=s.target;if(!(c.tagName==="INPUT"||c.tagName==="TEXTAREA")){if((s.metaKey||s.ctrlKey)&&s.key==="z"&&!s.shiftKey){s.preventDefault();const h=Me.current.pop();h&&(h.undo(),Dt.current.push(h))}if((s.metaKey||s.ctrlKey)&&(s.key==="Z"||s.key==="z"&&s.shiftKey)){s.preventDefault();const h=Dt.current.pop();h&&(h.do(),Me.current.push(h))}s.key==="g"&&(s.metaKey||s.ctrlKey)&&s.shiftKey&&(s.preventDefault(),lo(h=>!h)),s.key==="0"&&(s.metaKey||s.ctrlKey)&&(s.preventDefault(),T({padding:.08,minZoom:ve,maxZoom:2,duration:400}))}};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[T,ve]);const ts=d.useCallback(o=>{o.preventDefault(),o.dataTransfer.dropEffect="copy"},[]),os=d.useCallback(o=>{o.preventDefault();const s=o.dataTransfer.getData("application/memo-kind");if(s)try{const c=JSON.parse(s),h=A({x:o.clientX,y:o.clientY});Ae({x:o.clientX,y:o.clientY,flowX:h.x,flowY:h.y,kind:c.kind,layer:c.layer,construct:c.construct})}catch{}},[A]),ns=d.useCallback(o=>{const s=A({x:o.clientX,y:o.clientY});Ae({x:o.clientX,y:o.clientY,flowX:s.x,flowY:s.y})},[A]),ss=d.useCallback(o=>{if(!te||!l){Ae(null);return}const s=te.kind??"Part",c=te.layer??"logical",h=te.construct??"part",g=kn[c]??"#6B7280",S=`_new_${Date.now()}`,$={id:S,type:"diagramNode",position:{x:te.flowX,y:te.flowY},data:{label:o,kind:s,layer:c,construct:h,color:g,isNew:!0,onContextMenu:(M,X)=>{Re({x:M.clientX,y:M.clientY,nodeId:X,nodeKind:s})},onInlineEdit:(M,X)=>{sn({id:S,name:X,kind:s,construct:h,layer:c})}}};z(M=>[...M,$]),Ps({name:o,kind:s,construct:h,attributes:{_layer:c}});const R=(x==null?void 0:x.elementIds)??[];O(l,[...R,S]);const W=l,V={nodes:{...(k[W]??{}).nodes??{},[S]:{x:te.flowX,y:te.flowY}},edges:(k[W]??{}).edges??{}};D({[W]:V}),Ve(W,V),Ae(null)},[te,l,x,k,D,O,z]),is=d.useCallback(()=>{Re(null),Je(null)},[]),rs=d.useCallback((o,s)=>{s!=null&&s.isValid},[]),as=d.useCallback(o=>{const{source:s,target:c}=o;if(!s||!c)return;const h=t==null?void 0:t.elements[s],g=t==null?void 0:t.elements[c];!h||!g||Qe({x:window.innerWidth/2-130,y:window.innerHeight/2-160,sourceElement:h,targetElement:g})},[t]),ls=d.useCallback(async o=>{if(!fe||!l){Qe(null);return}const s=fe.sourceElement.id;Qe(null);const c=await i({type:o.type,sourceId:o.sourceId,targetId:o.targetId,direction:o.direction,selectedElementId:s,diagramId:l});if(!c.success){console.warn(`[MEMO] Relationship rejected: ${c.error}`);return}const h=rn[o.type]??"#6B7280",g={id:c.relationshipId??`e_${o.sourceId}_${o.targetId}_${o.type}`,source:o.sourceId,target:o.targetId,label:o.type,type:"default",style:{stroke:h,strokeWidth:2},labelStyle:{fontSize:"10px",fill:"#374151"},labelBgStyle:{fill:"#FFFFFF",fillOpacity:.9},labelBgPadding:[4,2],labelBgBorderRadius:4,markerEnd:{type:"arrowclosed",color:h}};w(S=>Ds(g,S))},[fe,l,w,i]),ds=d.useCallback((o,s)=>{Ee.current={id:s.id,x:s.position.x,y:s.position.y}},[]),cs=d.useCallback((o,s)=>{const c=Ee.current;if(Ee.current=null,!((c==null?void 0:c.id)===s.id&&Math.hypot(s.position.x-c.x,s.position.y-c.y)>2)||(ne.current=Date.now()+250,Ce(R=>R+1),!l))return;ae();const{x:g,y:S}=s.position,$=le.current.get(s.id);if(le.current.set(s.id,{x:g,y:S}),E(l,s.id,{x:g,y:S}),$){const R=s.id,W=l;fo({do:()=>E(W,R,{x:g,y:S}),undo:()=>{E(W,R,$),z(V=>V.map(M=>M.id===R?{...M,position:$}:M))}})}},[l,E,fo,z,ae]),ps=d.useCallback(o=>{o.some(s=>s.type==="position"&&s.dragging)&&ae(),o.some(s=>s.type==="dimensions"&&s.resizing)&&(ae(),Ce(s=>s+1)),ue(Ns(o,ee.current))},[ue,ae]),us=d.useCallback((o,s)=>{},[]),xs=d.useCallback((o,s)=>{o.preventDefault(),Je({x:o.clientX,y:o.clientY,edgeId:s.id,relType:String(s.label??"edge")})},[]),hs=d.useCallback((o,s)=>{if(Date.now()<ne.current)return;const c=s.type==="actionFlowLane"?s.data.inspectElementId:void 0;!c&&(s.id.startsWith("__")||s.id.includes("__start")||s.id.includes("__done"))||(F(c??s.id),l&&p({type:"diagram",diagramId:l}))},[F,l,p]),gs=d.useCallback((o,s)=>{var c;if((c=o==null?void 0:o.stopPropagation)==null||c.call(o),B==="actionflow"){if(!Object.values((t==null?void 0:t.elements)??{}).some(g=>g.parentAction===s.id))return;ut(s.id);return}if(B==="statetransition"){const h=s.data;if(!h.hasChildren||h.isMachine){F(s.id);return}pt(s.id);return}if(B==="interconnection"){if(!!!s.data.isContainer){F(s.id);return}Mt(s.id),Pe(new Set),F(null)}},[B,t==null?void 0:t.elements,F,ut,pt]),fs=d.useCallback(()=>{m(null),b(null),Re(null),Je(null),z(o=>o.map(s=>({...s,style:{...s.style,opacity:1,boxShadow:void 0}}))),w(o=>o.map(s=>s.selected?{...s,selected:!1}:s))},[m,b,z,w]),ms=d.useCallback((o,s)=>{var c;(c=o==null?void 0:o.stopPropagation)==null||c.call(o),!(Date.now()<ne.current)&&(w(h=>h.map(g=>({...g,selected:g.id===s.id}))),t!=null&&t.relationships.some(h=>h.id===s.id)?b(s.id):t!=null&&t.elements[s.id]&&F(s.id))},[t,F,b,w]),bs=d.useCallback((o,s)=>{Ue({endpointIds:[s.id]})},[]),ys=d.useCallback((o,s)=>{Ue({edgeId:s.id,endpointIds:Cn(s)})},[]),Po=d.useCallback(()=>Ue(null),[]),Fs=d.useCallback((o,s)=>{var c;l&&(E(l,o,{...((c=k[l])==null?void 0:c.nodes[o])??{x:0,y:0},color:s||void 0}),z(h=>h.map(g=>g.id===o?{...g,data:{...g.data,bgColor:s||void 0}}:g)))},[l,k,E,z]),_o=d.useCallback(o=>{if(!l||!x)return;const s=(x.elementIds??[]).filter(c=>c!==o);O(l,s),z(c=>c.filter(h=>h.id!==o))},[l,x,O,z]),ws=d.useCallback((o,s)=>{const c=s==="dashed"?"6 3":s==="dotted"?"2 3":void 0;w(h=>h.map(g=>g.id===o?{...g,style:{...g.style,strokeDasharray:c}}:g))},[w]),js=d.useCallback((o,s)=>{w(c=>c.map(h=>h.id===o?{...h,style:{...h.style,stroke:s||(rn[String(h.label??"")]??"#6B7280")}}:h))},[w]),vs=d.useCallback(o=>{w(s=>s.map(c=>c.id===o?{...c,label:c.label?"":o.split("_")[3]??""}:c))},[w]);if(x&&t&&B==="grid")return e.jsx(ci,{diagram:x,model:t,viewpointFilter:Q});if(x&&t&&B==="browser")return e.jsx(pi,{diagram:x,model:t,viewpointFilter:Q});if(x&&B==="geometry"){const o=an.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:o.color+"20",color:o.color,fontSize:N.badge,marginBottom:"12px"},children:o.label}),e.jsx("h3",{style:{fontSize:N.lg,fontWeight:600,color:"#374151",marginBottom:"8px"},children:x.name}),e.jsx("p",{style:{fontSize:N.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!x&&_.length===0&&!G?e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!Ne&&e.jsx(Xt,{collapsed:Ne,onToggleCollapse:()=>Et(!0)}),Ne&&e.jsx(Xt,{collapsed:!0,onToggleCollapse:()=>Et(!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:N.lg,fontWeight:600,color:"#374151",marginBottom:"8px"},children:"Select a Diagram"}),e.jsx("p",{style:{fontSize:N.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(Xt,{collapsed:Ne,onToggleCollapse:()=>Et(!Ne),elementIds:x==null?void 0:x.elementIds,eligibleKinds:x!=null&&x.viewpointId&&(t!=null&&t.viewpoints)?new Set(((qo=t.viewpoints.find(o=>o.id===x.viewpointId))==null?void 0:qo.visibleKinds)??[]):void 0}),e.jsxs("div",{className:"flex-1 relative",onDragOver:ts,onDrop:os,onDoubleClick:ns,children:[x&&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:[Le&&e.jsx("span",{className:"px-1.5 py-0.5 rounded font-semibold",style:{background:Le.color+"20",color:Le.color,fontSize:N.badge},title:`${Le.fullName}${Te?` · ${Te.fullName}`:""}`,children:B==="actionflow"?Kn:Le.label}),e.jsx("span",{className:"font-medium",style:{color:"#1a1a1a"},children:x.name}),x.auto&&e.jsx("span",{style:{color:"#9CA3AF",fontSize:"9px"},children:"auto"}),e.jsx(ce,{}),e.jsx(Ye,{icon:e.jsx(H.grid,{}),label:"Grid",active:co,onClick:()=>{zn(o=>{const s=!o;return lo(s),s})},title:"Show or hide the canvas grid and snapping (⌘⇧G)"}),Fe&&e.jsxs(e.Fragment,{children:[e.jsx(ce,{}),e.jsx(oe,{icon:e.jsx(H.expand,{}),onClick:Wt,title:"Expand all nodes",ariaLabel:"Expand all"}),e.jsx(oe,{icon:e.jsx(H.collapse,{}),onClick:Ot,title:"Collapse all nodes",ariaLabel:"Collapse all"})]}),B==="actionflow"&&e.jsxs(e.Fragment,{children:[e.jsx(Ye,{icon:e.jsx(H.lanes,{}),active:$e,onClick:()=>jo(o=>!o),title:"Toggle allocation swimlanes"}),$e&&Vn&&e.jsx(Ye,{icon:e.jsx(H.lanes,{}),label:"Stage",active:Ze==="stage",onClick:()=>po(o=>o==="stage"?"allocation":"stage"),title:"Group this flow by its modeled stages"}),$e&&Ze==="allocation"&&vo.length>0&&e.jsxs("select",{"aria-label":"Display hierarchy level",title:"Display responsibility lanes at a hierarchy level; the SysML allocation is unchanged",value:It,onChange:o=>uo(o.target.value==="all"?"all":Number(o.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"}),vo.map(o=>e.jsxs("option",{value:o,children:["L",o]},o))]}),e.jsx(ce,{}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:N.xs,fontWeight:600},children:"Steps"}),e.jsx(Gt,{value:Lt,onChange:Do,options:[{value:"flat",label:"Inline",title:"Expanded steps join the parent flow in place"},{value:"nested",label:"Nested",title:"Expanded steps are drawn inside their composite action (swimlanes off)"}]}),e.jsx(ce,{}),e.jsx(Gt,{value:Ct,onChange:$n,options:[{value:"horizontal",icon:e.jsx(H.arrowRight,{}),title:"Left-to-right flow"},{value:"vertical",icon:e.jsx(H.arrowDown,{}),title:"Top-to-bottom flow"}]}),e.jsx(ce,{}),e.jsxs(ur,{children:[e.jsx(oe,{icon:e.jsx(H.expand,{}),title:"Expand all sub-actions",onClick:()=>He(new Set(Object.values((t==null?void 0:t.elements)??{}).map(o=>o.parentAction).filter(o=>!!o)))}),e.jsx(oe,{icon:e.jsx(H.collapse,{}),title:"Collapse all sub-actions",onClick:()=>He(new Set)})]}),e.jsx(ce,{}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Ye,{icon:e.jsx(H.filter,{}),active:xo,badge:`${ge.size}/4`,onClick:()=>Wn(o=>!o),title:"Choose which modeled connection categories are visible"}),xo&&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:N.xs},children:"Show connection categories"}),e.jsx("div",{style:{color:"#6B7280",fontSize:N.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(o=>{const s=ge.has(o),c=o==="control"?"#4B5563":o==="data"?"#3498DB":o==="energy"?"#D97706":"#16A34A";return e.jsxs("button",{role:"switch","aria-checked":s,onClick:()=>On(h=>{const g=new Set(h);return g.has(o)?g.delete(o):g.add(o),g}),className:"w-full flex items-center justify-between px-1 py-1.5 rounded",style:{color:"#374151",textTransform:"capitalize"},title:`${s?"Hide":"Show"} ${o} connections`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{style:{width:9,height:9,borderRadius:"50%",background:c}}),o]}),e.jsx("span",{"aria-hidden":"true",style:{width:32,height:18,borderRadius:9,background:s?"#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:s?"translateX(14px)":"translateX(0)",transition:"transform 160ms ease"}})})]},o)})]})]}),e.jsx(Zt,{path:qn,nameOf:o=>{var s;return((s=t==null?void 0:t.elements[o])==null?void 0:s.name)??o},onFocus:Tt,rootLabel:"Back to the whole action flow"})]}),B==="interconnection"&&e.jsxs(e.Fragment,{children:[e.jsx(ce,{}),e.jsx(oe,{icon:e.jsx(H.expand,{}),onClick:()=>Pe(new Set),title:"Expand all parts",ariaLabel:"Expand all"}),e.jsx(oe,{icon:e.jsx(H.collapse,{}),onClick:()=>Pe(new Set(dt)),title:"Collapse all parts",ariaLabel:"Collapse all"}),e.jsx("span",{style:{color:"#9CA3AF",fontSize:N.xs,fontWeight:600},children:"Ports"}),e.jsx(Gt,{value:_e,onChange:ko,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"}]}),e.jsx(Zt,{path:Xn,nameOf:o=>{var s;return((s=t==null?void 0:t.elements[o])==null?void 0:s.name)??o},onFocus:Mt,rootLabel:"Back to the whole diagram"})]}),B==="statetransition"&&e.jsxs(e.Fragment,{children:[e.jsx(ce,{}),e.jsx(oe,{icon:e.jsx(H.expand,{}),onClick:()=>Ke(new Set),title:"Show all substates",ariaLabel:"Expand all substates"}),e.jsx(oe,{icon:e.jsx(H.collapse,{}),onClick:()=>Ke(new Set(lt)),title:"Fold every composite state",ariaLabel:"Collapse all substates"}),e.jsx(Zt,{path:Gn,nameOf:o=>{var s;return((s=t==null?void 0:t.elements[o])==null?void 0:s.name)??o},onFocus:zt,rootLabel:"Back to the whole machine"})]}),Nt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsxs("label",{className:"flex items-center gap-1 text-xs font-semibold",style:{color:"#475569"},children:["Level",e.jsxs("select",{"aria-label":"Use case hierarchy level",value:At,onChange:o=>bo(o.target.value==="all"?"all":Number(o.target.value)),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{color:"#374151",background:"#FFFFFF",border:"1px solid #D1D5DB"},children:[e.jsx("option",{value:"all",children:"All levels"}),Array.from({length:_n+1},(o,s)=>e.jsxs("option",{value:s,children:["L",s]},s))]})]}),e.jsxs("label",{className:"flex items-center gap-1 text-xs font-semibold",style:{color:"#475569"},children:["Routing",e.jsxs("select",{"aria-label":"Use case connector routing",value:Rt,onChange:o=>yo(o.target.value),className:"px-1.5 py-0.5 text-xs font-medium rounded",style:{color:"#374151",background:"#FFFFFF",border:"1px solid #D1D5DB"},children:[e.jsx("option",{value:"straight",children:"Straight"}),e.jsx("option",{value:"elbow",children:"Elbow"}),e.jsx("option",{value:"rounded",children:"Rounded"}),e.jsx("option",{value:"curved",children:"Curved"}),e.jsx("option",{value:"arc",children:"Arc"})]})]}),e.jsx("button",{onClick:es,className:"px-2 py-0.5 text-xs font-semibold rounded",style:{color:"#047857",background:"#ECFDF5",border:"1px solid #A7F3D0"},title:"Reapply the constrained hierarchy layout and obstacle-aware routes",children:"Auto arrange"}),wo.length>0&&e.jsxs("details",{className:"relative",children:[e.jsxs("summary",{className:"px-2 py-0.5 text-xs font-semibold rounded cursor-pointer",style:{color:"#374151",background:"#FFFFFF",border:"1px solid #D1D5DB"},children:["Actors",ze.size?`: ${ze.size} hidden`:""]}),e.jsxs("div",{className:"absolute top-7 left-0 z-30 min-w-48 p-2 rounded shadow-lg",style:{background:"#FFFFFF",border:"1px solid #D1D5DB"},children:[e.jsx("div",{className:"mb-1 text-xs",style:{color:"#64748B"},children:"Hide related use cases"}),wo.map(o=>e.jsxs("label",{className:"flex items-center gap-2 py-1 text-xs",style:{color:"#374151"},children:[e.jsx("input",{type:"checkbox",checked:ze.has(o.id),onChange:()=>Fo(s=>{const c=new Set(s);return c.has(o.id)?c.delete(o.id):c.add(o.id),c})}),o.name]},o.id))]})]})]}),Ie&&!Nt&&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:Hn.map(o=>e.jsx("button",{onClick:()=>{mo(o),le.current.clear()},className:"px-2 py-0.5 text-xs font-medium capitalize",style:{background:Se===o?"#1B3A4B":"#FFFFFF",color:Se===o?"#FFFFFF":"#6B7280"},title:o==="graph"?"Relationship graph with compartments":o==="tree"?"Decomposition tree with expand/collapse":"Nested containment blocks",children:o},o))}),Se!=="graph"&&e.jsxs(e.Fragment,{children:[e.jsx(oe,{icon:e.jsx(H.expand,{}),onClick:Wt,title:"Expand all nodes",ariaLabel:"Expand all"}),e.jsx(oe,{icon:e.jsx(H.collapse,{}),onClick:Ot,title:"Collapse all nodes",ariaLabel:"Collapse all"}),Se==="tree"&&e.jsx("button",{onClick:Pt,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"})]})]}),ot&&!Fe&&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(o=>e.jsx("button",{onClick:()=>{Yn(o),le.current.clear()},className:"px-2 py-0.5 text-xs font-medium",style:{background:We===o?"#1B3A4B":"#FFFFFF",color:We===o?"#FFFFFF":"#6B7280"},children:o==="containment"?"Containment":"Decomposition"},o))}),e.jsx(ce,{}),e.jsx(oe,{icon:e.jsx(H.expand,{}),onClick:Wt,title:"Expand all nodes",ariaLabel:"Expand all"}),e.jsx(oe,{icon:e.jsx(H.collapse,{}),onClick:Ot,title:"Collapse all nodes",ariaLabel:"Collapse all"}),We==="decomposition"&&e.jsx("button",{onClick:Pt,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"})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),!Nt&&e.jsxs("button",{"aria-pressed":he,onClick:()=>{if(he)ae();else{const o=L.getState().diagramLayouts[l],s={nodes:{},edges:{},canvas:{...o==null?void 0:o.canvas,autoLayout:!0}};D({[l]:s}),Ve(l,s),kt(c=>c+1)}},className:"px-2 py-0.5 text-xs font-semibold rounded",style:{background:he?"#ECFDF5":"#FFF7ED",color:he?"#047857":"#C2410C",border:`1px solid ${he?"#A7F3D0":"#FED7AA"}`},title:he?"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: ",he?"On":"Off"]})]}),l&&B==="interconnection"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"#E5E5E0"},children:"|"}),e.jsxs("button",{"aria-pressed":me,onClick:()=>{const o=L.getState().diagramLayouts[l]??{nodes:{},edges:{}},s={...o,canvas:{...o.canvas,flowAnimation:!me}};D({[l]:s}),Ve(l,s),w(c=>c.map(h=>({...h,data:{...h.data,flowAnimation:!me}})))},className:"px-2 py-0.5 text-xs font-semibold rounded",style:{background:me?"#EFF6FF":"#F8FAFC",color:me?"#1D4ED8":"#64748B",border:`1px solid ${me?"#93C5FD":"#CBD5E1"}`},title:"Toggle animated source-to-target flow on IBD connectors",children:["Flow: ",me?"On":"Off"]}),e.jsx("button",{"aria-pressed":Eo,onClick:()=>Co(o=>!o),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"})]})]}),Be&&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(o=>e.jsx("button",{onClick:()=>Pn(o),style:{width:20,height:20,borderRadius:4,cursor:"pointer",background:et===o?"#2DD4A8":"rgba(255,255,255,0.15)",color:et===o?"#1B3A4B":"#FFFFFF",fontWeight:700,fontSize:"11px",border:"none"},children:o},o)),e.jsx("button",{onClick:()=>{ho(null),z(o=>o.map(s=>({...s,style:{...s.style,opacity:1,pointerEvents:"all"}}))),w(o=>o.map(s=>({...s,style:{...s.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"})]}),tt&&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: ",tt]}),G&&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…"}),io&&!G&&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:N.xs},children:[e.jsx("span",{children:io}),e.jsx("button",{onClick:Pt,style:{border:"1px solid #B58A12",borderRadius:3,background:"#FFFFFF",color:"#5F4300",padding:"3px 8px",fontWeight:700,whiteSpace:"nowrap"},children:"Retry"})]}),nt.length>0&&!G&&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:N.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"Diagram error:"})," ",nt.length," floating ",nt.length===1?"action has":"actions have"," no flow or succession connection:"," ",nt.map((o,s)=>e.jsxs("span",{children:[s>0&&", ",e.jsx("button",{onClick:()=>F(o.id),style:{color:"#991B1B",textDecoration:"underline",fontWeight:700},children:o.name})]},o.id))]}),ct&&!G&&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:N.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"BDD error:"})," ","expected one connected hierarchy, but found ",ct.rootIds.length," roots",ct.disconnectedIds.length>0&&e.jsxs(e.Fragment,{children:[" and ",ct.disconnectedIds.length," disconnected/floating elements"]}),"."]}),B==="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:N.xs},children:[e.jsx("span",{style:{fontWeight:700},children:"Legend"}),ge.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"]}),ge.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"]}),ge.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"]}),ge.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"]})]}),B==="interconnection"&&_.length>0&&Eo&&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:N.xs},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{style:{fontWeight:700},children:"Ports"}),_e!=="none"?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qt,{color:Ft.in,glyph:"→"})," in"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qt,{color:Ft.out,glyph:"→"})," out"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qt,{color:Ft.inout,glyph:"⇄"})," inout"]}),_e==="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(o=>e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{width:20,height:0,borderTop:`2.5px solid ${ui[o]}`}}),o]},o))]})]}),!G&&_.length===0&&x&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",style:{zIndex:1},children:x.auto&&((Zo=x.elementIds)==null?void 0:Zo.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:N.sm,color:"#374151",fontWeight:600,marginBottom:4},children:"This view selects no elements"}),e.jsx("div",{style:{fontSize:N.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:N.sm,color:"#6B7280"},children:"Drag from palette or double-click to create elements"})]})}),G&&e.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",zIndex:20,background:`linear-gradient(90deg, ${ln.accent} 0%, ${ln.accent}80 50%, transparent 100%)`,backgroundSize:"200% 100%",animation:"memo-layout-progress 1.2s linear infinite"}}),e.jsxs(As,{nodes:_,edges:re,nodeTypes:Zn,edgeTypes:Qn,onNodesChange:ps,onEdgesChange:pe,onNodeClick:hs,onNodeDoubleClick:gs,onEdgeClick:ms,onPaneClick:fs,onNodeDragStart:ds,onNodeDragStop:cs,onNodeContextMenu:us,onEdgeContextMenu:xs,onNodeMouseEnter:bs,onNodeMouseLeave:Po,onEdgeMouseEnter:ys,onEdgeMouseLeave:Po,onConnect:as,onConnectStart:is,onConnectEnd:rs,connectionMode:Rs.Loose,defaultEdgeOptions:{interactionWidth:24},snapToGrid:Ln,snapGrid:mr,fitView:!0,fitViewOptions:{...hr,minZoom:ve},minZoom:.1,maxZoom:3,zoomOnScroll:!0,panOnScroll:!0,panOnScrollMode:"free",selectionOnDrag:!1,proOptions:fr,style:xr,children:[co&&e.jsx(Bs,{color:"#C5C7C2",gap:20,size:1.5}),e.jsx(yi,{}),e.jsx(Ms,{}),_.length>20&&e.jsx(Ts,{style:gr,nodeColor:Jn,maskColor:"rgba(247, 247, 245, 0.7)"})]})]}),te&&e.jsx(wr,{x:te.x,y:te.y,onConfirm:ss,onCancel:()=>Ae(null)}),fe&&e.jsx(xi,{x:fe.x,y:fe.y,sourceElement:fe.sourceElement,targetElement:fe.targetElement,registries:n,onSelect:ls,onCancel:()=>Qe(null)}),q&&e.jsx(sr,{x:q.x,y:q.y,nodeId:q.nodeId,nodeKind:q.nodeKind,onClose:()=>Re(null),onEditName:()=>{z(o=>o.map(s=>s.id===q.nodeId?{...s,data:{...s.data,_triggerEdit:!0}}:s))},onChangeColor:o=>Fs(q.nodeId,o),onRemoveFromDiagram:()=>_o(q.nodeId),onDeleteFromModel:()=>{_o(q.nodeId)},onShowProperties:()=>{m(q.nodeId)},onShowInCatalog:()=>{m(q.nodeId),I("catalog")},onFocusElement:()=>{ho(q.nodeId)},onShowRelMatrix:()=>{p({type:"traceability"})},onOpenSource:()=>{const o=t==null?void 0:t.elements[q.nodeId];o!=null&&o.file&&(navigator.clipboard.writeText(o.file).catch(()=>{}),go(o.file))},onViewKindInOntology:()=>{const o=q.nodeKind;let s=null,c=null;for(const h of v){for(const g of h.layers)if(g.kinds.some(S=>S.name===o)){s=h.name,c=g.id;break}if(s)break}s&&(f(o),y("ontologies"),I("ontology"),p({type:"ontology-detail",packageName:s,layerId:c??void 0}))}}),xe&&e.jsx(rr,{x:xe.x,y:xe.y,edgeId:xe.edgeId,relType:xe.relType,onClose:()=>Je(null),onChangeStyle:o=>ws(xe.edgeId,o),onChangeColor:o=>js(xe.edgeId,o),onToggleLabel:()=>vs(xe.edgeId),onDelete:()=>w(o=>o.filter(s=>s.id!==xe.edgeId))})]})}function Rr(){return e.jsx(Es,{children:e.jsx(jr,{})})}export{Rr as DiagramCanvas};
@@ -1,2 +0,0 @@
1
- import{j as e}from"./reactflow-CsCqNKB-.js";import{a as b}from"./zustand-CrhqMOHB.js";import{u as m,h as A,C as i,F as r,f as W,E as B,P as j,p as v,q as C,r as M,t as O,v as T}from"./index-BMgENwvO.js";const a="page",$=new Set(["Scenario","UseCase","UserActivity"]);function D(l){return l?l.split(`
2
- `).filter(s=>s.trim()).map((s,c)=>{const p=s.match(/^\d+\.\s*(.*)/);return{index:c,text:p?p[1].trim():s.trim()}}):[]}function V({element:l,layerColor:s,onSave:c}){const p=b.useMemo(()=>D(l.doc||""),[l.doc]),[y,u]=b.useState(!1);return y||p.length===0?e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:r.xs,color:i.faint,marginBottom:6,marginTop:0},children:["One step per line, numbered: ",e.jsx("code",{children:"1. User does something"})]}),e.jsx(v,{value:l.doc||"",onSave:n=>{c(n),u(!1)},density:a,multiline:!0,placeholder:"Click to add scenario steps…"})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>u(!0),style:{position:"absolute",top:0,right:0,fontSize:r.xs,color:i.muted,padding:"2px 9px",border:`1px solid ${i.border}`,borderRadius:"6px",background:i.surface,cursor:"pointer"},onMouseEnter:n=>{n.currentTarget.style.borderColor=i.accent},onMouseLeave:n=>{n.currentTarget.style.borderColor=i.border},children:"✎ Edit steps"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",paddingTop:4},children:[e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:r.xs,fontWeight:700,background:s,color:"#fff",letterSpacing:"0.06em",textTransform:"uppercase"},children:"Start"}),p.map((n,o)=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:[e.jsx(k,{color:s}),e.jsxs("div",{style:{width:"100%",maxWidth:"560px",display:"flex",alignItems:"flex-start",gap:"12px",background:i.surface,border:`1px solid ${s}30`,borderRadius:"8px",padding:"10px 14px",boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},children:[e.jsx("span",{style:{flexShrink:0,width:"24px",height:"24px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",background:s+"18",color:s,fontSize:r.xs,fontWeight:700},children:o+1}),e.jsx("span",{style:{fontSize:r.sm,color:i.primary,lineHeight:1.5,paddingTop:"3px"},children:n.text})]})]},o)),e.jsx(k,{color:s}),e.jsx("div",{style:{padding:"6px 20px",borderRadius:"999px",fontSize:r.xs,fontWeight:700,background:s+"20",color:s,letterSpacing:"0.06em",textTransform:"uppercase",border:`1px solid ${s}40`},children:"End"})]})]})}function k({color:l}){return e.jsx("div",{style:{width:"2px",height:"20px",background:l+"50",position:"relative"},children:e.jsx("div",{style:{position:"absolute",bottom:-5,left:"50%",transform:"translateX(-50%)",width:0,height:0,borderLeft:"5px solid transparent",borderRight:"5px solid transparent",borderTop:`6px solid ${l}80`}})})}function H(){var F,I,R;const l=m(t=>t.activeView),s=m(t=>t.model),c=m(t=>t.validation),p=m(t=>t.updateElementField),y=m(t=>t.updateElementAttribute),u=m(t=>t.applyEdit),n=l.type==="element-detail"?l.elementId:null,o=n&&s?s.elements[n]:null,S=b.useMemo(()=>{if(!s||!n)return{incoming:[],outgoing:[]};const t=A(s,n);return{incoming:t.filter(d=>d.targetId===n),outgoing:t.filter(d=>d.sourceId===n)}},[s,n]),h=b.useMemo(()=>!c||!n?[]:c.violations.filter(t=>t.elementId===n),[c,n]);if(!o||!n)return e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:i.surfaceAlt},children:e.jsxs("div",{className:"text-center",style:{color:i.faint},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"12px",opacity:.5},children:"📄"}),e.jsx("p",{style:{fontSize:r.md},children:"Select an element to view details"})]})});const g=W[o.layer]||i.muted,x=(F=s==null?void 0:s.registries)==null?void 0:F.kinds.find(t=>t.name===o.kind),E=((I=x==null?void 0:x.namespace)==null?void 0:I[1])??((R=x==null?void 0:x.namespace)==null?void 0:R[0]),w=(t,d)=>{p(n,t,d),u(n)},N=(t,d)=>{y(n,t,d),u(n)},f=Object.entries(o.attributes).filter(([t])=>t!=="id"&&t!=="name"),z=$.has(o.kind);return e.jsx("div",{className:"flex-1 overflow-y-auto",style:{background:"#EEF4F7"},children:e.jsxs("div",{style:{maxWidth:"1040px",margin:"0 auto",padding:"20px 28px 48px"},children:[e.jsxs("header",{style:{background:i.surface,border:"1px solid rgba(60,60,67,0.12)",borderLeft:`4px solid ${g}`,borderRadius:"16px",padding:"14px 18px",marginBottom:16,boxShadow:"0 1px 3px rgba(15,23,42,0.05)"},children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",style:{marginBottom:8},children:[e.jsx("span",{className:"px-2 py-0.5 rounded-md font-semibold",style:{background:g+"18",color:g,fontSize:r.xs},children:o.kind}),e.jsx("span",{className:"px-2 py-0.5 rounded-md",style:{background:i.surfaceAlt,color:i.muted,fontSize:r.xs},children:o.layer}),E&&e.jsx("span",{style:{color:i.faint,fontSize:r.xs},children:E.replace(/[_-]/g," ").replace(/\b\w/g,t=>t.toUpperCase())}),o.shortId&&e.jsx("span",{style:{marginLeft:"auto",color:i.faint,fontSize:r.xs,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:o.shortId})]}),e.jsx("h1",{style:{fontSize:"24px",fontWeight:700,color:i.primary,lineHeight:1.2,margin:0},children:o.name}),e.jsx("div",{style:{marginTop:9,paddingTop:8,borderTop:`1px solid ${i.borderLight}`},children:e.jsx(B,{density:a})})]}),h.length>0&&e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid #FEE2E2",background:"#FEF2F2",marginBottom:20},children:[e.jsxs("div",{className:"px-4 py-2 font-semibold",style:{color:"#DC2626",fontSize:r.sm,borderBottom:"1px solid #FEE2E2"},children:[h.length," violation",h.length!==1?"s":""]}),h.map((t,d)=>e.jsxs("div",{className:"px-4 py-2 flex items-center gap-2",style:{fontSize:r.xs},children:[e.jsx("span",{style:{color:"#DC2626"},children:"✖"}),e.jsxs("span",{style:{color:i.faint},children:["[",t.ruleId,"]"]}),e.jsx("span",{style:{color:"#991B1B"},children:t.description})]},d))]}),e.jsx(j,{title:z?"Flow":"Description",density:a,collapsible:!1,children:z?e.jsx(V,{element:o,layerColor:g,onSave:t=>w("doc",t)}):e.jsx(v,{value:o.doc||"",onSave:t=>w("doc",t),density:a,multiline:!0,placeholder:"Click to add a description…"})}),e.jsxs(j,{title:"Attributes",count:f.length,density:a,collapsible:!1,children:[f.length===0&&e.jsx("p",{style:{fontSize:r.sm,color:i.faint,margin:0},children:"This element defines no attributes."}),f.length>0&&e.jsx("div",{style:{borderTop:`1px solid ${i.border}`,maxWidth:900},children:f.map(([t,d])=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(150px, 24%) minmax(0, 1fr)",gap:16,alignItems:"center",padding:"7px 0",borderBottom:`1px solid ${i.borderLight}`},children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{color:i.secondary,fontSize:r.sm,fontWeight:600},children:t}),e.jsx("div",{style:{color:i.faint,fontSize:"10px"},children:"Editable"})]}),e.jsx(v,{value:String(d??""),onSave:L=>N(t,L),density:a,placeholder:"Add value…",compact:!0})]},t))})]}),e.jsx(C,{element:o,outgoing:S.outgoing,incoming:S.incoming,density:a}),e.jsx(j,{title:"Source",density:a,collapsible:!1,children:e.jsx("div",{style:{maxWidth:720},children:e.jsx(M,{label:"SysML source file",editability:T("file"),density:a,children:e.jsx(O,{value:o.file??"—",editability:T("file"),density:a,mono:!0})})})})]})})}export{H as ElementDetailView};
@@ -1 +0,0 @@
1
- import{j as e,H as C,P as k,R as D,a as S,i as O,f as R,g as I}from"./reactflow-CsCqNKB-.js";import{a as p}from"./zustand-CrhqMOHB.js";/* empty css */import{r as T}from"./layout-providers-Dr743WlP.js";import{f as L,u as h,I as P,J as M,K as z}from"./index-BMgENwvO.js";import"./elk-6l8mIQnQ.js";const A={ontology:{bg:"#EFF6FF",fg:"#2563EB",border:"#BFDBFE"},profile:{bg:"#F0FDF4",fg:"#16A34A",border:"#BBF7D0"},extension:{bg:"#FFF7ED",fg:"#EA580C",border:"#FED7AA"}};function H({data:i}){const s=i,l=A[s.type]??A.ontology;return e.jsxs("div",{"data-testid":`ontology-package-node-${s.name}`,onClick:s.onClick,onDoubleClick:s.onDoubleClick,onContextMenu:s.onContextMenu,style:{background:"#FFFFFF",border:s.selected?"2px solid #2563EB":"1px solid #E5E5E0",borderRadius:"12px",padding:"16px",minWidth:"240px",maxWidth:"300px",cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.06)",transition:"box-shadow 200ms ease, transform 200ms ease"},children:[e.jsx(C,{type:"target",position:k.Top,id:"top",style:w}),e.jsx(C,{type:"source",position:k.Bottom,id:"bottom",style:w}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"8px"},children:[e.jsx("span",{style:{padding:"1px 8px",fontSize:"10px",borderRadius:"9999px",fontWeight:600,background:l.bg,color:l.fg,border:`1px solid ${l.border}`},children:s.type}),e.jsxs("span",{style:{fontSize:"10px",color:"#9CA3AF"},children:["v",s.version]})]}),e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"#1a1a1a",marginBottom:"4px"},children:s.name}),s.description&&e.jsx("div",{style:{fontSize:"11px",color:"#9CA3AF",marginBottom:"10px",lineHeight:"1.4"},children:s.description.length>80?s.description.slice(0,80)+"…":s.description}),e.jsx("div",{style:{display:"flex",gap:"2px",marginBottom:"8px",height:"6px",borderRadius:"3px",overflow:"hidden"},children:s.layers.slice(0,12).map(d=>{const n=L[d.id]??d.color??"#6B7280";return e.jsx("div",{style:{flex:Math.max(d.kindCount,1),background:n,borderRadius:"1px"},title:`${d.label}: ${d.kindCount} kinds`},d.id)})}),e.jsxs("div",{style:{display:"flex",gap:"12px",fontSize:"11px",color:"#6B7280"},children:[e.jsxs("span",{children:[e.jsx("strong",{style:{color:"#1B3A4B"},children:s.kindCount})," kinds"]}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:"#1B3A4B"},children:s.layerCount})," layers"]})]})]})}const w={width:"8px",height:"8px",background:"#2563EB",border:"2px solid #FFFFFF",opacity:0},W=p.memo(H);function $({onClose:i}){const s=h(o=>o.availableOntologies),l=h(o=>o.ontologyInstallStatus),d=h(o=>o.setOntologyInstallStatus),[n,c]=p.useState(""),[r,g]=p.useState(null);function t(){n.trim()&&(d({installing:!0}),P(n.trim()),c(""))}function x(o){M(o),g(null)}return e.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-50",style:{background:"rgba(0,0,0,0.4)"},onClick:i,children:e.jsxs("div",{className:"rounded-xl shadow-2xl overflow-hidden",style:{background:"#FFFFFF",width:"520px",maxHeight:"600px",border:"1px solid #E5E5E0"},onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("h2",{className:"text-sm font-semibold",style:{color:"#1a1a1a"},children:"Manage Ontology Library"}),e.jsx("button",{onClick:i,className:"text-sm px-2 py-0.5 rounded hover:bg-gray-100",style:{color:"#9CA3AF"},children:"x"})]}),e.jsxs("div",{className:"p-5 space-y-5 overflow-y-auto",style:{maxHeight:"480px"},children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium block mb-1.5",style:{color:"#374151"},children:"Add Ontology"}),e.jsx("p",{className:"text-xs mb-2",style:{color:"#9CA3AF"},children:"Enter a git URL (https://...git), npm package name (@memoarchitect/...), or local path."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"https://gitlab.com/org/my-ontology.git",value:n,onChange:o=>c(o.target.value),onKeyDown:o=>o.key==="Enter"&&t(),className:"flex-1 px-3 py-2 text-xs rounded-lg",style:{border:"1px solid #E5E7EB",background:"#F9FAFB",color:"#374151",outline:"none"},onFocus:o=>o.currentTarget.style.borderColor="#2563EB",onBlur:o=>o.currentTarget.style.borderColor="#E5E7EB",disabled:l.installing}),e.jsx("button",{onClick:t,disabled:!n.trim()||l.installing,className:"px-4 py-2 text-xs rounded-lg font-medium",style:{background:l.installing?"#9CA3AF":"#1B3A4B",color:"#FFFFFF",opacity:!n.trim()||l.installing?.5:1,cursor:!n.trim()||l.installing?"not-allowed":"pointer"},children:l.installing?"Installing...":"Install"})]}),l.error&&e.jsx("div",{className:"mt-2 px-3 py-2 rounded-lg text-xs",style:{background:"#FEF2F2",color:"#DC2626",border:"1px solid #FECACA"},children:l.error}),l.lastInstalled&&!l.error&&e.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-xs",style:{background:"#F0FDF4",color:"#16A34A",border:"1px solid #BBF7D0"},children:["Installed ",l.lastInstalled]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-xs font-medium block mb-2",style:{color:"#374151"},children:["Installed Packages (",s.length,")"]}),e.jsxs("div",{className:"space-y-1.5",children:[s.map(o=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{border:"1px solid #E5E5E0",background:"#FAFAF8"},children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium truncate",style:{color:"#1a1a1a"},children:o.name}),e.jsx("span",{className:"px-1.5 py-0.5 text-xs rounded",style:{background:o.type==="ontology"?"#EFF6FF":o.type==="profile"?"#F0FDF4":"#FFF7ED",color:o.type==="ontology"?"#2563EB":o.type==="profile"?"#16A34A":"#EA580C",fontSize:"10px"},children:o.type})]}),e.jsxs("div",{className:"text-xs mt-0.5",style:{color:"#9CA3AF"},children:["v",o.version," · ",o.kindCount," kinds · ",o.layers.length," layers"]})]}),r===o.name?e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>x(o.name),className:"px-2 py-1 text-xs rounded",style:{background:"#DC2626",color:"#FFFFFF"},children:"Confirm"}),e.jsx("button",{onClick:()=>g(null),className:"px-2 py-1 text-xs rounded",style:{background:"#F3F4F6",color:"#374151"},children:"Cancel"})]}):e.jsx("button",{onClick:()=>g(o.name),className:"text-xs px-2 py-1 rounded hover:bg-red-50",style:{color:"#DC2626",border:"1px solid #FECACA"},children:"Remove"})]},o.name)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-xs",style:{color:"#9CA3AF"},children:"No ontology packages installed"})]})]})]})]})})}const _={ontologyPackage:W},Y=260,K=180;async function V(i){const s=new Map(i.map(t=>[t.name,t])),l={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.layered.nodePlacement.strategy":"BRANDES_KOEPF","elk.layered.spacing.nodeNodeBetweenLayers":"100","elk.spacing.nodeNode":"32","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.padding":"[top=24, left=24, bottom=24, right=24]"},children:i.map(t=>({id:t.name,width:Y,height:K})),edges:i.filter(t=>t.extends&&s.has(t.extends)).map((t,x)=>({id:`e-${x}`,sources:[t.extends],targets:[t.name]}))},d=await T(l),n=new Map;for(const t of d.children??[])n.set(t.id,{x:t.x??0,y:t.y??0});const c={ontology:"#3B82F6",profile:"#10B981",extension:"#F59E0B"},r=i.map(t=>({id:t.name,type:"ontologyPackage",position:n.get(t.name)??{x:0,y:0},data:{name:t.name,type:t.type,version:t.version,description:t.description,kindCount:t.kindCount,layerCount:t.layers.length,layers:t.layers.map(x=>({id:x.id,label:x.label,color:x.color,kindCount:x.kindCount})),selected:t.selected,onClick:()=>{}}})),g=[];for(const t of i)if(t.extends&&s.has(t.extends)){const x=c[t.type]??"#94A3B8";g.push({id:`${t.extends}->${t.name}`,source:t.extends,target:t.name,type:"smoothstep",data:{edgeType:"extends"},style:{stroke:x,strokeWidth:2,strokeDasharray:"6 3"},animated:!1,label:"extends",labelStyle:{fontSize:9,fill:x,fontWeight:500},labelBgStyle:{fill:"#F7F7F5",fillOpacity:.9},labelBgPadding:[4,2],markerEnd:{type:"arrowclosed",color:x,width:14,height:14}})}return{nodes:r,edges:g}}function G(i,s){const l=new Map;for(const c of s)c.extends&&(l.has(c.extends)||l.set(c.extends,[]),l.get(c.extends).push(c.name));const d=new Set([i]),n=[i];for(;n.length;){const c=n.shift();for(const r of l.get(c)??[])d.has(r)||(d.add(r),n.push(r))}return d}function U(){const i=h(a=>a.availableOntologies),s=h(a=>a.setActiveView),l=h(a=>a.hiddenEdgeTypes),d=h(a=>a.toggleHiddenEdgeType),[n,c]=p.useState(!1),[r,g]=p.useState({nodes:[],edges:[]}),[t,x]=p.useState(null),{fitView:o}=S();p.useEffect(()=>{let a=!1;return V(i).then(u=>{a||g(u)}).catch(u=>{console.error("[OntologyDiagram] ELK layout failed:",u)}),()=>{a=!0}},[i]);const F=p.useCallback(a=>{s({type:"ontology-detail",packageName:a})},[s]),E=p.useCallback(a=>{const u=G(a,i),m=r.nodes.filter(y=>u.has(y.id));m.length!==0&&o({nodes:m.map(y=>({id:y.id})),duration:400,padding:.2})},[i,r.nodes,o]),v=p.useCallback((a,u)=>{a.preventDefault(),x({x:a.clientX,y:a.clientY,packageName:u})},[]);p.useEffect(()=>{const a=u=>{if(u.key==="Escape"){if(t){x(null);return}o({padding:.1,duration:300})}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,o]);const{nodes:N,edges:B}=p.useMemo(()=>{const a=r.nodes.map(m=>({...m,data:{...m.data,onClick:()=>E(m.id),onDoubleClick:()=>F(m.id),onContextMenu:y=>v(y,m.id)}})),u=r.edges.filter(m=>{var j;const y=(j=m.data)==null?void 0:j.edgeType;return!y||!l.has(y)});return{nodes:a,edges:u}},[r,E,F,v,l]),f=p.useRef(null);p.useEffect(()=>{if(!t)return;const a=u=>{f.current&&!f.current.contains(u.target)&&x(null)};return window.addEventListener("mousedown",a),()=>window.removeEventListener("mousedown",a)},[t]);const b=l.has("extends");return i.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center",style:{background:"#F7F7F5"},children:e.jsxs("div",{className:"text-center",style:{color:"#9CA3AF"},children:[e.jsx("div",{className:"text-3xl mb-3",children:"◉"}),e.jsx("div",{className:"text-sm font-medium mb-1",style:{color:"#374151"},children:"No ontology packages found"}),e.jsx("div",{className:"text-xs",children:"Start the dev server to load ontology packages"})]})}):e.jsxs("div",{className:"flex-1",style:{background:"#F7F7F5"},children:[e.jsxs("div",{className:"flex items-start justify-between px-6 pt-5 pb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold",style:{color:"#1a1a1a"},children:"Ontology Library"}),e.jsxs("p",{className:"text-xs mt-1",style:{color:"#9CA3AF"},children:[i.length," package",i.length!==1?"s":""," available. Click to zoom, double-click to open, right-click for source."]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{"data-testid":"toggle-tracing",onClick:()=>d("extends"),title:b?"Show extends tracing edges":"Hide extends tracing edges",className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:b?{background:"#F0F0ED",color:"#6B7280",border:"1px solid #E5E5E0"}:{background:"#1B3A4B",color:"#2DD4A8",border:"1px solid transparent"},children:b?"Show Tracing":"Hide Tracing"}),e.jsx("button",{onClick:()=>c(!0),className:"px-3 py-1.5 text-xs rounded-lg font-medium",style:{background:"#1B3A4B",color:"#2DD4A8"},children:"+ Add Ontology"})]})]}),n&&e.jsx($,{onClose:()=>c(!1)}),e.jsx("div",{style:{flex:1,height:"calc(100% - 72px)"},children:e.jsxs(O,{nodes:N,edges:B,nodeTypes:_,fitView:!0,fitViewOptions:{padding:.1},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnScroll:!0,zoomOnDoubleClick:!1,minZoom:.2,maxZoom:2.5,proOptions:{hideAttribution:!0},children:[e.jsx(R,{color:"#E5E5E0",gap:24,size:1}),e.jsx(I,{showInteractive:!1})]})}),t&&e.jsx(Z,{menuRef:f,state:t,onClose:()=>x(null),packages:i})]})}const Z=({state:i,onClose:s,packages:l,menuRef:d})=>{const n=l.find(r=>r.name===i.packageName);function c(){if(!n)return;const r=n.rootDir?`${n.rootDir}/memo.package.yaml`:"";r?z(r):window.open(`vscode://file/${encodeURIComponent(n.name)}`),s()}return e.jsxs("div",{ref:d,style:{position:"fixed",top:i.y,left:i.x,zIndex:1e3,background:"#FFFFFF",border:"1px solid #E5E5E0",borderRadius:"8px",boxShadow:"0 6px 16px rgba(0,0,0,0.12)",padding:"4px",minWidth:"180px",fontSize:"12px"},children:[e.jsx("div",{style:{padding:"6px 10px",color:"#9CA3AF",fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.4px"},children:i.packageName}),e.jsx("button",{onClick:c,disabled:!(n!=null&&n.rootDir),style:{display:"block",width:"100%",textAlign:"left",padding:"6px 10px",border:"none",background:"transparent",cursor:n!=null&&n.rootDir?"pointer":"not-allowed",color:n!=null&&n.rootDir?"#1a1a1a":"#9CA3AF",borderRadius:"4px"},onMouseEnter:r=>{n!=null&&n.rootDir&&(r.currentTarget.style.background="#F0F0ED")},onMouseLeave:r=>{r.currentTarget.style.background="transparent"},children:"Open source"})]})};function oe(){return e.jsx(D,{children:e.jsx(U,{})})}export{oe as OntologyDecompositionDiagram,oe as default};
@@ -1,3 +0,0 @@
1
- import{j as e}from"./reactflow-CsCqNKB-.js";import{a as d}from"./zustand-CrhqMOHB.js";import{u as N,h as ne,i as oe,f as L}from"./index-BMgENwvO.js";const re=[{label:"Activity diagram",types:new Set(["act"])},{label:"Operative flow",types:new Set(["afd","ofd"])},{label:"Function flow",types:new Set(["ffd"])},{label:"Sequence diagram",types:new Set(["seq"])}];function ae(r){return re.map(b=>{const m=r.filter(g=>b.types.has(g.diagramType.toLowerCase()));return{label:b.label,items:m}}).filter(b=>b.items.length>0)}function q(r){return r?r.split(`
2
- `).filter(m=>m.trim()).map((m,g)=>{const S=m.match(/^\d+\.\s*(.*)/);return{index:g,text:S?S[1]:m}}):[]}function ce(r){return r.map((b,m)=>`${m+1}. ${b.text}`).join(`
3
- `)}function me(){const r=N(s=>s.model),b=N(s=>s.createRelationship),m=N(s=>s.selectElement),g=N(s=>s.selectedElementId),S=N(s=>s.setActiveMode),K=N(s=>s.setActiveView),[C,$]=d.useState(""),[c,h]=d.useState(null),[D,z]=d.useState(""),[M,W]=d.useState(null),[I,O]=d.useState(""),R=d.useMemo(()=>{if(!r)return[];const s=Object.values(r.elements),l=r.elements,t=(...a)=>{const k=new Set(a.map(x=>x.toLowerCase()));return r.relationships.filter(x=>k.has(x.type.toLowerCase()))},u=(a,k)=>{var x;return typeof a=="string"&&((x=a.split("::").at(-1))==null?void 0:x.trim())===k},p=s.filter(a=>a.kind.endsWith("UseCase")),j=a=>!C||a.name.toLowerCase().includes(C.toLowerCase())||a.kind.toLowerCase().includes(C.toLowerCase());return p.map(a=>{const k=t("Supports","supportsUseCase").filter(n=>n.targetId===a.id).map(n=>l[n.sourceId]).filter(n=>!!n&&n.kind==="OperationalWorkflow"),x=s.filter(n=>n.kind.endsWith("Scenario")).filter(n=>u(n.attributes.parentUseCase,a.id)||t("Realizes","scenarioRealizesUseCase").some(F=>F.sourceId===n.id&&F.targetId===a.id)),w=x.map(n=>s.find(F=>u(n.attributes.parentWorkflow,F.id))).filter(n=>!!n),A=[...new Map([...k,...w].map(n=>[n.id,n])).values()],f=x.map(n=>{const F=t("Composes","scenarioComprisesActivity").filter(o=>o.sourceId===n.id).map(o=>l[o.targetId]).filter(o=>!!o),_=t("Realizes","functionalRealizesOperative").filter(o=>o.targetId===n.id).map(o=>l[o.sourceId]).filter(o=>!!o&&o.layer==="functional"),se=_.flatMap(o=>t("Realizes","uIRealizesFunctional").filter(E=>E.targetId===o.id).map(E=>l[E.sourceId]).filter(E=>!!E&&E.layer==="usability")),B=new Set([n.id,...F.map(o=>o.id)]);let T=!0;for(;T;){T=!1;for(const o of s)o.parentAction&&B.has(o.parentAction)&&!B.has(o.id)&&(B.add(o.id),T=!0)}const te=(r.diagrams??[]).filter(o=>{var E;return((E=o.elementIds)==null?void 0:E.some(le=>B.has(le)))||o.name.toLowerCase().includes(n.name.toLowerCase())});return{scenario:n,activities:F,functionalScenarios:_,uiScenarios:se,views:te}}),v=A.map(n=>({workflow:n,scenarios:f.filter(({scenario:F})=>u(F.attributes.parentWorkflow,n.id))}));return{useCase:a,workflows:v}}).filter(a=>j(a.useCase)||a.workflows.some(({workflow:k,scenarios:x})=>j(k)||x.some(({scenario:w,activities:A,functionalScenarios:f,uiScenarios:v})=>j(w)||A.some(j)||f.some(j)||v.some(j))))},[r,C]),i=g&&r?r.elements[g]:null,U=d.useMemo(()=>ne(r,g||""),[r,g]),y=d.useMemo(()=>c||(i?q(i.doc||""):[]),[i,c]),P=d.useCallback(()=>{i&&h(q(i.doc||""))},[i]),Y=d.useCallback(()=>{if(!i||!c)return;const s=ce(c);oe({...i,doc:s}),h(null)},[i,c]),G=d.useCallback(()=>{if(!D.trim())return;const s=[...c||y,{index:y.length,text:D.trim()}];h(s),z("")},[D,c,y]),H=d.useCallback(s=>{const l=(c||y).filter((t,u)=>u!==s);h(l)},[c,y]),V=d.useCallback((s,l)=>{const t=[...c||y],u=s+l;u<0||u>=t.length||([t[s],t[u]]=[t[u],t[s]],h(t))},[c,y]),J=d.useCallback((s,l)=>{const t=[...c||y];t[s]={...t[s],text:l},h(t)},[c,y]),Q=d.useMemo(()=>{if(!r||!I)return[];const s=I.toLowerCase();return Object.values(r.elements).filter(l=>l.id!==g&&l.name.toLowerCase().includes(s)).slice(0,10)},[r,I,g]),[X,Z]=d.useState(new Set),ee=s=>{Z(l=>{const t=new Set(l);return t.has(s)?t.delete(s):t.add(s),t})};return e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsxs("div",{className:"w-72 flex flex-col overflow-hidden",style:{background:"#FFFFFF",borderRight:"1px solid #E5E5E0"},children:[e.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid #E5E5E0"},children:[e.jsx("div",{style:{color:"#1B3A4B",fontSize:"12px",fontWeight:700,marginBottom:7},children:"Use Case Browser"}),e.jsx("input",{type:"text",placeholder:"Search "+R.length+" use cases...",value:C,onChange:s=>$(s.target.value),className:"w-full px-3 py-2 text-sm rounded-lg focus:outline-none",style:{background:"#F7F7F5",border:"1px solid #E5E5E0",color:"#1a1a1a"}})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto text-xs py-1",children:[R.map(({useCase:s,workflows:l})=>{const t="use-case:"+s.id,u=X.has(t);return e.jsxs("div",{className:"mb-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 cursor-pointer",style:{borderRadius:"6px",margin:"0 4px"},onMouseEnter:p=>p.currentTarget.style.background="#F0F0ED",onMouseLeave:p=>p.currentTarget.style.background="transparent",onClick:()=>{m(s.id),h(null),ee(t)},children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded flex-shrink-0",style:{backgroundColor:L.functional,borderRadius:"3px"}}),e.jsx("span",{className:"font-medium flex-1",style:{color:"#374151"},children:s.name}),e.jsx("span",{style:{color:"#9CA3AF"},children:"Use case"}),e.jsx("span",{style:{color:"#D1D5DB"},children:u?"▸":"▾"})]}),!u&&e.jsx("div",{className:"ml-5 border-l pl-2",style:{borderColor:"#E5E5E0"},children:l.map(({workflow:p,scenarios:j})=>e.jsxs("div",{className:"mb-1",children:[e.jsx("button",{onClick:()=>{m(p.id),h(null)},className:"block w-full px-2 py-1 text-left truncate rounded",style:{color:"#374151",fontWeight:600},children:p.name}),e.jsxs("div",{className:"ml-3 border-l pl-2",style:{borderColor:"#D8E2E9"},children:[j.map(({scenario:a,activities:k,functionalScenarios:x,uiScenarios:w,views:A})=>e.jsxs("div",{className:"mb-1",children:[e.jsx("button",{onClick:()=>{m(a.id),h(null)},className:"block w-full px-2 py-1 text-left truncate rounded",style:{color:"#1B3A4B",fontWeight:500},children:a.name}),e.jsxs("div",{className:"ml-3 border-l pl-2",style:{borderColor:"#E5E5E0"},children:[[["Activity diagram",k],["Function flow",x],["Interaction sequence",w]].filter(([,f])=>f.length>0).map(([f,v])=>e.jsxs("div",{children:[e.jsx("div",{className:"pt-1",style:{color:"#6B7280",fontSize:"10px"},children:f}),v.map(n=>e.jsx("button",{onClick:()=>{m(n.id),h(null)},className:"block w-full px-1 py-0.5 text-left truncate rounded",style:{color:"#4B5563"},children:n.name},n.id))]},f)),ae(A).map(f=>e.jsxs("div",{children:[e.jsx("div",{className:"pt-1",style:{color:"#6B7280",fontSize:"10px"},children:f.label}),f.items.map(v=>e.jsx("button",{onClick:()=>{S("diagram"),K({type:"diagram",diagramId:v.id})},className:"block w-full px-1 py-0.5 text-left truncate rounded",style:{color:"#2563EB"},children:v.name},v.id))]},f.label))]})]},a.id)),j.length===0&&e.jsx("div",{className:"px-2 py-1",style:{color:"#9CA3AF",fontSize:"10px"},children:"No scenarios"})]})]},p.id))})]},s.id)}),R.length===0&&e.jsx("div",{className:"px-4 py-8 text-center",style:{color:"#9CA3AF"},children:"No use-case scenario chains found."})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",style:{background:"#F7F7F5"},children:[!i&&e.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"#9CA3AF"},children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"8px",opacity:.5},children:"▶"}),e.jsx("div",{className:"text-sm",children:"Select a scenario to edit steps and link elements"})]})}),i&&e.jsxs("div",{className:"max-w-2xl",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("h2",{className:"text-lg font-semibold",style:{color:"#1a1a1a"},children:i.name}),e.jsx("span",{className:"px-2 py-0.5 text-xs rounded-md font-medium",style:{background:"#E67E2218",color:"#E67E22"},children:i.kind})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"#6B7280"},children:"Steps"}),!c&&e.jsx("button",{onClick:P,className:"px-2 py-0.5 text-xs rounded",style:{background:"#2DD4A815",color:"#1B3A4B",border:"1px solid #2DD4A840"},children:"Edit"}),c&&e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:Y,className:"px-2 py-0.5 text-xs rounded font-medium",style:{background:"#2DD4A8",color:"#FFFFFF"},children:"Save"}),e.jsx("button",{onClick:()=>h(null),className:"px-2 py-0.5 text-xs rounded",style:{background:"#F3F4F6",color:"#6B7280"},children:"Cancel"})]})]}),e.jsx("div",{className:"space-y-1",children:y.map((s,l)=>e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},children:[e.jsx("span",{className:"flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium",style:{background:"#2DD4A815",color:"#1B3A4B"},children:l+1}),c?e.jsx("input",{type:"text",value:s.text,onChange:t=>J(l,t.target.value),className:"flex-1 text-sm px-2 py-1 rounded focus:outline-none",style:{border:"1px solid #E5E5E0",color:"#374151"}}):e.jsx("span",{className:"flex-1 text-sm",style:{color:"#374151"},children:s.text}),c&&e.jsxs("div",{className:"flex gap-0.5",children:[e.jsx("button",{onClick:()=>V(l,-1),className:"px-1 text-xs",style:{color:"#9CA3AF"},title:"Move up",children:"▲"}),e.jsx("button",{onClick:()=>V(l,1),className:"px-1 text-xs",style:{color:"#9CA3AF"},title:"Move down",children:"▼"}),e.jsx("button",{onClick:()=>H(l),className:"px-1 text-xs",style:{color:"#E74C3C"},title:"Remove",children:"✕"})]})]},l))}),c&&e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("input",{type:"text",value:D,onChange:s=>z(s.target.value),onKeyDown:s=>s.key==="Enter"&&G(),placeholder:"Add a step...",className:"flex-1 text-sm px-3 py-2 rounded-lg focus:outline-none",style:{background:"#FFFFFF",border:"1px solid #E5E5E0",color:"#374151"}}),e.jsx("button",{onClick:G,className:"px-3 py-2 text-xs rounded-lg font-medium",style:{background:"#2DD4A815",color:"#1B3A4B",border:"1px solid #2DD4A840"},children:"+ Add"})]}),y.length===0&&!c&&e.jsx("div",{className:"text-xs p-3 rounded-lg",style:{background:"#F3F4F6",color:"#9CA3AF"},children:"No steps defined. Click Edit to add scenario steps."})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsxs("h3",{className:"text-xs font-semibold uppercase tracking-wider",style:{color:"#6B7280"},children:["Linked Elements (",U.length,")"]}),e.jsx("button",{onClick:()=>W(M===null?0:null),className:"px-2 py-0.5 text-xs rounded",style:{background:"#4A90D915",color:"#4A90D9",border:"1px solid #4A90D940"},children:M!==null?"Done":"+ Link"})]}),M!==null&&e.jsxs("div",{className:"mb-2 p-2 rounded-lg",style:{background:"#FFFFFF",border:"1px solid #4A90D940"},children:[e.jsx("input",{type:"text",value:I,onChange:s=>O(s.target.value),placeholder:"Search elements to link...",className:"w-full text-sm px-2 py-1 rounded focus:outline-none mb-1",style:{border:"1px solid #E5E5E0",color:"#374151"}}),Q.map(s=>e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 text-xs rounded cursor-pointer",onMouseEnter:l=>l.currentTarget.style.background="#F0F0ED",onMouseLeave:l=>l.currentTarget.style.background="transparent",onClick:()=>{b({type:"traceTo",sourceId:i.id,targetId:s.id,direction:"outgoing",selectedElementId:i.id}),O(""),W(null)},children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:L[s.layer]||"#95A5A6"}}),e.jsx("span",{style:{color:"#374151"},children:s.name}),e.jsx("span",{style:{color:"#9CA3AF"},children:s.kind})]},s.id))]}),e.jsx("div",{className:"space-y-1",children:U.map(s=>{const l=s.sourceId===i.id?s.targetId:s.sourceId,t=r.elements[l],u=s.sourceId===i.id?"→":"←";return e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs rounded-lg cursor-pointer",style:{background:"#FFFFFF",border:"1px solid #E5E5E0"},onMouseEnter:p=>p.currentTarget.style.background="#F0F0ED",onMouseLeave:p=>p.currentTarget.style.background="#FFFFFF",onClick:()=>m(l),children:[e.jsx("span",{style:{color:"#9CA3AF"},children:u}),e.jsx("span",{className:"font-medium",style:{color:"#2563EB"},children:s.type}),e.jsx("span",{style:{color:"#374151"},children:(t==null?void 0:t.name)||l}),t&&e.jsx("span",{className:"ml-auto px-1.5 py-0.5 rounded text-xs",style:{background:(L[t.layer]||"#95A5A6")+"18",color:L[t.layer]||"#95A5A6"},children:t.kind})]},s.id)})})]}),e.jsx("div",{className:"text-xs",style:{color:"#D1D5DB"},children:i.file})]})]})]})}export{me as ScenarioEditor};