diff --git a/.agent/skills/basalt-html/parts/diagram-export.css b/.agent/skills/basalt-html/parts/diagram-export.css new file mode 100644 index 00000000..8673e6f1 --- /dev/null +++ b/.agent/skills/basalt-html/parts/diagram-export.css @@ -0,0 +1 @@ +@layer basalt{.diagram-export-note{flex:0 0 100%;margin:0;color:var(--basalt-text-secondary);font:var(--basalt-font-weight-regular) var(--basalt-text-xs-size) / var(--basalt-text-xs-line-height) var(--basalt-font-family-sans);text-wrap:balance}.diagram-viewer-row>.diagram-export-note{text-align:end}@media(forced-colors:active){.diagram-export-note{color:CanvasText}}} diff --git a/.agent/skills/basalt-html/parts/diagram-export.js b/.agent/skills/basalt-html/parts/diagram-export.js index fc495eaf..ebccaa33 100644 --- a/.agent/skills/basalt-html/parts/diagram-export.js +++ b/.agent/skills/basalt-html/parts/diagram-export.js @@ -1 +1 @@ -(()=>{var q="http://www.w3.org/2000/svg",C=t=>t.replace(/[&<>"']/g,s=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[s]),k=t=>!!t&&t!=="transparent"&&!/rgba\([^)]*,\s*0\)$/.test(t)&&!/\/\s*0\)$/.test(t),h=t=>Math.round(t*100)/100;function G(t){const s=l=>t.querySelector(`:scope > [class$="-${l}"], :scope > [class*="-${l} "]`);return["head","drawing","key"].map(s).filter(l=>!!(l&&l.getClientRects().length))}async function j(t){for(const s of Array.from(document.styleSheets)){let l;try{l=s.cssRules}catch{continue}for(const c of Array.from(l)){if(!(c instanceof CSSFontFaceRule)||c.style.getPropertyValue("font-family").replace(/["']/g,"").trim()!==t)continue;const e=/url\(["']?([^"')]+)["']?\)/.exec(c.style.getPropertyValue("src"))?.[1];if(e){if(e.startsWith("data:"))return e;try{const n=await fetch(new URL(e,s.href??location.href));if(!n.ok)return null;const o=await n.blob();return await new Promise((d,i)=>{const a=new FileReader;a.onload=()=>d(String(a.result)),a.onerror=i,a.readAsDataURL(o)})}catch{return null}}}}return null}function I(t,s,l){const c=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let e=c.nextNode();e;e=c.nextNode()){const n=e.parentElement;if(!n||!e.textContent?.trim()||n.closest("[aria-hidden='true'] .basalt-visually-hidden, .basalt-visually-hidden, .visually-hidden, [class$='-ruler'], [hidden]"))continue;const o=getComputedStyle(n);if(o.visibility==="hidden"||o.display==="none")continue;const d=e.textContent,i=document.createRange();for(const a of d.matchAll(/\S+/g)){i.setStart(e,a.index),i.setEnd(e,a.index+a[0].length);const m=i.getBoundingClientRect();if(!m.width)continue;const f=Number.parseFloat(o.fontSize),b=m.top-s.top+(m.height-f)/2+f*.8;l.push(`${C(a[0])}`)}}}function z(t,s,l){if(/-(lane|band|felse)(\s|$)/.test(` ${t.getAttribute("class")??""}`))for(const c of["::before","::after"]){const e=getComputedStyle(t,c);if(!e.content||e.content==="none"||e.content==="normal"||e.display==="none"||e.position!=="absolute")continue;const n=t.getBoundingClientRect(),o=getComputedStyle(t),d=n.left+(Number.parseFloat(o.borderLeftWidth)||0)+(Number.parseFloat(e.left)||0)-s.left,i=n.top+(Number.parseFloat(o.borderTopWidth)||0)+(Number.parseFloat(e.top)||0)-s.top,a=Number.parseFloat(e.width)||0,m=Number.parseFloat(e.height)||0,f=Number.parseFloat(e.borderTopWidth)||0,b=e.maskImage&&e.maskImage!=="none"?` stroke-dasharray="${Number.parseFloat(e.maskSize)/2||4} ${Number.parseFloat(e.maskSize)/2||4}"`:"";k(e.backgroundColor)&&a&&m?l.push(``):f&&k(e.borderTopColor)&&l.push(``)}}function O(t,s,l){const c=t.getBoundingClientRect();if(!c.width||!c.height||t.getAttribute("class")?.endsWith("-motion-defs"))return;const e=t.cloneNode(!0),n=[t,...Array.from(t.querySelectorAll("*"))],o=[e,...Array.from(e.querySelectorAll("*"))],d=t.viewBox?.baseVal,i=!!(d&&d.width&&(Math.abs(d.width-c.width)>.5||Math.abs(d.height-c.height)>.5));n.forEach((a,m)=>{const f=getComputedStyle(a),b=o[m];for(const w of["fill","stroke","stroke-width","stroke-dasharray","stroke-linecap","stroke-linejoin","opacity"])b.setAttribute(w,f.getPropertyValue(w));b.removeAttribute("class"),/-reveal-/.test(b.getAttribute("mask")??"")&&b.removeAttribute("mask"),i&&m>0&&b.setAttribute("vector-effect","non-scaling-stroke"),f.display==="none"&&b.setAttribute("display","none")}),e.setAttribute("x",String(h(c.left-s.left))),e.setAttribute("y",String(h(c.top-s.top))),e.setAttribute("width",String(h(c.width))),e.setAttribute("height",String(h(c.height))),e.removeAttribute("style"),l.push(e.outerHTML)}function D(t,s,l){const c=[t,...Array.from(t.querySelectorAll("*"))],e=c.filter(n=>n instanceof SVGSVGElement&&n.closest("svg")===n&&!!n.closest("[class$='-ink']"));for(const n of e)O(n,s,l);for(const n of c){if(n instanceof SVGElement){if(n.tagName.toLowerCase()!=="svg"||n.closest("svg")!==n||e.includes(n))continue;O(n,s,l);continue}const o=getComputedStyle(n);if(o.display==="none"||o.visibility==="hidden")continue;const d=n.getBoundingClientRect();if(!d.width||!d.height)continue;const i=h(d.left-s.left),a=h(d.top-s.top),m=h(d.width),f=h(d.height),b=Number.parseFloat(o.borderTopLeftRadius)||0,w=k(o.backgroundColor)?o.backgroundColor:"none",S=[o.borderTopWidth,o.borderRightWidth,o.borderBottomWidth,o.borderLeftWidth].map(r=>Number.parseFloat(r)||0),x=S.every(r=>r===S[0]);if(!x){const[r,u,p,v]=S,$=(N,R,L,F,E,M)=>{N&&k(R)&&l.push(``)};$(r,o.borderTopColor,i,a+r/2,i+m,a+r/2),$(p,o.borderBottomColor,i,a+f-p/2,i+m,a+f-p/2),$(v,o.borderLeftColor,i+v/2,a,i+v/2,a+f),$(u,o.borderRightColor,i+m-u/2,a,i+m-u/2,a+f)}const g=x?S[0]:0,T=o.borderLeftColor,A=g&&o.borderTopStyle!=="none"&&k(T)?T:"none";if(w!=="none"||A!=="none"){const r=o.borderTopStyle==="dashed"?' stroke-dasharray="4 2"':"";l.push(``),A!=="none"&&!r&&o.borderTopColor!==T&&k(o.borderTopColor)&&l.push(``)}z(n,s,l);const B=/url\(["']?([^"')]+)["']?\)/.exec(o.backgroundImage)?.[1];B&&/-mark$/.test(String(n.getAttribute("class")))&&l.push(``)}}var P=t=>t.querySelector("[class$='-title']")?.textContent?.trim()??"",H=t=>t.querySelector("figcaption")?.textContent?.trim()??"",U=(t,s)=>`${P(t).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"diagram"}.${s}`;async function V(t,s,l){const c=s.theme??"page",e=t.getAttribute("data-theme"),n=["data-lit","data-dim","data-near","data-ahead","data-arrival","data-arrival-out"],o=Array.from(t.querySelectorAll(n.map(r=>`[${r}]`).join(", "))),d=o.map(r=>[r,n.map(u=>r.getAttribute(u))]);o.forEach(r=>{for(const u of n)r.removeAttribute(u)});const i=Array.from(t.querySelectorAll("[class*='-flow'], [class*='-bead'], [class*='-packet']"));i.forEach(r=>{r.dataset.exportHidden=r.style.display,r.style.display="none"});const a=t.getAttribute("data-entrance");a&&a!=="done"&&t.setAttribute("data-entrance","done");const m=t.getAnimations({subtree:!0}).map(r=>({a:r,at:r.currentTime,running:r.playState==="running"}));for(const{a:r}of m){const u=r.effect?.getComputedTiming().endTime;r.pause(),typeof u=="number"&&Number.isFinite(u)&&(r.currentTime=u)}const f=t.getAttribute("data-viewer");f!==null&&t.removeAttribute("data-viewer");const b=[];for(let r=t.parentElement;r;r=r.parentElement){const u=getComputedStyle(r).transform,p=/^matrix\(([^,]+),[^,]+,[^,]+,([^,]+),/.exec(u);p&&(Math.abs(Number(p[1])-1)>1e-6||Math.abs(Number(p[2])-1)>1e-6)&&(b.push([r,r.style.transform]),r.style.transform="none")}c!=="page"&&t.setAttribute("data-theme",c),t.classList.add("basalt-exporting");let w;try{t.offsetWidth;const r=Number.parseFloat(getComputedStyle(t).getPropertyValue("--basalt-space-4"))||16,u=G(t),p=u.map(y=>y.getBoundingClientRect()),v=Math.min(...p.map(y=>y.left)),$=Math.min(...p.map(y=>y.top)),N=Math.max(...p.map(y=>y.right)),R=Math.max(...p.map(y=>y.bottom)),L=new DOMRect(v-r,$-r,0,0),F=Math.ceil(N-v+2*r),E=Math.ceil(R-$+2*r),M=getComputedStyle(t).getPropertyValue("--basalt-surface-page").trim()||getComputedStyle(document.body).backgroundColor,W=[];for(const y of u)D(y,L,W);for(const y of u)I(y,L,W);w={body:W,w:F,h:E,ground:M}}finally{t.classList.remove("basalt-exporting"),c!=="page"&&(e===null?t.removeAttribute("data-theme"):t.setAttribute("data-theme",e));for(const[r,u]of b)r.style.transform=u;f!==null&&t.setAttribute("data-viewer",f);for(const{a:r,at:u,running:p}of m)r.currentTime=u,p&&r.play();a&&a!=="done"&&t.setAttribute("data-entrance",a),i.forEach(r=>{r.style.display=r.dataset.exportHidden??"",delete r.dataset.exportHidden});for(const[r,u]of d)n.forEach((p,v)=>{const $=u[v];$!=null&&r.setAttribute(p,$)})}const{body:S,w:x,h:g,ground:T}=w;let A="";if(l){const r=[];for(const u of["Geist","Geist Mono"]){const p=await j(u);p?r.push(`@font-face{font-family:"${u}";src:url(${p});font-weight:100 900}`):console.warn(`Basalt diagramToSvg: the face "${u}" could not be read, so the file names it`)}r.length&&(A=``)}return{svg:`${C(P(t))}${C(H(t))}${A}${S.join("")}`,w:x,h:g}}async function _(t,s={}){const{svg:l}=await V(t,s,(s.fonts??"embed")==="embed");return new Blob([l],{type:"image/svg+xml"})}async function X(t){const s=new Blob([t],{type:"image/svg+xml"});if(typeof createImageBitmap=="function")try{const c=await createImageBitmap(s);return{source:c,done:()=>c.close()}}catch{}const l=[()=>URL.createObjectURL(s),()=>`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`];for(const c of l){const e=c(),n=()=>{e.startsWith("blob:")&&URL.revokeObjectURL(e)},o=new Image;o.src=e;try{return await o.decode(),{source:o,done:n}}catch{n()}}throw new Error("Basalt diagramToPng: the PNG could not be drawn. A canvas draws the figure's SVG through an image, and this page refused it both as a blob: URL and as a data: URL: a content policy allows them with `img-src 'self' blob:` (or `data:`). diagramToSvg needs neither")}async function J(t,s={}){const{svg:l,w:c,h:e}=await V(t,s,!0),n=s.scale??2,{source:o,done:d}=await X(l);try{const i=document.createElement("canvas");i.width=Math.round(c*n),i.height=Math.round(e*n);const a=i.getContext("2d");return a.scale(n,n),a.drawImage(o,0,0,c,e),await new Promise((m,f)=>i.toBlob(b=>b?m(b):f(new Error("Basalt diagramToPng: the PNG could not be made")),"image/png"))}finally{d()}}(function(t){"use strict";var s=t._;function l(e,n){var o=document.createElement("a");o.href=URL.createObjectURL(e),o.download=n,document.body.appendChild(o),o.click(),o.remove(),setTimeout(function(){URL.revokeObjectURL(o.href)},1e3)}function c(e,n){var o=document.createElement("button");o.type="button",o.className="btn diagram-download",o.setAttribute("data-variant","secondary"),o.setAttribute("data-size","sm");var d=document.createElement("span");return d.textContent=e,o.appendChild(d),o.addEventListener("click",n),o}s.diagramExport=function(e,n){var o=c("Download SVG",function(){_(n).then(function(a){l(a,U(n,"svg"))})}),d=c("Download PNG",function(){J(n).then(function(a){l(a,U(n,"png"))})}),i=e.querySelector(".diagram-clear");return e.insertBefore(o,i),e.insertBefore(d,i),[o,d]}})(window.Basalt)})(); +(()=>{var V="http://www.w3.org/2000/svg",L=t=>t.replace(/[&<>"']/g,c=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[c]),E=t=>!!t&&t!=="transparent"&&!/rgba\([^)]*,\s*0\)$/.test(t)&&!/\/\s*0\)$/.test(t),p=t=>Math.round(t*100)/100;function q(t){const c=l=>t.querySelector(`:scope > [class$="-${l}"], :scope > [class*="-${l} "]`);return["head","drawing","key"].map(c).filter(l=>!!(l&&l.getClientRects().length))}async function D(t){for(const c of Array.from(document.styleSheets)){let l;try{l=c.cssRules}catch{continue}for(const d of Array.from(l)){if(!(d instanceof CSSFontFaceRule)||d.style.getPropertyValue("font-family").replace(/["']/g,"").trim()!==t)continue;const e=/url\(["']?([^"')]+)["']?\)/.exec(d.style.getPropertyValue("src"))?.[1];if(e){if(e.startsWith("data:"))return e;try{const i=await fetch(new URL(e,c.href??location.href));if(!i.ok)return null;const r=await i.blob();return await new Promise((m,a)=>{const s=new FileReader;s.onload=()=>m(String(s.result)),s.onerror=a,s.readAsDataURL(r)})}catch{return null}}}}return null}function z(t,c,l){const d=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let e=d.nextNode();e;e=d.nextNode()){const i=e.parentElement;if(!i||!e.textContent?.trim()||i.closest("[aria-hidden='true'] .basalt-visually-hidden, .basalt-visually-hidden, .visually-hidden, [class$='-ruler'], [hidden]"))continue;const r=getComputedStyle(i);if(r.visibility==="hidden"||r.display==="none")continue;const m=e.textContent,a=document.createRange();for(const s of m.matchAll(/\S+/g)){a.setStart(e,s.index),a.setEnd(e,s.index+s[0].length);const n=a.getBoundingClientRect();if(!n.width)continue;const f=Number.parseFloat(r.fontSize),h=n.top-c.top+(n.height-f)/2+f*.8;l.push(`${L(s[0])}`)}}}function j(t,c,l){if(/-(lane|band|felse)(\s|$)/.test(` ${t.getAttribute("class")??""}`))for(const d of["::before","::after"]){const e=getComputedStyle(t,d);if(!e.content||e.content==="none"||e.content==="normal"||e.display==="none"||e.position!=="absolute")continue;const i=t.getBoundingClientRect(),r=getComputedStyle(t),m=i.left+(Number.parseFloat(r.borderLeftWidth)||0)+(Number.parseFloat(e.left)||0)-c.left,a=i.top+(Number.parseFloat(r.borderTopWidth)||0)+(Number.parseFloat(e.top)||0)-c.top,s=Number.parseFloat(e.width)||0,n=Number.parseFloat(e.height)||0,f=Number.parseFloat(e.borderTopWidth)||0,h=e.maskImage&&e.maskImage!=="none"?` stroke-dasharray="${Number.parseFloat(e.maskSize)/2||4} ${Number.parseFloat(e.maskSize)/2||4}"`:"";E(e.backgroundColor)&&s&&n?l.push(``):f&&E(e.borderTopColor)&&l.push(``)}}function W(t,c,l){const d=t.getBoundingClientRect();if(!d.width||!d.height||t.getAttribute("class")?.endsWith("-motion-defs"))return;const e=t.cloneNode(!0),i=[t,...Array.from(t.querySelectorAll("*"))],r=[e,...Array.from(e.querySelectorAll("*"))],m=t.viewBox?.baseVal,a=!!(m&&m.width&&(Math.abs(m.width-d.width)>.5||Math.abs(m.height-d.height)>.5));i.forEach((s,n)=>{const f=getComputedStyle(s),h=r[n];for(const x of["fill","stroke","stroke-width","stroke-dasharray","stroke-linecap","stroke-linejoin","opacity"])h.setAttribute(x,f.getPropertyValue(x));h.removeAttribute("class"),/-reveal-/.test(h.getAttribute("mask")??"")&&h.removeAttribute("mask"),a&&n>0&&h.setAttribute("vector-effect","non-scaling-stroke"),f.display==="none"&&h.setAttribute("display","none")}),e.setAttribute("x",String(p(d.left-c.left))),e.setAttribute("y",String(p(d.top-c.top))),e.setAttribute("width",String(p(d.width))),e.setAttribute("height",String(p(d.height))),e.removeAttribute("style"),l.push(e.outerHTML)}function I(t,c,l){const d=[t,...Array.from(t.querySelectorAll("*"))],e=d.filter(i=>i instanceof SVGSVGElement&&i.closest("svg")===i&&!!i.closest("[class$='-ink']"));for(const i of e)W(i,c,l);for(const i of d){if(i instanceof SVGElement){if(i.tagName.toLowerCase()!=="svg"||i.closest("svg")!==i||e.includes(i))continue;W(i,c,l);continue}const r=getComputedStyle(i);if(r.display==="none"||r.visibility==="hidden")continue;const m=i.getBoundingClientRect();if(!m.width||!m.height)continue;const a=p(m.left-c.left),s=p(m.top-c.top),n=p(m.width),f=p(m.height),h=Number.parseFloat(r.borderTopLeftRadius)||0,x=E(r.backgroundColor)?r.backgroundColor:"none",b=[r.borderTopWidth,r.borderRightWidth,r.borderBottomWidth,r.borderLeftWidth].map($=>Number.parseFloat($)||0),S=b.every($=>$===b[0]);if(!S){const[$,g,T,o]=b,u=(y,R,N,F,M,B)=>{y&&E(R)&&l.push(``)};u($,r.borderTopColor,a,s+$/2,a+n,s+$/2),u(T,r.borderBottomColor,a,s+f-T/2,a+n,s+f-T/2),u(o,r.borderLeftColor,a+o/2,s,a+o/2,s+f),u(g,r.borderRightColor,a+n-g/2,s,a+n-g/2,s+f)}const v=S?b[0]:0,A=r.borderLeftColor,k=v&&r.borderTopStyle!=="none"&&E(A)?A:"none";if(x!=="none"||k!=="none"){const $=r.borderTopStyle==="dashed"?' stroke-dasharray="4 2"':"";l.push(``),k!=="none"&&!$&&r.borderTopColor!==A&&E(r.borderTopColor)&&l.push(``)}j(i,c,l);const C=/url\(["']?([^"')]+)["']?\)/.exec(r.backgroundImage)?.[1];C&&/-mark$/.test(String(i.getAttribute("class")))&&l.push(``)}}var O=t=>t.querySelector("[class$='-title']")?.textContent?.trim()??"",H=t=>t.querySelector("figcaption")?.textContent?.trim()??"",G=(t,c)=>`${O(t).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"diagram"}.${c}`;async function U(t,c,l,d){const e=c.theme??"page",i=t.getAttribute("data-theme"),r=["data-lit","data-dim","data-near","data-ahead","data-arrival","data-arrival-out"],m=Array.from(t.querySelectorAll(r.map(o=>`[${o}]`).join(", "))),a=m.map(o=>[o,r.map(u=>o.getAttribute(u))]);m.forEach(o=>{for(const u of r)o.removeAttribute(u)});const s=Array.from(t.querySelectorAll("[class*='-flow'], [class*='-bead'], [class*='-packet']"));s.forEach(o=>{o.dataset.exportHidden=o.style.display,o.style.display="none"});const n=t.getAttribute("data-entrance");n&&n!=="done"&&t.setAttribute("data-entrance","done");const f=t.getAnimations({subtree:!0}).map(o=>({a:o,at:o.currentTime,running:o.playState==="running"}));for(const{a:o}of f){const u=o.effect?.getComputedTiming().endTime;o.pause(),typeof u=="number"&&Number.isFinite(u)&&(o.currentTime=u)}const h=t.getAttribute("data-viewer");h!==null&&t.removeAttribute("data-viewer");const x=[];for(let o=t.parentElement;o;o=o.parentElement){const u=getComputedStyle(o).transform,y=/^matrix\(([^,]+),[^,]+,[^,]+,([^,]+),/.exec(u);y&&(Math.abs(Number(y[1])-1)>1e-6||Math.abs(Number(y[2])-1)>1e-6)&&(x.push([o,o.style.transform]),o.style.transform="none")}const b=t.closest(".basalt-diagram-sizer, .diagram-sizer"),S=b?.hidden?b:null;S&&(S.hidden=!1),e!=="page"&&t.setAttribute("data-theme",e),t.classList.add("basalt-exporting");let v;try{t.offsetWidth;const o=Number.parseFloat(getComputedStyle(t).getPropertyValue("--basalt-space-4"))||16,u=q(t);if(!t.getClientRects().length||!u.length)throw new Error(`Basalt ${d}: the figure is not displayed (it or a parent is display: none), so it cannot be measured and no file is made`);const y=u.map(w=>w.getBoundingClientRect()),R=Math.min(...y.map(w=>w.left)),N=Math.min(...y.map(w=>w.top)),F=Math.max(...y.map(w=>w.right)),M=Math.max(...y.map(w=>w.bottom)),B=new DOMRect(R-o,N-o,0,0),K=Math.ceil(F-R+2*o),Q=Math.ceil(M-N+2*o),Y=getComputedStyle(t).getPropertyValue("--basalt-surface-page").trim()||getComputedStyle(document.body).backgroundColor,P=[];for(const w of u)I(w,B,P);for(const w of u)z(w,B,P);v={body:P,w:K,h:Q,ground:Y}}finally{t.classList.remove("basalt-exporting"),S&&(S.hidden=!0),e!=="page"&&(i===null?t.removeAttribute("data-theme"):t.setAttribute("data-theme",i));for(const[o,u]of x)o.style.transform=u;h!==null&&t.setAttribute("data-viewer",h);for(const{a:o,at:u,running:y}of f)o.currentTime=u,y&&o.play();n&&n!=="done"&&t.setAttribute("data-entrance",n),s.forEach(o=>{o.style.display=o.dataset.exportHidden??"",delete o.dataset.exportHidden});for(const[o,u]of a)r.forEach((y,R)=>{const N=u[R];N!=null&&o.setAttribute(y,N)})}const{body:A,w:k,h:C,ground:$}=v;let g="";if(l){const o=[];for(const u of["Geist","Geist Mono"]){const y=await D(u);y?o.push(`@font-face{font-family:"${u}";src:url(${y});font-weight:100 900}`):console.warn(`Basalt diagramToSvg: the face "${u}" could not be read, so the file names it`)}o.length&&(g=``)}return{svg:`${L(O(t))}${L(H(t))}${g}${A.join("")}`,w:k,h:C}}async function _(t,c={}){const{svg:l}=await U(t,c,(c.fonts??"embed")==="embed","diagramToSvg");return new Blob([l],{type:"image/svg+xml"})}async function X(t){const c=new Blob([t],{type:"image/svg+xml"});if(typeof createImageBitmap=="function")try{const d=await createImageBitmap(c);return{source:d,done:()=>d.close()}}catch{}const l=[()=>URL.createObjectURL(c),()=>`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`];for(const d of l){const e=d(),i=()=>{e.startsWith("blob:")&&URL.revokeObjectURL(e)},r=new Image;r.src=e;try{return await r.decode(),{source:r,done:i}}catch{i()}}throw Object.assign(new Error("Basalt diagramToPng: the PNG could not be drawn. A canvas draws the figure's SVG through an image, and this page refused it both as a blob: URL and as a data: URL: a content policy allows them with `img-src 'self' blob:` (or `data:`). diagramToSvg needs neither"),{name:"DiagramPolicyError"})}async function J(t,c={}){const{svg:l,w:d,h:e}=await U(t,c,!0,"diagramToPng"),i=c.scale??2,{source:r,done:m}=await X(l);try{const a=document.createElement("canvas");a.width=Math.round(d*i),a.height=Math.round(e*i);const s=a.getContext("2d");return s.scale(i,i),s.drawImage(r,0,0,d,e),await new Promise((n,f)=>a.toBlob(h=>h?n(h):f(new Error("Basalt diagramToPng: the PNG could not be made")),"image/png"))}finally{m()}}(function(t){"use strict";var c=t._,l="This page's security policy blocks the PNG. Download SVG still works.",d={svg:"The SVG could not be made.",png:"The PNG could not be made."},e=!1,i=0;function r(a,s){var n=document.createElement("a");n.href=URL.createObjectURL(a),n.download=s,document.body.appendChild(n),n.click(),n.remove(),setTimeout(function(){URL.revokeObjectURL(n.href)},1e3)}function m(a,s){var n=document.createElement("button");n.type="button",n.className="btn diagram-download",n.setAttribute("data-variant","secondary"),n.setAttribute("data-size","sm");var f=document.createElement("span");return f.textContent=a,n.appendChild(f),n.addEventListener("click",s),n}c.diagramExport=function(a,s){var n=[],f=a.classList.contains("diagram-viewer-end")?a.parentElement:a,h=a.closest("dialog"),x=!1,b=null;function S(g){if(b||(b=document.createElement("p"),b.className="diagram-export-note",b.id="diagram-export-note-"+ ++i,f.appendChild(b),n.push(b)),b.textContent!==g){b.textContent=g;var T=h&&h.querySelector('[role="status"]');T?(T.textContent="",setTimeout(function(){T.textContent=g},30)):c.announce(g)}}function v(){if(b){if(x){b.textContent=l;return}b.remove(),n.splice(n.indexOf(b),1),b=null}}function A(){x=!0,C.setAttribute("aria-disabled","true"),S(l),C.setAttribute("aria-describedby",b.id)}var k=m("Download SVG",function(){v(),_(s).then(function(g){r(g,G(s,"svg"))},function(g){S(d.svg),console.error(g)})}),C=m("Download PNG",function(){if(!x){if(v(),e){A();return}J(s).then(function(g){r(g,G(s,"png"))},function(g){console.error(g),g&&g.name==="DiagramPolicyError"?(e=!0,A()):S(d.png)})}}),$=a.querySelector(".diagram-clear");return a.insertBefore(k,$),a.insertBefore(C,$),n.push(k,C),n}})(window.Basalt)})(); diff --git a/.agent/skills/basalt-html/parts/diagram-zoom.css b/.agent/skills/basalt-html/parts/diagram-zoom.css index 4f115ef6..04d6c439 100644 --- a/.agent/skills/basalt-html/parts/diagram-zoom.css +++ b/.agent/skills/basalt-html/parts/diagram-zoom.css @@ -1 +1 @@ -@layer basalt{@media(pointer:coarse){.diagram-expand{min-height:var(--basalt-size-tap-min)}}@media(width>=720px){.dialog[data-form].diagram-viewer,.dialog[data-form][data-held].diagram-viewer{width:calc(100vw - 2 * var(--basalt-space-4));max-width:none;height:calc(100dvh - 2 * var(--basalt-space-4));max-height:none}}.diagram-viewer .sheet-head{flex:none}.diagram-viewer-source{overflow-wrap:break-word}.diagram-stage{--_pad: var(--basalt-space-4);--_travel: var(--basalt-space-1);--_clear: var(--basalt-space-4);--_rest: var(--basalt-duration-slower);position:relative;flex:1 1 auto;display:flex;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;touch-action:none;outline:none}@media(width>=720px){.diagram-stage{--_pad: var(--basalt-space-6)}}.diagram-stage:focus-visible{outline:var(--basalt-size-focus-width) solid var(--basalt-border-focus);outline-offset:calc(-1 * var(--basalt-size-focus-width))}.diagram-stage[data-pannable]{cursor:grab}.diagram-stage[data-pannable][data-dragging]{cursor:grabbing}.diagram-stage[data-list]{display:block;touch-action:pan-y}.diagram-probe{position:absolute;top:0;left:0;height:0;visibility:hidden;pointer-events:none}.diagram-probe[data-probe=row]{width:calc(var(--basalt-size-page-width) - 2 * var(--basalt-size-gutter))}.diagram-probe[data-probe=contain]{width:var(--basalt-size-breakpoint-container)}.diagram-sizer{position:relative;flex:none;box-sizing:content-box;margin:auto;padding:var(--_pad)}.diagram-sizer[hidden]{display:none}.diagram-layer{position:absolute;top:var(--_pad);inset-inline-start:var(--_pad);transform-origin:0 0;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}.diagram-layer:dir(rtl){transform-origin:100% 0}.diagram[data-viewer]{gap:0}.diagram[data-viewer]>:is(.diagram-head,.diagram-key,.diagram-hint,.diagram-tap-hint,.diagram-foot,.diagram-list,.diagram-summary){display:none}.diagram-viewer-list{box-sizing:border-box;max-width:calc(var(--basalt-size-page-width) - 2 * var(--basalt-size-gutter) + 2 * var(--_pad));padding:var(--_pad)}.diagram-viewer-foot{display:flex;flex-direction:column;gap:var(--basalt-space-3);padding-block-start:var(--basalt-space-3);--basalt-edge-room-start: calc(max(var(--basalt-space-5), var(--bh-inset-start)) - var(--bh-inset-start));--basalt-edge-room: initial;--basalt-edge-room-end: initial}.diagram-viewer-key{--_ground: var(--panel-bg, var(--basalt-surface-overlay))}.diagram-viewer-key .diagram-key{padding-block-start:0;border-top:0}.diagram-viewer-key[data-layout=drawn] .diagram-entry[data-when=stacked],.diagram-viewer-key[data-layout=stacked] .diagram-entry[data-when=drawn],.diagram-viewer-key[data-bare] .diagram-entry[data-line]{display:none}.diagram-viewer-row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--basalt-space-2)}.diagram-zoom{display:flex;align-items:center;gap:var(--basalt-space-1)}.diagram-level{display:inline-grid;justify-items:center;color:var(--basalt-text-secondary);font:var(--basalt-font-weight-regular) var(--basalt-text-sm-size) / var(--basalt-text-sm-line-height) var(--basalt-font-family-sans);font-variant-numeric:tabular-nums}.diagram-level:before{content:attr(data-reserve);grid-area:1 / 1;visibility:hidden}.diagram-level>span{grid-area:1 / 1}.diagram-viewer-hint{flex:1 1 auto;min-width:0}.diagram-viewer-end{display:flex;gap:var(--basalt-space-2);margin-inline-start:auto}@media(pointer:coarse){.diagram-zoom .btn,.diagram-viewer-end .btn{min-height:var(--basalt-size-tap-min);min-width:var(--basalt-size-tap-min)}}@media(forced-colors:active){.diagram-level{color:CanvasText}.diagram-viewer-foot [aria-disabled=true]{color:GrayText}}@media print{.diagram-expand,.diagram-viewer{display:none!important;transition:none!important}}} +@layer basalt{@media(pointer:coarse){.diagram-expand{min-height:var(--basalt-size-tap-min)}}@media(width>=720px){.dialog[data-form].diagram-viewer,.dialog[data-form][data-held].diagram-viewer{width:calc(100vw - 2 * var(--basalt-space-4));max-width:none;height:calc(100dvh - 2 * var(--basalt-space-4));max-height:none}}.diagram-viewer .sheet-head{flex:none}.diagram-viewer-source{overflow-wrap:break-word}.diagram-stage{--_pad: var(--basalt-space-4);--_travel: var(--basalt-space-1);--_clear: var(--basalt-space-4);--_rest: var(--basalt-duration-slower);position:relative;flex:1 1 auto;display:flex;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;touch-action:none;outline:none}@media(width>=720px){.diagram-stage{--_pad: var(--basalt-space-6)}}.diagram-stage:focus-visible{outline:var(--basalt-size-focus-width) solid var(--basalt-border-focus);outline-offset:calc(-1 * var(--basalt-size-focus-width))}.diagram-stage[data-pannable]{cursor:grab}.diagram-stage[data-pannable][data-dragging]{cursor:grabbing}.diagram-stage[data-list]{display:block;touch-action:pan-y}.diagram-probe{position:absolute;top:0;left:0;height:0;visibility:hidden;pointer-events:none}.diagram-probe[data-probe=row]{width:calc(var(--basalt-size-page-width) - 2 * var(--basalt-size-gutter))}.diagram-probe[data-probe=contain]{width:var(--basalt-size-breakpoint-container)}.diagram-sizer{position:relative;flex:none;box-sizing:content-box;margin:auto;padding:var(--_pad)}.diagram-sizer[hidden]{display:none}.diagram-sizer{overflow:clip}.diagram-layer{position:absolute;top:var(--_pad);inset-inline-start:var(--_pad);transform-origin:0 0;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}.diagram-layer:dir(rtl){transform-origin:100% 0}.diagram[data-viewer]{gap:0}.diagram[data-viewer]>:is(.diagram-head,.diagram-key,.diagram-hint,.diagram-tap-hint,.diagram-foot,.diagram-list,.diagram-summary){display:none}.diagram-viewer-list{box-sizing:border-box;max-width:calc(var(--basalt-size-page-width) - 2 * var(--basalt-size-gutter) + 2 * var(--_pad));padding:var(--_pad)}.diagram-viewer-foot{display:flex;flex-direction:column;gap:var(--basalt-space-3);padding-block-start:var(--basalt-space-3);--basalt-edge-room-start: calc(max(var(--basalt-space-5), var(--bh-inset-start)) - var(--bh-inset-start));--basalt-edge-room: initial;--basalt-edge-room-end: initial}.diagram-viewer-key{--_ground: var(--panel-bg, var(--basalt-surface-overlay))}.diagram-viewer-key .diagram-key{padding-block-start:0;border-top:0}.diagram-viewer-key[data-layout=drawn] .diagram-entry[data-when=stacked],.diagram-viewer-key[data-layout=stacked] .diagram-entry[data-when=drawn],.diagram-viewer-key[data-bare] .diagram-entry[data-line]{display:none}.diagram-viewer-row{display:flex;flex-wrap:wrap;align-items:center;gap:var(--basalt-space-2)}.diagram-zoom{display:flex;align-items:center;gap:var(--basalt-space-1);margin-inline-end:auto}.diagram-level{display:inline-grid;justify-items:center;color:var(--basalt-text-secondary);font:var(--basalt-font-weight-regular) var(--basalt-text-sm-size) / var(--basalt-text-sm-line-height) var(--basalt-font-family-sans);font-variant-numeric:tabular-nums}.diagram-level:before{content:attr(data-reserve);grid-area:1 / 1;visibility:hidden}.diagram-level>span{grid-area:1 / 1}.diagram-viewer-hint{flex:1 1 auto;min-width:0}.diagram-viewer-end{display:flex;flex-wrap:wrap;gap:var(--basalt-space-2);min-width:0}@media(pointer:coarse){.diagram-zoom .btn,.diagram-viewer-end .btn{min-height:var(--basalt-size-tap-min);min-width:var(--basalt-size-tap-min)}}@media(forced-colors:active){.diagram-level{color:CanvasText}.diagram-viewer-foot [aria-disabled=true]{color:GrayText}}@media print{.diagram-expand,.diagram-viewer{display:none!important;transition:none!important}}} diff --git a/.agent/skills/basalt-html/parts/diagram-zoom.js b/.agent/skills/basalt-html/parts/diagram-zoom.js index b5403fdc..928a8f38 100644 --- a/.agent/skills/basalt-html/parts/diagram-zoom.js +++ b/.agent/skills/basalt-html/parts/diagram-zoom.js @@ -1 +1 @@ -(()=>{var tt="Plus and minus zoom, zero fits the drawing, Escape closes.";function et(s){return[...s.filter(y=>y.keys[0]!=="Esc"),{keys:["+","−"],words:"zoom"},{keys:["0"],words:"fit"},{keys:["Esc"],words:"close"}]}var G=[25,33,50,67,75,100,125,150,200,300,400],j=4,J=2,at=100,Q=25,U=5e-4;function it(s){const{stage:e,sizer:y,layer:p,status:k}=s;let m=0,M=0,a=1,n=1,c=!1,d=!1,h=null,u="",z=0;const T=()=>Number.parseFloat(getComputedStyle(y).paddingTop)||0,A=()=>Math.min(n,1),q=t=>Math.min(j,Math.max(A(),t));function o(){if(!m||!M)return 1;const t=T(),r=e.clientWidth-2*t,x=e.clientHeight-2*t;if(r<=0||x<=0)return Math.min(1,J);const H=Math.min(r/m,x/M);return Math.min(J,Math.floor(H*100+1e-6)/100)}function l(){const t=A();return{zoom:a,level:Math.round(a*100),fit:n,min:t,max:j,atMin:a<=t+U,atMax:a>=j-U,atFit:Math.abs(a-n)e.clientWidth-2*T()+.5||M*a>e.clientHeight-2*T()+.5)}function S(){clearTimeout(z);const t=`Zoom ${Math.round(a*100)}%`;z=window.setTimeout(()=>{t!==u&&(u=t,k.textContent=t)},s.rest)}function v(){y.style.width=`${m*a}px`,y.style.height=`${M*a}px`,p.style.transform=`scale(${a})`}function K(t){const r=p.getBoundingClientRect();return{x:(t.x-r.left)/a,y:(t.y-r.top)/a}}function E(t,r){const x=p.getBoundingClientRect();e.scrollLeft+=x.left+t.x*a-r.x,e.scrollTop+=x.top+t.y*a-r.y}const g=()=>{const t=e.getBoundingClientRect();return{x:t.left+e.clientWidth/2,y:t.top+e.clientHeight/2}};function W(t,r=g(),x){if(d)return;const H=q(t);if(Math.abs(H-a)<1e-6){w();return}const st=x??K(r);a=H,v(),E(st,r),w(),S()}function L(t){c=!0;const r=a*100,x=t?G.find(H=>H>r+.5):[...G].reverse().find(H=>HNumber.parseFloat(getComputedStyle(e).getPropertyValue("--_travel"))||4,i=()=>{const[t,r]=[...f.values()];return{x:(t.x+r.x)/2,y:(t.y+r.y)/2}},b=()=>{const[t,r]=[...f.values()];return Math.hypot(t.x-r.x,t.y-r.y)};function Y(t){if(!d&&!(t.pointerType==="mouse"&&t.button!==0)&&(f.set(t.pointerId,{x:t.clientX,y:t.clientY}),f.size===1&&(F={x:t.clientX,y:t.clientY},C=F,O=!1,$=!1),f.size===2&&t.pointerType==="touch")){const r=i();B={d0:b()||1,z0:a,c:K(r)},$=!0,O=!1;try{e.setPointerCapture(t.pointerId)}catch{}}}function N(t){if(!f.has(t.pointerId)||d)return;if(f.set(t.pointerId,{x:t.clientX,y:t.clientY}),B&&f.size>=2){c=!0;const x=q(B.z0*(b()/B.d0)),H=i();Math.abs(x-a)>1e-6&&(a=x,v(),w(),S()),E(B.c,H);return}if(f.size!==1||!F||!C)return;const r={x:t.clientX,y:t.clientY};if(!O){if(Math.hypot(r.x-F.x,r.y-F.y)<=V())return;O=!0,$=!0,e.setAttribute("data-dragging","");try{e.setPointerCapture(t.pointerId)}catch{}}e.scrollLeft-=r.x-C.x,e.scrollTop-=r.y-C.y,C=r,t.preventDefault()}function Z(t){if(f.has(t.pointerId)){if(f.delete(t.pointerId),f.size<2&&(B=null),f.size===1){const[r]=[...f.values()];C=r,F=r,O=!0;return}f.size===0&&(O=!1,e.removeAttribute("data-dragging"),F=C=null)}}function P(t){$&&($=!1,t.preventDefault(),t.stopPropagation())}const X=new ResizeObserver(()=>{if(!m||!M)return;const t=c?K(g()):null;n=o(),c?(a=q(a),v(),t&&E(t,g())):(a=n,v()),w()});return X.observe(e),e.addEventListener("wheel",R,{passive:!1}),e.addEventListener("keydown",D),e.addEventListener("pointerdown",Y),e.addEventListener("pointermove",N),e.addEventListener("pointerup",Z),e.addEventListener("pointercancel",Z),e.addEventListener("click",P,!0),{size:I,zoomIn:()=>L(!0),zoomOut:()=>L(!1),fit:_,state:l,list(t){t!==d&&(t?(h={left:e.scrollLeft,top:e.scrollTop},d=!0,e.setAttribute("data-list",""),e.scrollTop=0):(d=!1,e.removeAttribute("data-list"),v(),h&&(e.scrollLeft=h.left,e.scrollTop=h.top),h=null),w())},travelled:()=>$,destroy(){clearTimeout(z),X.disconnect(),e.removeEventListener("wheel",R),e.removeEventListener("keydown",D),e.removeEventListener("pointerdown",Y),e.removeEventListener("pointermove",N),e.removeEventListener("pointerup",Z),e.removeEventListener("pointercancel",Z),e.removeEventListener("click",P,!0)}}}function nt(s,e,y){const p=s.getBoundingClientRect(),k=e.getBoundingClientRect(),m=p.left+y,M=p.left+s.clientWidth-y,a=p.top+y,n=p.top+s.clientHeight-y;k.leftM&&(s.scrollLeft+=Math.min(k.right-M,k.left-m)),k.topn&&(s.scrollTop+=Math.min(k.bottom-n,k.top-a))}function rt(s,e){s.memo.art=Math.ceil(e),s.layer.style.width=`${s.memo.art}px`}function ot(s,e,y,p,k,m,M,a){const{layer:n,memo:c,measureFigure:d}=a;if(c.model!==e&&(c.model=e,c.least=void 0,c.art=void 0),e.text){n.style.width=`${c.art??Math.min(a.avail,a.row)}px`;const w=n.style.transform;n.style.transform="none";const S=d(s,e,y,p,k,m,M);return n.style.transform=w,S}const h=w=>{n.style.width=`${Math.max(c.least||w,Math.min(a.avail,a.row))}px`};n.style.width||(n.style.width=`${Math.min(a.avail,a.row)}px`);const u=n.style.transform;n.style.transform="none";const z=n.offsetWidth?n.getBoundingClientRect().width/n.offsetWidth:1,T=Math.abs(z-1)>1e-4?` scale(${1/z})`:"";n.style.transform=T||"none";const A=(s.querySelector(`.${y}-drawing`)??n).getBoundingClientRect(),q=A.left-Math.round(A.left),o=A.top-Math.round(A.top);(q||o)&&(n.style.transform=`translate(${-q/z}px, ${-o/z}px)${T}`);let l=d(s,e,y,p,k,m,c.least===void 0?void 0:M,h);if(l.dyn.layout==="stacked"&&c.least===void 0&&l.least!==void 0){const w=l.dyn,S=g=>{n.style.width=`${g}px`;const W=d(s,e,y,p,w,m);return W.dyn.layout==="drawn"?d(s,e,y,p,W.dyn,m):W},v=Math.max(l.least,Math.min(a.avail,a.row)),K=Math.max(a.row,v)*1.5;let E;for(let g=v+16;g<=K&&E===void 0;g+=16)S(g).dyn.layout==="drawn"&&(E=g);if(E!==void 0){for(let g=E-15;ga.contain&&(n.style.width=`${a.contain}px`,l=d(s,e,y,p,l.dyn,m,M)),n.style.transform=u,l}(function(s){"use strict";var e=s._,y=0;function p(a){return e.diagramKit.escapeHtml(String(a??""))}function k(a){return''+p(a)+""}function m(a,n){return parseFloat(getComputedStyle(a).getPropertyValue(n))||0}function M(a,n,c,d){var h=e.diagramKit,u=Object.assign({},n,{motion:"still"}),z=h.buildModel(u,{placement:Array.isArray(u.placement)?u.placement[0]:u.placement}),T="dgv"+ ++y,A=h.figureKey("diagram",z),q=et(h.hintEntries(z,!0)).map(function(i){return""+i.keys.map(k).join(" ")+" "+p(i.words)+""}).join(""),o=document.createElement("dialog");o.className="panel float modal dialog diagram-viewer",o.setAttribute("data-form",""),o.setAttribute("aria-describedby",T+"-summary"),o.innerHTML='

'+p(z.title)+"

"+(n.source?'

'+p(n.source)+"

":"")+'

'+p(n.summary)+'

'+(A?'
'+h.toHtml(A)+"
":"")+'
',document.body.appendChild(o);var l=o.querySelector(".diagram-stage"),w=o.querySelector(".diagram-sizer"),S=o.querySelector(".diagram-layer"),v=S.firstChild,K=o.querySelector('[role="status"]'),E=o.querySelector(".diagram-level > span"),g=o.querySelector(".diagram-viewer-key"),W=o.querySelector(".diagram-toggle"),L={out:o.querySelector('[data-zoom="out"]'),in:o.querySelector('[data-zoom="in"]'),fit:o.querySelector('[data-zoom="fit"]')},_=null,I=!1,R=!1,D=function(i,b){b?i.setAttribute("aria-disabled","true"):i.removeAttribute("aria-disabled")},f=it({stage:l,sizer:w,layer:S,status:K,rest:m(l,"--_rest")||300,onChange:function(i){E.textContent=i.level+"%",D(L.out,i.listOpen||i.atMin),D(L.in,i.listOpen||i.atMax),D(L.fit,i.listOpen||i.atFit)}}),F={},C={layer:S,avail:0,row:1104,contain:480,memo:F,measureFigure:h.measureFigure,keys:tt,room:function(){var i=parseFloat(getComputedStyle(w).paddingTop)||0;return{w:l.clientWidth-2*i,h:l.clientHeight-2*i}},measure:function(i,b,Y,N,Z,P,X){return ot(i,b,Y,N,Z,P,X,C)},textWidth:function(i){rt(C,i)},onMeasured:function(i,b){l.setAttribute("data-layout",i.dyn.layout||""),g&&(g.setAttribute("data-layout",i.dyn.layout||""),g.toggleAttribute("data-bare",!!i.dyn.bare)),R=!!i.dyn.bare,W.hidden=R,$(I||R),f.size(b.offsetWidth,b.offsetHeight)}};function O(){C.avail=Math.max(0,Math.floor(l.clientWidth-2*(parseFloat(getComputedStyle(w).paddingLeft)||0))),C.row=o.querySelector('[data-probe="row"]').offsetWidth||1104,C.contain=o.querySelector('[data-probe="contain"]').offsetWidth||480}function $(i){i&&!_&&(_=document.createElement("div"),_.className="diagram-list diagram-viewer-list",_.innerHTML=h.figureList("diagram",z).map(function(b){return h.toHtml(b)}).join(""),l.appendChild(_)),i&&f.list(!0),_&&(_.hidden=!i),w.hidden=i,i||f.list(!1)}W.addEventListener("click",function(){I=!I,W.setAttribute("aria-expanded",String(I)),W.firstElementChild.textContent=I?"Hide the list":"View as list",$(I||R)}),L.out.addEventListener("click",function(){L.out.hasAttribute("aria-disabled")||f.zoomOut()}),L.in.addEventListener("click",function(){L.in.hasAttribute("aria-disabled")||f.zoomIn()}),L.fit.addEventListener("click",function(){L.fit.hasAttribute("aria-disabled")||f.fit()}),o.addEventListener("click",function(i){var b=i.target.closest&&i.target.closest("a.diagram-node[href]");!b||!o.contains(b)||i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||b.target&&b.target!=="_self"||o.open&&o.close()}),l.addEventListener("focusin",function(i){var b=i.target.closest&&i.target.closest(".diagram-node");b&&l.contains(b)&&nt(l,b,m(l,"--_clear")||16)}),n.export===!0&&typeof e.diagramExport=="function"&&e.diagramExport(o.querySelector(".diagram-viewer-end"),v),s.openDialog(o,d),O(),h.draw(v,u,!1,C),setTimeout(function(){l.focus({preventScroll:!0})},0);var B=l.clientWidth,V=new ResizeObserver(function(){Math.abs(l.clientWidth-B)<.5||(B=l.clientWidth,O(),v.__diagram&&v.__diagram.layout())});V.observe(l),o.addEventListener("transitionend",function(i){i.target===o&&i.propertyName==="transform"&&o.open&&v.__diagram&&v.__diagram.layout()}),a.setAttribute("data-viewing",""),c.animated&&c.settle(),o.addEventListener("close",function(){V.disconnect(),f.destroy(),v.__diagram&&v.__diagram.stop(),a.removeAttribute("data-viewing"),setTimeout(function(){o.remove()},m(o,"--_dur")*.75||300)})}e.diagramZoom=function(a,n,c){var d=a.querySelector(":scope > .diagram-foot");if(!d)return null;var h=d.querySelector(".diagram-expand");h&&h.remove();var u=document.createElement("button");u.type="button",u.className="btn diagram-expand",u.setAttribute("data-variant","secondary"),u.setAttribute("data-size","sm"),u.setAttribute("aria-haspopup","dialog"),u.innerHTML="Expand";var z=d.querySelector(".diagram-toggle");z&&z.nextSibling?d.insertBefore(u,z.nextSibling):d.appendChild(u);var T=function(){M(a,n,c,u)};return u.addEventListener("click",T),{destroy:function(){u.removeEventListener("click",T),u.remove()}}}})(window.Basalt)})(); +(()=>{var tt="Plus and minus zoom, zero fits the drawing, Escape closes.";function et(s){return[...s.filter(y=>y.keys[0]!=="Esc"),{keys:["+","−"],words:"zoom"},{keys:["0"],words:"fit"},{keys:["Esc"],words:"close"}]}var G=[25,33,50,67,75,100,125,150,200,300,400],V=4,J=2,at=100,Q=25,U=5e-4;function it(s){const{stage:e,sizer:y,layer:p,status:k}=s;let m=0,M=0,a=1,n=1,c=!1,d=!1,h=null,u="",z=0;const T=()=>Number.parseFloat(getComputedStyle(y).paddingTop)||0,A=()=>Math.min(n,1),q=t=>Math.min(V,Math.max(A(),t));function o(){if(!m||!M)return 1;const t=T(),r=e.clientWidth-2*t,x=e.clientHeight-2*t;if(r<=0||x<=0)return Math.min(1,J);const H=Math.min(r/m,x/M);return Math.min(J,Math.floor(H*100+1e-6)/100)}function l(){const t=A();return{zoom:a,level:Math.round(a*100),fit:n,min:t,max:V,atMin:a<=t+U,atMax:a>=V-U,atFit:Math.abs(a-n)e.clientWidth-2*T()+.5||M*a>e.clientHeight-2*T()+.5)}function S(){clearTimeout(z);const t=`Zoom ${Math.round(a*100)}%`;z=window.setTimeout(()=>{t!==u&&(u=t,k.textContent=t)},s.rest)}function v(){y.style.width=`${m*a}px`,y.style.height=`${M*a}px`,p.style.transform=`scale(${a})`}function K(t){const r=p.getBoundingClientRect();return{x:(t.x-r.left)/a,y:(t.y-r.top)/a}}function E(t,r){const x=p.getBoundingClientRect();e.scrollLeft+=x.left+t.x*a-r.x,e.scrollTop+=x.top+t.y*a-r.y}const g=()=>{const t=e.getBoundingClientRect();return{x:t.left+e.clientWidth/2,y:t.top+e.clientHeight/2}};function W(t,r=g(),x){if(d)return;const H=q(t);if(Math.abs(H-a)<1e-6){b();return}const lt=x??K(r);a=H,v(),E(lt,r),b(),S()}function L(t){c=!0;const r=a*100,x=t?G.find(H=>H>r+.5):[...G].reverse().find(H=>HNumber.parseFloat(getComputedStyle(e).getPropertyValue("--_travel"))||4,i=()=>{const[t,r]=[...f.values()];return{x:(t.x+r.x)/2,y:(t.y+r.y)/2}},w=()=>{const[t,r]=[...f.values()];return Math.hypot(t.x-r.x,t.y-r.y)};function D(t){if(!d&&!(t.pointerType==="mouse"&&t.button!==0)&&(f.set(t.pointerId,{x:t.clientX,y:t.clientY}),f.size===1&&($={x:t.clientX,y:t.clientY},C=$,F=!1,O=!1),f.size===2&&t.pointerType==="touch")){const r=i();B={d0:w()||1,z0:a,c:K(r)},O=!0,F=!1;try{e.setPointerCapture(t.pointerId)}catch{}}}function N(t){if(!f.has(t.pointerId)||d)return;if(f.set(t.pointerId,{x:t.clientX,y:t.clientY}),B&&f.size>=2){c=!0;const x=q(B.z0*(w()/B.d0)),H=i();Math.abs(x-a)>1e-6&&(a=x,v(),b(),S()),E(B.c,H);return}if(f.size!==1||!$||!C)return;const r={x:t.clientX,y:t.clientY};if(!F){if(Math.hypot(r.x-$.x,r.y-$.y)<=Y())return;F=!0,O=!0,e.setAttribute("data-dragging","");try{e.setPointerCapture(t.pointerId)}catch{}}e.scrollLeft-=r.x-C.x,e.scrollTop-=r.y-C.y,C=r,t.preventDefault()}function j(t){if(f.has(t.pointerId)){if(f.delete(t.pointerId),f.size<2&&(B=null),f.size===1){const[r]=[...f.values()];C=r,$=r,F=!0;return}f.size===0&&(F=!1,e.removeAttribute("data-dragging"),$=C=null)}}function P(t){O&&(O=!1,t.preventDefault(),t.stopPropagation())}const X=new ResizeObserver(()=>{if(!m||!M)return;const t=c?K(g()):null;n=o(),c?(a=q(a),v(),t&&E(t,g())):(a=n,v()),b()});return X.observe(e),e.addEventListener("wheel",R,{passive:!1}),e.addEventListener("keydown",Z),e.addEventListener("pointerdown",D),e.addEventListener("pointermove",N),e.addEventListener("pointerup",j),e.addEventListener("pointercancel",j),e.addEventListener("click",P,!0),{size:I,zoomIn:()=>L(!0),zoomOut:()=>L(!1),fit:_,state:l,list(t){t!==d&&(t?(h={left:e.scrollLeft,top:e.scrollTop},d=!0,e.setAttribute("data-list",""),e.scrollTop=0):(d=!1,e.removeAttribute("data-list"),v(),h&&(e.scrollLeft=h.left,e.scrollTop=h.top),h=null),b())},travelled:()=>O,destroy(){clearTimeout(z),X.disconnect(),e.removeEventListener("wheel",R),e.removeEventListener("keydown",Z),e.removeEventListener("pointerdown",D),e.removeEventListener("pointermove",N),e.removeEventListener("pointerup",j),e.removeEventListener("pointercancel",j),e.removeEventListener("click",P,!0)}}}function nt(s){return[s.querySelector(":scope > [class$='-drawing']")?.offsetWidth||s.offsetWidth,s.offsetHeight]}function rt(s,e,y){const p=s.getBoundingClientRect(),k=e.getBoundingClientRect(),m=p.left+y,M=p.left+s.clientWidth-y,a=p.top+y,n=p.top+s.clientHeight-y;k.leftM&&(s.scrollLeft+=Math.min(k.right-M,k.left-m)),k.topn&&(s.scrollTop+=Math.min(k.bottom-n,k.top-a))}function ot(s,e){s.memo.art=Math.ceil(e),s.layer.style.width=`${s.memo.art}px`}function st(s,e,y,p,k,m,M,a){const{layer:n,memo:c,measureFigure:d}=a;if(c.model!==e&&(c.model=e,c.least=void 0,c.art=void 0),e.text){n.style.width=`${c.art??Math.min(a.avail,a.row)}px`;const b=n.style.transform;n.style.transform="none";const S=d(s,e,y,p,k,m,M);return n.style.transform=b,S}const h=b=>{n.style.width=`${Math.max(c.least||b,Math.min(a.avail,a.row))}px`};n.style.width||(n.style.width=`${Math.min(a.avail,a.row)}px`);const u=n.style.transform;n.style.transform="none";const z=n.offsetWidth?n.getBoundingClientRect().width/n.offsetWidth:1,T=Math.abs(z-1)>1e-4?` scale(${1/z})`:"";n.style.transform=T||"none";const A=(s.querySelector(`.${y}-drawing`)??n).getBoundingClientRect(),q=A.left-Math.round(A.left),o=A.top-Math.round(A.top);(q||o)&&(n.style.transform=`translate(${-q/z}px, ${-o/z}px)${T}`);let l=d(s,e,y,p,k,m,c.least===void 0?void 0:M,h);if(l.dyn.layout==="stacked"&&c.least===void 0&&l.least!==void 0){const b=l.dyn,S=g=>{n.style.width=`${g}px`;const W=d(s,e,y,p,b,m);return W.dyn.layout==="drawn"?d(s,e,y,p,W.dyn,m):W},v=Math.max(l.least,Math.min(a.avail,a.row)),K=Math.max(a.row,v)*1.5;let E;for(let g=v+16;g<=K&&E===void 0;g+=16)S(g).dyn.layout==="drawn"&&(E=g);if(E!==void 0){for(let g=E-15;ga.contain&&(n.style.width=`${a.contain}px`,l=d(s,e,y,p,l.dyn,m,M)),n.style.transform=u,l}(function(s){"use strict";var e=s._,y=0;function p(a){return e.diagramKit.escapeHtml(String(a??""))}function k(a){return''+p(a)+""}function m(a,n){return parseFloat(getComputedStyle(a).getPropertyValue(n))||0}function M(a,n,c,d){var h=e.diagramKit,u=Object.assign({},n,{motion:"still"}),z=h.buildModel(u,{placement:Array.isArray(u.placement)?u.placement[0]:u.placement}),T="dgv"+ ++y,A=h.figureKey("diagram",z),q=et(h.hintEntries(z,!0)).map(function(i){return""+i.keys.map(k).join(" ")+" "+p(i.words)+""}).join(""),o=document.createElement("dialog");o.className="panel float modal dialog diagram-viewer",o.setAttribute("data-form",""),o.setAttribute("aria-describedby",T+"-summary"),o.innerHTML='

'+p(z.title)+"

"+(n.source?'

'+p(n.source)+"

":"")+'

'+p(n.summary)+'

'+(A?'
'+h.toHtml(A)+"
":"")+'
',document.body.appendChild(o);var l=o.querySelector(".diagram-stage"),b=o.querySelector(".diagram-sizer"),S=o.querySelector(".diagram-layer"),v=S.firstChild,K=o.querySelector('[role="status"]'),E=o.querySelector(".diagram-level > span"),g=o.querySelector(".diagram-viewer-key"),W=o.querySelector(".diagram-toggle"),L={out:o.querySelector('[data-zoom="out"]'),in:o.querySelector('[data-zoom="in"]'),fit:o.querySelector('[data-zoom="fit"]')},_=null,I=!1,R=!1,Z=function(i,w){w?i.setAttribute("aria-disabled","true"):i.removeAttribute("aria-disabled")},f=it({stage:l,sizer:b,layer:S,status:K,rest:m(l,"--_rest")||300,onChange:function(i){E.textContent=i.level+"%",Z(L.out,i.listOpen||i.atMin),Z(L.in,i.listOpen||i.atMax),Z(L.fit,i.listOpen||i.atFit)}}),$={},C={layer:S,avail:0,row:1104,contain:480,memo:$,measureFigure:h.measureFigure,keys:tt,room:function(){var i=parseFloat(getComputedStyle(b).paddingTop)||0;return{w:l.clientWidth-2*i,h:l.clientHeight-2*i}},measure:function(i,w,D,N,j,P,X){return st(i,w,D,N,j,P,X,C)},textWidth:function(i){ot(C,i)},onMeasured:function(i,w){l.setAttribute("data-layout",i.dyn.layout||""),g&&(g.setAttribute("data-layout",i.dyn.layout||""),g.toggleAttribute("data-bare",!!i.dyn.bare)),R=!!i.dyn.bare,W.hidden=R,O(I||R);var D=nt(w);f.size(D[0],D[1])}};function F(){C.avail=Math.max(0,Math.floor(l.clientWidth-2*(parseFloat(getComputedStyle(b).paddingLeft)||0))),C.row=o.querySelector('[data-probe="row"]').offsetWidth||1104,C.contain=o.querySelector('[data-probe="contain"]').offsetWidth||480}function O(i){i&&!_&&(_=document.createElement("div"),_.className="diagram-list diagram-viewer-list",_.innerHTML=h.figureList("diagram",z).map(function(w){return h.toHtml(w)}).join(""),l.appendChild(_)),i&&f.list(!0),_&&(_.hidden=!i),b.hidden=i,i||f.list(!1)}W.addEventListener("click",function(){I=!I,W.setAttribute("aria-expanded",String(I)),W.firstElementChild.textContent=I?"Hide the list":"View as list",O(I||R)}),L.out.addEventListener("click",function(){L.out.hasAttribute("aria-disabled")||f.zoomOut()}),L.in.addEventListener("click",function(){L.in.hasAttribute("aria-disabled")||f.zoomIn()}),L.fit.addEventListener("click",function(){L.fit.hasAttribute("aria-disabled")||f.fit()}),o.addEventListener("click",function(i){var w=i.target.closest&&i.target.closest("a.diagram-node[href]");!w||!o.contains(w)||i.defaultPrevented||i.button!==0||i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||w.target&&w.target!=="_self"||o.open&&o.close()}),l.addEventListener("focusin",function(i){var w=i.target.closest&&i.target.closest(".diagram-node");w&&l.contains(w)&&rt(l,w,m(l,"--_clear")||16)}),n.export===!0&&typeof e.diagramExport=="function"&&e.diagramExport(o.querySelector(".diagram-viewer-end"),v),s.openDialog(o,d),F(),h.draw(v,u,!1,C),setTimeout(function(){l.focus({preventScroll:!0})},0);var B=l.clientWidth,Y=new ResizeObserver(function(){Math.abs(l.clientWidth-B)<.5||(B=l.clientWidth,F(),v.__diagram&&v.__diagram.layout())});Y.observe(l),o.addEventListener("transitionend",function(i){i.target===o&&i.propertyName==="transform"&&o.open&&v.__diagram&&v.__diagram.layout()}),a.setAttribute("data-viewing",""),c.animated&&c.settle(),o.addEventListener("close",function(){Y.disconnect(),f.destroy(),v.__diagram&&v.__diagram.stop(),a.removeAttribute("data-viewing"),setTimeout(function(){o.remove()},m(o,"--_dur")*.75||300)})}e.diagramZoom=function(a,n,c){var d=a.querySelector(":scope > .diagram-foot");if(!d)return null;var h=d.querySelector(".diagram-expand");h&&h.remove();var u=document.createElement("button");u.type="button",u.className="btn diagram-expand",u.setAttribute("data-variant","secondary"),u.setAttribute("data-size","sm"),u.setAttribute("aria-haspopup","dialog"),u.innerHTML="Expand";var z=d.querySelector(".diagram-toggle");z&&z.nextSibling?d.insertBefore(u,z.nextSibling):d.appendChild(u);var T=function(){M(a,n,c,u)};return u.addEventListener("click",T),{destroy:function(){u.removeEventListener("click",T),u.remove()}}}})(window.Basalt)})(); diff --git a/.agent/skills/basalt-html/parts/diagram.css b/.agent/skills/basalt-html/parts/diagram.css index abece83a..f9690723 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-activation: 8px;--basalt-size-diagram-foot: 14px;--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(--_gw, 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);--_Rows: var(--_D) var(--_rows, none);display:grid;grid-template-columns:var(--_Cols, repeat(auto-fit, minmax(min(100%, var(--_track, var(--basalt-size-diagram-table))), 1fr)));grid-template-rows:var(--_Rows, none);gap:var(--_Gap, var(--basalt-space-4));align-items:start;max-width:none}.diagram[data-type=schema][data-marks]>.diagram-drawing{--_col-gap: calc(var(--basalt-space-12) + var(--basalt-space-3))}.diagram[data-type=sequence]>.diagram-drawing{display:flex;gap:0}.diagram[data-rtl]>.diagram-drawing{direction:ltr}.diagram[data-rtl]>.diagram-drawing{padding:var(--_Pad, 0 0 0 var(--_gutter, 0))}.diagram[data-rtl] .diagram-node[data-branch]{margin-inline:var(--_Mi, var(--basalt-space-6) var(--basalt-space-12))}.diagram[data-rtl]>.diagram-drawing :is(.diagram-node>:not(.diagram-mark),.diagram-lane-name,.diagram-said,.diagram-note,.diagram-band,.diagram-fhead,.diagram-felse){direction:rtl}.diagram[data-rtl] .diagram-gbox>.diagram-glabel{inset-inline:auto var(--basalt-space-3)}.diagram[data-rtl] .diagram-group>.diagram-glabel{inset-inline:auto calc(var(--basalt-space-3) + var(--_gx, var(--basalt-space-0)));margin-inline:0 calc(-1 * var(--basalt-space-1-5))}.diagram[data-rtl] .diagram-runs{direction:ltr;unicode-bidi:isolate}.diagram[data-rtl] .diagram-fhead{inset-inline-start:calc(100% - var(--_fl) - var(--_fw) + var(--basalt-size-hairline))}.diagram[data-rtl] .diagram-felse{padding-inline-start:calc(100% - var(--_fl) - var(--_fw) + var(--basalt-space-3))}.diagram[data-rtl] .diagram-felse:before{inset-inline-start:var(--_Fer, calc(-1 * var(--basalt-space-4)))}.diagram[data-rtl] .diagram-msg[data-self=end] :is(.diagram-said,.diagram-note){--_Sj: var(--_D) left;margin-inline-start:0;margin-inline-end:var(--_Sm, 0)}.diagram[data-rtl] .diagram-msg[data-self=start] :is(.diagram-said,.diagram-note){--_Sj: var(--_D) right;margin-inline-end:0;margin-inline-start:var(--_Sm, 0)}.diagram[data-rtl] :is(.diagram-run,.diagram-mlabel,.diagram-tname,.diagram-cname,.diagram-ctype,.diagram-label,.diagram-glabel,.diagram-kind){unicode-bidi:isolate}.diagram[data-rtl] :is(.diagram-run,.diagram-mlabel,.diagram-cname,.diagram-label){direction:ltr}.diagram[data-rtl] .diagram-arrow{scale:-1 1}.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{--_Mh: var(--_D) var(--_mh, auto);min-height:var(--_Mh, auto)}.diagram-node{--_Jc: var(--_D) normal;justify-content:var(--_Jc, center)}.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-shape=participant][data-mark]>.diagram-mark+:is(.diagram-kind,.diagram-name){padding-inline:var(--basalt-space-6)}.diagram-node[data-shape=participant]>.diagram-mark{--_Pmp: var(--_D) absolute;position:var(--_Pmp, static);flex:none;margin-inline-end:var(--_Pmm, var(--basalt-space-1-5));--_Pmm: var(--_D) 0}.diagram-node[data-shape=participant][data-mark]{--_Pfd: var(--_D) column;flex-direction:var(--_Pfd, row)}.diagram-node[data-shape=participant][data-mark]>.diagram-mark+.diagram-name{--_Pnp: var(--_D) var(--basalt-space-6);padding-inline:var(--_Pnp, 0)}.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-node[data-link]{color:inherit;text-decoration:none;-webkit-tap-highlight-color:transparent}.diagram-name-end{white-space:nowrap}.diagram-node[data-link] .diagram-name-end:after{content:"";display:inline-block;width:var(--basalt-size-icon-sm);height:var(--basalt-size-icon-sm);margin-inline-start:var(--basalt-space-1-5);vertical-align:calc(-1 * var(--basalt-space-0-5));background:var(--basalt-text-secondary);mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.5 12L17.5 12M17.5 12L11.5 7M17.5 12L11.5 17' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;transition:transform var(--basalt-duration-base) var(--basalt-ease-out),background-color var(--basalt-duration-base) var(--basalt-ease-out)}.diagram-node[data-link=external] .diagram-name-end:after{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 17L17 7M9.5 7L17 7M17 7L17 14.5' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")}.diagram-node[data-link][data-focal] .diagram-name-end:after{background:var(--basalt-diagram-focal-ink);opacity:var(--basalt-opacity-amount)}.diagram-node[data-link]:is(:hover,:focus-visible) .diagram-name-end:after{background:var(--basalt-text-primary);transform:translate(var(--basalt-space-0-5))}.diagram-node[data-link][data-focal]:is(:hover,:focus-visible) .diagram-name-end:after{background:var(--basalt-diagram-focal-ink);opacity:1}.diagram-node[data-link]:is(:hover,:focus-visible) :is(.diagram-name,.diagram-tname){text-decoration:underline var(--basalt-size-hairline);text-underline-offset:var(--basalt-size-underline-offset)}.diagram-node[data-link]:active{background:light-dark(color-mix(in srgb,var(--basalt-neutral-0) 4%,var(--panel-next, var(--basalt-surface-1))),color-mix(in srgb,var(--basalt-neutral-100) 6%,var(--panel-next, var(--basalt-surface-1))))}@supports not (color: light-dark(white,black)){.diagram-node[data-link]:active{background:color-mix(in srgb,color-mix(in srgb,var(--basalt-neutral-100) 6%,var(--panel-next, var(--basalt-surface-1))) var(--_dkp),color-mix(in srgb,var(--basalt-neutral-0) 4%,var(--panel-next, var(--basalt-surface-1))))}}.diagram-node[data-link][data-focal]:active{background:var(--basalt-action-primary-press)}.diagram-node[data-link]:dir(rtl) .diagram-name-end:after{scale:-1 1}.diagram-node[data-link]:dir(rtl):is(:hover,:focus-visible) .diagram-name-end:after{transform:translate(calc(-1 * var(--basalt-space-0-5)))}@media(prefers-reduced-motion:reduce){.diagram-node[data-link]:is(:hover,:focus-visible) .diagram-name-end:after,.diagram-node[data-link]:dir(rtl):is(:hover,:focus-visible) .diagram-name-end:after{transform:none}}@media(pointer:coarse){.diagram-node[data-link]{min-height:var(--basalt-size-tap-min)}}@media(forced-colors:active){.diagram .diagram-node[data-link] :is(.diagram-name,.diagram-tname){color:LinkText;text-decoration:underline}.diagram .diagram-node[data-link] .diagram-name-end:after{forced-color-adjust:none;background:LinkText}.diagram .diagram-node[data-link][data-focal] :is(.diagram-name,.diagram-tname){color:Canvas}.diagram .diagram-node[data-link][data-focal] .diagram-name-end:after{background:Canvas}}.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{--_tl: 0}.diagram-group:first-child{margin-block-start:0}.diagram-group[data-turn]{padding-block-start:calc(var(--basalt-space-12) + var(--basalt-space-4) * var(--_tl, 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-group>.diagram-glabel{z-index:1;margin-inline-start:calc(-1 * var(--basalt-space-1-5));padding-inline:var(--basalt-space-1-5);background:var(--_ground)}.diagram-group>.diagram-glabel{inset-inline-start:calc(var(--basalt-space-3) + var(--_gx, var(--basalt-space-0)))}.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-block:calc(-1 * var(--_gt, 1) * var(--basalt-space-8)) calc(-1 * var(--_gb, 1) * var(--basalt-space-4));margin-inline:calc(-1 * var(--_gs, 1) * var(--basalt-space-4)) calc(-1 * var(--_ge, 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-gbox[data-depth="2"],.diagram-group[data-depth="2"]{border-radius:var(--basalt-radius-md)}.diagram-list-group[data-depth="2"],.diagram-list-items[data-depth="2"]{margin-inline-start:var(--basalt-space-5)}.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[data-type=sequence]>.diagram-drawing>.diagram-ink{z-index:auto}.diagram-lifes{position:absolute;top:0;left:0;z-index:0;overflow:visible}.diagram[data-type=sequence] .diagram-ink>.diagram-svg{z-index:2}.diagram[data-type=sequence] .diagram-steps{z-index:auto}.diagram[data-type=sequence] .diagram-msg :is(.diagram-said,.diagram-note){position:relative;z-index:3}.diagram[data-type=sequence] :is(.diagram-fhead,.diagram-felse){z-index:3}.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-crow{fill:none;stroke:var(--basalt-diagram-edge);stroke-width:var(--basalt-size-hairline);stroke-linecap:butt;stroke-linejoin:miter;transition:stroke var(--basalt-duration-fast) var(--basalt-ease-out)}.diagram-ring{fill:var(--_ground);stroke:var(--basalt-diagram-edge);stroke-width:var(--basalt-size-hairline);transition:stroke var(--basalt-duration-fast) var(--basalt-ease-out)}.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-edge[data-lit] :is(.diagram-crow,.diagram-ring){stroke:var(--basalt-diagram-edge-main)}.diagram-edge[data-dim] :is(.diagram-crow,.diagram-ring){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-lines="2"]{height:calc(2 * var(--basalt-text-xs-line-height))}.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{--_Ac: var(--_D) var(--_ac, auto);display:flex;min-width:0;grid-column:var(--_Ac, auto);grid-row:1}.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-frame+.diagram-msgs>.diagram-msg:first-child{border-top-color:transparent}.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;column-gap:var(--basalt-space-1);row-gap:0;flex-wrap:wrap;color:var(--basalt-text-secondary)}.diagram-to{display:inline-flex;align-items:center;gap:var(--basalt-space-1);white-space:nowrap}.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-bar{fill:var(--panel-next, var(--basalt-surface-1));stroke:var(--basalt-diagram-structure);stroke-width:var(--basalt-size-hairline);rx:var(--basalt-radius-2xs)}.diagram-frame{--_Fpi: var(--_D) 0;--_cw: calc((100% - (var(--_cols, 1) - 1) * var(--basalt-space-5)) / var(--_cols, 1));--_Fl: var(--_D) calc((var(--_a) - 1) * (var(--_cw) + var(--basalt-space-5)) + var(--_fis, 0) * var(--basalt-space-2));--_Fw: var(--_D) calc((var(--_b) - var(--_a)) * (var(--_cw) + var(--basalt-space-5)) - var(--basalt-space-5) - (var(--_fis, 0) + var(--_fie, 0)) * var(--basalt-space-2));--_fl: var(--_Fl, 0%);--_fw: var(--_Fw, 100%);--_Fel: var(--_D) var(--_fl);--_Few: var(--_D) var(--_fw);--_Fer: var(--_D) calc(100% - var(--_fl) - var(--_fw));position:relative;padding-block:var(--basalt-size-control-lg) var(--basalt-space-2);padding-inline:var(--_Fpi, var(--basalt-space-4))}.diagram-frame+.diagram-frame{margin-block-start:var(--basalt-space-2)}.diagram-frame[data-depth="2"]{--_Fl: var(--_D) calc((var(--_a) - 1) * (var(--_cw) + var(--basalt-space-5)) + var(--_fis, 0) * var(--basalt-space-2))}.diagram-fbox{position:absolute;inset-block:0;inset-inline-start:var(--_fl);z-index:1;box-sizing:border-box;width:var(--_fw);border:var(--basalt-size-hairline) solid var(--basalt-diagram-structure);border-radius:var(--basalt-radius-lg);pointer-events:none}.diagram-frame[data-depth="2"]>.diagram-fbox{border-radius:var(--basalt-radius-xs)}.diagram-fhead{position:absolute;top:var(--basalt-size-hairline);inset-inline-start:calc(var(--_fl) + var(--basalt-size-hairline));display:flex;align-items:flex-start;gap:var(--basalt-space-3);margin:0;white-space:nowrap}.diagram-ftab{padding:var(--basalt-space-1) var(--basalt-space-3);border-inline-end:var(--basalt-size-hairline) solid var(--basalt-diagram-structure);border-block-end:var(--basalt-size-hairline) solid var(--basalt-diagram-structure);border-end-end-radius:var(--basalt-radius-xs);background:var(--_ground);color:var(--basalt-text-primary);font:var(--basalt-font-weight-semibold) var(--bh-xs-mono)}.diagram-flabel{margin-block-start:var(--basalt-space-1);margin-inline-start:calc(-1 * var(--basalt-space-1-5));padding-inline:var(--basalt-space-1-5);background:var(--_ground);color:var(--basalt-text-secondary);font:var(--basalt-font-weight-medium) var(--bh-xs)}.diagram-felse{position:relative;display:flex;align-items:center;gap:var(--basalt-space-1-5);height:var(--basalt-size-control-sm);margin:0;padding-inline-start:calc(var(--_fl) + var(--basalt-space-3));white-space:nowrap}.diagram-felse:before{content:"";position:absolute;top:0;inset-inline-start:var(--_Fel, calc(-1 * var(--basalt-space-4)));width:var(--_Few, calc(100% + 2 * var(--basalt-space-4)));height:var(--basalt-size-hairline);background:var(--basalt-diagram-structure);mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2 1' preserveAspectRatio='none'%3E%3Crect width='1' height='1'/%3E%3C/svg%3E") 0 0 / calc(2 * var(--basalt-size-diagram-guide-dash)) var(--basalt-size-hairline) repeat-x}.diagram-felse .diagram-flabel{margin-block-start:0;margin-inline-start:0}.diagram-fword{margin-inline-start:calc(-1 * var(--basalt-space-1-5));padding-inline:var(--basalt-space-1-5);background:var(--_ground);color:var(--basalt-text-tertiary);font:var(--basalt-font-weight-regular) var(--bh-xs-mono)}.diagram-fword+.diagram-flabel{margin-inline-start:calc(-1 * var(--basalt-space-1-5))}.diagram-key-letters[data-op]{color:var(--basalt-text-primary);font-weight:var(--basalt-font-weight-semibold)}.diagram-text{box-sizing:border-box;margin:0;padding:var(--basalt-space-4);overflow:hidden;border:var(--basalt-size-hairline) solid var(--basalt-border-rim);border-top-color:var(--basalt-border-rim-top);border-radius:var(--basalt-radius-md);background:var(--basalt-surface-sunken);color:var(--basalt-text-secondary);direction:ltr;font:var(--basalt-font-weight-regular) var(--basalt-text-xs-size) / var(--basalt-size-code-line-height) var(--basalt-font-family-mono);white-space:pre-wrap;overflow-wrap:break-word}.diagram-text[data-art]{white-space:pre;overflow-wrap:normal}.diagram-drawing:has(>.diagram-text){max-width:none}.diagram-text .diagram-text-ink{font:inherit;padding:0;border:0;border-radius:0;background:none;color:inherit}.diagram-tx-name,.diagram-tx-to{white-space:nowrap;color:var(--basalt-text-primary)}.diagram-tx-line{display:block;padding-inline-start:calc(var(--_in, 0) * 1ch);text-indent:calc(-1 * var(--_hang, 0) * 1ch)}.diagram-text [data-ink=focal],.diagram-text [data-ink=op]{color:var(--basalt-text-primary);font-weight:var(--basalt-font-weight-semibold)}.diagram-text :is([data-ink=name],[data-ink=working],[data-ink=plain]){color:var(--basalt-text-secondary)}.diagram-text :is([data-ink=main],[data-ink=label]){color:var(--basalt-text-primary)}.diagram-text :is([data-ink=life],[data-ink=num],[data-ink=note],[data-ink=frame],[data-ink=band]){color:var(--basalt-text-tertiary)}.diagram-key-glyph{font:var(--basalt-font-weight-regular) var(--bh-xs-mono);color:var(--basalt-text-secondary)}.diagram-key-glyph[data-ink=main]{color:var(--basalt-text-primary)}.diagram-key-glyph[data-ink=focal]{color:var(--basalt-text-primary);font-weight:var(--basalt-font-weight-semibold)}@media(forced-colors:active){.diagram-text :is([data-ink]){color:CanvasText}}.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-tap-hint{display:none;margin:0;color:var(--basalt-text-tertiary);font:var(--basalt-font-weight-regular) var(--bh-xs)}.diagram[data-touch][data-layout=drawn]>.diagram-tap-hint,.diagram[data-touch][data-layout=stacked]:not([data-bare],[data-type=sequence],[data-type=schema])>.diagram-tap-hint{display:block}.diagram[data-touch]>.diagram-hint{display:none}.diagram[data-touch] .diagram-node{min-height:var(--basalt-size-tap-min)}@media(pointer:coarse){.diagram-clear{min-height:var(--basalt-size-tap-min)}}.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-crow,.diagram-ring,.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"]:not([data-marks]))>.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 >= 816px){.diagram:not([data-layout])[data-type=architecture][data-cols="4"][data-reach="3"]>.diagram-drawing{--_D: }}@container (width >= 832px){.diagram:not([data-layout])[data-type=architecture][data-cols="4"][data-reach="4"]>.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 >= 1024px){.diagram:not([data-layout])[data-type=architecture][data-cols="5"][data-reach="3"]>.diagram-drawing{--_D: }}@container (width >= 1040px){.diagram:not([data-layout])[data-type=architecture][data-cols="5"][data-reach="4"]>.diagram-drawing{--_D: }}@container (width >= 1040px){.diagram:not([data-layout])[data-type=schema][data-cols="4"]:not([data-marks])>.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 >= 1232px){.diagram:not([data-layout])[data-type=architecture][data-cols="6"][data-reach="3"]>.diagram-drawing{--_D: }}@container (width >= 1248px){.diagram:not([data-layout])[data-type=architecture][data-cols="6"][data-reach="4"]>.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"]:not([data-marks])>.diagram-drawing{--_D: }}@container (width >= 1584px){.diagram:not([data-layout])[data-type=schema][data-cols="6"]:not([data-marks])>.diagram-drawing{--_D: }}@container (width >= 792px){.diagram:not([data-layout])[data-type=schema][data-marks][data-cols="3"]>.diagram-drawing{--_D: }}@container (width >= 1076px){.diagram:not([data-layout])[data-type=schema][data-marks][data-cols="4"]>.diagram-drawing{--_D: }}@container (width >= 1360px){.diagram:not([data-layout])[data-type=schema][data-marks][data-cols="5"]>.diagram-drawing{--_D: }}@container (width >= 1644px){.diagram:not([data-layout])[data-type=schema][data-marks][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-lifes,.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 :is(.diagram-crow,.diagram-ring){stroke:CanvasText}.diagram .diagram-ring{fill:Canvas}.diagram .diagram-edge[data-dim] :is(.diagram-crow,.diagram-ring){stroke:GrayText}.diagram .diagram-edge[data-lit] :is(.diagram-crow,.diagram-ring){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-bar{fill:Canvas;stroke:CanvasText}.diagram .diagram-fbox,.diagram .diagram-ftab{border-color:GrayText}.diagram .diagram-felse:before{background:GrayText}.diagram :is(.diagram-ftab,.diagram-flabel,.diagram-fword){color:CanvasText;background:Canvas}.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-lifes,.diagram-swatch,.diagram-arrow,.diagram-mark,.diagram-node[data-focal]{-webkit-print-color-adjust:exact;print-color-adjust:exact}.diagram-hint,.diagram-tap-hint,.diagram-clear,.diagram-download{display:none!important}.diagram .diagram-edge :is(.diagram-line,.diagram-tip[data-open]){stroke:var(--basalt-diagram-edge)!important}.diagram .diagram-edge .diagram-line[data-kind=main]{stroke:var(--basalt-diagram-edge-main)!important}.diagram .diagram-edge :is(.diagram-tip:not([data-open]),.diagram-dot){fill:var(--basalt-diagram-edge)!important}.diagram .diagram-edge .diagram-tip[data-kind=main]:not([data-open]){fill:var(--basalt-diagram-edge-main)!important}.diagram .diagram-edge :is(.diagram-crow,.diagram-ring){stroke:var(--basalt-diagram-edge)!important}.diagram .diagram-label{color:var(--basalt-diagram-edge)!important}}.basalt-exporting,.basalt-exporting *{transition:none!important}.diagram-msg[data-ahead] .diagram-mlabel{color:var(--basalt-text-secondary);transition:color var(--basalt-duration-fast) var(--basalt-ease-out)}.diagram-edge[data-ahead] .diagram-line{stroke:var(--basalt-diagram-edge-dim)}.diagram-edge[data-ahead] .diagram-tip:not([data-open]){fill:var(--basalt-diagram-edge-dim)}.diagram-edge[data-ahead] .diagram-tip[data-open]{stroke:var(--basalt-diagram-edge-dim)}.diagram-text [data-n][data-ahead] [data-ink=label],.diagram[data-motion=animated][data-entrance=pending] .diagram-text [data-n] [data-ink=label]{color:var(--basalt-text-secondary)}.diagram-text [data-n][data-ahead] :is([data-ink=main],[data-ink=plain]),.diagram[data-motion=animated][data-entrance=pending] .diagram-text [data-n] :is([data-ink=main],[data-ink=plain]){color:var(--basalt-text-tertiary)}.diagram-text [data-n][data-arrival] [data-ink=num]{color:var(--basalt-text-primary)}@media(prefers-reduced-motion:reduce){.diagram-msg[data-ahead] .diagram-mlabel{transition:none}}@media(forced-colors:active){.diagram .diagram-msg[data-ahead] .diagram-mlabel{color:GrayText}.diagram .diagram-edge[data-ahead] .diagram-line{stroke:GrayText}.diagram .diagram-edge[data-ahead] .diagram-tip:not([data-open]){fill:GrayText}.diagram .diagram-edge[data-ahead] .diagram-tip[data-open]{stroke:GrayText}.diagram .diagram-text [data-n][data-ahead] [data-ink]{color:GrayText}.diagram .diagram-text [data-n][data-arrival] [data-ink=num]{color:Highlight}}@media print{.diagram .diagram-msg[data-ahead] .diagram-mlabel{color:var(--basalt-text-primary)!important}}} +: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-activation: 8px;--basalt-size-diagram-foot: 14px;--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(--_gw, 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);--_Rows: var(--_D) var(--_rows, none);display:grid;grid-template-columns:var(--_Cols, repeat(auto-fit, minmax(min(100%, var(--_track, var(--basalt-size-diagram-table))), 1fr)));grid-template-rows:var(--_Rows, none);gap:var(--_Gap, var(--basalt-space-4));align-items:start;max-width:none}.diagram:not([data-type=sequence])[data-cols="1"]>.diagram-drawing{--_Max: var(--_D) max(var(--basalt-size-breakpoint-container), var(--_one, var(--basalt-size-breakpoint-container)))}.diagram[data-type=schema][data-cols="1"]>.diagram-drawing{max-width:var(--_Max, none)}.diagram[data-type=schema][data-marks]>.diagram-drawing{--_col-gap: calc(var(--basalt-space-12) + var(--basalt-space-3))}.diagram[data-type=sequence]>.diagram-drawing{display:flex;gap:0}.diagram[data-rtl]>.diagram-drawing{direction:ltr}.diagram[data-rtl]>.diagram-drawing{padding:var(--_Pad, 0 0 0 var(--_gutter, 0))}.diagram[data-rtl] .diagram-node[data-branch]{margin-inline:var(--_Mi, var(--basalt-space-6) var(--basalt-space-12))}.diagram[data-rtl]>.diagram-drawing :is(.diagram-node>:not(.diagram-mark),.diagram-lane-name,.diagram-said,.diagram-note,.diagram-band,.diagram-fhead,.diagram-felse){direction:rtl}.diagram[data-rtl] .diagram-gbox>.diagram-glabel{inset-inline:auto var(--basalt-space-3)}.diagram[data-rtl] .diagram-group>.diagram-glabel{inset-inline:auto calc(var(--basalt-space-3) + var(--_gx, var(--basalt-space-0)));margin-inline:0 calc(-1 * var(--basalt-space-1-5))}.diagram[data-rtl] .diagram-runs{direction:ltr;unicode-bidi:isolate}.diagram[data-rtl] .diagram-fhead{inset-inline-start:calc(100% - var(--_fl) - var(--_fw) + var(--basalt-size-hairline))}.diagram[data-rtl] .diagram-felse{padding-inline-start:calc(100% - var(--_fl) - var(--_fw) + var(--basalt-space-3))}.diagram[data-rtl] .diagram-felse:before{inset-inline-start:var(--_Fer, calc(-1 * var(--basalt-space-4)))}.diagram[data-rtl] .diagram-msg[data-self=end] :is(.diagram-said,.diagram-note){--_Sj: var(--_D) left;margin-inline-start:0;margin-inline-end:var(--_Sm, 0)}.diagram[data-rtl] .diagram-msg[data-self=start] :is(.diagram-said,.diagram-note){--_Sj: var(--_D) right;margin-inline-end:0;margin-inline-start:var(--_Sm, 0)}.diagram[data-rtl] :is(.diagram-run,.diagram-mlabel,.diagram-tname,.diagram-cname,.diagram-ctype,.diagram-label,.diagram-glabel,.diagram-kind){unicode-bidi:isolate}.diagram[data-rtl] :is(.diagram-run,.diagram-mlabel,.diagram-cname,.diagram-label){direction:ltr}.diagram[data-rtl] .diagram-arrow{scale:-1 1}.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{--_Mh: var(--_D) var(--_mh, auto);min-height:var(--_Mh, auto)}.diagram-node{--_Jc: var(--_D) normal;justify-content:var(--_Jc, center)}.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-shape=participant][data-mark]>.diagram-mark+:is(.diagram-kind,.diagram-name){padding-inline:var(--basalt-space-6)}.diagram-node[data-shape=participant]>.diagram-mark{--_Pmp: var(--_D) absolute;position:var(--_Pmp, static);flex:none;margin-inline-end:var(--_Pmm, var(--basalt-space-1-5));--_Pmm: var(--_D) 0}.diagram-node[data-shape=participant][data-mark]{--_Pfd: var(--_D) column;flex-direction:var(--_Pfd, row)}.diagram-node[data-shape=participant][data-mark]>.diagram-mark+.diagram-name{--_Pnp: var(--_D) var(--basalt-space-6);padding-inline:var(--_Pnp, 0)}.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-node[data-link]{color:inherit;text-decoration:none;-webkit-tap-highlight-color:transparent}.diagram-name-end{white-space:nowrap}.diagram-node[data-link] .diagram-name-end:after{content:"";display:inline-block;width:var(--basalt-size-icon-sm);height:var(--basalt-size-icon-sm);margin-inline-start:var(--basalt-space-1-5);vertical-align:calc(-1 * var(--basalt-space-0-5));background:var(--basalt-text-secondary);mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.5 12L17.5 12M17.5 12L11.5 7M17.5 12L11.5 17' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;transition:transform var(--basalt-duration-base) var(--basalt-ease-out),background-color var(--basalt-duration-base) var(--basalt-ease-out)}.diagram-node[data-link=external] .diagram-name-end:after{mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 17L17 7M9.5 7L17 7M17 7L17 14.5' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")}.diagram-node[data-link][data-focal] .diagram-name-end:after{background:var(--basalt-diagram-focal-ink);opacity:var(--basalt-opacity-amount)}.diagram-node[data-link]:is(:hover,:focus-visible) .diagram-name-end:after{background:var(--basalt-text-primary);transform:translate(var(--basalt-space-0-5))}.diagram-node[data-link][data-focal]:is(:hover,:focus-visible) .diagram-name-end:after{background:var(--basalt-diagram-focal-ink);opacity:1}.diagram-node[data-link]:is(:hover,:focus-visible) :is(.diagram-name,.diagram-tname){text-decoration:underline var(--basalt-size-hairline);text-underline-offset:var(--basalt-size-underline-offset)}.diagram-node[data-link]:active{background:light-dark(color-mix(in srgb,var(--basalt-neutral-0) 4%,var(--panel-next, var(--basalt-surface-1))),color-mix(in srgb,var(--basalt-neutral-100) 6%,var(--panel-next, var(--basalt-surface-1))))}@supports not (color: light-dark(white,black)){.diagram-node[data-link]:active{background:color-mix(in srgb,color-mix(in srgb,var(--basalt-neutral-100) 6%,var(--panel-next, var(--basalt-surface-1))) var(--_dkp),color-mix(in srgb,var(--basalt-neutral-0) 4%,var(--panel-next, var(--basalt-surface-1))))}}.diagram-node[data-link][data-focal]:active{background:var(--basalt-action-primary-press)}.diagram-node[data-link]:dir(rtl) .diagram-name-end:after{scale:-1 1}.diagram-node[data-link]:dir(rtl):is(:hover,:focus-visible) .diagram-name-end:after{transform:translate(calc(-1 * var(--basalt-space-0-5)))}@media(prefers-reduced-motion:reduce){.diagram-node[data-link]:is(:hover,:focus-visible) .diagram-name-end:after,.diagram-node[data-link]:dir(rtl):is(:hover,:focus-visible) .diagram-name-end:after{transform:none}}@media(pointer:coarse){.diagram-node[data-link]{min-height:var(--basalt-size-tap-min)}}@media(forced-colors:active){.diagram .diagram-node[data-link] :is(.diagram-name,.diagram-tname){color:LinkText;text-decoration:underline}.diagram .diagram-node[data-link] .diagram-name-end:after{forced-color-adjust:none;background:LinkText}.diagram .diagram-node[data-link][data-focal] :is(.diagram-name,.diagram-tname){color:Canvas}.diagram .diagram-node[data-link][data-focal] .diagram-name-end:after{background:Canvas}}.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{--_tl: 0}.diagram-group:first-child{margin-block-start:0}.diagram-group[data-turn]{padding-block-start:calc(var(--basalt-space-12) + var(--basalt-space-4) * var(--_tl, 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-group>.diagram-glabel{z-index:1;margin-inline-start:calc(-1 * var(--basalt-space-1-5));padding-inline:var(--basalt-space-1-5);background:var(--_ground)}.diagram-group>.diagram-glabel{inset-inline-start:calc(var(--basalt-space-3) + var(--_gx, var(--basalt-space-0)))}.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-block:calc(-1 * var(--_gt, 1) * var(--basalt-space-8)) calc(-1 * var(--_gb, 1) * var(--basalt-space-4));margin-inline:calc(-1 * var(--_gs, 1) * var(--basalt-space-4)) calc(-1 * var(--_ge, 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-gbox[data-depth="2"],.diagram-group[data-depth="2"]{border-radius:var(--basalt-radius-md)}.diagram-list-group[data-depth="2"],.diagram-list-items[data-depth="2"]{margin-inline-start:var(--basalt-space-5)}.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[data-type=sequence]>.diagram-drawing>.diagram-ink{z-index:auto}.diagram-lifes{position:absolute;top:0;left:0;z-index:0;overflow:visible}.diagram[data-type=sequence] .diagram-ink>.diagram-svg{z-index:2}.diagram[data-type=sequence] .diagram-steps{z-index:auto}.diagram[data-type=sequence] .diagram-msg :is(.diagram-said,.diagram-note){position:relative;z-index:3}.diagram[data-type=sequence] :is(.diagram-fhead,.diagram-felse){z-index:3}.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-crow{fill:none;stroke:var(--basalt-diagram-edge);stroke-width:var(--basalt-size-hairline);stroke-linecap:butt;stroke-linejoin:miter;transition:stroke var(--basalt-duration-fast) var(--basalt-ease-out)}.diagram-ring{fill:var(--_ground);stroke:var(--basalt-diagram-edge);stroke-width:var(--basalt-size-hairline);transition:stroke var(--basalt-duration-fast) var(--basalt-ease-out)}.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-edge[data-lit] :is(.diagram-crow,.diagram-ring){stroke:var(--basalt-diagram-edge-main)}.diagram-edge[data-dim] :is(.diagram-crow,.diagram-ring){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-lines="2"]{height:calc(2 * var(--basalt-text-xs-line-height))}.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{--_Ac: var(--_D) var(--_ac, auto);display:flex;min-width:0;grid-column:var(--_Ac, auto);grid-row:1}.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-frame+.diagram-msgs>.diagram-msg:first-child{border-top-color:transparent}.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;column-gap:var(--basalt-space-1);row-gap:0;flex-wrap:wrap;color:var(--basalt-text-secondary)}.diagram-to{display:inline-flex;align-items:center;gap:var(--basalt-space-1);white-space:nowrap}.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-bar{fill:var(--panel-next, var(--basalt-surface-1));stroke:var(--basalt-diagram-structure);stroke-width:var(--basalt-size-hairline);rx:var(--basalt-radius-2xs)}.diagram-frame{--_Fpi: var(--_D) 0;--_cw: calc((100% - (var(--_cols, 1) - 1) * var(--basalt-space-5)) / var(--_cols, 1));--_Fl: var(--_D) calc((var(--_a) - 1) * (var(--_cw) + var(--basalt-space-5)) + var(--_fis, 0) * var(--basalt-space-2));--_Fw: var(--_D) calc((var(--_b) - var(--_a)) * (var(--_cw) + var(--basalt-space-5)) - var(--basalt-space-5) - (var(--_fis, 0) + var(--_fie, 0)) * var(--basalt-space-2));--_fl: var(--_Fl, 0%);--_fw: var(--_Fw, 100%);--_Fel: var(--_D) var(--_fl);--_Few: var(--_D) var(--_fw);--_Fer: var(--_D) calc(100% - var(--_fl) - var(--_fw));position:relative;padding-block:var(--basalt-size-control-lg) var(--basalt-space-2);padding-inline:var(--_Fpi, var(--basalt-space-4))}.diagram-frame+.diagram-frame{margin-block-start:var(--basalt-space-2)}.diagram-frame[data-depth="2"]{--_Fl: var(--_D) calc((var(--_a) - 1) * (var(--_cw) + var(--basalt-space-5)) + var(--_fis, 0) * var(--basalt-space-2))}.diagram-fbox{position:absolute;inset-block:0;inset-inline-start:var(--_fl);z-index:1;box-sizing:border-box;width:var(--_fw);border:var(--basalt-size-hairline) solid var(--basalt-diagram-structure);border-radius:var(--basalt-radius-lg);pointer-events:none}.diagram-frame[data-depth="2"]>.diagram-fbox{border-radius:var(--basalt-radius-xs)}.diagram-fhead{position:absolute;top:var(--basalt-size-hairline);inset-inline-start:calc(var(--_fl) + var(--basalt-size-hairline));display:flex;align-items:flex-start;gap:var(--basalt-space-3);margin:0;white-space:nowrap}.diagram-ftab{padding:var(--basalt-space-1) var(--basalt-space-3);border-inline-end:var(--basalt-size-hairline) solid var(--basalt-diagram-structure);border-block-end:var(--basalt-size-hairline) solid var(--basalt-diagram-structure);border-end-end-radius:var(--basalt-radius-xs);background:var(--_ground);color:var(--basalt-text-primary);font:var(--basalt-font-weight-semibold) var(--bh-xs-mono)}.diagram-flabel{margin-block-start:var(--basalt-space-1);margin-inline-start:calc(-1 * var(--basalt-space-1-5));padding-inline:var(--basalt-space-1-5);background:var(--_ground);color:var(--basalt-text-secondary);font:var(--basalt-font-weight-medium) var(--bh-xs)}.diagram-felse{position:relative;display:flex;align-items:center;gap:var(--basalt-space-1-5);height:var(--basalt-size-control-sm);margin:0;padding-inline-start:calc(var(--_fl) + var(--basalt-space-3));white-space:nowrap}.diagram-felse:before{content:"";position:absolute;top:0;inset-inline-start:var(--_Fel, calc(-1 * var(--basalt-space-4)));width:var(--_Few, calc(100% + 2 * var(--basalt-space-4)));height:var(--basalt-size-hairline);background:var(--basalt-diagram-structure);mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 2 1' preserveAspectRatio='none'%3E%3Crect width='1' height='1'/%3E%3C/svg%3E") 0 0 / calc(2 * var(--basalt-size-diagram-guide-dash)) var(--basalt-size-hairline) repeat-x}.diagram-felse .diagram-flabel{margin-block-start:0;margin-inline-start:0}.diagram-fword{margin-inline-start:calc(-1 * var(--basalt-space-1-5));padding-inline:var(--basalt-space-1-5);background:var(--_ground);color:var(--basalt-text-tertiary);font:var(--basalt-font-weight-regular) var(--bh-xs-mono)}.diagram-fword+.diagram-flabel{margin-inline-start:calc(-1 * var(--basalt-space-1-5))}.diagram-key-letters[data-op]{color:var(--basalt-text-primary);font-weight:var(--basalt-font-weight-semibold)}.diagram-text{box-sizing:border-box;margin:0;padding:var(--basalt-space-4);overflow:hidden;border:var(--basalt-size-hairline) solid var(--basalt-border-rim);border-top-color:var(--basalt-border-rim-top);border-radius:var(--basalt-radius-md);background:var(--basalt-surface-sunken);color:var(--basalt-text-secondary);direction:ltr;font:var(--basalt-font-weight-regular) var(--basalt-text-xs-size) / var(--basalt-size-code-line-height) var(--basalt-font-family-mono);white-space:pre-wrap;overflow-wrap:break-word}.diagram-text[data-art]{white-space:pre;overflow-wrap:normal}.diagram-drawing:has(>.diagram-text){max-width:none}.diagram-text .diagram-text-ink{font:inherit;padding:0;border:0;border-radius:0;background:none;color:inherit}.diagram-tx-name,.diagram-tx-to{white-space:nowrap;color:var(--basalt-text-primary)}.diagram-tx-line{display:block;padding-inline-start:calc(var(--_in, 0) * 1ch);text-indent:calc(-1 * var(--_hang, 0) * 1ch)}.diagram-text [data-ink=focal],.diagram-text [data-ink=op]{color:var(--basalt-text-primary);font-weight:var(--basalt-font-weight-semibold)}.diagram-text :is([data-ink=name],[data-ink=working],[data-ink=plain]){color:var(--basalt-text-secondary)}.diagram-text :is([data-ink=main],[data-ink=label]){color:var(--basalt-text-primary)}.diagram-text :is([data-ink=life],[data-ink=num],[data-ink=note],[data-ink=frame],[data-ink=band]){color:var(--basalt-text-tertiary)}.diagram-key-glyph{font:var(--basalt-font-weight-regular) var(--bh-xs-mono);color:var(--basalt-text-secondary)}.diagram-key-glyph[data-ink=main]{color:var(--basalt-text-primary)}.diagram-key-glyph[data-ink=focal]{color:var(--basalt-text-primary);font-weight:var(--basalt-font-weight-semibold)}@media(forced-colors:active){.diagram-text :is([data-ink]){color:CanvasText}}.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-tap-hint{display:none;margin:0;color:var(--basalt-text-tertiary);font:var(--basalt-font-weight-regular) var(--bh-xs)}.diagram[data-touch][data-layout=drawn]>.diagram-tap-hint,.diagram[data-touch][data-layout=stacked]:not([data-bare],[data-type=sequence],[data-type=schema])>.diagram-tap-hint{display:block}.diagram[data-touch]>.diagram-hint{display:none}.diagram[data-touch] .diagram-node{min-height:var(--basalt-size-tap-min)}@media(pointer:coarse){.diagram-clear{min-height:var(--basalt-size-tap-min)}}.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-crow,.diagram-ring,.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"]:not([data-marks]))>.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 >= 816px){.diagram:not([data-layout])[data-type=architecture][data-cols="4"][data-reach="3"]>.diagram-drawing{--_D: }}@container (width >= 832px){.diagram:not([data-layout])[data-type=architecture][data-cols="4"][data-reach="4"]>.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 >= 1024px){.diagram:not([data-layout])[data-type=architecture][data-cols="5"][data-reach="3"]>.diagram-drawing{--_D: }}@container (width >= 1040px){.diagram:not([data-layout])[data-type=architecture][data-cols="5"][data-reach="4"]>.diagram-drawing{--_D: }}@container (width >= 1040px){.diagram:not([data-layout])[data-type=schema][data-cols="4"]:not([data-marks])>.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 >= 1232px){.diagram:not([data-layout])[data-type=architecture][data-cols="6"][data-reach="3"]>.diagram-drawing{--_D: }}@container (width >= 1248px){.diagram:not([data-layout])[data-type=architecture][data-cols="6"][data-reach="4"]>.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"]:not([data-marks])>.diagram-drawing{--_D: }}@container (width >= 1584px){.diagram:not([data-layout])[data-type=schema][data-cols="6"]:not([data-marks])>.diagram-drawing{--_D: }}@container (width >= 792px){.diagram:not([data-layout])[data-type=schema][data-marks][data-cols="3"]>.diagram-drawing{--_D: }}@container (width >= 1076px){.diagram:not([data-layout])[data-type=schema][data-marks][data-cols="4"]>.diagram-drawing{--_D: }}@container (width >= 1360px){.diagram:not([data-layout])[data-type=schema][data-marks][data-cols="5"]>.diagram-drawing{--_D: }}@container (width >= 1644px){.diagram:not([data-layout])[data-type=schema][data-marks][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-lifes,.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 :is(.diagram-crow,.diagram-ring){stroke:CanvasText}.diagram .diagram-ring{fill:Canvas}.diagram .diagram-edge[data-dim] :is(.diagram-crow,.diagram-ring){stroke:GrayText}.diagram .diagram-edge[data-lit] :is(.diagram-crow,.diagram-ring){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-bar{fill:Canvas;stroke:CanvasText}.diagram .diagram-fbox,.diagram .diagram-ftab{border-color:GrayText}.diagram .diagram-felse:before{background:GrayText}.diagram :is(.diagram-ftab,.diagram-flabel,.diagram-fword){color:CanvasText;background:Canvas}.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-lifes,.diagram-swatch,.diagram-arrow,.diagram-mark,.diagram-node[data-focal]{-webkit-print-color-adjust:exact;print-color-adjust:exact}.diagram-hint,.diagram-tap-hint,.diagram-foot{display:none!important}.diagram .diagram-edge :is(.diagram-line,.diagram-tip[data-open]){stroke:var(--basalt-diagram-edge)!important}.diagram .diagram-edge .diagram-line[data-kind=main]{stroke:var(--basalt-diagram-edge-main)!important}.diagram .diagram-edge :is(.diagram-tip:not([data-open]),.diagram-dot){fill:var(--basalt-diagram-edge)!important}.diagram .diagram-edge .diagram-tip[data-kind=main]:not([data-open]){fill:var(--basalt-diagram-edge-main)!important}.diagram .diagram-edge :is(.diagram-crow,.diagram-ring){stroke:var(--basalt-diagram-edge)!important}.diagram .diagram-label{color:var(--basalt-diagram-edge)!important}}.basalt-exporting,.basalt-exporting *{transition:none!important}.diagram-msg[data-ahead] .diagram-mlabel{color:var(--basalt-text-secondary);transition:color var(--basalt-duration-fast) var(--basalt-ease-out)}.diagram-edge[data-ahead] .diagram-line{stroke:var(--basalt-diagram-edge-dim)}.diagram-edge[data-ahead] .diagram-tip:not([data-open]){fill:var(--basalt-diagram-edge-dim)}.diagram-edge[data-ahead] .diagram-tip[data-open]{stroke:var(--basalt-diagram-edge-dim)}.diagram-text [data-n][data-ahead] [data-ink=label],.diagram[data-motion=animated][data-entrance=pending] .diagram-text [data-n] [data-ink=label]{color:var(--basalt-text-secondary)}.diagram-text [data-n][data-ahead] :is([data-ink=main],[data-ink=plain]),.diagram[data-motion=animated][data-entrance=pending] .diagram-text [data-n] :is([data-ink=main],[data-ink=plain]){color:var(--basalt-text-tertiary)}.diagram-text [data-n][data-arrival] [data-ink=num]{color:var(--basalt-text-primary)}@media(prefers-reduced-motion:reduce){.diagram-msg[data-ahead] .diagram-mlabel{transition:none}}@media(forced-colors:active){.diagram .diagram-msg[data-ahead] .diagram-mlabel{color:GrayText}.diagram .diagram-edge[data-ahead] .diagram-line{stroke:GrayText}.diagram .diagram-edge[data-ahead] .diagram-tip:not([data-open]){fill:GrayText}.diagram .diagram-edge[data-ahead] .diagram-tip[data-open]{stroke:GrayText}.diagram .diagram-text [data-n][data-ahead] [data-ink]{color:GrayText}.diagram .diagram-text [data-n][data-arrival] [data-ink=num]{color:Highlight}}@media print{.diagram .diagram-msg[data-ahead] .diagram-mlabel{color:var(--basalt-text-primary)!important}}} diff --git a/.agent/skills/basalt-html/parts/diagram.js b/.agent/skills/basalt-html/parts/diagram.js index a91065f9..563dccd1 100644 --- a/.agent/skills/basalt-html/parts/diagram.js +++ b/.agent/skills/basalt-html/parts/diagram.js @@ -1,6 +1,6 @@ -(()=>{var fn=["top","right","bottom","left"],un=["main","plain","dashed"],we=["one","zero-or-one","one-or-many","zero-or-many"],Ht={one:"Exactly one","zero-or-one":"Zero or one","one-or-many":"One or many","zero-or-many":"Zero or many"},hn=[2,3,4,5,6],ht=t=>t==null||t===""?void 0:String(t),Lt=t=>Object.assign(Object.create(null),t),Ot=(t,e)=>t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;function Nt(t,e={}){const o=e.checks!==!1,c=[],l=$=>{c.push($)},s=[],r=$=>{s.push($)},a=t.legend??{},d={};for(const $ of["main","plain","dashed","focal","group","activation"]){const u=ht(a[$]);u&&(d[$]=u)}const g=t.stepLabel,f=typeof g=="function"?$=>String(g($)):typeof g=="string"?($=>g.replace("{n}",String($))):$=>`Step ${$}`,i=t.shapeLabels??{},h={terminal:ht(i.terminal)??"Start or end",step:ht(i.step)??"Step",decision:ht(i.decision)??"Decision"},b=t.heading===void 0?3:hn.includes(t.heading)?t.heading:(l(`heading ${String(t.heading)} is not a level from 2 to 6: the title is an h3`),3),p=($,u)=>$==null?"plain":un.includes($)?$:(l(`"${String($)}" is not a kind of line (main, plain or dashed): ${u} is drawn plain`),"plain"),m=$=>{if($!=null){if(fn.includes($))return $;l(`"${String($)}" is not a side (top, right, bottom or left): the derived side is used`)}},M=($,u)=>typeof $=="number"&&Number.isInteger($)&&$>=1?$:(t.layout==="auto"&&$==null||l(`${u} is ${JSON.stringify($)}, not a whole number from 1: it is placed at 1`),1),L=[],z=[];let v=[];const O=[],B=[],j=t.type;if(["architecture","flowchart","data-flow","sequence","schema"].includes(j)||l(`"${String(j)}" is not a type of diagram (architecture, flowchart, data-flow, sequence or schema)`),j==="architecture"||j==="flowchart"){for(const $ of t.nodes??[]){const u=j==="flowchart"&&$.shape==="decision"?"decision":j==="flowchart"&&$.shape==="terminal"?"terminal":"box",w=String($.id??""),C=M($.row,`the row of ${w}`);L.push({id:w,i:L.length,name:String($.name??""),kind:u==="decision"?void 0:ht($.kind),detail:u==="decision"?void 0:ht($.detail),mono:!!$.detailMono,focal:!!$.focal,col:M($.col,`the column of ${w}`),row:C,row2:C,branch:!!$.branch,shape:u,group:j==="architecture"?ht($.group):void 0,mark:j==="architecture"?oe($.mark,l):void 0})}if(j==="architecture"){const $=(t.groups??[]).map(I=>({id:String(I.id??""),label:String(I.label??""),parent:ht(I.parent)})),u=new Map($.map(I=>[I.id,I])),w=I=>{if(!I.parent)return 1;const _=u.get(I.parent);return _?_.parent===I.id||_.id===I.id?(r(`the groups "${I.label}" and "${_.label}" are each other's parent`),I.parent=void 0,1):_.parent?(r(`the group "${I.label}" is a third level: groups nest two deep`),I.parent=void 0,1):2:(r(`the group "${I.label}" names the parent "${I.parent}", which is not a group`),I.parent=void 0,1)},C=$.map(w);$.forEach((I,_)=>O.push({...I,depth:C[_],members:L.filter(X=>X.group===I.id).map(X=>X.id),all:[]}));for(const I of O)I.all=[...I.members,...O.filter(_=>_.parent===I.id).flatMap(_=>_.members)];O.sort((I,_)=>I.depth-_.depth)}}else if(j==="data-flow"){v=(t.lanes??[]).map(u=>({id:String(u.id??""),label:String(u.label??"")}));const $=new Map(v.map((u,w)=>[u.id,w+1]));for(const u of t.nodes??[]){const w=String(u.id??""),C=String(u.lane??""),I=$.get(C);I===void 0&&l(`a node (${w}) names the lane "${C}", which is not in lanes`);const _=L.length+1;L.push({id:w,i:L.length,name:String(u.name??""),kind:f(_),detail:ht(u.detail),mono:!!u.detailMono,focal:!!u.focal,col:M(u.col,`the column of ${w}`),row:I??1,row2:I??1,branch:!1,shape:"box",lane:I??1,laneLabel:v[(I??1)-1]?.label??C,step:_,mark:oe(u.mark)})}}else if(j==="sequence"){(t.participants??[]).forEach((C,I)=>{const _=String(C.name??"");L.push({id:String(C.id??""),i:I,name:_,kind:ht(C.kind),mono:!1,focal:!!C.focal,col:I+1,row:1,row2:1,branch:!1,shape:"participant",short:ht(C.short)??_,mark:oe(C.mark)})});let $=0;const u=new Map(L.map(C=>[C.id,C.col])),w=(C,I)=>{let _=1/0,X=-1/0;for(const V of C??[]){if(!V||typeof V!="object")continue;if("band"in V){I>0&&r(`the band "${String(V.band)}" is inside a frame: a band is the whole figure's`),B.push({band:String(V.band??"")});continue}if("frame"in V){if(I>=2){r("a frame is a third level: frames nest two deep");continue}const $t=V.frame==="alt"||V.frame==="loop"||V.frame==="opt"?V.frame:"opt",bt=$t==="alt"?V.branches??[]:[{label:V.label,steps:V.steps}];$t==="alt"&&bt.length<2&&r("an alt frame has one branch: it needs two or more");const wt=String(bt[0]?.label??"");wt.length>40&&r(`the frame label "${wt}" is over 40 characters`);const vt=B.length;B.push({open:$t,label:wt,depth:I+1,a:0,b:0}),bt.forEach((y,S)=>{if(S){const W=String(y.label??"");W.length>40&&r(`the frame label "${W}" is over 40 characters`),B.push({otherwise:W,depth:I+1})}y.steps?.length||r(`a frame or branch ("${String(y.label??"")}") is empty`);const[E,k]=w(y.steps??[],I+1);_=Math.min(_,E),X=Math.max(X,k);const A=B[vt];A.a=Math.min(A.a||1/0,E),A.b=Math.max(A.b,k)}),B.push({close:I+1});continue}$++;const ft=String(V.label??"");ft.includes(` -`)&&r(`message ${$}'s label has a break: a message's second line is its note`);const st=String(V.from??""),lt=String(V.to??"");B.push({n:$,from:st,to:lt,label:qt(ft),note:ht(V.note),kind:p(V.kind,`message ${$}`),activate:V.activate===!0||void 0,deactivate:V.deactivate===!0||void 0});const pt=u.get(st)??1,kt=u.get(lt)??1,ut=pt===kt?pt===L.length?pt-1:pt+1:pt;_=Math.min(_,pt,kt,ut),X=Math.max(X,pt,kt,ut)}return[_,X]};w(t.steps??[],0);for(const C of B)"open"in C&&!Number.isFinite(C.a)&&(C.a=1,C.b=Math.max(1,L.length))}else if(j==="schema")for(const $ of t.tables??[]){const u=String($.name??""),[w,C]=Array.isArray($.row)?$.row:[$.row,$.row],I=M(w,`the row of ${u}`),_=Math.max(I,M(C,`the last row of ${u}`)),X=$.more===void 0||$.more===null?void 0:Number.isInteger($.more)&&$.more>0?$.more:(l(`${u}'s "more" is ${JSON.stringify($.more)}, not a whole number from 1: it is left out`),void 0);L.push({id:u,i:L.length,name:u,mono:!0,focal:!!$.focal,col:M($.col,`the column of ${u}`),row:I,row2:_,branch:!1,shape:"table",more:X,columns:($.columns??[]).map(V=>({name:String(V.name??""),type:ht(V.type),key:V.key==="PK"||V.key==="FK"?V.key:(V.key!==void 0&&V.key!==null&&l(`${u}.${String(V.name)}'s key is "${String(V.key)}", not PK or FK: it is left out`),void 0)}))})}let F=!1;if(t.layout==="auto"&&(j==="architecture"||j==="flowchart"||j==="schema")){const $=j==="schema"?t.tables:t.nodes;o&&($??[]).some(w=>w&&(w.col!==void 0||w.row!==void 0))&&l('a card under layout="auto" has a col or row, which is not read: there are no hints');const u=e.placement?.cells;u||(F=!0);for(const w of L){const C=u?.[w.id];w.col=C?.col??1,w.row=w.row2=C?.row??1}if(u){const w=new Map;for(const C of L){const I=Ot(u,C.id);if(!I){F=!0,l(`the placement has no cell for ${C.id}, so it is not used`);continue}const _=`${I.col},${I.row}`;w.has(_)&&(F=!0,l(`the placement puts ${w.get(_)} and ${C.id} in one cell, so it is not used`)),w.set(_,C.id)}}if(u&&!F)for(const w of O){const C=w.all.map(st=>L.find(lt=>lt.id===st)).filter(Boolean);if(!C.length)continue;const I=Math.min(...C.map(st=>st.col)),_=Math.max(...C.map(st=>st.col)),X=Math.min(...C.map(st=>st.row)),V=Math.max(...C.map(st=>st.row)),ft=L.filter(st=>!w.all.includes(st.id)&&st.col>=I&&st.col<=_&&st.row>=X&&st.row<=V);ft.length&&(F=!0,l(`the placement puts ${ft.map(st=>st.id).join(", ")} inside the box of the group "${w.label}", so it is not used`))}}else t.layout==="auto"&&r(`layout="auto" is for an architecture, a flowchart or a schema, not a ${j}`);((j==="schema"?t.tables:j==="sequence"?t.participants:t.nodes)??[]).forEach(($,u)=>{if(!$||$.href===void 0||$.href===null)return;const w=String($.href);if(j==="sequence"){r(`${L[u]?.id}: a participant cannot be a link (href)`);return}if(!w.trim()){r(`${L[u]?.id}'s href is empty`);return}const C=L[u];C&&(C.href=w,C.blank=$.target==="_blank")});const q=new Map;for(const $ of L)$.id?q.has($.id)&&l(`the id "${$.id}" is used twice`):l("a node has no id"),q.set($.id,$);if(j==="schema"){const $=(w,C)=>{if(w==null)return;const I=w,_=we.includes(I.from)?I.from:void 0;if(!_){r(`${C}'s cardinality "from" is ${JSON.stringify(I.from)}, not one, zero-or-one, one-or-many or zero-or-many: it is left out`);return}return I.to===void 0||I.to===null?{from:_,to:"one"}:I.to==="one"||I.to==="zero-or-one"?{from:_,to:I.to}:(r(`${C}'s cardinality "to" is ${JSON.stringify(I.to)}: a foreign key references one row at most (one or zero-or-one), so it is drawn as one`),{from:_,to:"one"})};(t.tables??[]).forEach(w=>(w.columns??[]).forEach((C,I)=>{const _=ht(C.references);if(!_&&C.cardinality!==void 0&&C.cardinality!==null&&r(`${String(w.name)}.${String(C.name)} states a cardinality but references nothing`),!_)return;const[X,V]=_.split("."),ft=q.get(X??""),st=ft?.columns?.findIndex(kt=>kt.name===V)??-1;if(!ft||st<0){l(`${String(w.name)}.${String(C.name)} references ${_}, which is not a shown column`);return}const lt=q.get(String(w.name??""));lt.columns[I].ref={table:X,column:V,row:st};const pt=$(C.cardinality,`${String(w.name)}.${String(C.name)}`);pt&&(lt.columns[I].card=pt),z.push({i:z.length,from:lt.id,to:X,kind:"plain",fromRow:I,toRow:st,fk:!0,card:pt})}));const u=z.filter(w=>w.card).length;u&&u!w.card).map(w=>`${w.from}.${q.get(w.from).columns[w.fromRow].name}`).join(", ")} ${z.length-u===1?"has":"have"} none)`)}else if(j!=="sequence")for(const $ of t.edges??[]){const u=String($.from??""),w=String($.to??"");if(!q.has(u)||!q.has(w)){l(`a line names ${q.has(u)?w:u}, which is not a node`);continue}const C=ht($.label),I=C?.split(` -`)??[];I.length>2&&r(`the label "${qt(C)}" has more than one break: a label is two lines at most`),I.some(_=>_.length>ke)&&r(`a line of the label "${qt(C)}" is over ${ke} characters: longer words belong in the node or the summary`),z.push({i:z.length,from:u,to:w,kind:p($.kind,`the line from ${u} to ${w}`),label:C,fromSide:m($.fromSide),toSide:m($.toSide),flow:j!=="flowchart"&&$.flow===!0?!0:void 0})}else for(const $ of B)"n"in $&&(!q.has($.from)||!q.has($.to))&&l(`message ${$.n} names ${q.has($.from)?$.to:$.from}, which is not a participant`);if(o&&j!=="sequence"&&!F){const $=new Map;for(const u of L)for(let w=u.row;w<=u.row2;w++){const C=`${u.col}:${w}`;$.has(C)&&l(`${u.id} and ${$.get(C)} share the cell at column ${u.col}, row ${w}`),$.set(C,u.id)}}if(o&&!F){for(const u of O){const w=u.all.map(_=>q.get(_));if(!w.length)continue;const C={c1:Math.min(...w.map(_=>_.col)),c2:Math.max(...w.map(_=>_.col)),r1:Math.min(...w.map(_=>_.row)),r2:Math.max(...w.map(_=>_.row2))};for(const _ of L)!u.all.includes(_.id)&&_.col>=C.c1&&_.col<=C.c2&&_.row>=C.r1&&_.row<=C.r2&&l(`${_.id} is inside the box of the group "${u.label}" but not a member`);const I=w.map(_=>_.i);Math.max(...I)-Math.min(...I)+1!==I.length&&l(`the members of the group "${u.label}" are not next to each other in the author's order, so the stacked drawing cannot wrap them in one box`)}for(const u of L)u.group&&!O.some(w=>w.id===u.group)&&l(`${u.id} names the group "${u.group}", which is not in groups`);L.filter(u=>u.focal).length>1&&l("more than one node is focal: a diagram has one at most");const $=new Set(j==="sequence"?B.flatMap(u=>"n"in u?[u.kind]:[]):z.map(u=>u.kind));$.has("main")&&!d.main&&l("main lines are drawn but the legend has no words for them (legend.main)"),$.has("dashed")&&!d.dashed&&l("dashed lines are drawn but the legend has no words for them (legend.dashed)"),L.some(u=>u.focal)&&!d.focal&&l("a focal node is drawn but the legend has no words for what it marks (legend.focal)")}const D=j==="architecture"||j==="data-flow",T=$=>Array.isArray($)&&$.length>1?$.map(String):void 0,R=D&&t.packet&&typeof t.packet=="object"?t.packet:void 0,H=R&&T(R.path),Q={animated:t.motion==="animated",pulse:D?T(t.pulse):void 0,packet:H?{path:H,repeat:R.repeat===!0,send:R.send}:void 0,run:j==="sequence"&&t.run===!0,firstVisit:t.entrance==="first-visit"||void 0};if(o)for(const $ of L){const u=$.mark?.says;if(!u?.length)continue;const w=[$.name,$.kind,$.detail,$.laneLabel].filter(Boolean).join(" ").toLowerCase();u.some(C=>w.includes(C.toLowerCase()))||l(`${$.id}'s mark stands for ${u.join(" or ")}, and none of its words say so`)}const at=[];if(j==="sequence"){const $=new Map,u=new Map;for(const w of B)"n"in w&&(u.set(w.from,w.n),u.set(w.to,w.n));for(const w of B)if("n"in w){if(w.activate){const C=$.get(w.to)??[];if(C.length>=3)r(`message ${w.n} opens a fourth bar on ${w.to}: three deep at most`);else{const I={who:w.to,from:w.n,to:w.n,depth:C.length+1};C.push(I),at.push(I),$.set(w.to,C)}}if(w.deactivate){const I=$.get(w.from)?.pop();I?I.to=w.n:r(`message ${w.n} closes a bar on ${w.from}, which has none open`)}}for(const[w,C]of $)for(const I of C)I.to=Math.max(I.from,u.get(w)??I.from)}const it=t.frameLabels??{},yt={opt:ht(it.opt)??"Only if",loop:ht(it.loop)??"Repeats",alt:ht(it.alt)??"One of these",else:ht(it.else)??"Otherwise"},dt=t.layout==="auto"&&!F?e.placement:void 0;let et=Math.max(1,dt?.cols??1,...L.map($=>$.col));if(e.rtl){for(const u of L)u.col=et-u.col+1;const $=u=>u==="left"?"right":u==="right"?"left":u;for(const u of z)u.fromSide=$(u.fromSide),u.toSide=$(u.toSide);for(const u of B)if("open"in u){const[w,C]=[et-u.b+1,et-u.a+1];u.a=w,u.b=C}et=Math.max(1,dt?.cols??1,...L.map(u=>u.col))}const nt=j==="data-flow"?Math.max(1,v.length):Math.max(1,dt?.rows??1,...L.map($=>$.row2)),tt={type:j,title:String(t.title??""),heading:b,legend:d,nodes:L,byId:q,edges:z,groups:O,lanes:v,steps:B,bars:at,frameWords:yt,cols:et,rows:nt,shapeLabels:h,stepWord:f,warnings:c,errors:s,motion:Q,memo:new Map,rtl:e.rtl||void 0,unplaced:F||void 0,text:j==="sequence"&&t.variant==="text"||void 0,marks:z.some($=>$.card)||void 0};if(t.layout==="auto"&&!F&&j!=="schema"&&pn(tt),o)for(const[$,u]of Object.entries(De(tt)))u>=48&&l(`${$} grows to ${u}px to hold the lines on one side: use another side`);return o&&L.length>100&&l(`the figure has ${L.length} cards: more than 100, which automatic layout places on the main thread`),o&&L.length>1&&!F&&!Ut(tt)&&l("some part cannot be reached from another by the arrow keys where the figure is drawn, so its arrows keep the author's order"),tt}function pn(t){const e=new Set(t.nodes.map(r=>`${r.col},${r.row}`)),n=(r,a)=>{const d=[];for(let g=Math.min(r,a)+1;g{const a=t.byId.get(r.from),d=t.byId.get(r.to),g=d.col>a.col?"right":"left",f=d.row>a.row?"bottom":"top",i=d.col>a.col?"left":"right",h=d.row>a.row?"top":"bottom",b=(M,L,z,v)=>n(M,L).map(O=>v?[O,z]:[z,O]);let p;const m=M=>(M==="right"?a.col1:M==="bottom"?a.row1)?[{sides:[M,M],cells:[]}]:[];return a.row===d.row?p=[{sides:[g,i],cells:b(a.col,d.col,a.row,!0)},...m("bottom"),...m("top")]:a.col===d.col?p=[{sides:[f,h],cells:b(a.row,d.row,a.col,!1)},...m("right"),...m("left")]:p=[{sides:[g,h],cells:[...b(a.col,d.col,a.row,!0),[d.col,a.row],...b(a.row,d.row,d.col,!1)]},{sides:[f,i],cells:[...b(a.row,d.row,a.col,!1),[a.col,d.row],...b(a.col,d.col,d.row,!0)]},{sides:[g,i],cells:b(a.col,d.col,a.row,!0)},{sides:[f,h],cells:b(a.row,d.row,a.col,!1)}],p.filter(M=>M.cells.every(([L,z])=>!e.has(`${L},${z}`)))},c=new Map,l=new Set;for(const r of t.edges)if(r.fromSide||r.toSide){const[a,d]=fe(t.byId.get(r.from),t.byId.get(r.to)),g=r.fromSide??a,f=r.toSide??d;l.add(`${r.from}.${g}`);for(const[i,h]of[[r.from,g],[r.to,f]])c.set(`${i}.${h}`,(c.get(`${i}.${h}`)??0)+1)}const s=t.edges.map((r,a)=>a).sort((r,a)=>o(t.edges[r]).length-o(t.edges[a]).length||+(t.edges[a].kind==="main")-+(t.edges[r].kind==="main")||r-a);for(const r of s){const a=t.edges[r];if(a.fromSide||a.toSide)continue;const d=(f,i,h)=>{const b=`${f}.${i}`;return(c.get(b)??0)>=3?!1:t.byId.get(f).shape!=="decision"?!0:h?!c.has(b):!l.has(b)},g=o(a).find(f=>d(a.from,f.sides[0],!0)&&d(a.to,f.sides[1],!1));if(g){l.add(`${a.from}.${g.sides[0]}`);for(const[f,i]of[[a.from,g.sides[0]],[a.to,g.sides[1]]])c.set(`${f}.${i}`,(c.get(`${f}.${i}`)??0)+1);a.fromSide=g.sides[0],a.toSide=g.sides[1]}}}function oe(t,e){if(typeof t=="string")return t?{id:t}:void 0;if(!t||typeof t!="object")return;const n=t,o=ve(ht(n.onLight),e);if(o)return{onLight:o,onDark:ve(ht(n.onDark),e)??o,says:Array.isArray(n.says)?n.says.map(String):void 0}}function ve(t,e){if(t){if(/^data:image\//i.test(t.trim()))return t;try{if(/^https?:$/.test(new URL(t,"https://basalt.invalid/").protocol)&&!/^http:/i.test(t.trim()))return t}catch{}e?.(`a card's mark ${JSON.stringify(t.slice(0,60))} is not a relative path, https or a data: image, so it is not drawn`)}}var xe=t=>`url("${t.replace(/[\\"\n\r\f;]/g,e=>e===` +(()=>{var fn=["top","right","bottom","left"],un=["main","plain","dashed"],we=["one","zero-or-one","one-or-many","zero-or-many"],Ht={one:"Exactly one","zero-or-one":"Zero or one","one-or-many":"One or many","zero-or-many":"Zero or many"},hn=[2,3,4,5,6],ht=t=>t==null||t===""?void 0:String(t),Lt=t=>Object.assign(Object.create(null),t),Ct=(t,e)=>t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;function Nt(t,e={}){const o=e.checks!==!1,c=[],l=$=>{c.push($)},s=[],r=$=>{s.push($)},a=t.legend??{},d={};for(const $ of["main","plain","dashed","focal","group","activation"]){const u=ht(a[$]);u&&(d[$]=u)}const g=t.stepLabel,f=typeof g=="function"?$=>String(g($)):typeof g=="string"?($=>g.replace("{n}",String($))):$=>`Step ${$}`,i=t.shapeLabels??{},h={terminal:ht(i.terminal)??"Start or end",step:ht(i.step)??"Step",decision:ht(i.decision)??"Decision"},b=t.heading===void 0?3:hn.includes(t.heading)?t.heading:(l(`heading ${String(t.heading)} is not a level from 2 to 6: the title is an h3`),3),p=($,u)=>$==null?"plain":un.includes($)?$:(l(`"${String($)}" is not a kind of line (main, plain or dashed): ${u} is drawn plain`),"plain"),m=$=>{if($!=null){if(fn.includes($))return $;l(`"${String($)}" is not a side (top, right, bottom or left): the derived side is used`)}},M=($,u)=>typeof $=="number"&&Number.isInteger($)&&$>=1?$:(t.layout==="auto"&&$==null||l(`${u} is ${JSON.stringify($)}, not a whole number from 1: it is placed at 1`),1),L=[],z=[];let v=[];const C=[],B=[],j=t.type;if(["architecture","flowchart","data-flow","sequence","schema"].includes(j)||l(`"${String(j)}" is not a type of diagram (architecture, flowchart, data-flow, sequence or schema)`),j==="architecture"||j==="flowchart"){for(const $ of t.nodes??[]){const u=j==="flowchart"&&$.shape==="decision"?"decision":j==="flowchart"&&$.shape==="terminal"?"terminal":"box",w=String($.id??""),O=M($.row,`the row of ${w}`);L.push({id:w,i:L.length,name:String($.name??""),kind:u==="decision"?void 0:ht($.kind),detail:u==="decision"?void 0:ht($.detail),mono:!!$.detailMono,focal:!!$.focal,col:M($.col,`the column of ${w}`),row:O,row2:O,branch:!!$.branch,shape:u,group:j==="architecture"?ht($.group):void 0,mark:j==="architecture"?se($.mark,l):void 0})}if(j==="architecture"){const $=(t.groups??[]).map(I=>({id:String(I.id??""),label:String(I.label??""),parent:ht(I.parent)})),u=new Map($.map(I=>[I.id,I])),w=I=>{if(!I.parent)return 1;const _=u.get(I.parent);return _?_.parent===I.id||_.id===I.id?(r(`the groups "${I.label}" and "${_.label}" are each other's parent`),I.parent=void 0,1):_.parent?(r(`the group "${I.label}" is a third level: groups nest two deep`),I.parent=void 0,1):2:(r(`the group "${I.label}" names the parent "${I.parent}", which is not a group`),I.parent=void 0,1)},O=$.map(w);$.forEach((I,_)=>C.push({...I,depth:O[_],members:L.filter(X=>X.group===I.id).map(X=>X.id),all:[]}));for(const I of C)I.all=[...I.members,...C.filter(_=>_.parent===I.id).flatMap(_=>_.members)];C.sort((I,_)=>I.depth-_.depth)}}else if(j==="data-flow"){v=(t.lanes??[]).map(u=>({id:String(u.id??""),label:String(u.label??"")}));const $=new Map(v.map((u,w)=>[u.id,w+1]));for(const u of t.nodes??[]){const w=String(u.id??""),O=String(u.lane??""),I=$.get(O);I===void 0&&l(`a node (${w}) names the lane "${O}", which is not in lanes`);const _=L.length+1;L.push({id:w,i:L.length,name:String(u.name??""),kind:f(_),detail:ht(u.detail),mono:!!u.detailMono,focal:!!u.focal,col:M(u.col,`the column of ${w}`),row:I??1,row2:I??1,branch:!1,shape:"box",lane:I??1,laneLabel:v[(I??1)-1]?.label??O,step:_,mark:se(u.mark)})}}else if(j==="sequence"){(t.participants??[]).forEach((O,I)=>{const _=String(O.name??"");L.push({id:String(O.id??""),i:I,name:_,kind:ht(O.kind),mono:!1,focal:!!O.focal,col:I+1,row:1,row2:1,branch:!1,shape:"participant",short:ht(O.short)??_,mark:se(O.mark)})});let $=0;const u=new Map(L.map(O=>[O.id,O.col])),w=(O,I)=>{let _=1/0,X=-1/0;for(const V of O??[]){if(!V||typeof V!="object")continue;if("band"in V){I>0&&r(`the band "${String(V.band)}" is inside a frame: a band is the whole figure's`),B.push({band:String(V.band??"")});continue}if("frame"in V){if(I>=2){r("a frame is a third level: frames nest two deep");continue}const $t=V.frame==="alt"||V.frame==="loop"||V.frame==="opt"?V.frame:"opt",bt=$t==="alt"?V.branches??[]:[{label:V.label,steps:V.steps}];$t==="alt"&&bt.length<2&&r("an alt frame has one branch: it needs two or more");const wt=String(bt[0]?.label??"");wt.length>40&&r(`the frame label "${wt}" is over 40 characters`);const vt=B.length;B.push({open:$t,label:wt,depth:I+1,a:0,b:0}),bt.forEach((y,S)=>{if(S){const W=String(y.label??"");W.length>40&&r(`the frame label "${W}" is over 40 characters`),B.push({otherwise:W,depth:I+1})}y.steps?.length||r(`a frame or branch ("${String(y.label??"")}") is empty`);const[E,k]=w(y.steps??[],I+1);_=Math.min(_,E),X=Math.max(X,k);const A=B[vt];A.a=Math.min(A.a||1/0,E),A.b=Math.max(A.b,k)}),B.push({close:I+1});continue}$++;const ft=String(V.label??"");ft.includes(` +`)&&r(`message ${$}'s label has a break: a message's second line is its note`);const st=String(V.from??""),lt=String(V.to??"");B.push({n:$,from:st,to:lt,label:qt(ft),note:ht(V.note),kind:p(V.kind,`message ${$}`),activate:V.activate===!0||void 0,deactivate:V.deactivate===!0||void 0});const pt=u.get(st)??1,kt=u.get(lt)??1,ut=pt===kt?pt===L.length?pt-1:pt+1:pt;_=Math.min(_,pt,kt,ut),X=Math.max(X,pt,kt,ut)}return[_,X]};w(t.steps??[],0);for(const O of B)"open"in O&&!Number.isFinite(O.a)&&(O.a=1,O.b=Math.max(1,L.length))}else if(j==="schema")for(const $ of t.tables??[]){const u=String($.name??""),[w,O]=Array.isArray($.row)?$.row:[$.row,$.row],I=M(w,`the row of ${u}`),_=Math.max(I,M(O,`the last row of ${u}`)),X=$.more===void 0||$.more===null?void 0:Number.isInteger($.more)&&$.more>0?$.more:(l(`${u}'s "more" is ${JSON.stringify($.more)}, not a whole number from 1: it is left out`),void 0);L.push({id:u,i:L.length,name:u,mono:!0,focal:!!$.focal,col:M($.col,`the column of ${u}`),row:I,row2:_,branch:!1,shape:"table",more:X,columns:($.columns??[]).map(V=>({name:String(V.name??""),type:ht(V.type),key:V.key==="PK"||V.key==="FK"?V.key:(V.key!==void 0&&V.key!==null&&l(`${u}.${String(V.name)}'s key is "${String(V.key)}", not PK or FK: it is left out`),void 0)}))})}let F=!1;if(t.layout==="auto"&&(j==="architecture"||j==="flowchart"||j==="schema")){const $=j==="schema"?t.tables:t.nodes;o&&($??[]).some(w=>w&&(w.col!==void 0||w.row!==void 0))&&l('a card under layout="auto" has a col or row, which is not read: there are no hints');const u=e.placement?.cells;u||(F=!0);for(const w of L){const O=u?.[w.id];w.col=O?.col??1,w.row=w.row2=O?.row??1}if(u){const w=new Map;for(const O of L){const I=Ct(u,O.id);if(!I){F=!0,l(`the placement has no cell for ${O.id}, so it is not used`);continue}const _=`${I.col},${I.row}`;w.has(_)&&(F=!0,l(`the placement puts ${w.get(_)} and ${O.id} in one cell, so it is not used`)),w.set(_,O.id)}}if(u&&!F)for(const w of C){const O=w.all.map(st=>L.find(lt=>lt.id===st)).filter(Boolean);if(!O.length)continue;const I=Math.min(...O.map(st=>st.col)),_=Math.max(...O.map(st=>st.col)),X=Math.min(...O.map(st=>st.row)),V=Math.max(...O.map(st=>st.row)),ft=L.filter(st=>!w.all.includes(st.id)&&st.col>=I&&st.col<=_&&st.row>=X&&st.row<=V);ft.length&&(F=!0,l(`the placement puts ${ft.map(st=>st.id).join(", ")} inside the box of the group "${w.label}", so it is not used`))}}else t.layout==="auto"&&r(`layout="auto" is for an architecture, a flowchart or a schema, not a ${j}`);((j==="schema"?t.tables:j==="sequence"?t.participants:t.nodes)??[]).forEach(($,u)=>{if(!$||$.href===void 0||$.href===null)return;const w=String($.href);if(j==="sequence"){r(`${L[u]?.id}: a participant cannot be a link (href)`);return}if(!w.trim()){r(`${L[u]?.id}'s href is empty`);return}const O=L[u];O&&(O.href=w,O.blank=$.target==="_blank")});const q=new Map;for(const $ of L)$.id?q.has($.id)&&l(`the id "${$.id}" is used twice`):l("a node has no id"),q.set($.id,$);if(j==="schema"){const $=(w,O)=>{if(w==null)return;const I=w,_=we.includes(I.from)?I.from:void 0;if(!_){r(`${O}'s cardinality "from" is ${JSON.stringify(I.from)}, not one, zero-or-one, one-or-many or zero-or-many: it is left out`);return}return I.to===void 0||I.to===null?{from:_,to:"one"}:I.to==="one"||I.to==="zero-or-one"?{from:_,to:I.to}:(r(`${O}'s cardinality "to" is ${JSON.stringify(I.to)}: a foreign key references one row at most (one or zero-or-one), so it is drawn as one`),{from:_,to:"one"})};(t.tables??[]).forEach(w=>(w.columns??[]).forEach((O,I)=>{const _=ht(O.references);if(!_&&O.cardinality!==void 0&&O.cardinality!==null&&r(`${String(w.name)}.${String(O.name)} states a cardinality but references nothing`),!_)return;const[X,V]=_.split("."),ft=q.get(X??""),st=ft?.columns?.findIndex(kt=>kt.name===V)??-1;if(!ft||st<0){l(`${String(w.name)}.${String(O.name)} references ${_}, which is not a shown column`);return}const lt=q.get(String(w.name??""));lt.columns[I].ref={table:X,column:V,row:st};const pt=$(O.cardinality,`${String(w.name)}.${String(O.name)}`);pt&&(lt.columns[I].card=pt),z.push({i:z.length,from:lt.id,to:X,kind:"plain",fromRow:I,toRow:st,fk:!0,card:pt})}));const u=z.filter(w=>w.card).length;u&&u!w.card).map(w=>`${w.from}.${q.get(w.from).columns[w.fromRow].name}`).join(", ")} ${z.length-u===1?"has":"have"} none)`)}else if(j!=="sequence")for(const $ of t.edges??[]){const u=String($.from??""),w=String($.to??"");if(!q.has(u)||!q.has(w)){l(`a line names ${q.has(u)?w:u}, which is not a node`);continue}const O=ht($.label),I=O?.split(` +`)??[];I.length>2&&r(`the label "${qt(O)}" has more than one break: a label is two lines at most`),I.some(_=>_.length>ke)&&r(`a line of the label "${qt(O)}" is over ${ke} characters: longer words belong in the node or the summary`),z.push({i:z.length,from:u,to:w,kind:p($.kind,`the line from ${u} to ${w}`),label:O,fromSide:m($.fromSide),toSide:m($.toSide),flow:j!=="flowchart"&&$.flow===!0?!0:void 0})}else for(const $ of B)"n"in $&&(!q.has($.from)||!q.has($.to))&&l(`message ${$.n} names ${q.has($.from)?$.to:$.from}, which is not a participant`);if(o&&j!=="sequence"&&!F){const $=new Map;for(const u of L)for(let w=u.row;w<=u.row2;w++){const O=`${u.col}:${w}`;$.has(O)&&l(`${u.id} and ${$.get(O)} share the cell at column ${u.col}, row ${w}`),$.set(O,u.id)}}if(o&&!F){for(const u of C){const w=u.all.map(_=>q.get(_));if(!w.length)continue;const O={c1:Math.min(...w.map(_=>_.col)),c2:Math.max(...w.map(_=>_.col)),r1:Math.min(...w.map(_=>_.row)),r2:Math.max(...w.map(_=>_.row2))};for(const _ of L)!u.all.includes(_.id)&&_.col>=O.c1&&_.col<=O.c2&&_.row>=O.r1&&_.row<=O.r2&&l(`${_.id} is inside the box of the group "${u.label}" but not a member`);const I=w.map(_=>_.i);Math.max(...I)-Math.min(...I)+1!==I.length&&l(`the members of the group "${u.label}" are not next to each other in the author's order, so the stacked drawing cannot wrap them in one box`)}for(const u of L)u.group&&!C.some(w=>w.id===u.group)&&l(`${u.id} names the group "${u.group}", which is not in groups`);L.filter(u=>u.focal).length>1&&l("more than one node is focal: a diagram has one at most");const $=new Set(j==="sequence"?B.flatMap(u=>"n"in u?[u.kind]:[]):z.map(u=>u.kind));$.has("main")&&!d.main&&l("main lines are drawn but the legend has no words for them (legend.main)"),$.has("dashed")&&!d.dashed&&l("dashed lines are drawn but the legend has no words for them (legend.dashed)"),L.some(u=>u.focal)&&!d.focal&&l("a focal node is drawn but the legend has no words for what it marks (legend.focal)")}const D=j==="architecture"||j==="data-flow",T=$=>Array.isArray($)&&$.length>1?$.map(String):void 0,R=D&&t.packet&&typeof t.packet=="object"?t.packet:void 0,H=R&&T(R.path),Q={animated:t.motion==="animated",pulse:D?T(t.pulse):void 0,packet:H?{path:H,repeat:R.repeat===!0,send:R.send}:void 0,run:j==="sequence"&&t.run===!0,firstVisit:t.entrance==="first-visit"||void 0};if(o)for(const $ of L){const u=$.mark?.says;if(!u?.length)continue;const w=[$.name,$.kind,$.detail,$.laneLabel].filter(Boolean).join(" ").toLowerCase();u.some(O=>w.includes(O.toLowerCase()))||l(`${$.id}'s mark stands for ${u.join(" or ")}, and none of its words say so`)}const at=[];if(j==="sequence"){const $=new Map,u=new Map;for(const w of B)"n"in w&&(u.set(w.from,w.n),u.set(w.to,w.n));for(const w of B)if("n"in w){if(w.activate){const O=$.get(w.to)??[];if(O.length>=3)r(`message ${w.n} opens a fourth bar on ${w.to}: three deep at most`);else{const I={who:w.to,from:w.n,to:w.n,depth:O.length+1};O.push(I),at.push(I),$.set(w.to,O)}}if(w.deactivate){const I=$.get(w.from)?.pop();I?I.to=w.n:r(`message ${w.n} closes a bar on ${w.from}, which has none open`)}}for(const[w,O]of $)for(const I of O)I.to=Math.max(I.from,u.get(w)??I.from)}const it=t.frameLabels??{},yt={opt:ht(it.opt)??"Only if",loop:ht(it.loop)??"Repeats",alt:ht(it.alt)??"One of these",else:ht(it.else)??"Otherwise"},dt=t.layout==="auto"&&!F?e.placement:void 0;let et=Math.max(1,dt?.cols??1,...L.map($=>$.col));if(e.rtl){for(const u of L)u.col=et-u.col+1;const $=u=>u==="left"?"right":u==="right"?"left":u;for(const u of z)u.fromSide=$(u.fromSide),u.toSide=$(u.toSide);for(const u of B)if("open"in u){const[w,O]=[et-u.b+1,et-u.a+1];u.a=w,u.b=O}et=Math.max(1,dt?.cols??1,...L.map(u=>u.col))}const nt=j==="data-flow"?Math.max(1,v.length):Math.max(1,dt?.rows??1,...L.map($=>$.row2)),tt={type:j,title:String(t.title??""),heading:b,legend:d,nodes:L,byId:q,edges:z,groups:C,lanes:v,steps:B,bars:at,frameWords:yt,cols:et,rows:nt,shapeLabels:h,stepWord:f,warnings:c,errors:s,motion:Q,memo:new Map,rtl:e.rtl||void 0,unplaced:F||void 0,text:j==="sequence"&&t.variant==="text"||void 0,marks:z.some($=>$.card)||void 0};if(t.layout==="auto"&&!F&&j!=="schema"&&pn(tt),o)for(const[$,u]of Object.entries(De(tt)))u>=48&&l(`${$} grows to ${u}px to hold the lines on one side: use another side`);return o&&L.length>100&&l(`the figure has ${L.length} cards: more than 100, which automatic layout places on the main thread`),o&&L.length>1&&!F&&!Xt(tt)&&l("some part cannot be reached from another by the arrow keys where the figure is drawn, so its arrows keep the author's order"),tt}function pn(t){const e=new Set(t.nodes.map(r=>`${r.col},${r.row}`)),n=(r,a)=>{const d=[];for(let g=Math.min(r,a)+1;g{const a=t.byId.get(r.from),d=t.byId.get(r.to),g=d.col>a.col?"right":"left",f=d.row>a.row?"bottom":"top",i=d.col>a.col?"left":"right",h=d.row>a.row?"top":"bottom",b=(M,L,z,v)=>n(M,L).map(C=>v?[C,z]:[z,C]);let p;const m=M=>(M==="right"?a.col1:M==="bottom"?a.row1)?[{sides:[M,M],cells:[]}]:[];return a.row===d.row?p=[{sides:[g,i],cells:b(a.col,d.col,a.row,!0)},...m("bottom"),...m("top")]:a.col===d.col?p=[{sides:[f,h],cells:b(a.row,d.row,a.col,!1)},...m("right"),...m("left")]:p=[{sides:[g,h],cells:[...b(a.col,d.col,a.row,!0),[d.col,a.row],...b(a.row,d.row,d.col,!1)]},{sides:[f,i],cells:[...b(a.row,d.row,a.col,!1),[a.col,d.row],...b(a.col,d.col,d.row,!0)]},{sides:[g,i],cells:b(a.col,d.col,a.row,!0)},{sides:[f,h],cells:b(a.row,d.row,a.col,!1)}],p.filter(M=>M.cells.every(([L,z])=>!e.has(`${L},${z}`)))},c=new Map,l=new Set;for(const r of t.edges)if(r.fromSide||r.toSide){const[a,d]=fe(t.byId.get(r.from),t.byId.get(r.to)),g=r.fromSide??a,f=r.toSide??d;l.add(`${r.from}.${g}`);for(const[i,h]of[[r.from,g],[r.to,f]])c.set(`${i}.${h}`,(c.get(`${i}.${h}`)??0)+1)}const s=t.edges.map((r,a)=>a).sort((r,a)=>o(t.edges[r]).length-o(t.edges[a]).length||+(t.edges[a].kind==="main")-+(t.edges[r].kind==="main")||r-a);for(const r of s){const a=t.edges[r];if(a.fromSide||a.toSide)continue;const d=(f,i,h)=>{const b=`${f}.${i}`;return(c.get(b)??0)>=3?!1:t.byId.get(f).shape!=="decision"?!0:h?!c.has(b):!l.has(b)},g=o(a).find(f=>d(a.from,f.sides[0],!0)&&d(a.to,f.sides[1],!1));if(g){l.add(`${a.from}.${g.sides[0]}`);for(const[f,i]of[[a.from,g.sides[0]],[a.to,g.sides[1]]])c.set(`${f}.${i}`,(c.get(`${f}.${i}`)??0)+1);a.fromSide=g.sides[0],a.toSide=g.sides[1]}}}function se(t,e){if(typeof t=="string")return t?{id:t}:void 0;if(!t||typeof t!="object")return;const n=t,o=ve(ht(n.onLight),e);if(o)return{onLight:o,onDark:ve(ht(n.onDark),e)??o,says:Array.isArray(n.says)?n.says.map(String):void 0}}function ve(t,e){if(t){if(/^data:image\//i.test(t.trim()))return t;try{if(/^https?:$/.test(new URL(t,"https://basalt.invalid/").protocol)&&!/^http:/i.test(t.trim()))return t}catch{}e?.(`a card's mark ${JSON.stringify(t.slice(0,60))} is not a relative path, https or a data: image, so it is not drawn`)}}var xe=t=>`url("${t.replace(/[\\"\n\r\f;]/g,e=>e===` `?"\\a ":e==="\r"?"\\d ":e==="\f"?"\\c ":e===";"?"\\3b ":`\\${e}`)}")`;function Rt(t,e,n){return t.memo.has(e)||t.memo.set(e,n()),t.memo.get(e)}var ke=28,Kt=t=>t.includes(` -`)?2:1,qt=t=>t.replace(/\n/g," "),Ft=t=>{const e=t.trim();return e?/[.!?]$/.test(e)?e:`${e}.`:""};function Me(t,e){return t.legend[e]}function gn(t,e){return e.shape==="decision"?"decision":e.shape==="terminal"?t.edges.some(n=>n.from===e.id)?"start":"end":e.kind??"step"}function mn(t,e){return Rt(t,`sentence:${e.i}`,()=>yn(t,e))}function yn(t,e){const n=[];if(t.type==="schema"){n.push(`${e.name}, table.`);const o=(e.columns??[]).filter(l=>l.ref).map(l=>`${l.ref.table} (${l.name}${l.card?`: ${Se(e.id,l.ref.table,l.card)}`:""})`),c=t.edges.filter(l=>l.to===e.id).map(l=>`${l.from} (${t.byId.get(l.from).columns[l.fromRow].name}${l.card?`: ${Se(l.from,l.to,l.card)}`:""})`);o.length&&n.push(`References ${o.join(", ")}.`),c.length&&n.push(`Referenced by ${c.join(", ")}.`)}else if(t.type==="sequence"){const o=t.steps.filter(s=>"n"in s&&s.from===e.id).length,c=t.steps.filter(s=>"n"in s&&s.to===e.id).length;n.push(Ft(e.kind?`${e.name}, ${e.kind}`:e.name)),n.push(`Sends ${o} ${o===1?"message":"messages"} and receives ${c}.`);const l=Ee(t,e);l&&n.push(l.trim())}else{const o=t.type==="data-flow"?`${t.stepWord(e.step)} of ${t.nodes.length}, ${e.laneLabel}`:t.type==="flowchart"?gn(t,e):e.kind;if(n.push(Ft(o?`${e.name}, ${o}`:e.name)),e.detail&&n.push(Ft(e.detail)),e.group){const s=t.groups.find(a=>a.id===e.group),r=s?.parent?t.groups.find(a=>a.id===s.parent):void 0;s&&n.push(r?`In ${s.label}, in ${r.label}.`:`In ${s.label}.`)}const c=t.edges.filter(s=>s.to===e.id).map(s=>`${t.byId.get(s.from).name}${s.label?` (${qt(s.label)})`:""}`),l=t.edges.filter(s=>s.from===e.id).map(s=>`${t.byId.get(s.to).name}${s.label?` (${qt(s.label)})`:""}`);c.length&&n.push(`From: ${c.join(", ")}.`),l.length&&n.push(`To: ${l.join(", ")}.`)}return e.focal&&t.legend.focal&&n.push(Ft(t.legend.focal)),n.join(" ")}var $n=(t,e,n,o)=>[`${Ht[n.from].toLowerCase()} `,o(t),` to ${Ht[n.to].toLowerCase()} `,o(e)],Se=(t,e,n)=>`${Ht[n.from].toLowerCase()} ${t} to ${Ht[n.to].toLowerCase()} ${e}`;function Ee(t,e){const n=t.bars.filter(c=>c.who===e.id&&c.depth===1);return n.length?` ${t.legend.activation??"Working"} during ${n.map(c=>c.from===c.to?`message ${c.from}`:`messages ${c.from} to ${c.to}`).join(" and ")}.`:""}function bn(t,e,n,o){const c=n.pointerType;if(c!=="touch"&&c!=="pen")return;const l=t.querySelector(`.${e}-drawing`),s=n.target;if(!l||!s||!l.contains(s)||!t.querySelector(`.${e}-edge`))return;const r=s.closest(`.${e}-node`);if(!r?.hasAttribute("href"))return r?r.dataset.node===o?null:r.dataset.node??null:o===null?void 0:null}function Ae(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 o=[];for(const c of n.flat(1/0))c!=null&&c!==!1&&!Array.isArray(c)&&o.push(c);return{t,a:e??{},c:o}}var wn={"&":"&","<":"<",">":">",'"':""","'":"'"},mt=t=>t.replace(/[&<>"']/g,e=>wn[e]),vn=" br img input meta link hr path polygon polyline circle rect line ";function se(t,e={}){if(typeof t=="string")return mt(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[o,c]of Object.entries(t.a))if(!(c==null||c===!1)){if(!/^[a-z][a-z0-9:-]*$/i.test(o))throw new Error(`diagram: "${o}" is not an attribute name`);n+=c===!0?` ${o}`:` ${o}="${mt(String(c))}"`}return vn.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(o=>se(o,e)).join("")}`}var xn=t=>({title:`${t}-title`,summary:`${t}-summary`,keys:`${t}-keys`,list:`${t}-list`,toggle:`${t}-toggle`});function Tt(t,e){return!e.layout||e.bare?!1:e.layout==="drawn"?!0:t.type!=="sequence"&&t.type!=="schema"}function kn(t,e){return t.type==="sequence"||t.type==="schema"?e.layout==="drawn":!0}function Zt(t,e){const n=e.all.map(o=>t.byId.get(o));return n.length?{c1:Math.min(...n.map(o=>o.col)),c2:Math.max(...n.map(o=>o.col)),r1:Math.min(...n.map(o=>o.row)),r2:Math.max(...n.map(o=>o.row2))}:null}function Le(t){return Rt(t,"group-edges",()=>{const e=[0,0,0,0];for(const n of t.groups){const o=Zt(t,n);if(!o)continue;[o.r1===1,o.c2===t.cols,o.r2===t.rows,o.c1===1].forEach((l,s)=>{l&&(e[s]=Math.max(e[s],_e(t,n,s)))})}return e})}function _e(t,e,n){const o=Zt(t,e);return t.groups.filter(s=>s.parent===e.id).some(s=>{const r=Zt(t,s);return r&&[r.r1===o.r1,r.c2===o.c2,r.r2===o.r2,r.c1===o.c1][n]})?2:1}function qe(t){const e=Le(t);return e[1]+e[3]}function ae(t){return t.type==="sequence"?t.nodes.length:t.cols}function Ie(t){return Rt(t,"plan",()=>Mn(t))}function Mn(t){const e=t.nodes,n=m=>t.type==="data-flow"||!e[m].branch,o=t.edges.map(m=>{const M=t.byId.get(m.from).i,L=t.byId.get(m.to).i,v=e.slice(Math.min(M,L)+1,Math.max(M,L)).every(O=>!n(O.i));return L===M+1&&!(n(M)&&!n(L))?"down":L===M-1?"up":L>M&&n(M)&&!n(L)&&v?"trunk":L>M&&n(M)&&n(L)&&v?"rail":L>M?"end-down":"end-up"}),c=t.edges.map((m,M)=>({e:m,k:M})).filter(({k:m})=>o[m]==="end-down"||o[m]==="end-up"),l=m=>{const M=t.byId.get(m.from).i,L=t.byId.get(m.to).i;return[Math.min(M,L),Math.max(M,L)]},s=(m,M)=>{const[L,z]=l(m),[v,O]=l(M);return L{const M=t.byId.get(m.from).i,[L,z]=l(m);return!n(M)&&e.slice(L+1,z).every(v=>!n(v.i))&&c.every(v=>v.e===m||!s(v.e,m))}),a=c.length>0&&(t.type==="data-flow"||!r),d=m=>{const[M,L]=l(m);return L-M},g=t.edges.map(()=>0);let f=!1;const i=[];for(const m of[...c].sort((M,L)=>d(M.e)-d(L.e)||M.k-L.k)){let M=0;for(const L of i)s(L.e,m.e)&&(M=Math.max(M,g[L.k]+1));g[m.k]=M,M>3&&(f=!0),i.push(m)}const h=Math.max(0,...c.map(({k:m})=>g[m]+1)),b=t.edges.map(()=>.5);for(const m of e){const M=c.filter(({e:v})=>v.from===m.id);if(M.length<2)continue;const L=M.filter(({k:v})=>o[v]==="end-down").sort((v,O)=>d(O.e)-d(v.e)||v.k-O.k);[...M.filter(({k:v})=>o[v]==="end-up").sort((v,O)=>d(v.e)-d(O.e)||O.k-v.k),...L].forEach(({k:v},O,B)=>{b[v]=B.length===2?O===0?1/3:2/3:(O+1)/(B.length+1)})}const p=Lt();for(let m=1;m{const D=o[q],T=t.byId.get(rt.from).i,R=t.byId.get(rt.to).i,H=R===m&&(D==="down"||D==="trunk"||D==="rail"||D==="end-down"),Q=T===m&&R===m-1&&D==="up",at=R===m-1&&D==="end-up";H&&(D==="trunk"||D==="end-down")&&(O=!0),at&&(B=!0),(H||Q||at)&&rt.label&&(z++,v=Math.max(v,D==="trunk"?40:48))}),(z>1||O&&B)&&(v=64);const j=c.filter(({e:rt,k:q})=>o[q]==="end-down"&&t.byId.get(rt.to).i===m).length,F=c.filter(({e:rt,k:q})=>o[q]==="end-up"&&t.byId.get(rt.to).i===m-1).length;v+=20*Math.max(0,j-1)+20*Math.max(0,F-1),p[M.id]=v}return{routes:o,gutter:a,lanes:g,exits:b,gaps:p,third:f,laneCount:h}}var Wt=(t,e)=>({width:t,height:e,viewBox:`0 0 ${t} ${e}`,"aria-hidden":"true",focusable:"false"});function Ce(t,e){const n=e==="fk"?"plain":e,o=n==="main"?8:8.5,c=24,l=n==="dashed"?c-1:c-7;return x("svg",{class:`${t}-swatch`,"data-kind":n,...Wt(24,16)},e==="fk"?x("circle",{class:`${t}-dot`,cx:3,cy:o,r:3}):null,x("path",{class:`${t}-line`,"data-kind":n,d:`M${e==="fk"?3:0} ${o}H${l}`}),n==="dashed"?x("path",{class:`${t}-tip`,"data-kind":n,"data-open":"",d:`M${c-8} ${o-4}L${c} ${o}L${c-8} ${o+4}`}):x("path",{class:`${t}-tip`,"data-kind":n,d:`M${c} ${o}L${c-8} ${o-4}L${c-8} ${o+4}Z`}))}function Sn(t,e){const{crow:n,ring:o}=Oe(e,24,8.5,-1);return x("svg",{class:`${t}-swatch`,"data-card":e,...Wt(24,16)},x("path",{class:`${t}-line`,"data-kind":"plain",d:"M0 8.5H24"}),x("path",{class:`${t}-crow`,d:n}),o?x("circle",{class:`${t}-ring`,cx:o.x,cy:o.y,r:o.r}):null)}function Oe(t,e,n,o,c=8,l=6){const s=h=>String(Math.round(h*100)/100),r=h=>e+o*h,a=c/2,d=h=>`M${s(r(h-.5))} ${s(n-a)}V${s(n+a)}`,g=t==="one-or-many"||t==="zero-or-many",f=t==="zero-or-one"||t==="zero-or-many";let i=g?`M${s(e)} ${s(n-a)}L${s(r(7.5))} ${s(n)}L${s(e)} ${s(n+a)}`:d(4);return f||(i+=d(g?11:8)),{crow:i,ring:f?{x:Math.round(r(10.5)*100)/100,y:n,r:l/2}:void 0}}function Dt(t,e){return e==="decision"?x("svg",{class:`${t}-swatch`,"data-shape":e,...Wt(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,...Wt(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,...Wt(16,16)},x("rect",{class:`${t}-swatch-shape`,x:.5,y:2.5,width:15,height:11,rx:2}))}function Be(t,e){return Rt(e,`key:${t}`,()=>An(t,e))}var En=Be;function An(t,e){const n=[],o=(s,r,a={})=>n.push(x("li",{class:`${t}-entry`,...a},s,x("span",null,r)));if(e.type==="schema"){const s=new Set(e.nodes.flatMap(r=>(r.columns??[]).map(a=>a.key)));for(const[r,a]of[["PK","Primary key"],["FK","Foreign key"]])s.has(r)&&n.push(x("li",{class:`${t}-entry`},x("span",{class:`${t}-key-letters`,"aria-hidden":"true"},r),x("span",null,a)))}if(e.type==="flowchart"){const s=new Set(e.nodes.map(r=>r.shape));s.has("terminal")&&o(Dt(t,"terminal"),e.shapeLabels.terminal),s.has("box")&&o(Dt(t,"box"),e.shapeLabels.step),s.has("decision")&&o(Dt(t,"decision"),e.shapeLabels.decision)}const c=new Set(e.type==="sequence"?e.steps.flatMap(s=>"n"in s?[s.kind]:[]):e.edges.filter(s=>!s.fk).map(s=>s.kind)),l=(s,r)=>x("span",{class:`${t}-key-glyph`,"data-ink":r,"aria-hidden":"true"},s);for(const s of["main","plain","dashed"]){const r=e.legend[s];c.has(s)&&r&&o(e.text?l(s==="main"?"━━▶":s==="dashed"?"┄┄▷":"──▶",s==="main"?"main":"plain"):Ce(t,s),r,{"data-line":e.text?void 0:""})}if(e.type==="schema"&&e.edges.length){e.edges.some(r=>!r.card)&&o(Ce(t,"fk"),e.legend.plain??"A foreign key, to the key it references",{"data-line":"","data-when":"drawn"});const s=new Set(e.edges.flatMap(r=>r.card?[r.card.from,r.card.to]:[]));for(const r of we)s.has(r)&&o(Sn(t,r),Ht[r],{"data-line":"","data-when":"drawn","data-card":r});n.push(x("li",{class:`${t}-entry`,"data-when":"stacked"},x("span",{class:`${t}-fk-mark`,"aria-hidden":"true"},e.rtl?"←":"→"),x("span",null,"The table a foreign key references")))}if(e.type==="sequence"){e.bars.length&&o(e.text?l("┃","working"):x("svg",{class:`${t}-swatch`,"data-shape":"bar",...Wt(16,16)},x("path",{class:`${t}-life`,d:"M8 0V16"}),x("rect",{class:`${t}-bar`,x:4.5,y:2.5,width:7,height:11,rx:1.5})),e.legend.activation??"Working",e.text?{}:{"data-when":"drawn"});const s=new Set(e.steps.flatMap(r=>"open"in r?[r.open]:[]));for(const r of["opt","loop","alt"])s.has(r)&&n.push(x("li",{class:`${t}-entry`},x("span",{class:`${t}-key-letters`,"data-op":"","aria-hidden":"true"},r),x("span",null,e.frameWords[r])))}return e.nodes.some(s=>s.focal)&&e.legend.focal&&o(e.text?l("╔═╗","focal"):Dt(t,"focal"),e.legend.focal,{"data-focal":""}),e.groups.length&&e.legend.group&&o(Dt(t,"group"),e.legend.group),n.length?x("div",{class:`${t}-key`},x("ul",{class:`${t}-legend`,"aria-label":"Key"},n)):null}function Ln(t,e){const n=e==="main"?6:6.5;return x("svg",{class:`${t}-arrow`,"data-kind":e,...Wt(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`}))}var It=t=>x("bdi",null,t);function re(t,e){if(!e.href)return It(e.name);const n=e.name.trimEnd().lastIndexOf(" ");return[n<0?"":e.name.slice(0,n+1),x("span",{class:`${t}-name-end`},n<0?e.name:e.name.slice(n+1))]}function _n(t,e,n){if(n.shape==="decision")return[x("span",{class:`${t}-words`},x("span",{class:`${t}-name`},re(t,n)))];const o=[];return e.type==="data-flow"?o.push(x("span",{class:`${t}-kind`},It(n.kind),x("span",{class:`${t}-lane-word`}," · ",It(n.laneLabel??"")))):n.kind&&o.push(x("span",{class:`${t}-kind`},It(n.kind))),o.push(x("span",{class:`${t}-name`},re(t,n))),n.detail&&o.push(x("span",{class:`${t}-detail`,"data-mono":n.mono?"":void 0},n.mono?x("span",{class:`${t}-runs`},Pt(n.detail).flatMap((c,l)=>[l?" ":"",x("span",{class:`${t}-run`},c)])):It(n.detail))),o}function qn(t,e,n){return[x("span",{class:`${t}-th`},x("span",{class:`${t}-tname`},re(t,e))),x("span",{class:`${t}-rows`},(e.columns??[]).map((o,c)=>x("span",{class:`${t}-row`,"data-row":c,"data-key":o.key},x("span",{class:`${t}-keyseat`},o.key??""),x("span",{class:`${t}-cname`},o.name),o.ref?x("span",{class:`${t}-ctype`,"data-ref":""},`${n.rtl?"←":"→"} `,It(o.ref.table)):o.type?x("span",{class:`${t}-ctype`},It(o.type)):null))),e.more?x("span",{class:`${t}-more`},`+ ${e.more} more`):null]}var je=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 Jt(t,e,n,o){const{P:c}=t,l=kn(e,o)||o.keep===n.id,s=Tt(e,o),r=o.layout==="drawn"&&o.rows,a=[`--_c:${n.col}`,`--_r:${r?2*n.row:n.row}`,`--_r2:${r?2*n.row2+1:n.row2+1}`];e.type==="data-flow"&&a.push(`--_lc:${n.col+1}`),e.type==="sequence"&&a.push(`--_c2:${n.col+1}`);const d=t.plan;if(d&&n.i>0){const b=Ot(d.gaps,n.id)??32,p=Ot(o.grow,n.id)??0;a.push(`--_gap:${p?`calc(${je(b)} + var(--basalt-space-4) * ${p})`:je(b)}`)}const g=Ot(o.heights,n.id);g&&a.push(`--_h:${g}px`);const f=Ot(De(e),n.id);f&&a.push(`--_mh:${f}px`);const i=Ot(o.words,n.id);i&&a.push(`--_ww:${i}px`);const h=s?o.stop===n.id?0:-1:o.keep===n.id?-1:void 0;return x(n.href?"a":"div",{class:`${c}-node`,href:n.href,target:n.href&&n.blank?"_blank":void 0,rel:n.href&&n.blank?"noopener noreferrer":void 0,"data-link":n.href?n.blank?"external":"":void 0,"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:a.join(";"),role:l&&!n.href?"img":void 0,"aria-label":l||n.href?mn(e,n):void 0,tabindex:h},n.shape==="decision"?x("svg",{class:`${c}-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:`${c}-mark`,"aria-hidden":"true",style:n.mark.onLight?`--_ml:${xe(n.mark.onLight)};--_md:${xe(n.mark.onDark??n.mark.onLight)}`:void 0}):null,n.shape==="table"?qn(c,n,e):_n(c,e,n))}function In(t,e,n){const{P:o}=t,c=[];if(e.type==="data-flow"&&c.push(...e.lanes.map((a,d)=>x("div",{class:`${o}-lane`,style:`--_r:${d+1}`,"aria-hidden":"true"},x("span",{class:`${o}-lane-name`},a.label)))),e.type==="architecture")for(const a of e.groups){const d=Zt(e,a);if(!d)continue;const g=[0,1,2,3].map(f=>_e(e,a,f));c.push(x("div",{class:`${o}-gbox`,"data-group":a.id,"data-depth":a.depth>1?a.depth:void 0,style:`--_c:${d.c1};--_c2:${d.c2+1};--_r:${d.r1};--_r2:${d.r2+1}${g[0]>1?";--_gt:2":""}${g[1]>1?";--_ge:2":""}${g[2]>1?";--_gb:2":""}${g[3]>1?";--_gs:2":""}`,"aria-hidden":"true"},x("span",{class:`${o}-glabel`},It(a.label))))}if(e.text)return[x("pre",{class:`${o}-text`,"aria-hidden":"true","data-art":n.art?"":void 0},x("code",{class:`${o}-text-ink`},Cn(o,e)))];if(e.type==="sequence")return c.push(x("ul",{class:`${o}-cast`},e.nodes.map(a=>x("li",{class:`${o}-actor`,style:e.rtl?`--_ac:${a.col}`:void 0},Jt(t,e,a,n))))),c.push(On(t,e)),c;const l=a=>{const d=a.group?e.groups.find(g=>g.id===a.group):void 0;return d?.parent?e.groups.find(g=>g.id===d.parent):d},s=(a,d,g)=>{const f=t.plan?Ot(n.grow,d[0].id)??0:0,i=d[0],h=t.plan&&i.group===a.id?e.edges.filter((m,M)=>m.to===i.id&&(t.plan.routes[M]==="trunk"||t.plan.routes[M]==="end-down")):[],b=Math.max(0,...h.map(m=>m.label?Kt(m.label):0)),p=[f?`--_ggrow:${f}`:"",b?`--_tl:${b}`:""].filter(Boolean).join(";");return x("div",{class:`${o}-group`,"data-group":a.id,"data-depth":a.depth>1?a.depth:void 0,"data-turn":h.length?"":void 0,style:p||void 0},x("span",{class:`${o}-glabel`,"aria-hidden":"true"},It(a.label)),g)};let r=0;for(;rp.id===g[i].group):void 0;if(!h){f.push(Jt(t,e,g[i],n)),i++;continue}const b=[];for(;iJt(t,e,p,n))))}c.push(s(d,g,f))}return c}function Cn(t,e){const n=[],o=a=>x("span",{class:`${t}-tx-name`},a),c=a=>a==="main"?"━▶":a==="dashed"?"┄▷":"─▶",l=(a,d,g,...f)=>x("span",{class:`${t}-tx-line`,...a,style:g?`--_in:${d+g};--_hang:${g}`:`--_in:${d}`},...f);n.push(l({"data-ink":"names"},0,0,e.nodes.flatMap((a,d)=>[d?" · ":"",o(a.name)])));const s=String(Math.max(1,...e.steps.map(a=>"n"in a?a.n:0))).length;let r=0;for(const a of e.steps){const d=2*r;if("band"in a){n.push(l({"data-ink":"band"},d,0,`── ${a.band} ──`));continue}if("open"in a){n.push(l({"data-ink":"frame"},d,0,x("span",{"data-ink":"op"},`[${a.open}]`),` ${a.label}`)),r++;continue}if("otherwise"in a){n.push(l({"data-ink":"frame"},2*Math.max(0,r-1),0,x("span",{"data-ink":"op"},"[else]"),` ${a.otherwise}`));continue}if("close"in a){r=Math.max(0,r-1),n.push(l({"data-ink":"frame"},2*r,0,"[end]"));continue}const g=e.byId.get(a.from)?.name??a.from,f=e.byId.get(a.to)?.name??a.to,i=s+2;n.push(l({"data-n":a.n},d,i,x("span",{"data-ink":"num"},String(a.n).padStart(s,"0"))," ",o(g)," ",x("span",{class:`${t}-tx-to`},x("span",{"data-ink":a.kind==="main"?"main":"plain"},c(a.kind))," ",f))),n.push(l({"data-n":a.n},d+i,0,x("span",{"data-ink":"label"},a.label))),a.note&&n.push(l({"data-n":a.n},d+i,0,x("span",{"data-ink":"note"},a.note)))}return n}function On(t,e){const{P:n}=t,o=[],c=[],l=()=>c.length?c[c.length-1].el.c:o;let s=null;for(const r of e.steps){if("band"in r){s=null,l().push(x("p",{class:`${n}-band`},x("span",null,r.band)));continue}if("open"in r){s=null;const p=c[c.length-1],m=p?`;--_fis:${r.a===p.a?1:0};--_fie:${r.b===p.b?1:0}`:"",M=x("div",{class:`${n}-frame`,"data-op":r.open,"data-depth":r.depth,style:`--_a:${r.a};--_b:${r.b+1}${m}`},x("span",{class:`${n}-fbox`,"aria-hidden":"true"}),x("p",{class:`${n}-fhead`},x("span",{class:`${n}-ftab`,"aria-hidden":"true"},r.open),x("span",{class:`${n}-flabel`},x("span",{class:t.hidden},`${e.frameWords[r.open]}: `),r.label)));l().push(M),c.push({el:M,a:r.a,b:r.b});continue}if("otherwise"in r){s=null,l().push(x("p",{class:`${n}-felse`},x("span",{class:`${n}-fword`,"aria-hidden":"true"},"else"),x("span",{class:`${n}-flabel`},x("span",{class:t.hidden},`${e.frameWords.else}: `),r.otherwise)));continue}if("close"in r){s=null,c.pop();continue}s||(s=x("ol",{class:`${n}-msgs`,start:r.n}),l().push(s));const a=e.byId.get(r.from),d=e.byId.get(r.to),g=a?.col??1,f=d?.col??1,i=g===f,h=i&&(e.rtl?g!==1:g===e.nodes.length),b=Me(e,r.kind);s.c.push(x("li",{class:`${n}-msg`,"data-kind":r.kind,"data-from":r.from,"data-to":r.to,"data-self":i?h?"start":"end":void 0,style:`--_a:${Math.min(g,f)};--_b:${Math.max(g,f)+1}`},x("span",{class:`${n}-said`},x("span",{class:`${n}-num`},String(r.n)),x("span",{class:`${n}-mlabel`},r.label)),x("span",{class:`${n}-route`},a?.short??r.from," ",x("span",{class:`${n}-to`},Ln(n,r.kind),x("span",{class:t.hidden}," to ")," ",d?.short??r.to,b?` · ${b}`:"")),r.note?x("span",{class:`${n}-note`},r.note):null))}return x("div",{class:`${n}-steps`},o)}function Re(t,e){return Rt(e,`list:${t}`,()=>jn(t,e))}var Bn=Re;function jn(t,e){const n=Math.min(6,e.heading+1),o=f=>x(`h${n}`,{class:`${t}-list-head`},f),c=f=>x("strong",null,f),l=f=>f.href?x("a",{href:f.href,target:f.blank?"_blank":void 0,rel:f.blank?"noopener noreferrer":void 0},c(f.name)):c(f.name),s=f=>x("code",{class:`${t}-code`},f),r=f=>e.byId.get(f)?.name??f,a=f=>{const i=Me(e,f);return i?` (${i})`:""},d=f=>f.focal&&e.legend.focal?` ${Ft(e.legend.focal)}`:"";if(e.type==="architecture"){const f=b=>x("li",null,l(b),b.kind?`, ${b.kind}`:"",b.detail?[". ",b.mono?s(b.detail):b.detail,/[.!?]$/.test(b.detail)?"":"."]:/[.!?]$/.test(b.kind??b.name)?"":".",d(b)),i=[o("Parts")],h=e.nodes.filter(b=>!b.group);h.length&&i.push(x("ul",{class:`${t}-list-items`},h.map(f)));for(const b of e.groups.filter(p=>p.depth===1)){i.push(x("p",{class:`${t}-list-group`},b.label)),b.members.length&&i.push(x("ul",{class:`${t}-list-items`},b.members.map(p=>f(e.byId.get(p)))));for(const p of e.groups.filter(m=>m.parent===b.id))i.push(x("p",{class:`${t}-list-group`,"data-depth":2},p.label)),i.push(x("ul",{class:`${t}-list-items`,"data-depth":2},p.members.map(m=>f(e.byId.get(m)))))}return i.push(o("Connections")),i.push(x("ol",{class:`${t}-list-items`},e.edges.map(b=>x("li",null,c(r(b.from))," to ",c(r(b.to)),b.label?[": ",s(qt(b.label))]:"",`${a(b.kind)}.`)))),i}if(e.type==="flowchart"){const f=i=>(e.byId.get(i)?.i??0)+1;return[x("ol",{class:`${t}-list-items`},e.nodes.map(i=>{const h=e.edges.filter(m=>m.from===i.id),b=i.shape==="decision"?"Decision":i.shape==="terminal"?h.length?"Start":"End":"Step",p=!i.detail&&/[.!?]$/.test(i.name)?" ":". ";return x("li",null,l(i),i.detail?[", ",i.mono?s(i.detail):i.detail]:"",`${p}${b}.`,d(i),h.length?x("ul",{class:`${t}-list-exits`},h.map(m=>x("li",null,m.label?`If ${qt(m.label)}: go to ${f(m.to)}, `:`Then: go to ${f(m.to)}, `,c(r(m.to)),a(m.kind)))):null)}))]}if(e.type==="data-flow")return[x("ol",{class:`${t}-list-items`},e.nodes.map(f=>{const i=e.edges.filter(h=>h.from===f.id);return x("li",null,`${f.laneLabel}: `,l(f),f.detail?[", ",f.mono?s(f.detail):f.detail]:"",".",d(f),i.length?[" Then ",...i.flatMap((h,b)=>[b?"; ":"",`to step ${e.byId.get(h.to).step}, `,c(r(h.to)),h.label?[": ",s(qt(h.label))]:"",a(h.kind)]),"."]:"")}))];if(e.type==="sequence"){const f=[o("Participants"),x("ul",{class:`${t}-list-items`},e.nodes.map(h=>x("li",null,c(h.name),h.kind?`, ${h.kind}`:"",".",d(h),Ee(e,h))))];f.push(o("Messages"));let i=null;for(const h of e.steps){if("band"in h){i=null,f.push(x(`h${Math.min(6,n+1)}`,{class:`${t}-list-group`},h.band));continue}if("open"in h){i=null,f.push(x(`h${Math.min(6,n+1)}`,{class:`${t}-list-group`,"data-depth":h.depth>1?h.depth:void 0},`${e.frameWords[h.open]}: ${h.label}`));continue}if("otherwise"in h){i=null,f.push(x(`h${Math.min(6,n+1)}`,{class:`${t}-list-group`,"data-depth":h.depth>1?h.depth:void 0},`${e.frameWords.else}: ${h.otherwise}`));continue}if("close"in h){i=null;continue}i||(i=x("ol",{class:`${t}-list-items`,start:h.n}),f.push(i)),i.c.push(x("li",null,s(h.label),": ",c(r(h.from))," to ",c(r(h.to)),`${a(h.kind)}.`,h.note?` ${Ft(h.note)}`:""))}return f}const g=[];for(const f of e.nodes)g.push(x(`h${n}`,{class:`${t}-list-group`},f.href?x("a",{href:f.href,target:f.blank?"_blank":void 0,rel:f.blank?"noopener noreferrer":void 0},s(f.name)):s(f.name),d(f))),g.push(x("ul",{class:`${t}-list-items`},[...(f.columns??[]).map(i=>x("li",null,s(i.name),i.key==="PK"?", primary key":i.key==="FK"?", foreign key":"",i.ref?[", references ",s(`${i.ref.table}.${i.ref.column}`),i.card?[" (",$n(f.id,i.ref.table,i.card,s),")"]:""]:i.type?`, ${i.type}`:"")),...f.more?[x("li",null,`and ${f.more} more ${f.more===1?"column":"columns"}`)]:[]]));return g}function Te(t,e=!1){const n=t.type==="architecture"?"part":t.type==="sequence"?"participant":t.type==="schema"?"table":"step";return`${e&&Ut(t)?`Arrow keys move to the nearest ${n} in that direction`:`Arrow keys move to the next or the previous ${n}, in the author's order`}; Home and End go to the ends; Escape clears the trace.${t.nodes.some(c=>c.href)?" Enter opens a part that is a link.":""}`}function ie(t,e=!1){const n=e&&t.type!=="sequence"&&Ut(t)&&t.cols>1&&t.rows>1,o=t.nodes.some(c=>c.href)?[{keys:["Enter"],words:"open"}]:[];return[{keys:n?["←","↑","↓","→"]:["←","→"],words:Ae(t)},{keys:["Home","End"],words:"the ends"},...o,{keys:["Esc"],words:"clear"}]}var Rn=(t,e)=>{for(let n=0;n({col:e.col,rows:[e.row,e.row2]});function Ut(t){return Rt(t,"spatial",()=>{const e=t.nodes.map(l=>({id:l.id,...Tn(t,l)})),n=(l,s)=>{const r=s==="right"||s==="left",a=s==="right"||s==="down",d=b=>r?[b.col,b.col]:b.rows,g=b=>r?b.rows:[b.col,b.col],f=d(l),i=g(l);let h=null;return e.forEach((b,p)=>{if(b===l)return;const m=d(b),M=g(b),L=a?m[0]-f[1]:f[0]-m[1];if(L<1)return;const z=Math.max(0,M[0]-i[1],i[0]-M[1]),v=[z===0?0:1,z===0?L:L+2*z,z,Math.abs(M[0]-i[0]),p];(!h||Rn(v,h.rank))&&(h={id:b.id,rank:v})}),h?.id??null},o=Lt();for(const l of e)o[l.id]={right:n(l,"right"),left:n(l,"left"),down:n(l,"down"),up:n(l,"up")};const c=l=>{const s=new Set([l]),r=[l];for(;r.length;)for(const a of Object.values(o[r.pop()]))a&&!s.has(a)&&(s.add(a),r.push(a));return s.size};return e.every(l=>c(l.id)===e.length)?o:null})}function Xt(t){return Rt(t,"turn-back-lanes",()=>{const e=new Map,n=new Set;if(!le(t))return{lane:e,dropped:n,lanes:0};const o=(a,d)=>(t.byId.get(a)?.row??0)*1e3+d,c=new Map;t.edges.forEach((a,d)=>{const g=`${a.to}.${a.toRow}.${a.card?.to??""}`,f=o(a.from,a.fromRow??0),i=o(a.to,a.toRow??0),h=c.get(g)??{members:[],lo:1/0,hi:-1/0};h.members.push(d),h.lo=Math.min(h.lo,f,i),h.hi=Math.max(h.hi,f,i),c.set(g,h)});const l=[...c.values()].sort((a,d)=>d.hi-d.lo-(a.hi-a.lo)),s=[];let r=0;for(const a of l.reverse()){const d=new Set(s.filter(f=>f.lo<=a.hi&&a.lo<=f.hi).map(f=>f.lane));let g=0;for(;d.has(g);)g++;if(g>1){for(const f of a.members)n.add(f);continue}s.push({lo:a.lo,hi:a.hi,lane:g});for(const f of a.members)e.set(f,g);r=Math.max(r,g+1)}return{lane:e,dropped:n,lanes:r}})}var le=t=>t.type==="schema"&&t.cols===1&&t.edges.length>0;function Yt(t,e,n){const o=n.prefix,c=xn(n.base),l=t.type==="sequence"||t.type==="schema"?null:Ie(t),s={P:o,ids:c,level:n.level,plan:l,hidden:n.hiddenClass},r=e.layout==="drawn",a=Tt(t,e),d=t.type==="sequence"||t.type==="schema"?r:!0,g=`h${t.heading}`,f=[`--_cols:${ae(t)}`];if(t.type==="architecture"&&t.groups.length||r&&e.pad){const i=t.type==="architecture"?Le(t):[0,0,0,0],h=(p,m,M)=>p?p>1?`calc(${p} * var(--basalt-space-${m}))`:`var(--basalt-space-${m})`:M?`var(--basalt-space-${M})`:"0px",b=r&&e.pad?"3":void 0;f.push(`--_gpad:${h(i[0],"8",b)} ${h(i[1],"4")} ${h(i[2],"4",b)} ${h(i[3],"4")}`)}if(l?.gutter&&l.laneCount>2&&f.push(`--_gw:calc(${l.laneCount} * var(--basalt-space-3-5) + var(--basalt-space-3))`),le(t)){const i=t.marks?"var(--basalt-space-6) + var(--basalt-space-1)":"var(--basalt-space-5)",h=Xt(t).lanes>1?`calc(${i} + var(--basalt-space-3))`:t.marks?`calc(${i})`:i;f.push(t.rtl?`--_gpad:0px 0px 0px ${h}`:`--_gpad:0px ${h} 0px 0px`)}return t.type==="schema"&&e.track&&f.push(`--_track:${e.track}px`),x("figure",{class:n.className?`${o} ${n.className}`:o,"aria-labelledby":c.title,"data-type":t.type,"data-cols":ae(t),"data-reach":t.type==="architecture"?qe(t):void 0,"data-gutter":l?.gutter?"":void 0,"data-marks":t.marks?"":void 0,"data-layout":e.layout??(t.unplaced?"stacked":void 0),"data-measured":e.layout?"":void 0,"data-bare":e.bare?"":void 0,"data-motion":t.motion.animated?"animated":void 0,"data-first-visit":t.motion.animated&&t.motion.firstVisit?"":void 0,"data-rtl":t.rtl?"":void 0,"data-viewer":n.viewer?"":void 0,style:f.join(";")},x("div",{class:`${o}-head`},x(g,{id:c.title,class:`${o}-title`},It(t.title)),n.hasSource?x("p",{class:`${o}-source`},x("bdi",null,{slot:"source"})):null),x("div",{class:`${o}-drawing`,style:r&&e.rows?`--_rows:${e.rows};--_row-gap:0px`:void 0,role:d?"group":void 0,"aria-roledescription":d?"diagram":void 0,"aria-labelledby":d?c.title:void 0,"aria-describedby":d?a?`${c.summary} ${c.keys}`:c.summary:void 0,"data-stops":a?"":void 0},In(s,t,e),t.text?null:x("div",{class:`${o}-ink`,"aria-hidden":"true"}),x("span",{class:`${o}-ruler`,"aria-hidden":"true"})),Be(o,t),x("p",{class:`${o}-hint`,"data-kbd-hint":"","aria-hidden":"true"},{slot:"hint"}),Tt(t,e)&&t.type!=="sequence"||r&&t.type==="sequence"?x("p",{class:`${o}-tap-hint`,"aria-hidden":"true"},`Tap ${Ae(t)} to highlight its lines. Tap it again to clear.`):null,x("div",{class:`${o}-foot`},{slot:"toggle"}),x("div",{id:c.list,class:`${o}-list`,hidden:!e.open},Re(o,t)),x("span",{id:c.keys,class:n.hiddenClass},n.viewer?`${Te(t,r)} ${n.viewer}`:Te(t,r)),x("figcaption",{id:c.summary,class:`${o}-summary`},{slot:"summary"}))}function zn(t){const e=getComputedStyle(t),n=(c,l)=>{const s=parseFloat(e.getPropertyValue(`--basalt-${c}`));return Number.isFinite(s)?s:l},o=new Map;return{space:c=>(o.has(c)||o.set(c,n(`space-${c}`,parseFloat(c.replace("-","."))*4)),o.get(c)),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),activation:n("size-diagram-activation",8),foot:n("size-diagram-foot",14)}}var Qt=(t,e)=>t==="main"?e.line:e.hair,xt=(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,ce=(t,e)=>({l:t.l-e,r:t.r+e,t:t.t-e,b:t.b+e});function Mt(t,e,n){const{l:o,t:c,r:l,b:s}=t.rect,r=(o+l)/2,a=(c+s)/2,d=(l-o)/2,g=(s-c)/2,f=e==="top"||e==="bottom";if(t.shape==="decision"){if(f){const b=n,p=g*Math.max(0,1-Math.abs(b-r)/d);return{x:b,y:e==="top"?a-p:a+p}}const i=n,h=d*Math.max(0,1-Math.abs(i-a)/g);return{x:e==="left"?r-h:r+h,y:i}}if(t.shape==="terminal"){const i=Math.min(d,g);if(f){const m=n,M=Math.min(Math.max(m,o+i),l-i),L=m-M,z=Math.abs(L)>=i?0:Math.sqrt(i*i-L*L);return{x:m,y:Math.abs(L)<1e-6?e==="top"?c:s:e==="top"?a-z:a+z}}const h=n,b=h-a,p=Math.abs(b)>=i?0:Math.sqrt(i*i-b*b);return{x:e==="left"?o+i-p:l-i+p,y:h}}return f?{x:n,y:e==="top"?c:s}:{x:e==="left"?o:l,y:n}}function Wn(t,e,n){const{l:o,t:c,r:l,b:s}=e.rect,r=(o+l)/2,a=(c+s)/2,d=(l-o)/2,g=(s-c)/2;if(e.shape==="decision")return Math.abs(t.x-r)/d+Math.abs(t.y-a)/g<1-n/Math.min(d,g);if(e.shape==="terminal"){const f=Math.min(d,g),i=Math.min(Math.max(t.x,o+f),l-f);return Math.hypot(t.x-i,t.y-a)o+n&&t.xc+n&&t.ymatchMedia("(forced-colors: active)").matches;function Hn(t,e){const n=t.querySelector(`.${e}-ruler`),o=new Map;return(c,l)=>{const s=`${l}|${c}`;return o.has(s)||(n.setAttribute("data-f",l),n.textContent=c,o.set(s,n.getBoundingClientRect().width),n.textContent=""),o.get(s)}}var Pt=t=>t?t.split(/\s+/).filter(Boolean):[];function Dn(t,e,n){const o=e.space;let c=e.node,l=e.table;for(const a of t.nodes){if(a.shape==="table"){for(const p of a.columns??[]){const m=p.ref?`${t.rtl?"←":"→"} ${p.ref.table}`:p.type??"",M=o("6")+n(p.name,"mono")+(m?o("3")+n(m,"mono"):0)+2*o("3")+2*e.hair;l=Math.max(l,Math.ceil(M))}l=Math.max(l,Math.ceil(n(a.name,"table")+2*o("3")+2*e.hair+(a.href?16+o("1-5"):0)));continue}const d=a.shape==="terminal"?2*o("5"):2*o("3"),g=a.mark&&!Fn()?(a.shape==="participant"?2:1)*o("6"):0;let f=0;const i=a.href?16+o("1-5"):0,h=Pt(a.name);if(h.forEach((p,m)=>{f=Math.max(f,n(p,a.shape==="decision"?"name-500":"name")+(a.kind?0:g)+(m===h.length-1?i:0))}),t.type!=="data-flow")for(const p of Pt(a.kind))f=Math.max(f,n(p,"mono")+g);for(const p of Pt(a.detail))f=Math.max(f,n(p,a.mono?"mono":"sans"));const b=a.shape==="decision"?f/.62:f+d+2*e.hair;c=Math.max(c,Math.ceil(b))}const s=ae(t);let r;return t.type==="data-flow"?r=e.lane+s*(c+o("12")):t.type==="schema"?r=s*l+(s-1)*(o("12")+(t.marks?o("3"):0))+(le(t)?(t.marks?o("6")+o("1"):o("5"))+(Xt(t).lanes>1?o("3"):0):0):t.type==="sequence"?r=s*c+(s-1)*o("5"):r=s*c+(s-1)*o("16")+qe(t)*o("4"),{track:c,table:l,least:Math.max(e.wide,r)}}function We(t,e,n=!1){const o=n?c=>-Math.round(-c):Math.round;return{x:(c,l)=>l%2===1?o(c+t-.5)+.5-t:o(c+t)-t,y:(c,l)=>l%2===1?Math.round(c+e-.5)+.5-e:Math.round(c+e)-e}}function de(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 Ne(t,e,n){const o=t.map(l=>({...l}));for(let l=1;l=2){const a=c[c.length-2];if(Math.abs(a.x-r.x)<.01&&Math.abs(r.x-s.x)<.01||Math.abs(a.y-r.y)<.01&&Math.abs(r.y-s.y)<.01){c[c.length-1]=s;continue}}c.push(s)}}return c}var _t=t=>t.slice(1).map((e,n)=>[t[n],e]);function te(t,e,n){const o=[];for(let l=0;lMath.min(p.x,m.x)+.75&&zMath.min(M.y,L.y)+.75&&vl.split(/\s+/).map(parseFloat).filter(s=>Number.isFinite(s)),o=(l,s,r)=>{const a=[];let d=s;for(const g of l)a.push([d,d+g]),d+=g+r;return a},c=o(n(e.gridTemplateRows),parseFloat(e.paddingTop)||0,parseFloat(e.rowGap)||0);return{cols:o(n(e.gridTemplateColumns),parseFloat(e.paddingLeft)||0,parseFloat(e.columnGap)||0),rows:t.style.getPropertyValue("--_rows").trim()?c.filter((l,s)=>s%2===1):c}}var ct=t=>t==="left"||t==="right",Fe={top:"bottom",bottom:"top",left:"right",right:"left"};function fe(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 He(t,e,n){const o=[];t.edges.forEach((l,s)=>{const r=t.byId.get(l.from),a=t.byId.get(l.to),[d,g]=e[s],f=r.row===a.row&&ct(d)&&ct(g)&&d===Fe[g]||r.col===a.col&&!ct(d)&&!ct(g)&&d===Fe[g];o.push({edge:s,end:"from",node:r,side:d,far:a,straight:f,f:.5},{edge:s,end:"to",node:a,side:g,far:r,straight:f,f:.5})});const c=new Map;for(const l of o){const s=`${l.node.id}.${l.side}`;c.has(s)||c.set(s,[]),c.get(s).push(l)}for(const[l,s]of c){if(s[0].node.shape==="decision")continue;const r=p=>ct(p.side)?p.far.row-p.node.row:p.far.col-p.node.col,a=s.filter(p=>p.straight),d=s.filter(p=>!p.straight);if(d.sort((p,m)=>r(p)-r(m)||(ct(p.side)?p.far.col-m.far.col:p.far.row-m.far.row)*(r(p)<0?1:-1)),s.length>3&&n(`${l.replace(".","'s ")} side has ${s.length} lines; more than three is an error: use another side`),!a.length){d.length===2?(d[0].f=.25,d[1].f=.75):d.length===3?(d[0].f=.25,d[1].f=.5,d[2].f=.75):d.length>3&&d.forEach((p,m)=>{p.f=(m+1)/(d.length+1)});continue}const g=new Map;for(const p of a)g.has(p.far.id)||g.set(p.far.id,[]),g.get(p.far.id).push(p);for(const p of g.values())p.length>1&&p.sort((m,M)=>m.edge-M.edge).forEach((m,M)=>{m.f=p.length===2?M===0?.25:.75:(M+1)/(p.length+1)});const f=Math.min(...a.map(p=>p.f)),i=Math.max(...a.map(p=>p.f)),h=d.filter(p=>r(p)<0),b=d.filter(p=>r(p)>=0);h.forEach((p,m)=>{p.f=f*(m+1)/(h.length+1)}),b.forEach((p,m)=>{p.f=i+(1-i)*(m+1)/(b.length+1)})}return o}function De(t,e=8,n=8){return Rt(t,`port-floors:${e}:${n}`,()=>{const o=Lt();if(t.type!=="architecture"&&t.type!=="flowchart"&&t.type!=="data-flow")return o;const c=t.edges.map(s=>{const r=t.byId.get(s.from),a=t.byId.get(s.to),[d,g]=fe(r,a);return[s.fromSide??d,s.toSide??g]}),l=new Map;for(const s of He(t,c,()=>{})){if(!ct(s.side)||s.node.shape!=="box")continue;const r=`${s.node.id}.${s.side}`;l.has(r)||l.set(r,[]),l.get(r).push(s.f)}for(const[s,r]of l){if(r.length<2)continue;const a=r.slice().sort((f,i)=>f-i).filter((f,i,h)=>i===0||f-h[i-1]>1e-9);let d=Math.max(e/a[0],e/(1-a[a.length-1]));for(let f=1;f{const s=t.byId.get(l.dataset.node);s&&c.set(s.id,{id:s.id,rect:xt(l,n),shape:s.shape,i:s.i})}),c}function Ke(t,e){const n=e.head,o=e.head/2,{x:c,y:l}=t.tip;return t.dir==="down"?{l:c-o,r:c+o,t:l-n,b:l}:t.dir==="up"?{l:c-o,r:c+o,t:l,b:l+n}:t.dir==="right"?{l:c-n,r:c,t:l-o,b:l+o}:{l:c,r:c+n,t:l-o,b:l+o}}var ue=(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 Ze(t,e,n,o,c=!1){const l=(r,a)=>{const d=r+a-Math.floor(r+a);return d<.005||d>.995?[0]:d<=.5?[-d,1-d]:[1-d,-d]},s=c?l(-t.r,-e).map(r=>-r):l(t.l,e);for(const r of l(t.t,n))for(const a of s){if(!a&&!r)return t;const d={l:t.l+a,r:t.r+a,t:t.t+r,b:t.b+r};if(o(d))return d}return t}function Vn(t,e,n,o,c,l,s,r,a){const d=s.space,g=[],f=[],i=[],h=[],b=d("1"),p=e.filter(m=>t.edges[m.i]?.label).sort((m,M)=>+(t.edges[M.i].kind==="main")-+(t.edges[m.i].kind==="main")||m.i-M.i);for(const m of p){const M=t.edges[m.i].label,L=r(M,"label"),z=16*Kt(M),v=m.pts.length-2,O=[];_t(m.pts).forEach(([q,D],T)=>{const R=Math.abs(q.y-D.y)<.01,H=R?q.x:q.y;let Q=R?D.x:D.y;const at=Math.sign(Q-H)||1;T===v&&(Q-=at*s.head);let it=[[H,Q]];for(const et of c)for(const nt of R?[et.l,et.r]:[et.t,et.b]){const tt=R?q.y:q.x;(R?tt>et.t&&ttet.l&&ttnt>Math.min(u,w)+1&&nt{const tt=(et+nt)/2,$=R?{x:tt,y:q.y}:{x:q.x,y:tt};return!c.some(u=>$.x>u.l&&$.xu.t&&$.y1&&yt(et,nt)?1:0})}),O.sort((q,D)=>D.pri-q.pri||D.len-q.len);let B=null,j=!1;const F=(q,D=!0)=>{const T=ce(q,b);return D&&(q.ll.r||q.tl.b)||n.some(R=>ze(T,R))||g.some(R=>Ct(T,R))||o.heads.some(R=>Ct(T,R))||o.rects.some(R=>Ct(T,R))?!1:!e.some(R=>R.i!==m.i&&_t(R.pts).some(([H,Q])=>Ct(T,ue(H,Q,R.width))))};for(const q of O){for(const D of[1/2,1/3,2/3]){const T=q.p+(q.q-q.p)*D,R=[],H=d("2")+m.width/2;if(q.horiz?(q.len>=L+2*d("1")+d("3-5")&&R.push({box:{l:T-L/2-d("1"),r:T+L/2+d("1"),t:q.c-z/2,b:q.c+z/2},on:!0}),R.push({box:{l:T-L/2,r:T+L/2,t:q.c-H-z,b:q.c-H},on:!1}),R.push({box:{l:T-L/2,r:T+L/2,t:q.c+H,b:q.c+H+z},on:!1})):(q.len>=z+d("3")&&R.push({box:{l:q.c-L/2-d("1"),r:q.c+L/2+d("1"),t:T-z/2,b:T+z/2},on:!0}),R.push({box:{l:q.c+H,r:q.c+H+L,t:T-z/2,b:T+z/2},on:!1}),R.push({box:{l:q.c-H-L,r:q.c-H,t:T-z/2,b:T+z/2},on:!1})),B=R.find(Q=>F(Q.box))??null,B)break;!j&&R.some(Q=>F(Q.box,!1))&&(j=!0)}if(B)break}if(!B){i.push(m.i),j&&h.push(m.i);continue}const rt=Ze(B.box,a.ox,a.oy,q=>F(q));g.push(rt),f.push({i:m.i,text:M,box:rt,on:B.on})}return{labels:f,unseated:i,bounded:h}}function Je(t,e,n,o){const c=[],l=[];return t.querySelectorAll(`.${n}-gbox, .${n}-group`).forEach(s=>{if(s.getClientRects().length===0||getComputedStyle(s).display==="contents")return;const r=xt(s,e);l.push(r),c.push({l:r.l,r:r.r,t:r.t,b:r.t+1},{l:r.l,r:r.r,t:r.b-1,b:r.b},{l:r.l,r:r.l+1,t:r.t,b:r.b},{l:r.r-1,r:r.r,t:r.t,b:r.b});const a=s.querySelector(`:scope > .${n}-glabel`);a&&a.getClientRects().length&&c.push(xt(a,e))}),t.querySelectorAll(`.${n}-lane`).forEach((s,r)=>{if(!s.getClientRects().length)return;const a=xt(s,e);r>0&&c.push({l:a.l,r:a.r,t:a.t-o/2-.5,b:a.t-o/2+.5});const d=s.querySelector(`.${n}-lane-name`);d&&c.push(xt(d,e))}),{obstacles:{rects:c,heads:[]},groups:l}}function Ue(t,e){const{m:o,tk:c,P:l,drawing:s,origin:r,warn:a}=t,d=c.space,g=Ve(o,s,r,l),f=[...g.values()],i=Gn(s),h=r.left-Math.floor(r.left),b=r.top-Math.floor(r.top),p=We(h,b),m=s.clientWidth,M=s.clientHeight,L=y=>o.type==="data-flow"?y.col+1:y.col,z=parseFloat(getComputedStyle(s).rowGap)||0,v={w:m,h:M,nodes:f,lines:[],lifelines:[],labels:[],crossings:[],through:[],unseated:[],outside:[],ox:h,oy:b};if(o.type==="sequence")return Zn(t,v,p);let O,B=[];o.type==="schema"?O=o.edges.map(y=>{const S=o.byId.get(y.from),E=o.byId.get(y.to);if(S.col===E.col){const W=!((o.rtl?S.col===1:S.col===o.cols)&&o.cols>1)===!o.rtl?"right":"left";return[W,W]}return E.col>S.col?["right","left"]:["left","right"]}):(O=o.edges.map(y=>{const S=o.byId.get(y.from),E=o.byId.get(y.to),[k,A]=fe(S,E);return[y.fromSide??k,y.toSide??A]}),B=He(o,O,a||(()=>{})));const j=(y,S)=>{const E=s.querySelector(`.${l}-node[data-node="${CSS.escape(y)}"] .${l}-row[data-row="${S}"]`);if(!E)return 0;const k=xt(E,r);return(k.t+k.b)/2},F=new Map;if(o.type==="schema"){const y=new Map;o.edges.forEach((E,k)=>{const A=`${E.to}.${E.toRow}.${O[k][1]}`;y.set(A,[...y.get(A)??[],k])});const S=E=>{const k=o.edges[E].card?.to;return k==="one"?0:k==="zero-or-one"?1:2};for(const E of y.values()){const k=[...new Set(E.map(S))].sort((A,W)=>A-W);if(k.length>1)for(const A of E)F.set(A,(k.indexOf(S(A))-(k.length-1)/2)*d("2"))}}const rt=y=>Math.round(y+h)-h,q=o.edges.map((y,S)=>{const[E,k]=O[S],A=g.get(y.from),W=g.get(y.to),J=Qt(y.kind,c);if(y.fk){const P=j(y.from,y.fromRow),ot=j(y.to,y.toRow)+(F.get(S)??0),gt=p.y(P,J),Bt=p.y(ot,J),Et=E==="right"?A.rect.r:A.rect.l,St=k==="right"?W.rect.r:W.rect.l;return{p1:{x:y.card?rt(Et):Et,y:gt},p2:{x:y.card?rt(St):St,y:Bt},r1:P,r2:Math.abs(gt-Bt)<.01?P:ot}}const K=B.find(P=>P.edge===S&&P.end==="from").f,Y=B.find(P=>P.edge===S&&P.end==="to").f;let U=Ge(A,E,K),Z=Ge(W,k,Y);const N=ct(E)?U.y:U.x;let G=ct(k)?Z.y:Z.x;return ct(E)?U={...U,y:p.y(U.y,J)}:U={...U,x:p.x(U.x,J)},ct(k)?Z={...Z,y:p.y(Z.y,J)}:Z={...Z,x:p.x(Z.x,J)},ct(E)&&ct(k)&&Math.abs(U.y-Z.y)<1.01&&(Z={...Z,y:U.y},G=N),!ct(E)&&!ct(k)&&Math.abs(U.x-Z.x)<1.01&&(Z={...Z,x:U.x},G=N),U=ct(E)?Mt(A,E,U.y):Mt(A,E,U.x),Z=ct(k)?Mt(W,k,Z.y):Mt(W,k,Z.x),{p1:U,p2:Z,r1:N,r2:G}}),D=new Set,T=(y,S)=>{D.has(y)||(D.add(y),a?.(`${o.edges[y].from} to ${o.edges[y].to} ${S}, so its line is not drawn; its row still writes the target`))};for(const y of Xt(o).dropped)T(y,"would need a third lane of turn-backs");const R=new Map,H=Lt();o.type==="schema"&&o.edges.forEach((y,S)=>{const E=o.byId.get(y.from),k=o.byId.get(y.to);if(Math.abs(E.col-k.col)<2)return;const A=Math.min(E.col,k.col),W=Math.max(E.col,k.col),J=o.nodes.filter(ot=>ot.col>A&&ot.colgt.row<=ot&>.row2>=ot+1)||Y.push({key:`g${ot}`,y:(K[ot-1][1]+K[ot][0])/2,inner:!0});Y.push({key:"top",y:K[0][0]-d("4"),inner:!1},{key:"bottom",y:K[K.length-1][1]+d("4"),inner:!1});const U=(q[S].r1+q[S].r2)/2,Z=t.pick?.[S]??Y.slice().sort((ot,gt)=>Math.abs(ot.y-U)-Math.abs(gt.y-U)||Number(gt.inner)-Number(ot.inner)||ot.y-gt.y)[0].key;H[S]=Z;const N=O[S][0]==="right"?E.col:E.col-1,G=i.cols[N-1],P=i.cols[N];R.set(S,{corridor:Z,first:G&&P?{key:`c${N}`,span:[G[1],P[0]]}:null,y:0})});const Q=new Map;for(const[y,S]of R){const E=o.edges[y],k=Q.get(S.corridor)??[],A=k.find(W=>{const J=o.edges[W[0]];return J.to===E.to&&J.toRow===E.toRow&&O[W[0]][1]===O[y][1]&&Math.abs(q[W[0]].p2.y-q[y].p2.y)<.5});A?A.push(y):k.length>=2?T(y,"would need a third lane in its corridor"):k.push([y]),Q.set(S.corridor,k)}for(const y of[...R.keys()])D.has(y)&&R.delete(y);const at=y=>{const S=o.edges[y[0]];return Math.abs(o.byId.get(S.from).col-o.byId.get(S.to).col)*1e4+Math.abs(q[y[0]].p1.x-q[y[0]].p2.x)},it=(y,S,E)=>{const k=i.rows;if(y==="top")return k[0][0]-d("4")-S*d("3");if(y==="bottom")return k[k.length-1][1]+d("4")+S*d("3");const A=Number(y.slice(1));return(k[A-1][1]+k[A][0])/2+(S-(E-1)/2)*d("3")},yt=(y,S)=>S.forEach((E,k)=>E.forEach(A=>{R.get(A).y=it(y,k,S.length)})),dt=()=>{for(const[y,S]of Q){const E=S.map(k=>k.filter(A=>R.has(A))).filter(k=>k.length);Q.set(y,E),yt(y,y==="top"||y==="bottom"?E.slice().sort((k,A)=>at(k)-at(A)):E.slice().sort((k,A)=>at(A)-at(k)))}};dt();const et=new Map,nt=new Set,tt=new Map,$=(y,S,E,k,A)=>{et.has(y)||et.set(y,{span:S,vertical:E,members:new Map});const W=et.get(y);W.members.has(k)||W.members.set(k,[]),W.members.get(k).push(A)},u=()=>{et.clear(),nt.clear(),tt.clear(),o.edges.forEach((y,S)=>{if(D.has(S))return;const E=R.get(S);E?.first&&$(E.first.key,E.first.span,!0,`far:${S}`,-(S+1));const[k,A]=O[S],{p1:W,p2:J}=q[S],K=o.byId.get(y.from),Y=o.byId.get(y.to);let U=null,Z=null,N=!1;if(k===A){if(ct(k)){const G=k==="right"?Math.max(L(K),L(Y)):Math.min(L(K),L(Y))-1,P=i.cols[G-1],ot=i.cols[G];P&&ot&&(U=`c${G}`,Z=[P[1],ot[0]],N=!0)}else{const G=k==="bottom"?Math.max(K.row2,Y.row2):Math.min(K.row,Y.row)-1,P=i.rows[G-1],ot=i.rows[G];P&&ot&&(U=`r${G}`,Z=[P[1],ot[0]],N=!1)}U&&nt.add(S)}else if(ct(k)&&ct(A)&&(E||Math.abs(W.y-J.y)>.5)){const G=L(Y),P=A==="left",ot=i.cols[(P?G-1:G)-1],gt=i.cols[(P?G:G+1)-1];ot&>&&(U=`c${P?G-1:G}`,Z=[ot[1],gt[0]],N=!0)}else if(!ct(k)&&!ct(A)&&Math.abs(W.x-J.x)>.5){const P=A==="top"?Y.row-1:Y.row2,ot=i.rows[P-1],gt=i.rows[P];ot&>&&(U=`r${P}`,Z=[ot[1],gt[0]],N=!1)}!U||!Z||(E&&tt.set(S,Z),$(U,Z,N,`${y.to}.${A}.${Math.round(N?J.y:J.x)}`,S))})};u();const w=new Map,C=y=>{const[S,E]=O[y],{p1:k,p2:A}=q[y],W=R.get(y);if(W){const J=tt.get(y),K=w.get(-(y+1))??(W.first?(W.first.span[0]+W.first.span[1])/2:k.x),Y=w.get(y)??(J?(J[0]+J[1])/2:A.x);return[k,{x:K,y:k.y},{x:K,y:W.y},{x:Y,y:W.y},{x:Y,y:A.y},A]}if(ct(S)&&ct(E)){if(S===E){const K=d(o.marks?"6":"4")+(o.type==="schema"&&o.cols===1?(Xt(o).lane.get(y)??0)*d("3"):0),Y=w.get(y)??(S==="right"?Math.max(k.x,A.x)+K:Math.min(k.x,A.x)-K);return[k,{x:Y,y:k.y},{x:Y,y:A.y},A]}if(Math.abs(k.y-A.y)<=.5)return[k,{x:A.x,y:k.y}];const J=w.get(y)??(k.x+A.x)/2;return[k,{x:J,y:k.y},{x:J,y:A.y},A]}if(!ct(S)&&!ct(E)){if(S===E){const K=w.get(y)??(S==="bottom"?Math.max(k.y,A.y)+d("4"):Math.min(k.y,A.y)-d("4"));return[k,{x:k.x,y:K},{x:A.x,y:K},A]}if(Math.abs(k.x-A.x)<=.5)return[k,{x:k.x,y:A.y}];const J=w.get(y)??(k.y+A.y)/2;return[k,{x:k.x,y:J},{x:A.x,y:J},A]}return ct(S)?[k,{x:A.x,y:k.y},A]:[k,{x:k.x,y:A.y},A]},I=y=>{const S=o.edges[y],E=Qt(S.kind,c),k=C(y),A=Ne(k,E,p);let W;return k.length===A.length&&(W=_t(k).map(([J,K])=>Math.abs(J.y-K.y)<.75?(J.y+K.y)/2:(J.x+K.x)/2),W[0]=q[y].r1,W.length>1&&(W[W.length-1]=q[y].r2)),{i:y,from:S.from,to:S.to,kind:S.kind,pts:A,tip:A[A.length-1],dir:de(A),dot:S.fk&&!S.card?A[0]:void 0,card:S.card,width:E,axes:W}},_=()=>o.edges.flatMap((y,S)=>D.has(S)?[]:[I(S)]);let X=null;const V=y=>{X??(X=_());const S=X.map(E=>y.has(E.i)?I(E.i):E);return{lines:S,score:Kn(S,y)*1e5+te(S,void 0,y).length*1e3+pe(S.filter(E=>y.has(E.i)),f,o).length}},ft=(y,S)=>{const E=y.flatMap(k=>{const A=k<0?-k-1:k,{p1:W,p2:J}=q[A],K=R.get(A);return K?k<0?[W.y,K.y]:[K.y,J.y]:S?[W.y,J.y]:[W.x,J.x]});return[Math.min(...E),Math.max(...E)]},st=y=>y<0?-y-1:y,lt=y=>{const S=[...y.members.values()].map(k=>({members:k,run:ft(k,y.vertical)})).sort((k,A)=>k.run[0]-A.run[0]),E=[];for(const k of S){const A=E[E.length-1];A&&A.some(W=>W.run[0]!(k.length===1&&k[0].members.every(A=>nt.has(A))))},pt=y=>(S,E)=>y[S].run[0]{const S=pt(y),E=[];return y.forEach((k,A)=>{let W=0;for(;E.some((J,K)=>J===W&&S(A,K));)W++;E.push(W)}),E},ut=y=>Math.max(0,...kt(y))+1;if(o.marks)for(let y=0;y3){S=W.map(J=>J.members.map(st));break}if(!S)break;const E=A=>Math.max(...A),k=S.filter(A=>A.some(W=>R.has(W))).sort((A,W)=>E(W)-E(A))[0]??S.slice().sort((A,W)=>E(W)-E(A))[0];for(const A of k)T(A,"would need a fourth lane in a marked gutter"),R.delete(A);u()}const $t=(y,S,E,k=!1)=>{const A=o.rtl&&k?E-1-S:S,W=y[1]-y[0];if(!o.marks)return y[0]+W/(E+1)*(A+1);const J=c.foot+c.radiusXs,K=E>1?Math.min(W/(E+1),(W-2*J)/(E-1)):0;return(y[0]+y[1])/2+(A-(E-1)/2)*K};dt();for(const[y,S]of Q){if(y==="top"||y==="bottom"||S.length<2)continue;const E=new Set(S.flat());let k=S,A=1/0;for(const W of he(S.slice().sort((J,K)=>at(K)-at(J)))){yt(y,W),X=null;const J=V(E);J.scoreY.members);if(o.marks){const Y=ut(S),U=pt(S),Z=S.length,N=new Set(E.flat().map(st)),G=Et=>Et.forEach((St,zt)=>E[zt].forEach(jt=>w.set(jt,$t(y.span,St,Y,y.vertical))));let P=kt(S),ot=1/0,gt=null;const Bt=[P];if(Y**Z<=729)for(let Et=0;EtMath.floor(Et/Y**jt)%Y);St.every((zt,jt)=>St.every((ne,Vt)=>Vt<=jt||zt!==ne||!U(jt,Vt)))&&Bt.push(St)}for(const Et of Bt){G(Et);const St=V(N);St.scoreZ.forEach(G=>w.set(G,$t(y.span,N,k,y.vertical))));const U=V(A);U.scoreY.forEach(Z=>w.set(Z,$t(y.span,U,k,y.vertical)))),X=K}if(v.lines=_(),o.marks&&(v.lines=v.lines.filter(y=>{if(!y.card)return!0;const S=_t(y.pts),E=([A,W])=>Math.hypot(W.x-A.x,W.y-A.y),k=S.length===1?2*c.foot:c.foot+c.radiusXs-.5;return E(S[0])>=k&&E(S[S.length-1])>=k?!0:(T(y.i,"has no room for its marks at an end"),R.delete(y.i),!1)})),R.size){const y=new Set([...R.values()].map(E=>E.corridor)),S=[y.has("top")?"var(--basalt-space-8)":"0px"];for(let E=1;E<=o.rows;E++)S.push("auto",EKe(y,c));const vt=Vn(o,v.lines,f,bt,wt,{l:0,t:0,r:m,b:M},c,e,{ox:h,oy:b});return v.labels=vt.labels,v.unseated=vt.unseated,v.bounded=vt.bounded,v.overlaps=[...new Set(Xe(v.lines,null).flat())],v}function Kn(t,e){return Xe(t,e).length}function Xe(t,e){const n=[];for(let o=0;o=r)continue;const[m,M]=i?[a.x,d.x]:[a.y,d.y],[L,z]=i?[g.x,f.x]:[g.y,f.y];Math.min(Math.max(m,M),Math.max(L,z))-Math.max(Math.min(m,M),Math.min(L,z))>1&&n.push([l.i,s.i])}}return n}function*he(t){if(t.length<=1){yield t.slice();return}if(t.length>5){yield t.slice();return}for(let e=0;e{const a=r===l.pts.length-1?Math.max(l.width/2,o.head/2):l.width/2;return s.x-a<-.5||s.x+a>e+.5||s.y-a<-.5||s.y+a>n+.5})&&c.push(l.i);return c}function pe(t,e,n){const o=[];for(const c of t){const l=_t(c.pts);e.some(s=>l.some(([r,a])=>Nn(r,a,s)))&&o.push(c.i)}return o}function Zn(t,e,n){const{m:o,tk:c,P:l,drawing:s,origin:r}=t,a=c.space,d=new Map;s.querySelectorAll(`.${l}-node`).forEach(v=>d.set(v.dataset.node,xt(v,r)));const g=s.querySelector(`.${l}-steps`),f=g?xt(g,r).b:e.h,i=v=>{const O=d.get(v);return O?n.x((O.l+O.r)/2,c.hair):0};for(const v of o.nodes){const O=d.get(v.id);O&&e.lifelines.push({x:i(v.id),y1:O.b,y2:f})}const h=v=>d.get(v.id),b=new Map;s.querySelectorAll(`.${l}-msg`).forEach(v=>{const O=xt(v,r);b.set(Number(v.querySelector(`.${l}-num`)?.textContent??0),(O.t+O.b)/2)});const p=c.activation,m=p/2,M=v=>{const O=o.byId.get(v.who);if(!O)return null;const B=i(v.who),F=(O.i===o.nodes.length-1&&o.nodes.length>1?-1:1)*(o.rtl?-1:1),rt=(v.depth-1)*a("1")*F,q=b.get(v.from)??0,D=b.get(v.to)??q,T=v.from===v.to;return{l:n.x(B-m+rt,c.hair),r:n.x(B+m+rt,c.hair),t:n.y(T?q-a("2")-a("1"):q,c.hair),b:n.y(T?q+a("2")+a("1"):D,c.hair)}},L=o.bars.map(v=>({bar:v,rect:M(v)})).filter(v=>v.rect);e.bars=L.map(v=>v.rect);const z=(v,O,B)=>L.filter(({bar:j})=>j.who===v&&j.to>=O&&(B?j.from<=O:j.fromF.bar.depth-j.bar.depth)[0]?.rect;s.querySelectorAll(`.${l}-msg`).forEach(v=>{const O=v.dataset.from,B=v.dataset.to,j=v.dataset.kind??"plain",F=Qt(j,c),rt=xt(v,r),q=n.y((rt.t+rt.b)/2,F),D=Number(v.querySelector(`.${l}-num`)?.textContent??0);let T=i(O),R=i(B),H;if(O===B){const nt=v.dataset.self==="start"?-a("6"):a("6"),tt=z(O,D,!0),$=tt?nt>0?tt.r:tt.l:T,u=n.y(q-a("2"),F),w=n.y(q+a("2"),F);H=[{x:$,y:u},{x:n.x(T+nt,F),y:u},{x:n.x(T+nt,F),y:w},{x:$,y:w}]}else{const nt=R>T?1:-1,tt=z(O,D,!1),$=z(B,D,!0);tt&&(T=nt>0?tt.r:tt.l),$&&(R=nt>0?$.l:$.r),H=[{x:T,y:q},{x:R,y:q}]}e.lines.push({i:D,from:O,to:B,kind:j,pts:H,tip:H[H.length-1],dir:de(H),width:F});const Q=v.querySelector(`.${l}-said`),at=v.querySelector(`.${l}-note`),it=o.byId.get(O),yt=o.byId.get(B);if(!it||!yt)return;const dt=O===B?(()=>{const nt=o.nodes.find($=>$.col===it.col+(v.dataset.self==="start"?-1:1)),tt=nt?i(nt.id):v.dataset.self==="start"?0:e.w;return Math.abs(tt-T)-a("6")-a("2-5")-a("2")})():Math.abs(R-T)-2*a("2");Math.max(Q?Q.getBoundingClientRect().width:0,at?at.getBoundingClientRect().width:0)>dt+.5&&e.unseated.push(D)}),s.querySelectorAll(`.${l}-fhead`).forEach(v=>{const O=v.parentElement?.querySelector(`:scope > .${l}-fbox`);if(!O)return;[...v.children].reduce((j,F)=>j+F.getBoundingClientRect().width,0)+a("3")>O.getBoundingClientRect().width+.5&&(e.misfit??(e.misfit=[])).push(`the frame "${v.querySelector(`.${l}-flabel`)?.textContent??""}" is wider than its participants`)});{const v=[...s.querySelectorAll(`.${l}-fbox`)].flatMap(O=>{const B=xt(O,r);return[{x:B.l+.5,t:B.t,b:B.b},{x:B.r-.5,t:B.t,b:B.b}]});v.length&&s.querySelectorAll(`.${l}-said, .${l}-note, .${l}-band > span`).forEach(O=>{if(!O.getClientRects().length)return;const B=ce(xt(O,r),a("1"));v.some(j=>B.lj.x&&B.tj.t)&&(e.misfit??(e.misfit=[])).push(`"${O.textContent?.trim()??""}" would lie on a frame's side`)})}return e}function Jn(t,e,n,o,c){const l=[];for(const[s,r]of t){if(!r.getClientRects().length)continue;const a=xt(r,n),d=xt(s,n),g=getComputedStyle(r),f=getComputedStyle(s),i={l:a.l+(parseFloat(g.paddingLeft)||0),r:a.r-(parseFloat(g.paddingRight)||0)},h=i.r-i.l,b=d.l+(parseFloat(f.borderLeftWidth)||0),p=d.r-(parseFloat(f.borderRightWidth)||0),m=[];for(const j of e)for(const[F,rt]of _t(j.pts)){const q=ue(F,rt,j.width);q.ta.t&&m.push({l:q.l,r:q.r})}const M=c("2-5"),L=j=>m.every(F=>F.r<=j-M+.01||F.l>=j+h+M-.01);if(L(i.l))continue;const z=m.map(j=>o?i.r-(j.l-M):j.r+M-i.l).filter(j=>j>0).sort((j,F)=>j-F),v=j=>o?i.l-j:i.l+j,O=j=>o?v(j)>=b+c("3")-.01:v(j)+h<=p-c("3")+.01,B=z.find(j=>O(j)&&L(v(j)));if(B===void 0){l.push(r.textContent??"");continue}r.style.setProperty("--_gx",`${Math.round(B*100)/100}px`)}return l}function Qe(t,e,n,o=Lt()){const{m:c,tk:l,P:s,drawing:r,origin:a}=t,d=l.space,g=Ve(c,r,a,s),f=[...g.values()],i=a.left-Math.floor(a.left),h=a.top-Math.floor(a.top),b=We(i,h,!!c.rtl),p=r.clientWidth,m=r.clientHeight,M={w:p,h:m,nodes:f,lines:[],lifelines:[],labels:[],crossings:[],through:[],unseated:[],outside:[],ox:i,oy:h},L=Lt();if(c.type==="sequence"||c.type==="schema")return{geo:M,grow:L};const z=!!c.rtl,v=z?-1:1,O=u=>z?u.r:u.l,B=u=>z?u.l:u.r,j=z?"left":"right",F=(u,w,C,I)=>{const _=u+I*v*w,X=_+I*v*C;return{l:Math.min(_,X),r:Math.max(_,X)}},rt=getComputedStyle(r),q=z?parseFloat(rt.paddingLeft)||0:p-(parseFloat(rt.paddingRight)||0),D=(u,w,C)=>{const I=[u];for(let _=1;_<=(Ot(o,w)??0);_++)I.push({...u,t:u.t+C*d("4")*_,b:u.b+C*d("4")*_});return I},T=new Map;r.querySelectorAll(`.${s}-node`).forEach(u=>{const w=u.parentElement,C=xt(w,a),I=getComputedStyle(w);T.set(u.dataset.node,z?C.l+(parseFloat(I.paddingLeft)||0)+(parseFloat(I.borderLeftWidth)||0):C.r-(parseFloat(I.paddingRight)||0)-(parseFloat(I.borderRightWidth)||0))});const R=c.nodes,H=u=>g.get(R[u].id),Q=new Map;r.querySelectorAll(`.${s}-group > .${s}-glabel`).forEach(u=>{u.style.removeProperty("--_gx"),Q.set(u.parentElement,u)});const at=new Map;for(const[u,w]of Q)w.getClientRects().length&&at.set(u,xt(w,a));const it=u=>{const w=r.querySelector(`.${s}-node[data-node="${CSS.escape(u)}"]`),C=w?.parentElement;return!!(C?.matches(`.${s}-group[data-turn]`)&&C.querySelector(`:scope > .${s}-node`)===w)},yt=(u,w,C)=>it(w)?Array.from({length:Math.round(C/16)+1},(I,_)=>({...u,t:u.t-_*d("4"),b:u.b-_*d("4")})):[u],dt=[],et=u=>Qt(c.edges[u].kind,l);c.edges.forEach((u,w)=>{const C=n.routes[w],I=g.get(u.from),_=g.get(u.to),X=et(w);let V=[];const ft=u.label,st=ft?e(ft,"label"):0,lt=ft?16*Kt(ft):16,pt=d("4");if(C==="down"||C==="up"){const ut=Math.max(I.rect.l,_.rect.l),$t=Math.min(I.rect.r,_.rect.r),bt=c.edges.map((S,E)=>({o:S,j:E})).filter(({o:S,j:E})=>(n.routes[E]==="down"||n.routes[E]==="up")&&(S.from===u.from&&S.to===u.to||S.from===u.to&&S.to===u.from)),wt=bt.findIndex(S=>S.j===w),vt=bt.length<2?.5:bt.length===2?wt===0?.25:.75:(wt+1)/(bt.length+1);let y=b.x(ut+($t-ut)*vt,X);if(C==="down"){const S=r.querySelector(`.${s}-node[data-node="${CSS.escape(u.to)}"]`),E=S?.parentElement,k=E&&E.matches(`.${s}-group`)&&E.querySelector(`:scope > .${s}-node`)===S?at.get(E):void 0;if(k&&E&&!E.contains(r.querySelector(`.${s}-node[data-node="${CSS.escape(u.from)}"]`))){const A=d("2-5")+X/2;if(y>k.l-A&&y=ut+d("6"):W<=$t-d("6"))&&(y=b.x(W,X))}}}if(V=C==="down"?[Mt(I,"bottom",y),Mt(_,"top",y)]:[Mt(I,"top",y),Mt(_,"bottom",y)],ft){let S=Math.min(V[0].y,V[1].y),E=Math.max(V[0].y,V[1].y);C==="down"?E-=l.head:S+=l.head;const k=[...r.querySelectorAll(`.${s}-group`)].map(K=>xt(K,a));let A=[[S,E]];for(const K of k)for(const Y of[K.t,K.b])A=A.flatMap(([U,Z])=>Y>U+1&&Yk.some(U=>(K+Y)/2>U.t&&(K+Y)/2U.l&&y1){const K=A.filter(([U,Z])=>!W(U,Z));[S,E]=(K.length?K:A).reduce((U,Z)=>Z[1]-Z[0]>U[1]-U[0]?Z:U)}const J=[1/2,1/3,2/3].map(K=>{const Y=S+(E-S)*K;return{l:y-st/2-d("1"),r:y+st/2+d("1"),t:Y-lt/2,b:Y+lt/2}});dt.push({k:w,cands:J,on:!0,card:C==="down"?u.to:u.from})}}else if(C==="trunk"||C==="rail"){const ut=C==="rail"?z?Math.min(I.rect.r,_.rect.r):Math.max(I.rect.l,_.rect.l):O(I.rect),$t=b.x(ut+v*d(C==="trunk"?"8":"3"),X),bt=Mt(I,"bottom",$t);if(C==="rail"){if(V=[bt,Mt(_,"top",$t)],ft){const wt=_.rect.t-d("6");dt.push({k:w,cands:D({...F($t,d("2-5"),st,1),t:wt-lt/2,b:wt+lt/2},u.to,-1),on:!1,card:u.to})}}else{const wt=b.x(O(_.rect)+v*d("6"),X),vt=b.y(_.rect.t-pt,X);V=[bt,{x:$t,y:vt},{x:wt,y:vt},Mt(_,"top",wt)];const y={...F(wt,d("2-5"),st,1),t:vt-lt/2,b:vt+lt/2};ft&&dt.push({k:w,cands:[...yt(y,u.to,lt),...D(y,u.to,-1).slice(1)],on:!1,card:u.to})}}else{const ut=Z=>T.get(Z)??(z?0:p),$t=z?Math.max(ut(u.from),ut(u.to)):Math.min(ut(u.from),ut(u.to)),bt=b.x(n.gutter?q+v*(n.lanes[w]+1)*d("3-5"):$t-v*d("2-5"),X),wt=b.y(I.rect.t+(I.rect.b-I.rect.t)*n.exits[w],X),vt=Mt(I,j,wt),y=C==="end-down",S=c.edges.map((Z,N)=>({o:Z,j:N})).filter(({o:Z,j:N})=>n.routes[N]===C&&Z.to===u.to).sort((Z,N)=>n.lanes[N.j]-n.lanes[Z.j]||Z.j-N.j),E=Math.max(0,S.findIndex(({j:Z})=>Z===w)),k=B(_.rect)-v*(d("6")+E*d("3")),A=B(_.rect)-v*(d("6")+(S.length-1)*d("3")),W=b.x(k,X),J=y?_.rect.t-pt-E*d("5"):_.rect.b+pt+E*d("5"),K=b.y(J,X);V=[vt,{x:bt,y:vt.y},{x:bt,y:K},{x:W,y:K},Mt(_,y?"top":"bottom",W)];const Y=y?u.to:R[_.i+1]?.id??u.to,U={...F(A,d("2-5"),st,-1),t:J-lt/2,b:J+lt/2};ft&&dt.push({k:w,cands:[...y?yt(U,Y,lt):[U],...D(U,Y,y?-1:1).slice(1)],on:!1,card:Y})}const kt=Ne(V,X,b);M.lines.push({i:w,from:u.from,to:u.to,kind:u.kind,pts:kt,tip:kt[kt.length-1],dir:de(kt),width:X})}),M.crossings=te(M.lines),M.through=pe(M.lines,f,c),M.outside=Ye(M.lines,p,m,l),M.seatless=Jn(Q,M.lines,a,z,d);const{obstacles:nt}=Je(r,a,s,0);nt.heads=M.lines.map(u=>Ke(u,l));const tt=[],$={l:0,t:0,r:p,b:m};for(const u of dt){const w=_=>{const X=ce(_,d("1"));return _.l<$.l-.5||_.r>$.r+.5||_.t<$.t-.5||_.b>$.b+.5||f.some(V=>ze(X,V))||tt.some(V=>Ct(X,V))||nt.heads.some(V=>Ct(X,V))||nt.rects.some(V=>Ct(X,V))||M.lines.some(V=>V.i!==u.k&&_t(V.pts).some(([ft,st])=>Ct(X,ue(ft,st,V.width))))},C=u.cands.find(_=>!w(_));C||(L[u.card]=(L[u.card]??0)+1,M.unseated.push(u.k));const I=C?Ze(C,i,h,_=>!w(_),z):u.cands[0];tt.push(I),M.labels.push({i:u.k,text:c.edges[u.k].label,box:I,on:u.on})}return{geo:M,grow:L}}function Pe(t,e,n=0){const o=s=>String(Math.round(s*100)/100);let c=`M${o(t[0].x)} ${o(t[0].y)}`;for(let s=1;s{const{crow:D,ring:T}=Oe(j,F.x,F.y,rt,n.head,n.dot);return`${T?``:""}`};return`${B(e.card.from,v,Math.sign(O.x-v.x)||1,"from")}${B(e.card.to,e.tip,-l.x||1,"to")}`}const s=e.kind==="dashed",r=n.head,a=n.head/2,d=s?1:r-1,g=e.pts.map(v=>({...v})),f=g[g.length-1];f.x-=l.x*d,f.y-=l.y*d;const i=e.tip.x-l.x*r,h=e.tip.y-l.y*r,b=-l.y*a,p=l.x*a,m=v=>Math.round(v*100)/100,M=mt(e.kind),L=s?``:``,z=e.dot?``:"";return`${L}${z}`}function tn(t,e,n,o){const c=new Map,l=new Map;for(const r of e.crossings)l.has(r.under)||l.set(r.under,[]),l.get(r.under).push(r);let s="";for(const[r,a]of l){const d=`${o}-cut-${r}`;c.set(r,d);const g=a.map(f=>{const i=e.lines[f.top],h=e.lines[f.under],b=i.width/2+n.cut,p=h.width/2+1;return f.underVertical?``:``}).join("");s+=`${g}`}return{defs:s,ids:c}}function en(t,e,n,o){const{defs:c,ids:l}=tn(t,e,n,o),s=e.lifelines.map(i=>``).join(""),r=(e.bars??[]).map(i=>``).join(""),a=e.lines.map((i,h)=>Xn(t,i,n,l.get(h)??null,i.from===i.to?n.radiusXs:n.radius)).join(""),g=`${s?`${s}`:""}${c?`${c}`:""}${r}${a}`,f=e.labels.map(i=>`1?' data-lines="2"':""}>${i.text.split(` -`).map(mt).join("
")}
`).join("");return g+f}function Yn(t,e,n){const o=t.querySelector(`.${e}-ink`);if(!o||!n)return;const c=s=>`${Math.round(s*100)/100}px`;o.querySelectorAll(`:scope > .${e}-label`).forEach((s,r)=>{const a=n.labels[r];if(!a||s.dataset.edge!==String(a.i))return;const d=[["left",c(a.box.l)],["top",c(a.box.t)],["width",c(a.box.r-a.box.l)]];for(const[g,f]of d)s.style.getPropertyValue(g)!==f&&s.style.setProperty(g,f)})}function ge(t,e,n,o,c,l,s,r){const d=t.querySelector(`.${n}-drawing`);if(!d||t.clientWidth===0)return{dyn:c,geo:null,ink:"",tokens:null};const g=zn(t),f=Hn(d,n),i=Dn(e,g,f);r?.(i.least);const h=t.clientWidth,b=(()=>{const q=document.activeElement;return q&&d.contains(q)&&q.dataset.node?q.dataset.node:void 0})(),p=q=>Tt(e,q)?{...q,stop:q.stop&&e.byId.has(q.stop)?q.stop:e.nodes[0]?.id,keep:void 0}:{...q,stop:q.stop??e.nodes[0]?.id,keep:b&&q.layout!=="drawn"?b:void 0};let m=!1;const M=q=>{if(m=!1,e.type!=="flowchart")return q;l({...q,heights:void 0,words:void 0});const D=Lt(),T=Lt();return d.querySelectorAll(`.${n}-node[data-shape="decision"]`).forEach(R=>{const H=R.querySelector(`.${n}-words`);if(!H)return;const Q=R.getBoundingClientRect(),at=dt=>{const et={w:dt.width+2*g.space("2-5"),h:dt.height+2*g.space("2")},nt=1-et.w/Q.width,tt=nt>.05?et.h/2/nt:et.h*10;return Math.max(g.space("16"),Math.ceil(Q.width/5),Math.ceil(2*tt))},it=H.getBoundingClientRect();let yt=at(it);if(yt>Q.width){const dt=$=>(R.style.setProperty("--_ww",`${$}px`),H.getBoundingClientRect()),et=Math.floor(R.clientWidth-2*g.space("2-5"));let nt=Math.ceil(it.width),tt=it.height;for(;nt1;){const I=$+u>>1;dt(I).heightQ.width&&(m=!0)}),{...q,heights:D,words:Object.keys(T).length?T:void 0}},L=()=>({m:e,tk:g,P:n,drawing:d,origin:d.getBoundingClientRect(),warn:s}),z=c.autoOpen?{open:!1,autoOpen:void 0}:{},v=(q,D)=>D.map(T=>Gt(e,q.lines.find(R=>R.i===T))).join(", ");if(e.text)return{dyn:{...c,layout:"stacked",bare:void 0},geo:null,ink:"",tokens:g,least:i.least};if(h>=i.least&&!e.unplaced){const q=H=>{let Q=p({...c,...z,layout:"drawn",grow:void 0,track:void 0,bare:void 0,pad:H||void 0,rows:void 0});Q=M(Q),l(Q);let at=Ue(L(),f);return at.corridors&&(Q={...Q,rows:at.corridors.rows},l(Q),at=Ue({...L(),pick:at.corridors.pick},f)),{dd:Q,g:at}};let{dd:D,g:T}=q(!1);const R=H=>H.through.length>0||H.outside.length>0||(H.overlaps?.length??0)>0||(H.misfit?.length??0)>0||m;if(!R(T)&&T.unseated.length&&T.unseated.every(H=>T.bounded?.includes(H))){const H=q(!0);!R(H.g)&&!H.g.unseated.length&&({dd:D,g:T}=H)}if(!R(T)&&!T.unseated.length)return T.crossings.length&&s?.(`${T.crossings.length} crossing${T.crossings.length===1?"":"s"} in the drawn layout: ${T.crossings.map(H=>`${Gt(e,T.lines[H.top])} over ${Gt(e,T.lines[H.under])}`).join("; ")}`),{dyn:D,geo:T,ink:en(n,T,g,o),tokens:g,least:i.least};m&&s?.(`the drawn layout does not fit at ${Math.round(h)}px: a decision would be taller than it is wide`),T.misfit?.length&&s?.(`the drawn layout does not fit at ${Math.round(h)}px: ${T.misfit.join("; ")}`),T.through.length&&s?.(`the drawn layout does not fit at ${Math.round(h)}px: ${v(T,T.through)} would pass through a node`),T.overlaps?.length&&s?.(`the drawn layout does not fit at ${Math.round(h)}px: ${v(T,T.overlaps)} would lie on one another`),T.outside.length&&s?.(`the drawn layout does not fit at ${Math.round(h)}px: ${v(T,T.outside)} would leave the drawing`),T.unseated.length&&s?.(`the drawn layout does not fit at ${Math.round(h)}px: no clean seat for ${T.unseated.map(H=>e.type==="sequence"?`message ${H}`:`"${qt(e.edges[H]?.label??"")}"`).join(", ")}`)}let O=p({...c,...z,layout:"stacked",heights:void 0,grow:Lt(),track:e.type==="schema"?i.table:void 0,bare:void 0,pad:void 0,rows:void 0});if(O=M(O),l(O),e.type==="sequence"||e.type==="schema")return{dyn:O,geo:null,ink:"",tokens:g,least:i.least};const B=Ie(e);let j=Qe(L(),f,B,O.grow);for(let q=0;q<6&&Object.keys(j.grow).length;q++){const D=Lt(O.grow);for(const[T,R]of Object.entries(j.grow))D[T]=(Ot(D,T)??0)+R;O={...O,grow:D},l(O),j=Qe(L(),f,B,D)}const F=j.geo;if(!B.third&&B.laneCount>2&&s?.(`the stacked drawing uses ${B.laneCount} end lanes (four at most)`),F.unseated.length>0||F.through.length>0||F.outside.length>0||B.third){F.unseated.length&&s?.(`the stacked drawing has no clean seat for ${[...new Set(F.unseated)].map(T=>`"${qt(e.edges[T]?.label??"")}"`).join(", ")}, so its lines are not drawn; the list holds every connection`),F.through.length&&s?.(`in the stacked drawing ${v(F,F.through)} would pass through a node, so its lines are not drawn`),F.outside.length&&s?.(`in the stacked drawing ${v(F,F.outside)} would leave the drawing, so its lines are not drawn`),B.third&&s?.("the stacked drawing would need a fifth end lane, so its lines are not drawn","error");const q={...F,lines:[],labels:[],crossings:[]};d.querySelectorAll(`.${n}-group > .${n}-glabel`).forEach(T=>T.style.removeProperty("--_gx"));const D=p({...O,grow:Lt(),bare:!0,open:c.bare?c.open:!0,autoOpen:c.bare?c.autoOpen:c.open?void 0:!0});return l(D),{dyn:D,geo:q,ink:"",tokens:g,least:i.least}}return F.seatless?.length&&s?.(`a stacked group's label has no clear seat on its top edge: ${F.seatless.map(q=>`"${q}"`).join(", ")}`),F.crossings.length&&s?.(`${F.crossings.length} crossing${F.crossings.length===1?"":"s"} in the stacked drawing (each is cut): ${F.crossings.map(q=>`${Gt(e,F.lines[q.top])} over ${Gt(e,F.lines[q.under])}`).join("; ")}`),{dyn:O,geo:F,ink:en(n,F,g,o),tokens:g,least:i.least}}function Gt(t,e){const n=t.byId.get(e.from)?.name??e.from,o=t.byId.get(e.to)?.name??e.to;return`${n} to ${o}`}function Qn(t,e,n,o,c,l){const s=new Set;if(l){s.add(l);for(const p of n?.lines??[])p.from===l&&s.add(p.to),p.to===l&&s.add(p.from)}if(t.toggleAttribute("data-tracing",!!l),t.querySelectorAll(`.${e}-node`).forEach(p=>p.toggleAttribute("data-near",s.has(p.dataset.node))),!n||!o)return;const r=p=>!!l&&(p.from===l||p.to===l),a=t.querySelector(`.${e}-edges`),d=new Map;t.querySelectorAll(`.${e}-edge`).forEach(p=>d.set(p.getAttribute("data-edge"),p));for(const p of n.lines){const m=d.get(String(p.i));m&&(m.toggleAttribute("data-lit",r(p)),m.toggleAttribute("data-dim",!!l&&!r(p)))}if(t.querySelectorAll(`.${e}-label`).forEach(p=>{const m=n.lines.find(M=>String(M.i)===p.dataset.edge);p.toggleAttribute("data-lit",!!(m&&r(m)))}),a){for(const p of n.lines)if(r(p)){const m=d.get(String(p.i));m&&a.appendChild(m)}}const g=te(n.lines,r),{defs:f,ids:i}=tn(e,{...n,crossings:g},o,c),h=t.querySelector(`.${e}-svg`);if(!h)return;let b=h.querySelector("defs");!b&&f&&(b=document.createElementNS("http://www.w3.org/2000/svg","defs"),h.insertBefore(b,h.firstChild)),b&&(b.innerHTML=f),n.lines.forEach((p,m)=>{const M=d.get(String(p.i))?.querySelector(`.${e}-line`);if(!M)return;const L=i.get(m);L?M.setAttribute("mask",`url(#${L})`):M.removeAttribute("mask")})}var Pn=()=>matchMedia("(prefers-reduced-motion: reduce), (forced-colors: active), print").matches||document.documentElement.getAttribute("data-loops")==="held";function to(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",Pn()||no(t)?"done":"pending")}}var eo=t=>`basalt-diagram-entrance:${location.pathname}#${t.id}`;function no(t){if(!t.hasAttribute("data-first-visit")||!t.id)return!1;try{return localStorage.getItem(eo(t))!==null}catch{return!1}}function nn(t){const e=t.getAttribute("data-entrance");e!=="pending"&&e!=="running"||(t.setAttribute("data-entrance","done"),t.dispatchEvent(new Event("basalt-diagram-settle")))}function oo(t,e,n,o=!1,c=!1){const l=o?Ut(t):null;if(l&&n.startsWith("Arrow")){const d={ArrowRight:c?"left":"right",ArrowLeft:c?"right":"left",ArrowDown:"down",ArrowUp:"up"}[n];return d?l[e]?.[d]??null:null}const s=t.byId.get(e)?.i??0,r=t.nodes.length;let a;if(n==="ArrowRight"||n==="ArrowDown")a=s+1;else if(n==="ArrowLeft"||n==="ArrowUp")a=s-1;else if(n==="Home")a=0;else if(n==="End")a=r-1;else return null;return t.nodes[Math.max(0,Math.min(r-1,a))].id}var so=["data-layout","data-measured","role","aria-roledescription","aria-labelledby","aria-describedby","aria-label","tabindex","data-stops","hidden","data-art"],on=["data-layout","data-measured","data-bare","data-motion","data-first-visit","data-rtl","data-cols","data-reach","data-gutter","data-marks"],ao=["--_track","--_h","--_ww","--_gap","--_ggrow","--_tl","--_gpad","--_gw","--_mh","--_rows","--_row-gap"],sn=t=>t==null||t===!1;function ro(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 ee(t,e,n=!0){if(typeof e=="string"||"slot"in e)return;const o=n?on:so;for(const s of o)sn(e.a[s])&&t.removeAttribute(s);for(const[s,r]of Object.entries(e.a)){if(s==="class")continue;if(s==="style"){const d=t.style,g=new Map(String(r??"").split(";").map(f=>{const i=f.indexOf(":");return[f.slice(0,i).trim(),f.slice(i+1).trim()]}).filter(([f])=>f));for(const[f,i]of g)d.getPropertyValue(f).trim()!==i&&d.setProperty(f,i);for(const f of ao)g.has(f)||d.removeProperty(f);continue}if(n&&!on.includes(s))continue;if(sn(r)){t.removeAttribute(s);continue}const a=r===!0?"":String(r);t.getAttribute(s)!==a&&t.setAttribute(s,a)}if(e.t==="svg"||typeof e.a.class=="string"&&(/-ruler$/.test(e.a.class)||/-ink$/.test(e.a.class)&&!e.a.class.endsWith("-text-ink"))||e.c.some(s=>typeof s!="string"&&"slot"in s))return;const c=[...t.children];let l=0;for(const s of e.c)if(!(typeof s=="string"||"slot"in s)){for(let r=l;rt.querySelector(`.${e}-node[data-node="${CSS.escape(l)}"]`);n&&c(n)?.setAttribute("tabindex","-1"),c(o)?.setAttribute("tabindex","0")}(function(t){"use strict";var e=t._,n="diagram",o=0;function c(i,h,b){return{prefix:n,base:i,hasSource:h.source!==void 0&&h.source!==null&&h.source!=="",hiddenClass:"visually-hidden",viewer:b?b.keys:void 0}}function l(i,h,b,p){var m=function(M){return''+mt(M)+""};return{source:mt(String(h.source||"")),summary:mt(String(h.summary||"")),hint:ie(i).map(function(M){return""+M.keys.map(m).join(" ")+" "+mt(M.words)+""}).join(""),toggle:'"}}function s(i,h,b){for(var p=i.layout==="auto"&&(i.type==="architecture"||i.type==="flowchart"||i.type==="schema"),m=p?Array.isArray(i.placement)?i.placement:i.placement?[i.placement]:[]:[],M=i.direction||(i.type==="flowchart"?"down":"right"),L=null,z=0;z");return{open:B.slice(0,j+1),inner:B.slice(j+1,B.length-9),warnings:v.errors.map(function(F){return"error: "+F}).concat(v.warnings)}}var r=["aria-labelledby","data-type","data-cols","data-reach","data-gutter","data-marks","data-layout","data-measured","data-bare"],a=["--_cols","--_gpad","--_track"];function d(i,h,b,p){i.__diagram&&i.__diagram.stop();var m=(i.getAttribute("aria-labelledby")||"").replace(/-title$/,"").replace(/[^A-Za-z0-9_-]/g,""),M=getComputedStyle(i).direction==="rtl",L=h.layout==="auto"&&(h.type==="architecture"||h.type==="flowchart"||h.type==="schema"),z=L?Array.isArray(h.placement)?h.placement:h.placement?[h.placement]:[]:[];L&&!z.length&&console.warn('Basalt diagram: "layout": "auto" needs a placement, which compose.mjs writes at build time; drawn from script, place it with placeDiagram (@srasyndicate/basalt/diagram-layout) and pass "placement". The figure is stacked');var v=h.direction?[h.direction]:h.type==="flowchart"?["down","right"]:["right","down"],O=function(N){for(var G=0;G .diagram-drawing")){if(!m||!i.querySelector("#"+CSS.escape(m+"-title"))){for(;document.getElementById("dg"+ ++o+"-title"););m="dg"+o}var j=s(h,m,p),F=document.createElement("div");F.innerHTML=j.open+"";var rt=F.firstChild;r.forEach(function(N){i.removeAttribute(N)}),a.forEach(function(N){i.style.removeProperty(N)});for(var q=0;q :not(script[data-diagram])").forEach(function(N){N.remove()}),i.insertAdjacentHTML("beforeend",j.inner)}B.warnings.forEach(function(N){console.warn("Basalt diagram: "+N)}),B.errors.forEach(function(N){console.error("Basalt diagram: "+N)}),B.motion.animated&&B.motion.firstVisit&&!i.id&&console.error('Basalt diagram: "entrance": "first-visit" needs an id on the figure: without one the entrance plays on every visit');var T=c(m,h,p),R={},H=null,Q=null,at=null,it=null,yt=Object.create(null),dt=function(N,G){yt[N]||(yt[N]=1,(G==="error"?console.error:console.warn)("Basalt diagram: "+N))},et=function(N){ee(i,Yt(B,N,T))},nt=i.querySelector(".diagram-ink"),tt=i.querySelector(".diagram-toggle"),$=!p&&B.motion.animated&&typeof e.diagramMotion=="function",u=null,w=null,C=function(){$&&nn(i)};function I(){Qn(i,n,H&&H.geo,H&&H.tokens,m,Q||it||at),V()}var _=null,X=!p&&matchMedia("(hover: none), (pointer: coarse)").matches;function V(){var N=X&&!p&&nt&&nt.innerHTML!=="";if(i.toggleAttribute("data-touch",!!(X&&!p)),N&&!_){var G=i.querySelector(":scope > .diagram-foot");if(!G)return;_=document.createElement("button"),_.type="button",_.className="btn diagram-clear",_.setAttribute("data-variant","secondary"),_.setAttribute("data-size","sm"),_.innerHTML="Clear highlight",_.addEventListener("click",function(){it&&(it=null,I())}),G.appendChild(_)}else!N&&_&&(_.remove(),_=null);_&&_!==_.parentNode.lastElementChild&&document.activeElement!==_&&_.parentNode.appendChild(_),_&&(it?_.removeAttribute("aria-disabled"):_.setAttribute("aria-disabled","true"))}function ft(N){if(!N.defaultPrevented){var G=bn(i,n,N,it);G!==void 0&&(C(),X=!0,it=G,I())}}function st(){tt&&(tt.setAttribute("aria-expanded",String(!!R.open)),tt.firstElementChild.textContent=R.open?"Hide the list":"View as list")}function lt(){if(L&&z.length>1&&!p){for(var N=null,G=[],P=!1,ot=0;ot1&&p&&!h.direction&&p.room){for(var ne=p.room(),Vt=-1,me=null,ye=0;yeVt+1e-6&&(Vt=rn,me=$e)}}}me&&(B=me)}H=(p?p.measure:ge)(i,B,n,m,R,et,dt),R=H.dyn,et(R),st();var be=i.querySelector(":scope > .diagram-hint");if(be){var ln=ie(B,R.layout==="drawn").map(function(At){return""+At.keys.map(function(fo){return''+mt(fo)+""}).join(" ")+" "+mt(At.words)+""}).join("");be.innerHTML!==ln&&(be.innerHTML=ln)}Tt(B,R)||(at=it=null);var cn=nt&&H.ink!==w;cn&&(nt.innerHTML=H.ink,w=H.ink),Yn(i,n,H.geo),I();var co=B.text?i.querySelector(".diagram-text[data-art]"):null;B.text&&typeof e.diagramText=="function"&&e.diagramText(i,B,h,p);var dn=B.text?i.querySelector(".diagram-text[data-art]"):null;$&&H.tokens&&(to(i,!!(H.geo&&H.geo.lines.length)||!!dn),(cn||dn!==co)&&u&&u.redrawn()),p&&p.onMeasured&&H.tokens&&p.onMeasured(H,i)}function pt(N){R=N,et(R)}function kt(N){var G=R.stop;R=Object.assign({},R,{stop:N}),io(i,n,G,N)}var ut=function(N){var G=N&&N.closest?N.closest(".diagram-node"):null;return G&&i.contains(G)?G:null};function $t(N){var G=ut(N.target);if(!(!G||N.defaultPrevented)){if(C(),N.key==="Escape"){!p&&(Q||at||it)&&(N.preventDefault(),Q=at=it=null,I());return}if(Tt(B,R)){var P=oo(B,G.getAttribute("data-node"),N.key,R.layout==="drawn");if(P){N.preventDefault(),kt(P);var ot=i.querySelector('.diagram-node[data-node="'+CSS.escape(P)+'"]');ot&&ot.focus()}}}}function bt(N){var G=ut(N.target);if(G){C();var P=G.getAttribute("data-node");Q=G.matches(":focus-visible")?P:null,Tt(B,R)&&R.stop!==P&&kt(P),I()}}function wt(N){var G=ut(N.target);G&&(ut(N.relatedTarget)||(Q=null),R.keep===G.getAttribute("data-node")&&pt(Object.assign({},R,{keep:void 0})),I())}function vt(N){if(!(N.pointerType!=="mouse"||!matchMedia("(hover: hover)").matches)){var G=ut(N.target);G&&C();var P=G&&Tt(B,R)?G.getAttribute("data-node"):null;P!==at&&(at=P,I())}}function y(){at&&(at=null,I())}function S(){C(),pt(Object.assign({},R,{open:!R.open,autoOpen:void 0})),st()}i.addEventListener("keydown",$t),i.addEventListener("focusin",bt),i.addEventListener("focusout",wt),i.addEventListener("pointerover",vt),i.addEventListener("pointerleave",y),i.addEventListener("click",ft),tt&&tt.addEventListener("click",S),lt();var E=i.clientWidth,k=0,A=!0,W=new ResizeObserver(function(){Math.abs(i.clientWidth-E)<.5||(E=i.clientWidth,cancelAnimationFrame(k),k=requestAnimationFrame(lt))});W.observe(i),document.fonts&&document.fonts.ready.then(function(){A&<()});var J=matchMedia("(forced-colors: active)"),K=B.nodes.some(function(N){return N.mark});K&&J.addEventListener("change",lt),$&&(u=e.diagramMotion(i,{fig:i,P:n,base:m,model:function(){return B},geo:function(){return H&&H.geo},tokens:function(){return H&&H.tokens}},h));var Y=!p&&h.zoom!==!1&&typeof e.diagramZoom=="function"?e.diagramZoom(i,h,{model:B,settle:C,animated:$}):null,U=i.querySelector(":scope > .diagram-foot"),Z=!p&&h.export===!0&&U&&typeof e.diagramExport=="function"?e.diagramExport(U,i):[];i.__diagram={stop:function(){Y&&Y.destroy(),Z.forEach(function(N){N.remove()}),A=!1,W.disconnect(),cancelAnimationFrame(k),K&&J.removeEventListener("change",lt),u&&u.destroy(),i.removeEventListener("keydown",$t),i.removeEventListener("focusin",bt),i.removeEventListener("focusout",wt),i.removeEventListener("pointerover",vt),i.removeEventListener("pointerleave",y),i.removeEventListener("click",ft),_&&_.remove(),tt&&tt.removeEventListener("click",S)},layout:lt,key:g(h),send:u&&u.sendValue?u.sendValue:null}}function g(i){try{return JSON.stringify(i,function(h,b){return h==="packet"&&b&&typeof b=="object"?Object.assign({},b,{send:void 0}):b})}catch{return null}}function f(){document.querySelectorAll("figure.diagram").forEach(function(i){if(!i.__diagram){var h=i.querySelector(":scope > script[data-diagram]");if(h)try{d(i,JSON.parse(h.textContent),!0)}catch(b){console.error("Basalt diagram: this figure could not be drawn",b)}}})}e.diagramMarkup=s,e.diagramKit={draw:d,buildModel:Nt,figureKey:En,figureList:Bn,hintEntries:ie,toHtml:se,escapeHtml:mt,settleEntrance:nn,measureFigure:ge},t.diagram=function(i,h){var b=i.__diagram,p=b&&b.send?g(h):null;if(p!==null&&p===b.key){b.send(h.packet?h.packet.send:void 0);return}d(i,h)},e.step(62,"wireDiagrams",f)})(window.Basalt)})(); +`)?2:1,qt=t=>t.replace(/\n/g," "),Ft=t=>{const e=t.trim();return e?/[.!?]$/.test(e)?e:`${e}.`:""};function Me(t,e){return t.legend[e]}function gn(t,e){return e.shape==="decision"?"decision":e.shape==="terminal"?t.edges.some(n=>n.from===e.id)?"start":"end":e.kind??"step"}function mn(t,e){return Rt(t,`sentence:${e.i}`,()=>yn(t,e))}function yn(t,e){const n=[];if(t.type==="schema"){n.push(`${e.name}, table.`);const o=(e.columns??[]).filter(l=>l.ref).map(l=>`${l.ref.table} (${l.name}${l.card?`: ${Se(e.id,l.ref.table,l.card)}`:""})`),c=t.edges.filter(l=>l.to===e.id).map(l=>`${l.from} (${t.byId.get(l.from).columns[l.fromRow].name}${l.card?`: ${Se(l.from,l.to,l.card)}`:""})`);o.length&&n.push(`References ${o.join(", ")}.`),c.length&&n.push(`Referenced by ${c.join(", ")}.`)}else if(t.type==="sequence"){const o=t.steps.filter(s=>"n"in s&&s.from===e.id).length,c=t.steps.filter(s=>"n"in s&&s.to===e.id).length;n.push(Ft(e.kind?`${e.name}, ${e.kind}`:e.name)),n.push(`Sends ${o} ${o===1?"message":"messages"} and receives ${c}.`);const l=Ee(t,e);l&&n.push(l.trim())}else{const o=t.type==="data-flow"?`${t.stepWord(e.step)} of ${t.nodes.length}, ${e.laneLabel}`:t.type==="flowchart"?gn(t,e):e.kind;if(n.push(Ft(o?`${e.name}, ${o}`:e.name)),e.detail&&n.push(Ft(e.detail)),e.group){const s=t.groups.find(a=>a.id===e.group),r=s?.parent?t.groups.find(a=>a.id===s.parent):void 0;s&&n.push(r?`In ${s.label}, in ${r.label}.`:`In ${s.label}.`)}const c=t.edges.filter(s=>s.to===e.id).map(s=>`${t.byId.get(s.from).name}${s.label?` (${qt(s.label)})`:""}`),l=t.edges.filter(s=>s.from===e.id).map(s=>`${t.byId.get(s.to).name}${s.label?` (${qt(s.label)})`:""}`);c.length&&n.push(`From: ${c.join(", ")}.`),l.length&&n.push(`To: ${l.join(", ")}.`)}return e.focal&&t.legend.focal&&n.push(Ft(t.legend.focal)),n.join(" ")}var $n=(t,e,n,o)=>[`${Ht[n.from].toLowerCase()} `,o(t),` to ${Ht[n.to].toLowerCase()} `,o(e)],Se=(t,e,n)=>`${Ht[n.from].toLowerCase()} ${t} to ${Ht[n.to].toLowerCase()} ${e}`;function Ee(t,e){const n=t.bars.filter(c=>c.who===e.id&&c.depth===1);return n.length?` ${t.legend.activation??"Working"} during ${n.map(c=>c.from===c.to?`message ${c.from}`:`messages ${c.from} to ${c.to}`).join(" and ")}.`:""}function bn(t,e,n,o){const c=n.pointerType;if(c!=="touch"&&c!=="pen")return;const l=t.querySelector(`.${e}-drawing`),s=n.target;if(!l||!s||!l.contains(s)||!t.querySelector(`.${e}-edge`))return;const r=s.closest(`.${e}-node`);if(!r?.hasAttribute("href"))return r?r.dataset.node===o?null:r.dataset.node??null:o===null?void 0:null}function Ae(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 o=[];for(const c of n.flat(1/0))c!=null&&c!==!1&&!Array.isArray(c)&&o.push(c);return{t,a:e??{},c:o}}var wn={"&":"&","<":"<",">":">",'"':""","'":"'"},mt=t=>t.replace(/[&<>"']/g,e=>wn[e]),vn=" br img input meta link hr path polygon polyline circle rect line ";function ae(t,e={}){if(typeof t=="string")return mt(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[o,c]of Object.entries(t.a))if(!(c==null||c===!1)){if(!/^[a-z][a-z0-9:-]*$/i.test(o))throw new Error(`diagram: "${o}" is not an attribute name`);n+=c===!0?` ${o}`:` ${o}="${mt(String(c))}"`}return vn.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(o=>ae(o,e)).join("")}`}var xn=t=>({title:`${t}-title`,summary:`${t}-summary`,keys:`${t}-keys`,list:`${t}-list`,toggle:`${t}-toggle`});function Tt(t,e){return!e.layout||e.bare?!1:e.layout==="drawn"?!0:t.type!=="sequence"&&t.type!=="schema"}function kn(t,e){return t.type==="sequence"||t.type==="schema"?e.layout==="drawn":!0}function Zt(t,e){const n=e.all.map(o=>t.byId.get(o));return n.length?{c1:Math.min(...n.map(o=>o.col)),c2:Math.max(...n.map(o=>o.col)),r1:Math.min(...n.map(o=>o.row)),r2:Math.max(...n.map(o=>o.row2))}:null}function Le(t){return Rt(t,"group-edges",()=>{const e=[0,0,0,0];for(const n of t.groups){const o=Zt(t,n);if(!o)continue;[o.r1===1,o.c2===t.cols,o.r2===t.rows,o.c1===1].forEach((l,s)=>{l&&(e[s]=Math.max(e[s],_e(t,n,s)))})}return e})}function _e(t,e,n){const o=Zt(t,e);return t.groups.filter(s=>s.parent===e.id).some(s=>{const r=Zt(t,s);return r&&[r.r1===o.r1,r.c2===o.c2,r.r2===o.r2,r.c1===o.c1][n]})?2:1}function qe(t){const e=Le(t);return e[1]+e[3]}function Jt(t){return t.type==="sequence"?t.nodes.length:t.cols}function Ie(t){return Rt(t,"plan",()=>Mn(t))}function Mn(t){const e=t.nodes,n=m=>t.type==="data-flow"||!e[m].branch,o=t.edges.map(m=>{const M=t.byId.get(m.from).i,L=t.byId.get(m.to).i,v=e.slice(Math.min(M,L)+1,Math.max(M,L)).every(C=>!n(C.i));return L===M+1&&!(n(M)&&!n(L))?"down":L===M-1?"up":L>M&&n(M)&&!n(L)&&v?"trunk":L>M&&n(M)&&n(L)&&v?"rail":L>M?"end-down":"end-up"}),c=t.edges.map((m,M)=>({e:m,k:M})).filter(({k:m})=>o[m]==="end-down"||o[m]==="end-up"),l=m=>{const M=t.byId.get(m.from).i,L=t.byId.get(m.to).i;return[Math.min(M,L),Math.max(M,L)]},s=(m,M)=>{const[L,z]=l(m),[v,C]=l(M);return L{const M=t.byId.get(m.from).i,[L,z]=l(m);return!n(M)&&e.slice(L+1,z).every(v=>!n(v.i))&&c.every(v=>v.e===m||!s(v.e,m))}),a=c.length>0&&(t.type==="data-flow"||!r),d=m=>{const[M,L]=l(m);return L-M},g=t.edges.map(()=>0);let f=!1;const i=[];for(const m of[...c].sort((M,L)=>d(M.e)-d(L.e)||M.k-L.k)){let M=0;for(const L of i)s(L.e,m.e)&&(M=Math.max(M,g[L.k]+1));g[m.k]=M,M>3&&(f=!0),i.push(m)}const h=Math.max(0,...c.map(({k:m})=>g[m]+1)),b=t.edges.map(()=>.5);for(const m of e){const M=c.filter(({e:v})=>v.from===m.id);if(M.length<2)continue;const L=M.filter(({k:v})=>o[v]==="end-down").sort((v,C)=>d(C.e)-d(v.e)||v.k-C.k);[...M.filter(({k:v})=>o[v]==="end-up").sort((v,C)=>d(v.e)-d(C.e)||C.k-v.k),...L].forEach(({k:v},C,B)=>{b[v]=B.length===2?C===0?1/3:2/3:(C+1)/(B.length+1)})}const p=Lt();for(let m=1;m{const D=o[q],T=t.byId.get(rt.from).i,R=t.byId.get(rt.to).i,H=R===m&&(D==="down"||D==="trunk"||D==="rail"||D==="end-down"),Q=T===m&&R===m-1&&D==="up",at=R===m-1&&D==="end-up";H&&(D==="trunk"||D==="end-down")&&(C=!0),at&&(B=!0),(H||Q||at)&&rt.label&&(z++,v=Math.max(v,D==="trunk"?40:48))}),(z>1||C&&B)&&(v=64);const j=c.filter(({e:rt,k:q})=>o[q]==="end-down"&&t.byId.get(rt.to).i===m).length,F=c.filter(({e:rt,k:q})=>o[q]==="end-up"&&t.byId.get(rt.to).i===m-1).length;v+=20*Math.max(0,j-1)+20*Math.max(0,F-1),p[M.id]=v}return{routes:o,gutter:a,lanes:g,exits:b,gaps:p,third:f,laneCount:h}}var Wt=(t,e)=>({width:t,height:e,viewBox:`0 0 ${t} ${e}`,"aria-hidden":"true",focusable:"false"});function Oe(t,e){const n=e==="fk"?"plain":e,o=n==="main"?8:8.5,c=24,l=n==="dashed"?c-1:c-7;return x("svg",{class:`${t}-swatch`,"data-kind":n,...Wt(24,16)},e==="fk"?x("circle",{class:`${t}-dot`,cx:3,cy:o,r:3}):null,x("path",{class:`${t}-line`,"data-kind":n,d:`M${e==="fk"?3:0} ${o}H${l}`}),n==="dashed"?x("path",{class:`${t}-tip`,"data-kind":n,"data-open":"",d:`M${c-8} ${o-4}L${c} ${o}L${c-8} ${o+4}`}):x("path",{class:`${t}-tip`,"data-kind":n,d:`M${c} ${o}L${c-8} ${o-4}L${c-8} ${o+4}Z`}))}function Sn(t,e){const{crow:n,ring:o}=Ce(e,24,8.5,-1);return x("svg",{class:`${t}-swatch`,"data-card":e,...Wt(24,16)},x("path",{class:`${t}-line`,"data-kind":"plain",d:"M0 8.5H24"}),x("path",{class:`${t}-crow`,d:n}),o?x("circle",{class:`${t}-ring`,cx:o.x,cy:o.y,r:o.r}):null)}function Ce(t,e,n,o,c=8,l=6){const s=h=>String(Math.round(h*100)/100),r=h=>e+o*h,a=c/2,d=h=>`M${s(r(h-.5))} ${s(n-a)}V${s(n+a)}`,g=t==="one-or-many"||t==="zero-or-many",f=t==="zero-or-one"||t==="zero-or-many";let i=g?`M${s(e)} ${s(n-a)}L${s(r(7.5))} ${s(n)}L${s(e)} ${s(n+a)}`:d(4);return f||(i+=d(g?11:8)),{crow:i,ring:f?{x:Math.round(r(10.5)*100)/100,y:n,r:l/2}:void 0}}function Dt(t,e){return e==="decision"?x("svg",{class:`${t}-swatch`,"data-shape":e,...Wt(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,...Wt(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,...Wt(16,16)},x("rect",{class:`${t}-swatch-shape`,x:.5,y:2.5,width:15,height:11,rx:2}))}function Be(t,e){return Rt(e,`key:${t}`,()=>An(t,e))}var En=Be;function An(t,e){const n=[],o=(s,r,a={})=>n.push(x("li",{class:`${t}-entry`,...a},s,x("span",null,r)));if(e.type==="schema"){const s=new Set(e.nodes.flatMap(r=>(r.columns??[]).map(a=>a.key)));for(const[r,a]of[["PK","Primary key"],["FK","Foreign key"]])s.has(r)&&n.push(x("li",{class:`${t}-entry`},x("span",{class:`${t}-key-letters`,"aria-hidden":"true"},r),x("span",null,a)))}if(e.type==="flowchart"){const s=new Set(e.nodes.map(r=>r.shape));s.has("terminal")&&o(Dt(t,"terminal"),e.shapeLabels.terminal),s.has("box")&&o(Dt(t,"box"),e.shapeLabels.step),s.has("decision")&&o(Dt(t,"decision"),e.shapeLabels.decision)}const c=new Set(e.type==="sequence"?e.steps.flatMap(s=>"n"in s?[s.kind]:[]):e.edges.filter(s=>!s.fk).map(s=>s.kind)),l=(s,r)=>x("span",{class:`${t}-key-glyph`,"data-ink":r,"aria-hidden":"true"},s);for(const s of["main","plain","dashed"]){const r=e.legend[s];c.has(s)&&r&&o(e.text?l(s==="main"?"━━▶":s==="dashed"?"┄┄▷":"──▶",s==="main"?"main":"plain"):Oe(t,s),r,{"data-line":e.text?void 0:""})}if(e.type==="schema"&&e.edges.length){e.edges.some(r=>!r.card)&&o(Oe(t,"fk"),e.legend.plain??"A foreign key, to the key it references",{"data-line":"","data-when":"drawn"});const s=new Set(e.edges.flatMap(r=>r.card?[r.card.from,r.card.to]:[]));for(const r of we)s.has(r)&&o(Sn(t,r),Ht[r],{"data-line":"","data-when":"drawn","data-card":r});n.push(x("li",{class:`${t}-entry`,"data-when":"stacked"},x("span",{class:`${t}-fk-mark`,"aria-hidden":"true"},e.rtl?"←":"→"),x("span",null,"The table a foreign key references")))}if(e.type==="sequence"){e.bars.length&&o(e.text?l("┃","working"):x("svg",{class:`${t}-swatch`,"data-shape":"bar",...Wt(16,16)},x("path",{class:`${t}-life`,d:"M8 0V16"}),x("rect",{class:`${t}-bar`,x:4.5,y:2.5,width:7,height:11,rx:1.5})),e.legend.activation??"Working",e.text?{}:{"data-when":"drawn"});const s=new Set(e.steps.flatMap(r=>"open"in r?[r.open]:[]));for(const r of["opt","loop","alt"])s.has(r)&&n.push(x("li",{class:`${t}-entry`},x("span",{class:`${t}-key-letters`,"data-op":"","aria-hidden":"true"},r),x("span",null,e.frameWords[r])))}return e.nodes.some(s=>s.focal)&&e.legend.focal&&o(e.text?l("╔═╗","focal"):Dt(t,"focal"),e.legend.focal,{"data-focal":""}),e.groups.length&&e.legend.group&&o(Dt(t,"group"),e.legend.group),n.length?x("div",{class:`${t}-key`},x("ul",{class:`${t}-legend`,"aria-label":"Key"},n)):null}function Ln(t,e){const n=e==="main"?6:6.5;return x("svg",{class:`${t}-arrow`,"data-kind":e,...Wt(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`}))}var It=t=>x("bdi",null,t);function re(t,e){if(!e.href)return It(e.name);const n=e.name.trimEnd().lastIndexOf(" ");return[n<0?"":e.name.slice(0,n+1),x("span",{class:`${t}-name-end`},n<0?e.name:e.name.slice(n+1))]}function _n(t,e,n){if(n.shape==="decision")return[x("span",{class:`${t}-words`},x("span",{class:`${t}-name`},re(t,n)))];const o=[];return e.type==="data-flow"?o.push(x("span",{class:`${t}-kind`},It(n.kind),x("span",{class:`${t}-lane-word`}," · ",It(n.laneLabel??"")))):n.kind&&o.push(x("span",{class:`${t}-kind`},It(n.kind))),o.push(x("span",{class:`${t}-name`},re(t,n))),n.detail&&o.push(x("span",{class:`${t}-detail`,"data-mono":n.mono?"":void 0},n.mono?x("span",{class:`${t}-runs`},te(n.detail).flatMap((c,l)=>[l?" ":"",x("span",{class:`${t}-run`},c)])):It(n.detail))),o}function qn(t,e,n){return[x("span",{class:`${t}-th`},x("span",{class:`${t}-tname`},re(t,e))),x("span",{class:`${t}-rows`},(e.columns??[]).map((o,c)=>x("span",{class:`${t}-row`,"data-row":c,"data-key":o.key},x("span",{class:`${t}-keyseat`},o.key??""),x("span",{class:`${t}-cname`},o.name),o.ref?x("span",{class:`${t}-ctype`,"data-ref":""},`${n.rtl?"←":"→"} `,It(o.ref.table)):o.type?x("span",{class:`${t}-ctype`},It(o.type)):null))),e.more?x("span",{class:`${t}-more`},`+ ${e.more} more`):null]}var je=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 Ut(t,e,n,o){const{P:c}=t,l=kn(e,o)||o.keep===n.id,s=Tt(e,o),r=o.layout==="drawn"&&o.rows,a=[`--_c:${n.col}`,`--_r:${r?2*n.row:n.row}`,`--_r2:${r?2*n.row2+1:n.row2+1}`];e.type==="data-flow"&&a.push(`--_lc:${n.col+1}`),e.type==="sequence"&&a.push(`--_c2:${n.col+1}`);const d=t.plan;if(d&&n.i>0){const b=Ct(d.gaps,n.id)??32,p=Ct(o.grow,n.id)??0;a.push(`--_gap:${p?`calc(${je(b)} + var(--basalt-space-4) * ${p})`:je(b)}`)}const g=Ct(o.heights,n.id);g&&a.push(`--_h:${g}px`);const f=Ct(De(e),n.id);f&&a.push(`--_mh:${f}px`);const i=Ct(o.words,n.id);i&&a.push(`--_ww:${i}px`);const h=s?o.stop===n.id?0:-1:o.keep===n.id?-1:void 0;return x(n.href?"a":"div",{class:`${c}-node`,href:n.href,target:n.href&&n.blank?"_blank":void 0,rel:n.href&&n.blank?"noopener noreferrer":void 0,"data-link":n.href?n.blank?"external":"":void 0,"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:a.join(";"),role:l&&!n.href?"img":void 0,"aria-label":l||n.href?mn(e,n):void 0,tabindex:h},n.shape==="decision"?x("svg",{class:`${c}-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:`${c}-mark`,"aria-hidden":"true",style:n.mark.onLight?`--_ml:${xe(n.mark.onLight)};--_md:${xe(n.mark.onDark??n.mark.onLight)}`:void 0}):null,n.shape==="table"?qn(c,n,e):_n(c,e,n))}function In(t,e,n){const{P:o}=t,c=[];if(e.type==="data-flow"&&c.push(...e.lanes.map((a,d)=>x("div",{class:`${o}-lane`,style:`--_r:${d+1}`,"aria-hidden":"true"},x("span",{class:`${o}-lane-name`},a.label)))),e.type==="architecture")for(const a of e.groups){const d=Zt(e,a);if(!d)continue;const g=[0,1,2,3].map(f=>_e(e,a,f));c.push(x("div",{class:`${o}-gbox`,"data-group":a.id,"data-depth":a.depth>1?a.depth:void 0,style:`--_c:${d.c1};--_c2:${d.c2+1};--_r:${d.r1};--_r2:${d.r2+1}${g[0]>1?";--_gt:2":""}${g[1]>1?";--_ge:2":""}${g[2]>1?";--_gb:2":""}${g[3]>1?";--_gs:2":""}`,"aria-hidden":"true"},x("span",{class:`${o}-glabel`},It(a.label))))}if(e.text)return[x("pre",{class:`${o}-text`,"aria-hidden":"true","data-art":n.art?"":void 0},x("code",{class:`${o}-text-ink`},On(o,e)))];if(e.type==="sequence")return c.push(x("ul",{class:`${o}-cast`},e.nodes.map(a=>x("li",{class:`${o}-actor`,style:e.rtl?`--_ac:${a.col}`:void 0},Ut(t,e,a,n))))),c.push(Cn(t,e)),c;const l=a=>{const d=a.group?e.groups.find(g=>g.id===a.group):void 0;return d?.parent?e.groups.find(g=>g.id===d.parent):d},s=(a,d,g)=>{const f=t.plan?Ct(n.grow,d[0].id)??0:0,i=d[0],h=t.plan&&i.group===a.id?e.edges.filter((m,M)=>m.to===i.id&&(t.plan.routes[M]==="trunk"||t.plan.routes[M]==="end-down")):[],b=Math.max(0,...h.map(m=>m.label?Kt(m.label):0)),p=[f?`--_ggrow:${f}`:"",b?`--_tl:${b}`:""].filter(Boolean).join(";");return x("div",{class:`${o}-group`,"data-group":a.id,"data-depth":a.depth>1?a.depth:void 0,"data-turn":h.length?"":void 0,style:p||void 0},x("span",{class:`${o}-glabel`,"aria-hidden":"true"},It(a.label)),g)};let r=0;for(;rp.id===g[i].group):void 0;if(!h){f.push(Ut(t,e,g[i],n)),i++;continue}const b=[];for(;iUt(t,e,p,n))))}c.push(s(d,g,f))}return c}function On(t,e){const n=[],o=a=>x("span",{class:`${t}-tx-name`},a),c=a=>a==="main"?"━▶":a==="dashed"?"┄▷":"─▶",l=(a,d,g,...f)=>x("span",{class:`${t}-tx-line`,...a,style:g?`--_in:${d+g};--_hang:${g}`:`--_in:${d}`},...f);n.push(l({"data-ink":"names"},0,0,e.nodes.flatMap((a,d)=>[d?" · ":"",o(a.name)])));const s=String(Math.max(1,...e.steps.map(a=>"n"in a?a.n:0))).length;let r=0;for(const a of e.steps){const d=2*r;if("band"in a){n.push(l({"data-ink":"band"},d,0,`── ${a.band} ──`));continue}if("open"in a){n.push(l({"data-ink":"frame"},d,0,x("span",{"data-ink":"op"},`[${a.open}]`),` ${a.label}`)),r++;continue}if("otherwise"in a){n.push(l({"data-ink":"frame"},2*Math.max(0,r-1),0,x("span",{"data-ink":"op"},"[else]"),` ${a.otherwise}`));continue}if("close"in a){r=Math.max(0,r-1),n.push(l({"data-ink":"frame"},2*r,0,"[end]"));continue}const g=e.byId.get(a.from)?.name??a.from,f=e.byId.get(a.to)?.name??a.to,i=s+2;n.push(l({"data-n":a.n},d,i,x("span",{"data-ink":"num"},String(a.n).padStart(s,"0"))," ",o(g)," ",x("span",{class:`${t}-tx-to`},x("span",{"data-ink":a.kind==="main"?"main":"plain"},c(a.kind))," ",f))),n.push(l({"data-n":a.n},d+i,0,x("span",{"data-ink":"label"},a.label))),a.note&&n.push(l({"data-n":a.n},d+i,0,x("span",{"data-ink":"note"},a.note)))}return n}function Cn(t,e){const{P:n}=t,o=[],c=[],l=()=>c.length?c[c.length-1].el.c:o;let s=null;for(const r of e.steps){if("band"in r){s=null,l().push(x("p",{class:`${n}-band`},x("span",null,r.band)));continue}if("open"in r){s=null;const p=c[c.length-1],m=p?`;--_fis:${r.a===p.a?1:0};--_fie:${r.b===p.b?1:0}`:"",M=x("div",{class:`${n}-frame`,"data-op":r.open,"data-depth":r.depth,style:`--_a:${r.a};--_b:${r.b+1}${m}`},x("span",{class:`${n}-fbox`,"aria-hidden":"true"}),x("p",{class:`${n}-fhead`},x("span",{class:`${n}-ftab`,"aria-hidden":"true"},r.open),x("span",{class:`${n}-flabel`},x("span",{class:t.hidden},`${e.frameWords[r.open]}: `),r.label)));l().push(M),c.push({el:M,a:r.a,b:r.b});continue}if("otherwise"in r){s=null,l().push(x("p",{class:`${n}-felse`},x("span",{class:`${n}-fword`,"aria-hidden":"true"},"else"),x("span",{class:`${n}-flabel`},x("span",{class:t.hidden},`${e.frameWords.else}: `),r.otherwise)));continue}if("close"in r){s=null,c.pop();continue}s||(s=x("ol",{class:`${n}-msgs`,start:r.n}),l().push(s));const a=e.byId.get(r.from),d=e.byId.get(r.to),g=a?.col??1,f=d?.col??1,i=g===f,h=i&&(e.rtl?g!==1:g===e.nodes.length),b=Me(e,r.kind);s.c.push(x("li",{class:`${n}-msg`,"data-kind":r.kind,"data-from":r.from,"data-to":r.to,"data-self":i?h?"start":"end":void 0,style:`--_a:${Math.min(g,f)};--_b:${Math.max(g,f)+1}`},x("span",{class:`${n}-said`},x("span",{class:`${n}-num`},String(r.n)),x("span",{class:`${n}-mlabel`},r.label)),x("span",{class:`${n}-route`},a?.short??r.from," ",x("span",{class:`${n}-to`},Ln(n,r.kind),x("span",{class:t.hidden}," to ")," ",d?.short??r.to,b?` · ${b}`:"")),r.note?x("span",{class:`${n}-note`},r.note):null))}return x("div",{class:`${n}-steps`},o)}function Re(t,e){return Rt(e,`list:${t}`,()=>jn(t,e))}var Bn=Re;function jn(t,e){const n=Math.min(6,e.heading+1),o=f=>x(`h${n}`,{class:`${t}-list-head`},f),c=f=>x("strong",null,f),l=f=>f.href?x("a",{href:f.href,target:f.blank?"_blank":void 0,rel:f.blank?"noopener noreferrer":void 0},c(f.name)):c(f.name),s=f=>x("code",{class:`${t}-code`},f),r=f=>e.byId.get(f)?.name??f,a=f=>{const i=Me(e,f);return i?` (${i})`:""},d=f=>f.focal&&e.legend.focal?` ${Ft(e.legend.focal)}`:"";if(e.type==="architecture"){const f=b=>x("li",null,l(b),b.kind?`, ${b.kind}`:"",b.detail?[". ",b.mono?s(b.detail):b.detail,/[.!?]$/.test(b.detail)?"":"."]:/[.!?]$/.test(b.kind??b.name)?"":".",d(b)),i=[o("Parts")],h=e.nodes.filter(b=>!b.group);h.length&&i.push(x("ul",{class:`${t}-list-items`},h.map(f)));for(const b of e.groups.filter(p=>p.depth===1)){i.push(x("p",{class:`${t}-list-group`},b.label)),b.members.length&&i.push(x("ul",{class:`${t}-list-items`},b.members.map(p=>f(e.byId.get(p)))));for(const p of e.groups.filter(m=>m.parent===b.id))i.push(x("p",{class:`${t}-list-group`,"data-depth":2},p.label)),i.push(x("ul",{class:`${t}-list-items`,"data-depth":2},p.members.map(m=>f(e.byId.get(m)))))}return i.push(o("Connections")),i.push(x("ol",{class:`${t}-list-items`},e.edges.map(b=>x("li",null,c(r(b.from))," to ",c(r(b.to)),b.label?[": ",s(qt(b.label))]:"",`${a(b.kind)}.`)))),i}if(e.type==="flowchart"){const f=i=>(e.byId.get(i)?.i??0)+1;return[x("ol",{class:`${t}-list-items`},e.nodes.map(i=>{const h=e.edges.filter(m=>m.from===i.id),b=i.shape==="decision"?"Decision":i.shape==="terminal"?h.length?"Start":"End":"Step",p=!i.detail&&/[.!?]$/.test(i.name)?" ":". ";return x("li",null,l(i),i.detail?[", ",i.mono?s(i.detail):i.detail]:"",`${p}${b}.`,d(i),h.length?x("ul",{class:`${t}-list-exits`},h.map(m=>x("li",null,m.label?`If ${qt(m.label)}: go to ${f(m.to)}, `:`Then: go to ${f(m.to)}, `,c(r(m.to)),a(m.kind)))):null)}))]}if(e.type==="data-flow")return[x("ol",{class:`${t}-list-items`},e.nodes.map(f=>{const i=e.edges.filter(h=>h.from===f.id);return x("li",null,`${f.laneLabel}: `,l(f),f.detail?[", ",f.mono?s(f.detail):f.detail]:"",".",d(f),i.length?[" Then ",...i.flatMap((h,b)=>[b?"; ":"",`to step ${e.byId.get(h.to).step}, `,c(r(h.to)),h.label?[": ",s(qt(h.label))]:"",a(h.kind)]),"."]:"")}))];if(e.type==="sequence"){const f=[o("Participants"),x("ul",{class:`${t}-list-items`},e.nodes.map(h=>x("li",null,c(h.name),h.kind?`, ${h.kind}`:"",".",d(h),Ee(e,h))))];f.push(o("Messages"));let i=null;for(const h of e.steps){if("band"in h){i=null,f.push(x(`h${Math.min(6,n+1)}`,{class:`${t}-list-group`},h.band));continue}if("open"in h){i=null,f.push(x(`h${Math.min(6,n+1)}`,{class:`${t}-list-group`,"data-depth":h.depth>1?h.depth:void 0},`${e.frameWords[h.open]}: ${h.label}`));continue}if("otherwise"in h){i=null,f.push(x(`h${Math.min(6,n+1)}`,{class:`${t}-list-group`,"data-depth":h.depth>1?h.depth:void 0},`${e.frameWords.else}: ${h.otherwise}`));continue}if("close"in h){i=null;continue}i||(i=x("ol",{class:`${t}-list-items`,start:h.n}),f.push(i)),i.c.push(x("li",null,s(h.label),": ",c(r(h.from))," to ",c(r(h.to)),`${a(h.kind)}.`,h.note?` ${Ft(h.note)}`:""))}return f}const g=[];for(const f of e.nodes)g.push(x(`h${n}`,{class:`${t}-list-group`},f.href?x("a",{href:f.href,target:f.blank?"_blank":void 0,rel:f.blank?"noopener noreferrer":void 0},s(f.name)):s(f.name),d(f))),g.push(x("ul",{class:`${t}-list-items`},[...(f.columns??[]).map(i=>x("li",null,s(i.name),i.key==="PK"?", primary key":i.key==="FK"?", foreign key":"",i.ref?[", references ",s(`${i.ref.table}.${i.ref.column}`),i.card?[" (",$n(f.id,i.ref.table,i.card,s),")"]:""]:i.type?`, ${i.type}`:"")),...f.more?[x("li",null,`and ${f.more} more ${f.more===1?"column":"columns"}`)]:[]]));return g}function Te(t,e=!1){const n=t.type==="architecture"?"part":t.type==="sequence"?"participant":t.type==="schema"?"table":"step";return`${e&&Xt(t)?`Arrow keys move to the nearest ${n} in that direction`:`Arrow keys move to the next or the previous ${n}, in the author's order`}; Home and End go to the ends; Escape clears the trace.${t.nodes.some(c=>c.href)?" Enter opens a part that is a link.":""}`}function ie(t,e=!1){const n=e&&t.type!=="sequence"&&Xt(t)&&t.cols>1&&t.rows>1,o=t.nodes.some(c=>c.href)?[{keys:["Enter"],words:"open"}]:[];return[{keys:n?["←","↑","↓","→"]:["←","→"],words:Ae(t)},{keys:["Home","End"],words:"the ends"},...o,{keys:["Esc"],words:"clear"}]}var Rn=(t,e)=>{for(let n=0;n({col:e.col,rows:[e.row,e.row2]});function Xt(t){return Rt(t,"spatial",()=>{const e=t.nodes.map(l=>({id:l.id,...Tn(t,l)})),n=(l,s)=>{const r=s==="right"||s==="left",a=s==="right"||s==="down",d=b=>r?[b.col,b.col]:b.rows,g=b=>r?b.rows:[b.col,b.col],f=d(l),i=g(l);let h=null;return e.forEach((b,p)=>{if(b===l)return;const m=d(b),M=g(b),L=a?m[0]-f[1]:f[0]-m[1];if(L<1)return;const z=Math.max(0,M[0]-i[1],i[0]-M[1]),v=[z===0?0:1,z===0?L:L+2*z,z,Math.abs(M[0]-i[0]),p];(!h||Rn(v,h.rank))&&(h={id:b.id,rank:v})}),h?.id??null},o=Lt();for(const l of e)o[l.id]={right:n(l,"right"),left:n(l,"left"),down:n(l,"down"),up:n(l,"up")};const c=l=>{const s=new Set([l]),r=[l];for(;r.length;)for(const a of Object.values(o[r.pop()]))a&&!s.has(a)&&(s.add(a),r.push(a));return s.size};return e.every(l=>c(l.id)===e.length)?o:null})}function Yt(t){return Rt(t,"turn-back-lanes",()=>{const e=new Map,n=new Set;if(!le(t))return{lane:e,dropped:n,lanes:0};const o=(a,d)=>(t.byId.get(a)?.row??0)*1e3+d,c=new Map;t.edges.forEach((a,d)=>{const g=`${a.to}.${a.toRow}.${a.card?.to??""}`,f=o(a.from,a.fromRow??0),i=o(a.to,a.toRow??0),h=c.get(g)??{members:[],lo:1/0,hi:-1/0};h.members.push(d),h.lo=Math.min(h.lo,f,i),h.hi=Math.max(h.hi,f,i),c.set(g,h)});const l=[...c.values()].sort((a,d)=>d.hi-d.lo-(a.hi-a.lo)),s=[];let r=0;for(const a of l.reverse()){const d=new Set(s.filter(f=>f.lo<=a.hi&&a.lo<=f.hi).map(f=>f.lane));let g=0;for(;d.has(g);)g++;if(g>1){for(const f of a.members)n.add(f);continue}s.push({lo:a.lo,hi:a.hi,lane:g});for(const f of a.members)e.set(f,g);r=Math.max(r,g+1)}return{lane:e,dropped:n,lanes:r}})}var le=t=>t.type==="schema"&&t.cols===1&&t.edges.length>0;function Qt(t,e,n){const o=n.prefix,c=xn(n.base),l=t.type==="sequence"||t.type==="schema"?null:Ie(t),s={P:o,ids:c,level:n.level,plan:l,hidden:n.hiddenClass},r=e.layout==="drawn",a=Tt(t,e),d=t.type==="sequence"||t.type==="schema"?r:!0,g=`h${t.heading}`,f=[`--_cols:${Jt(t)}`];if(t.type==="architecture"&&t.groups.length||r&&e.pad){const i=t.type==="architecture"?Le(t):[0,0,0,0],h=(p,m,M)=>p?p>1?`calc(${p} * var(--basalt-space-${m}))`:`var(--basalt-space-${m})`:M?`var(--basalt-space-${M})`:"0px",b=r&&e.pad?"3":void 0;f.push(`--_gpad:${h(i[0],"8",b)} ${h(i[1],"4")} ${h(i[2],"4",b)} ${h(i[3],"4")}`)}if(l?.gutter&&l.laneCount>2&&f.push(`--_gw:calc(${l.laneCount} * var(--basalt-space-3-5) + var(--basalt-space-3))`),le(t)){const i=t.marks?"var(--basalt-space-6) + var(--basalt-space-1)":"var(--basalt-space-5)",h=Yt(t).lanes>1?`calc(${i} + var(--basalt-space-3))`:t.marks?`calc(${i})`:i;f.push(t.rtl?`--_gpad:0px 0px 0px ${h}`:`--_gpad:0px ${h} 0px 0px`)}return t.type==="schema"&&e.track&&f.push(`--_track:${e.track}px`),r&&e.one&&f.push(`--_one:${e.one}px`),x("figure",{class:n.className?`${o} ${n.className}`:o,"aria-labelledby":c.title,"data-type":t.type,"data-cols":Jt(t),"data-reach":t.type==="architecture"?qe(t):void 0,"data-gutter":l?.gutter?"":void 0,"data-marks":t.marks?"":void 0,"data-layout":e.layout??(t.unplaced?"stacked":void 0),"data-measured":e.layout?"":void 0,"data-bare":e.bare?"":void 0,"data-motion":t.motion.animated?"animated":void 0,"data-first-visit":t.motion.animated&&t.motion.firstVisit?"":void 0,"data-rtl":t.rtl?"":void 0,"data-viewer":n.viewer?"":void 0,style:f.join(";")},x("div",{class:`${o}-head`},x(g,{id:c.title,class:`${o}-title`},It(t.title)),n.hasSource?x("p",{class:`${o}-source`},x("bdi",null,{slot:"source"})):null),x("div",{class:`${o}-drawing`,style:r&&e.rows?`--_rows:${e.rows};--_row-gap:0px`:void 0,role:d?"group":void 0,"aria-roledescription":d?"diagram":void 0,"aria-labelledby":d?c.title:void 0,"aria-describedby":d?a?`${c.summary} ${c.keys}`:c.summary:void 0,"data-stops":a?"":void 0},In(s,t,e),t.text?null:x("div",{class:`${o}-ink`,"aria-hidden":"true"}),x("span",{class:`${o}-ruler`,"aria-hidden":"true"})),Be(o,t),x("p",{class:`${o}-hint`,"data-kbd-hint":"","aria-hidden":"true"},{slot:"hint"}),Tt(t,e)&&t.type!=="sequence"||r&&t.type==="sequence"?x("p",{class:`${o}-tap-hint`,"aria-hidden":"true"},`Tap ${Ae(t)} to highlight its lines. Tap it again to clear.`):null,x("div",{class:`${o}-foot`},{slot:"toggle"}),x("div",{id:c.list,class:`${o}-list`,hidden:!e.open},Re(o,t)),x("span",{id:c.keys,class:n.hiddenClass},n.viewer?`${Te(t,r)} ${n.viewer}`:Te(t,r)),x("figcaption",{id:c.summary,class:`${o}-summary`},{slot:"summary"}))}function zn(t){const e=getComputedStyle(t),n=(c,l)=>{const s=parseFloat(e.getPropertyValue(`--basalt-${c}`));return Number.isFinite(s)?s:l},o=new Map;return{space:c=>(o.has(c)||o.set(c,n(`space-${c}`,parseFloat(c.replace("-","."))*4)),o.get(c)),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),activation:n("size-diagram-activation",8),foot:n("size-diagram-foot",14)}}var Pt=(t,e)=>t==="main"?e.line:e.hair,xt=(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}},Ot=(t,e,n=.01)=>t.le.l+n&&t.te.t+n,ce=(t,e)=>({l:t.l-e,r:t.r+e,t:t.t-e,b:t.b+e});function Mt(t,e,n){const{l:o,t:c,r:l,b:s}=t.rect,r=(o+l)/2,a=(c+s)/2,d=(l-o)/2,g=(s-c)/2,f=e==="top"||e==="bottom";if(t.shape==="decision"){if(f){const b=n,p=g*Math.max(0,1-Math.abs(b-r)/d);return{x:b,y:e==="top"?a-p:a+p}}const i=n,h=d*Math.max(0,1-Math.abs(i-a)/g);return{x:e==="left"?r-h:r+h,y:i}}if(t.shape==="terminal"){const i=Math.min(d,g);if(f){const m=n,M=Math.min(Math.max(m,o+i),l-i),L=m-M,z=Math.abs(L)>=i?0:Math.sqrt(i*i-L*L);return{x:m,y:Math.abs(L)<1e-6?e==="top"?c:s:e==="top"?a-z:a+z}}const h=n,b=h-a,p=Math.abs(b)>=i?0:Math.sqrt(i*i-b*b);return{x:e==="left"?o+i-p:l-i+p,y:h}}return f?{x:n,y:e==="top"?c:s}:{x:e==="left"?o:l,y:n}}function Wn(t,e,n){const{l:o,t:c,r:l,b:s}=e.rect,r=(o+l)/2,a=(c+s)/2,d=(l-o)/2,g=(s-c)/2;if(e.shape==="decision")return Math.abs(t.x-r)/d+Math.abs(t.y-a)/g<1-n/Math.min(d,g);if(e.shape==="terminal"){const f=Math.min(d,g),i=Math.min(Math.max(t.x,o+f),l-f);return Math.hypot(t.x-i,t.y-a)o+n&&t.xc+n&&t.ymatchMedia("(forced-colors: active)").matches;function Hn(t,e){const n=t.querySelector(`.${e}-ruler`),o=new Map;return(c,l)=>{const s=`${l}|${c}`;return o.has(s)||(n.setAttribute("data-f",l),n.textContent=c,o.set(s,n.getBoundingClientRect().width),n.textContent=""),o.get(s)}}var te=t=>t?t.split(/\s+/).filter(Boolean):[];function Dn(t,e,n){const o=e.space;let c=e.node,l=e.table;for(const a of t.nodes){if(a.shape==="table"){for(const p of a.columns??[]){const m=p.ref?`${t.rtl?"←":"→"} ${p.ref.table}`:p.type??"",M=o("6")+n(p.name,"mono")+(m?o("3")+n(m,"mono"):0)+2*o("3")+2*e.hair;l=Math.max(l,Math.ceil(M))}l=Math.max(l,Math.ceil(n(a.name,"table")+2*o("3")+2*e.hair+(a.href?16+o("1-5"):0)));continue}const d=a.shape==="terminal"?2*o("5"):2*o("3"),g=a.mark&&!Fn()?(a.shape==="participant"?2:1)*o("6"):0;let f=0;const i=a.href?16+o("1-5"):0,h=te(a.name);if(h.forEach((p,m)=>{f=Math.max(f,n(p,a.shape==="decision"?"name-500":"name")+(a.kind?0:g)+(m===h.length-1?i:0))}),t.type!=="data-flow")for(const p of te(a.kind))f=Math.max(f,n(p,"mono")+g);for(const p of te(a.detail))f=Math.max(f,n(p,a.mono?"mono":"sans"));const b=a.shape==="decision"?f/.62:f+d+2*e.hair;c=Math.max(c,Math.ceil(b))}const s=Jt(t);let r;return t.type==="data-flow"?r=e.lane+s*(c+o("12")):t.type==="schema"?r=s*l+(s-1)*(o("12")+(t.marks?o("3"):0))+(le(t)?(t.marks?o("6")+o("1"):o("5"))+(Yt(t).lanes>1?o("3"):0):0):t.type==="sequence"?r=s*c+(s-1)*o("5"):r=s*c+(s-1)*o("16")+qe(t)*o("4"),{track:c,table:l,least:Math.max(e.wide,r),own:Math.ceil(r)}}function We(t,e,n=!1){const o=n?c=>-Math.round(-c):Math.round;return{x:(c,l)=>l%2===1?o(c+t-.5)+.5-t:o(c+t)-t,y:(c,l)=>l%2===1?Math.round(c+e-.5)+.5-e:Math.round(c+e)-e}}function de(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 Ne(t,e,n){const o=t.map(l=>({...l}));for(let l=1;l=2){const a=c[c.length-2];if(Math.abs(a.x-r.x)<.01&&Math.abs(r.x-s.x)<.01||Math.abs(a.y-r.y)<.01&&Math.abs(r.y-s.y)<.01){c[c.length-1]=s;continue}}c.push(s)}}return c}var _t=t=>t.slice(1).map((e,n)=>[t[n],e]);function ee(t,e,n){const o=[];for(let l=0;lMath.min(p.x,m.x)+.75&&zMath.min(M.y,L.y)+.75&&vl.split(/\s+/).map(parseFloat).filter(s=>Number.isFinite(s)),o=(l,s,r)=>{const a=[];let d=s;for(const g of l)a.push([d,d+g]),d+=g+r;return a},c=o(n(e.gridTemplateRows),parseFloat(e.paddingTop)||0,parseFloat(e.rowGap)||0);return{cols:o(n(e.gridTemplateColumns),parseFloat(e.paddingLeft)||0,parseFloat(e.columnGap)||0),rows:t.style.getPropertyValue("--_rows").trim()?c.filter((l,s)=>s%2===1):c}}var ct=t=>t==="left"||t==="right",Fe={top:"bottom",bottom:"top",left:"right",right:"left"};function fe(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 He(t,e,n){const o=[];t.edges.forEach((l,s)=>{const r=t.byId.get(l.from),a=t.byId.get(l.to),[d,g]=e[s],f=r.row===a.row&&ct(d)&&ct(g)&&d===Fe[g]||r.col===a.col&&!ct(d)&&!ct(g)&&d===Fe[g];o.push({edge:s,end:"from",node:r,side:d,far:a,straight:f,f:.5},{edge:s,end:"to",node:a,side:g,far:r,straight:f,f:.5})});const c=new Map;for(const l of o){const s=`${l.node.id}.${l.side}`;c.has(s)||c.set(s,[]),c.get(s).push(l)}for(const[l,s]of c){if(s[0].node.shape==="decision")continue;const r=p=>ct(p.side)?p.far.row-p.node.row:p.far.col-p.node.col,a=s.filter(p=>p.straight),d=s.filter(p=>!p.straight);if(d.sort((p,m)=>r(p)-r(m)||(ct(p.side)?p.far.col-m.far.col:p.far.row-m.far.row)*(r(p)<0?1:-1)),s.length>3&&n(`${l.replace(".","'s ")} side has ${s.length} lines; more than three is an error: use another side`),!a.length){d.length===2?(d[0].f=.25,d[1].f=.75):d.length===3?(d[0].f=.25,d[1].f=.5,d[2].f=.75):d.length>3&&d.forEach((p,m)=>{p.f=(m+1)/(d.length+1)});continue}const g=new Map;for(const p of a)g.has(p.far.id)||g.set(p.far.id,[]),g.get(p.far.id).push(p);for(const p of g.values())p.length>1&&p.sort((m,M)=>m.edge-M.edge).forEach((m,M)=>{m.f=p.length===2?M===0?.25:.75:(M+1)/(p.length+1)});const f=Math.min(...a.map(p=>p.f)),i=Math.max(...a.map(p=>p.f)),h=d.filter(p=>r(p)<0),b=d.filter(p=>r(p)>=0);h.forEach((p,m)=>{p.f=f*(m+1)/(h.length+1)}),b.forEach((p,m)=>{p.f=i+(1-i)*(m+1)/(b.length+1)})}return o}function De(t,e=8,n=8){return Rt(t,`port-floors:${e}:${n}`,()=>{const o=Lt();if(t.type!=="architecture"&&t.type!=="flowchart"&&t.type!=="data-flow")return o;const c=t.edges.map(s=>{const r=t.byId.get(s.from),a=t.byId.get(s.to),[d,g]=fe(r,a);return[s.fromSide??d,s.toSide??g]}),l=new Map;for(const s of He(t,c,()=>{})){if(!ct(s.side)||s.node.shape!=="box")continue;const r=`${s.node.id}.${s.side}`;l.has(r)||l.set(r,[]),l.get(r).push(s.f)}for(const[s,r]of l){if(r.length<2)continue;const a=r.slice().sort((f,i)=>f-i).filter((f,i,h)=>i===0||f-h[i-1]>1e-9);let d=Math.max(e/a[0],e/(1-a[a.length-1]));for(let f=1;f{const s=t.byId.get(l.dataset.node);s&&c.set(s.id,{id:s.id,rect:xt(l,n),shape:s.shape,i:s.i})}),c}function Ke(t,e){const n=e.head,o=e.head/2,{x:c,y:l}=t.tip;return t.dir==="down"?{l:c-o,r:c+o,t:l-n,b:l}:t.dir==="up"?{l:c-o,r:c+o,t:l,b:l+n}:t.dir==="right"?{l:c-n,r:c,t:l-o,b:l+o}:{l:c,r:c+n,t:l-o,b:l+o}}var ue=(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 Ze(t,e,n,o,c=!1){const l=(r,a)=>{const d=r+a-Math.floor(r+a);return d<.005||d>.995?[0]:d<=.5?[-d,1-d]:[1-d,-d]},s=c?l(-t.r,-e).map(r=>-r):l(t.l,e);for(const r of l(t.t,n))for(const a of s){if(!a&&!r)return t;const d={l:t.l+a,r:t.r+a,t:t.t+r,b:t.b+r};if(o(d))return d}return t}function Vn(t,e,n,o,c,l,s,r,a){const d=s.space,g=[],f=[],i=[],h=[],b=d("1"),p=e.filter(m=>t.edges[m.i]?.label).sort((m,M)=>+(t.edges[M.i].kind==="main")-+(t.edges[m.i].kind==="main")||m.i-M.i);for(const m of p){const M=t.edges[m.i].label,L=r(M,"label"),z=16*Kt(M),v=m.pts.length-2,C=[];_t(m.pts).forEach(([q,D],T)=>{const R=Math.abs(q.y-D.y)<.01,H=R?q.x:q.y;let Q=R?D.x:D.y;const at=Math.sign(Q-H)||1;T===v&&(Q-=at*s.head);let it=[[H,Q]];for(const et of c)for(const nt of R?[et.l,et.r]:[et.t,et.b]){const tt=R?q.y:q.x;(R?tt>et.t&&ttet.l&&ttnt>Math.min(u,w)+1&&nt{const tt=(et+nt)/2,$=R?{x:tt,y:q.y}:{x:q.x,y:tt};return!c.some(u=>$.x>u.l&&$.xu.t&&$.y1&&yt(et,nt)?1:0})}),C.sort((q,D)=>D.pri-q.pri||D.len-q.len);let B=null,j=!1;const F=(q,D=!0)=>{const T=ce(q,b);return D&&(q.ll.r||q.tl.b)||n.some(R=>ze(T,R))||g.some(R=>Ot(T,R))||o.heads.some(R=>Ot(T,R))||o.rects.some(R=>Ot(T,R))?!1:!e.some(R=>R.i!==m.i&&_t(R.pts).some(([H,Q])=>Ot(T,ue(H,Q,R.width))))};for(const q of C){for(const D of[1/2,1/3,2/3]){const T=q.p+(q.q-q.p)*D,R=[],H=d("2")+m.width/2;if(q.horiz?(q.len>=L+2*d("1")+d("3-5")&&R.push({box:{l:T-L/2-d("1"),r:T+L/2+d("1"),t:q.c-z/2,b:q.c+z/2},on:!0}),R.push({box:{l:T-L/2,r:T+L/2,t:q.c-H-z,b:q.c-H},on:!1}),R.push({box:{l:T-L/2,r:T+L/2,t:q.c+H,b:q.c+H+z},on:!1})):(q.len>=z+d("3")&&R.push({box:{l:q.c-L/2-d("1"),r:q.c+L/2+d("1"),t:T-z/2,b:T+z/2},on:!0}),R.push({box:{l:q.c+H,r:q.c+H+L,t:T-z/2,b:T+z/2},on:!1}),R.push({box:{l:q.c-H-L,r:q.c-H,t:T-z/2,b:T+z/2},on:!1})),B=R.find(Q=>F(Q.box))??null,B)break;!j&&R.some(Q=>F(Q.box,!1))&&(j=!0)}if(B)break}if(!B){i.push(m.i),j&&h.push(m.i);continue}const rt=Ze(B.box,a.ox,a.oy,q=>F(q));g.push(rt),f.push({i:m.i,text:M,box:rt,on:B.on})}return{labels:f,unseated:i,bounded:h}}function Je(t,e,n,o){const c=[],l=[];return t.querySelectorAll(`.${n}-gbox, .${n}-group`).forEach(s=>{if(s.getClientRects().length===0||getComputedStyle(s).display==="contents")return;const r=xt(s,e);l.push(r),c.push({l:r.l,r:r.r,t:r.t,b:r.t+1},{l:r.l,r:r.r,t:r.b-1,b:r.b},{l:r.l,r:r.l+1,t:r.t,b:r.b},{l:r.r-1,r:r.r,t:r.t,b:r.b});const a=s.querySelector(`:scope > .${n}-glabel`);a&&a.getClientRects().length&&c.push(xt(a,e))}),t.querySelectorAll(`.${n}-lane`).forEach((s,r)=>{if(!s.getClientRects().length)return;const a=xt(s,e);r>0&&c.push({l:a.l,r:a.r,t:a.t-o/2-.5,b:a.t-o/2+.5});const d=s.querySelector(`.${n}-lane-name`);d&&c.push(xt(d,e))}),{obstacles:{rects:c,heads:[]},groups:l}}function Ue(t,e){const{m:o,tk:c,P:l,drawing:s,origin:r,warn:a}=t,d=c.space,g=Ve(o,s,r,l),f=[...g.values()],i=Gn(s),h=r.left-Math.floor(r.left),b=r.top-Math.floor(r.top),p=We(h,b),m=s.clientWidth,M=s.clientHeight,L=y=>o.type==="data-flow"?y.col+1:y.col,z=parseFloat(getComputedStyle(s).rowGap)||0,v={w:m,h:M,nodes:f,lines:[],lifelines:[],labels:[],crossings:[],through:[],unseated:[],outside:[],ox:h,oy:b};if(o.type==="sequence")return Zn(t,v,p);let C,B=[];o.type==="schema"?C=o.edges.map(y=>{const S=o.byId.get(y.from),E=o.byId.get(y.to);if(S.col===E.col){const W=!((o.rtl?S.col===1:S.col===o.cols)&&o.cols>1)===!o.rtl?"right":"left";return[W,W]}return E.col>S.col?["right","left"]:["left","right"]}):(C=o.edges.map(y=>{const S=o.byId.get(y.from),E=o.byId.get(y.to),[k,A]=fe(S,E);return[y.fromSide??k,y.toSide??A]}),B=He(o,C,a||(()=>{})));const j=(y,S)=>{const E=s.querySelector(`.${l}-node[data-node="${CSS.escape(y)}"] .${l}-row[data-row="${S}"]`);if(!E)return 0;const k=xt(E,r);return(k.t+k.b)/2},F=new Map;if(o.type==="schema"){const y=new Map;o.edges.forEach((E,k)=>{const A=`${E.to}.${E.toRow}.${C[k][1]}`;y.set(A,[...y.get(A)??[],k])});const S=E=>{const k=o.edges[E].card?.to;return k==="one"?0:k==="zero-or-one"?1:2};for(const E of y.values()){const k=[...new Set(E.map(S))].sort((A,W)=>A-W);if(k.length>1)for(const A of E)F.set(A,(k.indexOf(S(A))-(k.length-1)/2)*d("2"))}}const rt=y=>Math.round(y+h)-h,q=o.edges.map((y,S)=>{const[E,k]=C[S],A=g.get(y.from),W=g.get(y.to),J=Pt(y.kind,c);if(y.fk){const P=j(y.from,y.fromRow),ot=j(y.to,y.toRow)+(F.get(S)??0),gt=p.y(P,J),Bt=p.y(ot,J),Et=E==="right"?A.rect.r:A.rect.l,St=k==="right"?W.rect.r:W.rect.l;return{p1:{x:y.card?rt(Et):Et,y:gt},p2:{x:y.card?rt(St):St,y:Bt},r1:P,r2:Math.abs(gt-Bt)<.01?P:ot}}const K=B.find(P=>P.edge===S&&P.end==="from").f,Y=B.find(P=>P.edge===S&&P.end==="to").f;let U=Ge(A,E,K),Z=Ge(W,k,Y);const N=ct(E)?U.y:U.x;let G=ct(k)?Z.y:Z.x;return ct(E)?U={...U,y:p.y(U.y,J)}:U={...U,x:p.x(U.x,J)},ct(k)?Z={...Z,y:p.y(Z.y,J)}:Z={...Z,x:p.x(Z.x,J)},ct(E)&&ct(k)&&Math.abs(U.y-Z.y)<1.01&&(Z={...Z,y:U.y},G=N),!ct(E)&&!ct(k)&&Math.abs(U.x-Z.x)<1.01&&(Z={...Z,x:U.x},G=N),U=ct(E)?Mt(A,E,U.y):Mt(A,E,U.x),Z=ct(k)?Mt(W,k,Z.y):Mt(W,k,Z.x),{p1:U,p2:Z,r1:N,r2:G}}),D=new Set,T=(y,S)=>{D.has(y)||(D.add(y),a?.(`${o.edges[y].from} to ${o.edges[y].to} ${S}, so its line is not drawn; its row still writes the target`))};for(const y of Yt(o).dropped)T(y,"would need a third lane of turn-backs");const R=new Map,H=Lt();o.type==="schema"&&o.edges.forEach((y,S)=>{const E=o.byId.get(y.from),k=o.byId.get(y.to);if(Math.abs(E.col-k.col)<2)return;const A=Math.min(E.col,k.col),W=Math.max(E.col,k.col),J=o.nodes.filter(ot=>ot.col>A&&ot.colgt.row<=ot&>.row2>=ot+1)||Y.push({key:`g${ot}`,y:(K[ot-1][1]+K[ot][0])/2,inner:!0});Y.push({key:"top",y:K[0][0]-d("4"),inner:!1},{key:"bottom",y:K[K.length-1][1]+d("4"),inner:!1});const U=(q[S].r1+q[S].r2)/2,Z=t.pick?.[S]??Y.slice().sort((ot,gt)=>Math.abs(ot.y-U)-Math.abs(gt.y-U)||Number(gt.inner)-Number(ot.inner)||ot.y-gt.y)[0].key;H[S]=Z;const N=C[S][0]==="right"?E.col:E.col-1,G=i.cols[N-1],P=i.cols[N];R.set(S,{corridor:Z,first:G&&P?{key:`c${N}`,span:[G[1],P[0]]}:null,y:0})});const Q=new Map;for(const[y,S]of R){const E=o.edges[y],k=Q.get(S.corridor)??[],A=k.find(W=>{const J=o.edges[W[0]];return J.to===E.to&&J.toRow===E.toRow&&C[W[0]][1]===C[y][1]&&Math.abs(q[W[0]].p2.y-q[y].p2.y)<.5});A?A.push(y):k.length>=2?T(y,"would need a third lane in its corridor"):k.push([y]),Q.set(S.corridor,k)}for(const y of[...R.keys()])D.has(y)&&R.delete(y);const at=y=>{const S=o.edges[y[0]];return Math.abs(o.byId.get(S.from).col-o.byId.get(S.to).col)*1e4+Math.abs(q[y[0]].p1.x-q[y[0]].p2.x)},it=(y,S,E)=>{const k=i.rows;if(y==="top")return k[0][0]-d("4")-S*d("3");if(y==="bottom")return k[k.length-1][1]+d("4")+S*d("3");const A=Number(y.slice(1));return(k[A-1][1]+k[A][0])/2+(S-(E-1)/2)*d("3")},yt=(y,S)=>S.forEach((E,k)=>E.forEach(A=>{R.get(A).y=it(y,k,S.length)})),dt=()=>{for(const[y,S]of Q){const E=S.map(k=>k.filter(A=>R.has(A))).filter(k=>k.length);Q.set(y,E),yt(y,y==="top"||y==="bottom"?E.slice().sort((k,A)=>at(k)-at(A)):E.slice().sort((k,A)=>at(A)-at(k)))}};dt();const et=new Map,nt=new Set,tt=new Map,$=(y,S,E,k,A)=>{et.has(y)||et.set(y,{span:S,vertical:E,members:new Map});const W=et.get(y);W.members.has(k)||W.members.set(k,[]),W.members.get(k).push(A)},u=()=>{et.clear(),nt.clear(),tt.clear(),o.edges.forEach((y,S)=>{if(D.has(S))return;const E=R.get(S);E?.first&&$(E.first.key,E.first.span,!0,`far:${S}`,-(S+1));const[k,A]=C[S],{p1:W,p2:J}=q[S],K=o.byId.get(y.from),Y=o.byId.get(y.to);let U=null,Z=null,N=!1;if(k===A){if(ct(k)){const G=k==="right"?Math.max(L(K),L(Y)):Math.min(L(K),L(Y))-1,P=i.cols[G-1],ot=i.cols[G];P&&ot&&(U=`c${G}`,Z=[P[1],ot[0]],N=!0)}else{const G=k==="bottom"?Math.max(K.row2,Y.row2):Math.min(K.row,Y.row)-1,P=i.rows[G-1],ot=i.rows[G];P&&ot&&(U=`r${G}`,Z=[P[1],ot[0]],N=!1)}U&&nt.add(S)}else if(ct(k)&&ct(A)&&(E||Math.abs(W.y-J.y)>.5)){const G=L(Y),P=A==="left",ot=i.cols[(P?G-1:G)-1],gt=i.cols[(P?G:G+1)-1];ot&>&&(U=`c${P?G-1:G}`,Z=[ot[1],gt[0]],N=!0)}else if(!ct(k)&&!ct(A)&&Math.abs(W.x-J.x)>.5){const P=A==="top"?Y.row-1:Y.row2,ot=i.rows[P-1],gt=i.rows[P];ot&>&&(U=`r${P}`,Z=[ot[1],gt[0]],N=!1)}!U||!Z||(E&&tt.set(S,Z),$(U,Z,N,`${y.to}.${A}.${Math.round(N?J.y:J.x)}`,S))})};u();const w=new Map,O=y=>{const[S,E]=C[y],{p1:k,p2:A}=q[y],W=R.get(y);if(W){const J=tt.get(y),K=w.get(-(y+1))??(W.first?(W.first.span[0]+W.first.span[1])/2:k.x),Y=w.get(y)??(J?(J[0]+J[1])/2:A.x);return[k,{x:K,y:k.y},{x:K,y:W.y},{x:Y,y:W.y},{x:Y,y:A.y},A]}if(ct(S)&&ct(E)){if(S===E){const K=d(o.marks?"6":"4")+(o.type==="schema"&&o.cols===1?(Yt(o).lane.get(y)??0)*d("3"):0),Y=w.get(y)??(S==="right"?Math.max(k.x,A.x)+K:Math.min(k.x,A.x)-K);return[k,{x:Y,y:k.y},{x:Y,y:A.y},A]}if(Math.abs(k.y-A.y)<=.5)return[k,{x:A.x,y:k.y}];const J=w.get(y)??(k.x+A.x)/2;return[k,{x:J,y:k.y},{x:J,y:A.y},A]}if(!ct(S)&&!ct(E)){if(S===E){const K=w.get(y)??(S==="bottom"?Math.max(k.y,A.y)+d("4"):Math.min(k.y,A.y)-d("4"));return[k,{x:k.x,y:K},{x:A.x,y:K},A]}if(Math.abs(k.x-A.x)<=.5)return[k,{x:k.x,y:A.y}];const J=w.get(y)??(k.y+A.y)/2;return[k,{x:k.x,y:J},{x:A.x,y:J},A]}return ct(S)?[k,{x:A.x,y:k.y},A]:[k,{x:k.x,y:A.y},A]},I=y=>{const S=o.edges[y],E=Pt(S.kind,c),k=O(y),A=Ne(k,E,p);let W;return k.length===A.length&&(W=_t(k).map(([J,K])=>Math.abs(J.y-K.y)<.75?(J.y+K.y)/2:(J.x+K.x)/2),W[0]=q[y].r1,W.length>1&&(W[W.length-1]=q[y].r2)),{i:y,from:S.from,to:S.to,kind:S.kind,pts:A,tip:A[A.length-1],dir:de(A),dot:S.fk&&!S.card?A[0]:void 0,card:S.card,width:E,axes:W}},_=()=>o.edges.flatMap((y,S)=>D.has(S)?[]:[I(S)]);let X=null;const V=y=>{X??(X=_());const S=X.map(E=>y.has(E.i)?I(E.i):E);return{lines:S,score:Kn(S,y)*1e5+ee(S,void 0,y).length*1e3+pe(S.filter(E=>y.has(E.i)),f,o).length}},ft=(y,S)=>{const E=y.flatMap(k=>{const A=k<0?-k-1:k,{p1:W,p2:J}=q[A],K=R.get(A);return K?k<0?[W.y,K.y]:[K.y,J.y]:S?[W.y,J.y]:[W.x,J.x]});return[Math.min(...E),Math.max(...E)]},st=y=>y<0?-y-1:y,lt=y=>{const S=[...y.members.values()].map(k=>({members:k,run:ft(k,y.vertical)})).sort((k,A)=>k.run[0]-A.run[0]),E=[];for(const k of S){const A=E[E.length-1];A&&A.some(W=>W.run[0]!(k.length===1&&k[0].members.every(A=>nt.has(A))))},pt=y=>(S,E)=>y[S].run[0]{const S=pt(y),E=[];return y.forEach((k,A)=>{let W=0;for(;E.some((J,K)=>J===W&&S(A,K));)W++;E.push(W)}),E},ut=y=>Math.max(0,...kt(y))+1;if(o.marks)for(let y=0;y3){S=W.map(J=>J.members.map(st));break}if(!S)break;const E=A=>Math.max(...A),k=S.filter(A=>A.some(W=>R.has(W))).sort((A,W)=>E(W)-E(A))[0]??S.slice().sort((A,W)=>E(W)-E(A))[0];for(const A of k)T(A,"would need a fourth lane in a marked gutter"),R.delete(A);u()}const $t=(y,S,E,k=!1)=>{const A=o.rtl&&k?E-1-S:S,W=y[1]-y[0];if(!o.marks)return y[0]+W/(E+1)*(A+1);const J=c.foot+c.radiusXs,K=E>1?Math.min(W/(E+1),(W-2*J)/(E-1)):0;return(y[0]+y[1])/2+(A-(E-1)/2)*K};dt();for(const[y,S]of Q){if(y==="top"||y==="bottom"||S.length<2)continue;const E=new Set(S.flat());let k=S,A=1/0;for(const W of he(S.slice().sort((J,K)=>at(K)-at(J)))){yt(y,W),X=null;const J=V(E);J.scoreY.members);if(o.marks){const Y=ut(S),U=pt(S),Z=S.length,N=new Set(E.flat().map(st)),G=Et=>Et.forEach((St,zt)=>E[zt].forEach(jt=>w.set(jt,$t(y.span,St,Y,y.vertical))));let P=kt(S),ot=1/0,gt=null;const Bt=[P];if(Y**Z<=729)for(let Et=0;EtMath.floor(Et/Y**jt)%Y);St.every((zt,jt)=>St.every((oe,Vt)=>Vt<=jt||zt!==oe||!U(jt,Vt)))&&Bt.push(St)}for(const Et of Bt){G(Et);const St=V(N);St.scoreZ.forEach(G=>w.set(G,$t(y.span,N,k,y.vertical))));const U=V(A);U.scoreY.forEach(Z=>w.set(Z,$t(y.span,U,k,y.vertical)))),X=K}if(v.lines=_(),o.marks&&(v.lines=v.lines.filter(y=>{if(!y.card)return!0;const S=_t(y.pts),E=([A,W])=>Math.hypot(W.x-A.x,W.y-A.y),k=S.length===1?2*c.foot:c.foot+c.radiusXs-.5;return E(S[0])>=k&&E(S[S.length-1])>=k?!0:(T(y.i,"has no room for its marks at an end"),R.delete(y.i),!1)})),R.size){const y=new Set([...R.values()].map(E=>E.corridor)),S=[y.has("top")?"var(--basalt-space-8)":"0px"];for(let E=1;E<=o.rows;E++)S.push("auto",EKe(y,c));const vt=Vn(o,v.lines,f,bt,wt,{l:0,t:0,r:m,b:M},c,e,{ox:h,oy:b});return v.labels=vt.labels,v.unseated=vt.unseated,v.bounded=vt.bounded,v.overlaps=[...new Set(Xe(v.lines,null).flat())],v}function Kn(t,e){return Xe(t,e).length}function Xe(t,e){const n=[];for(let o=0;o=r)continue;const[m,M]=i?[a.x,d.x]:[a.y,d.y],[L,z]=i?[g.x,f.x]:[g.y,f.y];Math.min(Math.max(m,M),Math.max(L,z))-Math.max(Math.min(m,M),Math.min(L,z))>1&&n.push([l.i,s.i])}}return n}function*he(t){if(t.length<=1){yield t.slice();return}if(t.length>5){yield t.slice();return}for(let e=0;e{const a=r===l.pts.length-1?Math.max(l.width/2,o.head/2):l.width/2;return s.x-a<-.5||s.x+a>e+.5||s.y-a<-.5||s.y+a>n+.5})&&c.push(l.i);return c}function pe(t,e,n){const o=[];for(const c of t){const l=_t(c.pts);e.some(s=>l.some(([r,a])=>Nn(r,a,s)))&&o.push(c.i)}return o}function Zn(t,e,n){const{m:o,tk:c,P:l,drawing:s,origin:r}=t,a=c.space,d=new Map;s.querySelectorAll(`.${l}-node`).forEach(v=>d.set(v.dataset.node,xt(v,r)));const g=s.querySelector(`.${l}-steps`),f=g?xt(g,r).b:e.h,i=v=>{const C=d.get(v);return C?n.x((C.l+C.r)/2,c.hair):0};for(const v of o.nodes){const C=d.get(v.id);C&&e.lifelines.push({x:i(v.id),y1:C.b,y2:f})}const h=v=>d.get(v.id),b=new Map;s.querySelectorAll(`.${l}-msg`).forEach(v=>{const C=xt(v,r);b.set(Number(v.querySelector(`.${l}-num`)?.textContent??0),(C.t+C.b)/2)});const p=c.activation,m=p/2,M=v=>{const C=o.byId.get(v.who);if(!C)return null;const B=i(v.who),F=(C.i===o.nodes.length-1&&o.nodes.length>1?-1:1)*(o.rtl?-1:1),rt=(v.depth-1)*a("1")*F,q=b.get(v.from)??0,D=b.get(v.to)??q,T=v.from===v.to;return{l:n.x(B-m+rt,c.hair),r:n.x(B+m+rt,c.hair),t:n.y(T?q-a("2")-a("1"):q,c.hair),b:n.y(T?q+a("2")+a("1"):D,c.hair)}},L=o.bars.map(v=>({bar:v,rect:M(v)})).filter(v=>v.rect);e.bars=L.map(v=>v.rect);const z=(v,C,B)=>L.filter(({bar:j})=>j.who===v&&j.to>=C&&(B?j.from<=C:j.fromF.bar.depth-j.bar.depth)[0]?.rect;s.querySelectorAll(`.${l}-msg`).forEach(v=>{const C=v.dataset.from,B=v.dataset.to,j=v.dataset.kind??"plain",F=Pt(j,c),rt=xt(v,r),q=n.y((rt.t+rt.b)/2,F),D=Number(v.querySelector(`.${l}-num`)?.textContent??0);let T=i(C),R=i(B),H;if(C===B){const nt=v.dataset.self==="start"?-a("6"):a("6"),tt=z(C,D,!0),$=tt?nt>0?tt.r:tt.l:T,u=n.y(q-a("2"),F),w=n.y(q+a("2"),F);H=[{x:$,y:u},{x:n.x(T+nt,F),y:u},{x:n.x(T+nt,F),y:w},{x:$,y:w}]}else{const nt=R>T?1:-1,tt=z(C,D,!1),$=z(B,D,!0);tt&&(T=nt>0?tt.r:tt.l),$&&(R=nt>0?$.l:$.r),H=[{x:T,y:q},{x:R,y:q}]}e.lines.push({i:D,from:C,to:B,kind:j,pts:H,tip:H[H.length-1],dir:de(H),width:F});const Q=v.querySelector(`.${l}-said`),at=v.querySelector(`.${l}-note`),it=o.byId.get(C),yt=o.byId.get(B);if(!it||!yt)return;const dt=C===B?(()=>{const nt=o.nodes.find($=>$.col===it.col+(v.dataset.self==="start"?-1:1)),tt=nt?i(nt.id):v.dataset.self==="start"?0:e.w;return Math.abs(tt-T)-a("6")-a("2-5")-a("2")})():Math.abs(R-T)-2*a("2");Math.max(Q?Q.getBoundingClientRect().width:0,at?at.getBoundingClientRect().width:0)>dt+.5&&e.unseated.push(D)}),s.querySelectorAll(`.${l}-fhead`).forEach(v=>{const C=v.parentElement?.querySelector(`:scope > .${l}-fbox`);if(!C)return;[...v.children].reduce((j,F)=>j+F.getBoundingClientRect().width,0)+a("3")>C.getBoundingClientRect().width+.5&&(e.misfit??(e.misfit=[])).push(`the frame "${v.querySelector(`.${l}-flabel`)?.textContent??""}" is wider than its participants`)});{const v=[...s.querySelectorAll(`.${l}-fbox`)].flatMap(C=>{const B=xt(C,r);return[{x:B.l+.5,t:B.t,b:B.b},{x:B.r-.5,t:B.t,b:B.b}]});v.length&&s.querySelectorAll(`.${l}-said, .${l}-note, .${l}-band > span`).forEach(C=>{if(!C.getClientRects().length)return;const B=ce(xt(C,r),a("1"));v.some(j=>B.lj.x&&B.tj.t)&&(e.misfit??(e.misfit=[])).push(`"${C.textContent?.trim()??""}" would lie on a frame's side`)})}return e}function Jn(t,e,n,o,c){const l=[];for(const[s,r]of t){if(!r.getClientRects().length)continue;const a=xt(r,n),d=xt(s,n),g=getComputedStyle(r),f=getComputedStyle(s),i={l:a.l+(parseFloat(g.paddingLeft)||0),r:a.r-(parseFloat(g.paddingRight)||0)},h=i.r-i.l,b=d.l+(parseFloat(f.borderLeftWidth)||0),p=d.r-(parseFloat(f.borderRightWidth)||0),m=[];for(const j of e)for(const[F,rt]of _t(j.pts)){const q=ue(F,rt,j.width);q.ta.t&&m.push({l:q.l,r:q.r})}const M=c("2-5"),L=j=>m.every(F=>F.r<=j-M+.01||F.l>=j+h+M-.01);if(L(i.l))continue;const z=m.map(j=>o?i.r-(j.l-M):j.r+M-i.l).filter(j=>j>0).sort((j,F)=>j-F),v=j=>o?i.l-j:i.l+j,C=j=>o?v(j)>=b+c("3")-.01:v(j)+h<=p-c("3")+.01,B=z.find(j=>C(j)&&L(v(j)));if(B===void 0){l.push(r.textContent??"");continue}r.style.setProperty("--_gx",`${Math.round(B*100)/100}px`)}return l}function Qe(t,e,n,o=Lt()){const{m:c,tk:l,P:s,drawing:r,origin:a}=t,d=l.space,g=Ve(c,r,a,s),f=[...g.values()],i=a.left-Math.floor(a.left),h=a.top-Math.floor(a.top),b=We(i,h,!!c.rtl),p=r.clientWidth,m=r.clientHeight,M={w:p,h:m,nodes:f,lines:[],lifelines:[],labels:[],crossings:[],through:[],unseated:[],outside:[],ox:i,oy:h},L=Lt();if(c.type==="sequence"||c.type==="schema")return{geo:M,grow:L};const z=!!c.rtl,v=z?-1:1,C=u=>z?u.r:u.l,B=u=>z?u.l:u.r,j=z?"left":"right",F=(u,w,O,I)=>{const _=u+I*v*w,X=_+I*v*O;return{l:Math.min(_,X),r:Math.max(_,X)}},rt=getComputedStyle(r),q=z?parseFloat(rt.paddingLeft)||0:p-(parseFloat(rt.paddingRight)||0),D=(u,w,O)=>{const I=[u];for(let _=1;_<=(Ct(o,w)??0);_++)I.push({...u,t:u.t+O*d("4")*_,b:u.b+O*d("4")*_});return I},T=new Map;r.querySelectorAll(`.${s}-node`).forEach(u=>{const w=u.parentElement,O=xt(w,a),I=getComputedStyle(w);T.set(u.dataset.node,z?O.l+(parseFloat(I.paddingLeft)||0)+(parseFloat(I.borderLeftWidth)||0):O.r-(parseFloat(I.paddingRight)||0)-(parseFloat(I.borderRightWidth)||0))});const R=c.nodes,H=u=>g.get(R[u].id),Q=new Map;r.querySelectorAll(`.${s}-group > .${s}-glabel`).forEach(u=>{u.style.removeProperty("--_gx"),Q.set(u.parentElement,u)});const at=new Map;for(const[u,w]of Q)w.getClientRects().length&&at.set(u,xt(w,a));const it=u=>{const w=r.querySelector(`.${s}-node[data-node="${CSS.escape(u)}"]`),O=w?.parentElement;return!!(O?.matches(`.${s}-group[data-turn]`)&&O.querySelector(`:scope > .${s}-node`)===w)},yt=(u,w,O)=>it(w)?Array.from({length:Math.round(O/16)+1},(I,_)=>({...u,t:u.t-_*d("4"),b:u.b-_*d("4")})):[u],dt=[],et=u=>Pt(c.edges[u].kind,l);c.edges.forEach((u,w)=>{const O=n.routes[w],I=g.get(u.from),_=g.get(u.to),X=et(w);let V=[];const ft=u.label,st=ft?e(ft,"label"):0,lt=ft?16*Kt(ft):16,pt=d("4");if(O==="down"||O==="up"){const ut=Math.max(I.rect.l,_.rect.l),$t=Math.min(I.rect.r,_.rect.r),bt=c.edges.map((S,E)=>({o:S,j:E})).filter(({o:S,j:E})=>(n.routes[E]==="down"||n.routes[E]==="up")&&(S.from===u.from&&S.to===u.to||S.from===u.to&&S.to===u.from)),wt=bt.findIndex(S=>S.j===w),vt=bt.length<2?.5:bt.length===2?wt===0?.25:.75:(wt+1)/(bt.length+1);let y=b.x(ut+($t-ut)*vt,X);if(O==="down"){const S=r.querySelector(`.${s}-node[data-node="${CSS.escape(u.to)}"]`),E=S?.parentElement,k=E&&E.matches(`.${s}-group`)&&E.querySelector(`:scope > .${s}-node`)===S?at.get(E):void 0;if(k&&E&&!E.contains(r.querySelector(`.${s}-node[data-node="${CSS.escape(u.from)}"]`))){const A=d("2-5")+X/2;if(y>k.l-A&&y=ut+d("6"):W<=$t-d("6"))&&(y=b.x(W,X))}}}if(V=O==="down"?[Mt(I,"bottom",y),Mt(_,"top",y)]:[Mt(I,"top",y),Mt(_,"bottom",y)],ft){let S=Math.min(V[0].y,V[1].y),E=Math.max(V[0].y,V[1].y);O==="down"?E-=l.head:S+=l.head;const k=[...r.querySelectorAll(`.${s}-group`)].map(K=>xt(K,a));let A=[[S,E]];for(const K of k)for(const Y of[K.t,K.b])A=A.flatMap(([U,Z])=>Y>U+1&&Yk.some(U=>(K+Y)/2>U.t&&(K+Y)/2U.l&&y1){const K=A.filter(([U,Z])=>!W(U,Z));[S,E]=(K.length?K:A).reduce((U,Z)=>Z[1]-Z[0]>U[1]-U[0]?Z:U)}const J=[1/2,1/3,2/3].map(K=>{const Y=S+(E-S)*K;return{l:y-st/2-d("1"),r:y+st/2+d("1"),t:Y-lt/2,b:Y+lt/2}});dt.push({k:w,cands:J,on:!0,card:O==="down"?u.to:u.from})}}else if(O==="trunk"||O==="rail"){const ut=O==="rail"?z?Math.min(I.rect.r,_.rect.r):Math.max(I.rect.l,_.rect.l):C(I.rect),$t=b.x(ut+v*d(O==="trunk"?"8":"3"),X),bt=Mt(I,"bottom",$t);if(O==="rail"){if(V=[bt,Mt(_,"top",$t)],ft){const wt=_.rect.t-d("6");dt.push({k:w,cands:D({...F($t,d("2-5"),st,1),t:wt-lt/2,b:wt+lt/2},u.to,-1),on:!1,card:u.to})}}else{const wt=b.x(C(_.rect)+v*d("6"),X),vt=b.y(_.rect.t-pt,X);V=[bt,{x:$t,y:vt},{x:wt,y:vt},Mt(_,"top",wt)];const y={...F(wt,d("2-5"),st,1),t:vt-lt/2,b:vt+lt/2};ft&&dt.push({k:w,cands:[...yt(y,u.to,lt),...D(y,u.to,-1).slice(1)],on:!1,card:u.to})}}else{const ut=Z=>T.get(Z)??(z?0:p),$t=z?Math.max(ut(u.from),ut(u.to)):Math.min(ut(u.from),ut(u.to)),bt=b.x(n.gutter?q+v*(n.lanes[w]+1)*d("3-5"):$t-v*d("2-5"),X),wt=b.y(I.rect.t+(I.rect.b-I.rect.t)*n.exits[w],X),vt=Mt(I,j,wt),y=O==="end-down",S=c.edges.map((Z,N)=>({o:Z,j:N})).filter(({o:Z,j:N})=>n.routes[N]===O&&Z.to===u.to).sort((Z,N)=>n.lanes[N.j]-n.lanes[Z.j]||Z.j-N.j),E=Math.max(0,S.findIndex(({j:Z})=>Z===w)),k=B(_.rect)-v*(d("6")+E*d("3")),A=B(_.rect)-v*(d("6")+(S.length-1)*d("3")),W=b.x(k,X),J=y?_.rect.t-pt-E*d("5"):_.rect.b+pt+E*d("5"),K=b.y(J,X);V=[vt,{x:bt,y:vt.y},{x:bt,y:K},{x:W,y:K},Mt(_,y?"top":"bottom",W)];const Y=y?u.to:R[_.i+1]?.id??u.to,U={...F(A,d("2-5"),st,-1),t:J-lt/2,b:J+lt/2};ft&&dt.push({k:w,cands:[...y?yt(U,Y,lt):[U],...D(U,Y,y?-1:1).slice(1)],on:!1,card:Y})}const kt=Ne(V,X,b);M.lines.push({i:w,from:u.from,to:u.to,kind:u.kind,pts:kt,tip:kt[kt.length-1],dir:de(kt),width:X})}),M.crossings=ee(M.lines),M.through=pe(M.lines,f,c),M.outside=Ye(M.lines,p,m,l),M.seatless=Jn(Q,M.lines,a,z,d);const{obstacles:nt}=Je(r,a,s,0);nt.heads=M.lines.map(u=>Ke(u,l));const tt=[],$={l:0,t:0,r:p,b:m};for(const u of dt){const w=_=>{const X=ce(_,d("1"));return _.l<$.l-.5||_.r>$.r+.5||_.t<$.t-.5||_.b>$.b+.5||f.some(V=>ze(X,V))||tt.some(V=>Ot(X,V))||nt.heads.some(V=>Ot(X,V))||nt.rects.some(V=>Ot(X,V))||M.lines.some(V=>V.i!==u.k&&_t(V.pts).some(([ft,st])=>Ot(X,ue(ft,st,V.width))))},O=u.cands.find(_=>!w(_));O||(L[u.card]=(L[u.card]??0)+1,M.unseated.push(u.k));const I=O?Ze(O,i,h,_=>!w(_),z):u.cands[0];tt.push(I),M.labels.push({i:u.k,text:c.edges[u.k].label,box:I,on:u.on})}return{geo:M,grow:L}}function Pe(t,e,n=0){const o=s=>String(Math.round(s*100)/100);let c=`M${o(t[0].x)} ${o(t[0].y)}`;for(let s=1;s{const{crow:D,ring:T}=Ce(j,F.x,F.y,rt,n.head,n.dot);return`${T?``:""}`};return`${B(e.card.from,v,Math.sign(C.x-v.x)||1,"from")}${B(e.card.to,e.tip,-l.x||1,"to")}`}const s=e.kind==="dashed",r=n.head,a=n.head/2,d=s?1:r-1,g=e.pts.map(v=>({...v})),f=g[g.length-1];f.x-=l.x*d,f.y-=l.y*d;const i=e.tip.x-l.x*r,h=e.tip.y-l.y*r,b=-l.y*a,p=l.x*a,m=v=>Math.round(v*100)/100,M=mt(e.kind),L=s?``:``,z=e.dot?``:"";return`${L}${z}`}function tn(t,e,n,o){const c=new Map,l=new Map;for(const r of e.crossings)l.has(r.under)||l.set(r.under,[]),l.get(r.under).push(r);let s="";for(const[r,a]of l){const d=`${o}-cut-${r}`;c.set(r,d);const g=a.map(f=>{const i=e.lines[f.top],h=e.lines[f.under],b=i.width/2+n.cut,p=h.width/2+1;return f.underVertical?``:``}).join("");s+=`${g}`}return{defs:s,ids:c}}function en(t,e,n,o){const{defs:c,ids:l}=tn(t,e,n,o),s=e.lifelines.map(i=>``).join(""),r=(e.bars??[]).map(i=>``).join(""),a=e.lines.map((i,h)=>Xn(t,i,n,l.get(h)??null,i.from===i.to?n.radiusXs:n.radius)).join(""),g=`${s?`${s}`:""}${c?`${c}`:""}${r}${a}`,f=e.labels.map(i=>`1?' data-lines="2"':""}>${i.text.split(` +`).map(mt).join("
")}
`).join("");return g+f}function Yn(t,e,n){const o=t.querySelector(`.${e}-ink`);if(!o||!n)return;const c=s=>`${Math.round(s*100)/100}px`;o.querySelectorAll(`:scope > .${e}-label`).forEach((s,r)=>{const a=n.labels[r];if(!a||s.dataset.edge!==String(a.i))return;const d=[["left",c(a.box.l)],["top",c(a.box.t)],["width",c(a.box.r-a.box.l)]];for(const[g,f]of d)s.style.getPropertyValue(g)!==f&&s.style.setProperty(g,f)})}function ge(t,e,n,o,c,l,s,r){const d=t.querySelector(`.${n}-drawing`);if(!d||t.clientWidth===0)return{dyn:c,geo:null,ink:"",tokens:null};const g=zn(t),f=Hn(d,n),i=Dn(e,g,f);r?.(i.least);const h=t.clientWidth,b=(()=>{const q=document.activeElement;return q&&d.contains(q)&&q.dataset.node?q.dataset.node:void 0})(),p=q=>Tt(e,q)?{...q,stop:q.stop&&e.byId.has(q.stop)?q.stop:e.nodes[0]?.id,keep:void 0}:{...q,stop:q.stop??e.nodes[0]?.id,keep:b&&q.layout!=="drawn"?b:void 0};let m=!1;const M=q=>{if(m=!1,e.type!=="flowchart")return q;l({...q,heights:void 0,words:void 0});const D=Lt(),T=Lt();return d.querySelectorAll(`.${n}-node[data-shape="decision"]`).forEach(R=>{const H=R.querySelector(`.${n}-words`);if(!H)return;const Q=R.getBoundingClientRect(),at=dt=>{const et={w:dt.width+2*g.space("2-5"),h:dt.height+2*g.space("2")},nt=1-et.w/Q.width,tt=nt>.05?et.h/2/nt:et.h*10;return Math.max(g.space("16"),Math.ceil(Q.width/5),Math.ceil(2*tt))},it=H.getBoundingClientRect();let yt=at(it);if(yt>Q.width){const dt=$=>(R.style.setProperty("--_ww",`${$}px`),H.getBoundingClientRect()),et=Math.floor(R.clientWidth-2*g.space("2-5"));let nt=Math.ceil(it.width),tt=it.height;for(;nt1;){const I=$+u>>1;dt(I).heightQ.width&&(m=!0)}),{...q,heights:D,words:Object.keys(T).length?T:void 0}},L=()=>({m:e,tk:g,P:n,drawing:d,origin:d.getBoundingClientRect(),warn:s}),z=c.autoOpen?{open:!1,autoOpen:void 0}:{},v=(q,D)=>D.map(T=>Gt(e,q.lines.find(R=>R.i===T))).join(", ");if(e.text)return{dyn:{...c,layout:"stacked",bare:void 0},geo:null,ink:"",tokens:g,least:i.least};if(h>=i.least&&!e.unplaced){const q=H=>{let Q=p({...c,...z,layout:"drawn",grow:void 0,track:void 0,bare:void 0,pad:H||void 0,rows:void 0,one:e.type!=="sequence"&&Jt(e)===1?i.own:void 0});Q=M(Q),l(Q);let at=Ue(L(),f);return at.corridors&&(Q={...Q,rows:at.corridors.rows},l(Q),at=Ue({...L(),pick:at.corridors.pick},f)),{dd:Q,g:at}};let{dd:D,g:T}=q(!1);const R=H=>H.through.length>0||H.outside.length>0||(H.overlaps?.length??0)>0||(H.misfit?.length??0)>0||m;if(!R(T)&&T.unseated.length&&T.unseated.every(H=>T.bounded?.includes(H))){const H=q(!0);!R(H.g)&&!H.g.unseated.length&&({dd:D,g:T}=H)}if(!R(T)&&!T.unseated.length)return T.crossings.length&&s?.(`${T.crossings.length} crossing${T.crossings.length===1?"":"s"} in the drawn layout: ${T.crossings.map(H=>`${Gt(e,T.lines[H.top])} over ${Gt(e,T.lines[H.under])}`).join("; ")}`),{dyn:D,geo:T,ink:en(n,T,g,o),tokens:g,least:i.least};m&&s?.(`the drawn layout does not fit at ${Math.round(h)}px: a decision would be taller than it is wide`),T.misfit?.length&&s?.(`the drawn layout does not fit at ${Math.round(h)}px: ${T.misfit.join("; ")}`),T.through.length&&s?.(`the drawn layout does not fit at ${Math.round(h)}px: ${v(T,T.through)} would pass through a node`),T.overlaps?.length&&s?.(`the drawn layout does not fit at ${Math.round(h)}px: ${v(T,T.overlaps)} would lie on one another`),T.outside.length&&s?.(`the drawn layout does not fit at ${Math.round(h)}px: ${v(T,T.outside)} would leave the drawing`),T.unseated.length&&s?.(`the drawn layout does not fit at ${Math.round(h)}px: no clean seat for ${T.unseated.map(H=>e.type==="sequence"?`message ${H}`:`"${qt(e.edges[H]?.label??"")}"`).join(", ")}`)}let C=p({...c,...z,layout:"stacked",heights:void 0,grow:Lt(),track:e.type==="schema"?i.table:void 0,bare:void 0,pad:void 0,rows:void 0,one:void 0});if(C=M(C),l(C),e.type==="sequence"||e.type==="schema")return{dyn:C,geo:null,ink:"",tokens:g,least:i.least};const B=Ie(e);let j=Qe(L(),f,B,C.grow);for(let q=0;q<6&&Object.keys(j.grow).length;q++){const D=Lt(C.grow);for(const[T,R]of Object.entries(j.grow))D[T]=(Ct(D,T)??0)+R;C={...C,grow:D},l(C),j=Qe(L(),f,B,D)}const F=j.geo;if(!B.third&&B.laneCount>2&&s?.(`the stacked drawing uses ${B.laneCount} end lanes (four at most)`),F.unseated.length>0||F.through.length>0||F.outside.length>0||B.third){F.unseated.length&&s?.(`the stacked drawing has no clean seat for ${[...new Set(F.unseated)].map(T=>`"${qt(e.edges[T]?.label??"")}"`).join(", ")}, so its lines are not drawn; the list holds every connection`),F.through.length&&s?.(`in the stacked drawing ${v(F,F.through)} would pass through a node, so its lines are not drawn`),F.outside.length&&s?.(`in the stacked drawing ${v(F,F.outside)} would leave the drawing, so its lines are not drawn`),B.third&&s?.("the stacked drawing would need a fifth end lane, so its lines are not drawn","error");const q={...F,lines:[],labels:[],crossings:[]};d.querySelectorAll(`.${n}-group > .${n}-glabel`).forEach(T=>T.style.removeProperty("--_gx"));const D=p({...C,grow:Lt(),bare:!0,open:c.bare?c.open:!0,autoOpen:c.bare?c.autoOpen:c.open?void 0:!0});return l(D),{dyn:D,geo:q,ink:"",tokens:g,least:i.least}}return F.seatless?.length&&s?.(`a stacked group's label has no clear seat on its top edge: ${F.seatless.map(q=>`"${q}"`).join(", ")}`),F.crossings.length&&s?.(`${F.crossings.length} crossing${F.crossings.length===1?"":"s"} in the stacked drawing (each is cut): ${F.crossings.map(q=>`${Gt(e,F.lines[q.top])} over ${Gt(e,F.lines[q.under])}`).join("; ")}`),{dyn:C,geo:F,ink:en(n,F,g,o),tokens:g,least:i.least}}function Gt(t,e){const n=t.byId.get(e.from)?.name??e.from,o=t.byId.get(e.to)?.name??e.to;return`${n} to ${o}`}function Qn(t,e,n,o,c,l){const s=new Set;if(l){s.add(l);for(const p of n?.lines??[])p.from===l&&s.add(p.to),p.to===l&&s.add(p.from)}if(t.toggleAttribute("data-tracing",!!l),t.querySelectorAll(`.${e}-node`).forEach(p=>p.toggleAttribute("data-near",s.has(p.dataset.node))),!n||!o)return;const r=p=>!!l&&(p.from===l||p.to===l),a=t.querySelector(`.${e}-edges`),d=new Map;t.querySelectorAll(`.${e}-edge`).forEach(p=>d.set(p.getAttribute("data-edge"),p));for(const p of n.lines){const m=d.get(String(p.i));m&&(m.toggleAttribute("data-lit",r(p)),m.toggleAttribute("data-dim",!!l&&!r(p)))}if(t.querySelectorAll(`.${e}-label`).forEach(p=>{const m=n.lines.find(M=>String(M.i)===p.dataset.edge);p.toggleAttribute("data-lit",!!(m&&r(m)))}),a){for(const p of n.lines)if(r(p)){const m=d.get(String(p.i));m&&a.appendChild(m)}}const g=ee(n.lines,r),{defs:f,ids:i}=tn(e,{...n,crossings:g},o,c),h=t.querySelector(`.${e}-svg`);if(!h)return;let b=h.querySelector("defs");!b&&f&&(b=document.createElementNS("http://www.w3.org/2000/svg","defs"),h.insertBefore(b,h.firstChild)),b&&(b.innerHTML=f),n.lines.forEach((p,m)=>{const M=d.get(String(p.i))?.querySelector(`.${e}-line`);if(!M)return;const L=i.get(m);L?M.setAttribute("mask",`url(#${L})`):M.removeAttribute("mask")})}var Pn=()=>matchMedia("(prefers-reduced-motion: reduce), (forced-colors: active), print").matches||document.documentElement.getAttribute("data-loops")==="held";function to(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",Pn()||no(t)?"done":"pending")}}var eo=t=>`basalt-diagram-entrance:${location.pathname}#${t.id}`;function no(t){if(!t.hasAttribute("data-first-visit")||!t.id)return!1;try{return localStorage.getItem(eo(t))!==null}catch{return!1}}function nn(t){const e=t.getAttribute("data-entrance");e!=="pending"&&e!=="running"||(t.setAttribute("data-entrance","done"),t.dispatchEvent(new Event("basalt-diagram-settle")))}function oo(t,e,n,o=!1,c=!1){const l=o?Xt(t):null;if(l&&n.startsWith("Arrow")){const d={ArrowRight:c?"left":"right",ArrowLeft:c?"right":"left",ArrowDown:"down",ArrowUp:"up"}[n];return d?l[e]?.[d]??null:null}const s=t.byId.get(e)?.i??0,r=t.nodes.length;let a;if(n==="ArrowRight"||n==="ArrowDown")a=s+1;else if(n==="ArrowLeft"||n==="ArrowUp")a=s-1;else if(n==="Home")a=0;else if(n==="End")a=r-1;else return null;return t.nodes[Math.max(0,Math.min(r-1,a))].id}var so=["data-layout","data-measured","role","aria-roledescription","aria-labelledby","aria-describedby","aria-label","tabindex","data-stops","hidden","data-art"],on=["data-layout","data-measured","data-bare","data-motion","data-first-visit","data-rtl","data-cols","data-reach","data-gutter","data-marks"],ao=["--_track","--_h","--_ww","--_gap","--_ggrow","--_tl","--_gpad","--_gw","--_mh","--_rows","--_row-gap","--_one"],sn=t=>t==null||t===!1;function ro(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 o=n?on:so;for(const s of o)sn(e.a[s])&&t.removeAttribute(s);for(const[s,r]of Object.entries(e.a)){if(s==="class")continue;if(s==="style"){const d=t.style,g=new Map(String(r??"").split(";").map(f=>{const i=f.indexOf(":");return[f.slice(0,i).trim(),f.slice(i+1).trim()]}).filter(([f])=>f));for(const[f,i]of g)d.getPropertyValue(f).trim()!==i&&d.setProperty(f,i);for(const f of ao)g.has(f)||d.removeProperty(f);continue}if(n&&!on.includes(s))continue;if(sn(r)){t.removeAttribute(s);continue}const a=r===!0?"":String(r);t.getAttribute(s)!==a&&t.setAttribute(s,a)}if(e.t==="svg"||typeof e.a.class=="string"&&(/-ruler$/.test(e.a.class)||/-ink$/.test(e.a.class)&&!e.a.class.endsWith("-text-ink"))||e.c.some(s=>typeof s!="string"&&"slot"in s))return;const c=[...t.children];let l=0;for(const s of e.c)if(!(typeof s=="string"||"slot"in s)){for(let r=l;rt.querySelector(`.${e}-node[data-node="${CSS.escape(l)}"]`);n&&c(n)?.setAttribute("tabindex","-1"),c(o)?.setAttribute("tabindex","0")}(function(t){"use strict";var e=t._,n="diagram",o=0;function c(i,h,b){return{prefix:n,base:i,hasSource:h.source!==void 0&&h.source!==null&&h.source!=="",hiddenClass:"visually-hidden",viewer:b?b.keys:void 0}}function l(i,h,b,p){var m=function(M){return''+mt(M)+""};return{source:mt(String(h.source||"")),summary:mt(String(h.summary||"")),hint:ie(i).map(function(M){return""+M.keys.map(m).join(" ")+" "+mt(M.words)+""}).join(""),toggle:'"}}function s(i,h,b){for(var p=i.layout==="auto"&&(i.type==="architecture"||i.type==="flowchart"||i.type==="schema"),m=p?Array.isArray(i.placement)?i.placement:i.placement?[i.placement]:[]:[],M=i.direction||(i.type==="flowchart"?"down":"right"),L=null,z=0;z");return{open:B.slice(0,j+1),inner:B.slice(j+1,B.length-9),warnings:v.errors.map(function(F){return"error: "+F}).concat(v.warnings)}}var r=["aria-labelledby","data-type","data-cols","data-reach","data-gutter","data-marks","data-layout","data-measured","data-bare"],a=["--_cols","--_gpad","--_track"];function d(i,h,b,p){i.__diagram&&i.__diagram.stop();var m=(i.getAttribute("aria-labelledby")||"").replace(/-title$/,"").replace(/[^A-Za-z0-9_-]/g,""),M=getComputedStyle(i).direction==="rtl",L=h.layout==="auto"&&(h.type==="architecture"||h.type==="flowchart"||h.type==="schema"),z=L?Array.isArray(h.placement)?h.placement:h.placement?[h.placement]:[]:[];L&&!z.length&&console.warn('Basalt diagram: "layout": "auto" needs a placement, which compose.mjs writes at build time; drawn from script, place it with placeDiagram (@srasyndicate/basalt/diagram-layout) and pass "placement". The figure is stacked');var v=h.direction?[h.direction]:h.type==="flowchart"?["down","right"]:["right","down"],C=function(N){for(var G=0;G .diagram-drawing")){if(!m||!i.querySelector("#"+CSS.escape(m+"-title"))){for(;document.getElementById("dg"+ ++o+"-title"););m="dg"+o}var j=s(h,m,p),F=document.createElement("div");F.innerHTML=j.open+"";var rt=F.firstChild;r.forEach(function(N){i.removeAttribute(N)}),a.forEach(function(N){i.style.removeProperty(N)});for(var q=0;q :not(script[data-diagram])").forEach(function(N){N.remove()}),i.insertAdjacentHTML("beforeend",j.inner)}B.warnings.forEach(function(N){console.warn("Basalt diagram: "+N)}),B.errors.forEach(function(N){console.error("Basalt diagram: "+N)}),B.motion.animated&&B.motion.firstVisit&&!i.id&&console.error('Basalt diagram: "entrance": "first-visit" needs an id on the figure: without one the entrance plays on every visit');var T=c(m,h,p),R={},H=null,Q=null,at=null,it=null,yt=Object.create(null),dt=function(N,G){yt[N]||(yt[N]=1,(G==="error"?console.error:console.warn)("Basalt diagram: "+N))},et=function(N){ne(i,Qt(B,N,T))},nt=i.querySelector(".diagram-ink"),tt=i.querySelector(".diagram-toggle"),$=!p&&B.motion.animated&&typeof e.diagramMotion=="function",u=null,w=null,O=function(){$&&nn(i)};function I(){Qn(i,n,H&&H.geo,H&&H.tokens,m,Q||it||at),V()}var _=null,X=!p&&matchMedia("(hover: none), (pointer: coarse)").matches;function V(){var N=X&&!p&&nt&&nt.innerHTML!=="";if(i.toggleAttribute("data-touch",!!(X&&!p)),N&&!_){var G=i.querySelector(":scope > .diagram-foot");if(!G)return;_=document.createElement("button"),_.type="button",_.className="btn diagram-clear",_.setAttribute("data-variant","secondary"),_.setAttribute("data-size","sm"),_.innerHTML="Clear highlight",_.addEventListener("click",function(){it&&(it=null,I())}),G.insertBefore(_,G.querySelector(":scope > .diagram-export-note"))}else!N&&_&&(_.remove(),_=null);_&&_!==_.parentNode.lastElementChild&&document.activeElement!==_&&_.parentNode.appendChild(_),_&&(it?_.removeAttribute("aria-disabled"):_.setAttribute("aria-disabled","true"))}function ft(N){if(!N.defaultPrevented){var G=bn(i,n,N,it);G!==void 0&&(O(),X=!0,it=G,I())}}function st(){tt&&(tt.setAttribute("aria-expanded",String(!!R.open)),tt.firstElementChild.textContent=R.open?"Hide the list":"View as list")}function lt(){if(L&&z.length>1&&!p){for(var N=null,G=[],P=!1,ot=0;ot1&&p&&!h.direction&&p.room){for(var oe=p.room(),Vt=-1,me=null,ye=0;yeVt+1e-6&&(Vt=rn,me=$e)}}}me&&(B=me)}H=(p?p.measure:ge)(i,B,n,m,R,et,dt),R=H.dyn,et(R),st();var be=i.querySelector(":scope > .diagram-hint");if(be){var ln=ie(B,R.layout==="drawn").map(function(At){return""+At.keys.map(function(fo){return''+mt(fo)+""}).join(" ")+" "+mt(At.words)+""}).join("");be.innerHTML!==ln&&(be.innerHTML=ln)}Tt(B,R)||(at=it=null);var cn=nt&&H.ink!==w;cn&&(nt.innerHTML=H.ink,w=H.ink),Yn(i,n,H.geo),I();var co=B.text?i.querySelector(".diagram-text[data-art]"):null;B.text&&typeof e.diagramText=="function"&&e.diagramText(i,B,h,p);var dn=B.text?i.querySelector(".diagram-text[data-art]"):null;$&&H.tokens&&(to(i,!!(H.geo&&H.geo.lines.length)||!!dn),(cn||dn!==co)&&u&&u.redrawn()),p&&p.onMeasured&&H.tokens&&p.onMeasured(H,i)}function pt(N){R=N,et(R)}function kt(N){var G=R.stop;R=Object.assign({},R,{stop:N}),io(i,n,G,N)}var ut=function(N){var G=N&&N.closest?N.closest(".diagram-node"):null;return G&&i.contains(G)?G:null};function $t(N){var G=ut(N.target);if(!(!G||N.defaultPrevented)){if(O(),N.key==="Escape"){!p&&(Q||at||it)&&(N.preventDefault(),Q=at=it=null,I());return}if(Tt(B,R)){var P=oo(B,G.getAttribute("data-node"),N.key,R.layout==="drawn");if(P){N.preventDefault(),kt(P);var ot=i.querySelector('.diagram-node[data-node="'+CSS.escape(P)+'"]');ot&&ot.focus()}}}}function bt(N){var G=ut(N.target);if(G){O();var P=G.getAttribute("data-node");Q=G.matches(":focus-visible")?P:null,Tt(B,R)&&R.stop!==P&&kt(P),I()}}function wt(N){var G=ut(N.target);G&&(ut(N.relatedTarget)||(Q=null),R.keep===G.getAttribute("data-node")&&pt(Object.assign({},R,{keep:void 0})),I())}function vt(N){if(!(N.pointerType!=="mouse"||!matchMedia("(hover: hover)").matches)){var G=ut(N.target);G&&O();var P=G&&Tt(B,R)?G.getAttribute("data-node"):null;P!==at&&(at=P,I())}}function y(){at&&(at=null,I())}function S(){O(),pt(Object.assign({},R,{open:!R.open,autoOpen:void 0})),st()}i.addEventListener("keydown",$t),i.addEventListener("focusin",bt),i.addEventListener("focusout",wt),i.addEventListener("pointerover",vt),i.addEventListener("pointerleave",y),i.addEventListener("click",ft),tt&&tt.addEventListener("click",S),lt();var E=i.clientWidth,k=0,A=!0,W=new ResizeObserver(function(){Math.abs(i.clientWidth-E)<.5||(E=i.clientWidth,cancelAnimationFrame(k),k=requestAnimationFrame(lt))});W.observe(i),document.fonts&&document.fonts.ready.then(function(){A&<()});var J=matchMedia("(forced-colors: active)"),K=B.nodes.some(function(N){return N.mark});K&&J.addEventListener("change",lt),$&&(u=e.diagramMotion(i,{fig:i,P:n,base:m,model:function(){return B},geo:function(){return H&&H.geo},tokens:function(){return H&&H.tokens}},h));var Y=!p&&h.zoom!==!1&&typeof e.diagramZoom=="function"?e.diagramZoom(i,h,{model:B,settle:O,animated:$}):null,U=i.querySelector(":scope > .diagram-foot"),Z=!p&&h.export===!0&&U&&typeof e.diagramExport=="function"?e.diagramExport(U,i):[];i.__diagram={stop:function(){Y&&Y.destroy(),Z.forEach(function(N){N.remove()}),A=!1,W.disconnect(),cancelAnimationFrame(k),K&&J.removeEventListener("change",lt),u&&u.destroy(),i.removeEventListener("keydown",$t),i.removeEventListener("focusin",bt),i.removeEventListener("focusout",wt),i.removeEventListener("pointerover",vt),i.removeEventListener("pointerleave",y),i.removeEventListener("click",ft),_&&_.remove(),tt&&tt.removeEventListener("click",S)},layout:lt,key:g(h),send:u&&u.sendValue?u.sendValue:null}}function g(i){try{return JSON.stringify(i,function(h,b){return h==="packet"&&b&&typeof b=="object"?Object.assign({},b,{send:void 0}):b})}catch{return null}}function f(){document.querySelectorAll("figure.diagram").forEach(function(i){if(!i.__diagram){var h=i.querySelector(":scope > script[data-diagram]");if(h)try{d(i,JSON.parse(h.textContent),!0)}catch(b){console.error("Basalt diagram: this figure could not be drawn",b)}}})}e.diagramMarkup=s,e.diagramKit={draw:d,buildModel:Nt,figureKey:En,figureList:Bn,hintEntries:ie,toHtml:ae,escapeHtml:mt,settleEntrance:nn,measureFigure:ge},t.diagram=function(i,h){var b=i.__diagram,p=b&&b.send?g(h):null;if(p!==null&&p===b.key){b.send(h.packet?h.packet.send:void 0);return}d(i,h)},e.step(62,"wireDiagrams",f)})(window.Basalt)})(); diff --git a/.agent/skills/basalt-html/parts/manifest.json b/.agent/skills/basalt-html/parts/manifest.json index b4f9bcd1..3a297874 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. 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). DECISIONS 320 (versions and release notes): the release module is new (budget 15900 at first, usage 2400); topbar, app-shell and tab-bar gain the version link's classes (budgets: topbar 17700 to 19900, app-shell 4300 to 5200 with the rail's tooltip for it, tab-bar 4850 to 5200), their usage caps rising 2900 to 3100, 2600 to 2850 and 2250 to 2400 for its one line each; skillMd rose 12650 to 12800 for the release module's line and .version-link in topbar's. The code review of round 68 adds data-focus-self to the popover module (its Tab walk; budget 4950 to 5600, usage cap 950 to 1100) and logical start and end for its alignment; the release module's header grid and the Sources panel's touch rows take it to 16900. The spacing sweep of round 68 (DECISIONS 326: Copy link's words on the edge, the callout's last change, its reference column, the last release, the touch rows' end and the whole code chip) takes the release module to 17400. The ruling on where a release ends (DECISIONS 331: no padding under the last change in a release, a release-ending fold's hang, an arrived change keeping its padding, the panel holding its first margin, Build details 44 on touch and a closed Fixed panel taking no room) takes it to 19000. The code recheck of round 68 (recheck 5) has the popover's Tab walk follow Safari's own rule (Tab skips links on Apple's WebKit, Option-Tab reaches them): popover 5600 to 5900. The pixel recheck of round 68 has the Sources panel's touch rows keep their 20px lines with the link's box as hit area, space-3 rows and space-6 between two linked values (recheck-pixels 4), and the release's whole header take the arrival's plate: release 19000 to 19600. Merging #127 (stages, DECISIONS 316 and 328) into the versioning branch: both had raised skillMd from 12650 to 12800 for their own module's line, and together they came to 12886; SKILL.md was tightened in its wording (no rule dropped) to stay within 12800. Raised in diagram batch B's fix round (DECISIONS 318, the owner's diagram raise; and 326's sweep), each to its measured size: diagram 137700 to 144100 (the two reviews' fixes in the shared engine: right to left frames and self-calls, the corridors' and lanes' development words, the unusable-placement check, the transcript's hanging lines, the text art's frame widening, the frame-side fit check, the sequence's layers, the stacked group's turn room), diagram-motion 28450 to 30450 (the text sequence's build by ink and its colour-only run, moved into the motion module), diagram-zoom 17000 to 17600 (a linked card closes the viewer; the text art's own width; a placed model for the key hint), diagram-export 7850 to 10450 (an export at rest: sized drawing SVGs, no reveal masks, the pseudo-element rules, the lines under the cards, a viewer's figure read at 100% with its head and key, the rim's lit top). Raised at the batch B re-check (the decider's four rulings): diagram 144100 to 145100 (5.1's first list reported as errors apart from the warnings, a turn's label lines on the group entered by it and the seats beside its turn, the bare stack applied, the text art's reset of the core's inline code chip). Merging main (#127 and #128) into diagram batch B: skillMd keeps main's 12800 (batch B had raised it to 12950 for its diagram lines); SKILL.md was tightened in its wording to stay within it, no rule dropped; core takes main's 35550.Raised in the repo review (23 Nov 2026; budgets are soft, the owner's word): notifications 12450 to 12700 (a link is written only when relative, http, https or mailto, and side and align are checked before they reach the markup), combobox 11200 to 11350 (a disabled field's hidden input is disabled too, now and later), tooltip 3200 to 3550 (the gap to the opener is the tooltip's own, and hover and keyboard focus each hold it open; WCAG 1.4.13), chart 34750 to 34800 (the scale's step search and gridlines are bounded, so extreme values cannot hang the page), spinner 650 to 720 (its held rule moved in from loops, so a ring-only page keeps a stored hold), kbd 2900 to 2950, palette 11400 to 11500 (and its usage text 1350 to 1400, for the Mod line) and toast 16050 to 16200 (Mod in a palette item's keys is bound as it is drawn, and a toast action's aria-keyshortcuts resolves Mod). The safe-sinks rule (decided by the owner, Fable, Astra and Muse, 23 Nov 2026): skillMd 12650 to 12900, and 13050 with main's own raise merged in (one line: data goes in as textContent, a link passes Basalt.safeHref, an option comes from a fixed list), core 35400 to 35650, and 35800 with main's own raise merged in, and its usage 2950 to 3200 (one safeHref, published as Basalt.safeHref, and _.pick, in place of a copy in each module; esc escapes the apostrophe), link-tabs 5750 to 5900 (a refused link dispatches no event), diagram 92650 to 93000 (a card's mark is a relative path, https or a data: image). Merging #129 into diagram batch B: diagram keeps batch B's 145100 plus #129's mark check, set to its measure, and batch B's usage 4600. The fix round after both reviews of 421348e8 sets them to the measured sizes again: core 38950 to 39600 (every room says all three forms, and a hung word's box grows by a short room's shortfall), search to 5700 (it places its top again on a resize and with the keyboard; an empty list holds no padding), command-list to 14700 (it keeps the taller of its two heights), notifications to 12950 (the bell's edge), pane to 1950 (the page column's room), chart to 34950 (the date line's reason), and code, diagram-zoom, filter, links, sheet, still-table, tab-bar and topbar each by under 150 bytes (the three forms of a room; the selection column's width however given). Merged with main at db0bc418 (#129 to #131), DECISIONS 336's caps are set to the measured sizes again: core 35800 to 38950 and its usage 3200 to 3650, toast 16200 to 16750, terminal to 12700 (13050 with the open items' ruling: both copy buttons draw their three glyphs once, so a refused copy shows the close with no markup written after), diagram-zoom 17600 to 17750 (its viewer's Close and Zoom out hung, and the foot's room). Raised in DECISIONS 336 (reserved room across every component, claude/reserved-room), each to its measured size: core 35550 to 38700 (the edge rule a ghost .btn hangs by at a head, its ring and touch hit area, the side insets by direction, the .panel-head and page section-head that hang their last button by themselves) and its usage 2950 to 3450 (how data-edge and --basalt-edge-room are written); search 4400 to 5200 (search.js, the held top), terminal 11950 to 12550 (the close glyph for a refused copy, the edge on both copies), links 2750 to 3300 (the first icon link hung, the card room, the 20px glyph), toast 16050 to 16650 (the 46px hit areas on touch), selection 1500 to 1650 and still-table 14650 to 15000 (the 44px select column), command-list 14000 to 14350 (the panel hugs, the room is page), menu 8950 to 9150 (the column every row keeps when any row has a check or a glyph), notifications 12450 to 12600, filter 17500 to 17600, forms 3500 to 3550, sheet 5400 to 5450, topbar-nav 7550 to 7600 and app-shell 5200 to 5250 (logical sides, the edge and the room); topbar's usage 3100 to 3200 (a bar's last ghost control takes data-edge); command-list's usage 2150 to 2300 (the panel hugs; the room is page, and only on the page); dialog-form's usage 1300 to 1350 (its Close is written data-icon-only data-edge=\"end\"). Raised in the polish ruling of 336 (the selection box keeps to the cell's line): selection 1650 to 1750 (the box's start margin, min(space-4, half the spare room): 1710 measured) and its usage 1150 to 1350 (the rule's sentence: 1313 measured). Merging main (#130, #131) into claude/diagram-interop: diagram usage 4600 to 4850 (+5.4%: Batch B's diagram usage plus the basalt-diagram-export rule line, measured 4806), then 4850 to 5050 (noting that .lucid is for Lucid's REST API only and to use .vsdx in Lucid's UI, measured 4999). Raised for right to left (diagrams-rtl): diagram 145450 to 146000 (the stacked figure mirrors, its snap and whole-pixel labels with it; a drawn schema takes its turn-backs, its one-column room and its gutter lanes from the end side); then 146000 to 148000 for Fable's ruling on the stacked group label (the stem gives way, the label slides, the last resort's warning) and the author's strings isolated in ). Raised in the first tab (DECISIONS 358): tabs 3700 to 4600 (the scrollport and its hang, the divider as ::before, the underline's inset, the scroll margin, and the script that wraps the row and brings a focused tab into view: 4524 measured), link-tabs 5900 to 6350 (the hang and the divider as ::before: 6276 measured), tabs usage 750 to 1150 (the .tabs-scroll wrapper in the markup and the sentence on the scrollport, the hang and the underline: 1111 measured) and link-tabs usage 2550 to 2750 (the hang and the underline's width: 2702 measured). The pause toggle's held look (DECISIONS 361): toggle 1950 to 2400 (a seat whose glyph has a selected form draws both forms in one box with no check, and the hold's icon-only toggle crossfades between its two drawings: 2386 measured) and glyph 1950 to 2100 (the pair and the seat a toggle draws, shared with loops and diagram-motion: 2098 measured).", + "$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). DECISIONS 320 (versions and release notes): the release module is new (budget 15900 at first, usage 2400); topbar, app-shell and tab-bar gain the version link's classes (budgets: topbar 17700 to 19900, app-shell 4300 to 5200 with the rail's tooltip for it, tab-bar 4850 to 5200), their usage caps rising 2900 to 3100, 2600 to 2850 and 2250 to 2400 for its one line each; skillMd rose 12650 to 12800 for the release module's line and .version-link in topbar's. The code review of round 68 adds data-focus-self to the popover module (its Tab walk; budget 4950 to 5600, usage cap 950 to 1100) and logical start and end for its alignment; the release module's header grid and the Sources panel's touch rows take it to 16900. The spacing sweep of round 68 (DECISIONS 326: Copy link's words on the edge, the callout's last change, its reference column, the last release, the touch rows' end and the whole code chip) takes the release module to 17400. The ruling on where a release ends (DECISIONS 331: no padding under the last change in a release, a release-ending fold's hang, an arrived change keeping its padding, the panel holding its first margin, Build details 44 on touch and a closed Fixed panel taking no room) takes it to 19000. The code recheck of round 68 (recheck 5) has the popover's Tab walk follow Safari's own rule (Tab skips links on Apple's WebKit, Option-Tab reaches them): popover 5600 to 5900. The pixel recheck of round 68 has the Sources panel's touch rows keep their 20px lines with the link's box as hit area, space-3 rows and space-6 between two linked values (recheck-pixels 4), and the release's whole header take the arrival's plate: release 19000 to 19600. Merging #127 (stages, DECISIONS 316 and 328) into the versioning branch: both had raised skillMd from 12650 to 12800 for their own module's line, and together they came to 12886; SKILL.md was tightened in its wording (no rule dropped) to stay within 12800. Raised in diagram batch B's fix round (DECISIONS 318, the owner's diagram raise; and 326's sweep), each to its measured size: diagram 137700 to 144100 (the two reviews' fixes in the shared engine: right to left frames and self-calls, the corridors' and lanes' development words, the unusable-placement check, the transcript's hanging lines, the text art's frame widening, the frame-side fit check, the sequence's layers, the stacked group's turn room), diagram-motion 28450 to 30450 (the text sequence's build by ink and its colour-only run, moved into the motion module), diagram-zoom 17000 to 17600 (a linked card closes the viewer; the text art's own width; a placed model for the key hint), diagram-export 7850 to 10450 (an export at rest: sized drawing SVGs, no reveal masks, the pseudo-element rules, the lines under the cards, a viewer's figure read at 100% with its head and key, the rim's lit top). Raised at the batch B re-check (the decider's four rulings): diagram 144100 to 145100 (5.1's first list reported as errors apart from the warnings, a turn's label lines on the group entered by it and the seats beside its turn, the bare stack applied, the text art's reset of the core's inline code chip). Merging main (#127 and #128) into diagram batch B: skillMd keeps main's 12800 (batch B had raised it to 12950 for its diagram lines); SKILL.md was tightened in its wording to stay within it, no rule dropped; core takes main's 35550.Raised in the repo review (23 Nov 2026; budgets are soft, the owner's word): notifications 12450 to 12700 (a link is written only when relative, http, https or mailto, and side and align are checked before they reach the markup), combobox 11200 to 11350 (a disabled field's hidden input is disabled too, now and later), tooltip 3200 to 3550 (the gap to the opener is the tooltip's own, and hover and keyboard focus each hold it open; WCAG 1.4.13), chart 34750 to 34800 (the scale's step search and gridlines are bounded, so extreme values cannot hang the page), spinner 650 to 720 (its held rule moved in from loops, so a ring-only page keeps a stored hold), kbd 2900 to 2950, palette 11400 to 11500 (and its usage text 1350 to 1400, for the Mod line) and toast 16050 to 16200 (Mod in a palette item's keys is bound as it is drawn, and a toast action's aria-keyshortcuts resolves Mod). The safe-sinks rule (decided by the owner, Fable, Astra and Muse, 23 Nov 2026): skillMd 12650 to 12900, and 13050 with main's own raise merged in (one line: data goes in as textContent, a link passes Basalt.safeHref, an option comes from a fixed list), core 35400 to 35650, and 35800 with main's own raise merged in, and its usage 2950 to 3200 (one safeHref, published as Basalt.safeHref, and _.pick, in place of a copy in each module; esc escapes the apostrophe), link-tabs 5750 to 5900 (a refused link dispatches no event), diagram 92650 to 93000 (a card's mark is a relative path, https or a data: image). Merging #129 into diagram batch B: diagram keeps batch B's 145100 plus #129's mark check, set to its measure, and batch B's usage 4600. The fix round after both reviews of 421348e8 sets them to the measured sizes again: core 38950 to 39600 (every room says all three forms, and a hung word's box grows by a short room's shortfall), search to 5700 (it places its top again on a resize and with the keyboard; an empty list holds no padding), command-list to 14700 (it keeps the taller of its two heights), notifications to 12950 (the bell's edge), pane to 1950 (the page column's room), chart to 34950 (the date line's reason), and code, diagram-zoom, filter, links, sheet, still-table, tab-bar and topbar each by under 150 bytes (the three forms of a room; the selection column's width however given). Merged with main at db0bc418 (#129 to #131), DECISIONS 336's caps are set to the measured sizes again: core 35800 to 38950 and its usage 3200 to 3650, toast 16200 to 16750, terminal to 12700 (13050 with the open items' ruling: both copy buttons draw their three glyphs once, so a refused copy shows the close with no markup written after), diagram-zoom 17600 to 17750 (its viewer's Close and Zoom out hung, and the foot's room). Raised in DECISIONS 336 (reserved room across every component, claude/reserved-room), each to its measured size: core 35550 to 38700 (the edge rule a ghost .btn hangs by at a head, its ring and touch hit area, the side insets by direction, the .panel-head and page section-head that hang their last button by themselves) and its usage 2950 to 3450 (how data-edge and --basalt-edge-room are written); search 4400 to 5200 (search.js, the held top), terminal 11950 to 12550 (the close glyph for a refused copy, the edge on both copies), links 2750 to 3300 (the first icon link hung, the card room, the 20px glyph), toast 16050 to 16650 (the 46px hit areas on touch), selection 1500 to 1650 and still-table 14650 to 15000 (the 44px select column), command-list 14000 to 14350 (the panel hugs, the room is page), menu 8950 to 9150 (the column every row keeps when any row has a check or a glyph), notifications 12450 to 12600, filter 17500 to 17600, forms 3500 to 3550, sheet 5400 to 5450, topbar-nav 7550 to 7600 and app-shell 5200 to 5250 (logical sides, the edge and the room); topbar's usage 3100 to 3200 (a bar's last ghost control takes data-edge); command-list's usage 2150 to 2300 (the panel hugs; the room is page, and only on the page); dialog-form's usage 1300 to 1350 (its Close is written data-icon-only data-edge=\"end\"). Raised in the polish ruling of 336 (the selection box keeps to the cell's line): selection 1650 to 1750 (the box's start margin, min(space-4, half the spare room): 1710 measured) and its usage 1150 to 1350 (the rule's sentence: 1313 measured). Merging main (#130, #131) into claude/diagram-interop: diagram usage 4600 to 4850 (+5.4%: Batch B's diagram usage plus the basalt-diagram-export rule line, measured 4806), then 4850 to 5050 (noting that .lucid is for Lucid's REST API only and to use .vsdx in Lucid's UI, measured 4999). Raised for right to left (diagrams-rtl): diagram 145450 to 146000 (the stacked figure mirrors, its snap and whole-pixel labels with it; a drawn schema takes its turn-backs, its one-column room and its gutter lanes from the end side); then 146000 to 148000 for Fable's ruling on the stacked group label (the stem gives way, the label slides, the last resort's warning) and the author's strings isolated in ). Raised in the first tab (DECISIONS 358): tabs 3700 to 4600 (the scrollport and its hang, the divider as ::before, the underline's inset, the scroll margin, and the script that wraps the row and brings a focused tab into view: 4524 measured), link-tabs 5900 to 6350 (the hang and the divider as ::before: 6276 measured), tabs usage 750 to 1150 (the .tabs-scroll wrapper in the markup and the sentence on the scrollport, the hang and the underline: 1111 measured) and link-tabs usage 2550 to 2750 (the hang and the underline's width: 2702 measured). The pause toggle's held look (DECISIONS 361): toggle 1950 to 2400 (a seat whose glyph has a selected form draws both forms in one box with no check, and the hold's icon-only toggle crossfades between its two drawings: 2386 measured) and glyph 1950 to 2100 (the pair and the seat a toggle draws, shared with loops and diagram-motion: 2098 measured). Raised on claude/diagram-actions (diagrams-cimip's foot decision and its two rulings; budgets are soft, the reason recorded here): diagram 148000 to 148700 (main was already 148204 after #142; the one-column cap in the engine and its CSS, the foot out of print, and Clear highlight mounting before a download's note), diagram-zoom 17800 to 18000 (the viewer's end group wrapping from the start edge, the drawing's own box for Fit, the sizer's clip), diagram-export 10450 to 12850 (main was already 11147; the export of a hidden viewer drawing, the rejection of a figure with no box, and the refused-PNG note with its CSS), and the usage caps diagram 5050 to 5100 and diagram-export 700 to 760 for the rulings' words.", "budgets": { "skillMd": 13050, "core": 39600 @@ -821,8 +821,8 @@ "art", "kbd" ], - "budget": 148000, - "usage": 5050, + "budget": 148700, + "usage": 5100, "builds": [ "kbd" ] @@ -883,7 +883,7 @@ "dialog-form", "sheet" ], - "budget": 17800, + "budget": 18000, "usage": 900, "builds": [ "dialog", @@ -901,8 +901,8 @@ "requires": [ "diagram" ], - "budget": 10450, - "usage": 700 + "budget": 12850, + "usage": 760 }, "diagram-text": { "text": [ diff --git a/.agent/skills/basalt-html/parts/usage/diagram-export.md b/.agent/skills/basalt-html/parts/usage/diagram-export.md index e555ff98..213da2a1 100644 --- a/.agent/skills/basalt-html/parts/usage/diagram-export.md +++ b/.agent/skills/basalt-html/parts/usage/diagram-export.md @@ -3,5 +3,5 @@ Added for you when a diagram's JSON says `"export": true`. - The figure's foot gets "Download SVG" and "Download PNG", and so does its viewer's (the drawn layout at 100%, whatever the zoom). Each writes the figure in the theme shown: the title and source, the drawing and the key, at rest; native SVG with its words as text and the faces embedded; the PNG at 2x. -- The PNG is drawn through an image: under a content policy, `img-src` must allow `blob:` or `data:`. Where it allows neither, "Download PNG" makes no file and the console says why; "Download SVG" needs neither. +- The PNG is drawn through an image: under a content policy, `img-src` must allow `blob:` or `data:`. Where it allows neither, "Download PNG" makes no file, says so under the buttons and is switched off; the console names the `img-src` it needs; "Download SVG" needs neither. - Without `"export": true` there are no buttons and no module. Don't add your own. diff --git a/.agent/skills/basalt-html/parts/usage/diagram.md b/.agent/skills/basalt-html/parts/usage/diagram.md index 5d343dae..6394e28a 100644 --- a/.agent/skills/basalt-html/parts/usage/diagram.md +++ b/.agent/skills/basalt-html/parts/usage/diagram.md @@ -21,7 +21,7 @@ Boxes and the lines between them. `compose.mjs` writes the figure's words into t - **Place, don't route:** `col` and `row` are whole tracks from 1. Sides, slots, jogs, lanes, the group's box and a foreign key's line are derived. Write `fromSide` or `toSide` (`top`, `right`, `bottom`, `left`) only to change the default. `branch: true` indents a node in the stacked drawing. - **Lines:** `kind` is `main` (2px), `plain` (default) or `dashed` (a reply, a stream). One `label` each, at most 28 characters. `legend` gives each kind its words; `main`, `dashed` and a `focal` node must have words. One node at most is `focal`. - **Required:** `title`, `summary` (what it shows, in a sentence). `source`, `heading` (2 to 6, default 3). -- Monochrome: nothing takes a colour but a card's service mark. The drawn layout is used only where it fits; otherwise the figure is stacked, one column at most 480 wide. +- Monochrome: nothing takes a colour but a card's service mark. The drawn layout is used only where it fits; otherwise the figure is stacked. One column is at most 480 wide, drawn or stacked, on the start edge (or its track's least width where more). - **Motion:** `"motion": "animated"` (default still) draws each line once in view, every word at rest; it brings in `diagram-motion` (its usage says the rest). Motion never carries a fact alone. - **Flow, pulse, packet:** `"flow": true` on an edge marches it (a dashed line's own dashes) (give it a label). `"pulse": ["a", "b", "c"]` runs a bead along a route; `"packet": { "path": [...], "repeat": true }` sends a dot. One of pulse and packet; never flow on the mover's route. Architecture and data flow only. - **Run:** `"run": true` on a sequence adds "Play the run", a dot through every message. diff --git a/AGENTS.md b/AGENTS.md index aab3b494..cfadc7a3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -221,7 +221,7 @@ Basalt has one owner (Bailey) and a design panel of two independent design revie and where it is drawn differs by part: foundations' table in "Stages and runs" is the rule. - **Diagrams:** monochrome; one focal node, inverted. Three lines named by look (main 2px, plain 1px, dashed), and the key says what each means. The drawn layout is used only when it fits (640, the track minimums, a clean seat for every label); otherwise stacked, in - the author's order, at most 480 wide. Nothing is cut and nothing overlaps at any width. Ports, routes, groups and foreign keys are derived from one + the author's order, at most 480 wide. One column is at most 480 wide, drawn or stacked (or its track's least width where that is more), on the start edge. Nothing is cut and nothing overlaps at any width. Ports, routes, groups and foreign keys are derived from one record each. A flowchart's shapes have a 3:1 contour. Tracing changes ink, never weight. The words are in the HTML before script. Still by default; `motion="animated"` adds an entrance on view (each line draws once, every word at rest, inside five seconds) and, where the data names them, a flow line (cuts, only while they move), a pulse (a bead) or a packet (a dot): one mover a figure, loops @@ -233,7 +233,9 @@ Basalt has one owner (Bailey) and a design panel of two independent design revie draws far keys along a corridor. A sequence may show a participant working (a bar) and frame a run of messages (`opt`, `loop`, `alt`: structure, never a panel, every word plated), and may be written as text art, which never hides a line and has no caret. Groups nest two deep; four end lanes at most. A card may be a link (the card is the stop; the arrow is the cue). A label breaks only where its - author breaks it. Arrow keys are spatial, on tracks. On touch a tap traces and "Clear highlight" clears. In print a figure is untraced and light. + author breaks it. Arrow keys are spatial, on tracks. On touch a tap traces and "Clear highlight" clears. The foot's order is fixed ("View as list", + "Expand", the run button, "Pause animations", an app's `actions`, "Clear highlight") and it does not print; an app's actions are words-only secondary + buttons, never a menu, and follow the figure into the viewer. In print a figure is untraced and light. Right to left mirrors the figure, not the words. Automatic layout asks elkjs for a column and a row and nothing else; Basalt routes, and a figure is never scaled. elkjs loads on demand or not at all: place at build time. "Expand" opens the viewer: the drawn layout in a dialog (full screen under 720), laid out at 100% and zoomed by the reader with one transform, from Fit or 100% to 400%, in steps that land at once; it pans by scrolling; it diff --git a/docs/foundations.md b/docs/foundations.md index 20446ff7..ebfab6b2 100644 --- a/docs/foundations.md +++ b/docs/foundations.md @@ -1815,6 +1815,9 @@ card keeps its owner's colours ([Service marks](#service-marks)). One node may b receiver and kind. A schema is its cards in an auto-fit grid with no lines, because every foreign-key row writes its target. A stacked group whose first card is entered by a turn has `space-12` above; its label stays in the first `space-8`. Stacked, a group's label gives way to the lines at its top edge: it slides along the edge, on the start side, and is never set over a line that has room to pass. +- **One column is at most 480 wide, drawn or stacked.** A drawn layout of one column (architecture, flowchart, data flow, + schema) is at most `size-breakpoint-container` wide on the start edge, as the stack is, or its track's least width where that + is more. The room beside it is open page. Two columns or more share the figure's width. - **Several end lines into one card nest:** the line from the outermost lane turns lowest and enters nearest the end edge; each line from a lane further in turns `space-5` higher and enters `space-3` further in. Their labels are seated `space-2-5` clear of the innermost entry, each on its own turn's height, taken before the half-pixel snap. @@ -1867,6 +1870,13 @@ card keeps its owner's colours ([Service marks](#service-marks)). One node may b drawn, the letters set as the tab sets them ("Only if", "Repeats", "One of these"): built in, because they are notation. - The summary is required. "View as list" opens the same facts as real lists in the same figure: the parts and connections, a flowchart's steps with each exit written once, a data flow's steps, a sequence's messages, a schema's tables. +- **The foot** holds the figure's controls in one fixed order, `space-2` apart, wrapping from the start edge: "View as list", "Expand", + a sequence's run button, "Pause animations", the app's own actions, then "Clear highlight", which is last so that nothing moves when it + mounts. Each is a secondary small button with words. **An app's own actions** (`actions`) are the author asking for a control: words + only, in the order given, one press each and never a menu, three at most by intent (a development build warns past three, and past 24 + characters in a label, and draws them as written). Each is busy on its own until its promise settles. They exist once script runs, as + "Expand" does, and their code is loaded only by a figure that has some. A press settles a running entrance and hands the action the + figure it was pressed in. The foot does not print. - The figure's words are in the HTML before script runs, and where scripting is off the list is open. Before script the figure is stacked unless it is at least its least width (the track minimums and gaps summed, never under 640); a figure of more than six columns is stacked until script. @@ -1906,13 +1916,17 @@ rim included, with the sheet's head, body and foot. "Expand" is words only. Deci size. Under `scale(3)` the figure is the pixels a 3x screen draws. - **Fit** is the whole drawing in the stage (padding `space-6`, `space-4` under 720), 200% at most, and is how it opens. The limits are Fit or 100%, whichever is less, and 400%. Buttons and keys step through 25, 33, 50, 67, 75, 100, 125, 150, 200, 300 and 400, - and a step lands at once. The level is written between the buttons and spoken once it rests. + and a step lands at once. The level is written between the buttons and spoken once it rests. The drawing is what is drawn: a + one-column figure is fitted and scrolled as its column, not as the width it was laid out in. - **Zoom:** "Zoom out", "Zoom in" and "Fit"; `+`, `−` and `0` while focus is in the stage; Ctrl or Command with the wheel and a trackpad pinch, about the pointer; two fingers on touch, about their midpoint. - **Pan is a scroll:** the stage scrolls both ways. A drag past `space-1`, one finger on touch, the wheel, and the scrolling keys with the stage focused. No momentum and no rubber band. A drag does not select. -- **The foot** holds the figure's key at its real size, the key hint, and "View as list", which puts the list in the stage in - place of the drawing. +- **The foot** holds the figure's key at its real size, then one row: the zoom controls at the start, the key hint, and at the end "View + as list", which puts the list in the stage in place of the drawing, and after it the app's own actions (all but those marked + `inViewer: false`). The end group wraps and is never cut: it is at the row's end while it shares the row, and starts on the start edge + on a row of its own. An action pressed here is handed the viewer's drawing: the drawn layout at 100% whatever the zoom, with the list + open or closed. On a phone each row of actions takes 52px from the stage. - **Focus** opens on the stage (the flush field's inset ring). Esc always closes, and focus returns to "Expand". - **A trace works. Nothing else moves:** no entrance, flow, mover or run plays in the viewer, and the page's figure holds its loops while it is open. @@ -2005,12 +2019,15 @@ over its lifeline; a stacked chip draws the mark before the name. the reader's "Background graphics" setting (`print-color-adjust: exact`, with the `-webkit-` form). - Forced colours: cardinality marks follow their line; an activation's edge is `CanvasText`; a frame's edges are `GrayText`; a linked name is `LinkText`, underlined. -- Print: a figure prints untraced, in its resting ink, and in the light theme whatever the screen shows. +- Print: a figure prints untraced, in its resting ink, and in the light theme whatever the screen shows. The foot does not print: no + control is drawn on paper, and the list prints only where the reader opened it. - Right to left: the figure mirrors and its words do not, drawn and stacked (stacked, the rail and the trunk run down the right, a branch is indented from the right, and the end lines and the end gutter are on the left). Identifiers are isolated left to right as runs; named sides swap; the arrow keys stay physical; the text art stays left to right. - Export: a linked card's arrow is not drawn in a file. A PNG is drawn through an image, so under a content policy `img-src` must allow `blob:` or `data:`; where it allows neither, `diagramToPng` rejects with an error that says so and no file is made (the SVG needs neither). + The skill's "Download PNG" then says so in a note under the foot's buttons and is switched off; the console names the `img-src` to allow. + A figure that is not displayed cannot be measured: the promise rejects with an error that says so and no file is made. ### Diagram tokens diff --git a/packages/react/README.md b/packages/react/README.md index 098b9749..3135644a 100644 --- a/packages/react/README.md +++ b/packages/react/README.md @@ -296,7 +296,7 @@ None of these changes how anything looks: each is an existing look or rule, expo | `SkipLink` | The first thing on a page: a link past the bar and the navigation to the content. `` renders `Skip to content`; the words are `children`, so an app in another language replaces them, and any anchor prop passes through (`target` may carry its `#`). It is unseen until it has focus. With a sticky bar (`SiteHeader`, `AppHeader` or your own `.basalt-sticky-bar`) it then hangs under the bar, space-2 below its line, on the brand's start edge at every width, so it covers nothing in the bar; without one it sits at the page's top start (space-2 in). **How it finds the bar:** when it takes focus it reads the real bottom edge of the first element matching `.basalt-site-header, .basalt-app-header, .basalt-sticky-bar` and sits space-2 below it, and reads it again on scroll and resize while it holds focus, so a bar that is not at the top of the viewport (a notice above it) is still cleared; with no script or no bar it is where the stylesheet puts it, under a bar at the top. It floats like a tooltip (level 3, the rim, `shadow-overlay`, radius 8) on the toast layer; 44px tall on a coarse pointer; not drawn in print. It is the HTML skill's `.skip-link`, drawn with the same tokens. **The app places it itself, as the first element of the page** (before the bar, so it is the first tab stop): `AppShell` and `SiteHeader` render none. Give the target `tabIndex={-1}` so following the link moves focus to it (`AppShell`: `mainProps={{ id: "main", tabIndex: -1 }}`); a target that cannot take focus starts the next Tab there instead. | | `TimeChart`'s `lit`, `headline`, `headlineFormat`, `trend`, `plotSize`, `compact`, `lane`, `onDayActivate`, `activateHint`; `trailingMean(values, { window, min })` | The lit figure (DECISIONS 153; the implementation hasn't been reviewed). `lit`: solid marks take one vertical gradient in three neutral stops, a line one stroke in the top stop. `headline`: the frame with the picked day's number as the headline (one series), the unit beside it, one context line, no live region; its number is written in the chart's `locale` unless `headlineFormat` writes it. `trend`: `true` (7 days) or a window: the readings as small dots and their trailing mean as one straight line that breaks at a gap, one head dot, the number the trend. `plotSize="sm"` is the 96px plot. `compact` (with `kind="bar"` and `plotSize="sm"`) is the short bar plot (DECISIONS 160, the owner's choice for vote 10): no gridlines, no y labels, no gutter, the plot the figure's width; the legend, keys, table and caption stay; ignored for a line, a 240px plot or a second series. `lane` and `onDayActivate` are what `PhaseChart` is built from. `trailingMean` returns `Array` (no NaN for no data). | | `PhaseChart` | A trend over weeks with a lane of one choice a week (seven days a choice; lanes of other lengths are in the backlog) and the open week's plate: `name`, `values`, `calls` (`{ word, changed?, text }`), `week`, `onWeekChange`, plus the words, all required and each a whole string, since the chart ships no word for the period: `laneLabel` ("Choose a check-in"), `previousLabel` and `nextLabel` ("Previous check-in", "Next check-in"), `callName(index)` ("Check-in 31", "Nov 3 check-in"), `statusLine(index, call)` (what the status line says of the open choice) and `activateHint` ("opens its check-in", Enter's hint in the legend), plus a `TimeChart`'s `title`, `days`, `format`, `summary`. A press on a day, or Enter, opens its week; on a phone the lane is marks with previous and next controls. | -| `ArchitectureDiagram`, `FlowchartDiagram`, `DataFlowDiagram`, `SequenceDiagram`, `SchemaDiagram` | Diagrams (DECISIONS 281 and 282; the implementation hasn't been reviewed): boxes and the lines between them, monochrome, one focal node inverted, three lines named by their look (`main`, `plain`, `dashed`) whose meaning the `legend` gives. Each takes the figure's `title`, `heading`, `source`, required `summary` and `legend`, and its own data: `nodes` placed by `col` and `row` (an architecture's `groups`, a flowchart's `shape`, a data flow's `lanes`), `edges` by node id (`fromSide`/`toSide` only to change the derived side), a sequence's `participants` and `steps`, a schema's `tables` with `references: "table.column"` on a foreign key. The array's order is the stacked order, the focus order and the list's. The drawn layout is used only where it fits; otherwise the figure is stacked, at most 480 wide. One tab stop, arrow keys between nodes, a trace on hover or keyboard focus, and "View as list". Automatic layout (`layout="auto"`, DECISIONS 306, 1.8; foundations, "Automatic layout") leaves `col` and `row` out: elkjs gives each card a column and a row, and nothing else of elk's is read. Place at build time with `placeDiagram` from `@srasyndicate/basalt/diagram-layout` and pass `placement`, and elkjs never reaches the browser; without `placement` it is loaded on demand. | +| `ArchitectureDiagram`, `FlowchartDiagram`, `DataFlowDiagram`, `SequenceDiagram`, `SchemaDiagram` | Diagrams (DECISIONS 281 and 282; the implementation hasn't been reviewed): boxes and the lines between them, monochrome, one focal node inverted, three lines named by their look (`main`, `plain`, `dashed`) whose meaning the `legend` gives. Each takes the figure's `title`, `heading`, `source`, required `summary` and `legend`, and its own data: `nodes` placed by `col` and `row` (an architecture's `groups`, a flowchart's `shape`, a data flow's `lanes`), `edges` by node id (`fromSide`/`toSide` only to change the derived side), a sequence's `participants` and `steps`, a schema's `tables` with `references: "table.column"` on a foreign key. The array's order is the stacked order, the focus order and the list's. The drawn layout is used only where it fits; otherwise the figure is stacked, at most 480 wide. One tab stop, arrow keys between nodes, a trace on hover or keyboard focus, and "View as list". Automatic layout (`layout="auto"`, DECISIONS 306, 1.8; foundations, "Automatic layout") leaves `col` and `row` out: elkjs gives each card a column and a row, and nothing else of elk's is read. Place at build time with `placeDiagram` from `@srasyndicate/basalt/diagram-layout` and pass `placement`, and elkjs never reaches the browser; without `placement` it is loaded on demand. `actions` (`DiagramAction`: `label`, `onSelect`, and `id`, `disabled`, `inViewer`) are the app's own words-only buttons in the foot, after Basalt's controls and before "Clear highlight", in the order given, three at most by intent; each is busy on its own while its promise is answered, and `onSelect` is handed the figure it was pressed in (`figure`, `viewer`, `layout`). Their code loads only for a figure that has some. They follow the figure into the viewer's foot after "View as list": on a phone each row of actions takes 52px from the stage, and `inViewer: false` leaves one out. | | `ChartGroup` | Charts stacked in one figure (`label` names it): the y gutter and the right margin are as wide as the widest chart's, so every plot starts and ends at the same x. Put the charts inside; each keeps its own title, legend, summary and table. | | `ShareBar`, `shareOf(values)` | Parts of a whole as one bar: `parts` (`{ name, value }`), `size="sm"` (8px) or `"md"` (12px), `format(share, part)`. One ink, a 4px gap, each part's share (whole percents that add to 100) and name under it; a part that is more than nothing and rounds to 0 reads "<1%" (spoken "less than 1%"), and a part of nothing is left out. | | `CoverageStrip`, `coverageWords(days)` | One cell a day (`{ date, recorded, why }`): `form="strip"` (slivers, 48px) or `"week"` (seven squares); the missing dates in words, built from the cells. | diff --git a/packages/react/build.mjs b/packages/react/build.mjs index 38dfe52c..e4ac05bb 100644 --- a/packages/react/build.mjs +++ b/packages/react/build.mjs @@ -263,7 +263,7 @@ await esbuild.build({ ...fs.readdirSync(path.join(here, "src", "tooling")).filter((f) => /\.ts$/.test(f)).map((f) => path.join(here, "src", "tooling", f)), ], define: { __PHOSPHOR_NOTICE__: JSON.stringify(phosphorNotice), __BASALT_ROOT_MAP__: JSON.stringify(JSON.stringify(rootMap)) }, - plugins: [{ name: "lazy-modules", setup(build) { build.onResolve({ filter: /^\.\/(command-panel|glyph-flight|diagram-motion|diagram-viewer|diagram-layout|diagram-text|diagram-elk|release-sources|rail-tooltip)$/ }, (args) => (args.kind === "dynamic-import" ? { path: `${args.path}.js`, external: true } : undefined)); } }], + plugins: [{ name: "lazy-modules", setup(build) { build.onResolve({ filter: /^\.\/(command-panel|glyph-flight|diagram-motion|diagram-viewer|diagram-layout|diagram-text|diagram-actions|diagram-elk|release-sources|rail-tooltip)$/ }, (args) => (args.kind === "dynamic-import" ? { path: `${args.path}.js`, external: true } : undefined)); } }], outdir: dist, bundle: true, splitting: true, diff --git a/packages/react/src/architecture-diagram.tsx b/packages/react/src/architecture-diagram.tsx index 201a7f72..49dbfa32 100644 --- a/packages/react/src/architecture-diagram.tsx +++ b/packages/react/src/architecture-diagram.tsx @@ -5,7 +5,7 @@ import type { DiagramFigureProps } from "./diagram-figure"; import type { ArchitectureNode, DiagramFlowEdge, DiagramGroup, DiagramPacket, DiagramPlacement, DiagramUnplaced } from "./diagram-core"; export type { ArchitectureNode, DiagramEdge, DiagramFlowEdge, DiagramGroup, DiagramLegend, DiagramLineKind, DiagramMark, DiagramMotion, DiagramNode, DiagramPacket, DiagramPlacement, DiagramSide, DiagramUnplaced } from "./diagram-core"; -export type { DiagramFigureProps, DiagramLayoutInfo } from "./diagram-figure"; +export type { DiagramAction, DiagramActionContext, DiagramFigureProps, DiagramLayoutInfo } from "./diagram-figure"; interface ArchitectureDiagramBase extends DiagramFigureProps { /** The parts, in the author's order: the stacked order, the focus order and the list's. `col` and `row` place each in the drawn layout. */ diff --git a/packages/react/src/data-flow-diagram.tsx b/packages/react/src/data-flow-diagram.tsx index 166d9ecd..4468eb0b 100644 --- a/packages/react/src/data-flow-diagram.tsx +++ b/packages/react/src/data-flow-diagram.tsx @@ -5,6 +5,7 @@ import type { DiagramFigureProps } from "./diagram-figure"; import type { DataFlowLane, DataFlowNode, DiagramFlowEdge, DiagramPacket } from "./diagram-core"; export type { DataFlowLane, DataFlowNode, DiagramEdge, DiagramLegend, DiagramLineKind, DiagramSide } from "./diagram-core"; +export type { DiagramAction, DiagramActionContext } from "./diagram-figure"; export interface DataFlowDiagramProps extends DiagramFigureProps { /** The lanes, top to bottom: a node's row is its lane's place here. */ diff --git a/packages/react/src/diagram-actions.tsx b/packages/react/src/diagram-actions.tsx new file mode 100644 index 00000000..39e52d05 --- /dev/null +++ b/packages/react/src/diagram-actions.tsx @@ -0,0 +1,74 @@ +import * as React from "react"; + +import { Button } from "./button"; +import type { DiagramAction, DiagramActionContext } from "./diagram-figure"; + +// An app's own actions in a diagram's foot (the foot decision, diagrams-cimip): Basalt's Button, secondary and small, words only, in the order given, +// after Basalt's own controls and before "Clear highlight", and again in the viewer's foot after "View as list". A module of its own, not exported from +// the package: a figure imports it on demand, only when `actions` has an entry, and hands it to the viewer as a prop, so neither the figure's chunk nor +// the viewer's grows for a figure with none. Each button is busy on its own (Button's server rule); Basalt announces nothing on a press. + +declare const process: { env: { NODE_ENV?: string } }; + +export interface DiagramActionsProps { + actions: readonly DiagramAction[]; + /** Where they are drawn: the page's foot (false), or the viewer's, which leaves out an action with `inViewer: false`. */ + viewer: boolean; + /** What a press is handed, read at the press. */ + context: () => DiagramActionContext; + /** Called before `onSelect`: the page's figure settles a running entrance, as for any of its controls. */ + onPress?: () => void; + /** The diagram's name, for the development warnings. */ + component: string; +} + +let warned: Set | undefined; +function warnOnce(message: string, error?: boolean) { + warned ??= new Set(); + if (warned.has(message)) return; + warned.add(message); + if (error) console.error(message); + else console.warn(message); +} + +export function DiagramActions({ actions, viewer, context, onPress, component }: DiagramActionsProps) { + const seen = new Set(); + // Development only, and once: the page's foot says it, so the viewer's copy of the same list is not a second warning. + if (process.env.NODE_ENV !== "production" && !viewer) { + if (actions.length > 3) warnOnce(`Basalt ${component}: ${actions.length} actions in the foot; three at most, by intent (a foot is not a toolbar). They are drawn as written`); + for (const a of actions) { + if (!a.label) warnOnce(`Basalt ${component}: an action has no label, so it is not drawn`, true); + else if (a.label.length > 24) warnOnce(`Basalt ${component}: the action "${a.label}" is past 24 characters; a label in the foot is short. It is drawn as written`); + } + } + return ( + <> + {actions.map((action, at) => { + if (!action.label || (viewer && action.inViewer === false)) return null; + let key = action.id ?? action.label; + if (seen.has(key)) { + if (process.env.NODE_ENV !== "production" && !viewer) warnOnce(`Basalt ${component}: two actions are keyed "${key}"; give each its own id. The later one is keyed by its place`); + key = `${key}\u0000${at}`; + } + seen.add(key); + return ( + + ); + })} + + ); +} diff --git a/packages/react/src/diagram-core.ts b/packages/react/src/diagram-core.ts index 3e1aaee3..5f015358 100644 --- a/packages/react/src/diagram-core.ts +++ b/packages/react/src/diagram-core.ts @@ -848,6 +848,9 @@ export interface Dyn { pad?: boolean; /** A schema's rows with its corridors (DECISIONS 306, 1.1): a grid-template-rows of spacer tracks round the author's rows, set only where a far key is drawn. */ rows?: string; + /** A drawn layout of one column (the one-column ruling, diagrams-cimip): its column's least width, in px. The stylesheet caps the drawing at + * size-breakpoint-container, or at this where it is more, so the cap never takes the track under its minimum. */ + one?: number; } export interface TreeIds { base: string } @@ -1548,6 +1551,7 @@ export function figureTree(m: Model, dyn: Dyn, o: FigureOptions): VElement { style.push(m.rtl ? `--_gpad:0px 0px 0px ${room}` : `--_gpad:0px ${room} 0px 0px`); } if (m.type === "schema" && dyn.track) style.push(`--_track:${dyn.track}px`); + if (drawn && dyn.one) style.push(`--_one:${dyn.one}px`); return h("figure", { class: o.className ? `${P} ${o.className}` : P, "aria-labelledby": ids.title, @@ -1796,7 +1800,8 @@ function minimums(m: Model, tk: Tokens, measure: ReturnType) { // 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"); - return { track, table, least: Math.max(tk.wide, least) }; + // `own` is the least width the tracks themselves take, before the drawn layout's floor: for one column, the column's (the one-column ruling). + return { track, table, least: Math.max(tk.wide, least), own: Math.ceil(least) }; } // ---- Snapping: a 1px line on half pixels, a 2px line on whole ones, in the page's own pixel grid ---- @@ -3047,7 +3052,8 @@ export function measureFigure(fig: HTMLElement, m: Model, P: string, base: strin if (m.text) return { dyn: { ...current, layout: "stacked", bare: undefined }, geo: null, ink: "", tokens: tk, least: mins.least }; if (W >= mins.least && !m.unplaced) { const drawnTry = (pad: boolean) => { - let dd = stopOf({ ...current, ...closed, layout: "drawn", grow: undefined, track: undefined, bare: undefined, pad: pad || undefined, rows: undefined }); + // One column (not a sequence's participants) is capped before it is measured (the one-column ruling): its least width is written with the layout. + let dd = stopOf({ ...current, ...closed, layout: "drawn", grow: undefined, track: undefined, bare: undefined, pad: pad || undefined, rows: undefined, one: m.type !== "sequence" && columnCount(m) === 1 ? mins.own : undefined }); dd = heightsFor(dd); apply(dd); let g = drawnGeometry(input(), measure); @@ -3079,7 +3085,7 @@ export function measureFigure(fig: HTMLElement, m: Model, P: string, base: strin 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}` : `"${said(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, rows: undefined }); + let d = stopOf({ ...current, ...closed, layout: "stacked", heights: undefined, grow: record(), track: m.type === "schema" ? mins.table : undefined, bare: undefined, pad: undefined, rows: undefined, one: undefined }); d = heightsFor(d); apply(d); if (m.type === "sequence" || m.type === "schema") return { dyn: d, geo: null, ink: "", tokens: tk, least: mins.least }; @@ -3237,7 +3243,7 @@ export function keyTarget(m: Model, from: string, key: string, drawn = false, rt const MANAGED = ["data-layout", "data-measured", "role", "aria-roledescription", "aria-labelledby", "aria-describedby", "aria-label", "tabindex", "data-stops", "hidden", "data-art"]; // The figure's grid attributes follow the model too: an automatic figure's direction can change its columns after script (Neon's B8 of the code review). const ROOT_MANAGED = ["data-layout", "data-measured", "data-bare", "data-motion", "data-first-visit", "data-rtl", "data-cols", "data-reach", "data-gutter", "data-marks"]; -const MANAGED_STYLE = ["--_track", "--_h", "--_ww", "--_gap", "--_ggrow", "--_tl", "--_gpad", "--_gw", "--_mh", "--_rows", "--_row-gap"]; +const MANAGED_STYLE = ["--_track", "--_h", "--_ww", "--_gap", "--_ggrow", "--_tl", "--_gpad", "--_gw", "--_mh", "--_rows", "--_row-gap", "--_one"]; 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-export.ts b/packages/react/src/diagram-export.ts index d9865b54..4df38f1b 100644 --- a/packages/react/src/diagram-export.ts +++ b/packages/react/src/diagram-export.ts @@ -174,7 +174,7 @@ const summaryOf = (fig: HTMLElement) => fig.querySelector("figcaption")?.textCon /** The file's name: the title's slug. */ export const exportName = (fig: HTMLElement, ext: string) => `${(titleOf(fig).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "diagram")}.${ext}`; -async function svgText(fig: HTMLElement, options: DiagramExportOptions, embed: boolean): Promise<{ svg: string; w: number; h: number }> { +async function svgText(fig: HTMLElement, options: DiagramExportOptions, embed: boolean, who: string): Promise<{ svg: string; w: number; h: number }> { const theme = options.theme ?? "page"; const had = fig.getAttribute("data-theme"); // A file is at rest: no trace, no pending or running entrance, no mover, no quiet run (Neon's B5 of the code review). The figure is shown so for the read @@ -199,6 +199,11 @@ async function svgText(fig: HTMLElement, options: DiagramExportOptions, embed: b const m = /^matrix\(([^,]+),[^,]+,[^,]+,([^,]+),/.exec(t); if (m && (Math.abs(Number(m[1]) - 1) > 1e-6 || Math.abs(Number(m[2]) - 1) > 1e-6)) { scaled.push([el, el.style.transform]); el.style.transform = "none"; } } + // The viewer's drawing with its list open (the foot decision, 2.2): its sizer is hidden, so it is shown for the read and hidden again before anything + // waits, with no paint between. + const sizer = fig.closest(".basalt-diagram-sizer, .diagram-sizer"); + const unhid = sizer?.hidden ? sizer : null; + if (unhid) unhid.hidden = false; if (theme !== "page") fig.setAttribute("data-theme", theme); fig.classList.add("basalt-exporting"); let read: { body: string[]; w: number; h: number; ground: string }; @@ -206,6 +211,8 @@ async function svgText(fig: HTMLElement, options: DiagramExportOptions, embed: b void fig.offsetWidth; const pad = Number.parseFloat(getComputedStyle(fig).getPropertyValue("--basalt-space-4")) || 16; const parts = partsOf(fig); + // A figure with no box (it or a parent is display: none, an app's closed tab) cannot be measured: no file, never a broken one. + if (!fig.getClientRects().length || !parts.length) throw new Error(`Basalt ${who}: the figure is not displayed (it or a parent is display: none), so it cannot be measured and no file is made`); const rects = parts.map((p) => p.getBoundingClientRect()); const left = Math.min(...rects.map((r) => r.left)), top = Math.min(...rects.map((r) => r.top)); const right = Math.max(...rects.map((r) => r.right)), bottom = Math.max(...rects.map((r) => r.bottom)); @@ -218,6 +225,7 @@ async function svgText(fig: HTMLElement, options: DiagramExportOptions, embed: b read = { body, w, h, ground }; } finally { fig.classList.remove("basalt-exporting"); + if (unhid) unhid.hidden = true; if (theme !== "page") { if (had === null) fig.removeAttribute("data-theme"); else fig.setAttribute("data-theme", had); } for (const [el, t] of scaled) el.style.transform = t; if (viewer !== null) fig.setAttribute("data-viewer", viewer); @@ -243,9 +251,9 @@ async function svgText(fig: HTMLElement, options: DiagramExportOptions, embed: b declare const process: { env: { NODE_ENV?: string } }; -/** The figure as an SVG file: native SVG, its words as text, the faces embedded by default. */ +/** The figure as an SVG file: native SVG, its words as text, the faces embedded by default. A figure that is not displayed rejects, and no file is made. */ export async function diagramToSvg(figure: HTMLElement, options: DiagramExportOptions = {}): Promise { - const { svg } = await svgText(figure, options, (options.fonts ?? "embed") === "embed"); + const { svg } = await svgText(figure, options, (options.fonts ?? "embed") === "embed", "diagramToSvg"); return new Blob([svg], { type: "image/svg+xml" }); } @@ -273,17 +281,20 @@ async function drawable(svg: string): Promise<{ source: CanvasImageSource; done: return { source: img, done }; } catch { done(); } } - throw new Error("Basalt diagramToPng: the PNG could not be drawn. A canvas draws the figure's SVG through an image, and this page refused it both as a blob: URL and as a data: URL: a content policy allows them with `img-src 'self' blob:` (or `data:`). diagramToSvg needs neither"); + // Named, so a caller can tell the page's policy from any other failure without reading the words (the skill's note, diagrams-cimip ruling 2). + throw Object.assign(new Error("Basalt diagramToPng: the PNG could not be drawn. A canvas draws the figure's SVG through an image, and this page refused it both as a blob: URL and as a data: URL: a content policy allows them with `img-src 'self' blob:` (or `data:`). diagramToSvg needs neither"), { name: "DiagramPolicyError" }); } /** * The figure as a PNG file, at `scale` (2 by default), always drawn with the faces embedded. * * A canvas draws SVG only through an image: under a `Content-Security-Policy`, `img-src` must allow `blob:` or `data:` (where the browser decodes an SVG - * Blob with `createImageBitmap`, neither is needed). Where the page allows neither, the promise rejects with an error that says so, and no file is made. + * Blob with `createImageBitmap`, neither is needed). Where the page allows neither, the promise rejects with an error that says so (its `name` is + * "DiagramPolicyError"), and no file is made. + * A figure that is not displayed rejects too, and no file is made. */ export async function diagramToPng(figure: HTMLElement, options: DiagramExportOptions = {}): Promise { - const { svg, w, h } = await svgText(figure, options, true); + const { svg, w, h } = await svgText(figure, options, true, "diagramToPng"); const scale = options.scale ?? 2; const { source, done } = await drawable(svg); try { diff --git a/packages/react/src/diagram-figure.tsx b/packages/react/src/diagram-figure.tsx index 4032ffd8..dcfc28cb 100644 --- a/packages/react/src/diagram-figure.tsx +++ b/packages/react/src/diagram-figure.tsx @@ -29,6 +29,11 @@ let viewerLoading: Promise | undefined; /** The viewer (DECISIONS 310, 9.13): a module of its own, with the Dialog it needs, loaded at the Expand button's first hover, focus or touch. */ const loadViewer = () => (viewerLoading ??= import("./diagram-viewer").catch((error) => { viewerLoading = undefined; throw error; })); +type ActionsModule = typeof import("./diagram-actions"); +let actionsLoading: Promise | undefined; +/** An app's own actions (`actions`): a module of its own, with Button, loaded only by a figure that has some. */ +const loadActions = () => (actionsLoading ??= import("./diagram-actions").catch((error) => { actionsLoading = undefined; throw error; })); + // The figure every diagram shares (DECISIONS 281): the title, the drawing, the key, the key hint, the required summary and "View as list". // Not exported from the package: each of the five diagrams is its own module on top of it. The markup is the engine's tree, so it is the // HTML skill's markup too; the drawing is measured before the first paint and again when the figure's width changes or its fonts arrive. @@ -63,6 +68,35 @@ export interface DiagramFigureProps extends Omit, * `exportMeasuredDiagram(laid.spec, laid.geo, "drawio", { extras: readMeasuredExtras(laid.figure) })`. It draws nothing. */ onLayout?: (laid: DiagramLayoutInfo) => void; + /** + * The app's own actions, in the foot after Basalt's controls and before "Clear highlight", and in the viewer's foot after "View as list". Words-only + * secondary buttons, in the order given, three at most by intent. They exist once script runs, and their code loads only for a figure that has some. + */ + actions?: readonly DiagramAction[]; +} + +/** One of the app's own actions in a diagram's foot. */ +export interface DiagramAction { + /** The words on the button. Words only. */ + label: string; + /** Names the action across renders (the React key). The label by default; give one if the label can change, so the button and its focus are kept. */ + id?: string; + /** Pressed, with the figure it was pressed in. A returned promise keeps this button busy until it settles (the server rule); a rejection ends it and is raised again. */ + onSelect: (context: DiagramActionContext) => void | PromiseLike; + /** `true` keeps it in its seat, disabled, and still a focus stop. Default `false`. */ + disabled?: boolean; + /** `false` leaves it out of the viewer's foot. Default `true`. */ + inViewer?: boolean; +} + +/** What an action is handed: the figure it was pressed in. */ +export interface DiagramActionContext { + /** The figure element: the page's, or the viewer's drawing. What `diagramToSvg` and `diagramToPng` take. */ + readonly figure: HTMLElement; + /** Whether it was pressed in the viewer. */ + readonly viewer: boolean; + /** That figure's layout as `onLayout` reports it (what `exportMeasuredDiagram` takes); `null` where it has no measured geometry. */ + readonly layout: DiagramLayoutInfo | null; } /** A figure's layout as it is on screen (`onLayout`). */ @@ -141,6 +175,8 @@ export interface DiagramViewerMode { onMeasured: (measured: Measured, fig: HTMLElement) => void; /** A text sequence (9.3): the figure's width at which the art's widest line just fits; the viewer lays it out at that width. */ textWidth?: (need: number) => void; + /** After every layout with geometry: the figure's layout, as `onLayout` would report it, for an app's action pressed in the viewer. */ + laid?: (info: DiagramLayoutInfo) => void; } export interface DiagramFigureInternalProps extends DiagramFigureProps { @@ -150,7 +186,7 @@ export interface DiagramFigureInternalProps extends DiagramFigureProps { viewer?: DiagramViewerMode; } -export function DiagramFigure({ spec, component, viewer, zoom = true, onLayout, entrance: _entrance, title: _title, heading: _heading, legend: _legend, motion: _motion, source, summary, className, style, onKeyDown, onFocus, onBlur, onPointerOver, onPointerLeave, ref: callerRef, ...props }: DiagramFigureInternalProps) { +export function DiagramFigure({ spec, component, viewer, zoom = true, onLayout, actions, entrance: _entrance, title: _title, heading: _heading, legend: _legend, motion: _motion, source, summary, className, style, onKeyDown, onFocus, onBlur, onPointerOver, onPointerLeave, ref: callerRef, ...props }: DiagramFigureInternalProps) { const base = `dg${React.useId().replace(/[^a-zA-Z0-9_-]/g, "")}`; const level = usePanelLevel(); // The key hint is a data-kbd-hint legend, hidden on touch until a hardware key is pressed: this installs the listener that reveals it. @@ -237,6 +273,14 @@ export function DiagramFigure({ spec, component, viewer, zoom = true, onLayout, if (process.env.NODE_ENV !== "production" && model.motion.firstVisit && !props.id) errorOnce('entrance="first-visit" needs an id: without one the entrance plays on every visit'); }, [model, component, props.id]); + // The figure's layout as onLayout reports it, from the last measure; null before one, or with no geometry. Everything it reads is in measure's deps. + const layoutInfo = (): DiagramLayoutInfo | null => { + const fig = figRef.current, m = measured.current; + if (!fig || !m?.geo) return null; + const placed = auto ? placementFor(dirAt) : undefined; + return { spec: placed ? { ...spec, placement: placed } : spec, geo: m.geo, layout: m.dyn.layout === "drawn" ? "drawn" : "stacked", figure: fig }; + }; + const measure = React.useCallback(() => { const fig = figRef.current; if (!fig) return; @@ -294,8 +338,9 @@ export function DiagramFigure({ spec, component, viewer, zoom = true, onLayout, const trial = buildModel(spec, { rtl, placement: place }); const t = viewer.measure(fig, trial, P, base, {}, (d) => syncAttributes(fig, figureTree(trial, d, options))); if (t.dyn.layout !== "drawn") continue; - // Fit as the viewer takes it (whole per cents, 200% at most), so two directions that both fit at 200% tie and the type's own stays. - const fit = Math.min(2, Math.floor(Math.min(room.w / fig.offsetWidth, room.h / fig.offsetHeight) * 100 + 1e-6) / 100); + // Fit as the viewer takes it (whole per cents, 200% at most, of the drawing's own box: the one-column ruling), so two directions that both fit at 200% + // tie and the type's own stays. + const fit = Math.min(2, Math.floor(Math.min(room.w / (fig.querySelector(`.${P}-drawing`)?.offsetWidth || fig.offsetWidth), room.h / fig.offsetHeight) * 100 + 1e-6) / 100); if (fit > best + 1e-6) { best = fit; pick = k; } } if (pick !== dirAt) { setDirAt(pick); return; } @@ -336,10 +381,11 @@ export function DiagramFigure({ spec, component, viewer, zoom = true, onLayout, const key = `${result.dyn.layout ?? "stacked"}|${JSON.stringify(result.geo)}`; if (laidOut.current?.key !== key || laidOut.current.spec !== spec) { laidOut.current = { key, spec }; - const placed = auto ? placementFor(dirAt) : undefined; - told({ spec: placed ? { ...spec, placement: placed } : spec, geo: result.geo, layout: result.dyn.layout === "drawn" ? "drawn" : "stacked", figure: fig }); + told(layoutInfo()!); } } + // The viewer's figure tells the viewer, for an app's action pressed there (onLayout is the page's figure's alone). + if (viewer?.laid && result.geo) viewer.laid(layoutInfo()!); // The same layout is the same state: a measure that changes nothing renders nothing. // (A layout is plain data that the engine builds in one order, so its text is a fair test.) if (JSON.stringify(dynRef.current) !== JSON.stringify(result.dyn)) { dynRef.current = result.dyn; setDyn(result.dyn); } @@ -461,6 +507,18 @@ export function DiagramFigure({ spec, component, viewer, zoom = true, onLayout, void fetchViewer().then((mod) => { setOpening(false); if (mod) setViewerOpen(true); }); }; const closeViewer = React.useCallback(() => setViewerOpen(false), []); + // An app's own actions: their module loads once script runs, only for a figure that has some; until it arrives, and if it cannot, none is drawn. + const hasActions = !viewer && Boolean(actions?.length); + const [actionsModule, setActionsModule] = React.useState(null); + React.useEffect(() => { + if (!hasActions) return undefined; + let live = true; + loadActions().then((mod) => { if (live) setActionsModule(() => mod); }, (error: unknown) => { + if (process.env.NODE_ENV !== "production") warnOnce(component, `the actions could not load (${String(error)})`); + }); + return () => { live = false; }; + }, [hasActions, component]); + const Actions = hasActions ? actionsModule?.DiagramActions : undefined; React.useLayoutEffect(() => { const fig = figRef.current; if (!fig || viewer) return; @@ -556,7 +614,8 @@ export function DiagramFigure({ spec, component, viewer, zoom = true, onLayout, const inkProp = model.text && !dyn.art ? null : inkHtml; // The viewer's figure shows its drawing alone: its head, key, hint and foot are the dialog's. if (viewer) return toReact(tree, { source, summary, hint: null, toggle: null }, inkProp, root) as React.ReactElement; - // The foot (1.9, and DECISIONS 310, 9.1): "View as list", "Expand", then the run button and "Pause animations", which the motion module draws when it has loaded. + // The foot (1.9, and DECISIONS 310, 9.1): "View as list", "Expand", then the run button and "Pause animations", which the motion module draws when it has loaded, + // then an app's own actions and "Clear highlight". const Foot = motionModule?.MotionFoot; const expand = zoom && scripted ? ( <> @@ -580,7 +639,7 @@ export function DiagramFigure({ spec, component, viewer, zoom = true, onLayout, {opening ? : null} {viewerOpen && viewerModule ? ( - + ) : null} ) : null; @@ -591,6 +650,8 @@ export function DiagramFigure({ spec, component, viewer, zoom = true, onLayout, Clear highlight ) : null; - const foot = <>{toggle}{expand}{Foot && controller ? : null}{clear}; + // An app's actions (the foot decision): after Basalt's own controls and before "Clear highlight". A press settles a running entrance before onSelect. + const own = Actions && actions ? ({ figure: figRef.current!, viewer: false, layout: layoutInfo() })} /> : null; + const foot = <>{toggle}{expand}{Foot && controller ? : null}{own}{clear}; return toReact(tree, { source, summary, hint, toggle: foot }, inkProp, root) as React.ReactElement; } diff --git a/packages/react/src/diagram-viewer.tsx b/packages/react/src/diagram-viewer.tsx index 7e129565..3e7c8bb3 100644 --- a/packages/react/src/diagram-viewer.tsx +++ b/packages/react/src/diagram-viewer.tsx @@ -1,9 +1,10 @@ import * as React from "react"; import { Button, IconButton } from "./button"; -import type { DiagramFigureInternalProps, DiagramViewerMode } from "./diagram-figure"; +import type { DiagramActions } from "./diagram-actions"; +import type { DiagramAction, DiagramFigureInternalProps, DiagramLayoutInfo, DiagramViewerMode } from "./diagram-figure"; import type { buildModel, DiagramSpec, figureKey, figureList, hintEntries, Measured, measureFigure, Model, toHtml } from "./diagram-core"; -import { attachZoom, measureViewerFigure, revealIn, VIEWER_KEYS, viewerHint, viewerTextWidth } from "./diagram-zoom-core"; +import { attachZoom, drawnSize, measureViewerFigure, revealIn, VIEWER_KEYS, viewerHint, viewerTextWidth } from "./diagram-zoom-core"; import type { ViewerMemo, ZoomController, ZoomState } from "./diagram-zoom-core"; import { createPortal } from "react-dom"; @@ -39,6 +40,10 @@ export interface ViewerKit { export interface DiagramViewerProps { kit: ViewerKit; + /** An app's own actions, after "View as list" (all but those marked `inViewer: false`). */ + actions?: readonly DiagramAction[]; + /** Their component, loaded by the figure (diagram-actions.tsx): the viewer imports nothing for them. */ + Actions?: typeof DiagramActions; spec: DiagramSpec; component: string; source?: React.ReactNode; @@ -53,7 +58,7 @@ const EMPTY: ZoomState = { zoom: 1, level: 100, fit: 1, min: 1, max: 4, atMin: f /** A length token's value in CSS pixels, read from a probe the stage holds. */ const probeWidth = (stage: HTMLElement | null, which: string) => stage?.querySelector(`.${P}-probe[data-probe="${which}"]`)?.offsetWidth ?? 0; -export function DiagramViewer({ kit, spec, component, source, summary, opener, onClose }: DiagramViewerProps) { +export function DiagramViewer({ kit, actions, Actions, spec, component, source, summary, opener, onClose }: DiagramViewerProps) { const { Figure: DiagramFigure, Kbd, buildModel, figureKey, figureList, hintEntries, toHtml, inLevel, measureFigure } = kit; // The viewer's figure is still (9.7): no entrance, flow, mover or run, so no motion code is loaded for it. const still = React.useMemo(() => ({ ...spec, motion: "still" }), [spec]); @@ -103,11 +108,14 @@ export function DiagramViewer({ kit, spec, component, source, summary, opener, o return () => { z.destroy(); zoomRef.current = null; observer.disconnect(); stage.removeEventListener("focusin", onFocusIn); }; }, [stageNode, readStage]); - // After each layout the zoom learns the drawing's size at 100%: the figure's own box, read with the zoom taken off (offsetWidth ignores the transform). + // After each layout the zoom learns the drawing's size at 100%: the drawing's own box, read with the zoom taken off (offsetWidth ignores the transform). const onMeasured = React.useCallback((measured: Measured, fig: HTMLElement) => { setLayout({ layout: measured.dyn.layout, bare: measured.dyn.bare, open: measured.dyn.open }); - zoomRef.current?.size(fig.offsetWidth, fig.offsetHeight); + zoomRef.current?.size(...drawnSize(fig)); }, []); + // The drawing's layout, for an app's action pressed here: the viewer's figure reports it after every layout. + const laidRef = React.useRef(null); + const laid = React.useCallback((info: DiagramLayoutInfo) => { laidRef.current = info; }, []); const memo = React.useRef({}); // The figure is laid out as the dialog opens, through its scale from .98; once the entrance has ended it is laid out again, unscaled, so its lines // snap on the pixel grid they are drawn on. @@ -123,10 +131,11 @@ export function DiagramViewer({ kit, spec, component, source, summary, opener, o return { w: (stage?.clientWidth ?? 0) - 2 * pad, h: (stage?.clientHeight ?? 0) - 2 * pad }; }, onMeasured, + laid, measure: (fig, m, p, base, current, apply, warn) => measureViewerFigure(fig, m, p, base, current, apply, warn, { layer, avail, row: dims.row, contain: dims.contain, memo: memo.current, measureFigure }), textWidth: (need) => viewerTextWidth({ layer, avail, row: dims.row, contain: dims.contain, memo: memo.current, measureFigure }, need), }; - }, [avail, dims, onMeasured, measureFigure, settled]); + }, [avail, dims, onMeasured, laid, measureFigure, settled]); // A stack with no lines has its list open, as on the page (9.3). const showList = listOpen || Boolean(layout.bare); @@ -210,7 +219,7 @@ export function DiagramViewer({ kit, spec, component, source, summary, opener, o