diff --git a/.agent/skills/basalt-html/parts/diagram.css b/.agent/skills/basalt-html/parts/diagram.css
index 9cecd344..99d58fdc 100644
--- a/.agent/skills/basalt-html/parts/diagram.css
+++ b/.agent/skills/basalt-html/parts/diagram.css
@@ -1 +1 @@
-:root{--basalt-size-diagram-node: 144px;--basalt-size-diagram-table: 224px;--basalt-size-diagram-lane: 120px;--basalt-size-diagram-step: 56px;--basalt-size-diagram-head: 8px;--basalt-size-diagram-guide-dash: 4px;--basalt-size-diagram-bead: 24px;--basalt-size-diagram-flow: 12px}:root,[data-theme=light],.light{--basalt-diagram-edge-main: var(--basalt-text-primary);--basalt-diagram-edge: var(--basalt-text-secondary);--basalt-diagram-edge-dim: var(--basalt-border-input);--basalt-diagram-structure: var(--basalt-border-input);--basalt-diagram-focal: var(--basalt-action-primary);--basalt-diagram-focal-ink: var(--basalt-action-primary-text);--basalt-diagram-focal-rule: var(--basalt-white-6);--basalt-diagram-focal-rule-contrast: var(--basalt-white-38);--basalt-diagram-hit: var(--basalt-text-secondary);--basalt-diagram-focal-hit: var(--basalt-action-primary-hover)}[data-theme=dark],.dark{--basalt-diagram-edge-main: var(--basalt-text-primary);--basalt-diagram-edge: var(--basalt-text-secondary);--basalt-diagram-edge-dim: var(--basalt-border-input);--basalt-diagram-structure: var(--basalt-border-input);--basalt-diagram-focal: var(--basalt-action-primary);--basalt-diagram-focal-ink: var(--basalt-action-primary-text);--basalt-diagram-focal-rule: var(--basalt-black-8);--basalt-diagram-focal-rule-contrast: var(--basalt-black-45);--basalt-diagram-hit: var(--basalt-text-secondary);--basalt-diagram-focal-hit: var(--basalt-action-primary-hover)}@media(prefers-color-scheme:dark){:root:not([data-theme=light]):not(.light){--basalt-diagram-focal-rule: var(--basalt-black-8);--basalt-diagram-focal-rule-contrast: var(--basalt-black-45)}}@media(prefers-contrast:more){:root,[data-theme=light],[data-theme=dark],.light,.dark,:root:not([data-theme=light]):not(.light){--basalt-diagram-focal-rule: var(--basalt-diagram-focal-rule-contrast);--basalt-diagram-hit: var(--basalt-text-primary)}}@layer basalt{.diagram{--_ground: var(--panel-bg, var(--basalt-surface-page));container-type:inline-size;display:flex;flex-direction:column;gap:var(--basalt-space-4);width:100%;min-width:0;margin:0;font-family:var(--basalt-font-family-sans)}.diagram[hidden]{display:none}.diagram-head{display:flex;flex-direction:column;gap:var(--basalt-space-0-5);min-width:0}.diagram-title{margin:0;color:var(--basalt-text-primary);font:var(--basalt-font-weight-semibold) var(--bh-md);letter-spacing:var(--basalt-text-md-tracking)}.diagram-source{margin:0;color:var(--basalt-text-tertiary);font:var(--basalt-font-weight-regular) var(--bh-xs)}.diagram-drawing{--_D: initial;--_Display: var(--_D) grid;--_Max: var(--_D) none;--_Cols: var(--_D) repeat(var(--_cols, 1), minmax(0, 1fr));--_Gap: var(--_D) var(--_row-gap) var(--_col-gap);--_Pad: var(--_D) var(--_gpad, 0);--_row-gap: var(--basalt-space-12);--_col-gap: var(--basalt-space-16);position:relative;box-sizing:border-box;display:var(--_Display, flex);flex-direction:column;grid-template-columns:var(--_Cols, none);gap:var(--_Gap, 0);width:100%;max-width:var(--_Max, var(--basalt-size-breakpoint-container));min-width:0;padding:var(--_Pad, 0 var(--_gutter, 0) 0 0)}.diagram[data-layout=drawn]>.diagram-drawing{--_D: }.diagram[data-layout=stacked]>.diagram-drawing{--_D: initial}.diagram[data-gutter]>.diagram-drawing{--_gutter: var(--basalt-space-10)}.diagram[data-type=data-flow]>.diagram-drawing{--_Cols: var(--_D) var(--basalt-size-diagram-lane) repeat(var(--_cols, 1), minmax(0, 1fr));--_row-gap: var(--basalt-space-10);--_col-gap: var(--basalt-space-12)}.diagram[data-type=schema]>.diagram-drawing{--_row-gap: var(--basalt-space-8);--_col-gap: var(--basalt-space-12);display:grid;grid-template-columns:var(--_Cols, repeat(auto-fit, minmax(min(100%, var(--_track, var(--basalt-size-diagram-table))), 1fr)));gap:var(--_Gap, var(--basalt-space-4));align-items:start;max-width:none}.diagram[data-type=sequence]>.diagram-drawing{display:flex;gap:0}.diagram-node{--_Gc: var(--_D) var(--_c);--_Gr: var(--_D) var(--_r) / var(--_r2);--_Mt: var(--_D) 0;--_Align: var(--_D) center;position:relative;z-index:1;box-sizing:border-box;display:flex;flex-direction:column;min-width:0;grid-column:var(--_Gc, auto);grid-row:var(--_Gr, auto);align-self:var(--_Align, stretch);margin-block-start:var(--_Mt, var(--_gap, 0));padding:var(--basalt-space-2-5) var(--basalt-space-3);background:var(--panel-next, var(--basalt-surface-1));border:var(--basalt-size-hairline) solid var(--basalt-border-rim);border-top-color:var(--basalt-border-rim-top);border-radius:var(--basalt-radius-md);color:var(--basalt-text-primary);overflow-wrap:break-word;outline:none;transition:border-color var(--basalt-duration-fast) var(--basalt-ease-out)}.diagram[data-type=data-flow] .diagram-node{--_Gc: var(--_D) var(--_lc)}.diagram-node[data-branch]{--_Mi: var(--_D) 0;margin-inline:var(--_Mi, var(--basalt-space-12) var(--basalt-space-6))}.diagram-node:focus-visible{z-index:2;outline:var(--basalt-size-focus-width) solid var(--basalt-border-focus);outline-offset:var(--basalt-size-focus-offset)}.diagram-node[data-near]{border-color:var(--basalt-border-hover)}.diagram-kind{color:var(--basalt-text-tertiary);font:var(--basalt-font-weight-regular) var(--bh-xs-mono)}.diagram-lane-word{--_Lw: var(--_D) none;display:var(--_Lw, inline)}.diagram-name{color:var(--basalt-text-primary);font:var(--basalt-font-weight-semibold) var(--bh-sm)}.diagram-detail{margin-block-start:var(--basalt-space-0-5);color:var(--basalt-text-secondary);font:var(--basalt-font-weight-regular) var(--bh-xs)}.diagram-detail[data-mono]{font-family:var(--basalt-font-family-mono)}.diagram-run{display:inline-block;max-width:100%}:root,[data-theme=light],.light{--_dkm: initial}[data-theme=dark],.dark{--_dkm: }@media(prefers-color-scheme:dark){:root:not([data-theme=light]):not(.light){--_dkm: }}.diagram-mark{--_mf: var(--_dkm) var(--_md);position:absolute;inset-block-start:var(--basalt-space-2-5);inset-inline-end:var(--basalt-space-3);width:var(--basalt-size-icon-sm);height:var(--basalt-size-icon-sm);background:var(--_mf, var(--_ml)) center / contain no-repeat;pointer-events:none}.diagram-node[data-focal]>.diagram-mark{--_mf: var(--_dkm) var(--_ml);background-image:var(--_mf, var(--_md, var(--_ml)))}.diagram-node[data-mark]>.diagram-mark+:is(.diagram-kind,.diagram-name){padding-inline-end:var(--basalt-space-6)}.diagram-node[data-focal]{background:var(--basalt-diagram-focal);border-color:var(--basalt-diagram-focal)}.diagram-node[data-focal] :is(.diagram-name,.diagram-kind,.diagram-detail,.diagram-tname,.diagram-cname,.diagram-keyseat,.diagram-ctype,.diagram-more){color:var(--basalt-diagram-focal-ink)}.diagram-node[data-focal] :is(.diagram-kind,.diagram-detail,.diagram-keyseat,.diagram-ctype,.diagram-more){opacity:var(--basalt-opacity-amount)}.diagram[data-type=flowchart] .diagram-node:not([data-focal]){border-color:var(--basalt-diagram-structure)}.diagram[data-type=flowchart] .diagram-node:not([data-focal],[data-shape=decision])[data-near]{border-color:var(--basalt-text-secondary)}.diagram-node[data-shape=terminal]{align-items:center;padding-inline:var(--basalt-space-5);border-radius:var(--basalt-radius-full);text-align:center}.diagram-node[data-shape=decision]{justify-content:center;align-items:center;height:var(--_h, auto);min-height:var(--basalt-space-16);padding:var(--basalt-space-2) var(--basalt-space-2-5);text-align:center}.diagram-words{position:relative;max-width:calc(62% + (var(--basalt-space-2-5) + var(--basalt-size-hairline)) * 1.24)}.diagram-node[data-shape=decision] .diagram-name{font-weight:var(--basalt-font-weight-medium);text-wrap:balance}.diagram-diamond{display:none;position:absolute;inset:0;width:100%;height:100%;overflow:visible}.diagram-diamond path{fill:var(--panel-next, var(--basalt-surface-1));stroke:var(--basalt-diagram-structure);stroke-width:var(--basalt-size-hairline);vector-effect:non-scaling-stroke;transition:stroke var(--basalt-duration-fast) var(--basalt-ease-out)}.diagram[data-measured] .diagram-node[data-shape=decision]{background:none;border-color:transparent}.diagram[data-measured] .diagram-node[data-shape=decision] .diagram-diamond{display:block}.diagram-node[data-shape=decision][data-near] .diagram-diamond path{stroke:var(--basalt-text-secondary)}.diagram-node[data-shape=decision][data-focal] .diagram-diamond path{fill:var(--basalt-diagram-focal);stroke:var(--basalt-diagram-focal)}.diagram-group{--_Gd: var(--_D) contents;position:relative;box-sizing:border-box;display:var(--_Gd, flex);flex-direction:column;margin-block-start:calc(var(--basalt-space-12) + var(--basalt-space-4) * var(--_ggrow, 0));padding:var(--basalt-space-8) var(--basalt-space-3) var(--basalt-space-3-5);border:var(--basalt-size-hairline) dashed var(--basalt-diagram-structure);border-radius:var(--basalt-radius-lg)}.diagram-group:first-child{margin-block-start:0}.diagram-group>.diagram-glabel+.diagram-node{--_Mt: 0}.diagram-glabel{position:absolute;top:var(--basalt-space-2);inset-inline-start:var(--basalt-space-3);color:var(--basalt-text-secondary);font:var(--basalt-font-weight-regular) var(--bh-xs-mono);white-space:nowrap}.diagram-group>.diagram-glabel{--_Gl: var(--_D) none;display:var(--_Gl, block)}.diagram-gbox{--_Gb: var(--_D) block;position:relative;display:var(--_Gb, none);grid-column:var(--_c) / var(--_c2);grid-row:var(--_r) / var(--_r2);margin:calc(-1 * var(--basalt-space-8)) calc(-1 * var(--basalt-space-4)) calc(-1 * var(--basalt-space-4));border:var(--basalt-size-hairline) dashed var(--basalt-diagram-structure);border-radius:var(--basalt-radius-lg);pointer-events:none}.diagram-lane{--_Ln: var(--_D) flex;position:relative;display:var(--_Ln, none);grid-column:1 / -1;grid-row:var(--_r);align-items:center;pointer-events:none}.diagram-lane+.diagram-lane:before{content:"";position:absolute;inset-inline:0;top:calc(-1 * var(--basalt-space-5));border-top:var(--basalt-size-hairline) solid var(--basalt-border-divider)}.diagram-lane-name{box-sizing:border-box;width:var(--basalt-size-diagram-lane);padding-inline-end:var(--basalt-space-3);color:var(--basalt-text-secondary);font:var(--basalt-font-weight-medium) var(--bh-xs)}.diagram-ink{position:absolute;inset:0;z-index:0;pointer-events:none}.diagram-svg{position:absolute;top:0;left:0;overflow:visible}.diagram-ruler{position:absolute;visibility:hidden;white-space:pre;pointer-events:none}.diagram-ruler[data-f=name]{font:var(--basalt-font-weight-semibold) var(--bh-sm)}.diagram-ruler[data-f=name-500]{font:var(--basalt-font-weight-medium) var(--bh-sm)}.diagram-ruler[data-f=table]{font:var(--basalt-font-weight-semibold) var(--basalt-text-sm-size) / var(--basalt-text-sm-line-height) var(--basalt-font-family-mono)}.diagram-ruler:is([data-f=mono],[data-f=label]){font:var(--basalt-font-weight-regular) var(--bh-xs-mono)}.diagram-ruler[data-f=sans]{font:var(--basalt-font-weight-regular) var(--bh-xs)}.diagram-line{fill:none;stroke:var(--basalt-diagram-edge);stroke-width:var(--basalt-size-hairline);transition:stroke var(--basalt-duration-fast) var(--basalt-ease-out)}.diagram-line[data-kind=main]{stroke:var(--basalt-diagram-edge-main);stroke-width:var(--basalt-size-chart-line)}.diagram-line[data-kind=dashed]{stroke-dasharray:var(--basalt-size-chart-dash) var(--basalt-size-chart-dash-gap);stroke-linecap:butt}.diagram-tip{fill:var(--basalt-diagram-edge);transition:fill var(--basalt-duration-fast) var(--basalt-ease-out),stroke var(--basalt-duration-fast) var(--basalt-ease-out)}.diagram-tip[data-kind=main]{fill:var(--basalt-diagram-edge-main)}.diagram-tip[data-open]{fill:none;stroke:var(--basalt-diagram-edge);stroke-width:var(--basalt-size-hairline);stroke-linecap:round;stroke-linejoin:round}.diagram-dot{fill:var(--basalt-diagram-edge)}.diagram-life{fill:none;stroke:var(--basalt-diagram-structure);stroke-width:var(--basalt-size-hairline);stroke-dasharray:var(--basalt-size-diagram-guide-dash) var(--basalt-size-diagram-guide-dash)}.diagram-edge[data-lit] .diagram-line{stroke:var(--basalt-diagram-edge-main)}.diagram-edge[data-lit] .diagram-tip:not([data-open]),.diagram-edge[data-lit] .diagram-dot{fill:var(--basalt-diagram-edge-main)}.diagram-edge[data-lit] .diagram-tip[data-open]{stroke:var(--basalt-diagram-edge-main)}.diagram-edge[data-dim] .diagram-line{stroke:var(--basalt-diagram-edge-dim)}.diagram-edge[data-dim] .diagram-tip:not([data-open]),.diagram-edge[data-dim] .diagram-dot{fill:var(--basalt-diagram-edge-dim)}.diagram-edge[data-dim] .diagram-tip[data-open]{stroke:var(--basalt-diagram-edge-dim)}.diagram-label{position:absolute;box-sizing:border-box;height:var(--basalt-text-xs-line-height);color:var(--basalt-diagram-edge);font:var(--basalt-font-weight-regular) var(--bh-xs-mono);text-align:center;white-space:nowrap;transition:color var(--basalt-duration-fast) var(--basalt-ease-out)}.diagram-label[data-on]{background:var(--_ground)}.diagram-label[data-lit]{color:var(--basalt-diagram-edge-main)}.diagram-cast{--_Cd: var(--_D) grid;display:var(--_Cd, flex);flex-wrap:wrap;grid-template-columns:repeat(var(--_cols, 1),minmax(0,1fr));gap:var(--_Cast-gap, var(--basalt-space-1-5));--_Cast-gap: var(--_D) var(--basalt-space-5);margin:0;padding:0;list-style:none}.diagram-actor{display:flex;min-width:0}.diagram-node[data-shape=participant]{--_Pd: var(--_D) var(--basalt-space-2-5) var(--basalt-space-3);--_Pr: var(--_D) var(--basalt-radius-md);--_Pa: var(--_D) center;flex:var(--_Pflex, none);--_Pflex: var(--_D) 1;align-items:center;justify-content:var(--_Pa, center);min-height:var(--_Ph, var(--basalt-size-badge));--_Ph: var(--_D) 0;padding:var(--_Pd, 0 calc(var(--basalt-space-2) - var(--basalt-size-hairline)));border-radius:var(--_Pr, var(--basalt-radius-xs));text-align:center}.diagram-node[data-shape=participant]:not([data-focal]){--_Pbg: var(--_D) var(--panel-next, var(--basalt-surface-1));--_Pbc: var(--_D) var(--basalt-border-rim);--_Pbt: var(--_D) var(--basalt-border-rim-top);background:var(--_Pbg, none);border-color:var(--_Pbc, var(--basalt-border-hairline));border-top-color:var(--_Pbt, var(--basalt-border-hairline))}.diagram-node[data-shape=participant] .diagram-kind{--_Pk: var(--_D) block;display:var(--_Pk, none)}.diagram-node[data-shape=participant] .diagram-name{font-size:var(--_Pn, var(--basalt-text-xs-size));line-height:var(--_Pnl, var(--basalt-text-xs-line-height));font-weight:var(--_Pw, var(--basalt-font-weight-medium));--_Pn: var(--_D) var(--basalt-text-sm-size);--_Pnl: var(--_D) var(--basalt-text-sm-line-height);--_Pw: var(--_D) var(--basalt-font-weight-semibold)}.diagram-steps{--_Sp: var(--_D) var(--basalt-space-4);position:relative;z-index:1;padding-block-start:var(--_Sp, var(--basalt-space-4))}.diagram-msgs{margin:0;padding:0;list-style:none}.diagram-msg{--_Md: var(--_D) grid;--_Mc: var(--_D) repeat(var(--_cols, 1), minmax(0, 1fr));--_Mr: var(--_D) 1fr 1fr;--_Mh: var(--_D) var(--basalt-size-diagram-step);--_Mg: var(--_D) 0 var(--basalt-space-5);display:grid;grid-template-columns:var(--_Mc, var(--basalt-space-8) minmax(0, 1fr));grid-template-rows:var(--_Mr, auto);column-gap:var(--basalt-space-5);gap:var(--_Mg, 0);height:var(--_Mh, auto);padding-block:var(--_Mpb, var(--basalt-space-2-5));--_Mpb: var(--_D) 0;border-top:var(--_Mb, var(--basalt-size-hairline) solid var(--basalt-border-divider));--_Mb: var(--_D) 0;font:var(--basalt-font-weight-regular) var(--bh-xs)}.diagram-said{--_Sd: var(--_D) block;display:var(--_Sd, contents);grid-column:var(--_a) / var(--_b);grid-row:1;align-self:end;justify-self:center;margin-block-end:calc(var(--basalt-space-1) + var(--basalt-size-hairline));padding-inline:var(--basalt-space-1-5);background:var(--_ground);white-space:nowrap}.diagram-num{grid-column:1;color:var(--basalt-text-tertiary);font-variant-numeric:tabular-nums}.diagram-said .diagram-num{margin-inline-end:var(--_Nm, 0);--_Nm: var(--_D) var(--basalt-space-1-5)}.diagram-mlabel{grid-column:2;color:var(--basalt-text-primary);font-family:var(--basalt-font-family-mono)}.diagram-route{--_Rd: var(--_D) none;display:var(--_Rd, inline-flex);grid-column:2;align-items:center;gap:var(--basalt-space-1);flex-wrap:wrap;color:var(--basalt-text-secondary)}.diagram-note{--_Nd: var(--_D) 2;grid-column:var(--_Nc, 2);--_Nc: var(--_D) var(--_a) / var(--_b);grid-row:var(--_Nd, auto);align-self:start;justify-self:var(--_Nj, stretch);--_Nj: var(--_D) center;margin-block-start:var(--_Nmt, 0);--_Nmt: var(--_D) calc(var(--basalt-space-1) + var(--basalt-size-hairline));padding-inline:var(--_Npi, 0);--_Npi: var(--_D) var(--basalt-space-1-5);background:var(--_Nbg, none);--_Nbg: var(--_D) var(--_ground);color:var(--basalt-text-tertiary);white-space:var(--_Nws, normal);--_Nws: var(--_D) nowrap}.diagram-msg[data-self=end] :is(.diagram-said,.diagram-note){--_Sj: var(--_D) start;justify-self:var(--_Sj, stretch);--_Sm: var(--_D) calc(50% + var(--basalt-space-6) + var(--basalt-space-1));margin-inline-start:var(--_Sm, 0)}.diagram-msg[data-self=start] :is(.diagram-said,.diagram-note){--_Sj: var(--_D) end;justify-self:var(--_Sj, stretch);--_Sm: var(--_D) calc(50% + var(--basalt-space-6) + var(--basalt-space-1));margin-inline-end:var(--_Sm, 0)}.diagram-arrow{flex:none;overflow:visible}.diagram-band{--_Bh: var(--_D) var(--basalt-size-control-lg);--_Bj: var(--_D) center;position:relative;display:flex;align-items:center;justify-content:var(--_Bj, flex-start);height:var(--_Bh, auto);margin:var(--_Bm, var(--basalt-space-5) 0 var(--basalt-space-2));--_Bm: var(--_D) 0;color:var(--basalt-text-secondary);font:var(--basalt-font-weight-medium) var(--bh-xs)}.diagram-band:before{--_Br: var(--_D) "";content:var(--_Br, none);position:absolute;inset-inline:0;top:50%;border-top:var(--basalt-size-hairline) solid var(--basalt-border-divider)}.diagram-band>span{position:relative;padding-inline:var(--_Bp, 0);--_Bp: var(--_D) var(--basalt-space-1-5);background:var(--_ground)}.diagram-node[data-shape=table]{align-self:start;padding:0;overflow-wrap:normal}.diagram-th{padding:var(--basalt-space-2) var(--basalt-space-3);border-bottom:var(--basalt-size-hairline) solid var(--basalt-border-divider)}.diagram-node[data-focal] .diagram-th{border-bottom-color:var(--basalt-diagram-focal-rule)}.diagram-tname{color:var(--basalt-text-primary);font:var(--basalt-font-weight-semibold) var(--basalt-text-sm-size) / var(--basalt-text-sm-line-height) var(--basalt-font-family-mono)}.diagram-rows{display:flex;flex-direction:column;padding-block:var(--basalt-space-1)}.diagram-row{display:flex;flex-wrap:wrap;align-items:center;column-gap:var(--basalt-space-3);min-height:var(--basalt-size-control-sm);padding-inline:var(--basalt-space-3);font:var(--basalt-font-weight-regular) var(--bh-xs-mono)}.diagram-keyseat{flex:none;width:var(--basalt-space-6);margin-inline-end:calc(-1 * var(--basalt-space-3));color:var(--basalt-text-tertiary)}.diagram-cname{flex:1 0 auto;color:var(--basalt-text-primary)}.diagram-ctype{margin-inline-start:auto;color:var(--basalt-text-tertiary)}.diagram-ctype[data-ref]{color:var(--basalt-text-secondary)}.diagram-more{padding:0 var(--basalt-space-3) var(--basalt-space-2);color:var(--basalt-text-tertiary);font:var(--basalt-font-weight-regular) var(--bh-xs)}.diagram-key{padding-block-start:var(--basalt-space-3);border-top:var(--basalt-size-hairline) solid var(--basalt-border-divider)}.diagram-legend{display:flex;flex-wrap:wrap;gap:var(--basalt-space-2) var(--basalt-space-5);margin:0;padding:0;list-style:none;color:var(--basalt-text-secondary);font:var(--basalt-font-weight-regular) var(--bh-xs)}.diagram-entry{display:inline-flex;align-items:center;gap:var(--basalt-space-1-5)}.diagram[data-layout=drawn] .diagram-entry[data-when=stacked],.diagram[data-layout=stacked] .diagram-entry[data-when=drawn],.diagram:not([data-layout]) .diagram-entry[data-when=drawn]{display:none}.diagram-swatch{flex:none;overflow:visible}.diagram-swatch-shape{fill:var(--_ground);stroke:var(--basalt-diagram-structure);stroke-width:var(--basalt-size-hairline)}.diagram-swatch[data-shape=focal] .diagram-swatch-shape{fill:var(--basalt-diagram-focal);stroke:var(--basalt-diagram-focal)}.diagram-swatch[data-shape=group] .diagram-swatch-shape{fill:none;stroke-dasharray:var(--basalt-space-1) var(--basalt-space-0-5)}.diagram-fk-mark{color:var(--basalt-text-secondary);font-family:var(--basalt-font-family-mono)}.diagram-key-letters{color:var(--basalt-text-tertiary);font:var(--basalt-font-weight-regular) var(--bh-xs-mono)}.diagram-hint{display:flex;flex-wrap:wrap;gap:var(--basalt-space-1) var(--basalt-space-4);margin:0;color:var(--basalt-text-tertiary);font:var(--basalt-font-weight-regular) var(--bh-xs)}.diagram-hint>span{display:inline-flex;align-items:center;gap:var(--basalt-space-1)}.diagram[data-layout=stacked]:is([data-type=sequence],[data-type=schema]) .diagram-hint{display:none}.diagram[data-bare] :is(.diagram-entry[data-line],.diagram-hint){display:none}.diagram-summary{order:1;max-width:var(--basalt-size-prose-width);color:var(--basalt-text-secondary);font:var(--basalt-font-weight-regular) var(--bh-sm);text-wrap:pretty}.diagram-foot{order:2;display:flex;flex-wrap:wrap;gap:var(--basalt-space-2)}.diagram-list{order:3;max-width:var(--basalt-size-prose-width);color:var(--basalt-text-secondary);font:var(--basalt-font-weight-regular) var(--bh-sm)}.diagram-list[hidden]{display:none}.diagram-list strong{color:var(--basalt-text-primary);font-weight:var(--basalt-font-weight-semibold)}.diagram-code{padding:0;border-radius:0;background:none;color:var(--basalt-text-primary);font:var(--basalt-font-weight-regular) var(--basalt-text-xs-size) / var(--basalt-text-sm-line-height) var(--basalt-font-family-mono)}.diagram-list-head{margin:var(--basalt-space-4) 0 var(--basalt-space-2);color:var(--basalt-text-primary);font:var(--basalt-font-weight-semibold) var(--bh-sm)}.diagram-list-head:first-child{margin-block-start:0}.diagram-list-group{margin:var(--basalt-space-3) 0 var(--basalt-space-1);color:var(--basalt-text-primary);font-size:inherit;font-weight:var(--basalt-font-weight-medium);line-height:inherit}.diagram-list-items{display:flex;flex-direction:column;gap:var(--basalt-space-1);margin:0;padding-inline-start:var(--basalt-space-5)}.diagram-list-exits{margin:var(--basalt-space-1) 0 0;padding-inline-start:var(--basalt-space-5)}@media(pointer:coarse){.diagram-toggle{min-height:var(--basalt-size-tap-min)}}@media(prefers-reduced-motion:reduce){.diagram-node,.diagram-line,.diagram-tip,.diagram-label,.diagram-diamond path{transition:none}}@media(prefers-contrast:more){.diagram-node[data-focal] :is(.diagram-kind,.diagram-detail,.diagram-keyseat,.diagram-ctype,.diagram-more){opacity:1}}@container (width >= 640px){.diagram:not([data-layout]):is(:is([data-type=architecture],[data-type=flowchart]):is([data-cols="1"],[data-cols="2"],[data-cols="3"]),:is([data-type=data-flow],[data-type=schema]):is([data-cols="1"],[data-cols="2"]),[data-type=sequence]:is([data-cols="1"],[data-cols="2"],[data-cols="3"],[data-cols="4"]))>.diagram-drawing{--_D: }}@container (width >= 696px){.diagram:not([data-layout])[data-type=data-flow][data-cols="3"]>.diagram-drawing{--_D: }}@container (width >= 768px){.diagram:not([data-layout]):is([data-type=architecture][data-cols="4"][data-reach="0"],[data-type=flowchart][data-cols="4"],[data-type=schema][data-cols="3"])>.diagram-drawing{--_D: }}@container (width >= 784px){.diagram:not([data-layout])[data-type=architecture][data-cols="4"][data-reach="1"]>.diagram-drawing{--_D: }}@container (width >= 800px){.diagram:not([data-layout]):is([data-type=architecture][data-cols="4"][data-reach="2"],[data-type=sequence][data-cols="5"])>.diagram-drawing{--_D: }}@container (width >= 888px){.diagram:not([data-layout])[data-type=data-flow][data-cols="4"]>.diagram-drawing{--_D: }}@container (width >= 964px){.diagram:not([data-layout])[data-type=sequence][data-cols="6"]>.diagram-drawing{--_D: }}@container (width >= 976px){.diagram:not([data-layout]):is([data-type=architecture][data-cols="5"][data-reach="0"],[data-type=flowchart][data-cols="5"])>.diagram-drawing{--_D: }}@container (width >= 992px){.diagram:not([data-layout])[data-type=architecture][data-cols="5"][data-reach="1"]>.diagram-drawing{--_D: }}@container (width >= 1008px){.diagram:not([data-layout])[data-type=architecture][data-cols="5"][data-reach="2"]>.diagram-drawing{--_D: }}@container (width >= 1040px){.diagram:not([data-layout])[data-type=schema][data-cols="4"]>.diagram-drawing{--_D: }}@container (width >= 1080px){.diagram:not([data-layout])[data-type=data-flow][data-cols="5"]>.diagram-drawing{--_D: }}@container (width >= 1184px){.diagram:not([data-layout]):is([data-type=architecture][data-cols="6"][data-reach="0"],[data-type=flowchart][data-cols="6"])>.diagram-drawing{--_D: }}@container (width >= 1200px){.diagram:not([data-layout])[data-type=architecture][data-cols="6"][data-reach="1"]>.diagram-drawing{--_D: }}@container (width >= 1216px){.diagram:not([data-layout])[data-type=architecture][data-cols="6"][data-reach="2"]>.diagram-drawing{--_D: }}@container (width >= 1272px){.diagram:not([data-layout])[data-type=data-flow][data-cols="6"]>.diagram-drawing{--_D: }}@container (width >= 1312px){.diagram:not([data-layout])[data-type=schema][data-cols="5"]>.diagram-drawing{--_D: }}@container (width >= 1584px){.diagram:not([data-layout])[data-type=schema][data-cols="6"]>.diagram-drawing{--_D: }}@media(scripting:none){.diagram:not(#basalt-diagram-no-id)>.diagram-drawing{--_D: initial}.diagram-list[hidden]{display:block!important}.diagram-foot,.diagram-entry[data-line],.diagram-hint{display:none}}@media(forced-colors:active){.diagram-svg,.diagram-swatch,.diagram-arrow{forced-color-adjust:none}.diagram .diagram-line,.diagram .diagram-line[data-kind]{stroke:CanvasText}.diagram .diagram-tip,.diagram .diagram-tip[data-kind],.diagram .diagram-dot{fill:CanvasText}.diagram .diagram-tip[data-open],.diagram .diagram-tip[data-kind][data-open]{fill:none;stroke:CanvasText}.diagram .diagram-edge[data-dim] .diagram-line{stroke:GrayText}.diagram .diagram-edge[data-dim] :is(.diagram-tip:not([data-open]),.diagram-dot){fill:GrayText}.diagram .diagram-edge[data-dim] .diagram-tip[data-open]{stroke:GrayText}.diagram .diagram-edge[data-lit] .diagram-line{stroke:Highlight}.diagram .diagram-edge[data-lit] :is(.diagram-tip:not([data-open]),.diagram-dot){fill:Highlight}.diagram .diagram-edge[data-lit] .diagram-tip[data-open]{stroke:Highlight}.diagram .diagram-life{stroke:GrayText}.diagram .diagram-label{color:CanvasText;forced-color-adjust:none}.diagram .diagram-label[data-on]{background:Canvas}.diagram .diagram-label[data-lit]{color:Highlight}.diagram .diagram-swatch-shape{fill:Canvas;stroke:CanvasText}.diagram .diagram-swatch[data-shape=group] .diagram-swatch-shape{fill:none;stroke:GrayText}.diagram .diagram-swatch[data-shape=focal] .diagram-swatch-shape{fill:CanvasText;stroke:CanvasText}.diagram[data-type=flowchart] .diagram-node:not([data-focal]),.diagram[data-type=flowchart] .diagram-node:not([data-focal])[data-near]{border-color:CanvasText}.diagram[data-measured][data-type=flowchart] .diagram-node[data-shape=decision][data-shape]{forced-color-adjust:none;background:none;border-color:transparent}.diagram .diagram-diamond{forced-color-adjust:none}.diagram .diagram-diamond path,.diagram .diagram-node[data-near] .diagram-diamond path{fill:Canvas;stroke:CanvasText}.diagram .diagram-group,.diagram .diagram-gbox{border-color:GrayText}.diagram .diagram-lane+.diagram-lane:before,.diagram .diagram-band:before{border-color:GrayText}.diagram .diagram-hint{color:GrayText}.diagram :is(.diagram-kind,.diagram-name,.diagram-detail,.diagram-glabel,.diagram-lane-name,.diagram-title,.diagram-source,.diagram-num,.diagram-mlabel,.diagram-route,.diagram-note,.diagram-band,.diagram-tname,.diagram-cname,.diagram-keyseat,.diagram-ctype,.diagram-more,.diagram-legend,.diagram-fk-mark,.diagram-key-letters){color:CanvasText}.diagram .diagram-node:focus-visible{outline-color:Highlight}.diagram .diagram-node[data-focal],.diagram .diagram-node[data-focal][data-near]{forced-color-adjust:none;background:CanvasText;border-color:CanvasText}.diagram .diagram-node[data-focal] :is(.diagram-name,.diagram-kind,.diagram-detail,.diagram-tname,.diagram-cname,.diagram-keyseat,.diagram-ctype,.diagram-more){color:Canvas;opacity:1}.diagram .diagram-node[data-focal] .diagram-th{border-bottom-color:Canvas}.diagram .diagram-node[data-focal]:focus-visible{outline:var(--basalt-size-focus-width) solid Highlight}.diagram .diagram-node[data-focal][data-shape=decision] .diagram-diamond path{fill:CanvasText;stroke:CanvasText}.diagram .diagram-mark{display:none}.diagram .diagram-node[data-mark]>.diagram-mark+:is(.diagram-kind,.diagram-name){padding-inline-end:0}}@media print{.diagram-svg,.diagram-swatch,.diagram-arrow,.diagram-mark,.diagram-node[data-focal]{-webkit-print-color-adjust:exact;print-color-adjust:exact}.diagram-hint{display:none}}}
+:root{--basalt-size-diagram-node: 144px;--basalt-size-diagram-table: 224px;--basalt-size-diagram-lane: 120px;--basalt-size-diagram-step: 56px;--basalt-size-diagram-head: 8px;--basalt-size-diagram-guide-dash: 4px;--basalt-size-diagram-bead: 24px;--basalt-size-diagram-flow: 12px}:root,[data-theme=light],.light{--basalt-diagram-edge-main: var(--basalt-text-primary);--basalt-diagram-edge: var(--basalt-text-secondary);--basalt-diagram-edge-dim: var(--basalt-border-input);--basalt-diagram-structure: var(--basalt-border-input);--basalt-diagram-focal: var(--basalt-action-primary);--basalt-diagram-focal-ink: var(--basalt-action-primary-text);--basalt-diagram-focal-rule: var(--basalt-white-6);--basalt-diagram-focal-rule-contrast: var(--basalt-white-38);--basalt-diagram-hit: var(--basalt-text-secondary);--basalt-diagram-focal-hit: var(--basalt-action-primary-hover)}[data-theme=dark],.dark{--basalt-diagram-edge-main: var(--basalt-text-primary);--basalt-diagram-edge: var(--basalt-text-secondary);--basalt-diagram-edge-dim: var(--basalt-border-input);--basalt-diagram-structure: var(--basalt-border-input);--basalt-diagram-focal: var(--basalt-action-primary);--basalt-diagram-focal-ink: var(--basalt-action-primary-text);--basalt-diagram-focal-rule: var(--basalt-black-8);--basalt-diagram-focal-rule-contrast: var(--basalt-black-45);--basalt-diagram-hit: var(--basalt-text-secondary);--basalt-diagram-focal-hit: var(--basalt-action-primary-hover)}@media(prefers-color-scheme:dark){:root:not([data-theme=light]):not(.light){--basalt-diagram-focal-rule: var(--basalt-black-8);--basalt-diagram-focal-rule-contrast: var(--basalt-black-45)}}@media(prefers-contrast:more){:root,[data-theme=light],[data-theme=dark],.light,.dark,:root:not([data-theme=light]):not(.light){--basalt-diagram-focal-rule: var(--basalt-diagram-focal-rule-contrast);--basalt-diagram-hit: var(--basalt-text-primary)}}@layer basalt{.diagram{--_ground: var(--panel-bg, var(--basalt-surface-page));container-type:inline-size;display:flex;flex-direction:column;gap:var(--basalt-space-4);width:100%;min-width:0;margin:0;font-family:var(--basalt-font-family-sans)}.diagram[hidden]{display:none}.diagram-head{display:flex;flex-direction:column;gap:var(--basalt-space-0-5);min-width:0}.diagram-title{margin:0;color:var(--basalt-text-primary);font:var(--basalt-font-weight-semibold) var(--bh-md);letter-spacing:var(--basalt-text-md-tracking)}.diagram-source{margin:0;color:var(--basalt-text-tertiary);font:var(--basalt-font-weight-regular) var(--bh-xs)}.diagram-drawing{--_D: initial;--_Display: var(--_D) grid;--_Max: var(--_D) none;--_Cols: var(--_D) repeat(var(--_cols, 1), minmax(0, 1fr));--_Gap: var(--_D) var(--_row-gap) var(--_col-gap);--_Pad: var(--_D) var(--_gpad, 0);--_row-gap: var(--basalt-space-12);--_col-gap: var(--basalt-space-16);position:relative;box-sizing:border-box;display:var(--_Display, flex);flex-direction:column;grid-template-columns:var(--_Cols, none);gap:var(--_Gap, 0);width:100%;max-width:var(--_Max, var(--basalt-size-breakpoint-container));min-width:0;padding:var(--_Pad, 0 var(--_gutter, 0) 0 0)}.diagram[data-layout=drawn]>.diagram-drawing{--_D: }.diagram[data-layout=stacked]>.diagram-drawing{--_D: initial}.diagram[data-gutter]>.diagram-drawing{--_gutter: var(--basalt-space-10)}.diagram[data-type=data-flow]>.diagram-drawing{--_Cols: var(--_D) var(--basalt-size-diagram-lane) repeat(var(--_cols, 1), minmax(0, 1fr));--_row-gap: var(--basalt-space-10);--_col-gap: var(--basalt-space-12)}.diagram[data-type=schema]>.diagram-drawing{--_row-gap: var(--basalt-space-8);--_col-gap: var(--basalt-space-12);display:grid;grid-template-columns:var(--_Cols, repeat(auto-fit, minmax(min(100%, var(--_track, var(--basalt-size-diagram-table))), 1fr)));gap:var(--_Gap, var(--basalt-space-4));align-items:start;max-width:none}.diagram[data-type=sequence]>.diagram-drawing{display:flex;gap:0}.diagram-node{--_Gc: var(--_D) var(--_c);--_Gr: var(--_D) var(--_r) / var(--_r2);--_Mt: var(--_D) 0;--_Align: var(--_D) center;position:relative;z-index:1;box-sizing:border-box;display:flex;flex-direction:column;min-width:0;grid-column:var(--_Gc, auto);grid-row:var(--_Gr, auto);align-self:var(--_Align, stretch);margin-block-start:var(--_Mt, var(--_gap, 0));padding:var(--basalt-space-2-5) var(--basalt-space-3);background:var(--panel-next, var(--basalt-surface-1));border:var(--basalt-size-hairline) solid var(--basalt-border-rim);border-top-color:var(--basalt-border-rim-top);border-radius:var(--basalt-radius-md);color:var(--basalt-text-primary);overflow-wrap:break-word;outline:none;transition:border-color var(--basalt-duration-fast) var(--basalt-ease-out)}.diagram[data-type=data-flow] .diagram-node{--_Gc: var(--_D) var(--_lc)}.diagram-node[data-branch]{--_Mi: var(--_D) 0;margin-inline:var(--_Mi, var(--basalt-space-12) var(--basalt-space-6))}.diagram-node:focus-visible{z-index:2;outline:var(--basalt-size-focus-width) solid var(--basalt-border-focus);outline-offset:var(--basalt-size-focus-offset)}.diagram-node[data-near]{border-color:var(--basalt-border-hover)}.diagram-kind{color:var(--basalt-text-tertiary);font:var(--basalt-font-weight-regular) var(--bh-xs-mono)}.diagram-lane-word{--_Lw: var(--_D) none;display:var(--_Lw, inline)}.diagram-name{color:var(--basalt-text-primary);font:var(--basalt-font-weight-semibold) var(--bh-sm)}.diagram-detail{margin-block-start:var(--basalt-space-0-5);color:var(--basalt-text-secondary);font:var(--basalt-font-weight-regular) var(--bh-xs)}.diagram-detail[data-mono]{font-family:var(--basalt-font-family-mono)}.diagram-run{display:inline-block;max-width:100%}:root,[data-theme=light],.light{--_dkm: initial}[data-theme=dark],.dark{--_dkm: }@media(prefers-color-scheme:dark){:root:not([data-theme=light]):not(.light){--_dkm: }}.diagram-mark{--_mf: var(--_dkm) var(--_md);position:absolute;inset-block-start:var(--basalt-space-2-5);inset-inline-end:var(--basalt-space-3);width:var(--basalt-size-icon-sm);height:var(--basalt-size-icon-sm);background:var(--_mf, var(--_ml)) center / contain no-repeat;pointer-events:none}.diagram-node[data-focal]>.diagram-mark{--_mf: var(--_dkm) var(--_ml);background-image:var(--_mf, var(--_md, var(--_ml)))}.diagram-node[data-mark]>.diagram-mark+:is(.diagram-kind,.diagram-name){padding-inline-end:var(--basalt-space-6)}.diagram-node[data-focal]{background:var(--basalt-diagram-focal);border-color:var(--basalt-diagram-focal)}.diagram-node[data-focal] :is(.diagram-name,.diagram-kind,.diagram-detail,.diagram-tname,.diagram-cname,.diagram-keyseat,.diagram-ctype,.diagram-more){color:var(--basalt-diagram-focal-ink)}.diagram-node[data-focal] :is(.diagram-kind,.diagram-detail,.diagram-keyseat,.diagram-ctype,.diagram-more){opacity:var(--basalt-opacity-amount)}.diagram[data-type=flowchart] .diagram-node:not([data-focal]){border-color:var(--basalt-diagram-structure)}.diagram[data-type=flowchart] .diagram-node:not([data-focal],[data-shape=decision])[data-near]{border-color:var(--basalt-text-secondary)}.diagram-node[data-shape=terminal]{align-items:center;padding-inline:var(--basalt-space-5);border-radius:var(--basalt-radius-full);text-align:center}.diagram-node[data-shape=decision]{justify-content:center;align-items:center;height:var(--_h, auto);min-height:var(--basalt-space-16);padding:var(--basalt-space-2) var(--basalt-space-2-5);text-align:center}.diagram-words{position:relative;max-width:var(--_ww, calc(62% + (var(--basalt-space-2-5) + var(--basalt-size-hairline)) * 1.24))}.diagram-node[data-shape=decision] .diagram-name{font-weight:var(--basalt-font-weight-medium);text-wrap:balance}.diagram-diamond{display:none;position:absolute;inset:0;width:100%;height:100%;overflow:visible}.diagram-diamond path{fill:var(--panel-next, var(--basalt-surface-1));stroke:var(--basalt-diagram-structure);stroke-width:var(--basalt-size-hairline);vector-effect:non-scaling-stroke;transition:stroke var(--basalt-duration-fast) var(--basalt-ease-out)}.diagram[data-measured] .diagram-node[data-shape=decision]{background:none;border-color:transparent}.diagram[data-measured] .diagram-node[data-shape=decision] .diagram-diamond{display:block}.diagram-node[data-shape=decision][data-near] .diagram-diamond path{stroke:var(--basalt-text-secondary)}.diagram-node[data-shape=decision][data-focal] .diagram-diamond path{fill:var(--basalt-diagram-focal);stroke:var(--basalt-diagram-focal)}.diagram-group{--_Gd: var(--_D) contents;position:relative;box-sizing:border-box;display:var(--_Gd, flex);flex-direction:column;margin-block-start:calc(var(--basalt-space-12) + var(--basalt-space-4) * var(--_ggrow, 0));padding:var(--basalt-space-8) var(--basalt-space-3) var(--basalt-space-3-5);border:var(--basalt-size-hairline) dashed var(--basalt-diagram-structure);border-radius:var(--basalt-radius-lg)}.diagram-group:first-child{margin-block-start:0}.diagram-group>.diagram-glabel+.diagram-node{--_Mt: 0}.diagram-glabel{position:absolute;top:var(--basalt-space-2);inset-inline-start:var(--basalt-space-3);color:var(--basalt-text-secondary);font:var(--basalt-font-weight-regular) var(--bh-xs-mono);white-space:nowrap}.diagram-group>.diagram-glabel{--_Gl: var(--_D) none;display:var(--_Gl, block)}.diagram-gbox{--_Gb: var(--_D) block;position:relative;display:var(--_Gb, none);grid-column:var(--_c) / var(--_c2);grid-row:var(--_r) / var(--_r2);margin:calc(-1 * var(--basalt-space-8)) calc(-1 * var(--basalt-space-4)) calc(-1 * var(--basalt-space-4));border:var(--basalt-size-hairline) dashed var(--basalt-diagram-structure);border-radius:var(--basalt-radius-lg);pointer-events:none}.diagram-lane{--_Ln: var(--_D) flex;position:relative;display:var(--_Ln, none);grid-column:1 / -1;grid-row:var(--_r);align-items:center;pointer-events:none}.diagram-lane+.diagram-lane:before{content:"";position:absolute;inset-inline:0;top:calc(-1 * var(--basalt-space-5));border-top:var(--basalt-size-hairline) solid var(--basalt-border-divider)}.diagram-lane-name{box-sizing:border-box;width:var(--basalt-size-diagram-lane);padding-inline-end:var(--basalt-space-3);color:var(--basalt-text-secondary);font:var(--basalt-font-weight-medium) var(--bh-xs)}.diagram-ink{position:absolute;inset:0;z-index:0;pointer-events:none}.diagram-svg{position:absolute;top:0;left:0;overflow:visible}.diagram-ruler{position:absolute;visibility:hidden;white-space:pre;pointer-events:none}.diagram-ruler[data-f=name]{font:var(--basalt-font-weight-semibold) var(--bh-sm)}.diagram-ruler[data-f=name-500]{font:var(--basalt-font-weight-medium) var(--bh-sm)}.diagram-ruler[data-f=table]{font:var(--basalt-font-weight-semibold) var(--basalt-text-sm-size) / var(--basalt-text-sm-line-height) var(--basalt-font-family-mono)}.diagram-ruler:is([data-f=mono],[data-f=label]){font:var(--basalt-font-weight-regular) var(--bh-xs-mono)}.diagram-ruler[data-f=sans]{font:var(--basalt-font-weight-regular) var(--bh-xs)}.diagram-line{fill:none;stroke:var(--basalt-diagram-edge);stroke-width:var(--basalt-size-hairline);transition:stroke var(--basalt-duration-fast) var(--basalt-ease-out)}.diagram-line[data-kind=main]{stroke:var(--basalt-diagram-edge-main);stroke-width:var(--basalt-size-chart-line)}.diagram-line[data-kind=dashed]{stroke-dasharray:var(--basalt-size-chart-dash) var(--basalt-size-chart-dash-gap);stroke-linecap:butt}.diagram-tip{fill:var(--basalt-diagram-edge);transition:fill var(--basalt-duration-fast) var(--basalt-ease-out),stroke var(--basalt-duration-fast) var(--basalt-ease-out)}.diagram-tip[data-kind=main]{fill:var(--basalt-diagram-edge-main)}.diagram-tip[data-open]{fill:none;stroke:var(--basalt-diagram-edge);stroke-width:var(--basalt-size-hairline);stroke-linecap:round;stroke-linejoin:round}.diagram-dot{fill:var(--basalt-diagram-edge)}.diagram-life{fill:none;stroke:var(--basalt-diagram-structure);stroke-width:var(--basalt-size-hairline);stroke-dasharray:var(--basalt-size-diagram-guide-dash) var(--basalt-size-diagram-guide-dash)}.diagram-edge[data-lit] .diagram-line{stroke:var(--basalt-diagram-edge-main)}.diagram-edge[data-lit] .diagram-tip:not([data-open]),.diagram-edge[data-lit] .diagram-dot{fill:var(--basalt-diagram-edge-main)}.diagram-edge[data-lit] .diagram-tip[data-open]{stroke:var(--basalt-diagram-edge-main)}.diagram-edge[data-dim] .diagram-line{stroke:var(--basalt-diagram-edge-dim)}.diagram-edge[data-dim] .diagram-tip:not([data-open]),.diagram-edge[data-dim] .diagram-dot{fill:var(--basalt-diagram-edge-dim)}.diagram-edge[data-dim] .diagram-tip[data-open]{stroke:var(--basalt-diagram-edge-dim)}.diagram-label{position:absolute;box-sizing:border-box;height:var(--basalt-text-xs-line-height);color:var(--basalt-diagram-edge);font:var(--basalt-font-weight-regular) var(--bh-xs-mono);text-align:center;white-space:nowrap;transition:color var(--basalt-duration-fast) var(--basalt-ease-out)}.diagram-label[data-on]{background:var(--_ground)}.diagram-label[data-lit]{color:var(--basalt-diagram-edge-main)}.diagram-cast{--_Cd: var(--_D) grid;display:var(--_Cd, flex);flex-wrap:wrap;grid-template-columns:repeat(var(--_cols, 1),minmax(0,1fr));gap:var(--_Cast-gap, var(--basalt-space-1-5));--_Cast-gap: var(--_D) var(--basalt-space-5);margin:0;padding:0;list-style:none}.diagram-actor{display:flex;min-width:0}.diagram-node[data-shape=participant]{--_Pd: var(--_D) var(--basalt-space-2-5) var(--basalt-space-3);--_Pr: var(--_D) var(--basalt-radius-md);--_Pa: var(--_D) center;flex:var(--_Pflex, none);--_Pflex: var(--_D) 1;align-items:center;justify-content:var(--_Pa, center);min-height:var(--_Ph, var(--basalt-size-badge));--_Ph: var(--_D) 0;padding:var(--_Pd, 0 calc(var(--basalt-space-2) - var(--basalt-size-hairline)));border-radius:var(--_Pr, var(--basalt-radius-xs));text-align:center}.diagram-node[data-shape=participant]:not([data-focal]){--_Pbg: var(--_D) var(--panel-next, var(--basalt-surface-1));--_Pbc: var(--_D) var(--basalt-border-rim);--_Pbt: var(--_D) var(--basalt-border-rim-top);background:var(--_Pbg, none);border-color:var(--_Pbc, var(--basalt-border-hairline));border-top-color:var(--_Pbt, var(--basalt-border-hairline))}.diagram-node[data-shape=participant] .diagram-kind{--_Pk: var(--_D) block;display:var(--_Pk, none)}.diagram-node[data-shape=participant] .diagram-name{font-size:var(--_Pn, var(--basalt-text-xs-size));line-height:var(--_Pnl, var(--basalt-text-xs-line-height));font-weight:var(--_Pw, var(--basalt-font-weight-medium));--_Pn: var(--_D) var(--basalt-text-sm-size);--_Pnl: var(--_D) var(--basalt-text-sm-line-height);--_Pw: var(--_D) var(--basalt-font-weight-semibold)}.diagram-steps{--_Sp: var(--_D) var(--basalt-space-4);position:relative;z-index:1;padding-block-start:var(--_Sp, var(--basalt-space-4))}.diagram-msgs{margin:0;padding:0;list-style:none}.diagram-msg{--_Md: var(--_D) grid;--_Mc: var(--_D) repeat(var(--_cols, 1), minmax(0, 1fr));--_Mr: var(--_D) 1fr 1fr;--_Mh: var(--_D) var(--basalt-size-diagram-step);--_Mg: var(--_D) 0 var(--basalt-space-5);display:grid;grid-template-columns:var(--_Mc, var(--basalt-space-8) minmax(0, 1fr));grid-template-rows:var(--_Mr, auto);column-gap:var(--basalt-space-5);gap:var(--_Mg, 0);height:var(--_Mh, auto);padding-block:var(--_Mpb, var(--basalt-space-2-5));--_Mpb: var(--_D) 0;border-top:var(--_Mb, var(--basalt-size-hairline) solid var(--basalt-border-divider));--_Mb: var(--_D) 0;font:var(--basalt-font-weight-regular) var(--bh-xs)}.diagram-said{--_Sd: var(--_D) block;display:var(--_Sd, contents);grid-column:var(--_a) / var(--_b);grid-row:1;align-self:end;justify-self:center;margin-block-end:calc(var(--basalt-space-1) + var(--basalt-size-hairline));padding-inline:var(--basalt-space-1-5);background:var(--_ground);white-space:nowrap}.diagram-num{grid-column:1;color:var(--basalt-text-tertiary);font-variant-numeric:tabular-nums}.diagram-said .diagram-num{margin-inline-end:var(--_Nm, 0);--_Nm: var(--_D) var(--basalt-space-1-5)}.diagram-mlabel{grid-column:2;color:var(--basalt-text-primary);font-family:var(--basalt-font-family-mono)}.diagram-route{--_Rd: var(--_D) none;display:var(--_Rd, inline-flex);grid-column:2;align-items:center;gap:var(--basalt-space-1);flex-wrap:wrap;color:var(--basalt-text-secondary)}.diagram-note{--_Nd: var(--_D) 2;grid-column:var(--_Nc, 2);--_Nc: var(--_D) var(--_a) / var(--_b);grid-row:var(--_Nd, auto);align-self:start;justify-self:var(--_Nj, stretch);--_Nj: var(--_D) center;margin-block-start:var(--_Nmt, 0);--_Nmt: var(--_D) calc(var(--basalt-space-1) + var(--basalt-size-hairline));padding-inline:var(--_Npi, 0);--_Npi: var(--_D) var(--basalt-space-1-5);background:var(--_Nbg, none);--_Nbg: var(--_D) var(--_ground);color:var(--basalt-text-tertiary);white-space:var(--_Nws, normal);--_Nws: var(--_D) nowrap}.diagram-msg[data-self=end] :is(.diagram-said,.diagram-note){--_Sj: var(--_D) start;justify-self:var(--_Sj, stretch);--_Sm: var(--_D) calc(50% + var(--basalt-space-6) + var(--basalt-space-1));margin-inline-start:var(--_Sm, 0)}.diagram-msg[data-self=start] :is(.diagram-said,.diagram-note){--_Sj: var(--_D) end;justify-self:var(--_Sj, stretch);--_Sm: var(--_D) calc(50% + var(--basalt-space-6) + var(--basalt-space-1));margin-inline-end:var(--_Sm, 0)}.diagram-arrow{flex:none;overflow:visible}.diagram-band{--_Bh: var(--_D) var(--basalt-size-control-lg);--_Bj: var(--_D) center;position:relative;display:flex;align-items:center;justify-content:var(--_Bj, flex-start);height:var(--_Bh, auto);margin:var(--_Bm, var(--basalt-space-5) 0 var(--basalt-space-2));--_Bm: var(--_D) 0;color:var(--basalt-text-secondary);font:var(--basalt-font-weight-medium) var(--bh-xs)}.diagram-band:before{--_Br: var(--_D) "";content:var(--_Br, none);position:absolute;inset-inline:0;top:50%;border-top:var(--basalt-size-hairline) solid var(--basalt-border-divider)}.diagram-band>span{position:relative;padding-inline:var(--_Bp, 0);--_Bp: var(--_D) var(--basalt-space-1-5);background:var(--_ground)}.diagram-node[data-shape=table]{align-self:start;padding:0;overflow-wrap:normal}.diagram-th{padding:var(--basalt-space-2) var(--basalt-space-3);border-bottom:var(--basalt-size-hairline) solid var(--basalt-border-divider)}.diagram-node[data-focal] .diagram-th{border-bottom-color:var(--basalt-diagram-focal-rule)}.diagram-tname{color:var(--basalt-text-primary);font:var(--basalt-font-weight-semibold) var(--basalt-text-sm-size) / var(--basalt-text-sm-line-height) var(--basalt-font-family-mono)}.diagram-rows{display:flex;flex-direction:column;padding-block:var(--basalt-space-1)}.diagram-row{display:flex;flex-wrap:wrap;align-items:center;column-gap:var(--basalt-space-3);min-height:var(--basalt-size-control-sm);padding-inline:var(--basalt-space-3);font:var(--basalt-font-weight-regular) var(--bh-xs-mono)}.diagram-keyseat{flex:none;width:var(--basalt-space-6);margin-inline-end:calc(-1 * var(--basalt-space-3));color:var(--basalt-text-tertiary)}.diagram-cname{flex:1 0 auto;color:var(--basalt-text-primary)}.diagram-ctype{margin-inline-start:auto;color:var(--basalt-text-tertiary)}.diagram-ctype[data-ref]{color:var(--basalt-text-secondary)}.diagram-more{padding:0 var(--basalt-space-3) var(--basalt-space-2);color:var(--basalt-text-tertiary);font:var(--basalt-font-weight-regular) var(--bh-xs)}.diagram-key{padding-block-start:var(--basalt-space-3);border-top:var(--basalt-size-hairline) solid var(--basalt-border-divider)}.diagram-legend{display:flex;flex-wrap:wrap;gap:var(--basalt-space-2) var(--basalt-space-5);margin:0;padding:0;list-style:none;color:var(--basalt-text-secondary);font:var(--basalt-font-weight-regular) var(--bh-xs)}.diagram-entry{display:inline-flex;align-items:center;gap:var(--basalt-space-1-5)}.diagram[data-layout=drawn] .diagram-entry[data-when=stacked],.diagram[data-layout=stacked] .diagram-entry[data-when=drawn],.diagram:not([data-layout]) .diagram-entry[data-when=drawn]{display:none}.diagram-swatch{flex:none;overflow:visible}.diagram-swatch-shape{fill:var(--_ground);stroke:var(--basalt-diagram-structure);stroke-width:var(--basalt-size-hairline)}.diagram-swatch[data-shape=focal] .diagram-swatch-shape{fill:var(--basalt-diagram-focal);stroke:var(--basalt-diagram-focal)}.diagram-swatch[data-shape=group] .diagram-swatch-shape{fill:none;stroke-dasharray:var(--basalt-space-1) var(--basalt-space-0-5)}.diagram-fk-mark{color:var(--basalt-text-secondary);font-family:var(--basalt-font-family-mono)}.diagram-key-letters{color:var(--basalt-text-tertiary);font:var(--basalt-font-weight-regular) var(--bh-xs-mono)}.diagram-hint{display:flex;flex-wrap:wrap;gap:var(--basalt-space-1) var(--basalt-space-4);margin:0;color:var(--basalt-text-tertiary);font:var(--basalt-font-weight-regular) var(--bh-xs)}.diagram-hint>span{display:inline-flex;align-items:center;gap:var(--basalt-space-1)}.diagram[data-layout=stacked]:is([data-type=sequence],[data-type=schema]) .diagram-hint{display:none}.diagram[data-bare] :is(.diagram-entry[data-line],.diagram-hint){display:none}.diagram-summary{order:1;max-width:var(--basalt-size-prose-width);color:var(--basalt-text-secondary);font:var(--basalt-font-weight-regular) var(--bh-sm);text-wrap:pretty}.diagram-foot{order:2;display:flex;flex-wrap:wrap;gap:var(--basalt-space-2)}.diagram-list{order:3;max-width:var(--basalt-size-prose-width);color:var(--basalt-text-secondary);font:var(--basalt-font-weight-regular) var(--bh-sm)}.diagram-list[hidden]{display:none}.diagram-list strong{color:var(--basalt-text-primary);font-weight:var(--basalt-font-weight-semibold)}.diagram-code{padding:0;border-radius:0;background:none;color:var(--basalt-text-primary);font:var(--basalt-font-weight-regular) var(--basalt-text-xs-size) / var(--basalt-text-sm-line-height) var(--basalt-font-family-mono)}.diagram-list-head{margin:var(--basalt-space-4) 0 var(--basalt-space-2);color:var(--basalt-text-primary);font:var(--basalt-font-weight-semibold) var(--bh-sm)}.diagram-list-head:first-child{margin-block-start:0}.diagram-list-group{margin:var(--basalt-space-3) 0 var(--basalt-space-1);color:var(--basalt-text-primary);font-size:inherit;font-weight:var(--basalt-font-weight-medium);line-height:inherit}.diagram-list-items{display:flex;flex-direction:column;gap:var(--basalt-space-1);margin:0;padding-inline-start:var(--basalt-space-5)}.diagram-list-exits{margin:var(--basalt-space-1) 0 0;padding-inline-start:var(--basalt-space-5)}@media(pointer:coarse){.diagram-toggle{min-height:var(--basalt-size-tap-min)}}@media(prefers-reduced-motion:reduce){.diagram-node,.diagram-line,.diagram-tip,.diagram-label,.diagram-diamond path{transition:none}}@media(prefers-contrast:more){.diagram-node[data-focal] :is(.diagram-kind,.diagram-detail,.diagram-keyseat,.diagram-ctype,.diagram-more){opacity:1}}@container (width >= 640px){.diagram:not([data-layout]):is(:is([data-type=architecture],[data-type=flowchart]):is([data-cols="1"],[data-cols="2"],[data-cols="3"]),:is([data-type=data-flow],[data-type=schema]):is([data-cols="1"],[data-cols="2"]),[data-type=sequence]:is([data-cols="1"],[data-cols="2"],[data-cols="3"],[data-cols="4"]))>.diagram-drawing{--_D: }}@container (width >= 696px){.diagram:not([data-layout])[data-type=data-flow][data-cols="3"]>.diagram-drawing{--_D: }}@container (width >= 768px){.diagram:not([data-layout]):is([data-type=architecture][data-cols="4"][data-reach="0"],[data-type=flowchart][data-cols="4"],[data-type=schema][data-cols="3"])>.diagram-drawing{--_D: }}@container (width >= 784px){.diagram:not([data-layout])[data-type=architecture][data-cols="4"][data-reach="1"]>.diagram-drawing{--_D: }}@container (width >= 800px){.diagram:not([data-layout]):is([data-type=architecture][data-cols="4"][data-reach="2"],[data-type=sequence][data-cols="5"])>.diagram-drawing{--_D: }}@container (width >= 888px){.diagram:not([data-layout])[data-type=data-flow][data-cols="4"]>.diagram-drawing{--_D: }}@container (width >= 964px){.diagram:not([data-layout])[data-type=sequence][data-cols="6"]>.diagram-drawing{--_D: }}@container (width >= 976px){.diagram:not([data-layout]):is([data-type=architecture][data-cols="5"][data-reach="0"],[data-type=flowchart][data-cols="5"])>.diagram-drawing{--_D: }}@container (width >= 992px){.diagram:not([data-layout])[data-type=architecture][data-cols="5"][data-reach="1"]>.diagram-drawing{--_D: }}@container (width >= 1008px){.diagram:not([data-layout])[data-type=architecture][data-cols="5"][data-reach="2"]>.diagram-drawing{--_D: }}@container (width >= 1040px){.diagram:not([data-layout])[data-type=schema][data-cols="4"]>.diagram-drawing{--_D: }}@container (width >= 1080px){.diagram:not([data-layout])[data-type=data-flow][data-cols="5"]>.diagram-drawing{--_D: }}@container (width >= 1184px){.diagram:not([data-layout]):is([data-type=architecture][data-cols="6"][data-reach="0"],[data-type=flowchart][data-cols="6"])>.diagram-drawing{--_D: }}@container (width >= 1200px){.diagram:not([data-layout])[data-type=architecture][data-cols="6"][data-reach="1"]>.diagram-drawing{--_D: }}@container (width >= 1216px){.diagram:not([data-layout])[data-type=architecture][data-cols="6"][data-reach="2"]>.diagram-drawing{--_D: }}@container (width >= 1272px){.diagram:not([data-layout])[data-type=data-flow][data-cols="6"]>.diagram-drawing{--_D: }}@container (width >= 1312px){.diagram:not([data-layout])[data-type=schema][data-cols="5"]>.diagram-drawing{--_D: }}@container (width >= 1584px){.diagram:not([data-layout])[data-type=schema][data-cols="6"]>.diagram-drawing{--_D: }}@media(scripting:none){.diagram:not(#basalt-diagram-no-id)>.diagram-drawing{--_D: initial}.diagram-list[hidden]{display:block!important}.diagram-foot,.diagram-entry[data-line],.diagram-hint{display:none}}@media(forced-colors:active){.diagram-svg,.diagram-swatch,.diagram-arrow{forced-color-adjust:none}.diagram .diagram-line,.diagram .diagram-line[data-kind]{stroke:CanvasText}.diagram .diagram-tip,.diagram .diagram-tip[data-kind],.diagram .diagram-dot{fill:CanvasText}.diagram .diagram-tip[data-open],.diagram .diagram-tip[data-kind][data-open]{fill:none;stroke:CanvasText}.diagram .diagram-edge[data-dim] .diagram-line{stroke:GrayText}.diagram .diagram-edge[data-dim] :is(.diagram-tip:not([data-open]),.diagram-dot){fill:GrayText}.diagram .diagram-edge[data-dim] .diagram-tip[data-open]{stroke:GrayText}.diagram .diagram-edge[data-lit] .diagram-line{stroke:Highlight}.diagram .diagram-edge[data-lit] :is(.diagram-tip:not([data-open]),.diagram-dot){fill:Highlight}.diagram .diagram-edge[data-lit] .diagram-tip[data-open]{stroke:Highlight}.diagram .diagram-life{stroke:GrayText}.diagram .diagram-label{color:CanvasText;forced-color-adjust:none}.diagram .diagram-label[data-on]{background:Canvas}.diagram .diagram-label[data-lit]{color:Highlight}.diagram .diagram-swatch-shape{fill:Canvas;stroke:CanvasText}.diagram .diagram-swatch[data-shape=group] .diagram-swatch-shape{fill:none;stroke:GrayText}.diagram .diagram-swatch[data-shape=focal] .diagram-swatch-shape{fill:CanvasText;stroke:CanvasText}.diagram[data-type=flowchart] .diagram-node:not([data-focal]),.diagram[data-type=flowchart] .diagram-node:not([data-focal])[data-near]{border-color:CanvasText}.diagram[data-measured][data-type=flowchart] .diagram-node[data-shape=decision][data-shape]{forced-color-adjust:none;background:none;border-color:transparent}.diagram .diagram-diamond{forced-color-adjust:none}.diagram .diagram-diamond path,.diagram .diagram-node[data-near] .diagram-diamond path{fill:Canvas;stroke:CanvasText}.diagram .diagram-group,.diagram .diagram-gbox{border-color:GrayText}.diagram .diagram-lane+.diagram-lane:before,.diagram .diagram-band:before{border-color:GrayText}.diagram .diagram-hint{color:GrayText}.diagram :is(.diagram-kind,.diagram-name,.diagram-detail,.diagram-glabel,.diagram-lane-name,.diagram-title,.diagram-source,.diagram-num,.diagram-mlabel,.diagram-route,.diagram-note,.diagram-band,.diagram-tname,.diagram-cname,.diagram-keyseat,.diagram-ctype,.diagram-more,.diagram-legend,.diagram-fk-mark,.diagram-key-letters){color:CanvasText}.diagram .diagram-node:focus-visible{outline-color:Highlight}.diagram .diagram-node[data-focal],.diagram .diagram-node[data-focal][data-near]{forced-color-adjust:none;background:CanvasText;border-color:CanvasText}.diagram .diagram-node[data-focal] :is(.diagram-name,.diagram-kind,.diagram-detail,.diagram-tname,.diagram-cname,.diagram-keyseat,.diagram-ctype,.diagram-more){color:Canvas;opacity:1}.diagram .diagram-node[data-focal] .diagram-th{border-bottom-color:Canvas}.diagram .diagram-node[data-focal]:focus-visible{outline:var(--basalt-size-focus-width) solid Highlight}.diagram .diagram-node[data-focal][data-shape=decision] .diagram-diamond path{fill:CanvasText;stroke:CanvasText}.diagram .diagram-mark{display:none}.diagram .diagram-node[data-mark]>.diagram-mark+:is(.diagram-kind,.diagram-name){padding-inline-end:0}}@media print{.diagram-svg,.diagram-swatch,.diagram-arrow,.diagram-mark,.diagram-node[data-focal]{-webkit-print-color-adjust:exact;print-color-adjust:exact}.diagram-hint{display:none}}}
diff --git a/.agent/skills/basalt-html/parts/diagram.js b/.agent/skills/basalt-html/parts/diagram.js
index af24b73a..54e3aa24 100644
--- a/.agent/skills/basalt-html/parts/diagram.js
+++ b/.agent/skills/basalt-html/parts/diagram.js
@@ -1,2 +1,2 @@
-(()=>{var ee=["top","right","bottom","left"],ne=["main","plain","dashed"],oe=[2,3,4,5,6],at=t=>t==null||t===""?void 0:String(t),ut=t=>Object.assign(Object.create(null),t),ht=(t,e)=>t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;function Et(t,e={}){const n=e.checks!==!1,a=[],s=d=>{a.push(d)},o=t.legend??{},r={};for(const d of["main","plain","dashed","focal","group"]){const y=at(o[d]);y&&(r[d]=y)}const i=t.stepLabel,f=typeof i=="function"?d=>String(i(d)):typeof i=="string"?(d=>i.replace("{n}",String(d))):d=>`Step ${d}`,p=t.shapeLabels??{},h={terminal:at(p.terminal)??"Start or end",step:at(p.step)??"Step",decision:at(p.decision)??"Decision"},u=t.heading===void 0?3:oe.includes(t.heading)?t.heading:(s(`heading ${String(t.heading)} is not a level from 2 to 6: the title is an h3`),3),l=(d,y)=>d==null?"plain":ne.includes(d)?d:(s(`"${String(d)}" is not a kind of line (main, plain or dashed): ${y} is drawn plain`),"plain"),m=d=>{if(d!=null){if(ee.includes(d))return d;s(`"${String(d)}" is not a side (top, right, bottom or left): the derived side is used`)}},b=(d,y)=>typeof d=="number"&&Number.isInteger(d)&&d>=1?d:(s(`${y} is ${JSON.stringify(d)}, not a whole number from 1: it is placed at 1`),1),c=[],g=[];let $=[];const I=[],k=[],E=t.type;if(["architecture","flowchart","data-flow","sequence","schema"].includes(E)||s(`"${String(E)}" is not a type of diagram (architecture, flowchart, data-flow, sequence or schema)`),E==="architecture"||E==="flowchart"){for(const d of t.nodes??[]){const y=E==="flowchart"&&d.shape==="decision"?"decision":E==="flowchart"&&d.shape==="terminal"?"terminal":"box",v=String(d.id??""),B=b(d.row,`the row of ${v}`);c.push({id:v,i:c.length,name:String(d.name??""),kind:y==="decision"?void 0:at(d.kind),detail:y==="decision"?void 0:at(d.detail),mono:!!d.detailMono,focal:!!d.focal,col:b(d.col,`the column of ${v}`),row:B,row2:B,branch:!!d.branch,shape:y,group:E==="architecture"?at(d.group):void 0,mark:E==="architecture"?se(d.mark):void 0})}if(E==="architecture")for(const d of t.groups??[]){const y=String(d.id??"");I.push({id:y,label:String(d.label??""),members:c.filter(v=>v.group===y).map(v=>v.id)})}}else if(E==="data-flow"){$=(t.lanes??[]).map(y=>({id:String(y.id??""),label:String(y.label??"")}));const d=new Map($.map((y,v)=>[y.id,v+1]));for(const y of t.nodes??[]){const v=String(y.id??""),B=String(y.lane??""),T=d.get(B);T===void 0&&s(`a node (${v}) names the lane "${B}", which is not in lanes`);const j=c.length+1;c.push({id:v,i:c.length,name:String(y.name??""),kind:f(j),detail:at(y.detail),mono:!!y.detailMono,focal:!!y.focal,col:b(y.col,`the column of ${v}`),row:T??1,row2:T??1,branch:!1,shape:"box",lane:T??1,laneLabel:$[(T??1)-1]?.label??B,step:j})}}else if(E==="sequence"){(t.participants??[]).forEach((y,v)=>{const B=String(y.name??"");c.push({id:String(y.id??""),i:v,name:B,kind:at(y.kind),mono:!1,focal:!!y.focal,col:v+1,row:1,row2:1,branch:!1,shape:"participant",short:at(y.short)??B})});let d=0;for(const y of t.steps??[])"band"in y?k.push({band:String(y.band??"")}):(d++,k.push({n:d,from:String(y.from??""),to:String(y.to??""),label:String(y.label??""),note:at(y.note),kind:l(y.kind,`message ${d}`)}))}else if(E==="schema")for(const d of t.tables??[]){const y=String(d.name??""),[v,B]=Array.isArray(d.row)?d.row:[d.row,d.row],T=b(v,`the row of ${y}`),j=Math.max(T,b(B,`the last row of ${y}`)),z=d.more===void 0||d.more===null?void 0:Number.isInteger(d.more)&&d.more>0?d.more:(s(`${y}'s "more" is ${JSON.stringify(d.more)}, not a whole number from 1: it is left out`),void 0);c.push({id:y,i:c.length,name:y,mono:!0,focal:!!d.focal,col:b(d.col,`the column of ${y}`),row:T,row2:j,branch:!1,shape:"table",more:z,columns:(d.columns??[]).map(K=>({name:String(K.name??""),type:at(K.type),key:K.key==="PK"||K.key==="FK"?K.key:(K.key!==void 0&&K.key!==null&&s(`${y}.${String(K.name)}'s key is "${String(K.key)}", not PK or FK: it is left out`),void 0)}))})}const _=new Map;for(const d of c)d.id?_.has(d.id)&&s(`the id "${d.id}" is used twice`):s("a node has no id"),_.set(d.id,d);if(E==="schema")(t.tables??[]).forEach(d=>(d.columns??[]).forEach((y,v)=>{const B=at(y.references);if(!B)return;const[T,j]=B.split("."),z=_.get(T??""),K=z?.columns?.findIndex(A=>A.name===j)??-1;if(!z||K<0){s(`${String(d.name)}.${String(y.name)} references ${B}, which is not a shown column`);return}const M=_.get(String(d.name??""));M.columns[v].ref={table:T,column:j,row:K},g.push({i:g.length,from:M.id,to:T,kind:"plain",fromRow:v,toRow:K,fk:!0})}));else if(E!=="sequence")for(const d of t.edges??[]){const y=String(d.from??""),v=String(d.to??"");if(!_.has(y)||!_.has(v)){s(`a line names ${_.has(y)?v:y}, which is not a node`);continue}const B=at(d.label);B&&B.length>Lt&&s(`the label "${B}" is over ${Lt} characters: longer words belong in the node or the summary`),g.push({i:g.length,from:y,to:v,kind:l(d.kind,`the line from ${y} to ${v}`),label:B,fromSide:m(d.fromSide),toSide:m(d.toSide),flow:E!=="flowchart"&&d.flow===!0?!0:void 0})}else for(const d of k)"n"in d&&(!_.has(d.from)||!_.has(d.to))&&s(`message ${d.n} names ${_.has(d.from)?d.to:d.from}, which is not a participant`);if(n&&E!=="sequence"){const d=new Map;for(const y of c)for(let v=y.row;v<=y.row2;v++){const B=`${y.col}:${v}`;d.has(B)&&s(`${y.id} and ${d.get(B)} share the cell at column ${y.col}, row ${v}`),d.set(B,y.id)}}if(n){for(const y of I){const v=y.members.map(j=>_.get(j));if(!v.length)continue;const B={c1:Math.min(...v.map(j=>j.col)),c2:Math.max(...v.map(j=>j.col)),r1:Math.min(...v.map(j=>j.row)),r2:Math.max(...v.map(j=>j.row2))};for(const j of c)j.group!==y.id&&j.col>=B.c1&&j.col<=B.c2&&j.row>=B.r1&&j.row<=B.r2&&s(`${j.id} is inside the box of the group "${y.label}" but not a member`);const T=v.map(j=>j.i);Math.max(...T)-Math.min(...T)+1!==T.length&&s(`the members of the group "${y.label}" are not next to each other in the author's order, so the stacked drawing cannot wrap them in one box`)}for(const y of c)y.group&&!I.some(v=>v.id===y.group)&&s(`${y.id} names the group "${y.group}", which is not in groups`);c.filter(y=>y.focal).length>1&&s("more than one node is focal: a diagram has one at most");const d=new Set(E==="sequence"?k.flatMap(y=>"n"in y?[y.kind]:[]):g.map(y=>y.kind));d.has("main")&&!r.main&&s("main lines are drawn but the legend has no words for them (legend.main)"),d.has("dashed")&&!r.dashed&&s("dashed lines are drawn but the legend has no words for them (legend.dashed)"),c.some(y=>y.focal)&&!r.focal&&s("a focal node is drawn but the legend has no words for what it marks (legend.focal)")}const J=E==="architecture"||E==="data-flow",L=d=>Array.isArray(d)&&d.length>1?d.map(String):void 0,w=J&&t.packet&&typeof t.packet=="object"?t.packet:void 0,O=w&&L(w.path),C={animated:t.motion==="animated",pulse:J?L(t.pulse):void 0,packet:O?{path:O,repeat:w.repeat===!0,send:w.send}:void 0,run:E==="sequence"&&t.run===!0};if(n)for(const d of c){const y=d.mark?.says;if(!y?.length)continue;const v=[d.name,d.kind,d.detail].filter(Boolean).join(" ").toLowerCase();y.some(B=>v.includes(B.toLowerCase()))||s(`${d.id}'s mark stands for ${y.join(" or ")}, and none of its words say so`)}const R=Math.max(1,...c.map(d=>d.col)),X=E==="data-flow"?Math.max(1,$.length):Math.max(1,...c.map(d=>d.row2));return{type:E,title:String(t.title??""),heading:u,legend:r,nodes:c,byId:_,edges:g,groups:I,lanes:$,steps:k,cols:R,rows:X,shapeLabels:h,stepWord:f,warnings:a,motion:C,memo:new Map}}function se(t){if(typeof t=="string")return t?{id:t}:void 0;if(!t||typeof t!="object")return;const e=t,n=at(e.onLight);if(n)return{onLight:n,onDark:at(e.onDark)??n,says:Array.isArray(e.says)?e.says.map(String):void 0}}var At=t=>`url("${t.replace(/[\\"\n;]/g,e=>e===`
-`?"\\a ":e===";"?"\\3b ":`\\${e}`)}")`;function bt(t,e,n){return t.memo.has(e)||t.memo.set(e,n()),t.memo.get(e)}var Lt=28,pt=t=>{const e=t.trim();return e?/[.!?]$/.test(e)?e:`${e}.`:""};function qt(t,e){return t.legend[e]}function ae(t,e){return e.shape==="decision"?"decision":e.shape==="terminal"?t.edges.some(n=>n.from===e.id)?"start":"end":e.kind??"step"}function re(t,e){return bt(t,`sentence:${e.i}`,()=>ie(t,e))}function ie(t,e){const n=[];if(t.type==="schema"){n.push(`${e.name}, table.`);const a=(e.columns??[]).filter(o=>o.ref).map(o=>`${o.ref.table} (${o.name})`),s=t.edges.filter(o=>o.to===e.id).map(o=>`${o.from} (${t.byId.get(o.from).columns[o.fromRow].name})`);a.length&&n.push(`References ${a.join(", ")}.`),s.length&&n.push(`Referenced by ${s.join(", ")}.`)}else if(t.type==="sequence"){const a=t.steps.filter(o=>"n"in o&&o.from===e.id).length,s=t.steps.filter(o=>"n"in o&&o.to===e.id).length;n.push(pt(e.kind?`${e.name}, ${e.kind}`:e.name)),n.push(`Sends ${a} ${a===1?"message":"messages"} and receives ${s}.`)}else{const a=t.type==="data-flow"?`${t.stepWord(e.step)} of ${t.nodes.length}, ${e.laneLabel}`:t.type==="flowchart"?ae(t,e):e.kind;if(n.push(pt(a?`${e.name}, ${a}`:e.name)),e.detail&&n.push(pt(e.detail)),e.group){const r=t.groups.find(i=>i.id===e.group);r&&n.push(`In ${r.label}.`)}const s=t.edges.filter(r=>r.to===e.id).map(r=>`${t.byId.get(r.from).name}${r.label?` (${r.label})`:""}`),o=t.edges.filter(r=>r.from===e.id).map(r=>`${t.byId.get(r.to).name}${r.label?` (${r.label})`:""}`);s.length&&n.push(`From: ${s.join(", ")}.`),o.length&&n.push(`To: ${o.join(", ")}.`)}return e.focal&&t.legend.focal&&n.push(pt(t.legend.focal)),n.join(" ")}function le(t){return t.type==="architecture"?"a part":t.type==="sequence"?"a participant":t.type==="schema"?"a table":"a step"}function x(t,e,...n){const a=[];for(const s of n.flat(1/0))s!=null&&s!==!1&&!Array.isArray(s)&&a.push(s);return{t,a:e??{},c:a}}var ce={"&":"&","<":"<",">":">",'"':""","'":"'"},it=t=>t.replace(/[&<>"']/g,e=>ce[e]),de=" br img input meta link hr path polygon polyline circle rect line ";function It(t,e={}){if(typeof t=="string")return it(t);if("slot"in t)return e[t.slot]??"";if(!/^[a-z][a-z0-9]*$/.test(t.t))throw new Error(`diagram: "${t.t}" is not an element name`);let n="";for(const[a,s]of Object.entries(t.a))if(!(s==null||s===!1)){if(!/^[a-z][a-z0-9:-]*$/i.test(a))throw new Error(`diagram: "${a}" is not an attribute name`);n+=s===!0?` ${a}`:` ${a}="${it(String(s))}"`}return de.includes(` ${t.t} `)&&!t.c.length?t.t==="path"||t.t==="polygon"||t.t==="polyline"||t.t==="circle"||t.t==="rect"||t.t==="line"?`<${t.t}${n}/>`:`<${t.t}${n}>`:`<${t.t}${n}>${t.c.map(a=>It(a,e)).join("")}${t.t}>`}var ue=t=>({title:`${t}-title`,summary:`${t}-summary`,keys:`${t}-keys`,list:`${t}-list`,toggle:`${t}-toggle`});function ft(t,e){return!e.layout||e.bare?!1:e.layout==="drawn"?!0:t.type!=="sequence"&&t.type!=="schema"}function fe(t,e){return t.type==="sequence"||t.type==="schema"?e.layout==="drawn":!0}function Ot(t){let e=0;for(const n of t.groups){const a=n.members.map(s=>t.byId.get(s).col);a.length&&(Math.min(...a)===1&&(e|=1),Math.max(...a)===t.cols&&(e|=2))}return(e&1)+(e>>1&1)}function vt(t){return t.type==="sequence"?t.nodes.length:t.cols}function _t(t){return bt(t,"plan",()=>he(t))}function he(t){const e=t.nodes,n=c=>t.type==="data-flow"||!e[c].branch,a=t.edges.map(c=>{const g=t.byId.get(c.from).i,$=t.byId.get(c.to).i,k=e.slice(Math.min(g,$)+1,Math.max(g,$)).every(E=>!n(E.i));return $===g+1&&!(n(g)&&!n($))?"down":$===g-1?"up":$>g&&n(g)&&!n($)&&k?"trunk":$>g&&n(g)&&n($)&&k?"rail":$>g?"end-down":"end-up"}),s=t.edges.map((c,g)=>({e:c,k:g})).filter(({k:c})=>a[c]==="end-down"||a[c]==="end-up"),o=c=>{const g=t.byId.get(c.from).i,$=t.byId.get(c.to).i;return[Math.min(g,$),Math.max(g,$)]},r=(c,g)=>{const[$,I]=o(c),[k,E]=o(g);return ${const g=t.byId.get(c.from).i,[$,I]=o(c);return!n(g)&&e.slice($+1,I).every(k=>!n(k.i))&&s.every(k=>k.e===c||!r(k.e,c))}),f=s.length>0&&(t.type==="data-flow"||!i),p=c=>{const[g,$]=o(c);return $-g},h=t.edges.map(()=>0);let u=!1;const l=[];for(const c of[...s].sort((g,$)=>p(g.e)-p($.e)||g.k-$.k)){let g=0;for(const $ of l)r($.e,c.e)&&(g=Math.max(g,h[$.k]+1));h[c.k]=g,g>1&&(u=!0),l.push(c)}const m=t.edges.map(()=>.5);for(const c of e){const g=s.filter(({e:k})=>k.from===c.id);if(g.length<2)continue;const $=g.filter(({k})=>a[k]==="end-down").sort((k,E)=>p(E.e)-p(k.e)||k.k-E.k);[...g.filter(({k})=>a[k]==="end-up").sort((k,E)=>p(k.e)-p(E.e)||E.k-k.k),...$].forEach(({k},E,_)=>{m[k]=_.length===2?E===0?1/3:2/3:(E+1)/(_.length+1)})}const b=ut();for(let c=1;c{const w=a[L],O=t.byId.get(J.from).i,C=t.byId.get(J.to).i,R=C===c&&(w==="down"||w==="trunk"||w==="rail"||w==="end-down"),X=O===c&&C===c-1&&w==="up",d=C===c-1&&w==="end-up";R&&(w==="trunk"||w==="end-down")&&(E=!0),d&&(_=!0),(R||X||d)&&J.label&&(I++,k=Math.max(k,w==="trunk"?40:48))}),(I>1||E&&_)&&(k=64),b[g.id]=k}return{routes:a,gutter:f,lanes:h,exits:m,gaps:b,third:u}}var gt=(t,e)=>({width:t,height:e,viewBox:`0 0 ${t} ${e}`,"aria-hidden":"true",focusable:"false"});function Ct(t,e){const n=e==="fk"?"plain":e,a=n==="main"?8:8.5,s=24,o=n==="dashed"?s-1:s-7;return x("svg",{class:`${t}-swatch`,"data-kind":n,...gt(24,16)},e==="fk"?x("circle",{class:`${t}-dot`,cx:3,cy:a,r:3}):null,x("path",{class:`${t}-line`,"data-kind":n,d:`M${e==="fk"?3:0} ${a}H${o}`}),n==="dashed"?x("path",{class:`${t}-tip`,"data-kind":n,"data-open":"",d:`M${s-8} ${a-4}L${s} ${a}L${s-8} ${a+4}`}):x("path",{class:`${t}-tip`,"data-kind":n,d:`M${s} ${a}L${s-8} ${a-4}L${s-8} ${a+4}Z`}))}function mt(t,e){return e==="decision"?x("svg",{class:`${t}-swatch`,"data-shape":e,...gt(16,16)},x("path",{class:`${t}-swatch-shape`,d:"M8 2.5L14.5 8L8 13.5L1.5 8Z"})):e==="terminal"?x("svg",{class:`${t}-swatch`,"data-shape":e,...gt(16,16)},x("rect",{class:`${t}-swatch-shape`,x:.5,y:3.5,width:15,height:9,rx:4.5})):x("svg",{class:`${t}-swatch`,"data-shape":e,...gt(16,16)},x("rect",{class:`${t}-swatch-shape`,x:.5,y:2.5,width:15,height:11,rx:2}))}function pe(t,e){return bt(e,`key:${t}`,()=>ge(t,e))}function ge(t,e){const n=[],a=(o,r,i={})=>n.push(x("li",{class:`${t}-entry`,...i},o,x("span",null,r)));if(e.type==="schema"){const o=new Set(e.nodes.flatMap(r=>(r.columns??[]).map(i=>i.key)));for(const[r,i]of[["PK","Primary key"],["FK","Foreign key"]])o.has(r)&&n.push(x("li",{class:`${t}-entry`},x("span",{class:`${t}-key-letters`,"aria-hidden":"true"},r),x("span",null,i)))}if(e.type==="flowchart"){const o=new Set(e.nodes.map(r=>r.shape));o.has("terminal")&&a(mt(t,"terminal"),e.shapeLabels.terminal),o.has("box")&&a(mt(t,"box"),e.shapeLabels.step),o.has("decision")&&a(mt(t,"decision"),e.shapeLabels.decision)}const s=new Set(e.type==="sequence"?e.steps.flatMap(o=>"n"in o?[o.kind]:[]):e.edges.filter(o=>!o.fk).map(o=>o.kind));for(const o of["main","plain","dashed"]){const r=e.legend[o];s.has(o)&&r&&a(Ct(t,o),r,{"data-line":""})}return e.type==="schema"&&e.edges.length&&(a(Ct(t,"fk"),e.legend.plain??"A foreign key, to the key it references",{"data-line":"","data-when":"drawn"}),n.push(x("li",{class:`${t}-entry`,"data-when":"stacked"},x("span",{class:`${t}-fk-mark`,"aria-hidden":"true"},"→"),x("span",null,"The table a foreign key references")))),e.nodes.some(o=>o.focal)&&e.legend.focal&&a(mt(t,"focal"),e.legend.focal,{"data-focal":""}),e.groups.length&&e.legend.group&&a(mt(t,"group"),e.legend.group),n.length?x("div",{class:`${t}-key`},x("ul",{class:`${t}-legend`,"aria-label":"Key"},n)):null}function me(t,e){const n=e==="main"?6:6.5;return x("svg",{class:`${t}-arrow`,"data-kind":e,...gt(20,12)},x("path",{class:`${t}-line`,"data-kind":e,d:`M0 ${n}H${e==="dashed"?19:13}`}),e==="dashed"?x("path",{class:`${t}-tip`,"data-kind":e,"data-open":"",d:`M12 ${n-4}L20 ${n}L12 ${n+4}`}):x("path",{class:`${t}-tip`,"data-kind":e,d:`M20 ${n}L12 ${n-4}L12 ${n+4}Z`}))}function ye(t,e,n){if(n.shape==="decision")return[x("span",{class:`${t}-words`},x("span",{class:`${t}-name`},n.name))];const a=[];return e.type==="data-flow"?a.push(x("span",{class:`${t}-kind`},n.kind,x("span",{class:`${t}-lane-word`},` · ${n.laneLabel}`))):n.kind&&a.push(x("span",{class:`${t}-kind`},n.kind)),a.push(x("span",{class:`${t}-name`},n.name)),n.detail&&a.push(x("span",{class:`${t}-detail`,"data-mono":n.mono?"":void 0},n.mono?wt(n.detail).flatMap((s,o)=>[o?" ":"",x("span",{class:`${t}-run`},s)]):n.detail)),a}function be(t,e){return[x("span",{class:`${t}-th`},x("span",{class:`${t}-tname`},e.name)),x("span",{class:`${t}-rows`},(e.columns??[]).map((n,a)=>x("span",{class:`${t}-row`,"data-row":a,"data-key":n.key},x("span",{class:`${t}-keyseat`},n.key??""),x("span",{class:`${t}-cname`},n.name),n.ref?x("span",{class:`${t}-ctype`,"data-ref":""},`→ ${n.ref.table}`):n.type?x("span",{class:`${t}-ctype`},n.type):null))),e.more?x("span",{class:`${t}-more`},`+ ${e.more} more`):null]}var Bt=t=>{const e={32:"space-8",40:"space-10",48:"space-12",64:"space-16"};return e[t]?`var(--basalt-${e[t]})`:`${t}px`};function Mt(t,e,n,a){const{P:s}=t,o=fe(e,a)||a.keep===n.id,r=ft(e,a),i=[`--_c:${n.col}`,`--_r:${n.row}`,`--_r2:${n.row2+1}`];e.type==="data-flow"&&i.push(`--_lc:${n.col+1}`),e.type==="sequence"&&i.push(`--_c2:${n.col+1}`);const f=t.plan;if(f&&n.i>0){const u=ht(f.gaps,n.id)??32,l=ht(a.grow,n.id)??0;i.push(`--_gap:${l?`calc(${Bt(u)} + var(--basalt-space-4) * ${l})`:Bt(u)}`)}const p=ht(a.heights,n.id);p&&i.push(`--_h:${p}px`);const h=r?a.stop===n.id?0:-1:a.keep===n.id?-1:void 0;return x("div",{class:`${s}-node`,"data-node":n.id,"data-shape":n.shape,"data-focal":n.focal?"":void 0,"data-branch":n.branch?"":void 0,"data-mark":n.mark?n.mark.id??"":void 0,"data-level":t.level,style:i.join(";"),role:o?"img":void 0,"aria-label":o?re(e,n):void 0,tabindex:h},n.shape==="decision"?x("svg",{class:`${s}-diamond`,viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-hidden":"true",focusable:"false"},x("path",{d:"M50 0L100 50L50 100L0 50Z"})):null,n.mark?x("span",{class:`${s}-mark`,"aria-hidden":"true",style:n.mark.onLight?`--_ml:${At(n.mark.onLight)};--_md:${At(n.mark.onDark??n.mark.onLight)}`:void 0}):null,n.shape==="table"?be(s,n):ye(s,e,n))}function $e(t,e,n){const{P:a}=t,s=[];if(e.type==="data-flow"&&s.push(...e.lanes.map((r,i)=>x("div",{class:`${a}-lane`,style:`--_r:${i+1}`,"aria-hidden":"true"},x("span",{class:`${a}-lane-name`},r.label)))),e.type==="architecture")for(const r of e.groups){const i=r.members.map(l=>e.byId.get(l));if(!i.length)continue;const f=Math.min(...i.map(l=>l.col)),p=Math.max(...i.map(l=>l.col)),h=Math.min(...i.map(l=>l.row)),u=Math.max(...i.map(l=>l.row2));s.push(x("div",{class:`${a}-gbox`,"data-group":r.id,style:`--_c:${f};--_c2:${p+1};--_r:${h};--_r2:${u+1}`,"aria-hidden":"true"},x("span",{class:`${a}-glabel`},r.label)))}if(e.type==="sequence")return s.push(x("ul",{class:`${a}-cast`},e.nodes.map(r=>x("li",{class:`${a}-actor`},Mt(t,e,r,n))))),s.push(we(t,e)),s;let o=0;for(;oh.id===r.group):void 0;if(!i){s.push(Mt(t,e,r,n)),o++;continue}const f=[];for(;oMt(t,e,h,n))))}return s}function we(t,e){const{P:n}=t,a=[];let s=null;for(const o of e.steps){if("band"in o){s=null,a.push(x("p",{class:`${n}-band`},x("span",null,o.band)));continue}s||(s=x("ol",{class:`${n}-msgs`,start:o.n}),a.push(s));const r=e.byId.get(o.from),i=e.byId.get(o.to),f=r?.col??1,p=i?.col??1,h=f===p,u=h&&f===e.nodes.length,l=qt(e,o.kind);s.c.push(x("li",{class:`${n}-msg`,"data-kind":o.kind,"data-from":o.from,"data-to":o.to,"data-self":h?u?"start":"end":void 0,style:`--_a:${Math.min(f,p)};--_b:${Math.max(f,p)+1}`},x("span",{class:`${n}-said`},x("span",{class:`${n}-num`},String(o.n)),x("span",{class:`${n}-mlabel`},o.label)),x("span",{class:`${n}-route`},r?.short??o.from," ",me(n,o.kind),x("span",{class:t.hidden}," to ")," ",i?.short??o.to,l?` · ${l}`:""),o.note?x("span",{class:`${n}-note`},o.note):null))}return x("div",{class:`${n}-steps`},a)}function xe(t,e){return bt(e,`list:${t}`,()=>ve(t,e))}function ve(t,e){const n=Math.min(6,e.heading+1),a=h=>x(`h${n}`,{class:`${t}-list-head`},h),s=h=>x("strong",null,h),o=h=>x("code",{class:`${t}-code`},h),r=h=>e.byId.get(h)?.name??h,i=h=>{const u=qt(e,h);return u?` (${u})`:""},f=h=>h.focal&&e.legend.focal?` ${pt(e.legend.focal)}`:"";if(e.type==="architecture"){const h=m=>x("li",null,s(m.name),m.kind?`, ${m.kind}`:"",m.detail?[". ",m.mono?o(m.detail):m.detail,/[.!?]$/.test(m.detail)?"":"."]:/[.!?]$/.test(m.kind??m.name)?"":".",f(m)),u=[a("Parts")],l=e.nodes.filter(m=>!m.group);l.length&&u.push(x("ul",{class:`${t}-list-items`},l.map(h)));for(const m of e.groups)u.push(x("p",{class:`${t}-list-group`},m.label)),u.push(x("ul",{class:`${t}-list-items`},m.members.map(b=>h(e.byId.get(b)))));return u.push(a("Connections")),u.push(x("ol",{class:`${t}-list-items`},e.edges.map(m=>x("li",null,s(r(m.from))," to ",s(r(m.to)),m.label?[": ",o(m.label)]:"",`${i(m.kind)}.`)))),u}if(e.type==="flowchart"){const h=u=>(e.byId.get(u)?.i??0)+1;return[x("ol",{class:`${t}-list-items`},e.nodes.map(u=>{const l=e.edges.filter(c=>c.from===u.id),m=u.shape==="decision"?"Decision":u.shape==="terminal"?l.length?"Start":"End":"Step",b=!u.detail&&/[.!?]$/.test(u.name)?" ":". ";return x("li",null,s(u.name),u.detail?[", ",u.mono?o(u.detail):u.detail]:"",`${b}${m}.`,f(u),l.length?x("ul",{class:`${t}-list-exits`},l.map(c=>x("li",null,c.label?`If ${c.label}: go to ${h(c.to)}, `:`Then: go to ${h(c.to)}, `,s(r(c.to)),i(c.kind)))):null)}))]}if(e.type==="data-flow")return[x("ol",{class:`${t}-list-items`},e.nodes.map(h=>{const u=e.edges.filter(l=>l.from===h.id);return x("li",null,`${h.laneLabel}: `,s(h.name),h.detail?[", ",h.mono?o(h.detail):h.detail]:"",".",f(h),u.length?[" Then ",...u.flatMap((l,m)=>[m?"; ":"",`to step ${e.byId.get(l.to).step}, `,s(r(l.to)),l.label?[": ",o(l.label)]:"",i(l.kind)]),"."]:"")}))];if(e.type==="sequence"){const h=[a("Participants"),x("ul",{class:`${t}-list-items`},e.nodes.map(l=>x("li",null,s(l.name),l.kind?`, ${l.kind}`:"",".",f(l))))];h.push(a("Messages"));let u=null;for(const l of e.steps){if("band"in l){u=null,h.push(x(`h${Math.min(6,n+1)}`,{class:`${t}-list-group`},l.band));continue}u||(u=x("ol",{class:`${t}-list-items`,start:l.n}),h.push(u)),u.c.push(x("li",null,o(l.label),": ",s(r(l.from))," to ",s(r(l.to)),`${i(l.kind)}.`,l.note?` ${pt(l.note)}`:""))}return h}const p=[];for(const h of e.nodes)p.push(x(`h${n}`,{class:`${t}-list-group`},o(h.name),f(h))),p.push(x("ul",{class:`${t}-list-items`},[...(h.columns??[]).map(u=>x("li",null,o(u.name),u.key==="PK"?", primary key":u.key==="FK"?", foreign key":"",u.ref?[", references ",o(`${u.ref.table}.${u.ref.column}`)]:u.type?`, ${u.type}`:"")),...h.more?[x("li",null,`and ${h.more} more ${h.more===1?"column":"columns"}`)]:[]]));return p}function Me(t){return`Arrow keys move to the next or the previous ${t.type==="architecture"?"part":t.type==="sequence"?"participant":t.type==="schema"?"table":"step"}, in the author's order; Home and End go to the ends; Escape clears the trace.`}function ke(t){return[{keys:["←","→"],words:le(t)},{keys:["Home","End"],words:"the ends"},{keys:["Esc"],words:"clear"}]}function jt(t,e,n){const a=n.prefix,s=ue(n.base),o=t.type==="sequence"||t.type==="schema"?null:_t(t),r={P:a,ids:s,level:n.level,plan:o,hidden:n.hiddenClass},i=e.layout==="drawn",f=ft(t,e),p=t.type==="sequence"||t.type==="schema"?i:!0,h=`h${t.heading}`,u=[`--_cols:${vt(t)}`];if(t.type==="architecture"&&t.groups.length||i&&e.pad){const l=t.type==="architecture"?t.groups.flatMap(c=>c.members.map(g=>t.byId.get(g))):[],m=(c,g,$)=>c?`var(--basalt-space-${g})`:$?`var(--basalt-space-${$})`:"0px",b=i&&e.pad?"3":void 0;u.push(`--_gpad:${m(l.some(c=>c.row===1),"8",b)} ${m(l.some(c=>c.col===t.cols),"4")} ${m(l.some(c=>c.row2===t.rows),"4",b)} ${m(l.some(c=>c.col===1),"4")}`)}return t.type==="schema"&&e.track&&u.push(`--_track:${e.track}px`),x("figure",{class:n.className?`${a} ${n.className}`:a,"aria-labelledby":s.title,"data-type":t.type,"data-cols":vt(t),"data-reach":t.type==="architecture"?Ot(t):void 0,"data-gutter":o?.gutter?"":void 0,"data-layout":e.layout,"data-measured":e.layout?"":void 0,"data-bare":e.bare?"":void 0,"data-motion":t.motion.animated?"animated":void 0,style:u.join(";")},x("div",{class:`${a}-head`},x(h,{id:s.title,class:`${a}-title`},t.title),n.hasSource?x("p",{class:`${a}-source`},{slot:"source"}):null),x("div",{class:`${a}-drawing`,role:p?"group":void 0,"aria-roledescription":p?"diagram":void 0,"aria-labelledby":p?s.title:void 0,"aria-describedby":p?f?`${s.summary} ${s.keys}`:s.summary:void 0,"data-stops":f?"":void 0},$e(r,t,e),x("div",{class:`${a}-ink`,"aria-hidden":"true"}),x("span",{class:`${a}-ruler`,"aria-hidden":"true"})),pe(a,t),x("p",{class:`${a}-hint`,"data-kbd-hint":"","aria-hidden":"true"},{slot:"hint"}),x("div",{class:`${a}-foot`},{slot:"toggle"}),x("div",{id:s.list,class:`${a}-list`,hidden:!e.open},xe(a,t)),x("span",{id:s.keys,class:n.hiddenClass},Me(t)),x("figcaption",{id:s.summary,class:`${a}-summary`},{slot:"summary"}))}function Se(t){const e=getComputedStyle(t),n=(s,o)=>{const r=parseFloat(e.getPropertyValue(`--basalt-${s}`));return Number.isFinite(r)?r:o},a=new Map;return{space:s=>(a.has(s)||a.set(s,n(`space-${s}`,parseFloat(s.replace("-","."))*4)),a.get(s)),node:n("size-diagram-node",144),table:n("size-diagram-table",224),lane:n("size-diagram-lane",120),step:n("size-diagram-step",56),head:n("size-diagram-head",8),guide:n("size-diagram-guide-dash",4),hair:n("size-hairline",1),line:n("size-chart-line",2),cut:n("size-cut",2),dot:n("size-dot",6),dash:n("size-chart-dash",6),dashGap:n("size-chart-dash-gap",4),wide:n("size-breakpoint-container-lg",640),cap:n("size-breakpoint-container",480),radius:n("radius-md",8),radiusXs:n("radius-xs",4)}}var $t=(t,e)=>t==="main"?e.line:e.hair,lt=(t,e)=>{const n=t.getBoundingClientRect();return{l:n.left-e.left,t:n.top-e.top,r:n.right-e.left,b:n.bottom-e.top}},ct=(t,e,n=.01)=>t.le.l+n&&t.te.t+n,Tt=(t,e)=>({l:t.l-e,r:t.r+e,t:t.t-e,b:t.b+e});function rt(t,e,n){const{l:a,t:s,r:o,b:r}=t.rect,i=(a+o)/2,f=(s+r)/2,p=(o-a)/2,h=(r-s)/2,u=e==="top"||e==="bottom";if(t.shape==="decision"){if(u){const b=n,c=h*Math.max(0,1-Math.abs(b-i)/p);return{x:b,y:e==="top"?f-c:f+c}}const l=n,m=p*Math.max(0,1-Math.abs(l-f)/h);return{x:e==="left"?i-m:i+m,y:l}}if(t.shape==="terminal"){const l=Math.min(p,h);if(u){const g=n,$=Math.min(Math.max(g,a+l),o-l),I=g-$,k=Math.abs(I)>=l?0:Math.sqrt(l*l-I*I);return{x:g,y:Math.abs(I)<1e-6?e==="top"?s:r:e==="top"?f-k:f+k}}const m=n,b=m-f,c=Math.abs(b)>=l?0:Math.sqrt(l*l-b*b);return{x:e==="left"?a+l-c:o-l+c,y:m}}return u?{x:n,y:e==="top"?s:r}:{x:e==="left"?a:o,y:n}}function Ee(t,e,n){const{l:a,t:s,r:o,b:r}=e.rect,i=(a+o)/2,f=(s+r)/2,p=(o-a)/2,h=(r-s)/2;if(e.shape==="decision")return Math.abs(t.x-i)/p+Math.abs(t.y-f)/h<1-n/Math.min(p,h);if(e.shape==="terminal"){const u=Math.min(p,h),l=Math.min(Math.max(t.x,a+u),o-u);return Math.hypot(t.x-l,t.y-f)a+n&&t.xs+n&&t.ymatchMedia("(forced-colors: active)").matches;function qe(t,e){const n=t.querySelector(`.${e}-ruler`),a=new Map;return(s,o)=>{const r=`${o}|${s}`;return a.has(r)||(n.setAttribute("data-f",o),n.textContent=s,a.set(r,n.getBoundingClientRect().width),n.textContent=""),a.get(r)}}var wt=t=>t?t.split(/\s+/).filter(Boolean):[];function Ie(t,e,n){const a=e.space;let s=e.node,o=e.table;for(const f of t.nodes){if(f.shape==="table"){for(const m of f.columns??[]){const b=m.ref?`→ ${m.ref.table}`:m.type??"",c=a("6")+n(m.name,"mono")+(b?a("3")+n(b,"mono"):0)+2*a("3")+2*e.hair;o=Math.max(o,Math.ceil(c))}o=Math.max(o,Math.ceil(n(f.name,"table")+2*a("3")+2*e.hair));continue}const p=f.shape==="terminal"?2*a("5"):2*a("3"),h=f.mark&&!Le()?a("6"):0;let u=0;for(const m of wt(f.name))u=Math.max(u,n(m,f.shape==="decision"?"name-500":"name")+(f.kind?0:h));if(t.type!=="data-flow")for(const m of wt(f.kind))u=Math.max(u,n(m,"mono")+h);for(const m of wt(f.detail))u=Math.max(u,n(m,f.mono?"mono":"sans"));const l=f.shape==="decision"?u/.62:u+p+2*e.hair;s=Math.max(s,Math.ceil(l))}const r=vt(t);let i;return t.type==="data-flow"?i=e.lane+r*(s+a("12")):t.type==="schema"?i=r*o+(r-1)*a("12"):t.type==="sequence"?i=r*s+(r-1)*a("5"):i=r*s+(r-1)*a("16")+Ot(t)*a("4"),{track:s,table:o,least:Math.max(e.wide,i)}}function Ft(t,e){return{x:(n,a)=>a%2===1?Math.round(n+t-.5)+.5-t:Math.round(n+t)-t,y:(n,a)=>a%2===1?Math.round(n+e-.5)+.5-e:Math.round(n+e)-e}}function kt(t){const e=t[t.length-2],n=t[t.length-1];return Math.abs(e.x-n.x)<.01?n.y>e.y?"down":"up":n.x>e.x?"right":"left"}function Ht(t,e,n){const a=t.map(o=>({...o}));for(let o=1;o=2){const f=s[s.length-2];if(Math.abs(f.x-i.x)<.01&&Math.abs(i.x-r.x)<.01||Math.abs(f.y-i.y)<.01&&Math.abs(i.y-r.y)<.01){s[s.length-1]=r;continue}}s.push(r)}}return s}var dt=t=>t.slice(1).map((e,n)=>[t[n],e]);function xt(t,e,n){const a=[];for(let o=0;oMath.min(c.x,g.x)+.75&&kMath.min($.y,I.y)+.75&&Es.split(/\s+/).map(parseFloat).filter(o=>Number.isFinite(o)),a=(s,o,r)=>{const i=[];let f=o;for(const p of s)i.push([f,f+p]),f+=p+r;return i};return{cols:a(n(e.gridTemplateColumns),parseFloat(e.paddingLeft)||0,parseFloat(e.columnGap)||0),rows:a(n(e.gridTemplateRows),parseFloat(e.paddingTop)||0,parseFloat(e.rowGap)||0)}}var Q=t=>t==="left"||t==="right",Nt={top:"bottom",bottom:"top",left:"right",right:"left"};function _e(t,e){return t.row===e.row?e.col>t.col?["right","left"]:["left","right"]:t.col===e.col?e.row>t.row?["bottom","top"]:["top","bottom"]:[e.col>t.col?"right":"left",e.row>t.row?"top":"bottom"]}function Ce(t,e,n){const a=[];t.edges.forEach((o,r)=>{const i=t.byId.get(o.from),f=t.byId.get(o.to),[p,h]=e[r],u=i.row===f.row&&Q(p)&&Q(h)&&p===Nt[h]||i.col===f.col&&!Q(p)&&!Q(h)&&p===Nt[h];a.push({edge:r,end:"from",node:i,side:p,far:f,straight:u,f:.5},{edge:r,end:"to",node:f,side:h,far:i,straight:u,f:.5})});const s=new Map;for(const o of a){const r=`${o.node.id}.${o.side}`;s.has(r)||s.set(r,[]),s.get(r).push(o)}for(const[o,r]of s){if(r[0].node.shape==="decision")continue;const i=u=>Q(u.side)?u.far.row-u.node.row:u.far.col-u.node.col,f=r.filter(u=>u.straight),p=r.filter(u=>!u.straight);p.sort((u,l)=>i(u)-i(l)||(Q(u.side)?u.far.col-l.far.col:u.far.row-l.far.row)*(i(u)<0?1:-1)),r.length>3&&n(`${o.replace(".","'s ")} side has ${r.length} lines; more than three is an error: use another side`),f.length?p.forEach(u=>{u.f=i(u)<0?.25:.75}):p.length===2?(p[0].f=.25,p[1].f=.75):p.length===3?(p[0].f=.25,p[1].f=.5,p[2].f=.75):p.length>3&&p.forEach((u,l)=>{u.f=(l+1)/(p.length+1)});const h=new Map;for(const u of f)h.has(u.far.id)||h.set(u.far.id,[]),h.get(u.far.id).push(u);for(const u of h.values())u.length>1&&u.sort((l,m)=>l.edge-m.edge).forEach((l,m)=>{l.f=u.length===2?m===0?.25:.75:(m+1)/(u.length+1)})}return a}function zt(t,e,n){const{l:a,t:s,r:o,b:r}=t.rect;return Q(e)?rt(t,e,s+(r-s)*n):rt(t,e,a+(o-a)*n)}function Wt(t,e,n,a){const s=new Map;return e.querySelectorAll(`.${a}-node`).forEach(o=>{const r=t.byId.get(o.dataset.node);r&&s.set(r.id,{id:r.id,rect:lt(o,n),shape:r.shape,i:r.i})}),s}function Dt(t,e){const n=e.head,a=e.head/2,{x:s,y:o}=t.tip;return t.dir==="down"?{l:s-a,r:s+a,t:o-n,b:o}:t.dir==="up"?{l:s-a,r:s+a,t:o,b:o+n}:t.dir==="right"?{l:s-n,r:s,t:o-a,b:o+a}:{l:s,r:s+n,t:o-a,b:o+a}}var Gt=(t,e,n)=>({l:Math.min(t.x,e.x)-n/2,r:Math.max(t.x,e.x)+n/2,t:Math.min(t.y,e.y)-n/2,b:Math.max(t.y,e.y)+n/2});function Be(t,e,n,a,s,o,r,i){const f=r.space,p=[],h=[],u=[],l=[],m=f("1"),b=e.filter(c=>t.edges[c.i]?.label).sort((c,g)=>+(t.edges[g.i].kind==="main")-+(t.edges[c.i].kind==="main")||c.i-g.i);for(const c of b){const g=t.edges[c.i].label,$=i(g,"label"),I=16,k=c.pts.length-2,E=[];dt(c.pts).forEach(([w,O],C)=>{const R=Math.abs(w.y-O.y)<.01,X=R?w.x:w.y;let d=R?O.x:O.y;const y=Math.sign(d-X)||1;C===k&&(d-=y*r.head);let v=[[X,d]];for(const j of s)for(const z of R?[j.l,j.r]:[j.t,j.b]){const K=R?w.y:w.x;(R?K>j.t&&Kj.l&&Kz>Math.min(A,F)+1&&z{const K=(j+z)/2,M=R?{x:K,y:w.y}:{x:w.x,y:K};return!s.some(A=>M.x>A.l&&M.xA.t&&M.y1&&B(j,z)?1:0})}),E.sort((w,O)=>O.pri-w.pri||O.len-w.len);let _=null,J=!1;const L=(w,O=!0)=>{const C=Tt(w,m);return O&&(w.lo.r||w.to.b)||n.some(R=>Rt(C,R))||p.some(R=>ct(C,R))||a.heads.some(R=>ct(C,R))||a.rects.some(R=>ct(C,R))?!1:!e.some(R=>R.i!==c.i&&dt(R.pts).some(([X,d])=>ct(C,Gt(X,d,R.width))))};for(const w of E){for(const O of[1/2,1/3,2/3]){const C=w.p+(w.q-w.p)*O,R=[],X=f("2")+c.width/2;if(w.horiz?(w.len>=$+2*f("1")+f("3-5")&&R.push({box:{l:C-$/2-f("1"),r:C+$/2+f("1"),t:w.c-I/2,b:w.c+I/2},on:!0}),R.push({box:{l:C-$/2,r:C+$/2,t:w.c-X-I,b:w.c-X},on:!1}),R.push({box:{l:C-$/2,r:C+$/2,t:w.c+X,b:w.c+X+I},on:!1})):(w.len>=I+f("3")&&R.push({box:{l:w.c-$/2-f("1"),r:w.c+$/2+f("1"),t:C-I/2,b:C+I/2},on:!0}),R.push({box:{l:w.c+X,r:w.c+X+$,t:C-I/2,b:C+I/2},on:!1}),R.push({box:{l:w.c-X-$,r:w.c-X,t:C-I/2,b:C+I/2},on:!1})),_=R.find(d=>L(d.box))??null,_)break;!J&&R.some(d=>L(d.box,!1))&&(J=!0)}if(_)break}if(!_){u.push(c.i),J&&l.push(c.i);continue}p.push(_.box),h.push({i:c.i,text:g,box:_.box,on:_.on})}return{labels:h,unseated:u,bounded:l}}function Kt(t,e,n,a){const s=[],o=[];return t.querySelectorAll(`.${n}-gbox, .${n}-group`).forEach(r=>{if(r.getClientRects().length===0||getComputedStyle(r).display==="contents")return;const i=lt(r,e);o.push(i),s.push({l:i.l,r:i.r,t:i.t,b:i.t+1},{l:i.l,r:i.r,t:i.b-1,b:i.b},{l:i.l,r:i.l+1,t:i.t,b:i.b},{l:i.r-1,r:i.r,t:i.t,b:i.b});const f=r.querySelector(`:scope > .${n}-glabel`);f&&f.getClientRects().length&&s.push(lt(f,e))}),t.querySelectorAll(`.${n}-lane`).forEach((r,i)=>{if(!r.getClientRects().length)return;const f=lt(r,e);i>0&&s.push({l:f.l,r:f.r,t:f.t-a/2-.5,b:f.t-a/2+.5});const p=r.querySelector(`.${n}-lane-name`);p&&s.push(lt(p,e))}),{obstacles:{rects:s,heads:[]},groups:o}}function je(t,e){const{m:n,tk:a,P:s,drawing:o,origin:r,warn:i}=t,f=a.space,p=Wt(n,o,r,s),h=[...p.values()],u=Oe(o),l=r.left-Math.floor(r.left),m=r.top-Math.floor(r.top),b=Ft(l,m),c=o.clientWidth,g=o.clientHeight,$=M=>n.type==="data-flow"?M.col+1:M.col,I=parseFloat(getComputedStyle(o).rowGap)||0,k={w:c,h:g,nodes:h,lines:[],lifelines:[],labels:[],crossings:[],through:[],unseated:[],outside:[],ox:l,oy:m};if(n.type==="sequence")return Re(t,k,b);let E,_=[];n.type==="schema"?E=n.edges.map(M=>{const A=n.byId.get(M.from),F=n.byId.get(M.to);if(A.col===F.col){const S=A.col===n.cols?"left":"right";return[S,S]}return F.col>A.col?["right","left"]:["left","right"]}):(E=n.edges.map(M=>{const A=n.byId.get(M.from),F=n.byId.get(M.to),[S,q]=_e(A,F);return[M.fromSide??S,M.toSide??q]}),_=Ce(n,E,i??(()=>{})));const J=(M,A)=>{const F=o.querySelector(`.${s}-node[data-node="${CSS.escape(M)}"] .${s}-row[data-row="${A}"]`);if(!F)return 0;const S=lt(F,r);return(S.t+S.b)/2},L=n.edges.map((M,A)=>{const[F,S]=E[A],q=p.get(M.from),D=p.get(M.to),W=$t(M.kind,a);if(M.fk){const V=J(M.from,M.fromRow),et=J(M.to,M.toRow),ot=b.y(V,W),tt=b.y(et,W);return{p1:{x:F==="right"?q.rect.r:q.rect.l,y:ot},p2:{x:S==="right"?D.rect.r:D.rect.l,y:tt},r1:V,r2:Math.abs(ot-tt)<.01?V:et}}const Y=_.find(V=>V.edge===A&&V.end==="from").f,P=_.find(V=>V.edge===A&&V.end==="to").f;let G=zt(q,F,Y),N=zt(D,S,P);const U=Q(F)?G.y:G.x;let nt=Q(S)?N.y:N.x;return Q(F)?G={...G,y:b.y(G.y,W)}:G={...G,x:b.x(G.x,W)},Q(S)?N={...N,y:b.y(N.y,W)}:N={...N,x:b.x(N.x,W)},Q(F)&&Q(S)&&Math.abs(G.y-N.y)<1.01&&(N={...N,y:G.y},nt=U),!Q(F)&&!Q(S)&&Math.abs(G.x-N.x)<1.01&&(N={...N,x:G.x},nt=U),G=Q(F)?rt(q,F,G.y):rt(q,F,G.x),N=Q(S)?rt(D,S,N.y):rt(D,S,N.x),{p1:G,p2:N,r1:U,r2:nt}}),w=new Set;n.type==="schema"&&n.edges.forEach((M,A)=>{Math.abs(n.byId.get(M.from).col-n.byId.get(M.to).col)>1&&w.add(A)});const O=new Map,C=new Set;n.edges.forEach((M,A)=>{if(w.has(A))return;const[F,S]=E[A],{p1:q,p2:D}=L[A],W=n.byId.get(M.from),Y=n.byId.get(M.to);let P=null,G=null,N=!1;if(F===S){if(Q(F)){const V=F==="right"?Math.max($(W),$(Y)):Math.min($(W),$(Y))-1,et=u.cols[V-1],ot=u.cols[V];et&&ot&&(P=`c${V}`,G=[et[1],ot[0]],N=!0)}else{const V=F==="bottom"?Math.max(W.row2,Y.row2):Math.min(W.row,Y.row)-1,et=u.rows[V-1],ot=u.rows[V];et&&ot&&(P=`r${V}`,G=[et[1],ot[0]],N=!1)}P&&C.add(A)}else if(Q(F)&&Q(S)&&Math.abs(q.y-D.y)>.5){const V=$(Y),et=S==="left",ot=u.cols[(et?V-1:V)-1],tt=u.cols[(et?V:V+1)-1];ot&&tt&&(P=`c${et?V-1:V}`,G=[ot[1],tt[0]],N=!0)}else if(!Q(F)&&!Q(S)&&Math.abs(q.x-D.x)>.5){const et=S==="top"?Y.row-1:Y.row2,ot=u.rows[et-1],tt=u.rows[et];ot&&tt&&(P=`r${et}`,G=[ot[1],tt[0]],N=!1)}if(!P||!G)return;O.has(P)||O.set(P,{span:G,vertical:N,members:new Map});const U=`${M.to}.${S}.${Math.round(N?D.y:D.x)}`,nt=O.get(P);nt.members.has(U)||nt.members.set(U,[]),nt.members.get(U).push(A)});const R=new Map,X=M=>{const[A,F]=E[M],{p1:S,p2:q}=L[M];if(Q(A)&&Q(F)){if(A===F){const W=R.get(M)??(A==="right"?Math.max(S.x,q.x)+f("4"):Math.min(S.x,q.x)-f("4"));return[S,{x:W,y:S.y},{x:W,y:q.y},q]}if(Math.abs(S.y-q.y)<=.5)return[S,{x:q.x,y:S.y}];const D=R.get(M)??(S.x+q.x)/2;return[S,{x:D,y:S.y},{x:D,y:q.y},q]}if(!Q(A)&&!Q(F)){if(A===F){const W=R.get(M)??(A==="bottom"?Math.max(S.y,q.y)+f("4"):Math.min(S.y,q.y)-f("4"));return[S,{x:S.x,y:W},{x:q.x,y:W},q]}if(Math.abs(S.x-q.x)<=.5)return[S,{x:S.x,y:q.y}];const D=R.get(M)??(S.y+q.y)/2;return[S,{x:S.x,y:D},{x:q.x,y:D},q]}return Q(A)?[S,{x:q.x,y:S.y},q]:[S,{x:S.x,y:q.y},q]},d=M=>{const A=n.edges[M],F=$t(A.kind,a),S=X(M),q=Ht(S,F,b);let D;return S.length===q.length&&(D=dt(S).map(([W,Y])=>Math.abs(W.y-Y.y)<.75?(W.y+Y.y)/2:(W.x+Y.x)/2),D[0]=L[M].r1,D.length>1&&(D[D.length-1]=L[M].r2)),{i:M,from:A.from,to:A.to,kind:A.kind,pts:q,tip:q[q.length-1],dir:kt(q),dot:A.fk?q[0]:void 0,width:F,axes:D}},y=()=>n.edges.flatMap((M,A)=>w.has(A)?[]:[d(A)]);let v=null;const B=M=>{v??(v=y());const A=v.map(F=>M.has(F.i)?d(F.i):F);return{lines:A,score:Te(A,M)*1e5+xt(A,void 0,M).length*1e3+St(A.filter(F=>M.has(F.i)),h,n).length}},T=(M,A)=>{const F=M.flatMap(S=>{const{p1:q,p2:D}=L[S];return A?[q.y,D.y]:[q.x,D.x]});return[Math.min(...F),Math.max(...F)]};for(const[,M]of O){const A=[...M.members.values()].map(S=>({members:S,run:T(S,M.vertical)})).sort((S,q)=>S.run[0]-q.run[0]),F=[];for(const S of A){const q=F[F.length-1];q&&q.some(D=>D.run[0]U.members.every(nt=>C.has(nt))))continue;const q=S.map(U=>U.members),D=q.length,W=(M.span[1]-M.span[0])/(D+1);WV.forEach(ot=>R.set(ot,M.span[0]+W*(et+1))));const nt=B(Y);nt.scoreU.forEach(V=>R.set(V,M.span[0]+W*(nt+1)))),v=N}}k.lines=y();for(const M of w)i?.(`${n.edges[M].from} to ${n.edges[M].to} is two columns apart, so its line is not drawn; its row still writes the target`);k.crossings=xt(k.lines),k.through=St(k.lines,h,n),k.outside=Zt(k.lines,c,g,a);const{obstacles:j,groups:z}=Kt(o,r,s,I);j.heads=k.lines.map(M=>Dt(M,a));const K=Be(n,k.lines,h,j,z,{l:0,t:0,r:c,b:g},a,e);return k.labels=K.labels,k.unseated=K.unseated,k.bounded=K.bounded,k}function Te(t,e){let n=0;for(let a=0;a=i)continue;const[g,$]=l?[f.x,p.x]:[f.y,p.y],[I,k]=l?[h.x,u.x]:[h.y,u.y];Math.min(Math.max(g,$),Math.max(I,k))-Math.max(Math.min(g,$),Math.min(I,k))>1&&n++}}return n}function*Vt(t){if(t.length<=1){yield t.slice();return}if(t.length>5){yield t.slice();return}for(let e=0;e{const f=i===o.pts.length-1?Math.max(o.width/2,a.head/2):o.width/2;return r.x-f<-.5||r.x+f>e+.5||r.y-f<-.5||r.y+f>n+.5})&&s.push(o.i);return s}function St(t,e,n){const a=[];for(const s of t){const o=dt(s.pts);e.some(r=>o.some(([i,f])=>Ae(i,f,r)))&&a.push(s.i)}return a}function Re(t,e,n){const{m:a,tk:s,P:o,drawing:r,origin:i}=t,f=s.space,p=new Map;r.querySelectorAll(`.${o}-node`).forEach(b=>p.set(b.dataset.node,lt(b,i)));const h=r.querySelector(`.${o}-steps`),u=h?lt(h,i).b:e.h,l=b=>{const c=p.get(b);return c?n.x((c.l+c.r)/2,s.hair):0};for(const b of a.nodes){const c=p.get(b.id);c&&e.lifelines.push({x:l(b.id),y1:c.b,y2:u})}const m=b=>p.get(b.id);return r.querySelectorAll(`.${o}-msg`).forEach(b=>{const c=b.dataset.from,g=b.dataset.to,$=b.dataset.kind??"plain",I=$t($,s),k=lt(b,i),E=n.y((k.t+k.b)/2,I),_=Number(b.querySelector(`.${o}-num`)?.textContent??0),J=l(c),L=l(g);let w;if(c===g){const v=b.dataset.self==="start"?-f("6"):f("6"),B=n.y(E-f("2"),I),T=n.y(E+f("2"),I);w=[{x:J,y:B},{x:n.x(J+v,I),y:B},{x:n.x(J+v,I),y:T},{x:J,y:T}]}else w=[{x:J,y:E},{x:L,y:E}];e.lines.push({i:_,from:c,to:g,kind:$,pts:w,tip:w[w.length-1],dir:kt(w),width:I});const O=b.querySelector(`.${o}-said`),C=b.querySelector(`.${o}-note`),R=a.byId.get(c),X=a.byId.get(g);if(!R||!X)return;const d=c===g?(()=>{const v=a.nodes[R.i+(b.dataset.self==="start"?-1:1)],B=v?l(v.id):b.dataset.self==="start"?0:e.w;return Math.abs(B-J)-f("6")-f("2-5")-f("2")})():Math.abs(L-J)-2*f("2");Math.max(O?O.getBoundingClientRect().width:0,C?C.getBoundingClientRect().width:0)>d+.5&&e.unseated.push(_)}),e}function Jt(t,e,n,a=ut()){const{m:s,tk:o,P:r,drawing:i,origin:f}=t,p=o.space,h=Wt(s,i,f,r),u=[...h.values()],l=f.left-Math.floor(f.left),m=f.top-Math.floor(f.top),b=Ft(l,m),c=i.clientWidth,g=i.clientHeight,$={w:c,h:g,nodes:u,lines:[],lifelines:[],labels:[],crossings:[],through:[],unseated:[],outside:[],ox:l,oy:m},I=ut();if(s.type==="sequence"||s.type==="schema")return{geo:$,grow:I};const k=c-(parseFloat(getComputedStyle(i).paddingRight)||0),E=(d,y,v)=>{const B=[d];for(let T=1;T<=(ht(a,y)??0);T++)B.push({...d,t:d.t+v*p("4")*T,b:d.b+v*p("4")*T});return B},_=new Map;i.querySelectorAll(`.${r}-node`).forEach(d=>{const y=d.parentElement,v=lt(y,f),B=getComputedStyle(y);_.set(d.dataset.node,v.r-(parseFloat(B.paddingRight)||0)-(parseFloat(B.borderRightWidth)||0))});const J=s.nodes,L=d=>h.get(J[d].id),w=[],O=d=>$t(s.edges[d].kind,o);s.edges.forEach((d,y)=>{const v=n.routes[y],B=h.get(d.from),T=h.get(d.to),j=O(y);let z=[];const K=d.label,M=K?e(K,"label"):0,A=16,F=p("4");if(v==="down"||v==="up"){const q=Math.max(B.rect.l,T.rect.l),D=Math.min(B.rect.r,T.rect.r),W=s.edges.map((N,U)=>({o:N,j:U})).filter(({o:N,j:U})=>(n.routes[U]==="down"||n.routes[U]==="up")&&(N.from===d.from&&N.to===d.to||N.from===d.to&&N.to===d.from)),Y=W.findIndex(N=>N.j===y),P=W.length<2?.5:W.length===2?Y===0?.25:.75:(Y+1)/(W.length+1),G=b.x(q+(D-q)*P,j);if(z=v==="down"?[rt(B,"bottom",G),rt(T,"top",G)]:[rt(B,"top",G),rt(T,"bottom",G)],K){let N=Math.min(z[0].y,z[1].y),U=Math.max(z[0].y,z[1].y);v==="down"?U-=o.head:N+=o.head;const nt=[...i.querySelectorAll(`.${r}-group`)].map(tt=>lt(tt,f));let V=[[N,U]];for(const tt of nt)for(const H of[tt.t,tt.b])V=V.flatMap(([Z,st])=>H>Z+1&&Hnt.some(Z=>(tt+H)/2>Z.t&&(tt+H)/2Z.l&&G1){const tt=V.filter(([Z,st])=>!et(Z,st));[N,U]=(tt.length?tt:V).reduce((Z,st)=>st[1]-st[0]>Z[1]-Z[0]?st:Z)}const ot=[1/2,1/3,2/3].map(tt=>{const H=N+(U-N)*tt;return{l:G-M/2-p("1"),r:G+M/2+p("1"),t:H-A/2,b:H+A/2}});w.push({k:y,cands:ot,on:!0,card:v==="down"?d.to:d.from})}}else if(v==="trunk"||v==="rail"){const q=b.x(Math.max(B.rect.l,v==="rail"?T.rect.l:B.rect.l)+p(v==="trunk"?"8":"3"),j),D=rt(B,"bottom",q);if(v==="rail"){if(z=[D,rt(T,"top",q)],K){const W=T.rect.t-p("6");w.push({k:y,cands:E({l:q+p("2-5"),r:q+p("2-5")+M,t:W-A/2,b:W+A/2},d.to,-1),on:!1,card:d.to})}}else{const W=b.x(T.rect.l+p("6"),j),Y=b.y(T.rect.t-F,j);z=[D,{x:q,y:Y},{x:W,y:Y},rt(T,"top",W)],K&&w.push({k:y,cands:E({l:W+p("2-5"),r:W+p("2-5")+M,t:Y-A/2,b:Y+A/2},d.to,-1),on:!1,card:d.to})}}else{const q=Math.min(_.get(d.from)??c,_.get(d.to)??c),D=b.x(n.gutter?k+(n.lanes[y]?2*p("3-5"):p("3-5")):q-p("2-5"),j),W=b.y(B.rect.t+(B.rect.b-B.rect.t)*n.exits[y],j),Y=rt(B,"right",W),P=b.x(T.rect.r-p("6"),j),G=v==="end-down",N=b.y(G?T.rect.t-F:T.rect.b+F,j);z=[Y,{x:D,y:Y.y},{x:D,y:N},{x:P,y:N},rt(T,G?"top":"bottom",P)];const U=G?d.to:J[T.i+1]?.id??d.to;K&&w.push({k:y,cands:E({l:P-p("2-5")-M,r:P-p("2-5"),t:N-A/2,b:N+A/2},U,G?-1:1),on:!1,card:U})}const S=Ht(z,j,b);$.lines.push({i:y,from:d.from,to:d.to,kind:d.kind,pts:S,tip:S[S.length-1],dir:kt(S),width:j})}),$.crossings=xt($.lines),$.through=St($.lines,u,s),$.outside=Zt($.lines,c,g,o);const{obstacles:C}=Kt(i,f,r,0);C.heads=$.lines.map(d=>Dt(d,o));const R=[],X={l:0,t:0,r:c,b:g};for(const d of w){const y=T=>{const j=Tt(T,p("1"));return T.lX.r+.5||T.tX.b+.5||u.some(z=>Rt(j,z))||R.some(z=>ct(j,z))||C.heads.some(z=>ct(j,z))||C.rects.some(z=>ct(j,z))||$.lines.some(z=>z.i!==d.k&&dt(z.pts).some(([K,M])=>ct(j,Gt(K,M,z.width))))},v=d.cands.find(T=>!y(T));v||(I[d.card]=(I[d.card]??0)+1,$.unseated.push(d.k));const B=v??d.cands[0];R.push(B),$.labels.push({i:d.k,text:s.edges[d.k].label,box:B,on:d.on})}return{geo:$,grow:I}}function Fe(t,e){const n=o=>String(Math.round(o*100)/100);let a=`M${n(t[0].x)} ${n(t[0].y)}`;for(let o=1;o({...E})),u=h[h.length-1];u.x-=o.x*p,u.y-=o.y*p;const l=e.tip.x-o.x*i,m=e.tip.y-o.y*i,b=-o.y*f,c=o.x*f,g=E=>Math.round(E*100)/100,$=it(e.kind),I=r?``:``,k=e.dot?``:"";return`${I}${k}`}function Ut(t,e,n,a){const s=new Map,o=new Map;for(const i of e.crossings)o.has(i.under)||o.set(i.under,[]),o.get(i.under).push(i);let r="";for(const[i,f]of o){const p=`${a}-cut-${i}`;s.set(i,p);const h=f.map(u=>{const l=e.lines[u.top],m=e.lines[u.under],b=l.width/2+n.cut,c=m.width/2+1;return u.underVertical?``:``}).join("");r+=`${h}`}return{defs:r,ids:s}}function Xt(t,e,n,a){const{defs:s,ids:o}=Ut(t,e,n,a),r=e.lifelines.map(h=>``).join(""),i=e.lines.map((h,u)=>Ne(t,h,n,o.get(u)??null,h.from===h.to?n.radiusXs:n.radius)).join(""),f=``,p=e.labels.map(h=>`${it(h.text)}`).join("");return f+p}function ze(t,e,n,a,s,o,r){const i=t.querySelector(`.${n}-drawing`);if(!i||t.clientWidth===0)return{dyn:s,geo:null,ink:"",tokens:null};const f=Se(t),p=qe(i,n),h=Ie(e,f,p),u=t.clientWidth,l=(()=>{const L=document.activeElement;return L&&i.contains(L)&&L.dataset.node?L.dataset.node:void 0})(),m=L=>ft(e,L)?{...L,stop:L.stop&&e.byId.has(L.stop)?L.stop:e.nodes[0]?.id,keep:void 0}:{...L,stop:L.stop??e.nodes[0]?.id,keep:l&&L.layout!=="drawn"?l:void 0},b=L=>{if(e.type!=="flowchart")return L;o({...L,heights:void 0});const w=ut();return i.querySelectorAll(`.${n}-node[data-shape="decision"]`).forEach(O=>{const C=O.querySelector(`.${n}-words`);if(!C)return;const R=O.getBoundingClientRect(),X=C.getBoundingClientRect(),d={w:X.width+2*f.space("2-5"),h:X.height+2*f.space("2")},y=R.width/2,v=1-d.w/2/y,B=v>.05?d.h/2/v:d.h*10;w[O.dataset.node]=Math.max(f.space("16"),Math.ceil(R.width/5),Math.ceil(2*B))}),{...L,heights:w}},c=()=>({m:e,tk:f,P:n,drawing:i,origin:i.getBoundingClientRect(),warn:r}),g=s.autoOpen?{open:!1,autoOpen:void 0}:{},$=(L,w)=>w.map(O=>yt(e,L.lines.find(C=>C.i===O))).join(", ");if(u>=h.least){const L=C=>{let R=m({...s,...g,layout:"drawn",grow:void 0,track:void 0,bare:void 0,pad:C||void 0});return R=b(R),o(R),{dd:R,g:je(c(),p)}};let{dd:w,g:O}=L(!1);if(!O.through.length&&!O.outside.length&&O.unseated.length&&O.unseated.every(C=>O.bounded?.includes(C))){const C=L(!0);!C.g.through.length&&!C.g.unseated.length&&!C.g.outside.length&&({dd:w,g:O}=C)}if(!O.through.length&&!O.unseated.length&&!O.outside.length)return O.crossings.length&&r?.(`${O.crossings.length} crossing${O.crossings.length===1?"":"s"} in the drawn layout: ${O.crossings.map(C=>`${yt(e,O.lines[C.top])} over ${yt(e,O.lines[C.under])}`).join("; ")}`),{dyn:w,geo:O,ink:Xt(n,O,f,a),tokens:f};O.through.length&&r?.(`the drawn layout does not fit at ${Math.round(u)}px: ${$(O,O.through)} would pass through a node`),O.outside.length&&r?.(`the drawn layout does not fit at ${Math.round(u)}px: ${$(O,O.outside)} would leave the drawing`),O.unseated.length&&r?.(`the drawn layout does not fit at ${Math.round(u)}px: no clean seat for ${O.unseated.map(C=>e.type==="sequence"?`message ${C}`:`"${e.edges[C]?.label}"`).join(", ")}`)}let I=m({...s,...g,layout:"stacked",heights:void 0,grow:ut(),track:e.type==="schema"?h.table:void 0,bare:void 0,pad:void 0});if(I=b(I),o(I),e.type==="sequence"||e.type==="schema")return{dyn:I,geo:null,ink:"",tokens:f};const k=_t(e);let E=Jt(c(),p,k,I.grow);for(let L=0;L<6&&Object.keys(E.grow).length;L++){const w=ut(I.grow);for(const[O,C]of Object.entries(E.grow))w[O]=(ht(w,O)??0)+C;I={...I,grow:w},o(I),E=Jt(c(),p,k,w)}const _=E.geo;if(_.unseated.length>0||_.through.length>0||_.outside.length>0||k.third){_.unseated.length&&r?.(`the stacked drawing has no clean seat for ${[...new Set(_.unseated)].map(O=>`"${e.edges[O]?.label}"`).join(", ")}, so its lines are not drawn; the list holds every connection`),_.through.length&&r?.(`in the stacked drawing ${$(_,_.through)} would pass through a node, so its lines are not drawn`),_.outside.length&&r?.(`in the stacked drawing ${$(_,_.outside)} would leave the drawing, so its lines are not drawn`),k.third&&r?.("the stacked drawing would need a third end lane, so its lines are not drawn");const L={..._,lines:[],labels:[],crossings:[]};return{dyn:m({...I,grow:ut(),bare:!0,open:s.bare?s.open:!0,autoOpen:s.bare?s.autoOpen:s.open?void 0:!0}),geo:L,ink:"",tokens:f}}return _.crossings.length&&r?.(`${_.crossings.length} crossing${_.crossings.length===1?"":"s"} in the stacked drawing (each is cut): ${_.crossings.map(L=>`${yt(e,_.lines[L.top])} over ${yt(e,_.lines[L.under])}`).join("; ")}`),{dyn:I,geo:_,ink:Xt(n,_,f,a),tokens:f}}function yt(t,e){const n=t.byId.get(e.from)?.name??e.from,a=t.byId.get(e.to)?.name??e.to;return`${n} to ${a}`}function We(t,e,n,a,s,o){const r=new Set;if(o){r.add(o);for(const c of n?.lines??[])c.from===o&&r.add(c.to),c.to===o&&r.add(c.from)}if(t.toggleAttribute("data-tracing",!!o),t.querySelectorAll(`.${e}-node`).forEach(c=>c.toggleAttribute("data-near",r.has(c.dataset.node))),!n||!a)return;const i=c=>!!o&&(c.from===o||c.to===o),f=t.querySelector(`.${e}-edges`),p=new Map;t.querySelectorAll(`.${e}-edge`).forEach(c=>p.set(c.getAttribute("data-edge"),c));for(const c of n.lines){const g=p.get(String(c.i));g&&(g.toggleAttribute("data-lit",i(c)),g.toggleAttribute("data-dim",!!o&&!i(c)))}if(t.querySelectorAll(`.${e}-label`).forEach(c=>{const g=n.lines.find($=>String($.i)===c.dataset.edge);c.toggleAttribute("data-lit",!!(g&&i(g)))}),f){for(const c of n.lines)if(i(c)){const g=p.get(String(c.i));g&&f.appendChild(g)}}const h=xt(n.lines,i),{defs:u,ids:l}=Ut(e,{...n,crossings:h},a,s),m=t.querySelector(`.${e}-svg`);if(!m)return;let b=m.querySelector("defs");!b&&u&&(b=document.createElementNS("http://www.w3.org/2000/svg","defs"),m.insertBefore(b,m.firstChild)),b&&(b.innerHTML=u),n.lines.forEach((c,g)=>{const $=p.get(String(c.i))?.querySelector(`.${e}-line`);if(!$)return;const I=l.get(g);I?$.setAttribute("mask",`url(#${I})`):$.removeAttribute("mask")})}var De=()=>matchMedia("(prefers-reduced-motion: reduce), (forced-colors: active), print").matches||document.documentElement.getAttribute("data-loops")==="held";function Ge(t,e){const n=t.getAttribute("data-entrance");if(!(n==="running"||n==="done")){if(!e){n&&t.removeAttribute("data-entrance");return}n||t.setAttribute("data-entrance",De()?"done":"pending")}}function Ke(t){const e=t.getAttribute("data-entrance");e!=="pending"&&e!=="running"||(t.setAttribute("data-entrance","done"),t.dispatchEvent(new Event("basalt-diagram-settle")))}function Ve(t,e,n){const a=t.byId.get(e)?.i??0,s=t.nodes.length;let o;if(n==="ArrowRight"||n==="ArrowDown")o=a+1;else if(n==="ArrowLeft"||n==="ArrowUp")o=a-1;else if(n==="Home")o=0;else if(n==="End")o=s-1;else return null;return t.nodes[Math.max(0,Math.min(s-1,o))].id}var Ze=["data-layout","data-measured","role","aria-roledescription","aria-labelledby","aria-describedby","aria-label","tabindex","data-stops","hidden"],Yt=["data-layout","data-measured","data-bare","data-motion"],Je=["--_track","--_h","--_gap","--_ggrow","--_gpad"],Qt=t=>t==null||t===!1;function Ue(t,e){if(t.tagName.toLowerCase()!==e.t)return!1;const n=typeof e.a.class=="string"?e.a.class.split(" ")[0]:"";return!n||t.classList.contains(n)}function Pt(t,e,n=!0){if(typeof e=="string"||"slot"in e)return;const a=n?Yt:Ze;for(const r of a)Qt(e.a[r])&&t.removeAttribute(r);for(const[r,i]of Object.entries(e.a)){if(r==="class")continue;if(r==="style"){const p=t.style,h=new Map(String(i??"").split(";").map(u=>{const l=u.indexOf(":");return[u.slice(0,l).trim(),u.slice(l+1).trim()]}).filter(([u])=>u));for(const[u,l]of h)p.getPropertyValue(u).trim()!==l&&p.setProperty(u,l);for(const u of Je)h.has(u)||p.removeProperty(u);continue}if(n&&!Yt.includes(r))continue;if(Qt(i)){t.removeAttribute(r);continue}const f=i===!0?"":String(i);t.getAttribute(r)!==f&&t.setAttribute(r,f)}if(e.t==="svg"||typeof e.a.class=="string"&&/-(ink|ruler)$/.test(e.a.class)||e.c.some(r=>typeof r!="string"&&"slot"in r))return;const s=[...t.children];let o=0;for(const r of e.c)if(!(typeof r=="string"||"slot"in r)){for(let i=o;it.querySelector(`.${e}-node[data-node="${CSS.escape(o)}"]`);n&&s(n)?.setAttribute("tabindex","-1"),s(a)?.setAttribute("tabindex","0")}(function(t){"use strict";var e=t._,n="diagram",a=0;function s(l,m){return{prefix:n,base:l,hasSource:m.source!==void 0&&m.source!==null&&m.source!=="",hiddenClass:"visually-hidden"}}function o(l,m,b,c){var g=function($){return''+it($)+""};return{source:it(String(m.source||"")),summary:it(String(m.summary||"")),hint:ke(l).map(function($){return""+$.keys.map(g).join(" ")+" "+it($.words)+""}).join(""),toggle:'"}}function r(l,m){var b=Et(l),c=jt(b,{},s(m,l)),g=It(c,o(b,l,m,!1)),$=g.indexOf(">");return{open:g.slice(0,$+1),inner:g.slice($+1,g.length-9),warnings:b.warnings}}var i=["aria-labelledby","data-type","data-cols","data-reach","data-gutter","data-layout","data-measured","data-bare"],f=["--_cols","--_gpad","--_track"];function p(l,m,b){l.__diagram&&l.__diagram.stop();var c=(l.getAttribute("aria-labelledby")||"").replace(/-title$/,"").replace(/[^A-Za-z0-9_-]/g,""),g=Et(m);if(!b||!c||!l.querySelector(":scope > .diagram-drawing")){if(!c||!l.querySelector("#"+CSS.escape(c+"-title"))){for(;document.getElementById("dg"+ ++a+"-title"););c="dg"+a}var $=r(m,c),I=document.createElement("div");I.innerHTML=$.open+"";var k=I.firstChild;i.forEach(function(H){l.removeAttribute(H)}),f.forEach(function(H){l.style.removeProperty(H)});for(var E=0;E :not(script[data-diagram])").forEach(function(H){H.remove()}),l.insertAdjacentHTML("beforeend",$.inner)}g.warnings.forEach(function(H){console.warn("Basalt diagram: "+H)});var J=s(c,m),L={},w=null,O=null,C=null,R=Object.create(null),X=function(H){R[H]||(R[H]=1,console.warn("Basalt diagram: "+H))},d=function(H){Pt(l,jt(g,H,J))},y=l.querySelector(".diagram-ink"),v=l.querySelector(".diagram-toggle"),B=g.motion.animated&&typeof e.diagramMotion=="function",T=null,j=null,z=function(){B&&Ke(l)};function K(){We(l,n,w&&w.geo,w&&w.tokens,c,O||C)}function M(){v&&(v.setAttribute("aria-expanded",String(!!L.open)),v.firstElementChild.textContent=L.open?"Hide the list":"View as list")}function A(){w=ze(l,g,n,c,L,d,X),L=w.dyn,d(L),M(),ft(g,L)||(C=null);var H=y&&w.ink!==j;H&&(y.innerHTML=w.ink,j=w.ink),K(),B&&w.tokens&&(Ge(l,!!(w.geo&&w.geo.lines.length)),H&&T&&T.redrawn())}function F(H){L=H,d(L)}function S(H){var Z=L.stop;L=Object.assign({},L,{stop:H}),Xe(l,n,Z,H)}var q=function(H){var Z=H&&H.closest?H.closest(".diagram-node"):null;return Z&&l.contains(Z)?Z:null};function D(H){var Z=q(H.target);if(!(!Z||H.defaultPrevented)){if(z(),H.key==="Escape"){(O||C)&&(H.preventDefault(),O=C=null,K());return}if(ft(g,L)){var st=Ve(g,Z.getAttribute("data-node"),H.key);if(st){H.preventDefault(),S(st);var te=l.querySelector('.diagram-node[data-node="'+CSS.escape(st)+'"]');te&&te.focus()}}}}function W(H){var Z=q(H.target);if(Z){z();var st=Z.getAttribute("data-node");O=Z.matches(":focus-visible")?st:null,ft(g,L)&&L.stop!==st&&S(st),K()}}function Y(H){var Z=q(H.target);Z&&(q(H.relatedTarget)||(O=null),L.keep===Z.getAttribute("data-node")&&F(Object.assign({},L,{keep:void 0})),K())}function P(H){if(!(H.pointerType!=="mouse"||!matchMedia("(hover: hover)").matches)){var Z=q(H.target);Z&&z();var st=Z&&ft(g,L)?Z.getAttribute("data-node"):null;st!==C&&(C=st,K())}}function G(){C&&(C=null,K())}function N(){z(),F(Object.assign({},L,{open:!L.open,autoOpen:void 0})),M()}l.addEventListener("keydown",D),l.addEventListener("focusin",W),l.addEventListener("focusout",Y),l.addEventListener("pointerover",P),l.addEventListener("pointerleave",G),v&&v.addEventListener("click",N),A();var U=l.clientWidth,nt=0,V=!0,et=new ResizeObserver(function(){Math.abs(l.clientWidth-U)<.5||(U=l.clientWidth,cancelAnimationFrame(nt),nt=requestAnimationFrame(A))});et.observe(l),document.fonts&&document.fonts.ready.then(function(){V&&A()});var ot=matchMedia("(forced-colors: active)"),tt=g.nodes.some(function(H){return H.mark});tt&&ot.addEventListener("change",A),B&&(T=e.diagramMotion(l,{fig:l,P:n,base:c,model:function(){return g},geo:function(){return w&&w.geo},tokens:function(){return w&&w.tokens}},m)),l.__diagram={stop:function(){V=!1,et.disconnect(),cancelAnimationFrame(nt),tt&&ot.removeEventListener("change",A),T&&T.destroy(),l.removeEventListener("keydown",D),l.removeEventListener("focusin",W),l.removeEventListener("focusout",Y),l.removeEventListener("pointerover",P),l.removeEventListener("pointerleave",G),v&&v.removeEventListener("click",N)},layout:A,key:h(m),send:T&&T.sendValue?T.sendValue:null}}function h(l){try{return JSON.stringify(l,function(m,b){return m==="packet"&&b&&typeof b=="object"?Object.assign({},b,{send:void 0}):b})}catch{return null}}function u(){document.querySelectorAll("figure.diagram").forEach(function(l){if(!l.__diagram){var m=l.querySelector(":scope > script[data-diagram]");if(m)try{p(l,JSON.parse(m.textContent),!0)}catch(b){console.error("Basalt diagram: this figure could not be drawn",b)}}})}e.diagramMarkup=r,t.diagram=function(l,m){var b=l.__diagram,c=b&&b.send?h(m):null;if(c!==null&&c===b.key){b.send(m.packet?m.packet.send:void 0);return}p(l,m)},e.step(62,"wireDiagrams",u)})(window.Basalt)})();
+(()=>{var se=["top","right","bottom","left"],ae=["main","plain","dashed"],re=[2,3,4,5,6],at=t=>t==null||t===""?void 0:String(t),ut=t=>Object.assign(Object.create(null),t),ft=(t,e)=>t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;function Et(t,e={}){const s=e.checks!==!1,a=[],o=f=>{a.push(f)},r=t.legend??{},l={};for(const f of["main","plain","dashed","focal","group"]){const m=at(r[f]);m&&(l[f]=m)}const h=t.stepLabel,u=typeof h=="function"?f=>String(h(f)):typeof h=="string"?(f=>h.replace("{n}",String(f))):f=>`Step ${f}`,p=t.shapeLabels??{},g={terminal:at(p.terminal)??"Start or end",step:at(p.step)??"Step",decision:at(p.decision)??"Decision"},c=t.heading===void 0?3:re.includes(t.heading)?t.heading:(o(`heading ${String(t.heading)} is not a level from 2 to 6: the title is an h3`),3),y=(f,m)=>f==null?"plain":ae.includes(f)?f:(o(`"${String(f)}" is not a kind of line (main, plain or dashed): ${m} is drawn plain`),"plain"),b=f=>{if(f!=null){if(se.includes(f))return f;o(`"${String(f)}" is not a side (top, right, bottom or left): the derived side is used`)}},i=(f,m)=>typeof f=="number"&&Number.isInteger(f)&&f>=1?f:(o(`${m} is ${JSON.stringify(f)}, not a whole number from 1: it is placed at 1`),1),d=[],w=[];let q=[];const L=[],O=[],F=t.type;if(["architecture","flowchart","data-flow","sequence","schema"].includes(F)||o(`"${String(F)}" is not a type of diagram (architecture, flowchart, data-flow, sequence or schema)`),F==="architecture"||F==="flowchart"){for(const f of t.nodes??[]){const m=F==="flowchart"&&f.shape==="decision"?"decision":F==="flowchart"&&f.shape==="terminal"?"terminal":"box",A=String(f.id??""),S=i(f.row,`the row of ${A}`);d.push({id:A,i:d.length,name:String(f.name??""),kind:m==="decision"?void 0:at(f.kind),detail:m==="decision"?void 0:at(f.detail),mono:!!f.detailMono,focal:!!f.focal,col:i(f.col,`the column of ${A}`),row:S,row2:S,branch:!!f.branch,shape:m,group:F==="architecture"?at(f.group):void 0,mark:F==="architecture"?ie(f.mark):void 0})}if(F==="architecture")for(const f of t.groups??[]){const m=String(f.id??"");L.push({id:m,label:String(f.label??""),members:d.filter(A=>A.group===m).map(A=>A.id)})}}else if(F==="data-flow"){q=(t.lanes??[]).map(m=>({id:String(m.id??""),label:String(m.label??"")}));const f=new Map(q.map((m,A)=>[m.id,A+1]));for(const m of t.nodes??[]){const A=String(m.id??""),S=String(m.lane??""),z=f.get(S);z===void 0&&o(`a node (${A}) names the lane "${S}", which is not in lanes`);const C=d.length+1;d.push({id:A,i:d.length,name:String(m.name??""),kind:u(C),detail:at(m.detail),mono:!!m.detailMono,focal:!!m.focal,col:i(m.col,`the column of ${A}`),row:z??1,row2:z??1,branch:!1,shape:"box",lane:z??1,laneLabel:q[(z??1)-1]?.label??S,step:C})}}else if(F==="sequence"){(t.participants??[]).forEach((m,A)=>{const S=String(m.name??"");d.push({id:String(m.id??""),i:A,name:S,kind:at(m.kind),mono:!1,focal:!!m.focal,col:A+1,row:1,row2:1,branch:!1,shape:"participant",short:at(m.short)??S})});let f=0;for(const m of t.steps??[])"band"in m?O.push({band:String(m.band??"")}):(f++,O.push({n:f,from:String(m.from??""),to:String(m.to??""),label:String(m.label??""),note:at(m.note),kind:y(m.kind,`message ${f}`)}))}else if(F==="schema")for(const f of t.tables??[]){const m=String(f.name??""),[A,S]=Array.isArray(f.row)?f.row:[f.row,f.row],z=i(A,`the row of ${m}`),C=Math.max(z,i(S,`the last row of ${m}`)),K=f.more===void 0||f.more===null?void 0:Number.isInteger(f.more)&&f.more>0?f.more:(o(`${m}'s "more" is ${JSON.stringify(f.more)}, not a whole number from 1: it is left out`),void 0);d.push({id:m,i:d.length,name:m,mono:!0,focal:!!f.focal,col:i(f.col,`the column of ${m}`),row:z,row2:C,branch:!1,shape:"table",more:K,columns:(f.columns??[]).map(W=>({name:String(W.name??""),type:at(W.type),key:W.key==="PK"||W.key==="FK"?W.key:(W.key!==void 0&&W.key!==null&&o(`${m}.${String(W.name)}'s key is "${String(W.key)}", not PK or FK: it is left out`),void 0)}))})}const _=new Map;for(const f of d)f.id?_.has(f.id)&&o(`the id "${f.id}" is used twice`):o("a node has no id"),_.set(f.id,f);if(F==="schema")(t.tables??[]).forEach(f=>(f.columns??[]).forEach((m,A)=>{const S=at(m.references);if(!S)return;const[z,C]=S.split("."),K=_.get(z??""),W=K?.columns?.findIndex(T=>T.name===C)??-1;if(!K||W<0){o(`${String(f.name)}.${String(m.name)} references ${S}, which is not a shown column`);return}const M=_.get(String(f.name??""));M.columns[A].ref={table:z,column:C,row:W},w.push({i:w.length,from:M.id,to:z,kind:"plain",fromRow:A,toRow:W,fk:!0})}));else if(F!=="sequence")for(const f of t.edges??[]){const m=String(f.from??""),A=String(f.to??"");if(!_.has(m)||!_.has(A)){o(`a line names ${_.has(m)?A:m}, which is not a node`);continue}const S=at(f.label);S&&S.length>Lt&&o(`the label "${S}" is over ${Lt} characters: longer words belong in the node or the summary`),w.push({i:w.length,from:m,to:A,kind:y(f.kind,`the line from ${m} to ${A}`),label:S,fromSide:b(f.fromSide),toSide:b(f.toSide),flow:F!=="flowchart"&&f.flow===!0?!0:void 0})}else for(const f of O)"n"in f&&(!_.has(f.from)||!_.has(f.to))&&o(`message ${f.n} names ${_.has(f.from)?f.to:f.from}, which is not a participant`);if(s&&F!=="sequence"){const f=new Map;for(const m of d)for(let A=m.row;A<=m.row2;A++){const S=`${m.col}:${A}`;f.has(S)&&o(`${m.id} and ${f.get(S)} share the cell at column ${m.col}, row ${A}`),f.set(S,m.id)}}if(s){for(const m of L){const A=m.members.map(C=>_.get(C));if(!A.length)continue;const S={c1:Math.min(...A.map(C=>C.col)),c2:Math.max(...A.map(C=>C.col)),r1:Math.min(...A.map(C=>C.row)),r2:Math.max(...A.map(C=>C.row2))};for(const C of d)C.group!==m.id&&C.col>=S.c1&&C.col<=S.c2&&C.row>=S.r1&&C.row<=S.r2&&o(`${C.id} is inside the box of the group "${m.label}" but not a member`);const z=A.map(C=>C.i);Math.max(...z)-Math.min(...z)+1!==z.length&&o(`the members of the group "${m.label}" are not next to each other in the author's order, so the stacked drawing cannot wrap them in one box`)}for(const m of d)m.group&&!L.some(A=>A.id===m.group)&&o(`${m.id} names the group "${m.group}", which is not in groups`);d.filter(m=>m.focal).length>1&&o("more than one node is focal: a diagram has one at most");const f=new Set(F==="sequence"?O.flatMap(m=>"n"in m?[m.kind]:[]):w.map(m=>m.kind));f.has("main")&&!l.main&&o("main lines are drawn but the legend has no words for them (legend.main)"),f.has("dashed")&&!l.dashed&&o("dashed lines are drawn but the legend has no words for them (legend.dashed)"),d.some(m=>m.focal)&&!l.focal&&o("a focal node is drawn but the legend has no words for what it marks (legend.focal)")}const J=F==="architecture"||F==="data-flow",E=f=>Array.isArray(f)&&f.length>1?f.map(String):void 0,V=J&&t.packet&&typeof t.packet=="object"?t.packet:void 0,$=V&&E(V.path),G={animated:t.motion==="animated",pulse:J?E(t.pulse):void 0,packet:$?{path:$,repeat:V.repeat===!0,send:V.send}:void 0,run:F==="sequence"&&t.run===!0};if(s)for(const f of d){const m=f.mark?.says;if(!m?.length)continue;const A=[f.name,f.kind,f.detail].filter(Boolean).join(" ").toLowerCase();m.some(S=>A.includes(S.toLowerCase()))||o(`${f.id}'s mark stands for ${m.join(" or ")}, and none of its words say so`)}const j=Math.max(1,...d.map(f=>f.col)),v=F==="data-flow"?Math.max(1,q.length):Math.max(1,...d.map(f=>f.row2));return{type:F,title:String(t.title??""),heading:c,legend:l,nodes:d,byId:_,edges:w,groups:L,lanes:q,steps:O,cols:j,rows:v,shapeLabels:g,stepWord:u,warnings:a,motion:G,memo:new Map}}function ie(t){if(typeof t=="string")return t?{id:t}:void 0;if(!t||typeof t!="object")return;const e=t,n=at(e.onLight);if(n)return{onLight:n,onDark:at(e.onDark)??n,says:Array.isArray(e.says)?e.says.map(String):void 0}}var At=t=>`url("${t.replace(/[\\"\n;]/g,e=>e===`
+`?"\\a ":e===";"?"\\3b ":`\\${e}`)}")`;function bt(t,e,n){return t.memo.has(e)||t.memo.set(e,n()),t.memo.get(e)}var Lt=28,pt=t=>{const e=t.trim();return e?/[.!?]$/.test(e)?e:`${e}.`:""};function qt(t,e){return t.legend[e]}function le(t,e){return e.shape==="decision"?"decision":e.shape==="terminal"?t.edges.some(n=>n.from===e.id)?"start":"end":e.kind??"step"}function ce(t,e){return bt(t,`sentence:${e.i}`,()=>de(t,e))}function de(t,e){const n=[];if(t.type==="schema"){n.push(`${e.name}, table.`);const s=(e.columns??[]).filter(o=>o.ref).map(o=>`${o.ref.table} (${o.name})`),a=t.edges.filter(o=>o.to===e.id).map(o=>`${o.from} (${t.byId.get(o.from).columns[o.fromRow].name})`);s.length&&n.push(`References ${s.join(", ")}.`),a.length&&n.push(`Referenced by ${a.join(", ")}.`)}else if(t.type==="sequence"){const s=t.steps.filter(o=>"n"in o&&o.from===e.id).length,a=t.steps.filter(o=>"n"in o&&o.to===e.id).length;n.push(pt(e.kind?`${e.name}, ${e.kind}`:e.name)),n.push(`Sends ${s} ${s===1?"message":"messages"} and receives ${a}.`)}else{const s=t.type==="data-flow"?`${t.stepWord(e.step)} of ${t.nodes.length}, ${e.laneLabel}`:t.type==="flowchart"?le(t,e):e.kind;if(n.push(pt(s?`${e.name}, ${s}`:e.name)),e.detail&&n.push(pt(e.detail)),e.group){const r=t.groups.find(l=>l.id===e.group);r&&n.push(`In ${r.label}.`)}const a=t.edges.filter(r=>r.to===e.id).map(r=>`${t.byId.get(r.from).name}${r.label?` (${r.label})`:""}`),o=t.edges.filter(r=>r.from===e.id).map(r=>`${t.byId.get(r.to).name}${r.label?` (${r.label})`:""}`);a.length&&n.push(`From: ${a.join(", ")}.`),o.length&&n.push(`To: ${o.join(", ")}.`)}return e.focal&&t.legend.focal&&n.push(pt(t.legend.focal)),n.join(" ")}function ue(t){return t.type==="architecture"?"a part":t.type==="sequence"?"a participant":t.type==="schema"?"a table":"a step"}function x(t,e,...n){const s=[];for(const a of n.flat(1/0))a!=null&&a!==!1&&!Array.isArray(a)&&s.push(a);return{t,a:e??{},c:s}}var fe={"&":"&","<":"<",">":">",'"':""","'":"'"},it=t=>t.replace(/[&<>"']/g,e=>fe[e]),he=" br img input meta link hr path polygon polyline circle rect line ";function It(t,e={}){if(typeof t=="string")return it(t);if("slot"in t)return e[t.slot]??"";if(!/^[a-z][a-z0-9]*$/.test(t.t))throw new Error(`diagram: "${t.t}" is not an element name`);let n="";for(const[s,a]of Object.entries(t.a))if(!(a==null||a===!1)){if(!/^[a-z][a-z0-9:-]*$/i.test(s))throw new Error(`diagram: "${s}" is not an attribute name`);n+=a===!0?` ${s}`:` ${s}="${it(String(a))}"`}return he.includes(` ${t.t} `)&&!t.c.length?t.t==="path"||t.t==="polygon"||t.t==="polyline"||t.t==="circle"||t.t==="rect"||t.t==="line"?`<${t.t}${n}/>`:`<${t.t}${n}>`:`<${t.t}${n}>${t.c.map(s=>It(s,e)).join("")}${t.t}>`}var pe=t=>({title:`${t}-title`,summary:`${t}-summary`,keys:`${t}-keys`,list:`${t}-list`,toggle:`${t}-toggle`});function ht(t,e){return!e.layout||e.bare?!1:e.layout==="drawn"?!0:t.type!=="sequence"&&t.type!=="schema"}function ge(t,e){return t.type==="sequence"||t.type==="schema"?e.layout==="drawn":!0}function Ot(t){let e=0;for(const n of t.groups){const s=n.members.map(a=>t.byId.get(a).col);s.length&&(Math.min(...s)===1&&(e|=1),Math.max(...s)===t.cols&&(e|=2))}return(e&1)+(e>>1&1)}function vt(t){return t.type==="sequence"?t.nodes.length:t.cols}function _t(t){return bt(t,"plan",()=>me(t))}function me(t){const e=t.nodes,n=i=>t.type==="data-flow"||!e[i].branch,s=t.edges.map(i=>{const d=t.byId.get(i.from).i,w=t.byId.get(i.to).i,L=e.slice(Math.min(d,w)+1,Math.max(d,w)).every(O=>!n(O.i));return w===d+1&&!(n(d)&&!n(w))?"down":w===d-1?"up":w>d&&n(d)&&!n(w)&&L?"trunk":w>d&&n(d)&&n(w)&&L?"rail":w>d?"end-down":"end-up"}),a=t.edges.map((i,d)=>({e:i,k:d})).filter(({k:i})=>s[i]==="end-down"||s[i]==="end-up"),o=i=>{const d=t.byId.get(i.from).i,w=t.byId.get(i.to).i;return[Math.min(d,w),Math.max(d,w)]},r=(i,d)=>{const[w,q]=o(i),[L,O]=o(d);return w{const d=t.byId.get(i.from).i,[w,q]=o(i);return!n(d)&&e.slice(w+1,q).every(L=>!n(L.i))&&a.every(L=>L.e===i||!r(L.e,i))}),h=a.length>0&&(t.type==="data-flow"||!l),u=i=>{const[d,w]=o(i);return w-d},p=t.edges.map(()=>0);let g=!1;const c=[];for(const i of[...a].sort((d,w)=>u(d.e)-u(w.e)||d.k-w.k)){let d=0;for(const w of c)r(w.e,i.e)&&(d=Math.max(d,p[w.k]+1));p[i.k]=d,d>1&&(g=!0),c.push(i)}const y=t.edges.map(()=>.5);for(const i of e){const d=a.filter(({e:L})=>L.from===i.id);if(d.length<2)continue;const w=d.filter(({k:L})=>s[L]==="end-down").sort((L,O)=>u(O.e)-u(L.e)||L.k-O.k);[...d.filter(({k:L})=>s[L]==="end-up").sort((L,O)=>u(L.e)-u(O.e)||O.k-L.k),...w].forEach(({k:L},O,F)=>{y[L]=F.length===2?O===0?1/3:2/3:(O+1)/(F.length+1)})}const b=ut();for(let i=1;i{const E=s[J],V=t.byId.get(_.from).i,$=t.byId.get(_.to).i,G=$===i&&(E==="down"||E==="trunk"||E==="rail"||E==="end-down"),j=V===i&&$===i-1&&E==="up",v=$===i-1&&E==="end-up";G&&(E==="trunk"||E==="end-down")&&(O=!0),v&&(F=!0),(G||j||v)&&_.label&&(q++,L=Math.max(L,E==="trunk"?40:48))}),(q>1||O&&F)&&(L=64),b[d.id]=L}return{routes:s,gutter:h,lanes:p,exits:y,gaps:b,third:g}}var gt=(t,e)=>({width:t,height:e,viewBox:`0 0 ${t} ${e}`,"aria-hidden":"true",focusable:"false"});function Ct(t,e){const n=e==="fk"?"plain":e,s=n==="main"?8:8.5,a=24,o=n==="dashed"?a-1:a-7;return x("svg",{class:`${t}-swatch`,"data-kind":n,...gt(24,16)},e==="fk"?x("circle",{class:`${t}-dot`,cx:3,cy:s,r:3}):null,x("path",{class:`${t}-line`,"data-kind":n,d:`M${e==="fk"?3:0} ${s}H${o}`}),n==="dashed"?x("path",{class:`${t}-tip`,"data-kind":n,"data-open":"",d:`M${a-8} ${s-4}L${a} ${s}L${a-8} ${s+4}`}):x("path",{class:`${t}-tip`,"data-kind":n,d:`M${a} ${s}L${a-8} ${s-4}L${a-8} ${s+4}Z`}))}function mt(t,e){return e==="decision"?x("svg",{class:`${t}-swatch`,"data-shape":e,...gt(16,16)},x("path",{class:`${t}-swatch-shape`,d:"M8 2.5L14.5 8L8 13.5L1.5 8Z"})):e==="terminal"?x("svg",{class:`${t}-swatch`,"data-shape":e,...gt(16,16)},x("rect",{class:`${t}-swatch-shape`,x:.5,y:3.5,width:15,height:9,rx:4.5})):x("svg",{class:`${t}-swatch`,"data-shape":e,...gt(16,16)},x("rect",{class:`${t}-swatch-shape`,x:.5,y:2.5,width:15,height:11,rx:2}))}function ye(t,e){return bt(e,`key:${t}`,()=>be(t,e))}function be(t,e){const n=[],s=(o,r,l={})=>n.push(x("li",{class:`${t}-entry`,...l},o,x("span",null,r)));if(e.type==="schema"){const o=new Set(e.nodes.flatMap(r=>(r.columns??[]).map(l=>l.key)));for(const[r,l]of[["PK","Primary key"],["FK","Foreign key"]])o.has(r)&&n.push(x("li",{class:`${t}-entry`},x("span",{class:`${t}-key-letters`,"aria-hidden":"true"},r),x("span",null,l)))}if(e.type==="flowchart"){const o=new Set(e.nodes.map(r=>r.shape));o.has("terminal")&&s(mt(t,"terminal"),e.shapeLabels.terminal),o.has("box")&&s(mt(t,"box"),e.shapeLabels.step),o.has("decision")&&s(mt(t,"decision"),e.shapeLabels.decision)}const a=new Set(e.type==="sequence"?e.steps.flatMap(o=>"n"in o?[o.kind]:[]):e.edges.filter(o=>!o.fk).map(o=>o.kind));for(const o of["main","plain","dashed"]){const r=e.legend[o];a.has(o)&&r&&s(Ct(t,o),r,{"data-line":""})}return e.type==="schema"&&e.edges.length&&(s(Ct(t,"fk"),e.legend.plain??"A foreign key, to the key it references",{"data-line":"","data-when":"drawn"}),n.push(x("li",{class:`${t}-entry`,"data-when":"stacked"},x("span",{class:`${t}-fk-mark`,"aria-hidden":"true"},"→"),x("span",null,"The table a foreign key references")))),e.nodes.some(o=>o.focal)&&e.legend.focal&&s(mt(t,"focal"),e.legend.focal,{"data-focal":""}),e.groups.length&&e.legend.group&&s(mt(t,"group"),e.legend.group),n.length?x("div",{class:`${t}-key`},x("ul",{class:`${t}-legend`,"aria-label":"Key"},n)):null}function $e(t,e){const n=e==="main"?6:6.5;return x("svg",{class:`${t}-arrow`,"data-kind":e,...gt(20,12)},x("path",{class:`${t}-line`,"data-kind":e,d:`M0 ${n}H${e==="dashed"?19:13}`}),e==="dashed"?x("path",{class:`${t}-tip`,"data-kind":e,"data-open":"",d:`M12 ${n-4}L20 ${n}L12 ${n+4}`}):x("path",{class:`${t}-tip`,"data-kind":e,d:`M20 ${n}L12 ${n-4}L12 ${n+4}Z`}))}function we(t,e,n){if(n.shape==="decision")return[x("span",{class:`${t}-words`},x("span",{class:`${t}-name`},n.name))];const s=[];return e.type==="data-flow"?s.push(x("span",{class:`${t}-kind`},n.kind,x("span",{class:`${t}-lane-word`},` · ${n.laneLabel}`))):n.kind&&s.push(x("span",{class:`${t}-kind`},n.kind)),s.push(x("span",{class:`${t}-name`},n.name)),n.detail&&s.push(x("span",{class:`${t}-detail`,"data-mono":n.mono?"":void 0},n.mono?wt(n.detail).flatMap((a,o)=>[o?" ":"",x("span",{class:`${t}-run`},a)]):n.detail)),s}function xe(t,e){return[x("span",{class:`${t}-th`},x("span",{class:`${t}-tname`},e.name)),x("span",{class:`${t}-rows`},(e.columns??[]).map((n,s)=>x("span",{class:`${t}-row`,"data-row":s,"data-key":n.key},x("span",{class:`${t}-keyseat`},n.key??""),x("span",{class:`${t}-cname`},n.name),n.ref?x("span",{class:`${t}-ctype`,"data-ref":""},`→ ${n.ref.table}`):n.type?x("span",{class:`${t}-ctype`},n.type):null))),e.more?x("span",{class:`${t}-more`},`+ ${e.more} more`):null]}var Bt=t=>{const e={32:"space-8",40:"space-10",48:"space-12",64:"space-16"};return e[t]?`var(--basalt-${e[t]})`:`${t}px`};function Mt(t,e,n,s){const{P:a}=t,o=ge(e,s)||s.keep===n.id,r=ht(e,s),l=[`--_c:${n.col}`,`--_r:${n.row}`,`--_r2:${n.row2+1}`];e.type==="data-flow"&&l.push(`--_lc:${n.col+1}`),e.type==="sequence"&&l.push(`--_c2:${n.col+1}`);const h=t.plan;if(h&&n.i>0){const c=ft(h.gaps,n.id)??32,y=ft(s.grow,n.id)??0;l.push(`--_gap:${y?`calc(${Bt(c)} + var(--basalt-space-4) * ${y})`:Bt(c)}`)}const u=ft(s.heights,n.id);u&&l.push(`--_h:${u}px`);const p=ft(s.words,n.id);p&&l.push(`--_ww:${p}px`);const g=r?s.stop===n.id?0:-1:s.keep===n.id?-1:void 0;return x("div",{class:`${a}-node`,"data-node":n.id,"data-shape":n.shape,"data-focal":n.focal?"":void 0,"data-branch":n.branch?"":void 0,"data-mark":n.mark?n.mark.id??"":void 0,"data-level":t.level,style:l.join(";"),role:o?"img":void 0,"aria-label":o?ce(e,n):void 0,tabindex:g},n.shape==="decision"?x("svg",{class:`${a}-diamond`,viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-hidden":"true",focusable:"false"},x("path",{d:"M50 0L100 50L50 100L0 50Z"})):null,n.mark?x("span",{class:`${a}-mark`,"aria-hidden":"true",style:n.mark.onLight?`--_ml:${At(n.mark.onLight)};--_md:${At(n.mark.onDark??n.mark.onLight)}`:void 0}):null,n.shape==="table"?xe(a,n):we(a,e,n))}function ve(t,e,n){const{P:s}=t,a=[];if(e.type==="data-flow"&&a.push(...e.lanes.map((r,l)=>x("div",{class:`${s}-lane`,style:`--_r:${l+1}`,"aria-hidden":"true"},x("span",{class:`${s}-lane-name`},r.label)))),e.type==="architecture")for(const r of e.groups){const l=r.members.map(c=>e.byId.get(c));if(!l.length)continue;const h=Math.min(...l.map(c=>c.col)),u=Math.max(...l.map(c=>c.col)),p=Math.min(...l.map(c=>c.row)),g=Math.max(...l.map(c=>c.row2));a.push(x("div",{class:`${s}-gbox`,"data-group":r.id,style:`--_c:${h};--_c2:${u+1};--_r:${p};--_r2:${g+1}`,"aria-hidden":"true"},x("span",{class:`${s}-glabel`},r.label)))}if(e.type==="sequence")return a.push(x("ul",{class:`${s}-cast`},e.nodes.map(r=>x("li",{class:`${s}-actor`},Mt(t,e,r,n))))),a.push(Me(t,e)),a;let o=0;for(;op.id===r.group):void 0;if(!l){a.push(Mt(t,e,r,n)),o++;continue}const h=[];for(;oMt(t,e,p,n))))}return a}function Me(t,e){const{P:n}=t,s=[];let a=null;for(const o of e.steps){if("band"in o){a=null,s.push(x("p",{class:`${n}-band`},x("span",null,o.band)));continue}a||(a=x("ol",{class:`${n}-msgs`,start:o.n}),s.push(a));const r=e.byId.get(o.from),l=e.byId.get(o.to),h=r?.col??1,u=l?.col??1,p=h===u,g=p&&h===e.nodes.length,c=qt(e,o.kind);a.c.push(x("li",{class:`${n}-msg`,"data-kind":o.kind,"data-from":o.from,"data-to":o.to,"data-self":p?g?"start":"end":void 0,style:`--_a:${Math.min(h,u)};--_b:${Math.max(h,u)+1}`},x("span",{class:`${n}-said`},x("span",{class:`${n}-num`},String(o.n)),x("span",{class:`${n}-mlabel`},o.label)),x("span",{class:`${n}-route`},r?.short??o.from," ",$e(n,o.kind),x("span",{class:t.hidden}," to ")," ",l?.short??o.to,c?` · ${c}`:""),o.note?x("span",{class:`${n}-note`},o.note):null))}return x("div",{class:`${n}-steps`},s)}function ke(t,e){return bt(e,`list:${t}`,()=>Se(t,e))}function Se(t,e){const n=Math.min(6,e.heading+1),s=p=>x(`h${n}`,{class:`${t}-list-head`},p),a=p=>x("strong",null,p),o=p=>x("code",{class:`${t}-code`},p),r=p=>e.byId.get(p)?.name??p,l=p=>{const g=qt(e,p);return g?` (${g})`:""},h=p=>p.focal&&e.legend.focal?` ${pt(e.legend.focal)}`:"";if(e.type==="architecture"){const p=y=>x("li",null,a(y.name),y.kind?`, ${y.kind}`:"",y.detail?[". ",y.mono?o(y.detail):y.detail,/[.!?]$/.test(y.detail)?"":"."]:/[.!?]$/.test(y.kind??y.name)?"":".",h(y)),g=[s("Parts")],c=e.nodes.filter(y=>!y.group);c.length&&g.push(x("ul",{class:`${t}-list-items`},c.map(p)));for(const y of e.groups)g.push(x("p",{class:`${t}-list-group`},y.label)),g.push(x("ul",{class:`${t}-list-items`},y.members.map(b=>p(e.byId.get(b)))));return g.push(s("Connections")),g.push(x("ol",{class:`${t}-list-items`},e.edges.map(y=>x("li",null,a(r(y.from))," to ",a(r(y.to)),y.label?[": ",o(y.label)]:"",`${l(y.kind)}.`)))),g}if(e.type==="flowchart"){const p=g=>(e.byId.get(g)?.i??0)+1;return[x("ol",{class:`${t}-list-items`},e.nodes.map(g=>{const c=e.edges.filter(i=>i.from===g.id),y=g.shape==="decision"?"Decision":g.shape==="terminal"?c.length?"Start":"End":"Step",b=!g.detail&&/[.!?]$/.test(g.name)?" ":". ";return x("li",null,a(g.name),g.detail?[", ",g.mono?o(g.detail):g.detail]:"",`${b}${y}.`,h(g),c.length?x("ul",{class:`${t}-list-exits`},c.map(i=>x("li",null,i.label?`If ${i.label}: go to ${p(i.to)}, `:`Then: go to ${p(i.to)}, `,a(r(i.to)),l(i.kind)))):null)}))]}if(e.type==="data-flow")return[x("ol",{class:`${t}-list-items`},e.nodes.map(p=>{const g=e.edges.filter(c=>c.from===p.id);return x("li",null,`${p.laneLabel}: `,a(p.name),p.detail?[", ",p.mono?o(p.detail):p.detail]:"",".",h(p),g.length?[" Then ",...g.flatMap((c,y)=>[y?"; ":"",`to step ${e.byId.get(c.to).step}, `,a(r(c.to)),c.label?[": ",o(c.label)]:"",l(c.kind)]),"."]:"")}))];if(e.type==="sequence"){const p=[s("Participants"),x("ul",{class:`${t}-list-items`},e.nodes.map(c=>x("li",null,a(c.name),c.kind?`, ${c.kind}`:"",".",h(c))))];p.push(s("Messages"));let g=null;for(const c of e.steps){if("band"in c){g=null,p.push(x(`h${Math.min(6,n+1)}`,{class:`${t}-list-group`},c.band));continue}g||(g=x("ol",{class:`${t}-list-items`,start:c.n}),p.push(g)),g.c.push(x("li",null,o(c.label),": ",a(r(c.from))," to ",a(r(c.to)),`${l(c.kind)}.`,c.note?` ${pt(c.note)}`:""))}return p}const u=[];for(const p of e.nodes)u.push(x(`h${n}`,{class:`${t}-list-group`},o(p.name),h(p))),u.push(x("ul",{class:`${t}-list-items`},[...(p.columns??[]).map(g=>x("li",null,o(g.name),g.key==="PK"?", primary key":g.key==="FK"?", foreign key":"",g.ref?[", references ",o(`${g.ref.table}.${g.ref.column}`)]:g.type?`, ${g.type}`:"")),...p.more?[x("li",null,`and ${p.more} more ${p.more===1?"column":"columns"}`)]:[]]));return u}function Ee(t){return`Arrow keys move to the next or the previous ${t.type==="architecture"?"part":t.type==="sequence"?"participant":t.type==="schema"?"table":"step"}, in the author's order; Home and End go to the ends; Escape clears the trace.`}function Ae(t){return[{keys:["←","→"],words:ue(t)},{keys:["Home","End"],words:"the ends"},{keys:["Esc"],words:"clear"}]}var jt=t=>t.type==="schema"&&t.cols===1&&t.edges.length>0;function Tt(t,e,n){const s=n.prefix,a=pe(n.base),o=t.type==="sequence"||t.type==="schema"?null:_t(t),r={P:s,ids:a,level:n.level,plan:o,hidden:n.hiddenClass},l=e.layout==="drawn",h=ht(t,e),u=t.type==="sequence"||t.type==="schema"?l:!0,p=`h${t.heading}`,g=[`--_cols:${vt(t)}`];if(t.type==="architecture"&&t.groups.length||l&&e.pad){const c=t.type==="architecture"?t.groups.flatMap(i=>i.members.map(d=>t.byId.get(d))):[],y=(i,d,w)=>i?`var(--basalt-space-${d})`:w?`var(--basalt-space-${w})`:"0px",b=l&&e.pad?"3":void 0;g.push(`--_gpad:${y(c.some(i=>i.row===1),"8",b)} ${y(c.some(i=>i.col===t.cols),"4")} ${y(c.some(i=>i.row2===t.rows),"4",b)} ${y(c.some(i=>i.col===1),"4")}`)}return jt(t)&&g.push("--_gpad:0px var(--basalt-space-5) 0px 0px"),t.type==="schema"&&e.track&&g.push(`--_track:${e.track}px`),x("figure",{class:n.className?`${s} ${n.className}`:s,"aria-labelledby":a.title,"data-type":t.type,"data-cols":vt(t),"data-reach":t.type==="architecture"?Ot(t):void 0,"data-gutter":o?.gutter?"":void 0,"data-layout":e.layout,"data-measured":e.layout?"":void 0,"data-bare":e.bare?"":void 0,"data-motion":t.motion.animated?"animated":void 0,style:g.join(";")},x("div",{class:`${s}-head`},x(p,{id:a.title,class:`${s}-title`},t.title),n.hasSource?x("p",{class:`${s}-source`},{slot:"source"}):null),x("div",{class:`${s}-drawing`,role:u?"group":void 0,"aria-roledescription":u?"diagram":void 0,"aria-labelledby":u?a.title:void 0,"aria-describedby":u?h?`${a.summary} ${a.keys}`:a.summary:void 0,"data-stops":h?"":void 0},ve(r,t,e),x("div",{class:`${s}-ink`,"aria-hidden":"true"}),x("span",{class:`${s}-ruler`,"aria-hidden":"true"})),ye(s,t),x("p",{class:`${s}-hint`,"data-kbd-hint":"","aria-hidden":"true"},{slot:"hint"}),x("div",{class:`${s}-foot`},{slot:"toggle"}),x("div",{id:a.list,class:`${s}-list`,hidden:!e.open},ke(s,t)),x("span",{id:a.keys,class:n.hiddenClass},Ee(t)),x("figcaption",{id:a.summary,class:`${s}-summary`},{slot:"summary"}))}function Le(t){const e=getComputedStyle(t),n=(a,o)=>{const r=parseFloat(e.getPropertyValue(`--basalt-${a}`));return Number.isFinite(r)?r:o},s=new Map;return{space:a=>(s.has(a)||s.set(a,n(`space-${a}`,parseFloat(a.replace("-","."))*4)),s.get(a)),node:n("size-diagram-node",144),table:n("size-diagram-table",224),lane:n("size-diagram-lane",120),step:n("size-diagram-step",56),head:n("size-diagram-head",8),guide:n("size-diagram-guide-dash",4),hair:n("size-hairline",1),line:n("size-chart-line",2),cut:n("size-cut",2),dot:n("size-dot",6),dash:n("size-chart-dash",6),dashGap:n("size-chart-dash-gap",4),wide:n("size-breakpoint-container-lg",640),cap:n("size-breakpoint-container",480),radius:n("radius-md",8),radiusXs:n("radius-xs",4)}}var $t=(t,e)=>t==="main"?e.line:e.hair,lt=(t,e)=>{const n=t.getBoundingClientRect();return{l:n.left-e.left,t:n.top-e.top,r:n.right-e.left,b:n.bottom-e.top}},ct=(t,e,n=.01)=>t.le.l+n&&t.te.t+n,Rt=(t,e)=>({l:t.l-e,r:t.r+e,t:t.t-e,b:t.b+e});function rt(t,e,n){const{l:s,t:a,r:o,b:r}=t.rect,l=(s+o)/2,h=(a+r)/2,u=(o-s)/2,p=(r-a)/2,g=e==="top"||e==="bottom";if(t.shape==="decision"){if(g){const b=n,i=p*Math.max(0,1-Math.abs(b-l)/u);return{x:b,y:e==="top"?h-i:h+i}}const c=n,y=u*Math.max(0,1-Math.abs(c-h)/p);return{x:e==="left"?l-y:l+y,y:c}}if(t.shape==="terminal"){const c=Math.min(u,p);if(g){const d=n,w=Math.min(Math.max(d,s+c),o-c),q=d-w,L=Math.abs(q)>=c?0:Math.sqrt(c*c-q*q);return{x:d,y:Math.abs(q)<1e-6?e==="top"?a:r:e==="top"?h-L:h+L}}const y=n,b=y-h,i=Math.abs(b)>=c?0:Math.sqrt(c*c-b*b);return{x:e==="left"?s+c-i:o-c+i,y}}return g?{x:n,y:e==="top"?a:r}:{x:e==="left"?s:o,y:n}}function qe(t,e,n){const{l:s,t:a,r:o,b:r}=e.rect,l=(s+o)/2,h=(a+r)/2,u=(o-s)/2,p=(r-a)/2;if(e.shape==="decision")return Math.abs(t.x-l)/u+Math.abs(t.y-h)/p<1-n/Math.min(u,p);if(e.shape==="terminal"){const g=Math.min(u,p),c=Math.min(Math.max(t.x,s+g),o-g);return Math.hypot(t.x-c,t.y-h)s+n&&t.xa+n&&t.ymatchMedia("(forced-colors: active)").matches;function _e(t,e){const n=t.querySelector(`.${e}-ruler`),s=new Map;return(a,o)=>{const r=`${o}|${a}`;return s.has(r)||(n.setAttribute("data-f",o),n.textContent=a,s.set(r,n.getBoundingClientRect().width),n.textContent=""),s.get(r)}}var wt=t=>t?t.split(/\s+/).filter(Boolean):[];function Ce(t,e,n){const s=e.space;let a=e.node,o=e.table;for(const h of t.nodes){if(h.shape==="table"){for(const y of h.columns??[]){const b=y.ref?`→ ${y.ref.table}`:y.type??"",i=s("6")+n(y.name,"mono")+(b?s("3")+n(b,"mono"):0)+2*s("3")+2*e.hair;o=Math.max(o,Math.ceil(i))}o=Math.max(o,Math.ceil(n(h.name,"table")+2*s("3")+2*e.hair));continue}const u=h.shape==="terminal"?2*s("5"):2*s("3"),p=h.mark&&!Oe()?s("6"):0;let g=0;for(const y of wt(h.name))g=Math.max(g,n(y,h.shape==="decision"?"name-500":"name")+(h.kind?0:p));if(t.type!=="data-flow")for(const y of wt(h.kind))g=Math.max(g,n(y,"mono")+p);for(const y of wt(h.detail))g=Math.max(g,n(y,h.mono?"mono":"sans"));const c=h.shape==="decision"?g/.62:g+u+2*e.hair;a=Math.max(a,Math.ceil(c))}const r=vt(t);let l;return t.type==="data-flow"?l=e.lane+r*(a+s("12")):t.type==="schema"?l=r*o+(r-1)*s("12")+(jt(t)?s("5"):0):t.type==="sequence"?l=r*a+(r-1)*s("5"):l=r*a+(r-1)*s("16")+Ot(t)*s("4"),{track:a,table:o,least:Math.max(e.wide,l)}}function Ht(t,e){return{x:(n,s)=>s%2===1?Math.round(n+t-.5)+.5-t:Math.round(n+t)-t,y:(n,s)=>s%2===1?Math.round(n+e-.5)+.5-e:Math.round(n+e)-e}}function kt(t){const e=t[t.length-2],n=t[t.length-1];return Math.abs(e.x-n.x)<.01?n.y>e.y?"down":"up":n.x>e.x?"right":"left"}function Nt(t,e,n){const s=t.map(o=>({...o}));for(let o=1;o=2){const h=a[a.length-2];if(Math.abs(h.x-l.x)<.01&&Math.abs(l.x-r.x)<.01||Math.abs(h.y-l.y)<.01&&Math.abs(l.y-r.y)<.01){a[a.length-1]=r;continue}}a.push(r)}}return a}var dt=t=>t.slice(1).map((e,n)=>[t[n],e]);function xt(t,e,n){const s=[];for(let o=0;oMath.min(i.x,d.x)+.75&&LMath.min(w.y,q.y)+.75&&Oa.split(/\s+/).map(parseFloat).filter(o=>Number.isFinite(o)),s=(a,o,r)=>{const l=[];let h=o;for(const u of a)l.push([h,h+u]),h+=u+r;return l};return{cols:s(n(e.gridTemplateColumns),parseFloat(e.paddingLeft)||0,parseFloat(e.columnGap)||0),rows:s(n(e.gridTemplateRows),parseFloat(e.paddingTop)||0,parseFloat(e.rowGap)||0)}}var P=t=>t==="left"||t==="right",zt={top:"bottom",bottom:"top",left:"right",right:"left"};function je(t,e){return t.row===e.row?e.col>t.col?["right","left"]:["left","right"]:t.col===e.col?e.row>t.row?["bottom","top"]:["top","bottom"]:[e.col>t.col?"right":"left",e.row>t.row?"top":"bottom"]}function Te(t,e,n){const s=[];t.edges.forEach((o,r)=>{const l=t.byId.get(o.from),h=t.byId.get(o.to),[u,p]=e[r],g=l.row===h.row&&P(u)&&P(p)&&u===zt[p]||l.col===h.col&&!P(u)&&!P(p)&&u===zt[p];s.push({edge:r,end:"from",node:l,side:u,far:h,straight:g,f:.5},{edge:r,end:"to",node:h,side:p,far:l,straight:g,f:.5})});const a=new Map;for(const o of s){const r=`${o.node.id}.${o.side}`;a.has(r)||a.set(r,[]),a.get(r).push(o)}for(const[o,r]of a){if(r[0].node.shape==="decision")continue;const l=i=>P(i.side)?i.far.row-i.node.row:i.far.col-i.node.col,h=r.filter(i=>i.straight),u=r.filter(i=>!i.straight);if(u.sort((i,d)=>l(i)-l(d)||(P(i.side)?i.far.col-d.far.col:i.far.row-d.far.row)*(l(i)<0?1:-1)),r.length>3&&n(`${o.replace(".","'s ")} side has ${r.length} lines; more than three is an error: use another side`),!h.length){u.length===2?(u[0].f=.25,u[1].f=.75):u.length===3?(u[0].f=.25,u[1].f=.5,u[2].f=.75):u.length>3&&u.forEach((i,d)=>{i.f=(d+1)/(u.length+1)});continue}const p=new Map;for(const i of h)p.has(i.far.id)||p.set(i.far.id,[]),p.get(i.far.id).push(i);for(const i of p.values())i.length>1&&i.sort((d,w)=>d.edge-w.edge).forEach((d,w)=>{d.f=i.length===2?w===0?.25:.75:(w+1)/(i.length+1)});const g=Math.min(...h.map(i=>i.f)),c=Math.max(...h.map(i=>i.f)),y=u.filter(i=>l(i)<0),b=u.filter(i=>l(i)>=0);y.forEach((i,d)=>{i.f=g*(d+1)/(y.length+1)}),b.forEach((i,d)=>{i.f=c+(1-c)*(d+1)/(b.length+1)})}return s}function Wt(t,e,n){const{l:s,t:a,r:o,b:r}=t.rect;return P(e)?rt(t,e,a+(r-a)*n):rt(t,e,s+(o-s)*n)}function Dt(t,e,n,s){const a=new Map;return e.querySelectorAll(`.${s}-node`).forEach(o=>{const r=t.byId.get(o.dataset.node);r&&a.set(r.id,{id:r.id,rect:lt(o,n),shape:r.shape,i:r.i})}),a}function Gt(t,e){const n=e.head,s=e.head/2,{x:a,y:o}=t.tip;return t.dir==="down"?{l:a-s,r:a+s,t:o-n,b:o}:t.dir==="up"?{l:a-s,r:a+s,t:o,b:o+n}:t.dir==="right"?{l:a-n,r:a,t:o-s,b:o+s}:{l:a,r:a+n,t:o-s,b:o+s}}var Kt=(t,e,n)=>({l:Math.min(t.x,e.x)-n/2,r:Math.max(t.x,e.x)+n/2,t:Math.min(t.y,e.y)-n/2,b:Math.max(t.y,e.y)+n/2});function Vt(t,e,n,s){const a=(o,r)=>{const l=o+r-Math.floor(o+r);return l<.005||l>.995?[0]:l<=.5?[-l,1-l]:[1-l,-l]};for(const o of a(t.t,n))for(const r of a(t.l,e)){if(!r&&!o)return t;const l={l:t.l+r,r:t.r+r,t:t.t+o,b:t.b+o};if(s(l))return l}return t}function Re(t,e,n,s,a,o,r,l,h){const u=r.space,p=[],g=[],c=[],y=[],b=u("1"),i=e.filter(d=>t.edges[d.i]?.label).sort((d,w)=>+(t.edges[w.i].kind==="main")-+(t.edges[d.i].kind==="main")||d.i-w.i);for(const d of i){const w=t.edges[d.i].label,q=l(w,"label"),L=16,O=d.pts.length-2,F=[];dt(d.pts).forEach(([$,G],j)=>{const v=Math.abs($.y-G.y)<.01,f=v?$.x:$.y;let m=v?G.x:G.y;const A=Math.sign(m-f)||1;j===O&&(m-=A*r.head);let S=[[f,m]];for(const K of a)for(const W of v?[K.l,K.r]:[K.t,K.b]){const M=v?$.y:$.x;(v?M>K.t&&MK.l&&MW>Math.min(I,k)+1&&W{const M=(K+W)/2,T=v?{x:M,y:$.y}:{x:$.x,y:M};return!a.some(I=>T.x>I.l&&T.xI.t&&T.y1&&z(K,W)?1:0})}),F.sort(($,G)=>G.pri-$.pri||G.len-$.len);let _=null,J=!1;const E=($,G=!0)=>{const j=Rt($,b);return G&&($.lo.r||$.to.b)||n.some(v=>Ft(j,v))||p.some(v=>ct(j,v))||s.heads.some(v=>ct(j,v))||s.rects.some(v=>ct(j,v))?!1:!e.some(v=>v.i!==d.i&&dt(v.pts).some(([f,m])=>ct(j,Kt(f,m,v.width))))};for(const $ of F){for(const G of[1/2,1/3,2/3]){const j=$.p+($.q-$.p)*G,v=[],f=u("2")+d.width/2;if($.horiz?($.len>=q+2*u("1")+u("3-5")&&v.push({box:{l:j-q/2-u("1"),r:j+q/2+u("1"),t:$.c-L/2,b:$.c+L/2},on:!0}),v.push({box:{l:j-q/2,r:j+q/2,t:$.c-f-L,b:$.c-f},on:!1}),v.push({box:{l:j-q/2,r:j+q/2,t:$.c+f,b:$.c+f+L},on:!1})):($.len>=L+u("3")&&v.push({box:{l:$.c-q/2-u("1"),r:$.c+q/2+u("1"),t:j-L/2,b:j+L/2},on:!0}),v.push({box:{l:$.c+f,r:$.c+f+q,t:j-L/2,b:j+L/2},on:!1}),v.push({box:{l:$.c-f-q,r:$.c-f,t:j-L/2,b:j+L/2},on:!1})),_=v.find(m=>E(m.box))??null,_)break;!J&&v.some(m=>E(m.box,!1))&&(J=!0)}if(_)break}if(!_){c.push(d.i),J&&y.push(d.i);continue}const V=Vt(_.box,h.ox,h.oy,$=>E($));p.push(V),g.push({i:d.i,text:w,box:V,on:_.on})}return{labels:g,unseated:c,bounded:y}}function Zt(t,e,n,s){const a=[],o=[];return t.querySelectorAll(`.${n}-gbox, .${n}-group`).forEach(r=>{if(r.getClientRects().length===0||getComputedStyle(r).display==="contents")return;const l=lt(r,e);o.push(l),a.push({l:l.l,r:l.r,t:l.t,b:l.t+1},{l:l.l,r:l.r,t:l.b-1,b:l.b},{l:l.l,r:l.l+1,t:l.t,b:l.b},{l:l.r-1,r:l.r,t:l.t,b:l.b});const h=r.querySelector(`:scope > .${n}-glabel`);h&&h.getClientRects().length&&a.push(lt(h,e))}),t.querySelectorAll(`.${n}-lane`).forEach((r,l)=>{if(!r.getClientRects().length)return;const h=lt(r,e);l>0&&a.push({l:h.l,r:h.r,t:h.t-s/2-.5,b:h.t-s/2+.5});const u=r.querySelector(`.${n}-lane-name`);u&&a.push(lt(u,e))}),{obstacles:{rects:a,heads:[]},groups:o}}function Fe(t,e){const{m:s,tk:a,P:o,drawing:r,origin:l,warn:h}=t,u=a.space,p=Dt(s,r,l,o),g=[...p.values()],c=Be(r),y=l.left-Math.floor(l.left),b=l.top-Math.floor(l.top),i=Ht(y,b),d=r.clientWidth,w=r.clientHeight,q=M=>s.type==="data-flow"?M.col+1:M.col,L=parseFloat(getComputedStyle(r).rowGap)||0,O={w:d,h:w,nodes:g,lines:[],lifelines:[],labels:[],crossings:[],through:[],unseated:[],outside:[],ox:y,oy:b};if(s.type==="sequence")return Ne(t,O,i);let F,_=[];s.type==="schema"?F=s.edges.map(M=>{const T=s.byId.get(M.from),I=s.byId.get(M.to);if(T.col===I.col){const k=T.col===s.cols&&s.cols>1?"left":"right";return[k,k]}return I.col>T.col?["right","left"]:["left","right"]}):(F=s.edges.map(M=>{const T=s.byId.get(M.from),I=s.byId.get(M.to),[k,B]=je(T,I);return[M.fromSide??k,M.toSide??B]}),_=Te(s,F,h||(()=>{})));const J=(M,T)=>{const I=r.querySelector(`.${o}-node[data-node="${CSS.escape(M)}"] .${o}-row[data-row="${T}"]`);if(!I)return 0;const k=lt(I,l);return(k.t+k.b)/2},E=s.edges.map((M,T)=>{const[I,k]=F[T],B=p.get(M.from),H=p.get(M.to),Z=$t(M.kind,a);if(M.fk){const U=J(M.from,M.fromRow),nt=J(M.to,M.toRow),Y=i.y(U,Z),R=i.y(nt,Z);return{p1:{x:I==="right"?B.rect.r:B.rect.l,y:Y},p2:{x:k==="right"?H.rect.r:H.rect.l,y:R},r1:U,r2:Math.abs(Y-R)<.01?U:nt}}const tt=_.find(U=>U.edge===T&&U.end==="from").f,Q=_.find(U=>U.edge===T&&U.end==="to").f;let N=Wt(B,I,tt),D=Wt(H,k,Q);const et=P(I)?N.y:N.x;let ot=P(k)?D.y:D.x;return P(I)?N={...N,y:i.y(N.y,Z)}:N={...N,x:i.x(N.x,Z)},P(k)?D={...D,y:i.y(D.y,Z)}:D={...D,x:i.x(D.x,Z)},P(I)&&P(k)&&Math.abs(N.y-D.y)<1.01&&(D={...D,y:N.y},ot=et),!P(I)&&!P(k)&&Math.abs(N.x-D.x)<1.01&&(D={...D,x:N.x},ot=et),N=P(I)?rt(B,I,N.y):rt(B,I,N.x),D=P(k)?rt(H,k,D.y):rt(H,k,D.x),{p1:N,p2:D,r1:et,r2:ot}}),V=new Set;s.type==="schema"&&s.edges.forEach((M,T)=>{Math.abs(s.byId.get(M.from).col-s.byId.get(M.to).col)>1&&V.add(T)});const $=new Map,G=new Set;s.edges.forEach((M,T)=>{if(V.has(T))return;const[I,k]=F[T],{p1:B,p2:H}=E[T],Z=s.byId.get(M.from),tt=s.byId.get(M.to);let Q=null,N=null,D=!1;if(I===k){if(P(I)){const U=I==="right"?Math.max(q(Z),q(tt)):Math.min(q(Z),q(tt))-1,nt=c.cols[U-1],Y=c.cols[U];nt&&Y&&(Q=`c${U}`,N=[nt[1],Y[0]],D=!0)}else{const U=I==="bottom"?Math.max(Z.row2,tt.row2):Math.min(Z.row,tt.row)-1,nt=c.rows[U-1],Y=c.rows[U];nt&&Y&&(Q=`r${U}`,N=[nt[1],Y[0]],D=!1)}Q&&G.add(T)}else if(P(I)&&P(k)&&Math.abs(B.y-H.y)>.5){const U=q(tt),nt=k==="left",Y=c.cols[(nt?U-1:U)-1],R=c.cols[(nt?U:U+1)-1];Y&&R&&(Q=`c${nt?U-1:U}`,N=[Y[1],R[0]],D=!0)}else if(!P(I)&&!P(k)&&Math.abs(B.x-H.x)>.5){const nt=k==="top"?tt.row-1:tt.row2,Y=c.rows[nt-1],R=c.rows[nt];Y&&R&&(Q=`r${nt}`,N=[Y[1],R[0]],D=!1)}if(!Q||!N)return;$.has(Q)||$.set(Q,{span:N,vertical:D,members:new Map});const et=`${M.to}.${k}.${Math.round(D?H.y:H.x)}`,ot=$.get(Q);ot.members.has(et)||ot.members.set(et,[]),ot.members.get(et).push(T)});const j=new Map,v=M=>{const[T,I]=F[M],{p1:k,p2:B}=E[M];if(P(T)&&P(I)){if(T===I){const Z=j.get(M)??(T==="right"?Math.max(k.x,B.x)+u("4"):Math.min(k.x,B.x)-u("4"));return[k,{x:Z,y:k.y},{x:Z,y:B.y},B]}if(Math.abs(k.y-B.y)<=.5)return[k,{x:B.x,y:k.y}];const H=j.get(M)??(k.x+B.x)/2;return[k,{x:H,y:k.y},{x:H,y:B.y},B]}if(!P(T)&&!P(I)){if(T===I){const Z=j.get(M)??(T==="bottom"?Math.max(k.y,B.y)+u("4"):Math.min(k.y,B.y)-u("4"));return[k,{x:k.x,y:Z},{x:B.x,y:Z},B]}if(Math.abs(k.x-B.x)<=.5)return[k,{x:k.x,y:B.y}];const H=j.get(M)??(k.y+B.y)/2;return[k,{x:k.x,y:H},{x:B.x,y:H},B]}return P(T)?[k,{x:B.x,y:k.y},B]:[k,{x:k.x,y:B.y},B]},f=M=>{const T=s.edges[M],I=$t(T.kind,a),k=v(M),B=Nt(k,I,i);let H;return k.length===B.length&&(H=dt(k).map(([Z,tt])=>Math.abs(Z.y-tt.y)<.75?(Z.y+tt.y)/2:(Z.x+tt.x)/2),H[0]=E[M].r1,H.length>1&&(H[H.length-1]=E[M].r2)),{i:M,from:T.from,to:T.to,kind:T.kind,pts:B,tip:B[B.length-1],dir:kt(B),dot:T.fk?B[0]:void 0,width:I,axes:H}},m=()=>s.edges.flatMap((M,T)=>V.has(T)?[]:[f(T)]);let A=null;const S=M=>{A??(A=m());const T=A.map(I=>M.has(I.i)?f(I.i):I);return{lines:T,score:He(T,M)*1e5+xt(T,void 0,M).length*1e3+St(T.filter(I=>M.has(I.i)),g,s).length}},z=(M,T)=>{const I=M.flatMap(k=>{const{p1:B,p2:H}=E[k];return T?[B.y,H.y]:[B.x,H.x]});return[Math.min(...I),Math.max(...I)]};for(const[,M]of $){const T=[...M.members.values()].map(k=>({members:k,run:z(k,M.vertical)})).sort((k,B)=>k.run[0]-B.run[0]),I=[];for(const k of T){const B=I[I.length-1];B&&B.some(H=>H.run[0]G.has(et)))continue;const B=k.map(et=>et.members),H=B.length,Z=(M.span[1]-M.span[0])/(H+1);ZU.forEach(Y=>j.set(Y,M.span[0]+Z*(nt+1))));const ot=S(tt);ot.scoreet.forEach(U=>j.set(U,M.span[0]+Z*(ot+1)))),A=D}}O.lines=m();for(const M of V)h?.(`${s.edges[M].from} to ${s.edges[M].to} is two columns apart, so its line is not drawn; its row still writes the target`);O.crossings=xt(O.lines),O.through=St(O.lines,g,s),O.outside=Xt(O.lines,d,w,a);const{obstacles:C,groups:K}=Zt(r,l,o,L);C.heads=O.lines.map(M=>Gt(M,a));const W=Re(s,O.lines,g,C,K,{l:0,t:0,r:d,b:w},a,e,{ox:y,oy:b});return O.labels=W.labels,O.unseated=W.unseated,O.bounded=W.bounded,O.overlaps=[...new Set(Jt(O.lines,null).flat())],O}function He(t,e){return Jt(t,e).length}function Jt(t,e){const n=[];for(let s=0;s=l)continue;const[d,w]=c?[h.x,u.x]:[h.y,u.y],[q,L]=c?[p.x,g.x]:[p.y,g.y];Math.min(Math.max(d,w),Math.max(q,L))-Math.max(Math.min(d,w),Math.min(q,L))>1&&n.push([o.i,r.i])}}return n}function*Ut(t){if(t.length<=1){yield t.slice();return}if(t.length>5){yield t.slice();return}for(let e=0;e{const h=l===o.pts.length-1?Math.max(o.width/2,s.head/2):o.width/2;return r.x-h<-.5||r.x+h>e+.5||r.y-h<-.5||r.y+h>n+.5})&&a.push(o.i);return a}function St(t,e,n){const s=[];for(const a of t){const o=dt(a.pts);e.some(r=>o.some(([l,h])=>Ie(l,h,r)))&&s.push(a.i)}return s}function Ne(t,e,n){const{m:s,tk:a,P:o,drawing:r,origin:l}=t,h=a.space,u=new Map;r.querySelectorAll(`.${o}-node`).forEach(b=>u.set(b.dataset.node,lt(b,l)));const p=r.querySelector(`.${o}-steps`),g=p?lt(p,l).b:e.h,c=b=>{const i=u.get(b);return i?n.x((i.l+i.r)/2,a.hair):0};for(const b of s.nodes){const i=u.get(b.id);i&&e.lifelines.push({x:c(b.id),y1:i.b,y2:g})}const y=b=>u.get(b.id);return r.querySelectorAll(`.${o}-msg`).forEach(b=>{const i=b.dataset.from,d=b.dataset.to,w=b.dataset.kind??"plain",q=$t(w,a),L=lt(b,l),O=n.y((L.t+L.b)/2,q),F=Number(b.querySelector(`.${o}-num`)?.textContent??0),_=c(i),J=c(d);let E;if(i===d){const m=b.dataset.self==="start"?-h("6"):h("6"),A=n.y(O-h("2"),q),S=n.y(O+h("2"),q);E=[{x:_,y:A},{x:n.x(_+m,q),y:A},{x:n.x(_+m,q),y:S},{x:_,y:S}]}else E=[{x:_,y:O},{x:J,y:O}];e.lines.push({i:F,from:i,to:d,kind:w,pts:E,tip:E[E.length-1],dir:kt(E),width:q});const V=b.querySelector(`.${o}-said`),$=b.querySelector(`.${o}-note`),G=s.byId.get(i),j=s.byId.get(d);if(!G||!j)return;const v=i===d?(()=>{const m=s.nodes[G.i+(b.dataset.self==="start"?-1:1)],A=m?c(m.id):b.dataset.self==="start"?0:e.w;return Math.abs(A-_)-h("6")-h("2-5")-h("2")})():Math.abs(J-_)-2*h("2");Math.max(V?V.getBoundingClientRect().width:0,$?$.getBoundingClientRect().width:0)>v+.5&&e.unseated.push(F)}),e}function Yt(t,e,n,s=ut()){const{m:a,tk:o,P:r,drawing:l,origin:h}=t,u=o.space,p=Dt(a,l,h,r),g=[...p.values()],c=h.left-Math.floor(h.left),y=h.top-Math.floor(h.top),b=Ht(c,y),i=l.clientWidth,d=l.clientHeight,w={w:i,h:d,nodes:g,lines:[],lifelines:[],labels:[],crossings:[],through:[],unseated:[],outside:[],ox:c,oy:y},q=ut();if(a.type==="sequence"||a.type==="schema")return{geo:w,grow:q};const L=i-(parseFloat(getComputedStyle(l).paddingRight)||0),O=(v,f,m)=>{const A=[v];for(let S=1;S<=(ft(s,f)??0);S++)A.push({...v,t:v.t+m*u("4")*S,b:v.b+m*u("4")*S});return A},F=new Map;l.querySelectorAll(`.${r}-node`).forEach(v=>{const f=v.parentElement,m=lt(f,h),A=getComputedStyle(f);F.set(v.dataset.node,m.r-(parseFloat(A.paddingRight)||0)-(parseFloat(A.borderRightWidth)||0))});const _=a.nodes,J=v=>p.get(_[v].id),E=[],V=v=>$t(a.edges[v].kind,o);a.edges.forEach((v,f)=>{const m=n.routes[f],A=p.get(v.from),S=p.get(v.to),z=V(f);let C=[];const K=v.label,W=K?e(K,"label"):0,M=16,T=u("4");if(m==="down"||m==="up"){const k=Math.max(A.rect.l,S.rect.l),B=Math.min(A.rect.r,S.rect.r),H=a.edges.map((N,D)=>({o:N,j:D})).filter(({o:N,j:D})=>(n.routes[D]==="down"||n.routes[D]==="up")&&(N.from===v.from&&N.to===v.to||N.from===v.to&&N.to===v.from)),Z=H.findIndex(N=>N.j===f),tt=H.length<2?.5:H.length===2?Z===0?.25:.75:(Z+1)/(H.length+1),Q=b.x(k+(B-k)*tt,z);if(C=m==="down"?[rt(A,"bottom",Q),rt(S,"top",Q)]:[rt(A,"top",Q),rt(S,"bottom",Q)],K){let N=Math.min(C[0].y,C[1].y),D=Math.max(C[0].y,C[1].y);m==="down"?D-=o.head:N+=o.head;const et=[...l.querySelectorAll(`.${r}-group`)].map(Y=>lt(Y,h));let ot=[[N,D]];for(const Y of et)for(const R of[Y.t,Y.b])ot=ot.flatMap(([X,st])=>R>X+1&&Ret.some(X=>(Y+R)/2>X.t&&(Y+R)/2X.l&&Q1){const Y=ot.filter(([X,st])=>!U(X,st));[N,D]=(Y.length?Y:ot).reduce((X,st)=>st[1]-st[0]>X[1]-X[0]?st:X)}const nt=[1/2,1/3,2/3].map(Y=>{const R=N+(D-N)*Y;return{l:Q-W/2-u("1"),r:Q+W/2+u("1"),t:R-M/2,b:R+M/2}});E.push({k:f,cands:nt,on:!0,card:m==="down"?v.to:v.from})}}else if(m==="trunk"||m==="rail"){const k=b.x(Math.max(A.rect.l,m==="rail"?S.rect.l:A.rect.l)+u(m==="trunk"?"8":"3"),z),B=rt(A,"bottom",k);if(m==="rail"){if(C=[B,rt(S,"top",k)],K){const H=S.rect.t-u("6");E.push({k:f,cands:O({l:k+u("2-5"),r:k+u("2-5")+W,t:H-M/2,b:H+M/2},v.to,-1),on:!1,card:v.to})}}else{const H=b.x(S.rect.l+u("6"),z),Z=b.y(S.rect.t-T,z);C=[B,{x:k,y:Z},{x:H,y:Z},rt(S,"top",H)],K&&E.push({k:f,cands:O({l:H+u("2-5"),r:H+u("2-5")+W,t:Z-M/2,b:Z+M/2},v.to,-1),on:!1,card:v.to})}}else{const k=Math.min(F.get(v.from)??i,F.get(v.to)??i),B=b.x(n.gutter?L+(n.lanes[f]?2*u("3-5"):u("3-5")):k-u("2-5"),z),H=b.y(A.rect.t+(A.rect.b-A.rect.t)*n.exits[f],z),Z=rt(A,"right",H),tt=b.x(S.rect.r-u("6"),z),Q=m==="end-down",N=b.y(Q?S.rect.t-T:S.rect.b+T,z);C=[Z,{x:B,y:Z.y},{x:B,y:N},{x:tt,y:N},rt(S,Q?"top":"bottom",tt)];const D=Q?v.to:_[S.i+1]?.id??v.to;K&&E.push({k:f,cands:O({l:tt-u("2-5")-W,r:tt-u("2-5"),t:N-M/2,b:N+M/2},D,Q?-1:1),on:!1,card:D})}const I=Nt(C,z,b);w.lines.push({i:f,from:v.from,to:v.to,kind:v.kind,pts:I,tip:I[I.length-1],dir:kt(I),width:z})}),w.crossings=xt(w.lines),w.through=St(w.lines,g,a),w.outside=Xt(w.lines,i,d,o);const{obstacles:$}=Zt(l,h,r,0);$.heads=w.lines.map(v=>Gt(v,o));const G=[],j={l:0,t:0,r:i,b:d};for(const v of E){const f=S=>{const z=Rt(S,u("1"));return S.lj.r+.5||S.tj.b+.5||g.some(C=>Ft(z,C))||G.some(C=>ct(z,C))||$.heads.some(C=>ct(z,C))||$.rects.some(C=>ct(z,C))||w.lines.some(C=>C.i!==v.k&&dt(C.pts).some(([K,W])=>ct(z,Kt(K,W,C.width))))},m=v.cands.find(S=>!f(S));m||(q[v.card]=(q[v.card]??0)+1,w.unseated.push(v.k));const A=m?Vt(m,c,y,S=>!f(S)):v.cands[0];G.push(A),w.labels.push({i:v.k,text:a.edges[v.k].label,box:A,on:v.on})}return{geo:w,grow:q}}function ze(t,e){const n=o=>String(Math.round(o*100)/100);let s=`M${n(t[0].x)} ${n(t[0].y)}`;for(let o=1;o({...O})),g=p[p.length-1];g.x-=o.x*u,g.y-=o.y*u;const c=e.tip.x-o.x*l,y=e.tip.y-o.y*l,b=-o.y*h,i=o.x*h,d=O=>Math.round(O*100)/100,w=it(e.kind),q=r?``:``,L=e.dot?``:"";return`${q}${L}`}function Qt(t,e,n,s){const a=new Map,o=new Map;for(const l of e.crossings)o.has(l.under)||o.set(l.under,[]),o.get(l.under).push(l);let r="";for(const[l,h]of o){const u=`${s}-cut-${l}`;a.set(l,u);const p=h.map(g=>{const c=e.lines[g.top],y=e.lines[g.under],b=c.width/2+n.cut,i=y.width/2+1;return g.underVertical?``:``}).join("");r+=`${p}`}return{defs:r,ids:a}}function Pt(t,e,n,s){const{defs:a,ids:o}=Qt(t,e,n,s),r=e.lifelines.map(p=>``).join(""),l=e.lines.map((p,g)=>De(t,p,n,o.get(g)??null,p.from===p.to?n.radiusXs:n.radius)).join(""),h=``,u=e.labels.map(p=>`${it(p.text)}`).join("");return h+u}function Ge(t,e,n,s,a,o,r){const h=t.querySelector(`.${n}-drawing`);if(!h||t.clientWidth===0)return{dyn:a,geo:null,ink:"",tokens:null};const u=Le(t),p=_e(h,n),g=Ce(e,u,p),c=t.clientWidth,y=(()=>{const E=document.activeElement;return E&&h.contains(E)&&E.dataset.node?E.dataset.node:void 0})(),b=E=>ht(e,E)?{...E,stop:E.stop&&e.byId.has(E.stop)?E.stop:e.nodes[0]?.id,keep:void 0}:{...E,stop:E.stop??e.nodes[0]?.id,keep:y&&E.layout!=="drawn"?y:void 0},i=E=>{if(e.type!=="flowchart")return E;o({...E,heights:void 0,words:void 0});const V=ut(),$=ut();return h.querySelectorAll(`.${n}-node[data-shape="decision"]`).forEach(G=>{const j=G.querySelector(`.${n}-words`);if(!j)return;const v=G.getBoundingClientRect(),f=S=>{const z={w:S.width+2*u.space("2-5"),h:S.height+2*u.space("2")},C=1-z.w/v.width,K=C>.05?z.h/2/C:z.h*10;return Math.max(u.space("16"),Math.ceil(v.width/5),Math.ceil(2*K))},m=j.getBoundingClientRect();let A=f(m);if(A>v.width){const S=W=>(G.style.setProperty("--_ww",`${W}px`),j.getBoundingClientRect()),z=Math.floor(G.clientWidth-2*u.space("2-5"));let C=Math.ceil(m.width),K=m.height;for(;C1;){const k=W+M>>1;S(k).height({m:e,tk:u,P:n,drawing:h,origin:h.getBoundingClientRect(),warn:r}),w=a.autoOpen?{open:!1,autoOpen:void 0}:{},q=(E,V)=>V.map($=>yt(e,E.lines.find(G=>G.i===$))).join(", ");if(c>=g.least){const E=j=>{let v=b({...a,...w,layout:"drawn",grow:void 0,track:void 0,bare:void 0,pad:j||void 0});return v=i(v),o(v),{dd:v,g:Fe(d(),p)}};let{dd:V,g:$}=E(!1);const G=j=>j.through.length>0||j.outside.length>0||(j.overlaps?.length??0)>0;if(!G($)&&$.unseated.length&&$.unseated.every(j=>$.bounded?.includes(j))){const j=E(!0);!G(j.g)&&!j.g.unseated.length&&({dd:V,g:$}=j)}if(!G($)&&!$.unseated.length)return $.crossings.length&&r?.(`${$.crossings.length} crossing${$.crossings.length===1?"":"s"} in the drawn layout: ${$.crossings.map(j=>`${yt(e,$.lines[j.top])} over ${yt(e,$.lines[j.under])}`).join("; ")}`),{dyn:V,geo:$,ink:Pt(n,$,u,s),tokens:u};$.through.length&&r?.(`the drawn layout does not fit at ${Math.round(c)}px: ${q($,$.through)} would pass through a node`),$.overlaps?.length&&r?.(`the drawn layout does not fit at ${Math.round(c)}px: ${q($,$.overlaps)} would lie on one another`),$.outside.length&&r?.(`the drawn layout does not fit at ${Math.round(c)}px: ${q($,$.outside)} would leave the drawing`),$.unseated.length&&r?.(`the drawn layout does not fit at ${Math.round(c)}px: no clean seat for ${$.unseated.map(j=>e.type==="sequence"?`message ${j}`:`"${e.edges[j]?.label}"`).join(", ")}`)}let L=b({...a,...w,layout:"stacked",heights:void 0,grow:ut(),track:e.type==="schema"?g.table:void 0,bare:void 0,pad:void 0});if(L=i(L),o(L),e.type==="sequence"||e.type==="schema")return{dyn:L,geo:null,ink:"",tokens:u};const O=_t(e);let F=Yt(d(),p,O,L.grow);for(let E=0;E<6&&Object.keys(F.grow).length;E++){const V=ut(L.grow);for(const[$,G]of Object.entries(F.grow))V[$]=(ft(V,$)??0)+G;L={...L,grow:V},o(L),F=Yt(d(),p,O,V)}const _=F.geo;if(_.unseated.length>0||_.through.length>0||_.outside.length>0||O.third){_.unseated.length&&r?.(`the stacked drawing has no clean seat for ${[...new Set(_.unseated)].map($=>`"${e.edges[$]?.label}"`).join(", ")}, so its lines are not drawn; the list holds every connection`),_.through.length&&r?.(`in the stacked drawing ${q(_,_.through)} would pass through a node, so its lines are not drawn`),_.outside.length&&r?.(`in the stacked drawing ${q(_,_.outside)} would leave the drawing, so its lines are not drawn`),O.third&&r?.("the stacked drawing would need a third end lane, so its lines are not drawn");const E={..._,lines:[],labels:[],crossings:[]};return{dyn:b({...L,grow:ut(),bare:!0,open:a.bare?a.open:!0,autoOpen:a.bare?a.autoOpen:a.open?void 0:!0}),geo:E,ink:"",tokens:u}}return _.crossings.length&&r?.(`${_.crossings.length} crossing${_.crossings.length===1?"":"s"} in the stacked drawing (each is cut): ${_.crossings.map(E=>`${yt(e,_.lines[E.top])} over ${yt(e,_.lines[E.under])}`).join("; ")}`),{dyn:L,geo:_,ink:Pt(n,_,u,s),tokens:u}}function yt(t,e){const n=t.byId.get(e.from)?.name??e.from,s=t.byId.get(e.to)?.name??e.to;return`${n} to ${s}`}function Ke(t,e,n,s,a,o){const r=new Set;if(o){r.add(o);for(const i of n?.lines??[])i.from===o&&r.add(i.to),i.to===o&&r.add(i.from)}if(t.toggleAttribute("data-tracing",!!o),t.querySelectorAll(`.${e}-node`).forEach(i=>i.toggleAttribute("data-near",r.has(i.dataset.node))),!n||!s)return;const l=i=>!!o&&(i.from===o||i.to===o),h=t.querySelector(`.${e}-edges`),u=new Map;t.querySelectorAll(`.${e}-edge`).forEach(i=>u.set(i.getAttribute("data-edge"),i));for(const i of n.lines){const d=u.get(String(i.i));d&&(d.toggleAttribute("data-lit",l(i)),d.toggleAttribute("data-dim",!!o&&!l(i)))}if(t.querySelectorAll(`.${e}-label`).forEach(i=>{const d=n.lines.find(w=>String(w.i)===i.dataset.edge);i.toggleAttribute("data-lit",!!(d&&l(d)))}),h){for(const i of n.lines)if(l(i)){const d=u.get(String(i.i));d&&h.appendChild(d)}}const p=xt(n.lines,l),{defs:g,ids:c}=Qt(e,{...n,crossings:p},s,a),y=t.querySelector(`.${e}-svg`);if(!y)return;let b=y.querySelector("defs");!b&&g&&(b=document.createElementNS("http://www.w3.org/2000/svg","defs"),y.insertBefore(b,y.firstChild)),b&&(b.innerHTML=g),n.lines.forEach((i,d)=>{const w=u.get(String(i.i))?.querySelector(`.${e}-line`);if(!w)return;const q=c.get(d);q?w.setAttribute("mask",`url(#${q})`):w.removeAttribute("mask")})}var Ve=()=>matchMedia("(prefers-reduced-motion: reduce), (forced-colors: active), print").matches||document.documentElement.getAttribute("data-loops")==="held";function Ze(t,e){const n=t.getAttribute("data-entrance");if(!(n==="running"||n==="done")){if(!e){n&&t.removeAttribute("data-entrance");return}n||t.setAttribute("data-entrance",Ve()?"done":"pending")}}function Je(t){const e=t.getAttribute("data-entrance");e!=="pending"&&e!=="running"||(t.setAttribute("data-entrance","done"),t.dispatchEvent(new Event("basalt-diagram-settle")))}function Ue(t,e,n){const s=t.byId.get(e)?.i??0,a=t.nodes.length;let o;if(n==="ArrowRight"||n==="ArrowDown")o=s+1;else if(n==="ArrowLeft"||n==="ArrowUp")o=s-1;else if(n==="Home")o=0;else if(n==="End")o=a-1;else return null;return t.nodes[Math.max(0,Math.min(a-1,o))].id}var Xe=["data-layout","data-measured","role","aria-roledescription","aria-labelledby","aria-describedby","aria-label","tabindex","data-stops","hidden"],te=["data-layout","data-measured","data-bare","data-motion"],Ye=["--_track","--_h","--_ww","--_gap","--_ggrow","--_gpad"],ee=t=>t==null||t===!1;function Qe(t,e){if(t.tagName.toLowerCase()!==e.t)return!1;const n=typeof e.a.class=="string"?e.a.class.split(" ")[0]:"";return!n||t.classList.contains(n)}function ne(t,e,n=!0){if(typeof e=="string"||"slot"in e)return;const s=n?te:Xe;for(const r of s)ee(e.a[r])&&t.removeAttribute(r);for(const[r,l]of Object.entries(e.a)){if(r==="class")continue;if(r==="style"){const u=t.style,p=new Map(String(l??"").split(";").map(g=>{const c=g.indexOf(":");return[g.slice(0,c).trim(),g.slice(c+1).trim()]}).filter(([g])=>g));for(const[g,c]of p)u.getPropertyValue(g).trim()!==c&&u.setProperty(g,c);for(const g of Ye)p.has(g)||u.removeProperty(g);continue}if(n&&!te.includes(r))continue;if(ee(l)){t.removeAttribute(r);continue}const h=l===!0?"":String(l);t.getAttribute(r)!==h&&t.setAttribute(r,h)}if(e.t==="svg"||typeof e.a.class=="string"&&/-(ink|ruler)$/.test(e.a.class)||e.c.some(r=>typeof r!="string"&&"slot"in r))return;const a=[...t.children];let o=0;for(const r of e.c)if(!(typeof r=="string"||"slot"in r)){for(let l=o;lt.querySelector(`.${e}-node[data-node="${CSS.escape(o)}"]`);n&&a(n)?.setAttribute("tabindex","-1"),a(s)?.setAttribute("tabindex","0")}(function(t){"use strict";var e=t._,n="diagram",s=0;function a(c,y){return{prefix:n,base:c,hasSource:y.source!==void 0&&y.source!==null&&y.source!=="",hiddenClass:"visually-hidden"}}function o(c,y,b,i){var d=function(w){return''+it(w)+""};return{source:it(String(y.source||"")),summary:it(String(y.summary||"")),hint:Ae(c).map(function(w){return""+w.keys.map(d).join(" ")+" "+it(w.words)+""}).join(""),toggle:'"}}function r(c,y){var b=Et(c),i=Tt(b,{},a(y,c)),d=It(i,o(b,c,y,!1)),w=d.indexOf(">");return{open:d.slice(0,w+1),inner:d.slice(w+1,d.length-9),warnings:b.warnings}}var l=["aria-labelledby","data-type","data-cols","data-reach","data-gutter","data-layout","data-measured","data-bare"],h=["--_cols","--_gpad","--_track"];function u(c,y,b){c.__diagram&&c.__diagram.stop();var i=(c.getAttribute("aria-labelledby")||"").replace(/-title$/,"").replace(/[^A-Za-z0-9_-]/g,""),d=Et(y);if(!b||!i||!c.querySelector(":scope > .diagram-drawing")){if(!i||!c.querySelector("#"+CSS.escape(i+"-title"))){for(;document.getElementById("dg"+ ++s+"-title"););i="dg"+s}var w=r(y,i),q=document.createElement("div");q.innerHTML=w.open+"";var L=q.firstChild;l.forEach(function(R){c.removeAttribute(R)}),h.forEach(function(R){c.style.removeProperty(R)});for(var O=0;O :not(script[data-diagram])").forEach(function(R){R.remove()}),c.insertAdjacentHTML("beforeend",w.inner)}d.warnings.forEach(function(R){console.warn("Basalt diagram: "+R)});var _=a(i,y),J={},E=null,V=null,$=null,G=Object.create(null),j=function(R){G[R]||(G[R]=1,console.warn("Basalt diagram: "+R))},v=function(R){ne(c,Tt(d,R,_))},f=c.querySelector(".diagram-ink"),m=c.querySelector(".diagram-toggle"),A=d.motion.animated&&typeof e.diagramMotion=="function",S=null,z=null,C=function(){A&&Je(c)};function K(){Ke(c,n,E&&E.geo,E&&E.tokens,i,V||$)}function W(){m&&(m.setAttribute("aria-expanded",String(!!J.open)),m.firstElementChild.textContent=J.open?"Hide the list":"View as list")}function M(){E=Ge(c,d,n,i,J,v,j),J=E.dyn,v(J),W(),ht(d,J)||($=null);var R=f&&E.ink!==z;R&&(f.innerHTML=E.ink,z=E.ink),K(),A&&E.tokens&&(Ze(c,!!(E.geo&&E.geo.lines.length)),R&&S&&S.redrawn())}function T(R){J=R,v(J)}function I(R){var X=J.stop;J=Object.assign({},J,{stop:R}),Pe(c,n,X,R)}var k=function(R){var X=R&&R.closest?R.closest(".diagram-node"):null;return X&&c.contains(X)?X:null};function B(R){var X=k(R.target);if(!(!X||R.defaultPrevented)){if(C(),R.key==="Escape"){(V||$)&&(R.preventDefault(),V=$=null,K());return}if(ht(d,J)){var st=Ue(d,X.getAttribute("data-node"),R.key);if(st){R.preventDefault(),I(st);var oe=c.querySelector('.diagram-node[data-node="'+CSS.escape(st)+'"]');oe&&oe.focus()}}}}function H(R){var X=k(R.target);if(X){C();var st=X.getAttribute("data-node");V=X.matches(":focus-visible")?st:null,ht(d,J)&&J.stop!==st&&I(st),K()}}function Z(R){var X=k(R.target);X&&(k(R.relatedTarget)||(V=null),J.keep===X.getAttribute("data-node")&&T(Object.assign({},J,{keep:void 0})),K())}function tt(R){if(!(R.pointerType!=="mouse"||!matchMedia("(hover: hover)").matches)){var X=k(R.target);X&&C();var st=X&&ht(d,J)?X.getAttribute("data-node"):null;st!==$&&($=st,K())}}function Q(){$&&($=null,K())}function N(){C(),T(Object.assign({},J,{open:!J.open,autoOpen:void 0})),W()}c.addEventListener("keydown",B),c.addEventListener("focusin",H),c.addEventListener("focusout",Z),c.addEventListener("pointerover",tt),c.addEventListener("pointerleave",Q),m&&m.addEventListener("click",N),M();var D=c.clientWidth,et=0,ot=!0,U=new ResizeObserver(function(){Math.abs(c.clientWidth-D)<.5||(D=c.clientWidth,cancelAnimationFrame(et),et=requestAnimationFrame(M))});U.observe(c),document.fonts&&document.fonts.ready.then(function(){ot&&M()});var nt=matchMedia("(forced-colors: active)"),Y=d.nodes.some(function(R){return R.mark});Y&&nt.addEventListener("change",M),A&&(S=e.diagramMotion(c,{fig:c,P:n,base:i,model:function(){return d},geo:function(){return E&&E.geo},tokens:function(){return E&&E.tokens}},y)),c.__diagram={stop:function(){ot=!1,U.disconnect(),cancelAnimationFrame(et),Y&&nt.removeEventListener("change",M),S&&S.destroy(),c.removeEventListener("keydown",B),c.removeEventListener("focusin",H),c.removeEventListener("focusout",Z),c.removeEventListener("pointerover",tt),c.removeEventListener("pointerleave",Q),m&&m.removeEventListener("click",N)},layout:M,key:p(y),send:S&&S.sendValue?S.sendValue:null}}function p(c){try{return JSON.stringify(c,function(y,b){return y==="packet"&&b&&typeof b=="object"?Object.assign({},b,{send:void 0}):b})}catch{return null}}function g(){document.querySelectorAll("figure.diagram").forEach(function(c){if(!c.__diagram){var y=c.querySelector(":scope > script[data-diagram]");if(y)try{u(c,JSON.parse(y.textContent),!0)}catch(b){console.error("Basalt diagram: this figure could not be drawn",b)}}})}e.diagramMarkup=r,t.diagram=function(c,y){var b=c.__diagram,i=b&&b.send?p(y):null;if(i!==null&&i===b.key){b.send(y.packet?y.packet.send:void 0);return}u(c,y)},e.step(62,"wireDiagrams",g)})(window.Basalt)})();
diff --git a/.agent/skills/basalt-html/parts/manifest.json b/.agent/skills/basalt-html/parts/manifest.json
index 0659a0c4..8ea09914 100644
--- a/.agent/skills/basalt-html/parts/manifest.json
+++ b/.agent/skills/basalt-html/parts/manifest.json
@@ -1,5 +1,5 @@
{
- "$comment": "Which parts of the skill's CSS and JS a page gets. The core is always in. A module is in when the page's body has one of its classes, attributes or tags, matches one of its text patterns, or is named in a comment, and when another module needs it (requires). Modules are added in the order listed here, which is the order of the source files' cascade. classes: every class the module's CSS styles (the test checks them against the CSS and against SKILL.md). budget: the most bytes its minified CSS and JS may reach together. budgets: skillMd (SKILL.md, the context an agent pays: never above what it was), core (the CSS and JS of every page). icons: Phosphor names the module's script draws itself. Raised in the first parity PR (the owner's \"bring up the parity\"): forms (the number-input, search-clear and file-input chrome), disclosure (the native details marker), status (the accent reader and the forced-colours badge border), spinner (a fixed 16px ring), and the new number, range and accent modules. skillMd rose 10555 to 10900 for the new rules (number field, native chrome, the braille rule, the accent). Raised in the second parity PR (popup rows, levels and the segment's pill): segment 1400 to 3700 (the shared sliding pill: its script, 1.5 KB, and its CSS with the pill's two fallbacks), rows 3600 to 4300 (#27's plate-in-a-row geometry, the plate per level, the glide's shared plate and the forced-colours lit row, net of the removed bar), palette 9400 to 11300 (the glide's script, 2.4 KB: it follows the lit row, travels on a pointer, snaps on a key, and fades in place on leaving). The art module (DECISIONS 101 and 104) is the token groups only some pages name, taken out of the core so the core stays under its cap: the chart roles and lengths, the art colours, the aspect ratios and the stage headroom, in both themes (2087 bytes at 2100; it grows only when a token of those groups is added). A page gets it when its body names one of them, a var() in its own style included. The every-module page has no cap of its own (owner, DECISIONS 79): each part is capped, and a page carries only the parts it uses. usage: the most bytes of a module's usage text (src/usage/NAME.md; core.usage for core.md), which compose.mjs --usage prints on demand. It is context an agent pays only for the modules its page uses, so it is capped per part as SKILL.md and the CSS and script are (DECISIONS 79 and 109). Each is set a little above what its text was when the usage moved out of SKILL.md (DECISIONS 109); raising one needs a reason in the PR, and a rise of 40 to 50% is the owner's. textWords: each text pattern said in words, which compose.mjs --usage prints instead of the regular expression (one for each entry of text, in order). builds: modules a module requires whose markup its script writes, so --usage prints a line saying so instead of their usage text (the palette builds its own rows and key chips). The council's clarity check of the usage texts (all three: not yet clear) raised eight caps because the texts gained what an agent had to guess: callout 200 to 700 (the icon and one wrapper div around the title and body as markup, the four status icons, the role React's Callout renders), palette 1100 to 1300 (an item shown whole, keys as an array, keywords), stats 450 to 800 (a snippet of the figures and of the dl), tabs 500 to 650 (the unselected panels), code 250 to 450 (the markup and what each token class means), segment 150 to 300 (a click does not switch it), progress 150 to 350 (the empty span that paints the fill), theme 250 to 400 (leave the button empty), and accent 250 to 300. Topbar went down, 700 to 500, as its build detail was cut. Raised in the usage PR (the council's clarity check): palette 11300 to 11450 (the module grew 11283 to 11448, +165, about 1.5%), for the guard that makes a string `keys` warn and draw no chip instead of throwing in `keys.filter`, which the palette's usage already promised. Round 2 of the clarity check: tabs 650 to 750 (the panel's top space shown in the snippet, and that the script selects a tab on click). Raised in the site-icons and status PR (skill-parity part A, DECISIONS 106 and 107): status 1650 to 1900 (the neutral, pending and running marks, the badge's real border, and the forced-colours disc, net of the red danger word it drops) and its usage 400 to 1000 (every status in words, the word alone, running, forced colours); rows 4300 to 4450 (the profile list's seat rule and the status parts on a lit row) and its usage 300 to 600 (the profile list, with the one mistake: never an empty element for the seat). New: the links module (2671 bytes: the social row, the new-tab arrow's CSS and the script that draws it; budget 2750) and its usage (1746 bytes; cap 1850), which carries the social link, the glyph set, icon only and the new tab. Dropping Regular halves icons.json. Added in the overlay PR (skill-parity-4, batch 7 step 2, DECISIONS 108): the shared plate leaves palette.js for a glide module (the palette, a menu and the notification centre all call it), so the palette's cap went down, 11450 to 9250, and rows 4450 to 3850 (the plate's CSS moved to glide); and the overlay layer comes in as seven modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: popover (the native popup shell), menu, dialog (the dialog and alert dialog), sheet (on every side, the top one the site header's narrow menu), tooltip, toast and notifications (the centre). skillMd is unchanged in its cap (the eight new index lines fit within it); the core is unchanged in bytes. Added in the figures and charts PR (skill-parity-5, batch 7 step 3, DECISIONS 108): four modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: meter (React's Meter, CSS only, 2581 bytes), dlist (the description list, CSS only, 1265), terminal (the code block's transcript: its CSS, 3242, and the script that draws the gutter, the copy button and the replay, 4824) and chart (React's TimeChart and ChartGroup: 7313 of CSS and 23262 of script, which port chart.tsx's scale, layout, lane, labels, sentences, keyboard and table; it needs the art tokens, the table and the kbd chips, and a page without a chart carries none of it). Stats grew for the source line (budget 700 to 850, 798 bytes; its usage 800 to 950, 675 to 899 bytes, +33%, under the owner's 40 to 50%). skillMd is unchanged in its cap (four index lines fit within it); the core is unchanged in bytes. Added in the forms and selection PR (skill-parity-6, batch 7 step 4, DECISIONS 108): six modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: select (React's Select: the native select's closed trigger in every browser and, where `appearance: base-select` is shipped, the styled list with its two-line rows; a small script that says which input lit a row, 7740 bytes before it, choice (Checkbox, Radio, RadioGroup and Switch as styled native inputs; CSS only, with the first-frame rule), choice-card (ChoiceCard; CSS only), toggle (the pressed toggle's plate and check seat on .btn; CSS only), selection (a table's checkbox column: its fixed width and the script that sets aria-selected, the mixed header box and the count) and loops (the page-level hold on every loop with its switch: the held look and the script that stores it). The select's styles left forms, whose budget fell 3650 to 3250. skillMd rose 8621 to the size of its six new index lines, within its cap; the core is unchanged in bytes; compose adds the stored-hold line to the head of a page that has the loops module. Revised in the same PR (the lead's review of the build): the select gains select.js (one row is lit at a time, by whichever of the pointer and the keys moved last), and choice, toggle, selection and loops carry the first-frame rule, so a state a script sets on load (a mixed header box, the stored hold) paints at once with no crossfade. Added in the navigation and layout PR (skill-parity-7, batch 7 step 5, DECISIONS 108): five modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: glyph (Basalt's core glyphs drawn by name, at rest and selected, from a table the build works out from the drawn set; a page carries only the glyphs it names, and the drawing of a core glyph from data-glyph left the sheet module, which draws none now), nav (React's Nav: the sidebar's, the narrow menu's and More's rows, with the shared hugging pill), topbar-nav (the site header's links, one action and narrow menu, built by script from the bar's markup), app-shell (the shell, its sidebar and rail, and the app header) and tab-bar (the phone tab bar). The topbar module became the site header's bar (React's SiteHeader, DECISIONS 108: 56px with its line inside, the 44 by 44 brand target, the narrow-screen buttons, the derived sticky offset), budget 1600 to 3200 because its rules gained the app header's shared smoke, and its usage 500 to 750 (+50%) for the lockup's markup (the links, action and menu are topbar-nav's usage). Glide 3700 to 3950: the navigation's pill is a shape inside the row that the plate follows (about 200 bytes). The core's usage 2000 to 2100 (+5%): h2 is the Section step, the prose column's measure, and a link already 44px tall needs no margin. skillMd rose 9317 to 9863 for five index lines, under its cap; the core CSS grew 38 bytes (the layout tokens replace raw lengths, the gutter is one derived property, h2, .prose and .lead follow foundations) and the core script is unchanged. A module's media query writes %bp-md%, %bp-lg% or %bp-container% and the build substitutes the breakpoint tokens. Added in the tables and filters PR (skill-parity-8, batch 7 step 6, DECISIONS 108): the existing table module gains React's table additions (DECISIONS 95: the row header, \"Not observed\", the row density and the scroll hint with its small script), budget 1400 to 3000 (it was 1134 bytes of CSS; it is 2168 of CSS and 693 of script) and its usage 700 to 950 (+36%); and two modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: still-table (React's Table with `columns`: the fixed layout from a colgroup, the whole header cell as the sort button with its reserved seat, aria-sort, the pinned columns and their divider, the empty row; 4767 of CSS and 3264 of script, budget 8200) and filter (React's MultiSelect and FilterResult: the chips, the trigger and checklist with the search band from ten values, Clear held in place, the one debounced result line, and the narrowing of a table by `data-column`; 8240 of CSS and 7978 of script, budget 16400; it needs the popover, glide, glyph and choice modules). The core is unchanged in bytes. skillMd rose 9863 to 10128 for two index lines and the CaretUpDown icon's name, within its cap. Added in the commands PR (skill-parity-9, batch 7 step 7, DECISIONS 103 and 108): one new module a page carries only when it uses it, command-list (React's CommandList: the command panel set in the page, list plus preview, the push; it extends the palette and needs rows, kbd and glide; 5229 of CSS and 8734 of script, budget 14000, usage 2150). Two-line rows come to the existing modules: rows 3850 to 5350 (the described row's grid and description line, the push's chevron: 1481 bytes of CSS, the same rules React's menu rows carry), palette 9250 to 9900 (its rows are one function the list shares, with the description and the two-tier ranking of title matches over keyword and description matches; +636) and its usage 1300 to 1350, rows' usage 600 to 800, and glide 3950 to 4000 (a host that is idle counts as having no lit row, +54). skillMd rose 10128 to 10259 for one index line, within its cap; the core's CSS grew 24 bytes (.split.aside takes size-list-width in place of its raw 20rem: the same 320px, so no pixel moves) and the core script is unchanged. Added in the art PR (skill-parity-10, batch 7 step 8, DECISIONS 104 and 108): two modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: stage (React's Stage and PairedArt: full-bleed art under the site header, the pull-up by the sticky offset, the headroom, the paired art that follows the page's theme, and the forced-colours and print rules; CSS only, 1179 bytes) and framed-art (React's FramedArt: the figure, its rim and radius, the reserved box, the placeholder and the failed alt, the caption and credit; 2208 bytes of CSS and the 733-byte script that sets the frame's phase); both need the art tokens. The bar stays smoked over a stage: React clears it only over a stage that passed the headroom test helper, and a page has no test run (DECISIONS 108's note), so the skill builds no clear state. skillMd rose 10259 to 10500 for two index lines, within its cap; the core is unchanged in bytes. The callout gained the status rim in the same PR (DECISIONS 82, D8's status callouts): success, warning and danger draw their border in the status colour at 45% mixed in sRGB over the callout's own level, one solid colour on every side, and CanvasText in forced colours with the icon; the status colour is now one property the icon and the rim read. Its budget rose 900 to 1150 (the module is 1089 bytes, from 792: +297, about 37%); its usage is unchanged. Added in the overlays-and-the-rest PR (skill-parity-11, batch 7 step 9, DECISIONS 90 and 108): the last two parts of D8's part 5, each a module a page carries only when it uses it, with its own cap and usage cap set a little above its size: combobox (React's Combobox: the input with its caret button inside, the popup of the menu's rows with the glide's shared plate and two-line options, the filtering, the keys, the hidden value, the empty message and the check; 4342 of CSS and 6423 of script, budget 10900, usage 2150; it needs forms, popover and glide, and builds the last two) and sparkline (React's Sparkline: the label and latest value, the line, the axis, the empty sentence and the loading line that breathes; 1609 of CSS and 1874 of script, budget 3600, usage 950). The combobox copies the menu's row rules, as the select's list does, because React's Combobox renders MenuItem rows (a 40px hit area, a 36px plate) and the skill's .row is the palette's 44px: it carries no menu script. popover.js gains the combobox popup in the list of popups that keep focus where it is (+21 bytes, within its cap). skillMd rose 10500 to 10724 for two index lines, within its cap; the core is unchanged in bytes. Added in the motion-rules PR (DECISIONS 136 and 139): one module, ambient (a page's one ambient loop: CSS 828 bytes, script 433, budget 1300, usage 800), taken out of loops so the hold's own module grows only by the icon toggle's glyph swap (loops 2000 to 2200, +10%; its usage 1300 to 1650 for the icon form and the new settings-row sentence, +27%); and the chart's entrance (`entrance: true`: the marks' animations, their conditions and the redraw that restarts them at the elapsed time, 23262 to 25299 bytes of script; budget 30700 to 32800, +7%, usage 2500 to 2950, +18%). The core grew by the three tokens (27704 to 27862 bytes of CSS, under its cap). its stage usage gained the ambient art's line (1650 to 1750, +6%). skillMd rose 10724 to the size of the ambient index line, within its cap. Raised again in the motion-rules amendment (DECISIONS 143): chart 32800 to 33800 (script 25299 to 26375 bytes, +4%; +10% over the 30700 it began with) for the glide a new data set makes mid-entrance, print settling it, and `Basalt.pageChange()`; its usage 2950 to 3150 (+26% over the 2500 it began with). Raised in the second motion-rules amendment (DECISIONS 148): chart 33800 to 34400 (script 26375 to 26970 bytes: a line and its markers glide from their drawn geometry, and `beforeprint` settles the entrance; +12% over the 30700 it began with); topbar-nav 6900 to 7500 (+8.7%: the narrow menu's pause row, its CSS and 275 bytes of script, DECISIONS 148 item 2); loops usage 1650 to 1800 (+38% over the 1300 it began with, for the icon form's `title` and the menu row). Raised in the audit-design-b PR (DECISIONS 138 and 139): still-table 8200 to 13400 (+63%: the module was 7927 bytes and is 13311; the cut cell's plate, its focus stops and its dismissal, ported from React's cell-peek.ts, are 4273 bytes of script and 1111 of CSS; a still table that truncates needs them). The same PR: core usage 2100 to 2250 (+7%: the skip link, one bullet), forms usage 350 to 480 (+37%: the required mark), still-table usage 1950 to 2150 (+10%: the cut cell and the width rule), notifications usage 1050 to 1100 (+5%: the 44px entry on touch). The skip link's rim and radius took the core 30457 to 30609 bytes, under its cap (the rules that hang it under the bar are the topbar module's: 3200 to 3600, +12.5%); core 30720 to 31050 (+1.1%, DECISIONS 147: also the bar's links left out of the rule: the pseudo-element that makes a short standalone link a 44 by 44 target), skip-link script in the topbar module (3200 to 4150 over this PR, +30%: the rules that hang the link under the bar, 3600, and the script that reads the bar's real edge, 4150), sparkline 3600 to 4050 (+12.5%: React's ticker structure, so the value copies once on its line, and in forced colours the strips go and the number is plain text), forms budget 3250 to 3500 (+7.7%: the necessity word), notifications 9050 to 9250 (+2.2%: the 44px entry). Raised in the audit-design-b PR's E2 port (DECISIONS 138 and 139: the core set draws check, close, the chevrons, copy, plus, minus and search wherever a component draws them): the modules that drew a Phosphor icon for one of those now carry the core glyph's whole SVG, written in at build time (`%glyph-svg:name%`, the markup the glyph module's `_.glyph(name)` returns, so no module needs the glyph module and a page pays for nothing it does not use), and the Phosphor path of the same icon leaves the page. Each module's own bytes rose by that markup, and a page's total moved by what the Phosphor path it no longer carries saves: menu 8600 to 8900 (+303), combobox 10900 to 11200 (+303), copy 1900 to 2400 (+640), terminal 8100 to 8850 (+761), toast 13850 to 14150 (+325), number 2900 to 3400 (+557), filter 16400 to 17050 (+785), palette 9900 to 10450 (+536); the command list shares the palette's search drawing and fell 20 bytes. Set in integration-nov15, where the type-layout, motion-rules and audit-design-b branches meet: the combined tree measured SKILL.md 10959 bytes (each side's cap was 10900: both added index lines), core 31192 bytes (caps 30720 and 31050: the page-row and display rules, the three motion tokens and the skip link and 44px target rules all land in the core CSS) and core usage 2348 bytes (caps 2300 and 2250: type-layout's line and the skip-link bullet), so each is set to the measured bytes rounded up to the next 50: skillMd 10900 to 11000, core 31050 to 31200, core usage 2300 to 2350. Raised in the audit-design PR (decisions 138 and 139, parts A, D and C11): core 30720 to 31600 (+2.9%: the more-contrast block and its three aliases, and the field boundary token, every page carries as React does; the shadow-pill token is gone; the script gained `reserve`, 240 bytes), segment 3700 to 4100 and tabs 2300 to 2700 (the chosen label is 600 against 400, its width reserved by a span that carries its own copy, drawn unseen at 600; the pill's drop shadow is gone), and the segment's usage 300 to 380 (the weight and the glyph-only button). Raised again in the audit-design-a amendment (decision 145): core 31600 to 32300 (reserve() also reserves a label that is not plain text), segment 4100 to 5100 and tabs 2700 to 3500 (the second copy of such a label, and an icon drawn in both its forms), glyph 1100 to 1300 (a glyph in a segment or tab is drawn in both forms). Raised in the second audit-design-a amendment (decision 149): core 32300 to 32800 (reserve() builds the second copy of a label without any id, name, reference or hidden control, and does not copy a frame or media), segment 5100 to 5400 and its usage 380 to 500 (the 600 is on the label, the one-line rule and the usage text); the still-table cap is back at 8200, as the wash is on every cell again. Return 3 of the audit-design-a build (decision 149): tabs 3500 to 3700 (a tab the script has not reserved is 600 itself when selected, and one it declined is marked; the same two lines are in segment, which stays under 5400). Raised in the audit-fix-c2 PR (engineering, no pixel changes): toast 13850 to 14350 (the module was 13789 bytes and is 14288, +499, 3.6%) for F6, which focuses the Notifications region and Shift+Tab or Escape from it (or from the first toast) leaves it for where focus came from (and keeps a dialog's focus trap from wrapping it), as Base UI's viewport does in React, and for placing the region from focus (in the modal that holds it, or in the body), so a toast is never under a backdrop or in an inert modal whatever order the modals opened in (A3-09); the palette module grew 9864 to 9897 of its 9900 so that a palette opened over a modal sits inside it; topbar 3200 to 3250 (3123 to 3233, +110) for the scroll margin on what the bar holds, so a Tab into the bar from a scrolled page does not scroll the page (React's rule from PR #66); stage usage 1650 to 1750 (1580 to 1713, +8%) for the art's new place in the markup, after the content (A1-09), the stage's own CSS rising 1179 to 1208 within its 1250. skillMd rose 10724 to 10876 for the sentence that says a body may carry head tags, within its 10900. compose.mjs, the tool an agent runs, has no cap here (it is never in a page): it grew 21673 to 38153 bytes for the tokenizer that reads a body as HTML does and the head tags. Raised in the site-parts PR (DECISIONS 146, round 39), which folds each new part into the module it belongs with, so SKILL.md gains no index line (it has 41 bytes under its cap and a new module needs about 100): topbar 4150 to 17600 (+13450: the site footer and its disclosures, the lockup by pixel density, and a bar that arrives or leaves and returns, with its observer; a page that has a .topbar and no footer carries them too: the alternative, a module for each, needs its own index line and so SKILL.md bytes) and its usage 950 to 2900 (the footer's markup, the lockup's and the phase's); theme 650 to 4550 (the three-word theme choice: its CSS 2230 bytes and its script, 2277, with arrows, storage and the system listener) and its usage 400 to 1150 (the choice's markup written in full, so the right word is chosen before any script); segment 3700 to 3800 (a radio group's checked state besides a pressed button); stage 1250 to 2150 (its first script, 768 bytes, for fit and anchor) and its usage 1750 to 2000; framed-art 3000 to 3900 (drawn art in the frame: fit, anchor, no scaling strokes) and its usage 1250 to 1400. SKILL.md rose 10959 to 10992 (the topbar and theme index lines name .site-footer and .theme-choice). The head's theme line also writes data-theme-choice. Raised in site-parts return 2 (DECISIONS 146 B1 and B4): theme 4550 to 5350 (+800: the icon form of the theme choice, [data-theme-menu], whose button shows the theme in use, is named for the choice and opens the page's own .menu of three radio rows, in the theme script's 3073 bytes; the menu and popover modules are the page's, brought by its markup, so no module line was added and SKILL.md is 10993 of 11000) and its usage 1150 to 2200 (+91%: the menu's markup is written in full, and the deprecated toggle is said once); app-shell usage 2000 to 2100 and topbar-nav usage 1900 to 1950 (the theme control leaves the bar's text; the tools and the end cluster come in). The two example bodies still carry the deprecated data-theme-toggle. Return 2, F3 (DECISIONS 146 F): stage 2150 to 2250 (script 842 bytes: slice is the stage's default, as a frame's, and a drawing's own preserveAspectRatio stands unless the stage names data-fit or data-anchor) and its usage 2000 to 2150. framed-art 3900 to 4000 (a drawing's own preserveAspectRatio stands unless the figure names data-fit or data-anchor, +101 bytes). Return 3: theme 5350 to 5900 (script +569 bytes: who wrote data-theme, so System follows the system's change live and a theme the page set by hand, or a .dark or .light root, survives it). Raised in the controls port (DECISIONS 154): skillMd 11000 to 11200 for two index lines (link-tabs and option-chips, 214 bytes together), and core 31200 to 31600 for the nine tokens the port adds to every page's token CSS (the control rungs 44 to 64, two container widths, the confirm hold and the amount's opacity, 311 bytes). New modules (DECISIONS 154): link-tabs 2700 (its sizes, the 640 container step, the forced-colours underline, and the select that replaces the row under 720 with its 590-byte script, A15; it requires the select module), option-chips 5700 (the chip's states each written for a native radio inside a label, which needs :has on every one, plus the 1 KB script that keeps an aria-disabled chip reachable and never chosen). Return 3 (DECISIONS 154 conformance): link-tabs 2700 to 3100 and its usage 1650 to 1850 (the select's height for each row size, and a script that reads aria-current when it is needed and watches it move: 3,048 bytes), option-chips 5700 to 6700 (each state written twice, as a state attribute and as :has(), so no browser needs :has(): 4,975 CSS and 1,623 script). Return 4 (DECISIONS 158, Q2): link-tabs 3100 to 4300 and its usage 1850 to 2400 (the \"Go to\" label drawn at the select's start with its measured clearance, the select's accessible name kept as the words and the chosen page's, and the key hold that keeps a letter or an arrow on the closed select from navigating: 4,174 bytes, CSS 2,951 and script 1,223). Raised in the links-and-rows port (DECISIONS 152; the owner's approval is the lead's to confirm): the new link-rows module (5050 bytes of CSS, 50 of them for Castle's big-row arrow stepping colour over duration-fast, return 1, 1500 of usage: the directory's and the big rows' CSS, whose arrow is a core glyph drawn as a mask, and their tokens, size-row taken out of the core like type-layout's), disclosure 1550 to 3500 (Show all: the track, the clip and the settle, 1.5 KB of script and 1.8 KB of CSS), copy 2400 to 3500 (the form with words: the one cell and its script). SKILL.md rose 10959 to 10997 for one line, within its 11000 cap. Raised in the charts port PR (DECISIONS 153, D7a): chart 34400 to 34650 (script 26970 to 27270 bytes, +1.1% on the 34283 it was: `Basalt.trailingMean`, the trend maths React exports as `trailingMean`, 300 bytes), its usage 3150 to 3350 (+6%: one line for it). The tokens the batch adds (chart-lit-top, -mid and -base in both themes, size-chart-plot-sm, size-chart-row, size-meter-marker and radius-2xs) took the art module 2087 to 2546 bytes (budget 2100 to 2600, +24%: the chart tokens are its group) and the core 31192 to 31250 (cap 31200 to 31300, +0.3%: radius-2xs). Only D7a names a skill module in the charts ballot; the lit marks, the headline frame, the phase chart, the share bar, the coverage strip, the marks row and the range meter are React-only in this batch. Added in the overlays-and-search PR (DECISIONS 155, D10b and D13a): the sheet gains React's head, body and foot (the 44px close, the 20/28 title over a 13px count, the divider and the safe areas; its CSS 3.6 to 5.2 KB, budget 4050 to 5250, +30%) and its usage 1050 to 1450 (+38%: the anatomy and the step's focus, two bullets); and one new module a page carries only when it uses it, search (React's SearchDialog: the form, the field's -2 outline, the count line, the fixed-height results area and the rows with their picture slots and full-bleed hover wash; CSS only, 4368 bytes, budget 4400, usage 2050; it requires the dialog). The dialog's title draws no ring when script focuses it. skillMd rose 10959 to 11079 for the search line (the sheet's line is unchanged: its usage carries the anatomy), so its cap rose 11000 to 11100 (+0.9%). The core's CSS grew 31192 to 31421 bytes for the six new size tokens (the wide dialog, the search trigger and the logo and picture slots of a search result): its cap rose 31200 to 31450 (+0.8%). The two 44px values (the sheet's close and the search field) are local to their modules, with a lint exception that says they join the controls batch's size token (DECISIONS 154). Set in integration-nov15b, where audit-design-a, audit-fix-c2, site-parts, port-controls, port-links-rows, port-charts and port-overlays-search meet: the combined tree measured SKILL.md 11560 bytes (the caps were 11000, 11100 and 11200: each side added index lines), core 34086 bytes (caps 31300 to 33550: every side's rules land in the core CSS and script), topbar 17660 (17600 from site-parts, plus audit-fix-c2's skip-link and focus work), number 3453 (3400), palette 11379 (11000, audit-fix-c2's hosted scrim plus the core search glyph), dialog 5120 (5100), toast 15692 (15400) and stage usage 2248 (2150), each over every side's cap, so each is set to the measured bytes rounded up to the next 50: skillMd 11200 to 11600, core 33550 to 34100, topbar 17600 to 17700, number 3400 to 3500, palette 11000 to 11400, dialog 5100 to 5150, toast 15400 to 15700, stage usage 2150 to 2250. The segment cap is the base's 5400 plus port-controls' 100 (5500), unchanged by the merge. Raised in integration-nov15b, join 2 (a link tab takes the selected state, DECISIONS 138 A, 145, 149 and 154's D12 row): link-tabs 4300 to 5750 (+34%: the module was 4174 bytes and is 5736; the 600 against 400, the reserved width and the second copy of a composed label, an icon drawn in both its forms, the same rules a tab carries, 1,530 bytes of CSS and script) and its usage 2400 to 2550 (+6%: one bullet). The cap is the measured bytes rounded up to the next 50; a module that needs the tab's rules carries them as the segment and tabs modules do, so a page without link tabs pays nothing. Raised in the panels, art and parts port (DECISIONS 162): table 3000 to 3150 and its usage 950 to 1450 (the flat form and the two-line cell), stage 2250 to 2600 and its usage 2250 to 3100 (the closing block: its held art, forced colours and print; its section gap is type-layout's --basalt-section-gap, which a page with data-closing brings), the new app-tile 4300 (a 120-point polygon clip and the hairline's mask of the same outline), captioned 2000 and period 1400; skillMd 11600 to 11950 for one index line each for captioned, app-tile and period (358 bytes; the file is 11918). Raised in the logs, status and forms port (DECISIONS 162): core 34100 to 34200 (the new size-field-label-inline token, 80px, is written into every page's tokens: 25 bytes); dlist 1300 to 1900 and its usage 950 to 1060 (the stacked form, R9 and R10: a title over its text, 20px between entries, no divider; one usage line). Raised in audit-fix-c6 (the owner's cap, raised by the builder and for the owner to confirm): glyph 1300 to 1900, for redrawing a glyph when its ancestor's aria-current or data-current moves (the lists that hold glyphs are watched). Raised in the colour-ink-ladder build (DECISIONS 166): core 34200 to 34350 (the four lifted dark inks are four new primitives, each written into every page's tokens: the core measured 34307). Raised in the audit-2-design build (DECISIONS 167, Q7a): disclosure 3500 to 3800 (the core chevron drawn as a mask in place of two borders: the module measured 3755). Joined in the integration of c7 (#86) and c10 (#91): option-chips 6750 to 6850 (c7's reset resync and c10's data-ready together measure 6839). Raised in table-sort-3 (DECISIONS 257 and 261, the owner's pick: three sort states, the arrow after the label, explainers on column titles): still-table 13400 to 14650 (+9.3%: the module was 13343 bytes and is 14602; the end-aligned label's move by a transform, its right-to-left sign and the indicator that waits for it on a fine pointer, 912 bytes of CSS; the third state, the sort from the table's own order and a .explainer kept out of the button, 347 bytes of script) and its usage 2150 to 2250 (2197: the third state and the own order); the new explainer module 5850 (5842: a manual native popover opened from the sort button on hover, keyboard focus and a long press, placed above the header or beside it, 1752 bytes of CSS and 4090 of script; a page without explainers pays nothing) and its usage 900; skillMd 12250 to 12400 for the explainer's index line (113 bytes; the file is 12352). Each cap is the measured bytes rounded up to the next 50. Raised in table-sort-3's fix pass (Astra's review): explainer 5850 to 6900 (+18%: 5842 to 6864 bytes; the gap between the header and the card kept while a pointer crosses it, the close when its header leaves the view whatever has focus, the dismissal held until pointer and focus have both left, and its page-wide listeners and timers scoped to an open card and stopped when the table leaves the page, 1,022 bytes of script). Raised in cimip-gaps-2 batch B5 (the touch sizes under 720 whatever the pointer: each coarse-pointer target rule also answers a window under 720, about 20 bytes a rule; forms merged its three into one and stays under 3500): select 9000 to 9100 (measured 9064), selection 1480 to 1500 (1486), filter 17450 to 17500 (17473), option-chips 6850 to 6900 (6853), menu 8900 to 8950 (8902). B5 fix pass 1 (Astra): core 34550 to 34950 (measured 34911: 30762 CSS and 4149 JS) for stacked links in a column, each giving up the side of its 44px box that meets a neighbour, so a tap on a link's words is always that link's; core had 12 bytes free. DECISIONS 274 (the owner's pick: under 720 the toast stack hangs from the bar): toast 15700 to 16050 (measured 16035; 8 bytes were free; the stack's direction became one sign variable, trimming 585 of the 920 bytes the phone form first took). B5 merged with main (5ad5345a): main's own core measured 34930 against its 34550 cap before B5; with B5 (the touch sizes under 720 and stacked links in a column) it is 35331, so core is 35350; nav 5350 to 5400 (measured 5364: B4's nav plus the touch size under 720). The full run after the stream (DECISIONS 246): the site footer's links keep their own flex column under 720, as React's, out of the bare-link touch rule (26 bytes), so core is 35400 (measured 35357); sheet 5250 to 5400 (measured 5368: React's B5 ring room, ported: the held actions reach space-1-5 above their band, clipped, and the body keeps space-1-5 at each end). Raised for diagram motion and service marks (DECISIONS 292): skillMd 12550 to 12650 for the diagram-motion module's one line; diagram 87200 to 91000 for what a still diagram now carries (a card's mark and its seat, the pending frame, the comparison that writes a drawing only when it changed, and the print rule), and its usage 2600 to 4300 for the decision's four lines and the list of mark ids; the new diagram-motion module (the motion engine, its stylesheet and the motion tokens, in a page only when a diagram is animated) at 26200. Raised when the diagram tests were first run (DECISIONS 298): diagram 91000 to 91250 and diagram-motion 26200 to 26850. Fix round 1 of #124 had already taken them to 91205 and 26621 with the tests unrun; this round added 1 byte (every focal node prints its fill; a one-form mark's dark form falls back to its light one) and 180 (the entrance keeps its own clock when it is drawn again while paused).",
+ "$comment": "Which parts of the skill's CSS and JS a page gets. The core is always in. A module is in when the page's body has one of its classes, attributes or tags, matches one of its text patterns, or is named in a comment, and when another module needs it (requires). Modules are added in the order listed here, which is the order of the source files' cascade. classes: every class the module's CSS styles (the test checks them against the CSS and against SKILL.md). budget: the most bytes its minified CSS and JS may reach together. budgets: skillMd (SKILL.md, the context an agent pays: never above what it was), core (the CSS and JS of every page). icons: Phosphor names the module's script draws itself. Raised in the first parity PR (the owner's \"bring up the parity\"): forms (the number-input, search-clear and file-input chrome), disclosure (the native details marker), status (the accent reader and the forced-colours badge border), spinner (a fixed 16px ring), and the new number, range and accent modules. skillMd rose 10555 to 10900 for the new rules (number field, native chrome, the braille rule, the accent). Raised in the second parity PR (popup rows, levels and the segment's pill): segment 1400 to 3700 (the shared sliding pill: its script, 1.5 KB, and its CSS with the pill's two fallbacks), rows 3600 to 4300 (#27's plate-in-a-row geometry, the plate per level, the glide's shared plate and the forced-colours lit row, net of the removed bar), palette 9400 to 11300 (the glide's script, 2.4 KB: it follows the lit row, travels on a pointer, snaps on a key, and fades in place on leaving). The art module (DECISIONS 101 and 104) is the token groups only some pages name, taken out of the core so the core stays under its cap: the chart roles and lengths, the art colours, the aspect ratios and the stage headroom, in both themes (2087 bytes at 2100; it grows only when a token of those groups is added). A page gets it when its body names one of them, a var() in its own style included. The every-module page has no cap of its own (owner, DECISIONS 79): each part is capped, and a page carries only the parts it uses. usage: the most bytes of a module's usage text (src/usage/NAME.md; core.usage for core.md), which compose.mjs --usage prints on demand. It is context an agent pays only for the modules its page uses, so it is capped per part as SKILL.md and the CSS and script are (DECISIONS 79 and 109). Each is set a little above what its text was when the usage moved out of SKILL.md (DECISIONS 109); raising one needs a reason in the PR, and a rise of 40 to 50% is the owner's. textWords: each text pattern said in words, which compose.mjs --usage prints instead of the regular expression (one for each entry of text, in order). builds: modules a module requires whose markup its script writes, so --usage prints a line saying so instead of their usage text (the palette builds its own rows and key chips). The council's clarity check of the usage texts (all three: not yet clear) raised eight caps because the texts gained what an agent had to guess: callout 200 to 700 (the icon and one wrapper div around the title and body as markup, the four status icons, the role React's Callout renders), palette 1100 to 1300 (an item shown whole, keys as an array, keywords), stats 450 to 800 (a snippet of the figures and of the dl), tabs 500 to 650 (the unselected panels), code 250 to 450 (the markup and what each token class means), segment 150 to 300 (a click does not switch it), progress 150 to 350 (the empty span that paints the fill), theme 250 to 400 (leave the button empty), and accent 250 to 300. Topbar went down, 700 to 500, as its build detail was cut. Raised in the usage PR (the council's clarity check): palette 11300 to 11450 (the module grew 11283 to 11448, +165, about 1.5%), for the guard that makes a string `keys` warn and draw no chip instead of throwing in `keys.filter`, which the palette's usage already promised. Round 2 of the clarity check: tabs 650 to 750 (the panel's top space shown in the snippet, and that the script selects a tab on click). Raised in the site-icons and status PR (skill-parity part A, DECISIONS 106 and 107): status 1650 to 1900 (the neutral, pending and running marks, the badge's real border, and the forced-colours disc, net of the red danger word it drops) and its usage 400 to 1000 (every status in words, the word alone, running, forced colours); rows 4300 to 4450 (the profile list's seat rule and the status parts on a lit row) and its usage 300 to 600 (the profile list, with the one mistake: never an empty element for the seat). New: the links module (2671 bytes: the social row, the new-tab arrow's CSS and the script that draws it; budget 2750) and its usage (1746 bytes; cap 1850), which carries the social link, the glyph set, icon only and the new tab. Dropping Regular halves icons.json. Added in the overlay PR (skill-parity-4, batch 7 step 2, DECISIONS 108): the shared plate leaves palette.js for a glide module (the palette, a menu and the notification centre all call it), so the palette's cap went down, 11450 to 9250, and rows 4450 to 3850 (the plate's CSS moved to glide); and the overlay layer comes in as seven modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: popover (the native popup shell), menu, dialog (the dialog and alert dialog), sheet (on every side, the top one the site header's narrow menu), tooltip, toast and notifications (the centre). skillMd is unchanged in its cap (the eight new index lines fit within it); the core is unchanged in bytes. Added in the figures and charts PR (skill-parity-5, batch 7 step 3, DECISIONS 108): four modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: meter (React's Meter, CSS only, 2581 bytes), dlist (the description list, CSS only, 1265), terminal (the code block's transcript: its CSS, 3242, and the script that draws the gutter, the copy button and the replay, 4824) and chart (React's TimeChart and ChartGroup: 7313 of CSS and 23262 of script, which port chart.tsx's scale, layout, lane, labels, sentences, keyboard and table; it needs the art tokens, the table and the kbd chips, and a page without a chart carries none of it). Stats grew for the source line (budget 700 to 850, 798 bytes; its usage 800 to 950, 675 to 899 bytes, +33%, under the owner's 40 to 50%). skillMd is unchanged in its cap (four index lines fit within it); the core is unchanged in bytes. Added in the forms and selection PR (skill-parity-6, batch 7 step 4, DECISIONS 108): six modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: select (React's Select: the native select's closed trigger in every browser and, where `appearance: base-select` is shipped, the styled list with its two-line rows; a small script that says which input lit a row, 7740 bytes before it, choice (Checkbox, Radio, RadioGroup and Switch as styled native inputs; CSS only, with the first-frame rule), choice-card (ChoiceCard; CSS only), toggle (the pressed toggle's plate and check seat on .btn; CSS only), selection (a table's checkbox column: its fixed width and the script that sets aria-selected, the mixed header box and the count) and loops (the page-level hold on every loop with its switch: the held look and the script that stores it). The select's styles left forms, whose budget fell 3650 to 3250. skillMd rose 8621 to the size of its six new index lines, within its cap; the core is unchanged in bytes; compose adds the stored-hold line to the head of a page that has the loops module. Revised in the same PR (the lead's review of the build): the select gains select.js (one row is lit at a time, by whichever of the pointer and the keys moved last), and choice, toggle, selection and loops carry the first-frame rule, so a state a script sets on load (a mixed header box, the stored hold) paints at once with no crossfade. Added in the navigation and layout PR (skill-parity-7, batch 7 step 5, DECISIONS 108): five modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: glyph (Basalt's core glyphs drawn by name, at rest and selected, from a table the build works out from the drawn set; a page carries only the glyphs it names, and the drawing of a core glyph from data-glyph left the sheet module, which draws none now), nav (React's Nav: the sidebar's, the narrow menu's and More's rows, with the shared hugging pill), topbar-nav (the site header's links, one action and narrow menu, built by script from the bar's markup), app-shell (the shell, its sidebar and rail, and the app header) and tab-bar (the phone tab bar). The topbar module became the site header's bar (React's SiteHeader, DECISIONS 108: 56px with its line inside, the 44 by 44 brand target, the narrow-screen buttons, the derived sticky offset), budget 1600 to 3200 because its rules gained the app header's shared smoke, and its usage 500 to 750 (+50%) for the lockup's markup (the links, action and menu are topbar-nav's usage). Glide 3700 to 3950: the navigation's pill is a shape inside the row that the plate follows (about 200 bytes). The core's usage 2000 to 2100 (+5%): h2 is the Section step, the prose column's measure, and a link already 44px tall needs no margin. skillMd rose 9317 to 9863 for five index lines, under its cap; the core CSS grew 38 bytes (the layout tokens replace raw lengths, the gutter is one derived property, h2, .prose and .lead follow foundations) and the core script is unchanged. A module's media query writes %bp-md%, %bp-lg% or %bp-container% and the build substitutes the breakpoint tokens. Added in the tables and filters PR (skill-parity-8, batch 7 step 6, DECISIONS 108): the existing table module gains React's table additions (DECISIONS 95: the row header, \"Not observed\", the row density and the scroll hint with its small script), budget 1400 to 3000 (it was 1134 bytes of CSS; it is 2168 of CSS and 693 of script) and its usage 700 to 950 (+36%); and two modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: still-table (React's Table with `columns`: the fixed layout from a colgroup, the whole header cell as the sort button with its reserved seat, aria-sort, the pinned columns and their divider, the empty row; 4767 of CSS and 3264 of script, budget 8200) and filter (React's MultiSelect and FilterResult: the chips, the trigger and checklist with the search band from ten values, Clear held in place, the one debounced result line, and the narrowing of a table by `data-column`; 8240 of CSS and 7978 of script, budget 16400; it needs the popover, glide, glyph and choice modules). The core is unchanged in bytes. skillMd rose 9863 to 10128 for two index lines and the CaretUpDown icon's name, within its cap. Added in the commands PR (skill-parity-9, batch 7 step 7, DECISIONS 103 and 108): one new module a page carries only when it uses it, command-list (React's CommandList: the command panel set in the page, list plus preview, the push; it extends the palette and needs rows, kbd and glide; 5229 of CSS and 8734 of script, budget 14000, usage 2150). Two-line rows come to the existing modules: rows 3850 to 5350 (the described row's grid and description line, the push's chevron: 1481 bytes of CSS, the same rules React's menu rows carry), palette 9250 to 9900 (its rows are one function the list shares, with the description and the two-tier ranking of title matches over keyword and description matches; +636) and its usage 1300 to 1350, rows' usage 600 to 800, and glide 3950 to 4000 (a host that is idle counts as having no lit row, +54). skillMd rose 10128 to 10259 for one index line, within its cap; the core's CSS grew 24 bytes (.split.aside takes size-list-width in place of its raw 20rem: the same 320px, so no pixel moves) and the core script is unchanged. Added in the art PR (skill-parity-10, batch 7 step 8, DECISIONS 104 and 108): two modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: stage (React's Stage and PairedArt: full-bleed art under the site header, the pull-up by the sticky offset, the headroom, the paired art that follows the page's theme, and the forced-colours and print rules; CSS only, 1179 bytes) and framed-art (React's FramedArt: the figure, its rim and radius, the reserved box, the placeholder and the failed alt, the caption and credit; 2208 bytes of CSS and the 733-byte script that sets the frame's phase); both need the art tokens. The bar stays smoked over a stage: React clears it only over a stage that passed the headroom test helper, and a page has no test run (DECISIONS 108's note), so the skill builds no clear state. skillMd rose 10259 to 10500 for two index lines, within its cap; the core is unchanged in bytes. The callout gained the status rim in the same PR (DECISIONS 82, D8's status callouts): success, warning and danger draw their border in the status colour at 45% mixed in sRGB over the callout's own level, one solid colour on every side, and CanvasText in forced colours with the icon; the status colour is now one property the icon and the rim read. Its budget rose 900 to 1150 (the module is 1089 bytes, from 792: +297, about 37%); its usage is unchanged. Added in the overlays-and-the-rest PR (skill-parity-11, batch 7 step 9, DECISIONS 90 and 108): the last two parts of D8's part 5, each a module a page carries only when it uses it, with its own cap and usage cap set a little above its size: combobox (React's Combobox: the input with its caret button inside, the popup of the menu's rows with the glide's shared plate and two-line options, the filtering, the keys, the hidden value, the empty message and the check; 4342 of CSS and 6423 of script, budget 10900, usage 2150; it needs forms, popover and glide, and builds the last two) and sparkline (React's Sparkline: the label and latest value, the line, the axis, the empty sentence and the loading line that breathes; 1609 of CSS and 1874 of script, budget 3600, usage 950). The combobox copies the menu's row rules, as the select's list does, because React's Combobox renders MenuItem rows (a 40px hit area, a 36px plate) and the skill's .row is the palette's 44px: it carries no menu script. popover.js gains the combobox popup in the list of popups that keep focus where it is (+21 bytes, within its cap). skillMd rose 10500 to 10724 for two index lines, within its cap; the core is unchanged in bytes. Added in the motion-rules PR (DECISIONS 136 and 139): one module, ambient (a page's one ambient loop: CSS 828 bytes, script 433, budget 1300, usage 800), taken out of loops so the hold's own module grows only by the icon toggle's glyph swap (loops 2000 to 2200, +10%; its usage 1300 to 1650 for the icon form and the new settings-row sentence, +27%); and the chart's entrance (`entrance: true`: the marks' animations, their conditions and the redraw that restarts them at the elapsed time, 23262 to 25299 bytes of script; budget 30700 to 32800, +7%, usage 2500 to 2950, +18%). The core grew by the three tokens (27704 to 27862 bytes of CSS, under its cap). its stage usage gained the ambient art's line (1650 to 1750, +6%). skillMd rose 10724 to the size of the ambient index line, within its cap. Raised again in the motion-rules amendment (DECISIONS 143): chart 32800 to 33800 (script 25299 to 26375 bytes, +4%; +10% over the 30700 it began with) for the glide a new data set makes mid-entrance, print settling it, and `Basalt.pageChange()`; its usage 2950 to 3150 (+26% over the 2500 it began with). Raised in the second motion-rules amendment (DECISIONS 148): chart 33800 to 34400 (script 26375 to 26970 bytes: a line and its markers glide from their drawn geometry, and `beforeprint` settles the entrance; +12% over the 30700 it began with); topbar-nav 6900 to 7500 (+8.7%: the narrow menu's pause row, its CSS and 275 bytes of script, DECISIONS 148 item 2); loops usage 1650 to 1800 (+38% over the 1300 it began with, for the icon form's `title` and the menu row). Raised in the audit-design-b PR (DECISIONS 138 and 139): still-table 8200 to 13400 (+63%: the module was 7927 bytes and is 13311; the cut cell's plate, its focus stops and its dismissal, ported from React's cell-peek.ts, are 4273 bytes of script and 1111 of CSS; a still table that truncates needs them). The same PR: core usage 2100 to 2250 (+7%: the skip link, one bullet), forms usage 350 to 480 (+37%: the required mark), still-table usage 1950 to 2150 (+10%: the cut cell and the width rule), notifications usage 1050 to 1100 (+5%: the 44px entry on touch). The skip link's rim and radius took the core 30457 to 30609 bytes, under its cap (the rules that hang it under the bar are the topbar module's: 3200 to 3600, +12.5%); core 30720 to 31050 (+1.1%, DECISIONS 147: also the bar's links left out of the rule: the pseudo-element that makes a short standalone link a 44 by 44 target), skip-link script in the topbar module (3200 to 4150 over this PR, +30%: the rules that hang the link under the bar, 3600, and the script that reads the bar's real edge, 4150), sparkline 3600 to 4050 (+12.5%: React's ticker structure, so the value copies once on its line, and in forced colours the strips go and the number is plain text), forms budget 3250 to 3500 (+7.7%: the necessity word), notifications 9050 to 9250 (+2.2%: the 44px entry). Raised in the audit-design-b PR's E2 port (DECISIONS 138 and 139: the core set draws check, close, the chevrons, copy, plus, minus and search wherever a component draws them): the modules that drew a Phosphor icon for one of those now carry the core glyph's whole SVG, written in at build time (`%glyph-svg:name%`, the markup the glyph module's `_.glyph(name)` returns, so no module needs the glyph module and a page pays for nothing it does not use), and the Phosphor path of the same icon leaves the page. Each module's own bytes rose by that markup, and a page's total moved by what the Phosphor path it no longer carries saves: menu 8600 to 8900 (+303), combobox 10900 to 11200 (+303), copy 1900 to 2400 (+640), terminal 8100 to 8850 (+761), toast 13850 to 14150 (+325), number 2900 to 3400 (+557), filter 16400 to 17050 (+785), palette 9900 to 10450 (+536); the command list shares the palette's search drawing and fell 20 bytes. Set in integration-nov15, where the type-layout, motion-rules and audit-design-b branches meet: the combined tree measured SKILL.md 10959 bytes (each side's cap was 10900: both added index lines), core 31192 bytes (caps 30720 and 31050: the page-row and display rules, the three motion tokens and the skip link and 44px target rules all land in the core CSS) and core usage 2348 bytes (caps 2300 and 2250: type-layout's line and the skip-link bullet), so each is set to the measured bytes rounded up to the next 50: skillMd 10900 to 11000, core 31050 to 31200, core usage 2300 to 2350. Raised in the audit-design PR (decisions 138 and 139, parts A, D and C11): core 30720 to 31600 (+2.9%: the more-contrast block and its three aliases, and the field boundary token, every page carries as React does; the shadow-pill token is gone; the script gained `reserve`, 240 bytes), segment 3700 to 4100 and tabs 2300 to 2700 (the chosen label is 600 against 400, its width reserved by a span that carries its own copy, drawn unseen at 600; the pill's drop shadow is gone), and the segment's usage 300 to 380 (the weight and the glyph-only button). Raised again in the audit-design-a amendment (decision 145): core 31600 to 32300 (reserve() also reserves a label that is not plain text), segment 4100 to 5100 and tabs 2700 to 3500 (the second copy of such a label, and an icon drawn in both its forms), glyph 1100 to 1300 (a glyph in a segment or tab is drawn in both forms). Raised in the second audit-design-a amendment (decision 149): core 32300 to 32800 (reserve() builds the second copy of a label without any id, name, reference or hidden control, and does not copy a frame or media), segment 5100 to 5400 and its usage 380 to 500 (the 600 is on the label, the one-line rule and the usage text); the still-table cap is back at 8200, as the wash is on every cell again. Return 3 of the audit-design-a build (decision 149): tabs 3500 to 3700 (a tab the script has not reserved is 600 itself when selected, and one it declined is marked; the same two lines are in segment, which stays under 5400). Raised in the audit-fix-c2 PR (engineering, no pixel changes): toast 13850 to 14350 (the module was 13789 bytes and is 14288, +499, 3.6%) for F6, which focuses the Notifications region and Shift+Tab or Escape from it (or from the first toast) leaves it for where focus came from (and keeps a dialog's focus trap from wrapping it), as Base UI's viewport does in React, and for placing the region from focus (in the modal that holds it, or in the body), so a toast is never under a backdrop or in an inert modal whatever order the modals opened in (A3-09); the palette module grew 9864 to 9897 of its 9900 so that a palette opened over a modal sits inside it; topbar 3200 to 3250 (3123 to 3233, +110) for the scroll margin on what the bar holds, so a Tab into the bar from a scrolled page does not scroll the page (React's rule from PR #66); stage usage 1650 to 1750 (1580 to 1713, +8%) for the art's new place in the markup, after the content (A1-09), the stage's own CSS rising 1179 to 1208 within its 1250. skillMd rose 10724 to 10876 for the sentence that says a body may carry head tags, within its 10900. compose.mjs, the tool an agent runs, has no cap here (it is never in a page): it grew 21673 to 38153 bytes for the tokenizer that reads a body as HTML does and the head tags. Raised in the site-parts PR (DECISIONS 146, round 39), which folds each new part into the module it belongs with, so SKILL.md gains no index line (it has 41 bytes under its cap and a new module needs about 100): topbar 4150 to 17600 (+13450: the site footer and its disclosures, the lockup by pixel density, and a bar that arrives or leaves and returns, with its observer; a page that has a .topbar and no footer carries them too: the alternative, a module for each, needs its own index line and so SKILL.md bytes) and its usage 950 to 2900 (the footer's markup, the lockup's and the phase's); theme 650 to 4550 (the three-word theme choice: its CSS 2230 bytes and its script, 2277, with arrows, storage and the system listener) and its usage 400 to 1150 (the choice's markup written in full, so the right word is chosen before any script); segment 3700 to 3800 (a radio group's checked state besides a pressed button); stage 1250 to 2150 (its first script, 768 bytes, for fit and anchor) and its usage 1750 to 2000; framed-art 3000 to 3900 (drawn art in the frame: fit, anchor, no scaling strokes) and its usage 1250 to 1400. SKILL.md rose 10959 to 10992 (the topbar and theme index lines name .site-footer and .theme-choice). The head's theme line also writes data-theme-choice. Raised in site-parts return 2 (DECISIONS 146 B1 and B4): theme 4550 to 5350 (+800: the icon form of the theme choice, [data-theme-menu], whose button shows the theme in use, is named for the choice and opens the page's own .menu of three radio rows, in the theme script's 3073 bytes; the menu and popover modules are the page's, brought by its markup, so no module line was added and SKILL.md is 10993 of 11000) and its usage 1150 to 2200 (+91%: the menu's markup is written in full, and the deprecated toggle is said once); app-shell usage 2000 to 2100 and topbar-nav usage 1900 to 1950 (the theme control leaves the bar's text; the tools and the end cluster come in). The two example bodies still carry the deprecated data-theme-toggle. Return 2, F3 (DECISIONS 146 F): stage 2150 to 2250 (script 842 bytes: slice is the stage's default, as a frame's, and a drawing's own preserveAspectRatio stands unless the stage names data-fit or data-anchor) and its usage 2000 to 2150. framed-art 3900 to 4000 (a drawing's own preserveAspectRatio stands unless the figure names data-fit or data-anchor, +101 bytes). Return 3: theme 5350 to 5900 (script +569 bytes: who wrote data-theme, so System follows the system's change live and a theme the page set by hand, or a .dark or .light root, survives it). Raised in the controls port (DECISIONS 154): skillMd 11000 to 11200 for two index lines (link-tabs and option-chips, 214 bytes together), and core 31200 to 31600 for the nine tokens the port adds to every page's token CSS (the control rungs 44 to 64, two container widths, the confirm hold and the amount's opacity, 311 bytes). New modules (DECISIONS 154): link-tabs 2700 (its sizes, the 640 container step, the forced-colours underline, and the select that replaces the row under 720 with its 590-byte script, A15; it requires the select module), option-chips 5700 (the chip's states each written for a native radio inside a label, which needs :has on every one, plus the 1 KB script that keeps an aria-disabled chip reachable and never chosen). Return 3 (DECISIONS 154 conformance): link-tabs 2700 to 3100 and its usage 1650 to 1850 (the select's height for each row size, and a script that reads aria-current when it is needed and watches it move: 3,048 bytes), option-chips 5700 to 6700 (each state written twice, as a state attribute and as :has(), so no browser needs :has(): 4,975 CSS and 1,623 script). Return 4 (DECISIONS 158, Q2): link-tabs 3100 to 4300 and its usage 1850 to 2400 (the \"Go to\" label drawn at the select's start with its measured clearance, the select's accessible name kept as the words and the chosen page's, and the key hold that keeps a letter or an arrow on the closed select from navigating: 4,174 bytes, CSS 2,951 and script 1,223). Raised in the links-and-rows port (DECISIONS 152; the owner's approval is the lead's to confirm): the new link-rows module (5050 bytes of CSS, 50 of them for Castle's big-row arrow stepping colour over duration-fast, return 1, 1500 of usage: the directory's and the big rows' CSS, whose arrow is a core glyph drawn as a mask, and their tokens, size-row taken out of the core like type-layout's), disclosure 1550 to 3500 (Show all: the track, the clip and the settle, 1.5 KB of script and 1.8 KB of CSS), copy 2400 to 3500 (the form with words: the one cell and its script). SKILL.md rose 10959 to 10997 for one line, within its 11000 cap. Raised in the charts port PR (DECISIONS 153, D7a): chart 34400 to 34650 (script 26970 to 27270 bytes, +1.1% on the 34283 it was: `Basalt.trailingMean`, the trend maths React exports as `trailingMean`, 300 bytes), its usage 3150 to 3350 (+6%: one line for it). The tokens the batch adds (chart-lit-top, -mid and -base in both themes, size-chart-plot-sm, size-chart-row, size-meter-marker and radius-2xs) took the art module 2087 to 2546 bytes (budget 2100 to 2600, +24%: the chart tokens are its group) and the core 31192 to 31250 (cap 31200 to 31300, +0.3%: radius-2xs). Only D7a names a skill module in the charts ballot; the lit marks, the headline frame, the phase chart, the share bar, the coverage strip, the marks row and the range meter are React-only in this batch. Added in the overlays-and-search PR (DECISIONS 155, D10b and D13a): the sheet gains React's head, body and foot (the 44px close, the 20/28 title over a 13px count, the divider and the safe areas; its CSS 3.6 to 5.2 KB, budget 4050 to 5250, +30%) and its usage 1050 to 1450 (+38%: the anatomy and the step's focus, two bullets); and one new module a page carries only when it uses it, search (React's SearchDialog: the form, the field's -2 outline, the count line, the fixed-height results area and the rows with their picture slots and full-bleed hover wash; CSS only, 4368 bytes, budget 4400, usage 2050; it requires the dialog). The dialog's title draws no ring when script focuses it. skillMd rose 10959 to 11079 for the search line (the sheet's line is unchanged: its usage carries the anatomy), so its cap rose 11000 to 11100 (+0.9%). The core's CSS grew 31192 to 31421 bytes for the six new size tokens (the wide dialog, the search trigger and the logo and picture slots of a search result): its cap rose 31200 to 31450 (+0.8%). The two 44px values (the sheet's close and the search field) are local to their modules, with a lint exception that says they join the controls batch's size token (DECISIONS 154). Set in integration-nov15b, where audit-design-a, audit-fix-c2, site-parts, port-controls, port-links-rows, port-charts and port-overlays-search meet: the combined tree measured SKILL.md 11560 bytes (the caps were 11000, 11100 and 11200: each side added index lines), core 34086 bytes (caps 31300 to 33550: every side's rules land in the core CSS and script), topbar 17660 (17600 from site-parts, plus audit-fix-c2's skip-link and focus work), number 3453 (3400), palette 11379 (11000, audit-fix-c2's hosted scrim plus the core search glyph), dialog 5120 (5100), toast 15692 (15400) and stage usage 2248 (2150), each over every side's cap, so each is set to the measured bytes rounded up to the next 50: skillMd 11200 to 11600, core 33550 to 34100, topbar 17600 to 17700, number 3400 to 3500, palette 11000 to 11400, dialog 5100 to 5150, toast 15400 to 15700, stage usage 2150 to 2250. The segment cap is the base's 5400 plus port-controls' 100 (5500), unchanged by the merge. Raised in integration-nov15b, join 2 (a link tab takes the selected state, DECISIONS 138 A, 145, 149 and 154's D12 row): link-tabs 4300 to 5750 (+34%: the module was 4174 bytes and is 5736; the 600 against 400, the reserved width and the second copy of a composed label, an icon drawn in both its forms, the same rules a tab carries, 1,530 bytes of CSS and script) and its usage 2400 to 2550 (+6%: one bullet). The cap is the measured bytes rounded up to the next 50; a module that needs the tab's rules carries them as the segment and tabs modules do, so a page without link tabs pays nothing. Raised in the panels, art and parts port (DECISIONS 162): table 3000 to 3150 and its usage 950 to 1450 (the flat form and the two-line cell), stage 2250 to 2600 and its usage 2250 to 3100 (the closing block: its held art, forced colours and print; its section gap is type-layout's --basalt-section-gap, which a page with data-closing brings), the new app-tile 4300 (a 120-point polygon clip and the hairline's mask of the same outline), captioned 2000 and period 1400; skillMd 11600 to 11950 for one index line each for captioned, app-tile and period (358 bytes; the file is 11918). Raised in the logs, status and forms port (DECISIONS 162): core 34100 to 34200 (the new size-field-label-inline token, 80px, is written into every page's tokens: 25 bytes); dlist 1300 to 1900 and its usage 950 to 1060 (the stacked form, R9 and R10: a title over its text, 20px between entries, no divider; one usage line). Raised in audit-fix-c6 (the owner's cap, raised by the builder and for the owner to confirm): glyph 1300 to 1900, for redrawing a glyph when its ancestor's aria-current or data-current moves (the lists that hold glyphs are watched). Raised in the colour-ink-ladder build (DECISIONS 166): core 34200 to 34350 (the four lifted dark inks are four new primitives, each written into every page's tokens: the core measured 34307). Raised in the audit-2-design build (DECISIONS 167, Q7a): disclosure 3500 to 3800 (the core chevron drawn as a mask in place of two borders: the module measured 3755). Joined in the integration of c7 (#86) and c10 (#91): option-chips 6750 to 6850 (c7's reset resync and c10's data-ready together measure 6839). Raised in table-sort-3 (DECISIONS 257 and 261, the owner's pick: three sort states, the arrow after the label, explainers on column titles): still-table 13400 to 14650 (+9.3%: the module was 13343 bytes and is 14602; the end-aligned label's move by a transform, its right-to-left sign and the indicator that waits for it on a fine pointer, 912 bytes of CSS; the third state, the sort from the table's own order and a .explainer kept out of the button, 347 bytes of script) and its usage 2150 to 2250 (2197: the third state and the own order); the new explainer module 5850 (5842: a manual native popover opened from the sort button on hover, keyboard focus and a long press, placed above the header or beside it, 1752 bytes of CSS and 4090 of script; a page without explainers pays nothing) and its usage 900; skillMd 12250 to 12400 for the explainer's index line (113 bytes; the file is 12352). Each cap is the measured bytes rounded up to the next 50. Raised in table-sort-3's fix pass (Astra's review): explainer 5850 to 6900 (+18%: 5842 to 6864 bytes; the gap between the header and the card kept while a pointer crosses it, the close when its header leaves the view whatever has focus, the dismissal held until pointer and focus have both left, and its page-wide listeners and timers scoped to an open card and stopped when the table leaves the page, 1,022 bytes of script). Raised in cimip-gaps-2 batch B5 (the touch sizes under 720 whatever the pointer: each coarse-pointer target rule also answers a window under 720, about 20 bytes a rule; forms merged its three into one and stays under 3500): select 9000 to 9100 (measured 9064), selection 1480 to 1500 (1486), filter 17450 to 17500 (17473), option-chips 6850 to 6900 (6853), menu 8900 to 8950 (8902). B5 fix pass 1 (Astra): core 34550 to 34950 (measured 34911: 30762 CSS and 4149 JS) for stacked links in a column, each giving up the side of its 44px box that meets a neighbour, so a tap on a link's words is always that link's; core had 12 bytes free. DECISIONS 274 (the owner's pick: under 720 the toast stack hangs from the bar): toast 15700 to 16050 (measured 16035; 8 bytes were free; the stack's direction became one sign variable, trimming 585 of the 920 bytes the phone form first took). B5 merged with main (5ad5345a): main's own core measured 34930 against its 34550 cap before B5; with B5 (the touch sizes under 720 and stacked links in a column) it is 35331, so core is 35350; nav 5350 to 5400 (measured 5364: B4's nav plus the touch size under 720). The full run after the stream (DECISIONS 246): the site footer's links keep their own flex column under 720, as React's, out of the bare-link touch rule (26 bytes), so core is 35400 (measured 35357); sheet 5250 to 5400 (measured 5368: React's B5 ring room, ported: the held actions reach space-1-5 above their band, clipped, and the body keeps space-1-5 at each end). Raised for diagram motion and service marks (DECISIONS 292): skillMd 12550 to 12650 for the diagram-motion module's one line; diagram 87200 to 91000 for what a still diagram now carries (a card's mark and its seat, the pending frame, the comparison that writes a drawing only when it changed, and the print rule), and its usage 2600 to 4300 for the decision's four lines and the list of mark ids; the new diagram-motion module (the motion engine, its stylesheet and the motion tokens, in a page only when a diagram is animated) at 26200. Raised when the diagram tests were first run (DECISIONS 298): diagram 91000 to 91250 and diagram-motion 26200 to 26850. Raised in batch A of the diagrams backlog (DECISIONS 301): diagram 91250 to 92400, for the engine fixes it bundles (a decision kept no taller than it is wide, labels on whole pixels, slots beside a straight line, a one-column schema's turn-back); the skill keeps the development checks a production React build now drops. Raised again in that batch's review fixes: diagram 92400 to 92650, for the drawn layout refusing two lines laid on one another (Neon's blocking finding 1 on #126). Fix round 1 of #124 had already taken them to 91205 and 26621 with the tests unrun; this round added 1 byte (every focal node prints its fill; a one-form mark's dark form falls back to its light one) and 180 (the entrance keeps its own clock when it is drawn again while paused).",
"budgets": {
"skillMd": 12650,
"core": 35400
@@ -778,7 +778,7 @@
"art",
"kbd"
],
- "budget": 91250,
+ "budget": 92650,
"usage": 4300,
"builds": [
"kbd"
diff --git a/packages/react/src/diagram-core.ts b/packages/react/src/diagram-core.ts
index d017b1af..0ad864ff 100644
--- a/packages/react/src/diagram-core.ts
+++ b/packages/react/src/diagram-core.ts
@@ -6,6 +6,12 @@
//
// What the author writes is placement on a grid and one record per part; everything else is derived: the sides and slots a line uses, its
// route and jogs, the lanes it shares, a group's box, a foreign key's line, the stacked drawing's routes and gaps, and every label's seat.
+//
+// The development checks and warnings are written behind `process.env.NODE_ENV !== "production"` where they are made, so an app's production build,
+// whose bundler sets NODE_ENV, drops them and their words (DECISIONS 281, 4.1: they cost production nothing). The HTML skill bundles this file as a
+// development build: compose.mjs reports the warnings when it writes a page.
+
+declare const process: { env: { NODE_ENV?: string } };
// ============================================================================================================================================
// Public shapes (the components re-export these types; no third-party type appears in them)
@@ -191,7 +197,9 @@ export interface BuildOptions {
* few values (or the default, with a warning), and a track is a whole number from 1.
*/
export function buildModel(spec: DiagramSpec, options: BuildOptions = {}): Model {
- const checks = options.checks !== false;
+ // Development only: a bundler that sets NODE_ENV to production folds `dev` to false and drops every check below, its words included.
+ const dev = process.env.NODE_ENV !== "production";
+ const checks = dev && options.checks !== false;
const warnings: string[] = [];
const warn = (message: string) => { warnings.push(message); };
const legendIn = (spec.legend ?? {}) as Record;
@@ -201,22 +209,22 @@ export function buildModel(spec: DiagramSpec, options: BuildOptions = {}): Model
const stepWord = typeof stepLabel === "function" ? (n: number) => String(stepLabel(n)) : typeof stepLabel === "string" ? ((n: number) => stepLabel.replace("{n}", String(n))) : (n: number) => `Step ${n}`;
const shapeIn = (spec.shapeLabels ?? {}) as Record;
const shapeLabels = { terminal: txt(shapeIn.terminal) ?? "Start or end", step: txt(shapeIn.step) ?? "Step", decision: txt(shapeIn.decision) ?? "Decision" };
- const heading = spec.heading === undefined ? 3 : HEADINGS.includes(spec.heading as number) ? spec.heading : (warn(`heading ${String(spec.heading)} is not a level from 2 to 6: the title is an h3`), 3);
+ const heading = spec.heading === undefined ? 3 : HEADINGS.includes(spec.heading as number) ? spec.heading : (dev && warn(`heading ${String(spec.heading)} is not a level from 2 to 6: the title is an h3`), 3);
const kindOf = (k: unknown, where: string): DiagramLineKind => {
if (k === undefined || k === null) return "plain";
if (LINE_KINDS.includes(k as DiagramLineKind)) return k as DiagramLineKind;
- warn(`"${String(k)}" is not a kind of line (main, plain or dashed): ${where} is drawn plain`);
+ dev && warn(`"${String(k)}" is not a kind of line (main, plain or dashed): ${where} is drawn plain`);
return "plain";
};
const sideOf = (v: unknown): DiagramSide | undefined => {
if (v === undefined || v === null) return undefined;
if (SIDES.includes(v as DiagramSide)) return v as DiagramSide;
- warn(`"${String(v)}" is not a side (top, right, bottom or left): the derived side is used`);
+ dev && warn(`"${String(v)}" is not a side (top, right, bottom or left): the derived side is used`);
return undefined;
};
const trackOf = (v: unknown, what: string): number => {
if (typeof v === "number" && Number.isInteger(v) && v >= 1) return v;
- warn(`${what} is ${JSON.stringify(v)}, not a whole number from 1: it is placed at 1`);
+ dev && warn(`${what} is ${JSON.stringify(v)}, not a whole number from 1: it is placed at 1`);
return 1;
};
const nodes: MNode[] = [];
@@ -225,7 +233,7 @@ export function buildModel(spec: DiagramSpec, options: BuildOptions = {}): Model
const groups: Model["groups"] = [];
const steps: MStep[] = [];
const type = spec.type;
- if (!(["architecture", "flowchart", "data-flow", "sequence", "schema"] as unknown[]).includes(type)) warn(`"${String(type)}" is not a type of diagram (architecture, flowchart, data-flow, sequence or schema)`);
+ if (dev && !(["architecture", "flowchart", "data-flow", "sequence", "schema"] as unknown[]).includes(type)) warn(`"${String(type)}" is not a type of diagram (architecture, flowchart, data-flow, sequence or schema)`);
if (type === "architecture" || type === "flowchart") {
for (const raw of (spec.nodes ?? []) as Array) {
@@ -246,7 +254,7 @@ export function buildModel(spec: DiagramSpec, options: BuildOptions = {}): Model
const id = String(raw.id ?? "");
const laneId = String(raw.lane ?? "");
const lane = laneIndex.get(laneId);
- if (lane === undefined) warn(`a node (${id}) names the lane "${laneId}", which is not in lanes`);
+ if (lane === undefined) dev && warn(`a node (${id}) names the lane "${laneId}", which is not in lanes`);
const n = nodes.length + 1;
nodes.push({
id, i: nodes.length, name: String(raw.name ?? ""), kind: stepWord(n), detail: txt(raw.detail), mono: Boolean(raw.detailMono), focal: Boolean(raw.focal),
@@ -266,18 +274,18 @@ export function buildModel(spec: DiagramSpec, options: BuildOptions = {}): Model
const [r1, r2] = Array.isArray(t.row) ? t.row : [t.row, t.row];
const row = trackOf(r1, `the row of ${name}`);
const row2 = Math.max(row, trackOf(r2, `the last row of ${name}`));
- const more = t.more === undefined || t.more === null ? undefined : Number.isInteger(t.more) && t.more > 0 ? t.more : (warn(`${name}'s "more" is ${JSON.stringify(t.more)}, not a whole number from 1: it is left out`), undefined);
+ const more = t.more === undefined || t.more === null ? undefined : Number.isInteger(t.more) && t.more > 0 ? t.more : (dev && warn(`${name}'s "more" is ${JSON.stringify(t.more)}, not a whole number from 1: it is left out`), undefined);
nodes.push({
id: name, i: nodes.length, name, mono: true, focal: Boolean(t.focal), col: trackOf(t.col, `the column of ${name}`), row, row2, branch: false, shape: "table", more,
- columns: (t.columns ?? []).map((c) => ({ name: String(c.name ?? ""), type: txt(c.type), key: c.key === "PK" || c.key === "FK" ? c.key : (c.key !== undefined && c.key !== null && warn(`${name}.${String(c.name)}'s key is "${String(c.key)}", not PK or FK: it is left out`), undefined) })),
+ columns: (t.columns ?? []).map((c) => ({ name: String(c.name ?? ""), type: txt(c.type), key: c.key === "PK" || c.key === "FK" ? c.key : (c.key !== undefined && c.key !== null && dev && warn(`${name}.${String(c.name)}'s key is "${String(c.key)}", not PK or FK: it is left out`), undefined) })),
});
}
}
const byId = new Map();
for (const n of nodes) {
- if (!n.id) warn("a node has no id");
- else if (byId.has(n.id)) warn(`the id "${n.id}" is used twice`);
+ if (dev && !n.id) warn("a node has no id");
+ else if (dev && byId.has(n.id)) warn(`the id "${n.id}" is used twice`);
byId.set(n.id, n);
}
@@ -289,7 +297,7 @@ export function buildModel(spec: DiagramSpec, options: BuildOptions = {}): Model
const [table, column] = ref.split(".");
const target = byId.get(table ?? "");
const row = target?.columns?.findIndex((x) => x.name === column) ?? -1;
- if (!target || row < 0) { warn(`${String(t.name)}.${String(c.name)} references ${ref}, which is not a shown column`); return; }
+ if (!target || row < 0) { dev && warn(`${String(t.name)}.${String(c.name)} references ${ref}, which is not a shown column`); return; }
const source = byId.get(String(t.name ?? ""))!;
source.columns![k]!.ref = { table: table!, column: column!, row };
edges.push({ i: edges.length, from: source.id, to: table!, kind: "plain", fromRow: k, toRow: row, fk: true });
@@ -297,12 +305,12 @@ export function buildModel(spec: DiagramSpec, options: BuildOptions = {}): Model
} else if (type !== "sequence") {
for (const e of spec.edges ?? []) {
const from = String(e.from ?? ""), to = String(e.to ?? "");
- if (!byId.has(from) || !byId.has(to)) { warn(`a line names ${!byId.has(from) ? from : to}, which is not a node`); continue; }
+ if (!byId.has(from) || !byId.has(to)) { dev && warn(`a line names ${!byId.has(from) ? from : to}, which is not a node`); continue; }
const label = txt(e.label);
- if (label && label.length > MAX_LABEL) warn(`the label "${label}" is over ${MAX_LABEL} characters: longer words belong in the node or the summary`);
+ if (label && label.length > MAX_LABEL) dev && warn(`the label "${label}" is over ${MAX_LABEL} characters: longer words belong in the node or the summary`);
edges.push({ i: edges.length, from, to, kind: kindOf(e.kind, `the line from ${from} to ${to}`), label, fromSide: sideOf(e.fromSide), toSide: sideOf(e.toSide), flow: type !== "flowchart" && (e as DiagramFlowEdge).flow === true ? true : undefined });
}
- } else {
+ } else if (dev) {
for (const s of steps) if ("n" in s) {
if (!byId.has(s.from) || !byId.has(s.to)) warn(`message ${s.n} names ${!byId.has(s.from) ? s.from : s.to}, which is not a participant`);
}
@@ -477,6 +485,8 @@ export interface Dyn {
keep?: string;
/** A decision's measured height, by node id, in px. */
heights?: Record;
+ /** A decision's words' box, widened from 62% of its track so the diamond is no taller than it is wide, by node id, in px (unset where 62% is). */
+ words?: Record;
/** Extra lines of 16 added to the gap above a stacked card, when a label did not fit its seat. */
grow?: Record;
/** The schema's stacked track: its widest row, measured. */
@@ -719,6 +729,8 @@ function nodeTree(ctx: TreeContext, m: Model, n: MNode, dyn: Dyn): VElement {
}
const height = own(dyn.heights, n.id);
if (height) style.push(`--_h:${height}px`);
+ const wordsWidth = own(dyn.words, n.id);
+ if (wordsWidth) style.push(`--_ww:${wordsWidth}px`);
const tabbable = stops ? (dyn.stop === n.id ? 0 : -1) : dyn.keep === n.id ? -1 : undefined;
return h("div", {
class: `${P}-node`,
@@ -887,6 +899,9 @@ export interface FigureOptions {
}
/** The whole figure. Before script runs `dyn` is empty; the same tree, with the measured `dyn`, is what script settles on. */
+/** A schema of one column whose foreign keys are drawn as turn-backs on its end side, where it has no gutter. */
+const oneColumnTurnBacks = (m: Model) => m.type === "schema" && m.cols === 1 && m.edges.length > 0;
+
export function figureTree(m: Model, dyn: Dyn, o: FigureOptions): VElement {
const P = o.prefix;
const ids = idsOf(o.base);
@@ -905,6 +920,9 @@ export function figureTree(m: Model, dyn: Dyn, o: FigureOptions): VElement {
const block = drawn && dyn.pad ? "3" : undefined;
style.push(`--_gpad:${pad(members.some((n) => n.row === 1), "8", block)} ${pad(members.some((n) => n.col === m.cols), "4")} ${pad(members.some((n) => n.row2 === m.rows), "4", block)} ${pad(members.some((n) => n.col === 1), "4")}`);
}
+ // A schema of one column with a foreign key: its turn-backs run space-4 out on the end side, past the cards, so the drawn layout keeps space-5 there
+ // (the turn-back and its stroke on the pixel grid); the fit rule counts it (minimums).
+ if (oneColumnTurnBacks(m)) style.push("--_gpad:0px var(--basalt-space-5) 0px 0px");
if (m.type === "schema" && dyn.track) style.push(`--_track:${dyn.track}px`);
return h("figure", {
class: o.className ? `${P} ${o.className}` : P,
@@ -981,6 +999,8 @@ export interface Geo {
unseated: number[];
/** Lines (by edge index) that leave the drawing: a route the fit must refuse. */
outside: number[];
+ /** Lines (by edge index) laid on another line that does not end where it ends (not a bus): two lines read as one, so the fit refuses them. */
+ overlaps?: number[];
/** The offset of the drawing's origin from the device pixel grid, so lines can be snapped to it. */
ox: number;
oy: number;
@@ -1121,7 +1141,7 @@ function minimums(m: Model, tk: Tokens, measure: ReturnType) {
const n = columnCount(m);
let least: number;
if (m.type === "data-flow") least = tk.lane + n * (track + s("12"));
- else if (m.type === "schema") least = n * table + (n - 1) * s("12");
+ else if (m.type === "schema") least = n * table + (n - 1) * s("12") + (oneColumnTurnBacks(m) ? s("5") : 0);
// A sequence's columns hold its participants: measured once script runs (the stylesheet before script has only the token floor).
else if (m.type === "sequence") least = n * track + (n - 1) * s("5");
else least = n * track + (n - 1) * s("16") + groupReach(m) * s("4");
@@ -1233,16 +1253,24 @@ function assignSlots(m: Model, sides: Array<[DiagramSide, DiagramSide]>, warn: (
const straight = list.filter((p) => p.straight), rest = list.filter((p) => !p.straight);
// Nested: the line whose far end is farther along takes the slot nearer that way.
rest.sort((x, y) => along(x) - along(y) || (isH(x.side) ? x.far.col - y.far.col : x.far.row - y.far.row) * (along(x) < 0 ? 1 : -1));
- if (list.length > 3) warn(`${key.replace(".", "'s ")} side has ${list.length} lines; more than three is an error: use another side`);
- if (straight.length) rest.forEach((p) => { p.f = along(p) < 0 ? 0.25 : 0.75; });
- else if (rest.length === 2) { rest[0]!.f = 0.25; rest[1]!.f = 0.75; }
- else if (rest.length === 3) { rest[0]!.f = 0.25; rest[1]!.f = 0.5; rest[2]!.f = 0.75; }
- else if (rest.length > 3) rest.forEach((p, j) => { p.f = (j + 1) / (rest.length + 1); });
+ if (process.env.NODE_ENV !== "production" && list.length > 3) warn(`${key.replace(".", "'s ")} side has ${list.length} lines; more than three is an error: use another side`);
+ if (!straight.length) {
+ if (rest.length === 2) { rest[0]!.f = 0.25; rest[1]!.f = 0.75; }
+ else if (rest.length === 3) { rest[0]!.f = 0.25; rest[1]!.f = 0.5; rest[2]!.f = 0.75; }
+ else if (rest.length > 3) rest.forEach((p, j) => { p.f = (j + 1) / (rest.length + 1); });
+ continue;
+ }
// Two or more straight lines to one node (one each way) cannot all keep the middle: they would lie on one another. They take the side's slots by
// their count, in the author's order; the far end does the same, so each stays straight.
const byFar = new Map();
for (const p of straight) { if (!byFar.has(p.far.id)) byFar.set(p.far.id, []); byFar.get(p.far.id)!.push(p); }
for (const same of byFar.values()) if (same.length > 1) same.sort((x, y) => x.edge - y.edge).forEach((p, j) => { p.f = same.length === 2 ? (j === 0 ? 0.25 : 0.75) : (j + 1) / (same.length + 1); });
+ // Beside a straight line the others take the part of the side nearer their far end: one alone there takes the quarter point, as decided; two or more
+ // share that part evenly, nested (the one whose far end is farther along nearer that end), so no two lines leave one point.
+ const lo = Math.min(...straight.map((p) => p.f)), hi = Math.max(...straight.map((p) => p.f));
+ const before = rest.filter((p) => along(p) < 0), after = rest.filter((p) => along(p) >= 0);
+ before.forEach((p, j) => { p.f = (lo * (j + 1)) / (before.length + 1); });
+ after.forEach((p, j) => { p.f = hi + ((1 - hi) * (j + 1)) / (after.length + 1); });
}
return ports;
}
@@ -1283,7 +1311,22 @@ function headBox(line: GLine, tk: Tokens): Rect {
const segRect = (a: Pt, b: Pt, w: number): Rect => ({ l: Math.min(a.x, b.x) - w / 2, r: Math.max(a.x, b.x) + w / 2, t: Math.min(a.y, b.y) - w / 2, b: Math.max(a.y, b.y) + w / 2 });
/** Seats labels by 1.8: runs longest first, their clear shaft's middle then thirds; on the line, above, below (or beside). */
-function seatLabels(m: Model, lines: GLine[], nodes: GNode[], obstacles: Obstacles, groups: Rect[], bounds: Rect, tk: Tokens, measure: ReturnType): { labels: GLabel[]; unseated: number[]; bounded: number[] } {
+/**
+ * A seated label's box moved onto the page's whole pixels, so its words are never drawn on a half pixel at 1x (a label on a 1px line sat on them): to the
+ * nearest such place that `clear` accepts, which is the test the seat itself passed. Where none is, the seat stays as it was found. The seat is chosen
+ * before this, against the line's own centre, so whether a label seats never turns on where the pixel grid falls.
+ */
+function wholePixels(box: Rect, ox: number, oy: number, clear: (b: Rect) => boolean): Rect {
+ const moves = (v: number, o: number) => { const f = v + o - Math.floor(v + o); return f < 0.005 || f > 0.995 ? [0] : f <= 0.5 ? [-f, 1 - f] : [1 - f, -f]; };
+ for (const dy of moves(box.t, oy)) for (const dx of moves(box.l, ox)) {
+ if (!dx && !dy) return box;
+ const moved = { l: box.l + dx, r: box.r + dx, t: box.t + dy, b: box.b + dy };
+ if (clear(moved)) return moved;
+ }
+ return box;
+}
+
+function seatLabels(m: Model, lines: GLine[], nodes: GNode[], obstacles: Obstacles, groups: Rect[], bounds: Rect, tk: Tokens, measure: ReturnType, grid: { ox: number; oy: number }): { labels: GLabel[]; unseated: number[]; bounded: number[] } {
const s = tk.space;
const placed: Rect[] = [];
const labels: GLabel[] = [];
@@ -1346,8 +1389,9 @@ function seatLabels(m: Model, lines: GLine[], nodes: GNode[], obstacles: Obstacl
if (chosen) break;
}
if (!chosen) { unseated.push(line.i); if (inBounds) bounded.push(line.i); continue; }
- placed.push(chosen.box);
- labels.push({ i: line.i, text, box: chosen.box, on: chosen.on });
+ const box = wholePixels(chosen.box, grid.ox, grid.oy, (b) => clear(b));
+ placed.push(box);
+ labels.push({ i: line.i, text, box, on: chosen.on });
}
return { labels, unseated, bounded };
}
@@ -1374,6 +1418,7 @@ function obstaclesOf(drawing: HTMLElement, origin: DOMRect, P: string, rowGap: n
}
function drawnGeometry(input: DrawnInput, measure: ReturnType): Geo {
+ const dev = process.env.NODE_ENV !== "production";
const { m, tk, P, drawing, origin, warn } = input;
const s = tk.space;
const map = gNodes(m, drawing, origin, P);
@@ -1394,12 +1439,14 @@ function drawnGeometry(input: DrawnInput, measure: ReturnType): Ge
if (m.type === "schema") {
sides = m.edges.map((e) => {
const a = m.byId.get(e.from)!, b = m.byId.get(e.to)!;
- if (a.col === b.col) { const side: DiagramSide = a.col === m.cols ? "left" : "right"; return [side, side]; }
+ // One column: a turn-back on the end side (the start side in the last column, where the end is the drawing's edge). A schema of one column has no
+ // gutter on either side, so its turn-backs take the end side and the drawing keeps room for them there (figureTree).
+ if (a.col === b.col) { const side: DiagramSide = a.col === m.cols && m.cols > 1 ? "left" : "right"; return [side, side]; }
return b.col > a.col ? ["right", "left"] : ["left", "right"];
});
} else {
sides = m.edges.map((e) => { const a = m.byId.get(e.from)!, b = m.byId.get(e.to)!; const [d1, d2] = defaultSides(a, b); return [e.fromSide ?? d1, e.toSide ?? d2]; });
- ports = assignSlots(m, sides, warn ?? (() => {}));
+ ports = assignSlots(m, sides, (dev && warn) || (() => {}));
}
// End points.
@@ -1536,12 +1583,12 @@ function drawnGeometry(input: DrawnInput, measure: ReturnType): Ge
if (last && last.some((q) => q.run[0] < p.run[1] + s("8") && p.run[0] < q.run[1] + s("8"))) last.push(p); else clusters.push([p]);
}
for (const cluster of clusters) {
- // A turn-back alone keeps its own place, space-4 out from the side; beside a jog, the two share the gutter's lanes.
- if (cluster.every((c) => c.members.every((k) => turnBacks.has(k)))) continue;
+ // A turn-back alone keeps its own place, space-4 out from the side; beside a jog or another turn-back, they share the gutter's lanes.
+ if (cluster.length === 1 && cluster[0]!.members.every((k) => turnBacks.has(k))) continue;
const groupsOf = cluster.map((c) => c.members);
const count = groupsOf.length;
const step = (g.span[1] - g.span[0]) / (count + 1);
- if (step < s("3")) warn?.(`a gutter holds ${count} lanes side by side, closer than space-3`);
+ if (dev && step < s("3")) warn?.(`a gutter holds ${count} lanes side by side, closer than space-3`);
const inGutter = new Set(groupsOf.flat());
let best: number[][] = groupsOf, bestScore = Infinity, bestLines: GLine[] | null = null;
for (const perm of permutations(groupsOf)) {
@@ -1554,26 +1601,33 @@ function drawnGeometry(input: DrawnInput, measure: ReturnType): Ge
}
}
geo.lines = build();
- for (const k of dropped) warn?.(`${m.edges[k]!.from} to ${m.edges[k]!.to} is two columns apart, so its line is not drawn; its row still writes the target`);
+ if (dev) for (const k of dropped) warn?.(`${m.edges[k]!.from} to ${m.edges[k]!.to} is two columns apart, so its line is not drawn; its row still writes the target`);
geo.crossings = findCrossings(geo.lines);
geo.through = throughOf(geo.lines, nodes, m);
geo.outside = outsideOf(geo.lines, W, H, tk);
const { obstacles, groups } = obstaclesOf(drawing, origin, P, rowGap);
obstacles.heads = geo.lines.map((l) => headBox(l, tk));
- const seats = seatLabels(m, geo.lines, nodes, obstacles, groups, { l: 0, t: 0, r: W, b: H }, tk, measure);
+ const seats = seatLabels(m, geo.lines, nodes, obstacles, groups, { l: 0, t: 0, r: W, b: H }, tk, measure, { ox, oy });
geo.labels = seats.labels;
geo.unseated = seats.unseated;
geo.bounded = seats.bounded;
+ // Two lines on one another that are not a bus (a one-column schema's turn-backs to different keys, with no gutter to give each a lane) read as
+ // one line: the drawn layout is refused, as a line through a node is.
+ geo.overlaps = [...new Set(overlapPairs(geo.lines, null).flat())];
return geo;
}
/** Runs of two lines laid on one another (collinear and overlapping by more than a pixel), for lines in `only`. Lines that end on one point
* share a lane by design (a bus, 1.7), so they are not counted. */
function overlapsOf(lines: GLine[], only: Set): number {
- let count = 0;
+ return overlapPairs(lines, only).length;
+}
+/** Each such run as the pair of lines (by edge index) that lie on one another, once a run; `only` null takes every line. */
+function overlapPairs(lines: GLine[], only: Set | null): Array<[number, number]> {
+ const pairs: Array<[number, number]> = [];
for (let a = 0; a < lines.length; a++) for (let b = a + 1; b < lines.length; b++) {
const A = lines[a]!, B = lines[b]!;
- if (!only.has(A.i) && !only.has(B.i)) continue;
+ if (only && !only.has(A.i) && !only.has(B.i)) continue;
if (A.to === B.to && Math.abs(A.tip.x - B.tip.x) < 1 && Math.abs(A.tip.y - B.tip.y) < 1) continue;
const near = (A.width + B.width) / 2 + 0.5;
for (const [p1, p2] of segmentsOf(A.pts)) for (const [q1, q2] of segmentsOf(B.pts)) {
@@ -1582,10 +1636,10 @@ function overlapsOf(lines: GLine[], only: Set): number {
const [ac, bc] = aH ? [p1.y, q1.y] : [p1.x, q1.x];
if (Math.abs(ac - bc) >= near) continue;
const [a1, a2] = aH ? [p1.x, p2.x] : [p1.y, p2.y], [b1, b2] = aH ? [q1.x, q2.x] : [q1.y, q2.y];
- if (Math.min(Math.max(a1, a2), Math.max(b1, b2)) - Math.max(Math.min(a1, a2), Math.min(b1, b2)) > 1) count++;
+ if (Math.min(Math.max(a1, a2), Math.max(b1, b2)) - Math.max(Math.min(a1, a2), Math.min(b1, b2)) > 1) pairs.push([A.i, B.i]);
}
}
- return count;
+ return pairs;
}
function* permutations(items: T[]): Generator {
@@ -1775,7 +1829,7 @@ function stackedGeometry(input: DrawnInput, measure: ReturnType, p
};
const box = seat.cands.find((c) => !bad(c));
if (!box) { growBy[seat.card] = (growBy[seat.card] ?? 0) + 1; geo.unseated.push(seat.k); }
- const use = box ?? seat.cands[0]!;
+ const use = box ? wholePixels(box, ox, oy, (b) => !bad(b)) : seat.cands[0]!;
placed.push(use);
geo.labels.push({ i: seat.k, text: m.edges[seat.k]!.label!, box: use, on: seat.on });
}
@@ -1864,6 +1918,8 @@ export interface Measured { dyn: Dyn; geo: Geo | null; ink: string; tokens: Toke
* tree gives for it), so each try is measured as it would be drawn.
*/
export function measureFigure(fig: HTMLElement, m: Model, P: string, base: string, current: Dyn, apply: (dyn: Dyn) => void, warn?: (s: string) => void): Measured {
+ // Development only (the warnings): first, so a minifier sees it is a constant and drops what it guards.
+ const dev = process.env.NODE_ENV !== "production";
const drawing = fig.querySelector(`.${P}-drawing`);
// A figure with no width (inside a closed disclosure or an unselected tab) is not laid out: its resize observer lays it out once it is shown.
if (!drawing || fig.clientWidth === 0) return { dyn: current, geo: null, ink: "", tokens: null };
@@ -1878,19 +1934,44 @@ export function measureFigure(fig: HTMLElement, m: Model, P: string, base: strin
};
const heightsFor = (d: Dyn): Dyn => {
if (m.type !== "flowchart") return d;
- apply({ ...d, heights: undefined });
+ apply({ ...d, heights: undefined, words: undefined });
const heights = record();
+ const widened = record();
drawing.querySelectorAll(`.${P}-node[data-shape="decision"]`).forEach((el) => {
const words = el.querySelector(`.${P}-words`);
if (!words) return;
- const nr = el.getBoundingClientRect(), wr = words.getBoundingClientRect();
- const box = { w: wr.width + 2 * tk.space("2-5"), h: wr.height + 2 * tk.space("2") };
- const a = nr.width / 2;
- const denom = 1 - box.w / 2 / a;
- const half = denom > 0.05 ? box.h / 2 / denom : box.h * 10;
- heights[el.dataset.node!] = Math.max(tk.space("16"), Math.ceil(nr.width / 5), Math.ceil(2 * half));
+ const nr = el.getBoundingClientRect();
+ // The diamond is the track's width, and as tall as it must be for the words' box (grown space-2-5 each side and space-2 above and below) to lie
+ // inside it; never under space-16, nor under a fifth of its width (1.12).
+ const heightFor = (wr: DOMRect) => {
+ const box = { w: wr.width + 2 * tk.space("2-5"), h: wr.height + 2 * tk.space("2") };
+ const denom = 1 - box.w / nr.width;
+ const half = denom > 0.05 ? box.h / 2 / denom : box.h * 10;
+ return Math.max(tk.space("16"), Math.ceil(nr.width / 5), Math.ceil(2 * half));
+ };
+ const first = words.getBoundingClientRect();
+ let height = heightFor(first);
+ // The ceiling (DECISIONS 301): a diamond is no taller than it is wide. Its words wrap at 62% of the track; where that makes it taller than wide, the
+ // words' box widens, to the narrowest width that puts them on fewer lines, and again, until the diamond fits under the ceiling. Where no width does,
+ // the 62% box stays and the diamond is as tall as it must be.
+ if (height > nr.width) {
+ const at = (x: number) => { el.style.setProperty("--_ww", `${x}px`); return words.getBoundingClientRect(); };
+ const widest = Math.floor(el.clientWidth - 2 * tk.space("2-5"));
+ let from = Math.ceil(first.width), tall = first.height;
+ while (from < widest && at(widest).height < tall - 0.5) {
+ // The narrowest whole width with fewer lines than `tall`: a wider box never wraps onto more lines.
+ let lo = from, hi = widest;
+ while (hi - lo > 1) { const mid = (lo + hi) >> 1; if (at(mid).height < tall - 0.5) hi = mid; else lo = mid; }
+ const wr = at(hi), next = heightFor(wr);
+ if (next <= nr.width) { height = next; widened[el.dataset.node!] = hi; break; }
+ from = hi;
+ tall = wr.height;
+ }
+ el.style.removeProperty("--_ww");
+ }
+ heights[el.dataset.node!] = height;
});
- return { ...d, heights };
+ return { ...d, heights, words: Object.keys(widened).length ? widened : undefined };
};
const input = (): DrawnInput => ({ m, tk, P, drawing, origin: drawing.getBoundingClientRect(), warn });
// A list a bare stack opened closes when the figure is laid out again (it opens again if the stack is still bare).
@@ -1905,18 +1986,21 @@ export function measureFigure(fig: HTMLElement, m: Model, P: string, base: strin
};
let { dd: d, g: geo } = drawnTry(false);
// A label refused only because its seats leave the drawing (beside a line in a 40px first or last row) is given space-3 above and below.
- if (!geo.through.length && !geo.outside.length && geo.unseated.length && geo.unseated.every((k) => geo.bounded?.includes(k))) {
+ // A route the drawn layout refuses: through a node, off the drawing, or laid on another line.
+ const refused = (g: Geo) => g.through.length > 0 || g.outside.length > 0 || (g.overlaps?.length ?? 0) > 0;
+ if (!refused(geo) && geo.unseated.length && geo.unseated.every((k) => geo.bounded?.includes(k))) {
const padded = drawnTry(true);
- if (!padded.g.through.length && !padded.g.unseated.length && !padded.g.outside.length) ({ dd: d, g: geo } = padded);
+ if (!refused(padded.g) && !padded.g.unseated.length) ({ dd: d, g: geo } = padded);
}
- if (!geo.through.length && !geo.unseated.length && !geo.outside.length) {
- if (geo.crossings.length) warn?.(`${geo.crossings.length} crossing${geo.crossings.length === 1 ? "" : "s"} in the drawn layout: ${geo.crossings.map((c) => `${lineName(m, geo.lines[c.top]!)} over ${lineName(m, geo.lines[c.under]!)}`).join("; ")}`);
+ if (!refused(geo) && !geo.unseated.length) {
+ if (geo.crossings.length) dev && warn?.(`${geo.crossings.length} crossing${geo.crossings.length === 1 ? "" : "s"} in the drawn layout: ${geo.crossings.map((c) => `${lineName(m, geo.lines[c.top]!)} over ${lineName(m, geo.lines[c.under]!)}`).join("; ")}`);
return { dyn: d, geo, ink: inkHtml(P, geo, tk, base), tokens: tk };
}
// At a width the figure should fit by its tokens and words, a failure is the author's to fix.
- if (geo.through.length) warn?.(`the drawn layout does not fit at ${Math.round(W)}px: ${names(geo, geo.through)} would pass through a node`);
- if (geo.outside.length) warn?.(`the drawn layout does not fit at ${Math.round(W)}px: ${names(geo, geo.outside)} would leave the drawing`);
- if (geo.unseated.length) warn?.(`the drawn layout does not fit at ${Math.round(W)}px: no clean seat for ${geo.unseated.map((k) => (m.type === "sequence" ? `message ${k}` : `"${m.edges[k]?.label}"`)).join(", ")}`);
+ if (geo.through.length) dev && warn?.(`the drawn layout does not fit at ${Math.round(W)}px: ${names(geo, geo.through)} would pass through a node`);
+ if (geo.overlaps?.length) dev && warn?.(`the drawn layout does not fit at ${Math.round(W)}px: ${names(geo, geo.overlaps)} would lie on one another`);
+ if (geo.outside.length) dev && warn?.(`the drawn layout does not fit at ${Math.round(W)}px: ${names(geo, geo.outside)} would leave the drawing`);
+ if (geo.unseated.length) dev && warn?.(`the drawn layout does not fit at ${Math.round(W)}px: no clean seat for ${geo.unseated.map((k) => (m.type === "sequence" ? `message ${k}` : `"${m.edges[k]?.label}"`)).join(", ")}`);
}
let d = stopOf({ ...current, ...closed, layout: "stacked", heights: undefined, grow: record(), track: m.type === "schema" ? mins.table : undefined, bare: undefined, pad: undefined });
d = heightsFor(d);
@@ -1937,16 +2021,16 @@ export function measureFigure(fig: HTMLElement, m: Model, P: string, base: strin
// labels, as the stacked schema's do, and the list holds every connection.
const failed = geo.unseated.length > 0 || geo.through.length > 0 || geo.outside.length > 0 || plan.third;
if (failed) {
- if (geo.unseated.length) warn?.(`the stacked drawing has no clean seat for ${[...new Set(geo.unseated)].map((k) => `"${m.edges[k]?.label}"`).join(", ")}, so its lines are not drawn; the list holds every connection`);
- if (geo.through.length) warn?.(`in the stacked drawing ${names(geo, geo.through)} would pass through a node, so its lines are not drawn`);
- if (geo.outside.length) warn?.(`in the stacked drawing ${names(geo, geo.outside)} would leave the drawing, so its lines are not drawn`);
- if (plan.third) warn?.("the stacked drawing would need a third end lane, so its lines are not drawn");
+ if (geo.unseated.length) dev && warn?.(`the stacked drawing has no clean seat for ${[...new Set(geo.unseated)].map((k) => `"${m.edges[k]?.label}"`).join(", ")}, so its lines are not drawn; the list holds every connection`);
+ if (geo.through.length) dev && warn?.(`in the stacked drawing ${names(geo, geo.through)} would pass through a node, so its lines are not drawn`);
+ if (geo.outside.length) dev && warn?.(`in the stacked drawing ${names(geo, geo.outside)} would leave the drawing, so its lines are not drawn`);
+ if (dev && plan.third) warn?.("the stacked drawing would need a third end lane, so its lines are not drawn");
// Dressed as where scripting is off (1.13): no line in the key, no key hint, no stops, and the list open when the figure becomes bare.
const bare: Geo = { ...geo, lines: [], labels: [], crossings: [] };
const dyn = stopOf({ ...d, grow: record(), bare: true, open: current.bare ? current.open : true, autoOpen: current.bare ? current.autoOpen : current.open ? undefined : true });
return { dyn, geo: bare, ink: "", tokens: tk };
}
- if (geo.crossings.length) warn?.(`${geo.crossings.length} crossing${geo.crossings.length === 1 ? "" : "s"} in the stacked drawing (each is cut): ${geo.crossings.map((c) => `${lineName(m, geo.lines[c.top]!)} over ${lineName(m, geo.lines[c.under]!)}`).join("; ")}`);
+ if (geo.crossings.length) dev && warn?.(`${geo.crossings.length} crossing${geo.crossings.length === 1 ? "" : "s"} in the stacked drawing (each is cut): ${geo.crossings.map((c) => `${lineName(m, geo.lines[c.top]!)} over ${lineName(m, geo.lines[c.under]!)}`).join("; ")}`);
return { dyn: d, geo, ink: inkHtml(P, geo, tk, base), tokens: tk };
}
@@ -2054,7 +2138,7 @@ export function keyTarget(m: Model, from: string, key: string): string | null {
*/
const MANAGED = ["data-layout", "data-measured", "role", "aria-roledescription", "aria-labelledby", "aria-describedby", "aria-label", "tabindex", "data-stops", "hidden"];
const ROOT_MANAGED = ["data-layout", "data-measured", "data-bare", "data-motion"];
-const MANAGED_STYLE = ["--_track", "--_h", "--_gap", "--_ggrow", "--_gpad"];
+const MANAGED_STYLE = ["--_track", "--_h", "--_ww", "--_gap", "--_ggrow", "--_gpad"];
const absent = (value: VAttrs[string]) => value === undefined || value === null || value === false;
function pairs(el: Element, v: VElement): boolean {
if (el.tagName.toLowerCase() !== v.t) return false;
diff --git a/packages/react/src/diagram-figure.tsx b/packages/react/src/diagram-figure.tsx
index a7c76e71..8b84cea3 100644
--- a/packages/react/src/diagram-figure.tsx
+++ b/packages/react/src/diagram-figure.tsx
@@ -173,6 +173,9 @@ export function DiagramFigure({ spec, component, title: _title, heading: _headin
// follows the lines each time they are drawn again. What it follows is the drawing itself, not the string: if React wrote the ink again for any reason
// (a remount, the faces arriving with the same lines), the reveal and the loops are built again on the new elements.
const drawn = React.useRef<{ svg: Element | null; controller: MotionController | null } | null>(null);
+ // The motion code failed to load. A figure hidden when it failed (inside a closed disclosure, an unselected tab) had no lines and no entrance to settle
+ // then: the lines it draws when it is shown are settled in the frame they are drawn, so they are never left pending.
+ const motionFailed = React.useRef(false);
React.useLayoutEffect(() => {
const fig = figRef.current;
if (!fig || !animated || !measured.current?.tokens) return;
@@ -180,13 +183,20 @@ export function DiagramFigure({ spec, component, title: _title, heading: _headin
if (drawn.current && drawn.current.svg === svg && drawn.current.controller === controller) return;
drawn.current = { svg, controller };
entranceDrawn(fig, Boolean(measured.current.geo?.lines.length));
+ if (motionFailed.current) settleEntrance(fig);
controller?.redrawn();
});
React.useEffect(() => {
if (!animated) return undefined;
let live = true;
- // If the motion code cannot load, the figure settles: every line whole, as still.
- loadMotion().then((mod) => { if (live) setMotionModule(() => mod); }, () => { const fig = figRef.current; if (fig && live) settleEntrance(fig); });
+ motionFailed.current = false;
+ // If the motion code cannot load, the figure settles: every line whole, as still, now and whenever its lines are drawn later.
+ loadMotion().then((mod) => { if (live) setMotionModule(() => mod); }, () => {
+ if (!live) return;
+ motionFailed.current = true;
+ const fig = figRef.current;
+ if (fig) settleEntrance(fig);
+ });
return () => { live = false; };
}, [animated]);
React.useLayoutEffect(() => {
diff --git a/packages/react/src/diagram-motion-core.ts b/packages/react/src/diagram-motion-core.ts
index 75f56fb7..caa7f9c1 100644
--- a/packages/react/src/diagram-motion-core.ts
+++ b/packages/react/src/diagram-motion-core.ts
@@ -10,6 +10,8 @@
import { entranceBlocked, pathD, settleEntrance } from "./diagram-core";
import type { Geo, GLine, Model, Pt, Tokens } from "./diagram-core";
+declare const process: { env: { NODE_ENV?: string } };
+
export interface MotionHost {
/** The figure element, which carries data-motion="animated". */
fig: HTMLElement;
@@ -819,6 +821,8 @@ class Figure implements MotionController {
export function motionErrors(m: Model): { errors: string[]; warnings: string[] } {
const errors: string[] = [];
const warnings: string[] = [];
+ // Development only: a production build (NODE_ENV set by the app's bundler) drops the checks below and their words.
+ if (process.env.NODE_ENV === "production") return { errors, warnings };
const { pulse, packet } = m.motion;
if (pulse && packet) errors.push("a figure names both a pulse and a packet: it has one mover at most");
const path = pulse ?? packet?.path;
diff --git a/packages/react/src/styles/components.css b/packages/react/src/styles/components.css
index 29ff45ac..b6b849cf 100644
--- a/packages/react/src/styles/components.css
+++ b/packages/react/src/styles/components.css
@@ -4557,7 +4557,8 @@
box plus 62% of the padding and border, 1.24 of each side's). Before script it is a plain box of its words at least space-16 tall; once
measured it is as tall as its words need, never under space-16 nor flatter than 5:1. */
.basalt-diagram-node[data-shape="decision"] { justify-content: center; align-items: center; height: var(--_h, auto); min-height: var(--basalt-space-16); padding: var(--basalt-space-2) var(--basalt-space-2-5); text-align: center; }
- .basalt-diagram-words { position: relative; max-width: calc(62% + (var(--basalt-space-2-5) + var(--basalt-size-hairline)) * 1.24); }
+ /* Its words wrap at 62% of the track; a diamond that would be taller than it is wide has its words' box widened by the engine (--_ww, DECISIONS 301). */
+ .basalt-diagram-words { position: relative; max-width: var(--_ww, calc(62% + (var(--basalt-space-2-5) + var(--basalt-size-hairline)) * 1.24)); }
.basalt-diagram-node[data-shape="decision"] .basalt-diagram-name { font-weight: var(--basalt-font-weight-medium); text-wrap: balance; }
.basalt-diagram-diamond { display: none; position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.basalt-diagram-diamond path { fill: var(--_surface, var(--basalt-surface-1)); stroke: var(--basalt-diagram-structure); stroke-width: var(--basalt-size-hairline); vector-effect: non-scaling-stroke; transition: stroke var(--basalt-duration-fast) var(--basalt-ease-out); }
diff --git a/packages/react/test/diagram-fixes.test.mjs b/packages/react/test/diagram-fixes.test.mjs
new file mode 100644
index 00000000..88a364bd
--- /dev/null
+++ b/packages/react/test/diagram-fixes.test.mjs
@@ -0,0 +1,200 @@
+// Batch A of the diagrams' backlog (DECISIONS 301): the leftovers of round 64's reviews, each restoring or proving decided behaviour (DECISIONS 281 and
+// 282). Neon's findings 13 and 14 (slots on a side, the development checks in production) and Fable's polish P3 (a label on half pixels) and P4 (a
+// decision taller than it is wide). Finding 12 (a one-column schema with a foreign key) is in diagrams.test.mjs, beside the test it replaced.
+import assert from "node:assert/strict";
+import fs from "node:fs";
+import path from "node:path";
+import { after, before, describe, test } from "node:test";
+import { pathToFileURL } from "node:url";
+
+import * as esbuild from "esbuild";
+
+import { inspectSource } from "./diagram-geometry.mjs";
+import { fixturePage, launch, pkg } from "./support.mjs";
+
+const DATA = JSON.parse(fs.readFileSync(path.join(pkg, "test", "fixtures", "cimip-diagrams.json"), "utf8"));
+const P = "basalt-diagram";
+const font = (file) => fs.readFileSync(path.join(pkg, "dist", "fonts", file)).toString("base64");
+const FONTS = `@font-face{font-family:"Geist";src:url(data:font/woff2;base64,${font("Geist-Variable.woff2")}) format("woff2");font-weight:100 900}@font-face{font-family:"Geist Mono";src:url(data:font/woff2;base64,${font("GeistMono-Variable.woff2")}) format("woff2");font-weight:100 900}`;
+// The figure is the page's column, `--w` wide, with no padding round it: a test sets the figure's own width.
+const PAGE = `${FONTS} body{background:var(--basalt-surface-page);margin:0} #root{width:var(--w,1104px)}`;
+
+let browser;
+before(async () => { browser = await launch(); });
+after(async () => { await browser?.close(); });
+
+const HOST = `
+const C = { architecture: B.ArchitectureDiagram, flowchart: B.FlowchartDiagram, "data-flow": B.DataFlowDiagram, sequence: B.SequenceDiagram, schema: B.SchemaDiagram };
+function Host() {
+ const [list, setList] = React.useState([]);
+ window.__set = (next) => flushSync(() => setList(next));
+ return
;
+}
+createRoot(document.getElementById("root")).render();`;
+
+const frames = (page, n = 3) => page.evaluate((n) => new Promise((resolve) => { let k = 0; const step = () => (++k >= n ? resolve() : requestAnimationFrame(step)); requestAnimationFrame(step); }), n);
+async function figurePage({ dev = false, theme = "dark" } = {}) {
+ let page, errors;
+ if (dev) {
+ // The same host as an app's development build: the fixtures are production builds, which drop the warnings.
+ ({ page, errors } = await fixturePage(browser, "", { theme, viewport: { width: 1440, height: 1000 }, standards: true }));
+ const built = await esbuild.build({
+ stdin: { contents: `import * as React from "react"; import { createRoot } from "react-dom/client"; import { flushSync } from "react-dom"; import * as B from "./dist/index.js"; ${HOST}`, resolveDir: pkg, loader: "tsx" },
+ bundle: true, format: "iife", write: false, jsx: "automatic", platform: "browser", logLevel: "silent", define: { "process.env.NODE_ENV": '"development"' },
+ });
+ await page.addScriptTag({ content: built.outputFiles[0].text });
+ } else {
+ ({ page, errors } = await fixturePage(browser, HOST, { theme, viewport: { width: 1440, height: 1000 }, standards: true }));
+ }
+ const warnings = [];
+ page.on("console", (m) => { if (m.type() === "warning" || m.type() === "error") warnings.push(m.text()); });
+ await page.addStyleTag({ content: PAGE });
+ await page.evaluate(() => document.fonts.ready);
+ return { page, errors, warnings };
+}
+const draw = async (page, items) => { await page.evaluate((items) => window.__set(items), items); await frames(page, 4); };
+const widthTo = async (page, w) => { await page.evaluate((w) => document.getElementById("root").style.setProperty("--w", `${w}px`), w); await frames(page, 4); };
+const inspect = (page, key) => page.evaluate(`${inspectSource()}("${P}", "#fig-${key}")`);
+const node = (id, col, row) => ({ id, name: id.toUpperCase(), kind: "part", col, row });
+
+describe("slots on a side (Neon's finding 13)", () => {
+ test("beside a straight line, two lines toward one end share that half evenly, nested; no two lines leave one point", async () => {
+ const core = await import(pathToFileURL(path.join(pkg, "dist", "diagram-core.js")).href);
+ const slots = (spec) => core.derivedPorts(core.buildModel({ type: "architecture", title: "t", ...spec }));
+ // A to B runs straight; C and D are both below, so all three leave A's right side. C is nearer, so it is nearer the middle.
+ const fan = slots({ nodes: [node("a", 1, 1), node("b", 2, 1), node("c", 2, 2), node("d", 2, 3)], edges: [{ from: "a", to: "b" }, { from: "a", to: "c" }, { from: "a", to: "d" }] });
+ assert.deepEqual(fan.map((p) => [p.fromSide, Math.round(p.fromSlot * 1000) / 1000]), [["right", 0.5], ["right", 0.667], ["right", 0.833]]);
+ // Two straight lines between A and B (one each way) take the quarter points; a line from A to C below takes the part below them.
+ const pair = slots({ nodes: [node("a", 1, 1), node("b", 2, 1), node("c", 2, 2)], edges: [{ from: "a", to: "b" }, { from: "b", to: "a" }, { from: "a", to: "c" }] });
+ assert.deepEqual(pair.map((p) => [p.fromSlot, p.toSlot]), [[0.25, 0.25], [0.75, 0.75], [0.875, 0.5]]);
+ // The decided cases are unchanged: one beside a straight line takes the quarter nearer its far end, on either side of it.
+ const one = slots({ nodes: [node("a", 1, 2), node("b", 2, 2), node("c", 2, 1), node("d", 2, 3)], edges: [{ from: "a", to: "b" }, { from: "a", to: "c" }, { from: "a", to: "d" }] });
+ assert.deepEqual(one.map((p) => p.fromSlot), [0.5, 0.25, 0.75]);
+ // No two ends on one side of one node share a point, in the fixtures above and in the five examples.
+ for (const [name, list, m] of [["fan", fan], ["pair", pair], ["one", one], ...["architecture", "flowchart", "dataFlow"].map((k) => [k, core.derivedPorts(core.buildModel(DATA[k])), core.buildModel(DATA[k])])]) {
+ const seen = new Map();
+ for (const p of list) for (const [id, side, f] of [[p.from, p.fromSide, p.fromSlot], [p.to, p.toSide, p.toSlot]]) {
+ if (m?.byId.get(id)?.shape === "decision") continue; // a decision's lines leave its four points
+ const key = `${id}.${side}@${f}`;
+ // Two lines to one port share it by design when they are the same pair (a bus): count ends of different lines to different far nodes.
+ const far = id === p.from ? p.to : p.from;
+ if (seen.has(key) && seen.get(key) !== far) assert.fail(`${name}: two lines leave ${key}`);
+ seen.set(key, far);
+ }
+ }
+ });
+
+ test("the development warning for a fourth line on a side says \"has\" once", async () => {
+ const { page, warnings } = await figurePage({ dev: true });
+ await draw(page, [{ key: "four", spec: { type: "architecture", title: "Four", summary: "Four lines on one side.", nodes: [node("a", 1, 2), node("b", 2, 1), node("c", 2, 2), node("d", 2, 3), node("e", 2, 4)], edges: ["b", "c", "d", "e"].map((to) => ({ from: "a", to })) } }]);
+ const said = warnings.filter((w) => /side has/.test(w));
+ assert.ok(said.some((w) => w.includes("a's right side has 4 lines; more than three is an error")), JSON.stringify(warnings));
+ for (const w of said) assert.doesNotMatch(w, /\bhas\b.*\bhas\b/);
+ await page.close();
+ });
+});
+
+describe("the development checks cost production nothing (Neon's finding 14)", () => {
+ // Phrases only the checks write (a property name such as `crossings` is code, not a check's words).
+ const WORDS = ["share the cell at column", "main lines are drawn but", "is not a kind of line", "more than three is an error", "would leave the drawing", "in the drawn layout",
+ "third end lane", "stands for", "is used twice", "two columns apart", "closer than space-3"];
+ const bundle = async (entry, mode) => (await esbuild.build({
+ stdin: { contents: entry, resolveDir: pkg, loader: "js" }, bundle: true, minify: true, format: "esm", write: false, logLevel: "silent",
+ external: ["react", "react-dom", "react/jsx-runtime"], define: { "process.env.NODE_ENV": JSON.stringify(mode) },
+ plugins: [{ name: "on-demand", setup(build) { build.onResolve({ filter: /.*/ }, (args) => (args.kind === "dynamic-import" ? { path: args.path, external: true } : undefined)); } }],
+ })).outputFiles[0].text;
+
+ test("an app's production build of each diagram holds none of their words; its development build holds them all", async () => {
+ for (const name of ["ArchitectureDiagram", "FlowchartDiagram", "DataFlowDiagram", "SequenceDiagram", "SchemaDiagram"]) {
+ const entry = `import { ${name} } from "./dist/index.js"; console.log(${name});`;
+ const [prod, dev] = [await bundle(entry, "production"), await bundle(entry, "development")];
+ for (const w of WORDS) {
+ assert.ok(!prod.includes(w), `${name}'s production build holds "${w}"`);
+ assert.ok(dev.includes(w), `${name}'s development build lacks "${w}"`);
+ }
+ assert.ok(dev.length - prod.length > 2500, `${name}: production ${prod.length}, development ${dev.length}`);
+ }
+ });
+
+ test("the motion module's production build holds none of its checks' words", async () => {
+ const entry = `import { motionErrors } from "./dist/diagram-motion.js"; console.log(motionErrors);`;
+ const [prod, dev] = [await bundle(entry, "production"), await bundle(entry, "development")];
+ for (const w of ["names both a pulse and a packet", "flows but has no label", "is dashed and flows", "no line joins them in that direction"]) {
+ assert.ok(!prod.includes(w), `production holds "${w}"`);
+ assert.ok(dev.includes(w), `development lacks "${w}"`);
+ }
+ });
+});
+
+describe("labels on whole pixels (Fable's polish P3)", () => {
+ for (const theme of ["dark", "light"]) {
+ test(`${theme}: every label's box is on the page's whole pixels, at every drawn and stacked width tried, and the drawing has no problem`, async () => {
+ const { page } = await figurePage({ theme });
+ // An odd offset, so the drawing's own origin is not on a whole pixel either.
+ await page.addStyleTag({ content: "#root{margin-left:0.5px;padding-top:0.25px}" });
+ await draw(page, ["architecture", "flowchart", "dataFlow"].map((key) => ({ key, spec: DATA[key] })));
+ const off = [];
+ let labels = 0;
+ for (const w of [358, 480, 784, 880, 936, 960, 1000, 1087, 1104]) {
+ await widthTo(page, w);
+ for (const key of ["architecture", "flowchart", "dataFlow"]) {
+ const boxes = await page.evaluate((key) => [...document.querySelectorAll(`#fig-${key} .basalt-diagram-label`)].map((l) => { const r = l.getBoundingClientRect(); return [l.textContent, r.left, r.top]; }), key);
+ labels += boxes.length;
+ for (const [text, x, y] of boxes) if (Math.abs(x - Math.round(x)) > 0.01 || Math.abs(y - Math.round(y)) > 0.01) off.push(`${key} at ${w}: "${text}" at ${x}, ${y}`);
+ assert.deepEqual((await inspect(page, key)).problems, [], `${key} at ${w}`);
+ }
+ }
+ assert.ok(labels > 100, `${labels} labels read`);
+ assert.deepEqual(off, []);
+ await page.close();
+ });
+ }
+});
+
+describe("a decision no taller than it is wide (Fable's polish P4)", () => {
+ test("a diamond taller than wide has its words' box widened, to the narrowest that fits it under the ceiling; only where none can does it stay taller", async () => {
+ const { page } = await figurePage();
+ await draw(page, [{ key: "flow", spec: DATA.flowchart }]);
+ const widened = [], over = [];
+ for (let w = 930; w <= 1104; w += 3) {
+ await widthTo(page, w);
+ if ((await page.getAttribute("#fig-flow", "data-layout")) !== "drawn") continue;
+ const seen = await page.evaluate(() => [...document.querySelectorAll("#fig-flow .basalt-diagram-node[data-shape='decision']")].map((n) => {
+ const r = n.getBoundingClientRect(), words = n.querySelector(".basalt-diagram-words");
+ const own = n.style.getPropertyValue("--_ww");
+ // What any words box from the decided 62% up to the track's whole inside would make: is there one under the ceiling?
+ const height = (wr) => { const bw = wr.width + 20, bh = wr.height + 16, d = 1 - bw / r.width; return Math.max(64, Math.ceil(r.width / 5), Math.ceil(d > 0.05 ? bh / d : bh * 20)); };
+ n.style.removeProperty("--_ww");
+ const decided = height(words.getBoundingClientRect());
+ let can = false, narrowest = null;
+ for (let x = Math.ceil(words.getBoundingClientRect().width); x <= n.clientWidth - 20; x++) {
+ n.style.setProperty("--_ww", `${x}px`);
+ const h = height(words.getBoundingClientRect());
+ if (h <= r.width) { can = true; narrowest ??= x; }
+ }
+ n.style.removeProperty("--_ww");
+ if (own) n.style.setProperty("--_ww", own);
+ return { id: n.dataset.node, w: r.width, h: r.height, own: own ? parseFloat(own) : null, decided, can, narrowest };
+ }));
+ for (const d of seen) {
+ // The 5:1 floor stays, and so does the space-16 one.
+ assert.ok(d.w / d.h <= 5.001 && d.h >= 64 - 0.5, `at ${w}: ${d.id} is ${d.w} by ${d.h}`);
+ if (d.decided <= d.w) assert.equal(d.own, null, `at ${w}: ${d.id} fits at 62% and is not widened`);
+ else if (d.can) {
+ assert.ok(d.h <= d.w + 0.5, `at ${w}: ${d.id} is ${d.h} tall on ${d.w}`);
+ assert.equal(d.own, d.narrowest, `at ${w}: ${d.id} takes the narrowest box under the ceiling`);
+ widened.push(w);
+ } else {
+ assert.equal(d.own, null, `at ${w}: ${d.id} cannot fit, and keeps 62%`);
+ assert.ok(Math.abs(d.h - d.decided) <= 0.5, `at ${w}: ${d.id} is as tall as 1.12 says`);
+ over.push(`${w}: ${d.id} ${d.w}x${d.h}`);
+ }
+ }
+ assert.deepEqual((await inspect(page, "flow")).problems, [], `at ${w}`);
+ }
+ // "Risk medium or lower?" on the CIMIP flowchart: widened over part of the band Fable measured, and taller than wide only where no box could help.
+ assert.ok(widened.length > 0, "some width widens");
+ console.log(`widened at ${widened.join(", ")}; taller than wide at ${over.join("; ") || "none"}`);
+ await page.close();
+ });
+});
diff --git a/packages/react/test/diagram-geometry.mjs b/packages/react/test/diagram-geometry.mjs
index 48a78f76..80e10c83 100644
--- a/packages/react/test/diagram-geometry.mjs
+++ b/packages/react/test/diagram-geometry.mjs
@@ -51,6 +51,22 @@ function inspect(P, selector) {
});
const segs = (l) => l.pts.slice(1).map((p, k) => [l.pts[k], p]);
const segRect = (a, b, w) => ({ l: Math.min(a.x, b.x) - w / 2, r: Math.max(a.x, b.x) + w / 2, t: Math.min(a.y, b.y) - w / 2, b: Math.max(a.y, b.y) + w / 2 });
+ // Two lines laid on one another (collinear for more than a pixel) read as one line, unless they share an end: lines to one port share a lane (a bus),
+ // and lines leaving one card in the stacked drawing share its trunk.
+ for (let a = 0; a < lines.length; a++) for (let b = a + 1; b < lines.length; b++) {
+ const A = lines[a], B = lines[b];
+ if (Math.abs(A.tip.x - B.tip.x) < 1 && Math.abs(A.tip.y - B.tip.y) < 1) continue;
+ if (Math.abs(A.pts[0].x - B.pts[0].x) < 1 && Math.abs(A.pts[0].y - B.pts[0].y) < 1) continue;
+ const near = (A.width + B.width) / 2 + 0.5;
+ const on = segs(A).some(([p1, p2]) => segs(B).some(([q1, q2]) => {
+ const aH = Math.abs(p1.y - p2.y) < 0.01, bH = Math.abs(q1.y - q2.y) < 0.01, aV = Math.abs(p1.x - p2.x) < 0.01, bV = Math.abs(q1.x - q2.x) < 0.01;
+ if (!((aH && bH) || (aV && bV))) return false;
+ if (Math.abs(aH ? p1.y - q1.y : p1.x - q1.x) >= near) return false;
+ const [a1, a2, b1, b2] = aH ? [p1.x, p2.x, q1.x, q2.x] : [p1.y, p2.y, q1.y, q2.y];
+ return Math.min(Math.max(a1, a2), Math.max(b1, b2)) - Math.max(Math.min(a1, a2), Math.min(b1, b2)) > 1;
+ }));
+ if (on) problems.push(`${A.from} to ${A.to} lies on ${B.from} to ${B.to}`);
+ }
const heads = lines.map((l) => ({ i: l.i, ...R(l.tipEl) }));
const labels = [...drawing.querySelectorAll(`.${P}-label`)].map((el) => ({ i: el.dataset.edge, text: el.textContent, el, ...R(el) }));
const rules = [];
diff --git a/packages/react/test/diagram-motion.test.mjs b/packages/react/test/diagram-motion.test.mjs
index 5129ffd3..7f842e62 100644
--- a/packages/react/test/diagram-motion.test.mjs
+++ b/packages/react/test/diagram-motion.test.mjs
@@ -416,6 +416,9 @@ describe("measured again (first)", () => {
await untilState(page, "sequence", "running");
await page.setViewportSize({ width: 390, height: 900 });
await frames(page, 8);
+ // A participant's head becomes a chip in the stack, and its border's colour changes from the rim to the hairline over duration-fast, as a still
+ // figure's does: a CSS transition of the layout, not motion. Sampled within its 100ms it was there (a flake, on main too): let it end first.
+ await page.evaluate(() => Promise.all(document.getElementById("fig-sequence").getAnimations({ subtree: true }).filter((a) => a instanceof CSSTransition).map((a) => a.finished.catch(() => {}))));
const seen = await page.evaluate(() => { const f = document.getElementById("fig-sequence"); return { state: f.getAttribute("data-entrance"), anims: f.getAnimations({ subtree: true }).length, controls: f.querySelectorAll(".basalt-diagram-play, .basalt-diagram-pause").length }; });
assert.notEqual(seen.state, "pending");
assert.notEqual(seen.state, "running");
@@ -939,3 +942,213 @@ describe("section 7's remaining checks", () => {
});
}
});
+
+// The checks round 66's PR listed as not yet written (Neon's item 7 of round 65's code review), added in batch A of the backlog (DECISIONS 301).
+describe("section 7's checks, batch A", () => {
+ /** Finishes every finite animation running on a figure, frame by frame, `n` times, calling `look` after each frame. */
+ const runOut = async (page, key, n, look) => {
+ for (let k = 0; k < n; k++) {
+ await page.evaluate((key) => { for (const a of document.getElementById(`fig-${key}`).getAnimations({ subtree: true })) if (a.playState === "running" && a.effect?.getComputedTiming().iterations !== Infinity) a.finish(); }, key);
+ await frames(page, 1);
+ await look?.();
+ }
+ };
+ const settleNow = (page, key) => page.evaluate((key) => { const f = document.getElementById(`fig-${key}`); f.setAttribute("data-entrance", "done"); f.dispatchEvent(new Event("basalt-diagram-settle")); }, key);
+
+ test("with a packet in flight, one send waits and a second is dropped: two messages go, each to the last stop, then nothing", async () => {
+ const { page } = await motionPage();
+ const spec = (send) => `{ ...S.animated("dataFlow"), packet: { path: ["send", "append", "row", "hear", "see"], send: ${send} } }`;
+ await draw(page, [["send", spec(0)]]);
+ await until(page, () => document.querySelector("#fig-send .basalt-diagram-pause") || document.querySelector("#fig-send").getAttribute("data-entrance"));
+ await settleNow(page, "send");
+ await frames(page, 2);
+ const dotShown = () => page.evaluate(() => { const d = document.querySelector("#fig-send .basalt-diagram-packet"); return Boolean(d && getComputedStyle(d).display !== "none"); });
+ // The first render sends none.
+ assert.equal(await dotShown(), false);
+ await draw(page, [["send", spec(1)]]);
+ await until(page, () => { const d = document.querySelector("#fig-send .basalt-diagram-packet"); return d && getComputedStyle(d).display !== "none"; });
+ // Two more sends while the first dot flies: the first of them waits, the second is dropped.
+ await draw(page, [["send", spec(2)]]);
+ await draw(page, [["send", spec(3)]]);
+ // Count the messages that land: the last stop lifts once a message. The legs, the rests and the fades are animations on the figure, run out here.
+ let landed = 0, lit = false, quiet = 0;
+ await runOut(page, "send", 400, async () => {
+ const now = await page.evaluate(() => document.querySelector("#fig-send [data-node='see']").hasAttribute("data-arrival"));
+ if (now && !lit) landed++;
+ lit = now;
+ const busy = await page.evaluate(() => document.getElementById("fig-send").getAnimations({ subtree: true }).some((a) => a.playState === "running"));
+ quiet = busy || (await dotShown()) ? 0 : quiet + 1;
+ });
+ assert.equal(landed, 2, "the first message and the one that waited");
+ assert.ok(quiet > 10, "and then nothing moves");
+ // A later send, with nothing in flight, goes at once.
+ await draw(page, [["send", spec(4)]]);
+ await until(page, () => { const d = document.querySelector("#fig-send .basalt-diagram-packet"); return d && getComputedStyle(d).display !== "none"; });
+ });
+
+ test("a flow line's cuts stop space-1 short of its head; a flow line with under 48px showing has none, one with more has them", async () => {
+ const { page } = await motionPage();
+ // A stream into the card below (a 48px row gap: 40px of it shows past the head) and one into the card beside (a 64px column gap: 56px shows).
+ await draw(page, [["short", JSON.stringify({ type: "architecture", motion: "animated", title: "Streams", summary: "Two streams.", nodes: [
+ { id: "a", name: "A", kind: "part", col: 1, row: 1 }, { id: "b", name: "B", kind: "part", col: 2, row: 1 }, { id: "c", name: "C", kind: "part", col: 1, row: 2 }],
+ edges: [{ from: "a", to: "b", flow: true }, { from: "a", to: "c", flow: true }] })], ["architecture", `S.animated("architecture")`, 80]]);
+ for (const key of ["short", "architecture"]) await settleNow(page, key);
+ await until(page, () => [...document.querySelectorAll("#fig-short .basalt-diagram-flow, #fig-architecture .basalt-diagram-flow")].filter((x) => getComputedStyle(x).display !== "none").length >= 2);
+ await frames(page, 4);
+ const seen = await page.evaluate(() => [...document.querySelectorAll("figure")].flatMap((f) => [...f.querySelectorAll(".basalt-diagram-svg .basalt-diagram-edge")].map((g) => {
+ const i = g.dataset.edge;
+ const line = g.querySelector(".basalt-diagram-line"), tip = g.querySelector(".basalt-diagram-tip");
+ const nums = (d) => d.match(/-?[\d.]+/g).map(Number);
+ const t = nums(tip.getAttribute("d"));
+ const tipAt = { x: t[0], y: t[1] };
+ // The line's path stops under its head, 7 short of the tip (size-diagram-head less 1): what shows of it runs to the head's base, 8 short.
+ const len = line.getTotalLength();
+ // Its flow overlay, if it has one shown: the overlay's path starts where the line does.
+ const start = nums(line.getAttribute("d"));
+ const flow = [...f.querySelectorAll(".basalt-diagram-flow")].find((x) => { const p = nums(x.querySelector("path").getAttribute("d")); return Math.hypot(p[0] - start[0], p[1] - start[1]) < 1 && getComputedStyle(x).display !== "none"; });
+ let cutEnd = null;
+ if (flow) { const p = nums(flow.querySelector("path").getAttribute("d")); cutEnd = { x: p.at(-2), y: p.at(-1) }; }
+ return { fig: f.id, from: g.dataset.from, to: g.dataset.to, visible: len - 1, on: [...f.querySelectorAll(`.basalt-diagram-label[data-edge="${i}"][data-on]`)].map((x) => x.getBoundingClientRect().width), tip: tipAt, cutEnd };
+ })));
+ const short = seen.find((s) => s.fig === "fig-short" && s.to === "c"), long = seen.find((s) => s.fig === "fig-short" && s.to === "b");
+ assert.ok(short.visible < 48 && short.on.length === 0, JSON.stringify(short));
+ assert.equal(short.cutEnd, null, "under 48px showing: solid");
+ assert.ok(long.visible >= 48 && long.cutEnd, JSON.stringify(long));
+ const cut = seen.filter((s) => s.cutEnd);
+ assert.ok(cut.length >= 2, JSON.stringify(seen));
+ for (const s of cut) {
+ // The head is size-diagram-head (8) long: its base is 8 from the tip, and the cuts end at least space-1 (4) before it.
+ const fromTip = Math.hypot(s.cutEnd.x - s.tip.x, s.cutEnd.y - s.tip.y);
+ assert.ok(fromTip >= 8 + 4 - 0.5, `${s.fig} ${s.from} to ${s.to}: the cuts end ${fromTip.toFixed(1)} from the tip`);
+ // And a line that flows shows at least 48px (its plates taken off).
+ assert.ok(s.visible - s.on.reduce((a, b) => a + b, 0) >= 48, `${s.fig} ${s.from} to ${s.to} flows with ${s.visible}px showing`);
+ }
+ });
+
+ test("the data flow's, the flowchart's and the schema's totals are the decision's (1.3): 2.0s, 2.4s and 2.66s to the last line, 0.14s more at most to the last head", async () => {
+ const { page } = await motionPage();
+ const want = { dataFlow: 2000, flowchart: 2400, schema: 2660 };
+ for (const key of Object.keys(want)) {
+ await draw(page, [[key, `S.animated("${key}")`]]);
+ await untilState(page, key, "running");
+ const t = await page.evaluate((key) => {
+ const f = document.getElementById(`fig-${key}`);
+ const end = (a) => Number(a.effect.getComputedTiming().endTime);
+ // Each line's reveal is the first path of its own mask (as the architecture's total above reads it); its head fades in on the elements after.
+ const lines = [...f.querySelectorAll(".basalt-diagram-motion-defs mask")].map((m) => end(m.querySelector("path").getAnimations()[0]));
+ return { lines: Math.max(...lines), all: Math.max(...f.getAnimations({ subtree: true }).filter((a) => a.effect?.getComputedTiming().iterations !== Infinity).map(end)) };
+ }, key);
+ assert.ok(Math.abs(t.lines - want[key]) <= 50, `${key}: the last line ends at ${t.lines}`);
+ assert.ok(t.all - t.lines <= 140 + 1, `${key}: the last head ends ${t.all - t.lines}ms after it`);
+ }
+ });
+
+ for (const [theme, scheme] of [["light", "dark"], ["dark", "light"]]) {
+ test(`more contrast under a ${theme} theme chosen with the toggle (the system ${scheme}): a card's arrival rim is the theme's primary ink, not a traced neighbour's`, async () => {
+ const { page } = await motionPage({ theme, colorScheme: scheme, contrast: "more" });
+ await draw(page, [["architecture", `S.animated("architecture")`]]);
+ const seen = await page.evaluate(() => {
+ const f = document.getElementById("fig-architecture");
+ const n = f.querySelector("[data-node='alb']");
+ n.style.transition = "none";
+ n.setAttribute("data-arrival", "");
+ const rim = getComputedStyle(n).borderTopColor;
+ const probe = (v) => { const s = document.createElement("span"); s.style.color = v; f.append(s); const c = getComputedStyle(s).color; s.remove(); return c; };
+ const near = f.querySelector(".basalt-diagram-node:not([data-focal]):not([data-node='alb'])");
+ near.style.transition = "none";
+ near.setAttribute("data-near", "");
+ const traced = getComputedStyle(near).borderTopColor;
+ // Luminance of the rim, read through a canvas, so an oklch() value compares as a colour.
+ const c = document.createElement("canvas"); c.width = c.height = 1; const ctx = c.getContext("2d", { willReadFrequently: true });
+ ctx.fillStyle = rim; ctx.fillRect(0, 0, 1, 1); const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;
+ return { rim, primary: probe("var(--basalt-text-primary)"), traced, light: (r + g + b) / 3 > 128, system: matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light", more: matchMedia("(prefers-contrast: more)").matches };
+ });
+ assert.equal(seen.system, scheme);
+ assert.ok(seen.more);
+ assert.equal(seen.rim, seen.primary);
+ assert.notEqual(seen.rim, seen.traced);
+ // The theme's own primary ink: light on the dark theme, dark on the light one, whatever the system says.
+ assert.equal(seen.light, theme === "dark");
+ });
+ }
+
+ test("the fit rule counts a mark's padding: a card whose widest word is its name, with a mark and no kind, is drawn from space-6 a column later", async () => {
+ const { page } = await motionPage();
+ const word = "Supercalifragilisticexpialidocious";
+ const spec = (mark) => JSON.stringify({ type: "architecture", title: "Wide", summary: "A wide name.", nodes: [{ id: "a", name: word, col: 1, row: 1, ...(mark ? { mark: "aws-s3-bucket" } : {}) }, ...["b", "c", "d"].map((id, k) => ({ id, name: id.toUpperCase(), col: k + 2, row: 1 }))], edges: [{ from: "a", to: "b" }] });
+ await page.addStyleTag({ content: "#root{max-width:none;width:var(--w)}" });
+ const first = async (mark) => {
+ await draw(page, [["wide", spec(mark)]]);
+ let lo = 640, hi = 1400;
+ const drawnAt = async (w) => { await page.evaluate((w) => document.getElementById("root").style.setProperty("--w", `${w}px`), w); await frames(page, 3); return (await page.getAttribute("#fig-wide", "data-layout")) === "drawn"; };
+ assert.ok(await drawnAt(hi) && !(await drawnAt(lo)));
+ while (hi - lo > 1) { const mid = (lo + hi) >> 1; if (await drawnAt(mid)) hi = mid; else lo = mid; }
+ return hi;
+ };
+ const plain = await first(false), marked = await first(true);
+ // Four columns, each track at least the widest word: the name's space-6 (24) seat is in every track's minimum.
+ assert.ok(Math.abs(marked - plain - 4 * 24) <= 4, `drawn from ${plain} without the mark and ${marked} with it`);
+ // At its first drawn width, the name keeps clear of the mark.
+ const clear = await page.evaluate(() => {
+ const n = document.querySelector("#fig-wide [data-node='a']"), m = n.querySelector(".basalt-diagram-mark").getBoundingClientRect();
+ const range = document.createRange(); range.selectNodeContents(n.querySelector(".basalt-diagram-name"));
+ return [...range.getClientRects()].every((r) => r.right <= m.left || r.left >= m.right || r.bottom <= m.top || r.top >= m.bottom);
+ });
+ assert.ok(clear);
+ });
+
+ test("the motion code fails to load: the figure settles, every line whole as still, with no motion control and no error", async () => {
+ // An app's own build, split: the motion module is a chunk of its own, loaded on demand, which this page cannot fetch.
+ const built = await (await import("esbuild")).build({
+ stdin: { contents: `import * as React from "react"; import { createRoot } from "react-dom/client"; import { flushSync } from "react-dom"; import * as B from "./dist/index.js"; ${HOST}`, resolveDir: pkg, loader: "tsx" },
+ bundle: true, format: "esm", splitting: true, outdir: path.join(pkg, ".motion-fail"), write: false, jsx: "automatic", platform: "browser", logLevel: "silent", define: { "process.env.NODE_ENV": '"production"' },
+ entryNames: "main", chunkNames: "[name]-[hash]",
+ });
+ const files = new Map(built.outputFiles.map((f) => [`/${path.basename(f.path)}`, f.text]));
+ const motion = [...files.keys()].filter((name) => name !== "/main.js" && files.get(name).includes("Play the run"));
+ assert.equal(motion.length, 1, `the motion code is one chunk: ${[...files.keys()].join(", ")}`);
+ const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
+ const errors = [];
+ page.on("pageerror", (e) => errors.push(e.message));
+ const css = fs.readFileSync(path.join(pkg, "dist", "styles.css"), "utf8");
+ let refused = 0;
+ await page.route("http://basalt.test/**", (route) => {
+ const name = new URL(route.request().url()).pathname;
+ if (name === "/") return route.fulfill({ contentType: "text/html", body: `` });
+ if (motion.includes(name)) { refused++; return route.abort("failed"); }
+ if (files.has(name)) return route.fulfill({ contentType: "text/javascript", body: files.get(name) });
+ return route.fulfill({ status: 404, body: "" });
+ });
+ await page.goto("http://basalt.test/");
+ await page.waitForFunction(() => typeof window.__set === "function");
+ await draw(page, [["architecture", `S.animated("architecture")`], ["dataFlow", `S.animated("dataFlow")`, 80]]);
+ await until(page, () => ["architecture", "dataFlow"].every((k) => document.getElementById(`fig-${k}`)?.getAttribute("data-entrance") === "done"));
+ await frames(page, 4);
+ assert.ok(refused >= 1, "the motion chunk was asked for and refused");
+ const seen = await page.evaluate(() => [...document.querySelectorAll("figure")].map((f) => ({
+ edges: getComputedStyle(f.querySelector(".basalt-diagram-edges")).visibility,
+ masked: f.querySelectorAll(".basalt-diagram-edge[mask], .basalt-diagram-motion-defs").length,
+ parts: f.querySelectorAll(".basalt-diagram-flow, .basalt-diagram-bead, .basalt-diagram-packet, .basalt-diagram-play, .basalt-diagram-pause").length,
+ foot: f.querySelector(".basalt-diagram-foot").children.length,
+ lines: f.querySelectorAll(".basalt-diagram-svg .basalt-diagram-line").length,
+ animations: f.getAnimations({ subtree: true }).length,
+ })));
+ for (const s of seen) assert.deepEqual({ ...s, lines: s.lines > 0 }, { edges: "visible", masked: 0, parts: 0, foot: 1, lines: true, animations: 0 });
+
+ // A figure that mounts hidden (an unselected tab, a closed disclosure) is not measured and has no entrance when the load fails. Shown later, its
+ // lines are drawn then, and settled in that frame: never left pending behind a module that will not come (Neon's blocking finding 2 on #126).
+ const hide = await page.addStyleTag({ content: "#root > div > div:nth-child(3) { display: none; }" });
+ await draw(page, [["architecture", `S.animated("architecture")`], ["dataFlow", `S.animated("dataFlow")`, 80], ["late", `S.animated("architecture")`, 80]]);
+ await until(page, () => document.getElementById("fig-late") !== null);
+ // The browser keeps the failed module: the hidden figure's import is refused without a second request. Give it a moment to reject.
+ await page.waitForTimeout(300);
+ assert.deepEqual(await page.evaluate(() => { const f = document.getElementById("fig-late"); return { entrance: f.getAttribute("data-entrance"), measured: f.hasAttribute("data-measured") }; }), { entrance: null, measured: false }, "hidden: not measured, no entrance");
+ await hide.evaluate((s) => s.remove());
+ await until(page, () => document.querySelector("#fig-late .basalt-diagram-edges"));
+ await frames(page, 4);
+ const shown = await page.evaluate(() => { const f = document.getElementById("fig-late"); return { entrance: f.getAttribute("data-entrance"), edges: getComputedStyle(f.querySelector(".basalt-diagram-edges")).visibility, lines: f.querySelectorAll(".basalt-diagram-svg .basalt-diagram-line").length > 0, parts: f.querySelectorAll(".basalt-diagram-play, .basalt-diagram-pause").length }; });
+ assert.deepEqual(shown, { entrance: "done", edges: "visible", lines: true, parts: 0 });
+ assert.deepEqual(errors, []);
+ await page.close();
+ });
+});
diff --git a/packages/react/test/diagram-paint-bench.mjs b/packages/react/test/diagram-paint-bench.mjs
new file mode 100644
index 00000000..215aef9b
--- /dev/null
+++ b/packages/react/test/diagram-paint-bench.mjs
@@ -0,0 +1,144 @@
+// A paint benchmark for a page of animated diagrams (DECISIONS 292's backlog; built in batch A, DECISIONS 301). Not a test and not a gate: it reports.
+//
+// node packages/react/test/diagram-paint-bench.mjs [--seconds 10] [--height 900] [--json]
+//
+// It draws the five CIMIP examples, animated, and the marks kit on one React page (the built package, a production build, as an app ships it), waits for
+// every entrance to end, then records for `--seconds` (10 by default) with every loop that may run running: the time between frames (from
+// requestAnimationFrame), and what Chromium did (a timeline trace: paints, layouts, style recalculations, layer updates and raster tasks). Then it records the
+// same page with every figure still, for the floor. By default the window is tall enough for every figure to be in view at once, so every loop runs (a
+// loop out of view is frozen); `--height 900` measures a laptop's window, where only the first figures run.
+//
+// Chromium is launched as an app's reader has it (overlay scrollbars, and partial raster on: the full raster the stills use would charge every changed tile
+// whole). Alone on the machine: it waits for no other test or browser run to end, so check first (AGENTS.md, "One heavy run per Mac") and say so if one was going.
+import fs from "node:fs";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+
+import * as esbuild from "esbuild";
+import { chromium } from "playwright";
+
+import { OVERLAY_SCROLLBARS } from "../../../scripts/chromium-launch.mjs";
+
+const pkg = path.join(path.dirname(fileURLToPath(import.meta.url)), "..");
+const arg = (name, fallback) => { const k = process.argv.indexOf(`--${name}`); return k > 0 ? process.argv[k + 1] : fallback; };
+const SECONDS = Number(arg("seconds", 10));
+const HEIGHT = arg("height", null);
+const JSON_OUT = process.argv.includes("--json");
+
+const MANIFEST = JSON.parse(fs.readFileSync(path.join(pkg, "marks", "manifest.json"), "utf8"));
+const exportName = (id) => id.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
+const font = (file) => fs.readFileSync(path.join(pkg, "dist", "fonts", file)).toString("base64");
+const FONTS = `@font-face{font-family:"Geist";src:url(data:font/woff2;base64,${font("Geist-Variable.woff2")}) format("woff2");font-weight:100 900}@font-face{font-family:"Geist Mono";src:url(data:font/woff2;base64,${font("GeistMono-Variable.woff2")}) format("woff2");font-weight:100 900}`;
+
+// The page: the five examples with their motion keys (fixtures/diagram-motion.json), then the kit, each mark id its module.
+const HOST = `
+import * as React from "react"; import { createRoot } from "react-dom/client"; import * as B from "./dist/index.js";
+import still from "./test/fixtures/cimip-diagrams.json";
+import motion from "./test/fixtures/diagram-motion.json";
+${MANIFEST.marks.map((m) => `import { ${exportName(m.id)} } from "./dist/marks/${m.id}.js";`).join("\n")}
+const MARKS = { ${MANIFEST.marks.map((m) => `"${m.id}": ${exportName(m.id)}`).join(", ")} };
+const C = { architecture: B.ArchitectureDiagram, flowchart: B.FlowchartDiagram, "data-flow": B.DataFlowDiagram, sequence: B.SequenceDiagram, schema: B.SchemaDiagram };
+const animated = (key) => {
+ const { flow = [], marks = {}, ...keys } = motion.cimip[key];
+ const spec = { ...structuredClone(still[key]), ...keys };
+ if (spec.edges) spec.edges = spec.edges.map((e) => (flow.some(([f, t]) => f === e.from && t === e.to) ? { ...e, flow: true } : e));
+ if (spec.nodes) spec.nodes = spec.nodes.map((n) => (marks[n.id] ? { ...n, mark: marks[n.id] } : n));
+ return spec;
+};
+const STILL = new URLSearchParams(location.search).has("still");
+const specs = [...["architecture", "flowchart", "dataFlow", "sequence", "schema"].map((k) => [k, animated(k)]), ["kit", structuredClone(motion.kit)]];
+function Page() {
+ return {specs.map(([key, spec]) => {
+ const { type, ...props } = spec;
+ if (props.nodes) props.nodes = props.nodes.map((n) => (typeof n.mark === "string" ? { ...n, mark: MARKS[n.mark] } : n));
+ const X = C[type];
+ return ;
+ })};
+}
+createRoot(document.getElementById("root")).render();`;
+
+const built = await esbuild.build({
+ stdin: { contents: HOST, resolveDir: pkg, loader: "tsx" }, bundle: true, format: "esm", splitting: true, outdir: path.join(pkg, ".paint-bench"), write: false,
+ jsx: "automatic", platform: "browser", logLevel: "silent", define: { "process.env.NODE_ENV": '"production"' }, entryNames: "main", chunkNames: "[name]-[hash]", minify: true,
+});
+const files = new Map(built.outputFiles.map((f) => [`/${path.basename(f.path)}`, f.text]));
+const css = fs.readFileSync(path.join(pkg, "dist", "styles.css"), "utf8");
+const html = ``;
+
+const browser = await chromium.launch({ args: [OVERLAY_SCROLLBARS] });
+
+async function run(still) {
+ // The window is its final height from the first frame, so which figures start their entrance never depends on a resize (a tall one is trimmed to
+ // the page below, which hides nothing).
+ const page = await browser.newPage({ viewport: { width: 1440, height: HEIGHT ? Number(HEIGHT) : 8000 } });
+ await page.route("http://bench.test/**", (route) => {
+ const name = new URL(route.request().url()).pathname;
+ if (name === "/") return route.fulfill({ contentType: "text/html", body: html });
+ if (files.has(name)) return route.fulfill({ contentType: "text/javascript", body: files.get(name) });
+ return route.fulfill({ status: 404, body: "" });
+ });
+ await page.goto(`http://bench.test/${still ? "?still" : ""}`);
+ await page.waitForFunction(() => document.querySelectorAll("figure[data-measured]").length === 6, null, { timeout: 10000 });
+ await page.evaluate(() => document.fonts.ready);
+ // Every figure in view at once (unless --height asks for a window), so every loop that may run runs.
+ const height = HEIGHT ? Number(HEIGHT) : Math.min(8000, Math.ceil(await page.evaluate(() => document.querySelector("main").getBoundingClientRect().bottom + scrollY)));
+ await page.setViewportSize({ width: 1440, height });
+ // Every entrance in view to its end: the loops start when it settles. (A figure out of view stays pending: its entrance waits for the reader.)
+ if (!still) await page.waitForFunction(() => [...document.querySelectorAll("figure[data-entrance]")].every((f) => { const r = f.getBoundingClientRect(); return r.bottom <= 0 || r.top >= innerHeight || f.getAttribute("data-entrance") === "done"; }), null, { timeout: 15000, polling: 100 });
+ await page.waitForTimeout(500);
+ const state = await page.evaluate(() => ({
+ figures: document.querySelectorAll("figure").length,
+ inView: [...document.querySelectorAll("figure")].filter((f) => { const r = f.getBoundingClientRect(); return r.bottom > 0 && r.top < innerHeight; }).length,
+ pending: document.querySelectorAll("figure[data-entrance='pending']").length,
+ // A figure is moving when anything of its loops is running or shown: flow cuts are endless animations, but a pulse's and a packet's legs are finite
+ // animations run one after another, so endless ones alone undercount.
+ moving: [...document.querySelectorAll("figure")].filter((f) => f.getAnimations({ subtree: true }).some((a) => a.playState === "running") || [...f.querySelectorAll(".basalt-diagram-flow, .basalt-diagram-bead, .basalt-diagram-packet")].some((x) => getComputedStyle(x).display !== "none")).length,
+ }));
+ await browser.startTracing(page, { categories: ["devtools.timeline", "disabled-by-default-devtools.timeline"] });
+ const frames = await page.evaluate((ms) => new Promise((resolve) => {
+ const times = [];
+ const end = performance.now() + ms;
+ const step = (t) => { times.push(t); if (t < end) requestAnimationFrame(step); else resolve(times); };
+ requestAnimationFrame(step);
+ }), SECONDS * 1000);
+ const trace = JSON.parse((await browser.stopTracing()).toString("utf8"));
+ await page.close();
+ const gaps = frames.slice(1).map((t, k) => t - frames[k]).sort((a, b) => a - b);
+ const q = (p) => gaps[Math.min(gaps.length - 1, Math.floor(p * gaps.length))];
+ const events = (trace.traceEvents ?? trace).filter((e) => e.ph === "X" || e.ph === "B" || e.ph === "I" || e.ph === "i");
+ // Complete events only: an instant event of the same name (UpdateLayer has both) would count one piece of work twice.
+ const count = (name) => events.filter((e) => e.name === name && e.ph === "X").length;
+ const busy = (name) => events.filter((e) => e.name === name && e.ph === "X").reduce((sum, e) => sum + (e.dur ?? 0), 0) / 1000;
+ return {
+ mode: still ? "still" : "animated",
+ window: `1440 x ${height}`,
+ ...state,
+ seconds: SECONDS,
+ frames: frames.length - 1,
+ frameMs: { p50: +q(0.5).toFixed(2), p95: +q(0.95).toFixed(2), p99: +q(0.99).toFixed(2), max: +gaps.at(-1).toFixed(2), over20: gaps.filter((g) => g > 20).length },
+ paints: count("Paint"),
+ paintMs: +busy("Paint").toFixed(1),
+ layouts: count("Layout"),
+ layoutMs: +busy("Layout").toFixed(1),
+ styleRecalcs: count("UpdateLayoutTree"),
+ styleMs: +busy("UpdateLayoutTree").toFixed(1),
+ layerUpdates: count("UpdateLayer"),
+ // PrePaint runs every frame that is drawn, the benchmark's own requestAnimationFrame loop included: the still page's count is that floor.
+ prePaints: count("PrePaint"),
+ rasterTasks: count("RasterTask"),
+ rasterMs: +busy("RasterTask").toFixed(1),
+ };
+}
+
+const results = [await run(false), await run(true)];
+const version = browser.version();
+await browser.close();
+if (JSON_OUT) console.log(JSON.stringify(results, null, 1));
+else {
+ console.log(`Diagram paint benchmark: the five CIMIP examples animated and the kit, React production build, Chromium ${version}, ${SECONDS}s each.`);
+ for (const r of results) {
+ console.log(`\n${r.mode} (${r.window}, ${r.inView} of ${r.figures} figures in view, ${r.pending} pending, ${r.moving} moving)`);
+ console.log(` frames: ${r.frames} in ${r.seconds}s; between frames p50 ${r.frameMs.p50}ms, p95 ${r.frameMs.p95}ms, p99 ${r.frameMs.p99}ms, max ${r.frameMs.max}ms; ${r.frameMs.over20} over 20ms`);
+ console.log(` paints: ${r.paints} (${r.paintMs}ms); layouts: ${r.layouts} (${r.layoutMs}ms); style recalcs: ${r.styleRecalcs} (${r.styleMs}ms); raster tasks: ${r.rasterTasks} (${r.rasterMs}ms); layer updates: ${r.layerUpdates}; pre-paints: ${r.prePaints}`);
+ }
+}
diff --git a/packages/react/test/diagrams.test.mjs b/packages/react/test/diagrams.test.mjs
index 3f06b9dc..debc0320 100644
--- a/packages/react/test/diagrams.test.mjs
+++ b/packages/react/test/diagrams.test.mjs
@@ -239,13 +239,71 @@ describe("the fit rule (1.11) and seats (1.8)", () => {
await page.close();
});
- test("a route that would leave the drawing is not drawn: a one-column schema with a foreign key stays stacked", async () => {
+ test("a route that would leave the drawing is not drawn: a turn-back named on a first column's start side stays stacked", async () => {
+ const { page } = await diagramPage();
+ await page.evaluate(() => window.__set([{ key: "out", type: "architecture", props: { title: "Out", summary: "A turn-back off the drawing.", nodes: [
+ { id: "a", name: "A", col: 1, row: 1 }, { id: "b", name: "B", col: 2, row: 1 }, { id: "c", name: "C", col: 1, row: 2 }],
+ edges: [{ from: "a", to: "b" }, { from: "a", to: "c", fromSide: "left", toSide: "left" }] } }]));
+ await frames(page, 4);
+ assert.equal(await page.getAttribute("#fig-out", "data-layout"), "stacked");
+ assert.deepEqual((await inspect(page, "out")).problems, []);
+ await page.close();
+ });
+
+ // Neon's finding 12 on round 64 (DECISIONS 301): a schema of one column has no gutter on either side, and its turn-back was refused at every width.
+ test("a one-column schema with a foreign key is drawn: its turn-back runs space-4 out on the end side, inside the space-5 the drawing keeps there", async () => {
const { page } = await diagramPage({ viewport: { width: 640 + PAD, height: 1000 } });
- await page.evaluate(() => window.__set([{ key: "one", type: "schema", props: { title: "One", summary: "One column.", tables: [
+ await page.evaluate(() => window.__set([{ key: "one", type: "schema", props: { title: "One", summary: "One column.", legend: { plain: "A foreign key" }, tables: [
{ name: "a", col: 1, row: 1, columns: [{ name: "id", key: "PK" }] }, { name: "b", col: 1, row: 2, columns: [{ name: "a_id", key: "FK", references: "a.id" }] }] } }]));
+ for (const width of [640 + PAD, 1000, 1440]) {
+ await resize(page, width);
+ assert.equal(await page.getAttribute("#fig-one", "data-layout"), "drawn", `at ${width}`);
+ const r = await inspect(page, "one");
+ assert.deepEqual(r.problems, [], `at ${width}`);
+ const seen = await page.evaluate(() => {
+ const d = document.querySelector("#fig-one .basalt-diagram-drawing"), o = d.getBoundingClientRect();
+ const t = [...d.querySelectorAll(".basalt-diagram-node")].map((n) => n.getBoundingClientRect().right - o.left);
+ const xs = [...d.querySelectorAll(".basalt-diagram-line")].flatMap((p) => p.getAttribute("d").match(/-?[\d.]+/g).map(Number).filter((_, k) => k % 2 === 0));
+ return { pad: getComputedStyle(d).paddingRight, w: d.clientWidth, right: Math.max(...t), lane: Math.max(...xs), lines: d.querySelectorAll(".basalt-diagram-edge").length };
+ });
+ assert.equal(seen.lines, 1, `at ${width}: the foreign key's line`);
+ assert.equal(seen.pad, "20px", `at ${width}: space-5 on the end side`);
+ assert.ok(Math.abs(seen.lane - (seen.right + 16)) <= 0.5 && seen.lane + 0.5 <= seen.w, `at ${width}: the turn-back is space-4 out and inside the drawing (${JSON.stringify(seen)})`);
+ }
+ // Two columns keep their own rule and no end padding: the last column's turn-back is on its start side, in the gutter.
+ await page.evaluate(() => window.__set([{ key: "two", type: "schema", props: { title: "Two", summary: "Two columns.", legend: { plain: "A foreign key" }, tables: [
+ { name: "a", col: 1, row: 1, columns: [{ name: "id", key: "PK" }] }, { name: "b", col: 2, row: 1, columns: [{ name: "id", key: "PK" }] }, { name: "c", col: 2, row: 2, columns: [{ name: "b_id", key: "FK", references: "b.id" }] }] } }]));
+ await frames(page, 4);
+ assert.equal(await page.getAttribute("#fig-two", "data-layout"), "drawn");
+ assert.equal(await page.evaluate(() => getComputedStyle(document.querySelector("#fig-two .basalt-diagram-drawing")).paddingRight), "0px");
+ assert.deepEqual((await inspect(page, "two")).problems, []);
+ await page.close();
+ });
+
+ // Neon's blocking finding 1 on #126: two turn-backs to different keys, beside each other, were drawn on one lane.
+ test("turn-backs to different keys never lie on one another: in a gutter each takes a lane; with no gutter (one column) the schema stays stacked", async () => {
+ const { page } = await diagramPage();
+ const t = (name, col, row, refs = []) => ({ name, col, row, columns: [{ name: "id", key: "PK" }, ...refs.map((r) => ({ name: `${r}_id`, key: "FK", references: `${r}.id` }))] });
+ const schema = (key, tables) => ({ key, type: "schema", props: { title: key, summary: "Keys.", legend: { plain: "A foreign key" }, tables } });
+ await page.evaluate((list) => window.__set(list), [
+ // b to c and c to a overlap down the one column's end side.
+ schema("crossed", [t("a", 1, 1), t("b", 1, 2, ["c"]), t("c", 1, 3, ["a"])]),
+ // Two that do not overlap share the side and are drawn.
+ schema("apart", [t("a", 1, 1), t("b", 1, 2, ["a"]), t("c", 1, 3), t("d", 1, 4, ["c"])]),
+ // The same two in a last column: they turn back into the gutter, each on a lane of its own.
+ schema("gutter", [t("x", 1, 1), t("a", 2, 1), t("b", 2, 2, ["c"]), t("c", 2, 3, ["a"])]),
+ ]);
await frames(page, 4);
- assert.equal(await page.getAttribute("#fig-one", "data-layout"), "stacked");
- assert.deepEqual((await inspect(page, "one")).problems, []);
+ const lanes = (key) => page.evaluate((key) => [...document.querySelectorAll(`#fig-${key} .basalt-diagram-svg .basalt-diagram-line`)].map((p) => { const n = p.getAttribute("d").match(/-?[\d.]+/g).map(Number); return Math.min(...n.filter((_, k) => k % 2 === 0)); }), key);
+ for (const width of [1440, 1000]) {
+ await resize(page, width);
+ assert.equal(await page.getAttribute("#fig-crossed", "data-layout"), "stacked", `at ${width}: no lane for both, so no drawing`);
+ assert.equal(await page.getAttribute("#fig-apart", "data-layout"), "drawn", `at ${width}`);
+ assert.equal(await page.getAttribute("#fig-gutter", "data-layout"), "drawn", `at ${width}`);
+ for (const key of ["crossed", "apart", "gutter"]) assert.deepEqual((await inspect(page, key)).problems, [], `${key} at ${width}`);
+ const x = await lanes("gutter");
+ assert.equal(new Set(x.map((v) => Math.round(v))).size, 2, `at ${width}: two lanes in the gutter (${x})`);
+ }
await page.close();
});
diff --git a/packages/react/test/export-sizes.json b/packages/react/test/export-sizes.json
index 263e9700..3e1a4eee 100644
--- a/packages/react/test/export-sizes.json
+++ b/packages/react/test/export-sizes.json
@@ -18,7 +18,7 @@
"AppHeader": 1285,
"AppShell": 103887,
"AppTile": 1112,
- "ArchitectureDiagram": 70763,
+ "ArchitectureDiagram": 67580,
"ArrowDownGlyph": 2868,
"ArrowLeftGlyph": 2869,
"ArrowRightGlyph": 2859,
@@ -70,7 +70,7 @@
"CopyGlyph": 2884,
"Countdown": 3016,
"CoverageStrip": 1570,
- "DataFlowDiagram": 70780,
+ "DataFlowDiagram": 67597,
"DateAge": 2527,
"DescriptionColumns": 216,
"DescriptionItem": 593,
@@ -105,7 +105,7 @@
"Fieldset": 6390,
"FilterResult": 698,
"FilterToolbar": 774,
- "FlowchartDiagram": 70729,
+ "FlowchartDiagram": 67546,
"Form": 8730,
"FormGrid": 438,
"FormGridItem": 628,
@@ -224,7 +224,7 @@
"RunsGlyph": 3128,
"STATUS_MESSAGE_MS": 26,
"SandboxesGlyph": 2963,
- "SchemaDiagram": 70677,
+ "SchemaDiagram": 67494,
"SearchDialog": 88277,
"SearchField": 18301,
"SearchGlyph": 3181,
@@ -243,7 +243,7 @@
"SelectableList": 821,
"SelectionBar": 25913,
"Separator": 4531,
- "SequenceDiagram": 70725,
+ "SequenceDiagram": 67542,
"SettingsGlyph": 3100,
"ShareBar": 1411,
"Sheet": 70793,
@@ -412,11 +412,11 @@
"useWaitMark": 303
},
"package": {
- "bytes": 873383,
- "gzip": 289962
+ "bytes": 870189,
+ "gzip": 288896
},
"styles": {
- "bytes": 382498,
- "gzip": 49967
+ "bytes": 382510,
+ "gzip": 49971
}
}
diff --git a/tools/html-skill/build.mjs b/tools/html-skill/build.mjs
index 90372899..f3e59b8d 100644
--- a/tools/html-skill/build.mjs
+++ b/tools/html-skill/build.mjs
@@ -256,9 +256,12 @@ function diagramMotionCss() {
if (start < 0 || end < 0) throw new Error("html-skill: the diagram motion section of packages/react/src/styles/components.css moved; update diagramMotionCss");
return `@layer basalt {\n${react.slice(start, end).replaceAll(".basalt-diagram", ".diagram")}\n}\n`;
}
-/** A module whose source imports React's engine (the diagram module): bundled into one script, the import inlined. */
+/**
+ * A module whose source imports React's engine (the diagram module): bundled into one script, the import inlined. It is a development build of the engine
+ * (NODE_ENV "development"): the skill keeps the checks a production React build drops, since compose.mjs reports them when it writes a page.
+ */
function bundleModule(file) {
- const out = esbuild.buildSync({ entryPoints: [file], bundle: true, format: "iife", platform: "browser", target: "es2020", write: false, logLevel: "silent", legalComments: "inline", charset: "utf8" });
+ const out = esbuild.buildSync({ entryPoints: [file], bundle: true, format: "iife", platform: "browser", target: "es2020", write: false, logLevel: "silent", legalComments: "inline", charset: "utf8", define: { "process.env.NODE_ENV": '"development"' } });
return out.outputFiles[0].text;
}
diff --git a/tools/html-skill/src/modules.json b/tools/html-skill/src/modules.json
index 0659a0c4..8ea09914 100644
--- a/tools/html-skill/src/modules.json
+++ b/tools/html-skill/src/modules.json
@@ -1,5 +1,5 @@
{
- "$comment": "Which parts of the skill's CSS and JS a page gets. The core is always in. A module is in when the page's body has one of its classes, attributes or tags, matches one of its text patterns, or is named in a comment, and when another module needs it (requires). Modules are added in the order listed here, which is the order of the source files' cascade. classes: every class the module's CSS styles (the test checks them against the CSS and against SKILL.md). budget: the most bytes its minified CSS and JS may reach together. budgets: skillMd (SKILL.md, the context an agent pays: never above what it was), core (the CSS and JS of every page). icons: Phosphor names the module's script draws itself. Raised in the first parity PR (the owner's \"bring up the parity\"): forms (the number-input, search-clear and file-input chrome), disclosure (the native details marker), status (the accent reader and the forced-colours badge border), spinner (a fixed 16px ring), and the new number, range and accent modules. skillMd rose 10555 to 10900 for the new rules (number field, native chrome, the braille rule, the accent). Raised in the second parity PR (popup rows, levels and the segment's pill): segment 1400 to 3700 (the shared sliding pill: its script, 1.5 KB, and its CSS with the pill's two fallbacks), rows 3600 to 4300 (#27's plate-in-a-row geometry, the plate per level, the glide's shared plate and the forced-colours lit row, net of the removed bar), palette 9400 to 11300 (the glide's script, 2.4 KB: it follows the lit row, travels on a pointer, snaps on a key, and fades in place on leaving). The art module (DECISIONS 101 and 104) is the token groups only some pages name, taken out of the core so the core stays under its cap: the chart roles and lengths, the art colours, the aspect ratios and the stage headroom, in both themes (2087 bytes at 2100; it grows only when a token of those groups is added). A page gets it when its body names one of them, a var() in its own style included. The every-module page has no cap of its own (owner, DECISIONS 79): each part is capped, and a page carries only the parts it uses. usage: the most bytes of a module's usage text (src/usage/NAME.md; core.usage for core.md), which compose.mjs --usage prints on demand. It is context an agent pays only for the modules its page uses, so it is capped per part as SKILL.md and the CSS and script are (DECISIONS 79 and 109). Each is set a little above what its text was when the usage moved out of SKILL.md (DECISIONS 109); raising one needs a reason in the PR, and a rise of 40 to 50% is the owner's. textWords: each text pattern said in words, which compose.mjs --usage prints instead of the regular expression (one for each entry of text, in order). builds: modules a module requires whose markup its script writes, so --usage prints a line saying so instead of their usage text (the palette builds its own rows and key chips). The council's clarity check of the usage texts (all three: not yet clear) raised eight caps because the texts gained what an agent had to guess: callout 200 to 700 (the icon and one wrapper div around the title and body as markup, the four status icons, the role React's Callout renders), palette 1100 to 1300 (an item shown whole, keys as an array, keywords), stats 450 to 800 (a snippet of the figures and of the dl), tabs 500 to 650 (the unselected panels), code 250 to 450 (the markup and what each token class means), segment 150 to 300 (a click does not switch it), progress 150 to 350 (the empty span that paints the fill), theme 250 to 400 (leave the button empty), and accent 250 to 300. Topbar went down, 700 to 500, as its build detail was cut. Raised in the usage PR (the council's clarity check): palette 11300 to 11450 (the module grew 11283 to 11448, +165, about 1.5%), for the guard that makes a string `keys` warn and draw no chip instead of throwing in `keys.filter`, which the palette's usage already promised. Round 2 of the clarity check: tabs 650 to 750 (the panel's top space shown in the snippet, and that the script selects a tab on click). Raised in the site-icons and status PR (skill-parity part A, DECISIONS 106 and 107): status 1650 to 1900 (the neutral, pending and running marks, the badge's real border, and the forced-colours disc, net of the red danger word it drops) and its usage 400 to 1000 (every status in words, the word alone, running, forced colours); rows 4300 to 4450 (the profile list's seat rule and the status parts on a lit row) and its usage 300 to 600 (the profile list, with the one mistake: never an empty element for the seat). New: the links module (2671 bytes: the social row, the new-tab arrow's CSS and the script that draws it; budget 2750) and its usage (1746 bytes; cap 1850), which carries the social link, the glyph set, icon only and the new tab. Dropping Regular halves icons.json. Added in the overlay PR (skill-parity-4, batch 7 step 2, DECISIONS 108): the shared plate leaves palette.js for a glide module (the palette, a menu and the notification centre all call it), so the palette's cap went down, 11450 to 9250, and rows 4450 to 3850 (the plate's CSS moved to glide); and the overlay layer comes in as seven modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: popover (the native popup shell), menu, dialog (the dialog and alert dialog), sheet (on every side, the top one the site header's narrow menu), tooltip, toast and notifications (the centre). skillMd is unchanged in its cap (the eight new index lines fit within it); the core is unchanged in bytes. Added in the figures and charts PR (skill-parity-5, batch 7 step 3, DECISIONS 108): four modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: meter (React's Meter, CSS only, 2581 bytes), dlist (the description list, CSS only, 1265), terminal (the code block's transcript: its CSS, 3242, and the script that draws the gutter, the copy button and the replay, 4824) and chart (React's TimeChart and ChartGroup: 7313 of CSS and 23262 of script, which port chart.tsx's scale, layout, lane, labels, sentences, keyboard and table; it needs the art tokens, the table and the kbd chips, and a page without a chart carries none of it). Stats grew for the source line (budget 700 to 850, 798 bytes; its usage 800 to 950, 675 to 899 bytes, +33%, under the owner's 40 to 50%). skillMd is unchanged in its cap (four index lines fit within it); the core is unchanged in bytes. Added in the forms and selection PR (skill-parity-6, batch 7 step 4, DECISIONS 108): six modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: select (React's Select: the native select's closed trigger in every browser and, where `appearance: base-select` is shipped, the styled list with its two-line rows; a small script that says which input lit a row, 7740 bytes before it, choice (Checkbox, Radio, RadioGroup and Switch as styled native inputs; CSS only, with the first-frame rule), choice-card (ChoiceCard; CSS only), toggle (the pressed toggle's plate and check seat on .btn; CSS only), selection (a table's checkbox column: its fixed width and the script that sets aria-selected, the mixed header box and the count) and loops (the page-level hold on every loop with its switch: the held look and the script that stores it). The select's styles left forms, whose budget fell 3650 to 3250. skillMd rose 8621 to the size of its six new index lines, within its cap; the core is unchanged in bytes; compose adds the stored-hold line to the head of a page that has the loops module. Revised in the same PR (the lead's review of the build): the select gains select.js (one row is lit at a time, by whichever of the pointer and the keys moved last), and choice, toggle, selection and loops carry the first-frame rule, so a state a script sets on load (a mixed header box, the stored hold) paints at once with no crossfade. Added in the navigation and layout PR (skill-parity-7, batch 7 step 5, DECISIONS 108): five modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: glyph (Basalt's core glyphs drawn by name, at rest and selected, from a table the build works out from the drawn set; a page carries only the glyphs it names, and the drawing of a core glyph from data-glyph left the sheet module, which draws none now), nav (React's Nav: the sidebar's, the narrow menu's and More's rows, with the shared hugging pill), topbar-nav (the site header's links, one action and narrow menu, built by script from the bar's markup), app-shell (the shell, its sidebar and rail, and the app header) and tab-bar (the phone tab bar). The topbar module became the site header's bar (React's SiteHeader, DECISIONS 108: 56px with its line inside, the 44 by 44 brand target, the narrow-screen buttons, the derived sticky offset), budget 1600 to 3200 because its rules gained the app header's shared smoke, and its usage 500 to 750 (+50%) for the lockup's markup (the links, action and menu are topbar-nav's usage). Glide 3700 to 3950: the navigation's pill is a shape inside the row that the plate follows (about 200 bytes). The core's usage 2000 to 2100 (+5%): h2 is the Section step, the prose column's measure, and a link already 44px tall needs no margin. skillMd rose 9317 to 9863 for five index lines, under its cap; the core CSS grew 38 bytes (the layout tokens replace raw lengths, the gutter is one derived property, h2, .prose and .lead follow foundations) and the core script is unchanged. A module's media query writes %bp-md%, %bp-lg% or %bp-container% and the build substitutes the breakpoint tokens. Added in the tables and filters PR (skill-parity-8, batch 7 step 6, DECISIONS 108): the existing table module gains React's table additions (DECISIONS 95: the row header, \"Not observed\", the row density and the scroll hint with its small script), budget 1400 to 3000 (it was 1134 bytes of CSS; it is 2168 of CSS and 693 of script) and its usage 700 to 950 (+36%); and two modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: still-table (React's Table with `columns`: the fixed layout from a colgroup, the whole header cell as the sort button with its reserved seat, aria-sort, the pinned columns and their divider, the empty row; 4767 of CSS and 3264 of script, budget 8200) and filter (React's MultiSelect and FilterResult: the chips, the trigger and checklist with the search band from ten values, Clear held in place, the one debounced result line, and the narrowing of a table by `data-column`; 8240 of CSS and 7978 of script, budget 16400; it needs the popover, glide, glyph and choice modules). The core is unchanged in bytes. skillMd rose 9863 to 10128 for two index lines and the CaretUpDown icon's name, within its cap. Added in the commands PR (skill-parity-9, batch 7 step 7, DECISIONS 103 and 108): one new module a page carries only when it uses it, command-list (React's CommandList: the command panel set in the page, list plus preview, the push; it extends the palette and needs rows, kbd and glide; 5229 of CSS and 8734 of script, budget 14000, usage 2150). Two-line rows come to the existing modules: rows 3850 to 5350 (the described row's grid and description line, the push's chevron: 1481 bytes of CSS, the same rules React's menu rows carry), palette 9250 to 9900 (its rows are one function the list shares, with the description and the two-tier ranking of title matches over keyword and description matches; +636) and its usage 1300 to 1350, rows' usage 600 to 800, and glide 3950 to 4000 (a host that is idle counts as having no lit row, +54). skillMd rose 10128 to 10259 for one index line, within its cap; the core's CSS grew 24 bytes (.split.aside takes size-list-width in place of its raw 20rem: the same 320px, so no pixel moves) and the core script is unchanged. Added in the art PR (skill-parity-10, batch 7 step 8, DECISIONS 104 and 108): two modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: stage (React's Stage and PairedArt: full-bleed art under the site header, the pull-up by the sticky offset, the headroom, the paired art that follows the page's theme, and the forced-colours and print rules; CSS only, 1179 bytes) and framed-art (React's FramedArt: the figure, its rim and radius, the reserved box, the placeholder and the failed alt, the caption and credit; 2208 bytes of CSS and the 733-byte script that sets the frame's phase); both need the art tokens. The bar stays smoked over a stage: React clears it only over a stage that passed the headroom test helper, and a page has no test run (DECISIONS 108's note), so the skill builds no clear state. skillMd rose 10259 to 10500 for two index lines, within its cap; the core is unchanged in bytes. The callout gained the status rim in the same PR (DECISIONS 82, D8's status callouts): success, warning and danger draw their border in the status colour at 45% mixed in sRGB over the callout's own level, one solid colour on every side, and CanvasText in forced colours with the icon; the status colour is now one property the icon and the rim read. Its budget rose 900 to 1150 (the module is 1089 bytes, from 792: +297, about 37%); its usage is unchanged. Added in the overlays-and-the-rest PR (skill-parity-11, batch 7 step 9, DECISIONS 90 and 108): the last two parts of D8's part 5, each a module a page carries only when it uses it, with its own cap and usage cap set a little above its size: combobox (React's Combobox: the input with its caret button inside, the popup of the menu's rows with the glide's shared plate and two-line options, the filtering, the keys, the hidden value, the empty message and the check; 4342 of CSS and 6423 of script, budget 10900, usage 2150; it needs forms, popover and glide, and builds the last two) and sparkline (React's Sparkline: the label and latest value, the line, the axis, the empty sentence and the loading line that breathes; 1609 of CSS and 1874 of script, budget 3600, usage 950). The combobox copies the menu's row rules, as the select's list does, because React's Combobox renders MenuItem rows (a 40px hit area, a 36px plate) and the skill's .row is the palette's 44px: it carries no menu script. popover.js gains the combobox popup in the list of popups that keep focus where it is (+21 bytes, within its cap). skillMd rose 10500 to 10724 for two index lines, within its cap; the core is unchanged in bytes. Added in the motion-rules PR (DECISIONS 136 and 139): one module, ambient (a page's one ambient loop: CSS 828 bytes, script 433, budget 1300, usage 800), taken out of loops so the hold's own module grows only by the icon toggle's glyph swap (loops 2000 to 2200, +10%; its usage 1300 to 1650 for the icon form and the new settings-row sentence, +27%); and the chart's entrance (`entrance: true`: the marks' animations, their conditions and the redraw that restarts them at the elapsed time, 23262 to 25299 bytes of script; budget 30700 to 32800, +7%, usage 2500 to 2950, +18%). The core grew by the three tokens (27704 to 27862 bytes of CSS, under its cap). its stage usage gained the ambient art's line (1650 to 1750, +6%). skillMd rose 10724 to the size of the ambient index line, within its cap. Raised again in the motion-rules amendment (DECISIONS 143): chart 32800 to 33800 (script 25299 to 26375 bytes, +4%; +10% over the 30700 it began with) for the glide a new data set makes mid-entrance, print settling it, and `Basalt.pageChange()`; its usage 2950 to 3150 (+26% over the 2500 it began with). Raised in the second motion-rules amendment (DECISIONS 148): chart 33800 to 34400 (script 26375 to 26970 bytes: a line and its markers glide from their drawn geometry, and `beforeprint` settles the entrance; +12% over the 30700 it began with); topbar-nav 6900 to 7500 (+8.7%: the narrow menu's pause row, its CSS and 275 bytes of script, DECISIONS 148 item 2); loops usage 1650 to 1800 (+38% over the 1300 it began with, for the icon form's `title` and the menu row). Raised in the audit-design-b PR (DECISIONS 138 and 139): still-table 8200 to 13400 (+63%: the module was 7927 bytes and is 13311; the cut cell's plate, its focus stops and its dismissal, ported from React's cell-peek.ts, are 4273 bytes of script and 1111 of CSS; a still table that truncates needs them). The same PR: core usage 2100 to 2250 (+7%: the skip link, one bullet), forms usage 350 to 480 (+37%: the required mark), still-table usage 1950 to 2150 (+10%: the cut cell and the width rule), notifications usage 1050 to 1100 (+5%: the 44px entry on touch). The skip link's rim and radius took the core 30457 to 30609 bytes, under its cap (the rules that hang it under the bar are the topbar module's: 3200 to 3600, +12.5%); core 30720 to 31050 (+1.1%, DECISIONS 147: also the bar's links left out of the rule: the pseudo-element that makes a short standalone link a 44 by 44 target), skip-link script in the topbar module (3200 to 4150 over this PR, +30%: the rules that hang the link under the bar, 3600, and the script that reads the bar's real edge, 4150), sparkline 3600 to 4050 (+12.5%: React's ticker structure, so the value copies once on its line, and in forced colours the strips go and the number is plain text), forms budget 3250 to 3500 (+7.7%: the necessity word), notifications 9050 to 9250 (+2.2%: the 44px entry). Raised in the audit-design-b PR's E2 port (DECISIONS 138 and 139: the core set draws check, close, the chevrons, copy, plus, minus and search wherever a component draws them): the modules that drew a Phosphor icon for one of those now carry the core glyph's whole SVG, written in at build time (`%glyph-svg:name%`, the markup the glyph module's `_.glyph(name)` returns, so no module needs the glyph module and a page pays for nothing it does not use), and the Phosphor path of the same icon leaves the page. Each module's own bytes rose by that markup, and a page's total moved by what the Phosphor path it no longer carries saves: menu 8600 to 8900 (+303), combobox 10900 to 11200 (+303), copy 1900 to 2400 (+640), terminal 8100 to 8850 (+761), toast 13850 to 14150 (+325), number 2900 to 3400 (+557), filter 16400 to 17050 (+785), palette 9900 to 10450 (+536); the command list shares the palette's search drawing and fell 20 bytes. Set in integration-nov15, where the type-layout, motion-rules and audit-design-b branches meet: the combined tree measured SKILL.md 10959 bytes (each side's cap was 10900: both added index lines), core 31192 bytes (caps 30720 and 31050: the page-row and display rules, the three motion tokens and the skip link and 44px target rules all land in the core CSS) and core usage 2348 bytes (caps 2300 and 2250: type-layout's line and the skip-link bullet), so each is set to the measured bytes rounded up to the next 50: skillMd 10900 to 11000, core 31050 to 31200, core usage 2300 to 2350. Raised in the audit-design PR (decisions 138 and 139, parts A, D and C11): core 30720 to 31600 (+2.9%: the more-contrast block and its three aliases, and the field boundary token, every page carries as React does; the shadow-pill token is gone; the script gained `reserve`, 240 bytes), segment 3700 to 4100 and tabs 2300 to 2700 (the chosen label is 600 against 400, its width reserved by a span that carries its own copy, drawn unseen at 600; the pill's drop shadow is gone), and the segment's usage 300 to 380 (the weight and the glyph-only button). Raised again in the audit-design-a amendment (decision 145): core 31600 to 32300 (reserve() also reserves a label that is not plain text), segment 4100 to 5100 and tabs 2700 to 3500 (the second copy of such a label, and an icon drawn in both its forms), glyph 1100 to 1300 (a glyph in a segment or tab is drawn in both forms). Raised in the second audit-design-a amendment (decision 149): core 32300 to 32800 (reserve() builds the second copy of a label without any id, name, reference or hidden control, and does not copy a frame or media), segment 5100 to 5400 and its usage 380 to 500 (the 600 is on the label, the one-line rule and the usage text); the still-table cap is back at 8200, as the wash is on every cell again. Return 3 of the audit-design-a build (decision 149): tabs 3500 to 3700 (a tab the script has not reserved is 600 itself when selected, and one it declined is marked; the same two lines are in segment, which stays under 5400). Raised in the audit-fix-c2 PR (engineering, no pixel changes): toast 13850 to 14350 (the module was 13789 bytes and is 14288, +499, 3.6%) for F6, which focuses the Notifications region and Shift+Tab or Escape from it (or from the first toast) leaves it for where focus came from (and keeps a dialog's focus trap from wrapping it), as Base UI's viewport does in React, and for placing the region from focus (in the modal that holds it, or in the body), so a toast is never under a backdrop or in an inert modal whatever order the modals opened in (A3-09); the palette module grew 9864 to 9897 of its 9900 so that a palette opened over a modal sits inside it; topbar 3200 to 3250 (3123 to 3233, +110) for the scroll margin on what the bar holds, so a Tab into the bar from a scrolled page does not scroll the page (React's rule from PR #66); stage usage 1650 to 1750 (1580 to 1713, +8%) for the art's new place in the markup, after the content (A1-09), the stage's own CSS rising 1179 to 1208 within its 1250. skillMd rose 10724 to 10876 for the sentence that says a body may carry head tags, within its 10900. compose.mjs, the tool an agent runs, has no cap here (it is never in a page): it grew 21673 to 38153 bytes for the tokenizer that reads a body as HTML does and the head tags. Raised in the site-parts PR (DECISIONS 146, round 39), which folds each new part into the module it belongs with, so SKILL.md gains no index line (it has 41 bytes under its cap and a new module needs about 100): topbar 4150 to 17600 (+13450: the site footer and its disclosures, the lockup by pixel density, and a bar that arrives or leaves and returns, with its observer; a page that has a .topbar and no footer carries them too: the alternative, a module for each, needs its own index line and so SKILL.md bytes) and its usage 950 to 2900 (the footer's markup, the lockup's and the phase's); theme 650 to 4550 (the three-word theme choice: its CSS 2230 bytes and its script, 2277, with arrows, storage and the system listener) and its usage 400 to 1150 (the choice's markup written in full, so the right word is chosen before any script); segment 3700 to 3800 (a radio group's checked state besides a pressed button); stage 1250 to 2150 (its first script, 768 bytes, for fit and anchor) and its usage 1750 to 2000; framed-art 3000 to 3900 (drawn art in the frame: fit, anchor, no scaling strokes) and its usage 1250 to 1400. SKILL.md rose 10959 to 10992 (the topbar and theme index lines name .site-footer and .theme-choice). The head's theme line also writes data-theme-choice. Raised in site-parts return 2 (DECISIONS 146 B1 and B4): theme 4550 to 5350 (+800: the icon form of the theme choice, [data-theme-menu], whose button shows the theme in use, is named for the choice and opens the page's own .menu of three radio rows, in the theme script's 3073 bytes; the menu and popover modules are the page's, brought by its markup, so no module line was added and SKILL.md is 10993 of 11000) and its usage 1150 to 2200 (+91%: the menu's markup is written in full, and the deprecated toggle is said once); app-shell usage 2000 to 2100 and topbar-nav usage 1900 to 1950 (the theme control leaves the bar's text; the tools and the end cluster come in). The two example bodies still carry the deprecated data-theme-toggle. Return 2, F3 (DECISIONS 146 F): stage 2150 to 2250 (script 842 bytes: slice is the stage's default, as a frame's, and a drawing's own preserveAspectRatio stands unless the stage names data-fit or data-anchor) and its usage 2000 to 2150. framed-art 3900 to 4000 (a drawing's own preserveAspectRatio stands unless the figure names data-fit or data-anchor, +101 bytes). Return 3: theme 5350 to 5900 (script +569 bytes: who wrote data-theme, so System follows the system's change live and a theme the page set by hand, or a .dark or .light root, survives it). Raised in the controls port (DECISIONS 154): skillMd 11000 to 11200 for two index lines (link-tabs and option-chips, 214 bytes together), and core 31200 to 31600 for the nine tokens the port adds to every page's token CSS (the control rungs 44 to 64, two container widths, the confirm hold and the amount's opacity, 311 bytes). New modules (DECISIONS 154): link-tabs 2700 (its sizes, the 640 container step, the forced-colours underline, and the select that replaces the row under 720 with its 590-byte script, A15; it requires the select module), option-chips 5700 (the chip's states each written for a native radio inside a label, which needs :has on every one, plus the 1 KB script that keeps an aria-disabled chip reachable and never chosen). Return 3 (DECISIONS 154 conformance): link-tabs 2700 to 3100 and its usage 1650 to 1850 (the select's height for each row size, and a script that reads aria-current when it is needed and watches it move: 3,048 bytes), option-chips 5700 to 6700 (each state written twice, as a state attribute and as :has(), so no browser needs :has(): 4,975 CSS and 1,623 script). Return 4 (DECISIONS 158, Q2): link-tabs 3100 to 4300 and its usage 1850 to 2400 (the \"Go to\" label drawn at the select's start with its measured clearance, the select's accessible name kept as the words and the chosen page's, and the key hold that keeps a letter or an arrow on the closed select from navigating: 4,174 bytes, CSS 2,951 and script 1,223). Raised in the links-and-rows port (DECISIONS 152; the owner's approval is the lead's to confirm): the new link-rows module (5050 bytes of CSS, 50 of them for Castle's big-row arrow stepping colour over duration-fast, return 1, 1500 of usage: the directory's and the big rows' CSS, whose arrow is a core glyph drawn as a mask, and their tokens, size-row taken out of the core like type-layout's), disclosure 1550 to 3500 (Show all: the track, the clip and the settle, 1.5 KB of script and 1.8 KB of CSS), copy 2400 to 3500 (the form with words: the one cell and its script). SKILL.md rose 10959 to 10997 for one line, within its 11000 cap. Raised in the charts port PR (DECISIONS 153, D7a): chart 34400 to 34650 (script 26970 to 27270 bytes, +1.1% on the 34283 it was: `Basalt.trailingMean`, the trend maths React exports as `trailingMean`, 300 bytes), its usage 3150 to 3350 (+6%: one line for it). The tokens the batch adds (chart-lit-top, -mid and -base in both themes, size-chart-plot-sm, size-chart-row, size-meter-marker and radius-2xs) took the art module 2087 to 2546 bytes (budget 2100 to 2600, +24%: the chart tokens are its group) and the core 31192 to 31250 (cap 31200 to 31300, +0.3%: radius-2xs). Only D7a names a skill module in the charts ballot; the lit marks, the headline frame, the phase chart, the share bar, the coverage strip, the marks row and the range meter are React-only in this batch. Added in the overlays-and-search PR (DECISIONS 155, D10b and D13a): the sheet gains React's head, body and foot (the 44px close, the 20/28 title over a 13px count, the divider and the safe areas; its CSS 3.6 to 5.2 KB, budget 4050 to 5250, +30%) and its usage 1050 to 1450 (+38%: the anatomy and the step's focus, two bullets); and one new module a page carries only when it uses it, search (React's SearchDialog: the form, the field's -2 outline, the count line, the fixed-height results area and the rows with their picture slots and full-bleed hover wash; CSS only, 4368 bytes, budget 4400, usage 2050; it requires the dialog). The dialog's title draws no ring when script focuses it. skillMd rose 10959 to 11079 for the search line (the sheet's line is unchanged: its usage carries the anatomy), so its cap rose 11000 to 11100 (+0.9%). The core's CSS grew 31192 to 31421 bytes for the six new size tokens (the wide dialog, the search trigger and the logo and picture slots of a search result): its cap rose 31200 to 31450 (+0.8%). The two 44px values (the sheet's close and the search field) are local to their modules, with a lint exception that says they join the controls batch's size token (DECISIONS 154). Set in integration-nov15b, where audit-design-a, audit-fix-c2, site-parts, port-controls, port-links-rows, port-charts and port-overlays-search meet: the combined tree measured SKILL.md 11560 bytes (the caps were 11000, 11100 and 11200: each side added index lines), core 34086 bytes (caps 31300 to 33550: every side's rules land in the core CSS and script), topbar 17660 (17600 from site-parts, plus audit-fix-c2's skip-link and focus work), number 3453 (3400), palette 11379 (11000, audit-fix-c2's hosted scrim plus the core search glyph), dialog 5120 (5100), toast 15692 (15400) and stage usage 2248 (2150), each over every side's cap, so each is set to the measured bytes rounded up to the next 50: skillMd 11200 to 11600, core 33550 to 34100, topbar 17600 to 17700, number 3400 to 3500, palette 11000 to 11400, dialog 5100 to 5150, toast 15400 to 15700, stage usage 2150 to 2250. The segment cap is the base's 5400 plus port-controls' 100 (5500), unchanged by the merge. Raised in integration-nov15b, join 2 (a link tab takes the selected state, DECISIONS 138 A, 145, 149 and 154's D12 row): link-tabs 4300 to 5750 (+34%: the module was 4174 bytes and is 5736; the 600 against 400, the reserved width and the second copy of a composed label, an icon drawn in both its forms, the same rules a tab carries, 1,530 bytes of CSS and script) and its usage 2400 to 2550 (+6%: one bullet). The cap is the measured bytes rounded up to the next 50; a module that needs the tab's rules carries them as the segment and tabs modules do, so a page without link tabs pays nothing. Raised in the panels, art and parts port (DECISIONS 162): table 3000 to 3150 and its usage 950 to 1450 (the flat form and the two-line cell), stage 2250 to 2600 and its usage 2250 to 3100 (the closing block: its held art, forced colours and print; its section gap is type-layout's --basalt-section-gap, which a page with data-closing brings), the new app-tile 4300 (a 120-point polygon clip and the hairline's mask of the same outline), captioned 2000 and period 1400; skillMd 11600 to 11950 for one index line each for captioned, app-tile and period (358 bytes; the file is 11918). Raised in the logs, status and forms port (DECISIONS 162): core 34100 to 34200 (the new size-field-label-inline token, 80px, is written into every page's tokens: 25 bytes); dlist 1300 to 1900 and its usage 950 to 1060 (the stacked form, R9 and R10: a title over its text, 20px between entries, no divider; one usage line). Raised in audit-fix-c6 (the owner's cap, raised by the builder and for the owner to confirm): glyph 1300 to 1900, for redrawing a glyph when its ancestor's aria-current or data-current moves (the lists that hold glyphs are watched). Raised in the colour-ink-ladder build (DECISIONS 166): core 34200 to 34350 (the four lifted dark inks are four new primitives, each written into every page's tokens: the core measured 34307). Raised in the audit-2-design build (DECISIONS 167, Q7a): disclosure 3500 to 3800 (the core chevron drawn as a mask in place of two borders: the module measured 3755). Joined in the integration of c7 (#86) and c10 (#91): option-chips 6750 to 6850 (c7's reset resync and c10's data-ready together measure 6839). Raised in table-sort-3 (DECISIONS 257 and 261, the owner's pick: three sort states, the arrow after the label, explainers on column titles): still-table 13400 to 14650 (+9.3%: the module was 13343 bytes and is 14602; the end-aligned label's move by a transform, its right-to-left sign and the indicator that waits for it on a fine pointer, 912 bytes of CSS; the third state, the sort from the table's own order and a .explainer kept out of the button, 347 bytes of script) and its usage 2150 to 2250 (2197: the third state and the own order); the new explainer module 5850 (5842: a manual native popover opened from the sort button on hover, keyboard focus and a long press, placed above the header or beside it, 1752 bytes of CSS and 4090 of script; a page without explainers pays nothing) and its usage 900; skillMd 12250 to 12400 for the explainer's index line (113 bytes; the file is 12352). Each cap is the measured bytes rounded up to the next 50. Raised in table-sort-3's fix pass (Astra's review): explainer 5850 to 6900 (+18%: 5842 to 6864 bytes; the gap between the header and the card kept while a pointer crosses it, the close when its header leaves the view whatever has focus, the dismissal held until pointer and focus have both left, and its page-wide listeners and timers scoped to an open card and stopped when the table leaves the page, 1,022 bytes of script). Raised in cimip-gaps-2 batch B5 (the touch sizes under 720 whatever the pointer: each coarse-pointer target rule also answers a window under 720, about 20 bytes a rule; forms merged its three into one and stays under 3500): select 9000 to 9100 (measured 9064), selection 1480 to 1500 (1486), filter 17450 to 17500 (17473), option-chips 6850 to 6900 (6853), menu 8900 to 8950 (8902). B5 fix pass 1 (Astra): core 34550 to 34950 (measured 34911: 30762 CSS and 4149 JS) for stacked links in a column, each giving up the side of its 44px box that meets a neighbour, so a tap on a link's words is always that link's; core had 12 bytes free. DECISIONS 274 (the owner's pick: under 720 the toast stack hangs from the bar): toast 15700 to 16050 (measured 16035; 8 bytes were free; the stack's direction became one sign variable, trimming 585 of the 920 bytes the phone form first took). B5 merged with main (5ad5345a): main's own core measured 34930 against its 34550 cap before B5; with B5 (the touch sizes under 720 and stacked links in a column) it is 35331, so core is 35350; nav 5350 to 5400 (measured 5364: B4's nav plus the touch size under 720). The full run after the stream (DECISIONS 246): the site footer's links keep their own flex column under 720, as React's, out of the bare-link touch rule (26 bytes), so core is 35400 (measured 35357); sheet 5250 to 5400 (measured 5368: React's B5 ring room, ported: the held actions reach space-1-5 above their band, clipped, and the body keeps space-1-5 at each end). Raised for diagram motion and service marks (DECISIONS 292): skillMd 12550 to 12650 for the diagram-motion module's one line; diagram 87200 to 91000 for what a still diagram now carries (a card's mark and its seat, the pending frame, the comparison that writes a drawing only when it changed, and the print rule), and its usage 2600 to 4300 for the decision's four lines and the list of mark ids; the new diagram-motion module (the motion engine, its stylesheet and the motion tokens, in a page only when a diagram is animated) at 26200. Raised when the diagram tests were first run (DECISIONS 298): diagram 91000 to 91250 and diagram-motion 26200 to 26850. Fix round 1 of #124 had already taken them to 91205 and 26621 with the tests unrun; this round added 1 byte (every focal node prints its fill; a one-form mark's dark form falls back to its light one) and 180 (the entrance keeps its own clock when it is drawn again while paused).",
+ "$comment": "Which parts of the skill's CSS and JS a page gets. The core is always in. A module is in when the page's body has one of its classes, attributes or tags, matches one of its text patterns, or is named in a comment, and when another module needs it (requires). Modules are added in the order listed here, which is the order of the source files' cascade. classes: every class the module's CSS styles (the test checks them against the CSS and against SKILL.md). budget: the most bytes its minified CSS and JS may reach together. budgets: skillMd (SKILL.md, the context an agent pays: never above what it was), core (the CSS and JS of every page). icons: Phosphor names the module's script draws itself. Raised in the first parity PR (the owner's \"bring up the parity\"): forms (the number-input, search-clear and file-input chrome), disclosure (the native details marker), status (the accent reader and the forced-colours badge border), spinner (a fixed 16px ring), and the new number, range and accent modules. skillMd rose 10555 to 10900 for the new rules (number field, native chrome, the braille rule, the accent). Raised in the second parity PR (popup rows, levels and the segment's pill): segment 1400 to 3700 (the shared sliding pill: its script, 1.5 KB, and its CSS with the pill's two fallbacks), rows 3600 to 4300 (#27's plate-in-a-row geometry, the plate per level, the glide's shared plate and the forced-colours lit row, net of the removed bar), palette 9400 to 11300 (the glide's script, 2.4 KB: it follows the lit row, travels on a pointer, snaps on a key, and fades in place on leaving). The art module (DECISIONS 101 and 104) is the token groups only some pages name, taken out of the core so the core stays under its cap: the chart roles and lengths, the art colours, the aspect ratios and the stage headroom, in both themes (2087 bytes at 2100; it grows only when a token of those groups is added). A page gets it when its body names one of them, a var() in its own style included. The every-module page has no cap of its own (owner, DECISIONS 79): each part is capped, and a page carries only the parts it uses. usage: the most bytes of a module's usage text (src/usage/NAME.md; core.usage for core.md), which compose.mjs --usage prints on demand. It is context an agent pays only for the modules its page uses, so it is capped per part as SKILL.md and the CSS and script are (DECISIONS 79 and 109). Each is set a little above what its text was when the usage moved out of SKILL.md (DECISIONS 109); raising one needs a reason in the PR, and a rise of 40 to 50% is the owner's. textWords: each text pattern said in words, which compose.mjs --usage prints instead of the regular expression (one for each entry of text, in order). builds: modules a module requires whose markup its script writes, so --usage prints a line saying so instead of their usage text (the palette builds its own rows and key chips). The council's clarity check of the usage texts (all three: not yet clear) raised eight caps because the texts gained what an agent had to guess: callout 200 to 700 (the icon and one wrapper div around the title and body as markup, the four status icons, the role React's Callout renders), palette 1100 to 1300 (an item shown whole, keys as an array, keywords), stats 450 to 800 (a snippet of the figures and of the dl), tabs 500 to 650 (the unselected panels), code 250 to 450 (the markup and what each token class means), segment 150 to 300 (a click does not switch it), progress 150 to 350 (the empty span that paints the fill), theme 250 to 400 (leave the button empty), and accent 250 to 300. Topbar went down, 700 to 500, as its build detail was cut. Raised in the usage PR (the council's clarity check): palette 11300 to 11450 (the module grew 11283 to 11448, +165, about 1.5%), for the guard that makes a string `keys` warn and draw no chip instead of throwing in `keys.filter`, which the palette's usage already promised. Round 2 of the clarity check: tabs 650 to 750 (the panel's top space shown in the snippet, and that the script selects a tab on click). Raised in the site-icons and status PR (skill-parity part A, DECISIONS 106 and 107): status 1650 to 1900 (the neutral, pending and running marks, the badge's real border, and the forced-colours disc, net of the red danger word it drops) and its usage 400 to 1000 (every status in words, the word alone, running, forced colours); rows 4300 to 4450 (the profile list's seat rule and the status parts on a lit row) and its usage 300 to 600 (the profile list, with the one mistake: never an empty element for the seat). New: the links module (2671 bytes: the social row, the new-tab arrow's CSS and the script that draws it; budget 2750) and its usage (1746 bytes; cap 1850), which carries the social link, the glyph set, icon only and the new tab. Dropping Regular halves icons.json. Added in the overlay PR (skill-parity-4, batch 7 step 2, DECISIONS 108): the shared plate leaves palette.js for a glide module (the palette, a menu and the notification centre all call it), so the palette's cap went down, 11450 to 9250, and rows 4450 to 3850 (the plate's CSS moved to glide); and the overlay layer comes in as seven modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: popover (the native popup shell), menu, dialog (the dialog and alert dialog), sheet (on every side, the top one the site header's narrow menu), tooltip, toast and notifications (the centre). skillMd is unchanged in its cap (the eight new index lines fit within it); the core is unchanged in bytes. Added in the figures and charts PR (skill-parity-5, batch 7 step 3, DECISIONS 108): four modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: meter (React's Meter, CSS only, 2581 bytes), dlist (the description list, CSS only, 1265), terminal (the code block's transcript: its CSS, 3242, and the script that draws the gutter, the copy button and the replay, 4824) and chart (React's TimeChart and ChartGroup: 7313 of CSS and 23262 of script, which port chart.tsx's scale, layout, lane, labels, sentences, keyboard and table; it needs the art tokens, the table and the kbd chips, and a page without a chart carries none of it). Stats grew for the source line (budget 700 to 850, 798 bytes; its usage 800 to 950, 675 to 899 bytes, +33%, under the owner's 40 to 50%). skillMd is unchanged in its cap (four index lines fit within it); the core is unchanged in bytes. Added in the forms and selection PR (skill-parity-6, batch 7 step 4, DECISIONS 108): six modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: select (React's Select: the native select's closed trigger in every browser and, where `appearance: base-select` is shipped, the styled list with its two-line rows; a small script that says which input lit a row, 7740 bytes before it, choice (Checkbox, Radio, RadioGroup and Switch as styled native inputs; CSS only, with the first-frame rule), choice-card (ChoiceCard; CSS only), toggle (the pressed toggle's plate and check seat on .btn; CSS only), selection (a table's checkbox column: its fixed width and the script that sets aria-selected, the mixed header box and the count) and loops (the page-level hold on every loop with its switch: the held look and the script that stores it). The select's styles left forms, whose budget fell 3650 to 3250. skillMd rose 8621 to the size of its six new index lines, within its cap; the core is unchanged in bytes; compose adds the stored-hold line to the head of a page that has the loops module. Revised in the same PR (the lead's review of the build): the select gains select.js (one row is lit at a time, by whichever of the pointer and the keys moved last), and choice, toggle, selection and loops carry the first-frame rule, so a state a script sets on load (a mixed header box, the stored hold) paints at once with no crossfade. Added in the navigation and layout PR (skill-parity-7, batch 7 step 5, DECISIONS 108): five modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: glyph (Basalt's core glyphs drawn by name, at rest and selected, from a table the build works out from the drawn set; a page carries only the glyphs it names, and the drawing of a core glyph from data-glyph left the sheet module, which draws none now), nav (React's Nav: the sidebar's, the narrow menu's and More's rows, with the shared hugging pill), topbar-nav (the site header's links, one action and narrow menu, built by script from the bar's markup), app-shell (the shell, its sidebar and rail, and the app header) and tab-bar (the phone tab bar). The topbar module became the site header's bar (React's SiteHeader, DECISIONS 108: 56px with its line inside, the 44 by 44 brand target, the narrow-screen buttons, the derived sticky offset), budget 1600 to 3200 because its rules gained the app header's shared smoke, and its usage 500 to 750 (+50%) for the lockup's markup (the links, action and menu are topbar-nav's usage). Glide 3700 to 3950: the navigation's pill is a shape inside the row that the plate follows (about 200 bytes). The core's usage 2000 to 2100 (+5%): h2 is the Section step, the prose column's measure, and a link already 44px tall needs no margin. skillMd rose 9317 to 9863 for five index lines, under its cap; the core CSS grew 38 bytes (the layout tokens replace raw lengths, the gutter is one derived property, h2, .prose and .lead follow foundations) and the core script is unchanged. A module's media query writes %bp-md%, %bp-lg% or %bp-container% and the build substitutes the breakpoint tokens. Added in the tables and filters PR (skill-parity-8, batch 7 step 6, DECISIONS 108): the existing table module gains React's table additions (DECISIONS 95: the row header, \"Not observed\", the row density and the scroll hint with its small script), budget 1400 to 3000 (it was 1134 bytes of CSS; it is 2168 of CSS and 693 of script) and its usage 700 to 950 (+36%); and two modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: still-table (React's Table with `columns`: the fixed layout from a colgroup, the whole header cell as the sort button with its reserved seat, aria-sort, the pinned columns and their divider, the empty row; 4767 of CSS and 3264 of script, budget 8200) and filter (React's MultiSelect and FilterResult: the chips, the trigger and checklist with the search band from ten values, Clear held in place, the one debounced result line, and the narrowing of a table by `data-column`; 8240 of CSS and 7978 of script, budget 16400; it needs the popover, glide, glyph and choice modules). The core is unchanged in bytes. skillMd rose 9863 to 10128 for two index lines and the CaretUpDown icon's name, within its cap. Added in the commands PR (skill-parity-9, batch 7 step 7, DECISIONS 103 and 108): one new module a page carries only when it uses it, command-list (React's CommandList: the command panel set in the page, list plus preview, the push; it extends the palette and needs rows, kbd and glide; 5229 of CSS and 8734 of script, budget 14000, usage 2150). Two-line rows come to the existing modules: rows 3850 to 5350 (the described row's grid and description line, the push's chevron: 1481 bytes of CSS, the same rules React's menu rows carry), palette 9250 to 9900 (its rows are one function the list shares, with the description and the two-tier ranking of title matches over keyword and description matches; +636) and its usage 1300 to 1350, rows' usage 600 to 800, and glide 3950 to 4000 (a host that is idle counts as having no lit row, +54). skillMd rose 10128 to 10259 for one index line, within its cap; the core's CSS grew 24 bytes (.split.aside takes size-list-width in place of its raw 20rem: the same 320px, so no pixel moves) and the core script is unchanged. Added in the art PR (skill-parity-10, batch 7 step 8, DECISIONS 104 and 108): two modules a page carries only when it uses them, each with its own cap and usage cap set a little above its size: stage (React's Stage and PairedArt: full-bleed art under the site header, the pull-up by the sticky offset, the headroom, the paired art that follows the page's theme, and the forced-colours and print rules; CSS only, 1179 bytes) and framed-art (React's FramedArt: the figure, its rim and radius, the reserved box, the placeholder and the failed alt, the caption and credit; 2208 bytes of CSS and the 733-byte script that sets the frame's phase); both need the art tokens. The bar stays smoked over a stage: React clears it only over a stage that passed the headroom test helper, and a page has no test run (DECISIONS 108's note), so the skill builds no clear state. skillMd rose 10259 to 10500 for two index lines, within its cap; the core is unchanged in bytes. The callout gained the status rim in the same PR (DECISIONS 82, D8's status callouts): success, warning and danger draw their border in the status colour at 45% mixed in sRGB over the callout's own level, one solid colour on every side, and CanvasText in forced colours with the icon; the status colour is now one property the icon and the rim read. Its budget rose 900 to 1150 (the module is 1089 bytes, from 792: +297, about 37%); its usage is unchanged. Added in the overlays-and-the-rest PR (skill-parity-11, batch 7 step 9, DECISIONS 90 and 108): the last two parts of D8's part 5, each a module a page carries only when it uses it, with its own cap and usage cap set a little above its size: combobox (React's Combobox: the input with its caret button inside, the popup of the menu's rows with the glide's shared plate and two-line options, the filtering, the keys, the hidden value, the empty message and the check; 4342 of CSS and 6423 of script, budget 10900, usage 2150; it needs forms, popover and glide, and builds the last two) and sparkline (React's Sparkline: the label and latest value, the line, the axis, the empty sentence and the loading line that breathes; 1609 of CSS and 1874 of script, budget 3600, usage 950). The combobox copies the menu's row rules, as the select's list does, because React's Combobox renders MenuItem rows (a 40px hit area, a 36px plate) and the skill's .row is the palette's 44px: it carries no menu script. popover.js gains the combobox popup in the list of popups that keep focus where it is (+21 bytes, within its cap). skillMd rose 10500 to 10724 for two index lines, within its cap; the core is unchanged in bytes. Added in the motion-rules PR (DECISIONS 136 and 139): one module, ambient (a page's one ambient loop: CSS 828 bytes, script 433, budget 1300, usage 800), taken out of loops so the hold's own module grows only by the icon toggle's glyph swap (loops 2000 to 2200, +10%; its usage 1300 to 1650 for the icon form and the new settings-row sentence, +27%); and the chart's entrance (`entrance: true`: the marks' animations, their conditions and the redraw that restarts them at the elapsed time, 23262 to 25299 bytes of script; budget 30700 to 32800, +7%, usage 2500 to 2950, +18%). The core grew by the three tokens (27704 to 27862 bytes of CSS, under its cap). its stage usage gained the ambient art's line (1650 to 1750, +6%). skillMd rose 10724 to the size of the ambient index line, within its cap. Raised again in the motion-rules amendment (DECISIONS 143): chart 32800 to 33800 (script 25299 to 26375 bytes, +4%; +10% over the 30700 it began with) for the glide a new data set makes mid-entrance, print settling it, and `Basalt.pageChange()`; its usage 2950 to 3150 (+26% over the 2500 it began with). Raised in the second motion-rules amendment (DECISIONS 148): chart 33800 to 34400 (script 26375 to 26970 bytes: a line and its markers glide from their drawn geometry, and `beforeprint` settles the entrance; +12% over the 30700 it began with); topbar-nav 6900 to 7500 (+8.7%: the narrow menu's pause row, its CSS and 275 bytes of script, DECISIONS 148 item 2); loops usage 1650 to 1800 (+38% over the 1300 it began with, for the icon form's `title` and the menu row). Raised in the audit-design-b PR (DECISIONS 138 and 139): still-table 8200 to 13400 (+63%: the module was 7927 bytes and is 13311; the cut cell's plate, its focus stops and its dismissal, ported from React's cell-peek.ts, are 4273 bytes of script and 1111 of CSS; a still table that truncates needs them). The same PR: core usage 2100 to 2250 (+7%: the skip link, one bullet), forms usage 350 to 480 (+37%: the required mark), still-table usage 1950 to 2150 (+10%: the cut cell and the width rule), notifications usage 1050 to 1100 (+5%: the 44px entry on touch). The skip link's rim and radius took the core 30457 to 30609 bytes, under its cap (the rules that hang it under the bar are the topbar module's: 3200 to 3600, +12.5%); core 30720 to 31050 (+1.1%, DECISIONS 147: also the bar's links left out of the rule: the pseudo-element that makes a short standalone link a 44 by 44 target), skip-link script in the topbar module (3200 to 4150 over this PR, +30%: the rules that hang the link under the bar, 3600, and the script that reads the bar's real edge, 4150), sparkline 3600 to 4050 (+12.5%: React's ticker structure, so the value copies once on its line, and in forced colours the strips go and the number is plain text), forms budget 3250 to 3500 (+7.7%: the necessity word), notifications 9050 to 9250 (+2.2%: the 44px entry). Raised in the audit-design-b PR's E2 port (DECISIONS 138 and 139: the core set draws check, close, the chevrons, copy, plus, minus and search wherever a component draws them): the modules that drew a Phosphor icon for one of those now carry the core glyph's whole SVG, written in at build time (`%glyph-svg:name%`, the markup the glyph module's `_.glyph(name)` returns, so no module needs the glyph module and a page pays for nothing it does not use), and the Phosphor path of the same icon leaves the page. Each module's own bytes rose by that markup, and a page's total moved by what the Phosphor path it no longer carries saves: menu 8600 to 8900 (+303), combobox 10900 to 11200 (+303), copy 1900 to 2400 (+640), terminal 8100 to 8850 (+761), toast 13850 to 14150 (+325), number 2900 to 3400 (+557), filter 16400 to 17050 (+785), palette 9900 to 10450 (+536); the command list shares the palette's search drawing and fell 20 bytes. Set in integration-nov15, where the type-layout, motion-rules and audit-design-b branches meet: the combined tree measured SKILL.md 10959 bytes (each side's cap was 10900: both added index lines), core 31192 bytes (caps 30720 and 31050: the page-row and display rules, the three motion tokens and the skip link and 44px target rules all land in the core CSS) and core usage 2348 bytes (caps 2300 and 2250: type-layout's line and the skip-link bullet), so each is set to the measured bytes rounded up to the next 50: skillMd 10900 to 11000, core 31050 to 31200, core usage 2300 to 2350. Raised in the audit-design PR (decisions 138 and 139, parts A, D and C11): core 30720 to 31600 (+2.9%: the more-contrast block and its three aliases, and the field boundary token, every page carries as React does; the shadow-pill token is gone; the script gained `reserve`, 240 bytes), segment 3700 to 4100 and tabs 2300 to 2700 (the chosen label is 600 against 400, its width reserved by a span that carries its own copy, drawn unseen at 600; the pill's drop shadow is gone), and the segment's usage 300 to 380 (the weight and the glyph-only button). Raised again in the audit-design-a amendment (decision 145): core 31600 to 32300 (reserve() also reserves a label that is not plain text), segment 4100 to 5100 and tabs 2700 to 3500 (the second copy of such a label, and an icon drawn in both its forms), glyph 1100 to 1300 (a glyph in a segment or tab is drawn in both forms). Raised in the second audit-design-a amendment (decision 149): core 32300 to 32800 (reserve() builds the second copy of a label without any id, name, reference or hidden control, and does not copy a frame or media), segment 5100 to 5400 and its usage 380 to 500 (the 600 is on the label, the one-line rule and the usage text); the still-table cap is back at 8200, as the wash is on every cell again. Return 3 of the audit-design-a build (decision 149): tabs 3500 to 3700 (a tab the script has not reserved is 600 itself when selected, and one it declined is marked; the same two lines are in segment, which stays under 5400). Raised in the audit-fix-c2 PR (engineering, no pixel changes): toast 13850 to 14350 (the module was 13789 bytes and is 14288, +499, 3.6%) for F6, which focuses the Notifications region and Shift+Tab or Escape from it (or from the first toast) leaves it for where focus came from (and keeps a dialog's focus trap from wrapping it), as Base UI's viewport does in React, and for placing the region from focus (in the modal that holds it, or in the body), so a toast is never under a backdrop or in an inert modal whatever order the modals opened in (A3-09); the palette module grew 9864 to 9897 of its 9900 so that a palette opened over a modal sits inside it; topbar 3200 to 3250 (3123 to 3233, +110) for the scroll margin on what the bar holds, so a Tab into the bar from a scrolled page does not scroll the page (React's rule from PR #66); stage usage 1650 to 1750 (1580 to 1713, +8%) for the art's new place in the markup, after the content (A1-09), the stage's own CSS rising 1179 to 1208 within its 1250. skillMd rose 10724 to 10876 for the sentence that says a body may carry head tags, within its 10900. compose.mjs, the tool an agent runs, has no cap here (it is never in a page): it grew 21673 to 38153 bytes for the tokenizer that reads a body as HTML does and the head tags. Raised in the site-parts PR (DECISIONS 146, round 39), which folds each new part into the module it belongs with, so SKILL.md gains no index line (it has 41 bytes under its cap and a new module needs about 100): topbar 4150 to 17600 (+13450: the site footer and its disclosures, the lockup by pixel density, and a bar that arrives or leaves and returns, with its observer; a page that has a .topbar and no footer carries them too: the alternative, a module for each, needs its own index line and so SKILL.md bytes) and its usage 950 to 2900 (the footer's markup, the lockup's and the phase's); theme 650 to 4550 (the three-word theme choice: its CSS 2230 bytes and its script, 2277, with arrows, storage and the system listener) and its usage 400 to 1150 (the choice's markup written in full, so the right word is chosen before any script); segment 3700 to 3800 (a radio group's checked state besides a pressed button); stage 1250 to 2150 (its first script, 768 bytes, for fit and anchor) and its usage 1750 to 2000; framed-art 3000 to 3900 (drawn art in the frame: fit, anchor, no scaling strokes) and its usage 1250 to 1400. SKILL.md rose 10959 to 10992 (the topbar and theme index lines name .site-footer and .theme-choice). The head's theme line also writes data-theme-choice. Raised in site-parts return 2 (DECISIONS 146 B1 and B4): theme 4550 to 5350 (+800: the icon form of the theme choice, [data-theme-menu], whose button shows the theme in use, is named for the choice and opens the page's own .menu of three radio rows, in the theme script's 3073 bytes; the menu and popover modules are the page's, brought by its markup, so no module line was added and SKILL.md is 10993 of 11000) and its usage 1150 to 2200 (+91%: the menu's markup is written in full, and the deprecated toggle is said once); app-shell usage 2000 to 2100 and topbar-nav usage 1900 to 1950 (the theme control leaves the bar's text; the tools and the end cluster come in). The two example bodies still carry the deprecated data-theme-toggle. Return 2, F3 (DECISIONS 146 F): stage 2150 to 2250 (script 842 bytes: slice is the stage's default, as a frame's, and a drawing's own preserveAspectRatio stands unless the stage names data-fit or data-anchor) and its usage 2000 to 2150. framed-art 3900 to 4000 (a drawing's own preserveAspectRatio stands unless the figure names data-fit or data-anchor, +101 bytes). Return 3: theme 5350 to 5900 (script +569 bytes: who wrote data-theme, so System follows the system's change live and a theme the page set by hand, or a .dark or .light root, survives it). Raised in the controls port (DECISIONS 154): skillMd 11000 to 11200 for two index lines (link-tabs and option-chips, 214 bytes together), and core 31200 to 31600 for the nine tokens the port adds to every page's token CSS (the control rungs 44 to 64, two container widths, the confirm hold and the amount's opacity, 311 bytes). New modules (DECISIONS 154): link-tabs 2700 (its sizes, the 640 container step, the forced-colours underline, and the select that replaces the row under 720 with its 590-byte script, A15; it requires the select module), option-chips 5700 (the chip's states each written for a native radio inside a label, which needs :has on every one, plus the 1 KB script that keeps an aria-disabled chip reachable and never chosen). Return 3 (DECISIONS 154 conformance): link-tabs 2700 to 3100 and its usage 1650 to 1850 (the select's height for each row size, and a script that reads aria-current when it is needed and watches it move: 3,048 bytes), option-chips 5700 to 6700 (each state written twice, as a state attribute and as :has(), so no browser needs :has(): 4,975 CSS and 1,623 script). Return 4 (DECISIONS 158, Q2): link-tabs 3100 to 4300 and its usage 1850 to 2400 (the \"Go to\" label drawn at the select's start with its measured clearance, the select's accessible name kept as the words and the chosen page's, and the key hold that keeps a letter or an arrow on the closed select from navigating: 4,174 bytes, CSS 2,951 and script 1,223). Raised in the links-and-rows port (DECISIONS 152; the owner's approval is the lead's to confirm): the new link-rows module (5050 bytes of CSS, 50 of them for Castle's big-row arrow stepping colour over duration-fast, return 1, 1500 of usage: the directory's and the big rows' CSS, whose arrow is a core glyph drawn as a mask, and their tokens, size-row taken out of the core like type-layout's), disclosure 1550 to 3500 (Show all: the track, the clip and the settle, 1.5 KB of script and 1.8 KB of CSS), copy 2400 to 3500 (the form with words: the one cell and its script). SKILL.md rose 10959 to 10997 for one line, within its 11000 cap. Raised in the charts port PR (DECISIONS 153, D7a): chart 34400 to 34650 (script 26970 to 27270 bytes, +1.1% on the 34283 it was: `Basalt.trailingMean`, the trend maths React exports as `trailingMean`, 300 bytes), its usage 3150 to 3350 (+6%: one line for it). The tokens the batch adds (chart-lit-top, -mid and -base in both themes, size-chart-plot-sm, size-chart-row, size-meter-marker and radius-2xs) took the art module 2087 to 2546 bytes (budget 2100 to 2600, +24%: the chart tokens are its group) and the core 31192 to 31250 (cap 31200 to 31300, +0.3%: radius-2xs). Only D7a names a skill module in the charts ballot; the lit marks, the headline frame, the phase chart, the share bar, the coverage strip, the marks row and the range meter are React-only in this batch. Added in the overlays-and-search PR (DECISIONS 155, D10b and D13a): the sheet gains React's head, body and foot (the 44px close, the 20/28 title over a 13px count, the divider and the safe areas; its CSS 3.6 to 5.2 KB, budget 4050 to 5250, +30%) and its usage 1050 to 1450 (+38%: the anatomy and the step's focus, two bullets); and one new module a page carries only when it uses it, search (React's SearchDialog: the form, the field's -2 outline, the count line, the fixed-height results area and the rows with their picture slots and full-bleed hover wash; CSS only, 4368 bytes, budget 4400, usage 2050; it requires the dialog). The dialog's title draws no ring when script focuses it. skillMd rose 10959 to 11079 for the search line (the sheet's line is unchanged: its usage carries the anatomy), so its cap rose 11000 to 11100 (+0.9%). The core's CSS grew 31192 to 31421 bytes for the six new size tokens (the wide dialog, the search trigger and the logo and picture slots of a search result): its cap rose 31200 to 31450 (+0.8%). The two 44px values (the sheet's close and the search field) are local to their modules, with a lint exception that says they join the controls batch's size token (DECISIONS 154). Set in integration-nov15b, where audit-design-a, audit-fix-c2, site-parts, port-controls, port-links-rows, port-charts and port-overlays-search meet: the combined tree measured SKILL.md 11560 bytes (the caps were 11000, 11100 and 11200: each side added index lines), core 34086 bytes (caps 31300 to 33550: every side's rules land in the core CSS and script), topbar 17660 (17600 from site-parts, plus audit-fix-c2's skip-link and focus work), number 3453 (3400), palette 11379 (11000, audit-fix-c2's hosted scrim plus the core search glyph), dialog 5120 (5100), toast 15692 (15400) and stage usage 2248 (2150), each over every side's cap, so each is set to the measured bytes rounded up to the next 50: skillMd 11200 to 11600, core 33550 to 34100, topbar 17600 to 17700, number 3400 to 3500, palette 11000 to 11400, dialog 5100 to 5150, toast 15400 to 15700, stage usage 2150 to 2250. The segment cap is the base's 5400 plus port-controls' 100 (5500), unchanged by the merge. Raised in integration-nov15b, join 2 (a link tab takes the selected state, DECISIONS 138 A, 145, 149 and 154's D12 row): link-tabs 4300 to 5750 (+34%: the module was 4174 bytes and is 5736; the 600 against 400, the reserved width and the second copy of a composed label, an icon drawn in both its forms, the same rules a tab carries, 1,530 bytes of CSS and script) and its usage 2400 to 2550 (+6%: one bullet). The cap is the measured bytes rounded up to the next 50; a module that needs the tab's rules carries them as the segment and tabs modules do, so a page without link tabs pays nothing. Raised in the panels, art and parts port (DECISIONS 162): table 3000 to 3150 and its usage 950 to 1450 (the flat form and the two-line cell), stage 2250 to 2600 and its usage 2250 to 3100 (the closing block: its held art, forced colours and print; its section gap is type-layout's --basalt-section-gap, which a page with data-closing brings), the new app-tile 4300 (a 120-point polygon clip and the hairline's mask of the same outline), captioned 2000 and period 1400; skillMd 11600 to 11950 for one index line each for captioned, app-tile and period (358 bytes; the file is 11918). Raised in the logs, status and forms port (DECISIONS 162): core 34100 to 34200 (the new size-field-label-inline token, 80px, is written into every page's tokens: 25 bytes); dlist 1300 to 1900 and its usage 950 to 1060 (the stacked form, R9 and R10: a title over its text, 20px between entries, no divider; one usage line). Raised in audit-fix-c6 (the owner's cap, raised by the builder and for the owner to confirm): glyph 1300 to 1900, for redrawing a glyph when its ancestor's aria-current or data-current moves (the lists that hold glyphs are watched). Raised in the colour-ink-ladder build (DECISIONS 166): core 34200 to 34350 (the four lifted dark inks are four new primitives, each written into every page's tokens: the core measured 34307). Raised in the audit-2-design build (DECISIONS 167, Q7a): disclosure 3500 to 3800 (the core chevron drawn as a mask in place of two borders: the module measured 3755). Joined in the integration of c7 (#86) and c10 (#91): option-chips 6750 to 6850 (c7's reset resync and c10's data-ready together measure 6839). Raised in table-sort-3 (DECISIONS 257 and 261, the owner's pick: three sort states, the arrow after the label, explainers on column titles): still-table 13400 to 14650 (+9.3%: the module was 13343 bytes and is 14602; the end-aligned label's move by a transform, its right-to-left sign and the indicator that waits for it on a fine pointer, 912 bytes of CSS; the third state, the sort from the table's own order and a .explainer kept out of the button, 347 bytes of script) and its usage 2150 to 2250 (2197: the third state and the own order); the new explainer module 5850 (5842: a manual native popover opened from the sort button on hover, keyboard focus and a long press, placed above the header or beside it, 1752 bytes of CSS and 4090 of script; a page without explainers pays nothing) and its usage 900; skillMd 12250 to 12400 for the explainer's index line (113 bytes; the file is 12352). Each cap is the measured bytes rounded up to the next 50. Raised in table-sort-3's fix pass (Astra's review): explainer 5850 to 6900 (+18%: 5842 to 6864 bytes; the gap between the header and the card kept while a pointer crosses it, the close when its header leaves the view whatever has focus, the dismissal held until pointer and focus have both left, and its page-wide listeners and timers scoped to an open card and stopped when the table leaves the page, 1,022 bytes of script). Raised in cimip-gaps-2 batch B5 (the touch sizes under 720 whatever the pointer: each coarse-pointer target rule also answers a window under 720, about 20 bytes a rule; forms merged its three into one and stays under 3500): select 9000 to 9100 (measured 9064), selection 1480 to 1500 (1486), filter 17450 to 17500 (17473), option-chips 6850 to 6900 (6853), menu 8900 to 8950 (8902). B5 fix pass 1 (Astra): core 34550 to 34950 (measured 34911: 30762 CSS and 4149 JS) for stacked links in a column, each giving up the side of its 44px box that meets a neighbour, so a tap on a link's words is always that link's; core had 12 bytes free. DECISIONS 274 (the owner's pick: under 720 the toast stack hangs from the bar): toast 15700 to 16050 (measured 16035; 8 bytes were free; the stack's direction became one sign variable, trimming 585 of the 920 bytes the phone form first took). B5 merged with main (5ad5345a): main's own core measured 34930 against its 34550 cap before B5; with B5 (the touch sizes under 720 and stacked links in a column) it is 35331, so core is 35350; nav 5350 to 5400 (measured 5364: B4's nav plus the touch size under 720). The full run after the stream (DECISIONS 246): the site footer's links keep their own flex column under 720, as React's, out of the bare-link touch rule (26 bytes), so core is 35400 (measured 35357); sheet 5250 to 5400 (measured 5368: React's B5 ring room, ported: the held actions reach space-1-5 above their band, clipped, and the body keeps space-1-5 at each end). Raised for diagram motion and service marks (DECISIONS 292): skillMd 12550 to 12650 for the diagram-motion module's one line; diagram 87200 to 91000 for what a still diagram now carries (a card's mark and its seat, the pending frame, the comparison that writes a drawing only when it changed, and the print rule), and its usage 2600 to 4300 for the decision's four lines and the list of mark ids; the new diagram-motion module (the motion engine, its stylesheet and the motion tokens, in a page only when a diagram is animated) at 26200. Raised when the diagram tests were first run (DECISIONS 298): diagram 91000 to 91250 and diagram-motion 26200 to 26850. Raised in batch A of the diagrams backlog (DECISIONS 301): diagram 91250 to 92400, for the engine fixes it bundles (a decision kept no taller than it is wide, labels on whole pixels, slots beside a straight line, a one-column schema's turn-back); the skill keeps the development checks a production React build now drops. Raised again in that batch's review fixes: diagram 92400 to 92650, for the drawn layout refusing two lines laid on one another (Neon's blocking finding 1 on #126). Fix round 1 of #124 had already taken them to 91205 and 26621 with the tests unrun; this round added 1 byte (every focal node prints its fill; a one-form mark's dark form falls back to its light one) and 180 (the entrance keeps its own clock when it is drawn again while paused).",
"budgets": {
"skillMd": 12650,
"core": 35400
@@ -778,7 +778,7 @@
"art",
"kbd"
],
- "budget": 91250,
+ "budget": 92650,
"usage": 4300,
"builds": [
"kbd"
diff --git a/tools/html-skill/test/diagram-motion.test.mjs b/tools/html-skill/test/diagram-motion.test.mjs
index dd3dfec9..b1966e82 100644
--- a/tools/html-skill/test/diagram-motion.test.mjs
+++ b/tools/html-skill/test/diagram-motion.test.mjs
@@ -1,7 +1,7 @@
// The skill's diagram motion and service marks (DECISIONS 292): what compose.mjs writes (the diagram-motion module only for an animated diagram, one rule a
// mark a page names, a page's own mark read into the file), and the module in a page: pending until in view, the entrance, settling, the hold, print, and
// a one-form mark written once. Written when test runs were paused (DECISIONS 271); fixed and run when the owner lifted the skip for diagrams
-// (DECISIONS 298). React's and the skill's figures at rest drawing the same pixels is not yet here.
+// (DECISIONS 298). React's and the skill's figures at rest drawing the same pixels, and the skill's send queue, were added in batch A (DECISIONS 301).
import assert from "node:assert/strict";
import fs from "node:fs";
import os from "node:os";
@@ -10,11 +10,13 @@ import { after, before, describe, test } from "node:test";
import { compose } from "../../../.agent/skills/basalt-html/compose.mjs";
import { animated, FIGURES, kit, STILL } from "../../../packages/react/test/diagram-motion-fixture.mjs";
+import { fixturePage, launch as launchReact, pkg } from "../../../packages/react/test/support.mjs";
import { launch, openHtml } from "./support.mjs";
let browser;
-before(async () => { browser = await launch(); });
-after(async () => { await browser?.close(); });
+let reactBrowser;
+before(async () => { browser = await launch(); reactBrowser = await launchReact(); });
+after(async () => { await browser?.close(); await reactBrowser?.close(); });
const figure = (spec, id) => ``;
const page = (figs, gap = 0) => `Motion${figs.join("")}`;
@@ -135,3 +137,103 @@ describe("the module in a page", () => {
assert.ok(print.length === kit().nodes.filter((n) => n.mark).length && print.every((v) => v === "exact"), JSON.stringify(print));
});
});
+
+describe("batch A (DECISIONS 301)", () => {
+ test("Basalt.diagram's sends: with a packet in flight one waits and a second is dropped, so two messages land", async () => {
+ const spec = (send) => ({ ...animated("dataFlow"), packet: { path: ["send", "append", "row", "hear", "see"], send } });
+ const { page: p, errors } = await openHtml(browser, compose(page([figure(spec(0), "fig-send")])).html);
+ await p.evaluate(() => { const f = document.getElementById("fig-send"); f.setAttribute("data-entrance", "done"); f.dispatchEvent(new Event("basalt-diagram-settle")); });
+ const send = (n) => p.evaluate((s) => window.Basalt.diagram(document.getElementById("fig-send"), s), spec(n));
+ await send(1);
+ await p.waitForFunction(() => { const d = document.querySelector("#fig-send .diagram-packet"); return d && getComputedStyle(d).display !== "none"; }, null, { polling: "raf", timeout: 3000 });
+ await send(2);
+ await send(3);
+ let landed = 0, lit = false;
+ for (let k = 0; k < 400; k++) {
+ await p.evaluate(() => { for (const a of document.getElementById("fig-send").getAnimations({ subtree: true })) if (a.playState === "running" && a.effect?.getComputedTiming().iterations !== Infinity) a.finish(); });
+ await p.evaluate(() => new Promise((r) => requestAnimationFrame(r)));
+ const now = await p.evaluate(() => document.querySelector("#fig-send [data-node='see']").hasAttribute("data-arrival"));
+ if (now && !lit) landed++;
+ lit = now;
+ }
+ assert.equal(landed, 2);
+ assert.deepEqual(errors, []);
+ });
+
+ // React's host for one animated example: the fixture's data with its motion keys, and each mark id turned into its module, as an app imports them.
+ const MANIFEST = JSON.parse(fs.readFileSync(path.join(pkg, "marks", "manifest.json"), "utf8"));
+ const exportName = (id) => id.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
+ const REACT = `
+${MANIFEST.marks.map((m) => `import { ${exportName(m.id)} } from "./dist/marks/${m.id}.js";`).join("\n")}
+const MARKS = { ${MANIFEST.marks.map((m) => `"${m.id}": ${exportName(m.id)}`).join(", ")} };
+const C = { architecture: B.ArchitectureDiagram, flowchart: B.FlowchartDiagram, "data-flow": B.DataFlowDiagram, sequence: B.SequenceDiagram, schema: B.SchemaDiagram };
+function Host() {
+ const [spec, setSpec] = React.useState(null);
+ window.__set = (next) => flushSync(() => setSpec(next));
+ if (!spec) return null;
+ const { type, ...props } = spec;
+ if (props.nodes) props.nodes = props.nodes.map((n) => (typeof n.mark === "string" ? { ...n, mark: MARKS[n.mark] } : n));
+ const X = C[type];
+ return ;
+}
+createRoot(document.getElementById("root")).render();`;
+ const font = (file) => fs.readFileSync(path.join(pkg, "dist", "fonts", file)).toString("base64");
+ const FONTS = `@font-face{font-family:"Geist";src:url(data:font/woff2;base64,${font("Geist-Variable.woff2")}) format("woff2");font-weight:100 900}@font-face{font-family:"Geist Mono";src:url(data:font/woff2;base64,${font("GeistMono-Variable.woff2")}) format("woff2");font-weight:100 900}`;
+ const frames = (p, n) => p.evaluate((n) => new Promise((resolve) => { let k = 0; const step = () => (++k >= n ? resolve() : requestAnimationFrame(step)); requestAnimationFrame(step); }), n);
+ /** The drawing's pixels, read from a screenshot of it, with its size. */
+ /** The drawing's screenshot and its place on the page (not in the window, which a tall figure scrolls). */
+ const shot = async (p, prefix) => {
+ const loc = p.locator(`#fig-x .${prefix}-drawing`);
+ await loc.scrollIntoViewIfNeeded();
+ const box = await loc.evaluate((el) => { const r = el.getBoundingClientRect(); return { x: r.x + scrollX, y: r.y + scrollY, w: r.width, h: r.height }; });
+ return { box, png: await loc.screenshot({ type: "png" }) };
+ };
+ /** Two screenshots of one size, decoded in a page only when their files differ: how many pixels differ, and the first. */
+ const pixelDiff = (p, a, b) => p.evaluate(async ([a, b]) => {
+ const read = async (b64) => { const img = new Image(); img.src = `data:image/png;base64,${b64}`; await img.decode(); const c = document.createElement("canvas"); c.width = img.width; c.height = img.height; const ctx = c.getContext("2d"); ctx.drawImage(img, 0, 0); return { w: img.width, d: ctx.getImageData(0, 0, img.width, img.height).data }; };
+ const [x, y] = [await read(a), await read(b)];
+ let n = 0, first = null;
+ for (let k = 0; k < x.d.length; k += 4) if (x.d[k] !== y.d[k] || x.d[k + 1] !== y.d[k + 1] || x.d[k + 2] !== y.d[k + 2]) { n++; first ??= [(k / 4) % x.w, Math.floor(k / 4 / x.w)]; }
+ return { n, first };
+ }, [a.toString("base64"), b.toString("base64")]);
+ /** At rest: the hold settles the entrance and clears the loops to rest, every line whole; then nothing finite is left running. */
+ const atRest = async (p) => {
+ await p.waitForFunction(() => { const f = document.getElementById("fig-x"); return f && f.hasAttribute("data-measured") && (!f.querySelector("[class$='-svg']") || f.getAttribute("data-entrance") === "done"); }, null, { polling: "raf", timeout: 5000 });
+ await frames(p, 6);
+ await p.evaluate(() => Promise.all(document.getAnimations().filter((a) => a.effect?.getComputedTiming().iterations !== Infinity).map((a) => a.finished.catch(() => {}))));
+ };
+
+ for (const theme of ["dark", "light"]) {
+ test(`${theme}: React and the skill draw the same pixels for each animated example and the kit at rest (under the hold, settled)`, async () => {
+ const diff = [];
+ // React: one app page for every example (bundling it is most of the cost), as the still parity test gives it: border-box, the body's ink and type,
+ // and the text rendering and language the skill's core sets, which a pixel comparison of words must share.
+ const react = await fixturePage(reactBrowser, REACT, { theme, viewport: { width: 1440, height: 1000 }, standards: true });
+ await react.page.addStyleTag({ content: `${FONTS} *, ::before, ::after { box-sizing: border-box; } html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; text-size-adjust: 100%; } body { margin: 0; background: var(--basalt-surface-0); color: var(--basalt-text-primary); font: var(--basalt-font-weight-regular) var(--basalt-text-base-size) / var(--basalt-text-base-line-height) var(--basalt-font-family-sans); } #root{display:block}` });
+ await react.page.evaluate(() => { document.documentElement.lang = "en"; document.documentElement.setAttribute("data-loops", "held"); });
+ await react.page.evaluate(() => document.fonts.ready);
+ for (const key of [...FIGURES, "kit"]) {
+ const spec = key === "kit" ? kit() : animated(key);
+ // The skill: the page composed, one figure, held.
+ const skill = await openHtml(browser, compose(page([figure(spec, "fig-x")])).html, { scheme: theme, width: 1440 });
+ await skill.page.evaluate(() => document.documentElement.setAttribute("data-loops", "held"));
+ await atRest(skill.page);
+ // React: the figure drawn afresh on the one page.
+ await react.page.evaluate(() => window.__set(null));
+ await react.page.evaluate((s) => window.__set(s), spec);
+ await atRest(react.page);
+ const [a, b] = [await shot(skill.page, "diagram"), await shot(react.page, "basalt-diagram")];
+ if (["x", "y", "w", "h"].some((k) => Math.abs(a.box[k] - b.box[k]) > 0.01)) diff.push(`${key}: the drawing is ${JSON.stringify(a.box)} in the skill and ${JSON.stringify(b.box)} in React`);
+ else if (!a.png.equals(b.png)) {
+ const { n, first } = await pixelDiff(skill.page, a.png, b.png);
+ if (n) diff.push(`${key}: ${n} pixels differ, the first at ${first}`);
+ }
+ assert.deepEqual(skill.errors, []);
+ await skill.context.close();
+ }
+ assert.deepEqual(react.errors, []);
+ await react.page.close();
+ assert.deepEqual(diff, []);
+ });
+ }
+});