@iasiv5/dsh-skills 1.1.0 → 1.3.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 (65) hide show
  1. package/NOTICE.md +2 -1
  2. package/README.md +1 -1
  3. package/package.json +1 -1
  4. package/skills/answer-me-with-html/SKILL.md +7 -2
  5. package/skills/answer-me-with-html/references/video.md +1 -1
  6. package/skills/answer-me-with-html/scripts/am.mjs +614 -110
  7. package/skills/impeccable/SKILL.md +87 -0
  8. package/skills/impeccable/reference/adapt.md +318 -0
  9. package/skills/impeccable/reference/adapt.native.md +58 -0
  10. package/skills/impeccable/reference/android.md +46 -0
  11. package/skills/impeccable/reference/animate.md +89 -0
  12. package/skills/impeccable/reference/audit.md +150 -0
  13. package/skills/impeccable/reference/audit.native.md +143 -0
  14. package/skills/impeccable/reference/bolder.md +33 -0
  15. package/skills/impeccable/reference/clarify.md +94 -0
  16. package/skills/impeccable/reference/colorize.md +86 -0
  17. package/skills/impeccable/reference/component-review.md +63 -0
  18. package/skills/impeccable/reference/craft-floor.md +44 -0
  19. package/skills/impeccable/reference/craft.md +5 -0
  20. package/skills/impeccable/reference/critique.md +819 -0
  21. package/skills/impeccable/reference/degraded/asset-producer.md +42 -0
  22. package/skills/impeccable/reference/degraded/documenter.md +24 -0
  23. package/skills/impeccable/reference/degraded/finish-reviewer.md +38 -0
  24. package/skills/impeccable/reference/degraded/manual-edit-applier.md +93 -0
  25. package/skills/impeccable/reference/delight.md +70 -0
  26. package/skills/impeccable/reference/distill.md +111 -0
  27. package/skills/impeccable/reference/doctor.md +54 -0
  28. package/skills/impeccable/reference/document.md +416 -0
  29. package/skills/impeccable/reference/extract.md +69 -0
  30. package/skills/impeccable/reference/generate.md +101 -0
  31. package/skills/impeccable/reference/harden.md +362 -0
  32. package/skills/impeccable/reference/hooks.md +120 -0
  33. package/skills/impeccable/reference/init.md +133 -0
  34. package/skills/impeccable/reference/ios.md +51 -0
  35. package/skills/impeccable/reference/layout.md +84 -0
  36. package/skills/impeccable/reference/live-setup.md +104 -0
  37. package/skills/impeccable/reference/live.md +327 -0
  38. package/skills/impeccable/reference/mode-operate.md +21 -0
  39. package/skills/impeccable/reference/mode-persuade.md +19 -0
  40. package/skills/impeccable/reference/mode-read.md +21 -0
  41. package/skills/impeccable/reference/new-work.md +152 -0
  42. package/skills/impeccable/reference/onboard.md +235 -0
  43. package/skills/impeccable/reference/operate.md +61 -0
  44. package/skills/impeccable/reference/optimize.md +257 -0
  45. package/skills/impeccable/reference/overdrive.md +127 -0
  46. package/skills/impeccable/reference/polish.md +105 -0
  47. package/skills/impeccable/reference/quieter.md +99 -0
  48. package/skills/impeccable/reference/region-map.md +26 -0
  49. package/skills/impeccable/reference/routing.md +24 -0
  50. package/skills/impeccable/reference/shape.md +59 -0
  51. package/skills/impeccable/reference/typeset.md +90 -0
  52. package/skills/impeccable/reference/visualize.md +47 -0
  53. package/skills/impeccable/scripts/VERSION +1 -0
  54. package/skills/impeccable/scripts/command-metadata.json +98 -0
  55. package/skills/impeccable/scripts/data/font-index-failures.json +121 -0
  56. package/skills/impeccable/scripts/data/font-index.json +1 -0
  57. package/skills/impeccable/scripts/engine-checksums.txt +9 -0
  58. package/skills/impeccable/scripts/impeccable +319 -0
  59. package/skills/impeccable/scripts/impeccable.cmd +354 -0
  60. package/skills/impeccable/scripts/live-browser-dom.js +320 -0
  61. package/skills/impeccable/scripts/live-browser-ignores.js +246 -0
  62. package/skills/impeccable/scripts/live-browser-session.js +183 -0
  63. package/skills/impeccable/scripts/live-browser.js +13872 -0
  64. package/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
  65. package/skills-manifest.json +9 -0
@@ -392,12 +392,19 @@ body.am-has-reply-bar { padding-block-end: 72px; }
392
392
  .am-node-shape ~ .am-node-shape { filter: none; }
393
393
  /* The corner radius is an SVG attribute (the fallback for Safari before 17.4, which ignores a CSS rx); the default here equals the attribute. A pill and a diamond keep their shape. */
394
394
  .am-node--rect .am-node-shape, .am-node--er .am-node-shape { rx: var(--node-radius, 3px); }
