@sentropic/design-system-svelte 0.35.1 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/LICENSE.THIRD-PARTY.md +74 -1
  2. package/dist/Calendar.svelte +28 -1
  3. package/dist/Calendar.svelte.d.ts +7 -0
  4. package/dist/Calendar.svelte.d.ts.map +1 -1
  5. package/dist/ContentSwitcher.svelte +6 -1
  6. package/dist/DiagramCard.svelte +282 -0
  7. package/dist/DiagramCard.svelte.d.ts +44 -0
  8. package/dist/DiagramCard.svelte.d.ts.map +1 -0
  9. package/dist/DiagramCardHeader.svelte +173 -0
  10. package/dist/DiagramCardHeader.svelte.d.ts +37 -0
  11. package/dist/DiagramCardHeader.svelte.d.ts.map +1 -0
  12. package/dist/DiagramZone.svelte +378 -0
  13. package/dist/DiagramZone.svelte.d.ts +45 -0
  14. package/dist/DiagramZone.svelte.d.ts.map +1 -0
  15. package/dist/DiagramZoneHeader.svelte +97 -0
  16. package/dist/DiagramZoneHeader.svelte.d.ts +40 -0
  17. package/dist/DiagramZoneHeader.svelte.d.ts.map +1 -0
  18. package/dist/MenuPopover.svelte +101 -12
  19. package/dist/MenuPopover.svelte.d.ts.map +1 -1
  20. package/dist/Pagination.svelte +5 -0
  21. package/dist/RadioGroup.svelte +4 -1
  22. package/dist/TimeRangePicker.svelte +19 -1
  23. package/dist/TimeRangePicker.svelte.d.ts.map +1 -1
  24. package/dist/diagram-icons/DiagramIcon.svelte +65 -0
  25. package/dist/diagram-icons/DiagramIcon.svelte.d.ts +11 -0
  26. package/dist/diagram-icons/DiagramIcon.svelte.d.ts.map +1 -0
  27. package/dist/diagram-icons/PROVENANCE.md +72 -0
  28. package/dist/diagram-icons/index.d.ts +6 -0
  29. package/dist/diagram-icons/index.d.ts.map +1 -0
  30. package/dist/diagram-icons/index.js +4 -0
  31. package/dist/diagram-icons/registry.d.ts +52 -0
  32. package/dist/diagram-icons/registry.d.ts.map +1 -0
  33. package/dist/diagram-icons/registry.js +79 -0
  34. package/dist/diagram-render/index.d.ts +17 -0
  35. package/dist/diagram-render/index.d.ts.map +1 -0
  36. package/dist/diagram-render/index.js +11 -0
  37. package/dist/diagram-render/renderCardSvg.d.ts +83 -0
  38. package/dist/diagram-render/renderCardSvg.d.ts.map +1 -0
  39. package/dist/diagram-render/renderCardSvg.js +149 -0
  40. package/dist/diagram-render/renderZoneSvg.d.ts +88 -0
  41. package/dist/diagram-render/renderZoneSvg.d.ts.map +1 -0
  42. package/dist/diagram-render/renderZoneSvg.js +184 -0
  43. package/dist/diagramCardModel.d.ts +582 -0
  44. package/dist/diagramCardModel.d.ts.map +1 -0
  45. package/dist/diagramCardModel.js +1133 -0
  46. package/dist/index.d.ts +5 -0
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +2 -0
  49. package/dist/presence-badge/LockPresenceBadge.svelte +490 -0
  50. package/dist/presence-badge/LockPresenceBadge.svelte.d.ts +18 -0
  51. package/dist/presence-badge/LockPresenceBadge.svelte.d.ts.map +1 -0
  52. package/dist/presence-badge/index.d.ts +6 -0
  53. package/dist/presence-badge/index.d.ts.map +1 -0
  54. package/dist/presence-badge/index.js +3 -0
  55. package/dist/rich-text-editor/ComposerEditor.svelte +485 -0
  56. package/dist/rich-text-editor/ComposerEditor.svelte.d.ts +16 -0
  57. package/dist/rich-text-editor/ComposerEditor.svelte.d.ts.map +1 -0
  58. package/dist/rich-text-editor/RichTextEditor.svelte +557 -0
  59. package/dist/rich-text-editor/RichTextEditor.svelte.d.ts +45 -0
  60. package/dist/rich-text-editor/RichTextEditor.svelte.d.ts.map +1 -0
  61. package/dist/rich-text-editor/RichTextEditorFixture.svelte.d.ts +8 -0
  62. package/dist/rich-text-editor/RichTextEditorFixture.svelte.d.ts.map +1 -0
  63. package/dist/rich-text-editor/RichTextEditorNestedFixture.svelte.d.ts +13 -0
  64. package/dist/rich-text-editor/RichTextEditorNestedFixture.svelte.d.ts.map +1 -0
  65. package/dist/rich-text-editor/index.d.ts +10 -0
  66. package/dist/rich-text-editor/index.d.ts.map +1 -0
  67. package/dist/rich-text-editor/index.js +4 -0
  68. package/dist/rich-text-editor/rich-text-editor.css +115 -0
  69. package/package.json +54 -7
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Diagram pictogram registry — the blue duotone family (DC-1).
3
+ *
4
+ * Spec: spec/SPEC_EVOL_DS_DIAGRAM_CARDS.md §9. One family, drawn identically
5
+ * in cards and zones at the 70 px icon box: `viewBox="0 0 64 64"`, canonical
6
+ * base diamond `M8 53L32 44L56 53L32 62Z`, three layers (base / face / line),
7
+ * face stroke 1.5, line stroke 2.5. Layer colours resolve through the
8
+ * `diagramIcon` component tokens; no per-glyph colour, no raw hex here.
9
+ *
10
+ * Framework-neutral data: no Svelte import, so staged framework adapters
11
+ * (§12.6) reuse these path records without re-drawing a glyph. Provenance
12
+ * per glyph lives in PROVENANCE.md next to this file.
13
+ */
14
+ /** Canonical base diamond — the validated #711 render (§9.1). */
15
+ export const DIAGRAM_GLYPH_BASE = "M8 53L32 44L56 53L32 62Z";
16
+ /** Glyph viewBox in force for the whole family. */
17
+ export const DIAGRAM_GLYPH_VIEWBOX = "0 0 64 64";
18
+ function glyph(face, line, extra) {
19
+ return {
20
+ base: DIAGRAM_GLYPH_BASE,
21
+ face,
22
+ ...(line === undefined || line === "" ? {} : { line }),
23
+ ...extra,
24
+ };
25
+ }
26
+ /**
27
+ * The shipped set (§9.2): the radar-immobilier 19 redrawn on the canonical
28
+ * base plus the sentropic #711 9 (verbatim geometry). 28 names, no
29
+ * collisions across the two sources — no aliasing was needed.
30
+ */
31
+ export const DIAGRAM_GLYPHS = {
32
+ // --- radar-immobilier fa8133c2 (19): interiors preserved verbatim, base
33
+ // replaced by the canonical diamond (§9.1, DIF-12) ---
34
+ s3: glyph("M12 18Q32 6 52 18L47 47Q32 58 17 47Z", "M12 18Q32 30 52 18M18 29Q32 38 46 29", {
35
+ text: "S3",
36
+ }),
37
+ postgres: glyph("M12 16Q32 4 52 16V47Q32 59 12 47Z", "M12 16Q32 28 52 16M12 28Q32 40 52 28M12 40Q32 52 52 40"),
38
+ cluster: glyph("M32 7L54 20V44L32 57L10 44V20Z", "M32 19V32M21 26L32 32L43 26M32 32V46M32 32L20 40M32 32L44 40"),
39
+ web: glyph("M8 12H56V49H8Z", "M8 23H56M15 18H17M22 18H24M16 31H30V42H16ZM37 32H48M37 40H48"),
40
+ api: glyph("M8 12H56V50H8Z", "M22 24L15 31L22 38M42 24L49 31L42 38M35 22L29 40"),
41
+ cronjob: glyph("M32 8A24 24 0 1 1 31.9 8Z", "M32 16V32L43 39M17 16L12 21M47 16L52 21"),
42
+ identity: glyph("M32 6L52 14V31Q50 48 32 58Q14 48 12 31V14Z", "M26 29V24A6 6 0 0 1 38 24V29M23 29H41V42H23ZM32 34V37"),
43
+ workstation: glyph("M8 10H56V42H8Z", "M13 15H51V37H13ZM24 43V51M40 43V51M17 53H47M18 23L24 27L18 31M30 31H39"),
44
+ document: glyph("M15 6H37L50 19V57H15Z", "M37 6V19H50M23 28H42M23 36H42M23 44H35"),
45
+ map: glyph("M7 16L24 9L41 16L57 9V49L41 56L24 49L7 56Z", "M24 9V49M41 16V56M13 29L24 25L41 35L51 31"),
46
+ join: glyph("M8 12H24V27H8ZM40 12H56V27H40ZM24 42H40V57H24Z", "M16 27V34H48V27M32 34V42", {
47
+ darkLine: true,
48
+ }),
49
+ graph: glyph("M7 10H23V26H7ZM41 10H57V26H41ZM24 42H40V58H24Z", "M23 18H41M15 26L27 42M49 26L37 42", { darkLine: true }),
50
+ check: glyph("M14 8H50V57H14Z", "M23 8V15H41V8M23 35L30 42L43 27"),
51
+ release: glyph("M12 31L32 20L52 31V50L32 61L12 50Z", "M12 31L32 42L52 31M32 42V61M32 5V25M24 13L32 5L40 13"),
52
+ user: glyph("M22 17A10 10 0 1 1 42 17A10 10 0 1 1 22 17ZM12 54V44Q12 31 25 31H39Q52 31 52 44V54Z", "M20 44V54M44 44V54"),
53
+ url: glyph("M32 7A25 25 0 1 1 31.9 7Z", "M7 32H57M12 19H52M12 45H52M32 7C16 19 16 45 32 57C48 45 48 19 32 7Z"),
54
+ llm: glyph("M17 17H47V47H17Z", "M25 25H39V39H25ZM25 8V17M39 8V17M25 47V56M39 47V56M8 25H17M8 39H17M47 25H56M47 39H56"),
55
+ network: glyph("M24 7H40V23H24ZM5 42H21V58H5ZM43 42H59V58H43Z", "M32 23V33M13 42V33H51V42", { darkLine: true }),
56
+ unknown: glyph("M32 6L59 55H5Z", "M32 24V38M32 45V46"),
57
+ // --- sentropic #711 via the hrpolnav kit (9): verbatim geometry on the
58
+ // canonical base, 64-unit viewBox ---
59
+ people: glyph("M22 10a8 8 0 1 1 0 16a8 8 0 1 1 0-16Z M42 14a7 7 0 1 1 0 14a7 7 0 1 1 0-14Z M8 46c0-9 6-15 14-15s14 6 14 15Z M34 46c0-8 4-13 9-13s12 5 12 13Z"),
60
+ window: glyph("M9 11h46v36H9Z", "M9 19h46 M16 28h32 M16 35h22"),
61
+ server: glyph("M14 8h36v14H14Z M14 25h36v14H14Z", "M20 15h10 M20 32h10 M42 15h.1 M42 32h.1"),
62
+ brain: glyph("M32 12c-4-7-15-5-16 3c-8 1-11 11-6 17c-5 8 0 17 8 17c5 5 12 3 14-2c2 5 9 7 14 2c8 0 13-9 8-17c5-6 2-16-6-17c-1-8-12-10-16-3Z", "M32 12v35 M16 15c0 6 4 9 9 9 M10 32c4-4 9-3 12 1 M18 49c-2-5 0-10 5-12 M48 15c0-6-4-9-9-9 M54 32c-4-4-9-3-12 1 M46 49c2-5 0-10-5-12"),
63
+ robot: glyph("M14 16h36v31H14Z M8 25h6v13H8Z M50 25h6v13h-6Z M29 6h6v5h-6Z", "M32 11v5 M23 27h.1 M41 27h.1 M23 38h18"),
64
+ link: glyph("M10 12h16v14H10Z M38 30h16v14H38Z", "M26 19h12v11", { darkLine: true }),
65
+ db: glyph("M14 13c0-4 8-7 18-7s18 3 18 7v29c0 4-8 7-18 7s-18-3-18-7Z", "M14 13c0 4 8 7 18 7s18-3 18-7 M14 27c0 4 8 7 18 7s18-3 18-7"),
66
+ shield: glyph("M32 7l20 7v13c0 12-8 20-20 25C20 47 12 39 12 27V14Z", "M23 29l6 6 12-13"),
67
+ cloud: glyph("M18 44a10 10 0 0 1 0-20a14 14 0 0 1 27-4a11 11 0 0 1 3 24Z"),
68
+ };
69
+ /** Shipped glyph names (§9.2: 19 + 9 = 28). */
70
+ export const DIAGRAM_GLYPH_NAMES = Object.keys(DIAGRAM_GLYPHS);
71
+ /**
72
+ * Resolve a glyph name to its path record. Returns `undefined` for an
73
+ * unmapped name — the callers raise `card-icon-unknown` /
74
+ * `zone-icon-unknown` and draw nothing (DIF-14: no `server` fallback, no
75
+ * silent substitution).
76
+ */
77
+ export function getDiagramGlyph(name) {
78
+ return DIAGRAM_GLYPHS[name];
79
+ }
@@ -0,0 +1,17 @@
1
+ import { renderCardSvg, renderCardSvgFromPresentation, projectCardProps, type CardSvgResult } from "./renderCardSvg.js";
2
+ import { renderZoneSvg, renderZoneSvgFromPresentation, projectZoneProps, zoneContent, type ZoneSvgResult } from "./renderZoneSvg.js";
3
+ import { cardLineMeasurer, type CardLineLayout, type CardMeasureRequest } from "../diagramCardModel.js";
4
+ import type { CardDiagnostic, CardLayout, CardLineMeasure, CardPresentationInput, DiagramCardProps, DiagramGlyphPaths } from "./renderCardSvg.js";
5
+ import type { DiagramZoneProps, ZoneChildSpec, ZoneDiagnostic, ZoneLayout, ZonePresentationInput } from "../diagramCardModel.js";
6
+ export { renderCardSvg, renderCardSvgFromPresentation, projectCardProps };
7
+ export { renderZoneSvg, renderZoneSvgFromPresentation, projectZoneProps, zoneContent };
8
+ /**
9
+ * The canvas `LineMeasurer` bridge (diagram-canvas `MeasureRequest` shape):
10
+ * pass `cardLineMeasurer()` straight as the injected measurer. Exported
11
+ * through this subpath so hosts never reach into the barrel.
12
+ */
13
+ export { cardLineMeasurer };
14
+ export type { CardSvgResult, ZoneSvgResult };
15
+ export type { CardDiagnostic, CardLayout, CardLineLayout, CardLineMeasure, CardMeasureRequest, CardPresentationInput, DiagramCardProps, DiagramGlyphPaths, };
16
+ export type { DiagramZoneProps, ZoneChildSpec, ZoneDiagnostic, ZoneLayout, ZonePresentationInput, };
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/diagram-render/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,6BAA6B,EAC7B,gBAAgB,EAChB,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,aAAa,EACb,6BAA6B,EAC7B,gBAAgB,EAChB,WAAW,EACX,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACxB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,UAAU,EACV,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,gBAAgB,EAAE,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,gBAAgB,EAAE,WAAW,EAAE,CAAC;AACvF;;;;GAIG;AACH,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;AAC7C,YAAY,EACV,cAAc,EACd,UAAU,EACV,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,GAClB,CAAC;AACF,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,UAAU,EACV,qBAAqB,GACtB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { renderCardSvg, renderCardSvgFromPresentation, projectCardProps, } from "./renderCardSvg.js";
2
+ import { renderZoneSvg, renderZoneSvgFromPresentation, projectZoneProps, zoneContent, } from "./renderZoneSvg.js";
3
+ import { cardLineMeasurer, } from "../diagramCardModel.js";
4
+ export { renderCardSvg, renderCardSvgFromPresentation, projectCardProps };
5
+ export { renderZoneSvg, renderZoneSvgFromPresentation, projectZoneProps, zoneContent };
6
+ /**
7
+ * The canvas `LineMeasurer` bridge (diagram-canvas `MeasureRequest` shape):
8
+ * pass `cardLineMeasurer()` straight as the injected measurer. Exported
9
+ * through this subpath so hosts never reach into the barrel.
10
+ */
11
+ export { cardLineMeasurer };
@@ -0,0 +1,83 @@
1
+ /**
2
+ * `renderCardSvg` — pure atomic-card SVG renderer (DC-1).
3
+ *
4
+ * Plain TypeScript, no Svelte import. Ships on the
5
+ * `@sentropic/design-system-svelte/diagram-render` subpath. Consumes the
6
+ * same geometry source as the Svelte `DiagramCard`: the `diagramCard`
7
+ * component tokens plus the `diagram-canvas` `measure.ts` constants, via
8
+ * `../diagramCardModel.js` (shared projection + line layout).
9
+ *
10
+ * Exactly one rule element, drawn non-scaling (§5.4, DIF-07, DH-04); fixed
11
+ * 460 × 200 box; square corners; footer pinned at 9.25; no shortening —
12
+ * over-long slots are reported through the returned diagnostics (DC-D4) and
13
+ * the result is refused (no `svg`): overflow = refusal, never a truncation.
14
+ */
15
+ import { layoutCard, projectCardProps, type CardDiagnostic, type CardLayout, type CardLineMeasure, type CardPresentationInput, type DiagramCardProps, type DiagramGlyphPaths } from "../diagramCardModel.js";
16
+ export type { CardDiagnostic, CardLayout, CardLineMeasure, CardPresentationInput, DiagramCardProps, DiagramGlyphPaths, };
17
+ export { projectCardProps };
18
+ /** Icon pictogram group at (x, y) in the caller's coordinate space. */
19
+ export declare function iconGroupFor(name: string, glyph: DiagramGlyphPaths | undefined, x: number, y: number, size: number): string;
20
+ /**
21
+ * Card-local content (border, accent bar, icon, slots, rule, footer,
22
+ * toggle) with no `<svg>` root — shared by `renderCardSvg` (wrapped in a
23
+ * standalone root) and `renderZoneSvg` (wrapped in a translated `<g>` for
24
+ * the collapsed zone, §6.2: the zone IS the card).
25
+ */
26
+ export declare function renderCardContent(props: DiagramCardProps, measure?: CardLineMeasure): {
27
+ readonly content: string;
28
+ readonly layout: ReturnType<typeof layoutCard>;
29
+ };
30
+ /** The +/- toggle glyph in its slot box (card-local coordinates). */
31
+ export declare function toggleGlyph(toggle: {
32
+ collapsed: boolean;
33
+ label: string;
34
+ }, box: {
35
+ x: number;
36
+ y: number;
37
+ size: number;
38
+ }): string;
39
+ /**
40
+ * The card render result. Overflow = refusal (owner criterion): when the
41
+ * layout raises `card-overflow` — a too-wide line, a line-count overflow, or
42
+ * a header+body height that does not fit above the pinned rule — the result
43
+ * is `{ kind: "refused" }` with NO `svg`: no normal card is emitted until the
44
+ * content fits. The diagnostics carry the original slot text so the host
45
+ * knows what to shorten. The Svelte `DiagramCard` renders the matching
46
+ * refusal state (`data-card-refused`) on the same predicate — one contract,
47
+ * both renderers.
48
+ */
49
+ export type CardSvgResult = {
50
+ readonly kind: "rendered";
51
+ readonly svg: string;
52
+ readonly diagnostics: readonly CardDiagnostic[];
53
+ readonly layout: CardLayout;
54
+ } | {
55
+ readonly kind: "refused";
56
+ readonly diagnostics: readonly CardDiagnostic[];
57
+ readonly layout: CardLayout;
58
+ };
59
+ /**
60
+ * Render one atomic card as a standalone SVG string. `measure` defaults to
61
+ * the deterministic greedy wrapper; production hosts pass their measured
62
+ * `LineMeasurer` adapter. Returns a refused result (no `svg`) when the
63
+ * content overflows its frozen allocation.
64
+ */
65
+ export declare function renderCardSvg(props: DiagramCardProps, measure?: CardLineMeasure): CardSvgResult;
66
+ /**
67
+ * Convenience: project an `EntityPresentation` then render it. Returns
68
+ * `{ kind: "label" }` when the view carries no card presentation for the
69
+ * entity — the host renders a simple label node and no card — and
70
+ * `{ kind: "card", result }` otherwise, where `result` is the refused or
71
+ * rendered `CardSvgResult`.
72
+ */
73
+ export declare function renderCardSvgFromPresentation(presentation: CardPresentationInput | undefined, opts: {
74
+ entityId: string;
75
+ toggle?: DiagramCardProps["toggle"];
76
+ measure?: CardLineMeasure;
77
+ }): {
78
+ kind: "card";
79
+ result: CardSvgResult;
80
+ } | {
81
+ kind: "label";
82
+ };
83
+ //# sourceMappingURL=renderCardSvg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderCardSvg.d.ts","sourceRoot":"","sources":["../../src/lib/diagram-render/renderCardSvg.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAIL,UAAU,EACV,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAMhC,YAAY,EACV,cAAc,EACd,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,GAClB,CAAC;AACF,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAY5B,uEAAuE;AACvE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,iBAAiB,GAAG,SAAS,EACpC,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,MAAM,GACX,MAAM,CAgBR;AAgBD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,gBAAgB,EACvB,OAAO,GAAE,eAAoC,GAC5C;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAA;CAAE,CAiF9E;AAED,qEAAqE;AACrE,wBAAgB,WAAW,CACzB,MAAM,EAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAC7C,GAAG,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC1C,MAAM,CAOR;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GACrB;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAC;IAChD,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAC;IAChD,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B,CAAC;AAEN;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,gBAAgB,EACvB,OAAO,GAAE,eAAoC,GAC5C,aAAa,CAyBf;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,qBAAqB,GAAG,SAAS,EAC/C,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,eAAe,CAAA;CAAE,GACzF;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAQ7D"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * `renderCardSvg` — pure atomic-card SVG renderer (DC-1).
3
+ *
4
+ * Plain TypeScript, no Svelte import. Ships on the
5
+ * `@sentropic/design-system-svelte/diagram-render` subpath. Consumes the
6
+ * same geometry source as the Svelte `DiagramCard`: the `diagramCard`
7
+ * component tokens plus the `diagram-canvas` `measure.ts` constants, via
8
+ * `../diagramCardModel.js` (shared projection + line layout).
9
+ *
10
+ * Exactly one rule element, drawn non-scaling (§5.4, DIF-07, DH-04); fixed
11
+ * 460 × 200 box; square corners; footer pinned at 9.25; no shortening —
12
+ * over-long slots are reported through the returned diagnostics (DC-D4) and
13
+ * the result is refused (no `svg`): overflow = refusal, never a truncation.
14
+ */
15
+ import { CARD_GEOMETRY, defaultCardMeasure, firstOverflowDiagnostic, layoutCard, projectCardProps, } from "../diagramCardModel.js";
16
+ import { DIAGRAM_GLYPH_BASE, getDiagramGlyph, } from "../diagram-icons/registry.js";
17
+ export { projectCardProps };
18
+ function escapeXml(value) {
19
+ return String(value)
20
+ .replaceAll("&", "&amp;")
21
+ .replaceAll("<", "&lt;")
22
+ .replaceAll(">", "&gt;")
23
+ .replaceAll('"', "&quot;");
24
+ }
25
+ const FONT_STACK = "var(--st-font-sans, system-ui, sans-serif)";
26
+ /** Icon pictogram group at (x, y) in the caller's coordinate space. */
27
+ export function iconGroupFor(name, glyph, x, y, size) {
28
+ if (glyph === undefined)
29
+ return "";
30
+ const scale = size / 64;
31
+ const lineStroke = glyph.darkLine === true
32
+ ? "var(--st-component-diagramIcon-lineDarkStroke, var(--st-semantic-feedback-info))"
33
+ : "var(--st-component-diagramIcon-lineStroke, var(--st-semantic-surface-raised))";
34
+ return `<g class="st-diagramCard-icon" data-diagram-icon="${escapeXml(name)}" transform="translate(${x} ${y}) scale(${scale})" aria-hidden="true">` +
35
+ `<path d="${DIAGRAM_GLYPH_BASE}" fill="var(--st-component-diagramIcon-baseFill, color-mix(in srgb, var(--st-semantic-feedback-info) 18%, var(--st-semantic-surface-raised)))"/>` +
36
+ `<path d="${escapeXml(glyph.face)}" fill="var(--st-component-diagramIcon-faceFill, color-mix(in srgb, var(--st-semantic-feedback-info) 75%, var(--st-semantic-surface-raised)))" stroke="var(--st-component-diagramIcon-faceStroke, var(--st-semantic-feedback-info))" stroke-width="1.5" stroke-linejoin="round"/>` +
37
+ (glyph.line === undefined
38
+ ? ""
39
+ : `<path d="${escapeXml(glyph.line)}" fill="none" stroke="${lineStroke}" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/>`) +
40
+ (glyph.text === undefined
41
+ ? ""
42
+ : `<text x="32" y="47" text-anchor="middle" fill="var(--st-component-diagramIcon-lineStroke, var(--st-semantic-surface-raised))" font-size="13" font-weight="750">${escapeXml(glyph.text)}</text>`) +
43
+ `</g>`;
44
+ }
45
+ function textLines(lines, className, fill, extra) {
46
+ return lines
47
+ .map((line) => `<text class="${className}" x="${line.x}" y="${line.baseline}" text-anchor="${line.anchor === "middle" ? "middle" : "start"}" font-size="${line.size}" font-weight="${line.weight}" fill="${fill}"${extra}>${escapeXml(line.text)}</text>`)
48
+ .join("");
49
+ }
50
+ /**
51
+ * Card-local content (border, accent bar, icon, slots, rule, footer,
52
+ * toggle) with no `<svg>` root — shared by `renderCardSvg` (wrapped in a
53
+ * standalone root) and `renderZoneSvg` (wrapped in a translated `<g>` for
54
+ * the collapsed zone, §6.2: the zone IS the card).
55
+ */
56
+ export function renderCardContent(props, measure = defaultCardMeasure) {
57
+ const g = CARD_GEOMETRY;
58
+ const layout = layoutCard(props, measure);
59
+ const parts = [];
60
+ // Border, then the accent bar over the left stroke (border-left look).
61
+ // A proposed card is always drawn dashed, independently of the tint
62
+ // (owner criterion 5); the dash pattern is the kit's `4 5`.
63
+ parts.push(`<rect x="1" y="1" width="${g.width - 2}" height="${g.height - 2}" fill="var(--st-component-diagramCard-surface, var(--st-semantic-surface-raised))" stroke="var(--st-component-diagramCard-border, var(--st-semantic-border-strong))" stroke-width="${g.borderWidth}"${props.proposed === true ? ` stroke-dasharray="var(--st-component-diagramCard-proposedDashArray, 4 5)"` : ""}/>`);
64
+ parts.push(`<rect x="0" y="0" width="${g.accentWidth}" height="${g.height}" fill="var(--st-component-diagramCard-accent, var(--st-semantic-data-category1))"/>`);
65
+ if (layout.iconBox !== undefined && props.icon !== undefined) {
66
+ parts.push(iconGroupFor(props.icon, props.iconGlyph, layout.iconBox.x, layout.iconBox.y, layout.iconBox.size));
67
+ }
68
+ if (layout.kicker.length > 0) {
69
+ parts.push(textLines(layout.kicker, "st-diagramCard-kicker", "var(--st-component-diagramCard-secondaryText, var(--st-semantic-text-secondary))", ` letter-spacing="0.04em" style="text-transform:uppercase"`));
70
+ }
71
+ if (layout.title.length > 0) {
72
+ parts.push(textLines(layout.title, "st-diagramCard-title", "var(--st-component-diagramCard-text, var(--st-semantic-text-primary))", ""));
73
+ }
74
+ if (layout.body.length > 0) {
75
+ const secondary = layout.body.filter((line) => line.secondary);
76
+ const primary = layout.body.filter((line) => !line.secondary);
77
+ if (primary.length > 0) {
78
+ parts.push(textLines(primary, "st-diagramCard-body", "var(--st-component-diagramCard-text, var(--st-semantic-text-primary))", ""));
79
+ }
80
+ if (secondary.length > 0) {
81
+ parts.push(textLines(secondary, "st-diagramCard-detail", "var(--st-component-diagramCard-secondaryText, var(--st-semantic-text-secondary))", ""));
82
+ }
83
+ }
84
+ if (layout.ruleY !== undefined) {
85
+ parts.push(`<line class="st-diagramCard-rule" x1="${layout.ruleX1}" x2="${layout.ruleX2}" y1="${layout.ruleY}" y2="${layout.ruleY}" stroke="var(--st-component-diagramCard-rule, var(--st-semantic-border-subtle))" stroke-width="${g.ruleHeight}" vector-effect="non-scaling-stroke"/>`);
86
+ }
87
+ if (layout.footerLines.length > 0) {
88
+ parts.push(textLines(layout.footerLines, "st-diagramCard-footer", "var(--st-component-diagramCard-text, var(--st-semantic-text-primary))", ""));
89
+ }
90
+ if (layout.toggleBox !== undefined && props.toggle !== undefined) {
91
+ parts.push(toggleGlyph(props.toggle, layout.toggleBox));
92
+ }
93
+ return { content: parts.join(""), layout };
94
+ }
95
+ /** The +/- toggle glyph in its slot box (card-local coordinates). */
96
+ export function toggleGlyph(toggle, box) {
97
+ const center = box.size / 2;
98
+ const arm = 7;
99
+ const glyph = toggle.collapsed
100
+ ? `<path d="M ${center - arm} ${center} H ${center + arm} M ${center} ${center - arm} V ${center + arm}" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>`
101
+ : `<path d="M ${center - arm} ${center} H ${center + arm}" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>`;
102
+ return `<g class="st-diagramCard-toggle" data-toggle="true" data-collapsed="${toggle.collapsed ? "true" : "false"}" transform="translate(${box.x} ${box.y})" color="var(--st-semantic-text-primary)" aria-hidden="true"><title>${escapeXml(toggle.label)}</title><rect width="${box.size}" height="${box.size}" fill="transparent"/>${glyph}</g>`;
103
+ }
104
+ /**
105
+ * Render one atomic card as a standalone SVG string. `measure` defaults to
106
+ * the deterministic greedy wrapper; production hosts pass their measured
107
+ * `LineMeasurer` adapter. Returns a refused result (no `svg`) when the
108
+ * content overflows its frozen allocation.
109
+ */
110
+ export function renderCardSvg(props, measure = defaultCardMeasure) {
111
+ const g = CARD_GEOMETRY;
112
+ const { content, layout } = renderCardContent(props, measure);
113
+ const refused = firstOverflowDiagnostic(layout.diagnostics);
114
+ if (refused !== undefined) {
115
+ return { kind: "refused", diagnostics: layout.diagnostics, layout };
116
+ }
117
+ const overflowSlots = layout.diagnostics
118
+ .filter((diagnostic) => diagnostic.code === "card-overflow")
119
+ .map((diagnostic) => diagnostic.slot);
120
+ const unknownIcon = layout.diagnostics.some((diagnostic) => diagnostic.code === "card-icon-unknown");
121
+ const firstOverflow = overflowSlots.length === 0 ? undefined : overflowSlots[0];
122
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" class="st-diagramCard" data-entity="${escapeXml(props.entityId)}"${props.tone === undefined ? "" : ` data-tone="${escapeXml(props.tone)}"`}${props.proposed === true ? ' data-proposed="true"' : ""}${firstOverflow === undefined ? "" : ` data-card-overflow="${firstOverflow}"`}${unknownIcon ? ` data-card-icon-unknown=""` : ""} width="${g.width}" height="${g.height}" viewBox="0 0 ${g.width} ${g.height}" role="img" aria-label="${escapeXml(props.title)}" style="font-family:${FONT_STACK}">` +
123
+ `<title>${escapeXml(props.title)}</title>` +
124
+ content +
125
+ `</svg>`;
126
+ return {
127
+ kind: "rendered",
128
+ svg,
129
+ diagnostics: layout.diagnostics,
130
+ layout,
131
+ };
132
+ }
133
+ /**
134
+ * Convenience: project an `EntityPresentation` then render it. Returns
135
+ * `{ kind: "label" }` when the view carries no card presentation for the
136
+ * entity — the host renders a simple label node and no card — and
137
+ * `{ kind: "card", result }` otherwise, where `result` is the refused or
138
+ * rendered `CardSvgResult`.
139
+ */
140
+ export function renderCardSvgFromPresentation(presentation, opts) {
141
+ const resolved = projectCardProps(presentation, {
142
+ entityId: opts.entityId,
143
+ ...(opts.toggle === undefined ? {} : { toggle: opts.toggle }),
144
+ resolveGlyph: getDiagramGlyph,
145
+ });
146
+ if (resolved.kind !== "card")
147
+ return { kind: "label" };
148
+ return { kind: "card", result: renderCardSvg(resolved.props, opts.measure) };
149
+ }
@@ -0,0 +1,88 @@
1
+ /**
2
+ * `renderZoneSvg` — pure wrapping-card (zone) SVG renderer (DC-2 static
3
+ * half, spec §6).
4
+ *
5
+ * Plain TypeScript, no Svelte import. Ships on the
6
+ * `@sentropic/design-system-svelte/diagram-render` subpath next to
7
+ * `renderCardSvg`. Both renderers consume the same geometry source
8
+ * (`../diagramCardModel.js`): collapsed, the zone IS the atomic card
9
+ * (§6.2 — the card content is emitted inside a translated `<g>`); expanded,
10
+ * the frame carries the shared header, the header rule and the children.
11
+ *
12
+ * No hack from the hrpn FOLDED-CARD-HACKS list survives here: no
13
+ * `diagram-card-box` rect, no regex surgery on rendered output, no
14
+ * `foreignObject` toggle, no title pre-fitting (`FOLD_TITLE`), no
15
+ * function/detail re-roling (DH-08), no tint injection — the toggle is the
16
+ * same slot glyph as the card's and the subtitle is one body string.
17
+ */
18
+ import { CARD_GEOMETRY, projectZoneProps, type CardDiagnostic, type CardLineMeasure, type DiagramZoneProps, type DiagramGlyphPaths, type ZoneChildSpec, type ZoneDiagnostic, type ZoneLayout, type ZonePresentationInput } from "../diagramCardModel.js";
19
+ export type { CardDiagnostic, CardLineMeasure, DiagramGlyphPaths, DiagramZoneProps, ZoneChildSpec, ZoneDiagnostic, ZonePresentationInput, };
20
+ export { projectZoneProps };
21
+ /**
22
+ * Zone-local content (no outer `<svg>`): collapsed, the translated card
23
+ * content; expanded, frame + header + rule + children. Coordinates are
24
+ * zone-local (the caller wraps in `translate(x y)`). The returned
25
+ * `diagnostics` aggregate the zone's own diagnostics with every descendant
26
+ * card/zone diagnostic, each keeping its own `entityId` and original slot
27
+ * text — a nested overflow is never lost inside a zone.
28
+ */
29
+ export declare function zoneContent(props: DiagramZoneProps, children: readonly ZoneChildSpec[], measure: CardLineMeasure): {
30
+ content: string;
31
+ layout: ZoneLayout;
32
+ diagnostics: readonly ZoneDiagnostic[];
33
+ };
34
+ /**
35
+ * The zone render result. Overflow = refusal (owner criterion): when the
36
+ * zone's own layout or any descendant card/zone overflows, the result is
37
+ * `{ kind: "refused" }` with NO `svg` — the aggregated diagnostics carry each
38
+ * offender's `entityId` and original slot text. The Svelte `DiagramZone`
39
+ * renders the matching refusal state (`data-zone-refused`) on the same
40
+ * predicate — one contract, both renderers.
41
+ */
42
+ export type ZoneSvgResult = {
43
+ readonly kind: "rendered";
44
+ readonly svg: string;
45
+ readonly diagnostics: readonly ZoneDiagnostic[];
46
+ readonly layout: ZoneLayout;
47
+ } | {
48
+ readonly kind: "refused";
49
+ readonly diagnostics: readonly ZoneDiagnostic[];
50
+ readonly layout: ZoneLayout;
51
+ };
52
+ /**
53
+ * Render one zone as a standalone SVG string. Collapsed: the atomic card
54
+ * at the zone occurrence (460 × 200, plus the "+" toggle slot). Expanded:
55
+ * the frame with header, rule and children. `measure` defaults to the
56
+ * deterministic greedy wrapper. Returns a refused result (no `svg`) when
57
+ * the zone or any descendant overflows; descendant diagnostics are
58
+ * aggregated with their entity ids.
59
+ */
60
+ export declare function renderZoneSvg(props: DiagramZoneProps, opts?: {
61
+ children?: readonly ZoneChildSpec[];
62
+ measure?: CardLineMeasure;
63
+ }): ZoneSvgResult;
64
+ /**
65
+ * Convenience: project an `EntityPresentation` then render the zone.
66
+ * Returns `{ kind: "label" }` when the view carries no zone presentation
67
+ * for the entity (L-R12), and `{ kind: "zone", result }` otherwise, where
68
+ * `result` is the refused or rendered `ZoneSvgResult`.
69
+ */
70
+ export declare function renderZoneSvgFromPresentation(presentation: ZonePresentationInput | undefined, opts: {
71
+ entityId: string;
72
+ collapsed: boolean;
73
+ toggleLabel?: string;
74
+ align?: "left" | "center";
75
+ x?: number;
76
+ y?: number;
77
+ width?: number;
78
+ height?: number;
79
+ children?: readonly ZoneChildSpec[];
80
+ measure?: CardLineMeasure;
81
+ }): {
82
+ kind: "zone";
83
+ result: ZoneSvgResult;
84
+ } | {
85
+ kind: "label";
86
+ };
87
+ export { CARD_GEOMETRY };
88
+ //# sourceMappingURL=renderZoneSvg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderZoneSvg.d.ts","sourceRoot":"","sources":["../../src/lib/diagram-render/renderZoneSvg.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EACL,aAAa,EAKb,gBAAgB,EAEhB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC3B,MAAM,wBAAwB,CAAC;AAIhC,YAAY,EACV,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,qBAAqB,GACtB,CAAC;AACF,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAmD5B;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,SAAS,aAAa,EAAE,EAClC,OAAO,EAAE,eAAe,GACvB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAA;CAAE,CAuGjF;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GACrB;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAC;IAChD,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAC;IAChD,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B,CAAC;AAEN;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,gBAAgB,EACvB,IAAI,GAAE;IAAE,QAAQ,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,eAAe,CAAA;CAAO,GAC5E,aAAa,CAqBf;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,YAAY,EAAE,qBAAqB,GAAG,SAAS,EAC/C,IAAI,EAAE;IACJ,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC1B,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IACpC,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B,GACA;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAoB7D;AAID,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,184 @@
1
+ /**
2
+ * `renderZoneSvg` — pure wrapping-card (zone) SVG renderer (DC-2 static
3
+ * half, spec §6).
4
+ *
5
+ * Plain TypeScript, no Svelte import. Ships on the
6
+ * `@sentropic/design-system-svelte/diagram-render` subpath next to
7
+ * `renderCardSvg`. Both renderers consume the same geometry source
8
+ * (`../diagramCardModel.js`): collapsed, the zone IS the atomic card
9
+ * (§6.2 — the card content is emitted inside a translated `<g>`); expanded,
10
+ * the frame carries the shared header, the header rule and the children.
11
+ *
12
+ * No hack from the hrpn FOLDED-CARD-HACKS list survives here: no
13
+ * `diagram-card-box` rect, no regex surgery on rendered output, no
14
+ * `foreignObject` toggle, no title pre-fitting (`FOLD_TITLE`), no
15
+ * function/detail re-roling (DH-08), no tint injection — the toggle is the
16
+ * same slot glyph as the card's and the subtitle is one body string.
17
+ */
18
+ import { CARD_GEOMETRY, ZONE_GEOMETRY, defaultCardMeasure, firstOverflowDiagnostic, layoutZone, projectZoneProps, zoneCollapsedCardProps, } from "../diagramCardModel.js";
19
+ import { getDiagramGlyph } from "../diagram-icons/registry.js";
20
+ import { iconGroupFor, renderCardContent, toggleGlyph } from "./renderCardSvg.js";
21
+ export { projectZoneProps };
22
+ function escapeXml(value) {
23
+ return String(value)
24
+ .replaceAll("&", "&amp;")
25
+ .replaceAll("<", "&lt;")
26
+ .replaceAll(">", "&gt;")
27
+ .replaceAll('"', "&quot;");
28
+ }
29
+ const FONT_STACK = "var(--st-font-sans, system-ui, sans-serif)";
30
+ function textLines(lines, className, fill, extra) {
31
+ return lines
32
+ .map((line) => `<text class="${className}" x="${line.x}" y="${line.baseline}" text-anchor="${line.anchor === "middle" ? "middle" : "start"}" font-size="${line.size}" font-weight="${line.weight}" fill="${fill}"${extra}>${escapeXml(line.text)}</text>`)
33
+ .join("");
34
+ }
35
+ function childContent(child, measure) {
36
+ if (child.kind === "card") {
37
+ if (child.card === undefined)
38
+ throw new Error("fixture-error: card child without card props");
39
+ // The child's own diagnostics are kept with the child's entity id (and
40
+ // its original slot text): an overflowing child is aggregated by the
41
+ // zone, not silently dropped.
42
+ const { content, layout } = renderCardContent(child.card, measure);
43
+ const diagnostics = layout.diagnostics.map((diagnostic) => ({
44
+ code: diagnostic.code,
45
+ slot: diagnostic.slot,
46
+ entityId: diagnostic.entityId,
47
+ neededPx: diagnostic.neededPx,
48
+ allocatedPx: diagnostic.allocatedPx,
49
+ ...(diagnostic.text === undefined ? {} : { text: diagnostic.text }),
50
+ }));
51
+ return { content, diagnostics };
52
+ }
53
+ if (child.zone === undefined)
54
+ throw new Error("fixture-error: zone child without zone props");
55
+ const rendered = zoneContent(child.zone, child.children ?? [], measure);
56
+ return { content: rendered.content, diagnostics: rendered.diagnostics };
57
+ }
58
+ /**
59
+ * Zone-local content (no outer `<svg>`): collapsed, the translated card
60
+ * content; expanded, frame + header + rule + children. Coordinates are
61
+ * zone-local (the caller wraps in `translate(x y)`). The returned
62
+ * `diagnostics` aggregate the zone's own diagnostics with every descendant
63
+ * card/zone diagnostic, each keeping its own `entityId` and original slot
64
+ * text — a nested overflow is never lost inside a zone.
65
+ */
66
+ export function zoneContent(props, children, measure) {
67
+ const g = ZONE_GEOMETRY;
68
+ const layout = layoutZone(props, measure, children);
69
+ const x = layout.box.x;
70
+ const y = layout.box.y;
71
+ const parts = [];
72
+ const descendantDiagnostics = [];
73
+ if (layout.collapsed) {
74
+ const cardProps = zoneCollapsedCardProps(props);
75
+ const { content } = renderCardContent(cardProps, measure);
76
+ parts.push(content);
77
+ return { content: parts.join(""), layout, diagnostics: layout.diagnostics };
78
+ }
79
+ const header = layout.header;
80
+ if (header === undefined)
81
+ throw new Error("fixture-error: expanded zone without header layout");
82
+ const width = layout.box.width;
83
+ const height = layout.box.height;
84
+ // Frame (expanded only; collapsed is the card border, §6.4).
85
+ // A proposed zone is always drawn dashed, independently of the tint
86
+ // (owner criterion 5); the dash pattern is the kit's `4 5`.
87
+ parts.push(`<rect class="st-diagramZone-frame" x="0" y="0" width="${width}" height="${height}" rx="${g.radius}" fill="var(--st-component-diagramZone-surface, var(--st-semantic-surface-raised))" stroke="var(--st-component-diagramZone-border, var(--st-semantic-border-strong))" stroke-width="${g.borderWidth}"${props.proposed === true ? ` stroke-dasharray="var(--st-component-diagramZone-proposedDashArray, 4 5)"` : ""}/>`);
88
+ if (header.iconBox !== undefined && props.icon !== undefined) {
89
+ parts.push(iconGroupFor(props.icon, props.iconGlyph, header.iconBox.x - x, header.iconBox.y - y, header.iconBox.size));
90
+ }
91
+ if (header.kicker.length > 0) {
92
+ parts.push(textLines(header.kicker.map((line) => ({ ...line, x: line.x - x, baseline: line.baseline - y })), "st-diagramZone-kicker", "var(--st-component-diagramZone-secondaryText, var(--st-semantic-text-secondary))", ` letter-spacing="0.04em" style="text-transform:uppercase"`));
93
+ }
94
+ if (header.title.length > 0) {
95
+ parts.push(textLines(header.title.map((line) => ({ ...line, x: line.x - x, baseline: line.baseline - y })), "st-diagramZone-title", "var(--st-component-diagramZone-text, var(--st-semantic-text-primary))", ""));
96
+ }
97
+ if (header.subtitle.length > 0) {
98
+ parts.push(textLines(header.subtitle.map((line) => ({ ...line, x: line.x - x, baseline: line.baseline - y })), "st-diagramZone-subtitle", "var(--st-component-diagramZone-text, var(--st-semantic-text-primary))", ""));
99
+ }
100
+ // Header rule: same rule as the card footer rule (1 px, border-subtle,
101
+ // same insets), 4 px under the subtitle or the header block (§6.2).
102
+ parts.push(`<line class="st-diagramZone-rule" x1="${g.ruleInsetStart}" x2="${width - g.ruleInsetEnd}" y1="${header.ruleY - y}" y2="${header.ruleY - y}" stroke="var(--st-component-diagramZone-rule, var(--st-semantic-border-subtle))" stroke-width="${g.ruleHeight}" vector-effect="non-scaling-stroke"/>`);
103
+ if (header.toggleBox !== undefined && props.toggleLabel !== undefined) {
104
+ parts.push(toggleGlyph({ collapsed: false, label: props.toggleLabel }, { x: header.toggleBox.x - x, y: header.toggleBox.y - y, size: header.toggleBox.size }));
105
+ }
106
+ // Expanded footer (§6.1: folding never changes the footer) — the same
107
+ // pinned block as the collapsed card, with its own rule above it.
108
+ if (header.footer.length > 0) {
109
+ if (header.footerRuleY !== undefined) {
110
+ parts.push(`<line class="st-diagramZone-footerRule" x1="${g.ruleInsetStart}" x2="${width - g.ruleInsetEnd}" y1="${header.footerRuleY - y}" y2="${header.footerRuleY - y}" stroke="var(--st-component-diagramZone-rule, var(--st-semantic-border-subtle))" stroke-width="${g.ruleHeight}" vector-effect="non-scaling-stroke"/>`);
111
+ }
112
+ parts.push(textLines(header.footer.map((line) => ({ ...line, x: line.x - x, baseline: line.baseline - y })), "st-diagramZone-footer", "var(--st-component-diagramZone-text, var(--st-semantic-text-primary))", ""));
113
+ }
114
+ for (const child of children) {
115
+ const rendered = childContent(child, measure);
116
+ descendantDiagnostics.push(...rendered.diagnostics);
117
+ parts.push(`<g class="st-diagramZone-child" data-child-kind="${child.kind}" transform="translate(${child.x - x} ${child.y - y})">${rendered.content}</g>`);
118
+ }
119
+ return {
120
+ content: parts.join(""),
121
+ layout,
122
+ diagnostics: [...layout.diagnostics, ...descendantDiagnostics],
123
+ };
124
+ }
125
+ /**
126
+ * Render one zone as a standalone SVG string. Collapsed: the atomic card
127
+ * at the zone occurrence (460 × 200, plus the "+" toggle slot). Expanded:
128
+ * the frame with header, rule and children. `measure` defaults to the
129
+ * deterministic greedy wrapper. Returns a refused result (no `svg`) when
130
+ * the zone or any descendant overflows; descendant diagnostics are
131
+ * aggregated with their entity ids.
132
+ */
133
+ export function renderZoneSvg(props, opts = {}) {
134
+ const measure = opts.measure ?? defaultCardMeasure;
135
+ const children = opts.children ?? [];
136
+ const { content, layout, diagnostics } = zoneContent(props, children, measure);
137
+ if (firstOverflowDiagnostic(diagnostics) !== undefined) {
138
+ return { kind: "refused", diagnostics, layout };
139
+ }
140
+ const { x, y, width, height } = layout.box;
141
+ const overflowSlots = diagnostics
142
+ .filter((diagnostic) => diagnostic.code === "zone-overflow")
143
+ .map((diagnostic) => diagnostic.slot);
144
+ const unknownIcon = diagnostics.some((diagnostic) => diagnostic.code === "zone-icon-unknown");
145
+ const firstOverflow = overflowSlots.length === 0 ? undefined : overflowSlots[0];
146
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" class="st-diagramZoneSvg" width="${x + width}" height="${y + height}" viewBox="0 0 ${x + width} ${y + height}" role="img" aria-label="${escapeXml(props.title)}" style="font-family:${FONT_STACK}">` +
147
+ `<title>${escapeXml(props.title)}</title>` +
148
+ `<g class="st-diagramZone${layout.collapsed ? " st-diagramZone--collapsed" : " st-diagramZone--expanded"}" data-entity="${escapeXml(props.entityId)}" data-collapsed="${layout.collapsed ? "true" : "false"}"${props.tone === undefined ? "" : ` data-tone="${escapeXml(props.tone)}"`}${props.proposed === true ? ' data-proposed="true"' : ""}${firstOverflow === undefined ? "" : ` data-zone-overflow="${firstOverflow}"`}${unknownIcon ? ` data-zone-icon-unknown=""` : ""} transform="translate(${x} ${y})">` +
149
+ content +
150
+ `</g>` +
151
+ `</svg>`;
152
+ return { kind: "rendered", svg, diagnostics, layout };
153
+ }
154
+ /**
155
+ * Convenience: project an `EntityPresentation` then render the zone.
156
+ * Returns `{ kind: "label" }` when the view carries no zone presentation
157
+ * for the entity (L-R12), and `{ kind: "zone", result }` otherwise, where
158
+ * `result` is the refused or rendered `ZoneSvgResult`.
159
+ */
160
+ export function renderZoneSvgFromPresentation(presentation, opts) {
161
+ const resolved = projectZoneProps(presentation, {
162
+ entityId: opts.entityId,
163
+ collapsed: opts.collapsed,
164
+ ...(opts.toggleLabel === undefined ? {} : { toggleLabel: opts.toggleLabel }),
165
+ ...(opts.align === undefined ? {} : { align: opts.align }),
166
+ ...(opts.x === undefined ? {} : { x: opts.x }),
167
+ ...(opts.y === undefined ? {} : { y: opts.y }),
168
+ ...(opts.width === undefined ? {} : { width: opts.width }),
169
+ ...(opts.height === undefined ? {} : { height: opts.height }),
170
+ resolveGlyph: getDiagramGlyph,
171
+ });
172
+ if (resolved.kind !== "zone")
173
+ return { kind: "label" };
174
+ return {
175
+ kind: "zone",
176
+ result: renderZoneSvg(resolved.props, {
177
+ children: opts.children,
178
+ measure: opts.measure,
179
+ }),
180
+ };
181
+ }
182
+ // Re-exported for the zone parity corpus: the card geometry the collapsed
183
+ // zone reuses (DC-D13 — no second size).
184
+ export { CARD_GEOMETRY };