agentic-mermaid 0.5.3 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/Instructions_for_agents.md +1 -1
  3. package/README.md +1 -1
  4. package/dist/agent-core.d.ts +7 -7
  5. package/dist/agent-core.js +1 -1
  6. package/dist/agent.d.ts +7 -7
  7. package/dist/agent.js +1 -1
  8. package/dist/agentic-mermaid-mcp.js +1 -1
  9. package/dist/am.js +1 -1
  10. package/dist/browser-lazy/chunks/{agentic-producer-core-CC6OOLDW.js → agentic-producer-core-CWRJNRIK.js} +1 -1
  11. package/dist/browser-lazy/chunks/{architecture-QUFVKYJR.js → architecture-VU5WEHCH.js} +6 -6
  12. package/dist/browser-lazy/chunks/{block-6J3Q63BO.js → block-Z2DOU2NP.js} +5 -5
  13. package/dist/browser-lazy/chunks/{builtin-backends-7SOZZHPF.js → builtin-backends-6UTVDXF4.js} +6 -6
  14. package/dist/browser-lazy/chunks/c4-6FTCDDGS.js +10 -0
  15. package/dist/browser-lazy/chunks/{chunk-TYZOZXUJ.js → chunk-37ORXEBA.js} +6 -6
  16. package/dist/browser-lazy/chunks/{chunk-2UIA2IME.js → chunk-3VXXFUXR.js} +1 -1
  17. package/dist/browser-lazy/chunks/{chunk-2SH76OTH.js → chunk-6RXXXV66.js} +1 -1
  18. package/dist/browser-lazy/chunks/chunk-AVGL6Y22.js +1 -0
  19. package/dist/browser-lazy/chunks/chunk-BCPZYXNZ.js +20 -0
  20. package/dist/browser-lazy/chunks/chunk-CPO5P4L2.js +1 -0
  21. package/dist/browser-lazy/chunks/{chunk-OZ443IVJ.js → chunk-CURBYGWU.js} +8 -8
  22. package/dist/browser-lazy/chunks/{chunk-2GPK4VFF.js → chunk-DS3L2TY6.js} +1 -1
  23. package/dist/browser-lazy/chunks/{chunk-BU5LHXNJ.js → chunk-EBJK4IHL.js} +3 -3
  24. package/dist/browser-lazy/chunks/{chunk-AMJLVPUB.js → chunk-FCXWXIUB.js} +3 -3
  25. package/dist/browser-lazy/chunks/chunk-FNGOGVYM.js +6 -0
  26. package/dist/browser-lazy/chunks/{chunk-5B2Z7575.js → chunk-K6V5KN7D.js} +1 -1
  27. package/dist/browser-lazy/chunks/{chunk-J7FFAFQF.js → chunk-LRN76QCY.js} +1 -1
  28. package/dist/browser-lazy/chunks/chunk-NIAOQ3V2.js +1 -0
  29. package/dist/browser-lazy/chunks/{chunk-E2WMJZNM.js → chunk-OF4QKIRV.js} +1 -1
  30. package/dist/browser-lazy/chunks/{chunk-CN7WTBWB.js → chunk-OLZVJBI5.js} +1 -1
  31. package/dist/browser-lazy/chunks/{chunk-QA6GJQ4X.js → chunk-PRBLS664.js} +1 -1
  32. package/dist/browser-lazy/chunks/{chunk-X2UYKWKM.js → chunk-PRXEMB2V.js} +3 -3
  33. package/dist/browser-lazy/chunks/{chunk-NO7ZIVRU.js → chunk-Q6FTXOZS.js} +1 -1
  34. package/dist/browser-lazy/chunks/{chunk-PQGPS2YV.js → chunk-QRPOIILY.js} +1 -1
  35. package/dist/browser-lazy/chunks/{chunk-YCEICNM6.js → chunk-TG7JY42H.js} +1 -1
  36. package/dist/browser-lazy/chunks/{chunk-UL6NDWLL.js → chunk-TWYX5NPD.js} +1 -1
  37. package/dist/browser-lazy/chunks/{chunk-BY2CPG6B.js → chunk-TZMTDADJ.js} +1 -1
  38. package/dist/browser-lazy/chunks/chunk-UG33LVTQ.js +1 -0
  39. package/dist/browser-lazy/chunks/{chunk-HLWUNUCM.js → chunk-UJLLOK3R.js} +1 -1
  40. package/dist/browser-lazy/chunks/{chunk-SZELX2EJ.js → chunk-UKIYI4IO.js} +1 -1
  41. package/dist/browser-lazy/chunks/{chunk-VWVZGQE2.js → chunk-UOXZICCT.js} +1 -1
  42. package/dist/browser-lazy/chunks/{chunk-5X6MJX3H.js → chunk-VRXTQTLX.js} +1 -1
  43. package/dist/browser-lazy/chunks/{chunk-DF6765YX.js → chunk-WSZXZ4HF.js} +6 -6
  44. package/dist/browser-lazy/chunks/chunk-XBLK7VXJ.js +20 -0
  45. package/dist/browser-lazy/chunks/{chunk-ICC7HBJX.js → chunk-XJVCY4DA.js} +1 -1
  46. package/dist/browser-lazy/chunks/{class-5QA4SCTS.js → class-B7ED4IO7.js} +8 -8
  47. package/dist/{zenuml/chunks/decode-BWERFDGK.js → browser-lazy/chunks/decode-5MFOG3AZ.js} +1 -1
  48. package/dist/browser-lazy/chunks/{elk.bundled-L4CADV5W.js → elk.bundled-RYWHIS5N.js} +8 -8
  49. package/dist/browser-lazy/chunks/er-RJO33M6U.js +11 -0
  50. package/dist/browser-lazy/chunks/{eventmodeling-2BPLHWRN.js → eventmodeling-NZJFH7CB.js} +9 -9
  51. package/dist/browser-lazy/chunks/{flowchart-NEIMZTB5.js → flowchart-6WEGVIJH.js} +1 -1
  52. package/dist/browser-lazy/chunks/{forest-implementation-AEP24AIP.js → forest-implementation-RWFF7XDV.js} +1 -1
  53. package/dist/browser-lazy/chunks/{gantt-RDPIFYAF.js → gantt-3EBT47PN.js} +5 -5
  54. package/dist/browser-lazy/chunks/{gitgraph-N4Y5RYB7.js → gitgraph-LXYWMWAG.js} +4 -4
  55. package/dist/browser-lazy/chunks/{ishikawa-LD3YBDJN.js → ishikawa-TNFYQLXS.js} +2 -2
  56. package/dist/browser-lazy/chunks/{journey-6YQR5DJX.js → journey-ATEGEGT7.js} +7 -7
  57. package/dist/browser-lazy/chunks/{kanban-PLMJ7NBW.js → kanban-4SGNSK5P.js} +11 -11
  58. package/dist/browser-lazy/chunks/{mermaid-yaml-runtime-QVYX4EWK.js → mermaid-yaml-runtime-IK4ET4BT.js} +8 -8
  59. package/dist/browser-lazy/chunks/{mindmap-K2UBFO3Y.js → mindmap-5T7X3ENQ.js} +6 -6
  60. package/dist/browser-lazy/chunks/{packet-CUW4QY6Y.js → packet-4SQYN6UC.js} +3 -3
  61. package/dist/browser-lazy/chunks/{pie-7F7UUCG3.js → pie-HNPY7QHS.js} +7 -7
  62. package/dist/browser-lazy/chunks/{quadrant-TOONO2WC.js → quadrant-HG5UVCOG.js} +4 -4
  63. package/dist/browser-lazy/chunks/{radar-J6JVWVAX.js → radar-EIHX3Y7A.js} +7 -7
  64. package/dist/browser-lazy/chunks/render-core-37F7UHHU.js +3 -0
  65. package/dist/browser-lazy/chunks/{requirement-CMAKDJPO.js → requirement-PDLTNSWC.js} +7 -7
  66. package/dist/browser-lazy/chunks/{sankey-AWXQEP3F.js → sankey-K5QOVS24.js} +6 -6
  67. package/dist/browser-lazy/chunks/{sequence-Q2RJRB4L.js → sequence-CVTNAN4F.js} +1 -1
  68. package/dist/browser-lazy/chunks/{state-WRBFQEDX.js → state-EMHRVZIX.js} +2 -2
  69. package/dist/browser-lazy/chunks/{timeline-D2KILFXM.js → timeline-GCGZPQWS.js} +4 -4
  70. package/dist/browser-lazy/chunks/{treemap-N3VYX5D4.js → treemap-BXAVM6C5.js} +3 -3
  71. package/dist/browser-lazy/chunks/xychart-DSHCGE3Q.js +16 -0
  72. package/dist/browser-lazy/chunks/{zenuml-H4BXNYXR.js → zenuml-QU75FNEC.js} +8 -8
  73. package/dist/browser-lazy/index.js +1 -1
  74. package/dist/browser.global.js +507 -507
  75. package/dist/chunk-2WNJCUZG.js +52 -0
  76. package/dist/{chunk-XU5LPD2D.js → chunk-5BYN55G4.js} +1 -1
  77. package/dist/{chunk-JZOJ4YGS.js → chunk-5JQIK3AC.js} +47 -47
  78. package/dist/chunk-BHJZLM35.js +2 -0
  79. package/dist/{chunk-GVCHLSHH.js → chunk-BNS3NO3O.js} +2 -2
  80. package/dist/{chunk-NKNFOREZ.js → chunk-BRFXOVQK.js} +2 -2
  81. package/dist/{chunk-UA234O4M.js → chunk-CPO4MGL7.js} +2 -2
  82. package/dist/chunk-E4AJQAEN.js +2 -0
  83. package/dist/{chunk-H3NCS2XZ.js → chunk-NZQWSAD5.js} +2 -2
  84. package/dist/chunk-QULSM7S3.js +58 -0
  85. package/dist/{chunk-MKE7GNYU.js → chunk-ZKCI4BXW.js} +10 -6
  86. package/dist/{cli-YGGTJZH7.js → cli-6N2OYXG7.js} +43 -43
  87. package/dist/{index-EeXqJXr5.d.ts → index-BvPnCHcw.d.ts} +14 -4
  88. package/dist/index.d.ts +4 -4
  89. package/dist/index.js +1 -1
  90. package/dist/{mcp-cli-63DYXTVD.js → mcp-cli-O4YD2NQB.js} +2 -2
  91. package/dist/{paint-certification-6rwQjIv_.d.ts → paint-certification-6UB6BRr6.d.ts} +2 -2
  92. package/dist/server-ZKAXVFA2.js +527 -0
  93. package/dist/{svg-styles-BdnoM7AT.d.ts → svg-styles-CyT8yUfG.d.ts} +1 -1
  94. package/dist/svg-styles.d.ts +1 -1
  95. package/dist/svg-styles.js +1 -1
  96. package/dist/svg.d.ts +4 -4
  97. package/dist/svg.js +1 -1
  98. package/dist/{types-BcS52Mjt.d.ts → types-DMKjdWeL.d.ts} +1 -1
  99. package/dist/zenuml/chunks/{appearance-UOQ5KA6O.js → appearance-UJSXEKCJ.js} +1 -1
  100. package/dist/zenuml/chunks/{builtin-backends-KDKE7YHO.js → builtin-backends-2ETI2OTB.js} +11 -11
  101. package/dist/zenuml/chunks/{chunk-QWX77U7G.js → chunk-AT55WY2L.js} +2 -2
  102. package/dist/zenuml/chunks/chunk-NGGC5EHN.js +1 -0
  103. package/dist/zenuml/chunks/chunk-O23VFGJM.js +29 -0
  104. package/dist/zenuml/chunks/{chunk-42DXZ5C6.js → chunk-S2NMJ7E6.js} +2 -2
  105. package/dist/zenuml/chunks/{chunk-OXQWRSBM.js → chunk-WLQR46A6.js} +9 -9
  106. package/dist/zenuml/chunks/chunk-Y7DUY2UU.js +29 -0
  107. package/dist/{browser-lazy/chunks/decode-63UIZGD2.js → zenuml/chunks/decode-LDNNXEAO.js} +1 -1
  108. package/dist/zenuml/chunks/{mermaid-yaml-runtime-KZVU74WU.js → mermaid-yaml-runtime-A5CNJ3IE.js} +8 -8
  109. package/dist/zenuml/chunks/render-core-MBXTLSVO.js +3 -0
  110. package/dist/zenuml/chunks/{zenuml-EA2ZFRUX.js → zenuml-FDVVN4IM.js} +8 -8
  111. package/dist/zenuml.d.ts +2 -2
  112. package/dist/zenuml.js +1 -1
  113. package/docs/api.md +84 -4
  114. package/docs/quality.md +6 -3
  115. package/docs/style-authoring.md +23 -0
  116. package/docs/testing-strategy.md +5 -3
  117. package/package.json +3 -2
  118. package/server.json +2 -2
  119. package/skills/agentic-mermaid-diagram-workflow/references/code-mode.md +10 -1
  120. package/skills/agentic-mermaid-diagram-workflow/references/hosted-mcp.md +5 -1
  121. package/dist/browser-lazy/chunks/c4-SQVBZAKJ.js +0 -10
  122. package/dist/browser-lazy/chunks/chunk-4LHYF3BS.js +0 -1
  123. package/dist/browser-lazy/chunks/chunk-FAIMVOX5.js +0 -6
  124. package/dist/browser-lazy/chunks/chunk-GVOEAY52.js +0 -1
  125. package/dist/browser-lazy/chunks/chunk-J35HAQQF.js +0 -20
  126. package/dist/browser-lazy/chunks/chunk-RIVTHZAQ.js +0 -1
  127. package/dist/browser-lazy/chunks/chunk-Z3FDIVLN.js +0 -20
  128. package/dist/browser-lazy/chunks/er-7ZSKGN7Y.js +0 -11
  129. package/dist/browser-lazy/chunks/render-core-BZOM3K7D.js +0 -3
  130. package/dist/browser-lazy/chunks/xychart-G73OGK66.js +0 -16
  131. package/dist/chunk-7CRDX2QR.js +0 -2
  132. package/dist/chunk-DQDKA5ND.js +0 -2
  133. package/dist/chunk-EHCMJUMD.js +0 -52
  134. package/dist/chunk-OMY6NRQD.js +0 -58
  135. package/dist/server-5NEOHOFS.js +0 -524
  136. package/dist/zenuml/chunks/chunk-7TVYPTDW.js +0 -1
  137. package/dist/zenuml/chunks/chunk-RLJEI7YN.js +0 -29
  138. package/dist/zenuml/chunks/chunk-RZ6XK5CD.js +0 -29
  139. package/dist/zenuml/chunks/render-core-V5RQ737O.js +0 -3
  140. package/docs/MCP-DIRECTORY-LISTINGS.md +0 -76
  141. /package/dist/browser-lazy/chunks/{chunk-5FQ534HP.js → chunk-BMZ24VPS.js} +0 -0
  142. /package/dist/browser-lazy/chunks/{chunk-2I4UPL7Q.js → chunk-D6MQ7QSU.js} +0 -0
  143. /package/dist/browser-lazy/chunks/{chunk-CQE4HQEW.js → chunk-HJVO5VC3.js} +0 -0
  144. /package/dist/browser-lazy/chunks/{chunk-LH7HUDKW.js → chunk-L4UC3KGS.js} +0 -0
  145. /package/dist/browser-lazy/chunks/{chunk-NMQQMRIR.js → chunk-MFTQWHUB.js} +0 -0
  146. /package/dist/browser-lazy/chunks/{chunk-N5ELX7LR.js → chunk-PJJSDGLB.js} +0 -0
  147. /package/dist/browser-lazy/chunks/{chunk-CSFUKSU6.js → chunk-QCU5G5PZ.js} +0 -0
  148. /package/dist/browser-lazy/chunks/{chunk-VQYYGAXP.js → chunk-TLFX3U6S.js} +0 -0
  149. /package/dist/browser-lazy/chunks/{chunk-5UVGUSD6.js → chunk-YHMTSXIR.js} +0 -0
  150. /package/dist/zenuml/chunks/{chunk-EVPSMEKN.js → chunk-GC7IPQ5P.js} +0 -0