395
+ /* A state is a rounded rectangle; the default matches the rx attribute state.js writes, for Safari before 17.4. */
396
+ .am-node--state .am-node-shape { rx: var(--node-radius, 8px); }
397
+ /* The initial pseudo-state is a filled dot, the final one a ringed dot; both take the node tokens, so every theme draws them. */
398
+ .am-diagram .am-state-dot { fill: var(--node-stroke, var(--line, #1d2026)); }
399
+ .am-diagram .am-state-ring { fill: var(--node-fill, var(--paper, #ffffff)); stroke: var(--node-stroke, var(--line, #1d2026)); stroke-width: var(--node-width, var(--bw, 1.5px)); }
400
+ .am-diagram .am-state-core { fill: var(--node-stroke, var(--line, #1d2026)); }
395
401
  .am-node--hi .am-node-shape { fill: var(--hi-fill, var(--accent-bg, #e4ecf8)); stroke: var(--hi-stroke, var(--accent, #1d5fbf)); }
396
402
  .am-diagram .am-node-text { fill: var(--node-text, var(--ink, #16181d)); }
397
403
  .am-node--hi text { fill: var(--hi-text, var(--accent, #1d5fbf)); font-weight: 600; }
398
404
  .am-diagram .am-node--hi .am-node-text { fill: var(--hi-text, var(--accent, #1d5fbf)); }
399
405
  .am-edge { fill: none; stroke: var(--edge-color, var(--ink-2, #4b5260)); stroke-width: var(--edge-width, 1.3); }
400
406
  .am-edge--dashed { stroke-dasharray: 5 4; }
407
+ .am-class-hollow { fill: var(--paper, #ffffff); stroke: var(--edge-color, var(--ink-2, #4b5260)); stroke-width: var(--edge-width, 1.3); }
401
408
  .am-arrow { fill: var(--edge-color, var(--ink-2, #4b5260)); }
402
409
  .am-edge-label rect { fill: var(--paper, #ffffff); }
403
410
  .am-diagram .am-edge-label text { fill: var(--edge-label, var(--accent, #1d5fbf)); font-size: var(--am-fs-d-edge); }
@@ -406,6 +413,17 @@ body.am-has-reply-bar { padding-block-end: 72px; }
406
413
  /* The PK / FK / UK marks of an entity follow the node text, and the highlighted text in a highlighted entity, so they stay readable on the theme's fills. */
407
414
  .am-diagram .am-er-key { fill: var(--node-text, var(--ink-2, #4b5260)); }
408
415
  .am-diagram .am-node--hi .am-er-key { fill: var(--hi-text, var(--ink-2, #4b5260)); }
416
+ /* API contracts use the existing prose and table styles; the endpoint keeps its protocol punctuation left to right. */
417
+ .am-api-endpoint { display: flex; gap: 10px; align-items: baseline; overflow-wrap: anywhere; }
418
+ .am-api-endpoint strong { color: var(--accent); }
419
+ .am-api .am-api-section h4 { margin: 16px 0 6px; font-size: var(--am-fs-text); }
420
+ .am-api .am-api-section h4 code { font-weight: 400; }
421
+ .am-api .am-api-section table { margin: 0; table-layout: fixed; }
422
+ .am-api th:first-child { width: 28%; }
423
+ .am-api th, .am-api td { overflow-wrap: anywhere; }
424
+ .am-api tbody th { font: inherit; vertical-align: top; padding-block: 7px; }
425
+ /* Keep field code chips visible on every contract row; Markdown's stripe uses the same fill as inline code. */
426
+ .am-api tbody tr:nth-child(even) td { background: transparent; }
409
427
  .am-lifeline { stroke: var(--lifeline-color, var(--ink-3, #8b929e)); stroke-width: 1; stroke-dasharray: 4 4; }
410
428
  /* An actor (and the box of a divider) looks like a node unless the theme sets the actor tokens. */
411
429
  .am-actor { fill: var(--actor-fill, var(--node-fill, var(--paper, #ffffff))); stroke: var(--actor-stroke, var(--node-stroke, var(--line, #1d2026))); stroke-width: var(--node-width, var(--bw, 1.5px)); filter: var(--node-shadow, none); rx: var(--node-radius, 2px); }
@@ -693,6 +711,13 @@ var DELTA_CSS = `/* Change markers (only on pages that have one). Only the Chang
693
711
  .am-view-changes .am-cluster[data-delta="removed"] { stroke: var(--err, #c62828); }
694
712
  .am-view-changes .am-cluster-label[data-delta="added"] { fill: var(--ok, #1f9d4d); }
695
713
  .am-view-changes .am-cluster-label[data-delta="removed"] { fill: var(--err, #c62828); }
714
+ /* state: a state is an .am-node, and its initial and final dots take the same colors as a node shape. */
715
+ .am-view-changes .am-node[data-delta="added"] .am-state-dot, .am-view-changes .am-node[data-delta="added"] .am-state-core { fill: var(--ok, #1f9d4d); }
716
+ .am-view-changes .am-node[data-delta="removed"] .am-state-dot, .am-view-changes .am-node[data-delta="removed"] .am-state-core { fill: var(--err, #c62828); }
717
+ .am-view-changes .am-node[data-delta="changed"] .am-state-dot, .am-view-changes .am-node[data-delta="changed"] .am-state-core { fill: var(--warn, #a8620a); }
718
+ .am-view-changes .am-node[data-delta="added"] .am-state-ring { stroke: var(--ok, #1f9d4d); }
719
+ .am-view-changes .am-node[data-delta="removed"] .am-state-ring { stroke: var(--err, #c62828); }
720
+ .am-view-changes .am-node[data-delta="changed"] .am-state-ring { stroke: var(--warn, #a8620a); }
696
721
  .am-view-changes g[data-delta="removed"]:not(.am-delta-badge), .am-view-changes .am-cluster[data-delta="removed"], .am-view-changes .am-cluster-label[data-delta="removed"] { opacity: 0.55; }
697
722
  .am-view-changes .am-node[data-delta="removed"] > text, .am-view-changes g[data-delta="removed"] > .am-edge-label text, .am-view-changes .am-cluster-label[data-delta="removed"] { text-decoration: line-through; }
698
723
  .am-diagram .am-delta-badge circle { fill: var(--badge); stroke: var(--paper, #ffffff); stroke-width: 1.5; }
@@ -1438,8 +1463,10 @@ var zh_default = {
1438
1463
  closeAfter: { closing: "{n} \u79D2\u540E\u5173\u95ED\u6B64\u6807\u7B7E\u9875", keep: "\u4FDD\u6301\u6253\u5F00", closeFailed: "\u56DE\u590D\u5DF2\u590D\u5236\uFF0C\u73B0\u5728\u53EF\u4EE5\u5173\u95ED\u6B64\u6807\u7B7E\u9875\u3002" },
1439
1464
  toc: "\u76EE\u5F55",
1440
1465
  flow: "\u6D41\u7A0B\u56FE",
1466
+ state: "\u72B6\u6001\u673A\u56FE",
1441
1467
  sequence: "\u65F6\u5E8F\u56FE",
1442
1468
  er: "\u5B9E\u4F53\u5173\u7CFB\u56FE",
1469
+ class: "\u7C7B\u56FE",
1443
1470
  colon: "\uFF1A",
1444
1471
  sep: "\u3001",
1445
1472
  expand: "\u5C55\u5F00\u67E5\u770B\u56FE\u8868",
@@ -1449,6 +1476,7 @@ var zh_default = {
1449
1476
  generated: "Generated by",
1450
1477
  limits: { value: "{value} / max {limit}", limit: "max {limit}" },
1451
1478
  chart: { name: "\u56FE\u8868", data: "\u6570\u636E", value: "\u6570\u503C", share: "\u5360\u6BD4" },
1479
+ api: { path: "\u8DEF\u5F84\u53C2\u6570", query: "\u67E5\u8BE2\u53C2\u6570", headers: "\u8BF7\u6C42\u5934", request: "\u8BF7\u6C42", response: "\u54CD\u5E94", field: "\u5B57\u6BB5", type: "\u7C7B\u578B", description: "\u8BF4\u660E", requirement: "\u5FC5\u586B\u6027", required: "\u5FC5\u586B", optional: "\u53EF\u9009" },
1452
1480
  table: { filter: "\u7B5B\u9009\u8868\u683C" }
1453
1481
  },
1454
1482
  videoUi: {
@@ -1521,8 +1549,10 @@ var zh_Hant_default = {
1521
1549
  closeAfter: { closing: "{n} \u79D2\u5F8C\u95DC\u9589\u6B64\u5206\u9801", keep: "\u4FDD\u6301\u958B\u555F", closeFailed: "\u56DE\u8986\u5DF2\u8907\u88FD\uFF0C\u73FE\u5728\u53EF\u4EE5\u95DC\u9589\u6B64\u5206\u9801\u3002" },
1522
1550
  toc: "\u76EE\u9304",
1523
1551
  flow: "\u6D41\u7A0B\u5716",
1552
+ state: "\u72C0\u614B\u6A5F\u5716",
1524
1553
  sequence: "\u6642\u5E8F\u5716",
1525
1554
  er: "\u5BE6\u9AD4\u95DC\u806F\u5716",
1555
+ class: "\u985E\u5225\u5716",
1526
1556
  colon: "\uFF1A",
1527
1557
  sep: "\u3001",
1528
1558
  expand: "\u5C55\u958B\u67E5\u770B\u5716\u8868",
@@ -1532,6 +1562,7 @@ var zh_Hant_default = {
1532
1562
  generated: "Generated by",
1533
1563
  limits: { value: "{value} / max {limit}", limit: "max {limit}" },
1534
1564
  chart: { name: "\u5716\u8868", data: "\u8CC7\u6599", value: "\u6578\u503C", share: "\u5360\u6BD4" },
1565
+ api: { path: "\u8DEF\u5F91\u53C3\u6578", query: "\u67E5\u8A62\u53C3\u6578", headers: "\u8ACB\u6C42\u6A19\u982D", request: "\u8ACB\u6C42", response: "\u56DE\u61C9", field: "\u6B04\u4F4D", type: "\u578B\u5225", description: "\u8AAA\u660E", requirement: "\u5FC5\u586B\u6027", required: "\u5FC5\u586B", optional: "\u9078\u586B" },
1535
1566
  table: { filter: "\u7BE9\u9078\u8868\u683C" }
1536
1567
  },
1537
1568
  videoUi: {
@@ -1598,8 +1629,10 @@ var en_default = {
1598
1629
  closeAfter: { closing: "Closing this tab in {n}s", keep: "Keep open", closeFailed: "Reply copied. You can close this tab now." },
1599
1630
  toc: "Contents",
1600
1631
  flow: "Flowchart",
1632
+ state: "State machine diagram",
1601
1633
  sequence: "Sequence diagram",
1602
1634
  er: "Entity relationship diagram",
1635
+ class: "Class diagram",
1603
1636
  colon: ": ",
1604
1637
  sep: ", ",
1605
1638
  expand: "Expand diagram",
@@ -1609,6 +1642,7 @@ var en_default = {
1609
1642
  generated: "Generated by",
1610
1643
  limits: { value: "{value} / max {limit}", limit: "max {limit}" },
1611
1644
  chart: { name: "Chart", data: "Data", value: "Value", share: "Share" },
1645
+ api: { path: "Path parameters", query: "Query parameters", headers: "Headers", request: "Request", response: "Response", field: "Field", type: "Type", description: "Description", requirement: "Requirement", required: "Required", optional: "Optional" },
1612
1646
  table: { filter: "Filter table" }
1613
1647
  },
1614
1648
  // Player labels. drawn..duration are the title block cells; sheet is the scene header, with {n} and {total} the zero-padded numbers.
@@ -1681,8 +1715,10 @@ var ja_default = {
1681
1715
  closeAfter: { closing: "{n} \u79D2\u5F8C\u306B\u3053\u306E\u30BF\u30D6\u3092\u9589\u3058\u307E\u3059", keep: "\u958B\u3044\u305F\u307E\u307E\u306B\u3059\u308B", closeFailed: "\u8FD4\u4FE1\u3092\u30B3\u30D4\u30FC\u3057\u307E\u3057\u305F\u3002\u3053\u306E\u30BF\u30D6\u3092\u9589\u3058\u3066\u69CB\u3044\u307E\u305B\u3093\u3002" },
1682
1716
  toc: "\u76EE\u6B21",
1683
1717
  flow: "\u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8",
1718
+ state: "\u72B6\u614B\u9077\u79FB\u56F3",
1684
1719
  sequence: "\u30B7\u30FC\u30B1\u30F3\u30B9\u56F3",
1685
1720
  er: "ER \u56F3",
1721
+ class: "\u30AF\u30E9\u30B9\u56F3",
1686
1722
  colon: "\uFF1A",
1687
1723
  sep: "\u3001",
1688
1724
  expand: "\u62E1\u5927\u8868\u793A",
@@ -1692,6 +1728,7 @@ var ja_default = {
1692
1728
  generated: "Generated by",
1693
1729
  limits: { value: "{value} / max {limit}", limit: "max {limit}" },
1694
1730
  chart: { name: "\u30B0\u30E9\u30D5", data: "\u30C7\u30FC\u30BF", value: "\u5024", share: "\u5272\u5408" },
1731
+ api: { path: "\u30D1\u30B9\u30D1\u30E9\u30E1\u30FC\u30BF\u30FC", query: "\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF\u30FC", headers: "\u30D8\u30C3\u30C0\u30FC", request: "\u30EA\u30AF\u30A8\u30B9\u30C8", response: "\u30EC\u30B9\u30DD\u30F3\u30B9", field: "\u30D5\u30A3\u30FC\u30EB\u30C9", type: "\u578B", description: "\u8AAC\u660E", requirement: "\u5FC5\u9808\u30FB\u4EFB\u610F", required: "\u5FC5\u9808", optional: "\u4EFB\u610F" },
1695
1732
  table: { filter: "\u8868\u3092\u7D5E\u308A\u8FBC\u3080" }
1696
1733
  },
1697
1734
  videoUi: {
@@ -1762,8 +1799,10 @@ var he_default = {
1762
1799
  closeAfter: { closing: "\u05D4\u05DC\u05E9\u05D5\u05E0\u05D9\u05EA \u05EA\u05D9\u05E1\u05D2\u05E8 \u05D1\u05E2\u05D5\u05D3 {n} \u05E9\u05E0\u05D9\u05D5\u05EA", keep: "\u05DC\u05D4\u05E9\u05D0\u05D9\u05E8 \u05E4\u05EA\u05D5\u05D7\u05D4", closeFailed: "\u05D4\u05EA\u05D2\u05D5\u05D1\u05D4 \u05D4\u05D5\u05E2\u05EA\u05E7\u05D4. \u05D0\u05E4\u05E9\u05E8 \u05DC\u05E1\u05D2\u05D5\u05E8 \u05D0\u05EA \u05D4\u05DC\u05E9\u05D5\u05E0\u05D9\u05EA." },
1763
1800
  toc: "\u05EA\u05D5\u05DB\u05DF \u05D4\u05E2\u05E0\u05D9\u05D9\u05E0\u05D9\u05DD",
1764
1801
  flow: "\u05EA\u05E8\u05E9\u05D9\u05DD \u05D6\u05E8\u05D9\u05DE\u05D4",
1802
+ state: "\u05EA\u05E8\u05E9\u05D9\u05DD \u05DE\u05E6\u05D1\u05D9\u05DD",
1765
1803
  sequence: "\u05EA\u05E8\u05E9\u05D9\u05DD \u05E8\u05E6\u05E3",
1766
1804
  er: "\u05EA\u05E8\u05E9\u05D9\u05DD \u05D9\u05E9\u05D5\u05D9\u05D5\u05EA \u05D5\u05E7\u05E9\u05E8\u05D9\u05DD",
1805
+ class: "\u05EA\u05E8\u05E9\u05D9\u05DD \u05DE\u05D7\u05DC\u05E7\u05D5\u05EA",
1767
1806
  colon: ": ",
1768
1807
  sep: ", ",
1769
1808
  expand: "\u05D4\u05D2\u05D3\u05DC\u05EA \u05D4\u05EA\u05E8\u05E9\u05D9\u05DD",
@@ -1773,6 +1812,7 @@ var he_default = {
1773
1812
  generated: "\u05E0\u05D5\u05E6\u05E8 \u05D1\u05D0\u05DE\u05E6\u05E2\u05D5\u05EA",
1774
1813
  limits: { value: "{value} \u05DE\u05EA\u05D5\u05DA {limit}", limit: "\u05E2\u05D3 {limit}" },
1775
1814
  chart: { name: "\u05EA\u05E8\u05E9\u05D9\u05DD", data: "\u05E0\u05EA\u05D5\u05E0\u05D9\u05DD", value: "\u05E2\u05E8\u05DA", share: "\u05D7\u05DC\u05E7" },
1815
+ api: { path: "\u05E4\u05E8\u05DE\u05D8\u05E8\u05D9\u05DD \u05D1\u05E0\u05EA\u05D9\u05D1", query: "\u05E4\u05E8\u05DE\u05D8\u05E8\u05D9\u05DD \u05D1\u05E9\u05D0\u05D9\u05DC\u05EA\u05D4", headers: "\u05DB\u05D5\u05EA\u05E8\u05D5\u05EA", request: "\u05D1\u05E7\u05E9\u05D4", response: "\u05EA\u05D2\u05D5\u05D1\u05D4", field: "\u05E9\u05D3\u05D4", type: "\u05D8\u05D9\u05E4\u05D5\u05E1", description: "\u05EA\u05D9\u05D0\u05D5\u05E8", requirement: "\u05D3\u05E8\u05D9\u05E9\u05D4", required: "\u05D7\u05D5\u05D1\u05D4", optional: "\u05E8\u05E9\u05D5\u05EA" },
1776
1816
  table: { filter: "\u05E1\u05D9\u05E0\u05D5\u05DF \u05D4\u05D8\u05D1\u05DC\u05D4" }
1777
1817
  },
1778
1818
  // Names for the frontmatter keys an agent writes most (`author: …`), shown under the title. Other keys show as written.
@@ -4984,7 +5024,7 @@ function textLines(lines, cx, cy, lineHeight, attrs = "", dir = "ltr") {
4984
5024
  const top2 = cy - (lines.length - 1) * lineHeight / 2;
4985
5025
  return lines.map((line, i) => `<text x="${f(cx)}" y="${f(top2 + i * lineHeight)}" text-anchor="middle" dominant-baseline="central"${attrs}>${esc(svgLine(line, dir))}</text>`).join("");
4986
5026
  }
4987
- var EN_LABELS = { flow: "Flowchart", sequence: "Sequence diagram", er: "Entity relationship diagram", colon: ": ", sep: ", " };
5027
+ var EN_LABELS = { flow: "Flowchart", state: "State machine diagram", sequence: "Sequence diagram", er: "Entity relationship diagram", class: "Class diagram", colon: ": ", sep: ", " };
4988
5028
  function diagramLabel(ui, kind2, names2) {
4989
5029
  const u = { ...EN_LABELS, ...ui };
4990
5030
  return `${u[kind2]}${u.colon}${names2.join(u.sep)}`;
@@ -7395,6 +7435,7 @@ function edgeText(label) {
7395
7435
  };
7396
7436
  }
7397
7437
  function nodeSize(node) {
7438
+ if (node.size) return { lines: [], width: node.size[0], height: node.size[1] };
7398
7439
  const lines = labelLines(node.label, TEXT_MAX, FS2);
7399
7440
  const tw = Math.max(...lines.map((l) => measure(l, FS2)));
7400
7441
  const th = lines.length * LH2;
@@ -7594,9 +7635,10 @@ function layout2(model, rankdir, id, ui, pageDir = "ltr", warn) {
7594
7635
  const heads = ["added", "removed"].filter((state) => edges.some((e) => e.state === state));
7595
7636
  return `${svgOpen(width, height, label, pageDir)}${arrowDefs(id, heads)}<g>${clusters.join("")}</g><g>${edgeSvg.join("")}</g><g>${nodeSvg.join("")}</g></svg>`;
7596
7637
  }
7597
- function badgeSvg(state, x, y2) {
7638
+ function badgeSvg(state, x, y2, step) {
7598
7639
  if (!state) return "";
7599
- return `<g class="am-delta-badge am-delta-badge--${state}"${deltaAttr(state)} transform="translate(${f(x)},${f(y2)})"><circle r="7"/><text text-anchor="middle" dominant-baseline="central">${SIGN[state]}</text></g>`;
7640
+ const at3 = step === void 0 ? "" : ` data-step="${step}"`;
7641
+ return `<g class="am-delta-badge am-delta-badge--${state}"${at3}${deltaAttr(state)} transform="translate(${f(x)},${f(y2)})"><circle r="7"/><text text-anchor="middle" dominant-baseline="central">${SIGN[state]}</text></g>`;
7600
7642
  }
7601
7643
  function badgePoint(shape, x, y2, w2, h, rtl = false) {
7602
7644
  const s = rtl ? -1 : 1;
@@ -7631,24 +7673,332 @@ function diamondPoint(node, toward) {
7631
7673
  return { x: node.x + dx / k, y: node.y + dy / k };
7632
7674
  }
7633
7675
 
7676
+ // src/svg/loop.js
7677
+ var LOOP_OUT = 34;
7678
+ var LOOP_STEP = 20;
7679
+ var LOOP_END = 18;
7680
+ var LOOP_LABEL = 24;
7681
+ var LOOP_GAP = 6;
7682
+ function loopBeside({ x, y: y2, width, labelWidth: labelWidth3 = 0, nth = 0, offset = nth * LOOP_STEP, side = 1 }) {
7683
+ const edge = x + side * width / 2;
7684
+ const out = edge + side * LOOP_OUT + side * offset;
7685
+ const [ay, by] = [y2 - LOOP_END / 2, y2 + LOOP_END / 2];
7686
+ return {
7687
+ a: { x: edge, y: ay },
7688
+ b: { x: edge, y: by },
7689
+ c: [{ x: out, y: ay }, { x: out, y: by }],
7690
+ away: { x: side, y: 0 },
7691
+ label: labelWidth3 ? { x: out + side * 6 + side * labelWidth3 / 2, y: y2 } : null,
7692
+ corners: [[out + side * 6 + side * labelWidth3, by], [out, ay]]
7693
+ };
7694
+ }
7695
+ function loopBelow({ x, y: y2, height, labelWidth: labelWidth3 = 0, labelHeight = 18, depth = 0, side = 1 }) {
7696
+ const bottom = y2 + height / 2;
7697
+ const out = bottom + LOOP_OUT + depth;
7698
+ const [ax, bx] = [x - side * LOOP_END / 2, x + side * LOOP_END / 2];
7699
+ const half = Math.max(LOOP_END / 2, labelWidth3 / 2);
7700
+ return {
7701
+ a: { x: ax, y: bottom },
7702
+ b: { x: bx, y: bottom },
7703
+ c: [{ x: ax, y: out }, { x: bx, y: out }],
7704
+ away: { x: 0, y: 1 },
7705
+ label: labelWidth3 ? { x, y: out + 6 + labelHeight / 2 } : null,
7706
+ corners: [[x - half, bottom], [x + half, out + (labelWidth3 ? 6 + labelHeight : 0)]]
7707
+ };
7708
+ }
7709
+ var labelRoom = (width, height) => width ? Math.max(LOOP_LABEL, 6 + (height ?? 18)) : 0;
7710
+ function loopRoom(labelWidths, labelHeights = []) {
7711
+ const steps2 = labelWidths.slice(0, -1).reduce((depth, width, i) => depth + LOOP_STEP + labelRoom(width, labelHeights[i]), 0);
7712
+ return LOOP_OUT + steps2 + labelRoom(labelWidths.at(-1), labelHeights.at(-1)) + LOOP_GAP;
7713
+ }
7714
+ function loopPath({ a: a3, b, c: c2 }) {
7715
+ return `M${f(a3.x)},${f(a3.y)} C${f(c2[0].x)},${f(c2[0].y)} ${f(c2[1].x)},${f(c2[1].y)} ${f(b.x)},${f(b.y)}`;
7716
+ }
7717
+ function clipToBox(centre, box, toward) {
7718
+ const dx = toward.x - centre.x;
7719
+ const dy = toward.y - centre.y;
7720
+ const k = Math.max(Math.abs(dx) / (box.width / 2), Math.abs(dy) / (box.height / 2));
7721
+ if (k === 0) return { ...centre };
7722
+ return { x: centre.x + dx / k, y: centre.y + dy / k };
7723
+ }
7724
+
7725
+ // src/components/state.js
7726
+ var LH3 = 17;
7727
+ var DOT = 16;
7728
+ var DOT_R = 6;
7729
+ var DIRS2 = /* @__PURE__ */ new Set(["TB", "LR", "BT", "RL"]);
7730
+ var INITIAL = "\0initial";
7731
+ var FINAL = "\0final";
7732
+ var state_default = {
7733
+ name: "state",
7734
+ summary: "State machine diagram (automatic layout)",
7735
+ syntax: `\`\`\`state [TB|LR|BT|RL]
7736
+ [*] -> Idle \u2190 [*] on the left is the initial pseudo-state
7737
+ Idle -> Connecting: connect() \u2190 text after the colon is the event; it is optional
7738
+ Connecting -> Open: SYN-ACK
7739
+ Connecting -> Closed: RST
7740
+ Open -> Open: retransmit \u2190 a self-transition draws a loop
7741
+ Open -> Closed: close()
7742
+ Closed -> [*] \u2190 [*] on the right is the final pseudo-state
7743
+ \`\`\`
7744
+ - One transition per line. A state is a rounded rectangle; the initial pseudo-state is a filled dot, the final one a ringed dot.
7745
+ - The text on each side of \`->\` is the state's name; later lines can refer to it by that name alone. A line without an arrow declares a state (with a change marker).
7746
+ - A Mermaid \`stateDiagram-v2\` block is an error that shows the line to write: lines such as \`Idle --> Open\` are rejected with their line number.
7747
+ - Composite states, parallel regions, entry and exit actions, and history pseudo-states are not drawn.
7748
+ - Change markers show what a plan adds, removes and changes. A line can start with + (added), - (removed) or ~ (changed), followed by a space:
7749
+ \`\`\`state LR
7750
+ [*] -> Idle
7751
+ Idle -> Connecting: connect()
7752
+ + Connecting -> Polling: no reply
7753
+ - Connecting -> Closed
7754
+ ~ Connecting
7755
+ Polling -> Open: reply
7756
+ \`\`\`
7757
+ - A marker applies to the transition and to each state on its line. A state is removed when it appears only on - lines, added when it appears only on + lines, and unchanged when it also appears on an unmarked line. ~ State on a line without an arrow marks that state as changed.
7758
+ - ~ on a transition is an error: remove the old transition with - and add the new one with +. The same transition both unmarked and marked is an error too.
7759
+ - The Changes view draws added in the theme's ok color, removed faded with a struck-through label, changed with a warn outline, and each marked state with a +, \u2212 or ~ badge. A count row and a Before / Changes / After switch sit under the diagram.
7760
+ - A line that starts with a marker and a space is always read as a marker.`,
7761
+ example: "```state LR\n[*] -> Idle\nIdle -> Connecting: connect()\nConnecting -> Open: SYN-ACK\nConnecting -> Closed: RST\nOpen -> Open: retransmit\nOpen -> Closed: close()\nClosed -> [*]\n```",
7762
+ render(text2, { args, uid, ui, video, dir: pageDir = "ltr" }) {
7763
+ const model = parseState(text2);
7764
+ const dir = (args.match(/\b(TB|LR|BT|RL)\b/i)?.[1] ?? "TB").toUpperCase();
7765
+ const html = `<figure class="am-diagram am-state">${layout3(model, DIRS2.has(dir) ? dir : "TB", uid(), ui, pageDir, video)}</figure>`;
7766
+ return withDelta(html, [...model.nodes.values(), ...model.edges].map((x) => x.state ?? null), { ui, video });
7767
+ }
7768
+ };
7769
+ function parseState(text2) {
7770
+ const nodes = /* @__PURE__ */ new Map();
7771
+ const edges = [];
7772
+ const lines = /* @__PURE__ */ new Set();
7773
+ const add2 = (id, label, kind2, line, mark) => {
7774
+ const prev = nodes.get(id);
7775
+ const seen = { before: mark !== "+", after: mark !== "-", tilde: mark === "~" };
7776
+ const tildeLine = mark === "~" ? line : void 0;
7777
+ if (!prev) nodes.set(id, { id, label, kind: kind2, line, ...seen, ...tildeLine && { tildeLine } });
7778
+ else nodes.set(id, { ...prev, before: prev.before || seen.before, after: prev.after || seen.after, tilde: prev.tilde || seen.tilde, ...tildeLine && { tildeLine: prev.tildeLine ?? tildeLine } });
7779
+ return id;
7780
+ };
7781
+ const resolve7 = (name2, line, mark, side) => {
7782
+ if (name2 !== "[*]") return add2(name2, name2, "state", line, mark);
7783
+ return add2(side === "from" ? INITIAL : FINAL, "[*]", side === "from" ? "initial" : "final", line, mark);
7784
+ };
7785
+ for (const { text: raw, line: n } of contentLines(text2)) {
7786
+ const { mark, text: t } = splitMarker(raw);
7787
+ if (t.includes("\0")) throw new ComponentError(`state: a state name cannot contain U+0000: "${raw}"`, n);
7788
+ const state = markState(mark);
7789
+ checkMermaid(t, raw, mark, n);
7790
+ lines.add(n);
7791
+ const at3 = t.indexOf("->");
7792
+ if (at3 === -1) {
7793
+ if (/[::]/.test(t)) throw new ComponentError(`state cannot parse "${raw}". Write a transition as A -> B: event`, n);
7794
+ resolve7(t.trim(), n, mark, "from");
7795
+ continue;
7796
+ }
7797
+ if (mark === "~") throw new ComponentError('state: ~ marks a state, not a transition. To change a transition, remove the old one and add the new one: "- A -> B" then "+ A -> C"', n);
7798
+ const from = t.slice(0, at3).trim();
7799
+ const rest = t.slice(at3 + 2);
7800
+ const colon = rest.search(/[::]/);
7801
+ const to = (colon === -1 ? rest : rest.slice(0, colon)).trim();
7802
+ const label = colon === -1 ? "" : rest.slice(colon + 1).trim();
7803
+ if (to.includes("->")) throw new ComponentError(`state takes one transition per line: "${raw}" has two. Split it into two lines`, n);
7804
+ if (!from || !to) throw new ComponentError(`state: a transition needs a state on each side of ->; write "${raw}" as A -> B: event`, n);
7805
+ const fromId = resolve7(from, n, mark, "from");
7806
+ const toId = resolve7(to, n, mark, "to");
7807
+ edges.push({ from: fromId, to: toId, label, line: n, ...state && { state } });
7808
+ }
7809
+ if (!nodes.size) throw new ComponentError("state needs at least one state", 1);
7810
+ checkTransitions(edges, nodes);
7811
+ const settled = new Map([...nodes].map(([id, node]) => {
7812
+ const state = nodeState(node);
7813
+ return [id, state ? { ...node, state } : node];
7814
+ }));
7815
+ return { nodes: settled, edges, lines: [...lines].sort((a3, b) => a3 - b) };
7816
+ }
7817
+ function checkMermaid(t, raw, mark, line) {
7818
+ if (/^stateDiagram(-v2)?$/i.test(t)) {
7819
+ throw new ComponentError(`"${raw}" is Mermaid syntax; this block is a state diagram already, so write its transitions one line each, for example: [*] -> Idle`, line);
7820
+ }
7821
+ if (/^state\s+.+\{$/.test(t)) {
7822
+ throw new ComponentError(`"${raw}" is a Mermaid composite state, which this component does not draw; write each state on its own or in a transition`, line);
7823
+ }
7824
+ if (t === "}") throw new ComponentError(`"${raw}" closes a Mermaid composite state; this component has no nested states, so remove the braces`, line);
7825
+ const colon = t.search(/[::]/);
7826
+ const head = colon === -1 ? t : t.slice(0, colon);
7827
+ if (!head.includes("-->")) return;
7828
+ const fixedHead = head.replace(/-->/g, "->").replace(/\s+$/, "");
7829
+ const event = colon === -1 ? "" : t.slice(colon + 1).trim();
7830
+ const fixed2 = event ? `${fixedHead}: ${event}` : fixedHead;
7831
+ throw new ComponentError(`"${raw}" is Mermaid syntax; write ${mark && mark !== "~" ? `${mark} ` : ""}${fixed2}`, line);
7832
+ }
7833
+ function checkTransitions(edges, nodes) {
7834
+ const keyOf = (e) => `${e.from}\0${e.to}\0${e.label}`;
7835
+ const text2 = (e) => `${nodes.get(e.from).label} -> ${nodes.get(e.to).label}${e.label ? `: ${e.label}` : ""}`;
7836
+ for (const e of edges.filter((x) => x.state)) {
7837
+ const plain = edges.find((x) => !x.state && keyOf(x) === keyOf(e));
7838
+ if (plain) {
7839
+ throw new ComponentError(`state: the transition ${text2(e)} is written unmarked on line ${plain.line} and as ${e.state === "added" ? "+" : "-"} here. Mark every line of that transition, or none`, e.line);
7840
+ }
7841
+ }
7842
+ }
7843
+ function layout3(model, rankdir, id, ui, pageDir = "ltr", video = false) {
7844
+ const { nodes, edges, lines } = model;
7845
+ const rtl = pageDir === "rtl";
7846
+ const side = rtl ? -1 : 1;
7847
+ const below = rankdir === "LR" || rankdir === "RL";
7848
+ const loops = edges.filter((e) => e.from === e.to);
7849
+ const straight = edges.filter((e) => e.from !== e.to);
7850
+ const boxes = new Map([...nodes.values()].map((n) => {
7851
+ if (n.kind !== "state") return [n.id, { width: DOT, height: DOT, lines: [] }];
7852
+ const { width: width2, height: height2, lines: lines2 } = nodeSize({ label: n.label, shape: "rect" });
7853
+ return [n.id, { width: width2, height: height2, lines: lines2 }];
7854
+ }));
7855
+ const measured = new Map(loops.map((e) => [e, e.label ? edgeText(e.label) : { width: 0, height: 0 }]));
7856
+ const room = /* @__PURE__ */ new Map();
7857
+ const beside = /* @__PURE__ */ new Map();
7858
+ for (const from of new Set(loops.map((e) => e.from))) {
7859
+ const own = loops.filter((e) => e.from === from);
7860
+ const sizes = own.map((e) => measured.get(e));
7861
+ if (below) {
7862
+ room.set(from, { y: loopRoom(sizes.map((s) => s.width), sizes.map((s) => s.height)) });
7863
+ continue;
7864
+ }
7865
+ let offset = 0;
7866
+ beside.set(from, own.map((e, i) => {
7867
+ if (i) offset += Math.max(LOOP_STEP, sizes[i - 1].width + 6);
7868
+ return { edge: e, offset, labelWidth: sizes[i].width, extent: LOOP_OUT + offset + 6 + sizes[i].width };
7869
+ }));
7870
+ room.set(from, { x: Math.max(...beside.get(from).map((spec) => spec.extent)) });
7871
+ }
7872
+ const layoutNodes = new Map([...nodes].map(([key2, n]) => {
7873
+ const box = boxes.get(key2);
7874
+ const extra = room.get(key2) ?? {};
7875
+ return [key2, { ...n, shape: "rect", size: [box.width + (extra.x ?? 0), box.height + (extra.y ?? 0)] }];
7876
+ }));
7877
+ const { g, key } = runLayout({ nodes: layoutNodes, edges: straight, groups: [] }, rankdir, rtl, [], /* @__PURE__ */ new Map());
7878
+ const centre = (nodeId) => {
7879
+ const { x, y: y2 } = g.node(key.get(nodeId));
7880
+ const extra = room.get(nodeId) ?? {};
7881
+ return { x: x - side * (extra.x ?? 0) / 2, y: y2 - (extra.y ?? 0) / 2 };
7882
+ };
7883
+ const stepOf = new Map(lines.map((line, i) => [line, i]));
7884
+ const drawn = straight.map((e, i) => {
7885
+ const data = g.edge({ v: key.get(e.from), w: key.get(e.to), name: `e${i}` });
7886
+ return { e, data, points: clipEnds2(data.points, e, centre, boxes, room, nodes) };
7887
+ });
7888
+ const edgeSvg = drawn.map(({ e, data, points }) => {
7889
+ const head = e.state ? `${id}-arrow-${e.state}` : `${id}-arrow`;
7890
+ const path = `<path class="am-edge" d="${smoothPath(points)}" marker-end="url(#${head})"/>`;
7891
+ const text2 = e.label ? edgeLabelSvg(e.label, data.x, data.y, pageDir) : "";
7892
+ return `<g data-step="${stepOf.get(e.line)}"${deltaAttr(e.state)}>${path}${text2}</g>`;
7893
+ });
7894
+ const seen = /* @__PURE__ */ new Map();
7895
+ const loopSpecs = loops.map((e) => {
7896
+ const { x, y: y2 } = centre(e.from);
7897
+ const box = boxes.get(e.from);
7898
+ if (below) {
7899
+ const size = measured.get(e);
7900
+ const { depth } = seen.get(e.from) ?? { depth: 0 };
7901
+ seen.set(e.from, { depth: depth + LOOP_STEP + (e.label ? Math.max(LOOP_LABEL, 6 + size.height) : 0) });
7902
+ return { e, ...loopBelow({ x, y: y2, height: box.height, depth, side, labelWidth: size.width, labelHeight: size.height }) };
7903
+ }
7904
+ const spec = beside.get(e.from).find((x2) => x2.edge === e);
7905
+ return { e, ...loopBeside({ x, y: y2, width: box.width, side, offset: spec.offset, labelWidth: spec.labelWidth }) };
7906
+ });
7907
+ const loopsSvg = loopSpecs.map(({ e, ...spec }) => {
7908
+ const head = e.state ? `${id}-arrow-${e.state}` : `${id}-arrow`;
7909
+ const path = `<path class="am-edge" d="${loopPath(spec)}" marker-end="url(#${head})"/>`;
7910
+ const text2 = e.label && spec.label ? edgeLabelSvg(e.label, spec.label.x, spec.label.y, pageDir) : "";
7911
+ return `<g data-step="${stepOf.get(e.line)}"${deltaAttr(e.state)}>${path}${text2}</g>`;
7912
+ });
7913
+ const nodeSvg = [...nodes.values()].map((n) => {
7914
+ const { x, y: y2 } = centre(n.id);
7915
+ const box = boxes.get(n.id);
7916
+ const badgeStep = n.state === "changed" ? stepOf.get(n.tildeLine ?? n.line) : void 0;
7917
+ const badge = badgeSvg(n.state, rtl ? x - box.width / 2 : x + box.width / 2, y2 - box.height / 2, badgeStep);
7918
+ const keyAttr = n.kind === "state" ? ` data-key="${esc(n.label)}"` : "";
7919
+ const open = `<g class="am-node am-node--state${n.kind === "state" ? "" : ` am-node--${n.kind}`}"${keyAttr} data-step="${stepOf.get(n.line)}"${deltaAttr(n.state)}>`;
7920
+ if (n.kind === "initial") return `${open}<circle class="am-state-dot" cx="${f(x)}" cy="${f(y2)}" r="${DOT_R}"/>${badge}</g>`;
7921
+ if (n.kind === "final") return `${open}<circle class="am-state-ring" cx="${f(x)}" cy="${f(y2)}" r="${DOT_R}"/><circle class="am-state-core" cx="${f(x)}" cy="${f(y2)}" r="2.8"/>${badge}</g>`;
7922
+ return `${open}<rect class="am-node-shape" x="${f(x - box.width / 2)}" y="${f(y2 - box.height / 2)}" width="${f(box.width)}" height="${f(box.height)}" rx="8"/>${textLines(box.lines, x, y2, LH3, ' class="am-node-text"', pageDir)}${badge}</g>`;
7923
+ });
7924
+ const xs = [];
7925
+ const ys = [];
7926
+ const at3 = (x, y2) => {
7927
+ xs.push(x);
7928
+ ys.push(y2);
7929
+ };
7930
+ for (const n of nodes.values()) {
7931
+ const { x, y: y2 } = centre(n.id);
7932
+ const box = boxes.get(n.id);
7933
+ at3(x - box.width / 2, y2 - box.height / 2);
7934
+ at3(x + box.width / 2, y2 + box.height / 2);
7935
+ }
7936
+ for (const { e, data, points } of drawn) {
7937
+ for (const p of points) at3(p.x, p.y);
7938
+ if (e.label) {
7939
+ const { width: w2, height: h } = edgeText(e.label);
7940
+ at3(data.x - w2 / 2, data.y - h / 2);
7941
+ at3(data.x + w2 / 2, data.y + h / 2);
7942
+ }
7943
+ }
7944
+ for (const { e, corners, label: label2 } of loopSpecs) {
7945
+ corners.forEach(([x, y2]) => at3(x, y2));
7946
+ if (label2) {
7947
+ const { width: w2, height: h } = edgeText(e.label);
7948
+ at3(label2.x - w2 / 2, label2.y - h / 2);
7949
+ at3(label2.x + w2 / 2, label2.y + h / 2);
7950
+ }
7951
+ }
7952
+ const margin = 14;
7953
+ const shiftX = margin - Math.min(...xs);
7954
+ const shiftY = margin - Math.min(...ys);
7955
+ const shift = shiftX || shiftY ? ` transform="translate(${f(shiftX)},${f(shiftY)})"` : "";
7956
+ const width = Math.ceil(Math.max(...xs) - Math.min(...xs)) + 2 * margin;
7957
+ const height = Math.ceil(Math.max(...ys) - Math.min(...ys)) + 2 * margin;
7958
+ const names2 = [...nodes.values()].filter((n) => n.kind === "state").slice(0, 8).map((n) => n.label);
7959
+ const label = diagramLabel(ui, "state", names2);
7960
+ const heads = ["added", "removed"].filter((s) => edges.some((e) => e.state === s));
7961
+ const used = /* @__PURE__ */ new Set([
7962
+ ...straight.map((e) => stepOf.get(e.line)),
7963
+ ...loops.map((e) => stepOf.get(e.line)),
7964
+ ...[...nodes.values()].map((n) => stepOf.get(n.line)),
7965
+ ...[...nodes.values()].filter((n) => n.state === "changed").map((n) => stepOf.get(n.tildeLine ?? n.line))
7966
+ ]);
7967
+ const empty = video ? lines.map((line) => used.has(stepOf.get(line)) ? "" : `<g data-step="${stepOf.get(line)}"></g>`).join("") : "";
7968
+ return `${svgOpen(width, height, label, pageDir)}${arrowDefs(id, heads)}<g${shift}><g>${edgeSvg.join("")}</g><g>${loopsSvg.join("")}</g><g>${nodeSvg.join("")}</g>${empty}</g></svg>`;
7969
+ }
7970
+ function edgeLabelSvg(label, x, y2, pageDir) {
7971
+ const { lines, width: w2, height: h } = edgeText(label);
7972
+ return `<g class="am-edge-label"><rect x="${f(x - w2 / 2)}" y="${f(y2 - h / 2)}" width="${f(w2)}" height="${f(h)}" rx="3"/>${textLines(lines, x, y2, LH3, "", pageDir)}</g>`;
7973
+ }
7974
+ function clipEnds2(points, edge, centre, boxes, room, nodes) {
7975
+ const pts = points.map((p) => ({ ...p }));
7976
+ if (room.has(edge.from) && pts.length > 1) pts[0] = clipToBox(centre(edge.from), boxes.get(edge.from), points[1]);
7977
+ if (room.has(edge.to) && pts.length > 1) pts[pts.length - 1] = clipToBox(centre(edge.to), boxes.get(edge.to), points[points.length - 2]);
7978
+ const onCircle = (c2, toward, r) => {
7979
+ const dx = toward.x - c2.x;
7980
+ const dy = toward.y - c2.y;
7981
+ const d = Math.hypot(dx, dy);
7982
+ return d ? { x: c2.x + dx / d * r, y: c2.y + dy / d * r } : { ...c2 };
7983
+ };
7984
+ if (nodes.get(edge.from).kind === "initial" && pts.length > 1) pts[0] = onCircle(centre(edge.from), pts[1], DOT_R);
7985
+ if (nodes.get(edge.to).kind === "final" && pts.length > 1) pts[pts.length - 1] = onCircle(centre(edge.to), pts[pts.length - 2], DOT_R);
7986
+ return pts;
7987
+ }
7988
+
7634
7989
  // src/components/er.js
7635
7990
  var FS3 = DRAWING.node;
7636
7991
  var FIELD_FS = DRAWING.field;
7637
7992
  var KEY_FS = DRAWING.cluster;
7638
7993
  var EDGE_FS2 = DRAWING.edge;
7639
- var LH3 = 17;
7994
+ var LH4 = 17;
7640
7995
  var HEAD_LH = 20;
7641
7996
  var FIELD_LH = 17;
7642
7997
  var PAD = 11;
7643
7998
  var KEY_GAP = 12;
7644
7999
  var SIGN_W = 14;
7645
8000
  var MIN_WIDTH = 92;
7646
- var LOOP_OUT = 34;
7647
- var LOOP_STEP = 20;
7648
- var LOOP_END = 18;
7649
- var LOOP_LABEL = 24;
7650
- var LOOP_GAP = 6;
7651
- var DIRS2 = /* @__PURE__ */ new Set(["TB", "LR", "BT", "RL"]);
8001
+ var DIRS3 = /* @__PURE__ */ new Set(["TB", "LR", "BT", "RL"]);
7652
8002
  var CARDS = ["1\\.\\.\\*", "0\\.\\.1", "\\*", "1"];
7653
8003
  var MARKERS = /* @__PURE__ */ new Set(["PK", "FK", "UK"]);
7654
8004
  var RELATIONSHIP = new RegExp(`^(\\S+)\\s+(${CARDS.join("|")})\\s*--\\s*(${CARDS.join("|")})\\s+(\\S+)\\s*(?::\\s*(.*))?$`);
@@ -7695,7 +8045,7 @@ Order
7695
8045
  render(text2, { args, ui, video, dir: pageDir = "ltr" }) {
7696
8046
  const model = parseEr(text2);
7697
8047
  const dir = (args.match(/\b(TB|LR|BT|RL)\b/i)?.[1] ?? "TB").toUpperCase();
7698
- const html = `<figure class="am-diagram am-er">${layout3(model, DIRS2.has(dir) ? dir : "TB", ui, pageDir)}</figure>`;
8048
+ const html = `<figure class="am-diagram am-er">${layout4(model, DIRS3.has(dir) ? dir : "TB", ui, pageDir)}</figure>`;
7699
8049
  const states = [...model.entities.values()].flatMap((e) => [e.state, ...e.fields.map((x) => x.state)]).concat(model.written.map((rel) => rel.state));
7700
8050
  return withDelta(html, states.map((state) => state ?? null), { ui, video });
7701
8051
  }
@@ -7825,7 +8175,7 @@ function nodeSize2(entity) {
7825
8175
  const rows = entity.fields.map((field) => rowWidth(entity, field));
7826
8176
  return { width: Math.ceil(Math.max(MIN_WIDTH, nameWidth(entity) + 2 * PAD, ...rows)), height: HEAD_LH + entity.fields.length * FIELD_LH + 2 * PAD };
7827
8177
  }
7828
- function layout3(model, rankdir, ui, pageDir = "ltr") {
8178
+ function layout4(model, rankdir, ui, pageDir = "ltr") {
7829
8179
  const { entities } = model;
7830
8180
  const rels = relationships(model);
7831
8181
  const loops = rels.filter((rel) => rel.from === rel.to);
@@ -7838,7 +8188,7 @@ function layout3(model, rankdir, ui, pageDir = "ltr") {
7838
8188
  if (below) {
7839
8189
  for (const name2 of entities.keys()) {
7840
8190
  const own = loops.filter((rel) => rel.from === name2);
7841
- if (own.length) room.set(name2, loopRoom(own));
8191
+ if (own.length) room.set(name2, loopRoom(own.map((rel) => rel.label ? labelWidth2(rel.label) : 0)));
7842
8192
  }
7843
8193
  }
7844
8194
  const sizes = /* @__PURE__ */ new Map();
@@ -7883,7 +8233,9 @@ function layout3(model, rankdir, ui, pageDir = "ltr") {
7883
8233
  seen.set(rel.from, { nth: nth + 1, depth: depth + LOOP_STEP + (rel.label ? LOOP_LABEL : 0) });
7884
8234
  const { x, y: y2 } = centre(rel.from);
7885
8235
  const size = sizes.get(rel.from);
7886
- return below ? loopBelow(rel, x, y2, size, depth, s) : loopBeside(rel, x, y2, size, nth, s);
8236
+ const lw = rel.label ? labelWidth2(rel.label) : 0;
8237
+ const spec = below ? loopBelow({ x, y: y2, height: size.height, depth, side: s, labelWidth: lw }) : loopBeside({ x, y: y2, width: size.width, nth, side: s, labelWidth: lw });
8238
+ return { rel, ...spec };
7887
8239
  });
7888
8240
  const loopsSvg = loopSpecs.map((spec) => loopSvg(spec, stepOf.get(spec.rel.line), pageDir));
7889
8241
  const xs = [];
@@ -7916,17 +8268,6 @@ function layout3(model, rankdir, ui, pageDir = "ltr") {
7916
8268
  const label = diagramLabel(ui, "er", [...entities.keys()].slice(0, 8));
7917
8269
  return `${svgOpen(width, height, label, pageDir)}<g${shift}><g>${edgeSvg.join("")}</g><g>${loopsSvg.join("")}</g><g>${nodeSvg.join("")}</g></g></svg>`;
7918
8270
  }
7919
- function loopRoom(own) {
7920
- const steps2 = own.slice(0, -1).reduce((depth, rel) => depth + LOOP_STEP + (rel.label ? LOOP_LABEL : 0), 0);
7921
- return LOOP_OUT + steps2 + (own.at(-1).label ? LOOP_LABEL : 0) + LOOP_GAP;
7922
- }
7923
- function clipToBox(centre, size, toward) {
7924
- const dx = toward.x - centre.x;
7925
- const dy = toward.y - centre.y;
7926
- const k = Math.max(Math.abs(dx) / (size.width / 2), Math.abs(dy) / (size.height / 2));
7927
- if (k === 0) return { ...centre };
7928
- return { x: centre.x + dx / k, y: centre.y + dy / k };
7929
- }
7930
8271
  function nodeSvgOf(entity, x, y2, size, step, pageDir) {
7931
8272
  const left = x - size.width / 2;
7932
8273
  const top2 = y2 - size.height / 2;
@@ -7945,38 +8286,8 @@ function nodeSvgOf(entity, x, y2, size, step, pageDir) {
7945
8286
  const badge = badgeSvg(entity.state, rtl ? left : left + size.width, top2);
7946
8287
  return `<g class="am-node am-node--er${entity.hi ? " am-node--hi" : ""}" data-key="${esc(entity.name)}" data-step="${step}"${deltaAttr(entity.state)}><rect class="am-node-shape" x="${f(left)}" y="${f(top2)}" width="${f(size.width)}" height="${f(size.height)}" rx="3"/>${head}${rule}${fields2}${badge}</g>`;
7947
8288
  }
7948
- function loopBeside(rel, x, y2, size, nth, s) {
7949
- const edge = x + s * size.width / 2;
7950
- const out = edge + s * LOOP_OUT + s * nth * LOOP_STEP;
7951
- const [ay, by] = [y2 - LOOP_END / 2, y2 + LOOP_END / 2];
7952
- const label = rel.label ? { x: out + s * 6 + s * labelWidth2(rel.label) / 2, y: y2 } : null;
7953
- return {
7954
- rel,
7955
- a: { x: edge, y: ay },
7956
- b: { x: edge, y: by },
7957
- c: [{ x: out, y: ay }, { x: out, y: by }],
7958
- away: { x: s, y: 0 },
7959
- label,
7960
- corners: [[out + s * 6 + s * (rel.label ? labelWidth2(rel.label) : 0), by], [out, ay]]
7961
- };
7962
- }
7963
- function loopBelow(rel, x, y2, size, depth, s) {
7964
- const bottom = y2 + size.height / 2;
7965
- const out = bottom + LOOP_OUT + depth;
7966
- const [ax, bx] = [x - s * LOOP_END / 2, x + s * LOOP_END / 2];
7967
- const half = Math.max(LOOP_END / 2, rel.label ? labelWidth2(rel.label) / 2 : 0);
7968
- return {
7969
- rel,
7970
- a: { x: ax, y: bottom },
7971
- b: { x: bx, y: bottom },
7972
- c: [{ x: ax, y: out }, { x: bx, y: out }],
7973
- away: { x: 0, y: 1 },
7974
- label: rel.label ? { x, y: out + 6 + 9 } : null,
7975
- corners: [[x - half, bottom], [x + half, out + (rel.label ? 6 + 18 : 0)]]
7976
- };
7977
- }
7978
8289
  function loopSvg({ rel, a: a3, b, c: c2, away, label }, step, pageDir) {
7979
- const path = `<path class="am-edge" d="M${f(a3.x)},${f(a3.y)} C${f(c2[0].x)},${f(c2[0].y)} ${f(c2[1].x)},${f(c2[1].y)} ${f(b.x)},${f(b.y)}"/>`;
8290
+ const path = `<path class="am-edge" d="${loopPath({ a: a3, b, c: c2 })}"/>`;
7980
8291
  const ends = `${endMark(a3, { x: a3.x + away.x, y: a3.y + away.y }, rel.fromCard)}${endMark(b, { x: b.x + away.x, y: b.y + away.y }, rel.toCard)}`;
7981
8292
  const text2 = label ? labelSvg(rel.label, label.x, label.y, pageDir) : "";
7982
8293
  return `<g data-step="${step}"${deltaAttr(rel.state)}>${path}${ends}${text2}</g>`;
@@ -7986,7 +8297,7 @@ function labelWidth2(text2) {
7986
8297
  }
7987
8298
  function labelSvg(text2, x, y2, pageDir) {
7988
8299
  const w2 = labelWidth2(text2);
7989
- return `<g class="am-edge-label"><rect x="${f(x - w2 / 2)}" y="${f(y2 - 9)}" width="${f(w2)}" height="18" rx="3"/>${textLines([text2], x, y2, LH3, "", pageDir)}</g>`;
8300
+ return `<g class="am-edge-label"><rect x="${f(x - w2 / 2)}" y="${f(y2 - 9)}" width="${f(w2)}" height="18" rx="3"/>${textLines([text2], x, y2, LH4, "", pageDir)}</g>`;
7990
8301
  }
7991
8302
  function endsSvg(points, rel) {
7992
8303
  if (points.length < 2) return "";
@@ -8021,6 +8332,194 @@ function endMark(point, toward, card) {
8021
8332
  return `<g class="am-er-end am-edge">${marks}</g>`;
8022
8333
  }
8023
8334
 
8335
+ // src/components/class.js
8336
+ var RELATION = /^(\S+)\s+(--\|>|\.\.\|>|\*--|o--|-->|\.\.>|--)\s+([^\s:]+)(?:\s*:\s*(.*))?$/;
8337
+ var METHOD = /^[+\-#~]?\s*[^:\s(]+\s*\(/;
8338
+ var ROW = 20;
8339
+ var PAD2 = 12;
8340
+ function parseClass(text2) {
8341
+ const classes = /* @__PURE__ */ new Map();
8342
+ const relations = [];
8343
+ let current;
8344
+ for (const { raw, text: line, line: n } of contentLines(text2)) {
8345
+ if (/^\s/.test(raw)) {
8346
+ if (!current) throw new ComponentError("class: write a class or interface before its indented members", n);
8347
+ current.members.push(line);
8348
+ continue;
8349
+ }
8350
+ const relation = line.match(RELATION);
8351
+ if (relation) {
8352
+ relations.push({ from: relation[1], kind: relation[2], to: relation[3], label: relation[4] ?? "", line: n });
8353
+ current = null;
8354
+ continue;
8355
+ }
8356
+ const declaration = line.match(/^(?:(class|interface|abstract|enum)\s+)?(\*?)([^\s:]+)$/);
8357
+ if (!declaration || /--|\.\.>|[{}]/.test(line)) {
8358
+ throw new ComponentError(`class: cannot parse "${line}"; write class User, interface Store, or User --|> Entity`, n);
8359
+ }
8360
+ const [, kind2 = "class", hi, name2] = declaration;
8361
+ if (classes.has(name2)) throw new ComponentError(`class: "${name2}" is declared twice`, n);
8362
+ current = { name: name2, kind: kind2, hi: Boolean(hi), members: [], line: n };
8363
+ classes.set(name2, current);
8364
+ }
8365
+ if (!classes.size) throw new ComponentError("class needs at least one class or interface", 1);
8366
+ for (const relation of relations) {
8367
+ for (const name2 of [relation.from, relation.to]) {
8368
+ if (!classes.has(name2)) throw new ComponentError(`class: no declaration for "${name2}"`, relation.line);
8369
+ }
8370
+ }
8371
+ return { classes, relations };
8372
+ }
8373
+ var class_default = {
8374
+ name: "class",
8375
+ summary: "UML class diagram (attributes, methods, interfaces and relationships)",
8376
+ syntax: `\`\`\`class [TB|LR|BT|RL]
8377
+ abstract Entity
8378
+ +id: string
8379
+ class *User
8380
+ -email: string
8381
+ +save(): void
8382
+ interface Store
8383
+ +find(id: string): User
8384
+ User --|> Entity: extends
8385
+ User ..|> Store: implements
8386
+ \`\`\`
8387
+ - Declare class, interface, abstract or enum at column 0; a bare name is a class. * highlights a declaration.
8388
+ - Indent members. Visibility (+ public, - private, # protected, ~ package), types and signatures are shown as written.
8389
+ - Attributes and methods occupy separate compartments; a method starts with name( after its optional visibility sign. Parentheses in a property type do not make it a method.
8390
+ - Links: --|> inheritance, ..|> realization, *-- composition, o-- aggregation, --> association, ..> dependency, -- plain association.
8391
+ - Arrowheads point at the right-hand declaration; diamonds sit at the left-hand declaration. Labels after : are optional.
8392
+ - Declare both ends of every link. Self-links and parallel links are supported. The default direction is TB.`,
8393
+ example: "```class LR\ninterface Store\n +find(id: string): User\nclass UserStore\n -users: User[]\n +find(id: string): User\nUserStore ..|> Store: implements\n```",
8394
+ // render lays out measured UML boxes with dagre and emits the same themed SVG hooks as the other diagrams.
8395
+ render(text2, { args = "", uid, ui, dir = "ltr" }) {
8396
+ const { classes, relations } = parseClass(text2);
8397
+ const id = uid();
8398
+ const g = new Uo.graphlib.Graph({ multigraph: true });
8399
+ g.setGraph({ rankdir: args.match(/\b(TB|LR|BT|RL)\b/i)?.[1].toUpperCase() ?? "TB", nodesep: 44, ranksep: 64, marginx: 18, marginy: 18 });
8400
+ g.setDefaultEdgeLabel(() => ({}));
8401
+ const keys = new Map([...classes.keys()].map((name2, i) => [name2, `n${i}`]));
8402
+ for (const c2 of classes.values()) {
8403
+ const stereotype = c2.kind === "class" ? [] : [c2.kind];
8404
+ const attributes = c2.members.filter((m2) => !METHOD.test(m2));
8405
+ const methods = c2.members.filter((m2) => METHOD.test(m2));
8406
+ const groups = [[...stereotype, c2.name], attributes, methods].filter((rows) => rows.length);
8407
+ const widths = groups.flatMap((rows, i) => rows.map((row, n) => measure(row, i || stereotype.length && !n ? DRAWING.field : DRAWING.node, { bold: c2.hi })));
8408
+ g.setNode(keys.get(c2.name), { ...c2, groups, width: Math.ceil(Math.max(100, ...widths.map((w2) => w2 + 2 * PAD2))), height: groups.reduce((n, rows) => n + rows.length * ROW + PAD2, 0) });
8409
+ }
8410
+ relations.forEach((rel, i) => {
8411
+ g.setEdge(keys.get(rel.from), keys.get(rel.to), {
8412
+ ...rel,
8413
+ width: rel.label ? measure(rel.label, DRAWING.edge) + 12 : 0,
8414
+ height: rel.label ? 20 : 0,
8415
+ labelpos: "c"
8416
+ }, `e${i}`);
8417
+ });
8418
+ Uo.layout(g, { customOrder: orderRanks });
8419
+ if (dir === "rtl") mirrorLayout(g);
8420
+ const edges = g.edges().map((edge) => {
8421
+ const rel = g.edge(edge);
8422
+ const diamond = rel.kind === "*--" || rel.kind === "o--";
8423
+ const marker = diamond ? rel.kind === "*--" ? "filled" : "diamond" : rel.kind.includes("|>") ? "triangle" : "open";
8424
+ const end = rel.kind === "--" ? "" : ` marker-${diamond ? "start" : "end"}="url(#${id}-${marker})"`;
8425
+ const label = rel.label ? `<g class="am-edge-label"><rect x="${f(rel.x - rel.width / 2)}" y="${f(rel.y - 10)}" width="${f(rel.width)}" height="20" rx="3"/>${textLines([rel.label], rel.x, rel.y, ROW, "", dir)}</g>` : "";
8426
+ return `<g data-step="${rel.line - 1}"><path class="am-edge${rel.kind.startsWith("..") ? " am-edge--dashed" : ""}" d="${smoothPath(rel.points)}"${end}/>${label}</g>`;
8427
+ });
8428
+ const nodes = g.nodes().map((key) => {
8429
+ const c2 = g.node(key);
8430
+ const x = c2.x - c2.width / 2;
8431
+ const y2 = c2.y - c2.height / 2;
8432
+ let top2 = y2;
8433
+ const rows = c2.groups.map((group, k) => {
8434
+ const separator = k ? `<path class="am-edge" d="M${f(x)},${f(top2)} h${f(c2.width)}"/>` : "";
8435
+ const text3 = group.map((member, n) => {
8436
+ const kind2 = !k && !n && c2.kind !== "class";
8437
+ return `<text class="am-node-text" x="${f(k ? dir === "rtl" ? x + c2.width - PAD2 : x + PAD2 : c2.x)}" y="${f(top2 + PAD2 / 2 + ROW * (n + 0.5))}" text-anchor="${k ? "start" : "middle"}" dominant-baseline="central"${k || kind2 ? ` style="font-size:${DRAWING.field}px${kind2 ? ";font-style:italic;opacity:0.65" : ""}"` : ""}>${esc(svgLine(member, dir))}</text>`;
8438
+ }).join("");
8439
+ top2 += group.length * ROW + PAD2;
8440
+ return separator + text3;
8441
+ }).join("");
8442
+ return `<g class="am-node am-node--rect${c2.hi ? " am-node--hi" : ""}" data-key="${esc(c2.name)}" data-step="${c2.line - 1}"><rect class="am-node-shape" x="${f(x)}" y="${f(y2)}" width="${f(c2.width)}" height="${f(c2.height)}" rx="3"/>${rows}</g>`;
8443
+ });
8444
+ const defs = `<defs>${[["triangle", "M0,0 L10,5 L0,10 Z"], ["diamond", "M0,5 L6,0 L12,5 L6,10 Z"], ["filled", "M0,5 L6,0 L12,5 L6,10 Z"], ["open", "M1,1 L9,5 L1,9"]].map(([kind2, path]) => `<marker id="${id}-${kind2}" viewBox="-1 -1 14 12" refX="${kind2 === "diamond" || kind2 === "filled" ? 12 : 10}" refY="5" markerWidth="12" markerHeight="10" orient="auto-start-reverse"><path class="${kind2 === "filled" ? "am-arrow" : kind2 === "open" ? "am-edge" : "am-class-hollow"}" d="${path}"/></marker>`).join("")}</defs>`;
8445
+ return `<figure class="am-diagram am-class">${svgOpen(g.graph().width, g.graph().height, diagramLabel(ui, "class", [...classes.keys()]), dir)}${defs}${edges.join("")}${nodes.join("")}</svg></figure>`;
8446
+ }
8447
+ };
8448
+
8449
+ // src/components/api.js
8450
+ function parseApi(text2) {
8451
+ const lines = contentLines(text2);
8452
+ const first = lines.shift();
8453
+ const endpoint = first?.text.match(/^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE|CONNECT|RPC)\s+(\S+)$/);
8454
+ if (!endpoint || (endpoint[1] === "RPC" ? !/^[^/]+\/[^/]+$/.test(endpoint[2]) : !endpoint[2].startsWith("/"))) {
8455
+ throw new ComponentError("api: start with METHOD /path or RPC package.Service/Method", first?.line ?? 1);
8456
+ }
8457
+ const sections = [];
8458
+ let current;
8459
+ for (const { raw, text: line, line: n } of lines) {
8460
+ if (/^\s/.test(raw)) {
8461
+ const [spec, ...description] = line.split(/(?<!\\)\|/).map((part) => part.replace(/\\\|/g, "|"));
8462
+ const parts = spec.trim().split(/\s+/);
8463
+ const name2 = parts.shift();
8464
+ const requirement = /^(required|optional)$/.test(parts.at(-1)) ? parts.pop() : "";
8465
+ const type = parts.join(" ");
8466
+ if (!current || !type) throw new ComponentError("api: indent name type [required|optional] | description under a section", n);
8467
+ current.fields.push({ name: name2, type, requirement, description: description.join("|").trim() });
8468
+ continue;
8469
+ }
8470
+ const section = line.match(/^(path|query|headers|request|response)(?:\s+(.+))?$/);
8471
+ if (!section || section[1] === "response" && !section[2]) {
8472
+ throw new ComponentError("api: use path, query, headers, request [Type], or response STATUS [Type]", n);
8473
+ }
8474
+ if (section[1] === "response" && endpoint[1] !== "RPC" && !/^[1-5]\d{2}(?:\s|$)/.test(section[2])) {
8475
+ throw new ComponentError("api: HTTP responses need a status code from 100 to 599, for example response 200 User", n);
8476
+ }
8477
+ if (endpoint[1] === "RPC" && ["path", "query", "headers"].includes(section[1])) {
8478
+ throw new ComponentError("api: RPC contracts use request and response sections", n);
8479
+ }
8480
+ current = { kind: section[1], detail: section[2] ?? "", fields: [] };
8481
+ sections.push(current);
8482
+ }
8483
+ if (!sections.length) throw new ComponentError("api needs at least one request, parameter or response section", first.line);
8484
+ return { method: endpoint[1], target: endpoint[2], sections };
8485
+ }
8486
+ var api_default = {
8487
+ name: "api",
8488
+ summary: "HTTP API or RPC contract (parameters, request and response fields)",
8489
+ syntax: `\`\`\`api
8490
+ POST /users
8491
+ headers
8492
+ Authorization string required | Bearer token
8493
+ request CreateUserRequest
8494
+ email string required | Email address
8495
+ name string optional
8496
+ response 201 User
8497
+ id string required
8498
+ response 400 Error
8499
+ message string required
8500
+ \`\`\`
8501
+ - One endpoint per block: an uppercase HTTP method and /path, or RPC package.Service/Method.
8502
+ - Sections: path, query, headers, request [Type], response STATUS [Type]. RPC uses request and response.
8503
+ - Indent fields: name type [required|optional] | description. Types and descriptions are shown as text, including generics and nested field paths.
8504
+ - Write \\| for a literal | inside a type, such as string \\| null; the first unescaped | starts the description.
8505
+ - required and optional are explicit and visible in the Requirement column. If any field declares one, unspecified fields show a dash; otherwise this column is omitted.
8506
+ - A response requires a status (HTTP code 100-599 or RPC status name). A section without fields can describe an empty response, such as response 204.
8507
+ - This displays a contract; it does not send requests or import OpenAPI / protobuf files.`,
8508
+ example: "```api\nRPC users.UserService/GetUser\nrequest GetUserRequest\n id string required\nresponse OK User\n id string required\n email string optional\nresponse NOT_FOUND\n```",
8509
+ // render emits semantic tables, escaping every author-supplied contract value and translating the surrounding labels.
8510
+ render(text2, { ui } = {}) {
8511
+ const { method, target, sections } = parseApi(text2);
8512
+ const words3 = ui?.api ?? FALLBACK.ui.api;
8513
+ const body = sections.map(({ kind: kind2, detail, fields: fields2 }) => {
8514
+ const described = fields2.some((field) => field.description);
8515
+ const specified = fields2.some((field) => field.requirement);
8516
+ const table = fields2.length ? `<div class="am-table-wrap"><table><thead><tr><th scope="col">${esc(words3.field)}</th><th scope="col">${esc(words3.type)}</th>${specified ? `<th scope="col">${esc(words3.requirement)}</th>` : ""}${described ? `<th scope="col">${esc(words3.description)}</th>` : ""}</tr></thead><tbody>${fields2.map((field) => `<tr><th scope="row"><code>${esc(field.name)}</code></th><td><code>${esc(field.type)}</code></td>${specified ? `<td>${field.requirement ? esc(words3[field.requirement]) : "\u2014"}</td>` : ""}${described ? `<td>${esc(field.description)}</td>` : ""}</tr>`).join("")}</tbody></table></div>` : "";
8517
+ return `<section class="am-api-section"><h4>${esc(words3[kind2])}${detail ? ` <code>${esc(detail)}</code>` : ""}</h4>${table}</section>`;
8518
+ }).join("");
8519
+ return `<div class="am-api am-md"><div class="am-api-endpoint" dir="ltr"><strong>${esc(method)}</strong> <code>${esc(target)}</code></div>${body}</div>`;
8520
+ }
8521
+ };
8522
+
8024
8523
  // src/components/ask.js
8025
8524
  var OPTION = /^([*-])\s+(.+)$/;
8026
8525
  var ask_default = {
@@ -8127,9 +8626,9 @@ function lineRange(values) {
8127
8626
  }
8128
8627
 
8129
8628
  // src/components/chart-parts.js
8130
- var PAD2 = 8;
8629
+ var PAD3 = 8;
8131
8630
  var FS4 = { cat: DRAWING.chartCat, tick: DRAWING.chartTick, val: DRAWING.chartVal, legend: DRAWING.chartLegend };
8132
- var LH4 = 14;
8631
+ var LH5 = 14;
8133
8632
  var PLOT_H = 220;
8134
8633
  var MAX_WIDTH = 880;
8135
8634
  var SLOT_MAX = 104;
@@ -8181,7 +8680,7 @@ function valueAxis(m2, { axisX, width, y: y2, W: W3, X: X3 }) {
8181
8680
  }
8182
8681
  function categoryLabel(plan, i, label, cx, catTop, { X: X3, rtl, dir }) {
8183
8682
  if (plan.lines) {
8184
- return { svg: plan.lines[i].map((l, j) => text("am-ch-cat", X3(cx), catTop + 11 + j * LH4, l, dir, ' text-anchor="middle"')).join(""), tip: "" };
8683
+ return { svg: plan.lines[i].map((l, j) => text("am-ch-cat", X3(cx), catTop + 11 + j * LH5, l, dir, ' text-anchor="middle"')).join(""), tip: "" };
8185
8684
  }
8186
8685
  const shown2 = plan.shown[i];
8187
8686
  const [ax, ay] = [X3(cx + 3), catTop + 4];
@@ -8236,21 +8735,21 @@ function verticalBars(m2) {
8236
8735
  const slot = plan.slot;
8237
8736
  const bw = Math.max(6, Math.min(barMax, Math.floor((slot - Math.min(GUTTER, slot * 0.3) - (count2 - 1) * GAP) / count2)));
8238
8737
  const tickW = Math.max(...range.ticks.map((t) => measure(m2.tick(t), FS4.tick)));
8239
- const reach = plan.lines ? 0 : Math.max(...plan.shown.map((l, i) => measure(l, FS4.cat) * COS + FS4.cat * SIN - ((i + 0.5) * slot + PAD2 + tickW + 9)));
8240
- const axisX = PAD2 + Math.max(0, reach) + tickW + 6;
8738
+ const reach = plan.lines ? 0 : Math.max(...plan.shown.map((l, i) => measure(l, FS4.cat) * COS + FS4.cat * SIN - ((i + 0.5) * slot + PAD3 + tickW + 9)));
8739
+ const axisX = PAD3 + Math.max(0, reach) + tickW + 6;
8241
8740
  const legend = legendLayout(m2.names, Math.max(n * slot + tickW, 240));
8242
- const W3 = Math.ceil(Math.max(axisX + n * slot + PAD2, (legend.width ?? 0) + 2 * PAD2));
8243
- const plotTop = PAD2 + legend.height + (labels ? 16 : 6);
8741
+ const W3 = Math.ceil(Math.max(axisX + n * slot + PAD3, (legend.width ?? 0) + 2 * PAD3));
8742
+ const plotTop = PAD3 + legend.height + (labels ? 16 : 6);
8244
8743
  const plotBottom = plotTop + PLOT_H;
8245
8744
  const negLabels = labels && range.min < 0;
8246
8745
  const catTop = plotBottom + (negLabels ? 18 : 8);
8247
- const catH = plan.lines ? Math.max(...plan.lines.map((ls) => ls.length)) * LH4 + 4 : Math.max(...plan.shown.map((l) => measure(l, FS4.cat))) * SIN + 12;
8248
- const height = catTop + catH + PAD2;
8746
+ const catH = plan.lines ? Math.max(...plan.lines.map((ls) => ls.length)) * LH5 + 4 : Math.max(...plan.shown.map((l) => measure(l, FS4.cat))) * SIN + 12;
8747
+ const height = catTop + catH + PAD3;
8249
8748
  const X3 = mirror(W3, rtl);
8250
8749
  const rectX = (x, w2) => rtl ? W3 - x - w2 : x;
8251
8750
  const y2 = (v2) => plotTop + (range.max - v2) / (range.max - range.min) * PLOT_H;
8252
8751
  const y0 = y2(0);
8253
- const body = [legendSvg(legend, PAD2, PAD2, m2, W3)];
8752
+ const body = [legendSvg(legend, PAD3, PAD3, m2, W3)];
8254
8753
  body.push(...valueAxis(m2, { axisX, width: n * slot, y: y2, W: W3, X: X3 }));
8255
8754
  for (const [i, row] of rows.entries()) {
8256
8755
  const x0 = axisX + i * slot;
@@ -8276,23 +8775,23 @@ function horizontalBars(m2) {
8276
8775
  const lines = rows.map((r) => fitLines(r.label, CAT_WIDTH, 3, FS4.cat));
8277
8776
  const catW = Math.max(...lines.flat().map((l) => measure(l, FS4.cat)));
8278
8777
  const bh = BAR_H[count2];
8279
- const rowH = Math.max(count2 * bh + (count2 - 1) * GAP + 12, Math.max(...lines.map((ls) => ls.length)) * LH4 + 6);
8778
+ const rowH = Math.max(count2 * bh + (count2 - 1) * GAP + 12, Math.max(...lines.map((ls) => ls.length)) * LH5 + 6);
8280
8779
  const rel = (v2) => (v2 - range.min) / (range.max - range.min) * PLOT_W;
8281
8780
  const widths = rows.map((r) => r.values.map((v2) => labels ? measure(m2.tick(v2), FS4.val) : 0));
8282
8781
  const after = labels ? Math.max(0, ...rows.flatMap((r, i) => r.values.map((v2, k) => v2 >= 0 ? rel(v2) + 4 + widths[i][k] - PLOT_W : 0))) : 0;
8283
8782
  const before = labels ? Math.max(0, ...rows.flatMap((r, i) => r.values.map((v2, k) => v2 < 0 ? widths[i][k] + 4 - rel(v2) : 0))) : 0;
8284
8783
  const tickHalf = Math.max(...range.ticks.map((t) => measure(m2.tick(t), FS4.tick))) / 2;
8285
- const catX = PAD2 + catW;
8286
- const axisX = Math.max(catX + 8 + before, PAD2 + tickHalf);
8784
+ const catX = PAD3 + catW;
8785
+ const axisX = Math.max(catX + 8 + before, PAD3 + tickHalf);
8287
8786
  const legend = legendLayout(m2.names, Math.max(catW + PLOT_W, 240));
8288
- const W3 = Math.ceil(Math.max(axisX + PLOT_W + Math.max(after, tickHalf) + PAD2, (legend.width ?? 0) + 2 * PAD2));
8289
- const plotTop = PAD2 + legend.height + 4;
8787
+ const W3 = Math.ceil(Math.max(axisX + PLOT_W + Math.max(after, tickHalf) + PAD3, (legend.width ?? 0) + 2 * PAD3));
8788
+ const plotTop = PAD3 + legend.height + 4;
8290
8789
  const plotBottom = plotTop + n * rowH;
8291
- const height = plotBottom + 22 + PAD2;
8790
+ const height = plotBottom + 22 + PAD3;
8292
8791
  const X3 = mirror(W3, rtl);
8293
8792
  const x = (v2) => axisX + rel(v2);
8294
8793
  const x0 = x(0);
8295
- const body = [legendSvg(legend, PAD2, PAD2, m2, W3)];
8794
+ const body = [legendSvg(legend, PAD3, PAD3, m2, W3)];
8296
8795
  for (const t of range.ticks) {
8297
8796
  const line = t === 0 ? "am-ch-zero" : "am-ch-grid";
8298
8797
  body.push(`<line class="${line}" x1="${f(X3(x(t)))}" y1="${f(plotTop)}" x2="${f(X3(x(t)))}" y2="${f(plotBottom)}"/>`);
@@ -8310,8 +8809,8 @@ function horizontalBars(m2) {
8310
8809
  const end = v2 >= 0 ? x(v2) + 4 : x(v2) - 4;
8311
8810
  return bar + text("am-ch-val", X3(end), by + bh / 2, m2.tick(v2), dir, ` text-anchor="${v2 >= 0 ? "start" : "end"}" dominant-baseline="central"`);
8312
8811
  });
8313
- const first = top2 + rowH / 2 - (lines[i].length - 1) * LH4 / 2;
8314
- const name2 = lines[i].map((l, j) => text("am-ch-cat", X3(catX), first + j * LH4, l, dir, ' text-anchor="end" dominant-baseline="central"')).join("");
8812
+ const first = top2 + rowH / 2 - (lines[i].length - 1) * LH5 / 2;
8813
+ const name2 = lines[i].map((l, j) => text("am-ch-cat", X3(catX), first + j * LH5, l, dir, ' text-anchor="end" dominant-baseline="central"')).join("");
8315
8814
  body.push(rowGroup(m2, row, i, tooltip(row.label, lines[i].join(" ")), parts.join("") + name2));
8316
8815
  }
8317
8816
  return { width: W3, height, body };
@@ -8319,7 +8818,7 @@ function horizontalBars(m2) {
8319
8818
 
8320
8819
  // src/components/chart-line.js
8321
8820
  var MAX_VALUE_LABELS2 = 12;
8322
- var DOT = 3.5;
8821
+ var DOT2 = 3.5;
8323
8822
  var DOT_HI = 5.5;
8324
8823
  var LABEL_GAP = 9;
8325
8824
  var MIN_APART = 13;
@@ -8356,7 +8855,7 @@ function planAxis(rows, slot) {
8356
8855
  const lines = labels.map((l, i) => show2[i] ? wrap(l, room, FS4.cat) : null);
8357
8856
  if (lines.every((ls) => !ls || ls.length <= 2 && ls.every((l) => measure(l, FS4.cat) <= room + 0.5))) return { show: show2, lines, widths: lines.map((ls) => ls ? Math.max(...ls.map((l) => measure(l, FS4.cat))) : 0) };
8358
8857
  }
8359
- const show = shownRows(rows, Math.max(1, Math.ceil((LH4 + 1) / (slot * SIN))));
8858
+ const show = shownRows(rows, Math.max(1, Math.ceil((LH5 + 1) / (slot * SIN))));
8360
8859
  const shown2 = labels.map((l) => shorten(l, SLANT_MAX, FS4.cat));
8361
8860
  return { show, lines: null, shown: shown2, widths: shown2.map((l) => measure(l, FS4.cat)) };
8362
8861
  }
@@ -8377,7 +8876,7 @@ function valueLabels(m2, X3, x, values, ys, { valleys, end, bottom }) {
8377
8876
  function segment(X3, [x0, y0], [x1, y1], [hi0, hi1], k) {
8378
8877
  const len = Math.hypot(x1 - x0, y1 - y0);
8379
8878
  const [dx, dy] = [(x1 - x0) / len, (y1 - y0) / len];
8380
- const [r0, r1] = [hi0 ? DOT_HI : DOT, hi1 ? DOT_HI : DOT];
8879
+ const [r0, r1] = [hi0 ? DOT_HI : DOT2, hi1 ? DOT_HI : DOT2];
8381
8880
  return `<path class="am-ch-line am-ch-s${k + 1}" d="M${f(X3(x0 + dx * r0))},${f(y0 + dy * r0)} L${f(X3(x1 - dx * r1))},${f(y1 - dy * r1)}"/>`;
8382
8881
  }
8383
8882
  function lineChart(m2) {
@@ -8397,25 +8896,25 @@ function lineChart(m2) {
8397
8896
  const [left, right] = columnEnd(i) === "end" ? [0, column] : [column, 0];
8398
8897
  return { left: Math.max(half, slanted, left) - (i + 0.5) * slot, right: Math.max(half, right) - (n - i - 0.5) * slot };
8399
8898
  });
8400
- const axisX = Math.max(PAD2 + tickW + 6, PAD2 + Math.max(...over2.map((o) => o.left)));
8899
+ const axisX = Math.max(PAD3 + tickW + 6, PAD3 + Math.max(...over2.map((o) => o.left)));
8401
8900
  const plotW = n * slot;
8402
8901
  const legend = legendLayout(m2.names, Math.max(plotW + tickW, 240));
8403
- const W3 = Math.ceil(Math.max(axisX + plotW + Math.max(PAD2, 2 + Math.max(...over2.map((o) => o.right))), (legend.width ?? 0) + 2 * PAD2));
8404
- const plotTop = PAD2 + legend.height + (anyLabels ? 18 : 6);
8902
+ const W3 = Math.ceil(Math.max(axisX + plotW + Math.max(PAD3, 2 + Math.max(...over2.map((o) => o.right))), (legend.width ?? 0) + 2 * PAD3));
8903
+ const plotTop = PAD3 + legend.height + (anyLabels ? 18 : 6);
8405
8904
  const plotBottom = plotTop + PLOT_H;
8406
8905
  const catTop = plotBottom + (anyLabels ? 22 : 8);
8407
- const catH = plan.lines ? Math.max(...plan.lines.map((ls) => ls ? ls.length : 0)) * LH4 + 4 : Math.max(...plan.shown.map((l, i) => plan.show[i] ? measure(l, FS4.cat) : 0)) * SIN + 12;
8408
- const height = catTop + catH + PAD2;
8906
+ const catH = plan.lines ? Math.max(...plan.lines.map((ls) => ls ? ls.length : 0)) * LH5 + 4 : Math.max(...plan.shown.map((l, i) => plan.show[i] ? measure(l, FS4.cat) : 0)) * SIN + 12;
8907
+ const height = catTop + catH + PAD3;
8409
8908
  const X3 = mirror(W3, rtl);
8410
8909
  const y2 = (v2) => plotTop + (range.max - v2) / (range.max - range.min) * PLOT_H;
8411
8910
  const cx = (i) => axisX + (i + 0.5) * slot;
8412
- const body = [legendSvg(legend, PAD2, PAD2, m2, W3)];
8911
+ const body = [legendSvg(legend, PAD3, PAD3, m2, W3)];
8413
8912
  body.push(...valueAxis(m2, { axisX, width: plotW, y: y2, W: W3, X: X3 }));
8414
8913
  for (const [i, row] of rows.entries()) {
8415
8914
  const parts = [];
8416
8915
  if (row.hi) parts.push(`<line class="am-ch-guide" x1="${f(X3(cx(i)))}" y1="${f(plotTop)}" x2="${f(X3(cx(i)))}" y2="${f(plotBottom)}"/>`);
8417
8916
  if (i > 0) parts.push(...row.values.map((v2, k) => segment(X3, [cx(i - 1), y2(rows[i - 1].values[k])], [cx(i), y2(v2)], [rows[i - 1].hi, row.hi], k)));
8418
- parts.push(...row.values.map((v2, k) => `<circle class="am-ch-dot am-ch-s${k + 1}" cx="${f(X3(cx(i)))}" cy="${f(y2(v2))}" r="${row.hi ? DOT_HI : DOT}"/>`));
8917
+ parts.push(...row.values.map((v2, k) => `<circle class="am-ch-dot am-ch-s${k + 1}" cx="${f(X3(cx(i)))}" cy="${f(y2(v2))}" r="${row.hi ? DOT_HI : DOT2}"/>`));
8419
8918
  if (labelled[i]) {
8420
8919
  const around2 = (j, k) => rows[j]?.values[k];
8421
8920
  const valleys = row.values.map((v2, k) => i > 0 && i < n - 1 && around2(i - 1, k) > v2 && around2(i + 1, k) > v2);
@@ -8454,14 +8953,14 @@ function drawPie(data, { unit = "", dir = "ltr", label }) {
8454
8953
  const shares = asShares ? [] : values.map((v2) => percent(v2, total));
8455
8954
  const valueW = Math.max(...shown2.map((s) => measure(s, FS4.legend)));
8456
8955
  const shareW = asShares ? 0 : Math.max(...shares.map((s) => measure(s, FS4.legend)));
8457
- const heights = lines.map((ls) => Math.max(ls.length * LH4 + ROW_PAD, 24));
8956
+ const heights = lines.map((ls) => Math.max(ls.length * LH5 + ROW_PAD, 24));
8458
8957
  const legendH = heights.reduce((a3, b) => a3 + b, 0);
8459
8958
  const legendW = SW + labelW + COL_GAP + valueW + (asShares ? 0 : COL_GAP + shareW);
8460
- const H3 = Math.ceil(Math.max(2 * R2, legendH) + 2 * PAD2);
8461
- const W3 = Math.ceil(PAD2 + 2 * R2 + GAP2 + legendW + PAD2);
8462
- const [cx, cy] = [PAD2 + R2, H3 / 2];
8959
+ const H3 = Math.ceil(Math.max(2 * R2, legendH) + 2 * PAD3);
8960
+ const W3 = Math.ceil(PAD3 + 2 * R2 + GAP2 + legendW + PAD3);
8961
+ const [cx, cy] = [PAD3 + R2, H3 / 2];
8463
8962
  const X3 = mirror(W3, rtl);
8464
- const lx = PAD2 + 2 * R2 + GAP2;
8963
+ const lx = PAD3 + 2 * R2 + GAP2;
8465
8964
  const [valueX, shareX] = [lx + SW + labelW + COL_GAP + valueW, lx + legendW];
8466
8965
  const at3 = (r, turn2) => `${f(X3(cx + r * Math.sin(turn2 * TAU)))},${f(cy - r * Math.cos(turn2 * TAU))}`;
8467
8966
  const [outer, inner] = rtl ? [0, 1] : [1, 0];
@@ -8472,11 +8971,11 @@ function drawPie(data, { unit = "", dir = "ltr", label }) {
8472
8971
  for (const [i, row] of rows.entries()) {
8473
8972
  const span = total > 0 ? values[i] / total : 0;
8474
8973
  const mid2 = top2 + heights[i] / 2;
8475
- const first = mid2 - (lines[i].length - 1) * LH4 / 2;
8974
+ const first = mid2 - (lines[i].length - 1) * LH5 / 2;
8476
8975
  const parts = [];
8477
8976
  if (span > 0) parts.push(`<path class="am-ch-slice am-ch-s${i + 1}" d="${slice(turn, turn + span)}"/>`);
8478
8977
  parts.push(`<rect class="am-ch-sw am-ch-s${i + 1}" x="${f(rtl ? W3 - lx - 10 : lx)}" y="${f(mid2 - 5)}" width="10" height="10" rx="2"/>`);
8479
- parts.push(...lines[i].map((l, j) => text("am-ch-leg", X3(lx + SW), first + j * LH4, l, dir, ' dominant-baseline="central"')));
8978
+ parts.push(...lines[i].map((l, j) => text("am-ch-leg", X3(lx + SW), first + j * LH5, l, dir, ' dominant-baseline="central"')));
8480
8979
  parts.push(text("am-ch-num", X3(valueX), mid2, shown2[i], dir, ' text-anchor="end" dominant-baseline="central"'));
8481
8980
  if (!asShares) parts.push(text("am-ch-num", X3(shareX), mid2, shares[i], dir, ' text-anchor="end" dominant-baseline="central"'));
8482
8981
  body.push(stepGroup(i, `am-ch-row${anyHi ? row.hi ? " is-hi" : " is-dim" : ""}`, tooltip(row.label, lines[i].join(" ")), parts.join("")));
@@ -8605,7 +9104,7 @@ function dataTable({ series, rows }, { type, unit }, words3) {
8605
9104
  }
8606
9105
 
8607
9106
  // src/components/index.js
8608
- var ALL2 = [callout_default, kv_default, timeline_default, annot_default, tree_default, limits_default, chart_default, sequence_default, flow_default, er_default, ask_default];
9107
+ var ALL2 = [callout_default, kv_default, timeline_default, annot_default, tree_default, limits_default, chart_default, sequence_default, flow_default, state_default, er_default, class_default, api_default, ask_default];
8609
9108
  var COMPONENTS = new Map(ALL2.map((c2) => [c2.name, c2]));
8610
9109
  var RAW_LANGS = /* @__PURE__ */ new Set(["html", "svg"]);
8611
9110
 
@@ -8911,11 +9410,11 @@ function panelHtml(panel, { cols = 3, grid = true, hints = {} } = {}) {
8911
9410
  const { attrs } = panel;
8912
9411
  const span = Math.min(Number(attrs.span) || 1, cols);
8913
9412
  const rows = Number(attrs.rows) || 1;
8914
- const layout4 = [
9413
+ const layout5 = [
8915
9414
  grid && span > 1 ? `grid-column: span ${span}` : "",
8916
9415
  grid && rows > 1 ? `grid-row: span ${rows}` : ""
8917
9416
  ].filter(Boolean).join("; ");
8918
- const style = layout4 ? ` style="${layout4}"` : "";
9417
+ const style = layout5 ? ` style="${layout5}"` : "";
8919
9418
  const hinted = Math.floor(Number(hints.span));
8920
9419
  const data = grid && hinted >= 1 ? ` data-span="${Math.min(hinted, cols)}"` : "";
8921
9420
  const cls = `${span > 1 ? " am-span-wide" : ""}${attrs.bare ? " am-panel--bare" : ""}`;
@@ -9018,10 +9517,15 @@ var TEMPLATES = { sheet, doc };
9018
9517
  var block = (selector, vars) => `${selector} {
9019
9518
  ${Object.entries(vars).map(([k, v2]) => ` ${k}: ${v2};`).join("\n")}
9020
9519
  }`;
9021
- function tokenCss(sel, { common = {}, light = {}, dark = {} }) {
9022
- const parts = [block(`${sel}, ${sel}[data-mode="light"]`, { ...common, ...light })];
9520
+ function tokenCss(sel, { common = {}, light = {}, dark = {} }, fixedMode) {
9521
+ const baseScheme = fixedMode === "dark" ? "dark" : "light";
9522
+ const parts = [
9523
+ block(`${sel}, ${sel}[data-mode="light"]`, { "color-scheme": baseScheme, ...common, ...light }),
9524
+ block(`${sel}[data-mode="dark"]`, { "color-scheme": "dark", ...dark }),
9525
+ block(`${sel}[data-mode="auto"]`, { "color-scheme": "light dark" })
9526
+ ];
9023
9527
  if (Object.keys(dark).length) {
9024
- parts.push(block(`${sel}[data-mode="dark"]`, dark), `@media (prefers-color-scheme: dark) {
9528
+ parts.push(`@media (prefers-color-scheme: dark) {
9025
9529
  ${block(`${sel}[data-mode="auto"]`, dark)}
9026
9530
  }`);
9027
9531
  }
@@ -9036,11 +9540,11 @@ function pageCss(list2 = themes("page"), { diff = false, delta = false, rtl = fa
9036
9540
  const decorations = list2.filter((t) => t.css).map((t) => scoped(t.css, pageSel(t)));
9037
9541
  const fontFaces = fonts ? [...new Set(list2.map((t) => t.font).filter((f2) => f2 && FONT_CSS[f2]))].map((f2) => FONT_CSS[f2]) : [];
9038
9542
  const ownFonts = list2.filter((t) => t.ownFont).flatMap(ownLanguageFont);
9039
- return [list2.map((t) => tokenCss(pageSel(t), t.tokens)).join("\n\n"), ...languageFontCss(), ...ownFonts, typeScaleCss(), ...scale === 1 ? [] : [`html { --am-scale: ${scale}; }`], BASE_CSS, ...math2 ? [MATH_CSS] : [], ...chart ? [CHART_CSS] : [], ...table ? [TABLE_CSS] : [], ...diff ? [DIFF_CSS] : [], ...delta ? [DELTA_CSS] : [], ...update2 ? [UPDATE_CSS] : [], ...closeAfter ? [CLOSE_AFTER_CSS] : [], ...rtl ? [RTL_CSS] : [], ...fontFaces, ...decorations].join("\n\n");
9543
+ return [list2.map((t) => tokenCss(pageSel(t), t.tokens, t.mode)).join("\n\n"), ...languageFontCss(), ...ownFonts, typeScaleCss(), ...scale === 1 ? [] : [`html { --am-scale: ${scale}; }`], BASE_CSS, ...math2 ? [MATH_CSS] : [], ...chart ? [CHART_CSS] : [], ...table ? [TABLE_CSS] : [], ...diff ? [DIFF_CSS] : [], ...delta ? [DELTA_CSS] : [], ...update2 ? [UPDATE_CSS] : [], ...closeAfter ? [CLOSE_AFTER_CSS] : [], ...rtl ? [RTL_CSS] : [], ...fontFaces, ...decorations].join("\n\n");
9040
9544
  }
9041
9545
  function videoCss(list2 = themes("video"), { diff = false, delta = false, rtl = false, chart = false } = {}) {
9042
9546
  const parts = list2.filter((t) => t.video).flatMap((t) => [
9043
- t.video.tokens ? tokenCss(videoSel(t), t.video.tokens) : "",
9547
+ t.video.tokens ? tokenCss(videoSel(t), t.video.tokens, t.mode) : "",
9044
9548
  t.video.css ? scoped(t.video.css, videoSel(t)) : "",
9045
9549
  rtl && t.video.rtlCss ? scoped(t.video.rtlCss, videoSel(t)) : ""
9046
9550
  ]).filter(Boolean);
@@ -11900,7 +12404,7 @@ async function writePngSlices(page, htmlFile, folder, onWarn = () => {
11900
12404
  }, inputStat = statSync5(htmlFile)) {
11901
12405
  await page.page("Emulation.setEmulatedMedia", { media: "screen" });
11902
12406
  await settle2(page);
11903
- const layout4 = await page.evaluate(`(async () => {
12407
+ const layout5 = await page.evaluate(`(async () => {
11904
12408
  await document.fonts.ready;
11905
12409
  await new Promise((r) => setTimeout(r, ${SETTLE_MS}));
11906
12410
  await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)));
@@ -11919,16 +12423,16 @@ async function writePngSlices(page, htmlFile, folder, onWarn = () => {
11919
12423
  .map(box),
11920
12424
  };
11921
12425
  })()`);
11922
- if (layout4.empty) throw new ExportError("The page is empty: there is nothing to export");
12426
+ if (layout5.empty) throw new ExportError("The page is empty: there is nothing to export");
11923
12427
  try {
11924
12428
  mkdirSync4(folder, { recursive: true });
11925
12429
  if (!statSync5(folder).isDirectory()) throw new Error("not a folder");
11926
12430
  } catch (e) {
11927
12431
  throw new ExportError(`Cannot use the PNG folder ${folder}: ${e.message}`);
11928
12432
  }
11929
- const cuts = slicePoints(layout4.height, layout4.boxes, MAX_SLICE);
12433
+ const cuts = slicePoints(layout5.height, layout5.boxes, MAX_SLICE);
11930
12434
  const name2 = sliceName(htmlFile);
11931
- const bounds = [0, ...cuts, layout4.height];
12435
+ const bounds = [0, ...cuts, layout5.height];
11932
12436
  const written = [];
11933
12437
  for (let i = 1; i < bounds.length; i++) {
11934
12438
  const top2 = bounds[i - 1];
@@ -12134,7 +12638,7 @@ var CLEAN = Object.freeze({
12134
12638
  hintEveryDays: 7
12135
12639
  // the same notice at most once every 7 days
12136
12640
  });
12137
- var DIRS3 = ["pages", "videos", "cache"];
12641
+ var DIRS4 = ["pages", "videos", "cache"];
12138
12642
  var HOUR = DAY / 24;
12139
12643
  function walk(dir) {
12140
12644
  let entries;
@@ -12157,11 +12661,11 @@ function walk(dir) {
12157
12661
  }
12158
12662
  var sum = (files) => files.reduce((n, f2) => n + f2.bytes, 0);
12159
12663
  function usage2(home) {
12160
- const parts = Object.fromEntries(DIRS3.map((d) => {
12664
+ const parts = Object.fromEntries(DIRS4.map((d) => {
12161
12665
  const files = walk(join11(home, d));
12162
12666
  return [d, { count: files.length, bytes: sum(files) }];
12163
12667
  }));
12164
- return { ...parts, total: DIRS3.reduce((n, d) => n + parts[d].bytes, 0) };
12668
+ return { ...parts, total: DIRS4.reduce((n, d) => n + parts[d].bytes, 0) };
12165
12669
  }
12166
12670
  function clean2(home, { days = CLEAN.days, all = false, dryRun = false, now = Date.now(), temp } = {}) {
12167
12671
  const cutoff = now - days * DAY;
@@ -12998,7 +13502,7 @@ Client -> Server: ACK
12998
13502
  > The client sends ACK, and the connection is open.
12999
13503
 
13000
13504
  - "## " starts a scene; a scene holds components or Markdown (the picture), and lines that start with > are narration (one beat per line).
13001
- - When narration line N plays, step N of the picture appears: in flow / er / sequence / tree each source line is one step;
13505
+ - When narration line N plays, step N of the picture appears: in flow / state / er / sequence / tree each source line is one step;
13002
13506
  timeline, limits, chart rows, table rows, list items and paragraphs step item by item. With more steps than narration lines, the steps are spread across the lines;
13003
13507
  with more narration lines than steps, the extra first lines act as an opening and show nothing new.
13004
13508
  - Write [name] in narration: the camera zooms in on the element with that name and highlights it, and the word turns yellow in the caption.
@@ -13318,7 +13822,7 @@ Pick it like a built-in theme: theme: notes in the draft, --theme notes, or am c
13318
13822
  Keep the file self-contained: no url() or image-set() to http(s) or //, no @import, no @font-face, no backslash escapes. A link would send a request each time a page opens.
13319
13823
  am theme check warns about them; the catalog and am theme add reject them.
13320
13824
  - Diagram tokens (optional): node-fill node-stroke node-width node-radius node-shadow node-text, hi-fill hi-stroke hi-text, edge-color edge-width edge-label, actor-fill actor-stroke actor-text, note-fill note-stroke note-width note-radius, cluster-fill cluster-stroke, lifeline-color, series-1 series-2 series-3 series-4 series-5 series-6 (each with a -- prefix).
13321
- They restyle what is inside flow, sequence and er diagrams and tree boxes, and each defaults to today's look. The series tokens color the bars, lines and slices of a chart: a fixed palette is the default (a light set and a dark set); a series color below 3:1 against --paper in light or dark gives a warning. Widths and radii are a number or px / em (a bare number is px);
13825
+ They restyle what is inside flow, state, sequence and er diagrams and tree boxes, and each defaults to today's look. The series tokens color the bars, lines and slices of a chart: a fixed palette is the default (a light set and a dark set); a series color below 3:1 against --paper in light or dark gives a warning. Widths and radii are a number or px / em (a bare number is px);
13322
13826
  --node-shadow is none or drop-shadow(...), like drop-shadow(3px 3px 0 #111). Do not write diagram selectors in css. There is no token for fonts: diagram text is measured for the sans font.
13323
13827
  - video (optional): video-only variables (--v-stage, --v-title-font, --v-cap-fg, --v-cap-bg, --v-glow) and & css for am video.
13324
13828
  - A page carries the built-in themes plus every installed user theme, so the toolbar can switch to any of them and the page opens anywhere; readers without your fonts see the fallback.