@@ -0,0 +1,29 @@
1
+ import{$ as e,A as t,Aa as r,B as i,Ba as n,C as o,Ca as a,E as s,H as d,Ha as l,I as c,J as u,Ja as m,K as f,L as p,N as h,P as g,Q as y,R as b,T as x,V as k,W as v,Z as E,_ as $,aa as w,b as S,c as N,d as C,e as M,ia as z,na as O,p as T,s as j,t as _,u as I,x as A,y as D,ya as B,z as L,za as P}from"./chunk-O23VFGJM.js";import{b as F}from"./chunk-GC7IPQ5P.js";var U,R,W=0;function q(e,t){if(!U)return t();let r=R,i=W;R=e,W++;let n=performance.now();try{return t()}finally{let t=performance.now()-n;R=r,W=i,U(Object.freeze({stage:e,ms:t,depth:i,...r?{parent:r}:{}}))}}var G=new WeakMap;function V(e,t){let r=G.get(e)??[],i=Object.freeze({...t,attempts:Object.freeze(t.attempts.map(e=>Object.freeze({...e})))});r.some(e=>JSON.stringify(e)===JSON.stringify(i))||G.set(e,Object.freeze([...r,i]))}function H(e){return G.get(e)??Object.freeze([])}function Z(e,t){let r=G.get(e);r&&G.set(t,r)}var Y=class extends Error{constructor(e){super(`No certified layout after ${e.length} bounded attempts: ${e.map(e=>`${e.strategy}: ${e.violations.join("; ")}`).join(" | ")}`),this.attempts=e,this.name="LayoutCertificationError"}attempts;code="LAYOUT_CERTIFICATION_FAILED"},J=class extends Error{constructor(e,t){super(`${e} has not loaded`),this.dependency=e,this.load=t}dependency;load};function K(e){let t=new Set;for(;e instanceof Error&&!t.has(e);){if(e instanceof J)return e;t.add(e),e=e.cause}}function Q(e){let t=0x811c9dc5;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,0x1000193);return t>>>0}function X(...e){return Q(e.join("|")).toString(36)}function ee(e){let t=e>>>0;return()=>{t|=0;let e=Math.imul((t=t+0x6d2b79f5|0)^t>>>15,1|t);return(((e=e+Math.imul(e^e>>>7,61|e)^e)^e>>>14)>>>0)/0x100000000}}function et(e,t,r){return Q(`${e>>>0}|${t}|${r}`)}function er(e,t){let r=iq;iq=e;try{return t()}finally{iq=r}}var ei={};function en(e){return!e.includes("->")&&!/[#:"\[\],\u0000-\u001f]/.test(e)}function eo(e,...t){let r=t.map(String);return en(e)&&r.every(en)?[e,...r].join(":"):`part:${JSON.stringify([e,...r])}`}function ea(e){return m(e).domIdentity}function es(e,t){if(!ea(t.role))return e;let r=e.match(/^\s*<([A-Za-z][\w:-]*)\b[^>]*>/)?.[0];if(!r||r.startsWith("<style")||r.startsWith("<defs")||r.startsWith("<svg"))return e;let i=(e,t,r)=>{let i=b(r),n=RegExp(`\\s${t}="[^"]*"`);if(n.test(e))return e.replace(n,` ${t}="${i}"`);let o=e.endsWith("/>")?"/>":">";return`${e.slice(0,-o.length).trimEnd()} ${t}="${i}"${"/>"===o?" /":""}>`},n=i(i(r,"data-id",t.id),"data-role",t.role);return void 0!==t.from&&(n=i(n,"data-from",t.from)),void 0!==t.to&&(n=i(n,"data-to",t.to)),n===r?e:e.replace(r,n)}function ed(e,t){if(!m(e.role).relation||void 0===e.from||void 0===e.to)return;let r={from:e.from,to:e.to,...t?{label:t}:{}};return{label:`${r.from} to ${r.to}${r.label?`: ${r.label}`:""}`,role:"graphics-symbol",roleDescription:"relation",relation:r}}function el(e){return"­"===e?"hyphen":"​"===e?"wrap":void 0}function ec(e){return e.replace(/[\u00ad\u200b]/g,"")}F(ei,{connector:()=>tP,definitions:()=>tW,documentClose:()=>tq,documentContent:()=>tU,documentOpen:()=>tV,documentText:()=>tR,drawPathArtwork:()=>tZ,group:()=>tG,indentLines:()=>tC,pathArtwork:()=>tH,retainedGroupEmission:()=>tj,shape:()=>tI,text:()=>tF});var eu=new j(256,8388608),em=new WeakSet,ef=c(f);function ep(e){return ef.has(e)}function eh(e,t){em.has(e)&&em.add(t)}function eg(e,t){return e.bold===t.bold&&e.italic===t.italic&&e.underline===t.underline&&e.strikethrough===t.strikethrough}function ey(e){let t=[],r;for(let i of e.flatMap(e=>e.fragments??e)){let e=ec(i.text);if(!e)continue;let n=e===i.text?i:{...i,text:e,...i.clusters?{clusters:i.clusters.filter(e=>!el(e.text))}:{}};r&&eg(r,n)?(r.text+=n.text,r.clusters=r.clusters&&n.clusters?[...r.clusters,...n.clusters]:void 0,r.sourceEnd=n.sourceEnd):(r={...n},t.push(r))}return t}function eb(e,r){if(0===e.length)return 0;let n=r.safeFont?i:t,a=1!==e.length||e[0].fragments||ec(e[0].text)!==e[0].text?ey(e):e,s=1===a.length?a[0].text:a.map(e=>e.text).join("");if((r.letterSpacing??0)!==0&&!/[^\x20-\x7e]/u.test(s))return ek(a,r).width;let d=r.monospace?D()?a.reduce((e,t)=>e+o(t.text,r.fontSize,0,t.bold?Math.max(700,r.fontWeight):r.fontWeight,t.italic?"italic":"normal",r.fontFamily),0):o(s,r.fontSize):a.reduce((e,t)=>e+n(t.text,r.fontSize,t.bold?Math.max(700,r.fontWeight):r.fontWeight,t.italic?"italic":"normal",r.fontFamily),0);if(!D()&&/[^\x20-\x7e]/u.test(s))return Math.max(d,a.reduce((e,t)=>e+[...t.text].reduce((e,n)=>e+(0===L(n)?0:/[^\x20-\x7e]/u.test(n)?1.2*r.fontSize:i(n,r.fontSize,t.bold?Math.max(700,r.fontWeight):r.fontWeight)),0),0)+I(s).filter(e=>/\p{M}/u.test(e)&&[...e].every(e=>0===L(e))).length*r.fontSize*1.2)+Math.max(0,[...s].length-1)*Math.abs(r.letterSpacing??0);if((r.letterSpacing??0)<0)return ek(a,r).width;let l=r.letterSpacing??0;return Math.max(0,d+(0===l?0:Math.max(0,I(s).length-1)*l))}function ex(e,r,n,a){let s=r.bold?Math.max(700,a.fontWeight):a.fontWeight,d=r.italic?"italic":"normal",l=a.safeFont?i:t;return a.monospace?o(e,a.fontSize,0,s,d,a.fontFamily):l(e,a.fontSize,s,d,a.fontFamily)-(n||D()?0:.15*a.fontSize)}function ek(e,t){let r=0,i=0,n=0;for(let o of e){let e=I(o.text);for(let[a,s]of e.entries()){let d=ex(s,o,a===e.length-1,t);i=Math.min(i,r),n=Math.max(n,r+d),r+=d+(t.letterSpacing??0)}}return{width:n-i,originX:-i}}function ev(e){let{fragments:t,...r}=e.fragments?.at(-1)??e;return{...r,text:"-",clusters:void 0}}function eE(e,t){if(d("text-spans")&&(t={display:t.display,transform:t.transform,fontSize:t.fontSize,fontWeight:t.fontWeight,letterSpacing:t.letterSpacing,maxWidth:t.maxWidth,safeFont:t.safeFont,monospace:t.monospace,fontFamily:t.fontFamily}),!Number.isFinite(t.fontSize)||t.fontSize<=0||!Number.isFinite(t.fontWeight)||!Number.isFinite(t.letterSpacing??0))throw RangeError("Prepared text requires finite typography and a positive font size");let r=d("text-spans")&&!D()&&"string"==typeof e&&e.length<=16384?JSON.stringify([e,t]):void 0;if(void 0!==r){let e=eu.get(r);if(e)return e}let i=h(e,t.display,t.transform),n=t.maxWidth,o=[],a=[];for(let[e,r]of i.lines.entries()){if(e>0&&a.push({kind:"authored",sourceOffset:i.lineStarts[e]-1}),0===r.length){o.push([]);continue}if(!n||!Number.isFinite(n)||n<=0||eb(r,t)<=n){o.push(r.some(e=>ec(e.text)!==e.text)?ey(r):[...r]);continue}let s=function(e){let t=e.flatMap(e=>(e.clusters??I(e.text).map(t=>({text:t,sourceStart:e.sourceStart,sourceEnd:e.sourceEnd}))).map(t=>({...e,...t,clusters:void 0}))),r=0,i=0;return I(t.map(e=>e.text).join("")).map(e=>{let n=e.length,o=[];for(;n>0;){let e=t[r],a=Math.min(n,e.text.length-i);o.push({...e,text:e.text.slice(i,i+a)}),n-=a,(i+=a)===e.text.length&&(r++,i=0)}return{...o[0],text:e,sourceEnd:o.at(-1).sourceEnd,...o.length>1?{fragments:o}:{}}})}(r),l=d("text-spans"),c=l&&!D()?function(e,t){if(1!==e.length||t.monospace||t.letterSpacing||e[0].bold||e[0].italic||e[0].underline||e[0].strikethrough||/[^\x20-\x7e]/u.test(e[0].text))return;let r=e[0],i=e=>Number.isInteger(e)&&e>=0&&e<=0xffffffff;if(!r.clusters||r.clusters.length!==r.text.length||!i(r.sourceEnd)||r.clusters.some((e,t)=>e.text!==r.text[t]||!i(e.sourceStart)))return;let n=new Float64Array(r.text.length+1),o=new Uint32Array(r.text.length+1),a=t.fontWeight>=600?.6:t.fontWeight>=500?.57:.54;for(let e=0;e<r.text.length;e++){let i=L(r.text[e]);t.safeFont&&("W"===r.text[e]||"M"===r.text[e])&&(i+=.35),n[e+1]=n[e]+i,o[e]=r.clusters[e].sourceStart}return o[r.text.length]=r.sourceEnd,{offsets:o,width:(e,r)=>(n[r]-n[e])*t.fontSize*a+.15*t.fontSize}}(r,t):void 0,u=l?(e,r)=>{let i=c?.width(e,r);return void 0!==i&&Math.abs(i-n)>1e-8*Math.max(1,Math.abs(i),Math.abs(n))?i<n:eb(s.slice(e,r),t)<=n}:void 0,m=0;for(;m<s.length;){for(;m<s.length&&el(s[m].text);)m++;if(m===s.length)break;let e=m,r=-1,d=-1,l=e=>{let r=el(s[e].text);r&&e>m&&eb([...s.slice(m,e),..."hyphen"===r?[ev(s[e])]:[]],t)<=n&&(d=e+1)};if(u)for(;e<s.length&&u(m,e+1);)/\s/u.test(s[e].text)&&(r=e+1),l(e),e++;else for(;e<s.length&&eb(s.slice(m,e+1),t)<=n;)/\s/u.test(s[e].text)&&(r=e+1),l(e),e++;if(e===s.length){o.push(ey(s.slice(m)));break}if(e>m&&!/\s/u.test(s[e-1].text)&&/\s/u.test(s[e]?.text??""))for(r=e;r<s.length&&/\s/u.test(s[r].text);)r++;let f=!1,p,h;if(d>m&&d>=r)p=(e=d)-1,f="hyphen"===el(h=s[e-1].text);else if(r>m){if(s.slice(m,r).some(e=>!/\s/u.test(e.text)))for(;r<s.length&&/\s/u.test(s[r].text);)r++;for(p=e=r;p>m&&/\s/u.test(s[p-1].text);)p--;p===m?p=e:h=s.slice(p,e).map(e=>e.text).join("")}else{let r;if(r=e=Math.max(m+1,e),/[\p{Script=Latin}\p{Script=Greek}\p{Script=Cyrillic}]/u.test(s[r-1]?.text??"")&&/\p{L}/u.test(s[r]?.text??"")){for(;e>m+1&&eb([...s.slice(m,e),ev(s[e-1])],t)>n;)e--;f=eb([...s.slice(m,e),ev(s[e-1])],t)<=n}}let g=ey(s.slice(m,p??e)),y=c?.offsets[e]??s[e]?.sourceStart??i.source.length;if(f){let t=e===d?s[e-1]:void 0;g.push({...ev(s[e-1]),sourceStart:t?.sourceStart??y,sourceEnd:t?.sourceEnd??y})}o.push(g),e<s.length&&a.push({kind:f?"hyphen":"wrap",sourceOffset:y,...h?{replacedText:h}:{}}),m=e}0===s.length&&o.push([])}let l=i.lines.map(e=>e.map(e=>e.text).join("")).join(`
2
+ `),c=/\p{M}/u.test(l.normalize("NFD").replace(/[\uFE0E\uFE0F]/g,""))?I(l.normalize("NFD")).reduce((e,t)=>Math.max(e,(t.replace(/[\uFE0E\uFE0F]/g,"").match(/\p{M}/gu)??[]).length),0):0,u=t.fontSize*Math.max(s,2.4*!!/[\p{Script=Arabic}\p{Script=Hebrew}]/u.test(l),c?s+.6*c:0),m=o.map((e,r)=>{var n;let o,a,s,d,l,c=e.map(e=>"literal"===i.display?e.text:_(e)).join("");e.forEach(ef.freeze);let m=!/[^\x20-\x7e]/u.test(c),f=e.some(e=>e.bold||e.italic||e.underline||e.strikethrough),p=m?(t.letterSpacing??0)!==0?(n=t,o=e.flatMap((e,t)=>I(e.text).map(e=>({runIndex:t,text:e}))),a=0,s=0,d=0,l=o.map((t,r)=>{let i=e[t.runIndex],l=o[r+1],c=!l||!eg(i,e[l.runIndex]),u=ex(t.text,i,c,n),m=ef.freeze({...t,x:a,width:u});return s=Math.min(s,a),d=Math.max(d,a+u),a+=u+(n.letterSpacing??0),m}),{width:d-s,originX:-s,fragments:ef.freeze(l)}):f?function(e,t){let r=[];for(let[t,i]of e.entries()){let n=r.at(-1);n&&eg(e[n.runIndex],i)?n.text+=i.text:r.push({runIndex:t,text:i.text})}let i=0,n=r.map(({runIndex:r,text:n})=>{let o=eb([{...e[r],text:n}],t),a=ef.freeze({runIndex:r,text:n,x:i,width:o});return i+=o,a});return{width:i,originX:0,fragments:ef.freeze(n)}}(e,t):void 0:void 0;return ef.freeze({runs:ef.freeze(e),text:c,width:p?.width??eb(e,t),baseline:r*u+.35*t.fontSize,originX:p?.originX??0,...p?{fragments:p.fragments}:{}})}),f=m.map(e=>e.text);ef.freeze(f),a.forEach(ef.freeze);let p=m.reduce((e,t)=>Math.max(e,t.width),0),g=ef.freeze({unit:"px",prepared:i,text:f.join(`
3
+ `),lines:f,lineBlocks:ef.freeze(m),breaks:ef.freeze(a),width:p,height:f.length*u,lineHeight:u,fontSize:t.fontSize,fontWeight:t.fontWeight,letterSpacing:t.letterSpacing??0,monospace:t.monospace??!1,safeFont:t.safeFont??!1,...t.fontFamily?{fontFamily:t.fontFamily}:{}});return em.add(g),void 0!==r&&eu.set(r,g,2*r.length+128*g.prepared.source.length+256*g.lines.length+512),g}function e$(e,t,r=0){return Math.abs(e.x-t.x)<=r&&Math.abs(e.y-t.y)<=r}function ew(e,t){let r=t.x-e.x,i=t.y-e.y,n=Math.hypot(r,i);return Number.isFinite(n)&&n>0?{x:r/n,y:i/n}:void 0}function eS(e,t=!1){return"line"===e.kind?[{points:[{x:e.x1,y:e.y1},{x:e.x2,y:e.y2}],closed:!1}]:"path"===e.kind&&void 0!==e.subpaths?e.subpaths:[{points:e.points,closed:t}]}function eN(e){return"path"===e.kind&&/[AaCcQqSsTt]/.test(e.d)}function eC(e,t=!1){let r=[];for(let i of eS(e,t)){let t,n=i.points[0],o=i.points.at(-1);if(!n||!o)continue;for(let e=1;e<i.points.length&&!t;e++)t=ew(i.points[e-1],i.points[e]);let a=i.closed&&!e$(n,o);!t&&a&&(t=ew(o,n));let s=a?ew(o,n):void 0;for(let e=i.points.length-1;e>0&&!s;e--)s=ew(i.points[e-1],i.points[e]);r.push({start:"line"===e.kind?n:{...n},end:"line"===e.kind?o:{...i.closed?n:o},closed:i.closed,...t?{startTangent:t}:{},...s?{endTangent:s}:{}})}return r}function eM(e,t=!1){let r=[],i=[];for(let n of eS(e,t)){let e=n.points[0],t=n.closed?e:n.points.at(-1);e&&r.push(e),t&&i.push(t)}return{starts:r,ends:i}}function ez(e,t=!1){let r=[];for(let[i,n]of eS(e,t).entries()){for(let e=1;e<n.points.length;e++)r.push({start:n.points[e-1],end:n.points[e],subpathIndex:i,closing:!1});let e=n.points[0],t=n.points.at(-1);n.closed&&e&&t&&!e$(e,t)&&r.push({start:t,end:e,subpathIndex:i,closing:!0})}return r}function eO(e,t=!1){return"line"===e.kind?[]:"path"===e.kind?e.markerMidpoints??[]:eS(e,t).flatMap(e=>{if(e.points.length<2)return[];let t=e.closed&&e$(e.points[0],e.points.at(-1))?e.points.slice(0,-1):e.points;return e.closed?t.slice(1):t.slice(1,-1)})}function eT(e,t,r){let i=r*Math.PI/180,n=Math.cos(i),o=Math.sin(i),a=e.x-t.x,s=e.y-t.y;return{x:t.x+a*n-s*o,y:t.y+a*o+s*n}}var ej=[1,0,0,1,0,0];function e_(e){if(!e)return ej;if("matrix"===e.kind)return[e.a,e.b,e.c,e.d,e.e,e.f];let t=e.angle*Math.PI/180,r=Math.cos(t),i=Math.sin(t);return[r,i,-i,r,e.cx-r*e.cx+i*e.cy,e.cy-i*e.cx-r*e.cy]}function eI(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}function eA(e,t){return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}function eD(e){let t=e[0]*e[3]-e[1]*e[2];if(!(!Number.isFinite(t)||0===t))return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[3]*e[4])/t,(e[1]*e[4]-e[0]*e[5])/t]}function eB(e){return"rotate"===e.kind?`rotate(${e.angle} ${e.cx} ${e.cy})`:`matrix(${e.a} ${e.b} ${e.c} ${e.d} ${e.e} ${e.f})`}function eL(e){if(0!==e.length)return{x0:Math.min(...e.map(e=>e.x)),y0:Math.min(...e.map(e=>e.y)),x1:Math.max(...e.map(e=>e.x)),y1:Math.max(...e.map(e=>e.y))}}function eP(e,t){return e?t?{x0:Math.min(e.x0,t.x0),y0:Math.min(e.y0,t.y0),x1:Math.max(e.x1,t.x1),y1:Math.max(e.y1,t.y1)}:e:t}function eF(e,t){let r=Number.isFinite(t)?Math.max(0,t):0;return{x0:e.x0-r,y0:e.y0-r,x1:e.x1+r,y1:e.y1+r}}function eU(e,t,r){let i=/[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/y,n=0,o=0,a=0,s=0,d=0,l="",c="",u,m,f,p=!1,h=e=>{if(r){for(let t=0;t<e;t++)if(!r())return p=!0,!1}return!0},g=()=>{for(;n<e.length&&/[\s,]/.test(e[n]);){if(!h(1))return;n++}},y=(t=!1)=>{if(g(),p)return;if(t){let t=e[n];return("0"===t||"1"===t)&&h(1)?(n++,Number(t)):void 0}i.lastIndex=n;let r=i.exec(e);if(!r||!h(r[0].length))return;n=i.lastIndex;let o=Number(r[0]);return Number.isFinite(o)?o:void 0},b=(e,r)=>!!Number.isFinite(e)&&!!Number.isFinite(r)&&(m=eP(m,{x0:e,y0:r,x1:e,y1:r}),t&&(f=eP(f,{x0:e,y0:r,x1:e,y1:r})),!0);for(;;){if(g(),p)return;if(n>=e.length)return m;if(/[a-zA-Z]/.test(e[n])){if(!h(1)||(l=e[n++],!/[MmLlHhVvCcSsQqTtAaZz]/.test(l)||!m&&"M"!==l.toUpperCase()))return;if("Z"===l.toUpperCase()){if(t&&!t({bounds:{x0:Math.min(o,s),y0:Math.min(a,d),x1:Math.max(o,s),y1:Math.max(a,d)},line:[{x:o,y:a},{x:s,y:d}]}))return;o=s,a=d,c="Z",u=void 0,l="";continue}}if(!l)return;let r=l.toUpperCase(),i=l!==r;t&&(f={x0:o,y0:a,x1:o,y1:a});let x="A"===r?7:"C"===r?6:"S"===r||"Q"===r?4:"H"===r||"V"===r?1:2,k=[];for(let e=0;e<x;e++){let t=y("A"===r&&(3===e||4===e));if(void 0===t)return;k.push(t)}let v=e=>k[e]+(i?o:0),E=e=>k[e]+(i?a:0),$,w,S;if("H"===r)$=v(0),w=a;else if("V"===r)$=o,w=E(0);else if("C"===r||"S"===r||"Q"===r||"T"===r){let e=u&&("S"===r?"C"===c||"S"===c:"Q"===c||"T"===c)?{x:2*o-u.x,y:2*a-u.y}:{x:o,y:a};if(("S"===r||"T"===r)&&!b(e.x,e.y))return;for(let e=0;e<x-2;e+=2)if(!b(v(e),E(e+1)))return;$=v(x-2),w=E(x-1),S="T"===r?e:{x:v(x-4),y:E(x-3)}}else if("A"===r){$=v(5),w=E(6);let e=Math.abs(k[0]),t=Math.abs(k[1]);if(e>0&&t>0&&($!==o||w!==a)){let r=k[2]%360*Math.PI/180,i=Math.cos(r),n=Math.sin(r),s=(o-$)/2,d=(a-w)/2,l=i*s+n*d,c=-n*s+i*d,u=Math.hypot(l/e,c/t);u>1&&(e*=u,t*=u);let m=(l/e)**2+(c/t)**2,f=(k[3]===k[4]?-1:1)*Math.sqrt(Math.max(0,(1-m)/m)),p=f*e*c/t,h=-f*t*l/e,g=i*p-n*h+(o+$)/2,y=n*p+i*h+(a+w)/2,x=Math.hypot(e*i,t*n),v=Math.hypot(e*n,t*i);if(!b(g-x,y-v)||!b(g+x,y+v))return}}else $=v(0),w=E(1),"M"===r&&(s=$,d=w,l=i?"l":"L");if(!b($,w)||t&&"M"!==r&&!t({bounds:f,...["L","H","V"].includes(r)?{line:[{x:o,y:a},{x:$,y:w}]}:{}}))return;o=$,a=w,u=S,c=r}}function eR(e,t,r){return void 0!==eU(e,t,r)}function eW(e){switch(e.kind){case"rect":return{x0:e.x,y0:e.y,x1:e.x+e.width,y1:e.y+e.height};case"circle":return{x0:e.cx-e.r,y0:e.cy-e.r,x1:e.cx+e.r,y1:e.cy+e.r};case"ellipse":return{x0:e.cx-e.rx,y0:e.cy-e.ry,x1:e.cx+e.rx,y1:e.cy+e.ry};case"line":return{x0:Math.min(e.x1,e.x2),y0:Math.min(e.y1,e.y2),x1:Math.max(e.x1,e.x2),y1:Math.max(e.y1,e.y2)};case"polygon":case"polyline":return eL(e.points);case"compound":{let t;for(let r of e.children){let e=eW(r);if(!e)return;t=eP(t,e)}return t}case"path":return eU(e.d)}}function eq(e,t,r,i=!1,n){if(!e||!t)return;let o=e.geometry?eW(e.geometry):void 0;if(i&&e.geometry&&!o)return;let a=e.bounds??o??(e.viewBox?{x0:e.viewBox.x,y0:e.viewBox.y,x1:e.viewBox.x+e.viewBox.width,y1:e.viewBox.y+e.viewBox.height}:void 0)??(e.size?{x0:0,y0:0,x1:e.size.width,y1:e.size.height}:void 0);if(!a)return;if(i){a=eP(a,o);let t=eX(e.paint??{},!0);if(void 0===t)return;a=eF(a,t)}let s=e.ref?.x??0,d=e.ref?.y??0,l=a;if(e.viewBox&&e.size){let t=Math.min(e.size.width/e.viewBox.width,e.size.height/e.viewBox.height),r=(e.size.width-e.viewBox.width*t)/2,i=(e.size.height-e.viewBox.height*t)/2,n=i=>r+(i-e.viewBox.x)*t,o=r=>i+(r-e.viewBox.y)*t;l={x0:n(a.x0),y0:o(a.y0),x1:n(a.x1),y1:o(a.y1)},s=n(s),d=o(d)}let c=(e.units??"strokeWidth")==="strokeWidth"?r:1,u=Math.max(+!!i,e.scale??1)*c;if(void 0!==n){let e=n*Math.PI/180,r=Math.cos(e),i=Math.sin(e),o=[[l.x0,l.y0],[l.x0,l.y1],[l.x1,l.y0],[l.x1,l.y1]].map(([e,n])=>({x:t.x+((e-s)*r-(n-d)*i)*u,y:t.y+((e-s)*i+(n-d)*r)*u}));return o.every(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))?eL(o):void 0}let m=Math.max(Math.abs(l.x0-s),Math.abs(l.x1-s)),f=Math.max(Math.abs(l.y0-d),Math.abs(l.y1-d)),p=(i?Math.hypot(m,f):Math.max(m,f))*u;return{x0:t.x-p,y0:t.y-p,x1:t.x+p,y1:t.y+p}}function eG(e,t){let r=e.route.geometry,i=eM(r,e.route.closed),n=eO(r,e.route.closed),o=eK(t,e.transform),a=[],s=(t,i,n,s)=>{if(!i||!n)return;let d="number"==typeof i.orient?i.orient:s?180*Math.atan2(s.y,s.x)/Math.PI+180*("start"===t&&"auto-start-reverse"===i.orient):void 0,l=eV(e.stroke.width),c=eq(i,n,l,!0,d),u=e_(o),m=JSON.stringify([{...i,orient:i.orient??"auto"},d??["unknown",r],"userSpaceOnUse"===i.units?1:l,u.slice(0,4)]),f,p;if(void 0!==d&&i.geometry?.kind==="polygon"&&i.geometry.points.length<=64){let e=(i.viewBox&&i.size?Math.min(i.size.width/i.viewBox.width,i.size.height/i.viewBox.height):1)*Math.max(1,i.scale??1)*("userSpaceOnUse"===i.units?1:l),t=d*Math.PI/180,r=Math.cos(t),o=Math.sin(t);f=i.geometry.points.map(t=>{let a=(t.x-(i.ref?.x??0))*e,s=(t.y-(i.ref?.y??0))*e;return eA({x:n.x+a*r-s*o,y:n.y+a*o+s*r},u)});let[a,s,c,m]=u,h=(Math.hypot(a+m,s-c)+Math.hypot(a-m,s+c))/2,g=eX(i.paint??{},!0);void 0!==(p=void 0===g?void 0:g*e*h)&&Number.isFinite(p)&&f.every(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))||(f=void 0)}a.push({position:t,resource:i.id,anchor:eA(n,u),repaint:m,...f?{hull:f,padding:p}:{},...c?{bounds:eJ(c,o)}:{}})};if(i.starts.forEach((t,r)=>s("start",e.markers.start,t,e.route.contours[r]?.startTangent)),i.ends.forEach((t,r)=>s("end",e.markers.end,t,e.route.contours[r]?.endTangent)),1===e.markers.mid.length)for(let t of n)s("mid",e.markers.mid[0],t);else e.markers.mid.forEach((e,t)=>s("mid",e,n[t]));return a}function eV(e){let t="number"==typeof e?e:parseFloat(e);return Number.isFinite(t)?Math.max(0,t):1}var eH=new WeakMap;function eZ(e){let t=p(e.text,e.textContent),r="string"==typeof t?t:t.source;if(e.block){let t=e.block;if(t.prepared.source!==r||void 0!==e.fontSize&&e.fontSize!==t.fontSize||void 0!==e.fontWeight&&e.fontWeight!==t.fontWeight||void 0!==e.letterSpacing&&e.letterSpacing!==t.letterSpacing||void 0!==e.display&&e.display!==t.prepared.display)throw TypeError("Connector inline label typography and source must agree with its prepared block");return t}let i=e.fontSize??12,n=e.fontWeight??400,o=e.letterSpacing??0,a=e.display??"literal",s=eH.get(e);if(s&&("string"==typeof t?s.prepared.source===r:s.prepared===t)&&s.fontSize===i&&s.fontWeight===n&&s.letterSpacing===o&&s.prepared.display===a)return s;let d=eE(t,{display:a,fontSize:i,fontWeight:n,letterSpacing:o});return eH.set(e,d),d}function eY(e){if(e.visual?.kind!=="inline"||!e.anchor||void 0===e.fontSize||void 0===e.textAnchor)return;let t=eZ(e),r=t.width,i="middle"===e.textAnchor?e.anchor.x-r/2:"end"===e.textAnchor?e.anchor.x-r:e.anchor.x,n=e.anchor.y-Math.max(0,e.clearance??0),o=Math.max(0,e.halo?.width??0)/2;return eF({x0:i,y0:n-.35*t.fontSize-t.height/2,x1:i+r,y1:n-.35*t.fontSize+t.height/2},o)}function eJ(e,t){if(![e.x0,e.y0,e.x1,e.y1].every(Number.isFinite))return;if(!t)return e;if("rotate"===t.kind)return function(e,t,r){if(r%360==0)return{...e};let i=[eT({x:e.x0,y:e.y0},t,r),eT({x:e.x1,y:e.y0},t,r),eT({x:e.x0,y:e.y1},t,r),eT({x:e.x1,y:e.y1},t,r)];return{x0:Math.min(...i.map(e=>e.x)),y0:Math.min(...i.map(e=>e.y)),x1:Math.max(...i.map(e=>e.x)),y1:Math.max(...i.map(e=>e.y))}}(e,{x:t.cx,y:t.cy},t.angle);let r=e_(t),i=e.x0,n=e.y0,o=e.x0,a=e.y1,s=e.x1,d=e.y0,l=e.x1,c=e.y1;if(1===r[0]&&0===r[1]&&0===r[2]&&1===r[3]&&i===o&&n===d&&s===l&&a===c&&0!==i&&0!==n&&0!==s&&0!==a&&Number.isFinite(i)&&Number.isFinite(n)&&Number.isFinite(s)&&Number.isFinite(a)){let e=eA({x:i,y:n},r),t=eA({x:l,y:c},r);return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(t.x)&&Number.isFinite(t.y)?{x0:Math.min(e.x,t.x),y0:Math.min(e.y,t.y),x1:Math.max(e.x,t.x),y1:Math.max(e.y,t.y)}:void 0}let u=[[i,n],[o,a],[s,d],[l,c]].map(([e,t])=>eA({x:e,y:t},r));return u.every(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))?eL(u):void 0}function eK(e,t){if(!e)return t;if(!t)return e;let[r,i,n,o,a,s]=eI(e_(e),e_(t));return{kind:"matrix",a:r,b:i,c:n,d:o,e:a,f:s}}function eQ(e){return"line"!==e.geometry.kind&&!("polyline"===e.geometry.kind&&2===e.geometry.points.length&&!e.closed)}function eX(e,t){if(void 0===e.stroke||"none"===e.stroke||"transparent"===e.stroke||T(e.stroke)?.[3]===0)return 0;let r=e.strokeWidth??"1";if(!/^\s*(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?(?:px)?\s*$/.test(r))return;let i=Number.parseFloat(r)/2;if(!Number.isFinite(i))return;let n=e.strokeLinejoin??"miter",o=Number(e.strokeMiterlimit??4);if(!Number.isFinite(o)||o<1)return;let a=Math.max(t&&("miter"===n||"miter-clip"===n)?i*o:i,"square"===e.strokeLinecap?i*Math.SQRT2:i);return Number.isFinite(a)?a:void 0}function e0(e,t,r,i){if(!r)return eJ(eF(e,t),i);let n=eJ(e,i);return n?eF(n,t):void 0}function e1(e,t,r,i,n,o){return"line"!==e.kind||n?e0(t,r,n,o):eJ(function(e,t,r){let i=eW(e),n=Math.hypot(e.x2-e.x1,e.y2-e.y1);if(void 0!==r&&"butt"!==r||0===n)return eF(i,t);let o=t*Math.abs(e.y2-e.y1)/n,a=t*Math.abs(e.x2-e.x1)/n;return{x0:i.x0-o,y0:i.y0-a,x1:i.x1+o,y1:i.y1+a}}(e,r,i),o)}function e2(e,t,r,i){let n=0;for(let o=0;o<32;o++){let a,s=o/32,d=(o+1)/32,l=e=>Math.min(d,Math.max(s,e)),c=r=>e*(1-r)**2+t*(1+r+r*r),u=6*r*Math.min(s*(1-s),d*(1-d)),m=6*i*r*d/Math.hypot((a=l(e/(e+t)),3*(e*(1-a)**2+t*a*a)),u)-c(l((2*e-t)/(2*(e+t))));m>0&&(n=Math.max(n,(1-s)*m))}return Math.min(i,n)}function e3(e,t){return function e(t,r){let i,n=eK(r,t.transform);if(!n||eD(e_(n))){if("shape"===t.kind){if(!(i=eW(t.geometry)))return;let e=["polygon","polyline","path","compound"].includes(t.geometry.kind),r;for(let o of[t.paint,...t.childPaints??[]]){let a=eX(o,e),s=void 0===a?void 0:e1(t.geometry,i,a,o.strokeLinecap,"non-scaling-stroke"===o.vectorEffect,n);if(!s)return;r=r?eP(r,s):s}if(!t.conditionalPaint)return r;let o=eX(t.conditionalPaint,["polygon","polyline","path","compound"].includes(t.geometry.kind));if(!r||void 0===o)return;let a=e1(t.geometry,i,o,t.conditionalPaint.strokeLinecap,"non-scaling-stroke"===t.conditionalPaint.vectorEffect,n);return a?eP(r,a):void 0}if("connector"===t.kind)return function(e,t){let r=e.route.geometry,i=eW(r),n=eX({stroke:e.stroke.color,strokeWidth:String(e.stroke.width),strokeLinecap:e.stroke.lineCap,strokeLinejoin:e.stroke.lineJoin,strokeMiterlimit:String(e.stroke.miterLimit)},eQ(e.route));if(!i||void 0===n)return;let o="path"!==r.kind||"butt"!==e.stroke.lineCap||e.stroke.nonScaling?void 0:function(e,t){if(!/^[\s,0-9eE.+\-MC]+$/.test(e))return;let r=e.match(/[MC]|[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/g);if(!r||10!==r.length||"M"!==r[0]||"C"!==r[3])return;let i=r.filter(e=>"M"!==e&&"C"!==e).map(Number);if(!i.every(Number.isFinite))return;let[n,o,a,s,d,l,c,u]=i;if(a!==d||s!==o||l!==u||!((a-n)*(c-a)>0))return;let m=Math.abs(a-n),f=Math.abs(c-a),p=Math.abs(u-o),h=Math.sign(c-n),g=[n-h*e2(f,m,p,t),c+h*e2(m,f,p,t)];return{x0:Math.min(...g),y0:Math.min(o,u)-t,x1:Math.max(...g),y1:Math.max(o,u)+t}}(r.d,eV(e.stroke.width)/2),a=o?eJ(o,t):e0(i,n,e.stroke.nonScaling,t);if(!a)return;let s=eV(e.stroke.width),d=eM(r,e.route.closed),l=eO(r,e.route.closed);for(let{marker:r,anchor:i}of[...d.starts.flatMap(t=>e.markers.start?[{marker:e.markers.start,anchor:t}]:[]),...d.ends.flatMap(t=>e.markers.end?[{marker:e.markers.end,anchor:t}]:[]),...1===e.markers.mid.length?l.map(t=>({marker:e.markers.mid[0],anchor:t})):e.markers.mid.map((e,t)=>({marker:e,anchor:l[t]}))]){let e=eq(r,i,s,!0),n=e&&eJ(e,t);if(!n)return;a=eP(a,n)}for(let r of e.labels){let e=eP(r.bounds,eY(r));if(r.visual?.kind==="inline"&&!e)return;if(e){let r=eJ(e,t);if(!r)return;a=eP(a,r)}}return a}(t,n);if("text"===t.kind){i=function(e){let t;if("shape"===e.kind)t=eW(e.geometry);else if("connector"===e.kind)t=function(e){let t=e.route.geometry,r="path"===t.kind?eL(t.points):eW(t);if(!r)return;let i=eV(e.stroke.width),n=i/2;r=eF(r,"miter"===e.stroke.lineJoin||"miter-clip"===e.stroke.lineJoin?n*Math.max(1,e.stroke.miterLimit):n);let o=eM(t,e.route.closed);for(let t of o.starts)r=eP(r,eq(e.markers.start,t,i));for(let t of o.ends)r=eP(r,eq(e.markers.end,t,i));let a=eO(t,e.route.closed);if(1===e.markers.mid.length)for(let t of a)r=eP(r,eq(e.markers.mid[0],t,i));else for(let t=0;t<e.markers.mid.length;t++)r=eP(r,eq(e.markers.mid[t],a[t],i));for(let t of e.labels)t.bounds&&(r=eP(r,t.bounds)),r=eP(r,eY(t));return r}(e);else{if("text"!==e.kind)return;let r=e.textLayout??eE(e.text,{display:e.display,fontSize:e.fontSize,fontWeight:e.fontWeight??500,letterSpacing:e.letterSpacing}),i=r.width,n="middle"===e.anchor?e.x-i/2:"end"===e.anchor?e.x-i:e.x,o="offsetY"in r?r.offsetY:-(.35*e.fontSize);t={x0:n,y0:e.y+o-r.height/2,x1:n+i,y1:e.y+o+r.height/2}}return t?eJ(t,e.transform):void 0}({...t,transform:void 0});let e=eX(t.paint,!1);return i&&void 0!==e?e0(i,e,"non-scaling-stroke"===t.paint.vectorEffect,n):void 0}if("group"!==t.kind)return;for(let r of t.children){if("document"===r.node.kind&&r.node.nonPaint)continue;let t=e(r.node,n);if(!t)return;i=eP(i,t)}return i}}(e,t)}function e5(e,t,r){return!r||Object.hasOwn(e,t)?e[t]:void 0}function e4(e,t){return e?{...e,...e5(e,"geometry",t)?{geometry:e5(e,"geometry",t)}:{},...e5(e,"size",t)?{size:{...e5(e,"size",t)}}:{},...e5(e,"viewBox",t)?{viewBox:{...e5(e,"viewBox",t)}}:{},...e5(e,"ref",t)?{ref:{...e5(e,"ref",t)}}:{},...e5(e,"bounds",t)?{bounds:{...e5(e,"bounds",t)}}:{},...e5(e,"paint",t)?{paint:{...e5(e,"paint",t)}}:{}}:void 0}function e6(e,t){let r=e5(e,"owner",t),i=e5(e,"point",t);return{...e,...r?{owner:{...r}}:{},...i?{point:{...i}}:{}}}function e8(e,t=!1){if(t&&"path"===e.geometry.kind)throw TypeError("Deferred terminal projections require line or polyline geometry");let r=function(e,t,r=!1){let i=["continuous-geometry","stroke-width","stroke-cap","stroke-join"];e.bendRadius>0&&i.push("bend-radius"),void 0!==e5(t,"opacity",r)&&i.push("stroke-opacity"),("miter"===t.lineJoin||"miter-clip"===t.lineJoin)&&i.push("stroke-miter"),e5(t,"dash",r)&&i.push("dash-pattern");let n=e5(t,"dash",r);return n&&void 0!==e5(n,"offset",r)&&i.push("dash-offset"),void 0!==e5(t,"pathLength",r)&&i.push("path-length"),void 0!==e5(t,"paintOrder",r)&&i.push("paint-order"),/^url\(#[A-Za-z_][A-Za-z0-9_.:-]*\)$/.test(t.color)&&i.push("gradient-paint"),void 0!==e5(t,"mixBlendMode",r)&&"normal"!==e5(t,"mixBlendMode",r)&&i.push("mix-blend-mode"),e5(t,"nonScaling",r)&&i.push("non-scaling-stroke"),i}(e.route,e.stroke,t),i=function(e,t=!1){let r=[],i=[];return eS(e,t).forEach((e,t)=>{let n=e.points[0],o=e.closed?n:e.points.at(-1);n&&r.push({point:{...n},contourIndex:t}),o&&i.push({point:{...o},contourIndex:t})}),{starts:r,ends:i}}(e.geometry,e.route.closed),n=function(e,t=!1){if("line"===e.kind)return[];let r=eS(e,t);return"path"===e.kind?(e.markerMidpoints??[]).map(e=>{if(1===r.length)return{point:{...e},contourIndex:0};let t=r.flatMap((t,r)=>t.points.some(t=>e$(t,e))?[r]:[]);if(1!==t.length)throw TypeError("Path marker-mid vertices on multiple subpaths must belong to exactly one typed contour");return{point:{...e},contourIndex:t[0]}}):r.flatMap((e,t)=>{if(e.points.length<2)return[];let r=e.closed&&e$(e.points[0],e.points.at(-1))?e.points.slice(0,-1):e.points;return(e.closed?r.slice(1):r.slice(1,-1)).map(e=>({point:{...e},contourIndex:t}))})}(e.geometry,e.route.closed),o=e5(e.stroke,"dash",t),a={start:e5(e.markers,"start",t)?i.starts.map(r=>({markerId:e5(e.markers,"start",t).id,point:{...r.point},contourIndex:r.contourIndex})):[],mid:0===e.markers.mid.length?[]:n.map((t,r)=>({markerId:(1===e.markers.mid.length?e.markers.mid[0]:e.markers.mid[r]).id,point:{...t.point},contourIndex:t.contourIndex})),end:e5(e.markers,"end",t)?i.ends.map(r=>({markerId:e5(e.markers,"end",t).id,point:{...r.point},contourIndex:r.contourIndex})):[]};return{realization:"invisible"===e.lineStyle?"unsupported":"projected",topology:e.geometry.kind,geometry:e.geometry,direction:e.relationship.direction,relationship:e.relationship.kind,markers:{...e5(e.markers,"start",t)?{start:e4(e5(e.markers,"start",t),t)}:{},mid:e.markers.mid.map(e=>e4(e,t)),...e5(e.markers,"end",t)?{end:e4(e5(e.markers,"end",t),t)}:{}},markerPlacements:a,endpoints:{...e.endpoints,...e5(e.endpoints,"start",t)?{start:e6(e5(e.endpoints,"start",t),t)}:{},...e5(e.endpoints,"end",t)?{end:e6(e5(e.endpoints,"end",t),t)}:{}},route:{ownership:e.route.ownership,closed:e.route.closed,bendRadius:e.route.bendRadius,contours:e.route.contours.map(e=>({...e,start:{...e.start},end:{...e.end},...e5(e,"startTangent",t)?{startTangent:{...e5(e,"startTangent",t)}}:{},...e5(e,"endTangent",t)?{endTangent:{...e5(e,"endTangent",t)}}:{}})),...e5(e.route,"startTangent",t)?{startTangent:{...e5(e.route,"startTangent",t)}}:{},...e5(e.route,"endTangent",t)?{endTangent:{...e5(e.route,"endTangent",t)}}:{},labelAnchors:e.route.labelAnchors.map(e=>({...e}))},stroke:{...e.stroke,...o?{dash:{...o,array:Array.isArray(o.array)?[...o.array]:o.array}}:{}},hit:{...e.hit,geometry:e.hit.geometry},...e5(e,"transform",t)?{transform:{...e5(e,"transform",t)}}:{},labels:e.labels.map(e=>({...e,...e5(e,"anchor",t)?{anchor:{...e5(e,"anchor",t)}}:{},...e5(e,"bounds",t)?{bounds:{...e5(e,"bounds",t)}}:{},...e5(e,"halo",t)?{halo:{...e5(e,"halo",t)}}:{},...e5(e,"paint",t)?{paint:{...e5(e,"paint",t)}}:{},...e5(e,"visual",t)?{visual:{...e5(e,"visual",t)}}:{}})),lineStyle:e.lineStyle,strokeLosses:r,diagnostics:["invisible"===e.lineStyle?"This connector affects layout but is intentionally absent from terminal output.":`The terminal grid preserves connector semantics while projecting continuous stroke fields: ${r.join(", ")}.`,...e5(e,"additionalDiagnostics",t)??[]]}}var e7=new WeakMap,e9=0;function te(e){e9++;try{return e()}finally{e9--}}var tt={enumerable:!0,configurable:!0,get(){let e=e7.get(this);if(Object.hasOwn(e,"projection"))return e.projection;let t=e8(e,!0);return e7.set(this,{projection:t}),t},set(e){if(Object.isFrozen(this))throw TypeError("Cannot assign to readonly terminalProjection");Object.defineProperty(this,"terminalProjection",{value:e,enumerable:!0,configurable:!0,writable:!0}),e7.delete(this)}};function tr(e,t){e7.set(e,t),Object.defineProperty(e,"terminalProjection",tt)}function ti(e){let t=e7.get(e);return!t||Object.hasOwn(t,"projection")?void 0:Object.getOwnPropertyDescriptor(e,"terminalProjection")?.get===tt.get?t:void 0}function tn(e,t){let r=ti(e);return!!r&&(tr(t,r),!0)}var to=/^(?:class|data-[a-z][a-z0-9-]*|role|aria-[a-z]+|tabindex|pointer-events|transform|style)$/,ta=/^\s*<g\b[^>]*>(?:<title>[^<]*<\/title>)?$/,ts=/^\s*(?:--[A-Za-z0-9_-]+\s*:[^;]*(?:;\s*|$))*$/;function td({id:e,open:t,close:r,join:i,transform:n,paint:o}){if("</g>"!==r||!/^\s*$/.test(i))throw TypeError(`Group "${e}" close and join must not add artwork`);let a=new Set,s,d=ta.test(t)?w(t,"g",(t,r)=>{if(a.has(t))throw TypeError(`Group "${e}" open has a duplicate "${t}"`);if(a.add(t),"opacity"!==t&&"fill"!==t||o?.[t]===void 0||C(r)!==o[t]){if(!to.test(t))throw TypeError(`Group "${e}" open sets "${t}"; paint and geometry belong to typed marks`);if("style"===t&&!ts.test(C(r)))throw TypeError(`Group "${e}" open style may only set custom properties; paint belongs to typed marks`);"transform"===t&&(s=r)}}):void 0;if(["opacity","fill"].some(e=>a.has(e)!==(o?.[e]!==void 0)))throw TypeError(`Group "${e}" open disagrees with its typed paint`);if("g"!==d)throw TypeError(`Group "${e}" open must be one <g> tag with an optional <title>`);let l=void 0===s?void 0:C(s),c=void 0===l?void 0:function(e){let t=ej,r=0;for(let i of e.matchAll(/([A-Za-z]+)\s*\(([^()]*)\)/g)){let n;if(e.slice(r,i.index).trim())return;r=i.index+i[0].length;let o=i[2].trim();if(!o||/^(?:,)|(?:,)$|,\s*,/.test(o)||!/^[-+\d.eE,\s]+$/.test(o))return;let a=o.split(/[\s,]+/).map(Number);if(!a.every(Number.isFinite))return;if("matrix"===i[1]&&6===a.length)n=a;else if("translate"===i[1]&&(1===a.length||2===a.length))n=[1,0,0,1,a[0],a[1]??0];else if("scale"===i[1]&&(1===a.length||2===a.length))n=[a[0],0,0,a[1]??a[0],0,0];else{if("rotate"!==i[1]||1!==a.length&&3!==a.length)return;n=e_({kind:"rotate",angle:a[0],cx:a[1]??0,cy:a[2]??0})}t=eI(t,n)}return r>0&&!e.slice(r).trim()?t:void 0}(l),u=n?e_(n):void 0;if(void 0!==l&&!c)throw TypeError(`Group "${e}" open has an unsupported transform`);if(!!c!=!!u||c&&u&&c.some((e,t)=>Math.abs(e-u[t])>1e-9*Math.max(1,Math.abs(e))))throw TypeError(`Group "${e}" open transform disagrees with its typed transform`);return{matrix:c&&Object.freeze(c),style:a.has("style")}}function tl(e,t){let r=[...e].map(e=>e.codePointAt(0)),i=[...t].map(e=>e.codePointAt(0)),n=Math.min(r.length,i.length);for(let e=0;e<n;e++){let t=r[e]-i[e];if(0!==t)return t}return r.length-i.length}var tc=class{value="";raw(e){this.value+=e}attribute(e,t){this.value+=` ${e}="${"number"==typeof t?k(t):b(v(e,t))}"`}},tu=new Set(["id","role","from","to","relationship","direction","prepared-text","font-metrics","text-fragment","connector-label-for"]),tm=/^[A-Za-z0-9_-]+(?: [A-Za-z0-9_-]+)*$/,tf=/^[a-z][a-z0-9-]*$/;function tp(e,t){if(t){if(t.className&&e.attribute("class",t.className),t.data)for(let r of Object.keys(t.data))e.attribute(`data-${r}`,t.data[r]);t.ariaHidden&&e.attribute("aria-hidden","true"),0===t.tabIndex&&e.attribute("tabindex",0),void 0!==t.ariaLabel&&e.attribute("aria-label",t.ariaLabel)}}function th(e,t){void 0!==t.fill&&e.attribute("fill",t.fill),void 0!==t.fillOpacity&&e.attribute("fill-opacity",t.fillOpacity),void 0!==t.stroke&&e.attribute("stroke",t.stroke),void 0!==t.strokeOpacity&&e.attribute("stroke-opacity",t.strokeOpacity),void 0!==t.strokeWidth&&e.attribute("stroke-width",t.strokeWidth),void 0!==t.strokeDasharray&&e.attribute("stroke-dasharray",t.strokeDasharray),void 0!==t.strokeDashoffset&&e.attribute("stroke-dashoffset",t.strokeDashoffset),void 0!==t.strokeLinecap&&e.attribute("stroke-linecap",t.strokeLinecap),void 0!==t.strokeLinejoin&&e.attribute("stroke-linejoin",t.strokeLinejoin),void 0!==t.strokeMiterlimit&&e.attribute("stroke-miterlimit",t.strokeMiterlimit),void 0!==t.vectorEffect&&e.attribute("vector-effect",t.vectorEffect),void 0!==t.paintOrder&&e.attribute("paint-order",t.paintOrder),void 0!==t.opacity&&e.attribute("opacity",t.opacity)}function tg(e,t){t&&e.attribute("transform",eB(t))}function ty(e,t,r){t&&ea(t.role)&&(e.attribute("data-id",t.id),e.attribute("data-role",t.role),void 0!==t.from&&e.attribute("data-from",t.from),void 0!==t.to&&e.attribute("data-to",t.to)),r&&(e.attribute("role",r.role),e.attribute("aria-roledescription",r.roleDescription),e.attribute("aria-label",r.label))}function tb(e,t){switch(t.kind){case"rect":e.attribute("x",t.x),e.attribute("y",t.y),e.attribute("width",t.width),e.attribute("height",t.height),void 0!==t.rx&&e.attribute("rx",t.rx),void 0!==t.ry&&e.attribute("ry",t.ry);return;case"circle":e.attribute("cx",t.cx),e.attribute("cy",t.cy),e.attribute("r",t.r);return;case"ellipse":e.attribute("cx",t.cx),e.attribute("cy",t.cy),e.attribute("rx",t.rx),e.attribute("ry",t.ry);return;case"line":e.attribute("x1",t.x1),e.attribute("y1",t.y1),e.attribute("x2",t.x2),e.attribute("y2",t.y2);return;case"polygon":case"polyline":{let r="";for(let e=0;e<t.points.length;e++){let i=t.points[e];r+=`${e?" ":""}${i.x},${i.y}`}e.attribute("points",r);return}case"path":e.attribute("d",t.d)}}var tx=new WeakMap,tk=new WeakSet,tv=new WeakMap,tE=/<\s*text/i;function t$(e){if(!e.includes("<svg"))return e;let t="",r=0;for(;r<e.length;){let i=e.indexOf("<",r);if(i<0)return t+e.slice(r);if(t+=e.slice(r,i),e.startsWith("\x3c!--",i)){let n=e.indexOf("--\x3e",i+4);if(n<0)return t+e.slice(i);t+=e.slice(i,n+3),r=n+3;continue}let n,o=i+1;for(;o<e.length;o++){let t=e[o];if(n)t===n&&(n=void 0);else if('"'===t||"'"===t)n=t;else if(">"===t)break}if(o>=e.length)return t+e.slice(i);t+=function(e){let t=e.match(/^<([A-Za-z_][A-Za-z0-9_.:-]*)/);if(!t||e.startsWith("</")||e.startsWith("<!")||e.startsWith("<?"))return e;let r=t[1];if("svg"!==r)return e;let i=/\/\s*>$/.test(e),n=i?e.lastIndexOf("/"):e.length-1,o=[],a=t[0].length;for(;a<n;){for(;/\s/.test(e[a]??"");)a++;if(a>=n)break;let t=e.slice(a).match(/^([^\s=<>/]+)/);if(!t)return e;let r=t[1];for(a+=t[0].length;/\s/.test(e[a]??"");)a++;if("="!==e[a])return e;for(a++;/\s/.test(e[a]??"");)a++;let i=e[a];if('"'!==i&&"'"!==i)return e;let s=++a;for(;a<n&&e[a]!==i;)a++;if(e[a]!==i)return e;let d=e.slice(s,a);a++,o.push({name:r,value:'"'===i?d:d.replaceAll('"',"&quot;"),index:o.length})}let s=new Map([["xmlns",0],["width",1],["height",2],["viewBox",3],["style",4]]);o.sort((e,t)=>(s.get(e.name)??100)-(s.get(t.name)??100)||tl(e.name,t.name)||e.index-t.index);let d=o.map(e=>`${e.name}="${e.value}"`).join(" ");return`<${r}${d?` ${d}`:""}${i?" /":""}>`}(e.slice(i,o+1)),r=o+1}return t}function tw(e,t){if("document"!==e.kind)throw TypeError(`Scene ${e.kind} "${e.id}" is written from its fields, not stored markup`);return tx.set(e,t$(t)),e}function tS(e){return tk.add(e),e}function tN(e){let t=tx.get(e);if(void 0!==t)return t;if(!tk.has(e))throw TypeError(`Scene node "${e.id}" has no admitted SVG serialization`);let r=tv.get(e);if(void 0!==r)return r;let i=function(e){switch(e.kind){case"shape":return function(e){let t=new tc,r="compound"===e.geometry.kind,i="compound"===e.geometry.kind?e.geometry.children:[e.geometry];for(let n=0;n<i.length;n++){let o=i[n];if("compound"===o.kind)throw TypeError(`Shape "${e.id}" nests compound geometry`);n&&t.raw(`
4
+ `),t.raw(`<${o.kind}`),0===n&&tp(t,e.attributes),tb(t,o),th(t,r?e.childPaints?.[n]??e.paint:e.paint),tg(t,e.transform),0===n&&ty(t,e.identity,e.accessibility),t.raw(" />")}return t.value}(e);case"text":return function(e){let t=new tc;tp(t,e.attributes),t.attribute("text-anchor",e.anchor),e.dominantBaseline&&t.attribute("dominant-baseline",e.dominantBaseline),e.block?.fontFamily&&t.attribute("font-family",e.block.fontFamily),t.attribute("font-size",e.fontSize),t.attribute("font-weight",e.fontWeight??e.block?.fontWeight??400),(e.letterSpacing??0)!==0&&t.attribute("letter-spacing",e.letterSpacing),e.fontStyle&&t.attribute("font-style",e.fontStyle),e.textDecoration&&t.attribute("text-decoration",e.textDecoration),th(t,e.paint),tg(t,e.transform),ty(t,e.identity,e.accessibility);let r=t.value.slice(1),i="prepared"===e.measurement&&e.block,n=x(i?e.block:e.text,e.x,e.y,e.fontSize,r,e.baselineShift??.35,"literal"===e.display);if(!e.spans)return n;let o=i?e.block.text:e.text,a=`>${y(o)}</text>`;if(!n.endsWith(a))throw TypeError(`Text "${e.id}" spans require a one-line label`);let s="";for(let t of e.spans)s+=`<tspan fill="${b(t.fill)}">${y(t.text)}</tspan>`;return`${n.slice(0,-a.length)}>${s}</text>`}(e);case"connector":return function(e){let t=new tc,{stroke:r,markers:i}=e,n=r.dash,o=i.mid[0];if("invisible"!==e.lineStyle){let a=e.route.geometry;t.raw(`<${a.kind}`),tp(t,e.attributes),tb(t,a),"line"!==a.kind&&t.attribute("fill","none"),t.attribute("stroke",r.color),void 0!==r.opacity&&t.attribute("stroke-opacity",r.opacity),t.attribute("stroke-width",r.width),n&&t.attribute("stroke-dasharray","string"==typeof n.array?n.array:n.array.join(" ")),n?.offset!==void 0&&t.attribute("stroke-dashoffset",n.offset),"butt"!==r.lineCap&&t.attribute("stroke-linecap",r.lineCap),"miter"!==r.lineJoin&&t.attribute("stroke-linejoin",r.lineJoin),4!==r.miterLimit&&t.attribute("stroke-miterlimit",r.miterLimit),void 0!==r.pathLength&&t.attribute("pathLength",r.pathLength),void 0!==r.paintOrder&&t.attribute("paint-order",r.paintOrder),r.nonScaling&&t.attribute("vector-effect","non-scaling-stroke"),r.mixBlendMode&&t.attribute("style",`mix-blend-mode:${r.mixBlendMode}`),i.start&&t.attribute("marker-start",`url(#${i.start.id})`),o&&t.attribute("marker-mid",`url(#${o.id})`),i.end&&t.attribute("marker-end",`url(#${i.end.id})`),"none"===e.hit.pointerEvents&&t.attribute("pointer-events","none"),tg(t,e.transform),t.attribute("data-relationship",e.relationship.kind),t.attribute("data-direction",e.relationship.direction),ty(t,e.identity,e.accessibility),t.raw(" />")}for(let r=0;r<e.labels.length;r++){let i=function(e,t,r){if(t.visual?.kind!=="inline")return;if(!t.anchor||!t.paint||void 0===t.fontSize||void 0===t.textAnchor)throw TypeError(`Connector "${e.id}" inline label ${r+1} requires anchor, paint, fontSize, and textAnchor`);let i=eZ(t),n={...t.paint,...t.halo?{stroke:t.halo.color??"var(--bg)",strokeWidth:String(t.halo.width),paintOrder:"stroke fill"}:{}},o=new tc;return o.attribute("data-id",t.id??`${e.id}-label-${r+1}`),o.attribute("data-role","label"),o.attribute("data-connector-label-for",e.id),o.attribute("font-size",i.fontSize),o.attribute("font-weight",i.fontWeight),i.letterSpacing&&o.attribute("letter-spacing",i.letterSpacing),o.attribute("text-anchor",t.textAnchor),tg(o,e.transform),th(o,n),x(i,t.anchor.x,t.anchor.y-Math.max(0,t.clearance??0),i.fontSize,o.value.slice(1),0)}(e,e.labels[r],r);void 0!==i&&(t.value&&t.raw(`
5
+ `),t.raw(i))}return t.value}(e);case"group":return[e.open,...e.children.map(e=>tC(tN(e.node),e.indent)),e.close].join(e.join);case"document":throw TypeError(`Scene node "${e.id}" has no admitted SVG serialization`)}}(e);return"group"!==e.kind&&Object.isFrozen(e)&&tv.set(e,i),i}function tC(e,t){if(t<=0||""===e)return e;let r=" ".repeat(t);return r+e.replace(/\n/g,`
6
+ ${r}`)}function tM(e,t){let r=tx.get(e);void 0!==r&&tx.set(t,r),tk.has(e)&&tk.add(t)}function tz(e){let t=e=>{if("document"===e.kind){let t=tx.get(e);return void 0!==t&&!tE.test(t)}if(!tk.has(e))return!1;switch(e.kind){case"text":return"prepared"===e.measurement&&void 0!==e.block;case"shape":case"connector":return!0;case"group":return!tE.test(e.open)&&!tE.test(e.close)&&e.children.every(e=>t(e.node))}};return e.parts.every(t)}function tO(e,t){if(t){for(let r of Object.keys(t))if("className"!==r&&"data"!==r&&"ariaHidden"!==r&&"tabIndex"!==r&&"ariaLabel"!==r)throw TypeError(`Mark "${e}" has unknown attribute hook "${r}"`);if(void 0!==t.className&&!tm.test(t.className))throw TypeError(`Mark "${e}" class must be space-separated CSS tokens`);for(let[r,i]of Object.entries(t.data??{})){if(!tf.test(r))throw TypeError(`Mark "${e}" has an invalid data attribute key "${r}"`);if(tu.has(r))throw TypeError(`Mark "${e}" data-${r} belongs to its typed fields`);if("string"!=typeof i)throw TypeError(`Mark "${e}" data-${r} must be a string`)}if(void 0!==t.ariaHidden&&!0!==t.ariaHidden)throw TypeError(`Mark "${e}" ariaHidden must be true when present`);if(void 0!==t.tabIndex&&0!==t.tabIndex)throw TypeError(`Mark "${e}" tabIndex must be 0 when present`);if(void 0!==t.ariaLabel&&"string"!=typeof t.ariaLabel)throw TypeError(`Mark "${e}" ariaLabel must be a string`)}}var tT=new WeakMap;function tj(e){return tT.get(e)}function t_(e){if(e.identity)return{...e.identity,role:e.role};let t=e.attributes?.className?.split(" ");return{id:e.id,role:e.role,...t?{classNames:t}:{}}}function tI(e){if(tO(e.id,e.attributes),e.childPaints&&("compound"!==e.geometry.kind||e.childPaints.length!==e.geometry.children.length))throw TypeError(`Shape "${e.id}" child paints must match its compound geometry`);if(!1===e.identity&&e.owner?.role!==e.role)throw TypeError(`Shape "${e.id}" without DOM identity requires an explicit owner with the same role`);let t=!1===e.identity?void 0:t_(e),r=t?ed(t,e.attributes?.data?.label):void 0;if(r&&e.attributes?.ariaLabel!==void 0)throw TypeError(`Shape "${e.id}" takes its aria-label from typed relation accessibility`);return tS({kind:"shape",id:e.id,role:e.role,...t?{identity:t}:{},...e.owner?{owner:e.owner}:{},...e.visibility?{visibility:e.visibility}:{},...r?{accessibility:r}:{},geometry:e.geometry,paint:e.paint,...e.childPaints?{childPaints:e.childPaints}:{},...e.conditionalPaint?{conditionalPaint:e.conditionalPaint}:{},...void 0!==e.surfaceFragment?{surfaceFragment:e.surfaceFragment}:{},...e.channels?{channels:e.channels}:{},...e.transform?{transform:e.transform}:{},...e.attributes?{attributes:e.attributes}:{}})}var tA={id:!0,role:!0,geometry:!0,lineStyle:!0,paint:!0,identity:!0,owner:!0,visibility:!0,endpoints:!0,relationship:!0,route:!0,stroke:!0,markers:!0,labels:!0,hit:!0,terminalProjection:!0,channels:!0,transform:!0,attributes:!0},tD={start:!0,mid:!0,end:!0};function tB(e,t,r){if(!e||"object"!=typeof e||Array.isArray(e))throw TypeError(`${r} fields must be an object`);for(let i of Reflect.ownKeys(e))if(!Object.hasOwn(t,i))throw TypeError(`unknown ${r} field "${String(i)}"`)}function tL(e,t){return t?{...e,...t,...t.owner?{owner:{...t.owner}}:{},...t.point?{point:{...t.point}}:{}}:e??{}}function tP(e){var t;let r;if(tB(e,tA,"connector"),void 0!==e.markers&&tB(e.markers,tD,"marker"),"path"!==e.geometry.kind&&e.route?.closed===!0)throw TypeError(`Connector "${e.id}" closed route topology requires path geometry`);if("path"===e.geometry.kind){let r=e.geometry,i=r.subpaths,n=(t=r.d,t.match(/[Mm](?=\s*[-+.]?\d)/g)?.length??0);if(n>1&&!i)throw TypeError(`Connector "${e.id}" path has multiple SVG subpaths but no typed subpaths`);if(i){if(0===i.length||i.some(e=>e.points.length<2))throw TypeError(`Connector "${e.id}" typed subpaths must each contain at least two points`);if(n!==i.length)throw TypeError(`Connector "${e.id}" typed subpath count disagrees with SVG path moves`);let t=i.flatMap(e=>e.points);if(t.length!==r.points.length||t.some((e,t)=>{let i=r.points[t];return!i||i.x!==e.x||i.y!==e.y}))throw TypeError(`Connector "${e.id}" typed subpaths disagree with the canonical point projection`)}}let i=eS(e.geometry,e.route?.closed??!1),n=1===i.length&&i[0].closed;if("path"===e.geometry.kind&&e.geometry.subpaths&&e.route?.closed!==void 0&&e.route.closed!==n)throw TypeError(`Connector "${e.id}" route.closed disagrees with typed subpath topology`);let o="path"===e.geometry.kind&&e.geometry.subpaths?n:e.route?.closed??!1;if("path"===e.geometry.kind&&(e.geometry.d.match(/[Zz]/g)?.length??0)!==(e.geometry.subpaths?e.geometry.subpaths.filter(e=>e.closed).length:+!!o))throw TypeError(`Connector "${e.id}" SVG close commands disagree with typed closed-contour semantics`);let a=e.markers?.start,s=e.markers?.end,d=e.markers?.mid??[];for(let t of[a,...d,s])if(t?.geometry?.kind==="path"&&!t.bounds&&!t.viewBox&&!t.size)throw TypeError(`Connector "${e.id}" path marker "${t.id}" requires bounds, viewBox, or size`);!function(e,t,r,i){if(0===i.length)return;let n=eO(t,r).length;if(0===n)throw RangeError(`Connector "${e}" has mid markers but no typed interior route points`);if(1!==i.length&&i.length!==n)throw RangeError(`Connector "${e}" mid markers must contain one repeated descriptor or one descriptor per interior route point`);if(1!==new Set(i.map(e=>e.id)).size)throw RangeError(`Connector "${e}" uses distinct mid markers that one SVG marker-mid carrier cannot represent`);i[0].id}(e.id,e.geometry,o,d);let l=function(e,t){if("line"===e.kind)return{start:{point:{x:e.x1,y:e.y1}},end:{point:{x:e.x2,y:e.y2}}};let r=eS(e,t),i=r[0]?.points[0],n=r.at(-1),o=n?.closed?n.points[0]:n?.points.at(-1);return{...i?{start:{point:{...i}}}:{},...o?{end:{point:{...o}}}:{}}}(e.geometry,o);for(let t of["start","end"]){let r=e.endpoints?.[t]?.point,i=l[t]?.point;if(r&&i&&!e$(r,i))throw TypeError(`Connector "${e.id}" endpoints.${t}.point disagrees with typed route geometry`)}let c={...e.endpoints??{},start:tL(l.start,e.endpoints?.start),end:tL(l.end,e.endpoints?.end)},m={kind:e.relationship?.kind??e.role,direction:e.relationship?.direction??(void 0!==c.from&&c.from===c.to?"self":a&&s?"bidirectional":a?"reverse":s?"forward":"undirected")},f=(e.labels??[]).map(e=>{let t=p(e.text,e.textContent),r=u(e.text);return{...e,text:r,..."string"!=typeof t?{textContent:{...e.textContent,value:r}}:{}}}),h={id:e.identity?.id??e.id,role:e.role,...e.identity?.classNames?{classNames:e.identity.classNames}:{},...e.identity?.from??c.from?{from:e.identity?.from??c.from}:{},...e.identity?.to??c.to?{to:e.identity?.to??c.to}:{}},y=f[0],b=ed(h,y?.visual?.kind==="inline"?eZ(y).lineBlocks.map(e=>e.runs.map(e=>e.text).join("")).join(`
7
+ `):y?g(p(y.text,y.textContent),y.display??"literal"):void 0);if(tO(e.id,e.attributes),b&&e.attributes?.ariaLabel!==void 0)throw TypeError(`Connector "${e.id}" takes its aria-label from typed relation accessibility`);for(let[t,r]of f.entries())if(r.visual?.kind==="inline"&&(!r.anchor||!r.paint||void 0===r.fontSize||void 0===r.textAnchor))throw TypeError(`Connector "${e.id}" inline label ${t+1} requires anchor, paint, fontSize, and textAnchor`);let x=e.stroke?.width??e.paint.strokeWidth??"1",k=e.stroke?.dash??(e.paint.strokeDasharray?{array:e.paint.strokeDasharray,...void 0!==e.paint.strokeDashoffset?{offset:e.paint.strokeDashoffset}:{}}:void 0),v=e.stroke?.opacity??e.paint.opacity,E=e.stroke?.paintOrder??e.paint.paintOrder,$=e.stroke?.mixBlendMode,w={color:e.stroke?.color??e.paint.stroke??"var(--_line)",width:x,...void 0!==v?{opacity:v}:{},...k?{dash:k}:{},lineCap:e.stroke?.lineCap??e.paint.strokeLinecap??"butt",lineJoin:e.stroke?.lineJoin??e.paint.strokeLinejoin??"miter",miterLimit:e.stroke?.miterLimit??Number(e.paint.strokeMiterlimit??4),...e.stroke?.pathLength!==void 0?{pathLength:e.stroke.pathLength}:{},...void 0!==E?{paintOrder:E}:{},...void 0!==$?{mixBlendMode:$}:{},nonScaling:e.stroke?.nonScaling??"non-scaling-stroke"===e.paint.vectorEffect,...e.stroke?.encodesValue?{encodesValue:!0}:{}},S=eC(e.geometry,o),N=e.route?.contours;if(N&&(N.length!==S.length||N.some((e,t)=>{let r=S[t];return!r||e.start.x!==r.start.x||e.start.y!==r.start.y||e.end.x!==r.end.x||e.end.y!==r.end.y||e.closed!==r.closed})))throw TypeError(`Connector "${e.id}" route contours disagree with typed subpath endpoint topology`);if(!eN(e.geometry)&&N)for(let[t,r]of N.entries()){let i=S[t];for(let n of["startTangent","endTangent"]){let o=r[n],a=i[n];if(o&&(!a||!e$(o,a,1e-9)))throw TypeError(`Connector "${e.id}" route.contours[${t}].${n} disagrees with linear route geometry`)}}let C=N?S.map((e,t)=>{let r=N?.[t],i=r?.startTangent??e.startTangent,n=r?.endTangent??e.endTangent;return{start:{...e.start},end:{...e.end},closed:e.closed,...i?{startTangent:i}:{},...n?{endTangent:n}:{}}}):S;for(let t of C)for(let r of[t.startTangent,t.endTangent]){if(!r)continue;let t=Math.hypot(r.x,r.y);if(!Number.isFinite(t)||Math.abs(t-1)>1e-9)throw TypeError(`Connector "${e.id}" contour tangents must be finite unit vectors`)}for(let t of[e.route?.startTangent,e.route?.endTangent]){if(!t)continue;let r=Math.hypot(t.x,t.y);if(!Number.isFinite(r)||Math.abs(r-1)>1e-9)throw TypeError(`Connector "${e.id}" route tangents must be finite unit vectors`)}for(let[t,r,i]of[["startTangent",e.route?.startTangent,C[0]?.startTangent],["endTangent",e.route?.endTangent,C.at(-1)?.endTangent]])if(r&&i&&!e$(r,i,1e-9))throw TypeError(`Connector "${e.id}" route.${t} disagrees with its contour tangent authority`);let M={geometry:e.geometry,ownership:e.route?.ownership??"family",closed:o,bendRadius:e.route?.bendRadius??0,contours:C,...e.route?.startTangent??C[0]?.startTangent?{startTangent:e.route?.startTangent??C[0]?.startTangent}:{},...e.route?.endTangent??C.at(-1)?.endTangent?{endTangent:e.route?.endTangent??C.at(-1)?.endTangent}:{},labelAnchors:e.route?.labelAnchors??f.flatMap(e=>e.anchor?[e.anchor]:[])};if(e.hit?.closed!==void 0&&e.hit.closed!==o)throw TypeError(`Connector "${e.id}" hit.closed must match route.closed topology`);let z={geometry:e.hit?.geometry??e.geometry,closed:e.hit?.closed??o,strokeWidth:e.hit?.strokeWidth??Math.max(6,Number.isFinite(r="number"==typeof x?x:parseFloat(x))?Math.max(0,r):1),pointerEvents:e.hit?.pointerEvents??("invisible"===e.lineStyle?"none":"stroke")},O={geometry:e.geometry,lineStyle:e.lineStyle,endpoints:c,relationship:m,route:M,stroke:w,markers:{...a?{start:a}:{},mid:d,...s?{end:s}:{}},labels:f,hit:z,...e.transform?{transform:e.transform}:{},additionalDiagnostics:e.terminalProjection?.diagnostics},T={kind:"connector",id:e.id,role:e.role,lineStyle:e.lineStyle,endpoints:c,relationship:m,route:M,stroke:w,markers:{...a?{start:a}:{},mid:d,...s?{end:s}:{}},labels:f,hit:z,terminalProjection:void 0,identity:h,...e.owner?{owner:e.owner}:{},...e.visibility?{visibility:e.visibility}:{},...b?{accessibility:b}:{},...e.channels?{channels:e.channels}:{},...e.transform?{transform:e.transform}:{},...e.attributes?{attributes:e.attributes}:{}};return function(e,t){if(0===e9||"path"===t.geometry.kind||void 0!==t.additionalDiagnostics&&!t.additionalDiagnostics.every(e=>"string"==typeof e)){e.terminalProjection=e8(t);return}t.additionalDiagnostics&&Object.defineProperty(t,"additionalDiagnostics",{value:Object.freeze([...t.additionalDiagnostics])}),tr(e,Object.freeze(t))}(T,O),tS(T)}function tF(e){let{block:t,...r}=e;if(t){for(let r of["fontSize","fontWeight","letterSpacing"])if(void 0!==e[r]&&e[r]!==t[r])throw TypeError(`Text "${e.id}" ${r} differs from its retained prepared block`)}tO(e.id,e.attributes);let i=e.fontWeight??t?.fontWeight??400,n=e.letterSpacing??t?.letterSpacing??0,o=e.display??t?.prepared.display??"formatted",a=t??eE(e.text,{display:o,fontSize:e.fontSize,fontWeight:i,letterSpacing:n});if(e.spans&&(1!==a.lines.length||e.spans.map(e=>e.text).join("")!==a.text))throw TypeError(`Text "${e.id}" spans must spell its one displayed line`);let d=e.baselineShift??.35,l=a.lines.length,c=t?t.lineHeight:e.fontSize*s,u=(1===l?0:-((l-1)/2)*c)+e.fontSize*d,m="hanging"===e.dominantBaseline?a.lineHeight/2:"middle"===e.dominantBaseline||"central"===e.dominantBaseline?0:-(.35*e.fontSize),f=u+(l-1)*a.lineHeight/2+m,p=t_(e),h=ed(p,e.attributes?.data?.label);if(h&&e.attributes?.ariaLabel!==void 0)throw TypeError(`Text "${e.id}" takes its aria-label from typed relation accessibility`);return tS({kind:"text",...r,identity:p,accessibility:h,block:a,measurement:t?"prepared":"fallback",...t?{prepared:!0,preparedLines:t.lineBlocks.map(e=>e.runs)}:{},fontWeight:i,letterSpacing:n,display:o,textLayout:{width:a.width,height:a.height,lineHeight:a.lineHeight,offsetY:f}})}function tU(e,t){return tw({kind:"document",element:"content",...e},t)}function tR(e){let t="title"===e.element?"title":"desc",r=e.domId?` id="${b(e.domId)}"`:"";return tw({kind:"document",role:"chrome",...e},`<${t}${r}>${y(e.text)}</${t}>`)}function tW(e,t){return tw({kind:"document",role:"defs",element:"definitions",...e},t)}function tq(){return tw({kind:"document",id:"svg-close",role:"chrome",element:"close"},"</svg>")}function tG(e){let t,r,i,n,o,a=e.open,s=e.close,d=e.join??`
8
+ `,l=td({id:e.id,open:a,close:s,join:d,transform:e.transform}),c=(t=a.match(/^\s*<([A-Za-z][\w:-]*)\b[^>]*>/)?.[0]??"",i=((r=e=>{let r=t.match(RegExp(`\\s${e}="([^"]*)"`))?.[1];return void 0===r?void 0:C(r)})("class")??"").split(/\s+/).filter(Boolean),n=r("data-from"),o=r("data-to"),{id:r("data-id")??e.id,role:e.role,...void 0!==n?{from:n}:{},...void 0!==o?{to:o}:{},...i.length>0?{classNames:i}:{}}),u=e.paint,m=u?.opacity,f=u?.fill,p=u&&[...void 0!==m?[`opacity="${b(m)}"`]:[],...void 0!==f?[`fill="${b(f)}"`]:[]].join(" "),h=p?a.replace(/^(\s*<g)\b/,`$1 ${p}`):a,g=e.owner??{id:c.id,role:c.role},y=e.children.map(e=>{var t;let r;if(e.node.owner||"document"===e.node.kind||"group"===e.node.kind)return e;if(ti(e.node)){let t={};for(let r of Object.keys(e.node))t[r]="terminalProjection"===r?void 0:e.node[r];t.owner=g,r=t,tn(e.node,r)}else r={...e.node,owner:g};return t=e.node,(tx.has(t)||tk.has(t))&&tM(e.node,r),{...e,node:r}}),x=t$(es(h,c)),k=tS({kind:"group",id:e.id,role:e.role,open:x,close:s,children:y,join:d,channels:e.channels,identity:c,owner:g,...e.visibility?{visibility:e.visibility}:{},...e.transform?{transform:e.transform}:{},...u?{paint:u}:{}});return tT.set(k,Object.freeze({open:x,opacity:m,...l,style:l.style||void 0!==f})),k}function tV(e,t){return tw({kind:"document",element:"open",id:e.id,role:"prelude"},t)}function tH(e){return tZ({shape:tI,group:tG},e)}function tZ(e,t){return e.group({id:t.id,role:"icon",open:t.open,close:"</g>",...t.transform?{transform:t.transform}:{},...t.owner?{owner:t.owner}:{},...t.channels?{channels:t.channels}:{},join:t.join??"",children:t.paths.map((r,i)=>({indent:t.indent??0,node:e.shape({id:eo(t.id,"path",i),role:"icon",geometry:{kind:"path",d:r},paint:t.paint,...t.owner?{owner:t.owner}:{}})}))})}function tY(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\\(?:\r\n|[\n\r\f])/g,"").replace(/\\([0-9a-fA-F]{1,6})\s?/g,(e,t)=>{let r=Number.parseInt(t,16);return Number.isFinite(r)?String.fromCodePoint(r):""}).replace(/\\([^\n\r\f])/g,"$1")}var tJ=/\s([^\s=<>]+)\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/g,tK=/<(?:[^\s<>/:]+:)?(?:animate(?:Motion|Transform)?|set)\b/i,tQ=/^on[a-z]/,tX=/[(:@\\&]/,t0=/^(?:javascript|vbscript|data|file):/,t1=/(?:javascript|vbscript|data|file)\s*:/i,t2=/(?:expression|behavior)\s*\(/i,t3=/(?:expression|behavior)\s*\(|-moz-binding\s*:/i,t5=new Set(["amp","lt","gt","quot","apos"]);function t4(e){return" "===e||" "===e||e===`
9
+ `||"\r"===e}function t6(e,t){let r=e.charCodeAt(t),i=32|r;if(!(i>=97&&i<=122||95===r))return -1;let n=t+1;for(;$(e[n]);)n++;return n}var t8="http://www.w3.org/XML/1998/namespace";function t7(e){return 9===e||10===e||13===e||e>=32&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111}function t9(e){for(let t=e.indexOf("&");t>=0;t=e.indexOf("&",t+1)){let r=e.indexOf(";",t+1);if(r<0)return!1;let i=e.slice(t+1,r);if(i.startsWith("#x")||i.startsWith("#X")){if(!/^[0-9a-f]+$/i.test(i.slice(2))||!t7(Number.parseInt(i.slice(2),16)))return!1}else if(i.startsWith("#")){if(!/^[0-9]+$/.test(i.slice(1))||!t7(Number.parseInt(i.slice(1),10)))return!1}else if(!t5.has(i))return!1;t=r}return!0}function re(e,t){if(/[\0-\x08\x0b\x0c\x0e-\x1f\ud800-\udfff\ufffe\uffff]/u.test(e))return!1;let r=[],i=!1,n=!1,o=0;for(;o<e.length;){let a;if("<"!==e[o]){let t=e.indexOf("<",o),i=t<0?e.length:t,n=e.slice(o,i);if(0===r.length&&""!==n.trim()||n.includes("]]>")||!t9(n))return!1;o=i;continue}if(e.startsWith("\x3c!--",o)){if(0===r.length)return!1;let t=e.indexOf("--\x3e",o+4),i=t<0?"":e.slice(o+4,t);if(t<0||i.includes("--")||i.endsWith("-"))return!1;o=t+3;continue}if(e.startsWith("<![CDATA[",o)||e.startsWith("<!",o)||e.startsWith("<?",o))return!1;if(e.startsWith("</",o)){let t=t6(e,o+2);if(t<0)return!1;let i=e.slice(o+2,t);if(i.includes(":"))return!1;for(;t4(e[t]);)t++;if(">"!==e[t]||r.pop()?.name!==i)return!1;if(o=t+1,0===r.length){if("svg"!==i||n)return!1;n=!0}continue}let s=t6(e,o+1);if(s<0||n)return!1;let d=e.slice(o+1,s);if(d.includes(":"))return!1;if(0===r.length){if(i||"svg"!==d)return!1;i=!0}let l=s,c=new Set,u=[],m=!1;for(;;){let r=t4(e[l]);for(;t4(e[l]);)l++;if(">"===e[l]){l++;break}if("/"===e[l]&&">"===e[l+1]){m=!0,l+=2;break}if(!r)return!1;let i=t6(e,l);if(i<0)return!1;let n=e.slice(l,i);if(c.has(n))return!1;let o=n.includes(":"),a=o?function(e){let t=e.indexOf(":");if(!(t<=0||t===e.length-1||e.indexOf(":",t+1)>=0))return{prefix:e.slice(0,t),local:e.slice(t+1)}}(n):void 0;if(o&&!a)return!1;for(c.add(n),l=i;t4(e[l]);)l++;if("="!==e[l])return!1;for(l++;t4(e[l]);)l++;let s=e[l];if('"'!==s&&"'"!==s)return!1;let d=++l;if((l=e.indexOf(s,d))<0)return!1;let f=e.slice(d,l);if(f.includes("<")||!t9(f))return!1;(a||"xmlns"===n)&&u.push({name:n,...a,value:rt(f)}),t?.(n,f),l++}let f=r.at(-1)?.namespaces??new Map([["xml",t8]]),p;for(let e of u){let t="xmlns"===e.name,r="xmlns"===e.prefix;if(!t&&!r)continue;let i=t?"":e.local,n=e.value;if("xmlns"===i||"http://www.w3.org/2000/xmlns/"===n||"xml"===i&&n!==t8||"xml"!==i&&n===t8||""!==i&&""===n)return!1;p||(f=p=new Map(f)),p.set(i,n)}if("http://www.w3.org/2000/svg"!==f.get("")||r.length>0&&"svg"===d)return!1;for(let e of u){if("xmlns"===e.name||"xmlns"===e.prefix)continue;let t=f.get(e.prefix);if(void 0===t)return!1;let r=`${t}\0${e.local}`;if(a||(a=new Set),a.has(r))return!1;a.add(r)}if(o=l,m){if(0===r.length)return!1}else r.push({name:d,namespaces:f})}return i&&n&&0===r.length}function rt(e){if(!e.includes("&"))return e;let t=e;for(let e=0;e<3;e++){let e=t.replace(/&#x([0-9a-f]+);?/gi,(e,t)=>{let r=Number.parseInt(t,16);return Number.isFinite(r)&&r<=1114111?String.fromCodePoint(r):""}).replace(/&#([0-9]+);?/g,(e,t)=>{let r=Number.parseInt(t,10);return Number.isFinite(r)&&r<=1114111?String.fromCodePoint(r):""}).replace(/&colon;?/gi,":").replace(/&sol;?/gi,"/").replace(/&tab;?/gi," ").replace(/&newline;?/gi,`
10
+ `).replace(/&quot;?/gi,'"').replace(/&apos;?/gi,"'").replace(/&lt;?/gi,"<").replace(/&gt;?/gi,">").replace(/&amp;?/gi,"&");if(e===t)break;t=e}return t}function rr(e){return rt(e).replace(/[\u0000-\u0020\u007f-\u009f]+/g,"").toLowerCase()}function ri(e){let t=tY(rt(e)),r=[];for(let e of(/@import\b/i.test(t)&&r.push("@import"),t.matchAll(/url\s*\(\s*(["']?)([\s\S]*?)\1\s*\)/gi))){let t=rr(e[2]);""===t||t.startsWith("#")||r.push(`url(${e[2].trim()})`)}for(let e of t.matchAll(/(?:-webkit-)?(?:image-set|cross-fade)\s*\(/gi))r.push(`${e[0].slice(0,-1).trim()}()`);return r}function rn(e){return!!(t3.test(e)||t1.test(e))}var ro=new Set(["clip-path","cursor","fill","filter","marker-end","marker-mid","marker-start","mask","stroke","style"]);function ra(e,t){if(void 0!==e&&""!==e)return"string"!=typeof e?"Mermaid themeCSS must be a string":`Raw Mermaid themeCSS is not allowed in ${t} security mode because selectors can escape an imported SVG; use a declarative StyleSpec`}function rs(e,t,r,i){let n=e.slice(e.lastIndexOf(":")+1).toLowerCase();if(tQ.test(n)&&(r.push("inline-event-handler"),i.push("inline-event-handler")),"xml:base"===e.toLowerCase()&&r.push(`xml:base=${t}`),"href"===n||"src"===n||"data"===n){let n=rr(t);""===n||n.startsWith("#")||r.push(n.startsWith("javascript:")?"javascript-url":t),t0.test(n)&&i.push(`${e}=${t}`)}if(ro.has(n)||"values"===n||"from"===n||"to"===n){if(!tX.test(t))return;let n=tY(rt(t));(ri(n).length>0||t1.test(n)||t2.test(n))&&r.push(`${e}=${t}`),rn(n)&&i.push(`${e}=${t}`)}}function rd(e,t,r){for(let i of e.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/gi))rn(tY(rt(i[1])))&&r.push("active-css"),t.push(...ri(i[1]));for(let i of["script","foreignObject","image","object","embed","iframe"])RegExp(`<(?:[^\\s<>/:]+:)?${i}\\b`,"i").test(e)&&(t.push(`<${i}>`),"image"!==i&&r.push(`<${i}>`));return tK.test(e)&&(t.push("<animation>"),r.push("<animation>")),Object.freeze({active:Object.freeze(r),refs:Object.freeze(t)})}function rl(e){let{refs:t}=E("security",e,()=>(function(e){let t=e.replace(/<!--[\s\S]*?-->/g,""),r=[],i=[];for(let e of function(e){let t=[];for(let r=e.indexOf("<");r>=0;r=e.indexOf("<",r+1)){let i,n=e[r+1];if(n&&"/"!==n&&"!"!==n&&"?"!==n&&/[^\s<>]/.test(n))for(let n=r+1;n<e.length;n++){let o=e[n];if(i)o===i&&(i=void 0);else if('"'===o||"'"===o)i=o;else if(">"===o){t.push(e.slice(r,n+1)),r=n;break}}}return t}(t))for(let t of e.matchAll(RegExp(tJ.source,"g")))rs(t[1],function(e){let t=e[0];return('"'===t||"'"===t)&&e[e.length-1]===t?e.slice(1,-1):e}(t[2]),r,i);return rd(t,r,i)})(e));return{ok:0===t.length,refs:[...t]}}function rc(e,t="default"){let r=E("final-security",e,()=>{let t=[],r=[],i=!1,n;if(!re(e,(e,o)=>{if(!i)try{rs(e,o,t,r)}catch(e){i=!0,n=e}}))return!1;if(i)throw n;return rd(e.replace(/<!--[\s\S]*?-->/g,""),t,r)});if(!r)throw Error("OutputSecurityPolicy rejected an invalid SVG document envelope");let{active:i,refs:n}=r;if(i.length>0)throw Error(`OutputSecurityPolicy rejected active content: ${i.join(", ")}`);if("strict"===t&&n.length)throw Error(`OutputSecurityPolicy strict verification failed: ${n.join(", ")}`);return{svg:e,diagnostics:"strict"===t?[]:n.map(e=>({code:"EXTERNAL_REFERENCE",reference:e}))}}var ru=["document","text","shape","container","connector","marker","data-mark"];Object.freeze(ru.map(e=>Object.freeze({primitive:e,operation:"document"===e?"serialize":"render"})));var rm=["measure","layout","bounds","hit-test","render","accessibility","terminal-project","serialize"],rf=["geometry","paint","stroke","transform","identity","relation","labels","markers","resources","interaction","topology","subpaths","closedness","bend-radius","endpoints","direction","hit-geometry","stroke-opacity","stroke-cap","stroke-join","stroke-miter","dash-array","dash-offset","dash-restart","path-length","paint-order","compositing","non-scaling-stroke","marker-orientation","marker-overflow"],rp=Object.freeze([{primitive:"document",feature:"identity",operation:"serialize"},{primitive:"document",feature:"resources",operation:"serialize"},{primitive:"document",feature:"interaction",operation:"accessibility"},{primitive:"text",feature:"geometry",operation:"render"},{primitive:"text",feature:"paint",operation:"render"},{primitive:"text",feature:"labels",operation:"accessibility"},{primitive:"text",feature:"identity",operation:"serialize"},{primitive:"shape",feature:"geometry",operation:"render"},{primitive:"shape",feature:"paint",operation:"render"},{primitive:"shape",feature:"identity",operation:"serialize"},{primitive:"container",feature:"geometry",operation:"render"},{primitive:"container",feature:"paint",operation:"render"},{primitive:"container",feature:"identity",operation:"serialize"},{primitive:"connector",feature:"geometry",operation:"render"},{primitive:"connector",feature:"stroke",operation:"render"},{primitive:"connector",feature:"transform",operation:"render"},{primitive:"connector",feature:"topology",operation:"render"},{primitive:"connector",feature:"subpaths",operation:"render"},{primitive:"connector",feature:"closedness",operation:"render"},{primitive:"connector",feature:"bend-radius",operation:"render"},{primitive:"connector",feature:"stroke-opacity",operation:"render"},{primitive:"connector",feature:"stroke-cap",operation:"render"},{primitive:"connector",feature:"stroke-join",operation:"render"},{primitive:"connector",feature:"stroke-miter",operation:"render"},{primitive:"connector",feature:"dash-array",operation:"render"},{primitive:"connector",feature:"dash-offset",operation:"render"},{primitive:"connector",feature:"dash-restart",operation:"render"},{primitive:"connector",feature:"path-length",operation:"render"},{primitive:"connector",feature:"paint-order",operation:"render"},{primitive:"connector",feature:"compositing",operation:"render"},{primitive:"connector",feature:"non-scaling-stroke",operation:"render"},{primitive:"connector",feature:"marker-orientation",operation:"render"},{primitive:"connector",feature:"marker-overflow",operation:"render"},{primitive:"connector",feature:"endpoints",operation:"serialize"},{primitive:"connector",feature:"direction",operation:"serialize"},{primitive:"connector",feature:"labels",operation:"render"},{primitive:"connector",feature:"labels",operation:"accessibility"},{primitive:"connector",feature:"markers",operation:"render"},{primitive:"connector",feature:"relation",operation:"accessibility"},{primitive:"connector",feature:"interaction",operation:"hit-test"},{primitive:"connector",feature:"hit-geometry",operation:"hit-test"},{primitive:"connector",feature:"identity",operation:"serialize"},{primitive:"marker",feature:"geometry",operation:"render"},{primitive:"marker",feature:"paint",operation:"render"},{primitive:"marker",feature:"identity",operation:"serialize"},{primitive:"data-mark",feature:"geometry",operation:"render"},{primitive:"data-mark",feature:"paint",operation:"render"},{primitive:"data-mark",feature:"identity",operation:"serialize"}].map(e=>Object.freeze(e))),rh=["native","emulated","projected","lossy","unsupported"];function rg(e){switch(e.kind){case"text":return["text"];case"shape":return e.channels?.value===void 0?["shape"]:["shape","data-mark"];case"group":return["container"];case"connector":return["connector"];case"document":return e.markerResources?.length?["document","marker"]:["document"]}}function ry(e,t,r="rough"){let i="crisp"===t?"native":"emulated",n="crisp"===t?"native":"projected",o="src/__tests__/backend-capability-conformance.test.ts",a=e=>"crisp"===t?{realization:"native"}:"geometry"===e||"topology"===e?{realization:"lossy",diagnostic:"The exact authored path remains as an invisible semantic carrier, but arbitrary curves are flattened to typed routed contours for the visible sketch."}:"closedness"===e?{realization:"lossy",diagnostic:"Sketch shafts are rebuilt from routed geometry and do not preserve explicit closed-subpath semantics."}:"bend-radius"===e?{realization:"lossy",diagnostic:"The authored rounded carrier remains exact, but the visible sketch follows its routed polyline and cannot preserve the continuous bend radius."}:"dash-restart"===e?{realization:"lossy",diagnostic:"A rough stroke may contain multiple generated stroke subpaths, so SVG dash restart boundaries can differ."}:"path-length"===e?{realization:"lossy",diagnostic:"One pathLength value spans generated stroke subpaths, so a sketch cannot retain one authored path calibration exactly."}:"hybrid"===r&&("stroke-cap"===e||"stroke-join"===e||"stroke-miter"===e||"non-scaling-stroke"===e)?{realization:"lossy",diagnostic:`Freehand ribbon geometry cannot preserve authored ${e} semantics; dashed Hybrid connectors fall back to the faithful rough projection.`}:"marker-orientation"===e||"marker-overflow"===e?{realization:"projected",diagnostic:"Marker geometry, orientation, and overflow remain in the typed marker projection instead of being sketched."}:{realization:"emulated"},s=[{target:e,primitive:"document",feature:"identity",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"document",feature:"resources",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"document",feature:"interaction",operation:"accessibility",realization:"native",evidence:o},{target:e,primitive:"text",feature:"geometry",operation:"render",realization:"native",evidence:o},{target:e,primitive:"text",feature:"paint",operation:"render",realization:"native",evidence:o},{target:e,primitive:"text",feature:"labels",operation:"accessibility",realization:"native",evidence:o},{target:e,primitive:"text",feature:"identity",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"shape",feature:"geometry",operation:"render",realization:i,evidence:o},{target:e,primitive:"shape",feature:"paint",operation:"render",realization:i,evidence:o},{target:e,primitive:"shape",feature:"identity",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"container",feature:"geometry",operation:"render",realization:"native",evidence:o},{target:e,primitive:"container",feature:"paint",operation:"render",realization:"native",evidence:o},{target:e,primitive:"container",feature:"identity",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"connector",feature:"geometry",operation:"render",...a("geometry"),evidence:o},{target:e,primitive:"connector",feature:"stroke",operation:"render",realization:i,evidence:o},...["transform","topology","subpaths","closedness","bend-radius","stroke-opacity","stroke-cap","stroke-join","stroke-miter","dash-array","dash-offset","dash-restart","path-length","paint-order","compositing","non-scaling-stroke","marker-orientation","marker-overflow"].map(t=>({target:e,primitive:"connector",feature:t,operation:"render",...a(t),evidence:o})),{target:e,primitive:"connector",feature:"relation",operation:"accessibility",realization:"native",evidence:o},{target:e,primitive:"connector",feature:"endpoints",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"connector",feature:"direction",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"connector",feature:"labels",operation:"render",realization:"native",evidence:o},{target:e,primitive:"connector",feature:"labels",operation:"accessibility",realization:"native",evidence:o},{target:e,primitive:"connector",feature:"markers",operation:"render",realization:n,evidence:o},{target:e,primitive:"connector",feature:"interaction",operation:"hit-test",realization:"native",evidence:o},{target:e,primitive:"connector",feature:"hit-geometry",operation:"hit-test",realization:"native",evidence:o},{target:e,primitive:"connector",feature:"identity",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"marker",feature:"geometry",operation:"render",realization:n,evidence:o},{target:e,primitive:"marker",feature:"paint",operation:"render",realization:n,evidence:o},{target:e,primitive:"marker",feature:"identity",operation:"serialize",realization:"native",evidence:o},{target:e,primitive:"data-mark",feature:"geometry",operation:"render",realization:i,evidence:o},{target:e,primitive:"data-mark",feature:"paint",operation:"render",realization:i,evidence:o},{target:e,primitive:"data-mark",feature:"identity",operation:"serialize",realization:"native",evidence:o}],d=rx(s);if(!d.valid)throw Error(`Invalid graphical backend capability contract: ${d.diagnostics.join("; ")}`);return Object.freeze(s.map(e=>Object.freeze({...e})))}function rb(e){return[e.target,e.primitive,e.feature,e.operation].join("\0")}function rx(e){let t=[],r=new Set;for(let i=0;i<e.length;i++){let n=e[i],o=rb(n);r.has(o)&&t.push(`claim[${i}]: duplicate target/primitive/feature/operation`),r.add(o),""===n.target.trim()&&t.push(`claim[${i}]: target must not be empty`),""===n.primitive.trim()&&t.push(`claim[${i}]: primitive must not be empty`),""===n.feature.trim()&&t.push(`claim[${i}]: feature must not be empty`),""===n.operation.trim()&&t.push(`claim[${i}]: operation must not be empty`),rh.includes(n.realization)||t.push(`claim[${i}]: invalid realization ${String(n.realization)}`),"lossy"!==n.realization&&"unsupported"!==n.realization||n.diagnostic?.trim()||t.push(`claim[${i}]: ${n.realization} realization requires a diagnostic`)}return{valid:0===t.length,diagnostics:t}}function rk(e,t,r){let i=r.x-t.x,n=r.y-t.y,o=i*i+n*n;if(0===o)return Math.hypot(e.x-t.x,e.y-t.y);let a=Math.max(0,Math.min(1,((e.x-t.x)*i+(e.y-t.y)*n)/o));return Math.hypot(e.x-(t.x+a*i),e.y-(t.y+a*n))}function rv(e,t,r=0){return function(e,t,r,i){if("none"===e.hit.pointerEvents)return!1;let n=eD(eI(i,e_(e.transform)));if(!n)return!1;if(e.stroke.nonScaling){let n=function(e,t,r){if("none"===e.hit.pointerEvents)return;let i=ez(e.hit.geometry,e.hit.closed);if(0===i.length)return;let n=eI(r,e_(e.transform)),o=1/0;for(let e of i)o=Math.min(o,rk(t,eA(e.start,n),eA(e.end,n)));return o}(e,t,i);return void 0!==n&&n<=e.hit.strokeWidth/2+Math.max(0,r)}let o=eA(t,n),a=(Math.hypot(n[0]+n[3],n[1]-n[2])+Math.hypot(n[0]-n[3],n[1]+n[2]))/2,s=e.hit.strokeWidth/2+(r>0?r*a:0);return ez(e.hit.geometry,e.hit.closed).some(e=>rk(o,e.start,e.end)<=s)}(e,t,r,ej)}function rE(e,t){if(!Number.isFinite(e))throw Error(`Marker ${t} must be finite`);return e}function r$(e){return e.map(e=>`${rE(e.x,"point.x")} ${rE(e.y,"point.y")}`).join(", ")}function rw(e){if("string"!=typeof e.id||""===e.id.trim())throw Error("Marker id must not be empty");if(!["arrow","open-arrow","circle","cross","triangle","diamond","diamond-open"].includes(String(e.shape)))throw Error(`Marker "${e.id}" has an unknown shape`);if(!e.geometry)throw Error(`Marker "${e.id}" must declare geometry`);if(!e.size)throw Error(`Marker "${e.id}" must declare marker size`);if(!e.ref)throw Error(`Marker "${e.id}" must declare a reference point`);if(!(e.size.width>0)||!(e.size.height>0))throw Error(`Marker "${e.id}" size must be positive`);if(rE(e.size.width,"size.width"),rE(e.size.height,"size.height"),rE(e.ref.x,"ref.x"),rE(e.ref.y,"ref.y"),void 0!==e.units&&"strokeWidth"!==e.units&&"userSpaceOnUse"!==e.units)throw Error(`Marker "${e.id}" units must be strokeWidth or userSpaceOnUse`);if("number"==typeof e.orient)rE(e.orient,"orient");else if(void 0!==e.orient&&"auto"!==e.orient&&"auto-start-reverse"!==e.orient)throw Error(`Marker "${e.id}" orient must be auto, auto-start-reverse, or a finite angle`);if(void 0!==e.overflow&&"hidden"!==e.overflow&&"visible"!==e.overflow)throw Error(`Marker "${e.id}" overflow must be hidden or visible`);if(e.viewBox&&(rE(e.viewBox.x,"viewBox.x"),rE(e.viewBox.y,"viewBox.y"),rE(e.viewBox.width,"viewBox.width"),rE(e.viewBox.height,"viewBox.height"),!(e.viewBox.width>0)||!(e.viewBox.height>0)))throw Error(`Marker "${e.id}" viewBox must be positive`)}function rS(e,t={}){rw(e);let r=" ".repeat(t.indent??2),i=`${r} `,n=e.units,o=e.orient??"auto",a=[`id="${b(e.id)}"`,`markerWidth="${rE(e.size.width,"size.width")}"`,`markerHeight="${rE(e.size.height,"size.height")}"`,`refX="${rE(e.ref.x,"ref.x")}"`,`refY="${rE(e.ref.y,"ref.y")}"`,`orient="${b(String(o))}"`,...n?[`markerUnits="${b(n)}"`]:[],...e.viewBox?[`viewBox="${rE(e.viewBox.x,"viewBox.x")} ${rE(e.viewBox.y,"viewBox.y")} ${rE(e.viewBox.width,"viewBox.width")} ${rE(e.viewBox.height,"viewBox.height")}"`]:[],...e.overflow?[`overflow="${b(e.overflow)}"`]:[]];return[`${r}<marker ${a.join(" ")}>`,...function e(t,r,i){let n=function(e){if(!e)return"";let t=[];return void 0!==e.fill&&t.push(`fill="${b(e.fill)}"`),void 0!==e.stroke&&t.push(`stroke="${b(e.stroke)}"`),void 0!==e.strokeWidth&&t.push(`stroke-width="${b(e.strokeWidth)}"`),void 0!==e.strokeDasharray&&t.push(`stroke-dasharray="${b(e.strokeDasharray)}"`),void 0!==e.strokeDashoffset&&t.push(`stroke-dashoffset="${b(e.strokeDashoffset)}"`),void 0!==e.strokeLinecap&&t.push(`stroke-linecap="${b(e.strokeLinecap)}"`),void 0!==e.strokeLinejoin&&t.push(`stroke-linejoin="${b(e.strokeLinejoin)}"`),void 0!==e.strokeMiterlimit&&t.push(`stroke-miterlimit="${b(e.strokeMiterlimit)}"`),void 0!==e.vectorEffect&&t.push(`vector-effect="${b(e.vectorEffect)}"`),void 0!==e.paintOrder&&t.push(`paint-order="${b(e.paintOrder)}"`),void 0!==e.opacity&&t.push(`opacity="${b(e.opacity)}"`),t.length>0?` ${t.join(" ")}`:""}(r);switch(t.kind){case"rect":return[`${i}<rect x="${rE(t.x,"rect.x")}" y="${rE(t.y,"rect.y")}" width="${rE(t.width,"rect.width")}" height="${rE(t.height,"rect.height")}"${void 0!==t.rx?` rx="${rE(t.rx,"rect.rx")}"`:""}${void 0!==t.ry?` ry="${rE(t.ry,"rect.ry")}"`:""}${n} />`];case"circle":return[`${i}<circle cx="${rE(t.cx,"circle.cx")}" cy="${rE(t.cy,"circle.cy")}" r="${rE(t.r,"circle.r")}"${n} />`];case"ellipse":return[`${i}<ellipse cx="${rE(t.cx,"ellipse.cx")}" cy="${rE(t.cy,"ellipse.cy")}" rx="${rE(t.rx,"ellipse.rx")}" ry="${rE(t.ry,"ellipse.ry")}"${n} />`];case"line":return[`${i}<line x1="${rE(t.x1,"line.x1")}" y1="${rE(t.y1,"line.y1")}" x2="${rE(t.x2,"line.x2")}" y2="${rE(t.y2,"line.y2")}"${n} />`];case"polygon":return[`${i}<polygon points="${r$(t.points)}"${n} />`];case"polyline":return[`${i}<polyline points="${r$(t.points)}"${n} />`];case"path":return[`${i}<path d="${b(t.d)}"${n} />`];case"compound":return t.children.flatMap(t=>e(t,r,i))}}(e.geometry,e.paint,i),`${r}</marker>`].join(`
11
+ `)}function rN(e,t={}){let r=new Set;for(let t of e){if(r.has(t.id))throw Error(`Duplicate marker resource "${t.id}"`);r.add(t.id)}return e.map(e=>rS(e,t)).join(`
12
+ `)}Object.freeze(["importance","value","category","status","progress","route","emphasis"]);var rC=/^[A-Za-z_][A-Za-z0-9_.:-]*$/,rM=Object.freeze({maxIdLength:256,maxCoordinate:1e6,maxStopsPerGradient:256,maxResources:1e4,maxAggregateStops:2e4,maxSerializationBytes:8e6});function rz(e,t){if(!Number.isFinite(e))throw Error(`Linear gradient ${t} must be finite`);if(Math.abs(e)>rM.maxCoordinate)throw Error(`Linear gradient ${t} must not exceed ${rM.maxCoordinate}`);return e}function rO(e){if(!rC.test(e.id))throw Error(`Linear gradient id ${JSON.stringify(e.id)} must use the safe SVG id grammar`);if(e.id.length>rM.maxIdLength)throw Error(`Linear gradient id must contain at most ${rM.maxIdLength} characters`);if("userSpaceOnUse"!==e.units&&"objectBoundingBox"!==e.units)throw Error(`Linear gradient "${e.id}" units must be userSpaceOnUse or objectBoundingBox`);if(rz(e.x1,"x1"),rz(e.y1,"y1"),rz(e.x2,"x2"),rz(e.y2,"y2"),e.stops.length<2)throw Error(`Linear gradient "${e.id}" must declare at least two stops`);if(e.stops.length>rM.maxStopsPerGradient)throw Error(`Linear gradient "${e.id}" must declare at most ${rM.maxStopsPerGradient} stops`);let t=-1;for(let[r,i]of e.stops.entries()){if(rz(i.offset,`stops[${r}].offset`),i.offset<0||i.offset>1)throw Error(`Linear gradient "${e.id}" stop offsets must be in [0,1]`);if(i.offset<t)throw Error(`Linear gradient "${e.id}" stop offsets must be non-decreasing`);if(t=i.offset,void 0===O(i.color)||/^url\s*\(/i.test(i.color))throw Error(`Linear gradient "${e.id}" stop ${r} must use a safe non-fetching CSS paint`);if(void 0!==i.opacity&&(!Number.isFinite(i.opacity)||i.opacity<0||i.opacity>1))throw Error(`Linear gradient "${e.id}" stop opacity must be in [0,1]`)}}function rT(e,t={}){rO(e);let r=" ".repeat(t.indent??2),i=`${r} `,n=[`id="${b(e.id)}"`,`gradientUnits="${e.units}"`,`x1="${rz(e.x1,"x1")}"`,`y1="${rz(e.y1,"y1")}"`,`x2="${rz(e.x2,"x2")}"`,`y2="${rz(e.y2,"y2")}"`];return[`${r}<linearGradient ${n.join(" ")}>`,...e.stops.map(e=>{var t;return`${i}<stop offset="${t=e.offset,`${Math.round(1e5*t)/1e3}%`}" stop-color="${b(e.color)}"${void 0===e.opacity?"":` stop-opacity="${e.opacity}"`} />`}),`${r}</linearGradient>`].join(`
13
+ `)}var rj=Object.freeze({maxExtent:1e6,maxNodes:1e5,maxDepth:64,maxTextLength:1e6,maxTextBytes:2e6,maxPoints:5e4,maxSerializationBytesPerNode:5e6,maxAggregateSerializationBytes:16e6,maxFinalSvgBytes:8e6}),r_=class extends Error{constructor(e){super(`Scene validation failed: ${e.map(e=>`${e.path}: ${e.message}`).join("; ")}`),this.diagnostics=e,this.name="SceneValidationError"}diagnostics;code="SCENE_VALIDATION_FAILED"},rI=rj.maxExtent,rA=rj.maxNodes,rD=rj.maxDepth,rB=rj.maxTextLength,rL=rj.maxTextBytes,rP=rj.maxPoints,rF=rj.maxSerializationBytesPerNode,rU=rj.maxAggregateSerializationBytes,rR=rj.maxFinalSvgBytes,rW=/^[A-Za-z0-9][A-Za-z0-9_.:/-]*$/,rq=/^[a-z0-9][a-z0-9._/-]*:[a-z0-9][a-z0-9._/-]*$/i,rG=/^(?:none|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?(?:[\s,]+[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)*)$/,rV=/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/,rH=/^([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)(?:px)?$/,rZ=/^([-+]?\d*\.?\d+(?:[eE][-+]?\d+)?)$/,rY=/^var\(--[a-z0-9_-]+(?:,\s*[-+]?\d*\.?\d+)?\)$/i,rJ=Object.freeze({M:2,m:2,L:2,l:2,H:1,h:1,V:1,v:1,C:6,c:6,S:4,s:4,Q:4,q:4,T:2,t:2,A:7,a:7,Z:0,z:0}),rK=/[-+]?(?:(?:\d+(?:\.\d*)?)|(?:\.\d+))(?:[eE][-+]?\d+)?/y,rQ=["fill","stroke","strokeWidth","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","vectorEffect","paintOrder","opacity"];function rX(e,t="final SVG"){if("string"!=typeof e)throw TypeError(`${t} must be a string`);if(!(3*e.length<=rR)&&!E("final-svg-budget",e,()=>N(e,rR)<=rR))throw RangeError(`${t} exceeds the ${rR}-byte final SVG limit`)}function r0(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function r1(e,t,r,i){e.push({code:t,path:r,message:i})}function r2(e,t,r,i){let n=new Set(t);for(let t of Object.keys(e))n.has(t)||r1(i,"SCENE_DOCUMENT",`${r}.${t}`,"is not part of the external Scene contract")}function r3(e,t,r,i={}){return"number"==typeof e&&Number.isFinite(e)?(i.positive&&e<=0&&r1(r,"SCENE_BOUNDS",t,"must be positive"),i.nonNegative&&e<0&&r1(r,"SCENE_BOUNDS",t,"must be non-negative"),Math.abs(e)>rI&&r1(r,"SCENE_BOUNDS",t,`must not exceed ${rI} user units`),!0):(r1(r,"SCENE_FINITE",t,"must be a finite number"),!1)}function r5(e,t,r,i={}){return"string"!=typeof e?(r1(r,"SCENE_ID",t,"must be a string"),!1):(i.empty||0!==e.length||r1(r,"SCENE_ID",t,"must not be empty"),e.length>(i.max??256)&&r1(r,"SCENE_ID",t,"is too long"),rV.test(e)&&r1(r,"SCENE_ID",t,"contains a control character"),i.externalId&&!rW.test(e)&&r1(r,"SCENE_ID",t,"must use the safe external id grammar"),!0)}function r4(e,t,r,i={}){if(void 0===e)return;if("string"!=typeof e&&"number"!=typeof e)return void r1(r,"SCENE_PAINT",t,"must be a finite numeric value");let n=("string"==typeof e?e.trim():void 0)?.match(i.length?rH:rZ),o="number"==typeof e?e:n?Number(n[1]):NaN;if(Number.isFinite(o))i.nonNegative&&o<0?r1(r,"SCENE_PAINT",t,"must be non-negative"):i.unitInterval&&(o<0||o>1)&&r1(r,"SCENE_PAINT",t,"must be in [0,1]");else{if("string"==typeof e&&rY.test(e.trim()))return;r1(r,"SCENE_PAINT",t,`must be a finite number or safe numeric custom-property reference (received ${JSON.stringify(e)})`)}}function r6(e,t,r,i=!1){if(!r0(e))return void r1(r,"SCENE_PAINT",t,"must be a paint object");for(let n of(i&&r2(e,rQ,t,r),["fill","stroke"])){let o=e[n],a=r8(o);void 0!==o&&void 0===O(o)&&(i||!a)&&r1(r,"SCENE_PAINT",`${t}.${n}`,"must be a safe non-fetching CSS paint")}if(r4(e.strokeWidth,`${t}.strokeWidth`,r,{nonNegative:!0,length:!0}),r4(e.strokeDashoffset,`${t}.strokeDashoffset`,r,{length:!0}),r4(e.strokeMiterlimit,`${t}.strokeMiterlimit`,r,{nonNegative:!0}),r4(e.opacity,`${t}.opacity`,r,{unitInterval:!0}),r4(e.fillOpacity,`${t}.fillOpacity`,r,{unitInterval:!0}),r4(e.strokeOpacity,`${t}.strokeOpacity`,r,{unitInterval:!0}),void 0===e.strokeDasharray||"string"==typeof e.strokeDasharray&&rG.test(e.strokeDasharray.trim())||r1(r,"SCENE_PAINT",`${t}.strokeDasharray`,'must be "none" or a finite numeric dash list'),void 0===e.strokeLinecap||["butt","round","square"].includes(String(e.strokeLinecap))||r1(r,"SCENE_PAINT",`${t}.strokeLinecap`,"must be butt, round, or square"),void 0===e.strokeLinejoin||["arcs","bevel","miter","miter-clip","round"].includes(String(e.strokeLinejoin))||r1(r,"SCENE_PAINT",`${t}.strokeLinejoin`,"must be arcs, bevel, miter, miter-clip, or round"),void 0===e.vectorEffect||["none","non-scaling-stroke"].includes(String(e.vectorEffect))||r1(r,"SCENE_PAINT",`${t}.vectorEffect`,"must be none or non-scaling-stroke"),void 0!==e.paintOrder){let i="string"==typeof e.paintOrder?e.paintOrder.trim().split(/\s+/).filter(Boolean).map(e=>e.toLowerCase()):[];1===i.length&&"normal"===i[0]||i.length>=1&&i.length<=3&&new Set(i).size===i.length&&i.every(e=>["fill","stroke","markers"].includes(e))||r1(r,"SCENE_PAINT",`${t}.paintOrder`,"must be normal or one to three unique fill, stroke, and markers keywords")}}function r8(e){return("string"==typeof e?/^url\(#([A-Za-z_][A-Za-z0-9_.:-]*)\)$/.exec(e.trim()):null)?.[1]}function r7(e,t,r,i,n,o,a,s){if(!e||"string"!=typeof i||e[r])return;let d=Math.max(0,a-e[t]),l=N(i,d);l>d?(e[t]=a+1,e[r]=!0,r1(o,"SCENE_BOUNDS",n,`${s} exceed the aggregate ${a}-byte limit`)):e[t]+=l}function r9(e,t,r,i,n=!1){r0(e)?(n&&r2(e,["x","y"],t,r),!i||i.pointsExceeded||++i.points>rP&&(i.pointsExceeded=!0,r1(r,"SCENE_BOUNDS",t,`Scene points exceed the aggregate ${rP}-point limit`)),r3(e.x,`${t}.x`,r),r3(e.y,`${t}.y`,r)):r1(r,"SCENE_FINITE",t,"must be a point object")}function ie(e,t,r){if(!r0(e)||"number"!=typeof e.x||"number"!=typeof e.y)return;let i=Math.hypot(e.x,e.y);(!Number.isFinite(i)||Math.abs(i-1)>1e-9)&&r1(r,"SCENE_FINITE",t,"must be a finite unit vector")}function it(e,t,r,i,n,o=!1){if(!Array.isArray(e))return void r1(r,"SCENE_FINITE",t,"must be an array of points");if(e.length<i&&r1(r,"SCENE_BOUNDS",t,`must contain at least ${i} points`),n?.pointCollections.has(e))return;n?.pointCollections.add(e),e.length>rA&&r1(r,"SCENE_BOUNDS",t,"contains too many points");let a=Math.min(e.length,rA,n?Math.max(0,rP-n.points+1):rA);for(let i=0;i<a;i++)r9(e[i],`${t}[${i}]`,r,n,o)}function ir(e,t,r,i=!1,n=0,o,a=!1){if(n>rD)return void r1(r,"SCENE_BOUNDS",t,`geometry exceeds maximum nesting depth ${rD}`);if(!r0(e)||"string"!=typeof e.kind)return void r1(r,"SCENE_DOCUMENT",t,"must be a typed geometry object");if(a){let i={rect:["kind","x","y","width","height","rx","ry"],circle:["kind","cx","cy","r"],ellipse:["kind","cx","cy","rx","ry"],line:["kind","x1","y1","x2","y2"],polygon:["kind","points"],polyline:["kind","points"],path:["kind","d","points"],compound:["kind","children"]}[e.kind];i&&r2(e,i,t,r)}switch(e.kind){case"rect":r3(e.x,`${t}.x`,r),r3(e.y,`${t}.y`,r),r3(e.width,`${t}.width`,r,{nonNegative:!0}),r3(e.height,`${t}.height`,r,{nonNegative:!0}),void 0!==e.rx&&r3(e.rx,`${t}.rx`,r,{nonNegative:!0}),void 0!==e.ry&&r3(e.ry,`${t}.ry`,r,{nonNegative:!0});return;case"circle":r3(e.cx,`${t}.cx`,r),r3(e.cy,`${t}.cy`,r),r3(e.r,`${t}.r`,r,{nonNegative:!0});return;case"ellipse":r3(e.cx,`${t}.cx`,r),r3(e.cy,`${t}.cy`,r),r3(e.rx,`${t}.rx`,r,{nonNegative:!0}),r3(e.ry,`${t}.ry`,r,{nonNegative:!0});return;case"line":r3(e.x1,`${t}.x1`,r),r3(e.y1,`${t}.y1`,r),r3(e.x2,`${t}.x2`,r),r3(e.y2,`${t}.y2`,r);return;case"polygon":it(e.points,`${t}.points`,r,3,o,a);return;case"polyline":it(e.points,`${t}.points`,r,2,o,a);return;case"path":if("string"!=typeof e.d||0===e.d.length||e.d.length>rB)r1(r,"SCENE_SECURITY",`${t}.d`,"must use bounded SVG path data");else{let n=function(e,t=!1){let r=0,i,n=!1,o=0,a=()=>{for(;r<e.length&&(","===e[r]||/\s/.test(e[r]));)r++},s=()=>{let t=e[r];return void 0!==t&&"MmLlHhVvCcSsQqTtAaZz".includes(t)?t:void 0},d=()=>{a(),rK.lastIndex=r;let t=rK.exec(e);if(!t)return"expected a numeric path parameter";r=rK.lastIndex;let i=Number(t[0]);return Number.isFinite(i)?Math.abs(i)>rI?`path parameter ${t[0]} exceeds ${rI} user units`:void 0:`path parameter ${t[0]} is not finite`};for(;a(),!(r>=e.length);){let l=s();if(void 0!==l){if(i=l,r++,!n&&"M"!==i&&"m"!==i)return"must start with an M or m moveto command";if(n&&t&&("M"===i||"m"===i))return"multiple moveto subpaths require typed subpath geometry";if(n=!0,"Z"===i||"z"===i){i=void 0;continue}}else if(void 0===i)return"path parameters must follow a command";let c=rJ[i];if(void 0===c||0===c)return`unknown path command ${String(i)}`;let u=0;for(;;){if(a(),r>=e.length||void 0!==s()){if(0===u)return`command ${i} requires ${c} parameters`;break}for(let t=0;t<c;t++){if(a(),r>=e.length||void 0!==s())return`command ${i} ended before its ${c}-parameter group was complete`;if(("A"===i||"a"===i)&&(3===t||4===t)){let t=e[r];if("0"!==t&&"1"!==t)return`command ${i} arc flags must be 0 or 1`;r++}else{let e=d();if(e)return e}}if(u++,++o>rP)return`contains more than ${rP} path parameter groups`}}return n?void 0:"must contain an M or m moveto command"}(e.d,a&&!i);n&&r1(r,"SCENE_SECURITY",`${t}.d`,`must use semantic SVG path data: ${n}`)}if(void 0!==e.points&&it(e.points,`${t}.points`,r,2,o,a),void 0!==e.markerMidpoints&&it(e.markerMidpoints,`${t}.markerMidpoints`,r,0,o,a),void 0!==e.subpaths)if(Array.isArray(e.subpaths)&&0!==e.subpaths.length)for(let i=0;i<Math.min(e.subpaths.length,rA);i++){let n=e.subpaths[i];if(!r0(n)){r1(r,"SCENE_DOCUMENT",`${t}.subpaths[${i}]`,"must be a typed contour");continue}it(n.points,`${t}.subpaths[${i}].points`,r,2,o,a),"boolean"!=typeof n.closed&&r1(r,"SCENE_DOCUMENT",`${t}.subpaths[${i}].closed`,"must be boolean")}else r1(r,"SCENE_BOUNDS",`${t}.subpaths`,"must be a non-empty array of typed contours");return;case"compound":if(!Array.isArray(e.children))return void r1(r,"SCENE_BOUNDS",`${t}.children`,"must be a geometry array");e.children.length>rA&&r1(r,"SCENE_BOUNDS",`${t}.children`,"contains too many geometries");for(let s=0;s<Math.min(e.children.length,rA);s++)ir(e.children[s],`${t}.children[${s}]`,r,i,n+1,o,a);return;default:r1(r,"SCENE_DOCUMENT",`${t}.kind`,`unknown geometry kind "${e.kind}"`)}}function ii(e,t,r,i,n){if(!r0(e))return r1(r,"SCENE_MARKER",t,"must be a marker descriptor"),!1;if(i&&r2(e,["id","shape","geometry","size","viewBox","ref","bounds","units","orient","overflow","paint","scale"],t,r),r5(e.id,`${t}.id`,r,{externalId:i}),["arrow","open-arrow","circle","cross","triangle","diamond","diamond-open"].includes(String(e.shape))||r1(r,"SCENE_MARKER",`${t}.shape`,"must be a known marker shape"),ir(e.geometry,`${t}.geometry`,r,!0,0,n,i),i&&r0(e.geometry)&&"compound"===e.geometry.kind&&(!Array.isArray(e.geometry.children)||0===e.geometry.children.length)&&r1(r,"SCENE_BOUNDS",`${t}.geometry.children`,"external marker compounds must contain geometry"),r0(e.size)&&(i&&r2(e.size,["width","height"],`${t}.size`,r),r3(e.size.width,`${t}.size.width`,r,{positive:!0}),r3(e.size.height,`${t}.size.height`,r,{positive:!0})),r0(e.ref)&&r9(e.ref,`${t}.ref`,r,n,i),void 0!==e.paint&&r6(e.paint,`${t}.paint`,r,i),r0(e.viewBox)&&(i&&r2(e.viewBox,["x","y","width","height"],`${t}.viewBox`,r),r3(e.viewBox.x,`${t}.viewBox.x`,r),r3(e.viewBox.y,`${t}.viewBox.y`,r),r3(e.viewBox.width,`${t}.viewBox.width`,r,{positive:!0}),r3(e.viewBox.height,`${t}.viewBox.height`,r,{positive:!0})),r0(e.bounds)){for(let n of(i&&r2(e.bounds,["x0","y0","x1","y1"],`${t}.bounds`,r),["x0","y0","x1","y1"]))r3(e.bounds[n],`${t}.bounds.${n}`,r);"number"==typeof e.bounds.x0&&"number"==typeof e.bounds.x1&&e.bounds.x0>e.bounds.x1&&r1(r,"SCENE_BOUNDS",`${t}.bounds`,"x0 must not exceed x1"),"number"==typeof e.bounds.y0&&"number"==typeof e.bounds.y1&&e.bounds.y0>e.bounds.y1&&r1(r,"SCENE_BOUNDS",`${t}.bounds`,"y0 must not exceed y1")}void 0!==e.scale&&r3(e.scale,`${t}.scale`,r,{nonNegative:!0}),void 0===e.units||["strokeWidth","userSpaceOnUse"].includes(String(e.units))||r1(r,"SCENE_MARKER",`${t}.units`,"must be strokeWidth or userSpaceOnUse"),"number"==typeof e.orient?r3(e.orient,`${t}.orient`,r):void 0===e.orient||["auto","auto-start-reverse"].includes(String(e.orient))||r1(r,"SCENE_MARKER",`${t}.orient`,"must be auto, auto-start-reverse, or a finite angle"),void 0===e.overflow||["hidden","visible"].includes(String(e.overflow))||r1(r,"SCENE_MARKER",`${t}.overflow`,"must be hidden or visible");try{rw(e)}catch(e){r1(r,"SCENE_MARKER",t,e instanceof Error?e.message:String(e))}return"string"==typeof e.id}function io(e,t,r){let i;try{i=tN(e),N(i,rF)>rF&&r1(r.diagnostics,"SCENE_DOCUMENT",t,"has an oversized SVG serialization")}catch(e){r1(r.diagnostics,"SCENE_DOCUMENT",t,e instanceof Error?e.message:String(e))}return r.aggregateBudgets&&void 0!==i&&r7(r.budget,"serializationBytes","serializationExceeded",i,t,r.diagnostics,rU,"Scene serializations"),i}function ia(t,r,i,n,o){var a,s,d,c;if(n>rD)return void r1(i.diagnostics,"SCENE_BOUNDS",r,`exceeds maximum nesting depth ${rD}`);if(++i.nodeCount>rA){i.nodeCount===rA+1&&r1(i.diagnostics,"SCENE_BOUNDS",r,"contains too many Scene nodes");return}if(!r0(t)||"string"!=typeof t.kind)return void r1(i.diagnostics,"SCENE_DOCUMENT",r,"must be a typed Scene node");let u=t.kind;if(function(e,t,r){if(r0(e))if("connector"===e.kind){if(r0(e.stroke)){let i=r8(e.stroke.color);i&&r.push({id:i,path:`${t}.stroke.color`})}if(Array.isArray(e.labels))for(let i=0;i<Math.min(e.labels.length,rA);i++){let n=e.labels[i];r0(n)&&is(n.paint,`${t}.labels[${i}].paint`,r)}}else is(e.paint,`${t}.paint`,r)}(t,r,i.paintReferences),!["shape","connector","text","group","document"].includes(u))return void r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.kind`,`unknown Scene node kind "${u}"`);if(i.external&&n>0&&"document"===u&&r1(i.diagnostics,"SCENE_DOCUMENT",r,`${u} marks must be top-level document furniture`),i.external){let e=["kind","id","role","identity","accessibility","channels","transform","owner"];r2(t,{shape:[...e,"geometry","paint"],text:[...e,"text","x","y","fontSize","anchor","baselineShift","paint","fontWeight","letterSpacing","display","textLayout","block","measurement","prepared"],group:[...e,"open","close","children","join"],document:[...e,"element","text","domId","markerResources"],connector:[...e,"lineStyle","endpoints","relationship","route","stroke","markers","labels","hit","terminalProjection"]}[u],r,i.diagnostics)}if(r5(t.id,`${r}.id`,i.diagnostics,{externalId:i.external})){let e=i.ids.get(t.id);i.external&&e?r1(i.diagnostics,"SCENE_ID",`${r}.id`,`duplicates ${e.path}`):i.ids.set(t.id,{path:`${r}.id`,kind:u})}if(void 0!==t.domId&&r5(t.domId,`${r}.domId`,i.diagnostics,{externalId:i.external})){let e=i.domIds.get(t.domId),n=i.markerIds.get(t.domId),o=i.gradientIds.get(t.domId);i.external&&e?r1(i.diagnostics,"SCENE_ID",`${r}.domId`,`duplicates DOM id owned by ${e}`):i.external&&n?r1(i.diagnostics,"SCENE_ID",`${r}.domId`,`collides with marker resource "${t.domId}"`):o?r1(i.diagnostics,"SCENE_ID",`${r}.domId`,`collides with gradient resource "${t.domId}"`):i.domIds.set(t.domId,`${r}.domId`)}a=t.role,s=`${r}.role`,"string"!=typeof a?r1(i.diagnostics,"SCENE_ROLE",s,"must be a Scene role string"):Object.prototype.hasOwnProperty.call(l,a)||rq.test(a)?m(a).applicableKinds.includes(u)||r1(i.diagnostics,"SCENE_ROLE",s,`role "${a}" is not applicable to ${u} marks`):r1(i.diagnostics,"SCENE_ROLE",s,"must be a built-in or namespaced Scene role"),"string"==typeof t.id&&"string"==typeof t.role&&i.subjects.add(JSON.stringify([t.id,t.role])),r0(t.identity)&&"string"==typeof t.identity.id&&"string"==typeof t.identity.role&&i.subjects.add(JSON.stringify([t.identity.id,t.identity.role])),r0(t.owner)&&"string"==typeof t.owner.id&&"string"==typeof t.owner.role&&i.ownerReferences.push({key:JSON.stringify([t.owner.id,t.owner.role]),path:`${r}.owner`}),function(e,t,r){if(void 0!==e){if(!r0(e))return r1(r,"SCENE_DOCUMENT",t,"must be a semantic channel object");for(let i of["importance","value","progress"])void 0!==e[i]&&r3(e[i],`${t}.${i}`,r);for(let i of("number"==typeof e.progress&&(e.progress<0||e.progress>1)&&r1(r,"SCENE_BOUNDS",`${t}.progress`,"must be in [0,1]"),["category","status","route"]))void 0!==e[i]&&r5(e[i],`${t}.${i}`,r,{max:4096});void 0!==e.emphasis&&"boolean"!=typeof e.emphasis&&r1(r,"SCENE_DOCUMENT",`${t}.emphasis`,"must be boolean")}}(t.channels,`${r}.channels`,i.diagnostics);let f=i.native&&"document"!==u?void 0:io(t,r,i);if(void 0!==t.transform){if(r0(t.transform)&&["rotate","matrix"].includes(String(t.transform.kind)))for(let e of"matrix"===t.transform.kind?["a","b","c","d","e","f"]:["angle","cx","cy"])r3(t.transform[e],`${r}.transform.${e}`,i.diagnostics);else r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.transform`,"must be a rotate or matrix transform");i.external&&r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.transform`,"external Scene transforms are not exposed by the declarative builder")}if(void 0!==t.owner&&(r0(t.owner)?(r5(t.owner.id,`${r}.owner.id`,i.diagnostics),"string"==typeof t.owner.role&&(Object.hasOwn(l,t.owner.role)||rq.test(t.owner.role))||r1(i.diagnostics,"SCENE_ROLE",`${r}.owner.role`,"must be a Scene role")):r1(i.diagnostics,"SCENE_REFERENCE",`${r}.owner`,"must be a semantic owner")),void 0!==t.visibility&&"conditional"!==t.visibility&&r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.visibility`,"must be conditional"),void 0!==t.attributes&&function(e,t,r){if(!r0(e))return r1(r,"SCENE_DOCUMENT",t,"must be an attribute hook object");if(r2(e,["className","data","ariaHidden","tabIndex","ariaLabel"],t,r),void 0===e.className||"string"==typeof e.className&&tm.test(e.className)||r1(r,"SCENE_DOCUMENT",`${t}.className`,"must be space-separated CSS class tokens"),void 0!==e.ariaHidden&&!0!==e.ariaHidden&&r1(r,"SCENE_DOCUMENT",`${t}.ariaHidden`,"must be true when present"),void 0!==e.tabIndex&&0!==e.tabIndex&&r1(r,"SCENE_DOCUMENT",`${t}.tabIndex`,"must be 0 when present"),void 0!==e.ariaLabel&&r5(e.ariaLabel,`${t}.ariaLabel`,r,{max:rB}),void 0!==e.data){if(!r0(e.data))return r1(r,"SCENE_DOCUMENT",`${t}.data`,"must be a string record");for(let[i,n]of Object.entries(e.data))(!tf.test(i)||tu.has(i))&&r1(r,"SCENE_DOCUMENT",`${t}.data.${i}`,"must be a family data-* key the writer does not own"),r5(n,`${t}.data.${i}`,r,{empty:!0,max:rB})}}(t.attributes,`${r}.attributes`,i.diagnostics),"shape"===u){void 0===t.identity&&"string"==typeof t.role&&ea(t.role)&&(i.native&&"string"==typeof t.id&&r0(t.owner)&&"string"==typeof t.owner.id&&t.owner.role===t.role?i.native.artwork.push({id:t.id,owner:{id:t.owner.id,role:t.role},path:`${r}.identity`}):o&&r0(t.owner)&&t.role===o.role&&t.owner.id===o.id&&t.owner.role===o.role||r1(i.diagnostics,"SCENE_FIDELITY",`${r}.identity`,"owned artwork without DOM identity must be inside its matching semantic group")),void 0!==t.surfaceFragment&&"boolean"!=typeof t.surfaceFragment&&r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.surfaceFragment`,"must be boolean"),ir(t.geometry,`${r}.geometry`,i.diagnostics,!1,0,i.budget,i.external),i.external&&r0(t.geometry)&&("path"===t.geometry.kind||"compound"===t.geometry.kind)&&r1(i.diagnostics,"SCENE_BOUNDS",`${r}.geometry`,"external shapes must use a directly bounded structured geometry"),r6(t.paint,`${r}.paint`,i.diagnostics,i.external),void 0!==t.childPaints&&(Array.isArray(t.childPaints)&&r0(t.geometry)&&"compound"===t.geometry.kind&&Array.isArray(t.geometry.children)&&t.childPaints.length===t.geometry.children.length?t.childPaints.forEach((e,t)=>r6(e,`${r}.childPaints[${t}]`,i.diagnostics,i.external)):r1(i.diagnostics,"SCENE_PAINT",`${r}.childPaints`,"must give one paint per compound geometry child")),void 0!==t.conditionalPaint&&("conditional"!==t.visibility&&r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.conditionalPaint`,"requires an explicit conditional state"),r6(t.conditionalPaint,`${r}.conditionalPaint`,i.diagnostics,i.external));return}if("text"===u){if(r5(t.text,`${r}.text`,i.diagnostics,{empty:!0,max:rB}),i.aggregateBudgets&&r7(i.budget,"textBytes","textExceeded",t.text,`${r}.text`,i.diagnostics,rL,"Scene text values"),r3(t.x,`${r}.x`,i.diagnostics),r3(t.y,`${r}.y`,i.diagnostics),r3(t.fontSize,`${r}.fontSize`,i.diagnostics,{positive:!0}),void 0!==t.fontWeight&&r3(t.fontWeight,`${r}.fontWeight`,i.diagnostics,{positive:!0}),void 0!==t.letterSpacing&&r3(t.letterSpacing,`${r}.letterSpacing`,i.diagnostics),void 0!==t.display&&"literal"!==t.display&&"formatted"!==t.display&&r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.display`,"must be literal or formatted"),void 0===t.measurement||["prepared","fallback"].includes(String(t.measurement))||r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.measurement`,"must identify prepared or fallback measurement"),"prepared"!==t.measurement||r0(t.block)&&"px"===t.block.unit&&r0(t.block.prepared)||r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.block`,"prepared text must retain its actual pixel block"),r0(t.block)){for(let e of(d=t.block,em.has(d)||r1(i.diagnostics,"SCENE_FIDELITY",`${r}.block`,"must retain the actual immutable pixel text preparation"),["fontSize","fontWeight","letterSpacing"]))void 0!==t[e]&&t[e]!==t.block[e]&&r1(i.diagnostics,"SCENE_FIDELITY",`${r}.block.${e}`,"must equal the retained text typography");for(let e of["width","height","fontSize","fontWeight","lineHeight"])r3(t.block[e],`${r}.block.${e}`,i.diagnostics,{nonNegative:!0});r0(t.textLayout)&&(t.block.width!==t.textLayout.width||t.block.height!==t.textLayout.height||t.block.lineHeight!==t.textLayout.lineHeight)&&r1(i.diagnostics,"SCENE_FIDELITY",`${r}.textLayout`,"retained block differs from occupied text geometry")}if(void 0!==t.textLayout&&(r0(t.textLayout)?(i.external&&r2(t.textLayout,["width","height","lineHeight","offsetY"],`${r}.textLayout`,i.diagnostics),r3(t.textLayout.width,`${r}.textLayout.width`,i.diagnostics,{nonNegative:!0}),r3(t.textLayout.height,`${r}.textLayout.height`,i.diagnostics,{nonNegative:!0}),r3(t.textLayout.lineHeight,`${r}.textLayout.lineHeight`,i.diagnostics,{positive:!0}),r3(t.textLayout.offsetY,`${r}.textLayout.offsetY`,i.diagnostics)):r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.textLayout`,"must be measured text geometry")),["start","middle","end"].includes(String(t.anchor))||r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.anchor`,"must be start, middle, or end"),void 0!==t.baselineShift&&r3(t.baselineShift,`${r}.baselineShift`,i.diagnostics),void 0===t.dominantBaseline||["middle","central","hanging"].includes(String(t.dominantBaseline))||r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.dominantBaseline`,"must be middle, central, or hanging"),void 0!==t.fontStyle&&"italic"!==t.fontStyle&&r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.fontStyle`,"must be italic"),void 0===t.textDecoration||["underline","line-through","underline line-through"].includes(String(t.textDecoration))||r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.textDecoration`,"must be underline, line-through, or both"),void 0!==t.spans)if(Array.isArray(t.spans)&&0!==t.spans.length){t.spans.length>rA&&r1(i.diagnostics,"SCENE_BOUNDS",`${r}.spans`,"contains too many text runs");for(let e=0;e<Math.min(t.spans.length,rA);e++){let n=t.spans[e];if(!r0(n)){r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.spans[${e}]`,"must be a painted run");continue}r5(n.text,`${r}.spans[${e}].text`,i.diagnostics,{empty:!0,max:rB}),i.aggregateBudgets&&r7(i.budget,"textBytes","textExceeded",n.text,`${r}.spans[${e}].text`,i.diagnostics,rL,"Scene text values"),r6({fill:n.fill},`${r}.spans[${e}]`,i.diagnostics,i.external)}}else r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.spans`,"must be a non-empty run list");r6(t.paint,`${r}.paint`,i.diagnostics,i.external);return}if("group"===u){if(i.native&&"string"==typeof t.role&&ea(t.role)&&r0(t.identity)&&"string"==typeof t.identity.id&&t.identity.role===t.role&&i.native.groups.add(JSON.stringify([t.identity.id,t.role])),void 0!==t.paint&&(r6(t.paint,`${r}.paint`,i.diagnostics,i.external),r0(t.paint)&&r2(t.paint,["opacity","fill"],`${r}.paint`,i.diagnostics)),!Array.isArray(t.children))return void r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.children`,"must be an array");t.children.length>rA&&r1(i.diagnostics,"SCENE_BOUNDS",`${r}.children`,"contains too many Scene nodes");let e=Math.min(t.children.length,Math.max(0,rA-i.nodeCount+1)),a="string"==typeof t.role&&ea(t.role)?r0(t.identity)&&"string"==typeof t.identity.id&&t.identity.role===t.role?{id:t.identity.id,role:t.role}:void 0:o;for(let o=0;o<e;o++){let e=t.children[o];r0(e)?(r3(e.indent,`${r}.children[${o}].indent`,i.diagnostics,{nonNegative:!0}),ia(e.node,`${r}.children[${o}].node`,i,n+1,a)):r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.children[${o}]`,"must wrap a Scene node")}try{td(t)}catch(e){r1(i.diagnostics,"SCENE_DOCUMENT",r,String(e))}return void(i.external&&("string"!=typeof t.open||!/^<g(?:\s|>)/.test(t.open)||"</g>"!==t.close)&&r1(i.diagnostics,"SCENE_SECURITY",r,"external containers must use a generated <g> wrapper"))}if("document"===u){if(void 0!==t.nonPaint){let n={accessibility:["title","desc"],stylesheet:["style"],"interaction-metadata":["title","desc"]}[String(t.nonPaint)];("content"!==t.element||!n||void 0===f||e(f).some(e=>!n.includes(e.name)))&&r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.nonPaint`,"must describe only closed non-painting metadata elements")}if(["open","title","description","definitions","content","close"].includes(String(t.element))||r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.element`,"has an unknown document element"),void 0!==t.markerResources)if(Array.isArray(t.markerResources)){t.markerResources.length>rA&&r1(i.diagnostics,"SCENE_BOUNDS",`${r}.markerResources`,"contains too many marker resources");for(let e=0;e<Math.min(t.markerResources.length,rA);e++){if(i.native&&i.markerIds.size>=rA)return void r1(i.diagnostics,"SCENE_BOUNDS",`${r}.markerResources`,"contains too many aggregate marker resources");let n=t.markerResources[e],o=`${r}.markerResources[${e}]`;if(ii(n,o,i.diagnostics,i.external,i.budget)&&"string"==typeof n.id){let e=i.markerIds.get(n.id),t=i.domIds.get(n.id);e?r1(i.diagnostics,"SCENE_MARKER",`${o}.id`,`duplicates marker resource "${n.id}"`):i.external&&t?r1(i.diagnostics,"SCENE_ID",`${o}.id`,`collides with DOM id owned by ${t}`):i.gradientIds.has(n.id)?r1(i.diagnostics,"SCENE_ID",`${o}.id`,`collides with gradient resource "${n.id}"`):i.markerIds.set(n.id,n)}}if(i.external&&"definitions"===t.element)try{let e=t$(`<defs>
14
+ ${rN(t.markerResources)}
15
+ </defs>`);f!==e&&r1(i.diagnostics,"SCENE_FIDELITY",r,"definitions must be generated from the typed marker resources")}catch{}}else r1(i.diagnostics,"SCENE_MARKER",`${r}.markerResources`,"must be an array");if(void 0!==t.gradientResources)if("definitions"!==t.element&&r1(i.diagnostics,"SCENE_PAINT",`${r}.gradientResources`,"are only valid on a definitions document mark"),Array.isArray(t.gradientResources)){t.gradientResources.length>rM.maxResources&&r1(i.diagnostics,"SCENE_BOUNDS",`${r}.gradientResources`,`contains more than ${rM.maxResources} gradient resources`);for(let e=0;e<Math.min(t.gradientResources.length,rM.maxResources);e++){if(i.native&&i.gradientIds.size>=rM.maxResources)return void r1(i.diagnostics,"SCENE_BOUNDS",`${r}.gradientResources`,`contains more than ${rM.maxResources} aggregate gradient resources`);let n=t.gradientResources[e],o=`${r}.gradientResources[${e}]`;try{rO(n),i.gradientIds.has(n.id)||i.markerIds.has(n.id)||i.domIds.has(n.id)?r1(i.diagnostics,"SCENE_ID",`${o}.id`,`duplicates SVG resource id "${n.id}"`):i.gradientIds.set(n.id,n)}catch(e){r1(i.diagnostics,"SCENE_PAINT",o,e instanceof Error?e.message:String(e))}}if("definitions"===t.element)try{let e=[...Array.isArray(t.markerResources)&&t.markerResources.length>0?[rN(t.markerResources)]:[],...t.gradientResources.length>0?[function(e,t={}){if(e.length>rM.maxResources)throw Error(`A definitions mark may declare at most ${rM.maxResources} linear gradients`);let r=new Set,i=0,n=0,o=[];for(let a of e){if(r.has(a.id))throw Error(`Duplicate linear gradient resource "${a.id}"`);if(r.add(a.id),(i+=a.stops.length)>rM.maxAggregateStops)throw Error(`Linear gradient resources may declare at most ${rM.maxAggregateStops} aggregate stops`);let e=rT(a,t),s=+(0!==o.length),d=rM.maxSerializationBytes-n-s,l=N(e,Math.max(0,d));if(l>d)throw Error(`Linear gradient serialization exceeds ${rM.maxSerializationBytes} bytes`);n+=l+s,o.push(e)}return o.join(`
16
+ `)}(t.gradientResources)]:[]].join(`
17
+ `),n=t$(`<defs>
18
+ ${e}
19
+ </defs>`);f!==n&&r1(i.diagnostics,"SCENE_FIDELITY",r,"definitions must be generated from typed resources")}catch{}}else r1(i.diagnostics,"SCENE_PAINT",`${r}.gradientResources`,"must be an array");i.aggregateBudgets&&("title"===t.element||"description"===t.element)&&(r5(t.text,`${r}.text`,i.diagnostics,{empty:!0,max:rB}),r7(i.budget,"textBytes","textExceeded",t.text,`${r}.text`,i.diagnostics,rL,"Scene text values")),i.external&&"close"===t.element&&"</svg>"!==f&&r1(i.diagnostics,"SCENE_SECURITY",r,"external document close must be canonical");return}if(["solid","dotted","dashed","thick","invisible"].includes(String(t.lineStyle))||r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.lineStyle`,"has an unknown line style"),r0(t.endpoints)){for(let e of["from","to"])i.external&&void 0===t.endpoints[e]?r1(i.diagnostics,"SCENE_REFERENCE",`${r}.endpoints.${e}`,"is required for external connectors"):void 0!==t.endpoints[e]&&r5(t.endpoints[e],`${r}.endpoints.${e}`,i.diagnostics,{externalId:i.external})&&i.endpointReferences.push({id:t.endpoints[e],path:`${r}.endpoints.${e}`});for(let e of["start","end"]){let n=t.endpoints[e];if(r0(n)&&(void 0!==n.point&&r9(n.point,`${r}.endpoints.${e}.point`,i.diagnostics,i.budget,i.external),void 0!==n.id&&r5(n.id,`${r}.endpoints.${e}.id`,i.diagnostics,{externalId:i.external}),void 0!==n.portId&&r5(n.portId,`${r}.endpoints.${e}.portId`,i.diagnostics,{externalId:i.external}),void 0!==n.owner)){let o=`${r}.endpoints.${e}.owner`;if(r0(n.owner)){r5(n.owner.id,`${o}.id`,i.diagnostics),"string"==typeof n.owner.role&&(Object.hasOwn(l,n.owner.role)||rq.test(n.owner.role))||r1(i.diagnostics,"SCENE_ROLE",`${o}.role`,"must be a Scene role");let r=t.endpoints["start"===e?"from":"to"];void 0!==r&&n.owner.id!==r&&r1(i.diagnostics,"SCENE_FIDELITY",o,"must retain the authored endpoint identity"),i.ownerReferences.push({key:JSON.stringify([n.owner.id,n.owner.role]),path:o})}else r1(i.diagnostics,"SCENE_REFERENCE",o,"must be a semantic owner")}}}else r1(i.diagnostics,"SCENE_REFERENCE",`${r}.endpoints`,"must be a typed endpoint object");if(r0(t.relationship)?r5(t.relationship.kind,`${r}.relationship.kind`,i.diagnostics,{max:4096}):r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.relationship`,"must be a typed relationship"),r0(t.relationship)&&!["forward","reverse","bidirectional","undirected","self"].includes(String(t.relationship.direction))&&r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.relationship.direction`,"has an unknown connector direction"),r0(t.route)){if(ir(t.route.geometry,`${r}.route.geometry`,i.diagnostics,!1,0,i.budget,i.external),i.external&&r0(t.route.geometry)&&"path"===t.route.geometry.kind&&!Array.isArray(t.route.geometry.points)&&r1(i.diagnostics,"SCENE_BOUNDS",`${r}.route.geometry.points`,"external connector paths require deterministic routed points"),r3(t.route.bendRadius,`${r}.route.bendRadius`,i.diagnostics,{nonNegative:!0}),["authored","layout","family","projected"].includes(String(t.route.ownership))||r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.route.ownership`,"has an unknown route ownership"),"boolean"!=typeof t.route.closed&&r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.route.closed`,"must be boolean"),!0===t.route.closed&&r0(t.route.geometry)&&"path"!==t.route.geometry.kind&&r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.route.closed`,"closed connector topology requires path geometry"),void 0!==t.route.startTangent&&(r9(t.route.startTangent,`${r}.route.startTangent`,i.diagnostics,i.budget,i.external),ie(t.route.startTangent,`${r}.route.startTangent`,i.diagnostics)),void 0!==t.route.endTangent&&(r9(t.route.endTangent,`${r}.route.endTangent`,i.diagnostics,i.budget,i.external),ie(t.route.endTangent,`${r}.route.endTangent`,i.diagnostics)),Array.isArray(t.route.labelAnchors)){t.route.labelAnchors.length>rA&&r1(i.diagnostics,"SCENE_BOUNDS",`${r}.route.labelAnchors`,"contains too many points");let e=Math.min(t.route.labelAnchors.length,rA,Math.max(0,rP-i.budget.points+1));for(let n=0;n<e;n++)r9(t.route.labelAnchors[n],`${r}.route.labelAnchors[${n}]`,i.diagnostics,i.budget,i.external)}else r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.route.labelAnchors`,"must be an array");if(Array.isArray(t.route.contours)){(0===t.route.contours.length||t.route.contours.length>rA)&&r1(i.diagnostics,"SCENE_BOUNDS",`${r}.route.contours`,"must contain a bounded non-empty contour list");for(let e=0;e<Math.min(t.route.contours.length,rA);e++){let n=t.route.contours[e];if(!r0(n)){r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.route.contours[${e}]`,"must be typed contour semantics");continue}for(let[t,o]of(r9(n.start,`${r}.route.contours[${e}].start`,i.diagnostics,i.budget,i.external),r9(n.end,`${r}.route.contours[${e}].end`,i.diagnostics,i.budget,i.external),"boolean"!=typeof n.closed&&r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.route.contours[${e}].closed`,"must be boolean"),[["startTangent",n.startTangent],["endTangent",n.endTangent]])){if(void 0===o)continue;let n=`${r}.route.contours[${e}].${t}`;r9(o,n,i.diagnostics,i.budget,i.external),ie(o,n,i.diagnostics)}}}else r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.route.contours`,"must be an array")}else r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.route`,"must be a typed connector route");if(r0(t.stroke)){if(void 0===O(t.stroke.color)&&(i.external||!r8(t.stroke.color))&&r1(i.diagnostics,"SCENE_PAINT",`${r}.stroke.color`,"must be a safe non-fetching CSS paint"),r4(t.stroke.width,`${r}.stroke.width`,i.diagnostics,{nonNegative:!0,length:!0}),r4(t.stroke.opacity,`${r}.stroke.opacity`,i.diagnostics,{unitInterval:!0}),r4(t.stroke.miterLimit,`${r}.stroke.miterLimit`,i.diagnostics,{nonNegative:!0}),r4(t.stroke.pathLength,`${r}.stroke.pathLength`,i.diagnostics,{nonNegative:!0}),["butt","round","square"].includes(String(t.stroke.lineCap))||r1(i.diagnostics,"SCENE_PAINT",`${r}.stroke.lineCap`,"has an unknown line cap"),["arcs","bevel","miter","miter-clip","round"].includes(String(t.stroke.lineJoin))||r1(i.diagnostics,"SCENE_PAINT",`${r}.stroke.lineJoin`,"has an unknown line join"),void 0===t.stroke.mixBlendMode||["normal","multiply"].includes(String(t.stroke.mixBlendMode))||r1(i.diagnostics,"SCENE_PAINT",`${r}.stroke.mixBlendMode`,"must be normal or multiply"),"boolean"!=typeof t.stroke.nonScaling&&r1(i.diagnostics,"SCENE_PAINT",`${r}.stroke.nonScaling`,"must be boolean"),void 0!==t.stroke.encodesValue&&"boolean"!=typeof t.stroke.encodesValue&&r1(i.diagnostics,"SCENE_PAINT",`${r}.stroke.encodesValue`,"must be boolean"),void 0!==t.stroke.dash)if(r0(t.stroke.dash)){let e=t.stroke.dash.array;"string"==typeof e?rG.test(e.trim())||r1(i.diagnostics,"SCENE_PAINT",`${r}.stroke.dash.array`,"must be a finite numeric dash list"):Array.isArray(e)?e.forEach((e,t)=>r4(e,`${r}.stroke.dash.array[${t}]`,i.diagnostics,{nonNegative:!0})):r1(i.diagnostics,"SCENE_PAINT",`${r}.stroke.dash.array`,"must be a string or numeric array"),r4(t.stroke.dash.offset,`${r}.stroke.dash.offset`,i.diagnostics)}else r1(i.diagnostics,"SCENE_PAINT",`${r}.stroke.dash`,"must be a dash descriptor")}else r1(i.diagnostics,"SCENE_PAINT",`${r}.stroke`,"must be a typed connector stroke");if(r0(t.hit)?(ir(t.hit.geometry,`${r}.hit.geometry`,i.diagnostics,!1,0,i.budget,i.external),r3(t.hit.strokeWidth,`${r}.hit.strokeWidth`,i.diagnostics,{nonNegative:!0}),"boolean"!=typeof t.hit.closed&&r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.hit.closed`,"must be boolean"),["stroke","none"].includes(String(t.hit.pointerEvents))||r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.hit.pointerEvents`,"has unknown pointer-event semantics"),r0(t.route)&&"boolean"==typeof t.route.closed&&"boolean"==typeof t.hit.closed&&t.hit.closed!==t.route.closed&&r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.hit.closed`,"must match route.closed topology")):r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.hit`,"must be typed hit geometry"),Array.isArray(t.labels)){t.labels.length>rA&&r1(i.diagnostics,"SCENE_BOUNDS",`${r}.labels`,"contains too many connector labels");for(let e=0;e<Math.min(t.labels.length,rA);e++){let n=t.labels[e];if(!r0(n)){r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.labels[${e}]`,"must be a label descriptor");continue}if(i.external&&r2(n,["id","text","anchor","bounds","halo","clearance","paint","fontSize","textAnchor","visual"],`${r}.labels[${e}]`,i.diagnostics),void 0!==n.id&&r5(n.id,`${r}.labels[${e}].id`,i.diagnostics,{externalId:i.external}),r5(n.text,`${r}.labels[${e}].text`,i.diagnostics,{empty:!0,max:rB}),i.aggregateBudgets&&r7(i.budget,"textBytes","textExceeded",n.text,`${r}.labels[${e}].text`,i.diagnostics,rL,"Scene text values"),void 0!==n.anchor&&r9(n.anchor,`${r}.labels[${e}].anchor`,i.diagnostics,i.budget,i.external),void 0!==n.bounds)if(r0(n.bounds)){for(let t of(i.external&&r2(n.bounds,["x0","y0","x1","y1"],`${r}.labels[${e}].bounds`,i.diagnostics),["x0","y0","x1","y1"]))r3(n.bounds[t],`${r}.labels[${e}].bounds.${t}`,i.diagnostics);"number"==typeof n.bounds.x0&&"number"==typeof n.bounds.x1&&n.bounds.x0>n.bounds.x1&&r1(i.diagnostics,"SCENE_BOUNDS",`${r}.labels[${e}].bounds`,"x0 must not exceed x1"),"number"==typeof n.bounds.y0&&"number"==typeof n.bounds.y1&&n.bounds.y0>n.bounds.y1&&r1(i.diagnostics,"SCENE_BOUNDS",`${r}.labels[${e}].bounds`,"y0 must not exceed y1")}else r1(i.diagnostics,"SCENE_BOUNDS",`${r}.labels[${e}].bounds`,"must be a finite ordered box");if(void 0!==n.clearance&&r3(n.clearance,`${r}.labels[${e}].clearance`,i.diagnostics,{nonNegative:!0}),void 0===n.block||r0(n.block)&&(c=n.block,em.has(c))||r1(i.diagnostics,"SCENE_FIDELITY",`${r}.labels[${e}].block`,"must retain the actual immutable pixel text preparation"),void 0!==n.fontSize&&r3(n.fontSize,`${r}.labels[${e}].fontSize`,i.diagnostics,{positive:!0}),void 0!==n.fontWeight&&r3(n.fontWeight,`${r}.labels[${e}].fontWeight`,i.diagnostics,{positive:!0}),void 0!==n.letterSpacing&&r3(n.letterSpacing,`${r}.labels[${e}].letterSpacing`,i.diagnostics),void 0!==n.display&&"literal"!==n.display&&"formatted"!==n.display&&r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.labels[${e}].display`,"must be literal or formatted"),void 0===n.textAnchor||["start","middle","end"].includes(String(n.textAnchor))||r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.labels[${e}].textAnchor`,"must be start, middle, or end"),void 0!==n.paint&&r6(n.paint,`${r}.labels[${e}].paint`,i.diagnostics,i.external),void 0!==n.halo&&(r0(n.halo)?(i.external&&r2(n.halo,["color","width"],`${r}.labels[${e}].halo`,i.diagnostics),r3(n.halo.width,`${r}.labels[${e}].halo.width`,i.diagnostics,{nonNegative:!0}),void 0!==n.halo.color&&void 0===O(n.halo.color)&&r1(i.diagnostics,"SCENE_PAINT",`${r}.labels[${e}].halo.color`,"must be a safe non-fetching CSS paint")):r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.labels[${e}].halo`,"must be a halo descriptor")),void 0!==n.visual)if(r0(n.visual)&&["inline","companion"].includes(String(n.visual.kind)))if("companion"===n.visual.kind){let t=`${r}.labels[${e}].visual.markId`;r5(n.visual.markId,t,i.diagnostics,{externalId:i.external})&&i.companionLabelReferences.push({id:n.visual.markId,path:t})}else(void 0===n.anchor||void 0===n.paint||void 0===n.fontSize||void 0===n.textAnchor)&&r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.labels[${e}].visual`,"inline labels require anchor, paint, fontSize, and textAnchor");else r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.labels[${e}].visual`,"must be inline or companion label ownership")}}if(r0(t.markers)){Array.isArray(t.markers.mid)||r1(i.diagnostics,"SCENE_MARKER",`${r}.markers.mid`,"must be an array"),Array.isArray(t.markers.mid)&&t.markers.mid.length>rA&&r1(i.diagnostics,"SCENE_BOUNDS",`${r}.markers.mid`,"contains too many mid markers");let e=[[t.markers.start,`${r}.markers.start`],[t.markers.end,`${r}.markers.end`]];if(Array.isArray(t.markers.mid))for(let i=0;i<Math.min(t.markers.mid.length,rA);i++)e.push([t.markers.mid[i],`${r}.markers.mid[${i}]`]);for(let[t,r]of e)void 0!==t&&ii(t,r,i.diagnostics,i.external,i.budget)&&r0(t)&&"string"==typeof t.id&&i.markerReferences.push({id:t.id,path:`${r}.id`,marker:t})}else r1(i.diagnostics,"SCENE_MARKER",`${r}.markers`,"must be a typed marker set");if(!(!i.external&&!i.crossChecks&&i.native&&void 0!==ti(t))){if(r0(t.terminalProjection)){for(let e of(["native","emulated","projected","lossy","unsupported"].includes(String(t.terminalProjection.realization))||r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.terminalProjection.realization`,"has an unknown realization"),["line","polyline","path"].includes(String(t.terminalProjection.topology))||r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.terminalProjection.topology`,"has an unknown topology"),ir(t.terminalProjection.geometry,`${r}.terminalProjection.geometry`,i.diagnostics,!1,0,void 0,i.external),["forward","reverse","bidirectional","undirected","self"].includes(String(t.terminalProjection.direction))||r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.terminalProjection.direction`,"has an unknown direction"),["solid","dotted","dashed","thick","invisible"].includes(String(t.terminalProjection.lineStyle))||r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.terminalProjection.lineStyle`,"has an unknown line style"),["labels","strokeLosses","diagnostics"]))Array.isArray(t.terminalProjection[e])||r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.terminalProjection.${e}`,"must be an array");if(r0(t.terminalProjection.markers)&&Array.isArray(t.terminalProjection.markers.mid)||r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.terminalProjection.markers`,"must contain a mid-marker array"),r0(t.terminalProjection.markerPlacements))for(let e of["start","mid","end"]){let n=t.terminalProjection.markerPlacements[e];if(!Array.isArray(n)){r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.terminalProjection.markerPlacements.${e}`,"must be an array");continue}for(let t=0;t<Math.min(n.length,rA);t++){let o=n[t];if(!r0(o)){r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.terminalProjection.markerPlacements.${e}[${t}]`,"must be a marker placement");continue}r5(o.markerId,`${r}.terminalProjection.markerPlacements.${e}[${t}].markerId`,i.diagnostics,{externalId:i.external}),r9(o.point,`${r}.terminalProjection.markerPlacements.${e}[${t}].point`,i.diagnostics,void 0,i.external),r3(o.contourIndex,`${r}.terminalProjection.markerPlacements.${e}[${t}].contourIndex`,i.diagnostics,{nonNegative:!0})}}else r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.terminalProjection.markerPlacements`,"must contain typed start/mid/end marker placements");for(let e of["endpoints","route","stroke","hit"])r0(t.terminalProjection[e])||r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.terminalProjection.${e}`,"must preserve typed connector semantics")}else r1(i.diagnostics,"SCENE_DOCUMENT",`${r}.terminalProjection`,"must be a terminal projection");!i.external&&i.crossChecks&&function(e,t,r){if(!r0(e.route)||!r0(e.stroke)||!r0(e.markers)||!Array.isArray(e.markers.mid)||!Array.isArray(e.labels)||!r0(e.hit)||!r0(e.endpoints)||!r0(e.relationship)||!r0(e.terminalProjection)||!Array.isArray(e.terminalProjection.diagnostics))return;let i=e.route.geometry,n=eM(i,e.route.closed),o=n.starts[0],a=n.ends.at(-1);for(let[i,n,s]of[["start",e.endpoints.start?.point,o],["end",e.endpoints.end?.point,a]])n&&s&&!e$(n,s)&&r1(r.diagnostics,"SCENE_FIDELITY",`${t}.endpoints.${i}.point`,"must equal the endpoint derived from connector geometry");let s=eC(i,e.route.closed);e.route.contours.length!==s.length&&r1(r.diagnostics,"SCENE_FIDELITY",`${t}.route.contours`,"must match the geometry-derived contour count");let d=!eN(i);for(let i=0;i<Math.min(e.route.contours.length,s.length);i++){let n=e.route.contours[i],o=s[i];if(e$(n.start,o.start)&&e$(n.end,o.end)&&n.closed===o.closed||r1(r.diagnostics,"SCENE_FIDELITY",`${t}.route.contours[${i}]`,"must match geometry-derived endpoint topology"),d)for(let e of["startTangent","endTangent"]){let a=n[e],s=o[e];(void 0===a!=(void 0===s)||a&&s&&!e$(a,s,1e-9))&&r1(r.diagnostics,"SCENE_FIDELITY",`${t}.route.contours[${i}].${e}`,"must match the tangent derived from linear route geometry")}}let l=e.route.contours[0]?.startTangent,c=e.route.contours.at(-1)?.endTangent;for(let[i,n,o]of[["startTangent",e.route.startTangent,l],["endTangent",e.route.endTangent,c]])(void 0===n!=(void 0===o)||n&&o&&!e$(n,o,1e-9))&&r1(r.diagnostics,"SCENE_FIDELITY",`${t}.route.${i}`,"must equal the corresponding contour tangent authority");try{let n=e8({geometry:i,lineStyle:e.lineStyle,endpoints:e.endpoints,relationship:e.relationship,route:e.route,stroke:e.stroke,markers:e.markers,labels:e.labels,hit:e.hit,...e.transform?{transform:e.transform}:{},additionalDiagnostics:e.terminalProjection.diagnostics.slice(1)});(function e(t,r){if(Object.is(t,r))return!0;if(Array.isArray(t)||Array.isArray(r))return Array.isArray(t)&&Array.isArray(r)&&t.length===r.length&&t.every((t,i)=>e(t,r[i]));if(!r0(t)||!r0(r))return!1;let i=Object.keys(t).filter(e=>void 0!==t[e]).sort(),n=Object.keys(r).filter(e=>void 0!==r[e]).sort();return i.length===n.length&&i.every((i,o)=>i===n[o]&&e(t[i],r[i]))})(e.terminalProjection,n)||r1(r.diagnostics,"SCENE_FIDELITY",`${t}.terminalProjection`,"must equal the canonical projection derived from connector semantics")}catch(e){r1(r.diagnostics,"SCENE_FIDELITY",`${t}.terminalProjection`,e instanceof Error?e.message:String(e))}}(t,r,i)}}function is(e,t,r){if(r0(e))for(let i of["fill","stroke"]){let n=r8(e[i]);n&&r.push({id:n,path:`${t}.${i}`})}}function id(e,t={}){return"external"===t.mode||"internal"===t.mode?t.mode:(r0(e)&&"string"==typeof e.family?r(e.family):void 0)?.kind==="family"?"external":"internal"}function il(e,t={}){let r=[];if(im(e,!1,r),"external"===id(e)&&r1(r,"SCENE_DOCUMENT","scene.family","native admission requires a built-in family"),r.length>0)throw new r_(r);let i={artwork:[],groups:new Set,enclosures:new Map},n={...iu(r,!1,t.crossChecks??!1,!0),native:i},o,a=()=>{if(o)throw Error("Native Scene validation has already finished");if(r.length>0)throw new r_(r)},s=e=>{if(a(),!Number.isInteger(e)||e<0||e>rD)throw r1(r,"SCENE_BOUNDS","scene.depth",`must be an integer nesting depth between 0 and ${rD}`),new r_(r)};return{node(e,t=0){if(a(),s(t),"group"===e.kind&&(!Array.isArray(e.children)||0!==e.children.length))throw r1(r,"SCENE_DOCUMENT","scene.parts","native groups must be shallow headers with separately submitted children"),new r_(r);let i=`scene.parts[${n.nodeCount}]`;if(ia(e,i,n,t),r.length>0)throw new r_(r);let o="document"===e.kind?tN(e):io(e,i,n);if(r.length>0)throw new r_(r);return o},depth:s,enclosure(e,t){a(),r5(e,"scene.enclosure.id",r),r5(t.id,"scene.enclosure.owner.id",r);let n=i.enclosures.get(e);if(n&&(n.id!==t.id||n.role!==t.role)?r1(r,"SCENE_FIDELITY","scene.enclosure","artwork cannot have conflicting semantic enclosures"):i.enclosures.size>=rA?r1(r,"SCENE_BOUNDS","scene.enclosure","contains too many semantic enclosure relations"):i.enclosures.set(e,{id:t.id,role:t.role}),r.length>0)throw new r_(r)},serialization(e){if(a(),N(e,rF)>rF)throw r1(r,"SCENE_DOCUMENT","scene.serialization","has an oversized SVG serialization"),new r_(r)},finish(){if(o)return o;for(let e of(ic(n),i.artwork)){let t=i.enclosures.get(e.id);t&&t.id===e.owner.id&&t.role===e.owner.role&&i.groups.has(JSON.stringify([t.id,t.role]))||r1(r,"SCENE_FIDELITY",e.path,"owned artwork without DOM identity must be inside its matching semantic group")}return o=Object.freeze({valid:0===r.length,diagnostics:Object.freeze(r.map(e=>Object.freeze(e)))})}}}function ic(e){for(let t of e.paintReferences)e.gradientIds.has(t.id)||r1(e.diagnostics,"SCENE_REFERENCE",t.path,`references undeclared gradient "${t.id}"`);for(let t of e.ownerReferences)e.subjects.has(t.key)||r1(e.diagnostics,"SCENE_REFERENCE",t.path,"must reference an actual Scene subject identity and role");for(let t of e.companionLabelReferences){let r=e.ids.get(t.id);r?"text"!==r.kind&&r1(e.diagnostics,"SCENE_REFERENCE",t.path,`must reference a Text mark; "${t.id}" is a ${r.kind} mark`):r1(e.diagnostics,"SCENE_REFERENCE",t.path,`references unknown companion Text mark "${t.id}"`)}}function iu(e,t,r,i=t){return{diagnostics:e,external:t,aggregateBudgets:i,paintReferences:[],ids:new Map,subjects:new Set,ownerReferences:[],domIds:new Map,markerIds:new Map,gradientIds:new Map,markerReferences:[],endpointReferences:[],companionLabelReferences:[],budget:{textBytes:0,serializationBytes:0,points:0,textExceeded:!1,serializationExceeded:!1,pointsExceeded:!1,pointCollections:new WeakSet},crossChecks:r,nodeCount:0}}function im(e,t,r){r5(e.family,"scene.family",r);let i=r3(e.width,"scene.width",r,t?{positive:!0}:{nonNegative:!0}),n=r3(e.height,"scene.height",r,t?{positive:!0}:{nonNegative:!0});if(void 0!==e.transparent&&"boolean"!=typeof e.transparent&&r1(r,"SCENE_DOCUMENT","scene.transparent","must be boolean"),r0(e.colors)){for(let i of(t&&r2(e.colors,["bg","fg","line","accent","muted","surface","border","font","shadow","embedFontImport"],"scene.colors",r),["bg","fg","line","accent","muted","surface","border"]))("bg"===i||"fg"===i||void 0!==e.colors[i])&&void 0===O(e.colors[i])&&r1(r,"SCENE_PAINT",`scene.colors.${i}`,"must be a safe non-fetching CSS paint");void 0!==e.colors.font&&void 0===z(e.colors.font)&&r1(r,"SCENE_SECURITY","scene.colors.font","must be a safe non-fetching font family"),void 0!==e.colors.shadow&&"boolean"!=typeof e.colors.shadow&&r1(r,"SCENE_DOCUMENT","scene.colors.shadow","must be boolean"),void 0!==e.colors.embedFontImport&&"boolean"!=typeof e.colors.embedFontImport&&r1(r,"SCENE_DOCUMENT","scene.colors.embedFontImport","must be boolean")}else r1(r,"SCENE_DOCUMENT","scene.colors","must be a DiagramColors object");return{widthOk:i,heightOk:n}}var ip=globalThis.process?.env,ih=ip?.AGENTIC_MERMAID_SCENE_ASSERTIONS==="1",ig=new WeakSet;function iy(e){return ih||void 0!==e&&(ig.has(e)||"strict"===e.renderOptions.layoutSafety)}var ib=16*rj.maxNodes,ix=16*rj.maxNodes,ik=8*rj.maxTextBytes,iv=Object.freeze({...Object.freeze({maxObjects:4*rj.maxNodes,maxTextBytes:rj.maxTextBytes,maxArrayEntries:rj.maxNodes,maxAggregateArrayEntries:ix,maxDepth:4*rj.maxDepth,maxPropertiesPerObject:64,maxAggregateProperties:ib,maxPropertyKeyBytes:256,maxAggregatePropertyKeyBytes:ik}),maxObjects:8*rj.maxNodes,maxTextBytes:rj.maxTextBytes+rj.maxAggregateSerializationBytes+rj.maxFinalSvgBytes}),iE=new WeakMap;function i$(e,t,r=!0){iE.set(e,{mode:t,crossChecks:r})}function iw(){throw new r_([{code:"SCENE_DOCUMENT",path:"scene.family",message:"source-only browser admission requires a built-in family"}])}function iS(e,t,r){let i=function(e,t,r,i){let n=[];if(!r0(e))return Object.freeze({valid:!1,diagnostics:Object.freeze([{code:"SCENE_DOCUMENT",path:"scene",message:"must be a Scene document object"}])});let o="external"===id(e,t);if(o&&1)return r1(n,"SCENE_DOCUMENT","scene.family","source-only browser admission requires a built-in family"),Object.freeze({valid:!1,diagnostics:Object.freeze(n)});o&&r2(e,["family","width","height","colors","transparent","parts"],"scene",n);let{widthOk:a,heightOk:s}=im(e,o,n);if(Array.isArray(e.parts)){let t=iu(n,o,r);e.parts.length>rA&&r1(n,"SCENE_BOUNDS","scene.parts","contains too many top-level Scene nodes");for(let r=0;r<Math.min(e.parts.length,rA);r++)ia(e.parts[r],`scene.parts[${r}]`,t,0);let i=o?(void 0).document(e,t,a,s):void 0;if(ic(t),0===n.length&&o&&(void 0).canonical(e,n),0===n.length&&r)try{let t=o?i:e.parts.map(tN).join(`
20
+ `);void 0!==t&&rc(t,o?"strict":"default")}catch(e){r1(n,"SCENE_SECURITY","scene",e instanceof Error?e.message:String(e))}}else r1(n,"SCENE_DOCUMENT","scene.parts","must be an array");return Object.freeze({valid:0===n.length,diagnostics:Object.freeze(n.map(e=>Object.freeze(e)))})}(e,{mode:t},r);if(!i.valid)throw new r_(i.diagnostics)}function iN(e){return iC(e)}function iC(e,t,r=iy()){return function(e,t,r,i,n=!1){let o="object"==typeof e&&null!==e?iE.get(e):void 0;n&&("external"===t||void 0!==o&&("external"===o.mode||"external"===id(e)))&&iw();let a="internal"!==t||r;if(void 0!==o&&o.mode===(t??id(e)))return("external"===o.mode||r)&&!o.crossChecks&&(i(e,o.mode,!0),i$(e,o.mode,!0)),e;let s=function(e,t,r="input"){let i=new WeakSet,n=new WeakMap,o=0,a=0,s=0,d=0,l=0,c=(e,r,u)=>{if("string"==typeof e){let r=Math.max(0,t.maxTextBytes-a),i=N(e,r);if(i>r)throw Error(`External Scene text values exceed the aggregate ${t.maxTextBytes}-byte limit`);return a+=i,e}if(null===e||"object"!=typeof e){if("function"==typeof e||"symbol"==typeof e||"bigint"==typeof e)throw TypeError(`External Scene ${u} must be declarative data`);return e}if(r>t.maxDepth)throw Error("External Scene input object graph is too deeply nested");if(++o>t.maxObjects)throw Error("External Scene input object graph is too large");if(i.has(e))throw Error("External Scene input must be acyclic");let m=n.get(e);if(void 0!==m)return m;i.add(e);try{if(Array.isArray(e)){if(Object.getPrototypeOf(e)!==Array.prototype)throw TypeError(`External Scene ${u} must be a plain array`);let i=Reflect.getOwnPropertyDescriptor(e,"length");if(!i||!("value"in i)||"number"!=typeof i.value||!Number.isSafeInteger(i.value)||i.value<0)throw TypeError(`External Scene ${u}.length must be a non-negative integer data property`);let o=i.value;if(o>t.maxArrayEntries)throw Error(`External Scene ${u} contains too many entries`);if((s+=o)>t.maxAggregateArrayEntries)throw Error(`External Scene input exceeds the aggregate ${t.maxAggregateArrayEntries}-array-entry limit`);let a=Reflect.ownKeys(e);if(a.length>o+1||!a.includes("length"))throw TypeError(`External Scene ${u} must not define custom array properties or iterators`);let d=new Map;for(let t of(d.set("length",i),a)){if("length"===t)continue;let r=Reflect.getOwnPropertyDescriptor(e,t);if(!r)throw TypeError(`External Scene ${u} has an unstable property descriptor`);d.set(t,r)}for(let e of a)if("length"!==e&&("string"!=typeof e||!/^(?:0|[1-9]\d*)$/.test(e)||Number(e)>=o))throw TypeError(`External Scene ${u} must not define custom array properties or iterators`);let l=Array(o);n.set(e,l),tM(e,l);for(let e=0;e<o;e++){let t=d.get(String(e));if(!t)throw TypeError(`External Scene ${u} must not be sparse`);if(!("value"in t)||!t.enumerable)throw TypeError(`External Scene ${u}[${e}] must be an enumerable data property`);l[e]=c(t.value,r+1,`${u}[${e}]`)}return Object.freeze(l)}let i=Object.getPrototypeOf(e);if(i!==Object.prototype&&null!==i)throw TypeError(`External Scene ${u} must be a plain object`);let o=Reflect.ownKeys(e);if(o.length>t.maxPropertiesPerObject)throw Error(`External Scene ${u} contains too many properties`);if((d+=o.length)>t.maxAggregateProperties)throw Error(`External Scene input exceeds the aggregate ${t.maxAggregateProperties}-property limit`);for(let e of o){if("string"!=typeof e)continue;let r=Math.max(0,t.maxAggregatePropertyKeyBytes-l),i=N(e,Math.min(t.maxPropertyKeyBytes,r));if(i>t.maxPropertyKeyBytes)throw Error(`External Scene ${u} contains a property key longer than ${t.maxPropertyKeyBytes} bytes`);if(i>r)throw Error(`External Scene property keys exceed the aggregate ${t.maxAggregatePropertyKeyBytes}-byte limit`);l+=i}let a=Object.create(null);for(let t of(n.set(e,a),tM(e,a),o)){let i;if("string"!=typeof t)throw TypeError(`External Scene ${u} must not contain symbol keys`);let n=Reflect.getOwnPropertyDescriptor(e,t);if(!n||!n.enumerable)throw TypeError(`External Scene ${u}.${t} must be an enumerable data property`);if("value"in n)i=n.value;else if(i=function(e,t,r){let i=e7.get(e);return"terminalProjection"===t&&i&&r.get===tt.get?tt.get.call(e):void 0}(e,t,n),void 0===i)throw TypeError(`External Scene ${u}.${t} must be an enumerable data property`);Object.defineProperty(a,t,{value:c(i,r+1,`${u}.${t}`),enumerable:!0,configurable:!1,writable:!1})}return eh(e,a),Object.freeze(a)}finally{i.delete(e)}};return c(e,0,r)}(e,iv,"scene");return n&&"external"===id(s)&&iw(),i(s,t,"internal"!==t||r),i$(s,t??id(s),a),s}(e,t,r,iS,!0)}var iM="backend-claim-matrix@4";function iz(){let e={bg:"#ffffff",fg:"#172033",line:"#334155",accent:"#a33b20"},t={id:"backend-conformance-arrow",shape:"arrow",geometry:{kind:"path",d:"M 0 0 L 8 4 L 0 8 Z"},size:{width:8,height:8},viewBox:{x:0,y:0,width:8,height:8},ref:{x:8,y:4},units:"userSpaceOnUse",orient:"auto",overflow:"visible",paint:{fill:"#a33b20",stroke:"#334155",strokeWidth:"1"}},r={id:"backend-conformance-gradient",units:"userSpaceOnUse",x1:0,y1:0,x2:120,y2:0,stops:[{offset:0,color:"#a33b20"},{offset:1,color:"#334155"}]},i=tV({id:"backend-conformance-prelude",width:120,height:80,colors:e,transparent:!0,font:"Inter",hasMonoFont:!1},'<svg xmlns="http://www.w3.org/2000/svg" width="120" height="80" viewBox="0 0 120 80" role="img" aria-labelledby="backend-conformance-title backend-conformance-description">'),n=tR({id:"backend-conformance-title",element:"title",text:"Backend conformance fixture",domId:"backend-conformance-title"}),o=tR({id:"backend-conformance-description",element:"description",text:"A representative Scene document",domId:"backend-conformance-description"}),a=tW({id:"backend-conformance-definitions",markerResources:[t],gradientResources:[r]},`<defs>
21
+ ${rS(t)}
22
+ ${rT(r)}
23
+ </defs>`),s=tI({id:"backend-conformance-node",role:"node",geometry:{kind:"rect",x:8,y:16,width:34,height:24,rx:3,ry:3},paint:{fill:"#f4efe6",stroke:"#334155",strokeWidth:"2"}}),d=tG({id:"backend-conformance-container",role:"group",open:"<g>",paint:{opacity:"0.8",fill:"#f4efe6"},close:"</g>",children:[{node:s,indent:2}]}),l=tI({id:"backend-conformance-data-mark",role:"bar",geometry:{kind:"rect",x:92,y:48,width:16,height:20},paint:{fill:"#a33b20",stroke:"#334155",strokeWidth:"1"},channels:{value:.75,category:"fixture"}}),c=tP({id:"backend-conformance-relation",role:"edge",geometry:{kind:"path",d:"M 42 28 L 62 14 Q 66 12 70 14 L 90 28",points:[{x:42,y:28},{x:66,y:12},{x:90,y:28}],markerMidpoints:[{x:62,y:14},{x:70,y:14}]},lineStyle:"dashed",paint:{fill:"none",stroke:"#334155",strokeWidth:"2",opacity:"0.65",strokeLinecap:"square",strokeLinejoin:"bevel",strokeMiterlimit:"7",strokeDasharray:"6 3",strokeDashoffset:"2",vectorEffect:"non-scaling-stroke",paintOrder:"stroke fill"},endpoints:{from:"backend-conformance-node",to:"backend-conformance-data-mark"},relationship:{kind:"dependency",direction:"forward"},route:{ownership:"layout",bendRadius:4,labelAnchors:[{x:66,y:8}],contours:[{start:{x:42,y:28},end:{x:90,y:28},closed:!1,startTangent:{x:.8192319205190405,y:-.5734623443633283},endTangent:{x:.8192319205190405,y:.5734623443633283}}]},stroke:{opacity:.65,dash:{array:"6 3",offset:2},lineCap:"square",lineJoin:"bevel",miterLimit:7,pathLength:77,paintOrder:"stroke fill",mixBlendMode:"multiply",nonScaling:!0},markers:{start:t,mid:[t],end:t},labels:[{id:"backend-conformance-relation-label",text:"depends on",anchor:{x:66,y:8},clearance:2,halo:{color:"#ffffff",width:3},paint:{fill:"#172033"},fontSize:11,textAnchor:"middle",visual:{kind:"inline"}}]}),u=tP({id:"backend-conformance-freehand-relation",role:"edge",geometry:{kind:"line",x1:42,y1:58,x2:90,y2:58},lineStyle:"solid",paint:{fill:"none",stroke:"#334155",strokeWidth:"2",strokeLinecap:"square",strokeLinejoin:"miter",strokeMiterlimit:"7",vectorEffect:"non-scaling-stroke"},endpoints:{from:"backend-conformance-node",to:"backend-conformance-data-mark"},relationship:{kind:"association",direction:"forward"},stroke:{lineCap:"square",lineJoin:"miter",miterLimit:7,nonScaling:!0},transform:{kind:"rotate",angle:90,cx:42,cy:58}}),m=tP({id:"backend-conformance-closed-relation",role:"edge",geometry:{kind:"path",d:"M 10 65 L 25 50 L 40 65 Z",points:[{x:10,y:65},{x:25,y:50},{x:40,y:65}]},lineStyle:"solid",paint:{fill:"none",stroke:"#334155",strokeWidth:"2"},route:{ownership:"authored",closed:!0}}),f=tP({id:"backend-conformance-multi-relation",role:"edge",geometry:{kind:"path",d:"M 8 72 L 28 72 M 52 72 L 72 72",points:[{x:8,y:72},{x:28,y:72},{x:52,y:72},{x:72,y:72}],subpaths:[{points:[{x:8,y:72},{x:28,y:72}],closed:!1},{points:[{x:52,y:72},{x:72,y:72}],closed:!1}]},lineStyle:"solid",paint:{fill:"none",stroke:"#334155",strokeWidth:"2"},markers:{start:t,mid:[],end:t}}),p=tF({id:"backend-conformance-text",role:"member",text:"Fixture label",x:25,y:31,fontSize:12,anchor:"middle",paint:{fill:"#172033"},baselineShift:0});return S({doc:{family:"backend-conformance",width:120,height:80,colors:e,transparent:!1,parts:[i,n,o,a,d,l,c,p,tq()]},context:{seed:24301,style:{stroke:"freehand",fill:"wash",roughness:1,bowing:1,passes:2,strokeWidth:1.5,hachureAngle:-41,hachureGap:5,fillWeight:.8,washOpacity:.3,washEdge:.34,backdrop:"plain"}},probes:[{primitive:"document",node:i,requiredFragments:["<svg","backend-conformance-title"]},{primitive:"marker",node:a,requiredFragments:['id="backend-conformance-arrow"']},{primitive:"container",node:d,requiredFragments:['data-id="backend-conformance-container"','data-id="backend-conformance-node"']},{primitive:"shape",node:s,requiredFragments:['data-id="backend-conformance-node"','data-role="node"']},{primitive:"data-mark",node:l,requiredFragments:['data-id="backend-conformance-data-mark"','data-role="bar"']},{primitive:"connector",node:c,requiredFragments:['data-id="backend-conformance-relation"','data-role="edge"']},{primitive:"text",node:p,requiredFragments:['data-id="backend-conformance-text"',"Fixture label"]}],nodes:{root:i,marker:a,shape:s,container:d,dataMark:l,richConnector:c,freehandConnector:u,closedConnector:m,multiSubpathConnector:f,label:p}})}function iO(e){return 0===e.length?void 0:`missing ${e.join(", ")}`}function iT(e,t,r){return e?{passed:e,observation:t}:{passed:e,observation:t,diagnostic:r}}function ij(e,t){return e.split(t).length-1}function i_(e,t){let r=e.drawNode(t,iG.context);return rX(r,"backend conformance drawNode output"),r}function iI(e){let t=e.render(iG.doc,iG.context);return rX(t,"backend conformance render output"),t}function iA(e,t){let r=e.match(/^\s*<(?:line|polyline|path)\b[^>]*>/)?.[0]??"";return/\sstroke-opacity="0"/.test(r)?e.split(`
24
+ `).slice(t.split(`
25
+ `).length).join(`
26
+ `):e}function iD(e,t,r,i=()=>!0){let n=i_(e,r),o=iA(n,tN(r)),a="text"===r.kind?n.includes(r.text)&&n.includes(`x="${r.x}"`)&&n.includes(`y="${r.y}"`):"shape"===r.kind&&"rect"===r.geometry.kind?n.includes(`x="${r.geometry.x}"`)&&n.includes(`y="${r.geometry.y}"`)&&n.includes(`width="${r.geometry.width}"`)&&n.includes(`height="${r.geometry.height}"`):"connector"===r.kind&&"line"===r.route.geometry.kind?n.includes(`x1="${r.route.geometry.x1}"`)&&n.includes(`y1="${r.route.geometry.y1}"`)&&n.includes(`x2="${r.route.geometry.x2}"`)&&n.includes(`y2="${r.route.geometry.y2}"`):"connector"===r.kind&&"path"===r.route.geometry.kind?n.includes(`d="${r.route.geometry.d}"`):n===tN(r),s="native"===t.realization?a:"emulated"===t.realization&&n!==tN(r)&&o.includes("<path"),d="backend:hybrid"!==t.target||"shape"!==r.kind||n.includes("fill-opacity=")&&n.includes('stroke="none"');return iT(s&&d&&i(n,o),(t.realization,""),`backend output did not demonstrate ${t.realization} ${t.primitive}/${t.feature}`)}function iB(e,t,r,i){let n="lossy"===t.realization?iG.nodes.freehandConnector:iG.nodes.richConnector,o=i_(e,n),a=iA(o,tN(n));return"lossy"===t.realization?iT(o!==tN(n)&&a.includes('stroke="none"')&&!a.includes(`${r}="`),"",`lossy ${r} projection was not observable on the visible freehand ribbon`):iT(("native"===t.realization?o.includes('data-id="backend-conformance-relation"'):o!==tN(n))&&a.includes(`${r}="${i}"`),(t.realization,""),`${r}=${i} was not preserved by the ${t.realization} realization`)}function iL(e){return[e.primitive,e.feature,e.operation].join("/")}Object.freeze(["draw-node-determinism","draw-node-semantics","document-determinism","single-svg-document","finite-serialization","output-security","document-semantics","container-semantics","shape-semantics","text-semantics","connector-semantics","marker-semantics","data-mark-semantics","capability-claims"]);var iP=Object.freeze({"document/identity/serialize":e=>{let t=iI(e);return iT(1===ij(t,"<svg")&&t.includes('viewBox="0 0 120 80"')&&t.trimEnd().endsWith("</svg>"),"","document envelope or bounds were not preserved")},"document/resources/serialize":e=>{let t=iI(e);return iT(t.includes("<defs>")&&t.includes('id="backend-conformance-arrow"')&&t.includes('<linearGradient id="backend-conformance-gradient"')&&rl(t).ok,"","document resources were missing or unsafe")},"document/interaction/accessibility":e=>{let t=iI(e);return iT(t.includes('role="img"')&&t.includes('aria-labelledby="backend-conformance-title backend-conformance-description"')&&t.includes('<title id="backend-conformance-title">Backend conformance fixture</title>')&&t.includes('<desc id="backend-conformance-description">A representative Scene document</desc>'),"","document accessibility projection was incomplete")},"text/geometry/render":(e,t)=>iD(e,t,iG.nodes.label,e=>e.includes('x="25"')&&e.includes('y="31"')&&e.includes('font-size="12"')),"text/paint/render":(e,t)=>iD(e,t,iG.nodes.label,e=>e.includes('fill="#172033"')),"text/labels/accessibility":e=>iT(i_(e,iG.nodes.label).includes("Fixture label"),"","text label was not serialized"),"text/identity/serialize":e=>{let t=i_(e,iG.nodes.label);return iT(t.includes('data-id="backend-conformance-text"')&&t.includes('data-role="member"'),"","text DOM identity was lost")},"shape/geometry/render":(e,t)=>iD(e,t,iG.nodes.shape),"shape/paint/render":(e,t)=>iD(e,t,iG.nodes.shape,e=>e.includes("#334155")&&e.includes("#f4efe6")),"shape/identity/serialize":e=>{let t=i_(e,iG.nodes.shape);return iT(t.includes('data-id="backend-conformance-node"')&&t.includes('data-role="node"'),"","shape DOM identity was lost")},"container/geometry/render":(e,t)=>{let r=i_(e,iG.nodes.container);return iT("native"===t.realization&&r.startsWith("<g ")&&r.trimEnd().endsWith("</g>")&&r.includes('data-id="backend-conformance-node"'),"","container boundary/child geometry was not preserved as a native wrapper")},"container/paint/render":(e,t)=>{let r=i_(e,iG.nodes.container);return iT("native"===t.realization&&r.includes('opacity="0.8"')&&r.includes('fill="#f4efe6"'),"","container paint cascade was not preserved as a native wrapper")},"container/identity/serialize":e=>{let t=i_(e,iG.nodes.container);return iT(t.includes('data-id="backend-conformance-container"')&&t.includes('data-role="group"'),"","container DOM identity was lost")},"connector/geometry/render":(e,t)=>{let r=iG.nodes.richConnector,i=i_(e,r),n=iA(i,tN(r));return iT("native"===t.realization?"path"===r.route.geometry.kind&&i.includes(`d="${r.route.geometry.d}"`):"lossy"===t.realization&&i!==tN(r)&&i.includes("Q 66 12 70 14")&&!n.includes("Q 66 12 70 14"),(t.realization,""),"connector geometry realization did not match its claim")},"connector/stroke/render":(e,t)=>iD(e,t,iG.nodes.freehandConnector,e=>e.includes("#334155")),"connector/transform/render":(e,t)=>{let r=iG.nodes.freehandConnector,i=i_(e,r),n=iA(i,tN(r));return iT(i.includes('transform="rotate(90 42 58)"')&&rv(r,{x:42,y:82})&&!rv(r,{x:66,y:58})&&("native"===t.realization?!/\sstroke-opacity="0"/.test(i.match(/^\s*<(?:line|polyline|path)\b[^>]*>/)?.[0]??""):"emulated"===t.realization&&n.startsWith('<g transform="rotate(90 42 58)">')),"","connector transform was not preserved by both rendering and interaction")},"connector/topology/render":(e,t)=>{let r=iG.nodes.richConnector,i=i_(e,r),n=iA(i,tN(r));return iT("native"===t.realization?"path"===r.route.geometry.kind&&i.includes(`d="${r.route.geometry.d}"`):"lossy"===t.realization&&i!==tN(r)&&i.includes("Q 66 12 70 14")&&!n.includes("Q 66 12 70 14"),(t.realization,""),"connector topology realization did not match its claim")},"connector/subpaths/render":(e,t)=>{let r=iG.nodes.multiSubpathConnector,i=i_(e,r),n=iA(i,tN(r)),o=rv(r,{x:18,y:72})&&rv(r,{x:62,y:72})&&!rv(r,{x:40,y:72})&&2===r.route.contours.length&&r.route.contours.every(e=>e.startTangent?.x===1&&e.endTangent?.x===1),a="native"===t.realization?2===ij(i.match(/^\s*<path\b[^>]*>/)?.[0]??"","M "):"emulated"===t.realization&&i!==tN(r)&&ij(n,"<path")>=2;return iT(o&&a,"","connector subpath boundaries were not preserved")},"connector/closedness/render":(e,t)=>{let r=iG.nodes.closedConnector,i=i_(e,r),n=iA(i,tN(r));return iT(rv(r,{x:25,y:65})&&("native"===t.realization?/\sZ(?:\s|&quot;|")/.test(i.match(/^\s*<path\b[^>]*>/)?.[0]??""):"lossy"===t.realization&&i!==tN(r)&&/\sZ(?:\s|&quot;|")/.test(i.slice(0,i.indexOf(`
27
+ `)))&&!n.includes("M 10 65 L 25 50 L 40 65 Z")),(t.realization,""),"output did not demonstrate the declared closedness realization")},"connector/bend-radius/render":(e,t)=>{let r=iG.nodes.richConnector,i=i_(e,r),n=iA(i,tN(r));return iT(i.includes("Q 66 12 70 14")&&4===r.route.bendRadius&&("native"===t.realization?!/\sstroke-opacity="0"/.test(i.match(/^\s*<path\b[^>]*>/)?.[0]??""):"lossy"===t.realization&&i!==tN(r)&&!n.includes("Q 66 12 70 14")),(t.realization,""),"bend-radius realization did not match the declared capability")},"connector/stroke-opacity/render":(e,t)=>iB(e,t,"stroke-opacity","0.65"),"connector/stroke-cap/render":(e,t)=>iB(e,t,"stroke-linecap","square"),"connector/stroke-join/render":(e,t)=>iB(e,t,"stroke-linejoin","bevel"),"connector/stroke-miter/render":(e,t)=>iB(e,t,"stroke-miterlimit","7"),"connector/dash-array/render":(e,t)=>iB(e,t,"stroke-dasharray","6 3"),"connector/dash-offset/render":(e,t)=>iB(e,t,"stroke-dashoffset","2"),"connector/dash-restart/render":(e,t)=>{let r=iG.nodes.richConnector,i=iA(i_(e,r),tN(r)),n=ij(i,'stroke-dasharray="6 3"'),o=ij(i,"M");return iT("native"===t.realization?1===n:"lossy"===t.realization&&n>=1&&o>1,(t.realization,""),"dash restart boundaries did not match the declared realization")},"connector/path-length/render":(e,t)=>{let r=iG.nodes.richConnector,i=iA(i_(e,r),tN(r)),n=ij(i,'pathLength="77"'),o=ij(i,"M");return iT("native"===t.realization?1===n:"lossy"===t.realization&&n>=1&&o>1,(t.realization,""),"pathLength behavior did not match the declared realization")},"connector/paint-order/render":(e,t)=>iB(e,t,"paint-order","stroke fill"),"connector/compositing/render":(e,t)=>iB(e,t,"style","mix-blend-mode:multiply"),"connector/non-scaling-stroke/render":(e,t)=>iB(e,t,"vector-effect","non-scaling-stroke"),"connector/marker-orientation/render":(e,t)=>{let r=iI(e);if("unsupported"===t.realization)return iT(r.includes('orient="auto"')&&!r.includes('marker-start="url(#backend-conformance-arrow)"')&&!r.includes('marker-mid="url(#backend-conformance-arrow)"')&&!r.includes('marker-end="url(#backend-conformance-arrow)"'),"","backend declared connector marker orientation unsupported but attached the marker");let i=r.includes('orient="auto"')&&r.includes('marker-start="url(#backend-conformance-arrow)"')&&r.includes('marker-mid="url(#backend-conformance-arrow)"')&&r.includes('marker-end="url(#backend-conformance-arrow)"'),n="projected"!==t.realization||r.includes('markerUnits="userSpaceOnUse"');return iT(("native"===t.realization||"projected"===t.realization)&&i&&n,(t.realization,""),"marker orientation/carrier projection did not match the declaration")},"connector/marker-overflow/render":(e,t)=>{let r=iI(e),i=r.includes('marker-start="url(#backend-conformance-arrow)"')&&r.includes('marker-end="url(#backend-conformance-arrow)"');return"unsupported"===t.realization?iT(r.includes('overflow="visible"')&&!i&&!r.includes('marker-mid="url(#backend-conformance-arrow)"'),"","backend declared connector marker overflow unsupported but attached the marker"):iT(("native"===t.realization||"projected"===t.realization)&&r.includes('overflow="visible"')&&i,(t.realization,""),"marker overflow or its connector attachment was not preserved")},"connector/endpoints/serialize":e=>{let t=i_(e,iG.nodes.richConnector);return iT(t.includes('data-from="backend-conformance-node"')&&t.includes('data-to="backend-conformance-data-mark"'),"","connector endpoint identities were not serialized")},"connector/direction/serialize":e=>{let t=i_(e,iG.nodes.richConnector);return iT(t.includes('data-relationship="dependency"')&&t.includes('data-direction="forward"'),"","connector relationship direction was not serialized")},"connector/labels/accessibility":e=>iT(i_(e,iG.nodes.richConnector).includes('aria-label="backend-conformance-node to backend-conformance-data-mark: depends on"'),"","connector label was absent from accessibility output"),"connector/labels/render":(e,t)=>{let r=i_(e,iG.nodes.richConnector);return iT("native"===t.realization&&r.includes('data-id="backend-conformance-relation-label"')&&r.includes('data-connector-label-for="backend-conformance-relation"')&&r.includes('x="66" y="6"')&&r.includes('font-size="11"')&&r.includes('fill="#172033"')&&r.includes('stroke="#ffffff"')&&r.includes('stroke-width="3"')&&r.includes('paint-order="stroke fill"')&&r.includes(">depends on</text>"),"","connector label visual semantics were not preserved")},"connector/relation/accessibility":e=>{let t=i_(e,iG.nodes.richConnector);return iT(t.includes('data-from="backend-conformance-node"')&&t.includes('data-to="backend-conformance-data-mark"')&&t.includes('role="graphics-symbol"')&&t.includes('aria-roledescription="relation"')&&t.includes('aria-label="backend-conformance-node to backend-conformance-data-mark: depends on"'),"","connector relation accessibility semantics were lost")},"connector/markers/render":(e,t)=>{let r=i_(e,iG.nodes.richConnector);return"unsupported"===t.realization?iT(!r.includes('marker-start="url(#backend-conformance-arrow)"')&&!r.includes('marker-mid="url(#backend-conformance-arrow)"')&&!r.includes('marker-end="url(#backend-conformance-arrow)"'),"","backend declared connector markers unsupported but still serialized one"):iT(("native"===t.realization||"projected"===t.realization)&&r.includes('marker-start="url(#backend-conformance-arrow)"')&&r.includes('marker-mid="url(#backend-conformance-arrow)"')&&r.includes('marker-end="url(#backend-conformance-arrow)"'),(t.realization,""),"connector marker projection did not match the declaration")},"connector/interaction/hit-test":e=>{let t=iG.nodes.freehandConnector;return iT(i_(e,t).includes('data-id="backend-conformance-freehand-relation"')&&rv(t,{x:42,y:82})&&!rv(t,{x:66,y:58}),"","connector carrier or typed hit geometry was not preserved")},"connector/hit-geometry/hit-test":e=>{let t=iG.nodes.multiSubpathConnector;return iT(i_(e,t).includes('data-id="backend-conformance-multi-relation"')&&rv(t,{x:18,y:72})&&!rv(t,{x:40,y:72}),"","connector hit geometry did not preserve typed contour boundaries")},"connector/identity/serialize":e=>{let t=i_(e,iG.nodes.richConnector);return iT(t.includes('data-id="backend-conformance-relation"')&&t.includes('data-role="edge"'),"","connector DOM identity was lost")},"marker/geometry/render":(e,t)=>{let r=i_(e,iG.nodes.marker);return iT(("native"===t.realization||"projected"===t.realization)&&r.includes("M 0 0 L 8 4 L 0 8 Z")&&r.includes('viewBox="0 0 8 8"'),(t.realization,""),"marker geometry was not present in backend output")},"marker/paint/render":(e,t)=>{let r=i_(e,iG.nodes.marker);return iT(("native"===t.realization||"projected"===t.realization)&&r.includes('fill="#a33b20"')&&r.includes('stroke="#334155"'),(t.realization,""),"marker paint was not present in backend output")},"marker/identity/serialize":e=>iT(i_(e,iG.nodes.marker).includes('id="backend-conformance-arrow"'),"","marker resource identity was lost"),"data-mark/geometry/render":(e,t)=>iD(e,t,iG.nodes.dataMark),"data-mark/paint/render":(e,t)=>iD(e,t,iG.nodes.dataMark,e=>e.includes("#a33b20")&&e.includes("#334155")),"data-mark/identity/serialize":e=>{let t=i_(e,iG.nodes.dataMark);return iT(t.includes('data-id="backend-conformance-data-mark"')&&t.includes('data-role="bar"'),"","quantitative mark DOM identity was lost")}}),iF=Symbol();function iU(e,t,r){return e[iF]?.(t,r)??r}function iR(e,t,r,i){return[e,...i.map(e=>tC(e.serialized,e.indent)),t].join(r)}function iW(e,t){return!t.style||e.transparent?"":`<rect width="${k(e.width)}" height="${k(e.height)}" fill="var(--bg)" data-backdrop="page" />`}var iq,iG,iV,iH={id:"default",capabilities:ry("backend:default","crisp"),drawNode:e=>tN(e),render(e,t){let r=iN(e),i=iW(r,t);return r.parts.map((e,r)=>{let n=iU(t,e,tN(e));return i&&0===r?`${n}
28
+ ${i}`:n}).join(`
29
+ `)}},iZ=new WeakSet([iH.render]),iY=Object.getOwnPropertyDescriptors(iH);function iJ(e){return e===iH&&iZ.has(e.render)}function iK(e){return void 0!==iV&&e===iV}var iQ,iX="1.0.0",i0=Object.freeze({core:B,scene:"^2.0.0"}),i1=Object.freeze({owner:"agentic-mermaid",source:"built-in",reference:"src/scene/backend.ts"}),i2=Object.freeze({owner:"host",source:"in-process"}),i3=new Map,i5=new Map,i4=new Map,i6=null;function i8(e,t){if(e.passed)return;let r=e.checks.filter(e=>!e.passed).map(e=>`${e.id}${e.diagnostic?`: ${e.diagnostic}`:""}`);throw Error(`Built-in backend "${t}" failed SVG conformance: ${r.join("; ")}`)}function i7(e){(function(){if(null!==i6)throw Error(`Backend registry mutation is forbidden while candidate "${i6}" is undergoing conformance`)})(),i6="<built-in>";try{var t,r,i;let o,s,d,l=e.id,c=P("backend",l);i6=c;let u=i5.get(l);if(void 0!==u)throw Error(`Backend input name "${l}" already selects "${u}"`);let m=function(e){if(e!==iH)return!1;for(let t of["id","capabilities","drawNode","render"]){let r=Object.getOwnPropertyDescriptor(e,t);if(!r||!("value"in r)||r.value!==iY[t].value)return!1}return!0}(e);if(!Array.isArray(e.capabilities))throw Error(`Backend "${e.id}" must declare capability claims`);let f=rx(e.capabilities);if(!f.valid)throw Error(`Backend "${e.id}" has invalid capabilities: ${f.diagnostics.join("; ")}`);if(0===e.capabilities.length)throw Error(`Backend "${e.id}" must declare capability claims`);if(e.capabilities.find(e=>e.target!==c))throw Error(`Backend "${e.id}" capability target must be "${c}"`);let p=e.capabilities.find(e=>!e.evidence?.trim());if(p)throw Error(`Backend "${e.id}" capability ${p.primitive}/${p.feature}/${p.operation} must declare evidence`);for(let{primitive:t,feature:r,operation:i}of rp)if(!e.capabilities.some(e=>e.primitive===t&&e.feature===r&&e.operation===i))throw Error(`Backend "${e.id}" must declare an evidenced essential ${t}/${r}/${i} capability`);let h=(s=!1,{running:()=>s,report:()=>{if(o)return o;let t=i6;i6=c,s=!0;try{o=function(e,t=e.id){var r;iG??=A(void 0,iz);let i=[],n=(e,t,r)=>{i.push(Object.freeze({id:e,passed:t,...r?{diagnostic:r}:{}}))},o=[],a=[];for(let t of iG.probes)try{let r=i_(e,t.node),i=i_(e,t.node);if("string"!=typeof r||"string"!=typeof i){o.push(`${t.primitive} returned a non-string`),a.push(`${t.primitive} returned a non-string`);continue}r!==i&&o.push(`${t.primitive} changed between identical calls`);let n=t.requiredFragments.filter(e=>!r.includes(e));n.length>0&&a.push(`${t.primitive} ${iO(n)}`)}catch(r){let e=`${t.primitive} threw ${r instanceof Error?r.message:String(r)}`;o.push(e),a.push(e)}n("draw-node-determinism",0===o.length,o.join("; ")||void 0),n("draw-node-semantics",0===a.length,a.join("; ")||void 0);let s="",d="",l;try{s=iI(e),d=iI(e),"string"!=typeof s||"string"!=typeof d?(l="render must return a string",s="string"==typeof s?s:"",d="string"==typeof d?d:""):s!==d&&(l="render changed between identical calls")}catch(e){l=`render threw ${e instanceof Error?e.message:String(e)}`}n("document-determinism",void 0===l,l);let c=E("xml-envelope",r=s,()=>re(r));n("single-svg-document",c,c?void 0:"render must return one well-formed namespaced SVG document");let u=s.match(/\b(?:NaN|Infinity|undefined)\b/)?.[0];n("finite-serialization",!u,u?`serialized ${u}`:void 0);let m=rl(s),f;try{rc(s,"default")}catch(e){f=e instanceof Error?e.message:String(e)}let p=m.ok&&void 0===f;for(let[e,t]of(n("output-security",p,p?void 0:[f,m.ok?void 0:`unsafe SVG constructs: ${m.refs.join(", ")}`].filter(Boolean).join("; ")),[["document-semantics",['aria-labelledby="backend-conformance-title backend-conformance-description"','<title id="backend-conformance-title">Backend conformance fixture</title>','<desc id="backend-conformance-description">A representative Scene document</desc>']],["container-semantics",['data-id="backend-conformance-container"','data-role="group"']],["shape-semantics",['data-id="backend-conformance-node"','data-role="node"']],["text-semantics",['data-id="backend-conformance-text"','data-role="member"',"Fixture label"]],["connector-semantics",['data-id="backend-conformance-relation"','data-role="edge"','data-from="backend-conformance-node"','data-to="backend-conformance-data-mark"','role="graphics-symbol"','aria-roledescription="relation"','aria-label="backend-conformance-node to backend-conformance-data-mark: depends on"']],["marker-semantics",['id="backend-conformance-arrow"']],["data-mark-semantics",['data-id="backend-conformance-data-mark"','data-role="bar"']]])){let r=t.filter(e=>!s.includes(e));n(e,0===r.length,iO(r))}let h=e.capabilities.map(t=>{let r=rb(t),i=iP[iL(t)],n={claimKey:r,target:t.target,primitive:t.primitive,feature:t.feature,operation:t.operation,realization:t.realization,...t.diagnostic?{limitation:t.diagnostic}:{}};if(!i)return ru.includes(t.primitive)&&rf.includes(t.feature)&&rm.includes(t.operation)?{...n,status:"failed",diagnostic:"No executable witness is registered for this core claim."}:{...n,status:"unverified-extension",diagnostic:"Namespaced extension claim is outside the built-in witness vocabulary."};let o=`${iM}/${iL(t)}`;try{let r=i(e,t);return{...n,witnessId:o,status:r.passed?"passed":"failed",observation:r.observation,...r.diagnostic?{diagnostic:r.diagnostic}:{}}}catch(e){return{...n,witnessId:o,status:"failed",diagnostic:`Witness threw ${e instanceof Error?e.message:String(e)}`}}}),g=h.filter(e=>"failed"===e.status);return n("capability-claims",0===g.length,g.map(e=>`${e.primitive}/${e.feature}/${e.operation}: ${e.diagnostic??"failed"}`).join("; ")||void 0),S({version:4,fixtureId:iM,backendId:t,contracts:{scene:2,outputSecurity:2},directOutputs:["svg"],passed:i.every(e=>e.passed),checks:i,claims:h})}(m?function(e){let{id:t,capabilities:r,drawNode:i,render:n}=e,o;return{id:t,capabilities:r,drawNode:(t,r)=>i.call(e,t,r),render(t,r){let i=t===iG?.doc?o??=iN(t):t;return n.call(e,i,r)}}}(e):e,c)}finally{s=!1,i6=t}return o}}),g=(r=(t=function(e,t,r){let{drawNode:i,render:n}=e,o=!1,a=()=>{o||r.running()||(i8(r.report(),t),o=!0)};return e.drawNode=(t,r)=>(a(),i.call(e,t,r)),e.render=(t,r)=>(a(),n.call(e,t,r)),e===iH&&iZ.has(n)&&iZ.add(e.render),e}(e,l,h)).capabilities,d=["target","primitive","feature","operation","realization","evidence","diagnostic"],t.capabilities=Object.freeze(r.map(e=>{let t=("object"==typeof e||"function"==typeof e)&&null!==e?e:void 0,r=t?{...t}:{};if(t)for(let e of d)Object.prototype.hasOwnProperty.call(r,e)||(r[e]=Reflect.get(t,e));return Object.freeze(r)})),Object.freeze(t));a(i3,{identity:(i={version:iX,compatibility:i0,provenance:i1},n({id:c,kind:"backend",version:i.version??iX,compatibility:i.compatibility,provenance:i.provenance??i2})),value:g}),i4.set(c,h.report),i5.set(l,c),m&&(iV=g),iQ=void 0}finally{i6=null}}function i9(){return Object.freeze(Array.from(i3.values(),({identity:e,value:t})=>{let r=i4.get(e.id);return Object.freeze({identity:e,backend:t,inputName:Array.from(i5.entries()).find(([,t])=>t===e.id)?.[0]??e.id,get conformance(){return r()}})}))}function ne(e,t){return e.find(e=>e.identity.id===t||e.inputName===t)}function nt(e,t){M("backend-registry",t?"bypass":iQ?"hit":"miss");let r=t?i9():iQ??=i9(),i=ne(r,e);if(!t)return i;let n=t.selectBackend(Object.freeze({requestedId:e,...i?{canonicalId:i.identity.id}:{},registered:r}));if(null!==n)return"string"==typeof n?ne(r,n):i}i7(iH);export{tl as a,V as b,H as c,Z as d,q as e,Y as f,J as g,K as h,X as i,ee as j,et as k,er as l,ra as m,rc as n,eo as o,es as p,ep as q,eh as r,eE as s,eS as t,ej as u,e_ as v,eI as w,eA as x,eD as y,eB as z,eP as A,eF as B,eR as C,eG as D,eY as E,eJ as F,eQ as G,eX as H,e3 as I,te as J,ti as K,tn as L,td as M,tN as N,tC as O,tM as P,tz as Q,tj as R,tI as S,tP as T,tF as U,tU as V,tR as W,tW as X,tq as Y,tG as Z,tV as _,tZ as $,ei as aa,rp as ba,rg as ca,ry as da,rS as ea,rN as fa,rj as ga,r_ as ha,rX as ia,il as ja,iy as ka,iN as la,iC as ma,iU as na,iR as oa,iW as pa,iH as qa,iJ as ra,iK as sa,i8 as ta,i7 as ua,nt as va};