@johnoscott/isometric-engine 0.12.3 → 0.14.1

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 (45) hide show
  1. package/EDITOR-GUIDE.md +10 -2
  2. package/README.md +1 -1
  3. package/assets/app.css +12 -0
  4. package/assets/marks.css +2 -0
  5. package/iso-editor.js +189 -188
  6. package/iso-render.js +82 -82
  7. package/iso-systems.js +79 -79
  8. package/js/iso-editor/commands.js +7 -0
  9. package/js/iso-editor/connections.js +24 -0
  10. package/js/iso-editor/make-way.js +62 -0
  11. package/js/iso-editor/model.js +17 -3
  12. package/js/iso-editor/ui/actions.js +22 -24
  13. package/js/iso-editor/ui/canvas.js +564 -223
  14. package/js/iso-editor/ui/mount.js +2 -1
  15. package/js/iso-editor/ui/palette-look.js +53 -0
  16. package/js/iso-editor/ui/props.js +2 -2
  17. package/js/iso-editor/ui/rename.js +114 -0
  18. package/js/iso-editor/ui/setup.js +4 -0
  19. package/js/iso-viewer/viewport.js +17 -5
  20. package/package.json +1 -1
  21. package/src/iso-editor/commands.ts +9 -0
  22. package/src/iso-editor/connections.ts +28 -0
  23. package/src/iso-editor/make-way.ts +89 -0
  24. package/src/iso-editor/model.ts +17 -3
  25. package/src/iso-editor/ui/actions.ts +20 -23
  26. package/src/iso-editor/ui/app.css +10 -0
  27. package/src/iso-editor/ui/canvas.ts +469 -180
  28. package/src/iso-editor/ui/marks.css +2 -0
  29. package/src/iso-editor/ui/mount.ts +4 -3
  30. package/src/iso-editor/ui/palette-look.ts +51 -0
  31. package/src/iso-editor/ui/props.ts +3 -3
  32. package/src/iso-editor/ui/rename.ts +105 -0
  33. package/src/iso-editor/ui/setup.ts +11 -0
  34. package/src/iso-viewer/viewport.ts +25 -5
  35. package/types/iso-editor/connections.d.ts +8 -0
  36. package/types/iso-editor/make-way.d.ts +40 -0
  37. package/types/iso-editor/model.d.ts +8 -2
  38. package/types/iso-editor/ui/actions.d.ts +5 -2
  39. package/types/iso-editor/ui/canvas.d.ts +42 -12
  40. package/types/iso-editor/ui/mount.d.ts +6 -2
  41. package/types/iso-editor/ui/palette-look.d.ts +5 -0
  42. package/types/iso-editor/ui/props.d.ts +1 -1
  43. package/types/iso-editor/ui/rename.d.ts +43 -0
  44. package/types/iso-editor/ui/setup.d.ts +7 -0
  45. package/types/iso-viewer/viewport.d.ts +13 -1
package/iso-render.js CHANGED
@@ -1,72 +1,72 @@
1
- var xf=Object.defineProperty;var hi=(t,e)=>{for(var n in e)xf(t,n,{get:e[n],enumerable:!0})};var Zl={};hi(Zl,{Bounds:()=>js,C:()=>yt,DiagError:()=>go,FONTS:()=>at,Kernel:()=>gs,S:()=>Xe,VEl:()=>lr,allowed:()=>Ji,apply:()=>Ds,bubble:()=>Tr,buildSvg:()=>Wl,center:()=>$r,colorRef:()=>Mn,createHash:()=>Ql,depthSort:()=>Vs,didYouMean:()=>Yn,distance:()=>Hi,envelope:()=>Er,esc:()=>ut,extendTheme:()=>mo,faceFrame:()=>gi,fileLines:()=>Ar,formatDiag:()=>Wi,formatDiags:()=>Gl,iso:()=>we,keyGlyph:()=>Ja,loadTheme:()=>po,matStr:()=>zs,n1:()=>it,parse:()=>ql,parseSvg:()=>Xi,placeholderFace:()=>Qa,pt:()=>ts,screenFaces:()=>bs,screenGlass:()=>Za,serialize:()=>bo,sha256Hex:()=>Qi,socketGlyph:()=>Xa,tag:()=>me,termLines:()=>Ks,textWidth:()=>Jt,themeCss:()=>ho,themeParts:()=>Yi,vdoc:()=>Jl});var Wa={sans700_13:{"0":.6787,"1":.5059,"2":.6372,"3":.6631,"4":.6812,"5":.6577,"6":.6777,"7":.6172,"8":.688,"9":.6777," ":.252,"!":.3506,'"':.563,"#":.6655,$:.6655,"%":1.0298,"&":.7388,"'":.3418,"(":.4229,")":.4229,"*":.4785,"+":.6655,",":.3418,"-":.4785,".":.3418,"/":.3286,":":.3418,";":.3418,"<":.6655,"=":.6655,">":.6655,"?":.5513,"@":.9214,A:.7266,B:.6875,C:.7354,D:.7417,E:.6162,F:.5918,G:.7544,H:.7773,I:.3125,J:.5952,K:.7036,L:.5889,M:.9009,N:.7622,O:.7808,P:.668,Q:.7808,R:.6885,S:.6694,T:.6543,U:.7544,V:.7153,W:1.0034,X:.7236,Y:.7021,Z:.6699,"[":.4229,"\\":.3286,"]":.4229,"^":.6655,_:.5845,"`":.4941,a:.584,b:.6455,c:.5815,d:.6455,e:.5952,f:.407,g:.6396,h:.6265,i:.2813,j:.2813,k:.5957,l:.2891,m:.9263,n:.6216,o:.6138,p:.6411,q:.6416,r:.4338,s:.5513,t:.4114,u:.6216,v:.5771,w:.8413,x:.5747,y:.5913,z:.5605,"{":.4229,"|":.2935,"}":.4229,"~":.6655,"\xB7":.3418,"\u2192":.9375,"\u2190":.9375,"\u2191":.8096,"\u2193":.8096,"\u2019":.3418,"\u2018":.3418,"\u201C":.5474,"\u201D":.5474,"\u2026":.9482,"\u2013":.6216,"\u2014":.9045,"\u2715":.7622,"\xD7":.6655,"\u2248":.6655,"\u2264":.6655,"\u2265":.6655,\u00E9:.5952},sans800_15:{"0":.687,"1":.5122,"2":.6406,"3":.6675,"4":.686,"5":.6626,"6":.6836,"7":.6191,"8":.6968,"9":.6836," ":.2344,"!":.3555,'"':.5835,"#":.6694,$:.6694,"%":1.0566,"&":.7397,"'":.3491,"(":.4287,")":.4287,"*":.4731,"+":.6694,",":.3491,"-":.4731,".":.3491,"/":.3286,":":.3491,";":.3491,"<":.6694,"=":.6694,">":.6694,"?":.5562,"@":.9146,A:.7363,B:.6899,C:.7339,D:.7388,E:.6147,F:.5903,G:.749,H:.7813,I:.3198,J:.6064,K:.7104,L:.5879,M:.9019,N:.7612,O:.7759,P:.6709,Q:.7759,R:.6924,S:.6719,T:.6533,U:.7524,V:.7212,W:1.0073,X:.731,Y:.71,Z:.6646,"[":.4287,"\\":.3286,"]":.4287,"^":.6694,_:.5889,"`":.4844,a:.5864,b:.6479,c:.5811,d:.6479,e:.5952,f:.4139,g:.6416,h:.6309,i:.2847,j:.2847,k:.605,l:.2935,m:.937,n:.626,o:.6138,p:.6436,q:.6445,r:.4406,s:.5557,t:.4198,u:.626,v:.5806,w:.856,x:.5835,y:.5996,z:.5601,"{":.4287,"|":.2974,"}":.4287,"~":.6694,"\xB7":.3491,"\u2192":.9404,"\u2190":.9404,"\u2191":.811,"\u2193":.811,"\u2019":.3491,"\u2018":.3491,"\u201C":.5688,"\u201D":.5688,"\u2026":.9883,"\u2013":.626,"\u2014":.9118,"\u2715":.7622,"\xD7":.6694,"\u2248":.6694,"\u2264":.6694,"\u2265":.6694,\u00E9:.5952},sans800_10_5:{"0":.7114,"1":.5366,"2":.665,"3":.6919,"4":.7104,"5":.687,"6":.708,"7":.6436,"8":.7212,"9":.708," ":.2588,"!":.3799,'"':.6079,"#":.6938,$:.6938,"%":1.0811,"&":.7642,"'":.3735,"(":.4531,")":.4531,"*":.4976,"+":.6938,",":.3735,"-":.4976,".":.3735,"/":.353,":":.3735,";":.3735,"<":.6938,"=":.6938,">":.6938,"?":.5806,"@":.939,A:.7607,B:.7144,C:.7583,D:.7632,E:.6392,F:.6147,G:.7734,H:.8057,I:.3442,J:.6309,K:.7349,L:.6123,M:.9263,N:.7856,O:.8003,P:.6953,Q:.8003,R:.7168,S:.6963,T:.6777,U:.7769,V:.7456,W:1.0317,X:.7554,Y:.7344,Z:.689,"[":.4531,"\\":.353,"]":.4531,"^":.6938,_:.6133,"`":.5088,a:.6108,b:.6724,c:.6055,d:.6724,e:.6196,f:.4383,g:.666,h:.6553,i:.3091,j:.3091,k:.6294,l:.3179,m:.9614,n:.6504,o:.6382,p:.668,q:.6689,r:.465,s:.5801,t:.4442,u:.6504,v:.605,w:.8804,x:.6079,y:.624,z:.5845,"{":.4531,"|":.3218,"}":.4531,"~":.6938,"\xB7":.3735,"\u2192":.9648,"\u2190":.9648,"\u2191":.8354,"\u2193":.8354,"\u2019":.3735,"\u2018":.3735,"\u201C":.5933,"\u201D":.5933,"\u2026":1.0127,"\u2013":.6504,"\u2014":.9204,"\u2715":.7622,"\xD7":.6938,"\u2248":.6938,"\u2264":.6938,"\u2265":.6938,\u00E9:.6196},sans600_12:{"0":.6665,"1":.4956,"2":.6299,"3":.6548,"4":.6724,"5":.6484,"6":.668,"7":.6113,"8":.6753,"9":.668," ":.2656,"!":.3413,'"':.5386,"#":.6577,$:.6577,"%":.999,"&":.7334,"'":.3306,"(":.4131,")":.4131,"*":.48,"+":.6577,",":.3306,"-":.48,".":.3306,"/":.3247,":":.3306,";":.3306,"<":.6577,"=":.6577,">":.6577,"?":.5425,"@":.9238,A:.7129,B:.6812,C:.7329,D:.7402,E:.6133,F:.5889,G:.7559,H:.7695,I:.3013,J:.5801,K:.6924,L:.5859,M:.8955,N:.7593,O:.7813,P:.6606,Q:.7813,R:.6807,S:.6626,T:.6514,U:.7524,V:.7056,W:.9956,X:.7124,Y:.6904,Z:.6709,"[":.4131,"\\":.3247,"]":.4131,"^":.6577,_:.5757,"`":.5,a:.5771,b:.6392,c:.5781,d:.6392,e:.5908,f:.3957,g:.6333,h:.6177,i:.2739,j:.2734,k:.582,l:.2808,m:.9116,n:.6128,o:.6099,p:.6348,q:.6348,r:.4232,s:.543,t:.3991,u:.6128,v:.5693,w:.8228,x:.562,y:.5791,z:.5571,"{":.4131,"|":.2856,"}":.4131,"~":.6577,"\xB7":.3306,"\u2192":.9307,"\u2190":.9307,"\u2191":.8037,"\u2193":.8037,"\u2019":.3306,"\u2018":.3306,"\u201C":.522,"\u201D":.522,"\u2026":.9043,"\u2013":.6128,"\u2014":.8957,"\u2715":.7622,"\xD7":.6577,"\u2248":.6577,"\u2264":.6577,"\u2265":.6577,\u00E9:.5908},sans800_12:{"0":.7026,"1":.5278,"2":.6563,"3":.6831,"4":.7017,"5":.6782,"6":.6992,"7":.6348,"8":.7124,"9":.6992," ":.25,"!":.3711,'"':.5991,"#":.6851,$:.6851,"%":1.0723,"&":.7554,"'":.3647,"(":.4443,")":.4443,"*":.4888,"+":.6851,",":.3647,"-":.4888,".":.3647,"/":.3442,":":.3647,";":.3647,"<":.6851,"=":.6851,">":.6851,"?":.5718,"@":.9302,A:.752,B:.7056,C:.7495,D:.7544,E:.6304,F:.606,G:.7646,H:.7969,I:.3354,J:.6221,K:.7261,L:.6035,M:.9175,N:.7769,O:.7915,P:.6865,Q:.7915,R:.708,S:.6875,T:.6689,U:.7681,V:.7368,W:1.0229,X:.7466,Y:.7256,Z:.6802,"[":.4443,"\\":.3442,"]":.4443,"^":.6851,_:.6045,"`":.5,a:.6021,b:.6636,c:.5967,d:.6636,e:.6108,f:.4295,g:.6572,h:.6465,i:.3003,j:.3003,k:.6206,l:.3091,m:.9526,n:.6416,o:.6294,p:.6592,q:.6602,r:.4562,s:.5713,t:.4354,u:.6416,v:.5962,w:.8716,x:.5991,y:.6152,z:.5757,"{":.4443,"|":.313,"}":.4443,"~":.6851,"\xB7":.3647,"\u2192":.9561,"\u2190":.9561,"\u2191":.8267,"\u2193":.8267,"\u2019":.3647,"\u2018":.3647,"\u201C":.5845,"\u201D":.5845,"\u2026":1.0039,"\u2013":.6416,"\u2014":.9173,"\u2715":.7622,"\xD7":.6851,"\u2248":.6851,"\u2264":.6851,"\u2265":.6851,\u00E9:.6108},sans800_11_5:{"0":.7056,"1":.5308,"2":.6592,"3":.686,"4":.7046,"5":.6812,"6":.7021,"7":.6377,"8":.7153,"9":.7021," ":.2529,"!":.374,'"':.6021,"#":.688,$:.688,"%":1.0752,"&":.7583,"'":.3677,"(":.4473,")":.4473,"*":.4917,"+":.688,",":.3677,"-":.4917,".":.3677,"/":.3472,":":.3677,";":.3677,"<":.688,"=":.688,">":.688,"?":.5747,"@":.9331,A:.7549,B:.7085,C:.7524,D:.7573,E:.6333,F:.6089,G:.7676,H:.7998,I:.3384,J:.625,K:.729,L:.6064,M:.9204,N:.7798,O:.7944,P:.6895,Q:.7944,R:.7109,S:.6904,T:.6719,U:.771,V:.7397,W:1.0259,X:.7495,Y:.7285,Z:.6831,"[":.4473,"\\":.3472,"]":.4473,"^":.688,_:.6074,"`":.5029,a:.605,b:.6665,c:.5996,d:.6665,e:.6138,f:.4325,g:.6602,h:.6494,i:.3032,j:.3032,k:.6235,l:.312,m:.9556,n:.6445,o:.6323,p:.6621,q:.6631,r:.4591,s:.5742,t:.4383,u:.6445,v:.5991,w:.8745,x:.6021,y:.6182,z:.5786,"{":.4473,"|":.3159,"}":.4473,"~":.688,"\xB7":.3677,"\u2192":.959,"\u2190":.959,"\u2191":.8296,"\u2193":.8296,"\u2019":.3677,"\u2018":.3677,"\u201C":.5874,"\u201D":.5874,"\u2026":1.0068,"\u2013":.6445,"\u2014":.9183,"\u2715":.7622,"\xD7":.688,"\u2248":.688,"\u2264":.688,"\u2265":.688,\u00E9:.6138},sans400_13:{"0":.624,"1":.458,"2":.5977,"3":.6211,"4":.6377,"5":.6123,"6":.6309,"7":.582,"8":.6328,"9":.6309," ":.2754,"!":.3052,'"':.4717,"#":.624,$:.624,"%":.9194,"&":.7056,"'":.291,"(":.376,")":.376,"*":.4658,"+":.624,",":.291,"-":.4658,".":.291,"/":.2988,":":.291,";":.291,"<":.624,"=":.624,">":.624,"?":.5068,"@":.9121,A:.668,B:.6514,C:.71,D:.7207,E:.5898,F:.5664,G:.7407,H:.7363,I:.2617,J:.5322,K:.6528,L:.562,M:.8682,N:.7363,O:.7656,P:.6294,Q:.7656,R:.6475,S:.6313,T:.6279,U:.7314,V:.668,W:.9619,X:.6729,Y:.6494,Z:.6558,"[":.376,"\\":.2988,"]":.376,"^":.624,_:.5405,"`":.4941,a:.5459,b:.6084,c:.5537,d:.6084,e:.5654,f:.356,g:.6035,h:.5825,i:.2412,j:.2407,k:.5371,l:.2471,m:.8643,n:.5776,o:.585,p:.6045,q:.6035,r:.3843,s:.5083,t:.3574,u:.5776,v:.5361,w:.7686,x:.5186,y:.5371,z:.5332,"{":.376,"|":.2529,"}":.376,"~":.624,"\xB7":.291,"\u2192":.8999,"\u2190":.8999,"\u2191":.7754,"\u2193":.7754,"\u2019":.291,"\u2018":.291,"\u201C":.4531,"\u201D":.4531,"\u2026":.7988,"\u2013":.5776,"\u2014":.872,"\u2715":.7622,"\xD7":.624,"\u2248":.624,"\u2264":.624,"\u2265":.624,\u00E9:.5654},mono400_11:{"0":.6021,"1":.6021,"2":.6021,"3":.6021,"4":.6021,"5":.6021,"6":.6021,"7":.6021,"8":.6021,"9":.6021," ":.6021,"!":.6021,'"':.6021,"#":.6021,$:.6021,"%":.6021,"&":.6021,"'":.6021,"(":.6021,")":.6021,"*":.6021,"+":.6021,",":.6021,"-":.6021,".":.6021,"/":.6021,":":.6021,";":.6021,"<":.6021,"=":.6021,">":.6021,"?":.6021,"@":.6021,A:.6021,B:.6021,C:.6021,D:.6021,E:.6021,F:.6021,G:.6021,H:.6021,I:.6021,J:.6021,K:.6021,L:.6021,M:.6021,N:.6021,O:.6021,P:.6021,Q:.6021,R:.6021,S:.6021,T:.6021,U:.6021,V:.6021,W:.6021,X:.6021,Y:.6021,Z:.6021,"[":.6021,"\\":.6021,"]":.6021,"^":.6021,_:.6021,"`":.6021,a:.6021,b:.6021,c:.6021,d:.6021,e:.6021,f:.6021,g:.6021,h:.6021,i:.6021,j:.6021,k:.6021,l:.6021,m:.6021,n:.6021,o:.6021,p:.6021,q:.6021,r:.6021,s:.6021,t:.6021,u:.6021,v:.6021,w:.6021,x:.6021,y:.6021,z:.6021,"{":.6021,"|":.6021,"}":.6021,"~":.6021,"\xB7":.6021,"\u2192":.6021,"\u2190":.6021,"\u2191":.6021,"\u2193":.6021,"\u2019":.6021,"\u2018":.6021,"\u201C":.6021,"\u201D":.6021,"\u2026":.6021,"\u2013":.6021,"\u2014":.6021,"\u2715":.6021,"\xD7":.6021,"\u2248":.6021,"\u2264":.6021,"\u2265":.6021,\u00E9:.6021},mono600_11:{"0":.6021,"1":.6021,"2":.6021,"3":.6021,"4":.6021,"5":.6021,"6":.6021,"7":.6021,"8":.6021,"9":.6021," ":.6021,"!":.6021,'"':.6021,"#":.6021,$:.6021,"%":.6021,"&":.6021,"'":.6021,"(":.6021,")":.6021,"*":.6021,"+":.6021,",":.6021,"-":.6021,".":.6021,"/":.6021,":":.6021,";":.6021,"<":.6021,"=":.6021,">":.6021,"?":.6021,"@":.6021,A:.6021,B:.6021,C:.6021,D:.6021,E:.6021,F:.6021,G:.6021,H:.6021,I:.6021,J:.6021,K:.6021,L:.6021,M:.6021,N:.6021,O:.6021,P:.6021,Q:.6021,R:.6021,S:.6021,T:.6021,U:.6021,V:.6021,W:.6021,X:.6021,Y:.6021,Z:.6021,"[":.6021,"\\":.6021,"]":.6021,"^":.6021,_:.6021,"`":.6021,a:.6021,b:.6021,c:.6021,d:.6021,e:.6021,f:.6021,g:.6021,h:.6021,i:.6021,j:.6021,k:.6021,l:.6021,m:.6021,n:.6021,o:.6021,p:.6021,q:.6021,r:.6021,s:.6021,t:.6021,u:.6021,v:.6021,w:.6021,x:.6021,y:.6021,z:.6021,"{":.6021,"|":.6021,"}":.6021,"~":.6021,"\xB7":.6021,"\u2192":.6021,"\u2190":.6021,"\u2191":.6021,"\u2193":.6021,"\u2019":.6021,"\u2018":.6021,"\u201C":.6021,"\u201D":.6021,"\u2026":.6021,"\u2013":.6021,"\u2014":.6021,"\u2715":.6021,"\xD7":.6021,"\u2248":.6021,"\u2264":.6021,"\u2265":.6021,\u00E9:.6021}};var Xe=34,yt=Math.cos(Math.PI/6),we=(t,e,n=0)=>[(t-e)*yt*Xe,(t+e)*.5*Xe-n*Xe],it=t=>{let e=Math.round(t*10)/10;return Object.is(e,-0)?"0":String(e)},ts=t=>`${it(t[0])},${it(t[1])}`,ut=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function me(t,e={},n){let s="";for(let r in e){let o=e[r];o==null||o===!1||o===""||(s+=` ${r}="${ut(typeof o=="number"?it(o):o)}"`)}return n===void 0?`<${t}${s}/>`:`<${t}${s}>${n}</${t}>`}var at={lbl:{key:"sans700_13",size:13},sub:{key:"mono400_11",size:11},slabname:{key:"sans800_15",size:15,spacing:.12},sm:{key:"sans800_10_5",size:10.5,spacing:.1},floor:{key:"mono600_11",size:11,spacing:.01},say:{key:"sans600_12",size:12},tunname:{key:"sans800_12",size:12,spacing:.14},badge:{key:"sans800_11_5",size:11.5}};function Jt(t,e){let n=Wa[e.key],s=e.key.startsWith("mono")?.6:.58,r=0;for(let o of t)r+=n[o]??s;return(r+(e.spacing??0)*[...t].length)*e.size}var Ds=(t,e,n)=>[t[0]*e+t[2]*n+t[4],t[1]*e+t[3]*n+t[5]],zs=t=>`matrix(${t.map(e=>Math.round(e*1e4)/1e4).join(" ")})`;function gi(t,e){if(e==="left"){let[r,o]=we(t.x0,t.y1,t.z1);return{m:[yt,.5,0,1,r,o],w:(t.x1-t.x0)*Xe,h:(t.z1-t.z0)*Xe}}if(e==="right"){let[r,o]=we(t.x1,t.y1,t.z1);return{m:[yt,-.5,0,1,r,o],w:(t.y1-t.y0)*Xe,h:(t.z1-t.z0)*Xe}}let[n,s]=we(t.x0,t.y0,t.z1);return{m:[yt,.5,-yt,.5,n,s],w:(t.x1-t.x0)*Xe,h:(t.y1-t.y0)*Xe}}var js=class{x0=1/0;y0=1/0;x1=-1/0;y1=-1/0;add(e){e[0]<this.x0&&(this.x0=e[0]),e[0]>this.x1&&(this.x1=e[0]),e[1]<this.y0&&(this.y0=e[1]),e[1]>this.y1&&(this.y1=e[1])}addRect(e,n,s,r){this.add([e,n]),this.add([e+s,n+r])}get empty(){return this.x0===1/0}},gs=class{bounds=new js;texts=[];planes=[];planePolys=[];defs=new Map;poly(e,n,s={}){let r=e.map(o=>we(o[0],o[1],o[2]));return r.forEach(o=>this.bounds.add(o)),me("polygon",{points:r.map(ts).join(" "),class:n,...s})}line3(e,n,s,r={}){let o=we(...e),i=we(...n);return this.bounds.add(o),this.bounds.add(i),me("line",{x1:o[0],y1:o[1],x2:i[0],y2:i[1],class:s,...r})}blockFaces(e){let{x0:n,y0:s,x1:r,y1:o,z0:i,z1:a}=e;return this.poly([[n,o,i],[r,o,i],[r,o,a],[n,o,a]],"lft")+this.poly([[r,s,i],[r,o,i],[r,o,a],[r,s,a]],"rgt")+this.poly([[n,s,a],[r,s,a],[r,o,a],[n,o,a]],"top")}onFace(e,n,s,r){let o=gi(e,n);for(let[i,a]of[[0,0],[o.w,0],[0,o.h],[o.w,o.h]])this.bounds.add(Ds(o.m,i,a));return me("g",{class:r,transform:zs(o.m)},s(o.w,o.h))}onMatrix(e,n,s,r,o){for(let[i,a]of[[0,0],[n,0],[0,s],[n,s]])this.bounds.add(Ds(e,i,a));return me("g",{class:o,transform:zs(e)},r(n,s))}text(e,n,s,r,o,i="middle",a={},l){let c=Jt(s,o),u={x:i==="start"?e:i==="end"?e-c:e-c/2,y:n-o.size*.8,w:c,h:o.size*1.05,text:s,owner:l};return this.bounds.addRect(u.x-2,u.y-2,u.w+4,u.h+4),this.texts.push(u),me("text",{x:e,y:n,class:r,"text-anchor":i==="start"?void 0:i,...a},ut(s))}planeText(e,n,s,r,o="start",i={}){let a=Jt(n,r),l=o==="start"?0:o==="end"?-a:-a/2,c=[[l,-r.size*.8],[l+a,-r.size*.8],[l,r.size*.25],[l+a,r.size*.25]].map(([d,p])=>Ds(e,d,p));c.forEach(d=>this.bounds.add(d));let f=c.map(d=>d[0]),u=c.map(d=>d[1]);return this.planePolys.push([c[0],c[1],c[3],c[2]]),this.planes.push({x:Math.min(...f),y:Math.min(...u),w:Math.max(...f)-Math.min(...f),h:Math.max(...u)-Math.min(...u)}),me("text",{transform:zs(e),class:s,"text-anchor":o==="start"?void 0:o,...i},ut(n))}floorText(e,n,s,r,o,i="x",a="start",l={}){let[c,f]=we(e,n,s),u=i==="x"?[yt,.5,-yt,.5,c,f]:[yt,-.5,yt,.5,c,f];return this.planeText(u,r,o,at.floor,a,l)}faceText(e,n,s,r,o,i,a="left",l="start",c={}){let[f,u]=we(e,n,s),d=a==="left"?[yt,.5,0,1,f,u]:[yt,-.5,0,1,f,u];return this.planeText(d,r,o,i,l,c)}def(e,n){this.defs.set(e,n)}},$r=t=>[(t.x0+t.x1)/2,(t.y0+t.y1)/2,t.z1];function Ks(t,e,n){let s="";for(let r=0;r<n;r++){let o=e.z1-(e.z1-e.z0)*(.28+r*.2),i=(e.x1-e.x0)*(r===n-1?.35:.62-r*.1);s+=t.line3([e.x0+.35,e.y1,o],[e.x0+.35+i,e.y1,o],"det")}return s}function Er(t,e){let s=e.z1,r=[e.x0+.55,e.y0+.55,s],o=[e.x1-.55,e.y0+.55,s],i=[e.x1-.55,e.y1-.55,s],a=[e.x0+.55,e.y1-.55,s],l=[(e.x0+e.x1)/2,(e.y0+e.y1)/2,s];return t.poly([r,o,i,a],"det")+t.line3(r,l,"det")+t.line3(l,o,"det")}function Tr(t,e){let s=e.z1,r=t.poly([[e.x0+.55,e.y0+.55,s],[e.x1-.55,e.y0+.55,s],[e.x1-.55,e.y1-.55,s],[e.x0+.55,e.y1-.55,s]],"det");for(let o=1;o<=2;o++){let i=e.y0+.55+(e.y1-e.y0-1.1)*o/3;r+=t.line3([e.x0+.55+.3,i,s],[e.x1-.55-.3-(o===2?.5:0),i,s],"det")}return r}function Ar(t,e){let s=e.z1,r=(e.y0+e.y1)/2;return t.line3([e.x0+.3,r-.2,s],[e.x1-.3,r-.2,s],"det")+t.line3([e.x0+.3,r+.2,s],[e.x1-.3-.3,r+.2,s],"det")}function Ja(t,e){let n=(e.x0+e.x1)/2,s=(e.y0+e.y1)/2,r=e.z1+.005,o=Math.min(e.x1-e.x0,e.y1-e.y0)*.16,i=[];for(let a=0;a<20;a++){let l=a/20*Math.PI*2;i.push([n-o*1.4+Math.cos(l)*o,s+Math.sin(l)*o,r])}return t.poly(i,"det")+t.line3([n-o*.4,s,r],[n+o*2.2,s,r],"det")+t.line3([n+o*1.7,s,r],[n+o*1.7,s+o*.8,r],"det")}function Xa(t,e){let n=(e.x0+e.x1)/2,s=(e.y0+e.y1)/2,r=e.z1+.005,o=Math.min(e.x1-e.x0,e.y1-e.y0)*.28,i=[];for(let a=0;a<24;a++){let l=a/24*Math.PI*2;i.push([n+Math.cos(l)*o,s+Math.sin(l)*o,r])}return t.poly(i,"det sock-hole")}var ns=(t,e,n,s,r,o=0)=>me("rect",{class:t,x:e,y:n,width:s,height:r,rx:o||void 0}),bs={terminal(t,e){let n="",s=Math.max(2,Math.floor((e-12)/9));for(let r=0;r<s;r++){let o=10+r*9,i=(t-18)*[.7,.45,.6,.3,.55][r%5];n+=me("line",{class:"ln",x1:8,y1:o,x2:8+i,y2:o})}return n},chat(t,e){return[[6,.62,"w"],[.3,.58,"m"],[6,.46,"w"],[.42,.5,"m"]].map((s,r)=>{let o=(t-14)*s[1],i=s[0]===6?7:t-7-o;return ns(s[2],i,8+r*(e-18)/4,o,(e-18)/4-4,3)}).join("")},desktop(t,e){return ns("wall",5,5,t-10,e-10,2)+ns("bar",5,5,t-10,6)+ns("win",t*.5,13,t*.38,e*.42,2)},tiles(t,e){let i=(t-12-5)/3,a=(e-12-2.5*1)/2,l="";for(let c=0;c<2;c++)for(let f=0;f<3;f++){let u=6+f*(i+2.5),d=6+c*(a+2.5);l+=ns("t",u,d,i,a,1.5),[.3,.52,.74].forEach((p,h)=>{l+=me("line",{class:"ln",x1:u+2.5,y1:d+a*p,x2:u+2.5+(i-5)*[.8,.5,.65][(h+c+f)%3],y2:d+a*p})})}return l}};function Qa(t,e){let n=t/2,s=e/2,r=Math.min(t,e)*.22;return ns("unk",t*.2,e*.2,t*.6,e*.6,2)+me("path",{class:"unk-q",d:`M${it(n-r*.5)},${it(s-r*.45)}a${it(r*.5)},${it(r*.5)} 0 1 1 ${it(r*.5)},${it(r*.55)}v${it(r*.3)}`})+me("circle",{class:"unk-dot",cx:it(n),cy:it(s+r*.75),r:it(Math.max(.8,r*.1))})}function Za(t,e){return ns("glass",3,3,t-6,e-6,3)}function vf(t){let e=[we(t.x0,t.y0,t.z1),we(t.x1,t.y0,t.z0),we(t.x0,t.y1,t.z0),we(t.x1,t.y1,t.z0),we(t.x1,t.y1,t.z1),we(t.x0,t.y0,t.z0)],n=e.map(r=>r[0]),s=e.map(r=>r[1]);return[Math.min(...n),Math.min(...s),Math.max(...n),Math.max(...s)]}function Sf(t,e){let s=t.x1<=e.x0+1e-6,r=e.x1<=t.x0+1e-6,o=t.y1<=e.y0+1e-6,i=e.y1<=t.y0+1e-6,a=t.z1<=e.z0+1e-6,l=e.z1<=t.z0+1e-6,c=s||o||a,f=r||i||l;return c&&!f?-1:f&&!c?1:0}function Vs(t){let e=t.length,n=t.map(c=>vf(c.box)),s=c=>c.box.x0+c.box.y0+c.box.z0*.01,r=t.map(()=>[]),o=new Array(e).fill(0);for(let c=0;c<e;c++)for(let f=c+1;f<e;f++){let u=n[c],d=n[f];if(u[2]<=d[0]||d[2]<=u[0]||u[3]<=d[1]||d[3]<=u[1])continue;let p=Sf(t[c].box,t[f].box);p<0?(r[c].push(f),o[f]++):p>0&&(r[f].push(c),o[c]++)}let i=[],a=t.map((c,f)=>f).filter(c=>!o[c]),l=new Array(e).fill(!1);for(;i.length<e;){if(!a.length){let f=t.map((u,d)=>d).filter(u=>!l[u]).sort((u,d)=>s(t[u])-s(t[d]));a.push(f[0]),o[f[0]]=0}a.sort((f,u)=>s(t[f])-s(t[u])||f-u);let c=a.shift();if(!l[c]){l[c]=!0,i.push(t[c]);for(let f of r[c])!l[f]&&--o[f]===0&&a.push(f)}}return i}var Nr=Symbol.for("yaml.alias"),Pr=Symbol.for("yaml.document"),an=Symbol.for("yaml.map"),bi=Symbol.for("yaml.pair"),Gt=Symbol.for("yaml.scalar"),Pn=Symbol.for("yaml.seq"),Ft=Symbol.for("yaml.node.type"),ln=t=>!!t&&typeof t=="object"&&t[Ft]===Nr,bn=t=>!!t&&typeof t=="object"&&t[Ft]===Pr,_t=t=>!!t&&typeof t=="object"&&t[Ft]===an,Le=t=>!!t&&typeof t=="object"&&t[Ft]===bi,Ne=t=>!!t&&typeof t=="object"&&t[Ft]===Gt,Dt=t=>!!t&&typeof t=="object"&&t[Ft]===Pn;function Ge(t){if(t&&typeof t=="object")switch(t[Ft]){case an:case Pn:return!0}return!1}function De(t){if(t&&typeof t=="object")switch(t[Ft]){case Nr:case an:case Gt:case Pn:return!0}return!1}var Or=t=>(Ne(t)||Ge(t))&&!!t.anchor;var zt=Symbol("break visit"),el=Symbol("skip children"),yn=Symbol("remove node");function xn(t,e){let n=tl(e);bn(t)?ys(null,t.contents,n,Object.freeze([t]))===yn&&(t.contents=null):ys(null,t,n,Object.freeze([]))}xn.BREAK=zt;xn.SKIP=el;xn.REMOVE=yn;function ys(t,e,n,s){let r=nl(t,e,n,s);if(De(r)||Le(r))return sl(t,s,r),ys(t,r,n,s);if(typeof r!="symbol"){if(Ge(e)){s=Object.freeze(s.concat(e));for(let o=0;o<e.items.length;++o){let i=ys(o,e.items[o],n,s);if(typeof i=="number")o=i-1;else{if(i===zt)return zt;i===yn&&(e.items.splice(o,1),o-=1)}}}else if(Le(e)){s=Object.freeze(s.concat(e));let o=ys("key",e.key,n,s);if(o===zt)return zt;o===yn&&(e.key=null);let i=ys("value",e.value,n,s);if(i===zt)return zt;i===yn&&(e.value=null)}}return r}async function Rr(t,e){let n=tl(e);bn(t)?await xs(null,t.contents,n,Object.freeze([t]))===yn&&(t.contents=null):await xs(null,t,n,Object.freeze([]))}Rr.BREAK=zt;Rr.SKIP=el;Rr.REMOVE=yn;async function xs(t,e,n,s){let r=await nl(t,e,n,s);if(De(r)||Le(r))return sl(t,s,r),xs(t,r,n,s);if(typeof r!="symbol"){if(Ge(e)){s=Object.freeze(s.concat(e));for(let o=0;o<e.items.length;++o){let i=await xs(o,e.items[o],n,s);if(typeof i=="number")o=i-1;else{if(i===zt)return zt;i===yn&&(e.items.splice(o,1),o-=1)}}}else if(Le(e)){s=Object.freeze(s.concat(e));let o=await xs("key",e.key,n,s);if(o===zt)return zt;o===yn&&(e.key=null);let i=await xs("value",e.value,n,s);if(i===zt)return zt;i===yn&&(e.value=null)}}return r}function tl(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function nl(t,e,n,s){if(typeof n=="function")return n(t,e,s);if(_t(e))return n.Map?.(t,e,s);if(Dt(e))return n.Seq?.(t,e,s);if(Le(e))return n.Pair?.(t,e,s);if(Ne(e))return n.Scalar?.(t,e,s);if(ln(e))return n.Alias?.(t,e,s)}function sl(t,e,n){let s=e[e.length-1];if(Ge(s))s.items[t]=n;else if(Le(s))t==="key"?s.key=n:s.value=n;else if(bn(s))s.contents=n;else{let r=ln(s)?"alias":"scalar";throw new Error(`Cannot replace node with ${r} parent`)}}var Mf={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},$f=t=>t.replace(/[!,[\]{}]/g,e=>Mf[e]),wn=class t{constructor(e,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,n)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,n){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let s=e.trim().split(/[ \t]+/),r=s.shift();switch(r){case"%TAG":{if(s.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),s.length<2))return!1;let[o,i]=s;return this.tags[o]=i,!0}case"%YAML":{if(this.yaml.explicit=!0,s.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[o]=s;if(o==="1.1"||o==="1.2")return this.yaml.version=o,!0;{let i=/^\d+\.\d+$/.test(o);return n(6,`Unsupported YAML version ${o}`,i),!1}}default:return n(0,`Unknown directive ${r}`,!0),!1}}tagName(e,n){if(e==="!")return"!";if(e[0]!=="!")return n(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let i=e.slice(2,-1);return i==="!"||i==="!!"?(n(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&n("Verbatim tags must end with a >"),i)}let[,s,r]=e.match(/^(.*!)([^!]*)$/s);r||n(`The ${e} tag has no suffix`);let o=this.tags[s];if(o)try{return o+decodeURIComponent(r)}catch(i){return n(String(i)),null}return s==="!"?e:(n(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[n,s]of Object.entries(this.tags))if(e.startsWith(s))return n+$f(e.substring(s.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags),r;if(e&&s.length>0&&De(e.contents)){let o={};xn(e.contents,(i,a)=>{De(a)&&a.tag&&(o[a.tag]=!0)}),r=Object.keys(o)}else r=[];for(let[o,i]of s)o==="!!"&&i==="tag:yaml.org,2002:"||(!e||r.some(a=>a.startsWith(i)))&&n.push(`%TAG ${o} ${i}`);return n.join(`
2
- `)}};wn.defaultYaml={explicit:!1,version:"1.2"};wn.defaultTags={"!!":"tag:yaml.org,2002:"};function Cr(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(n)}return!0}function yi(t){let e=new Set;return xn(t,{Value(n,s){s.anchor&&e.add(s.anchor)}}),e}function xi(t,e){for(let n=1;;++n){let s=`${t}${n}`;if(!e.has(s))return s}}function rl(t,e){let n=[],s=new Map,r=null;return{onAnchor:o=>{n.push(o),r??(r=yi(t));let i=xi(e,r);return r.add(i),i},setAnchors:()=>{for(let o of n){let i=s.get(o);if(typeof i=="object"&&i.anchor&&(Ne(i.node)||Ge(i.node)))i.node.anchor=i.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:s}}function zn(t,e,n,s){if(s&&typeof s=="object")if(Array.isArray(s))for(let r=0,o=s.length;r<o;++r){let i=s[r],a=zn(t,s,String(r),i);a===void 0?delete s[r]:a!==i&&(s[r]=a)}else if(s instanceof Map)for(let r of Array.from(s.keys())){let o=s.get(r),i=zn(t,s,r,o);i===void 0?s.delete(r):i!==o&&s.set(r,i)}else if(s instanceof Set)for(let r of Array.from(s)){let o=zn(t,s,r,r);o===void 0?s.delete(r):o!==r&&(s.delete(r),s.add(o))}else for(let[r,o]of Object.entries(s)){let i=zn(t,s,r,o);i===void 0?delete s[r]:i!==o&&(s[r]=i)}return t.call(e,n,s)}function St(t,e,n){if(Array.isArray(t))return t.map((s,r)=>St(s,String(r),n));if(t&&typeof t.toJSON=="function"){if(!n||!Or(t))return t.toJSON(e,n);let s={aliasCount:0,count:1,res:void 0};n.anchors.set(t,s),n.onCreate=o=>{s.res=o,delete n.onCreate};let r=t.toJSON(e,n);return n.onCreate&&n.onCreate(r),r}return typeof t=="bigint"&&!n?.keep?Number(t):t}var jn=class{constructor(e){Object.defineProperty(this,Ft,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:n,maxAliasCount:s,onAnchor:r,reviver:o}={}){if(!bn(e))throw new TypeError("A document argument is required");let i={anchors:new Map,doc:e,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},a=St(this,"",i);if(typeof r=="function")for(let{count:l,res:c}of i.anchors.values())r(c,l);return typeof o=="function"?zn(o,{"":a},"",a):a}};var On=class extends jn{constructor(e){super(Nr),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,n){if(n?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let s;n?.aliasResolveCache?s=n.aliasResolveCache:(s=[],xn(e,{Node:(o,i)=>{(ln(i)||Or(i))&&s.push(i)}}),n&&(n.aliasResolveCache=s));let r;for(let o of s){if(o===this)break;o.anchor===this.source&&(r=o)}if(r&&n){let{anchors:o,doc:i,maxAliasCount:a}=n,l=o.get(r);if(l||(St(r,null,n),l=o.get(r)),l?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(a>=0&&(l.count+=1,l.aliasCount===0&&(l.aliasCount=Lr(i,r,o)),l.count*l.aliasCount>a)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}}return r}toJSON(e,n){if(!n)return{source:this.source};let s=this.resolve(n.doc,n);if(!s){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(r)}return n.anchors.get(s).res}toString(e,n,s){let r=`*${this.source}`;if(e){if(Cr(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let o=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(o)}if(e.implicitKey)return`${r} `}return r}};function Lr(t,e,n){if(ln(e)){let s=e.resolve(t),r=n&&s&&n.get(s);return r?r.count*r.aliasCount:0}else if(Ge(e)){let s=0;for(let r of e.items){let o=Lr(t,r,n);o>s&&(s=o)}return s}else if(Le(e)){let s=Lr(t,e.key,n),r=Lr(t,e.value,n);return Math.max(s,r)}return 1}var Ir=t=>!t||typeof t!="function"&&typeof t!="object",ge=class extends jn{constructor(e){super(Gt),this.value=e}toJSON(e,n){return n?.keep?this.value:St(this.value,e,n)}toString(){return String(this.value)}};ge.BLOCK_FOLDED="BLOCK_FOLDED";ge.BLOCK_LITERAL="BLOCK_LITERAL";ge.PLAIN="PLAIN";ge.QUOTE_DOUBLE="QUOTE_DOUBLE";ge.QUOTE_SINGLE="QUOTE_SINGLE";var Ef="tag:yaml.org,2002:";function Tf(t,e,n){if(e){let s=n.filter(o=>o.tag===e),r=s.find(o=>!o.format)??s[0];if(!r)throw new Error(`Tag ${e} not found`);return r}return n.find(s=>s.identify?.(t)&&!s.format)}function Rn(t,e,n){if(bn(t)&&(t=t.contents),De(t))return t;if(Le(t)){let u=n.schema[an].createNode?.(n.schema,null,n);return u.items.push(t),u}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:s,onAnchor:r,onTagObj:o,schema:i,sourceObjects:a}=n,l;if(s&&t&&typeof t=="object"){if(l=a.get(t),l)return l.anchor??(l.anchor=r(t)),new On(l.anchor);l={anchor:null,node:null},a.set(t,l)}e?.startsWith("!!")&&(e=Ef+e.slice(2));let c=Tf(t,e,i.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let u=new ge(t);return l&&(l.node=u),u}c=t instanceof Map?i[an]:Symbol.iterator in Object(t)?i[Pn]:i[an]}o&&(o(c),delete n.onTagObj);let f=c?.createNode?c.createNode(n.schema,t,n):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(n.schema,t,n):new ge(t);return e?f.tag=e:c.default||(f.tag=c.tag),l&&(l.node=f),f}function Gs(t,e,n){let s=n;for(let r=e.length-1;r>=0;--r){let o=e[r];if(typeof o=="number"&&Number.isInteger(o)&&o>=0){let i=[];i[o]=s,s=i}else s=new Map([[o,s]])}return Rn(s,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var ks=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,ws=class extends jn{constructor(e,n){super(e),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(e){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(n.schema=e),n.items=n.items.map(s=>De(s)||Le(s)?s.clone(e):s),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(ks(e))this.add(n);else{let[s,...r]=e,o=this.get(s,!0);if(Ge(o))o.addIn(r,n);else if(o===void 0&&this.schema)this.set(s,Gs(this.schema,r,n));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${r}`)}}deleteIn(e){let[n,...s]=e;if(s.length===0)return this.delete(n);let r=this.get(n,!0);if(Ge(r))return r.deleteIn(s);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`)}getIn(e,n){let[s,...r]=e,o=this.get(s,!0);return r.length===0?!n&&Ne(o)?o.value:o:Ge(o)?o.getIn(r,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!Le(n))return!1;let s=n.value;return s==null||e&&Ne(s)&&s.value==null&&!s.commentBefore&&!s.comment&&!s.tag})}hasIn(e){let[n,...s]=e;if(s.length===0)return this.has(n);let r=this.get(n,!0);return Ge(r)?r.hasIn(s):!1}setIn(e,n){let[s,...r]=e;if(r.length===0)this.set(s,n);else{let o=this.get(s,!0);if(Ge(o))o.setIn(r,n);else if(o===void 0&&this.schema)this.set(s,Gs(this.schema,r,n));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${r}`)}}};var ol=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Xt(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var kn=(t,e,n)=>t.endsWith(`
1
+ var xf=Object.defineProperty;var bi=(t,e)=>{for(var n in e)xf(t,n,{get:e[n],enumerable:!0})};var tc={};bi(tc,{Bounds:()=>js,C:()=>yt,DiagError:()=>go,FONTS:()=>at,Kernel:()=>gs,S:()=>Xe,VEl:()=>lr,allowed:()=>Qi,apply:()=>Ds,bubble:()=>Tr,buildSvg:()=>Xl,center:()=>$r,colorRef:()=>Mn,createHash:()=>ec,depthSort:()=>Ks,didYouMean:()=>Yn,distance:()=>Ji,envelope:()=>Er,esc:()=>ut,extendTheme:()=>mo,faceFrame:()=>yi,fileLines:()=>Ar,formatDiag:()=>Xi,formatDiags:()=>ql,iso:()=>we,keyGlyph:()=>Qa,loadTheme:()=>po,matStr:()=>zs,n1:()=>it,parse:()=>Hl,parseSvg:()=>Zi,placeholderFace:()=>el,pt:()=>ts,screenFaces:()=>bs,screenGlass:()=>tl,serialize:()=>bo,sha256Hex:()=>ea,socketGlyph:()=>Za,tag:()=>me,termLines:()=>Vs,textWidth:()=>Jt,themeCss:()=>ho,themeParts:()=>Wi,vdoc:()=>Ql});var Xa={sans700_13:{"0":.6787,"1":.5059,"2":.6372,"3":.6631,"4":.6812,"5":.6577,"6":.6777,"7":.6172,"8":.688,"9":.6777," ":.252,"!":.3506,'"':.563,"#":.6655,$:.6655,"%":1.0298,"&":.7388,"'":.3418,"(":.4229,")":.4229,"*":.4785,"+":.6655,",":.3418,"-":.4785,".":.3418,"/":.3286,":":.3418,";":.3418,"<":.6655,"=":.6655,">":.6655,"?":.5513,"@":.9214,A:.7266,B:.6875,C:.7354,D:.7417,E:.6162,F:.5918,G:.7544,H:.7773,I:.3125,J:.5952,K:.7036,L:.5889,M:.9009,N:.7622,O:.7808,P:.668,Q:.7808,R:.6885,S:.6694,T:.6543,U:.7544,V:.7153,W:1.0034,X:.7236,Y:.7021,Z:.6699,"[":.4229,"\\":.3286,"]":.4229,"^":.6655,_:.5845,"`":.4941,a:.584,b:.6455,c:.5815,d:.6455,e:.5952,f:.407,g:.6396,h:.6265,i:.2813,j:.2813,k:.5957,l:.2891,m:.9263,n:.6216,o:.6138,p:.6411,q:.6416,r:.4338,s:.5513,t:.4114,u:.6216,v:.5771,w:.8413,x:.5747,y:.5913,z:.5605,"{":.4229,"|":.2935,"}":.4229,"~":.6655,"\xB7":.3418,"\u2192":.9375,"\u2190":.9375,"\u2191":.8096,"\u2193":.8096,"\u2019":.3418,"\u2018":.3418,"\u201C":.5474,"\u201D":.5474,"\u2026":.9482,"\u2013":.6216,"\u2014":.9045,"\u2715":.7622,"\xD7":.6655,"\u2248":.6655,"\u2264":.6655,"\u2265":.6655,\u00E9:.5952},sans800_15:{"0":.687,"1":.5122,"2":.6406,"3":.6675,"4":.686,"5":.6626,"6":.6836,"7":.6191,"8":.6968,"9":.6836," ":.2344,"!":.3555,'"':.5835,"#":.6694,$:.6694,"%":1.0566,"&":.7397,"'":.3491,"(":.4287,")":.4287,"*":.4731,"+":.6694,",":.3491,"-":.4731,".":.3491,"/":.3286,":":.3491,";":.3491,"<":.6694,"=":.6694,">":.6694,"?":.5562,"@":.9146,A:.7363,B:.6899,C:.7339,D:.7388,E:.6147,F:.5903,G:.749,H:.7813,I:.3198,J:.6064,K:.7104,L:.5879,M:.9019,N:.7612,O:.7759,P:.6709,Q:.7759,R:.6924,S:.6719,T:.6533,U:.7524,V:.7212,W:1.0073,X:.731,Y:.71,Z:.6646,"[":.4287,"\\":.3286,"]":.4287,"^":.6694,_:.5889,"`":.4844,a:.5864,b:.6479,c:.5811,d:.6479,e:.5952,f:.4139,g:.6416,h:.6309,i:.2847,j:.2847,k:.605,l:.2935,m:.937,n:.626,o:.6138,p:.6436,q:.6445,r:.4406,s:.5557,t:.4198,u:.626,v:.5806,w:.856,x:.5835,y:.5996,z:.5601,"{":.4287,"|":.2974,"}":.4287,"~":.6694,"\xB7":.3491,"\u2192":.9404,"\u2190":.9404,"\u2191":.811,"\u2193":.811,"\u2019":.3491,"\u2018":.3491,"\u201C":.5688,"\u201D":.5688,"\u2026":.9883,"\u2013":.626,"\u2014":.9118,"\u2715":.7622,"\xD7":.6694,"\u2248":.6694,"\u2264":.6694,"\u2265":.6694,\u00E9:.5952},sans800_10_5:{"0":.7114,"1":.5366,"2":.665,"3":.6919,"4":.7104,"5":.687,"6":.708,"7":.6436,"8":.7212,"9":.708," ":.2588,"!":.3799,'"':.6079,"#":.6938,$:.6938,"%":1.0811,"&":.7642,"'":.3735,"(":.4531,")":.4531,"*":.4976,"+":.6938,",":.3735,"-":.4976,".":.3735,"/":.353,":":.3735,";":.3735,"<":.6938,"=":.6938,">":.6938,"?":.5806,"@":.939,A:.7607,B:.7144,C:.7583,D:.7632,E:.6392,F:.6147,G:.7734,H:.8057,I:.3442,J:.6309,K:.7349,L:.6123,M:.9263,N:.7856,O:.8003,P:.6953,Q:.8003,R:.7168,S:.6963,T:.6777,U:.7769,V:.7456,W:1.0317,X:.7554,Y:.7344,Z:.689,"[":.4531,"\\":.353,"]":.4531,"^":.6938,_:.6133,"`":.5088,a:.6108,b:.6724,c:.6055,d:.6724,e:.6196,f:.4383,g:.666,h:.6553,i:.3091,j:.3091,k:.6294,l:.3179,m:.9614,n:.6504,o:.6382,p:.668,q:.6689,r:.465,s:.5801,t:.4442,u:.6504,v:.605,w:.8804,x:.6079,y:.624,z:.5845,"{":.4531,"|":.3218,"}":.4531,"~":.6938,"\xB7":.3735,"\u2192":.9648,"\u2190":.9648,"\u2191":.8354,"\u2193":.8354,"\u2019":.3735,"\u2018":.3735,"\u201C":.5933,"\u201D":.5933,"\u2026":1.0127,"\u2013":.6504,"\u2014":.9204,"\u2715":.7622,"\xD7":.6938,"\u2248":.6938,"\u2264":.6938,"\u2265":.6938,\u00E9:.6196},sans600_12:{"0":.6665,"1":.4956,"2":.6299,"3":.6548,"4":.6724,"5":.6484,"6":.668,"7":.6113,"8":.6753,"9":.668," ":.2656,"!":.3413,'"':.5386,"#":.6577,$:.6577,"%":.999,"&":.7334,"'":.3306,"(":.4131,")":.4131,"*":.48,"+":.6577,",":.3306,"-":.48,".":.3306,"/":.3247,":":.3306,";":.3306,"<":.6577,"=":.6577,">":.6577,"?":.5425,"@":.9238,A:.7129,B:.6812,C:.7329,D:.7402,E:.6133,F:.5889,G:.7559,H:.7695,I:.3013,J:.5801,K:.6924,L:.5859,M:.8955,N:.7593,O:.7813,P:.6606,Q:.7813,R:.6807,S:.6626,T:.6514,U:.7524,V:.7056,W:.9956,X:.7124,Y:.6904,Z:.6709,"[":.4131,"\\":.3247,"]":.4131,"^":.6577,_:.5757,"`":.5,a:.5771,b:.6392,c:.5781,d:.6392,e:.5908,f:.3957,g:.6333,h:.6177,i:.2739,j:.2734,k:.582,l:.2808,m:.9116,n:.6128,o:.6099,p:.6348,q:.6348,r:.4232,s:.543,t:.3991,u:.6128,v:.5693,w:.8228,x:.562,y:.5791,z:.5571,"{":.4131,"|":.2856,"}":.4131,"~":.6577,"\xB7":.3306,"\u2192":.9307,"\u2190":.9307,"\u2191":.8037,"\u2193":.8037,"\u2019":.3306,"\u2018":.3306,"\u201C":.522,"\u201D":.522,"\u2026":.9043,"\u2013":.6128,"\u2014":.8957,"\u2715":.7622,"\xD7":.6577,"\u2248":.6577,"\u2264":.6577,"\u2265":.6577,\u00E9:.5908},sans800_12:{"0":.7026,"1":.5278,"2":.6563,"3":.6831,"4":.7017,"5":.6782,"6":.6992,"7":.6348,"8":.7124,"9":.6992," ":.25,"!":.3711,'"':.5991,"#":.6851,$:.6851,"%":1.0723,"&":.7554,"'":.3647,"(":.4443,")":.4443,"*":.4888,"+":.6851,",":.3647,"-":.4888,".":.3647,"/":.3442,":":.3647,";":.3647,"<":.6851,"=":.6851,">":.6851,"?":.5718,"@":.9302,A:.752,B:.7056,C:.7495,D:.7544,E:.6304,F:.606,G:.7646,H:.7969,I:.3354,J:.6221,K:.7261,L:.6035,M:.9175,N:.7769,O:.7915,P:.6865,Q:.7915,R:.708,S:.6875,T:.6689,U:.7681,V:.7368,W:1.0229,X:.7466,Y:.7256,Z:.6802,"[":.4443,"\\":.3442,"]":.4443,"^":.6851,_:.6045,"`":.5,a:.6021,b:.6636,c:.5967,d:.6636,e:.6108,f:.4295,g:.6572,h:.6465,i:.3003,j:.3003,k:.6206,l:.3091,m:.9526,n:.6416,o:.6294,p:.6592,q:.6602,r:.4562,s:.5713,t:.4354,u:.6416,v:.5962,w:.8716,x:.5991,y:.6152,z:.5757,"{":.4443,"|":.313,"}":.4443,"~":.6851,"\xB7":.3647,"\u2192":.9561,"\u2190":.9561,"\u2191":.8267,"\u2193":.8267,"\u2019":.3647,"\u2018":.3647,"\u201C":.5845,"\u201D":.5845,"\u2026":1.0039,"\u2013":.6416,"\u2014":.9173,"\u2715":.7622,"\xD7":.6851,"\u2248":.6851,"\u2264":.6851,"\u2265":.6851,\u00E9:.6108},sans800_11_5:{"0":.7056,"1":.5308,"2":.6592,"3":.686,"4":.7046,"5":.6812,"6":.7021,"7":.6377,"8":.7153,"9":.7021," ":.2529,"!":.374,'"':.6021,"#":.688,$:.688,"%":1.0752,"&":.7583,"'":.3677,"(":.4473,")":.4473,"*":.4917,"+":.688,",":.3677,"-":.4917,".":.3677,"/":.3472,":":.3677,";":.3677,"<":.688,"=":.688,">":.688,"?":.5747,"@":.9331,A:.7549,B:.7085,C:.7524,D:.7573,E:.6333,F:.6089,G:.7676,H:.7998,I:.3384,J:.625,K:.729,L:.6064,M:.9204,N:.7798,O:.7944,P:.6895,Q:.7944,R:.7109,S:.6904,T:.6719,U:.771,V:.7397,W:1.0259,X:.7495,Y:.7285,Z:.6831,"[":.4473,"\\":.3472,"]":.4473,"^":.688,_:.6074,"`":.5029,a:.605,b:.6665,c:.5996,d:.6665,e:.6138,f:.4325,g:.6602,h:.6494,i:.3032,j:.3032,k:.6235,l:.312,m:.9556,n:.6445,o:.6323,p:.6621,q:.6631,r:.4591,s:.5742,t:.4383,u:.6445,v:.5991,w:.8745,x:.6021,y:.6182,z:.5786,"{":.4473,"|":.3159,"}":.4473,"~":.688,"\xB7":.3677,"\u2192":.959,"\u2190":.959,"\u2191":.8296,"\u2193":.8296,"\u2019":.3677,"\u2018":.3677,"\u201C":.5874,"\u201D":.5874,"\u2026":1.0068,"\u2013":.6445,"\u2014":.9183,"\u2715":.7622,"\xD7":.688,"\u2248":.688,"\u2264":.688,"\u2265":.688,\u00E9:.6138},sans400_13:{"0":.624,"1":.458,"2":.5977,"3":.6211,"4":.6377,"5":.6123,"6":.6309,"7":.582,"8":.6328,"9":.6309," ":.2754,"!":.3052,'"':.4717,"#":.624,$:.624,"%":.9194,"&":.7056,"'":.291,"(":.376,")":.376,"*":.4658,"+":.624,",":.291,"-":.4658,".":.291,"/":.2988,":":.291,";":.291,"<":.624,"=":.624,">":.624,"?":.5068,"@":.9121,A:.668,B:.6514,C:.71,D:.7207,E:.5898,F:.5664,G:.7407,H:.7363,I:.2617,J:.5322,K:.6528,L:.562,M:.8682,N:.7363,O:.7656,P:.6294,Q:.7656,R:.6475,S:.6313,T:.6279,U:.7314,V:.668,W:.9619,X:.6729,Y:.6494,Z:.6558,"[":.376,"\\":.2988,"]":.376,"^":.624,_:.5405,"`":.4941,a:.5459,b:.6084,c:.5537,d:.6084,e:.5654,f:.356,g:.6035,h:.5825,i:.2412,j:.2407,k:.5371,l:.2471,m:.8643,n:.5776,o:.585,p:.6045,q:.6035,r:.3843,s:.5083,t:.3574,u:.5776,v:.5361,w:.7686,x:.5186,y:.5371,z:.5332,"{":.376,"|":.2529,"}":.376,"~":.624,"\xB7":.291,"\u2192":.8999,"\u2190":.8999,"\u2191":.7754,"\u2193":.7754,"\u2019":.291,"\u2018":.291,"\u201C":.4531,"\u201D":.4531,"\u2026":.7988,"\u2013":.5776,"\u2014":.872,"\u2715":.7622,"\xD7":.624,"\u2248":.624,"\u2264":.624,"\u2265":.624,\u00E9:.5654},mono400_11:{"0":.6021,"1":.6021,"2":.6021,"3":.6021,"4":.6021,"5":.6021,"6":.6021,"7":.6021,"8":.6021,"9":.6021," ":.6021,"!":.6021,'"':.6021,"#":.6021,$:.6021,"%":.6021,"&":.6021,"'":.6021,"(":.6021,")":.6021,"*":.6021,"+":.6021,",":.6021,"-":.6021,".":.6021,"/":.6021,":":.6021,";":.6021,"<":.6021,"=":.6021,">":.6021,"?":.6021,"@":.6021,A:.6021,B:.6021,C:.6021,D:.6021,E:.6021,F:.6021,G:.6021,H:.6021,I:.6021,J:.6021,K:.6021,L:.6021,M:.6021,N:.6021,O:.6021,P:.6021,Q:.6021,R:.6021,S:.6021,T:.6021,U:.6021,V:.6021,W:.6021,X:.6021,Y:.6021,Z:.6021,"[":.6021,"\\":.6021,"]":.6021,"^":.6021,_:.6021,"`":.6021,a:.6021,b:.6021,c:.6021,d:.6021,e:.6021,f:.6021,g:.6021,h:.6021,i:.6021,j:.6021,k:.6021,l:.6021,m:.6021,n:.6021,o:.6021,p:.6021,q:.6021,r:.6021,s:.6021,t:.6021,u:.6021,v:.6021,w:.6021,x:.6021,y:.6021,z:.6021,"{":.6021,"|":.6021,"}":.6021,"~":.6021,"\xB7":.6021,"\u2192":.6021,"\u2190":.6021,"\u2191":.6021,"\u2193":.6021,"\u2019":.6021,"\u2018":.6021,"\u201C":.6021,"\u201D":.6021,"\u2026":.6021,"\u2013":.6021,"\u2014":.6021,"\u2715":.6021,"\xD7":.6021,"\u2248":.6021,"\u2264":.6021,"\u2265":.6021,\u00E9:.6021},mono600_11:{"0":.6021,"1":.6021,"2":.6021,"3":.6021,"4":.6021,"5":.6021,"6":.6021,"7":.6021,"8":.6021,"9":.6021," ":.6021,"!":.6021,'"':.6021,"#":.6021,$:.6021,"%":.6021,"&":.6021,"'":.6021,"(":.6021,")":.6021,"*":.6021,"+":.6021,",":.6021,"-":.6021,".":.6021,"/":.6021,":":.6021,";":.6021,"<":.6021,"=":.6021,">":.6021,"?":.6021,"@":.6021,A:.6021,B:.6021,C:.6021,D:.6021,E:.6021,F:.6021,G:.6021,H:.6021,I:.6021,J:.6021,K:.6021,L:.6021,M:.6021,N:.6021,O:.6021,P:.6021,Q:.6021,R:.6021,S:.6021,T:.6021,U:.6021,V:.6021,W:.6021,X:.6021,Y:.6021,Z:.6021,"[":.6021,"\\":.6021,"]":.6021,"^":.6021,_:.6021,"`":.6021,a:.6021,b:.6021,c:.6021,d:.6021,e:.6021,f:.6021,g:.6021,h:.6021,i:.6021,j:.6021,k:.6021,l:.6021,m:.6021,n:.6021,o:.6021,p:.6021,q:.6021,r:.6021,s:.6021,t:.6021,u:.6021,v:.6021,w:.6021,x:.6021,y:.6021,z:.6021,"{":.6021,"|":.6021,"}":.6021,"~":.6021,"\xB7":.6021,"\u2192":.6021,"\u2190":.6021,"\u2191":.6021,"\u2193":.6021,"\u2019":.6021,"\u2018":.6021,"\u201C":.6021,"\u201D":.6021,"\u2026":.6021,"\u2013":.6021,"\u2014":.6021,"\u2715":.6021,"\xD7":.6021,"\u2248":.6021,"\u2264":.6021,"\u2265":.6021,\u00E9:.6021}};var Xe=34,yt=Math.cos(Math.PI/6),we=(t,e,n=0)=>[(t-e)*yt*Xe,(t+e)*.5*Xe-n*Xe],it=t=>{let e=Math.round(t*10)/10;return Object.is(e,-0)?"0":String(e)},ts=t=>`${it(t[0])},${it(t[1])}`,ut=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function me(t,e={},n){let s="";for(let r in e){let o=e[r];o==null||o===!1||o===""||(s+=` ${r}="${ut(typeof o=="number"?it(o):o)}"`)}return n===void 0?`<${t}${s}/>`:`<${t}${s}>${n}</${t}>`}var at={lbl:{key:"sans700_13",size:13},sub:{key:"mono400_11",size:11},slabname:{key:"sans800_15",size:15,spacing:.12},sm:{key:"sans800_10_5",size:10.5,spacing:.1},floor:{key:"mono600_11",size:11,spacing:.01},say:{key:"sans600_12",size:12},tunname:{key:"sans800_12",size:12,spacing:.14},badge:{key:"sans800_11_5",size:11.5}};function Jt(t,e){let n=Xa[e.key],s=e.key.startsWith("mono")?.6:.58,r=0;for(let o of t)r+=n[o]??s;return(r+(e.spacing??0)*[...t].length)*e.size}var Ds=(t,e,n)=>[t[0]*e+t[2]*n+t[4],t[1]*e+t[3]*n+t[5]],zs=t=>`matrix(${t.map(e=>Math.round(e*1e4)/1e4).join(" ")})`;function yi(t,e){if(e==="left"){let[r,o]=we(t.x0,t.y1,t.z1);return{m:[yt,.5,0,1,r,o],w:(t.x1-t.x0)*Xe,h:(t.z1-t.z0)*Xe}}if(e==="right"){let[r,o]=we(t.x1,t.y1,t.z1);return{m:[yt,-.5,0,1,r,o],w:(t.y1-t.y0)*Xe,h:(t.z1-t.z0)*Xe}}let[n,s]=we(t.x0,t.y0,t.z1);return{m:[yt,.5,-yt,.5,n,s],w:(t.x1-t.x0)*Xe,h:(t.y1-t.y0)*Xe}}var js=class{x0=1/0;y0=1/0;x1=-1/0;y1=-1/0;add(e){e[0]<this.x0&&(this.x0=e[0]),e[0]>this.x1&&(this.x1=e[0]),e[1]<this.y0&&(this.y0=e[1]),e[1]>this.y1&&(this.y1=e[1])}addRect(e,n,s,r){this.add([e,n]),this.add([e+s,n+r])}get empty(){return this.x0===1/0}},gs=class{bounds=new js;texts=[];planes=[];planePolys=[];defs=new Map;poly(e,n,s={}){let r=e.map(o=>we(o[0],o[1],o[2]));return r.forEach(o=>this.bounds.add(o)),me("polygon",{points:r.map(ts).join(" "),class:n,...s})}line3(e,n,s,r={}){let o=we(...e),i=we(...n);return this.bounds.add(o),this.bounds.add(i),me("line",{x1:o[0],y1:o[1],x2:i[0],y2:i[1],class:s,...r})}blockFaces(e){let{x0:n,y0:s,x1:r,y1:o,z0:i,z1:a}=e;return this.poly([[n,o,i],[r,o,i],[r,o,a],[n,o,a]],"lft")+this.poly([[r,s,i],[r,o,i],[r,o,a],[r,s,a]],"rgt")+this.poly([[n,s,a],[r,s,a],[r,o,a],[n,o,a]],"top")}onFace(e,n,s,r){let o=yi(e,n);for(let[i,a]of[[0,0],[o.w,0],[0,o.h],[o.w,o.h]])this.bounds.add(Ds(o.m,i,a));return me("g",{class:r,transform:zs(o.m)},s(o.w,o.h))}onMatrix(e,n,s,r,o){for(let[i,a]of[[0,0],[n,0],[0,s],[n,s]])this.bounds.add(Ds(e,i,a));return me("g",{class:o,transform:zs(e)},r(n,s))}text(e,n,s,r,o,i="middle",a={},l){let c=Jt(s,o),u={x:i==="start"?e:i==="end"?e-c:e-c/2,y:n-o.size*.8,w:c,h:o.size*1.05,text:s,owner:l};return this.bounds.addRect(u.x-2,u.y-2,u.w+4,u.h+4),this.texts.push(u),me("text",{x:e,y:n,class:r,"text-anchor":i==="start"?void 0:i,...a},ut(s))}planeText(e,n,s,r,o="start",i={}){let a=Jt(n,r),l=o==="start"?0:o==="end"?-a:-a/2,c=[[l,-r.size*.8],[l+a,-r.size*.8],[l,r.size*.25],[l+a,r.size*.25]].map(([d,p])=>Ds(e,d,p));c.forEach(d=>this.bounds.add(d));let f=c.map(d=>d[0]),u=c.map(d=>d[1]);return this.planePolys.push([c[0],c[1],c[3],c[2]]),this.planes.push({x:Math.min(...f),y:Math.min(...u),w:Math.max(...f)-Math.min(...f),h:Math.max(...u)-Math.min(...u)}),me("text",{transform:zs(e),class:s,"text-anchor":o==="start"?void 0:o,...i},ut(n))}floorText(e,n,s,r,o,i="x",a="start",l={}){let[c,f]=we(e,n,s),u=i==="x"?[yt,.5,-yt,.5,c,f]:[yt,-.5,yt,.5,c,f];return this.planeText(u,r,o,at.floor,a,l)}faceText(e,n,s,r,o,i,a="left",l="start",c={}){let[f,u]=we(e,n,s),d=a==="left"?[yt,.5,0,1,f,u]:[yt,-.5,0,1,f,u];return this.planeText(d,r,o,i,l,c)}def(e,n){this.defs.set(e,n)}},$r=t=>[(t.x0+t.x1)/2,(t.y0+t.y1)/2,t.z1];function Vs(t,e,n){let s="";for(let r=0;r<n;r++){let o=e.z1-(e.z1-e.z0)*(.28+r*.2),i=(e.x1-e.x0)*(r===n-1?.35:.62-r*.1);s+=t.line3([e.x0+.35,e.y1,o],[e.x0+.35+i,e.y1,o],"det")}return s}function Er(t,e){let s=e.z1,r=[e.x0+.55,e.y0+.55,s],o=[e.x1-.55,e.y0+.55,s],i=[e.x1-.55,e.y1-.55,s],a=[e.x0+.55,e.y1-.55,s],l=[(e.x0+e.x1)/2,(e.y0+e.y1)/2,s];return t.poly([r,o,i,a],"det")+t.line3(r,l,"det")+t.line3(l,o,"det")}function Tr(t,e){let s=e.z1,r=t.poly([[e.x0+.55,e.y0+.55,s],[e.x1-.55,e.y0+.55,s],[e.x1-.55,e.y1-.55,s],[e.x0+.55,e.y1-.55,s]],"det");for(let o=1;o<=2;o++){let i=e.y0+.55+(e.y1-e.y0-1.1)*o/3;r+=t.line3([e.x0+.55+.3,i,s],[e.x1-.55-.3-(o===2?.5:0),i,s],"det")}return r}function Ar(t,e){let s=e.z1,r=(e.y0+e.y1)/2;return t.line3([e.x0+.3,r-.2,s],[e.x1-.3,r-.2,s],"det")+t.line3([e.x0+.3,r+.2,s],[e.x1-.3-.3,r+.2,s],"det")}function Qa(t,e){let n=(e.x0+e.x1)/2,s=(e.y0+e.y1)/2,r=e.z1+.005,o=Math.min(e.x1-e.x0,e.y1-e.y0)*.16,i=[];for(let a=0;a<20;a++){let l=a/20*Math.PI*2;i.push([n-o*1.4+Math.cos(l)*o,s+Math.sin(l)*o,r])}return t.poly(i,"det")+t.line3([n-o*.4,s,r],[n+o*2.2,s,r],"det")+t.line3([n+o*1.7,s,r],[n+o*1.7,s+o*.8,r],"det")}function Za(t,e){let n=(e.x0+e.x1)/2,s=(e.y0+e.y1)/2,r=e.z1+.005,o=Math.min(e.x1-e.x0,e.y1-e.y0)*.28,i=[];for(let a=0;a<24;a++){let l=a/24*Math.PI*2;i.push([n+Math.cos(l)*o,s+Math.sin(l)*o,r])}return t.poly(i,"det sock-hole")}var ns=(t,e,n,s,r,o=0)=>me("rect",{class:t,x:e,y:n,width:s,height:r,rx:o||void 0}),bs={terminal(t,e){let n="",s=Math.max(2,Math.floor((e-12)/9));for(let r=0;r<s;r++){let o=10+r*9,i=(t-18)*[.7,.45,.6,.3,.55][r%5];n+=me("line",{class:"ln",x1:8,y1:o,x2:8+i,y2:o})}return n},chat(t,e){return[[6,.62,"w"],[.3,.58,"m"],[6,.46,"w"],[.42,.5,"m"]].map((s,r)=>{let o=(t-14)*s[1],i=s[0]===6?7:t-7-o;return ns(s[2],i,8+r*(e-18)/4,o,(e-18)/4-4,3)}).join("")},desktop(t,e){return ns("wall",5,5,t-10,e-10,2)+ns("bar",5,5,t-10,6)+ns("win",t*.5,13,t*.38,e*.42,2)},tiles(t,e){let i=(t-12-5)/3,a=(e-12-2.5*1)/2,l="";for(let c=0;c<2;c++)for(let f=0;f<3;f++){let u=6+f*(i+2.5),d=6+c*(a+2.5);l+=ns("t",u,d,i,a,1.5),[.3,.52,.74].forEach((p,h)=>{l+=me("line",{class:"ln",x1:u+2.5,y1:d+a*p,x2:u+2.5+(i-5)*[.8,.5,.65][(h+c+f)%3],y2:d+a*p})})}return l}};function el(t,e){let n=t/2,s=e/2,r=Math.min(t,e)*.22;return ns("unk",t*.2,e*.2,t*.6,e*.6,2)+me("path",{class:"unk-q",d:`M${it(n-r*.5)},${it(s-r*.45)}a${it(r*.5)},${it(r*.5)} 0 1 1 ${it(r*.5)},${it(r*.55)}v${it(r*.3)}`})+me("circle",{class:"unk-dot",cx:it(n),cy:it(s+r*.75),r:it(Math.max(.8,r*.1))})}function tl(t,e){return ns("glass",3,3,t-6,e-6,3)}function vf(t){let e=[we(t.x0,t.y0,t.z1),we(t.x1,t.y0,t.z0),we(t.x0,t.y1,t.z0),we(t.x1,t.y1,t.z0),we(t.x1,t.y1,t.z1),we(t.x0,t.y0,t.z0)],n=e.map(r=>r[0]),s=e.map(r=>r[1]);return[Math.min(...n),Math.min(...s),Math.max(...n),Math.max(...s)]}function Sf(t,e){let s=t.x1<=e.x0+1e-6,r=e.x1<=t.x0+1e-6,o=t.y1<=e.y0+1e-6,i=e.y1<=t.y0+1e-6,a=t.z1<=e.z0+1e-6,l=e.z1<=t.z0+1e-6,c=s||o||a,f=r||i||l;return c&&!f?-1:f&&!c?1:0}function Ks(t){let e=t.length,n=t.map(c=>vf(c.box)),s=c=>c.box.x0+c.box.y0+c.box.z0*.01,r=t.map(()=>[]),o=new Array(e).fill(0);for(let c=0;c<e;c++)for(let f=c+1;f<e;f++){let u=n[c],d=n[f];if(u[2]<=d[0]||d[2]<=u[0]||u[3]<=d[1]||d[3]<=u[1])continue;let p=Sf(t[c].box,t[f].box);p<0?(r[c].push(f),o[f]++):p>0&&(r[f].push(c),o[c]++)}let i=[],a=t.map((c,f)=>f).filter(c=>!o[c]),l=new Array(e).fill(!1);for(;i.length<e;){if(!a.length){let f=t.map((u,d)=>d).filter(u=>!l[u]).sort((u,d)=>s(t[u])-s(t[d]));a.push(f[0]),o[f[0]]=0}a.sort((f,u)=>s(t[f])-s(t[u])||f-u);let c=a.shift();if(!l[c]){l[c]=!0,i.push(t[c]);for(let f of r[c])!l[f]&&--o[f]===0&&a.push(f)}}return i}var Nr=Symbol.for("yaml.alias"),Pr=Symbol.for("yaml.document"),an=Symbol.for("yaml.map"),xi=Symbol.for("yaml.pair"),Gt=Symbol.for("yaml.scalar"),Pn=Symbol.for("yaml.seq"),Ft=Symbol.for("yaml.node.type"),ln=t=>!!t&&typeof t=="object"&&t[Ft]===Nr,bn=t=>!!t&&typeof t=="object"&&t[Ft]===Pr,_t=t=>!!t&&typeof t=="object"&&t[Ft]===an,Le=t=>!!t&&typeof t=="object"&&t[Ft]===xi,Ne=t=>!!t&&typeof t=="object"&&t[Ft]===Gt,Dt=t=>!!t&&typeof t=="object"&&t[Ft]===Pn;function Ge(t){if(t&&typeof t=="object")switch(t[Ft]){case an:case Pn:return!0}return!1}function De(t){if(t&&typeof t=="object")switch(t[Ft]){case Nr:case an:case Gt:case Pn:return!0}return!1}var Rr=t=>(Ne(t)||Ge(t))&&!!t.anchor;var zt=Symbol("break visit"),nl=Symbol("skip children"),yn=Symbol("remove node");function xn(t,e){let n=sl(e);bn(t)?ys(null,t.contents,n,Object.freeze([t]))===yn&&(t.contents=null):ys(null,t,n,Object.freeze([]))}xn.BREAK=zt;xn.SKIP=nl;xn.REMOVE=yn;function ys(t,e,n,s){let r=rl(t,e,n,s);if(De(r)||Le(r))return ol(t,s,r),ys(t,r,n,s);if(typeof r!="symbol"){if(Ge(e)){s=Object.freeze(s.concat(e));for(let o=0;o<e.items.length;++o){let i=ys(o,e.items[o],n,s);if(typeof i=="number")o=i-1;else{if(i===zt)return zt;i===yn&&(e.items.splice(o,1),o-=1)}}}else if(Le(e)){s=Object.freeze(s.concat(e));let o=ys("key",e.key,n,s);if(o===zt)return zt;o===yn&&(e.key=null);let i=ys("value",e.value,n,s);if(i===zt)return zt;i===yn&&(e.value=null)}}return r}async function Or(t,e){let n=sl(e);bn(t)?await xs(null,t.contents,n,Object.freeze([t]))===yn&&(t.contents=null):await xs(null,t,n,Object.freeze([]))}Or.BREAK=zt;Or.SKIP=nl;Or.REMOVE=yn;async function xs(t,e,n,s){let r=await rl(t,e,n,s);if(De(r)||Le(r))return ol(t,s,r),xs(t,r,n,s);if(typeof r!="symbol"){if(Ge(e)){s=Object.freeze(s.concat(e));for(let o=0;o<e.items.length;++o){let i=await xs(o,e.items[o],n,s);if(typeof i=="number")o=i-1;else{if(i===zt)return zt;i===yn&&(e.items.splice(o,1),o-=1)}}}else if(Le(e)){s=Object.freeze(s.concat(e));let o=await xs("key",e.key,n,s);if(o===zt)return zt;o===yn&&(e.key=null);let i=await xs("value",e.value,n,s);if(i===zt)return zt;i===yn&&(e.value=null)}}return r}function sl(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function rl(t,e,n,s){if(typeof n=="function")return n(t,e,s);if(_t(e))return n.Map?.(t,e,s);if(Dt(e))return n.Seq?.(t,e,s);if(Le(e))return n.Pair?.(t,e,s);if(Ne(e))return n.Scalar?.(t,e,s);if(ln(e))return n.Alias?.(t,e,s)}function ol(t,e,n){let s=e[e.length-1];if(Ge(s))s.items[t]=n;else if(Le(s))t==="key"?s.key=n:s.value=n;else if(bn(s))s.contents=n;else{let r=ln(s)?"alias":"scalar";throw new Error(`Cannot replace node with ${r} parent`)}}var Mf={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},$f=t=>t.replace(/[!,[\]{}]/g,e=>Mf[e]),wn=class t{constructor(e,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,n)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,n){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let s=e.trim().split(/[ \t]+/),r=s.shift();switch(r){case"%TAG":{if(s.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),s.length<2))return!1;let[o,i]=s;return this.tags[o]=i,!0}case"%YAML":{if(this.yaml.explicit=!0,s.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[o]=s;if(o==="1.1"||o==="1.2")return this.yaml.version=o,!0;{let i=/^\d+\.\d+$/.test(o);return n(6,`Unsupported YAML version ${o}`,i),!1}}default:return n(0,`Unknown directive ${r}`,!0),!1}}tagName(e,n){if(e==="!")return"!";if(e[0]!=="!")return n(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let i=e.slice(2,-1);return i==="!"||i==="!!"?(n(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&n("Verbatim tags must end with a >"),i)}let[,s,r]=e.match(/^(.*!)([^!]*)$/s);r||n(`The ${e} tag has no suffix`);let o=this.tags[s];if(o)try{return o+decodeURIComponent(r)}catch(i){return n(String(i)),null}return s==="!"?e:(n(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[n,s]of Object.entries(this.tags))if(e.startsWith(s))return n+$f(e.substring(s.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags),r;if(e&&s.length>0&&De(e.contents)){let o={};xn(e.contents,(i,a)=>{De(a)&&a.tag&&(o[a.tag]=!0)}),r=Object.keys(o)}else r=[];for(let[o,i]of s)o==="!!"&&i==="tag:yaml.org,2002:"||(!e||r.some(a=>a.startsWith(i)))&&n.push(`%TAG ${o} ${i}`);return n.join(`
2
+ `)}};wn.defaultYaml={explicit:!1,version:"1.2"};wn.defaultTags={"!!":"tag:yaml.org,2002:"};function Cr(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(n)}return!0}function wi(t){let e=new Set;return xn(t,{Value(n,s){s.anchor&&e.add(s.anchor)}}),e}function ki(t,e){for(let n=1;;++n){let s=`${t}${n}`;if(!e.has(s))return s}}function il(t,e){let n=[],s=new Map,r=null;return{onAnchor:o=>{n.push(o),r??(r=wi(t));let i=ki(e,r);return r.add(i),i},setAnchors:()=>{for(let o of n){let i=s.get(o);if(typeof i=="object"&&i.anchor&&(Ne(i.node)||Ge(i.node)))i.node.anchor=i.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:s}}function zn(t,e,n,s){if(s&&typeof s=="object")if(Array.isArray(s))for(let r=0,o=s.length;r<o;++r){let i=s[r],a=zn(t,s,String(r),i);a===void 0?delete s[r]:a!==i&&(s[r]=a)}else if(s instanceof Map)for(let r of Array.from(s.keys())){let o=s.get(r),i=zn(t,s,r,o);i===void 0?s.delete(r):i!==o&&s.set(r,i)}else if(s instanceof Set)for(let r of Array.from(s)){let o=zn(t,s,r,r);o===void 0?s.delete(r):o!==r&&(s.delete(r),s.add(o))}else for(let[r,o]of Object.entries(s)){let i=zn(t,s,r,o);i===void 0?delete s[r]:i!==o&&(s[r]=i)}return t.call(e,n,s)}function St(t,e,n){if(Array.isArray(t))return t.map((s,r)=>St(s,String(r),n));if(t&&typeof t.toJSON=="function"){if(!n||!Rr(t))return t.toJSON(e,n);let s={aliasCount:0,count:1,res:void 0};n.anchors.set(t,s),n.onCreate=o=>{s.res=o,delete n.onCreate};let r=t.toJSON(e,n);return n.onCreate&&n.onCreate(r),r}return typeof t=="bigint"&&!n?.keep?Number(t):t}var jn=class{constructor(e){Object.defineProperty(this,Ft,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:n,maxAliasCount:s,onAnchor:r,reviver:o}={}){if(!bn(e))throw new TypeError("A document argument is required");let i={anchors:new Map,doc:e,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},a=St(this,"",i);if(typeof r=="function")for(let{count:l,res:c}of i.anchors.values())r(c,l);return typeof o=="function"?zn(o,{"":a},"",a):a}};var Rn=class extends jn{constructor(e){super(Nr),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,n){if(n?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let s;n?.aliasResolveCache?s=n.aliasResolveCache:(s=[],xn(e,{Node:(o,i)=>{(ln(i)||Rr(i))&&s.push(i)}}),n&&(n.aliasResolveCache=s));let r;for(let o of s){if(o===this)break;o.anchor===this.source&&(r=o)}if(r&&n){let{anchors:o,doc:i,maxAliasCount:a}=n,l=o.get(r);if(l||(St(r,null,n),l=o.get(r)),l?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(a>=0&&(l.count+=1,l.aliasCount===0&&(l.aliasCount=Lr(i,r,o)),l.count*l.aliasCount>a)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}}return r}toJSON(e,n){if(!n)return{source:this.source};let s=this.resolve(n.doc,n);if(!s){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(r)}return n.anchors.get(s).res}toString(e,n,s){let r=`*${this.source}`;if(e){if(Cr(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let o=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(o)}if(e.implicitKey)return`${r} `}return r}};function Lr(t,e,n){if(ln(e)){let s=e.resolve(t),r=n&&s&&n.get(s);return r?r.count*r.aliasCount:0}else if(Ge(e)){let s=0;for(let r of e.items){let o=Lr(t,r,n);o>s&&(s=o)}return s}else if(Le(e)){let s=Lr(t,e.key,n),r=Lr(t,e.value,n);return Math.max(s,r)}return 1}var Ir=t=>!t||typeof t!="function"&&typeof t!="object",ge=class extends jn{constructor(e){super(Gt),this.value=e}toJSON(e,n){return n?.keep?this.value:St(this.value,e,n)}toString(){return String(this.value)}};ge.BLOCK_FOLDED="BLOCK_FOLDED";ge.BLOCK_LITERAL="BLOCK_LITERAL";ge.PLAIN="PLAIN";ge.QUOTE_DOUBLE="QUOTE_DOUBLE";ge.QUOTE_SINGLE="QUOTE_SINGLE";var Ef="tag:yaml.org,2002:";function Tf(t,e,n){if(e){let s=n.filter(o=>o.tag===e),r=s.find(o=>!o.format)??s[0];if(!r)throw new Error(`Tag ${e} not found`);return r}return n.find(s=>s.identify?.(t)&&!s.format)}function On(t,e,n){if(bn(t)&&(t=t.contents),De(t))return t;if(Le(t)){let u=n.schema[an].createNode?.(n.schema,null,n);return u.items.push(t),u}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:s,onAnchor:r,onTagObj:o,schema:i,sourceObjects:a}=n,l;if(s&&t&&typeof t=="object"){if(l=a.get(t),l)return l.anchor??(l.anchor=r(t)),new Rn(l.anchor);l={anchor:null,node:null},a.set(t,l)}e?.startsWith("!!")&&(e=Ef+e.slice(2));let c=Tf(t,e,i.tags);if(!c){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let u=new ge(t);return l&&(l.node=u),u}c=t instanceof Map?i[an]:Symbol.iterator in Object(t)?i[Pn]:i[an]}o&&(o(c),delete n.onTagObj);let f=c?.createNode?c.createNode(n.schema,t,n):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(n.schema,t,n):new ge(t);return e?f.tag=e:c.default||(f.tag=c.tag),l&&(l.node=f),f}function Gs(t,e,n){let s=n;for(let r=e.length-1;r>=0;--r){let o=e[r];if(typeof o=="number"&&Number.isInteger(o)&&o>=0){let i=[];i[o]=s,s=i}else s=new Map([[o,s]])}return On(s,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:t,sourceObjects:new Map})}var ks=t=>t==null||typeof t=="object"&&!!t[Symbol.iterator]().next().done,ws=class extends jn{constructor(e,n){super(e),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(e){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(n.schema=e),n.items=n.items.map(s=>De(s)||Le(s)?s.clone(e):s),this.range&&(n.range=this.range.slice()),n}addIn(e,n){if(ks(e))this.add(n);else{let[s,...r]=e,o=this.get(s,!0);if(Ge(o))o.addIn(r,n);else if(o===void 0&&this.schema)this.set(s,Gs(this.schema,r,n));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${r}`)}}deleteIn(e){let[n,...s]=e;if(s.length===0)return this.delete(n);let r=this.get(n,!0);if(Ge(r))return r.deleteIn(s);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`)}getIn(e,n){let[s,...r]=e,o=this.get(s,!0);return r.length===0?!n&&Ne(o)?o.value:o:Ge(o)?o.getIn(r,n):void 0}hasAllNullValues(e){return this.items.every(n=>{if(!Le(n))return!1;let s=n.value;return s==null||e&&Ne(s)&&s.value==null&&!s.commentBefore&&!s.comment&&!s.tag})}hasIn(e){let[n,...s]=e;if(s.length===0)return this.has(n);let r=this.get(n,!0);return Ge(r)?r.hasIn(s):!1}setIn(e,n){let[s,...r]=e;if(r.length===0)this.set(s,n);else{let o=this.get(s,!0);if(Ge(o))o.setIn(r,n);else if(o===void 0&&this.schema)this.set(s,Gs(this.schema,r,n));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${r}`)}}};var al=t=>t.replace(/^(?!$)(?: $)?/gm,"#");function Xt(t,e){return/^\n+$/.test(t)?t.substring(1):e?t.replace(/^(?! *$)/gm,e):t}var kn=(t,e,n)=>t.endsWith(`
3
3
  `)?Xt(n,e):n.includes(`
4
4
  `)?`
5
- `+Xt(n,e):(t.endsWith(" ")?"":" ")+n;var wi="flow",Fr="block",Us="quoted";function qs(t,e,n="flow",{indentAtStart:s,lineWidth:r=80,minContentWidth:o=20,onFold:i,onOverflow:a}={}){if(!r||r<0)return t;r<o&&(o=0);let l=Math.max(1+o,1+r-e.length);if(t.length<=l)return t;let c=[],f={},u=r-e.length;typeof s=="number"&&(s>r-Math.max(2,o)?c.push(0):u=r-s);let d,p,h=!1,m=-1,y=-1,I=-1;n===Fr&&(m=il(t,m,e.length),m!==-1&&(u=m+l));for(let M;M=t[m+=1];){if(n===Us&&M==="\\"){switch(y=m,t[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}I=m}if(M===`
6
- `)n===Fr&&(m=il(t,m,e.length)),u=m+e.length+l,d=void 0;else{if(M===" "&&p&&p!==" "&&p!==`
5
+ `+Xt(n,e):(t.endsWith(" ")?"":" ")+n;var vi="flow",Fr="block",Us="quoted";function qs(t,e,n="flow",{indentAtStart:s,lineWidth:r=80,minContentWidth:o=20,onFold:i,onOverflow:a}={}){if(!r||r<0)return t;r<o&&(o=0);let l=Math.max(1+o,1+r-e.length);if(t.length<=l)return t;let c=[],f={},u=r-e.length;typeof s=="number"&&(s>r-Math.max(2,o)?c.push(0):u=r-s);let d,p,h=!1,m=-1,y=-1,I=-1;n===Fr&&(m=ll(t,m,e.length),m!==-1&&(u=m+l));for(let M;M=t[m+=1];){if(n===Us&&M==="\\"){switch(y=m,t[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}I=m}if(M===`
6
+ `)n===Fr&&(m=ll(t,m,e.length)),u=m+e.length+l,d=void 0;else{if(M===" "&&p&&p!==" "&&p!==`
7
7
  `&&p!==" "){let $=t[m+1];$&&$!==" "&&$!==`
8
- `&&$!==" "&&(d=m)}if(m>=u)if(d)c.push(d),u=d+l,d=void 0;else if(n===Us){for(;p===" "||p===" ";)p=M,M=t[m+=1],h=!0;let $=m>I+1?m-2:y-1;if(f[$])return t;c.push($),f[$]=!0,u=$+l,d=void 0}else h=!0}p=M}if(h&&a&&a(),c.length===0)return t;i&&i();let N=t.slice(0,c[0]);for(let M=0;M<c.length;++M){let $=c[M],O=c[M+1]||t.length;$===0?N=`
9
- ${e}${t.slice(0,O)}`:(n===Us&&f[$]&&(N+=`${t[$]}\\`),N+=`
10
- ${e}${t.slice($+1,O)}`)}return N}function il(t,e,n){let s=e,r=e+1,o=t[r];for(;o===" "||o===" ";)if(e<r+n)o=t[++e];else{do o=t[++e];while(o&&o!==`
8
+ `&&$!==" "&&(d=m)}if(m>=u)if(d)c.push(d),u=d+l,d=void 0;else if(n===Us){for(;p===" "||p===" ";)p=M,M=t[m+=1],h=!0;let $=m>I+1?m-2:y-1;if(f[$])return t;c.push($),f[$]=!0,u=$+l,d=void 0}else h=!0}p=M}if(h&&a&&a(),c.length===0)return t;i&&i();let N=t.slice(0,c[0]);for(let M=0;M<c.length;++M){let $=c[M],R=c[M+1]||t.length;$===0?N=`
9
+ ${e}${t.slice(0,R)}`:(n===Us&&f[$]&&(N+=`${t[$]}\\`),N+=`
10
+ ${e}${t.slice($+1,R)}`)}return N}function ll(t,e,n){let s=e,r=e+1,o=t[r];for(;o===" "||o===" ";)if(e<r+n)o=t[++e];else{do o=t[++e];while(o&&o!==`
11
11
  `);s=e,r=e+1,o=t[r]}return s}var _r=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Dr=t=>/^(%|---|\.\.\.)/m.test(t);function Af(t,e,n){if(!e||e<0)return!1;let s=e-n,r=t.length;if(r<=s)return!1;for(let o=0,i=0;o<r;++o)if(t[o]===`
12
12
  `){if(o-i>s)return!0;if(i=o+1,r-i<=s)return!1}return!0}function Ys(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:s}=e,r=e.options.doubleQuotedMinMultiLineLength,o=e.indent||(Dr(t)?" ":""),i="",a=0;for(let l=0,c=n[l];c;c=n[++l])if(c===" "&&n[l+1]==="\\"&&n[l+2]==="n"&&(i+=n.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(n[l+1]){case"u":{i+=n.slice(a,l);let f=n.substr(l+2,4);switch(f){case"0000":i+="\\0";break;case"0007":i+="\\a";break;case"000b":i+="\\v";break;case"001b":i+="\\e";break;case"0085":i+="\\N";break;case"00a0":i+="\\_";break;case"2028":i+="\\L";break;case"2029":i+="\\P";break;default:f.substr(0,2)==="00"?i+="\\x"+f.substr(2):i+=n.substr(l,6)}l+=5,a=l+1}break;case"n":if(s||n[l+2]==='"'||n.length<r)l+=1;else{for(i+=n.slice(a,l)+`
13
13
 
14
14
  `;n[l+2]==="\\"&&n[l+3]==="n"&&n[l+4]!=='"';)i+=`
15
- `,l+=2;i+=o,n[l+2]===" "&&(i+="\\"),l+=1,a=l+1}break;default:l+=1}return i=a?i+n.slice(a):n,s?i:qs(i,o,Us,_r(e,!1))}function ki(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
15
+ `,l+=2;i+=o,n[l+2]===" "&&(i+="\\"),l+=1,a=l+1}break;default:l+=1}return i=a?i+n.slice(a):n,s?i:qs(i,o,Us,_r(e,!1))}function Si(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
16
16
  `)||/[ \t]\n|\n[ \t]/.test(t))return Ys(t,e);let n=e.indent||(Dr(t)?" ":""),s="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
17
- ${n}`)+"'";return e.implicitKey?s:qs(s,n,wi,_r(e,!1))}function vs(t,e){let{singleQuote:n}=e.options,s;if(n===!1)s=Ys;else{let r=t.includes('"'),o=t.includes("'");r&&!o?s=ki:o&&!r?s=Ys:s=n?ki:Ys}return s(t,e)}var vi;try{vi=new RegExp(`(^|(?<!
17
+ ${n}`)+"'";return e.implicitKey?s:qs(s,n,vi,_r(e,!1))}function vs(t,e){let{singleQuote:n}=e.options,s;if(n===!1)s=Ys;else{let r=t.includes('"'),o=t.includes("'");r&&!o?s=Si:o&&!r?s=Ys:s=n?Si:Ys}return s(t,e)}var Mi;try{Mi=new RegExp(`(^|(?<!
18
18
  ))
19
19
  +(?!
20
- |$)`,"g")}catch{vi=/\n+(?!\n|$)/g}function Br({comment:t,type:e,value:n},s,r,o){let{blockQuote:i,commentString:a,lineWidth:l}=s.options;if(!i||/\n[\t ]+$/.test(n))return vs(n,s);let c=s.indent||(s.forceBlockIndent||Dr(n)?" ":""),f=i==="literal"?!0:i==="folded"||e===ge.BLOCK_FOLDED?!1:e===ge.BLOCK_LITERAL?!0:!Af(n,l,c.length);if(!n)return f?`|
20
+ |$)`,"g")}catch{Mi=/\n+(?!\n|$)/g}function Br({comment:t,type:e,value:n},s,r,o){let{blockQuote:i,commentString:a,lineWidth:l}=s.options;if(!i||/\n[\t ]+$/.test(n))return vs(n,s);let c=s.indent||(s.forceBlockIndent||Dr(n)?" ":""),f=i==="literal"?!0:i==="folded"||e===ge.BLOCK_FOLDED?!1:e===ge.BLOCK_LITERAL?!0:!Af(n,l,c.length);if(!n)return f?`|
21
21
  `:`>
22
- `;let u,d;for(d=n.length;d>0;--d){let O=n[d-1];if(O!==`
23
- `&&O!==" "&&O!==" ")break}let p=n.substring(d),h=p.indexOf(`
22
+ `;let u,d;for(d=n.length;d>0;--d){let R=n[d-1];if(R!==`
23
+ `&&R!==" "&&R!==" ")break}let p=n.substring(d),h=p.indexOf(`
24
24
  `);h===-1?u="-":n===p||h!==p.length-1?(u="+",o&&o()):u="",p&&(n=n.slice(0,-p.length),p[p.length-1]===`
25
- `&&(p=p.slice(0,-1)),p=p.replace(vi,`$&${c}`));let m=!1,y,I=-1;for(y=0;y<n.length;++y){let O=n[y];if(O===" ")m=!0;else if(O===`
26
- `)I=y;else break}let N=n.substring(0,I<y?I+1:y);N&&(n=n.substring(N.length),N=N.replace(/\n+/g,`$&${c}`));let $=(m?c?"2":"1":"")+u;if(t&&($+=" "+a(t.replace(/ ?[\r\n]+/g," ")),r&&r()),!f){let O=n.replace(/\n+/g,`
27
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),E=!1,x=_r(s,!0);i!=="folded"&&e!==ge.BLOCK_FOLDED&&(x.onOverflow=()=>{E=!0});let T=qs(`${N}${O}${p}`,c,Fr,x);if(!E)return`>${$}
25
+ `&&(p=p.slice(0,-1)),p=p.replace(Mi,`$&${c}`));let m=!1,y,I=-1;for(y=0;y<n.length;++y){let R=n[y];if(R===" ")m=!0;else if(R===`
26
+ `)I=y;else break}let N=n.substring(0,I<y?I+1:y);N&&(n=n.substring(N.length),N=N.replace(/\n+/g,`$&${c}`));let $=(m?c?"2":"1":"")+u;if(t&&($+=" "+a(t.replace(/ ?[\r\n]+/g," ")),r&&r()),!f){let R=n.replace(/\n+/g,`
27
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),E=!1,w=_r(s,!0);i!=="folded"&&e!==ge.BLOCK_FOLDED&&(w.onOverflow=()=>{E=!0});let T=qs(`${N}${R}${p}`,c,Fr,w);if(!E)return`>${$}
28
28
  ${c}${T}`}return n=n.replace(/\n+/g,`$&${c}`),`|${$}
29
29
  ${c}${N}${n}${p}`}function Nf(t,e,n,s){let{type:r,value:o}=t,{actualString:i,implicitKey:a,indent:l,indentStep:c,inFlow:f}=e;if(a&&o.includes(`
30
30
  `)||f&&/[[\]{},]/.test(o))return vs(o,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||f||!o.includes(`
31
31
  `)?vs(o,e):Br(t,e,n,s);if(!a&&!f&&r!==ge.PLAIN&&o.includes(`
32
32
  `))return Br(t,e,n,s);if(Dr(o)){if(l==="")return e.forceBlockIndent=!0,Br(t,e,n,s);if(a&&l===c)return vs(o,e)}let u=o.replace(/\n+/g,`$&
33
- ${l}`);if(i){let d=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(u),{compat:p,tags:h}=e.doc.schema;if(h.some(d)||p?.some(d))return vs(o,e)}return a?u:qs(u,l,wi,_r(e,!1))}function ss(t,e,n,s){let{implicitKey:r,inFlow:o}=e,i=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==ge.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(i.value)&&(a=ge.QUOTE_DOUBLE);let l=f=>{switch(f){case ge.BLOCK_FOLDED:case ge.BLOCK_LITERAL:return r||o?vs(i.value,e):Br(i,e,n,s);case ge.QUOTE_DOUBLE:return Ys(i.value,e);case ge.QUOTE_SINGLE:return ki(i.value,e);case ge.PLAIN:return Nf(i,e,n,s);default:return null}},c=l(a);if(c===null){let{defaultKeyType:f,defaultStringType:u}=e.options,d=r&&f||u;if(c=l(d),c===null)throw new Error(`Unsupported default string type ${d}`)}return c}function zr(t,e){let n=Object.assign({blockQuote:!0,commentString:ol,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),s;switch(n.collectionStyle){case"block":s=!1;break;case"flow":s=!0;break;default:s=null}return{anchors:new Set,doc:t,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:s,options:n}}function Pf(t,e){if(e.tag){let r=t.filter(o=>o.tag===e.tag);if(r.length>0)return r.find(o=>o.format===e.format)??r[0]}let n,s;if(Ne(e)){s=e.value;let r=t.filter(o=>o.identify?.(s));if(r.length>1){let o=r.filter(i=>i.test);o.length>0&&(r=o)}n=r.find(o=>o.format===e.format)??r.find(o=>!o.format)}else s=e,n=t.find(r=>r.nodeClass&&s instanceof r.nodeClass);if(!n){let r=s?.constructor?.name??(s===null?"null":typeof s);throw new Error(`Tag not resolved for ${r} value`)}return n}function Of(t,e,{anchors:n,doc:s}){if(!s.directives)return"";let r=[],o=(Ne(t)||Ge(t))&&t.anchor;o&&Cr(o)&&(n.add(o),r.push(`&${o}`));let i=t.tag??(e.default?null:e.tag);return i&&r.push(s.directives.tagString(i)),r.join(" ")}function Cn(t,e,n,s){if(Le(t))return t.toString(e,n,s);if(ln(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let r,o=De(t)?t:e.doc.createNode(t,{onTagObj:l=>r=l});r??(r=Pf(e.doc.schema.tags,o));let i=Of(o,r,e);i.length>0&&(e.indentAtStart=(e.indentAtStart??0)+i.length+1);let a=typeof r.stringify=="function"?r.stringify(o,e,n,s):Ne(o)?ss(o,e,n,s):o.toString(e,n,s);return i?Ne(o)||a[0]==="{"||a[0]==="["?`${i} ${a}`:`${i}
34
- ${e.indent}${a}`:a}function al({key:t,value:e},n,s,r){let{allNullValues:o,doc:i,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:u}}=n,d=De(t)&&t.comment||null;if(u){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(Ge(t)||!De(t)&&typeof t=="object"){let x="With simple keys, collection cannot be used as a key value";throw new Error(x)}}let p=!u&&(!t||d&&e==null&&!n.inFlow||Ge(t)||(Ne(t)?t.type===ge.BLOCK_FOLDED||t.type===ge.BLOCK_LITERAL:typeof t=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(u||!o),indent:a+l});let h=!1,m=!1,y=Cn(t,n,()=>h=!0,()=>m=!0);if(!p&&!n.inFlow&&y.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(n.inFlow){if(o||e==null)return h&&s&&s(),y===""?"?":p?`? ${y}`:y}else if(o&&!u||e==null&&p)return y=`? ${y}`,d&&!h?y+=kn(y,n.indent,c(d)):m&&r&&r(),y;h&&(d=null),p?(d&&(y+=kn(y,n.indent,c(d))),y=`? ${y}
35
- ${a}:`):(y=`${y}:`,d&&(y+=kn(y,n.indent,c(d))));let I,N,M;De(e)?(I=!!e.spaceBefore,N=e.commentBefore,M=e.comment):(I=!1,N=null,M=null,e&&typeof e=="object"&&(e=i.createNode(e))),n.implicitKey=!1,!p&&!d&&Ne(e)&&(n.indentAtStart=y.length+1),m=!1,!f&&l.length>=2&&!n.inFlow&&!p&&Dt(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let $=!1,O=Cn(e,n,()=>$=!0,()=>m=!0),E=" ";if(d||I||N){if(E=I?`
36
- `:"",N){let x=c(N);E+=`
37
- ${Xt(x,n.indent)}`}O===""&&!n.inFlow?E===`
33
+ ${l}`);if(i){let d=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(u),{compat:p,tags:h}=e.doc.schema;if(h.some(d)||p?.some(d))return vs(o,e)}return a?u:qs(u,l,vi,_r(e,!1))}function ss(t,e,n,s){let{implicitKey:r,inFlow:o}=e,i=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==ge.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(i.value)&&(a=ge.QUOTE_DOUBLE);let l=f=>{switch(f){case ge.BLOCK_FOLDED:case ge.BLOCK_LITERAL:return r||o?vs(i.value,e):Br(i,e,n,s);case ge.QUOTE_DOUBLE:return Ys(i.value,e);case ge.QUOTE_SINGLE:return Si(i.value,e);case ge.PLAIN:return Nf(i,e,n,s);default:return null}},c=l(a);if(c===null){let{defaultKeyType:f,defaultStringType:u}=e.options,d=r&&f||u;if(c=l(d),c===null)throw new Error(`Unsupported default string type ${d}`)}return c}function zr(t,e){let n=Object.assign({blockQuote:!0,commentString:al,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},t.schema.toStringOptions,e),s;switch(n.collectionStyle){case"block":s=!1;break;case"flow":s=!0;break;default:s=null}return{anchors:new Set,doc:t,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:s,options:n}}function Pf(t,e){if(e.tag){let r=t.filter(o=>o.tag===e.tag);if(r.length>0)return r.find(o=>o.format===e.format)??r[0]}let n,s;if(Ne(e)){s=e.value;let r=t.filter(o=>o.identify?.(s));if(r.length>1){let o=r.filter(i=>i.test);o.length>0&&(r=o)}n=r.find(o=>o.format===e.format)??r.find(o=>!o.format)}else s=e,n=t.find(r=>r.nodeClass&&s instanceof r.nodeClass);if(!n){let r=s?.constructor?.name??(s===null?"null":typeof s);throw new Error(`Tag not resolved for ${r} value`)}return n}function Rf(t,e,{anchors:n,doc:s}){if(!s.directives)return"";let r=[],o=(Ne(t)||Ge(t))&&t.anchor;o&&Cr(o)&&(n.add(o),r.push(`&${o}`));let i=t.tag??(e.default?null:e.tag);return i&&r.push(s.directives.tagString(i)),r.join(" ")}function Cn(t,e,n,s){if(Le(t))return t.toString(e,n,s);if(ln(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let r,o=De(t)?t:e.doc.createNode(t,{onTagObj:l=>r=l});r??(r=Pf(e.doc.schema.tags,o));let i=Rf(o,r,e);i.length>0&&(e.indentAtStart=(e.indentAtStart??0)+i.length+1);let a=typeof r.stringify=="function"?r.stringify(o,e,n,s):Ne(o)?ss(o,e,n,s):o.toString(e,n,s);return i?Ne(o)||a[0]==="{"||a[0]==="["?`${i} ${a}`:`${i}
34
+ ${e.indent}${a}`:a}function cl({key:t,value:e},n,s,r){let{allNullValues:o,doc:i,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:u}}=n,d=De(t)&&t.comment||null;if(u){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(Ge(t)||!De(t)&&typeof t=="object"){let w="With simple keys, collection cannot be used as a key value";throw new Error(w)}}let p=!u&&(!t||d&&e==null&&!n.inFlow||Ge(t)||(Ne(t)?t.type===ge.BLOCK_FOLDED||t.type===ge.BLOCK_LITERAL:typeof t=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(u||!o),indent:a+l});let h=!1,m=!1,y=Cn(t,n,()=>h=!0,()=>m=!0);if(!p&&!n.inFlow&&y.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(n.inFlow){if(o||e==null)return h&&s&&s(),y===""?"?":p?`? ${y}`:y}else if(o&&!u||e==null&&p)return y=`? ${y}`,d&&!h?y+=kn(y,n.indent,c(d)):m&&r&&r(),y;h&&(d=null),p?(d&&(y+=kn(y,n.indent,c(d))),y=`? ${y}
35
+ ${a}:`):(y=`${y}:`,d&&(y+=kn(y,n.indent,c(d))));let I,N,M;De(e)?(I=!!e.spaceBefore,N=e.commentBefore,M=e.comment):(I=!1,N=null,M=null,e&&typeof e=="object"&&(e=i.createNode(e))),n.implicitKey=!1,!p&&!d&&Ne(e)&&(n.indentAtStart=y.length+1),m=!1,!f&&l.length>=2&&!n.inFlow&&!p&&Dt(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let $=!1,R=Cn(e,n,()=>$=!0,()=>m=!0),E=" ";if(d||I||N){if(E=I?`
36
+ `:"",N){let w=c(N);E+=`
37
+ ${Xt(w,n.indent)}`}R===""&&!n.inFlow?E===`
38
38
  `&&M&&(E=`
39
39
 
40
40
  `):E+=`
41
- ${n.indent}`}else if(!p&&Ge(e)){let x=O[0],T=O.indexOf(`
42
- `),L=T!==-1,w=n.inFlow??e.flow??e.items.length===0;if(L||!w){let P=!1;if(L&&(x==="&"||x==="!")){let b=O.indexOf(" ");x==="&"&&b!==-1&&b<T&&O[b+1]==="!"&&(b=O.indexOf(" ",b+1)),(b===-1||T<b)&&(P=!0)}P||(E=`
43
- ${n.indent}`)}}else(O===""||O[0]===`
44
- `)&&(E="");return y+=E+O,n.inFlow?$&&s&&s():M&&!$?y+=kn(y,n.indent,c(M)):m&&r&&r(),y}function jr(t,e){(t==="debug"||t==="warn")&&console.warn(e)}var Kr="<<",cn={identify:t=>t===Kr||typeof t=="symbol"&&t.description===Kr,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new ge(Symbol(Kr)),{addToJSMap:Mi}),stringify:()=>Kr},ll=(t,e)=>(cn.identify(e)||Ne(e)&&(!e.type||e.type===ge.PLAIN)&&cn.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===cn.tag&&n.default);function Mi(t,e,n){let s=cl(t,n);if(Dt(s))for(let r of s.items)Si(t,e,r);else if(Array.isArray(s))for(let r of s)Si(t,e,r);else Si(t,e,s)}function Si(t,e,n){let s=cl(t,n);if(!_t(s))throw new Error("Merge sources must be maps or map aliases");let r=s.toJSON(null,t,Map);for(let[o,i]of r)e instanceof Map?e.has(o)||e.set(o,i):e instanceof Set?e.add(o):Object.prototype.hasOwnProperty.call(e,o)||Object.defineProperty(e,o,{value:i,writable:!0,enumerable:!0,configurable:!0});return e}function cl(t,e){return t&&ln(e)?e.resolve(t.doc,t):e}function Vr(t,e,{key:n,value:s}){if(De(n)&&n.addToJSMap)n.addToJSMap(t,e,s);else if(ll(t,n))Mi(t,e,s);else{let r=St(n,"",t);if(e instanceof Map)e.set(r,St(s,r,t));else if(e instanceof Set)e.add(r);else{let o=Rf(n,r,t),i=St(s,o,t);o in e?Object.defineProperty(e,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):e[o]=i}}return e}function Rf(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(De(t)&&n?.doc){let s=zr(n.doc,{});s.anchors=new Set;for(let o of n.anchors.keys())s.anchors.add(o.anchor);s.inFlow=!0,s.inStringifyKey=!0;let r=t.toString(s);if(!n.mapKeyWarned){let o=JSON.stringify(r);o.length>40&&(o=o.substring(0,36)+'..."'),jr(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(e)}function Ss(t,e,n){let s=Rn(t,void 0,n),r=Rn(e,void 0,n);return new gt(s,r)}var gt=class t{constructor(e,n=null){Object.defineProperty(this,Ft,{value:bi}),this.key=e,this.value=n}clone(e){let{key:n,value:s}=this;return De(n)&&(n=n.clone(e)),De(s)&&(s=s.clone(e)),new t(n,s)}toJSON(e,n){let s=n?.mapAsMap?new Map:{};return Vr(n,s,this)}toString(e,n,s){return e?.doc?al(this,e,n,s):JSON.stringify(this)}};function Ur(t,e,n){return(e.inFlow??t.flow?Lf:Cf)(t,e,n)}function Cf({comment:t,items:e},n,{blockItemPrefix:s,flowChars:r,itemIndent:o,onChompKeep:i,onComment:a}){let{indent:l,options:{commentString:c}}=n,f=Object.assign({},n,{indent:o,type:null}),u=!1,d=[];for(let h=0;h<e.length;++h){let m=e[h],y=null;if(De(m))!u&&m.spaceBefore&&d.push(""),Gr(n,d,m.commentBefore,u),m.comment&&(y=m.comment);else if(Le(m)){let N=De(m.key)?m.key:null;N&&(!u&&N.spaceBefore&&d.push(""),Gr(n,d,N.commentBefore,u))}u=!1;let I=Cn(m,f,()=>y=null,()=>u=!0);y&&(I+=kn(I,o,c(y))),u&&y&&(u=!1),d.push(s+I)}let p;if(d.length===0)p=r.start+r.end;else{p=d[0];for(let h=1;h<d.length;++h){let m=d[h];p+=m?`
41
+ ${n.indent}`}else if(!p&&Ge(e)){let w=R[0],T=R.indexOf(`
42
+ `),L=T!==-1,x=n.inFlow??e.flow??e.items.length===0;if(L||!x){let P=!1;if(L&&(w==="&"||w==="!")){let b=R.indexOf(" ");w==="&"&&b!==-1&&b<T&&R[b+1]==="!"&&(b=R.indexOf(" ",b+1)),(b===-1||T<b)&&(P=!0)}P||(E=`
43
+ ${n.indent}`)}}else(R===""||R[0]===`
44
+ `)&&(E="");return y+=E+R,n.inFlow?$&&s&&s():M&&!$?y+=kn(y,n.indent,c(M)):m&&r&&r(),y}function jr(t,e){(t==="debug"||t==="warn")&&console.warn(e)}var Vr="<<",cn={identify:t=>t===Vr||typeof t=="symbol"&&t.description===Vr,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new ge(Symbol(Vr)),{addToJSMap:Ei}),stringify:()=>Vr},fl=(t,e)=>(cn.identify(e)||Ne(e)&&(!e.type||e.type===ge.PLAIN)&&cn.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===cn.tag&&n.default);function Ei(t,e,n){let s=ul(t,n);if(Dt(s))for(let r of s.items)$i(t,e,r);else if(Array.isArray(s))for(let r of s)$i(t,e,r);else $i(t,e,s)}function $i(t,e,n){let s=ul(t,n);if(!_t(s))throw new Error("Merge sources must be maps or map aliases");let r=s.toJSON(null,t,Map);for(let[o,i]of r)e instanceof Map?e.has(o)||e.set(o,i):e instanceof Set?e.add(o):Object.prototype.hasOwnProperty.call(e,o)||Object.defineProperty(e,o,{value:i,writable:!0,enumerable:!0,configurable:!0});return e}function ul(t,e){return t&&ln(e)?e.resolve(t.doc,t):e}function Kr(t,e,{key:n,value:s}){if(De(n)&&n.addToJSMap)n.addToJSMap(t,e,s);else if(fl(t,n))Ei(t,e,s);else{let r=St(n,"",t);if(e instanceof Map)e.set(r,St(s,r,t));else if(e instanceof Set)e.add(r);else{let o=Of(n,r,t),i=St(s,o,t);o in e?Object.defineProperty(e,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):e[o]=i}}return e}function Of(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(De(t)&&n?.doc){let s=zr(n.doc,{});s.anchors=new Set;for(let o of n.anchors.keys())s.anchors.add(o.anchor);s.inFlow=!0,s.inStringifyKey=!0;let r=t.toString(s);if(!n.mapKeyWarned){let o=JSON.stringify(r);o.length>40&&(o=o.substring(0,36)+'..."'),jr(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(e)}function Ss(t,e,n){let s=On(t,void 0,n),r=On(e,void 0,n);return new gt(s,r)}var gt=class t{constructor(e,n=null){Object.defineProperty(this,Ft,{value:xi}),this.key=e,this.value=n}clone(e){let{key:n,value:s}=this;return De(n)&&(n=n.clone(e)),De(s)&&(s=s.clone(e)),new t(n,s)}toJSON(e,n){let s=n?.mapAsMap?new Map:{};return Kr(n,s,this)}toString(e,n,s){return e?.doc?cl(this,e,n,s):JSON.stringify(this)}};function Ur(t,e,n){return(e.inFlow??t.flow?Lf:Cf)(t,e,n)}function Cf({comment:t,items:e},n,{blockItemPrefix:s,flowChars:r,itemIndent:o,onChompKeep:i,onComment:a}){let{indent:l,options:{commentString:c}}=n,f=Object.assign({},n,{indent:o,type:null}),u=!1,d=[];for(let h=0;h<e.length;++h){let m=e[h],y=null;if(De(m))!u&&m.spaceBefore&&d.push(""),Gr(n,d,m.commentBefore,u),m.comment&&(y=m.comment);else if(Le(m)){let N=De(m.key)?m.key:null;N&&(!u&&N.spaceBefore&&d.push(""),Gr(n,d,N.commentBefore,u))}u=!1;let I=Cn(m,f,()=>y=null,()=>u=!0);y&&(I+=kn(I,o,c(y))),u&&y&&(u=!1),d.push(s+I)}let p;if(d.length===0)p=r.start+r.end;else{p=d[0];for(let h=1;h<d.length;++h){let m=d[h];p+=m?`
45
45
  ${l}${m}`:`
46
46
  `}}return t?(p+=`
47
47
  `+Xt(c(t),l),a&&a()):u&&i&&i(),p}function Lf({items:t},e,{flowChars:n,itemIndent:s}){let{indent:r,indentStep:o,flowCollectionPadding:i,options:{commentString:a}}=e;s+=o;let l=Object.assign({},e,{indent:s,inFlow:!0,type:null}),c=!1,f=0,u=[];for(let h=0;h<t.length;++h){let m=t[h],y=null;if(De(m))m.spaceBefore&&u.push(""),Gr(e,u,m.commentBefore,!1),m.comment&&(y=m.comment);else if(Le(m)){let N=De(m.key)?m.key:null;N&&(N.spaceBefore&&u.push(""),Gr(e,u,N.commentBefore,!1),N.comment&&(c=!0));let M=De(m.value)?m.value:null;M?(M.comment&&(y=M.comment),M.commentBefore&&(c=!0)):m.value==null&&N?.comment&&(y=N.comment)}y&&(c=!0);let I=Cn(m,l,()=>y=null);c||(c=u.length>f||I.includes(`
48
48
  `)),h<t.length-1?I+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(c||(c=u.reduce((N,M)=>N+M.length+2,2)+(I.length+2)>e.options.lineWidth)),c&&(I+=",")),y&&(I+=kn(I,s,a(y))),u.push(I),f=u.length}let{start:d,end:p}=n;if(u.length===0)return d+p;if(!c){let h=u.reduce((m,y)=>m+y.length+2,2);c=e.options.lineWidth>0&&h>e.options.lineWidth}if(c){let h=d;for(let m of u)h+=m?`
49
49
  ${o}${r}${m}`:`
50
50
  `;return`${h}
51
- ${r}${p}`}else return`${d}${i}${u.join(" ")}${i}${p}`}function Gr({indent:t,options:{commentString:e}},n,s,r){if(s&&r&&(s=s.replace(/^\n+/,"")),s){let o=Xt(e(s),t);n.push(o.trimStart())}}function Kn(t,e){let n=Ne(e)?e.value:e;for(let s of t)if(Le(s)&&(s.key===e||s.key===n||Ne(s.key)&&s.key.value===n))return s}var xt=class extends ws{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(an,e),this.items=[]}static from(e,n,s){let{keepUndefined:r,replacer:o}=s,i=new this(e),a=(l,c)=>{if(typeof o=="function")c=o.call(n,l,c);else if(Array.isArray(o)&&!o.includes(l))return;(c!==void 0||r)&&i.items.push(Ss(l,c,s))};if(n instanceof Map)for(let[l,c]of n)a(l,c);else if(n&&typeof n=="object")for(let l of Object.keys(n))a(l,n[l]);return typeof e.sortMapEntries=="function"&&i.items.sort(e.sortMapEntries),i}add(e,n){let s;Le(e)?s=e:!e||typeof e!="object"||!("key"in e)?s=new gt(e,e?.value):s=new gt(e.key,e.value);let r=Kn(this.items,s.key),o=this.schema?.sortMapEntries;if(r){if(!n)throw new Error(`Key ${s.key} already set`);Ne(r.value)&&Ir(s.value)?r.value.value=s.value:r.value=s.value}else if(o){let i=this.items.findIndex(a=>o(s,a)<0);i===-1?this.items.push(s):this.items.splice(i,0,s)}else this.items.push(s)}delete(e){let n=Kn(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let r=Kn(this.items,e)?.value;return(!n&&Ne(r)?r.value:r)??void 0}has(e){return!!Kn(this.items,e)}set(e,n){this.add(new gt(e,n),!0)}toJSON(e,n,s){let r=s?new s:n?.mapAsMap?new Map:{};n?.onCreate&&n.onCreate(r);for(let o of this.items)Vr(n,r,o);return r}toString(e,n,s){if(!e)return JSON.stringify(this);for(let r of this.items)if(!Le(r))throw new Error(`Map items must all be pairs; found ${JSON.stringify(r)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Ur(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:s,onComment:n})}};var fn={collection:"map",default:!0,nodeClass:xt,tag:"tag:yaml.org,2002:map",resolve(t,e){return _t(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>xt.from(t,e,n)};var Ot=class extends ws{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Pn,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=qr(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let s=qr(e);if(typeof s!="number")return;let r=this.items[s];return!n&&Ne(r)?r.value:r}has(e){let n=qr(e);return typeof n=="number"&&n<this.items.length}set(e,n){let s=qr(e);if(typeof s!="number")throw new Error(`Expected a valid index, not ${e}.`);let r=this.items[s];Ne(r)&&Ir(n)?r.value=n:this.items[s]=n}toJSON(e,n){let s=[];n?.onCreate&&n.onCreate(s);let r=0;for(let o of this.items)s.push(St(o,String(r++),n));return s}toString(e,n,s){return e?Ur(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:s,onComment:n}):JSON.stringify(this)}static from(e,n,s){let{replacer:r}=s,o=new this(e);if(n&&Symbol.iterator in Object(n)){let i=0;for(let a of n){if(typeof r=="function"){let l=n instanceof Set?a:String(i++);a=r.call(n,l,a)}o.items.push(Rn(a,void 0,s))}}return o}};function qr(t){let e=Ne(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}var un={collection:"seq",default:!0,nodeClass:Ot,tag:"tag:yaml.org,2002:seq",resolve(t,e){return Dt(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>Ot.from(t,e,n)};var Vn={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,n,s){return e=Object.assign({actualString:!0},e),ss(t,e,n,s)}};var rs={identify:t=>t==null,createNode:()=>new ge(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new ge(null),stringify:({source:t},e)=>typeof t=="string"&&rs.test.test(t)?t:e.options.nullStr};var Hs={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new ge(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&Hs.test.test(t)){let s=t[0]==="t"||t[0]==="T";if(e===s)return t}return e?n.options.trueStr:n.options.falseStr}};function Rt({format:t,minFractionDigits:e,tag:n,value:s}){if(typeof s=="bigint")return String(s);let r=typeof s=="number"?s:Number(s);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let o=Object.is(s,-0)?"-0":JSON.stringify(s);if(!t&&e&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let i=o.indexOf(".");i<0&&(i=o.length,o+=".");let a=e-(o.length-i-1);for(;a-- >0;)o+="0"}return o}var Yr={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Rt},Hr={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Rt(t)}},Wr={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new ge(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:Rt};var Jr=t=>typeof t=="bigint"||Number.isInteger(t),$i=(t,e,n,{intAsBigInt:s})=>s?BigInt(t):parseInt(t.substring(e),n);function fl(t,e,n){let{value:s}=t;return Jr(s)&&s>=0?n+s.toString(e):Rt(t)}var Xr={identify:t=>Jr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>$i(t,2,8,n),stringify:t=>fl(t,8,"0o")},Qr={identify:Jr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>$i(t,0,10,n),stringify:Rt},Zr={identify:t=>Jr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>$i(t,2,16,n),stringify:t=>fl(t,16,"0x")};var ul=[fn,un,Vn,rs,Hs,Xr,Qr,Zr,Yr,Hr,Wr];function dl(t){return typeof t=="bigint"||Number.isInteger(t)}var eo=({value:t})=>JSON.stringify(t),If=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:eo},{identify:t=>t==null,createNode:()=>new ge(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:eo},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:eo},{identify:dl,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:n})=>n?BigInt(t):parseInt(t,10),stringify:({value:t})=>dl(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:eo}],Ff={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},pl=[fn,un].concat(If,Ff);var Ws={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof atob=="function"){let n=atob(t.replace(/[\n\r]/g,"")),s=new Uint8Array(n.length);for(let r=0;r<n.length;++r)s[r]=n.charCodeAt(r);return s}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:n},s,r,o){if(!n)return"";let i=n,a;if(typeof btoa=="function"){let l="";for(let c=0;c<i.length;++c)l+=String.fromCharCode(i[c]);a=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=ge.BLOCK_LITERAL),e!==ge.QUOTE_DOUBLE){let l=Math.max(s.options.lineWidth-s.indent.length,s.options.minContentWidth),c=Math.ceil(a.length/l),f=new Array(c);for(let u=0,d=0;u<c;++u,d+=l)f[u]=a.substr(d,l);a=f.join(e===ge.BLOCK_LITERAL?`
52
- `:" ")}return ss({comment:t,type:e,value:a},s,r,o)}};function Ei(t,e){if(Dt(t))for(let n=0;n<t.items.length;++n){let s=t.items[n];if(!Le(s)){if(_t(s)){s.items.length>1&&e("Each pair must have its own sequence indicator");let r=s.items[0]||new gt(new ge(null));if(s.commentBefore&&(r.key.commentBefore=r.key.commentBefore?`${s.commentBefore}
51
+ ${r}${p}`}else return`${d}${i}${u.join(" ")}${i}${p}`}function Gr({indent:t,options:{commentString:e}},n,s,r){if(s&&r&&(s=s.replace(/^\n+/,"")),s){let o=Xt(e(s),t);n.push(o.trimStart())}}function Vn(t,e){let n=Ne(e)?e.value:e;for(let s of t)if(Le(s)&&(s.key===e||s.key===n||Ne(s.key)&&s.key.value===n))return s}var xt=class extends ws{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(an,e),this.items=[]}static from(e,n,s){let{keepUndefined:r,replacer:o}=s,i=new this(e),a=(l,c)=>{if(typeof o=="function")c=o.call(n,l,c);else if(Array.isArray(o)&&!o.includes(l))return;(c!==void 0||r)&&i.items.push(Ss(l,c,s))};if(n instanceof Map)for(let[l,c]of n)a(l,c);else if(n&&typeof n=="object")for(let l of Object.keys(n))a(l,n[l]);return typeof e.sortMapEntries=="function"&&i.items.sort(e.sortMapEntries),i}add(e,n){let s;Le(e)?s=e:!e||typeof e!="object"||!("key"in e)?s=new gt(e,e?.value):s=new gt(e.key,e.value);let r=Vn(this.items,s.key),o=this.schema?.sortMapEntries;if(r){if(!n)throw new Error(`Key ${s.key} already set`);Ne(r.value)&&Ir(s.value)?r.value.value=s.value:r.value=s.value}else if(o){let i=this.items.findIndex(a=>o(s,a)<0);i===-1?this.items.push(s):this.items.splice(i,0,s)}else this.items.push(s)}delete(e){let n=Vn(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let r=Vn(this.items,e)?.value;return(!n&&Ne(r)?r.value:r)??void 0}has(e){return!!Vn(this.items,e)}set(e,n){this.add(new gt(e,n),!0)}toJSON(e,n,s){let r=s?new s:n?.mapAsMap?new Map:{};n?.onCreate&&n.onCreate(r);for(let o of this.items)Kr(n,r,o);return r}toString(e,n,s){if(!e)return JSON.stringify(this);for(let r of this.items)if(!Le(r))throw new Error(`Map items must all be pairs; found ${JSON.stringify(r)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Ur(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:s,onComment:n})}};var fn={collection:"map",default:!0,nodeClass:xt,tag:"tag:yaml.org,2002:map",resolve(t,e){return _t(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>xt.from(t,e,n)};var Rt=class extends ws{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Pn,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=qr(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let s=qr(e);if(typeof s!="number")return;let r=this.items[s];return!n&&Ne(r)?r.value:r}has(e){let n=qr(e);return typeof n=="number"&&n<this.items.length}set(e,n){let s=qr(e);if(typeof s!="number")throw new Error(`Expected a valid index, not ${e}.`);let r=this.items[s];Ne(r)&&Ir(n)?r.value=n:this.items[s]=n}toJSON(e,n){let s=[];n?.onCreate&&n.onCreate(s);let r=0;for(let o of this.items)s.push(St(o,String(r++),n));return s}toString(e,n,s){return e?Ur(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:s,onComment:n}):JSON.stringify(this)}static from(e,n,s){let{replacer:r}=s,o=new this(e);if(n&&Symbol.iterator in Object(n)){let i=0;for(let a of n){if(typeof r=="function"){let l=n instanceof Set?a:String(i++);a=r.call(n,l,a)}o.items.push(On(a,void 0,s))}}return o}};function qr(t){let e=Ne(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}var un={collection:"seq",default:!0,nodeClass:Rt,tag:"tag:yaml.org,2002:seq",resolve(t,e){return Dt(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>Rt.from(t,e,n)};var Kn={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,n,s){return e=Object.assign({actualString:!0},e),ss(t,e,n,s)}};var rs={identify:t=>t==null,createNode:()=>new ge(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new ge(null),stringify:({source:t},e)=>typeof t=="string"&&rs.test.test(t)?t:e.options.nullStr};var Hs={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new ge(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&Hs.test.test(t)){let s=t[0]==="t"||t[0]==="T";if(e===s)return t}return e?n.options.trueStr:n.options.falseStr}};function Ot({format:t,minFractionDigits:e,tag:n,value:s}){if(typeof s=="bigint")return String(s);let r=typeof s=="number"?s:Number(s);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let o=Object.is(s,-0)?"-0":JSON.stringify(s);if(!t&&e&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let i=o.indexOf(".");i<0&&(i=o.length,o+=".");let a=e-(o.length-i-1);for(;a-- >0;)o+="0"}return o}var Yr={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Ot},Hr={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Ot(t)}},Wr={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(t){let e=new ge(parseFloat(t)),n=t.indexOf(".");return n!==-1&&t[t.length-1]==="0"&&(e.minFractionDigits=t.length-n-1),e},stringify:Ot};var Jr=t=>typeof t=="bigint"||Number.isInteger(t),Ti=(t,e,n,{intAsBigInt:s})=>s?BigInt(t):parseInt(t.substring(e),n);function dl(t,e,n){let{value:s}=t;return Jr(s)&&s>=0?n+s.toString(e):Ot(t)}var Xr={identify:t=>Jr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(t,e,n)=>Ti(t,2,8,n),stringify:t=>dl(t,8,"0o")},Qr={identify:Jr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(t,e,n)=>Ti(t,0,10,n),stringify:Ot},Zr={identify:t=>Jr(t)&&t>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(t,e,n)=>Ti(t,2,16,n),stringify:t=>dl(t,16,"0x")};var pl=[fn,un,Kn,rs,Hs,Xr,Qr,Zr,Yr,Hr,Wr];function ml(t){return typeof t=="bigint"||Number.isInteger(t)}var eo=({value:t})=>JSON.stringify(t),If=[{identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify:eo},{identify:t=>t==null,createNode:()=>new ge(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:eo},{identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:t=>t==="true",stringify:eo},{identify:ml,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(t,e,{intAsBigInt:n})=>n?BigInt(t):parseInt(t,10),stringify:({value:t})=>ml(t)?t.toString():JSON.stringify(t)},{identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:t=>parseFloat(t),stringify:eo}],Ff={default:!0,tag:"",test:/^/,resolve(t,e){return e(`Unresolved plain scalar ${JSON.stringify(t)}`),t}},hl=[fn,un].concat(If,Ff);var Ws={identify:t=>t instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(t,e){if(typeof atob=="function"){let n=atob(t.replace(/[\n\r]/g,"")),s=new Uint8Array(n.length);for(let r=0;r<n.length;++r)s[r]=n.charCodeAt(r);return s}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),t},stringify({comment:t,type:e,value:n},s,r,o){if(!n)return"";let i=n,a;if(typeof btoa=="function"){let l="";for(let c=0;c<i.length;++c)l+=String.fromCharCode(i[c]);a=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=ge.BLOCK_LITERAL),e!==ge.QUOTE_DOUBLE){let l=Math.max(s.options.lineWidth-s.indent.length,s.options.minContentWidth),c=Math.ceil(a.length/l),f=new Array(c);for(let u=0,d=0;u<c;++u,d+=l)f[u]=a.substr(d,l);a=f.join(e===ge.BLOCK_LITERAL?`
52
+ `:" ")}return ss({comment:t,type:e,value:a},s,r,o)}};function Ai(t,e){if(Dt(t))for(let n=0;n<t.items.length;++n){let s=t.items[n];if(!Le(s)){if(_t(s)){s.items.length>1&&e("Each pair must have its own sequence indicator");let r=s.items[0]||new gt(new ge(null));if(s.commentBefore&&(r.key.commentBefore=r.key.commentBefore?`${s.commentBefore}
53
53
  ${r.key.commentBefore}`:s.commentBefore),s.comment){let o=r.value??r.key;o.comment=o.comment?`${s.comment}
54
- ${o.comment}`:s.comment}s=r}t.items[n]=Le(s)?s:new gt(s)}}else e("Expected a sequence for this tag");return t}function Ti(t,e,n){let{replacer:s}=n,r=new Ot(t);r.tag="tag:yaml.org,2002:pairs";let o=0;if(e&&Symbol.iterator in Object(e))for(let i of e){typeof s=="function"&&(i=s.call(e,String(o++),i));let a,l;if(Array.isArray(i))if(i.length===2)a=i[0],l=i[1];else throw new TypeError(`Expected [key, value] tuple: ${i}`);else if(i&&i instanceof Object){let c=Object.keys(i);if(c.length===1)a=c[0],l=i[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=i;r.items.push(Ss(a,l,n))}return r}var Js={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ei,createNode:Ti};var Ms=class t extends Ot{constructor(){super(),this.add=xt.prototype.add.bind(this),this.delete=xt.prototype.delete.bind(this),this.get=xt.prototype.get.bind(this),this.has=xt.prototype.has.bind(this),this.set=xt.prototype.set.bind(this),this.tag=t.tag}toJSON(e,n){if(!n)return super.toJSON(e);let s=new Map;n?.onCreate&&n.onCreate(s);for(let r of this.items){let o,i;if(Le(r)?(o=St(r.key,"",n),i=St(r.value,o,n)):o=St(r,"",n),s.has(o))throw new Error("Ordered maps must not include duplicate keys");s.set(o,i)}return s}static from(e,n,s){let r=Ti(e,n,s),o=new this;return o.items=r.items,o}};Ms.tag="tag:yaml.org,2002:omap";var Xs={collection:"seq",identify:t=>t instanceof Map,nodeClass:Ms,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=Ei(t,e),s=[];for(let{key:r}of n.items)Ne(r)&&(s.includes(r.value)?e(`Ordered maps must not include duplicate keys: ${r.value}`):s.push(r.value));return Object.assign(new Ms,n)},createNode:(t,e,n)=>Ms.from(t,e,n)};function ml({value:t,source:e},n){return e&&(t?Ai:Ni).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var Ai={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new ge(!0),stringify:ml},Ni={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new ge(!1),stringify:ml};var hl={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Rt},gl={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Rt(t)}},bl={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new ge(parseFloat(t.replace(/_/g,""))),n=t.indexOf(".");if(n!==-1){let s=t.substring(n+1).replace(/_/g,"");s[s.length-1]==="0"&&(e.minFractionDigits=s.length)}return e},stringify:Rt};var Qs=t=>typeof t=="bigint"||Number.isInteger(t);function to(t,e,n,{intAsBigInt:s}){let r=t[0];if((r==="-"||r==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),s){switch(n){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let i=BigInt(t);return r==="-"?BigInt(-1)*i:i}let o=parseInt(t,n);return r==="-"?-1*o:o}function Pi(t,e,n){let{value:s}=t;if(Qs(s)){let r=s.toString(e);return s<0?"-"+n+r.substr(1):n+r}return Rt(t)}var yl={identify:Qs,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>to(t,2,2,n),stringify:t=>Pi(t,2,"0b")},xl={identify:Qs,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>to(t,1,8,n),stringify:t=>Pi(t,8,"0")},wl={identify:Qs,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>to(t,0,10,n),stringify:Rt},kl={identify:Qs,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>to(t,2,16,n),stringify:t=>Pi(t,16,"0x")};var $s=class t extends xt{constructor(e){super(e),this.tag=t.tag}add(e){let n;Le(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new gt(e.key,null):n=new gt(e,null),Kn(this.items,n.key)||this.items.push(n)}get(e,n){let s=Kn(this.items,e);return!n&&Le(s)?Ne(s.key)?s.key.value:s.key:s}set(e,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);let s=Kn(this.items,e);s&&!n?this.items.splice(this.items.indexOf(s),1):!s&&n&&this.items.push(new gt(e))}toJSON(e,n){return super.toJSON(e,n,Set)}toString(e,n,s){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),n,s);throw new Error("Set items must all have null values")}static from(e,n,s){let{replacer:r}=s,o=new this(e);if(n&&Symbol.iterator in Object(n))for(let i of n)typeof r=="function"&&(i=r.call(n,i,i)),o.items.push(Ss(i,null,s));return o}};$s.tag="tag:yaml.org,2002:set";var Zs={collection:"map",identify:t=>t instanceof Set,nodeClass:$s,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>$s.from(t,e,n),resolve(t,e){if(_t(t)){if(t.hasAllNullValues(!0))return Object.assign(new $s,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};function Oi(t,e){let n=t[0],s=n==="-"||n==="+"?t.substring(1):t,r=i=>e?BigInt(i):Number(i),o=s.replace(/_/g,"").split(":").reduce((i,a)=>i*r(60)+r(a),r(0));return n==="-"?r(-1)*o:o}function vl(t){let{value:e}=t,n=i=>i;if(typeof e=="bigint")n=i=>BigInt(i);else if(isNaN(e)||!isFinite(e))return Rt(t);let s="";e<0&&(s="-",e*=n(-1));let r=n(60),o=[e%r];return e<60?o.unshift(0):(e=(e-o[0])/r,o.unshift(e%r),e>=60&&(e=(e-o[0])/r,o.unshift(e))),s+o.map(i=>String(i).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var no={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:n})=>Oi(t,n),stringify:vl},so={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>Oi(t,!1),stringify:vl},Es={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(Es.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,s,r,o,i,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(n,s-1,r,o||0,i||0,a||0,l),f=e[8];if(f&&f!=="Z"){let u=Oi(f,!1);Math.abs(u)<30&&(u*=60),c-=6e4*u}return new Date(c)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};var Ri=[fn,un,Vn,rs,Ai,Ni,yl,xl,wl,kl,hl,gl,bl,Ws,cn,Xs,Js,Zs,no,so,Es];var Sl=new Map([["core",ul],["failsafe",[fn,un,Vn]],["json",pl],["yaml11",Ri],["yaml-1.1",Ri]]),Ml={binary:Ws,bool:Hs,float:Wr,floatExp:Hr,floatNaN:Yr,floatTime:so,int:Qr,intHex:Zr,intOct:Xr,intTime:no,map:fn,merge:cn,null:rs,omap:Xs,pairs:Js,seq:un,set:Zs,timestamp:Es},$l={"tag:yaml.org,2002:binary":Ws,"tag:yaml.org,2002:merge":cn,"tag:yaml.org,2002:omap":Xs,"tag:yaml.org,2002:pairs":Js,"tag:yaml.org,2002:set":Zs,"tag:yaml.org,2002:timestamp":Es};function ro(t,e,n){let s=Sl.get(e);if(s&&!t)return n&&!s.includes(cn)?s.concat(cn):s.slice();let r=s;if(!r)if(Array.isArray(t))r=[];else{let o=Array.from(Sl.keys()).filter(i=>i!=="yaml11").map(i=>JSON.stringify(i)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${o} or define customTags array`)}if(Array.isArray(t))for(let o of t)r=r.concat(o);else typeof t=="function"&&(r=t(r.slice()));return n&&(r=r.concat(cn)),r.reduce((o,i)=>{let a=typeof i=="string"?Ml[i]:i;if(!a){let l=JSON.stringify(i),c=Object.keys(Ml).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return o.includes(a)||o.push(a),o},[])}var Bf=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,er=class t{constructor({compat:e,customTags:n,merge:s,resolveKnownTags:r,schema:o,sortMapEntries:i,toStringDefaults:a}){this.compat=Array.isArray(e)?ro(e,"compat"):e?ro(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=r?$l:{},this.tags=ro(n,this.name,s),this.toStringOptions=a??null,Object.defineProperty(this,an,{value:fn}),Object.defineProperty(this,Gt,{value:Vn}),Object.defineProperty(this,Pn,{value:un}),this.sortMapEntries=typeof i=="function"?i:i===!0?Bf:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};function El(t,e){let n=[],s=e.directives===!0;if(e.directives!==!1&&t.directives){let l=t.directives.toString(t);l?(n.push(l),s=!0):t.directives.docStart&&(s=!0)}s&&n.push("---");let r=zr(t,e),{commentString:o}=r.options;if(t.commentBefore){n.length!==1&&n.unshift("");let l=o(t.commentBefore);n.unshift(Xt(l,""))}let i=!1,a=null;if(t.contents){if(De(t.contents)){if(t.contents.spaceBefore&&s&&n.push(""),t.contents.commentBefore){let f=o(t.contents.commentBefore);n.push(Xt(f,""))}r.forceBlockIndent=!!t.comment,a=t.contents.comment}let l=a?void 0:()=>i=!0,c=Cn(t.contents,r,()=>a=null,l);a&&(c+=kn(c,"",o(a))),(c[0]==="|"||c[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(Cn(t.contents,r));if(t.directives?.docEnd)if(t.comment){let l=o(t.comment);l.includes(`
54
+ ${o.comment}`:s.comment}s=r}t.items[n]=Le(s)?s:new gt(s)}}else e("Expected a sequence for this tag");return t}function Ni(t,e,n){let{replacer:s}=n,r=new Rt(t);r.tag="tag:yaml.org,2002:pairs";let o=0;if(e&&Symbol.iterator in Object(e))for(let i of e){typeof s=="function"&&(i=s.call(e,String(o++),i));let a,l;if(Array.isArray(i))if(i.length===2)a=i[0],l=i[1];else throw new TypeError(`Expected [key, value] tuple: ${i}`);else if(i&&i instanceof Object){let c=Object.keys(i);if(c.length===1)a=c[0],l=i[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=i;r.items.push(Ss(a,l,n))}return r}var Js={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ai,createNode:Ni};var Ms=class t extends Rt{constructor(){super(),this.add=xt.prototype.add.bind(this),this.delete=xt.prototype.delete.bind(this),this.get=xt.prototype.get.bind(this),this.has=xt.prototype.has.bind(this),this.set=xt.prototype.set.bind(this),this.tag=t.tag}toJSON(e,n){if(!n)return super.toJSON(e);let s=new Map;n?.onCreate&&n.onCreate(s);for(let r of this.items){let o,i;if(Le(r)?(o=St(r.key,"",n),i=St(r.value,o,n)):o=St(r,"",n),s.has(o))throw new Error("Ordered maps must not include duplicate keys");s.set(o,i)}return s}static from(e,n,s){let r=Ni(e,n,s),o=new this;return o.items=r.items,o}};Ms.tag="tag:yaml.org,2002:omap";var Xs={collection:"seq",identify:t=>t instanceof Map,nodeClass:Ms,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=Ai(t,e),s=[];for(let{key:r}of n.items)Ne(r)&&(s.includes(r.value)?e(`Ordered maps must not include duplicate keys: ${r.value}`):s.push(r.value));return Object.assign(new Ms,n)},createNode:(t,e,n)=>Ms.from(t,e,n)};function gl({value:t,source:e},n){return e&&(t?Pi:Ri).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var Pi={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new ge(!0),stringify:gl},Ri={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new ge(!1),stringify:gl};var bl={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Ot},yl={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():Ot(t)}},xl={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new ge(parseFloat(t.replace(/_/g,""))),n=t.indexOf(".");if(n!==-1){let s=t.substring(n+1).replace(/_/g,"");s[s.length-1]==="0"&&(e.minFractionDigits=s.length)}return e},stringify:Ot};var Qs=t=>typeof t=="bigint"||Number.isInteger(t);function to(t,e,n,{intAsBigInt:s}){let r=t[0];if((r==="-"||r==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),s){switch(n){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let i=BigInt(t);return r==="-"?BigInt(-1)*i:i}let o=parseInt(t,n);return r==="-"?-1*o:o}function Oi(t,e,n){let{value:s}=t;if(Qs(s)){let r=s.toString(e);return s<0?"-"+n+r.substr(1):n+r}return Ot(t)}var wl={identify:Qs,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>to(t,2,2,n),stringify:t=>Oi(t,2,"0b")},kl={identify:Qs,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>to(t,1,8,n),stringify:t=>Oi(t,8,"0")},vl={identify:Qs,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>to(t,0,10,n),stringify:Ot},Sl={identify:Qs,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>to(t,2,16,n),stringify:t=>Oi(t,16,"0x")};var $s=class t extends xt{constructor(e){super(e),this.tag=t.tag}add(e){let n;Le(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new gt(e.key,null):n=new gt(e,null),Vn(this.items,n.key)||this.items.push(n)}get(e,n){let s=Vn(this.items,e);return!n&&Le(s)?Ne(s.key)?s.key.value:s.key:s}set(e,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);let s=Vn(this.items,e);s&&!n?this.items.splice(this.items.indexOf(s),1):!s&&n&&this.items.push(new gt(e))}toJSON(e,n){return super.toJSON(e,n,Set)}toString(e,n,s){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),n,s);throw new Error("Set items must all have null values")}static from(e,n,s){let{replacer:r}=s,o=new this(e);if(n&&Symbol.iterator in Object(n))for(let i of n)typeof r=="function"&&(i=r.call(n,i,i)),o.items.push(Ss(i,null,s));return o}};$s.tag="tag:yaml.org,2002:set";var Zs={collection:"map",identify:t=>t instanceof Set,nodeClass:$s,default:!1,tag:"tag:yaml.org,2002:set",createNode:(t,e,n)=>$s.from(t,e,n),resolve(t,e){if(_t(t)){if(t.hasAllNullValues(!0))return Object.assign(new $s,t);e("Set items must all have null values")}else e("Expected a mapping for this tag");return t}};function Ci(t,e){let n=t[0],s=n==="-"||n==="+"?t.substring(1):t,r=i=>e?BigInt(i):Number(i),o=s.replace(/_/g,"").split(":").reduce((i,a)=>i*r(60)+r(a),r(0));return n==="-"?r(-1)*o:o}function Ml(t){let{value:e}=t,n=i=>i;if(typeof e=="bigint")n=i=>BigInt(i);else if(isNaN(e)||!isFinite(e))return Ot(t);let s="";e<0&&(s="-",e*=n(-1));let r=n(60),o=[e%r];return e<60?o.unshift(0):(e=(e-o[0])/r,o.unshift(e%r),e>=60&&(e=(e-o[0])/r,o.unshift(e))),s+o.map(i=>String(i).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var no={identify:t=>typeof t=="bigint"||Number.isInteger(t),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(t,e,{intAsBigInt:n})=>Ci(t,n),stringify:Ml},so={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:t=>Ci(t,!1),stringify:Ml},Es={identify:t=>t instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(t){let e=t.match(Es.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,s,r,o,i,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(n,s-1,r,o||0,i||0,a||0,l),f=e[8];if(f&&f!=="Z"){let u=Ci(f,!1);Math.abs(u)<30&&(u*=60),c-=6e4*u}return new Date(c)},stringify:({value:t})=>t?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};var Li=[fn,un,Kn,rs,Pi,Ri,wl,kl,vl,Sl,bl,yl,xl,Ws,cn,Xs,Js,Zs,no,so,Es];var $l=new Map([["core",pl],["failsafe",[fn,un,Kn]],["json",hl],["yaml11",Li],["yaml-1.1",Li]]),El={binary:Ws,bool:Hs,float:Wr,floatExp:Hr,floatNaN:Yr,floatTime:so,int:Qr,intHex:Zr,intOct:Xr,intTime:no,map:fn,merge:cn,null:rs,omap:Xs,pairs:Js,seq:un,set:Zs,timestamp:Es},Tl={"tag:yaml.org,2002:binary":Ws,"tag:yaml.org,2002:merge":cn,"tag:yaml.org,2002:omap":Xs,"tag:yaml.org,2002:pairs":Js,"tag:yaml.org,2002:set":Zs,"tag:yaml.org,2002:timestamp":Es};function ro(t,e,n){let s=$l.get(e);if(s&&!t)return n&&!s.includes(cn)?s.concat(cn):s.slice();let r=s;if(!r)if(Array.isArray(t))r=[];else{let o=Array.from($l.keys()).filter(i=>i!=="yaml11").map(i=>JSON.stringify(i)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${o} or define customTags array`)}if(Array.isArray(t))for(let o of t)r=r.concat(o);else typeof t=="function"&&(r=t(r.slice()));return n&&(r=r.concat(cn)),r.reduce((o,i)=>{let a=typeof i=="string"?El[i]:i;if(!a){let l=JSON.stringify(i),c=Object.keys(El).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return o.includes(a)||o.push(a),o},[])}var Bf=(t,e)=>t.key<e.key?-1:t.key>e.key?1:0,er=class t{constructor({compat:e,customTags:n,merge:s,resolveKnownTags:r,schema:o,sortMapEntries:i,toStringDefaults:a}){this.compat=Array.isArray(e)?ro(e,"compat"):e?ro(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=r?Tl:{},this.tags=ro(n,this.name,s),this.toStringOptions=a??null,Object.defineProperty(this,an,{value:fn}),Object.defineProperty(this,Gt,{value:Kn}),Object.defineProperty(this,Pn,{value:un}),this.sortMapEntries=typeof i=="function"?i:i===!0?Bf:null}clone(){let e=Object.create(t.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};function Al(t,e){let n=[],s=e.directives===!0;if(e.directives!==!1&&t.directives){let l=t.directives.toString(t);l?(n.push(l),s=!0):t.directives.docStart&&(s=!0)}s&&n.push("---");let r=zr(t,e),{commentString:o}=r.options;if(t.commentBefore){n.length!==1&&n.unshift("");let l=o(t.commentBefore);n.unshift(Xt(l,""))}let i=!1,a=null;if(t.contents){if(De(t.contents)){if(t.contents.spaceBefore&&s&&n.push(""),t.contents.commentBefore){let f=o(t.contents.commentBefore);n.push(Xt(f,""))}r.forceBlockIndent=!!t.comment,a=t.contents.comment}let l=a?void 0:()=>i=!0,c=Cn(t.contents,r,()=>a=null,l);a&&(c+=kn(c,"",o(a))),(c[0]==="|"||c[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(Cn(t.contents,r));if(t.directives?.docEnd)if(t.comment){let l=o(t.comment);l.includes(`
55
55
  `)?(n.push("..."),n.push(Xt(l,""))):n.push(`... ${l}`)}else n.push("...");else{let l=t.comment;l&&i&&(l=l.replace(/^\n+/,"")),l&&((!i||a)&&n[n.length-1]!==""&&n.push(""),n.push(Xt(o(l),"")))}return n.join(`
56
56
  `)+`
57
- `}var Gn=class t{constructor(e,n,s){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Ft,{value:Pr});let r=null;typeof n=="function"||Array.isArray(n)?r=n:s===void 0&&n&&(s=n,n=void 0);let o=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},s);this.options=o;let{version:i}=o;s?._directives?(this.directives=s._directives.atDocument(),this.directives.yaml.explicit&&(i=this.directives.yaml.version)):this.directives=new wn({version:i}),this.setSchema(i,s),this.contents=e===void 0?null:this.createNode(e,r,s)}clone(){let e=Object.create(t.prototype,{[Ft]:{value:Pr}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=De(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Ts(this.contents)&&this.contents.add(e)}addIn(e,n){Ts(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let s=yi(this);e.anchor=!n||s.has(n)?xi(n||"a",s):n}return new On(e.anchor)}createNode(e,n,s){let r;if(typeof n=="function")e=n.call({"":e},"",e),r=n;else if(Array.isArray(n)){let y=N=>typeof N=="number"||N instanceof String||N instanceof Number,I=n.filter(y).map(String);I.length>0&&(n=n.concat(I)),r=n}else s===void 0&&n&&(s=n,n=void 0);let{aliasDuplicateObjects:o,anchorPrefix:i,flow:a,keepUndefined:l,onTagObj:c,tag:f}=s??{},{onAnchor:u,setAnchors:d,sourceObjects:p}=rl(this,i||"a"),h={aliasDuplicateObjects:o??!0,keepUndefined:l??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:p},m=Rn(e,f,h);return a&&Ge(m)&&(m.flow=!0),d(),m}createPair(e,n,s={}){let r=this.createNode(e,null,s),o=this.createNode(n,null,s);return new gt(r,o)}delete(e){return Ts(this.contents)?this.contents.delete(e):!1}deleteIn(e){return ks(e)?this.contents==null?!1:(this.contents=null,!0):Ts(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return Ge(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return ks(e)?!n&&Ne(this.contents)?this.contents.value:this.contents:Ge(this.contents)?this.contents.getIn(e,n):void 0}has(e){return Ge(this.contents)?this.contents.has(e):!1}hasIn(e){return ks(e)?this.contents!==void 0:Ge(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=Gs(this.schema,[e],n):Ts(this.contents)&&this.contents.set(e,n)}setIn(e,n){ks(e)?this.contents=n:this.contents==null?this.contents=Gs(this.schema,Array.from(e),n):Ts(this.contents)&&this.contents.setIn(e,n)}setSchema(e,n={}){typeof e=="number"&&(e=String(e));let s;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new wn({version:"1.1"}),s={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new wn({version:e}),s={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,s=null;break;default:{let r=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${r}`)}}if(n.schema instanceof Object)this.schema=n.schema;else if(s)this.schema=new er(Object.assign(s,n));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:n,mapAsMap:s,maxAliasCount:r,onAnchor:o,reviver:i}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:s===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},l=St(this.contents,n??"",a);if(typeof o=="function")for(let{count:c,res:f}of a.anchors.values())o(f,c);return typeof i=="function"?zn(i,{"":l},"",l):l}toJSON(e,n){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:n})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let n=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${n}`)}return El(this,e)}};function Ts(t){if(Ge(t))return!0;throw new Error("Expected a YAML collection as document contents")}var tr=class extends Error{constructor(e,n,s,r){super(),this.name=e,this.code=s,this.message=r,this.pos=n}},dn=class extends tr{constructor(e,n,s){super("YAMLParseError",e,n,s)}},nr=class extends tr{constructor(e,n,s){super("YAMLWarning",e,n,s)}},Ci=(t,e)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(a=>e.linePos(a));let{line:s,col:r}=n.linePos[0];n.message+=` at line ${s}, column ${r}`;let o=r-1,i=t.substring(e.lineStarts[s-1],e.lineStarts[s]).replace(/[\n\r]+$/,"");if(o>=60&&i.length>80){let a=Math.min(o-39,i.length-79);i="\u2026"+i.substring(a),o-=a-1}if(i.length>80&&(i=i.substring(0,79)+"\u2026"),s>1&&/^ *$/.test(i.substring(0,o))){let a=t.substring(e.lineStarts[s-2],e.lineStarts[s-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
57
+ `}var Gn=class t{constructor(e,n,s){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Ft,{value:Pr});let r=null;typeof n=="function"||Array.isArray(n)?r=n:s===void 0&&n&&(s=n,n=void 0);let o=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},s);this.options=o;let{version:i}=o;s?._directives?(this.directives=s._directives.atDocument(),this.directives.yaml.explicit&&(i=this.directives.yaml.version)):this.directives=new wn({version:i}),this.setSchema(i,s),this.contents=e===void 0?null:this.createNode(e,r,s)}clone(){let e=Object.create(t.prototype,{[Ft]:{value:Pr}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=De(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Ts(this.contents)&&this.contents.add(e)}addIn(e,n){Ts(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let s=wi(this);e.anchor=!n||s.has(n)?ki(n||"a",s):n}return new Rn(e.anchor)}createNode(e,n,s){let r;if(typeof n=="function")e=n.call({"":e},"",e),r=n;else if(Array.isArray(n)){let y=N=>typeof N=="number"||N instanceof String||N instanceof Number,I=n.filter(y).map(String);I.length>0&&(n=n.concat(I)),r=n}else s===void 0&&n&&(s=n,n=void 0);let{aliasDuplicateObjects:o,anchorPrefix:i,flow:a,keepUndefined:l,onTagObj:c,tag:f}=s??{},{onAnchor:u,setAnchors:d,sourceObjects:p}=il(this,i||"a"),h={aliasDuplicateObjects:o??!0,keepUndefined:l??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:p},m=On(e,f,h);return a&&Ge(m)&&(m.flow=!0),d(),m}createPair(e,n,s={}){let r=this.createNode(e,null,s),o=this.createNode(n,null,s);return new gt(r,o)}delete(e){return Ts(this.contents)?this.contents.delete(e):!1}deleteIn(e){return ks(e)?this.contents==null?!1:(this.contents=null,!0):Ts(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return Ge(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return ks(e)?!n&&Ne(this.contents)?this.contents.value:this.contents:Ge(this.contents)?this.contents.getIn(e,n):void 0}has(e){return Ge(this.contents)?this.contents.has(e):!1}hasIn(e){return ks(e)?this.contents!==void 0:Ge(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=Gs(this.schema,[e],n):Ts(this.contents)&&this.contents.set(e,n)}setIn(e,n){ks(e)?this.contents=n:this.contents==null?this.contents=Gs(this.schema,Array.from(e),n):Ts(this.contents)&&this.contents.setIn(e,n)}setSchema(e,n={}){typeof e=="number"&&(e=String(e));let s;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new wn({version:"1.1"}),s={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new wn({version:e}),s={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,s=null;break;default:{let r=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${r}`)}}if(n.schema instanceof Object)this.schema=n.schema;else if(s)this.schema=new er(Object.assign(s,n));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:n,mapAsMap:s,maxAliasCount:r,onAnchor:o,reviver:i}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:s===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},l=St(this.contents,n??"",a);if(typeof o=="function")for(let{count:c,res:f}of a.anchors.values())o(f,c);return typeof i=="function"?zn(i,{"":l},"",l):l}toJSON(e,n){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:n})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let n=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${n}`)}return Al(this,e)}};function Ts(t){if(Ge(t))return!0;throw new Error("Expected a YAML collection as document contents")}var tr=class extends Error{constructor(e,n,s,r){super(),this.name=e,this.code=s,this.message=r,this.pos=n}},dn=class extends tr{constructor(e,n,s){super("YAMLParseError",e,n,s)}},nr=class extends tr{constructor(e,n,s){super("YAMLWarning",e,n,s)}},Ii=(t,e)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(a=>e.linePos(a));let{line:s,col:r}=n.linePos[0];n.message+=` at line ${s}, column ${r}`;let o=r-1,i=t.substring(e.lineStarts[s-1],e.lineStarts[s]).replace(/[\n\r]+$/,"");if(o>=60&&i.length>80){let a=Math.min(o-39,i.length-79);i="\u2026"+i.substring(a),o-=a-1}if(i.length>80&&(i=i.substring(0,79)+"\u2026"),s>1&&/^ *$/.test(i.substring(0,o))){let a=t.substring(e.lineStarts[s-2],e.lineStarts[s-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
58
58
  `),i=a+i}if(/[^ ]/.test(i)){let a=1,l=n.linePos[1];l?.line===s&&l.col>r&&(a=Math.max(1,Math.min(l.col-r,80-o)));let c=" ".repeat(o)+"^".repeat(a);n.message+=`:
59
59
 
60
60
  ${i}
61
61
  ${c}
62
- `}};function vn(t,{flow:e,indicator:n,next:s,offset:r,onError:o,parentIndent:i,startOnNewline:a}){let l=!1,c=a,f=a,u="",d="",p=!1,h=!1,m=null,y=null,I=null,N=null,M=null,$=null,O=null;for(let T of t)switch(h&&(T.type!=="space"&&T.type!=="newline"&&T.type!=="comma"&&o(T.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h=!1),m&&(c&&T.type!=="comment"&&T.type!=="newline"&&o(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),T.type){case"space":!e&&(n!=="doc-start"||s?.type!=="flow-collection")&&T.source.includes(" ")&&(m=T),f=!0;break;case"comment":{f||o(T,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let L=T.source.substring(1)||" ";u?u+=d+L:u=L,d="",c=!1;break}case"newline":c?u?u+=T.source:(!$||n!=="seq-item-ind")&&(l=!0):d+=T.source,c=!0,p=!0,(y||I)&&(N=T),f=!0;break;case"anchor":y&&o(T,"MULTIPLE_ANCHORS","A node can have at most one anchor"),T.source.endsWith(":")&&o(T.offset+T.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),y=T,O??(O=T.offset),c=!1,f=!1,h=!0;break;case"tag":{I&&o(T,"MULTIPLE_TAGS","A node can have at most one tag"),I=T,O??(O=T.offset),c=!1,f=!1,h=!0;break}case n:(y||I)&&o(T,"BAD_PROP_ORDER",`Anchors and tags must be after the ${T.source} indicator`),$&&o(T,"UNEXPECTED_TOKEN",`Unexpected ${T.source} in ${e??"collection"}`),$=T,c=n==="seq-item-ind"||n==="explicit-key-ind",f=!1;break;case"comma":if(e){M&&o(T,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),M=T,c=!1,f=!1;break}default:o(T,"UNEXPECTED_TOKEN",`Unexpected ${T.type} token`),c=!1,f=!1}let E=t[t.length-1],x=E?E.offset+E.source.length:r;return h&&s&&s.type!=="space"&&s.type!=="newline"&&s.type!=="comma"&&(s.type!=="scalar"||s.source!=="")&&o(s.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(c&&m.indent<=i||s?.type==="block-map"||s?.type==="block-seq")&&o(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:M,found:$,spaceBefore:l,comment:u,hasNewline:p,anchor:y,tag:I,newlineAfterProp:N,end:x,start:O??x}}function Un(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
63
- `))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let n of e.start)if(n.type==="newline")return!0;if(e.sep){for(let n of e.sep)if(n.type==="newline")return!0}if(Un(e.key)||Un(e.value))return!0}return!1;default:return!0}}function sr(t,e,n){if(e?.type==="flow-collection"){let s=e.end[0];s.indent===t&&(s.source==="]"||s.source==="}")&&Un(e)&&n(s,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function oo(t,e,n){let{uniqueKeys:s}=t.options;if(s===!1)return!1;let r=typeof s=="function"?s:(o,i)=>o===i||Ne(o)&&Ne(i)&&o.value===i.value;return e.some(o=>r(o.key,n))}var Tl="All mapping items must start at the same column";function Al({composeNode:t,composeEmptyNode:e},n,s,r,o){let i=o?.nodeClass??xt,a=new i(n.schema);n.atRoot&&(n.atRoot=!1);let l=s.offset,c=null;for(let f of s.items){let{start:u,key:d,sep:p,value:h}=f,m=vn(u,{indicator:"explicit-key-ind",next:d??p?.[0],offset:l,onError:r,parentIndent:s.indent,startOnNewline:!0}),y=!m.found;if(y){if(d&&(d.type==="block-seq"?r(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==s.indent&&r(l,"BAD_INDENT",Tl)),!m.anchor&&!m.tag&&!p){c=m.end,m.comment&&(a.comment?a.comment+=`
64
- `+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||Un(d))&&r(d??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else m.found?.indent!==s.indent&&r(l,"BAD_INDENT",Tl);n.atKey=!0;let I=m.end,N=d?t(n,d,m,r):e(n,I,u,null,m,r);n.schema.compat&&sr(s.indent,d,r),n.atKey=!1,oo(n,a.items,N)&&r(I,"DUPLICATE_KEY","Map keys must be unique");let M=vn(p??[],{indicator:"map-value-ind",next:h,offset:N.range[2],onError:r,parentIndent:s.indent,startOnNewline:!d||d.type==="block-scalar"});if(l=M.end,M.found){y&&(h?.type==="block-map"&&!M.hasNewline&&r(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&m.start<M.found.offset-1024&&r(N.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let $=h?t(n,h,M,r):e(n,l,p,null,M,r);n.schema.compat&&sr(s.indent,h,r),l=$.range[2];let O=new gt(N,$);n.options.keepSourceTokens&&(O.srcToken=f),a.items.push(O)}else{y&&r(N.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),M.comment&&(N.comment?N.comment+=`
65
- `+M.comment:N.comment=M.comment);let $=new gt(N);n.options.keepSourceTokens&&($.srcToken=f),a.items.push($)}}return c&&c<l&&r(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[s.offset,l,c??l],a}function Nl({composeNode:t,composeEmptyNode:e},n,s,r,o){let i=o?.nodeClass??Ot,a=new i(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let l=s.offset,c=null;for(let{start:f,value:u}of s.items){let d=vn(f,{indicator:"seq-item-ind",next:u,offset:l,onError:r,parentIndent:s.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||u)u?.type==="block-seq"?r(d.end,"BAD_INDENT","All sequence items must start at the same column"):r(l,"MISSING_CHAR","Sequence item without - indicator");else{c=d.end,d.comment&&(a.comment=d.comment);continue}let p=u?t(n,u,d,r):e(n,d.end,f,null,d,r);n.schema.compat&&sr(s.indent,u,r),l=p.range[2],a.items.push(p)}return a.range=[s.offset,l,c??l],a}function Sn(t,e,n,s){let r="";if(t){let o=!1,i="";for(let a of t){let{source:l,type:c}=a;switch(c){case"space":o=!0;break;case"comment":{n&&!o&&s(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=l.substring(1)||" ";r?r+=i+f:r=f,i="";break}case"newline":r&&(i+=l),o=!0;break;default:s(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:r,offset:e}}var Li="Block collections are not allowed within flow collections",Ii=t=>t&&(t.type==="block-map"||t.type==="block-seq");function Pl({composeNode:t,composeEmptyNode:e},n,s,r,o){let i=s.start.source==="{",a=i?"flow map":"flow sequence",l=o?.nodeClass??(i?xt:Ot),c=new l(n.schema);c.flow=!0;let f=n.atRoot;f&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let u=s.offset+s.start.source.length;for(let y=0;y<s.items.length;++y){let I=s.items[y],{start:N,key:M,sep:$,value:O}=I,E=vn(N,{flow:a,indicator:"explicit-key-ind",next:M??$?.[0],offset:u,onError:r,parentIndent:s.indent,startOnNewline:!1});if(!E.found){if(!E.anchor&&!E.tag&&!$&&!O){y===0&&E.comma?r(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):y<s.items.length-1&&r(E.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),E.comment&&(c.comment?c.comment+=`
66
- `+E.comment:c.comment=E.comment),u=E.end;continue}!i&&n.options.strict&&Un(M)&&r(M,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(y===0)E.comma&&r(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(E.comma||r(E.start,"MISSING_CHAR",`Missing , between ${a} items`),E.comment){let x="";e:for(let T of N)switch(T.type){case"comma":case"space":break;case"comment":x=T.source.substring(1);break e;default:break e}if(x){let T=c.items[c.items.length-1];Le(T)&&(T=T.value??T.key),T.comment?T.comment+=`
67
- `+x:T.comment=x,E.comment=E.comment.substring(x.length+1)}}if(!i&&!$&&!E.found){let x=O?t(n,O,E,r):e(n,E.end,$,null,E,r);c.items.push(x),u=x.range[2],Ii(O)&&r(x.range,"BLOCK_IN_FLOW",Li)}else{n.atKey=!0;let x=E.end,T=M?t(n,M,E,r):e(n,x,N,null,E,r);Ii(M)&&r(T.range,"BLOCK_IN_FLOW",Li),n.atKey=!1;let L=vn($??[],{flow:a,indicator:"map-value-ind",next:O,offset:T.range[2],onError:r,parentIndent:s.indent,startOnNewline:!1});if(L.found){if(!i&&!E.found&&n.options.strict){if($)for(let b of $){if(b===L.found)break;if(b.type==="newline"){r(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}E.start<L.found.offset-1024&&r(L.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else O&&("source"in O&&O.source?.[0]===":"?r(O,"MISSING_CHAR",`Missing space after : in ${a}`):r(L.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let w=O?t(n,O,L,r):L.found?e(n,L.end,$,null,L,r):null;w?Ii(O)&&r(w.range,"BLOCK_IN_FLOW",Li):L.comment&&(T.comment?T.comment+=`
68
- `+L.comment:T.comment=L.comment);let P=new gt(T,w);if(n.options.keepSourceTokens&&(P.srcToken=I),i){let b=c;oo(n,b.items,T)&&r(x,"DUPLICATE_KEY","Map keys must be unique"),b.items.push(P)}else{let b=new xt(n.schema);b.flow=!0,b.items.push(P);let v=(w??T).range;b.range=[T.range[0],v[1],v[2]],c.items.push(b)}u=w?w.range[2]:L.end}}let d=i?"}":"]",[p,...h]=s.end,m=u;if(p?.source===d)m=p.offset+p.source.length;else{let y=a[0].toUpperCase()+a.substring(1),I=f?`${y} must end with a ${d}`:`${y} in block collection must be sufficiently indented and end with a ${d}`;r(u,f?"MISSING_CHAR":"BAD_INDENT",I),p&&p.source.length!==1&&h.unshift(p)}if(h.length>0){let y=Sn(h,m,n.options.strict,r);y.comment&&(c.comment?c.comment+=`
69
- `+y.comment:c.comment=y.comment),c.range=[s.offset,m,y.offset]}else c.range=[s.offset,m,m];return c}function Fi(t,e,n,s,r,o){let i=n.type==="block-map"?Al(t,e,n,s,o):n.type==="block-seq"?Nl(t,e,n,s,o):Pl(t,e,n,s,o),a=i.constructor;return r==="!"||r===a.tagName?(i.tag=a.tagName,i):(r&&(i.tag=r),i)}function Ol(t,e,n,s,r){let o=s.tag,i=o?e.directives.tagName(o.source,d=>r(o,"TAG_RESOLVE_FAILED",d)):null;if(n.type==="block-seq"){let{anchor:d,newlineAfterProp:p}=s,h=d&&o?d.offset>o.offset?d:o:d??o;h&&(!p||p.offset<h.offset)&&r(h,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!o||!i||i==="!"||i===xt.tagName&&a==="map"||i===Ot.tagName&&a==="seq")return Fi(t,e,n,r,i);let l=e.schema.tags.find(d=>d.tag===i&&d.collection===a);if(!l){let d=e.schema.knownTags[i];if(d?.collection===a)e.schema.tags.push(Object.assign({},d,{default:!1})),l=d;else return d?r(o,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0):r(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,!0),Fi(t,e,n,r,i)}let c=Fi(t,e,n,r,i,l),f=l.resolve?.(c,d=>r(o,"TAG_RESOLVE_FAILED",d),e.options)??c,u=De(f)?f:new ge(f);return u.range=c.range,u.tag=i,l?.format&&(u.format=l.format),u}function Bi(t,e,n){let s=e.offset,r=_f(e,t.options.strict,n);if(!r)return{value:"",type:null,comment:"",range:[s,s,s]};let o=r.mode===">"?ge.BLOCK_FOLDED:ge.BLOCK_LITERAL,i=e.source?Df(e.source):[],a=i.length;for(let m=i.length-1;m>=0;--m){let y=i[m][1];if(y===""||y==="\r")a=m;else break}if(a===0){let m=r.chomp==="+"&&i.length>0?`
62
+ `}};function vn(t,{flow:e,indicator:n,next:s,offset:r,onError:o,parentIndent:i,startOnNewline:a}){let l=!1,c=a,f=a,u="",d="",p=!1,h=!1,m=null,y=null,I=null,N=null,M=null,$=null,R=null;for(let T of t)switch(h&&(T.type!=="space"&&T.type!=="newline"&&T.type!=="comma"&&o(T.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h=!1),m&&(c&&T.type!=="comment"&&T.type!=="newline"&&o(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),T.type){case"space":!e&&(n!=="doc-start"||s?.type!=="flow-collection")&&T.source.includes(" ")&&(m=T),f=!0;break;case"comment":{f||o(T,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let L=T.source.substring(1)||" ";u?u+=d+L:u=L,d="",c=!1;break}case"newline":c?u?u+=T.source:(!$||n!=="seq-item-ind")&&(l=!0):d+=T.source,c=!0,p=!0,(y||I)&&(N=T),f=!0;break;case"anchor":y&&o(T,"MULTIPLE_ANCHORS","A node can have at most one anchor"),T.source.endsWith(":")&&o(T.offset+T.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),y=T,R??(R=T.offset),c=!1,f=!1,h=!0;break;case"tag":{I&&o(T,"MULTIPLE_TAGS","A node can have at most one tag"),I=T,R??(R=T.offset),c=!1,f=!1,h=!0;break}case n:(y||I)&&o(T,"BAD_PROP_ORDER",`Anchors and tags must be after the ${T.source} indicator`),$&&o(T,"UNEXPECTED_TOKEN",`Unexpected ${T.source} in ${e??"collection"}`),$=T,c=n==="seq-item-ind"||n==="explicit-key-ind",f=!1;break;case"comma":if(e){M&&o(T,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),M=T,c=!1,f=!1;break}default:o(T,"UNEXPECTED_TOKEN",`Unexpected ${T.type} token`),c=!1,f=!1}let E=t[t.length-1],w=E?E.offset+E.source.length:r;return h&&s&&s.type!=="space"&&s.type!=="newline"&&s.type!=="comma"&&(s.type!=="scalar"||s.source!=="")&&o(s.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(c&&m.indent<=i||s?.type==="block-map"||s?.type==="block-seq")&&o(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:M,found:$,spaceBefore:l,comment:u,hasNewline:p,anchor:y,tag:I,newlineAfterProp:N,end:w,start:R??w}}function Un(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
63
+ `))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let n of e.start)if(n.type==="newline")return!0;if(e.sep){for(let n of e.sep)if(n.type==="newline")return!0}if(Un(e.key)||Un(e.value))return!0}return!1;default:return!0}}function sr(t,e,n){if(e?.type==="flow-collection"){let s=e.end[0];s.indent===t&&(s.source==="]"||s.source==="}")&&Un(e)&&n(s,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function oo(t,e,n){let{uniqueKeys:s}=t.options;if(s===!1)return!1;let r=typeof s=="function"?s:(o,i)=>o===i||Ne(o)&&Ne(i)&&o.value===i.value;return e.some(o=>r(o.key,n))}var Nl="All mapping items must start at the same column";function Pl({composeNode:t,composeEmptyNode:e},n,s,r,o){let i=o?.nodeClass??xt,a=new i(n.schema);n.atRoot&&(n.atRoot=!1);let l=s.offset,c=null;for(let f of s.items){let{start:u,key:d,sep:p,value:h}=f,m=vn(u,{indicator:"explicit-key-ind",next:d??p?.[0],offset:l,onError:r,parentIndent:s.indent,startOnNewline:!0}),y=!m.found;if(y){if(d&&(d.type==="block-seq"?r(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==s.indent&&r(l,"BAD_INDENT",Nl)),!m.anchor&&!m.tag&&!p){c=m.end,m.comment&&(a.comment?a.comment+=`
64
+ `+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||Un(d))&&r(d??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else m.found?.indent!==s.indent&&r(l,"BAD_INDENT",Nl);n.atKey=!0;let I=m.end,N=d?t(n,d,m,r):e(n,I,u,null,m,r);n.schema.compat&&sr(s.indent,d,r),n.atKey=!1,oo(n,a.items,N)&&r(I,"DUPLICATE_KEY","Map keys must be unique");let M=vn(p??[],{indicator:"map-value-ind",next:h,offset:N.range[2],onError:r,parentIndent:s.indent,startOnNewline:!d||d.type==="block-scalar"});if(l=M.end,M.found){y&&(h?.type==="block-map"&&!M.hasNewline&&r(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&m.start<M.found.offset-1024&&r(N.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let $=h?t(n,h,M,r):e(n,l,p,null,M,r);n.schema.compat&&sr(s.indent,h,r),l=$.range[2];let R=new gt(N,$);n.options.keepSourceTokens&&(R.srcToken=f),a.items.push(R)}else{y&&r(N.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),M.comment&&(N.comment?N.comment+=`
65
+ `+M.comment:N.comment=M.comment);let $=new gt(N);n.options.keepSourceTokens&&($.srcToken=f),a.items.push($)}}return c&&c<l&&r(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[s.offset,l,c??l],a}function Rl({composeNode:t,composeEmptyNode:e},n,s,r,o){let i=o?.nodeClass??Rt,a=new i(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let l=s.offset,c=null;for(let{start:f,value:u}of s.items){let d=vn(f,{indicator:"seq-item-ind",next:u,offset:l,onError:r,parentIndent:s.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||u)u?.type==="block-seq"?r(d.end,"BAD_INDENT","All sequence items must start at the same column"):r(l,"MISSING_CHAR","Sequence item without - indicator");else{c=d.end,d.comment&&(a.comment=d.comment);continue}let p=u?t(n,u,d,r):e(n,d.end,f,null,d,r);n.schema.compat&&sr(s.indent,u,r),l=p.range[2],a.items.push(p)}return a.range=[s.offset,l,c??l],a}function Sn(t,e,n,s){let r="";if(t){let o=!1,i="";for(let a of t){let{source:l,type:c}=a;switch(c){case"space":o=!0;break;case"comment":{n&&!o&&s(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=l.substring(1)||" ";r?r+=i+f:r=f,i="";break}case"newline":r&&(i+=l),o=!0;break;default:s(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:r,offset:e}}var Fi="Block collections are not allowed within flow collections",Bi=t=>t&&(t.type==="block-map"||t.type==="block-seq");function Ol({composeNode:t,composeEmptyNode:e},n,s,r,o){let i=s.start.source==="{",a=i?"flow map":"flow sequence",l=o?.nodeClass??(i?xt:Rt),c=new l(n.schema);c.flow=!0;let f=n.atRoot;f&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let u=s.offset+s.start.source.length;for(let y=0;y<s.items.length;++y){let I=s.items[y],{start:N,key:M,sep:$,value:R}=I,E=vn(N,{flow:a,indicator:"explicit-key-ind",next:M??$?.[0],offset:u,onError:r,parentIndent:s.indent,startOnNewline:!1});if(!E.found){if(!E.anchor&&!E.tag&&!$&&!R){y===0&&E.comma?r(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):y<s.items.length-1&&r(E.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),E.comment&&(c.comment?c.comment+=`
66
+ `+E.comment:c.comment=E.comment),u=E.end;continue}!i&&n.options.strict&&Un(M)&&r(M,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(y===0)E.comma&&r(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(E.comma||r(E.start,"MISSING_CHAR",`Missing , between ${a} items`),E.comment){let w="";e:for(let T of N)switch(T.type){case"comma":case"space":break;case"comment":w=T.source.substring(1);break e;default:break e}if(w){let T=c.items[c.items.length-1];Le(T)&&(T=T.value??T.key),T.comment?T.comment+=`
67
+ `+w:T.comment=w,E.comment=E.comment.substring(w.length+1)}}if(!i&&!$&&!E.found){let w=R?t(n,R,E,r):e(n,E.end,$,null,E,r);c.items.push(w),u=w.range[2],Bi(R)&&r(w.range,"BLOCK_IN_FLOW",Fi)}else{n.atKey=!0;let w=E.end,T=M?t(n,M,E,r):e(n,w,N,null,E,r);Bi(M)&&r(T.range,"BLOCK_IN_FLOW",Fi),n.atKey=!1;let L=vn($??[],{flow:a,indicator:"map-value-ind",next:R,offset:T.range[2],onError:r,parentIndent:s.indent,startOnNewline:!1});if(L.found){if(!i&&!E.found&&n.options.strict){if($)for(let b of $){if(b===L.found)break;if(b.type==="newline"){r(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}E.start<L.found.offset-1024&&r(L.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else R&&("source"in R&&R.source?.[0]===":"?r(R,"MISSING_CHAR",`Missing space after : in ${a}`):r(L.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let x=R?t(n,R,L,r):L.found?e(n,L.end,$,null,L,r):null;x?Bi(R)&&r(x.range,"BLOCK_IN_FLOW",Fi):L.comment&&(T.comment?T.comment+=`
68
+ `+L.comment:T.comment=L.comment);let P=new gt(T,x);if(n.options.keepSourceTokens&&(P.srcToken=I),i){let b=c;oo(n,b.items,T)&&r(w,"DUPLICATE_KEY","Map keys must be unique"),b.items.push(P)}else{let b=new xt(n.schema);b.flow=!0,b.items.push(P);let v=(x??T).range;b.range=[T.range[0],v[1],v[2]],c.items.push(b)}u=x?x.range[2]:L.end}}let d=i?"}":"]",[p,...h]=s.end,m=u;if(p?.source===d)m=p.offset+p.source.length;else{let y=a[0].toUpperCase()+a.substring(1),I=f?`${y} must end with a ${d}`:`${y} in block collection must be sufficiently indented and end with a ${d}`;r(u,f?"MISSING_CHAR":"BAD_INDENT",I),p&&p.source.length!==1&&h.unshift(p)}if(h.length>0){let y=Sn(h,m,n.options.strict,r);y.comment&&(c.comment?c.comment+=`
69
+ `+y.comment:c.comment=y.comment),c.range=[s.offset,m,y.offset]}else c.range=[s.offset,m,m];return c}function _i(t,e,n,s,r,o){let i=n.type==="block-map"?Pl(t,e,n,s,o):n.type==="block-seq"?Rl(t,e,n,s,o):Ol(t,e,n,s,o),a=i.constructor;return r==="!"||r===a.tagName?(i.tag=a.tagName,i):(r&&(i.tag=r),i)}function Cl(t,e,n,s,r){let o=s.tag,i=o?e.directives.tagName(o.source,d=>r(o,"TAG_RESOLVE_FAILED",d)):null;if(n.type==="block-seq"){let{anchor:d,newlineAfterProp:p}=s,h=d&&o?d.offset>o.offset?d:o:d??o;h&&(!p||p.offset<h.offset)&&r(h,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!o||!i||i==="!"||i===xt.tagName&&a==="map"||i===Rt.tagName&&a==="seq")return _i(t,e,n,r,i);let l=e.schema.tags.find(d=>d.tag===i&&d.collection===a);if(!l){let d=e.schema.knownTags[i];if(d?.collection===a)e.schema.tags.push(Object.assign({},d,{default:!1})),l=d;else return d?r(o,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0):r(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,!0),_i(t,e,n,r,i)}let c=_i(t,e,n,r,i,l),f=l.resolve?.(c,d=>r(o,"TAG_RESOLVE_FAILED",d),e.options)??c,u=De(f)?f:new ge(f);return u.range=c.range,u.tag=i,l?.format&&(u.format=l.format),u}function Di(t,e,n){let s=e.offset,r=_f(e,t.options.strict,n);if(!r)return{value:"",type:null,comment:"",range:[s,s,s]};let o=r.mode===">"?ge.BLOCK_FOLDED:ge.BLOCK_LITERAL,i=e.source?Df(e.source):[],a=i.length;for(let m=i.length-1;m>=0;--m){let y=i[m][1];if(y===""||y==="\r")a=m;else break}if(a===0){let m=r.chomp==="+"&&i.length>0?`
70
70
  `.repeat(Math.max(1,i.length-1)):"",y=s+r.length;return e.source&&(y+=e.source.length),{value:m,type:o,comment:r.comment,range:[s,y,y]}}let l=e.indent+r.indent,c=e.offset+r.length,f=0;for(let m=0;m<a;++m){let[y,I]=i[m];if(I===""||I==="\r")r.indent===0&&y.length>l&&(l=y.length);else{y.length<l&&n(c+y.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),r.indent===0&&(l=y.length),f=m,l===0&&!t.atRoot&&n(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=y.length+I.length+1}for(let m=i.length-1;m>=a;--m)i[m][0].length>l&&(a=m+1);let u="",d="",p=!1;for(let m=0;m<f;++m)u+=i[m][0].slice(l)+`
71
71
  `;for(let m=f;m<a;++m){let[y,I]=i[m];c+=y.length+I.length+1;let N=I[I.length-1]==="\r";if(N&&(I=I.slice(0,-1)),I&&y.length<l){let $=`Block scalar lines must not be less indented than their ${r.indent?"explicit indentation indicator":"first line"}`;n(c-I.length-(N?2:1),"BAD_INDENT",$),y=""}o===ge.BLOCK_LITERAL?(u+=d+y.slice(l)+I,d=`
72
72
  `):y.length>l||I[0]===" "?(d===" "?d=`
@@ -81,36 +81,36 @@ ${c}
81
81
  `+i[m][0].slice(l);u[u.length-1]!==`
82
82
  `&&(u+=`
83
83
  `);break;default:u+=`
84
- `}let h=s+r.length+e.source.length;return{value:u,type:o,comment:r.comment,range:[s,h,h]}}function _f({offset:t,props:e},n,s){if(e[0].type!=="block-scalar-header")return s(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:r}=e[0],o=r[0],i=0,a="",l=-1;for(let d=1;d<r.length;++d){let p=r[d];if(!a&&(p==="-"||p==="+"))a=p;else{let h=Number(p);!i&&h?i=h:l===-1&&(l=t+d)}}l!==-1&&s(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${r}`);let c=!1,f="",u=r.length;for(let d=1;d<e.length;++d){let p=e[d];switch(p.type){case"space":c=!0;case"newline":u+=p.source.length;break;case"comment":n&&!c&&s(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=p.source.length,f=p.source.substring(1);break;case"error":s(p,"UNEXPECTED_TOKEN",p.message),u+=p.source.length;break;default:{let h=`Unexpected token in block scalar header: ${p.type}`;s(p,"UNEXPECTED_TOKEN",h);let m=p.source;m&&typeof m=="string"&&(u+=m.length)}}}return{mode:o,indent:i,chomp:a,comment:f,length:u}}function Df(t){let e=t.split(/\n( *)/),n=e[0],s=n.match(/^( *)/),o=[s?.[1]?[s[1],n.slice(s[1].length)]:["",n]];for(let i=1;i<e.length;i+=2)o.push([e[i],e[i+1]]);return o}function _i(t,e,n){let{offset:s,type:r,source:o,end:i}=t,a,l,c=(d,p,h)=>n(s+d,p,h);switch(r){case"scalar":a=ge.PLAIN,l=zf(o,c);break;case"single-quoted-scalar":a=ge.QUOTE_SINGLE,l=jf(o,c);break;case"double-quoted-scalar":a=ge.QUOTE_DOUBLE,l=Kf(o,c);break;default:return n(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${r}`),{value:"",type:null,comment:"",range:[s,s+o.length,s+o.length]}}let f=s+o.length,u=Sn(i,f,e,n);return{value:l,type:a,comment:u.comment,range:[s,f,u.offset]}}function zf(t,e){let n="";switch(t[0]){case" ":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${t[0]}`;break}case"@":case"`":{n=`reserved character ${t[0]}`;break}}return n&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`),Rl(t)}function jf(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Rl(t.slice(1,-1)).replace(/''/g,"'")}function Rl(t){let e=/(.*?)\r?\n/sy,n=e.exec(t);if(!n)return t;let s,r;try{s=new RegExp("(?<![ ])[ ]+$"),r=new RegExp("^[ ]+|(?<![ ])[ ]+$","g")}catch{s=/[ \t]+$/,r=/^[ \t]+|[ \t]+$/g}let o=n[1].replace(s,""),i=" ",a=e.lastIndex;for(;n=e.exec(t);){let c=n[1].replace(r,"");c===""?i===`
84
+ `}let h=s+r.length+e.source.length;return{value:u,type:o,comment:r.comment,range:[s,h,h]}}function _f({offset:t,props:e},n,s){if(e[0].type!=="block-scalar-header")return s(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:r}=e[0],o=r[0],i=0,a="",l=-1;for(let d=1;d<r.length;++d){let p=r[d];if(!a&&(p==="-"||p==="+"))a=p;else{let h=Number(p);!i&&h?i=h:l===-1&&(l=t+d)}}l!==-1&&s(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${r}`);let c=!1,f="",u=r.length;for(let d=1;d<e.length;++d){let p=e[d];switch(p.type){case"space":c=!0;case"newline":u+=p.source.length;break;case"comment":n&&!c&&s(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=p.source.length,f=p.source.substring(1);break;case"error":s(p,"UNEXPECTED_TOKEN",p.message),u+=p.source.length;break;default:{let h=`Unexpected token in block scalar header: ${p.type}`;s(p,"UNEXPECTED_TOKEN",h);let m=p.source;m&&typeof m=="string"&&(u+=m.length)}}}return{mode:o,indent:i,chomp:a,comment:f,length:u}}function Df(t){let e=t.split(/\n( *)/),n=e[0],s=n.match(/^( *)/),o=[s?.[1]?[s[1],n.slice(s[1].length)]:["",n]];for(let i=1;i<e.length;i+=2)o.push([e[i],e[i+1]]);return o}function zi(t,e,n){let{offset:s,type:r,source:o,end:i}=t,a,l,c=(d,p,h)=>n(s+d,p,h);switch(r){case"scalar":a=ge.PLAIN,l=zf(o,c);break;case"single-quoted-scalar":a=ge.QUOTE_SINGLE,l=jf(o,c);break;case"double-quoted-scalar":a=ge.QUOTE_DOUBLE,l=Vf(o,c);break;default:return n(t,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${r}`),{value:"",type:null,comment:"",range:[s,s+o.length,s+o.length]}}let f=s+o.length,u=Sn(i,f,e,n);return{value:l,type:a,comment:u.comment,range:[s,f,u.offset]}}function zf(t,e){let n="";switch(t[0]){case" ":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${t[0]}`;break}case"@":case"`":{n=`reserved character ${t[0]}`;break}}return n&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`),Ll(t)}function jf(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),Ll(t.slice(1,-1)).replace(/''/g,"'")}function Ll(t){let e=/(.*?)\r?\n/sy,n=e.exec(t);if(!n)return t;let s,r;try{s=new RegExp("(?<![ ])[ ]+$"),r=new RegExp("^[ ]+|(?<![ ])[ ]+$","g")}catch{s=/[ \t]+$/,r=/^[ \t]+|[ \t]+$/g}let o=n[1].replace(s,""),i=" ",a=e.lastIndex;for(;n=e.exec(t);){let c=n[1].replace(r,"");c===""?i===`
85
85
  `?o+=i:i=`
86
- `:(o+=i+c,i=" "),a=e.lastIndex}let l=/[ \t]*(.*)/sy;return l.lastIndex=a,n=l.exec(t),o+i+(n?.[1]??"")}function Kf(t,e){let n="";for(let s=1;s<t.length-1;++s){let r=t[s];if(!(r==="\r"&&t[s+1]===`
86
+ `:(o+=i+c,i=" "),a=e.lastIndex}let l=/[ \t]*(.*)/sy;return l.lastIndex=a,n=l.exec(t),o+i+(n?.[1]??"")}function Vf(t,e){let n="";for(let s=1;s<t.length-1;++s){let r=t[s];if(!(r==="\r"&&t[s+1]===`
87
87
  `))if(r===`
88
- `){let{fold:o,offset:i}=Vf(t,s);n+=o,s=i}else if(r==="\\"){let o=t[++s],i=Gf[o];if(i)n+=i;else if(o===`
88
+ `){let{fold:o,offset:i}=Kf(t,s);n+=o,s=i}else if(r==="\\"){let o=t[++s],i=Gf[o];if(i)n+=i;else if(o===`
89
89
  `)for(o=t[s+1];o===" "||o===" ";)o=t[++s+1];else if(o==="\r"&&t[s+1]===`
90
90
  `)for(o=t[++s+1];o===" "||o===" ";)o=t[++s+1];else if(o==="x"||o==="u"||o==="U"){let a=o==="x"?2:o==="u"?4:8;n+=Uf(t,s+1,a,e),s+=a}else{let a=t.substr(s-1,2);e(s-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),n+=a}}else if(r===" "||r===" "){let o=s,i=t[s+1];for(;i===" "||i===" ";)i=t[++s+1];i!==`
91
91
  `&&!(i==="\r"&&t[s+2]===`
92
- `)&&(n+=s>o?t.slice(o,s+1):r)}else n+=r}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),n}function Vf(t,e){let n="",s=t[e+1];for(;(s===" "||s===" "||s===`
92
+ `)&&(n+=s>o?t.slice(o,s+1):r)}else n+=r}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),n}function Kf(t,e){let n="",s=t[e+1];for(;(s===" "||s===" "||s===`
93
93
  `||s==="\r")&&!(s==="\r"&&t[e+2]!==`
94
94
  `);)s===`
95
95
  `&&(n+=`
96
96
  `),e+=1,s=t[e+1];return n||(n=" "),{fold:n,offset:e}}var Gf={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
97
- `,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Uf(t,e,n,s){let r=t.substr(e,n),i=r.length===n&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;try{return String.fromCodePoint(i)}catch{let a=t.substr(e-2,n+2);return s(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}function Di(t,e,n,s){let{value:r,type:o,comment:i,range:a}=e.type==="block-scalar"?Bi(t,e,s):_i(e,t.options.strict,s),l=n?t.directives.tagName(n.source,u=>s(n,"TAG_RESOLVE_FAILED",u)):null,c;t.options.stringKeys&&t.atKey?c=t.schema[Gt]:l?c=qf(t.schema,r,l,n,s):e.type==="scalar"?c=Yf(t,r,e,s):c=t.schema[Gt];let f;try{let u=c.resolve(r,d=>s(n??e,"TAG_RESOLVE_FAILED",d),t.options);f=Ne(u)?u:new ge(u)}catch(u){let d=u instanceof Error?u.message:String(u);s(n??e,"TAG_RESOLVE_FAILED",d),f=new ge(r)}return f.range=a,f.source=r,o&&(f.type=o),l&&(f.tag=l),c.format&&(f.format=c.format),i&&(f.comment=i),f}function qf(t,e,n,s,r){if(n==="!")return t[Gt];let o=[];for(let a of t.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)o.push(a);else return a;for(let a of o)if(a.test?.test(e))return a;let i=t.knownTags[n];return i&&!i.collection?(t.tags.push(Object.assign({},i,{default:!1,test:void 0})),i):(r(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),t[Gt])}function Yf({atKey:t,directives:e,schema:n},s,r,o){let i=n.tags.find(a=>(a.default===!0||t&&a.default==="key")&&a.test?.test(s))||n[Gt];if(n.compat){let a=n.compat.find(l=>l.default&&l.test?.test(s))??n[Gt];if(i.tag!==a.tag){let l=e.tagString(i.tag),c=e.tagString(a.tag),f=`Value may be parsed as either ${l} or ${c}`;o(r,"TAG_RESOLVE_FAILED",f,!0)}}return i}function Cl(t,e,n){if(e){n??(n=e.length);for(let s=n-1;s>=0;--s){let r=e[s];switch(r.type){case"space":case"comment":case"newline":t-=r.source.length;continue}for(r=e[++s];r?.type==="space";)t+=r.source.length,r=e[++s];break}}return t}var Hf={composeNode:zi,composeEmptyNode:io};function zi(t,e,n,s){let r=t.atKey,{spaceBefore:o,comment:i,anchor:a,tag:l}=n,c,f=!0;switch(e.type){case"alias":c=Wf(t,e,s),(a||l)&&s(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=Di(t,e,l,s),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=Ol(Hf,t,e,n,s),a&&(c.anchor=a.source.substring(1))}catch(u){let d=u instanceof Error?u.message:String(u);s(e,"RESOURCE_EXHAUSTION",d)}break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;s(e,"UNEXPECTED_TOKEN",u),f=!1}}return c??(c=io(t,e.offset,void 0,null,n,s)),a&&c.anchor===""&&s(a,"BAD_ALIAS","Anchor cannot be an empty string"),r&&t.options.stringKeys&&(!Ne(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&s(l??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),o&&(c.spaceBefore=!0),i&&(e.type==="scalar"&&e.source===""?c.comment=i:c.commentBefore=i),t.options.keepSourceTokens&&f&&(c.srcToken=e),c}function io(t,e,n,s,{spaceBefore:r,comment:o,anchor:i,tag:a,end:l},c){let f={type:"scalar",offset:Cl(e,n,s),indent:-1,source:""},u=Di(t,f,a,c);return i&&(u.anchor=i.source.substring(1),u.anchor===""&&c(i,"BAD_ALIAS","Anchor cannot be an empty string")),r&&(u.spaceBefore=!0),o&&(u.comment=o,u.range[2]=l),u}function Wf({options:t},{offset:e,source:n,end:s},r){let o=new On(n.substring(1));o.source===""&&r(e,"BAD_ALIAS","Alias cannot be an empty string"),o.source.endsWith(":")&&r(e+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let i=e+n.length,a=Sn(s,i,t.strict,r);return o.range=[e,i,a.offset],a.comment&&(o.comment=a.comment),o}function Ll(t,e,{offset:n,start:s,value:r,end:o},i){let a=Object.assign({_directives:e},t),l=new Gn(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=vn(s,{indicator:"doc-start",next:r??o?.[0],offset:n,onError:i,parentIndent:0,startOnNewline:!0});f.found&&(l.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!f.hasNewline&&i(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=r?zi(c,r,f,i):io(c,f.end,s,null,f,i);let u=l.contents.range[2],d=Sn(o,u,!1,i);return d.comment&&(l.comment=d.comment),l.range=[n,u,d.offset],l}function rr(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:n}=t;return[e,e+(typeof n=="string"?n.length:1)]}function Il(t){let e="",n=!1,s=!1;for(let r=0;r<t.length;++r){let o=t[r];switch(o[0]){case"#":e+=(e===""?"":s?`
97
+ `,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Uf(t,e,n,s){let r=t.substr(e,n),i=r.length===n&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;try{return String.fromCodePoint(i)}catch{let a=t.substr(e-2,n+2);return s(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}function ji(t,e,n,s){let{value:r,type:o,comment:i,range:a}=e.type==="block-scalar"?Di(t,e,s):zi(e,t.options.strict,s),l=n?t.directives.tagName(n.source,u=>s(n,"TAG_RESOLVE_FAILED",u)):null,c;t.options.stringKeys&&t.atKey?c=t.schema[Gt]:l?c=qf(t.schema,r,l,n,s):e.type==="scalar"?c=Yf(t,r,e,s):c=t.schema[Gt];let f;try{let u=c.resolve(r,d=>s(n??e,"TAG_RESOLVE_FAILED",d),t.options);f=Ne(u)?u:new ge(u)}catch(u){let d=u instanceof Error?u.message:String(u);s(n??e,"TAG_RESOLVE_FAILED",d),f=new ge(r)}return f.range=a,f.source=r,o&&(f.type=o),l&&(f.tag=l),c.format&&(f.format=c.format),i&&(f.comment=i),f}function qf(t,e,n,s,r){if(n==="!")return t[Gt];let o=[];for(let a of t.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)o.push(a);else return a;for(let a of o)if(a.test?.test(e))return a;let i=t.knownTags[n];return i&&!i.collection?(t.tags.push(Object.assign({},i,{default:!1,test:void 0})),i):(r(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),t[Gt])}function Yf({atKey:t,directives:e,schema:n},s,r,o){let i=n.tags.find(a=>(a.default===!0||t&&a.default==="key")&&a.test?.test(s))||n[Gt];if(n.compat){let a=n.compat.find(l=>l.default&&l.test?.test(s))??n[Gt];if(i.tag!==a.tag){let l=e.tagString(i.tag),c=e.tagString(a.tag),f=`Value may be parsed as either ${l} or ${c}`;o(r,"TAG_RESOLVE_FAILED",f,!0)}}return i}function Il(t,e,n){if(e){n??(n=e.length);for(let s=n-1;s>=0;--s){let r=e[s];switch(r.type){case"space":case"comment":case"newline":t-=r.source.length;continue}for(r=e[++s];r?.type==="space";)t+=r.source.length,r=e[++s];break}}return t}var Hf={composeNode:Vi,composeEmptyNode:io};function Vi(t,e,n,s){let r=t.atKey,{spaceBefore:o,comment:i,anchor:a,tag:l}=n,c,f=!0;switch(e.type){case"alias":c=Wf(t,e,s),(a||l)&&s(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=ji(t,e,l,s),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=Cl(Hf,t,e,n,s),a&&(c.anchor=a.source.substring(1))}catch(u){let d=u instanceof Error?u.message:String(u);s(e,"RESOURCE_EXHAUSTION",d)}break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;s(e,"UNEXPECTED_TOKEN",u),f=!1}}return c??(c=io(t,e.offset,void 0,null,n,s)),a&&c.anchor===""&&s(a,"BAD_ALIAS","Anchor cannot be an empty string"),r&&t.options.stringKeys&&(!Ne(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&s(l??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),o&&(c.spaceBefore=!0),i&&(e.type==="scalar"&&e.source===""?c.comment=i:c.commentBefore=i),t.options.keepSourceTokens&&f&&(c.srcToken=e),c}function io(t,e,n,s,{spaceBefore:r,comment:o,anchor:i,tag:a,end:l},c){let f={type:"scalar",offset:Il(e,n,s),indent:-1,source:""},u=ji(t,f,a,c);return i&&(u.anchor=i.source.substring(1),u.anchor===""&&c(i,"BAD_ALIAS","Anchor cannot be an empty string")),r&&(u.spaceBefore=!0),o&&(u.comment=o,u.range[2]=l),u}function Wf({options:t},{offset:e,source:n,end:s},r){let o=new Rn(n.substring(1));o.source===""&&r(e,"BAD_ALIAS","Alias cannot be an empty string"),o.source.endsWith(":")&&r(e+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let i=e+n.length,a=Sn(s,i,t.strict,r);return o.range=[e,i,a.offset],a.comment&&(o.comment=a.comment),o}function Fl(t,e,{offset:n,start:s,value:r,end:o},i){let a=Object.assign({_directives:e},t),l=new Gn(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=vn(s,{indicator:"doc-start",next:r??o?.[0],offset:n,onError:i,parentIndent:0,startOnNewline:!0});f.found&&(l.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!f.hasNewline&&i(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=r?Vi(c,r,f,i):io(c,f.end,s,null,f,i);let u=l.contents.range[2],d=Sn(o,u,!1,i);return d.comment&&(l.comment=d.comment),l.range=[n,u,d.offset],l}function rr(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:n}=t;return[e,e+(typeof n=="string"?n.length:1)]}function Bl(t){let e="",n=!1,s=!1;for(let r=0;r<t.length;++r){let o=t[r];switch(o[0]){case"#":e+=(e===""?"":s?`
98
98
 
99
99
  `:`
100
- `)+(o.substring(1)||" "),n=!0,s=!1;break;case"%":t[r+1]?.[0]!=="#"&&(r+=1),n=!1;break;default:n||(s=!0),n=!1}}return{comment:e,afterEmptyLine:s}}var or=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,s,r,o)=>{let i=rr(n);o?this.warnings.push(new nr(i,s,r)):this.errors.push(new dn(i,s,r))},this.directives=new wn({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:s,afterEmptyLine:r}=Il(this.prelude);if(s){let o=e.contents;if(n)e.comment=e.comment?`${e.comment}
100
+ `)+(o.substring(1)||" "),n=!0,s=!1;break;case"%":t[r+1]?.[0]!=="#"&&(r+=1),n=!1;break;default:n||(s=!0),n=!1}}return{comment:e,afterEmptyLine:s}}var or=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,s,r,o)=>{let i=rr(n);o?this.warnings.push(new nr(i,s,r)):this.errors.push(new dn(i,s,r))},this.directives=new wn({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:s,afterEmptyLine:r}=Bl(this.prelude);if(s){let o=e.contents;if(n)e.comment=e.comment?`${e.comment}
101
101
  ${s}`:s;else if(r||e.directives.docStart||!o)e.commentBefore=s;else if(Ge(o)&&!o.flow&&o.items.length>0){let i=o.items[0];Le(i)&&(i=i.key);let a=i.commentBefore;i.commentBefore=a?`${s}
102
102
  ${a}`:s}else{let i=o.commentBefore;o.commentBefore=i?`${s}
103
- ${i}`:s}}if(n){for(let o=0;o<this.errors.length;++o)e.errors.push(this.errors[o]);for(let o=0;o<this.warnings.length;++o)e.warnings.push(this.warnings[o])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Il(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,n=!1,s=-1){for(let r of e)yield*this.next(r);yield*this.end(n,s)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(n,s,r)=>{let o=rr(e);o[0]+=n,this.onError(o,"BAD_DIRECTIVE",s,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=Ll(this.options,this.directives,e,this.onError);this.atDirectives&&!n.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(n,!1),this.doc&&(yield this.doc),this.doc=n,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let n=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,s=new dn(rr(e),"UNEXPECTED_TOKEN",n);this.atDirectives||!this.doc?this.errors.push(s):this.doc.errors.push(s);break}case"doc-end":{if(!this.doc){let s="Unexpected doc-end without preceding document";this.errors.push(new dn(rr(e),"UNEXPECTED_TOKEN",s));break}this.doc.directives.docEnd=!0;let n=Sn(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),n.comment){let s=this.doc.comment;this.doc.comment=s?`${s}
104
- ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new dn(rr(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let s=Object.assign({_directives:this.directives},this.options),r=new Gn(void 0,s);this.atDirectives&&this.onError(n,"MISSING_CHAR","Missing directives-end indicator line"),r.range=[0,n,n],this.decorate(r,!1),yield r}}};var ji=Symbol("break visit"),Jf=Symbol("skip children"),Fl=Symbol("remove item");function os(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Bl(Object.freeze([]),t,e)}os.BREAK=ji;os.SKIP=Jf;os.REMOVE=Fl;os.itemAtPath=(t,e)=>{let n=t;for(let[s,r]of e){let o=n?.[s];if(o&&"items"in o)n=o.items[r];else return}return n};os.parentCollection=(t,e)=>{let n=os.itemAtPath(t,e.slice(0,-1)),s=e[e.length-1][0],r=n?.[s];if(r&&"items"in r)return r;throw new Error("Parent collection not found")};function Bl(t,e,n){let s=n(e,t);if(typeof s=="symbol")return s;for(let r of["key","value"]){let o=e[r];if(o&&"items"in o){for(let i=0;i<o.items.length;++i){let a=Bl(Object.freeze(t.concat([[r,i]])),o.items[i],n);if(typeof a=="number")i=a-1;else{if(a===ji)return ji;a===Fl&&(o.items.splice(i,1),i-=1)}}typeof s=="function"&&r==="key"&&(s=s(e,t))}}return typeof s=="function"?s(e,t):s}var Ki="\uFEFF",Vi="",Gi="",ao="";function _l(t){switch(t){case Ki:return"byte-order-mark";case Vi:return"doc-mode";case Gi:return"flow-error-end";case ao:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
103
+ ${i}`:s}}if(n){for(let o=0;o<this.errors.length;++o)e.errors.push(this.errors[o]);for(let o=0;o<this.warnings.length;++o)e.warnings.push(this.warnings[o])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Bl(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,n=!1,s=-1){for(let r of e)yield*this.next(r);yield*this.end(n,s)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(n,s,r)=>{let o=rr(e);o[0]+=n,this.onError(o,"BAD_DIRECTIVE",s,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=Fl(this.options,this.directives,e,this.onError);this.atDirectives&&!n.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(n,!1),this.doc&&(yield this.doc),this.doc=n,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let n=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,s=new dn(rr(e),"UNEXPECTED_TOKEN",n);this.atDirectives||!this.doc?this.errors.push(s):this.doc.errors.push(s);break}case"doc-end":{if(!this.doc){let s="Unexpected doc-end without preceding document";this.errors.push(new dn(rr(e),"UNEXPECTED_TOKEN",s));break}this.doc.directives.docEnd=!0;let n=Sn(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),n.comment){let s=this.doc.comment;this.doc.comment=s?`${s}
104
+ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new dn(rr(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let s=Object.assign({_directives:this.directives},this.options),r=new Gn(void 0,s);this.atDirectives&&this.onError(n,"MISSING_CHAR","Missing directives-end indicator line"),r.range=[0,n,n],this.decorate(r,!1),yield r}}};var Ki=Symbol("break visit"),Jf=Symbol("skip children"),_l=Symbol("remove item");function os(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),Dl(Object.freeze([]),t,e)}os.BREAK=Ki;os.SKIP=Jf;os.REMOVE=_l;os.itemAtPath=(t,e)=>{let n=t;for(let[s,r]of e){let o=n?.[s];if(o&&"items"in o)n=o.items[r];else return}return n};os.parentCollection=(t,e)=>{let n=os.itemAtPath(t,e.slice(0,-1)),s=e[e.length-1][0],r=n?.[s];if(r&&"items"in r)return r;throw new Error("Parent collection not found")};function Dl(t,e,n){let s=n(e,t);if(typeof s=="symbol")return s;for(let r of["key","value"]){let o=e[r];if(o&&"items"in o){for(let i=0;i<o.items.length;++i){let a=Dl(Object.freeze(t.concat([[r,i]])),o.items[i],n);if(typeof a=="number")i=a-1;else{if(a===Ki)return Ki;a===_l&&(o.items.splice(i,1),i-=1)}}typeof s=="function"&&r==="key"&&(s=s(e,t))}}return typeof s=="function"?s(e,t):s}var Gi="\uFEFF",Ui="",qi="",ao="";function zl(t){switch(t){case Gi:return"byte-order-mark";case Ui:return"doc-mode";case qi:return"flow-error-end";case ao:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
105
105
  `:case`\r
106
106
  `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(t[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}function pn(t){switch(t){case void 0:case" ":case`
107
- `:case"\r":case" ":return!0;default:return!1}}var Dl=new Set("0123456789ABCDEFabcdef"),Qf=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),lo=new Set(",[]{}"),Zf=new Set(` ,[]{}
108
- \r `),Ui=t=>!t||Zf.has(t),ir=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,n=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!n;let s=this.next??"stream";for(;s&&(n||this.hasChars(1));)s=yield*this.parseNext(s)}atLineEnd(){let e=this.pos,n=this.buffer[e];for(;n===" "||n===" ";)n=this.buffer[++e];return!n||n==="#"||n===`
107
+ `:case"\r":case" ":return!0;default:return!1}}var jl=new Set("0123456789ABCDEFabcdef"),Qf=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),lo=new Set(",[]{}"),Zf=new Set(` ,[]{}
108
+ \r `),Yi=t=>!t||Zf.has(t),ir=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,n=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!n;let s=this.next??"stream";for(;s&&(n||this.hasChars(1));)s=yield*this.parseNext(s)}atLineEnd(){let e=this.pos,n=this.buffer[e];for(;n===" "||n===" ";)n=this.buffer[++e];return!n||n==="#"||n===`
109
109
  `?!0:n==="\r"?this.buffer[e+1]===`
110
110
  `:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let n=this.buffer[e];if(this.indentNext>0){let s=0;for(;n===" ";)n=this.buffer[++s+e];if(n==="\r"){let r=this.buffer[s+e+1];if(r===`
111
111
  `||!r&&!this.atEnd)return e+s+1}return n===`
112
112
  `||s>=this.indentNext||!n&&!this.atEnd?e+s:-1}if(n==="-"||n==="."){let s=this.buffer.substr(e,3);if((s==="---"||s==="...")&&pn(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
113
- `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===Ki&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let n=e.length,s=e.indexOf("#");for(;s!==-1;){let o=e[s-1];if(o===" "||o===" "){n=s-1;break}else s=e.indexOf("#",s+1)}for(;;){let o=e[n-1];if(o===" "||o===" ")n-=1;else break}let r=(yield*this.pushCount(n))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),"stream"}if(this.atLineEnd()){let n=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-n),yield*this.pushNewline(),"stream"}return yield Vi,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let n=this.peek(3);if((n==="---"||n==="...")&&pn(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,n==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!pn(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,n]=this.peek(2);if(!n&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&pn(n)){let s=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=s,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let n=yield*this.pushIndicators();switch(e[n]){case"#":yield*this.pushCount(e.length-n);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Ui),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return n+=yield*this.parseBlockScalarHeader(),n+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-n),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,n,s=-1;do e=yield*this.pushNewline(),e>0?(n=yield*this.pushSpaces(!1),this.indentValue=s=n):n=0,n+=yield*this.pushSpaces(!0);while(e+n>0);let r=this.getLine();if(r===null)return this.setNext("flow");if((s!==-1&&s<this.indentNext&&r[0]!=="#"||s===0&&(r.startsWith("---")||r.startsWith("..."))&&pn(r[3]))&&!(s===this.indentNext-1&&this.flowLevel===1&&(r[0]==="]"||r[0]==="}")))return this.flowLevel=0,yield Gi,yield*this.parseLineStart();let o=0;for(;r[o]===",";)o+=yield*this.pushCount(1),o+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(o+=yield*this.pushIndicators(),r[o]){case void 0:return"flow";case"#":return yield*this.pushCount(r.length-o),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Ui),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let i=this.charAt(1);if(this.flowKey||pn(i)||i===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),n=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;n!==-1&&this.buffer[n+1]==="'";)n=this.buffer.indexOf("'",n+2);else for(;n!==-1;){let o=0;for(;this.buffer[n-1-o]==="\\";)o+=1;if(o%2===0)break;n=this.buffer.indexOf('"',n+1)}let s=this.buffer.substring(0,n),r=s.indexOf(`
113
+ `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===Gi&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let n=e.length,s=e.indexOf("#");for(;s!==-1;){let o=e[s-1];if(o===" "||o===" "){n=s-1;break}else s=e.indexOf("#",s+1)}for(;;){let o=e[n-1];if(o===" "||o===" ")n-=1;else break}let r=(yield*this.pushCount(n))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),"stream"}if(this.atLineEnd()){let n=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-n),yield*this.pushNewline(),"stream"}return yield Ui,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let n=this.peek(3);if((n==="---"||n==="...")&&pn(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,n==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!pn(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,n]=this.peek(2);if(!n&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&pn(n)){let s=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=s,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let n=yield*this.pushIndicators();switch(e[n]){case"#":yield*this.pushCount(e.length-n);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Yi),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return n+=yield*this.parseBlockScalarHeader(),n+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-n),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,n,s=-1;do e=yield*this.pushNewline(),e>0?(n=yield*this.pushSpaces(!1),this.indentValue=s=n):n=0,n+=yield*this.pushSpaces(!0);while(e+n>0);let r=this.getLine();if(r===null)return this.setNext("flow");if((s!==-1&&s<this.indentNext&&r[0]!=="#"||s===0&&(r.startsWith("---")||r.startsWith("..."))&&pn(r[3]))&&!(s===this.indentNext-1&&this.flowLevel===1&&(r[0]==="]"||r[0]==="}")))return this.flowLevel=0,yield qi,yield*this.parseLineStart();let o=0;for(;r[o]===",";)o+=yield*this.pushCount(1),o+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(o+=yield*this.pushIndicators(),r[o]){case void 0:return"flow";case"#":return yield*this.pushCount(r.length-o),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Yi),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let i=this.charAt(1);if(this.flowKey||pn(i)||i===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),n=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;n!==-1&&this.buffer[n+1]==="'";)n=this.buffer.indexOf("'",n+2);else for(;n!==-1;){let o=0;for(;this.buffer[n-1-o]==="\\";)o+=1;if(o%2===0)break;n=this.buffer.indexOf('"',n+1)}let s=this.buffer.substring(0,n),r=s.indexOf(`
114
114
  `,this.pos);if(r!==-1){for(;r!==-1;){let o=this.continueScalar(r+1);if(o===-1)break;r=s.indexOf(`
115
115
  `,o)}r!==-1&&(n=r-(s[r-1]==="\r"?2:1))}if(n===-1){if(!this.atEnd)return this.setNext("quoted-scalar");n=this.buffer.length}return yield*this.pushToIndex(n+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let n=this.buffer[++e];if(n==="+")this.blockScalarKeep=!0;else if(n>"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>pn(n)||n==="#")}*parseBlockScalar(){let e=this.pos-1,n=0,s;e:for(let o=this.pos;s=this.buffer[o];++o)switch(s){case" ":n+=1;break;case`
116
116
  `:e=o,n=0;break;case"\r":{let i=this.buffer[o+1];if(!i&&!this.atEnd)return this.setNext("block-scalar");if(i===`
@@ -120,26 +120,26 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
120
120
  `&&o>=this.pos&&o+1+n>a)e=o;else break}while(!0);return yield ao,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,n=this.pos-1,s=this.pos-1,r;for(;r=this.buffer[++s];)if(r===":"){let o=this.buffer[s+1];if(pn(o)||e&&lo.has(o))break;n=s}else if(pn(r)){let o=this.buffer[s+1];if(r==="\r"&&(o===`
121
121
  `?(s+=1,r=`
122
122
  `,o=this.buffer[s+1]):n=s),o==="#"||e&&lo.has(o))break;if(r===`
123
- `){let i=this.continueScalar(s+1);if(i===-1)break;s=Math.max(s,i-2)}}else{if(e&&lo.has(r))break;n=s}return!r&&!this.atEnd?this.setNext("plain-scalar"):(yield ao,yield*this.pushToIndex(n+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,n){let s=this.buffer.slice(this.pos,e);return s?(yield s,this.pos+=s.length,s.length):(n&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Ui),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let n=this.flowLevel>0,s=this.charAt(1);if(pn(s)||n&&lo.has(s)){n?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,n=this.buffer[e];for(;!pn(n)&&n!==">";)n=this.buffer[++e];return yield*this.pushToIndex(n===">"?e+1:e,!1)}else{let e=this.pos+1,n=this.buffer[e];for(;n;)if(Qf.has(n))n=this.buffer[++e];else if(n==="%"&&Dl.has(this.buffer[e+1])&&Dl.has(this.buffer[e+2]))n=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
123
+ `){let i=this.continueScalar(s+1);if(i===-1)break;s=Math.max(s,i-2)}}else{if(e&&lo.has(r))break;n=s}return!r&&!this.atEnd?this.setNext("plain-scalar"):(yield ao,yield*this.pushToIndex(n+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,n){let s=this.buffer.slice(this.pos,e);return s?(yield s,this.pos+=s.length,s.length):(n&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Yi),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let n=this.flowLevel>0,s=this.charAt(1);if(pn(s)||n&&lo.has(s)){n?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,n=this.buffer[e];for(;!pn(n)&&n!==">";)n=this.buffer[++e];return yield*this.pushToIndex(n===">"?e+1:e,!1)}else{let e=this.pos+1,n=this.buffer[e];for(;n;)if(Qf.has(n))n=this.buffer[++e];else if(n==="%"&&jl.has(this.buffer[e+1])&&jl.has(this.buffer[e+2]))n=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
124
124
  `?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
125
- `?yield*this.pushCount(2):0}*pushSpaces(e){let n=this.pos-1,s;do s=this.buffer[++n];while(s===" "||e&&s===" ");let r=n-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=n),r}*pushUntil(e){let n=this.pos,s=this.buffer[n];for(;!e(s);)s=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};var is=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let n=0,s=this.lineStarts.length;for(;n<s;){let o=n+s>>1;this.lineStarts[o]<e?n=o+1:s=o}if(this.lineStarts[n]===e)return{line:n+1,col:1};if(n===0)return{line:0,col:e};let r=this.lineStarts[n-1];return{line:n,col:e-r+1}}}};function qn(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function zl(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Kl(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function co(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function As(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function fo(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let n=0;n<e.length;++n)t.push(e[n])}function jl(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!qn(e.start,"explicit-key-ind")&&!qn(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Kl(e.value)?e.value.end?fo(e.value.end,e.sep):e.value.end=e.sep:fo(e.start,e.sep),delete e.sep)}var ar=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new ir,this.onNewLine=e}*parse(e,n=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let s of this.lexer.lex(e,n))yield*this.next(s);n||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=_l(e);if(n)if(n==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=n,yield*this.step(),n){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let s=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:s,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let n=e??this.stack.pop();if(!n)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield n;else{let s=this.peek(1);switch(n.type==="block-scalar"?n.indent="indent"in s?s.indent:0:n.type==="flow-collection"&&s.type==="document"&&(n.indent=0),n.type==="flow-collection"&&jl(n),s.type){case"document":s.value=n;break;case"block-scalar":s.props.push(n);break;case"block-map":{let r=s.items[s.items.length-1];if(r.value){s.items.push({start:[],key:n,sep:[]}),this.onKeyLine=!0;return}else if(r.sep)r.value=n;else{Object.assign(r,{key:n,sep:[]}),this.onKeyLine=!r.explicitKey;return}break}case"block-seq":{let r=s.items[s.items.length-1];r.value?s.items.push({start:[],value:n}):r.value=n;break}case"flow-collection":{let r=s.items[s.items.length-1];!r||r.value?s.items.push({start:[],key:n,sep:[]}):r.sep?r.value=n:Object.assign(r,{key:n,sep:[]});return}default:yield*this.pop(),yield*this.pop(n)}if((s.type==="document"||s.type==="block-map"||s.type==="block-seq")&&(n.type==="block-map"||n.type==="block-seq")){let r=n.items[n.items.length-1];r&&!r.sep&&!r.value&&r.start.length>0&&zl(r.start)===-1&&(n.indent===0||r.start.every(o=>o.type!=="comment"||o.indent<n.indent))&&(s.type==="document"?s.end=r.start:s.items.push({start:r.start}),n.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{zl(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let n=co(this.peek(2)),s=As(n),r;e.end?(r=e.end,r.push(this.sourceToken),delete e.end):r=[this.sourceToken];let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let n=this.source.indexOf(`
125
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let n=this.pos-1,s;do s=this.buffer[++n];while(s===" "||e&&s===" ");let r=n-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=n),r}*pushUntil(e){let n=this.pos,s=this.buffer[n];for(;!e(s);)s=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};var is=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let n=0,s=this.lineStarts.length;for(;n<s;){let o=n+s>>1;this.lineStarts[o]<e?n=o+1:s=o}if(this.lineStarts[n]===e)return{line:n+1,col:1};if(n===0)return{line:0,col:e};let r=this.lineStarts[n-1];return{line:n,col:e-r+1}}}};function qn(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function Vl(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Gl(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function co(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function As(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function fo(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let n=0;n<e.length;++n)t.push(e[n])}function Kl(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!qn(e.start,"explicit-key-ind")&&!qn(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Gl(e.value)?e.value.end?fo(e.value.end,e.sep):e.value.end=e.sep:fo(e.start,e.sep),delete e.sep)}var ar=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new ir,this.onNewLine=e}*parse(e,n=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let s of this.lexer.lex(e,n))yield*this.next(s);n||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=zl(e);if(n)if(n==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=n,yield*this.step(),n){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let s=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:s,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let n=e??this.stack.pop();if(!n)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield n;else{let s=this.peek(1);switch(n.type==="block-scalar"?n.indent="indent"in s?s.indent:0:n.type==="flow-collection"&&s.type==="document"&&(n.indent=0),n.type==="flow-collection"&&Kl(n),s.type){case"document":s.value=n;break;case"block-scalar":s.props.push(n);break;case"block-map":{let r=s.items[s.items.length-1];if(r.value){s.items.push({start:[],key:n,sep:[]}),this.onKeyLine=!0;return}else if(r.sep)r.value=n;else{Object.assign(r,{key:n,sep:[]}),this.onKeyLine=!r.explicitKey;return}break}case"block-seq":{let r=s.items[s.items.length-1];r.value?s.items.push({start:[],value:n}):r.value=n;break}case"flow-collection":{let r=s.items[s.items.length-1];!r||r.value?s.items.push({start:[],key:n,sep:[]}):r.sep?r.value=n:Object.assign(r,{key:n,sep:[]});return}default:yield*this.pop(),yield*this.pop(n)}if((s.type==="document"||s.type==="block-map"||s.type==="block-seq")&&(n.type==="block-map"||n.type==="block-seq")){let r=n.items[n.items.length-1];r&&!r.sep&&!r.value&&r.start.length>0&&Vl(r.start)===-1&&(n.indent===0||r.start.every(o=>o.type!=="comment"||o.indent<n.indent))&&(s.type==="document"?s.end=r.start:s.items.push({start:r.start}),n.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{Vl(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let n=co(this.peek(2)),s=As(n),r;e.end?(r=e.end,r.push(this.sourceToken),delete e.end):r=[this.sourceToken];let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let n=this.source.indexOf(`
126
126
  `)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
127
- `,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){let s="end"in n.value?n.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,e.indent)){let r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){fo(r,n.start),r.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let s=!this.onKeyLine&&this.indent===e.indent,r=s&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind",o=[];if(r&&n.sep&&!n.value){let i=[];for(let a=0;a<n.sep.length;++a){let l=n.sep[a];switch(l.type){case"newline":i.push(a);break;case"space":break;case"comment":l.indent>e.indent&&(i.length=0);break;default:i.length=0}}i.length>=2&&(o=n.sep.splice(i[1]))}switch(this.type){case"anchor":case"tag":r||n.value?(o.push(this.sourceToken),e.items.push({start:o}),this.onKeyLine=!0):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"explicit-key-ind":!n.sep&&!n.explicitKey?(n.start.push(this.sourceToken),n.explicitKey=!0):r||n.value?(o.push(this.sourceToken),e.items.push({start:o,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(n.explicitKey)if(n.sep)if(n.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(qn(n.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]});else if(Kl(n.key)&&!qn(n.sep,"newline")){let i=As(n.start),a=n.key,l=n.sep;l.push(this.sourceToken),delete n.key,delete n.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:a,sep:l}]})}else o.length>0?n.sep=n.sep.concat(o,this.sourceToken):n.sep.push(this.sourceToken);else if(qn(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let i=As(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||r?e.items.push({start:o,key:null,sep:[this.sourceToken]}):qn(n.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);r||n.value?(e.items.push({start:o,key:i,sep:[]}),this.onKeyLine=!0):n.sep?this.stack.push(i):(Object.assign(n,{key:i,sep:[]}),this.onKeyLine=!0);return}default:{let i=this.startBlockValue(e);if(i){if(i.type==="block-seq"){if(!n.explicitKey&&n.sep&&!qn(n.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else s&&e.items.push({start:o});this.stack.push(i);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(n.value){let s="end"in n.value?n.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,e.indent)){let r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){fo(r,n.start),r.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=e.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;n.value||qn(n.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>e.indent){let s=this.startBlockValue(e);if(s){this.stack.push(s);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let n=e.items[e.items.length-1];if(this.type==="flow-error-end"){let s;do yield*this.pop(),s=this.peek(1);while(s?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!n||n.value?e.items.push({start:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let r=this.flowScalar(this.type);!n||n.value?e.items.push({start:[],key:r,sep:[]}):n.sep?this.stack.push(r):Object.assign(n,{key:r,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let s=this.startBlockValue(e);s?this.stack.push(s):(yield*this.pop(),yield*this.step())}else{let s=this.peek(2);if(s.type==="block-map"&&(this.type==="map-value-ind"&&s.indent===e.indent||this.type==="newline"&&!s.items[s.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&s.type!=="flow-collection"){let r=co(s),o=As(r);jl(e);let i=e.end.splice(1,e.end.length);i.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:o,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let n=this.source.indexOf(`
127
+ `,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){let s="end"in n.value?n.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,e.indent)){let r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){fo(r,n.start),r.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let s=!this.onKeyLine&&this.indent===e.indent,r=s&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind",o=[];if(r&&n.sep&&!n.value){let i=[];for(let a=0;a<n.sep.length;++a){let l=n.sep[a];switch(l.type){case"newline":i.push(a);break;case"space":break;case"comment":l.indent>e.indent&&(i.length=0);break;default:i.length=0}}i.length>=2&&(o=n.sep.splice(i[1]))}switch(this.type){case"anchor":case"tag":r||n.value?(o.push(this.sourceToken),e.items.push({start:o}),this.onKeyLine=!0):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"explicit-key-ind":!n.sep&&!n.explicitKey?(n.start.push(this.sourceToken),n.explicitKey=!0):r||n.value?(o.push(this.sourceToken),e.items.push({start:o,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(n.explicitKey)if(n.sep)if(n.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(qn(n.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]});else if(Gl(n.key)&&!qn(n.sep,"newline")){let i=As(n.start),a=n.key,l=n.sep;l.push(this.sourceToken),delete n.key,delete n.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:a,sep:l}]})}else o.length>0?n.sep=n.sep.concat(o,this.sourceToken):n.sep.push(this.sourceToken);else if(qn(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let i=As(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||r?e.items.push({start:o,key:null,sep:[this.sourceToken]}):qn(n.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);r||n.value?(e.items.push({start:o,key:i,sep:[]}),this.onKeyLine=!0):n.sep?this.stack.push(i):(Object.assign(n,{key:i,sep:[]}),this.onKeyLine=!0);return}default:{let i=this.startBlockValue(e);if(i){if(i.type==="block-seq"){if(!n.explicitKey&&n.sep&&!qn(n.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else s&&e.items.push({start:o});this.stack.push(i);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let n=e.items[e.items.length-1];switch(this.type){case"newline":if(n.value){let s="end"in n.value?n.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,e.indent)){let r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){fo(r,n.start),r.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=e.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;n.value||qn(n.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>e.indent){let s=this.startBlockValue(e);if(s){this.stack.push(s);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let n=e.items[e.items.length-1];if(this.type==="flow-error-end"){let s;do yield*this.pop(),s=this.peek(1);while(s?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!n||n.value?e.items.push({start:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let r=this.flowScalar(this.type);!n||n.value?e.items.push({start:[],key:r,sep:[]}):n.sep?this.stack.push(r):Object.assign(n,{key:r,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let s=this.startBlockValue(e);s?this.stack.push(s):(yield*this.pop(),yield*this.step())}else{let s=this.peek(2);if(s.type==="block-map"&&(this.type==="map-value-ind"&&s.indent===e.indent||this.type==="newline"&&!s.items[s.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&s.type!=="flow-collection"){let r=co(s),o=As(r);Kl(e);let i=e.end.splice(1,e.end.length);i.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:o,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let n=this.source.indexOf(`
128
128
  `)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
129
- `,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let n=co(e),s=As(n);return s.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let n=co(e),s=As(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(s=>s.type==="newline"||s.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};function eu(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new is||null,prettyErrors:e}}function uo(t,e={}){let{lineCounter:n,prettyErrors:s}=eu(e),r=new ar(n?.addNewLine),o=new or(e),i=null;for(let a of o.compose(r.parse(t),!0,t.length))if(!i)i=a;else if(i.options.logLevel!=="silent"){i.errors.push(new dn(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return s&&n&&(i.errors.forEach(Ci(t,n)),i.warnings.forEach(Ci(t,n))),i}function qi(t,e,n){let s;typeof e=="function"?s=e:n===void 0&&e&&typeof e=="object"&&(n=e);let r=uo(t,n);if(!r)return null;if(r.warnings.forEach(o=>jr(r.options.logLevel,o)),r.errors.length>0){if(r.options.logLevel!=="silent")throw r.errors[0];r.errors=[]}return r.toJS(Object.assign({reviver:s},n))}function po(t){let e=qi(t);for(let n of["light","dark","kinds","roles"])if(!e||typeof e[n]!="object")throw new Error(`theme: missing "${n}"`);return e}function mo(t,e={},n={}){let s={...t.kinds};for(let[r,o]of Object.entries(n)){let i=s[o.like??r]??s.control;s[r]={color:o.color??i.color,dash:o.dash??i.dash,legend:o.legend??i.legend}}return{...t,roles:{...t.roles,...e},kinds:s}}var Vl=t=>Object.entries(t).map(([e,n])=>`--${e}:${n}`).join(";");function Mn(t,e){return e in t.light?`var(--${e})`:e}function ho(t){let{light:e,dark:n,rest:s}=Yi(t);return`:root{${e}}
129
+ `,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let n=co(e),s=As(n);return s.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let n=co(e),s=As(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(s=>s.type==="newline"||s.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};function eu(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new is||null,prettyErrors:e}}function uo(t,e={}){let{lineCounter:n,prettyErrors:s}=eu(e),r=new ar(n?.addNewLine),o=new or(e),i=null;for(let a of o.compose(r.parse(t),!0,t.length))if(!i)i=a;else if(i.options.logLevel!=="silent"){i.errors.push(new dn(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return s&&n&&(i.errors.forEach(Ii(t,n)),i.warnings.forEach(Ii(t,n))),i}function Hi(t,e,n){let s;typeof e=="function"?s=e:n===void 0&&e&&typeof e=="object"&&(n=e);let r=uo(t,n);if(!r)return null;if(r.warnings.forEach(o=>jr(r.options.logLevel,o)),r.errors.length>0){if(r.options.logLevel!=="silent")throw r.errors[0];r.errors=[]}return r.toJS(Object.assign({reviver:s},n))}function po(t){let e=Hi(t);for(let n of["light","dark","kinds","roles"])if(!e||typeof e[n]!="object")throw new Error(`theme: missing "${n}"`);return e}function mo(t,e={},n={}){let s={...t.kinds};for(let[r,o]of Object.entries(n)){let i=s[o.like??r]??s.control;s[r]={color:o.color??i.color,dash:o.dash??i.dash,legend:o.legend??i.legend}}return{...t,roles:{...t.roles,...e},kinds:s}}var Ul=t=>Object.entries(t).map(([e,n])=>`--${e}:${n}`).join(";");function Mn(t,e){return e in t.light?`var(--${e})`:e}function ho(t){let{light:e,dark:n,rest:s}=Wi(t);return`:root{${e}}
130
130
  @media (prefers-color-scheme: dark){:root:not([data-theme="light"]){${n}}}
131
131
  :root[data-theme="dark"]{${n}}
132
- ${s}`}function Yi(t){let e="";for(let[n,s]of Object.entries(t.roles))e+=`.k-${n}{--h:${s.h};--s:${s.s}%}`,s.top?e+=`.k-${n} .top{fill:${s.top}}`:s.tint&&(e+=`.k-${n} .top{fill:color-mix(in srgb,hsl(${s.h} ${Math.min(100,s.s+15)}% 50%) ${s.tint}%,var(--pad-top))}`),e+=`
132
+ ${s}`}function Wi(t){let e="";for(let[n,s]of Object.entries(t.roles))e+=`.k-${n}{--h:${s.h};--s:${s.s}%}`,s.top?e+=`.k-${n} .top{fill:${s.top}}`:s.tint&&(e+=`.k-${n} .top{fill:color-mix(in srgb,hsl(${s.h} ${Math.min(100,s.s+15)}% 50%) ${s.tint}%,var(--pad-top))}`),e+=`
133
133
  `;for(let[n,s]of Object.entries(t.kinds)){let r=Mn(t,s.color),o=s.dash==="dashed"?";stroke-dasharray:7 6;stroke-width:2.4":s.dash==="dotted"?";stroke-dasharray:3 6;stroke-width:2.4":"";e+=`.f-${n}{stroke:${r}${o}} .t-${n}{fill:${r}} .c-${n}{--c:${r}}
134
- `}return{light:Vl(t.light),dark:Vl(t.dark),rest:e}}var go=class extends Error{diags;constructor(e){super(e.map(n=>`${n.line}:${n.col} ${n.message}`).join(`
135
- `)),this.diags=e}};function Hi(t,e){let n=t.length,s=e.length;if(!n)return s;if(!s)return n;let r=Array.from({length:n+1},(o,i)=>[i,...Array(s).fill(0)]);for(let o=0;o<=s;o++)r[0][o]=o;for(let o=1;o<=n;o++)for(let i=1;i<=s;i++){let a=t[o-1]===e[i-1]?0:1;r[o][i]=Math.min(r[o-1][i]+1,r[o][i-1]+1,r[o-1][i-1]+a),o>1&&i>1&&t[o-1]===e[i-2]&&t[o-2]===e[i-1]&&(r[o][i]=Math.min(r[o][i],r[o-2][i-2]+1))}return r[n][s]}function Yn(t,e){let n,s=1/0,r=t.toLowerCase();for(let i of e){let a=Hi(r,i.toLowerCase());a<s&&(s=a,n=i)}if(n===void 0)return;let o=Math.max(1,Math.min(3,Math.floor(Math.max(t.length,n.length)/3)));return s<=o?n:void 0}function Wi(t,e,n){t.file&&(e=t.file,n=t.source);let r=`${t.line?`${e}:${t.line}:${t.col}`:e} ${t.severity}: ${t.message}`;if(t.hint&&(r+=`
134
+ `}return{light:Ul(t.light),dark:Ul(t.dark),rest:e}}var go=class extends Error{diags;constructor(e){super(e.map(n=>`${n.line}:${n.col} ${n.message}`).join(`
135
+ `)),this.diags=e}};function Ji(t,e){let n=t.length,s=e.length;if(!n)return s;if(!s)return n;let r=Array.from({length:n+1},(o,i)=>[i,...Array(s).fill(0)]);for(let o=0;o<=s;o++)r[0][o]=o;for(let o=1;o<=n;o++)for(let i=1;i<=s;i++){let a=t[o-1]===e[i-1]?0:1;r[o][i]=Math.min(r[o-1][i]+1,r[o][i-1]+1,r[o-1][i-1]+a),o>1&&i>1&&t[o-1]===e[i-2]&&t[o-2]===e[i-1]&&(r[o][i]=Math.min(r[o][i],r[o-2][i-2]+1))}return r[n][s]}function Yn(t,e){let n,s=1/0,r=t.toLowerCase();for(let i of e){let a=Ji(r,i.toLowerCase());a<s&&(s=a,n=i)}if(n===void 0)return;let o=Math.max(1,Math.min(3,Math.floor(Math.max(t.length,n.length)/3)));return s<=o?n:void 0}function Xi(t,e,n){t.file&&(e=t.file,n=t.source);let r=`${t.line?`${e}:${t.line}:${t.col}`:e} ${t.severity}: ${t.message}`;if(t.hint&&(r+=`
136
136
  ${t.hint}`),n&&t.line){let i=n.split(/\r?\n/)[t.line-1]??"",a=String(t.line).padStart(4);r+=`
137
137
  ${a} | ${i}
138
- ${" ".repeat(a.length)} | ${" ".repeat(Math.max(0,t.col-1))}^`}return r}function Gl(t,e,n){return t.map(s=>Wi(s,e,n)).join(`
138
+ ${" ".repeat(a.length)} | ${" ".repeat(Math.max(0,t.col-1))}^`}return r}function ql(t,e,n){return t.map(s=>Xi(s,e,n)).join(`
139
139
 
140
- `)}function Ul(t){return t.split("/").slice(1).map(e=>{let n=e.replace(/~1/g,"/").replace(/~0/g,"~");return/^\d+$/.test(n)?Number(n):n})}function ql(t){let e=new is,n=uo(t,{lineCounter:e,prettyErrors:!1,uniqueKeys:!0}),s=[],r=l=>{let c=e.linePos(l);return{line:c.line,col:c.col}};for(let l of n.errors){let c=r(l.pos[0]),f=l.message.split(`
140
+ `)}function Yl(t){return t.split("/").slice(1).map(e=>{let n=e.replace(/~1/g,"/").replace(/~0/g,"~");return/^\d+$/.test(n)?Number(n):n})}function Hl(t){let e=new is,n=uo(t,{lineCounter:e,prettyErrors:!1,uniqueKeys:!0}),s=[],r=l=>{let c=e.linePos(l);return{line:c.line,col:c.col}};for(let l of n.errors){let c=r(l.pos[0]),f=l.message.split(`
141
141
  `)[0],u=/Nested mappings|Implicit keys|mapping values/i.test(f)?`text that contains ": " (a colon followed by a blank) must be in quotes, e.g. command: 'send "a: b"'`:/Map keys must be unique/i.test(f)?"a key is written twice in the same map":void 0;s.push({severity:"error",message:`YAML: ${f}`,line:c.line,col:c.col,path:"",hint:u})}for(let l of n.warnings){let c=r(l.pos[0]);s.push({severity:"warning",message:`YAML: ${l.message.split(`
142
- `)[0]}`,line:c.line,col:c.col,path:""})}function o(l,c={}){let f=Ul(l),u=n.contents,d={line:1,col:1},p=h=>{let m=h?.range;m&&(d=r(m[0]))};p(u);for(let h=0;h<f.length;h++){let m=f[h];if(_t(u)){let y=u.items.find(I=>Le(I)&&Ne(I.key)&&String(I.key.value)===String(m));if(!y)break;if(c.key&&h===f.length-1)return p(y.key),d;p(y.key),u=y.value,u&&p(u)}else if(Dt(u)&&typeof m=="number"){if(u=u.items[m],!u)break;p(u)}else break}return d}function i(l){let c=n.contents;for(let p of Ul(l)){if(_t(c)){let h=c.items.find(m=>Le(m)&&Ne(m.key)&&String(m.key.value)===String(p));if(!h)return;c=h.value}else if(Dt(c)&&typeof p=="number")c=c.items[p];else return;if(!c)return}let f=c.range;if(!f)return;let u=e.linePos(Math.max(f[0],f[1]-1)).line,d=t.split(/\r?\n/);for(;u>e.linePos(f[0]).line&&/^\s*(#.*)?$/.test(d[u-1]??"");)u--;return{start:e.linePos(f[0]).line,end:u}}let a=null;return n.errors.length||(a=n.toJS({maxAliasCount:100})),{data:a,locate:o,span:i,diags:s}}var nu=new Set(["svg","g","defs","marker","symbol","title","desc","path","polygon","polyline","line","rect","circle","ellipse","text","tspan","linearGradient","radialGradient","stop","clipPath"]),su=new Set(["id","class","role","transform","viewBox","width","height","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","fx","fy","d","points","offset","gradientUnits","gradientTransform","markerWidth","markerHeight","refX","refY","orient","markerUnits","text-anchor","dominant-baseline","font-size","font-weight","letter-spacing","fill","stroke","stroke-width","stroke-dasharray","stroke-linecap","stroke-linejoin","opacity","fill-opacity","stroke-opacity","stop-color","stop-opacity","marker-start","marker-mid","marker-end","clip-path","preserveAspectRatio","vector-effect","paint-order","style"]),ru=new Set(["fill","stroke","marker-start","marker-mid","marker-end","clip-path","style"]),ou={amp:"&",lt:"<",gt:">",quot:'"',apos:"'","#39":"'"},Yl=t=>t.replace(/&(amp|lt|gt|quot|apos|#39);/g,(e,n)=>ou[n]);function Ji(t,e){return t.startsWith("data-")||t.startsWith("aria-")?/^[a-z][\w-]*$/.test(t):!(!su.has(t)||ru.has(t)&&/url\(\s*(?!['"]?#)|javascript:|expression\(|@import/i.test(e))}function Xi(t){let e={name:"#root",attrs:[],children:[]},n=[{node:e,dropped:!1}],s=/<(?:!--)[\s\S]*?-->|<\/([a-zA-Z][\w:-]*)\s*>|<([a-zA-Z][\w:-]*)((?:\s+[\w:-]+="[^"]*")*)\s*(\/?)>|([^<]+)/g,r,o=0;for(;r=s.exec(t);){if(r.index!==o)throw new Error(`not the renderer's SVG at ${o}: ${JSON.stringify(t.slice(o,o+40))}`);o=s.lastIndex;let i=n[n.length-1];if(r[0].charAt(1)!=="!"){if(r[1]){if(n.length<2||i.node.name!==r[1])throw new Error(`a stray </${r[1]}>`);n.pop();continue}if(r[2]){let a=r[2],l=[];for(let u of r[3].matchAll(/([\w:-]+)="([^"]*)"/g)){let d=u[1],p=Yl(u[2]);d==="xmlns"||d.startsWith("xmlns:")||Ji(d,p)&&l.push([d,p])}let c={name:a,attrs:l,children:[]},f=i.dropped||!nu.has(a);f||i.node.children.push(c),r[4]||n.push({node:c,dropped:f});continue}!i.dropped&&r[5].trim()&&i.node.children.push(Yl(r[5]))}}if(o!==t.length)throw new Error(`not the renderer's SVG at ${o}`);if(n.length!==1)throw new Error(`<${n[n.length-1].node.name}> is never closed`);return e}var iu="http://www.w3.org/2000/svg",Hl=t=>t.replace(/var\(--([a-zA-Z][\w-]*)/g,"var(--iso-$1");function Wl(t,e=document){let n=r=>{let o=e.createElementNS(iu,r.name);for(let[i,a]of r.attrs)i==="style"?o.style.cssText=Hl(a):o.setAttribute(i,/var\(--/.test(a)?Hl(a):a);for(let i of r.children)o.append(typeof i=="string"?e.createTextNode(i):n(i));return o},s=Xi(t).children.find(r=>typeof r!="string"&&r.name==="svg");if(!s)throw new Error("the drawing has no <svg>");return n(s)}var au=t=>t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),lr=class t{name;attrs=[];children=[];style={};constructor(e){this.name=e}setAttribute(e,n){let s=this.attrs.findIndex(r=>r[0]===e);s>=0?this.attrs[s][1]=String(n):this.attrs.push([e,String(n)])}getAttribute(e){return this.attrs.find(n=>n[0]===e)?.[1]??null}append(...e){for(let n of e)n!=null&&this.children.push(n)}set textContent(e){this.children=[String(e)]}get textContent(){return this.children.map(e=>typeof e=="string"?e:e.textContent).join("")}toNode(){let e=Object.entries(this.style).filter(([,n])=>n!==""&&n!==void 0).map(([n,s])=>`${au(n)}:${s}`).join(";");return{name:this.name,attrs:e?[...this.attrs,["style",e]]:[...this.attrs],children:this.children.map(n=>n instanceof t?n.toNode():n)}}},Jl={createElementNS:(t,e)=>new lr(e)},Xl=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),lu=t=>Xl(t).replace(/"/g,"&quot;");function bo(t,e=new Set(["style"])){if(typeof t=="string")return Xl(t);let n=t.attrs.map(([r,o])=>` ${r}="${lu(o)}"`).join("");if(!t.children.length)return`<${t.name}${n}/>`;let s=e.has(t.name)?t.children.map(r=>typeof r=="string"?r.replace(/<\//g,"<\\/"):bo(r,e)).join(""):t.children.map(r=>bo(r,e)).join("");return`<${t.name}${n}>${s}</${t.name}>`}var cu=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function Qi(t){let e=new TextEncoder().encode(t),n=e.length,s=Math.ceil((n+9)/64),r=new Uint8Array(s*64);r.set(e),r[n]=128;let o=new DataView(r.buffer);o.setUint32(r.length-4,n*8>>>0),o.setUint32(r.length-8,Math.floor(n/536870912));let i=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64),l=(c,f)=>c>>>f|c<<32-f;for(let c=0;c<s;c++){for(let N=0;N<16;N++)a[N]=o.getUint32(c*64+N*4);for(let N=16;N<64;N++){let M=l(a[N-15],7)^l(a[N-15],18)^a[N-15]>>>3,$=l(a[N-2],17)^l(a[N-2],19)^a[N-2]>>>10;a[N]=a[N-16]+M+a[N-7]+$>>>0}let[f,u,d,p,h,m,y,I]=i;for(let N=0;N<64;N++){let M=I+(l(h,6)^l(h,11)^l(h,25))+(h&m^~h&y)+cu[N]+a[N]>>>0,$=(l(f,2)^l(f,13)^l(f,22))+(f&u^f&d^u&d)>>>0;I=y,y=m,m=h,h=p+M>>>0,p=d,d=u,u=f,f=M+$>>>0}i[0]+=f,i[1]+=u,i[2]+=d,i[3]+=p,i[4]+=h,i[5]+=m,i[6]+=y,i[7]+=I}return[...i].map(c=>c.toString(16).padStart(8,"0")).join("")}function Ql(t){if(t!=="sha256")throw new Error(`only sha256 here, not ${t}`);let e="",n={update(s){return e+=s,n},digest(s){return Qi(e)}};return n}var $c={};hi($c,{BOARD_3D:()=>Wn,BOARD_CSS:()=>vc,FLAT_DEFAULTS:()=>ka,FLAT_FONTS:()=>va,GRID_CSS:()=>ya,LABEL_BUDGET:()=>Ko,MARKS_CSS:()=>ga,Obstacles:()=>ls,PAGE_CSS:()=>ma,PLAYER_CSS:()=>qo,PLAYER_UI_CSS:()=>ba,ROUTE_BUDGET:()=>Po,WALL_T:()=>$n,assembly:()=>_o,baseCss:()=>Uo,boardCatalog:()=>Sc,boardDiagram:()=>Mc,boardErrors:()=>Ho,boardOf:()=>Wo,boxAsset:()=>tc,boxSilhouette:()=>gc,calloutRect:()=>fa,cardAsset:()=>Sa,cloudPath:()=>sa,compileRaw:()=>pc,convexOverlap:()=>pr,defaultLabel:()=>sc,drawCloud:()=>vo,drawDecos:()=>na,drawingCss:()=>ha,durationFor:()=>da,facePainter:()=>ko,flatHit:()=>kc,floorAt:()=>Ns,floorOf:()=>bc,focusView:()=>dc,gateBox:()=>ur,iconPainter:()=>cr,inConvex:()=>ua,kindsCss:()=>xo,labelRect:()=>mr,layoutFlat:()=>Rs,lineRectArea:()=>cc,localAt:()=>hc,markCss:()=>wo,metricsMeasure:()=>wc,midpoint:()=>pa,noSource:()=>xa,nodeKind:()=>as,nodeKindOr:()=>Qt,offscreen:()=>Bo,openList:()=>ia,overlap2:()=>Mo,overlaps:()=>Yo,paddingOf:()=>yc,parseEnd:()=>Ut,place:()=>$o,placeBoard:()=>gr,placeCallout:()=>Io,placeNodeLabel:()=>hr,placeholderIcon:()=>ta,plate:()=>nc,polyBounds:()=>Fn,polyRectArea:()=>Os,rectArea:()=>ca,regionKind:()=>pt,regionRole:()=>Vo,registerMarks:()=>ec,renderScene:()=>Go,resolveSteps:()=>Do,routeAll:()=>Oo,screenToGrid:()=>mc,silhouette:()=>qt,simplify:()=>dr,snapMove:()=>xc,wallHeight:()=>yo,wallsOf:()=>jo});var pt=(t,e)=>e!==void 0&&Object.hasOwn(t.regions,e)?t.regions[e]:void 0,as=(t,e)=>t.nodes[e??t.defaultNode],Qt=(t,e)=>as(t,e)??t.nodes[t.defaultNode],yo=t=>Object.values(t.regions).find(e=>e.shape==="walled")?.z[1]??.8,xo=t=>Object.values(t.regions).map(e=>e.css??"").join("");var Zi=Object.create(null),ea=[];function ec(t){Object.assign(Zi,t.icons??{}),Object.assign(bs,t.faces??{}),t.css&&!ea.includes(t.css)&&ea.push(t.css)}var wo=()=>ea.join(""),cr=t=>Object.hasOwn(Zi,t)?Zi[t]:void 0,ko=t=>Object.hasOwn(bs,t)?bs[t]:void 0;function ta(t,e){let n=(e.x0+e.x1)/2,s=(e.y0+e.y1)/2,r=e.z1+.005,o=Math.min(.6,(e.x1-e.x0)*.24,(e.y1-e.y0)*.24),i=[[n-o,s-o,r],[n+o,s-o,r],[n+o,s+o,r],[n-o,s+o,r]];return t.poly(i,"ico-unknown")+t.line3([n-o*.3,s-o*.35,r],[n+o*.3,s-o*.35,r],"ico-unknown-q")+t.line3([n+o*.3,s-o*.35,r],[n,s+o*.1,r],"ico-unknown-q")+t.line3([n,s+o*.45,r],[n,s+o*.5,r],"ico-unknown-q")}function na(t,e,n){let s="";for(let r of n??[])r==="terminal"?s+=Ks(t,e,3):r==="envelope"?s+=Er(t,e):r==="bubble"?s+=Tr(t,e):r==="file-lines"?s+=Ar(t,e):typeof r=="object"&&(r.terminal&&(s+=Ks(t,e,r.terminal)),r.icon&&(s+=(cr(r.icon)??ta)(t,e)));return s}var fu=(t,e)=>(t.deco??e.deco??[]).filter(n=>n!=="ghost");function tc(t,e,n,s,r,o){let i={name:t,description:e,size:n,role:s,deco:r,draw:(a,l,c)=>a.blockFaces(l)+na(a,l,fu(c,i))+(o?o(a,l):"")};return i}function nc(t){let[e,n]=$r(t);return{x0:e-.75,y0:n-.75,x1:e+.75,y1:n+.75,z0:t.z0,z1:t.z0+.18}}function sa(t,e){let n=Math.max(8,Math.min(t,e)*.18),s=n*.55,r=s,o=s,i=t-s,a=e-s,l=(c,f,u,d)=>{let p=Math.hypot(u-c,d-f),h=Math.max(1,Math.round(p/(n*1.7))),m="";for(let y=1;y<=h;y++){let I=c+(u-c)*y/h,N=f+(d-f)*y/h,M=p/h/2*1.08;m+=` A${M.toFixed(1)},${M.toFixed(1)} 0 0 1 ${I.toFixed(1)},${N.toFixed(1)}`}return m};return`M${r.toFixed(1)},${o.toFixed(1)}`+l(r,o,i,o)+l(i,o,i,a)+l(i,a,r,a)+l(r,a,r,o)+"Z"}function vo(t,e){let n={...e,z0:e.z1},s=a=>{let[l,c]=we(e.x0,e.y0,a);return[yt,.5,-yt,.5,l,c]},r=(e.x1-e.x0)*Xe,o=(e.y1-e.y0)*Xe,i=sa(r,o);return t.onMatrix(s(e.z0),r,o,()=>me("path",{d:i,class:"lft cloud-side"}))+t.onMatrix(s(e.z1),r,o,()=>me("path",{d:i,class:"top cloud-top"}))}function sc(t,e){let[n,s]=we((t.x0+t.x1)/2,(t.y0+t.y1)/2,t.z1+.75);return{x:n,y:s-18+(e?0:6),anchor:"middle"}}var $n=.16,ra=["right-of","left-of","below","behind"];function $o(t,e,n,s,r,o={},i){let a=[],l=(b,v,g,R=!1,F="error")=>{let j=n.locate(b,{key:R});a.push({severity:F,message:v,line:j.line,col:j.col,path:b,hint:g})},c=[],f=new Map,u=[],d=new Map,p=new Set([...Object.keys(s.roles),...Object.keys(o)]);function h(b,v){let g=f.get(b.id);if(g){let R=n.locate(g.path+"/id");return l(b.path+"/id",`duplicate id "${b.id}" (first used on line ${R.line})`),!1}return f.set(b.id,b),c.push(b),b.parent=v,v?v.children.push(b):u.push(b),!0}let m=()=>({x0:0,y0:0,z0:0,x1:0,y1:0,z1:0});function y(b,v,g){let R={id:b.id,type:"node",path:v,children:[],box:m(),floor:0,node:b,appears:b.appears,disappears:b.disappears};h(R,g)&&(b.nodes??[]).forEach((F,j)=>y(F,`${v}/nodes/${j}`,R))}function I(b,v,g){let R={id:b.id,type:"region",path:v,children:[],box:m(),floor:0,region:b,appears:b.appears,disappears:b.disappears};h(R,g)&&((b.nodes??[]).forEach((F,j)=>y(F,`${v}/nodes/${j}`,R)),(b.regions??[]).forEach((F,j)=>I(F,`${v}/regions/${j}`,R)))}(t.regions??[]).forEach((b,v)=>I(b,`${e}/regions/${v}`,void 0)),(t.nodes??[]).forEach((b,v)=>y(b,`${e}/nodes/${v}`,void 0));let N=()=>f.keys(),M=()=>c.filter(b=>b.type==="region").map(b=>b.id);for(let b of[...c]){let v=b.node??b.region;if(v.in!==void 0){let R=f.get(v.in);if(!R){l(b.path+"/in",`unknown region "${v.in}"`+fr(v.in,M()));continue}if(R.type!=="region"){l(b.path+"/in",`"${v.in}" is a node, not a region; put nodes on a node with its own "nodes:" list`);continue}if(b.parent&&b.parent!==R){l(b.path+"/in",`"${b.id}" is written inside "${b.parent.id}" but says in: ${v.in}; use one or the other`);continue}for(let F=R;F;F=F.parent)if(F===b){l(b.path+"/in",`"${b.id}" cannot be inside itself`);continue}b.parent||(u.splice(u.indexOf(b),1),b.parent=R,R.children.push(b))}if(b.node){let R=b.node.asset;R!==void 0&&!as(r,R)&&l(b.path+"/asset",`unknown asset "${R}"`+fr(R,Object.keys(r.nodes)),`assets: ${Object.keys(r.nodes).join(", ")}`)}let g=(b.node??b.region).role;g!==void 0&&!p.has(g)&&l(b.path+"/role",`unknown colour role "${g}"`+fr(g,p),`add it under "roles:" at the top of the file, or use one of: ${[...p].join(", ")}`)}for(let b of c){let v=b.region?.gate;if(!v?.node)continue;let g=f.get(v.node);if(!g){l(b.path+"/gate/node",`unknown node "${v.node}"`+fr(v.node,N()));continue}if(g.type!=="node"){l(b.path+"/gate/node",`"${v.node}" is a region; a gate is a node`);continue}g.placedBy=b.id;let R=g.node;(R.at||ra.some(F=>R[F]))&&l(g.path,`"${g.id}" is the gate of "${b.id}", which places it; its own placement is ignored`,void 0,!1,"warning")}let $=b=>b.gap??t.gap??2;function O(b){let v=b.node,g=Qt(r,v.asset),R=v.size,F=g.size[0],j=g.size[1],U=g.size[2];if(R&&(F=R[0],j=R[1],R.length>2&&(U=R[2])),b.placedBy){let ne=f.get(b.placedBy).region,B=ne.gate,V=B.width??2,q=R?Math.min(F,j):.3;U=R&&R.length>2?U:B.height??(ne.height??yo(r))+.3,B.side==="e"||B.side==="w"?(F=q,j=V):(F=V,j=q)}return[F,j,U]}function E(b,v,g,R,F){for(let X of v)T(X);let j=v.filter(X=>!X.placedBy),U=new Set(j),ne=new Set,B=[],V=new Set,q=X=>{let te=X.node??X.region,ye=[];for(let Fe of ra){let S=te[Fe];if(S===void 0)continue;let Y=f.get(S);if(!Y){l(`${X.path}/${Fe}`,`unknown id "${S}"`+fr(S,N()));continue}if(Y===X){l(`${X.path}/${Fe}`,`"${X.id}" cannot be placed ${Fe} itself`);continue}if(!U.has(Y)){let se=le=>le.parent?`"${le.parent.id}"`:"the scene";l(`${X.path}/${Fe}`,`"${S}" is in ${se(Y)} but "${X.id}" is in ${se(X)}; relative placement works between items in the same region`,Y.placedBy?`"${S}" is a gate, placed by its ${f.get(Y.placedBy)?.region?.kind??"region"}`:`place "${X.id}" relative to something in ${se(X)}, or use "at:"`);continue}ye.push(Y)}if(!ye.length&&!te.at){let Fe=j.indexOf(X);Fe>0&&ye.push(j[Fe-1])}return ye},Z=X=>{if(!ne.has(X)){if(V.has(X)){l(X.path,`placement loop: "${X.id}" is placed relative to something placed relative to it`);return}V.add(X),q(X).forEach(Z),V.delete(X),ne.add(X),B.push(X)}};j.forEach(Z);for(let X of B){let te=X.node??X.region,ye=d.get(X),Fe=ra.find(S=>te[S]!==void 0&&f.get(te[S])&&U.has(f.get(te[S])));if(te.at&&Fe&&l(`${X.path}/at`,`"${X.id}" has both "at" and "${Fe}"; "at" wins`,void 0,!0,"warning"),te.at)ye.x=te.at[0],ye.y=te.at[1];else if(Fe)x(ye,d.get(f.get(te[Fe])),Fe,$(te),te.align??"center");else{let S=j.indexOf(X);S>0?x(ye,d.get(j[S-1]),R==="row"?"right-of":"below",$(te),"center"):(ye.x=g,ye.y=g)}te.shift&&(ye.x+=te.shift[0],ye.y+=te.shift[1])}if(F||!j.length)return{w:0,d:0};let A=1/0,D=1/0,K=-1/0,W=-1/0;for(let X of j){let te=d.get(X);A=Math.min(A,te.x),D=Math.min(D,te.y),K=Math.max(K,te.x+te.w),W=Math.max(W,te.y+te.d)}let ie=Math.min(0,A-g),de=Math.min(0,D-g);if(ie||de)for(let X of j){let te=d.get(X);te.x-=ie,te.y-=de}return{w:K-ie+g,d:W-de+g}}function x(b,v,g,R,F){let j=()=>{b.y=F==="start"?v.y:F==="end"?v.y+v.d-b.d:v.y+(v.d-b.d)/2},U=()=>{b.x=F==="start"?v.x:F==="end"?v.x+v.w-b.w:v.x+(v.w-b.w)/2};g==="right-of"?(b.x=v.x+v.w+R,j()):g==="left-of"?(b.x=v.x-R-b.w,j()):g==="below"?(b.y=v.y+v.d+R,U()):(b.y=v.y-R-b.d,U())}function T(b){if(b.type==="node"){let[B,V,q]=O(b);d.set(b,{x:0,y:0,w:B,d:V,h:q,z:b.node.z??0}),b.children.length&&E(b,b.children,0,"row",!0);return}let v=b.region,g=v.padding??pt(r,v.kind)?.pad,R=!!v.size,F=E(b,b.children,g,v.flow??"row",R),j=v.size?v.size[0]:Math.max(F.w,g*2+.5),U=v.size?v.size[1]:Math.max(F.d,g*2+.5);if(!v.size&&v.gate){let B=(v.gate.width??2)+1;v.gate.side==="e"||v.gate.side==="w"?U=Math.max(U,B):j=Math.max(j,B)}let ne=v.size&&v.size.length>2?v.size[2]:v.height??pt(r,v.kind).z[1];d.set(b,{x:0,y:0,w:j,d:U,h:ne,z:0})}E(void 0,u,0,t.flow??"row",!0);function L(b,v,g,R){let F=d.get(b),j=v+F.x,U=g+F.y;if(b.type==="region"){let ne=pt(r,b.region.kind),[B]=ne.z,V=ne.floor,q=ne.shape==="slab"&&pt(r,b.parent?.region?.kind)?.shape==="slab"?0:B,Z=b.region.z??0,A=R+q+Z,D=R+F.h+Z;b.box={x0:j,y0:U,z0:A,x1:j+F.w,y1:U+F.d,z1:D},b.floor=V?D:R}else{let ne=R+F.z;b.box={x0:j,y0:U,z0:ne,x1:j+F.w,y1:U+F.d,z1:ne+F.h},b.floor=b.box.z1}for(let ne of b.children)ne.placedBy||L(ne,j,U,b.floor)}for(let b of u)b.placedBy||L(b,0,0,0);if(i){let b=g=>Math.round(g/i)*i,v=g=>Math.round(g*1e9)/1e9;for(let g of c){if(g.placedBy)continue;let R=g.box,F=b(R.x0),j=b(R.x1),U=b(R.y0),ne=b(R.y1);j-F<i&&(j=F+i),ne-U<i&&(ne=U+i),g.box={...R,x0:v(F),x1:v(j),y0:v(U),y1:v(ne)};let B=g.node??g.region;B.at&&B.at.forEach((V,q)=>{let Z=V/i;Math.abs(Z-Math.round(Z))>1e-6&&l(`${g.path}/at/${q}`,`${V} is not on the ${i} grid; it is drawn at ${v(b(V))}`,void 0,!1,"warning")})}}for(let b of c){let v=b.region?.gate;if(!v?.node)continue;let g=f.get(v.node);!g||g.placedBy!==b.id||(g.box=ur(b,d.get(g).h,d.get(g).w,d.get(g).d),g.floor=g.box.z1)}for(let b of c){let v=b.children.filter(g=>!g.placedBy);for(let g=0;g<v.length;g++)for(let R=g+1;R<v.length;R++){let F=v[g],j=v[R];So(F,r)||So(j,r)||Mo(F.box,j.box)&&l(j.path,`"${j.id}" overlaps "${F.id}"`,'move one with "at", a relative placement, "gap" or "shift"',!1,"warning")}if(b.parent&&b.parent.type==="region"&&!b.placedBy){let g=b.parent.box,R=b.box,F=1e-6;(R.x0<g.x0-F||R.y0<g.y0-F||R.x1>g.x1+F||R.y1>g.y1+F)&&l(b.path,`"${b.id}" sticks out of region "${b.parent.id}"`,`make "${b.parent.id}" bigger, or leave out its "size" so it fits its contents`,!1,"warning")}}{let b=u.filter(v=>!v.placedBy);for(let v=0;v<b.length;v++)for(let g=v+1;g<b.length;g++){let R=b[v],F=b[g];Mo(R.box,F.box)&&!So(R,r)&&!So(F,r)&&l(F.path,`"${F.id}" overlaps "${R.id}"`,'move one with "at", a relative placement, "gap" or "shift"',!1,"warning")}}let w=new Set,P=a.filter(b=>{let v=b.path+b.message;return w.has(v)?!1:(w.add(v),!0)});return{items:c,byId:f,roots:u,diags:P,catalog:r}}var So=(t,e)=>t.type==="region"&&["zone","tunnel"].includes(pt(e,t.region.kind)?.shape??"");function ur(t,e,n,s){let r=t.region.gate,o=t.box,i=t.box.z0,a=r.at??.5,l=r.width??2;if(r.side==="w"||r.side==="e"){let u=r.side==="w"?o.x0+$n/2:o.x1-$n/2,d=o.y0+(o.y1-o.y0)*a;return{x0:u-n/2,x1:u+n/2,y0:d-l/2,y1:d+l/2,z0:i,z1:i+e}}let c=r.side==="n"?o.y0+$n/2:o.y1-$n/2,f=o.x0+(o.x1-o.x0)*a;return{x0:f-l/2,x1:f+l/2,y0:c-s/2,y1:c+s/2,z0:i,z1:i+e}}function Mo(t,e,n=1e-6){return t.x0<e.x1-n&&e.x0<t.x1-n&&t.y0<e.y1-n&&e.y0<t.y1-n}function fr(t,e){let n=Yn(t,e);return n?` (did you mean "${n}"?)`:""}var Ln=.2,Eo=.05,uu=.6,To=.25,Ao={n:[0,-1],s:[0,1],e:[1,0],w:[-1,0]};function Ut(t){let e=/^(.*?)(?:\.(n|e|s|w|top))?$/.exec(t);return{id:e[1],side:e[2]}}var rc=new WeakMap;function Ns(t,e,n){let s=rc.get(t);if(!s){s=[];for(let i of t.items){if(i.type!=="region"||!pt(t.catalog,i.region.kind)?.floor)continue;let a=0;for(let l=i.parent;l;l=l.parent)a++;s.push({r:i,d:a})}rc.set(t,s)}let r=0,o=-1;for(let{r:i,d:a}of s){let l=i.box,c=1e-6;e>=l.x0-c&&e<=l.x1+c&&n>=l.y0-c&&n<=l.y1+c&&a>o&&(o=a,r=i.floor)}return r}function du(t,e){let n=[(t.x0+t.x1)/2,(t.y0+t.y1)/2],s=[(e.x0+e.x1)/2,(e.y0+e.y1)/2],r=s[0]-n[0],o=s[1]-n[1],i=Math.max(e.x0-t.x1,t.x0-e.x1),a=Math.max(e.y0-t.y1,t.y0-e.y1);return i>0&&(a<=0||i>=a)?r>0?"e":"w":a>0?o>0?"s":"n":Math.abs(r)>=Math.abs(o)?r>0?"e":"w":o>0?"s":"n"}var Po=5e5;function Oo(t,e,n,s,r,o){let i=[],a=(M,$,O,E="error")=>{let x=s.locate(M);i.push({severity:E,message:$,line:x.line,col:x.col,path:M,hint:O})},l=t.routes??[],c={left:Po},f=0,u=()=>n.items.map(M=>M.id),d=new Map,p=[],h=[];l.forEach((M,$)=>{let O=`${e}/routes/${$}`;(d.has(M.id)||n.byId.has(M.id))&&a(O+"/id",`duplicate id "${M.id}"`),d.set(M.id,$);let E=M.kind??"send";r.has(E)||a(O+"/kind",`unknown flow kind "${E}"`+oa(E,r),`kinds: ${[...r].join(", ")}; add one under "kinds:"`);let x={id:M.id,raw:M,path:O,kind:E,points:[]},T=(L,w)=>{let{id:P}=Ut(L),b=n.byId.get(P);if(!b){a(`${O}/${w}`,`unknown node "${P}"`+oa(P,u()));return}return b};x.from=T(M.from,"from"),x.to=T(M.to,"to"),p.push(x),h.push({r:x})});let m=new Map;for(let M of h){let{r:$}=M;if(!$.from||!$.to||$.raw.points)continue;let O=Ut($.raw.from).side,E=Ut($.raw.to).side,x=$.raw.via?.[0],T=$.raw.via?.[$.raw.via.length-1],L=(v,g)=>{if(Array.isArray(v))return{x0:v[0],x1:v[0],y0:v[1],y1:v[1],z0:0,z1:0};if(typeof v=="string"){let R=n.byId.get(Ut(v).id);if(R)return R.box}return g.box},w=(v,g,R)=>{let F=g??du(v.box,R);return{node:v,side:F,explicit:!!g,p:[0,0],z:0}};M.a=w($.from,O,L(x,$.to)),M.b=w($.to,E,L(T,$.from));let P=L(x,$.to),b=L(T,$.from);for(let[v,g]of[[M.a,P],[M.b,b]]){let R=`${v.node.id}.${v.side}`;m.has(R)||m.set(R,[]),m.get(R).push({e:v,other:[(g.x0+g.x1)/2,(g.y0+g.y1)/2]})}}for(let[,M]of m){let $=M[0].e,O=$.node.box,E=$.side,x=E==="e"||E==="w"?1:0;M.sort((v,g)=>v.other[x]-g.other[x]);let T=x?O.y0:O.x0,L=x?O.y1:O.x1,w=(T+L)/2,P=Math.max(0,L-T-.3),b=M.length>1?Math.min(uu,P/(M.length-1)):0;M.forEach((v,g)=>{let R=(g-(M.length-1)/2)*b,F=w+R,j=v.e.node.box.z0;if(E==="top"){v.e.p=[(O.x0+O.x1)/2,(O.y0+O.y1)/2],v.e.z=O.z1;return}let[U,ne]=Ao[E];v.e.p=x?[U>0?O.x1+Eo:O.x0-Eo,F]:[F,ne>0?O.y1+Eo:O.y0-Eo],v.e.z=j})}let y=[];for(let M of n.items)M.type==="node"&&y.push(M.box);let I=[];for(let M of n.items.filter($=>pt(n.catalog,$.region?.kind)?.shape==="walled")){let{x0:$,y0:O,x1:E,y1:x}=M.box,T=$n,L=M.region.gate,w=[[{x0:$,y0:O,x1:E,y1:O+T,z0:0,z1:0},"n"],[{x0:$,y0:x-T,x1:E,y1:x,z0:0,z1:0},"s"],[{x0:$,y0:O,x1:$+T,y1:x,z0:0,z1:0},"w"],[{x0:E-T,y0:O,x1:E,y1:x,z0:0,z1:0},"e"]];for(let[P,b]of w)if(L&&L.side===b){if(L.node)continue;let v=L.at??.5,g=L.width??2;if(b==="e"||b==="w"){let R=O+(x-O)*v;I.push({...P,y1:R-g/2},{...P,y0:R+g/2})}else{let R=$+(E-$)*v;I.push({...P,x1:R-g/2},{...P,x0:R+g/2})}}else I.push(P)}let N=new Map;for(let M of h){let{r:$,a:O,b:E}=M;if($.raw.points){$.points=$.raw.points.map(F=>[F[0],F[1],F.length>2?F[2]:Ns(n,F[0],F[1])+.01]);continue}if(!O||!E)continue;let x=[];($.raw.via??[]).forEach((F,j)=>{if(Array.isArray(F))if(o){let U=ne=>Math.round(Math.round(ne/o)*o*1e9)/1e9;F.forEach((ne,B)=>{Math.abs(ne/o-Math.round(ne/o))>1e-6&&a(`${$.path}/via/${j}/${B}`,`${ne} is not on the ${o} grid; it is drawn at ${U(ne)}`,void 0,"warning")}),x.push({p:[U(F[0]),U(F[1])]})}else x.push({p:[F[0],F[1]]});else{let{id:U,side:ne}=Ut(F),B=n.byId.get(U);if(!B){a(`${$.path}/via/${j}`,`unknown node "${U}"`+oa(U,u()));return}let V=ne&&ne!=="top"?ne:"n",[q,Z]=Ao[V],A=B.box;x.push({p:[q?q>0?A.x1+.4:A.x0-.4:(A.x0+A.x1)/2,Z?Z>0?A.y1+.4:A.y0-.4:(A.y0+A.y1)/2]})}});let L=y.filter(F=>F!==O.node.box&&F!==E.node.box).concat($.raw.cross?[]:I).filter(F=>!No(O.node.box,F)&&!No(E.node.box,F)&&!No(F,O.node.box)&&!No(F,E.node.box)),w=O.side==="top"?void 0:Ao[O.side],P=E.side==="top"?void 0:Ao[E.side],b=[O.p,...x.map(F=>F.p),E.p],v=[O.p],g=w,R=!0;for(let F=0;F+1<b.length;F++){let j=F+2===b.length,U=mu(b[F],b[F+1],L,N,g,j&&P?[-P[0],-P[1]]:void 0,c);if(!U){R=!1;break}v.push(...U.slice(1));let ne=v.length;if(ne>=2){let B=Math.sign(v[ne-1][0]-v[ne-2][0]),V=Math.sign(v[ne-1][1]-v[ne-2][1]);g=[B,V]}}!R&&c.left<=0?(f++,v=[O.p,[E.p[0],O.p[1]],E.p]):R||(a($.path,`no path found for route "${$.id}" from "${O.node.id}" to "${E.node.id}"`,'add "via" points, or use "points" to draw it by hand',"warning"),v=[O.p,[E.p[0],O.p[1]],E.p]),v=dr(v);for(let F=0;F+1<v.length;F++)pu(N,v[F],v[F+1]);$.points=bu(n,v,O,E)}return f&&a(e,`${f} of ${p.length} routes were drawn as plain elbows: the scene is too large to route them all around what stands in the way (${Po.toLocaleString("en")} search steps)`,'split it into scenes, or give the busiest routes "via" points or "points"',"warning"),{routes:p,diags:i}}function No(t,e){return e.x0>=t.x0-1e-6&&e.x1<=t.x1+1e-6&&e.y0>=t.y0-1e-6&&e.y1<=t.y1+1e-6&&e.z0>=t.z1-1e-6}var oc=(t,e)=>`${Math.round(t/Ln)},${Math.round(e/Ln)}`;function pu(t,e,n){let s=Math.max(1,Math.round(Math.hypot(n[0]-e[0],n[1]-e[1])/Ln));for(let r=0;r<=s;r++){let o=oc(e[0]+(n[0]-e[0])*r/s,e[1]+(n[1]-e[1])*r/s);t.set(o,(t.get(o)??0)+1)}}function ic(t,e,n){for(let s of n)if(t>s.x0-To&&t<s.x1+To&&e>s.y0-To&&e<s.y1+To)return!0;return!1}function mu(t,e,n,s,r,o,i={left:1/0}){if((Math.abs(t[0]-e[0])<1e-6||Math.abs(t[1]-e[1])<1e-6)&&gu(t,e,n)){let B=[Math.sign(e[0]-t[0]),Math.sign(e[1]-t[1])],V=!r||r[0]===B[0]&&r[1]===B[1],q=!o||o[0]===B[0]&&o[1]===B[1];if(V&&q)return[t,e]}if(i.left<=0)return null;let a=B=>Math.round((B-t[0])/Ln),l=B=>Math.round((B-t[1])/Ln),c=B=>t[0]+B*Ln,f=B=>t[1]+B*Ln,u=a(e[0]),d=l(e[1]),p=30,h=Math.min(0,u)-p,m=Math.max(0,u)+p,y=Math.min(0,d)-p,I=Math.max(0,d)+p,N=1.2,M=Ln,$=.06,O=[[1,0],[-1,0],[0,1],[0,-1]],E=m-h+1,x=I-y+1,T=(B,V)=>(B-h)*x+(V-y),L=new Int8Array(E*x).fill(-1),w=new Float64Array(E*x).fill(-1),P=new Float64Array(E*x*4).fill(1/0),b=(B,V)=>{let q=T(B,V);return L[q]<0&&(L[q]=ic(c(B),f(V),n)?1:0),L[q]===1},v=(B,V)=>{let q=T(B,V);return w[q]<0&&(w[q]=s.get(oc(c(B),f(V)))??0),w[q]},g=ia(),R=(B,V)=>(Math.abs(B-u)+Math.abs(V-d))*M,F=r?O.findIndex(B=>B[0]===r[0]&&B[1]===r[1]):-1;g.push({i:0,j:0,d:F,g:0,f:R(0,0),idx:0,hp:0});let j=(B,V)=>Math.abs(B)+Math.abs(V)<=2,U=(B,V)=>Math.abs(B-u)+Math.abs(V-d)<=2,ne=0;for(;g.length()&&ne++<2e5;){if(i.left--<=0)return null;let B=g.take();if(B.i===u&&B.j===d&&!(o&&B.d>=0&&(O[B.d][0]!==o[0]||O[B.d][1]!==o[1]))){let V=[];for(let q=B;q;q=q.prev)V.push([c(q.i),f(q.j)]);return V.reverse(),V[0]=t,hu(dr(V),e)}for(let V=0;V<4;V++){let q=O[V];if(B.d>=0&&q[0]===-O[B.d][0]&&q[1]===-O[B.d][1])continue;let Z=B.i+q[0],A=B.j+q[1];if(Z<h||Z>m||A<y||A>I||!j(Z,A)&&!U(Z,A)&&b(Z,A))continue;if((j(Z,A)||U(Z,A))&&b(Z,A)&&!(Z===u&&A===d)){let ie=j(Z,A)?r:o&&[-o[0],-o[1]];if(!ie||(j(Z,A)?q[0]!==ie[0]||q[1]!==ie[1]:q[0]!==o[0]||q[1]!==o[1]))continue}let D=B.d>=0&&B.d!==V?N:0,K=B.g+M+D+v(Z,A)*$,W=T(Z,A)*4+V;P[W]<=K||(P[W]=K,g.push({i:Z,j:A,d:V,g:K,f:K+R(Z,A),prev:B,idx:0,hp:0}))}}return null}function ia(){let t=[],e=[],n=(i,a)=>i.f<a.f||i.f===a.f&&i.idx<a.idx,s=(i,a)=>{let l=e[i];e[i]=e[a],e[a]=l,e[i].hp=i,e[a].hp=a},r=i=>{for(;i>0;){let a=i-1>>1;if(!n(e[i],e[a]))break;s(i,a),i=a}},o=i=>{for(;;){let a=2*i+1,l=a+1,c=i;if(a<e.length&&n(e[a],e[c])&&(c=a),l<e.length&&n(e[l],e[c])&&(c=l),c===i)return;s(i,c),i=c}};return{length:()=>t.length,push(i){i.idx=t.length,t.push(i),i.hp=e.length,e.push(i),r(i.hp)},take(){let i=e[0],a=e.pop();e.length&&(e[0]=a,a.hp=0,o(0));let l=t.pop();return l!==i&&(t[i.idx]=l,l.idx=i.idx,r(l.hp)),i}}}function hu(t,e){let n=t.map(o=>[o[0],o[1]]),s=n.length,r=n[s-1];if(s>=2){let o=n[s-2];Math.abs(o[1]-r[1])<1e-9?(o[1]=e[1],s>=3&&Math.abs(n[s-3][1]-r[1])<1e-9&&(n[s-3][1]=e[1])):Math.abs(o[0]-r[0])<1e-9&&(o[0]=e[0],s>=3&&Math.abs(n[s-3][0]-r[0])<1e-9&&(n[s-3][0]=e[0]))}return n[s-1]=e,dr(n)}function gu(t,e,n){let s=Math.max(1,Math.round(Math.hypot(e[0]-t[0],e[1]-t[1])/(Ln/2)));for(let r=2;r<s-1;r++)if(ic(t[0]+(e[0]-t[0])*r/s,t[1]+(e[1]-t[1])*r/s,n))return!1;return!0}function dr(t){let e=[];for(let n of t){let s=e.length;if(!(s&&Math.abs(e[s-1][0]-n[0])<1e-6&&Math.abs(e[s-1][1]-n[1])<1e-6)){if(s>=2){let r=e[s-2],o=e[s-1];if(Math.abs(r[0]-o[0])<1e-6&&Math.abs(o[0]-n[0])<1e-6||Math.abs(r[1]-o[1])<1e-6&&Math.abs(o[1]-n[1])<1e-6){e[s-1]=n;continue}}e.push(n)}}return e}function bu(t,e,n,s){let r=new Set,o=new Set;for(let c of t.items)c.type!=="region"||!pt(t.catalog,c.region.kind)?.floor||(r.add(c.box.x0),r.add(c.box.x1),o.add(c.box.y0),o.add(c.box.y1));let i=[],a=(c,f)=>Ns(t,c,f)+.01;for(let c=0;c+1<e.length;c++){let[f,u]=e[c],[d,p]=e[c+1],h=[0,1];if(Math.abs(u-p)<1e-6)for(let m of r){let y=(m-f)/(d-f);y>1e-6&&y<1-1e-6&&h.push(y)}else for(let m of o){let y=(m-u)/(p-u);y>1e-6&&y<1-1e-6&&h.push(y)}h.sort((m,y)=>m-y);for(let m=0;m+1<h.length;m++){let y=h[m],I=h[m+1],N=(y+I)/2,M=a(f+(d-f)*N,u+(p-u)*N),$=[f+(d-f)*y,u+(p-u)*y,M],O=[f+(d-f)*I,u+(p-u)*I,M],E=i[i.length-1];E&&(Math.abs(E[0]-$[0])>1e-6||Math.abs(E[1]-$[1])>1e-6||Math.abs(E[2]-$[2])>1e-6)?i.push($):E||i.push($),i.push(O)}}i.length&&(i[0][2]=n.side==="top"?n.z:n.node.box.z0+.01,i[i.length-1][2]=s.side==="top"?s.z:s.node.box.z0+.01);let l=[];for(let c of i){let f=l.length;if(f>=2){let u=l[f-2],d=l[f-1],p=Math.abs(u[2]-d[2])<1e-9&&Math.abs(d[2]-c[2])<1e-9,h=Math.abs(u[0]-d[0])<1e-6&&Math.abs(d[0]-c[0])<1e-6||Math.abs(u[1]-d[1])<1e-6&&Math.abs(d[1]-c[1])<1e-6;if(p&&h){l[f-1]=c;continue}}l.push(c)}return l}function oa(t,e){let n=Yn(t,e);return n?` (did you mean "${n}"?)`:""}function qt(t){return[we(t.x0,t.y0,t.z1),we(t.x1,t.y0,t.z1),we(t.x1,t.y0,t.z0),we(t.x1,t.y1,t.z0),we(t.x0,t.y1,t.z0),we(t.x0,t.y1,t.z1)]}function Fn(t){let e=t.map(o=>o[0]),n=t.map(o=>o[1]),s=Math.min(...e),r=Math.min(...n);return{x:s,y:r,w:Math.max(...e)-s,h:Math.max(...n)-r}}function Os(t,e){let n=t,s=(a,l)=>{let c=[];for(let f=0;f<n.length;f++){let u=n[f],d=n[(f+1)%n.length],p=a(u),h=a(d);p&&c.push(u),p!==h&&c.push(l(u,d))}n=c},r=a=>(l,c)=>[a,l[1]+(c[1]-l[1])*(a-l[0])/(c[0]-l[0])],o=a=>(l,c)=>[l[0]+(c[0]-l[0])*(a-l[1])/(c[1]-l[1]),a];if(s(a=>a[0]>=e.x,r(e.x)),!n.length||(s(a=>a[0]<=e.x+e.w,r(e.x+e.w)),!n.length)||(s(a=>a[1]>=e.y,o(e.y)),!n.length)||(s(a=>a[1]<=e.y+e.h,o(e.y+e.h)),!n.length))return 0;let i=0;for(let a=0;a<n.length;a++){let l=n[a],c=n[(a+1)%n.length];i+=l[0]*c[1]-c[0]*l[1]}return Math.abs(i)/2}function ca(t,e){let n=Math.min(t.x+t.w,e.x+e.w)-Math.max(t.x,e.x),s=Math.min(t.y+t.h,e.y+e.h)-Math.max(t.y,e.y);return n>0&&s>0?n*s:0}function cc(t,e){let n=0;for(let s=0;s+1<t.length;s++){let r=t[s],o=t[s+1],i=Math.hypot(o[0]-r[0],o[1]-r[1]),a=Math.max(1,Math.ceil(i/4));for(let l=0;l<a;l++){let c=r[0]+(o[0]-r[0])*(l+.5)/a,f=r[1]+(o[1]-r[1])*(l+.5)/a;c>=e.x&&c<=e.x+e.w&&f>=e.y&&f<=e.y+e.h&&(n+=i/a*4)}}return n}var In=64,Co=class{cells=new Map;n=0;add(e,n,s,r,o){for(let i=Math.floor(n/In);i<=Math.floor(r/In);i++)for(let a=Math.floor(s/In);a<=Math.floor(o/In);a++){let l=i*1048576+a,c=this.cells.get(l);c||this.cells.set(l,c=[]),c[c.length-1]!==e&&c.push(e)}}query(e,n,s,r){let o=new Set;for(let i=Math.floor(e/In);i<=Math.floor(s/In);i++)for(let a=Math.floor(n/In);a<=Math.floor(r/In);a++){let l=this.cells.get(i*1048576+a);if(l)for(let c of l)o.add(c)}return[...o].sort((i,a)=>i-a)}},aa=t=>{let e=1/0,n=1/0,s=-1/0,r=-1/0;for(let[o,i]of t)o<e&&(e=o),o>s&&(s=o),i<n&&(n=i),i>r&&(r=i);return[e,n,s,r]},Lo=new WeakMap;function Hn(t,e){let n=Lo.get(t);for((!n||n.n>t.length)&&Lo.set(t,n=new Co);n.n<t.length;n.n++){let[s,r,o,i]=e(t[n.n]);n.add(n.n,s,r,o,i)}return n}function ac(t){let e=Lo.get(t);for((!e||e.n>t.length)&&Lo.set(t,e=new Co);e.n<t.length;e.n++){let n=t[e.n].pts;for(let s=0;s+1<n.length;s++){let r=n[s],o=n[s+1],i=e.n*65536+s,a=Math.max(1,Math.ceil(Math.hypot(o[0]-r[0],o[1]-r[1])/(In/2)));for(let l=0;l<a;l++){let c=l/a,f=(l+1)/a,u=r[0]+(o[0]-r[0])*c,d=r[1]+(o[1]-r[1])*c,p=r[0]+(o[0]-r[0])*f,h=r[1]+(o[1]-r[1])*f;e.add(i,Math.min(u,p)-1,Math.min(d,h)-1,Math.max(u,p)+1,Math.max(d,h)+1)}}}return e}var En=(t,e,n,s,r)=>t.query(e,n,s,r),Ps=t=>aa(t),Ro=t=>[t.x,t.y,t.x+t.w,t.y+t.h];function lc(t,e,n,[s,r,o,i]){let a=0,l=n-1;for(let c of[0,1]){let f=e[c]-t[c],u=c?r:s,d=c?i:o;if(Math.abs(f)<1e-12){if(t[c]<u||t[c]>d)return[1,0];continue}let p=(u-t[c])/f*n-.5,h=(d-t[c])/f*n-.5;p>h&&([p,h]=[h,p]),a=Math.max(a,Math.floor(p)-1),l=Math.min(l,Math.ceil(h)+1)}return[a,l]}var ls=class t{polys=[];rects=[];lines=[];solids=[];slants=[];budget={spots:1/0,over:!1,told:!1};hidden(e){let n=0;for(let s of En(Hn(this.solids,Ps),...Ro(e)))n+=Os(this.solids[s],e);return n}hiddenPoly(e){let n=0;for(let s of En(Hn(this.solids,Ps),...aa(e)))n+=pr(e,this.solids[s]);return n}costPoly(e,n=1/0){let s=aa(e),r=0;for(let o of En(Hn(this.polys,i=>Ps(i.poly)),...s))r+=pr(e,this.polys[o].poly);for(let o of En(Hn(this.rects,i=>Ro(i.r)),...s))r+=Os(e,this.rects[o].r)*2;for(let o of En(Hn(this.slants,Ps),...s))r+=pr(e,this.slants[o])*2;if(r>=n)return r;for(let o of En(ac(this.lines),...s)){if(r>=n)return r;let i=this.lines[Math.floor(o/65536)].pts,a=o%65536,l=i[a],c=i[a+1],f=Math.hypot(c[0]-l[0],c[1]-l[1]),u=Math.max(1,Math.ceil(f/4)),[d,p]=lc(l,c,u,s);for(let h=d;h<=p;h++)ua(e,[l[0]+(c[0]-l[0])*(h+.5)/u,l[1]+(c[1]-l[1])*(h+.5)/u])&&(r+=f/u*4*.6)}return r}cost(e,n,s=.6){let r=Ro(e),o=0;for(let i of En(Hn(this.polys,a=>Ps(a.poly)),...r)){let a=this.polys[i];o+=Os(a.poly,e)*(a.owner===n?1.5:1)}for(let i of En(Hn(this.rects,a=>Ro(a.r)),...r)){let a=this.rects[i];(a.owner!==n||!n)&&(o+=ca(a.r,e)*2)}for(let i of En(Hn(this.slants,Ps),...r))o+=Os(this.slants[i],e)*2;if(s){let i=-1,a=0;for(let l of En(ac(this.lines),...r)){let c=Math.floor(l/65536);c!==i&&(i>=0&&(o+=a*s),i=c,a=0);let f=this.lines[c].pts,u=l%65536,d=f[u],p=f[u+1],h=Math.hypot(p[0]-d[0],p[1]-d[1]),m=Math.max(1,Math.ceil(h/4)),[y,I]=lc(d,p,m,r);for(let N=y;N<=I;N++){let M=d[0]+(p[0]-d[0])*(N+.5)/m,$=d[1]+(p[1]-d[1])*(N+.5)/m;M>=e.x&&M<=e.x+e.w&&$>=e.y&&$<=e.y+e.h&&(a+=h/m*4)}}i>=0&&(o+=a*s)}return o}fork(){let e=new t;return e.budget=this.budget,e.polys=this.polys,e.lines=this.lines,e.solids=this.solids,e.rects=[...this.rects],e.slants=this.slants,e}},fc=14;function mr(t,e,n,s){let r=Math.max(t.name?Jt(t.name,at.lbl):0,t.sub?Jt(t.sub,at.sub):0)+4,o=(t.name?1:0)+(t.sub?1:0),i=n-(t.name?11:9)-1,a=(o-1)*fc+(t.name?11:9)+4;return{x:s==="start"?e-2:s==="end"?e-r+2:e-r/2,y:i,w:r,h:a}}function hr(t,e,n,s,r,o){let i=Fn(n),a=we((e.x0+e.x1)/2,(e.y0+e.y1)/2,e.z1)[0],c=((t.name?1:0)+(t.sub?1:0)-1)*fc+4,f=i.y-6-c,u=i.y+Math.min(i.h,60)*.45,d=[];o&&d.push({...o,pen:0}),d.push({x:a,y:f,anchor:"middle",pen:o?20:0});for(let m of[12,24,40])d.push({x:a,y:f-m,anchor:"middle",pen:20+m});for(let m of[-30,30,-60,60])d.push({x:a+m,y:f-4,anchor:"middle",pen:30+Math.abs(m)});d.push({x:i.x+i.w+8,y:u,anchor:"start",pen:120}),d.push({x:i.x-8,y:u,anchor:"end",pen:120}),d.push({x:a,y:i.y+i.h+14,anchor:"middle",pen:300});let p,h=1/0;for(let m of d){let y=mr(t,m.x,m.y,m.anchor),I=s.cost(y,r,.15)*2+m.pen;I<h&&(h=I,p={x:m.x,y:m.y,anchor:m.anchor,rect:y})}return p}function fa(t,e,n,s){return{x:(s==="start"?e:s==="end"?e-t:e-t/2)-2,y:n-14,w:t+4,h:28}}function Io(t,e,n,s,r){let o=[{...s,pen:0}];for(let f of[-46,-66,-86,-106,-126,-146])for(let u of[0,-70,70,-140,140])o.push({x:e+u,y:n+f,anchor:"middle",pen:10+(-f-46)*.5+Math.abs(u)*.4});for(let f of[34,60,86])o.push({x:e,y:n+f,anchor:"middle",pen:60+f*.3});let i=s.x-e,a=s.y-n;for(let f of[-1,1])for(let u of[16,32,48])o.push({...s,y:n+a+f*u,x:e+i,pen:5+u});for(let f of[-1,1])for(let u of[30,60,90])for(let d of[0,16,-16])o.push({...s,x:e+i+f*u,y:n+a+d,pen:8+u*.6+Math.abs(d)});let l,c=1/0;for(let f of o){let u=fa(t,f.x,f.y,f.anchor),d=r.cost(u,void 0,.05)*3+f.pen;d<c&&(c=d,l={x:f.x,y:f.y,anchor:f.anchor,rect:u})}return l}var uc=t=>{let e=0;for(let n=0;n<t.length;n++){let s=t[n],r=t[(n+1)%t.length];e+=s[0]*r[1]-r[0]*s[1]}return e/2},la=t=>uc(t)<0?[...t].reverse():t;function ua(t,e){let n=la(t);for(let s=0;s<n.length;s++){let r=n[s],o=n[(s+1)%n.length];if((o[0]-r[0])*(e[1]-r[1])-(o[1]-r[1])*(e[0]-r[0])<0)return!1}return!0}function pr(t,e){let n=la(t),s=la(e);for(let r=0;r<s.length&&n.length;r++){let o=s[r],i=s[(r+1)%s.length],a=c=>(i[0]-o[0])*(c[1]-o[1])-(i[1]-o[1])*(c[0]-o[0]),l=n;n=[];for(let c=0;c<l.length;c++){let f=l[c],u=l[(c+1)%l.length],d=a(f),p=a(u);if(d>=0&&n.push(f),d>=0!=p>=0){let h=d/(d-p);n.push([f[0]+(u[0]-f[0])*h,f[1]+(u[1]-f[1])*h])}}}return n.length>=3?Math.abs(uc(n)):0}var Fo=24;function Bo(t,e){let[n,s,r,o]=e,i=t.x+t.w/2,a=t.y+t.h/2,l=[["left",i-n],["right",n+r-i],["top",a-s],["bottom",s+o-a]];l.sort((f,u)=>f[1]-u[1]);let c=l[0][0];return c==="left"?{edge:c,dx:-(t.x+t.w-n)-Fo,dy:0}:c==="right"?{edge:c,dx:n+r-t.x+Fo,dy:0}:c==="top"?{edge:c,dx:0,dy:-(t.y+t.h-s)-Fo}:{edge:c,dx:0,dy:s+o-t.y+Fo}}function _o(t,e,n){let s=$=>{let O=0;for(let E=$.parent;E;E=E.parent)O++;return O},r=$=>$.box.x0+$.box.y0+$.box.z0*.01,o=t.items.filter($=>$.type==="region").sort(($,O)=>s($)-s(O)||r($)-r(O)),i=t.items.filter($=>$.type==="node").sort(($,O)=>r($)-r(O)||$.box.z0-O.box.z0),a=[],l=Math.min(90,400/Math.max(1,o.length)),c=650;o.forEach(($,O)=>{let E=Fn(qt($.box));a.push({id:$.id,kind:"region",...Bo(E,n),delay:Math.round(O*l),dur:c,bbox:E})});let f=250+Math.round(l*o.length),u=Math.min(70,700/Math.max(1,i.length)),d=600;i.forEach(($,O)=>{let E=Fn(qt($.box));a.push({id:$.id,kind:"node",...Bo(E,n),delay:Math.round(f+O*u),dur:d,bbox:E})});let p=i.length?f+(i.length-1)*u:f,h=Math.round(p+300),m=Math.min(30,300/Math.max(1,e.length)),y=400,I=e.filter($=>$.points.length>=2).map(($,O)=>({id:$.id,delay:Math.round(h+O*m),dur:y})),N={delay:h+200,dur:400},M=Math.max(...a.map($=>$.delay+$.dur),...I.map($=>$.delay+$.dur),N.delay+N.dur);return{pieces:a,routes:I,labels:N,total:M}}function da(t){return Math.max(5600,Math.min(12500,2600+t.length*40))}function Do(t,e,n,s,r,o){let i=[],a=(w,P,b,v="error")=>{let g=r.locate(w);i.push({severity:v,message:P,line:g.line,col:g.col,path:w,hint:b})},l=t.steps??[],c=new Set(Object.keys(o.kinds)),f=new Map(s.map(w=>[w.id,w])),u=()=>[...n.byId.keys(),...f.keys()],d=new Map;l.forEach((w,P)=>{w.id&&(d.has(w.id)&&a(`${e}/steps/${P}/id`,`duplicate step id "${w.id}"`),d.set(w.id,P+1))});let p=l.length,h=(w,P)=>{if(typeof w=="number"){if(w<1||w>p){a(P,`there is no step ${w}; this scene has ${p} step(s)`);return}return w}let b=d.get(w);return b===void 0&&a(P,`unknown step "${w}"`+Zt(w,d.keys())),b},m=w=>Mn(o,o.kinds[w]?.color??"control"),y=[],I=w=>{y.includes(w)||y.push(w)};for(let w of s)I(w.kind);let N={},M=(w,P,b,v)=>{if(P===void 0&&b===void 0)return;let g=P!==void 0?h(P,v+"/appears"):1,R=b!==void 0?h(b,v+"/disappears"):p+1;N[w]=Array.from({length:p},(F,j)=>j+1>=(g??1)&&j+1<(R??p+1))};for(let w of n.items)M(w.id,w.appears,w.disappears,w.path);for(let w of s)M(w.id,w.raw.appears,w.raw.disappears,w.path);let $=[],O=[],E=[],x=[],T=()=>{for(let w of s){if(w.raw.appears!==void 0||w.raw.disappears!==void 0)continue;let P=[w.from,w.to].map(b=>b&&(N[b.id]??L(b)));P.some(Boolean)&&(N[w.id]=Array.from({length:p},(b,v)=>P.every(g=>!g||g[v])))}},L=w=>{for(let P=w.parent;P;P=P.parent)if(N[P.id])return N[P.id]};return l.forEach((w,P)=>{let b=P+1,v=`${e}/steps/${P}`,g=w.kind??"control";c.has(g)||a(v+"/kind",`unknown flow kind "${g}"`+Zt(g,c)),I(g);let R=new Set,F=[];(w.animate??[]).forEach((B,V)=>{let q=Array.isArray(B)?B:[B],Z=[];q.forEach((A,D)=>{let K=Array.isArray(B)?`${v}/animate/${V}/${D}`:`${v}/animate/${V}`,W,ie;if(typeof A=="string"){let te=/^([^:\s]+)\s*(?::\s*(\S+))?$/.exec(A.trim());W=te?te[1]:A,ie=te?.[2]}else{let te=Object.entries(A)[0];W=te[0],ie=te[1]}let de=f.get(W);if(!de){a(K,`unknown route "${W}"`+Zt(W,f.keys()));return}if(ie&&!c.has(ie)){a(K,`unknown flow kind "${ie}"`+Zt(ie,c));return}let X=ie??de.kind;I(X),Z.push({route:W,kind:X,color:m(X)}),R.add(W),de.from&&R.add(de.from.id),de.to&&R.add(de.to.id)}),Z.length&&F.push(Z)});let j=[];(w.pulse??[]).forEach((B,V)=>{let q=n.byId.get(B);if(!q){a(`${v}/pulse/${V}`,`unknown node "${B}"`+Zt(B,n.byId.keys()));return}let Z,A,D,K,W=q.node?as(n.catalog,q.node.asset):void 0;if(W?.pulse)[Z,A,D,K]=W.pulse(q.box);else{let X=q.box;Z=(X.x0+X.x1)/2,A=(X.y0+X.y1)/2,D=X.z1,K=Math.max(22,Math.min(60,(X.x1-X.x0+X.y1-X.y0)*8.5))}let[ie,de]=we(Z,A,D);j.push([ie,de,K*1.7,K*.98]),R.add(B)}),(w.highlight??[]).forEach((B,V)=>{!n.byId.has(B)&&!f.has(B)&&a(`${v}/highlight/${V}`,`unknown id "${B}"`+Zt(B,u())),R.add(B)});for(let[B,V]of[["show",!0],["hide",!1]])(w[B]??[]).forEach((q,Z)=>{if(!n.byId.has(q)&&!f.has(q)){a(`${v}/${B}/${Z}`,`unknown id "${q}"`+Zt(q,u()));return}let A=N[q]??(N[q]=Array(p).fill(!V));for(let D=P;D<p;D++)A[D]=V});if((w.say??[]).forEach((B,V)=>{let q,Z;if(Array.isArray(B.at))[q,Z]=we(B.at[0],B.at[1],B.at[2]??.36);else{let D=n.byId.get(B.at);if(!D){a(`${v}/say/${V}/at`,`unknown node "${B.at}"`+Zt(B.at,n.byId.keys()));return}let K=D.box;[q,Z]=we((K.x0+K.x1)/2,(K.y0+K.y1)/2,K.z1+.75)}let A=B.kind??g;c.has(A)||a(`${v}/say/${V}/kind`,`unknown flow kind "${A}"`+Zt(A,c)),O.push({step:b,x:q+(B.dx??0),y:Z+(B.dy??(Array.isArray(B.at)?0:-46)),ax:q,ay:Z,text:B.text,kind:A,anchor:B.anchor??"middle"})}),(w.mark??[]).forEach((B,V)=>{if(B.at){E.push({step:b,p:[B.at[0],B.at[1],B.at[2]??.36]});return}let q=B.on?f.get(B.on):void 0;if(!q){a(`${v}/mark/${V}`,B.on?`unknown route "${B.on}"`+Zt(B.on,f.keys()):'a mark needs "on: ROUTE" or "at: [x, y]"');return}let Z=q.points[q.points.length-1];E.push({step:b,p:[Z[0],Z[1],Z[2]+.6],on:q.id}),R.add(q.id)}),t.badges&&w.badge!==!1){let B=Array.isArray(w.badge)?[w.badge[0],w.badge[1],w.badge[2]??.36]:void 0,V=typeof w.badge=="string"?w.badge:F[0]?.[0]?.route,q=V?f.get(V):void 0;if(!B)if(q)B=pa(q.points);else if(V&&n.byId.get(V)){let Z=n.byId.get(V).box;B=[(Z.x0+Z.x1)/2,(Z.y0+Z.y1)/2,Z.z1+.3]}else typeof w.badge=="string"&&a(`${v}/badge`,`unknown id "${w.badge}"`+Zt(w.badge,u()));B&&x.push({step:b,num:w.number??b,kind:g,p:B})}for(let B of[...R])for(let V=n.byId.get(B)?.parent;V;V=V.parent)R.add(V.id);for(let B of n.items)B.region?.kind==="tunnel"&&(B.region.around??[]).some(V=>R.has(V))&&R.add(B.id);let U;if(w.focus?.length){let B=1/0,V=1/0,q=-1/0,Z=-1/0;w.focus.forEach((A,D)=>{let K=n.byId.get(A);if(!K){a(`${v}/focus/${D}`,`unknown node or region "${A}"`+Zt(A,n.byId.keys()));return}let W=K.box;for(let[ie,de,X]of[[W.x0,W.y0,W.z1],[W.x1,W.y0,W.z0],[W.x0,W.y1,W.z0],[W.x1,W.y1,W.z0],[W.x1,W.y0,W.z1],[W.x0,W.y1,W.z1]]){let[te,ye]=we(ie,de,X);B=Math.min(B,te),V=Math.min(V,ye),q=Math.max(q,te),Z=Math.max(Z,ye)}R.add(A)}),B<1/0&&(U=[Math.round(B-60),Math.round(V-70),Math.round(q+60),Math.round(Z+40)])}let ne=w.caption??"";$.push({n:b,num:w.number??b,kind:g,color:m(g),heading:w.heading,caption:ne,command:w.command??"",phases:F,pulses:j,lit:[...R],duration:w.duration===void 0||w.duration==="auto"?da(ne):w.duration,...U?{focus:U}:{}})}),T(),{steps:$,says:O,marks:E,badges:x,vis:N,diags:i,kindsUsed:y}}function pa(t){let e=t.slice(1).map((s,r)=>Math.hypot(s[0]-t[r][0],s[1]-t[r][1],s[2]-t[r][2])),n=e.reduce((s,r)=>s+r,0)/2;for(let s=0;s<e.length;s++){if(n<=e[s]&&e[s]>0){let r=n/e[s],o=t[s],i=t[s+1];return[o[0]+(i[0]-o[0])*r,o[1]+(i[1]-o[1])*r,o[2]+(i[2]-o[2])*r]}n-=e[s]}return t[0]}function Zt(t,e){let n=Yn(t,e);return n?` (did you mean "${n}"?)`:""}function dc(t,e){if(!e)return t;let[n,s,r,o]=e,i=t[2]/t[3],a=r-n,l=o-s;a/l<i?a=l*i:l=a/i,a=Math.min(a,t[2]),l=Math.min(l,t[3]);let c=(n+r)/2,f=(s+o)/2,u=Math.max(t[0],Math.min(t[0]+t[2]-a,c-a/2)),d=Math.max(t[1],Math.min(t[1]+t[3]-l,f-l/2));return[u,d,a,l]}var Vo=(t,e)=>e.role??pt(t,e.kind)?.role,zo=(t,e)=>pt(t,e.region.kind)?.shape;function Go({scene:t,layout:e,routes:n,steps:s,theme:r,id:o,gridStep:i=1}){let a=new gs,l={base:"",floor:"",flows:"",blocks:[],air:"",labels:"",marks:"",badges:""},c=new ls;c.budget.spots=Ko;let f=g=>s.vis[g]?{"data-vis":"1"}:{},u=e.items.filter(g=>g.type==="region"),d=g=>{let R=0;for(let F=g.parent;F;F=F.parent)R++;return R},p=e.catalog,h=u.filter(g=>zo(p,g)!=="walled"&&zo(p,g)!=="tunnel"),m=Vs(h.map(g=>({box:g.box,r:g}))).map(g=>g.r).sort((g,R)=>d(g)-d(R));for(let g of m)l.base+=xu(a,p,g,f(g.id),i);for(let g of u.filter(R=>zo(p,R)==="walled")){for(let F of jo(g))c.solids.push(qt(F));for(let F of jo(g))l.blocks.push({box:F,svg:me("g",{class:`blk k-${Vo(p,g.region)} wall${g.region.ghost?" ghost":""}`,"data-id":g.id,"data-dim":"1",...f(g.id)},a.blockFaces(F))});let R=g.region.gate;if(R&&!R.node){let F=ur(g,R.height??(g.region.height??.8)+.3,.3,.3);c.solids.push(qt(F)),l.blocks.push({box:F,svg:me("g",{class:"blk k-gate","data-id":g.id,...f(g.id)},a.blockFaces(F))})}g.region.label&&(g.region["label-style"]??"face")!=="none"&&(l.labels+=a.faceText(g.box.x0+.3,g.box.y1,g.box.z0+.13,g.region.label,"slabname sm fz",at.sm,"left","start",{"data-id":g.id,...f(g.id)}))}for(let g of u.filter(R=>zo(p,R)==="tunnel"))l.air+=ku(a,g,f(g.id));let y=e.items.filter(g=>g.type==="node");for(let g of y){let R=g.node,F=Qt(p,R.asset),j=R.ghost||(R.deco??[]).includes("ghost"),U=["blk",`k-${R.role??F.role}`,F.cls,j?"ghost":""].filter(Boolean).join(" ");l.blocks.push({box:g.box,svg:me("g",{class:U,"data-id":g.id,"data-dim":"1",...f(g.id)},F.draw(a,g.box,R))}),c.polys.push({poly:qt(g.box),owner:g.id}),c.solids.push(qt(g.box))}let I=Vs(l.blocks).map(g=>g.svg).join(""),N=new Set,M={};for(let g of n){if(g.points.length<2)continue;let R=g.points.map(U=>we(U[0],U[1],U[2]));R.forEach(U=>a.bounds.add(U));let F="M"+R.map(ts).join(" L");M[g.id]=F;let j=g.raw.arrow!==!1;j&&N.add(g.kind),l.flows+=me("g",{"data-hl":g.id,"data-id":g.id,...f(g.id)},me("path",{d:F,class:`flow f-${g.kind}`,"marker-end":j?`url(#ah-${o}-${g.kind})`:void 0})),c.lines.push({pts:R,owner:g.id})}for(let g of N)a.def(`ah-${o}-${g}`,me("marker",{id:`ah-${o}-${g}`,viewBox:"0 0 10 10",refX:"7",refY:"5",markerWidth:"4.2",markerHeight:"4.2",orient:"auto-start-reverse"},me("path",{d:"M0,0 L10,5 L0,10 z",style:`fill:${Mn(r,r.kinds[g]?.color??"control")}`})));for(let g of a.planePolys)c.slants.push(g);let $=y.filter(g=>g.node.label||g.node.sub).sort((g,R)=>(R.box.x1-R.box.x0)*(R.box.y1-R.box.y0)-(g.box.x1-g.box.x0)*(g.box.y1-g.box.y0));for(let g of $)l.labels+=wu(a,p,g,c,f(g.id));let O=[];for(let g of n)if(g.raw.label&&g.points.length>=2){let R=vu(a,g,c,f(g.id),e);l.floor+=R.svg,R.warning&&O.push({path:`${g.path}/label`,message:R.warning}),c.budget.over&&!c.budget.told&&(c.budget.told=!0,O.push({path:g.path,message:`from route "${g.id}" on, route labels were placed without weighing what other labels and lines cover: the scene is too large to search every spot (${Ko.toLocaleString("en")} spots); split it into scenes, or give the labels "along", "side" or "at"`}))}(t.notes??[]).forEach((g,R)=>{let F=Su(a,g,e,n,`${o}-note-${R}`);g.floor?l.floor+=F:l.labels+=F});let E=[],x=new Map;for(let g of s.says){let R=x.get(g.step)??c.fork();x.set(g.step,R);let F=Jt(g.text,at.say)+18,j=Io(F,g.ax,g.ay,{x:g.x,y:g.y,anchor:g.anchor},R);R.rects.push({r:j.rect,owner:""}),E.push({step:g.step,...j.rect,text:g.text});let U=j.rect.x+2;a.bounds.addRect(j.rect.x,j.rect.y,j.rect.w,j.rect.h);let ne=Mn(r,r.kinds[g.kind]?.color??"control");l.marks+=me("g",{class:"say","data-step":g.step},me("rect",{x:U,y:j.y-12,width:F,height:24,rx:12,style:`stroke:${ne}`})+me("text",{x:U+F/2,y:j.y+4,"text-anchor":"middle",style:`fill:${ne}`},ut(g.text)))}for(let g of s.marks){let[R,F]=we(...g.p);a.bounds.addRect(R-12,F-12,24,24),l.marks+=me("g",{class:"xm","data-step":g.step,"data-hl":g.on},me("circle",{cx:R,cy:F,r:10})+me("path",{d:`M${it(R-4.5)},${it(F-4.5)} L${it(R+4.5)},${it(F+4.5)} M${it(R+4.5)},${it(F-4.5)} L${it(R-4.5)},${it(F+4.5)}`}))}for(let g of s.badges){let[R,F]=we(...g.p);a.bounds.addRect(R-13,F-13,26,26),l.badges+=me("g",{class:`badge c-${g.kind}`,"data-go":g.step,"data-badge":g.step,tabindex:"0",role:"button","aria-label":`Step ${g.num}`},me("circle",{cx:R,cy:F,r:11.5})+me("text",{x:R,y:F+.5},String(g.num)))}let T=a.bounds,L=22,w=T.empty?[0,0,100,100]:[Math.floor(T.x0-L),Math.floor(T.y0-L),Math.ceil(T.x1-T.x0+L*2),Math.ceil(T.y1-T.y0+L*2)],P=[...a.defs.values()].join(""),b=(g,R)=>me("g",{class:"g-"+g},R);return{svg:me("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:w.join(" "),role:"img","aria-label":t.aria??t.title,"data-scene":o},me("defs",{},P)+b("base",l.base)+b("floor",l.floor)+b("flows",l.flows)+b("blocks",I)+b("air",l.air)+b("labels",l.labels)+b("marks",l.marks)+b("badges",l.badges)+b("anim","")),viewBox:w,texts:a.texts,paths:M,warnings:O,callouts:E,assembly:_o(e,n,w)}}function yu(t,e){let n=t.z1+.002,s=1e-6,r=[],o=(i,a)=>{let l=we(i[0],i[1],n),c=we(a[0],a[1],n);r.push(`M${ts(l)}L${ts(c)}`)};for(let i=Math.ceil((t.x0+s)/e)*e;i<t.x1-s;i+=e)o([i,t.y0],[i,t.y1]);for(let i=Math.ceil((t.y0+s)/e)*e;i<t.y1-s;i+=e)o([t.x0,i],[t.x1,i]);return r.length?me("path",{class:"grid",d:r.join("")}):""}function xu(t,e,n,s,r=1){let o=n.region,i=n.box,a=Vo(e,o),l=pt(e,o.kind),c=l?.shape,f={"data-id":n.id,"data-dim":"1",...s},u="";c==="cloud"?u=me("g",{class:`blk k-${a} cloud`,...f},vo(t,i)):c==="zone"?u=me("g",{class:`zone k-${a}`,...f},t.poly([[i.x0,i.y0,i.z1],[i.x1,i.y0,i.z1],[i.x1,i.y1,i.z1],[i.x0,i.y1,i.z1]])):u=me("g",{class:`blk k-${a}${o.ghost?" ghost":""}`,...f},t.blockFaces(i)+yu(i,r));let d=o["label-style"]??l?.labelStyle;if(o.label&&d!=="none")if(d==="face"){let p=i.z1-i.z0,h=N=>N.size*.73/Xe,m=c==="slab"&&.28+h(at.slabname)+.08>p,y=c==="slab"&&!m,I=y?i.z0+.28:m?i.z0+Math.max(.02,(p-h(at.sm))/2):i.z0+Math.min(.1,p*.25);u+=me("g",f,t.faceText(i.x0+(y?.6:.3),i.y1,I,o.label,y?"slabname":"slabname sm",y?at.slabname:at.sm,"left","start"))}else if(d==="face-right")u+=me("g",f,t.faceText(i.x1,i.y0+.6,i.z0+Math.max(.14,(i.z1-i.z0)*.2),o.label,"slabname",at.slabname,"right","end"));else{let p=c==="cloud"?"middle":"start",h=c==="cloud"?(i.x0+i.x1)/2:i.x0+.35,m=c==="cloud"?(i.y0+i.y1)/2:i.y1-.35;u+=me("g",f,t.floorText(h,m,i.z1+.01,o.label,"slabname sm","x",p))}return u}function jo(t){let{x0:e,y0:n,x1:s,y1:r,z0:o,z1:i}=t.box,a=$n,l=t.region.gate,c=[],f=d=>{d.x1-d.x0>1e-6&&d.y1-d.y0>1e-6&&c.push({...d,z0:o,z1:i})},u=(d,p,h)=>{if(!l||l.side!==h)return[[d,p]];let m=l.at??.5,y=l.width??2,I=h==="e"||h==="w"?n+(r-n)*m:e+(s-e)*m;return[[d,I-y/2],[I+y/2,p]]};for(let[d,p]of u(e,s,"n"))f({x0:d,y0:n,x1:p,y1:n+a});for(let[d,p]of u(n+a,r-a,"w"))f({x0:e,y0:d,x1:e+a,y1:p});for(let[d,p]of u(n+a,r-a,"e"))f({x0:s-a,y0:d,x1:s,y1:p});for(let[d,p]of u(e,s,"s"))f({x0:d,y0:r-a,x1:p,y1:r});return c}function wu(t,e,n,s,r){let o=n.node,i=Qt(e,o.asset),a=n.box,l={name:o.label,sub:o.sub},c=o["label-at"],f;if(c){let d=Fn(qt(a)),p=c.side??"above",h=d.y+Math.min(d.h,60)*.45;p==="right"?f={x:d.x+d.w+8,y:h,anchor:"start"}:p==="left"?f={x:d.x-8,y:h,anchor:"end"}:p==="below"?f={x:d.x+d.w/2,y:d.y+d.h+14,anchor:"middle"}:f=hr(l,a,qt(a),new ls,n.id),f={...f,x:f.x+(c.dx??0),y:f.y+(c.dy??0)}}else{let d=i.label?i.label(a,o,!!o.sub):void 0;f=hr(l,a,qt(a),s,n.id,d)}s.rects.push({r:mr(l,f.x,f.y,f.anchor),owner:""});let u="";return o.label&&(u+=t.text(f.x,f.y,o.label,"lbl",at.lbl,f.anchor,{},n.id)),o.sub&&(u+=t.text(f.x,o.label?f.y+14:f.y,o.sub,"sub mono",at.sub,f.anchor,{},n.id)),me("g",{"data-id":n.id,"data-dim":"1",...r},u)}function ku(t,e,n){let{x0:s,y0:r,x1:o,y1:i,z0:a,z1:l}=e.box,c=t.blockFaces(e.box),f=o-s>=i-r,u=Math.max(1,Math.round((f?o-s:i-r)/1.6));for(let p=1;p<u;p++){let h=f?s+(o-s)*p/u:r+(i-r)*p/u;c+=t.poly(f?[[h,r,l],[h,i,l],[h,i,a]]:[[s,h,l],[o,h,l],[o,h,a]],"rib")}let d=e.region.label;return d&&e.region["label-style"]!=="none"&&(c+=f?t.faceText(s+.35,i,a+.14,d,"tunname",at.tunname,"left","start"):t.faceText(o,i-.35,a+.18,d,"tunname",at.tunname,"right","start")),me("g",{class:"tunnel","data-id":e.id,"data-dim":"1",...n},c)}var Ko=2e4;function vu(t,e,n,s,r){let o=typeof e.raw.label=="string"?{text:e.raw.label}:e.raw.label,i=`floor mono t-${e.kind}`,a={"data-hl":e.id,...s},l=at.floor;if(o.at){let N=o.at.length>2?o.at[2]:e.points[0][2];return{svg:t.floorText(o.at[0],o.at[1],N,o.text,i,o.dir??"x",o.anchor??"start",a)}}let c=e.points,f=[];for(let N=0;N+1<c.length;N++){let M=c[N],$=c[N+1];Math.abs(M[2]-$[2])>1e-6||f.push({i:N,len:Math.hypot($[0]-M[0],$[1]-M[1])})}if(!f.length)return{svg:"",warning:`label "${o.text}" of route "${e.id}" was dropped: the route has no level segment`};let u=o.along?f.filter(N=>N.i===Math.min(o.along-1,c.length-2)):[...f].sort((N,M)=>M.len-N.len),d=.22,p=11/Xe,h=N=>{let M=Jt(N,l)/Xe,$,O=1/0,E=0;e:for(let x of u.length?u:f){let T=c[x.i],L=c[x.i+1],w=T[2],P=Math.abs(T[1]-L[1])<1e-6,b=P?Math.min(T[0],L[0]):Math.min(T[1],L[1]),v=P?Math.max(T[0],L[0]):Math.max(T[1],L[1]),g=P?T[1]:T[0],R=o.side==="left"?[-1]:o.side==="right"?[1]:[-1,1],F=[];for(let j=b+.3;j<=Math.max(b+.3,v-M-.2)+1e-9;j+=.4)F.push(j);for(let j=v-M-.2+.4;j<v+.5&&v-b<M+.5;j+=.6)F.push(j);for(let j of R)for(let U of F){if(O<=E*.5)break e;let ne=j<0?g-d:g+d+p,B,V,q;if(P?(B=U,V=ne,q=[we(B,V-p,w),we(B+M,V-p,w),we(B+M,V,w),we(B,V,w)]):(B=ne,V=U+M,q=[we(B-p,V,w),we(B-p,V-M,w),we(B,V-M,w),we(B,V,w)]),(P?[[B,V-p],[B+M,V-p],[B+M,V],[B,V]]:[[B-p,V],[B-p,V-M],[B,V-M],[B,V]]).some(([ie,de])=>Math.abs(Ns(r,ie,de)+.01-w)>.001)){E++;continue}let A=n.hiddenPoly(q),D=A*50+E*.5,K=n.budget.spots-- >0;K||(n.budget.over=!0);let W=D>=O?1/0:K?D+n.costPoly(q,O-D):D;E++,W<O&&(O=W,$={x:B,y:V,z:w,dir:P?"x":"y",rect:Fn(q),poly:q,hidden:A})}}return $&&$.hidden<6?$:void 0},m=o.text,y=h(m),I;if(!y){let N=o.text.split(/(\s+)/);for(let M=N.length-1;M>0&&!y;M--){let $=N.slice(0,M).join("").trimEnd().replace(/[\s,;:·–-]+$/,"")+"\u2026";if($.length<6)break;let O=h($);O&&(y=O,m=$)}I=y?`label of route "${e.id}" shortened to "${m}": no clear floor for the whole text`:`label "${o.text}" of route "${e.id}" was dropped: blocks cover every spot beside it`,y?I+='; give it "along", "side" or "at", or move the nodes apart':I+='; give it "at: [x, y]", or move the nodes apart'}return y?(n.slants.push(y.poly),{svg:t.floorText(y.x,y.y,y.z+.01,m,i,y.dir,"start",a),warning:I}):{svg:"",warning:I}}function Su(t,e,n,s,r){let o=e.on?s.find(f=>f.id===e.on):void 0,i=e.on&&!o?n.byId.get(e.on):void 0,a=e.at,l={"data-id":r,"data-hl":o?.id,"data-dim":o?void 0:"1"},c=e.kind??o?.kind??"control";if(e.floor){let f=a&&a.length>2?a[2]:o?o.points[0][2]:i?i.floor:.36,[u,d]=a?[a[0],a[1]]:o?[o.points[0][0]+.35,o.points[0][1]-.25]:i?[i.box.x0+.3,i.box.y1-.3]:[0,0];return t.floorText(u,d,f+.01,e.floor,`floor mono t-${c}`,e.dir??"x",e.anchor??"start",l)}if(e.face){let f=i?.box,[u,d,p]=a?[a[0],a[1],a[2]??.45]:f?[f.x0+.3,f.y1,f.z0+.13]:[0,0,0];return t.faceText(u,d,p,e.face,"slabname sm",at.sm,"left",e.anchor??"start",l)}if(e.label||e.sub){let f=i?.box,u=a?[a[0],a[1],a[2]??.36]:f?[(f.x0+f.x1)/2,(f.y0+f.y1)/2,f.z1+.75]:[0,0,0],[d,p]=we(u[0],u[1],u[2]),h=d+(e.dx??0),m=p-18+(e.dy??0),y=e.anchor??"middle",I="";return e.label&&(I+=t.text(h,m,e.label,"lbl",at.lbl,y)),e.sub&&(I+=t.text(h,e.label?m+14:m,e.sub,"sub mono",at.sub,y)),me("g",l,I)}return""}var ma=`
142
+ `)[0]}`,line:c.line,col:c.col,path:""})}function o(l,c={}){let f=Yl(l),u=n.contents,d={line:1,col:1},p=h=>{let m=h?.range;m&&(d=r(m[0]))};p(u);for(let h=0;h<f.length;h++){let m=f[h];if(_t(u)){let y=u.items.find(I=>Le(I)&&Ne(I.key)&&String(I.key.value)===String(m));if(!y)break;if(c.key&&h===f.length-1)return p(y.key),d;p(y.key),u=y.value,u&&p(u)}else if(Dt(u)&&typeof m=="number"){if(u=u.items[m],!u)break;p(u)}else break}return d}function i(l){let c=n.contents;for(let p of Yl(l)){if(_t(c)){let h=c.items.find(m=>Le(m)&&Ne(m.key)&&String(m.key.value)===String(p));if(!h)return;c=h.value}else if(Dt(c)&&typeof p=="number")c=c.items[p];else return;if(!c)return}let f=c.range;if(!f)return;let u=e.linePos(Math.max(f[0],f[1]-1)).line,d=t.split(/\r?\n/);for(;u>e.linePos(f[0]).line&&/^\s*(#.*)?$/.test(d[u-1]??"");)u--;return{start:e.linePos(f[0]).line,end:u}}let a=null;return n.errors.length||(a=n.toJS({maxAliasCount:100})),{data:a,locate:o,span:i,diags:s}}var nu=new Set(["svg","g","defs","marker","symbol","title","desc","path","polygon","polyline","line","rect","circle","ellipse","text","tspan","linearGradient","radialGradient","stop","clipPath"]),su=new Set(["id","class","role","transform","viewBox","width","height","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","fx","fy","d","points","offset","gradientUnits","gradientTransform","markerWidth","markerHeight","refX","refY","orient","markerUnits","text-anchor","dominant-baseline","font-size","font-weight","letter-spacing","fill","stroke","stroke-width","stroke-dasharray","stroke-linecap","stroke-linejoin","opacity","fill-opacity","stroke-opacity","stop-color","stop-opacity","marker-start","marker-mid","marker-end","clip-path","preserveAspectRatio","vector-effect","paint-order","style"]),ru=new Set(["fill","stroke","marker-start","marker-mid","marker-end","clip-path","style"]),ou={amp:"&",lt:"<",gt:">",quot:'"',apos:"'","#39":"'"},Wl=t=>t.replace(/&(amp|lt|gt|quot|apos|#39);/g,(e,n)=>ou[n]);function Qi(t,e){return t.startsWith("data-")||t.startsWith("aria-")?/^[a-z][\w-]*$/.test(t):!(!su.has(t)||ru.has(t)&&/url\(\s*(?!['"]?#)|javascript:|expression\(|@import/i.test(e))}function Zi(t){let e={name:"#root",attrs:[],children:[]},n=[{node:e,dropped:!1}],s=/<(?:!--)[\s\S]*?-->|<\/([a-zA-Z][\w:-]*)\s*>|<([a-zA-Z][\w:-]*)((?:\s+[\w:-]+="[^"]*")*)\s*(\/?)>|([^<]+)/g,r,o=0;for(;r=s.exec(t);){if(r.index!==o)throw new Error(`not the renderer's SVG at ${o}: ${JSON.stringify(t.slice(o,o+40))}`);o=s.lastIndex;let i=n[n.length-1];if(r[0].charAt(1)!=="!"){if(r[1]){if(n.length<2||i.node.name!==r[1])throw new Error(`a stray </${r[1]}>`);n.pop();continue}if(r[2]){let a=r[2],l=[];for(let u of r[3].matchAll(/([\w:-]+)="([^"]*)"/g)){let d=u[1],p=Wl(u[2]);d==="xmlns"||d.startsWith("xmlns:")||Qi(d,p)&&l.push([d,p])}let c={name:a,attrs:l,children:[]},f=i.dropped||!nu.has(a);f||i.node.children.push(c),r[4]||n.push({node:c,dropped:f});continue}!i.dropped&&r[5].trim()&&i.node.children.push(Wl(r[5]))}}if(o!==t.length)throw new Error(`not the renderer's SVG at ${o}`);if(n.length!==1)throw new Error(`<${n[n.length-1].node.name}> is never closed`);return e}var iu="http://www.w3.org/2000/svg",Jl=t=>t.replace(/var\(--([a-zA-Z][\w-]*)/g,"var(--iso-$1");function Xl(t,e=document){let n=r=>{let o=e.createElementNS(iu,r.name);for(let[i,a]of r.attrs)i==="style"?o.style.cssText=Jl(a):o.setAttribute(i,/var\(--/.test(a)?Jl(a):a);for(let i of r.children)o.append(typeof i=="string"?e.createTextNode(i):n(i));return o},s=Zi(t).children.find(r=>typeof r!="string"&&r.name==="svg");if(!s)throw new Error("the drawing has no <svg>");return n(s)}var au=t=>t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),lr=class t{name;attrs=[];children=[];style={};constructor(e){this.name=e}setAttribute(e,n){let s=this.attrs.findIndex(r=>r[0]===e);s>=0?this.attrs[s][1]=String(n):this.attrs.push([e,String(n)])}getAttribute(e){return this.attrs.find(n=>n[0]===e)?.[1]??null}append(...e){for(let n of e)n!=null&&this.children.push(n)}set textContent(e){this.children=[String(e)]}get textContent(){return this.children.map(e=>typeof e=="string"?e:e.textContent).join("")}toNode(){let e=Object.entries(this.style).filter(([,n])=>n!==""&&n!==void 0).map(([n,s])=>`${au(n)}:${s}`).join(";");return{name:this.name,attrs:e?[...this.attrs,["style",e]]:[...this.attrs],children:this.children.map(n=>n instanceof t?n.toNode():n)}}},Ql={createElementNS:(t,e)=>new lr(e)},Zl=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),lu=t=>Zl(t).replace(/"/g,"&quot;");function bo(t,e=new Set(["style"])){if(typeof t=="string")return Zl(t);let n=t.attrs.map(([r,o])=>` ${r}="${lu(o)}"`).join("");if(!t.children.length)return`<${t.name}${n}/>`;let s=e.has(t.name)?t.children.map(r=>typeof r=="string"?r.replace(/<\//g,"<\\/"):bo(r,e)).join(""):t.children.map(r=>bo(r,e)).join("");return`<${t.name}${n}>${s}</${t.name}>`}var cu=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function ea(t){let e=new TextEncoder().encode(t),n=e.length,s=Math.ceil((n+9)/64),r=new Uint8Array(s*64);r.set(e),r[n]=128;let o=new DataView(r.buffer);o.setUint32(r.length-4,n*8>>>0),o.setUint32(r.length-8,Math.floor(n/536870912));let i=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64),l=(c,f)=>c>>>f|c<<32-f;for(let c=0;c<s;c++){for(let N=0;N<16;N++)a[N]=o.getUint32(c*64+N*4);for(let N=16;N<64;N++){let M=l(a[N-15],7)^l(a[N-15],18)^a[N-15]>>>3,$=l(a[N-2],17)^l(a[N-2],19)^a[N-2]>>>10;a[N]=a[N-16]+M+a[N-7]+$>>>0}let[f,u,d,p,h,m,y,I]=i;for(let N=0;N<64;N++){let M=I+(l(h,6)^l(h,11)^l(h,25))+(h&m^~h&y)+cu[N]+a[N]>>>0,$=(l(f,2)^l(f,13)^l(f,22))+(f&u^f&d^u&d)>>>0;I=y,y=m,m=h,h=p+M>>>0,p=d,d=u,u=f,f=M+$>>>0}i[0]+=f,i[1]+=u,i[2]+=d,i[3]+=p,i[4]+=h,i[5]+=m,i[6]+=y,i[7]+=I}return[...i].map(c=>c.toString(16).padStart(8,"0")).join("")}function ec(t){if(t!=="sha256")throw new Error(`only sha256 here, not ${t}`);let e="",n={update(s){return e+=s,n},digest(s){return ea(e)}};return n}var Tc={};bi(Tc,{BOARD_3D:()=>Wn,BOARD_CSS:()=>Mc,FLAT_DEFAULTS:()=>Sa,FLAT_FONTS:()=>Ma,GRID_CSS:()=>wa,LABEL_BUDGET:()=>Vo,MARKS_CSS:()=>ya,Obstacles:()=>ls,PAGE_CSS:()=>ga,PLAYER_CSS:()=>qo,PLAYER_UI_CSS:()=>xa,ROUTE_BUDGET:()=>Po,WALL_T:()=>$n,assembly:()=>_o,baseCss:()=>Uo,boardCatalog:()=>$c,boardDiagram:()=>Ec,boardErrors:()=>Ho,boardOf:()=>Wo,boxAsset:()=>sc,boxSilhouette:()=>yc,calloutRect:()=>da,cardAsset:()=>$a,cloudPath:()=>oa,compileRaw:()=>hc,convexOverlap:()=>pr,defaultLabel:()=>oc,drawCloud:()=>vo,drawDecos:()=>ra,drawingCss:()=>ba,durationFor:()=>ma,facePainter:()=>ko,flatHit:()=>Sc,floorAt:()=>Ns,floorOf:()=>xc,focusView:()=>mc,gateBox:()=>ur,iconPainter:()=>cr,inConvex:()=>pa,kindsCss:()=>xo,labelRect:()=>mr,layoutFlat:()=>Os,lineRectArea:()=>uc,localAt:()=>bc,markCss:()=>wo,metricsMeasure:()=>vc,midpoint:()=>ha,noSource:()=>ka,nodeKind:()=>as,nodeKindOr:()=>Qt,offscreen:()=>Bo,openList:()=>la,overlap2:()=>Mo,overlaps:()=>Yo,paddingOf:()=>wc,parseEnd:()=>Ut,place:()=>$o,placeBoard:()=>gr,placeCallout:()=>Io,placeNodeLabel:()=>hr,placeholderIcon:()=>sa,plate:()=>rc,polyBounds:()=>Fn,polyRectArea:()=>Rs,rectArea:()=>ua,regionKind:()=>pt,regionRole:()=>Ko,registerMarks:()=>nc,renderScene:()=>Go,resolveSteps:()=>Do,routeAll:()=>Ro,screenToGrid:()=>gc,silhouette:()=>qt,simplify:()=>dr,snapMove:()=>kc,wallHeight:()=>yo,wallsOf:()=>jo});var pt=(t,e)=>e!==void 0&&Object.hasOwn(t.regions,e)?t.regions[e]:void 0,as=(t,e)=>t.nodes[e??t.defaultNode],Qt=(t,e)=>as(t,e)??t.nodes[t.defaultNode],yo=t=>Object.values(t.regions).find(e=>e.shape==="walled")?.z[1]??.8,xo=t=>Object.values(t.regions).map(e=>e.css??"").join("");var ta=Object.create(null),na=[];function nc(t){Object.assign(ta,t.icons??{}),Object.assign(bs,t.faces??{}),t.css&&!na.includes(t.css)&&na.push(t.css)}var wo=()=>na.join(""),cr=t=>Object.hasOwn(ta,t)?ta[t]:void 0,ko=t=>Object.hasOwn(bs,t)?bs[t]:void 0;function sa(t,e){let n=(e.x0+e.x1)/2,s=(e.y0+e.y1)/2,r=e.z1+.005,o=Math.min(.6,(e.x1-e.x0)*.24,(e.y1-e.y0)*.24),i=[[n-o,s-o,r],[n+o,s-o,r],[n+o,s+o,r],[n-o,s+o,r]];return t.poly(i,"ico-unknown")+t.line3([n-o*.3,s-o*.35,r],[n+o*.3,s-o*.35,r],"ico-unknown-q")+t.line3([n+o*.3,s-o*.35,r],[n,s+o*.1,r],"ico-unknown-q")+t.line3([n,s+o*.45,r],[n,s+o*.5,r],"ico-unknown-q")}function ra(t,e,n){let s="";for(let r of n??[])r==="terminal"?s+=Vs(t,e,3):r==="envelope"?s+=Er(t,e):r==="bubble"?s+=Tr(t,e):r==="file-lines"?s+=Ar(t,e):typeof r=="object"&&(r.terminal&&(s+=Vs(t,e,r.terminal)),r.icon&&(s+=(cr(r.icon)??sa)(t,e)));return s}var fu=(t,e)=>(t.deco??e.deco??[]).filter(n=>n!=="ghost");function sc(t,e,n,s,r,o){let i={name:t,description:e,size:n,role:s,deco:r,draw:(a,l,c)=>a.blockFaces(l)+ra(a,l,fu(c,i))+(o?o(a,l):"")};return i}function rc(t){let[e,n]=$r(t);return{x0:e-.75,y0:n-.75,x1:e+.75,y1:n+.75,z0:t.z0,z1:t.z0+.18}}function oa(t,e){let n=Math.max(8,Math.min(t,e)*.18),s=n*.55,r=s,o=s,i=t-s,a=e-s,l=(c,f,u,d)=>{let p=Math.hypot(u-c,d-f),h=Math.max(1,Math.round(p/(n*1.7))),m="";for(let y=1;y<=h;y++){let I=c+(u-c)*y/h,N=f+(d-f)*y/h,M=p/h/2*1.08;m+=` A${M.toFixed(1)},${M.toFixed(1)} 0 0 1 ${I.toFixed(1)},${N.toFixed(1)}`}return m};return`M${r.toFixed(1)},${o.toFixed(1)}`+l(r,o,i,o)+l(i,o,i,a)+l(i,a,r,a)+l(r,a,r,o)+"Z"}function vo(t,e){let n={...e,z0:e.z1},s=a=>{let[l,c]=we(e.x0,e.y0,a);return[yt,.5,-yt,.5,l,c]},r=(e.x1-e.x0)*Xe,o=(e.y1-e.y0)*Xe,i=oa(r,o);return t.onMatrix(s(e.z0),r,o,()=>me("path",{d:i,class:"lft cloud-side"}))+t.onMatrix(s(e.z1),r,o,()=>me("path",{d:i,class:"top cloud-top"}))}function oc(t,e){let[n,s]=we((t.x0+t.x1)/2,(t.y0+t.y1)/2,t.z1+.75);return{x:n,y:s-18+(e?0:6),anchor:"middle"}}var $n=.16,ia=["right-of","left-of","below","behind"];function $o(t,e,n,s,r,o={},i){let a=[],l=(b,v,g,O=!1,F="error")=>{let j=n.locate(b,{key:O});a.push({severity:F,message:v,line:j.line,col:j.col,path:b,hint:g})},c=[],f=new Map,u=[],d=new Map,p=new Set([...Object.keys(s.roles),...Object.keys(o)]);function h(b,v){let g=f.get(b.id);if(g){let O=n.locate(g.path+"/id");return l(b.path+"/id",`duplicate id "${b.id}" (first used on line ${O.line})`),!1}return f.set(b.id,b),c.push(b),b.parent=v,v?v.children.push(b):u.push(b),!0}let m=()=>({x0:0,y0:0,z0:0,x1:0,y1:0,z1:0});function y(b,v,g){let O={id:b.id,type:"node",path:v,children:[],box:m(),floor:0,node:b,appears:b.appears,disappears:b.disappears};h(O,g)&&(b.nodes??[]).forEach((F,j)=>y(F,`${v}/nodes/${j}`,O))}function I(b,v,g){let O={id:b.id,type:"region",path:v,children:[],box:m(),floor:0,region:b,appears:b.appears,disappears:b.disappears};h(O,g)&&((b.nodes??[]).forEach((F,j)=>y(F,`${v}/nodes/${j}`,O)),(b.regions??[]).forEach((F,j)=>I(F,`${v}/regions/${j}`,O)))}(t.regions??[]).forEach((b,v)=>I(b,`${e}/regions/${v}`,void 0)),(t.nodes??[]).forEach((b,v)=>y(b,`${e}/nodes/${v}`,void 0));let N=()=>f.keys(),M=()=>c.filter(b=>b.type==="region").map(b=>b.id);for(let b of[...c]){let v=b.node??b.region;if(v.in!==void 0){let O=f.get(v.in);if(!O){l(b.path+"/in",`unknown region "${v.in}"`+fr(v.in,M()));continue}if(O.type!=="region"){l(b.path+"/in",`"${v.in}" is a node, not a region; put nodes on a node with its own "nodes:" list`);continue}if(b.parent&&b.parent!==O){l(b.path+"/in",`"${b.id}" is written inside "${b.parent.id}" but says in: ${v.in}; use one or the other`);continue}for(let F=O;F;F=F.parent)if(F===b){l(b.path+"/in",`"${b.id}" cannot be inside itself`);continue}b.parent||(u.splice(u.indexOf(b),1),b.parent=O,O.children.push(b))}if(b.node){let O=b.node.asset;O!==void 0&&!as(r,O)&&l(b.path+"/asset",`unknown asset "${O}"`+fr(O,Object.keys(r.nodes)),`assets: ${Object.keys(r.nodes).join(", ")}`)}let g=(b.node??b.region).role;g!==void 0&&!p.has(g)&&l(b.path+"/role",`unknown colour role "${g}"`+fr(g,p),`add it under "roles:" at the top of the file, or use one of: ${[...p].join(", ")}`)}for(let b of c){let v=b.region?.gate;if(!v?.node)continue;let g=f.get(v.node);if(!g){l(b.path+"/gate/node",`unknown node "${v.node}"`+fr(v.node,N()));continue}if(g.type!=="node"){l(b.path+"/gate/node",`"${v.node}" is a region; a gate is a node`);continue}g.placedBy=b.id;let O=g.node;(O.at||ia.some(F=>O[F]))&&l(g.path,`"${g.id}" is the gate of "${b.id}", which places it; its own placement is ignored`,void 0,!1,"warning")}let $=b=>b.gap??t.gap??2;function R(b){let v=b.node,g=Qt(r,v.asset),O=v.size,F=g.size[0],j=g.size[1],U=g.size[2];if(O&&(F=O[0],j=O[1],O.length>2&&(U=O[2])),b.placedBy){let ne=f.get(b.placedBy).region,B=ne.gate,K=B.width??2,q=O?Math.min(F,j):.3;U=O&&O.length>2?U:B.height??(ne.height??yo(r))+.3,B.side==="e"||B.side==="w"?(F=q,j=K):(F=K,j=q)}return[F,j,U]}function E(b,v,g,O,F){for(let X of v)T(X);let j=v.filter(X=>!X.placedBy),U=new Set(j),ne=new Set,B=[],K=new Set,q=X=>{let te=X.node??X.region,ye=[];for(let Fe of ia){let S=te[Fe];if(S===void 0)continue;let Y=f.get(S);if(!Y){l(`${X.path}/${Fe}`,`unknown id "${S}"`+fr(S,N()));continue}if(Y===X){l(`${X.path}/${Fe}`,`"${X.id}" cannot be placed ${Fe} itself`);continue}if(!U.has(Y)){let se=le=>le.parent?`"${le.parent.id}"`:"the scene";l(`${X.path}/${Fe}`,`"${S}" is in ${se(Y)} but "${X.id}" is in ${se(X)}; relative placement works between items in the same region`,Y.placedBy?`"${S}" is a gate, placed by its ${f.get(Y.placedBy)?.region?.kind??"region"}`:`place "${X.id}" relative to something in ${se(X)}, or use "at:"`);continue}ye.push(Y)}if(!ye.length&&!te.at){let Fe=j.indexOf(X);Fe>0&&ye.push(j[Fe-1])}return ye},Z=X=>{if(!ne.has(X)){if(K.has(X)){l(X.path,`placement loop: "${X.id}" is placed relative to something placed relative to it`);return}K.add(X),q(X).forEach(Z),K.delete(X),ne.add(X),B.push(X)}};j.forEach(Z);for(let X of B){let te=X.node??X.region,ye=d.get(X),Fe=ia.find(S=>te[S]!==void 0&&f.get(te[S])&&U.has(f.get(te[S])));if(te.at&&Fe&&l(`${X.path}/at`,`"${X.id}" has both "at" and "${Fe}"; "at" wins`,void 0,!0,"warning"),te.at)ye.x=te.at[0],ye.y=te.at[1];else if(Fe)w(ye,d.get(f.get(te[Fe])),Fe,$(te),te.align??"center");else{let S=j.indexOf(X);S>0?w(ye,d.get(j[S-1]),O==="row"?"right-of":"below",$(te),"center"):(ye.x=g,ye.y=g)}te.shift&&(ye.x+=te.shift[0],ye.y+=te.shift[1])}if(F||!j.length)return{w:0,d:0};let A=1/0,D=1/0,V=-1/0,W=-1/0;for(let X of j){let te=d.get(X);A=Math.min(A,te.x),D=Math.min(D,te.y),V=Math.max(V,te.x+te.w),W=Math.max(W,te.y+te.d)}let ie=Math.min(0,A-g),de=Math.min(0,D-g);if(ie||de)for(let X of j){let te=d.get(X);te.x-=ie,te.y-=de}return{w:V-ie+g,d:W-de+g}}function w(b,v,g,O,F){let j=()=>{b.y=F==="start"?v.y:F==="end"?v.y+v.d-b.d:v.y+(v.d-b.d)/2},U=()=>{b.x=F==="start"?v.x:F==="end"?v.x+v.w-b.w:v.x+(v.w-b.w)/2};g==="right-of"?(b.x=v.x+v.w+O,j()):g==="left-of"?(b.x=v.x-O-b.w,j()):g==="below"?(b.y=v.y+v.d+O,U()):(b.y=v.y-O-b.d,U())}function T(b){if(b.type==="node"){let[B,K,q]=R(b);d.set(b,{x:0,y:0,w:B,d:K,h:q,z:b.node.z??0}),b.children.length&&E(b,b.children,0,"row",!0);return}let v=b.region,g=v.padding??pt(r,v.kind)?.pad,O=!!v.size,F=E(b,b.children,g,v.flow??"row",O),j=v.size?v.size[0]:Math.max(F.w,g*2+.5),U=v.size?v.size[1]:Math.max(F.d,g*2+.5);if(!v.size&&v.gate){let B=(v.gate.width??2)+1;v.gate.side==="e"||v.gate.side==="w"?U=Math.max(U,B):j=Math.max(j,B)}let ne=v.size&&v.size.length>2?v.size[2]:v.height??pt(r,v.kind).z[1];d.set(b,{x:0,y:0,w:j,d:U,h:ne,z:0})}E(void 0,u,0,t.flow??"row",!0);function L(b,v,g,O){let F=d.get(b),j=v+F.x,U=g+F.y;if(b.type==="region"){let ne=pt(r,b.region.kind),[B]=ne.z,K=ne.floor,q=ne.shape==="slab"&&pt(r,b.parent?.region?.kind)?.shape==="slab"?0:B,Z=b.region.z??0,A=O+q+Z,D=O+F.h+Z;b.box={x0:j,y0:U,z0:A,x1:j+F.w,y1:U+F.d,z1:D},b.floor=K?D:O}else{let ne=O+F.z;b.box={x0:j,y0:U,z0:ne,x1:j+F.w,y1:U+F.d,z1:ne+F.h},b.floor=b.box.z1}for(let ne of b.children)ne.placedBy||L(ne,j,U,b.floor)}for(let b of u)b.placedBy||L(b,0,0,0);if(i){let b=g=>Math.round(g/i)*i,v=g=>Math.round(g*1e9)/1e9;for(let g of c){if(g.placedBy)continue;let O=g.box,F=b(O.x0),j=b(O.x1),U=b(O.y0),ne=b(O.y1);j-F<i&&(j=F+i),ne-U<i&&(ne=U+i),g.box={...O,x0:v(F),x1:v(j),y0:v(U),y1:v(ne)};let B=g.node??g.region;B.at&&B.at.forEach((K,q)=>{let Z=K/i;Math.abs(Z-Math.round(Z))>1e-6&&l(`${g.path}/at/${q}`,`${K} is not on the ${i} grid; it is drawn at ${v(b(K))}`,void 0,!1,"warning")})}}for(let b of c){let v=b.region?.gate;if(!v?.node)continue;let g=f.get(v.node);!g||g.placedBy!==b.id||(g.box=ur(b,d.get(g).h,d.get(g).w,d.get(g).d),g.floor=g.box.z1)}for(let b of c){let v=b.children.filter(g=>!g.placedBy);for(let g=0;g<v.length;g++)for(let O=g+1;O<v.length;O++){let F=v[g],j=v[O];So(F,r)||So(j,r)||Mo(F.box,j.box)&&l(j.path,`"${j.id}" overlaps "${F.id}"`,'move one with "at", a relative placement, "gap" or "shift"',!1,"warning")}if(b.parent&&b.parent.type==="region"&&!b.placedBy){let g=b.parent.box,O=b.box,F=1e-6;(O.x0<g.x0-F||O.y0<g.y0-F||O.x1>g.x1+F||O.y1>g.y1+F)&&l(b.path,`"${b.id}" sticks out of region "${b.parent.id}"`,`make "${b.parent.id}" bigger, or leave out its "size" so it fits its contents`,!1,"warning")}}{let b=u.filter(v=>!v.placedBy);for(let v=0;v<b.length;v++)for(let g=v+1;g<b.length;g++){let O=b[v],F=b[g];Mo(O.box,F.box)&&!So(O,r)&&!So(F,r)&&l(F.path,`"${F.id}" overlaps "${O.id}"`,'move one with "at", a relative placement, "gap" or "shift"',!1,"warning")}}let x=new Set,P=a.filter(b=>{let v=b.path+b.message;return x.has(v)?!1:(x.add(v),!0)});return{items:c,byId:f,roots:u,diags:P,catalog:r}}var So=(t,e)=>t.type==="region"&&["zone","tunnel"].includes(pt(e,t.region.kind)?.shape??"");function ur(t,e,n,s){let r=t.region.gate,o=t.box,i=t.box.z0,a=r.at??.5,l=r.width??2;if(r.side==="w"||r.side==="e"){let u=r.side==="w"?o.x0+$n/2:o.x1-$n/2,d=o.y0+(o.y1-o.y0)*a;return{x0:u-n/2,x1:u+n/2,y0:d-l/2,y1:d+l/2,z0:i,z1:i+e}}let c=r.side==="n"?o.y0+$n/2:o.y1-$n/2,f=o.x0+(o.x1-o.x0)*a;return{x0:f-l/2,x1:f+l/2,y0:c-s/2,y1:c+s/2,z0:i,z1:i+e}}function Mo(t,e,n=1e-6){return t.x0<e.x1-n&&e.x0<t.x1-n&&t.y0<e.y1-n&&e.y0<t.y1-n}function fr(t,e){let n=Yn(t,e);return n?` (did you mean "${n}"?)`:""}var Ln=.2,Eo=.05,uu=.6,To=.25,Ao={n:[0,-1],s:[0,1],e:[1,0],w:[-1,0]};function Ut(t){let e=/^(.*?)(?:\.(n|e|s|w|top))?$/.exec(t);return{id:e[1],side:e[2]}}var ic=new WeakMap;function Ns(t,e,n){let s=ic.get(t);if(!s){s=[];for(let i of t.items){if(i.type!=="region"||!pt(t.catalog,i.region.kind)?.floor)continue;let a=0;for(let l=i.parent;l;l=l.parent)a++;s.push({r:i,d:a})}ic.set(t,s)}let r=0,o=-1;for(let{r:i,d:a}of s){let l=i.box,c=1e-6;e>=l.x0-c&&e<=l.x1+c&&n>=l.y0-c&&n<=l.y1+c&&a>o&&(o=a,r=i.floor)}return r}function du(t,e){let n=[(t.x0+t.x1)/2,(t.y0+t.y1)/2],s=[(e.x0+e.x1)/2,(e.y0+e.y1)/2],r=s[0]-n[0],o=s[1]-n[1],i=Math.max(e.x0-t.x1,t.x0-e.x1),a=Math.max(e.y0-t.y1,t.y0-e.y1);return i>0&&(a<=0||i>=a)?r>0?"e":"w":a>0?o>0?"s":"n":Math.abs(r)>=Math.abs(o)?r>0?"e":"w":o>0?"s":"n"}var Po=5e5;function Ro(t,e,n,s,r,o){let i=[],a=(M,$,R,E="error")=>{let w=s.locate(M);i.push({severity:E,message:$,line:w.line,col:w.col,path:M,hint:R})},l=t.routes??[],c={left:Po},f=0,u=()=>n.items.map(M=>M.id),d=new Map,p=[],h=[];l.forEach((M,$)=>{let R=`${e}/routes/${$}`;(d.has(M.id)||n.byId.has(M.id))&&a(R+"/id",`duplicate id "${M.id}"`),d.set(M.id,$);let E=M.kind??"send";r.has(E)||a(R+"/kind",`unknown flow kind "${E}"`+aa(E,r),`kinds: ${[...r].join(", ")}; add one under "kinds:"`);let w={id:M.id,raw:M,path:R,kind:E,points:[]},T=(L,x)=>{let{id:P}=Ut(L),b=n.byId.get(P);if(!b){a(`${R}/${x}`,`unknown node "${P}"`+aa(P,u()));return}return b};w.from=T(M.from,"from"),w.to=T(M.to,"to"),p.push(w),h.push({r:w})});let m=new Map;for(let M of h){let{r:$}=M;if(!$.from||!$.to||$.raw.points)continue;let R=Ut($.raw.from).side,E=Ut($.raw.to).side,w=$.raw.via?.[0],T=$.raw.via?.[$.raw.via.length-1],L=(v,g)=>{if(Array.isArray(v))return{x0:v[0],x1:v[0],y0:v[1],y1:v[1],z0:0,z1:0};if(typeof v=="string"){let O=n.byId.get(Ut(v).id);if(O)return O.box}return g.box},x=(v,g,O)=>{let F=g??du(v.box,O);return{node:v,side:F,explicit:!!g,p:[0,0],z:0}};M.a=x($.from,R,L(w,$.to)),M.b=x($.to,E,L(T,$.from));let P=L(w,$.to),b=L(T,$.from);for(let[v,g]of[[M.a,P],[M.b,b]]){let O=`${v.node.id}.${v.side}`;m.has(O)||m.set(O,[]),m.get(O).push({e:v,other:[(g.x0+g.x1)/2,(g.y0+g.y1)/2]})}}for(let[,M]of m){let $=M[0].e,R=$.node.box,E=$.side,w=E==="e"||E==="w"?1:0;M.sort((v,g)=>v.other[w]-g.other[w]);let T=w?R.y0:R.x0,L=w?R.y1:R.x1,x=(T+L)/2,P=Math.max(0,L-T-.3),b=M.length>1?Math.min(uu,P/(M.length-1)):0;M.forEach((v,g)=>{let O=(g-(M.length-1)/2)*b,F=x+O,j=v.e.node.box.z0;if(E==="top"){v.e.p=[(R.x0+R.x1)/2,(R.y0+R.y1)/2],v.e.z=R.z1;return}let[U,ne]=Ao[E];v.e.p=w?[U>0?R.x1+Eo:R.x0-Eo,F]:[F,ne>0?R.y1+Eo:R.y0-Eo],v.e.z=j})}let y=[];for(let M of n.items)M.type==="node"&&y.push(M.box);let I=[];for(let M of n.items.filter($=>pt(n.catalog,$.region?.kind)?.shape==="walled")){let{x0:$,y0:R,x1:E,y1:w}=M.box,T=$n,L=M.region.gate,x=[[{x0:$,y0:R,x1:E,y1:R+T,z0:0,z1:0},"n"],[{x0:$,y0:w-T,x1:E,y1:w,z0:0,z1:0},"s"],[{x0:$,y0:R,x1:$+T,y1:w,z0:0,z1:0},"w"],[{x0:E-T,y0:R,x1:E,y1:w,z0:0,z1:0},"e"]];for(let[P,b]of x)if(L&&L.side===b){if(L.node)continue;let v=L.at??.5,g=L.width??2;if(b==="e"||b==="w"){let O=R+(w-R)*v;I.push({...P,y1:O-g/2},{...P,y0:O+g/2})}else{let O=$+(E-$)*v;I.push({...P,x1:O-g/2},{...P,x0:O+g/2})}}else I.push(P)}let N=new Map;for(let M of h){let{r:$,a:R,b:E}=M;if($.raw.points){$.points=$.raw.points.map(F=>[F[0],F[1],F.length>2?F[2]:Ns(n,F[0],F[1])+.01]);continue}if(!R||!E)continue;let w=[];($.raw.via??[]).forEach((F,j)=>{if(Array.isArray(F))if(o){let U=ne=>Math.round(Math.round(ne/o)*o*1e9)/1e9;F.forEach((ne,B)=>{Math.abs(ne/o-Math.round(ne/o))>1e-6&&a(`${$.path}/via/${j}/${B}`,`${ne} is not on the ${o} grid; it is drawn at ${U(ne)}`,void 0,"warning")}),w.push({p:[U(F[0]),U(F[1])]})}else w.push({p:[F[0],F[1]]});else{let{id:U,side:ne}=Ut(F),B=n.byId.get(U);if(!B){a(`${$.path}/via/${j}`,`unknown node "${U}"`+aa(U,u()));return}let K=ne&&ne!=="top"?ne:"n",[q,Z]=Ao[K],A=B.box;w.push({p:[q?q>0?A.x1+.4:A.x0-.4:(A.x0+A.x1)/2,Z?Z>0?A.y1+.4:A.y0-.4:(A.y0+A.y1)/2]})}});let L=y.filter(F=>F!==R.node.box&&F!==E.node.box).concat($.raw.cross?[]:I).filter(F=>!No(R.node.box,F)&&!No(E.node.box,F)&&!No(F,R.node.box)&&!No(F,E.node.box)),x=R.side==="top"?void 0:Ao[R.side],P=E.side==="top"?void 0:Ao[E.side],b=[R.p,...w.map(F=>F.p),E.p],v=[R.p],g=x,O=!0;for(let F=0;F+1<b.length;F++){let j=F+2===b.length,U=mu(b[F],b[F+1],L,N,g,j&&P?[-P[0],-P[1]]:void 0,c);if(!U){O=!1;break}v.push(...U.slice(1));let ne=v.length;if(ne>=2){let B=Math.sign(v[ne-1][0]-v[ne-2][0]),K=Math.sign(v[ne-1][1]-v[ne-2][1]);g=[B,K]}}!O&&c.left<=0?(f++,v=[R.p,[E.p[0],R.p[1]],E.p]):O||(a($.path,`no path found for route "${$.id}" from "${R.node.id}" to "${E.node.id}"`,'add "via" points, or use "points" to draw it by hand',"warning"),v=[R.p,[E.p[0],R.p[1]],E.p]),v=dr(v);for(let F=0;F+1<v.length;F++)pu(N,v[F],v[F+1]);$.points=bu(n,v,R,E)}return f&&a(e,`${f} of ${p.length} routes were drawn as plain elbows: the scene is too large to route them all around what stands in the way (${Po.toLocaleString("en")} search steps)`,'split it into scenes, or give the busiest routes "via" points or "points"',"warning"),{routes:p,diags:i}}function No(t,e){return e.x0>=t.x0-1e-6&&e.x1<=t.x1+1e-6&&e.y0>=t.y0-1e-6&&e.y1<=t.y1+1e-6&&e.z0>=t.z1-1e-6}var ac=(t,e)=>`${Math.round(t/Ln)},${Math.round(e/Ln)}`;function pu(t,e,n){let s=Math.max(1,Math.round(Math.hypot(n[0]-e[0],n[1]-e[1])/Ln));for(let r=0;r<=s;r++){let o=ac(e[0]+(n[0]-e[0])*r/s,e[1]+(n[1]-e[1])*r/s);t.set(o,(t.get(o)??0)+1)}}function lc(t,e,n){for(let s of n)if(t>s.x0-To&&t<s.x1+To&&e>s.y0-To&&e<s.y1+To)return!0;return!1}function mu(t,e,n,s,r,o,i={left:1/0}){if((Math.abs(t[0]-e[0])<1e-6||Math.abs(t[1]-e[1])<1e-6)&&gu(t,e,n)){let B=[Math.sign(e[0]-t[0]),Math.sign(e[1]-t[1])],K=!r||r[0]===B[0]&&r[1]===B[1],q=!o||o[0]===B[0]&&o[1]===B[1];if(K&&q)return[t,e]}if(i.left<=0)return null;let a=B=>Math.round((B-t[0])/Ln),l=B=>Math.round((B-t[1])/Ln),c=B=>t[0]+B*Ln,f=B=>t[1]+B*Ln,u=a(e[0]),d=l(e[1]),p=30,h=Math.min(0,u)-p,m=Math.max(0,u)+p,y=Math.min(0,d)-p,I=Math.max(0,d)+p,N=1.2,M=Ln,$=.06,R=[[1,0],[-1,0],[0,1],[0,-1]],E=m-h+1,w=I-y+1,T=(B,K)=>(B-h)*w+(K-y),L=new Int8Array(E*w).fill(-1),x=new Float64Array(E*w).fill(-1),P=new Float64Array(E*w*4).fill(1/0),b=(B,K)=>{let q=T(B,K);return L[q]<0&&(L[q]=lc(c(B),f(K),n)?1:0),L[q]===1},v=(B,K)=>{let q=T(B,K);return x[q]<0&&(x[q]=s.get(ac(c(B),f(K)))??0),x[q]},g=la(),O=(B,K)=>(Math.abs(B-u)+Math.abs(K-d))*M,F=r?R.findIndex(B=>B[0]===r[0]&&B[1]===r[1]):-1;g.push({i:0,j:0,d:F,g:0,f:O(0,0),idx:0,hp:0});let j=(B,K)=>Math.abs(B)+Math.abs(K)<=2,U=(B,K)=>Math.abs(B-u)+Math.abs(K-d)<=2,ne=0;for(;g.length()&&ne++<2e5;){if(i.left--<=0)return null;let B=g.take();if(B.i===u&&B.j===d&&!(o&&B.d>=0&&(R[B.d][0]!==o[0]||R[B.d][1]!==o[1]))){let K=[];for(let q=B;q;q=q.prev)K.push([c(q.i),f(q.j)]);return K.reverse(),K[0]=t,hu(dr(K),e)}for(let K=0;K<4;K++){let q=R[K];if(B.d>=0&&q[0]===-R[B.d][0]&&q[1]===-R[B.d][1])continue;let Z=B.i+q[0],A=B.j+q[1];if(Z<h||Z>m||A<y||A>I||!j(Z,A)&&!U(Z,A)&&b(Z,A))continue;if((j(Z,A)||U(Z,A))&&b(Z,A)&&!(Z===u&&A===d)){let ie=j(Z,A)?r:o&&[-o[0],-o[1]];if(!ie||(j(Z,A)?q[0]!==ie[0]||q[1]!==ie[1]:q[0]!==o[0]||q[1]!==o[1]))continue}let D=B.d>=0&&B.d!==K?N:0,V=B.g+M+D+v(Z,A)*$,W=T(Z,A)*4+K;P[W]<=V||(P[W]=V,g.push({i:Z,j:A,d:K,g:V,f:V+O(Z,A),prev:B,idx:0,hp:0}))}}return null}function la(){let t=[],e=[],n=(i,a)=>i.f<a.f||i.f===a.f&&i.idx<a.idx,s=(i,a)=>{let l=e[i];e[i]=e[a],e[a]=l,e[i].hp=i,e[a].hp=a},r=i=>{for(;i>0;){let a=i-1>>1;if(!n(e[i],e[a]))break;s(i,a),i=a}},o=i=>{for(;;){let a=2*i+1,l=a+1,c=i;if(a<e.length&&n(e[a],e[c])&&(c=a),l<e.length&&n(e[l],e[c])&&(c=l),c===i)return;s(i,c),i=c}};return{length:()=>t.length,push(i){i.idx=t.length,t.push(i),i.hp=e.length,e.push(i),r(i.hp)},take(){let i=e[0],a=e.pop();e.length&&(e[0]=a,a.hp=0,o(0));let l=t.pop();return l!==i&&(t[i.idx]=l,l.idx=i.idx,r(l.hp)),i}}}function hu(t,e){let n=t.map(o=>[o[0],o[1]]),s=n.length,r=n[s-1];if(s>=2){let o=n[s-2];Math.abs(o[1]-r[1])<1e-9?(o[1]=e[1],s>=3&&Math.abs(n[s-3][1]-r[1])<1e-9&&(n[s-3][1]=e[1])):Math.abs(o[0]-r[0])<1e-9&&(o[0]=e[0],s>=3&&Math.abs(n[s-3][0]-r[0])<1e-9&&(n[s-3][0]=e[0]))}return n[s-1]=e,dr(n)}function gu(t,e,n){let s=Math.max(1,Math.round(Math.hypot(e[0]-t[0],e[1]-t[1])/(Ln/2)));for(let r=2;r<s-1;r++)if(lc(t[0]+(e[0]-t[0])*r/s,t[1]+(e[1]-t[1])*r/s,n))return!1;return!0}function dr(t){let e=[];for(let n of t){let s=e.length;if(!(s&&Math.abs(e[s-1][0]-n[0])<1e-6&&Math.abs(e[s-1][1]-n[1])<1e-6)){if(s>=2){let r=e[s-2],o=e[s-1];if(Math.abs(r[0]-o[0])<1e-6&&Math.abs(o[0]-n[0])<1e-6||Math.abs(r[1]-o[1])<1e-6&&Math.abs(o[1]-n[1])<1e-6){e[s-1]=n;continue}}e.push(n)}}return e}function bu(t,e,n,s){let r=new Set,o=new Set;for(let c of t.items)c.type!=="region"||!pt(t.catalog,c.region.kind)?.floor||(r.add(c.box.x0),r.add(c.box.x1),o.add(c.box.y0),o.add(c.box.y1));let i=[],a=(c,f)=>Ns(t,c,f)+.01;for(let c=0;c+1<e.length;c++){let[f,u]=e[c],[d,p]=e[c+1],h=[0,1];if(Math.abs(u-p)<1e-6)for(let m of r){let y=(m-f)/(d-f);y>1e-6&&y<1-1e-6&&h.push(y)}else for(let m of o){let y=(m-u)/(p-u);y>1e-6&&y<1-1e-6&&h.push(y)}h.sort((m,y)=>m-y);for(let m=0;m+1<h.length;m++){let y=h[m],I=h[m+1],N=(y+I)/2,M=a(f+(d-f)*N,u+(p-u)*N),$=[f+(d-f)*y,u+(p-u)*y,M],R=[f+(d-f)*I,u+(p-u)*I,M],E=i[i.length-1];E&&(Math.abs(E[0]-$[0])>1e-6||Math.abs(E[1]-$[1])>1e-6||Math.abs(E[2]-$[2])>1e-6)?i.push($):E||i.push($),i.push(R)}}i.length&&(i[0][2]=n.side==="top"?n.z:n.node.box.z0+.01,i[i.length-1][2]=s.side==="top"?s.z:s.node.box.z0+.01);let l=[];for(let c of i){let f=l.length;if(f>=2){let u=l[f-2],d=l[f-1],p=Math.abs(u[2]-d[2])<1e-9&&Math.abs(d[2]-c[2])<1e-9,h=Math.abs(u[0]-d[0])<1e-6&&Math.abs(d[0]-c[0])<1e-6||Math.abs(u[1]-d[1])<1e-6&&Math.abs(d[1]-c[1])<1e-6;if(p&&h){l[f-1]=c;continue}}l.push(c)}return l}function aa(t,e){let n=Yn(t,e);return n?` (did you mean "${n}"?)`:""}function qt(t){return[we(t.x0,t.y0,t.z1),we(t.x1,t.y0,t.z1),we(t.x1,t.y0,t.z0),we(t.x1,t.y1,t.z0),we(t.x0,t.y1,t.z0),we(t.x0,t.y1,t.z1)]}function Fn(t){let e=t.map(o=>o[0]),n=t.map(o=>o[1]),s=Math.min(...e),r=Math.min(...n);return{x:s,y:r,w:Math.max(...e)-s,h:Math.max(...n)-r}}function Rs(t,e){let n=t,s=(a,l)=>{let c=[];for(let f=0;f<n.length;f++){let u=n[f],d=n[(f+1)%n.length],p=a(u),h=a(d);p&&c.push(u),p!==h&&c.push(l(u,d))}n=c},r=a=>(l,c)=>[a,l[1]+(c[1]-l[1])*(a-l[0])/(c[0]-l[0])],o=a=>(l,c)=>[l[0]+(c[0]-l[0])*(a-l[1])/(c[1]-l[1]),a];if(s(a=>a[0]>=e.x,r(e.x)),!n.length||(s(a=>a[0]<=e.x+e.w,r(e.x+e.w)),!n.length)||(s(a=>a[1]>=e.y,o(e.y)),!n.length)||(s(a=>a[1]<=e.y+e.h,o(e.y+e.h)),!n.length))return 0;let i=0;for(let a=0;a<n.length;a++){let l=n[a],c=n[(a+1)%n.length];i+=l[0]*c[1]-c[0]*l[1]}return Math.abs(i)/2}function ua(t,e){let n=Math.min(t.x+t.w,e.x+e.w)-Math.max(t.x,e.x),s=Math.min(t.y+t.h,e.y+e.h)-Math.max(t.y,e.y);return n>0&&s>0?n*s:0}function uc(t,e){let n=0;for(let s=0;s+1<t.length;s++){let r=t[s],o=t[s+1],i=Math.hypot(o[0]-r[0],o[1]-r[1]),a=Math.max(1,Math.ceil(i/4));for(let l=0;l<a;l++){let c=r[0]+(o[0]-r[0])*(l+.5)/a,f=r[1]+(o[1]-r[1])*(l+.5)/a;c>=e.x&&c<=e.x+e.w&&f>=e.y&&f<=e.y+e.h&&(n+=i/a*4)}}return n}var In=64,Co=class{cells=new Map;n=0;add(e,n,s,r,o){for(let i=Math.floor(n/In);i<=Math.floor(r/In);i++)for(let a=Math.floor(s/In);a<=Math.floor(o/In);a++){let l=i*1048576+a,c=this.cells.get(l);c||this.cells.set(l,c=[]),c[c.length-1]!==e&&c.push(e)}}query(e,n,s,r){let o=new Set;for(let i=Math.floor(e/In);i<=Math.floor(s/In);i++)for(let a=Math.floor(n/In);a<=Math.floor(r/In);a++){let l=this.cells.get(i*1048576+a);if(l)for(let c of l)o.add(c)}return[...o].sort((i,a)=>i-a)}},ca=t=>{let e=1/0,n=1/0,s=-1/0,r=-1/0;for(let[o,i]of t)o<e&&(e=o),o>s&&(s=o),i<n&&(n=i),i>r&&(r=i);return[e,n,s,r]},Lo=new WeakMap;function Hn(t,e){let n=Lo.get(t);for((!n||n.n>t.length)&&Lo.set(t,n=new Co);n.n<t.length;n.n++){let[s,r,o,i]=e(t[n.n]);n.add(n.n,s,r,o,i)}return n}function cc(t){let e=Lo.get(t);for((!e||e.n>t.length)&&Lo.set(t,e=new Co);e.n<t.length;e.n++){let n=t[e.n].pts;for(let s=0;s+1<n.length;s++){let r=n[s],o=n[s+1],i=e.n*65536+s,a=Math.max(1,Math.ceil(Math.hypot(o[0]-r[0],o[1]-r[1])/(In/2)));for(let l=0;l<a;l++){let c=l/a,f=(l+1)/a,u=r[0]+(o[0]-r[0])*c,d=r[1]+(o[1]-r[1])*c,p=r[0]+(o[0]-r[0])*f,h=r[1]+(o[1]-r[1])*f;e.add(i,Math.min(u,p)-1,Math.min(d,h)-1,Math.max(u,p)+1,Math.max(d,h)+1)}}}return e}var En=(t,e,n,s,r)=>t.query(e,n,s,r),Ps=t=>ca(t),Oo=t=>[t.x,t.y,t.x+t.w,t.y+t.h];function fc(t,e,n,[s,r,o,i]){let a=0,l=n-1;for(let c of[0,1]){let f=e[c]-t[c],u=c?r:s,d=c?i:o;if(Math.abs(f)<1e-12){if(t[c]<u||t[c]>d)return[1,0];continue}let p=(u-t[c])/f*n-.5,h=(d-t[c])/f*n-.5;p>h&&([p,h]=[h,p]),a=Math.max(a,Math.floor(p)-1),l=Math.min(l,Math.ceil(h)+1)}return[a,l]}var ls=class t{polys=[];rects=[];lines=[];solids=[];slants=[];budget={spots:1/0,over:!1,told:!1};hidden(e){let n=0;for(let s of En(Hn(this.solids,Ps),...Oo(e)))n+=Rs(this.solids[s],e);return n}hiddenPoly(e){let n=0;for(let s of En(Hn(this.solids,Ps),...ca(e)))n+=pr(e,this.solids[s]);return n}costPoly(e,n=1/0){let s=ca(e),r=0;for(let o of En(Hn(this.polys,i=>Ps(i.poly)),...s))r+=pr(e,this.polys[o].poly);for(let o of En(Hn(this.rects,i=>Oo(i.r)),...s))r+=Rs(e,this.rects[o].r)*2;for(let o of En(Hn(this.slants,Ps),...s))r+=pr(e,this.slants[o])*2;if(r>=n)return r;for(let o of En(cc(this.lines),...s)){if(r>=n)return r;let i=this.lines[Math.floor(o/65536)].pts,a=o%65536,l=i[a],c=i[a+1],f=Math.hypot(c[0]-l[0],c[1]-l[1]),u=Math.max(1,Math.ceil(f/4)),[d,p]=fc(l,c,u,s);for(let h=d;h<=p;h++)pa(e,[l[0]+(c[0]-l[0])*(h+.5)/u,l[1]+(c[1]-l[1])*(h+.5)/u])&&(r+=f/u*4*.6)}return r}cost(e,n,s=.6){let r=Oo(e),o=0;for(let i of En(Hn(this.polys,a=>Ps(a.poly)),...r)){let a=this.polys[i];o+=Rs(a.poly,e)*(a.owner===n?1.5:1)}for(let i of En(Hn(this.rects,a=>Oo(a.r)),...r)){let a=this.rects[i];(a.owner!==n||!n)&&(o+=ua(a.r,e)*2)}for(let i of En(Hn(this.slants,Ps),...r))o+=Rs(this.slants[i],e)*2;if(s){let i=-1,a=0;for(let l of En(cc(this.lines),...r)){let c=Math.floor(l/65536);c!==i&&(i>=0&&(o+=a*s),i=c,a=0);let f=this.lines[c].pts,u=l%65536,d=f[u],p=f[u+1],h=Math.hypot(p[0]-d[0],p[1]-d[1]),m=Math.max(1,Math.ceil(h/4)),[y,I]=fc(d,p,m,r);for(let N=y;N<=I;N++){let M=d[0]+(p[0]-d[0])*(N+.5)/m,$=d[1]+(p[1]-d[1])*(N+.5)/m;M>=e.x&&M<=e.x+e.w&&$>=e.y&&$<=e.y+e.h&&(a+=h/m*4)}}i>=0&&(o+=a*s)}return o}fork(){let e=new t;return e.budget=this.budget,e.polys=this.polys,e.lines=this.lines,e.solids=this.solids,e.rects=[...this.rects],e.slants=this.slants,e}},dc=14;function mr(t,e,n,s){let r=Math.max(t.name?Jt(t.name,at.lbl):0,t.sub?Jt(t.sub,at.sub):0)+4,o=(t.name?1:0)+(t.sub?1:0),i=n-(t.name?11:9)-1,a=(o-1)*dc+(t.name?11:9)+4;return{x:s==="start"?e-2:s==="end"?e-r+2:e-r/2,y:i,w:r,h:a}}function hr(t,e,n,s,r,o){let i=Fn(n),a=we((e.x0+e.x1)/2,(e.y0+e.y1)/2,e.z1)[0],c=((t.name?1:0)+(t.sub?1:0)-1)*dc+4,f=i.y-6-c,u=i.y+Math.min(i.h,60)*.45,d=[];o&&d.push({...o,pen:0}),d.push({x:a,y:f,anchor:"middle",pen:o?20:0});for(let m of[12,24,40])d.push({x:a,y:f-m,anchor:"middle",pen:20+m});for(let m of[-30,30,-60,60])d.push({x:a+m,y:f-4,anchor:"middle",pen:30+Math.abs(m)});d.push({x:i.x+i.w+8,y:u,anchor:"start",pen:120}),d.push({x:i.x-8,y:u,anchor:"end",pen:120}),d.push({x:a,y:i.y+i.h+14,anchor:"middle",pen:300});let p,h=1/0;for(let m of d){let y=mr(t,m.x,m.y,m.anchor),I=s.cost(y,r,.15)*2+m.pen;I<h&&(h=I,p={x:m.x,y:m.y,anchor:m.anchor,rect:y})}return p}function da(t,e,n,s){return{x:(s==="start"?e:s==="end"?e-t:e-t/2)-2,y:n-14,w:t+4,h:28}}function Io(t,e,n,s,r){let o=[{...s,pen:0}];for(let f of[-46,-66,-86,-106,-126,-146])for(let u of[0,-70,70,-140,140])o.push({x:e+u,y:n+f,anchor:"middle",pen:10+(-f-46)*.5+Math.abs(u)*.4});for(let f of[34,60,86])o.push({x:e,y:n+f,anchor:"middle",pen:60+f*.3});let i=s.x-e,a=s.y-n;for(let f of[-1,1])for(let u of[16,32,48])o.push({...s,y:n+a+f*u,x:e+i,pen:5+u});for(let f of[-1,1])for(let u of[30,60,90])for(let d of[0,16,-16])o.push({...s,x:e+i+f*u,y:n+a+d,pen:8+u*.6+Math.abs(d)});let l,c=1/0;for(let f of o){let u=da(t,f.x,f.y,f.anchor),d=r.cost(u,void 0,.05)*3+f.pen;d<c&&(c=d,l={x:f.x,y:f.y,anchor:f.anchor,rect:u})}return l}var pc=t=>{let e=0;for(let n=0;n<t.length;n++){let s=t[n],r=t[(n+1)%t.length];e+=s[0]*r[1]-r[0]*s[1]}return e/2},fa=t=>pc(t)<0?[...t].reverse():t;function pa(t,e){let n=fa(t);for(let s=0;s<n.length;s++){let r=n[s],o=n[(s+1)%n.length];if((o[0]-r[0])*(e[1]-r[1])-(o[1]-r[1])*(e[0]-r[0])<0)return!1}return!0}function pr(t,e){let n=fa(t),s=fa(e);for(let r=0;r<s.length&&n.length;r++){let o=s[r],i=s[(r+1)%s.length],a=c=>(i[0]-o[0])*(c[1]-o[1])-(i[1]-o[1])*(c[0]-o[0]),l=n;n=[];for(let c=0;c<l.length;c++){let f=l[c],u=l[(c+1)%l.length],d=a(f),p=a(u);if(d>=0&&n.push(f),d>=0!=p>=0){let h=d/(d-p);n.push([f[0]+(u[0]-f[0])*h,f[1]+(u[1]-f[1])*h])}}}return n.length>=3?Math.abs(pc(n)):0}var Fo=24;function Bo(t,e){let[n,s,r,o]=e,i=t.x+t.w/2,a=t.y+t.h/2,l=[["left",i-n],["right",n+r-i],["top",a-s],["bottom",s+o-a]];l.sort((f,u)=>f[1]-u[1]);let c=l[0][0];return c==="left"?{edge:c,dx:-(t.x+t.w-n)-Fo,dy:0}:c==="right"?{edge:c,dx:n+r-t.x+Fo,dy:0}:c==="top"?{edge:c,dx:0,dy:-(t.y+t.h-s)-Fo}:{edge:c,dx:0,dy:s+o-t.y+Fo}}function _o(t,e,n){let s=$=>{let R=0;for(let E=$.parent;E;E=E.parent)R++;return R},r=$=>$.box.x0+$.box.y0+$.box.z0*.01,o=t.items.filter($=>$.type==="region").sort(($,R)=>s($)-s(R)||r($)-r(R)),i=t.items.filter($=>$.type==="node").sort(($,R)=>r($)-r(R)||$.box.z0-R.box.z0),a=[],l=Math.min(90,400/Math.max(1,o.length)),c=650;o.forEach(($,R)=>{let E=Fn(qt($.box));a.push({id:$.id,kind:"region",...Bo(E,n),delay:Math.round(R*l),dur:c,bbox:E})});let f=250+Math.round(l*o.length),u=Math.min(70,700/Math.max(1,i.length)),d=600;i.forEach(($,R)=>{let E=Fn(qt($.box));a.push({id:$.id,kind:"node",...Bo(E,n),delay:Math.round(f+R*u),dur:d,bbox:E})});let p=i.length?f+(i.length-1)*u:f,h=Math.round(p+300),m=Math.min(30,300/Math.max(1,e.length)),y=400,I=e.filter($=>$.points.length>=2).map(($,R)=>({id:$.id,delay:Math.round(h+R*m),dur:y})),N={delay:h+200,dur:400},M=Math.max(...a.map($=>$.delay+$.dur),...I.map($=>$.delay+$.dur),N.delay+N.dur);return{pieces:a,routes:I,labels:N,total:M}}function ma(t){return Math.max(5600,Math.min(12500,2600+t.length*40))}function Do(t,e,n,s,r,o){let i=[],a=(x,P,b,v="error")=>{let g=r.locate(x);i.push({severity:v,message:P,line:g.line,col:g.col,path:x,hint:b})},l=t.steps??[],c=new Set(Object.keys(o.kinds)),f=new Map(s.map(x=>[x.id,x])),u=()=>[...n.byId.keys(),...f.keys()],d=new Map;l.forEach((x,P)=>{x.id&&(d.has(x.id)&&a(`${e}/steps/${P}/id`,`duplicate step id "${x.id}"`),d.set(x.id,P+1))});let p=l.length,h=(x,P)=>{if(typeof x=="number"){if(x<1||x>p){a(P,`there is no step ${x}; this scene has ${p} step(s)`);return}return x}let b=d.get(x);return b===void 0&&a(P,`unknown step "${x}"`+Zt(x,d.keys())),b},m=x=>Mn(o,o.kinds[x]?.color??"control"),y=[],I=x=>{y.includes(x)||y.push(x)};for(let x of s)I(x.kind);let N={},M=(x,P,b,v)=>{if(P===void 0&&b===void 0)return;let g=P!==void 0?h(P,v+"/appears"):1,O=b!==void 0?h(b,v+"/disappears"):p+1;N[x]=Array.from({length:p},(F,j)=>j+1>=(g??1)&&j+1<(O??p+1))};for(let x of n.items)M(x.id,x.appears,x.disappears,x.path);for(let x of s)M(x.id,x.raw.appears,x.raw.disappears,x.path);let $=[],R=[],E=[],w=[],T=()=>{for(let x of s){if(x.raw.appears!==void 0||x.raw.disappears!==void 0)continue;let P=[x.from,x.to].map(b=>b&&(N[b.id]??L(b)));P.some(Boolean)&&(N[x.id]=Array.from({length:p},(b,v)=>P.every(g=>!g||g[v])))}},L=x=>{for(let P=x.parent;P;P=P.parent)if(N[P.id])return N[P.id]};return l.forEach((x,P)=>{let b=P+1,v=`${e}/steps/${P}`,g=x.kind??"control";c.has(g)||a(v+"/kind",`unknown flow kind "${g}"`+Zt(g,c)),I(g);let O=new Set,F=[];(x.animate??[]).forEach((B,K)=>{let q=Array.isArray(B)?B:[B],Z=[];q.forEach((A,D)=>{let V=Array.isArray(B)?`${v}/animate/${K}/${D}`:`${v}/animate/${K}`,W,ie;if(typeof A=="string"){let te=/^([^:\s]+)\s*(?::\s*(\S+))?$/.exec(A.trim());W=te?te[1]:A,ie=te?.[2]}else{let te=Object.entries(A)[0];W=te[0],ie=te[1]}let de=f.get(W);if(!de){a(V,`unknown route "${W}"`+Zt(W,f.keys()));return}if(ie&&!c.has(ie)){a(V,`unknown flow kind "${ie}"`+Zt(ie,c));return}let X=ie??de.kind;I(X),Z.push({route:W,kind:X,color:m(X)}),O.add(W),de.from&&O.add(de.from.id),de.to&&O.add(de.to.id)}),Z.length&&F.push(Z)});let j=[];(x.pulse??[]).forEach((B,K)=>{let q=n.byId.get(B);if(!q){a(`${v}/pulse/${K}`,`unknown node "${B}"`+Zt(B,n.byId.keys()));return}let Z,A,D,V,W=q.node?as(n.catalog,q.node.asset):void 0;if(W?.pulse)[Z,A,D,V]=W.pulse(q.box);else{let X=q.box;Z=(X.x0+X.x1)/2,A=(X.y0+X.y1)/2,D=X.z1,V=Math.max(22,Math.min(60,(X.x1-X.x0+X.y1-X.y0)*8.5))}let[ie,de]=we(Z,A,D);j.push([ie,de,V*1.7,V*.98]),O.add(B)}),(x.highlight??[]).forEach((B,K)=>{!n.byId.has(B)&&!f.has(B)&&a(`${v}/highlight/${K}`,`unknown id "${B}"`+Zt(B,u())),O.add(B)});for(let[B,K]of[["show",!0],["hide",!1]])(x[B]??[]).forEach((q,Z)=>{if(!n.byId.has(q)&&!f.has(q)){a(`${v}/${B}/${Z}`,`unknown id "${q}"`+Zt(q,u()));return}let A=N[q]??(N[q]=Array(p).fill(!K));for(let D=P;D<p;D++)A[D]=K});if((x.say??[]).forEach((B,K)=>{let q,Z;if(Array.isArray(B.at))[q,Z]=we(B.at[0],B.at[1],B.at[2]??.36);else{let D=n.byId.get(B.at);if(!D){a(`${v}/say/${K}/at`,`unknown node "${B.at}"`+Zt(B.at,n.byId.keys()));return}let V=D.box;[q,Z]=we((V.x0+V.x1)/2,(V.y0+V.y1)/2,V.z1+.75)}let A=B.kind??g;c.has(A)||a(`${v}/say/${K}/kind`,`unknown flow kind "${A}"`+Zt(A,c)),R.push({step:b,x:q+(B.dx??0),y:Z+(B.dy??(Array.isArray(B.at)?0:-46)),ax:q,ay:Z,text:B.text,kind:A,anchor:B.anchor??"middle"})}),(x.mark??[]).forEach((B,K)=>{if(B.at){E.push({step:b,p:[B.at[0],B.at[1],B.at[2]??.36]});return}let q=B.on?f.get(B.on):void 0;if(!q){a(`${v}/mark/${K}`,B.on?`unknown route "${B.on}"`+Zt(B.on,f.keys()):'a mark needs "on: ROUTE" or "at: [x, y]"');return}let Z=q.points[q.points.length-1];E.push({step:b,p:[Z[0],Z[1],Z[2]+.6],on:q.id}),O.add(q.id)}),t.badges&&x.badge!==!1){let B=Array.isArray(x.badge)?[x.badge[0],x.badge[1],x.badge[2]??.36]:void 0,K=typeof x.badge=="string"?x.badge:F[0]?.[0]?.route,q=K?f.get(K):void 0;if(!B)if(q)B=ha(q.points);else if(K&&n.byId.get(K)){let Z=n.byId.get(K).box;B=[(Z.x0+Z.x1)/2,(Z.y0+Z.y1)/2,Z.z1+.3]}else typeof x.badge=="string"&&a(`${v}/badge`,`unknown id "${x.badge}"`+Zt(x.badge,u()));B&&w.push({step:b,num:x.number??b,kind:g,p:B})}for(let B of[...O])for(let K=n.byId.get(B)?.parent;K;K=K.parent)O.add(K.id);for(let B of n.items)B.region?.kind==="tunnel"&&(B.region.around??[]).some(K=>O.has(K))&&O.add(B.id);let U;if(x.focus?.length){let B=1/0,K=1/0,q=-1/0,Z=-1/0;x.focus.forEach((A,D)=>{let V=n.byId.get(A);if(!V){a(`${v}/focus/${D}`,`unknown node or region "${A}"`+Zt(A,n.byId.keys()));return}let W=V.box;for(let[ie,de,X]of[[W.x0,W.y0,W.z1],[W.x1,W.y0,W.z0],[W.x0,W.y1,W.z0],[W.x1,W.y1,W.z0],[W.x1,W.y0,W.z1],[W.x0,W.y1,W.z1]]){let[te,ye]=we(ie,de,X);B=Math.min(B,te),K=Math.min(K,ye),q=Math.max(q,te),Z=Math.max(Z,ye)}O.add(A)}),B<1/0&&(U=[Math.round(B-60),Math.round(K-70),Math.round(q+60),Math.round(Z+40)])}let ne=x.caption??"";$.push({n:b,num:x.number??b,kind:g,color:m(g),heading:x.heading,caption:ne,command:x.command??"",phases:F,pulses:j,lit:[...O],duration:x.duration===void 0||x.duration==="auto"?ma(ne):x.duration,...U?{focus:U}:{}})}),T(),{steps:$,says:R,marks:E,badges:w,vis:N,diags:i,kindsUsed:y}}function ha(t){let e=t.slice(1).map((s,r)=>Math.hypot(s[0]-t[r][0],s[1]-t[r][1],s[2]-t[r][2])),n=e.reduce((s,r)=>s+r,0)/2;for(let s=0;s<e.length;s++){if(n<=e[s]&&e[s]>0){let r=n/e[s],o=t[s],i=t[s+1];return[o[0]+(i[0]-o[0])*r,o[1]+(i[1]-o[1])*r,o[2]+(i[2]-o[2])*r]}n-=e[s]}return t[0]}function Zt(t,e){let n=Yn(t,e);return n?` (did you mean "${n}"?)`:""}function mc(t,e){if(!e)return t;let[n,s,r,o]=e,i=t[2]/t[3],a=r-n,l=o-s;a/l<i?a=l*i:l=a/i,a=Math.min(a,t[2]),l=Math.min(l,t[3]);let c=(n+r)/2,f=(s+o)/2,u=Math.max(t[0],Math.min(t[0]+t[2]-a,c-a/2)),d=Math.max(t[1],Math.min(t[1]+t[3]-l,f-l/2));return[u,d,a,l]}var Ko=(t,e)=>e.role??pt(t,e.kind)?.role,zo=(t,e)=>pt(t,e.region.kind)?.shape;function Go({scene:t,layout:e,routes:n,steps:s,theme:r,id:o,gridStep:i=1}){let a=new gs,l={base:"",floor:"",flows:"",blocks:[],air:"",labels:"",marks:"",badges:""},c=new ls;c.budget.spots=Vo;let f=g=>s.vis[g]?{"data-vis":"1"}:{},u=e.items.filter(g=>g.type==="region"),d=g=>{let O=0;for(let F=g.parent;F;F=F.parent)O++;return O},p=e.catalog,h=u.filter(g=>zo(p,g)!=="walled"&&zo(p,g)!=="tunnel"),m=Ks(h.map(g=>({box:g.box,r:g}))).map(g=>g.r).sort((g,O)=>d(g)-d(O));for(let g of m)l.base+=xu(a,p,g,f(g.id),i);for(let g of u.filter(O=>zo(p,O)==="walled")){for(let F of jo(g))c.solids.push(qt(F));for(let F of jo(g))l.blocks.push({box:F,svg:me("g",{class:`blk k-${Ko(p,g.region)} wall${g.region.ghost?" ghost":""}`,"data-id":g.id,"data-dim":"1",...f(g.id)},a.blockFaces(F))});let O=g.region.gate;if(O&&!O.node){let F=ur(g,O.height??(g.region.height??.8)+.3,.3,.3);c.solids.push(qt(F)),l.blocks.push({box:F,svg:me("g",{class:"blk k-gate","data-id":g.id,...f(g.id)},a.blockFaces(F))})}g.region.label&&(g.region["label-style"]??"face")!=="none"&&(l.labels+=a.faceText(g.box.x0+.3,g.box.y1,g.box.z0+.13,g.region.label,"slabname sm fz",at.sm,"left","start",{"data-id":g.id,...f(g.id)}))}for(let g of u.filter(O=>zo(p,O)==="tunnel"))l.air+=ku(a,g,f(g.id));let y=e.items.filter(g=>g.type==="node");for(let g of y){let O=g.node,F=Qt(p,O.asset),j=O.ghost||(O.deco??[]).includes("ghost"),U=["blk",`k-${O.role??F.role}`,F.cls,j?"ghost":""].filter(Boolean).join(" ");l.blocks.push({box:g.box,svg:me("g",{class:U,"data-id":g.id,"data-dim":"1",...f(g.id)},F.draw(a,g.box,O))}),c.polys.push({poly:qt(g.box),owner:g.id}),c.solids.push(qt(g.box))}let I=Ks(l.blocks).map(g=>g.svg).join(""),N=new Set,M={};for(let g of n){if(g.points.length<2)continue;let O=g.points.map(U=>we(U[0],U[1],U[2]));O.forEach(U=>a.bounds.add(U));let F="M"+O.map(ts).join(" L");M[g.id]=F;let j=g.raw.arrow!==!1;j&&N.add(g.kind),l.flows+=me("g",{"data-hl":g.id,"data-id":g.id,...f(g.id)},me("path",{d:F,class:`flow f-${g.kind}`,"marker-end":j?`url(#ah-${o}-${g.kind})`:void 0})),c.lines.push({pts:O,owner:g.id})}for(let g of N)a.def(`ah-${o}-${g}`,me("marker",{id:`ah-${o}-${g}`,viewBox:"0 0 10 10",refX:"7",refY:"5",markerWidth:"4.2",markerHeight:"4.2",orient:"auto-start-reverse"},me("path",{d:"M0,0 L10,5 L0,10 z",style:`fill:${Mn(r,r.kinds[g]?.color??"control")}`})));for(let g of a.planePolys)c.slants.push(g);let $=y.filter(g=>g.node.label||g.node.sub).sort((g,O)=>(O.box.x1-O.box.x0)*(O.box.y1-O.box.y0)-(g.box.x1-g.box.x0)*(g.box.y1-g.box.y0));for(let g of $)l.labels+=wu(a,p,g,c,f(g.id));let R=[];for(let g of n)if(g.raw.label&&g.points.length>=2){let O=vu(a,g,c,f(g.id),e);l.floor+=O.svg,O.warning&&R.push({path:`${g.path}/label`,message:O.warning}),c.budget.over&&!c.budget.told&&(c.budget.told=!0,R.push({path:g.path,message:`from route "${g.id}" on, route labels were placed without weighing what other labels and lines cover: the scene is too large to search every spot (${Vo.toLocaleString("en")} spots); split it into scenes, or give the labels "along", "side" or "at"`}))}(t.notes??[]).forEach((g,O)=>{let F=Su(a,g,e,n,`${o}-note-${O}`);g.floor?l.floor+=F:l.labels+=F});let E=[],w=new Map;for(let g of s.says){let O=w.get(g.step)??c.fork();w.set(g.step,O);let F=Jt(g.text,at.say)+18,j=Io(F,g.ax,g.ay,{x:g.x,y:g.y,anchor:g.anchor},O);O.rects.push({r:j.rect,owner:""}),E.push({step:g.step,...j.rect,text:g.text});let U=j.rect.x+2;a.bounds.addRect(j.rect.x,j.rect.y,j.rect.w,j.rect.h);let ne=Mn(r,r.kinds[g.kind]?.color??"control");l.marks+=me("g",{class:"say","data-step":g.step},me("rect",{x:U,y:j.y-12,width:F,height:24,rx:12,style:`stroke:${ne}`})+me("text",{x:U+F/2,y:j.y+4,"text-anchor":"middle",style:`fill:${ne}`},ut(g.text)))}for(let g of s.marks){let[O,F]=we(...g.p);a.bounds.addRect(O-12,F-12,24,24),l.marks+=me("g",{class:"xm","data-step":g.step,"data-hl":g.on},me("circle",{cx:O,cy:F,r:10})+me("path",{d:`M${it(O-4.5)},${it(F-4.5)} L${it(O+4.5)},${it(F+4.5)} M${it(O+4.5)},${it(F-4.5)} L${it(O-4.5)},${it(F+4.5)}`}))}for(let g of s.badges){let[O,F]=we(...g.p);a.bounds.addRect(O-13,F-13,26,26),l.badges+=me("g",{class:`badge c-${g.kind}`,"data-go":g.step,"data-badge":g.step,tabindex:"0",role:"button","aria-label":`Step ${g.num}`},me("circle",{cx:O,cy:F,r:11.5})+me("text",{x:O,y:F+.5},String(g.num)))}let T=a.bounds,L=22,x=T.empty?[0,0,100,100]:[Math.floor(T.x0-L),Math.floor(T.y0-L),Math.ceil(T.x1-T.x0+L*2),Math.ceil(T.y1-T.y0+L*2)],P=[...a.defs.values()].join(""),b=(g,O)=>me("g",{class:"g-"+g},O);return{svg:me("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:x.join(" "),role:"img","aria-label":t.aria??t.title,"data-scene":o},me("defs",{},P)+b("base",l.base)+b("floor",l.floor)+b("flows",l.flows)+b("blocks",I)+b("air",l.air)+b("labels",l.labels)+b("marks",l.marks)+b("badges",l.badges)+b("anim","")),viewBox:x,texts:a.texts,paths:M,warnings:R,callouts:E,assembly:_o(e,n,x)}}function yu(t,e){let n=t.z1+.002,s=1e-6,r=[],o=(i,a)=>{let l=we(i[0],i[1],n),c=we(a[0],a[1],n);r.push(`M${ts(l)}L${ts(c)}`)};for(let i=Math.ceil((t.x0+s)/e)*e;i<t.x1-s;i+=e)o([i,t.y0],[i,t.y1]);for(let i=Math.ceil((t.y0+s)/e)*e;i<t.y1-s;i+=e)o([t.x0,i],[t.x1,i]);return r.length?me("path",{class:"grid",d:r.join("")}):""}function xu(t,e,n,s,r=1){let o=n.region,i=n.box,a=Ko(e,o),l=pt(e,o.kind),c=l?.shape,f={"data-id":n.id,"data-dim":"1",...s},u="";c==="cloud"?u=me("g",{class:`blk k-${a} cloud`,...f},vo(t,i)):c==="zone"?u=me("g",{class:`zone k-${a}`,...f},t.poly([[i.x0,i.y0,i.z1],[i.x1,i.y0,i.z1],[i.x1,i.y1,i.z1],[i.x0,i.y1,i.z1]])):u=me("g",{class:`blk k-${a}${o.ghost?" ghost":""}`,...f},t.blockFaces(i)+yu(i,r));let d=o["label-style"]??l?.labelStyle;if(o.label&&d!=="none")if(d==="face"){let p=i.z1-i.z0,h=N=>N.size*.73/Xe,m=c==="slab"&&.28+h(at.slabname)+.08>p,y=c==="slab"&&!m,I=y?i.z0+.28:m?i.z0+Math.max(.02,(p-h(at.sm))/2):i.z0+Math.min(.1,p*.25);u+=me("g",f,t.faceText(i.x0+(y?.6:.3),i.y1,I,o.label,y?"slabname":"slabname sm",y?at.slabname:at.sm,"left","start"))}else if(d==="face-right")u+=me("g",f,t.faceText(i.x1,i.y0+.6,i.z0+Math.max(.14,(i.z1-i.z0)*.2),o.label,"slabname",at.slabname,"right","end"));else{let p=c==="cloud"?"middle":"start",h=c==="cloud"?(i.x0+i.x1)/2:i.x0+.35,m=c==="cloud"?(i.y0+i.y1)/2:i.y1-.35;u+=me("g",f,t.floorText(h,m,i.z1+.01,o.label,"slabname sm","x",p))}return u}function jo(t){let{x0:e,y0:n,x1:s,y1:r,z0:o,z1:i}=t.box,a=$n,l=t.region.gate,c=[],f=d=>{d.x1-d.x0>1e-6&&d.y1-d.y0>1e-6&&c.push({...d,z0:o,z1:i})},u=(d,p,h)=>{if(!l||l.side!==h)return[[d,p]];let m=l.at??.5,y=l.width??2,I=h==="e"||h==="w"?n+(r-n)*m:e+(s-e)*m;return[[d,I-y/2],[I+y/2,p]]};for(let[d,p]of u(e,s,"n"))f({x0:d,y0:n,x1:p,y1:n+a});for(let[d,p]of u(n+a,r-a,"w"))f({x0:e,y0:d,x1:e+a,y1:p});for(let[d,p]of u(n+a,r-a,"e"))f({x0:s-a,y0:d,x1:s,y1:p});for(let[d,p]of u(e,s,"s"))f({x0:d,y0:r-a,x1:p,y1:r});return c}function wu(t,e,n,s,r){let o=n.node,i=Qt(e,o.asset),a=n.box,l={name:o.label,sub:o.sub},c=o["label-at"],f;if(c){let d=Fn(qt(a)),p=c.side??"above",h=d.y+Math.min(d.h,60)*.45;p==="right"?f={x:d.x+d.w+8,y:h,anchor:"start"}:p==="left"?f={x:d.x-8,y:h,anchor:"end"}:p==="below"?f={x:d.x+d.w/2,y:d.y+d.h+14,anchor:"middle"}:f=hr(l,a,qt(a),new ls,n.id),f={...f,x:f.x+(c.dx??0),y:f.y+(c.dy??0)}}else{let d=i.label?i.label(a,o,!!o.sub):void 0;f=hr(l,a,qt(a),s,n.id,d)}s.rects.push({r:mr(l,f.x,f.y,f.anchor),owner:""});let u="";return o.label&&(u+=t.text(f.x,f.y,o.label,"lbl",at.lbl,f.anchor,{},n.id)),o.sub&&(u+=t.text(f.x,o.label?f.y+14:f.y,o.sub,"sub mono",at.sub,f.anchor,{},n.id)),me("g",{"data-id":n.id,"data-dim":"1",...r},u)}function ku(t,e,n){let{x0:s,y0:r,x1:o,y1:i,z0:a,z1:l}=e.box,c=t.blockFaces(e.box),f=o-s>=i-r,u=Math.max(1,Math.round((f?o-s:i-r)/1.6));for(let p=1;p<u;p++){let h=f?s+(o-s)*p/u:r+(i-r)*p/u;c+=t.poly(f?[[h,r,l],[h,i,l],[h,i,a]]:[[s,h,l],[o,h,l],[o,h,a]],"rib")}let d=e.region.label;return d&&e.region["label-style"]!=="none"&&(c+=f?t.faceText(s+.35,i,a+.14,d,"tunname",at.tunname,"left","start"):t.faceText(o,i-.35,a+.18,d,"tunname",at.tunname,"right","start")),me("g",{class:"tunnel","data-id":e.id,"data-dim":"1",...n},c)}var Vo=2e4;function vu(t,e,n,s,r){let o=typeof e.raw.label=="string"?{text:e.raw.label}:e.raw.label,i=`floor mono t-${e.kind}`,a={"data-hl":e.id,...s},l=at.floor;if(o.at){let N=o.at.length>2?o.at[2]:e.points[0][2];return{svg:t.floorText(o.at[0],o.at[1],N,o.text,i,o.dir??"x",o.anchor??"start",a)}}let c=e.points,f=[];for(let N=0;N+1<c.length;N++){let M=c[N],$=c[N+1];Math.abs(M[2]-$[2])>1e-6||f.push({i:N,len:Math.hypot($[0]-M[0],$[1]-M[1])})}if(!f.length)return{svg:"",warning:`label "${o.text}" of route "${e.id}" was dropped: the route has no level segment`};let u=o.along?f.filter(N=>N.i===Math.min(o.along-1,c.length-2)):[...f].sort((N,M)=>M.len-N.len),d=.22,p=11/Xe,h=N=>{let M=Jt(N,l)/Xe,$,R=1/0,E=0;e:for(let w of u.length?u:f){let T=c[w.i],L=c[w.i+1],x=T[2],P=Math.abs(T[1]-L[1])<1e-6,b=P?Math.min(T[0],L[0]):Math.min(T[1],L[1]),v=P?Math.max(T[0],L[0]):Math.max(T[1],L[1]),g=P?T[1]:T[0],O=o.side==="left"?[-1]:o.side==="right"?[1]:[-1,1],F=[];for(let j=b+.3;j<=Math.max(b+.3,v-M-.2)+1e-9;j+=.4)F.push(j);for(let j=v-M-.2+.4;j<v+.5&&v-b<M+.5;j+=.6)F.push(j);for(let j of O)for(let U of F){if(R<=E*.5)break e;let ne=j<0?g-d:g+d+p,B,K,q;if(P?(B=U,K=ne,q=[we(B,K-p,x),we(B+M,K-p,x),we(B+M,K,x),we(B,K,x)]):(B=ne,K=U+M,q=[we(B-p,K,x),we(B-p,K-M,x),we(B,K-M,x),we(B,K,x)]),(P?[[B,K-p],[B+M,K-p],[B+M,K],[B,K]]:[[B-p,K],[B-p,K-M],[B,K-M],[B,K]]).some(([ie,de])=>Math.abs(Ns(r,ie,de)+.01-x)>.001)){E++;continue}let A=n.hiddenPoly(q),D=A*50+E*.5,V=n.budget.spots-- >0;V||(n.budget.over=!0);let W=D>=R?1/0:V?D+n.costPoly(q,R-D):D;E++,W<R&&(R=W,$={x:B,y:K,z:x,dir:P?"x":"y",rect:Fn(q),poly:q,hidden:A})}}return $&&$.hidden<6?$:void 0},m=o.text,y=h(m),I;if(!y){let N=o.text.split(/(\s+)/);for(let M=N.length-1;M>0&&!y;M--){let $=N.slice(0,M).join("").trimEnd().replace(/[\s,;:·–-]+$/,"")+"\u2026";if($.length<6)break;let R=h($);R&&(y=R,m=$)}I=y?`label of route "${e.id}" shortened to "${m}": no clear floor for the whole text`:`label "${o.text}" of route "${e.id}" was dropped: blocks cover every spot beside it`,y?I+='; give it "along", "side" or "at", or move the nodes apart':I+='; give it "at: [x, y]", or move the nodes apart'}return y?(n.slants.push(y.poly),{svg:t.floorText(y.x,y.y,y.z+.01,m,i,y.dir,"start",a),warning:I}):{svg:"",warning:I}}function Su(t,e,n,s,r){let o=e.on?s.find(f=>f.id===e.on):void 0,i=e.on&&!o?n.byId.get(e.on):void 0,a=e.at,l={"data-id":r,"data-hl":o?.id,"data-dim":o?void 0:"1"},c=e.kind??o?.kind??"control";if(e.floor){let f=a&&a.length>2?a[2]:o?o.points[0][2]:i?i.floor:.36,[u,d]=a?[a[0],a[1]]:o?[o.points[0][0]+.35,o.points[0][1]-.25]:i?[i.box.x0+.3,i.box.y1-.3]:[0,0];return t.floorText(u,d,f+.01,e.floor,`floor mono t-${c}`,e.dir??"x",e.anchor??"start",l)}if(e.face){let f=i?.box,[u,d,p]=a?[a[0],a[1],a[2]??.45]:f?[f.x0+.3,f.y1,f.z0+.13]:[0,0,0];return t.faceText(u,d,p,e.face,"slabname sm",at.sm,"left",e.anchor??"start",l)}if(e.label||e.sub){let f=i?.box,u=a?[a[0],a[1],a[2]??.36]:f?[(f.x0+f.x1)/2,(f.y0+f.y1)/2,f.z1+.75]:[0,0,0],[d,p]=we(u[0],u[1],u[2]),h=d+(e.dx??0),m=p-18+(e.dy??0),y=e.anchor??"middle",I="";return e.label&&(I+=t.text(h,m,e.label,"lbl",at.lbl,y)),e.sub&&(I+=t.text(h,e.label?m+14:m,e.sub,"sub mono",at.sub,y)),me("g",l,I)}return""}var ga=`
143
143
  *{box-sizing:border-box}
144
144
  html,body{margin:0}
145
145
  body{background:var(--bg);color:var(--ink);font:15px/1.55 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;-webkit-font-smoothing:antialiased;overflow-x:hidden}
@@ -163,7 +163,7 @@ h2{font-size:20px;margin:44px 0 4px;letter-spacing:-.005em;text-wrap:balance}
163
163
  .legend i{display:inline-block;width:26px;height:0;border-top:3px solid}
164
164
  .legend i.box{height:10px;border-width:1.5px;border-style:solid;border-radius:2px}
165
165
  footer{margin-top:40px;font-size:12.5px;color:var(--muted)}
166
- `,ha=t=>Mu+xo(t)+$u+wo(),Mu=`
166
+ `,ba=t=>Mu+xo(t)+$u+wo(),Mu=`
167
167
  /* blocks: hue per role, lightness per face and theme */
168
168
  .blk .top{fill:hsl(var(--h) var(--s) var(--l-top))}
169
169
  .blk .lft{fill:hsl(var(--h) var(--s) var(--l-left))}
@@ -211,7 +211,7 @@ footer{margin-top:40px;font-size:12.5px;color:var(--muted)}
211
211
 
212
212
  /* flows */
213
213
  .flow{fill:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round}
214
- `,Uo=t=>ma+ha(t),ga=`
214
+ `,Uo=t=>ga+ba(t),ya=`
215
215
  /* step marks */
216
216
  .xm circle{fill:var(--surface);stroke:var(--blocked);stroke-width:2.5}
217
217
  .xm path{stroke:var(--blocked);stroke-width:3;stroke-linecap:round}
@@ -234,7 +234,7 @@ svg.all .badge{opacity:1}
234
234
  svg.focus.all [data-hl]:not(.hl),svg.focus.all.dim-all [data-dim]:not(.hl){opacity:.9}
235
235
  svg [data-step]:not(.on),svg.all [data-step]{opacity:0!important;pointer-events:none}
236
236
  .pre{opacity:0!important;pointer-events:none}
237
- `,ba=`
237
+ `,xa=`
238
238
  /* player */
239
239
  .player{display:flex;align-items:flex-start;gap:10px 14px;padding:12px 16px;border-top:1px solid var(--line);flex-wrap:wrap}
240
240
  .ctrls{display:flex;gap:6px;flex:none}
@@ -269,20 +269,20 @@ details.steps li code{font-size:11.5px}
269
269
  .still .ctrls,.still .tools{display:none}
270
270
  .tools{display:flex;gap:6px;flex:none;order:3;margin-left:auto}
271
271
  .pbtn.small{font-size:12px;padding:4px 11px;font-weight:600;color:var(--muted)}
272
- .pbtn.small[aria-pressed="true"]{color:var(--ink);border-color:var(--muted);background:var(--surface)}`,ya=`
272
+ .pbtn.small[aria-pressed="true"]{color:var(--ink);border-color:var(--muted);background:var(--surface)}`,wa=`
273
273
  .grid{display:none;fill:none;stroke:var(--ink);stroke-width:.6;opacity:.16;pointer-events:none}
274
274
  svg.show-grid .grid{display:inline}
275
275
  svg.pre-assemble > g:not(.g-anim){opacity:0}
276
- `,qo=ga+ba+ya;var xa=t=>({data:t,locate:()=>({line:0,col:0}),span:()=>{},diags:[]});function pc(t,e,n,s=xa(t),r,o={},i=[]){let a=mo(po(e),t.roles,t.kinds),l=[],c=new Map;return t.scenes.forEach((f,u)=>{let d=`/scenes/${u}`;if(c.has(f.id)){let N=s.locate(d+"/id");i.push({severity:"error",message:`duplicate scene id "${f.id}"`,line:N.line,col:N.col,path:d+"/id"})}c.set(f.id,u);let p={...t.grid,...f.grid,...o.snap?{snap:o.snap}:{}},h=$o(f,d,s,a,n,t.roles,p.snap);i.push(...h.diags);let m=Oo(f,d,h,s,new Set(Object.keys(a.kinds)),p.snap);i.push(...m.diags);let y=Do(f,d,h,m.routes,s,a);i.push(...y.diags),i.push(...Eu(f,d,n,s));let I=Go({scene:f,layout:h,routes:m.routes,steps:y,theme:a,id:f.id,gridStep:p.step??p.snap??1});for(let N of I.warnings){let M=s.locate(N.path);i.push({severity:"warning",message:N.message,line:M.line,col:M.col,path:N.path})}l.push({id:f.id,raw:f,layout:h,routes:m.routes,steps:y,rendered:I,grid:p,assemble:f.assemble??t.assemble??!1})}),i.sort((f,u)=>f.line-u.line||f.col-u.col),{ok:!i.some(f=>f.severity==="error"),diags:i,doc:t,theme:a,catalog:n,scenes:l,parsed:s,source:r}}function Eu(t,e,n,s){let r=[],o=(a,l)=>{let c=s.locate(a);r.push({severity:"warning",message:l,line:c.line,col:c.col,path:a})},i=(a,l)=>{a.nodes?.forEach((c,f)=>{let u=`${l}/nodes/${f}`;(c.deco??Qt(n,c.asset).deco??[]).forEach((d,p)=>{typeof d=="object"&&d.icon&&!cr(d.icon)&&o(c.deco?`${u}/deco/${p}/icon`:u,`node "${c.id}": no icon "${d.icon}" is registered here, so it is drawn as a placeholder`)}),c.face!==void 0&&!ko(c.face)&&o(`${u}/face`,`node "${c.id}": no screen face "${c.face}" is registered here, so it is drawn as a placeholder`)}),a.regions?.forEach((c,f)=>i(c,`${l}/regions/${f}`))};return i(t,e),r}function mc(t,e){let n=t/(yt*Xe),s=2*e/Xe;return[(n+s)/2,(s-n)/2]}function hc(t,e){let n=t.layout.byId.get(e);if(!n)return;let s=n.parent?[n.parent.box.x0,n.parent.box.y0]:[0,0];return[n.box.x0-s[0],n.box.y0-s[1]]}function gc(t){let e=[];for(let n of[t.x0,t.x1])for(let s of[t.y0,t.y1])for(let r of[t.z0,t.z1])e.push(we(n,s,r));return Tu(e)}function bc(t){return[[t.x0,t.y0],[t.x1,t.y0],[t.x1,t.y1],[t.x0,t.y1]].map(([e,n])=>we(e,n,t.z0))}function Tu(t){let e=[...new Map(t.map(o=>[`${o[0].toFixed(3)},${o[1].toFixed(3)}`,o])).values()].sort((o,i)=>o[0]-i[0]||o[1]-i[1]);if(e.length<3)return e;let n=(o,i,a)=>(i[0]-o[0])*(a[1]-o[1])-(i[1]-o[1])*(a[0]-o[0]),s=[],r=[];for(let o of e){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],o)<=1e-9;)s.pop();s.push(o)}for(let o of[...e].reverse()){for(;r.length>=2&&n(r[r.length-2],r[r.length-1],o)<=1e-9;)r.pop();r.push(o)}return[...s.slice(0,-1),...r.slice(0,-1)]}var yc=(t,e)=>e?.padding??pt(t,e?.kind)?.pad??0;function xc(t,e,n,s,r){let o=f=>Math.round(f/n)*n,i=o(t[0]+e[0]),a=o(t[1]+e[1]),l={left:!1,right:!1,top:!1,bottom:!1};if(r){let f=Math.ceil(r.pad/n-1e-9)*n,u=Math.floor((r.w-r.pad-s[0])/n+1e-9)*n,d=Math.floor((r.d-r.pad-s[1])/n+1e-9)*n;i<f&&(i=f,l.left=!0),u>=f&&i>u&&(i=u,l.right=!0),a<f&&(a=f,l.top=!0),d>=f&&a>d&&(a=d,l.bottom=!0)}let c=f=>Math.round(f*1e3)/1e3;return{at:[c(i),c(a)],delta:[c(i-t[0]),c(a-t[1])],clamped:l}}function Yo(t,e){return e.some(s=>t.x0<s.x1-1e-6&&t.x1>s.x0+1e-6&&t.y0<s.y1-1e-6&&t.y1>s.y0+1e-6)}var ka=Object.freeze({W:178,H:58,GX:44,GY:44,PAD:22,TITLE:30,CH:96,cardRx:9,panelRx:14,bend:70,overlap:400,crossPanel:300,border:120,nearEdge:200,margin:16}),va={name:{key:"sans600_12",size:13},sub:{key:"sans400_13",size:10},title:{key:"sans700_13",size:12,spacing:.02},titleSub:{key:"sans400_13",size:10.5},label:{key:"sans600_12",size:10.5}},wc=(t,e)=>Jt(t,va[e]);function Ho(t){let e=[],n=new Map,s=(l,c)=>{if(typeof c!="string"||!c){e.push(`${l} has no id`);return}let f=n.get(c);f?e.push(`duplicate id "${c}": a ${f} and a ${l} (cards and panels share one set of ids)`):n.set(c,l)};for(let l of t.cards)s("card",l.id),(!Array.isArray(l.cell)||l.cell.length!==2||!l.cell.every(c=>Number.isInteger(c)&&c>=0))&&e.push(`card "${l.id}": cell must be [column, row], whole numbers from 0`);for(let l of t.panels??[]){s("panel",l.id);let c=l.cells;(!Array.isArray(c)||c.length!==4||!c.every(f=>Number.isInteger(f)&&f>=0)||c[2]<c[0]||c[3]<c[1])&&e.push(`panel "${l.id}": cells must be [c0, r0, c1, r1] with c0 \u2264 c1 and r0 \u2264 r1`)}let r=new Map;for(let l of t.cards){let c=String(l.cell);r.has(c)?e.push(`cards "${r.get(c)}" and "${l.id}" are both at cell [${c}]`):r.set(c,l.id)}let o=(t.panels??[]).filter(l=>Array.isArray(l.cells)&&l.cells.length===4);for(let l=0;l<o.length;l++)for(let c=l+1;c<o.length;c++){let f=o[l].cells,u=o[c].cells;f[0]<=u[2]&&u[0]<=f[2]&&f[1]<=u[3]&&u[1]<=f[3]&&!wa(f,u)&&!wa(u,f)&&e.push(`panels "${o[l].id}" and "${o[c].id}" overlap without one holding the other`)}let i=new Set([...t.cards.map(l=>l.id),...o.map(l=>l.id)]),a=new Set(o.map(l=>l.id));return(t.links??[]).forEach((l,c)=>{let f=`link ${l.id?`"${l.id}"`:c}`;for(let u of["a","b"])i.has(l[u])||e.push(`${f}: ${u} "${l[u]}" is no card or panel`);for(let u of["aOn","bOn"])l[u]!==void 0&&!a.has(l[u])&&e.push(`${f}: ${u} "${l[u]}" is no panel`);l.id!==void 0&&s("link",l.id)}),e}var wa=(t,e)=>t[0]>=e[0]&&t[2]<=e[2]&&t[1]>=e[1]&&t[3]<=e[3];function gr(t,e){let{W:n,H:s,GX:r,GY:o,PAD:i,TITLE:a,CH:l}=e,c=t.panels??[],f=A=>(A[2]-A[0]+1)*(A[3]-A[1]+1),u=(A,D)=>{let K=c[A].cells,W=c[D].cells;return wa(W,K)?f(K)>f(W)||A<D:!1},d=c.map((A,D)=>{let K=-1;return c.forEach((W,ie)=>{ie!==D&&u(ie,D)&&(K<0||u(K,ie))&&(K=ie)}),K}),p=A=>d[A]<0?0:1+p(d[A]),h=(A,D)=>{let K=-1;c.forEach((ie,de)=>{let X=ie.cells;A>=X[0]&&A<=X[2]&&D>=X[1]&&D<=X[3]&&(K<0||u(K,de))&&(K=de)});let W=[];for(let ie=K;ie>=0;ie=d[ie])W.unshift(ie);return W},m=Math.max(1,...t.cards.map(A=>A.cell[0]+1),...c.map(A=>A.cells[2]+1)),y=Math.max(1,...t.cards.map(A=>A.cell[1]+1),...c.map(A=>A.cells[3]+1)),I=[];for(let A=0;A<m;A++){I.push([]);for(let D=0;D<y;D++)I[A].push(h(A,D))}let N=(A,D,K)=>{let W=A.filter(de=>!D.includes(de)),ie=D.filter(de=>!A.includes(de));return!W.length&&!ie.length?0:W.length*(i+(K?a:0))+ie.length*i+l},M=new Array(m+1).fill(0),$=new Array(y+1).fill(0);for(let A=0;A<y;A++)for(let D=1;D<m;D++){let K=N(I[D-1][A],I[D][A],!1);K&&(M[D]=Math.max(M[D],K-r))}for(let A=0;A<m;A++)for(let D=1;D<y;D++){let K=N(I[A][D-1],I[A][D],!0);K&&($[D]=Math.max($[D],K-o))}let O=A=>{let D=A*(n+r);for(let K=1;K<=A;K++)D+=M[K];return D},E=A=>{let D=A*(s+o);for(let K=1;K<=A;K++)D+=$[K];return D},x=(A,D,K,W)=>K===D?A(D):A(D)+(W-D)*(A(K)-A(D))/(K-D),T=c.map(()=>new Set),L=(A,D)=>{for(let K=A;K>=0;K=d[K])T[K].add(D)};c.forEach((A,D)=>{L(D,A.cells[1]),L(D,A.cells[3])});for(let A of t.cards){let D=I[A.cell[0]][A.cell[1]];D.length&&L(D[D.length-1],A.cell[1])}let w=c.map(()=>new Map),P=(A,D)=>A.slice(A.indexOf(D)+1);for(let A of c.map((D,K)=>K).sort((D,K)=>p(D)-p(K)||D-K)){let D=c[A].cells,K=[...T[A]].sort((ie,de)=>ie-de),W=d[A]>=0?w[d[A]].get(K[0]):E(K[0]);w[A].set(K[0],W);for(let ie=1;ie<K.length;ie++){let de=0;for(let X=D[0];X<=D[2];X++)de=Math.max(de,N(P(I[X][K[ie-1]],A),P(I[X][K[ie]],A),!0));W+=s+Math.max(o,de),w[A].set(K[ie],W)}}let b=c.map(()=>new Set),v=(A,D)=>{for(let K=A;K>=0;K=d[K])b[K].add(D)};c.forEach((A,D)=>{v(D,A.cells[0]),v(D,A.cells[2])});for(let A of t.cards){let D=I[A.cell[0]][A.cell[1]];D.length&&v(D[D.length-1],A.cell[0])}let g=c.map(()=>new Map);for(let A of c.map((D,K)=>K).sort((D,K)=>p(D)-p(K)||D-K)){let D=c[A].cells,K=[...b[A]].sort((ie,de)=>ie-de);if(d[A]<0&&!d.includes(A)&&K.length===D[2]-D[0]+1){for(let ie of K)g[A].set(ie,x(O,D[0],D[2],ie));continue}let W=d[A]>=0?g[d[A]].get(K[0]):O(K[0]);g[A].set(K[0],W);for(let ie=1;ie<K.length;ie++){let de=0;for(let X=D[1];X<=D[3];X++)de=Math.max(de,N(P(I[K[ie-1]][X],A),P(I[K[ie]][X],A),!1));W+=n+Math.max(r,de),g[A].set(K[ie],W)}}let R=(A,D)=>{let K=I[A][D],W=K.length?K[K.length-1]:-1;return W>=0?[g[W].get(A),w[W].get(D)]:[O(A),E(D)]},F=c.map((A,D)=>D).sort((A,D)=>p(D)-p(A)||A-D),j=new Array(c.length);for(let A of F){let D=c[A].cells,K=[],W=[];for(let X of t.cards){let te=I[X.cell[0]][X.cell[1]];te[te.length-1]===A&&(K.push(g[A].get(X.cell[0])),W.push(w[A].get(X.cell[1])))}let ie=X=>X.cell[0]>=D[0]&&X.cell[0]<=D[2]&&X.cell[1]>=D[1]&&X.cell[1]<=D[3];for(let X of[D[1],D[3]])t.cards.some(te=>te.cell[1]===X&&ie(te))||W.push(w[A].get(X));for(let X of[D[0],D[2]])t.cards.some(te=>te.cell[0]===X&&ie(te))||K.push(g[A].get(X));let de={l:K.length?Math.min(...K):1/0,t:W.length?Math.min(...W):1/0,r:K.length?Math.max(...K)+n:-1/0,b:W.length?Math.max(...W)+s:-1/0};c.forEach((X,te)=>{if(d[te]!==A)return;let ye=j[te];de.l=Math.min(de.l,ye.l),de.t=Math.min(de.t,ye.t),de.r=Math.max(de.r,ye.r),de.b=Math.max(de.b,ye.b)}),j[A]={l:de.l-i,t:de.t-i,r:de.r+i,b:de.b+i+a}}let U=t.cards.map(A=>R(A.cell[0],A.cell[1])),ne=t.cards.map(A=>{let D=I[A.cell[0]][A.cell[1]];return D.length?D[D.length-1]:-1}),B=(A,D)=>{for(let K=A;K>=0;K=d[K])if(K===D)return!0;return!1},V=(A,D)=>{t.cards.forEach((K,W)=>{ne[W]>=0&&B(ne[W],A)&&(U[W]=[U[W][0]+D,U[W][1]])}),c.forEach((K,W)=>{B(W,A)&&(j[W]={...j[W],l:j[W].l+D,r:j[W].r+D})})},q=A=>{let D=[],K=[],W=[],ie=[];t.cards.forEach((S,Y)=>{ne[Y]===A&&(D.push(U[Y][0]),W.push(U[Y][0]+n),K.push(U[Y][1]),ie.push(U[Y][1]+s))}),c.forEach((S,Y)=>{d[Y]===A&&(D.push(j[Y].l),W.push(j[Y].r),K.push(j[Y].t),ie.push(j[Y].b))});let de=j[A],X=Math.min(...D,de.l+i),te=Math.max(...W,de.r-i),ye=Math.min(...K,de.t+i),Fe=Math.max(...ie,de.b-i-a);j[A]={l:X-i,t:ye-i,r:te+i,b:Fe+i+a}};for(let A of F)if(d[A]<0&&!d.includes(A))q(A);else{let K=[];t.cards.forEach((te,ye)=>{ne[ye]===A&&K.push({l:U[ye][0],r:U[ye][0]+n,t:U[ye][1],b:U[ye][1]+s,card:ye})}),c.forEach((te,ye)=>{d[ye]===A&&K.push({...j[ye],panel:ye})}),K.sort((te,ye)=>te.l-ye.l||te.t-ye.t);let W=Math.min(...K.map(te=>te.l)),ie=[];for(let te of K){let ye=W;for(let S of ie)S.t<te.b&&te.t<S.b&&S.r<=te.l+1e-6&&(ye=Math.max(ye,S.r+(S.card!==void 0&&te.card!==void 0?r:l)));let Fe=ye-te.l;Fe<-1e-6&&(te.card!==void 0?U[te.card]=[U[te.card][0]+Fe,U[te.card][1]]:V(te.panel,Fe),te.l+=Fe,te.r+=Fe),ie.push(te)}let de=K.map(te=>te.l),X=K.map(te=>te.r);j[A]={...j[A],l:Math.min(...de)-i,r:Math.max(...X)+i}}return{prect:j,parentIx:d,depthOf:p,pos:R,cardAt:A=>U[A]}}function Rs(t,e,n={}){if(n.wrap){let{wrap:k,..._}=n;return Rs(Au(t,e,k.aspect,_),e,_)}let s=Ho(t);if(s.length)throw new Error(`the board has ${s.length} error${s.length>1?"s":""}:
276
+ `,qo=ya+xa+wa;var ka=t=>({data:t,locate:()=>({line:0,col:0}),span:()=>{},diags:[]});function hc(t,e,n,s=ka(t),r,o={},i=[]){let a=mo(po(e),t.roles,t.kinds),l=[],c=new Map;return t.scenes.forEach((f,u)=>{let d=`/scenes/${u}`;if(c.has(f.id)){let N=s.locate(d+"/id");i.push({severity:"error",message:`duplicate scene id "${f.id}"`,line:N.line,col:N.col,path:d+"/id"})}c.set(f.id,u);let p={...t.grid,...f.grid,...o.snap?{snap:o.snap}:{}},h=$o(f,d,s,a,n,t.roles,p.snap);i.push(...h.diags);let m=Ro(f,d,h,s,new Set(Object.keys(a.kinds)),p.snap);i.push(...m.diags);let y=Do(f,d,h,m.routes,s,a);i.push(...y.diags),i.push(...Eu(f,d,n,s));let I=Go({scene:f,layout:h,routes:m.routes,steps:y,theme:a,id:f.id,gridStep:p.step??p.snap??1});for(let N of I.warnings){let M=s.locate(N.path);i.push({severity:"warning",message:N.message,line:M.line,col:M.col,path:N.path})}l.push({id:f.id,raw:f,layout:h,routes:m.routes,steps:y,rendered:I,grid:p,assemble:f.assemble??t.assemble??!1})}),i.sort((f,u)=>f.line-u.line||f.col-u.col),{ok:!i.some(f=>f.severity==="error"),diags:i,doc:t,theme:a,catalog:n,scenes:l,parsed:s,source:r}}function Eu(t,e,n,s){let r=[],o=(a,l)=>{let c=s.locate(a);r.push({severity:"warning",message:l,line:c.line,col:c.col,path:a})},i=(a,l)=>{a.nodes?.forEach((c,f)=>{let u=`${l}/nodes/${f}`;(c.deco??Qt(n,c.asset).deco??[]).forEach((d,p)=>{typeof d=="object"&&d.icon&&!cr(d.icon)&&o(c.deco?`${u}/deco/${p}/icon`:u,`node "${c.id}": no icon "${d.icon}" is registered here, so it is drawn as a placeholder`)}),c.face!==void 0&&!ko(c.face)&&o(`${u}/face`,`node "${c.id}": no screen face "${c.face}" is registered here, so it is drawn as a placeholder`)}),a.regions?.forEach((c,f)=>i(c,`${l}/regions/${f}`))};return i(t,e),r}function gc(t,e){let n=t/(yt*Xe),s=2*e/Xe;return[(n+s)/2,(s-n)/2]}function bc(t,e){let n=t.layout.byId.get(e);if(!n)return;let s=n.parent?[n.parent.box.x0,n.parent.box.y0]:[0,0];return[n.box.x0-s[0],n.box.y0-s[1]]}function yc(t){let e=[];for(let n of[t.x0,t.x1])for(let s of[t.y0,t.y1])for(let r of[t.z0,t.z1])e.push(we(n,s,r));return Tu(e)}function xc(t){return[[t.x0,t.y0],[t.x1,t.y0],[t.x1,t.y1],[t.x0,t.y1]].map(([e,n])=>we(e,n,t.z0))}function Tu(t){let e=[...new Map(t.map(o=>[`${o[0].toFixed(3)},${o[1].toFixed(3)}`,o])).values()].sort((o,i)=>o[0]-i[0]||o[1]-i[1]);if(e.length<3)return e;let n=(o,i,a)=>(i[0]-o[0])*(a[1]-o[1])-(i[1]-o[1])*(a[0]-o[0]),s=[],r=[];for(let o of e){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],o)<=1e-9;)s.pop();s.push(o)}for(let o of[...e].reverse()){for(;r.length>=2&&n(r[r.length-2],r[r.length-1],o)<=1e-9;)r.pop();r.push(o)}return[...s.slice(0,-1),...r.slice(0,-1)]}var wc=(t,e)=>e?.padding??pt(t,e?.kind)?.pad??0;function kc(t,e,n,s,r){let o=f=>Math.round(f/n)*n,i=o(t[0]+e[0]),a=o(t[1]+e[1]),l={left:!1,right:!1,top:!1,bottom:!1};if(r){let f=Math.ceil(r.pad/n-1e-9)*n,u=Math.floor((r.w-r.pad-s[0])/n+1e-9)*n,d=Math.floor((r.d-r.pad-s[1])/n+1e-9)*n;i<f&&(i=f,l.left=!0),u>=f&&i>u&&(i=u,l.right=!0),a<f&&(a=f,l.top=!0),d>=f&&a>d&&(a=d,l.bottom=!0)}let c=f=>Math.round(f*1e3)/1e3;return{at:[c(i),c(a)],delta:[c(i-t[0]),c(a-t[1])],clamped:l}}function Yo(t,e){return e.some(s=>t.x0<s.x1-1e-6&&t.x1>s.x0+1e-6&&t.y0<s.y1-1e-6&&t.y1>s.y0+1e-6)}var Sa=Object.freeze({W:178,H:58,GX:44,GY:44,PAD:22,TITLE:30,CH:96,cardRx:9,panelRx:14,bend:70,overlap:400,crossPanel:300,border:120,nearEdge:200,margin:16}),Ma={name:{key:"sans600_12",size:13},sub:{key:"sans400_13",size:10},title:{key:"sans700_13",size:12,spacing:.02},titleSub:{key:"sans400_13",size:10.5},label:{key:"sans600_12",size:10.5}},vc=(t,e)=>Jt(t,Ma[e]);function Ho(t){let e=[],n=new Map,s=(l,c)=>{if(typeof c!="string"||!c){e.push(`${l} has no id`);return}let f=n.get(c);f?e.push(`duplicate id "${c}": a ${f} and a ${l} (cards and panels share one set of ids)`):n.set(c,l)};for(let l of t.cards)s("card",l.id),(!Array.isArray(l.cell)||l.cell.length!==2||!l.cell.every(c=>Number.isInteger(c)&&c>=0))&&e.push(`card "${l.id}": cell must be [column, row], whole numbers from 0`);for(let l of t.panels??[]){s("panel",l.id);let c=l.cells;(!Array.isArray(c)||c.length!==4||!c.every(f=>Number.isInteger(f)&&f>=0)||c[2]<c[0]||c[3]<c[1])&&e.push(`panel "${l.id}": cells must be [c0, r0, c1, r1] with c0 \u2264 c1 and r0 \u2264 r1`)}let r=new Map;for(let l of t.cards){let c=String(l.cell);r.has(c)?e.push(`cards "${r.get(c)}" and "${l.id}" are both at cell [${c}]`):r.set(c,l.id)}let o=(t.panels??[]).filter(l=>Array.isArray(l.cells)&&l.cells.length===4);for(let l=0;l<o.length;l++)for(let c=l+1;c<o.length;c++){let f=o[l].cells,u=o[c].cells;f[0]<=u[2]&&u[0]<=f[2]&&f[1]<=u[3]&&u[1]<=f[3]&&!va(f,u)&&!va(u,f)&&e.push(`panels "${o[l].id}" and "${o[c].id}" overlap without one holding the other`)}let i=new Set([...t.cards.map(l=>l.id),...o.map(l=>l.id)]),a=new Set(o.map(l=>l.id));return(t.links??[]).forEach((l,c)=>{let f=`link ${l.id?`"${l.id}"`:c}`;for(let u of["a","b"])i.has(l[u])||e.push(`${f}: ${u} "${l[u]}" is no card or panel`);for(let u of["aOn","bOn"])l[u]!==void 0&&!a.has(l[u])&&e.push(`${f}: ${u} "${l[u]}" is no panel`);l.id!==void 0&&s("link",l.id)}),e}var va=(t,e)=>t[0]>=e[0]&&t[2]<=e[2]&&t[1]>=e[1]&&t[3]<=e[3];function gr(t,e){let{W:n,H:s,GX:r,GY:o,PAD:i,TITLE:a,CH:l}=e,c=t.panels??[],f=A=>(A[2]-A[0]+1)*(A[3]-A[1]+1),u=(A,D)=>{let V=c[A].cells,W=c[D].cells;return va(W,V)?f(V)>f(W)||A<D:!1},d=c.map((A,D)=>{let V=-1;return c.forEach((W,ie)=>{ie!==D&&u(ie,D)&&(V<0||u(V,ie))&&(V=ie)}),V}),p=A=>d[A]<0?0:1+p(d[A]),h=(A,D)=>{let V=-1;c.forEach((ie,de)=>{let X=ie.cells;A>=X[0]&&A<=X[2]&&D>=X[1]&&D<=X[3]&&(V<0||u(V,de))&&(V=de)});let W=[];for(let ie=V;ie>=0;ie=d[ie])W.unshift(ie);return W},m=Math.max(1,...t.cards.map(A=>A.cell[0]+1),...c.map(A=>A.cells[2]+1)),y=Math.max(1,...t.cards.map(A=>A.cell[1]+1),...c.map(A=>A.cells[3]+1)),I=[];for(let A=0;A<m;A++){I.push([]);for(let D=0;D<y;D++)I[A].push(h(A,D))}let N=(A,D,V)=>{let W=A.filter(de=>!D.includes(de)),ie=D.filter(de=>!A.includes(de));return!W.length&&!ie.length?0:W.length*(i+(V?a:0))+ie.length*i+l},M=new Array(m+1).fill(0),$=new Array(y+1).fill(0);for(let A=0;A<y;A++)for(let D=1;D<m;D++){let V=N(I[D-1][A],I[D][A],!1);V&&(M[D]=Math.max(M[D],V-r))}for(let A=0;A<m;A++)for(let D=1;D<y;D++){let V=N(I[A][D-1],I[A][D],!0);V&&($[D]=Math.max($[D],V-o))}let R=A=>{let D=A*(n+r);for(let V=1;V<=A;V++)D+=M[V];return D},E=A=>{let D=A*(s+o);for(let V=1;V<=A;V++)D+=$[V];return D},w=(A,D,V,W)=>V===D?A(D):A(D)+(W-D)*(A(V)-A(D))/(V-D),T=c.map(()=>new Set),L=(A,D)=>{for(let V=A;V>=0;V=d[V])T[V].add(D)};c.forEach((A,D)=>{L(D,A.cells[1]),L(D,A.cells[3])});for(let A of t.cards){let D=I[A.cell[0]][A.cell[1]];D.length&&L(D[D.length-1],A.cell[1])}let x=c.map(()=>new Map),P=(A,D)=>A.slice(A.indexOf(D)+1);for(let A of c.map((D,V)=>V).sort((D,V)=>p(D)-p(V)||D-V)){let D=c[A].cells,V=[...T[A]].sort((ie,de)=>ie-de),W=d[A]>=0?x[d[A]].get(V[0]):E(V[0]);x[A].set(V[0],W);for(let ie=1;ie<V.length;ie++){let de=0;for(let X=D[0];X<=D[2];X++)de=Math.max(de,N(P(I[X][V[ie-1]],A),P(I[X][V[ie]],A),!0));W+=s+Math.max(o,de),x[A].set(V[ie],W)}}let b=c.map(()=>new Set),v=(A,D)=>{for(let V=A;V>=0;V=d[V])b[V].add(D)};c.forEach((A,D)=>{v(D,A.cells[0]),v(D,A.cells[2])});for(let A of t.cards){let D=I[A.cell[0]][A.cell[1]];D.length&&v(D[D.length-1],A.cell[0])}let g=c.map(()=>new Map);for(let A of c.map((D,V)=>V).sort((D,V)=>p(D)-p(V)||D-V)){let D=c[A].cells,V=[...b[A]].sort((ie,de)=>ie-de);if(d[A]<0&&!d.includes(A)&&V.length===D[2]-D[0]+1){for(let ie of V)g[A].set(ie,w(R,D[0],D[2],ie));continue}let W=d[A]>=0?g[d[A]].get(V[0]):R(V[0]);g[A].set(V[0],W);for(let ie=1;ie<V.length;ie++){let de=0;for(let X=D[1];X<=D[3];X++)de=Math.max(de,N(P(I[V[ie-1]][X],A),P(I[V[ie]][X],A),!1));W+=n+Math.max(r,de),g[A].set(V[ie],W)}}let O=(A,D)=>{let V=I[A][D],W=V.length?V[V.length-1]:-1;return W>=0?[g[W].get(A),x[W].get(D)]:[R(A),E(D)]},F=c.map((A,D)=>D).sort((A,D)=>p(D)-p(A)||A-D),j=new Array(c.length);for(let A of F){let D=c[A].cells,V=[],W=[];for(let X of t.cards){let te=I[X.cell[0]][X.cell[1]];te[te.length-1]===A&&(V.push(g[A].get(X.cell[0])),W.push(x[A].get(X.cell[1])))}let ie=X=>X.cell[0]>=D[0]&&X.cell[0]<=D[2]&&X.cell[1]>=D[1]&&X.cell[1]<=D[3];for(let X of[D[1],D[3]])t.cards.some(te=>te.cell[1]===X&&ie(te))||W.push(x[A].get(X));for(let X of[D[0],D[2]])t.cards.some(te=>te.cell[0]===X&&ie(te))||V.push(g[A].get(X));let de={l:V.length?Math.min(...V):1/0,t:W.length?Math.min(...W):1/0,r:V.length?Math.max(...V)+n:-1/0,b:W.length?Math.max(...W)+s:-1/0};c.forEach((X,te)=>{if(d[te]!==A)return;let ye=j[te];de.l=Math.min(de.l,ye.l),de.t=Math.min(de.t,ye.t),de.r=Math.max(de.r,ye.r),de.b=Math.max(de.b,ye.b)}),j[A]={l:de.l-i,t:de.t-i,r:de.r+i,b:de.b+i+a}}let U=t.cards.map(A=>O(A.cell[0],A.cell[1])),ne=t.cards.map(A=>{let D=I[A.cell[0]][A.cell[1]];return D.length?D[D.length-1]:-1}),B=(A,D)=>{for(let V=A;V>=0;V=d[V])if(V===D)return!0;return!1},K=(A,D)=>{t.cards.forEach((V,W)=>{ne[W]>=0&&B(ne[W],A)&&(U[W]=[U[W][0]+D,U[W][1]])}),c.forEach((V,W)=>{B(W,A)&&(j[W]={...j[W],l:j[W].l+D,r:j[W].r+D})})},q=A=>{let D=[],V=[],W=[],ie=[];t.cards.forEach((S,Y)=>{ne[Y]===A&&(D.push(U[Y][0]),W.push(U[Y][0]+n),V.push(U[Y][1]),ie.push(U[Y][1]+s))}),c.forEach((S,Y)=>{d[Y]===A&&(D.push(j[Y].l),W.push(j[Y].r),V.push(j[Y].t),ie.push(j[Y].b))});let de=j[A],X=Math.min(...D,de.l+i),te=Math.max(...W,de.r-i),ye=Math.min(...V,de.t+i),Fe=Math.max(...ie,de.b-i-a);j[A]={l:X-i,t:ye-i,r:te+i,b:Fe+i+a}};for(let A of F)if(d[A]<0&&!d.includes(A))q(A);else{let V=[];t.cards.forEach((te,ye)=>{ne[ye]===A&&V.push({l:U[ye][0],r:U[ye][0]+n,t:U[ye][1],b:U[ye][1]+s,card:ye})}),c.forEach((te,ye)=>{d[ye]===A&&V.push({...j[ye],panel:ye})}),V.sort((te,ye)=>te.l-ye.l||te.t-ye.t);let W=Math.min(...V.map(te=>te.l)),ie=[];for(let te of V){let ye=W;for(let S of ie)S.t<te.b&&te.t<S.b&&S.r<=te.l+1e-6&&(ye=Math.max(ye,S.r+(S.card!==void 0&&te.card!==void 0?r:l)));let Fe=ye-te.l;Fe<-1e-6&&(te.card!==void 0?U[te.card]=[U[te.card][0]+Fe,U[te.card][1]]:K(te.panel,Fe),te.l+=Fe,te.r+=Fe),ie.push(te)}let de=V.map(te=>te.l),X=V.map(te=>te.r);j[A]={...j[A],l:Math.min(...de)-i,r:Math.max(...X)+i}}return{prect:j,parentIx:d,depthOf:p,pos:O,cardAt:A=>U[A]}}function Os(t,e,n={}){if(n.wrap){let{wrap:k,..._}=n;return Os(Au(t,e,k.aspect,_),e,_)}let s=Ho(t);if(s.length)throw new Error(`the board has ${s.length} error${s.length>1?"s":""}:
277
277
  ${s.join(`
278
- `)}`);let r={...ka,...n},{W:o,H:i}=r,a=k=>Math.round(k*10)/10,l=[],c=t.panels??[],{prect:f,parentIx:u,depthOf:d,cardAt:p}=gr(t,r),h=c.map((k,_)=>{let z=f[_],oe=e(k.label??"","title")+(k.sub?e(k.sub,"titleSub"):0);return{...k,rect:z,titleAt:[a(z.l+16),a(z.b-15)],depth:d(_),parent:u[_]>=0?c[u[_]].id:void 0,title:{l:z.l+10,r:z.l+22+oe,t:z.b-30,b:z.b-6}}}),m=t.cards.map(k=>{let[_,z]=p(t.cards.indexOf(k));return{...k,rect:{l:_,t:z,r:_+o,b:z+i}}}),y=new Map;h.forEach(k=>y.set(k.id,k.rect)),m.forEach(k=>y.set(k.id,k.rect));let I=m.map(k=>k.rect),N=h.map(k=>k.rect),M=h.filter(k=>k.label).map(k=>k.title),$=(k,_)=>k.l>=_.l&&k.r<=_.r&&k.t>=_.t&&k.b<=_.b,O=(k,_,z,oe)=>Math.min(k[0],_[0])<z.r+oe&&Math.max(k[0],_[0])>z.l-oe&&Math.min(k[1],_[1])<z.b+oe&&Math.max(k[1],_[1])>z.t-oe,E=(k,_)=>N.reduce((z,oe)=>{if(k[0]===_[0]){let re=Math.min(k[1],_[1]),ke=Math.max(k[1],_[1]);k[0]>oe.l&&k[0]<oe.r&&(z+=[oe.t,oe.b].filter(he=>he>re+1&&he<ke-1).length)}else{let re=Math.min(k[0],_[0]),ke=Math.max(k[0],_[0]);k[1]>oe.t&&k[1]<oe.b&&(z+=[oe.l,oe.r].filter(he=>he>re+1&&he<ke-1).length)}return z},0),x=(k,_)=>N.some(z=>k[1]===_[1]?[z.t,z.b].some(oe=>Math.abs(k[1]-oe)<16&&Math.max(k[0],_[0])>z.l&&Math.min(k[0],_[0])<z.r):[z.l,z.r].some(oe=>Math.abs(k[0]-oe)<16&&Math.max(k[1],_[1])>z.t&&Math.min(k[1],_[1])<z.b)),T=(k,_,z,oe)=>N.filter(re=>re!==z&&re!==oe&&!$(z,re)&&!$(oe,re)&&O(k,_,{l:re.l+3,r:re.r-3,t:re.t+3,b:re.b-3},0)).length,L=[],w=new Map,P=new Map,b=(k,_)=>{L.push([k,_]);let[z,oe]=k[1]===_[1]?[w,k[1]]:k[0]===_[0]?[P,k[0]]:[void 0,0];if(!z)return;let re=Math.floor(oe/6);(z.get(re)??z.set(re,[]).get(re)).push([k,_])},v=(k,_)=>{let z=k[1]===_[1];if(!z&&k[0]!==_[0])return 0;let oe=z?1:0,re=z?0:1,ke=z?w:P,he=Math.floor(k[oe]/6),He=Math.min(k[re],_[re]),$e=Math.max(k[re],_[re]),be=0;for(let Ae=he-1;Ae<=he+1;Ae++)for(let[Ie,ot]of ke.get(Ae)??[])Math.abs(k[oe]-Ie[oe])<6&&Math.min($e,Math.max(Ie[re],ot[re]))-Math.max(He,Math.min(Ie[re],ot[re]))>0&&be++;return be},g=[...y.values()],R=Math.min(...g.map(k=>k.l)),F=Math.max(...g.map(k=>k.r)),j=Math.min(...g.map(k=>k.t)),U=Math.max(...g.map(k=>k.b)),ne=(k,_)=>{let z=(k+_)/2;return[z,z-12,z+12,z-24,z+24]},B=(()=>{let k=[];return I.forEach(_=>I.forEach(z=>{z.t>_.b&&z.l<_.r+400&&z.r>_.l-400&&k.push(...ne(_.b,z.t))})),k.push(j-22,j-34,U+22,U+34),[...new Set(k.map(Math.round))]})(),V=(()=>{let k=[];return I.forEach(_=>I.forEach(z=>{z.l>_.r&&k.push(...ne(_.r,z.l))})),k.push(R-22,R-34,F+22,F+34),[...new Set(k.map(Math.round))]})(),q=new Map,Z=new Map,A=k=>{let _=q.get(k);return _||q.set(k,_=I.filter(z=>k<z.b+6&&k>z.t-6)),_},D=k=>{let _=Z.get(k);return _||Z.set(k,_=I.filter(z=>k<z.r+6&&k>z.l-6)),_},K=r.crossPanel/r.overlap,W=r.border/r.overlap,ie=r.nearEdge/r.overlap;function de(k,_,z,oe,re=!0){let ke=0;for(let be=1;be<k.length;be++)ke+=Math.abs(k[be-1][0]-k[be][0])+Math.abs(k[be-1][1]-k[be][1]);let he=ke+r.bend*(k.length-2);if(he>=oe)return he;let He=0,$e=0;for(let be=1;be<k.length;be++){let Ae=k[be-1],Ie=k[be];if(re){if(le(Ae,Ie,_,z)||x(Ae,Ie))return 1/0;continue}for(let ot of Ae[1]===Ie[1]?A(Ae[1]):D(Ae[0]))ot!==_&&ot!==z&&O(Ae,Ie,ot,6)&&He++;for(let ot of M)O(Ae,Ie,ot,2)&&He++}for(let be=1;be<k.length;be++){let Ae=k[be-1],Ie=k[be];if($e+=v(Ae,Ie)+K*T(Ae,Ie,_,z)+W*E(Ae,Ie),x(Ae,Ie)&&($e+=ie),he+r.overlap*$e>=oe)return he+r.overlap*$e}return he+r.overlap*$e+He*1e5}let X=k=>(k.l+k.r)/2,te=k=>(k.t+k.b)/2,ye=[0,-22,22,-44,44],Fe={bc:1/0},S=(k,_,z,oe)=>Math.abs(k-z)+Math.abs(_-oe),Y=(k,_,z,oe,re,ke,he,He)=>{let $e=0;return $e+=S(k,_,z,oe),$e+=S(z,oe,re,ke),$e+=S(re,ke,he,He),$e+r.bend*2},se=(k,_,z,oe,re,ke,he,He,$e,be)=>{let Ae=0;return Ae+=S(k,_,z,oe),Ae+=S(z,oe,re,ke),Ae+=S(re,ke,he,He),Ae+=S(he,He,$e,be),Ae+r.bend*3},le=(k,_,z,oe)=>{for(let re of k[1]===_[1]?A(k[1]):D(k[0]))if(re!==z&&re!==oe&&O(k,_,re,6))return!0;for(let re of M)if(O(k,_,re,2))return!0;return x(k,_)};function Pe(k,_,z,oe){let re=Math.max(k.l,_.l),ke=Math.min(k.r,_.r);if(ke-re>24)for(let We of ye){let Ze=(re+ke)/2+We;Ze>re+8&&Ze<ke-8&&z(_.t>=k.b?[[Ze,k.b],[Ze,_.t]]:[[Ze,k.t],[Ze,_.b]])}let he=Math.max(k.t,_.t),He=Math.min(k.b,_.b);if(He-he>16)for(let We of[0,-10,10]){let Ze=(he+He)/2+We;z(_.l>=k.r?[[k.r,Ze],[_.l,Ze]]:[[k.l,Ze],[_.r,Ze]])}let $e=V.length,be=B.length,Ae=new Uint8Array(ye.length*be),Ie=new Uint8Array(ye.length*be),ot=new Uint8Array(ye.length*$e),Zn=new Uint8Array(ye.length*$e),ht=(We,Ze,sn,Mt)=>oe?(We[Ze]||(We[Ze]=le(sn,Mt,k,_)?2:1),We[Ze]===1):!0;ye.forEach((We,Ze)=>ye.forEach((sn,Mt)=>{let wt=X(k)+We,kt=X(_)+sn,$t=te(k)+We/3,ct=te(_)+sn/3;B.forEach((Ce,rn)=>{let et=Ce>k.b?k.b:Ce<k.t?k.t:null,Bt=Ce>_.b?_.b:Ce<_.t?_.t:null;et!==null&&Bt!==null&&Y(wt,et,wt,Ce,kt,Ce,kt,Bt)<Fe.bc&&ht(Ae,Ze*be+rn,[wt,et],[wt,Ce])&&ht(Ie,Mt*be+rn,[kt,Ce],[kt,Bt])&&z([[wt,et],[wt,Ce],[kt,Ce],[kt,Bt]])}),V.forEach((Ce,rn)=>{let et=Ce>k.r?k.r:Ce<k.l?k.l:null,Bt=Ce>_.r?_.r:Ce<_.l?_.l:null;et!==null&&Bt!==null&&Y(et,$t,Ce,$t,Ce,ct,Bt,ct)<Fe.bc&&ht(ot,Ze*$e+rn,[et,$t],[Ce,$t])&&ht(Zn,Mt*$e+rn,[Ce,ct],[Bt,ct])&&z([[et,$t],[Ce,$t],[Ce,ct],[Bt,ct]])}),We===0&&sn===0&&V.forEach((Ce,rn)=>B.forEach((et,Bt)=>{let C=Ce>k.r?k.r:Ce<k.l?k.l:null,G=et>_.b?_.b:et<_.t?_.t:null;C!==null&&G!==null&&se(C,$t,Ce,$t,Ce,et,kt,et,kt,G)<Fe.bc&&ht(ot,Ze*$e+rn,[C,$t],[Ce,$t])&&ht(Ie,Mt*be+Bt,[kt,et],[kt,G])&&z([[C,$t],[Ce,$t],[Ce,et],[kt,et],[kt,G]]);let J=et>k.b?k.b:et<k.t?k.t:null,ee=Ce>_.r?_.r:Ce<_.l?_.l:null;J!==null&&ee!==null&&se(wt,J,wt,et,Ce,et,Ce,ct,ee,ct)<Fe.bc&&ht(Ae,Ze*be+Bt,[wt,J],[wt,et])&&ht(Zn,Mt*$e+rn,[Ce,ct],[ee,ct])&&z([[wt,J],[wt,et],[Ce,et],[Ce,ct],[ee,ct]])}));let ms=X(k)<_.l?_.l:X(k)>_.r?_.r:null,Et=ct<k.t?k.t:ct>k.b?k.b:null;ms!==null&&Et!==null&&z([[wt,Et],[wt,ct],[ms,ct]]);let es=te(k)<_.t?_.t:te(k)>_.b?_.b:null,hs=kt<k.l?k.l:kt>k.r?k.r:null;es!==null&&hs!==null&&z([[hs,$t],[kt,$t],[kt,es]])}))}function ae(k,_,z,oe){for(let re of ye){let ke=X(k)+re,he=te(k)+re/3,He=[[[ke,k.t],[ke,_.t]],[[k.r,he],[_.r,he]],[[ke,k.b],[ke,_.b]],[[k.l,he],[_.l,he]]];for(let $e of He)oe(z?[$e[1],$e[0]]:$e)}}let Be=(k,_,z,oe)=>{let re=null;return Fe.bc=1/0,k(ke=>{let he=de(ke,_,z,Fe.bc,oe);he<Fe.bc&&(Fe.bc=he,re=ke)},oe),re},xe=[],fe=k=>N.some(_=>[_.l,_.r].some(z=>k.l<z+3&&k.r>z-3&&k.b>_.t&&k.t<_.b)||[_.t,_.b].some(z=>k.t<z+3&&k.b>z-3&&k.r>_.l&&k.l<_.r)),Se=k=>L.filter(([_,z])=>O(_,z,k,1)).length,Ve=k=>M.some(_=>k.l<_.r&&k.r>_.l&&k.t<_.b&&k.b>_.t),Te=k=>I.filter(_=>k.l<_.r+3&&k.r>_.l-3&&k.t<_.b+3&&k.b>_.t-3).length,Qe=k=>xe.filter(_=>k.l<_.r+4&&k.r>_.l-4&&k.t<_.b+2&&k.b>_.t-2).length,lt=k=>50*rt(k)+3*Se(k)+(fe(k)?1:0)+(Ve(k)?5:0)+5*Te(k)+5*Qe(k),je=k=>Se(k)>0||fe(k)||Ve(k)||Te(k)>0||Qe(k)>0,st=[];(t.links??[]).forEach((k,_)=>{let z=k.id??`link-${_}`,oe=y.get(k.aOn??k.a),re=y.get(k.bOn??k.b);if(oe===re){l.push(`link "${z}" joins "${k.aOn??k.a}" to itself: not drawn`),st.push({...k,id:z,points:[],routed:!1});return}let ke=$(oe,re)?$e=>ae(oe,re,!1,$e):$(re,oe)?$e=>ae(re,oe,!0,$e):($e,be)=>Pe(oe,re,$e,be),he=Be(ke,oe,re,!0),He=!0;if(he||(he=Be(ke,oe,re,!1),He=!1,l.push(`link "${z}": no clear route; drawn the least bad way`)),!he){st.push({...k,id:z,points:[],routed:!1});return}for(let $e=1;$e<he.length;$e++)b(he[$e-1],he[$e]);st.push({...k,id:z,points:he,routed:He})});let Ye=[];for(let k=0;k<L.length;k++)for(let _=k+1;_<L.length;_++){let[z,oe]=L[k],[re,ke]=L[_],he=z[1]===oe[1],He=re[1]===ke[1];if(he===He)continue;let[$e,be]=he?[[z,oe],[re,ke]]:[[re,ke],[z,oe]],Ae=be[0][0],Ie=$e[0][1];Ae>Math.min($e[0][0],$e[1][0])&&Ae<Math.max($e[0][0],$e[1][0])&&Ie>Math.min(be[0][1],be[1][1])&&Ie<Math.max(be[0][1],be[1][1])&&Ye.push([Ae,Ie])}let rt=k=>Ye.filter(([_,z])=>_>k.l-2&&_<k.r+2&&z>k.t-2&&z<k.b+2).length;for(let k of st){let _=k,z=k.points;if(!_.label||!z.length)continue;let oe=[];for(let be=1;be<z.length;be++)oe.push([z[be-1],z[be]]);let re=be=>Math.abs(be[0][0]-be[1][0])+Math.abs(be[0][1]-be[1][1]);oe.sort((be,Ae)=>re(Ae)-re(be));let ke=e(_.label,"label")+6,he=null,He=null,$e=1/0;for(let[be,Ae]of oe){let Ie=(be[0]+Ae[0])/2,ot=(be[1]+Ae[1])/2,Zn=be[1]===Ae[1]?[0,-.3,.3,-.15,.15].flatMap(ht=>{let We=Ie+ht*Math.abs(be[0]-Ae[0]);return[[We,ot-6,"middle"],[We,ot+15,"middle"]]}):[0,-.3,.3].flatMap(ht=>{let We=ot+4+ht*Math.abs(be[1]-Ae[1]);return[[Ie+7,We,"start"],[Ie-7,We,"end"],[Ie+24,We,"start"],[Ie-24,We,"end"]]});for(let[ht,We,Ze]of Zn){let sn=Ze==="middle"?ht-ke/2:Ze==="end"?ht-ke:ht,Mt={l:sn,r:sn+ke,t:We-11,b:We+3};if(!je(Mt)){he=[ht,We,Ze,Mt];break}let wt=lt(Mt);wt<$e&&($e=wt,He=[ht,We,Ze,Mt])}if(he)break}if(!he&&He&&(he=He),!he){let[be,Ae]=oe[0],Ie=(be[0]+Ae[0])/2,ot=(be[1]+Ae[1])/2-6;he=[Ie,ot,"middle",{l:Ie-ke/2,r:Ie+ke/2,t:ot-11,b:ot+3}]}xe.push(he[3]),k.at={x:a(he[0]),y:a(he[1]),anchor:he[2],box:he[3],text:_.label}}let ce=[],Re=[];for(let k of[...g,...xe,...h.map(_=>_.title)])ce.push(k.l,k.r),Re.push(k.t,k.b);for(let k of st)for(let _ of k.points)ce.push(_[0]),Re.push(_[1]);let Ee=r.margin,tt={l:Math.min(...ce)-Ee,t:Math.min(...Re)-Ee,r:Math.max(...ce)+Ee,b:Math.max(...Re)+Ee};return{cards:m,panels:h,links:st,bounds:tt,options:r,warnings:l}}function kc(t,e,n){let s=o=>e>=o.l&&e<=o.r&&n>=o.t&&n<=o.b,r=t.cards.find(o=>s(o.rect));return r?r.id:[...t.panels].sort((o,i)=>i.depth-o.depth).find(o=>s(o.rect))?.id}function Au(t,e,n,s={}){let r=a=>{let l=Rs(a,e,s);return Math.max(l.bounds.r-l.bounds.l,(l.bounds.b-l.bounds.t)*n)},o=t,i=r(t);for(let a=0;a<12;a++){let l,c=i;for(let f of Nu(o)){if(Ho(f).length)continue;let u=r(f);u<c-.5&&(c=u,l=f)}if(!l)break;o=l,i=c}return o}function*Nu(t){let e=t.panels??[],n=(i,a)=>i[0]>=a[0]&&i[2]<=a[2]&&i[1]>=a[1]&&i[3]<=a[3],s=(i,a)=>i.every((l,c)=>l===a[c]),r=(i,a=-1)=>{let l=-1;return e.forEach((c,f)=>{f===a||!n(i,c.cells)||a>=0&&f>a&&s(c.cells,e[a].cells)||(l<0||n(c.cells,e[l].cells)&&(!s(c.cells,e[l].cells)||f>l))&&(l=f)}),l},o=i=>{let a=[];return e.forEach((l,c)=>{r(l.cells,c)===i&&a.push({range:[...l.cells],panel:c})}),t.cards.forEach((l,c)=>{let f=[l.cell[0],l.cell[1],l.cell[0],l.cell[1]];r(f)===i&&a.push({range:f,card:c})}),a};for(let i of[-1,...e.map((a,l)=>l)]){let a=o(i);if(i>=0&&!a.some(u=>u.panel!==void 0))continue;let l=u=>[u.range[1],u.range[3]],c=[];for(let u of[...a].sort((d,p)=>d.range[1]-p.range[1]||d.range[0]-p.range[0])){let d=c.find(p=>p.some(h=>l(h)[0]<=l(u)[1]&&l(u)[0]<=l(h)[1]));d?d.push(u):c.push([u])}let f=Math.max(...a.map(u=>u.range[3]));for(let u of c){u.sort((d,p)=>d.range[0]-p.range[0]);for(let d=1;d<u.length;d++){let p=u.slice(d),h=u[0].range[0],m=f+1,y=Math.min(...p.map(E=>E.range[1])),I=Math.max(...p.map(E=>E.range[3]))-y+1,N=t.cards.map(E=>({...E,cell:[...E.cell]})),M=e.map(E=>({...E,cells:[...E.cells]}));for(let E of N)E.cell[1]>f&&(E.cell[1]+=I);let $=new Set;for(let E=i;E>=0&&!$.has(E);E=r(e[E].cells,E))$.add(E);M.forEach((E,x)=>{E.cells[1]>f?(E.cells[1]+=I,E.cells[3]+=I):($.has(x)||E.cells[1]<=f&&E.cells[3]>f)&&(E.cells[3]+=I)});let O=h;for(let E of p){let x=O-E.range[0],T=m+(E.range[1]-y)-E.range[1],L=w=>w[0]>=E.range[0]&&w[0]<=E.range[2]&&w[1]>=E.range[1]&&w[1]<=E.range[3];t.cards.forEach((w,P)=>{L([w.cell[0],w.cell[1]])&&(N[P].cell=[w.cell[0]+x,w.cell[1]+T])}),e.forEach((w,P)=>{n(w.cells,E.range)&&(M[P].cells=[w.cells[0]+x,w.cells[1]+T,w.cells[2]+x,w.cells[3]+T])}),O+=E.range[2]-E.range[0]+1}e.forEach((E,x)=>{let T=t.cards.map((L,w)=>n([L.cell[0],L.cell[1],L.cell[0],L.cell[1]],E.cells)?N[w].cell:void 0).filter(L=>!!L);T.length&&(M[x].cells=[Math.min(...T.map(L=>L[0])),Math.min(...T.map(L=>L[1])),Math.max(...T.map(L=>L[0])),Math.max(...T.map(L=>L[1]))])}),yield{cards:N,panels:M,links:t.links}}}}}function Wo(t,e=()=>!0){let n=t.layout.items.filter(x=>e(x.id)),s=t.layout.catalog,r=!t.layout.items.some(x=>x.type==="node"),o=x=>r?!x.children.some(T=>e(T.id)):x.type==="node"&&!x.children.some(T=>T.type==="node"&&e(T.id)),i=n.filter(o),a=x=>{let T=[];for(let L=x;L;L=L.parent)T.unshift(L);return T},l=new Map(i.map(x=>[x.id,a(x)])),c=(x,T)=>{let L=l.get(x.id),w=l.get(T.id),P=0;for(;P<L.length&&P<w.length&&L[P]===w[P];)P++;return[L[P].box,w[P].box]},f=1e-6,u=(x,T)=>{let[L,w]=c(x,T);return L.y1<=w.y0+f&&L.x0<w.x1-f&&w.x0<L.x1-f},d=(x,T)=>{let[L,w]=c(x,T);return L.x1<=w.x0+f&&L.y0<w.y1-f&&w.y0<L.y1-f},p=(x,T)=>{let L=new Map,w=[];for(let P of[...i].sort((b,v)=>T(b)-T(v))){let b=0;for(let v of w)L.get(v.id)+1>b&&x(v,P)&&(b=L.get(v.id)+1);L.set(P.id,b),w.push(P)}return L},h=p(u,x=>x.box.y0),m=p(d,x=>x.box.x0),y=Math.min(...i.map(x=>x.box.x1-x.box.x0))/2;for(let x of i)if(!x.parent)for(let T of i)T.parent&&T.box.x0<=x.box.x0+y&&m.set(x.id,Math.max(m.get(x.id),m.get(T.id)));let I=new Map;for(let x of i)I.set(x.id,[m.get(x.id),h.get(x.id)]);let N=new Map;for(let x of i){let T=I.get(x.id),L=N.get(String(T));if(L!==void 0&&L!==x.id){for(let[,w]of I)w[0]>T[0]&&w!==T&&w[0]++;T[0]++,N.clear();for(let w of i)N.set(String(I.get(w.id)),w.id)}else N.set(String(T),x.id)}let M=i.map(x=>{if(x.region){let w=x.region;return{id:x.id,label:w.label??x.id,sub:void 0,role:w.role??pt(s,w.kind)?.role??"grey",ghost:w.ghost||void 0,cell:I.get(x.id)}}let T=x.node,L=Qt(s,T.asset);return{id:x.id,label:T.label??x.id,sub:T.sub,role:T.role??L.role,ghost:T.ghost||void 0,cell:I.get(x.id)}}),$=[];for(let x of n){if(o(x))continue;let T=[],L=g=>{for(let R of g.children){let F=I.get(R.id);F&&T.push(F),L(R)}};if(L(x),!T.length)continue;let w=T.map(g=>g[0]),P=T.map(g=>g[1]),b=x.type==="region"?x.region.label:x.node.label??x.id,v=x.type==="region"?x.region.role??pt(s,x.region.kind)?.role:x.node.role??Qt(s,x.node.asset).role;$.push({id:x.id,label:b,sub:x.type==="node"?x.node.sub:void 0,role:v,cells:[Math.min(...w),Math.min(...P),Math.max(...w),Math.max(...P)]})}let O=new Set([...M.map(x=>x.id),...$.map(x=>x.id)]),E=[];for(let x of t.routes){if(!e(x.id))continue;let T=Ut(x.raw.from).id,L=Ut(x.raw.to).id;if(!O.has(T)||!O.has(L))continue;let w=typeof x.raw.label=="string"?x.raw.label:x.raw.label?.text;E.push({id:x.id,a:T,b:L,kind:x.kind,label:w})}return{cards:M,panels:$,links:E}}var Wn={W:4,D:2,H:.9,GX:2,GY:2.4,PAD:.6,CH:2.2,PANEL_H:.3},vc=`
278
+ `)}`);let r={...Sa,...n},{W:o,H:i}=r,a=k=>Math.round(k*10)/10,l=[],c=t.panels??[],{prect:f,parentIx:u,depthOf:d,cardAt:p}=gr(t,r),h=c.map((k,_)=>{let z=f[_],oe=e(k.label??"","title")+(k.sub?e(k.sub,"titleSub"):0);return{...k,rect:z,titleAt:[a(z.l+16),a(z.b-15)],depth:d(_),parent:u[_]>=0?c[u[_]].id:void 0,title:{l:z.l+10,r:z.l+22+oe,t:z.b-30,b:z.b-6}}}),m=t.cards.map(k=>{let[_,z]=p(t.cards.indexOf(k));return{...k,rect:{l:_,t:z,r:_+o,b:z+i}}}),y=new Map;h.forEach(k=>y.set(k.id,k.rect)),m.forEach(k=>y.set(k.id,k.rect));let I=m.map(k=>k.rect),N=h.map(k=>k.rect),M=h.filter(k=>k.label).map(k=>k.title),$=(k,_)=>k.l>=_.l&&k.r<=_.r&&k.t>=_.t&&k.b<=_.b,R=(k,_,z,oe)=>Math.min(k[0],_[0])<z.r+oe&&Math.max(k[0],_[0])>z.l-oe&&Math.min(k[1],_[1])<z.b+oe&&Math.max(k[1],_[1])>z.t-oe,E=(k,_)=>N.reduce((z,oe)=>{if(k[0]===_[0]){let re=Math.min(k[1],_[1]),ke=Math.max(k[1],_[1]);k[0]>oe.l&&k[0]<oe.r&&(z+=[oe.t,oe.b].filter(he=>he>re+1&&he<ke-1).length)}else{let re=Math.min(k[0],_[0]),ke=Math.max(k[0],_[0]);k[1]>oe.t&&k[1]<oe.b&&(z+=[oe.l,oe.r].filter(he=>he>re+1&&he<ke-1).length)}return z},0),w=(k,_)=>N.some(z=>k[1]===_[1]?[z.t,z.b].some(oe=>Math.abs(k[1]-oe)<16&&Math.max(k[0],_[0])>z.l&&Math.min(k[0],_[0])<z.r):[z.l,z.r].some(oe=>Math.abs(k[0]-oe)<16&&Math.max(k[1],_[1])>z.t&&Math.min(k[1],_[1])<z.b)),T=(k,_,z,oe)=>N.filter(re=>re!==z&&re!==oe&&!$(z,re)&&!$(oe,re)&&R(k,_,{l:re.l+3,r:re.r-3,t:re.t+3,b:re.b-3},0)).length,L=[],x=new Map,P=new Map,b=(k,_)=>{L.push([k,_]);let[z,oe]=k[1]===_[1]?[x,k[1]]:k[0]===_[0]?[P,k[0]]:[void 0,0];if(!z)return;let re=Math.floor(oe/6);(z.get(re)??z.set(re,[]).get(re)).push([k,_])},v=(k,_)=>{let z=k[1]===_[1];if(!z&&k[0]!==_[0])return 0;let oe=z?1:0,re=z?0:1,ke=z?x:P,he=Math.floor(k[oe]/6),He=Math.min(k[re],_[re]),$e=Math.max(k[re],_[re]),be=0;for(let Ae=he-1;Ae<=he+1;Ae++)for(let[Ie,ot]of ke.get(Ae)??[])Math.abs(k[oe]-Ie[oe])<6&&Math.min($e,Math.max(Ie[re],ot[re]))-Math.max(He,Math.min(Ie[re],ot[re]))>0&&be++;return be},g=[...y.values()],O=Math.min(...g.map(k=>k.l)),F=Math.max(...g.map(k=>k.r)),j=Math.min(...g.map(k=>k.t)),U=Math.max(...g.map(k=>k.b)),ne=(k,_)=>{let z=(k+_)/2;return[z,z-12,z+12,z-24,z+24]},B=(()=>{let k=[];return I.forEach(_=>I.forEach(z=>{z.t>_.b&&z.l<_.r+400&&z.r>_.l-400&&k.push(...ne(_.b,z.t))})),k.push(j-22,j-34,U+22,U+34),[...new Set(k.map(Math.round))]})(),K=(()=>{let k=[];return I.forEach(_=>I.forEach(z=>{z.l>_.r&&k.push(...ne(_.r,z.l))})),k.push(O-22,O-34,F+22,F+34),[...new Set(k.map(Math.round))]})(),q=new Map,Z=new Map,A=k=>{let _=q.get(k);return _||q.set(k,_=I.filter(z=>k<z.b+6&&k>z.t-6)),_},D=k=>{let _=Z.get(k);return _||Z.set(k,_=I.filter(z=>k<z.r+6&&k>z.l-6)),_},V=r.crossPanel/r.overlap,W=r.border/r.overlap,ie=r.nearEdge/r.overlap;function de(k,_,z,oe,re=!0){let ke=0;for(let be=1;be<k.length;be++)ke+=Math.abs(k[be-1][0]-k[be][0])+Math.abs(k[be-1][1]-k[be][1]);let he=ke+r.bend*(k.length-2);if(he>=oe)return he;let He=0,$e=0;for(let be=1;be<k.length;be++){let Ae=k[be-1],Ie=k[be];if(re){if(le(Ae,Ie,_,z)||w(Ae,Ie))return 1/0;continue}for(let ot of Ae[1]===Ie[1]?A(Ae[1]):D(Ae[0]))ot!==_&&ot!==z&&R(Ae,Ie,ot,6)&&He++;for(let ot of M)R(Ae,Ie,ot,2)&&He++}for(let be=1;be<k.length;be++){let Ae=k[be-1],Ie=k[be];if($e+=v(Ae,Ie)+V*T(Ae,Ie,_,z)+W*E(Ae,Ie),w(Ae,Ie)&&($e+=ie),he+r.overlap*$e>=oe)return he+r.overlap*$e}return he+r.overlap*$e+He*1e5}let X=k=>(k.l+k.r)/2,te=k=>(k.t+k.b)/2,ye=[0,-22,22,-44,44],Fe={bc:1/0},S=(k,_,z,oe)=>Math.abs(k-z)+Math.abs(_-oe),Y=(k,_,z,oe,re,ke,he,He)=>{let $e=0;return $e+=S(k,_,z,oe),$e+=S(z,oe,re,ke),$e+=S(re,ke,he,He),$e+r.bend*2},se=(k,_,z,oe,re,ke,he,He,$e,be)=>{let Ae=0;return Ae+=S(k,_,z,oe),Ae+=S(z,oe,re,ke),Ae+=S(re,ke,he,He),Ae+=S(he,He,$e,be),Ae+r.bend*3},le=(k,_,z,oe)=>{for(let re of k[1]===_[1]?A(k[1]):D(k[0]))if(re!==z&&re!==oe&&R(k,_,re,6))return!0;for(let re of M)if(R(k,_,re,2))return!0;return w(k,_)};function Pe(k,_,z,oe){let re=Math.max(k.l,_.l),ke=Math.min(k.r,_.r);if(ke-re>24)for(let We of ye){let Ze=(re+ke)/2+We;Ze>re+8&&Ze<ke-8&&z(_.t>=k.b?[[Ze,k.b],[Ze,_.t]]:[[Ze,k.t],[Ze,_.b]])}let he=Math.max(k.t,_.t),He=Math.min(k.b,_.b);if(He-he>16)for(let We of[0,-10,10]){let Ze=(he+He)/2+We;z(_.l>=k.r?[[k.r,Ze],[_.l,Ze]]:[[k.l,Ze],[_.r,Ze]])}let $e=K.length,be=B.length,Ae=new Uint8Array(ye.length*be),Ie=new Uint8Array(ye.length*be),ot=new Uint8Array(ye.length*$e),Zn=new Uint8Array(ye.length*$e),ht=(We,Ze,sn,Mt)=>oe?(We[Ze]||(We[Ze]=le(sn,Mt,k,_)?2:1),We[Ze]===1):!0;ye.forEach((We,Ze)=>ye.forEach((sn,Mt)=>{let wt=X(k)+We,kt=X(_)+sn,$t=te(k)+We/3,ct=te(_)+sn/3;B.forEach((Ce,rn)=>{let et=Ce>k.b?k.b:Ce<k.t?k.t:null,Bt=Ce>_.b?_.b:Ce<_.t?_.t:null;et!==null&&Bt!==null&&Y(wt,et,wt,Ce,kt,Ce,kt,Bt)<Fe.bc&&ht(Ae,Ze*be+rn,[wt,et],[wt,Ce])&&ht(Ie,Mt*be+rn,[kt,Ce],[kt,Bt])&&z([[wt,et],[wt,Ce],[kt,Ce],[kt,Bt]])}),K.forEach((Ce,rn)=>{let et=Ce>k.r?k.r:Ce<k.l?k.l:null,Bt=Ce>_.r?_.r:Ce<_.l?_.l:null;et!==null&&Bt!==null&&Y(et,$t,Ce,$t,Ce,ct,Bt,ct)<Fe.bc&&ht(ot,Ze*$e+rn,[et,$t],[Ce,$t])&&ht(Zn,Mt*$e+rn,[Ce,ct],[Bt,ct])&&z([[et,$t],[Ce,$t],[Ce,ct],[Bt,ct]])}),We===0&&sn===0&&K.forEach((Ce,rn)=>B.forEach((et,Bt)=>{let C=Ce>k.r?k.r:Ce<k.l?k.l:null,G=et>_.b?_.b:et<_.t?_.t:null;C!==null&&G!==null&&se(C,$t,Ce,$t,Ce,et,kt,et,kt,G)<Fe.bc&&ht(ot,Ze*$e+rn,[C,$t],[Ce,$t])&&ht(Ie,Mt*be+Bt,[kt,et],[kt,G])&&z([[C,$t],[Ce,$t],[Ce,et],[kt,et],[kt,G]]);let J=et>k.b?k.b:et<k.t?k.t:null,ee=Ce>_.r?_.r:Ce<_.l?_.l:null;J!==null&&ee!==null&&se(wt,J,wt,et,Ce,et,Ce,ct,ee,ct)<Fe.bc&&ht(Ae,Ze*be+Bt,[wt,J],[wt,et])&&ht(Zn,Mt*$e+rn,[Ce,ct],[ee,ct])&&z([[wt,J],[wt,et],[Ce,et],[Ce,ct],[ee,ct]])}));let ms=X(k)<_.l?_.l:X(k)>_.r?_.r:null,Et=ct<k.t?k.t:ct>k.b?k.b:null;ms!==null&&Et!==null&&z([[wt,Et],[wt,ct],[ms,ct]]);let es=te(k)<_.t?_.t:te(k)>_.b?_.b:null,hs=kt<k.l?k.l:kt>k.r?k.r:null;es!==null&&hs!==null&&z([[hs,$t],[kt,$t],[kt,es]])}))}function ae(k,_,z,oe){for(let re of ye){let ke=X(k)+re,he=te(k)+re/3,He=[[[ke,k.t],[ke,_.t]],[[k.r,he],[_.r,he]],[[ke,k.b],[ke,_.b]],[[k.l,he],[_.l,he]]];for(let $e of He)oe(z?[$e[1],$e[0]]:$e)}}let Be=(k,_,z,oe)=>{let re=null;return Fe.bc=1/0,k(ke=>{let he=de(ke,_,z,Fe.bc,oe);he<Fe.bc&&(Fe.bc=he,re=ke)},oe),re},xe=[],fe=k=>N.some(_=>[_.l,_.r].some(z=>k.l<z+3&&k.r>z-3&&k.b>_.t&&k.t<_.b)||[_.t,_.b].some(z=>k.t<z+3&&k.b>z-3&&k.r>_.l&&k.l<_.r)),Se=k=>L.filter(([_,z])=>R(_,z,k,1)).length,Ke=k=>M.some(_=>k.l<_.r&&k.r>_.l&&k.t<_.b&&k.b>_.t),Te=k=>I.filter(_=>k.l<_.r+3&&k.r>_.l-3&&k.t<_.b+3&&k.b>_.t-3).length,Qe=k=>xe.filter(_=>k.l<_.r+4&&k.r>_.l-4&&k.t<_.b+2&&k.b>_.t-2).length,lt=k=>50*rt(k)+3*Se(k)+(fe(k)?1:0)+(Ke(k)?5:0)+5*Te(k)+5*Qe(k),je=k=>Se(k)>0||fe(k)||Ke(k)||Te(k)>0||Qe(k)>0,st=[];(t.links??[]).forEach((k,_)=>{let z=k.id??`link-${_}`,oe=y.get(k.aOn??k.a),re=y.get(k.bOn??k.b);if(oe===re){l.push(`link "${z}" joins "${k.aOn??k.a}" to itself: not drawn`),st.push({...k,id:z,points:[],routed:!1});return}let ke=$(oe,re)?$e=>ae(oe,re,!1,$e):$(re,oe)?$e=>ae(re,oe,!0,$e):($e,be)=>Pe(oe,re,$e,be),he=Be(ke,oe,re,!0),He=!0;if(he||(he=Be(ke,oe,re,!1),He=!1,l.push(`link "${z}": no clear route; drawn the least bad way`)),!he){st.push({...k,id:z,points:[],routed:!1});return}for(let $e=1;$e<he.length;$e++)b(he[$e-1],he[$e]);st.push({...k,id:z,points:he,routed:He})});let Ye=[];for(let k=0;k<L.length;k++)for(let _=k+1;_<L.length;_++){let[z,oe]=L[k],[re,ke]=L[_],he=z[1]===oe[1],He=re[1]===ke[1];if(he===He)continue;let[$e,be]=he?[[z,oe],[re,ke]]:[[re,ke],[z,oe]],Ae=be[0][0],Ie=$e[0][1];Ae>Math.min($e[0][0],$e[1][0])&&Ae<Math.max($e[0][0],$e[1][0])&&Ie>Math.min(be[0][1],be[1][1])&&Ie<Math.max(be[0][1],be[1][1])&&Ye.push([Ae,Ie])}let rt=k=>Ye.filter(([_,z])=>_>k.l-2&&_<k.r+2&&z>k.t-2&&z<k.b+2).length;for(let k of st){let _=k,z=k.points;if(!_.label||!z.length)continue;let oe=[];for(let be=1;be<z.length;be++)oe.push([z[be-1],z[be]]);let re=be=>Math.abs(be[0][0]-be[1][0])+Math.abs(be[0][1]-be[1][1]);oe.sort((be,Ae)=>re(Ae)-re(be));let ke=e(_.label,"label")+6,he=null,He=null,$e=1/0;for(let[be,Ae]of oe){let Ie=(be[0]+Ae[0])/2,ot=(be[1]+Ae[1])/2,Zn=be[1]===Ae[1]?[0,-.3,.3,-.15,.15].flatMap(ht=>{let We=Ie+ht*Math.abs(be[0]-Ae[0]);return[[We,ot-6,"middle"],[We,ot+15,"middle"]]}):[0,-.3,.3].flatMap(ht=>{let We=ot+4+ht*Math.abs(be[1]-Ae[1]);return[[Ie+7,We,"start"],[Ie-7,We,"end"],[Ie+24,We,"start"],[Ie-24,We,"end"]]});for(let[ht,We,Ze]of Zn){let sn=Ze==="middle"?ht-ke/2:Ze==="end"?ht-ke:ht,Mt={l:sn,r:sn+ke,t:We-11,b:We+3};if(!je(Mt)){he=[ht,We,Ze,Mt];break}let wt=lt(Mt);wt<$e&&($e=wt,He=[ht,We,Ze,Mt])}if(he)break}if(!he&&He&&(he=He),!he){let[be,Ae]=oe[0],Ie=(be[0]+Ae[0])/2,ot=(be[1]+Ae[1])/2-6;he=[Ie,ot,"middle",{l:Ie-ke/2,r:Ie+ke/2,t:ot-11,b:ot+3}]}xe.push(he[3]),k.at={x:a(he[0]),y:a(he[1]),anchor:he[2],box:he[3],text:_.label}}let ce=[],Oe=[];for(let k of[...g,...xe,...h.map(_=>_.title)])ce.push(k.l,k.r),Oe.push(k.t,k.b);for(let k of st)for(let _ of k.points)ce.push(_[0]),Oe.push(_[1]);let Ee=r.margin,tt={l:Math.min(...ce)-Ee,t:Math.min(...Oe)-Ee,r:Math.max(...ce)+Ee,b:Math.max(...Oe)+Ee};return{cards:m,panels:h,links:st,bounds:tt,options:r,warnings:l}}function Sc(t,e,n){let s=o=>e>=o.l&&e<=o.r&&n>=o.t&&n<=o.b,r=t.cards.find(o=>s(o.rect));return r?r.id:[...t.panels].sort((o,i)=>i.depth-o.depth).find(o=>s(o.rect))?.id}function Au(t,e,n,s={}){let r=a=>{let l=Os(a,e,s);return Math.max(l.bounds.r-l.bounds.l,(l.bounds.b-l.bounds.t)*n)},o=t,i=r(t);for(let a=0;a<12;a++){let l,c=i;for(let f of Nu(o)){if(Ho(f).length)continue;let u=r(f);u<c-.5&&(c=u,l=f)}if(!l)break;o=l,i=c}return o}function*Nu(t){let e=t.panels??[],n=(i,a)=>i[0]>=a[0]&&i[2]<=a[2]&&i[1]>=a[1]&&i[3]<=a[3],s=(i,a)=>i.every((l,c)=>l===a[c]),r=(i,a=-1)=>{let l=-1;return e.forEach((c,f)=>{f===a||!n(i,c.cells)||a>=0&&f>a&&s(c.cells,e[a].cells)||(l<0||n(c.cells,e[l].cells)&&(!s(c.cells,e[l].cells)||f>l))&&(l=f)}),l},o=i=>{let a=[];return e.forEach((l,c)=>{r(l.cells,c)===i&&a.push({range:[...l.cells],panel:c})}),t.cards.forEach((l,c)=>{let f=[l.cell[0],l.cell[1],l.cell[0],l.cell[1]];r(f)===i&&a.push({range:f,card:c})}),a};for(let i of[-1,...e.map((a,l)=>l)]){let a=o(i);if(i>=0&&!a.some(u=>u.panel!==void 0))continue;let l=u=>[u.range[1],u.range[3]],c=[];for(let u of[...a].sort((d,p)=>d.range[1]-p.range[1]||d.range[0]-p.range[0])){let d=c.find(p=>p.some(h=>l(h)[0]<=l(u)[1]&&l(u)[0]<=l(h)[1]));d?d.push(u):c.push([u])}let f=Math.max(...a.map(u=>u.range[3]));for(let u of c){u.sort((d,p)=>d.range[0]-p.range[0]);for(let d=1;d<u.length;d++){let p=u.slice(d),h=u[0].range[0],m=f+1,y=Math.min(...p.map(E=>E.range[1])),I=Math.max(...p.map(E=>E.range[3]))-y+1,N=t.cards.map(E=>({...E,cell:[...E.cell]})),M=e.map(E=>({...E,cells:[...E.cells]}));for(let E of N)E.cell[1]>f&&(E.cell[1]+=I);let $=new Set;for(let E=i;E>=0&&!$.has(E);E=r(e[E].cells,E))$.add(E);M.forEach((E,w)=>{E.cells[1]>f?(E.cells[1]+=I,E.cells[3]+=I):($.has(w)||E.cells[1]<=f&&E.cells[3]>f)&&(E.cells[3]+=I)});let R=h;for(let E of p){let w=R-E.range[0],T=m+(E.range[1]-y)-E.range[1],L=x=>x[0]>=E.range[0]&&x[0]<=E.range[2]&&x[1]>=E.range[1]&&x[1]<=E.range[3];t.cards.forEach((x,P)=>{L([x.cell[0],x.cell[1]])&&(N[P].cell=[x.cell[0]+w,x.cell[1]+T])}),e.forEach((x,P)=>{n(x.cells,E.range)&&(M[P].cells=[x.cells[0]+w,x.cells[1]+T,x.cells[2]+w,x.cells[3]+T])}),R+=E.range[2]-E.range[0]+1}e.forEach((E,w)=>{let T=t.cards.map((L,x)=>n([L.cell[0],L.cell[1],L.cell[0],L.cell[1]],E.cells)?N[x].cell:void 0).filter(L=>!!L);T.length&&(M[w].cells=[Math.min(...T.map(L=>L[0])),Math.min(...T.map(L=>L[1])),Math.max(...T.map(L=>L[0])),Math.max(...T.map(L=>L[1]))])}),yield{cards:N,panels:M,links:t.links}}}}}function Wo(t,e=()=>!0){let n=t.layout.items.filter(w=>e(w.id)),s=t.layout.catalog,r=!t.layout.items.some(w=>w.type==="node"),o=w=>r?!w.children.some(T=>e(T.id)):w.type==="node"&&!w.children.some(T=>T.type==="node"&&e(T.id)),i=n.filter(o),a=w=>{let T=[];for(let L=w;L;L=L.parent)T.unshift(L);return T},l=new Map(i.map(w=>[w.id,a(w)])),c=(w,T)=>{let L=l.get(w.id),x=l.get(T.id),P=0;for(;P<L.length&&P<x.length&&L[P]===x[P];)P++;return[L[P].box,x[P].box]},f=1e-6,u=(w,T)=>{let[L,x]=c(w,T);return L.y1<=x.y0+f&&L.x0<x.x1-f&&x.x0<L.x1-f},d=(w,T)=>{let[L,x]=c(w,T);return L.x1<=x.x0+f&&L.y0<x.y1-f&&x.y0<L.y1-f},p=(w,T)=>{let L=new Map,x=[];for(let P of[...i].sort((b,v)=>T(b)-T(v))){let b=0;for(let v of x)L.get(v.id)+1>b&&w(v,P)&&(b=L.get(v.id)+1);L.set(P.id,b),x.push(P)}return L},h=p(u,w=>w.box.y0),m=p(d,w=>w.box.x0),y=Math.min(...i.map(w=>w.box.x1-w.box.x0))/2;for(let w of i)if(!w.parent)for(let T of i)T.parent&&T.box.x0<=w.box.x0+y&&m.set(w.id,Math.max(m.get(w.id),m.get(T.id)));let I=new Map;for(let w of i)I.set(w.id,[m.get(w.id),h.get(w.id)]);let N=new Map;for(let w of i){let T=I.get(w.id),L=N.get(String(T));if(L!==void 0&&L!==w.id){for(let[,x]of I)x[0]>T[0]&&x!==T&&x[0]++;T[0]++,N.clear();for(let x of i)N.set(String(I.get(x.id)),x.id)}else N.set(String(T),w.id)}let M=i.map(w=>{if(w.region){let x=w.region;return{id:w.id,label:x.label??w.id,sub:void 0,role:x.role??pt(s,x.kind)?.role??"grey",ghost:x.ghost||void 0,cell:I.get(w.id)}}let T=w.node,L=Qt(s,T.asset);return{id:w.id,label:T.label??w.id,sub:T.sub,role:T.role??L.role,ghost:T.ghost||void 0,cell:I.get(w.id)}}),$=[];for(let w of n){if(o(w))continue;let T=[],L=g=>{for(let O of g.children){let F=I.get(O.id);F&&T.push(F),L(O)}};if(L(w),!T.length)continue;let x=T.map(g=>g[0]),P=T.map(g=>g[1]),b=w.type==="region"?w.region.label:w.node.label??w.id,v=w.type==="region"?w.region.role??pt(s,w.region.kind)?.role:w.node.role??Qt(s,w.node.asset).role;$.push({id:w.id,label:b,sub:w.type==="node"?w.node.sub:void 0,role:v,cells:[Math.min(...x),Math.min(...P),Math.max(...x),Math.max(...P)]})}let R=new Set([...M.map(w=>w.id),...$.map(w=>w.id)]),E=[];for(let w of t.routes){if(!e(w.id))continue;let T=Ut(w.raw.from).id,L=Ut(w.raw.to).id;if(!R.has(T)||!R.has(L))continue;let x=typeof w.raw.label=="string"?w.raw.label:w.raw.label?.text;E.push({id:w.id,a:T,b:L,kind:w.kind,label:x})}return{cards:M,panels:$,links:E}}var Wn={W:4,D:2,H:.9,GX:2,GY:2.4,PAD:.6,CH:2.2,PANEL_H:.3},Mc=`
279
279
  .blk .card-name{font-size:13px;font-weight:600;fill:var(--ink)}
280
280
  .blk .card-sub{font-size:10px;fill:var(--ink);opacity:.75}
281
281
  .blk.ghost .card-name,.blk.ghost .card-sub{fill:var(--muted)}
282
- `;function Sa(t){return{name:"card",description:"A card: a slab with its name on its front face",size:[Wn.W,Wn.D,Wn.H],role:"grey",draw(e,n,s){let r=t(s.id),o=e.blockFaces(n);if(!r)return o;let i=n.z1-n.z0;return o+=e.faceText(n.x0+.2,n.y1,n.z0+(r.sub?i*.52:i*.34),r.label,"card-name",at.lbl,"left","start"),r.sub&&(o+=e.faceText(n.x0+.2,n.y1,n.z0+i*.14,r.sub,"card-sub",at.sub,"left","start")),o}}}function Sc(t){let e=new Map(t.cards.map(n=>[n.id,{label:n.label,sub:n.sub}]));return{regions:{panel:{shape:"slab",pad:Wn.PAD,z:[Wn.PANEL_H,0],floor:!0,role:"grey",labelStyle:"floor"}},nodes:{card:Sa(n=>e.get(n))},defaultNode:"card"}}function Mc(t,e={}){let n=Wn,{prect:s,parentIx:r,cardAt:o}=gr(t,{W:n.W,H:n.D,GX:n.GX,GY:n.GY,PAD:n.PAD,TITLE:0,CH:n.CH}),i=t.panels??[],a=h=>Math.round(h*1e3)/1e3,l=h=>(h.cells[2]-h.cells[0]+1)*(h.cells[3]-h.cells[1]+1),c=h=>{let m=-1;return i.forEach((y,I)=>{let N=y.cells;h.cell[0]>=N[0]&&h.cell[0]<=N[2]&&h.cell[1]>=N[1]&&h.cell[1]<=N[3]&&(m<0||l(y)<=l(i[m]))&&(m=I)}),m},f=i.map((h,m)=>{let y=s[m],I=r[m]>=0?s[r[m]]:{l:0,t:0};return{id:h.id,kind:"panel",label:h.label,role:h.role,at:[a(y.l-I.l),a(y.t-I.t)],size:[a(y.r-y.l),a(y.b-y.t)],regions:[],nodes:[]}}),u=[],d=[];f.forEach((h,m)=>r[m]>=0?f[r[m]].regions.push(h):u.push(h));for(let h of t.cards){let[m,y]=o(t.cards.indexOf(h)),I=c(h),N=I>=0?s[I]:{l:0,t:0},M={id:h.id,asset:"card",role:h.role,ghost:h.ghost||void 0,at:[a(m-N.l),a(y-N.t)],size:[n.W,n.D,n.H]};(I>=0?f[I].nodes:d).push(M)}for(let h of f)h.regions.length||delete h.regions,h.nodes.length||delete h.nodes;let p=(t.links??[]).map((h,m)=>({id:h.id??`link-${m}`,from:h.aOn??h.a,to:h.bOn??h.b,kind:h.kind,label:h.label}));return{isodiag:1,title:e.title,kinds:e.kinds,roles:e.roles,scenes:[{id:"board",title:e.title??"board",regions:u,nodes:d,routes:p}]}}var mf={};hi(mf,{APPEARS:()=>Oc,BASE_FIELDS:()=>Fa,BINS:()=>zc,BIN_MS:()=>tn,CARD:()=>dt,DUAL_VIEW_CSS:()=>pf,IDLES:()=>Rc,MAX_ZOOM:()=>Tc,MIN_ZOOM:()=>Ec,P3:()=>ze,SEGMENT_NAME:()=>Qo,SEVERITIES:()=>jt,TIMELINE_VERSION:()=>Dc,activityOf:()=>Ka,attr:()=>mn,binNext:()=>ri,binStart:()=>cs,buildLayer:()=>vr,cardMotion:()=>Cc,clamp:()=>_n,cls:()=>Ic,crumbs:()=>Is,dualView:()=>ff,ease:()=>kr,escapeName:()=>ti,extent:()=>Jo,findGaps:()=>oi,fitWithOverlay:()=>Fc,flatCss:()=>rf,flatSvg:()=>ui,formatScope:()=>jc,gapKey:()=>us,gapLabel:()=>fs,h:()=>Q,hasSegment:()=>Gc,highlights:()=>xr,isZone:()=>Yc,isoVars:()=>Bc,join:()=>Kc,kindOf:()=>Cs,legend:()=>Ia,levelOf:()=>Nt,markConnectors:()=>mi,md:()=>Tn,measureIn:()=>di,memorySource:()=>Qc,modeFor:()=>ja,morphSvgs:()=>cf,mountTimeline:()=>nf,n:()=>Ta,nameOf:()=>Ls,node:()=>Lc,offsetAt:()=>Ct,overlayPaint:()=>Nc,parentOf:()=>Vc,prefixAt:()=>Bn,prune:()=>Na,pts:()=>br,rangeOf:()=>yr,readTime:()=>Ba,rectOf:()=>of,renderPage:()=>_c,rewrite:()=>Aa,scope:()=>Oa,scopePattern:()=>Zo,scopeRules:()=>ei,scopeSelector:()=>Pa,searchFor:()=>Fs,severities:()=>Uc,stepData:()=>La,storedMode:()=>uf,ticks:()=>ii,timeScale:()=>Bs,toCSV:()=>li,toJSON:()=>ai,unite:()=>Xo,viewToggle:()=>df,viewport:()=>Ac,within:()=>Kt});var Ec=.1,Tc=8;function Ac(t,e){let n,s,r=!1,o=0,i=0,a=0,l=0,c=0,f=!1,u=()=>{let x=t.getBoundingClientRect();return{w:Math.max(1,x.width),h:Math.max(1,x.height)}},d=(x=n)=>{let T=u();return Math.min(T.w/x.w,T.h/x.h)},p=x=>{o++;try{x()}finally{o--}};function h(){let x=e.svg();if(!x||!n)return;o||(r=!0);let T=u(),L=d(),w=T.w/L,P=T.h/L;n={x:n.x+(n.w-w)/2,y:n.y+(n.h-P)/2,w,h:P},x.setAttribute("viewBox",`${n.x.toFixed(2)} ${n.y.toFixed(2)} ${n.w.toFixed(2)} ${n.h.toFixed(2)}`),i=L,e.onApply(L),a&&Math.abs(L/a-1)>.02&&(cancelAnimationFrame(l),l=requestAnimationFrame(()=>{l=0,e.onRezoom()}))}let m=(x,T)=>{let L=t.getBoundingClientRect(),w=d();return{x:n.x+(x-L.left)/w,y:n.y+(T-L.top)/w}};function y(x,T,L){if(!n)return;let w=d(),P=Math.min(8,Math.max(.1,w*x)),b=t.getBoundingClientRect(),v=T??b.left+b.width/2,g=L??b.top+b.height/2,R=m(v,g),F=u();n={x:R.x-(v-b.left)/P,y:R.y-(g-b.top)/P,w:F.w/P,h:F.h/P},h()}function I(x=s){if(!x)return;let T=u(),L=24,w=Math.min(8,Math.max(.1,Math.min((T.w-L*2)/x.w,(T.h-L*2)/x.h))),P=x.x+x.w/2,b=x.y+x.h/2,v={x:P-T.w/w/2,y:b-T.h/w/2,w:T.w/w,h:T.h/w};if(n&&Math.abs(v.w/n.w-1)<.001&&Math.abs(v.h/n.h-1)<.001&&Math.abs(v.x-n.x)<v.w*.001&&Math.abs(v.y-n.y)<v.h*.001){h();return}n=v,h()}function N(){for(let x=0,T="";x<4;x++){let L=e.itemsBox()??s;if(!L)return;let w=[L.x,L.y,L.w,L.h].map(b=>Math.round(b)).join();if(w===T)break;T=w;let P=Math.max(24,Math.min(L.w,L.h)*.06);if(p(()=>I({x:L.x-P,y:L.y-P,w:L.w+P*2,h:L.h+P*2})),!e.marksShowing()||!a||Math.abs(d()/a-1)<=.02)break;cancelAnimationFrame(l),l=0,e.onRezoom()}r=!1}function M(){if(r||!e.svg()||!n)return;let x=t.getBoundingClientRect();x.width<2||x.height<2||N()}function $(){if(!n)return;let x=d();y(1/x)}function O(){return new Promise(x=>{let T=0,L=i,w=()=>{if(f){x();return}let P=!!(l||c)||i!==L;L=i,T=P?0:T+1,T>=2?x():requestAnimationFrame(w)};requestAnimationFrame(w)})}let E=new ResizeObserver(()=>{if(!(!n||f)){if(r&&i){let x=u(),T=n.x+n.w/2,L=n.y+n.h/2;n={x:T-x.w/i/2,y:L-x.h/i/2,w:x.w/i,h:x.h/i}}r||(cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=0,f||M()})),p(h)}});return E.observe(t),{get view(){return n},set view(x){n=x},get full(){return s},set full(x){s=x},get moved(){return r},get zoom(){return i},painted(x){a=x},size:u,scale:d,quietly:p,applyView:h,toSvg:m,zoomAt:y,fit:I,fitItems:N,autoFit:M,actual:$,settled:O,dispose(){cancelAnimationFrame(c),cancelAnimationFrame(l),E.disconnect(),f=!0}}}var mt="http://www.w3.org/2000/svg",dt={half:2.4,h:3.2,t:.25,above:1.4,lift:3.8,fan:.32,gap:.3},ze=(t,e,n)=>[(t-e)*yt*Xe,(t+e)*.5*Xe-n*Xe],br=t=>t.map(([e,n])=>`${e.toFixed(1)},${n.toFixed(1)}`).join(" ");function Nc(t,e){function n(o,i,a){let l=t.k(),c=(u,d,p,h,m="")=>{let y=o.createElementNS(mt,"g");y.setAttribute("class",`live-badge ${p.cls} ${m}`.trim());let I=8/l,N=o.createElementNS(mt,"circle");if(N.setAttribute("cx",String(u)),N.setAttribute("cy",String(d)),N.setAttribute("r",String(I)),y.append(N),"g"in p){let $=o.createElementNS(mt,"text");$.setAttribute("x",String(u)),$.setAttribute("y",String(d)),$.style.fontSize=`${(10/l).toFixed(2)}px`,$.textContent=p.g,y.append($)}else{let $=o.createElementNS(mt,"use");$.setAttribute("href",t.iconHref(p.icon));let O=11/l;$.setAttribute("x",String(u-O/2)),$.setAttribute("y",String(d-O/2)),$.setAttribute("width",String(O)),$.setAttribute("height",String(O)),y.append($)}let M=o.createElementNS(mt,"title");M.textContent=h,y.append(M),i(y)},f=(u,d)=>{for(let p of t.outlinesFor(u)){if(p.kind!=="poly")continue;let h=o.createElementNS(mt,"polygon");h.setAttribute("class",d),h.setAttribute("points",p.points.map(([m,y])=>`${m.toFixed(1)},${y.toFixed(1)}`).join(" ")),i(h)}};for(let u of a){let d=t.boxOf(u.at);if(d){if(u.outline&&f(u.at,u.outline),u.badge)c(d.x,d.y,u.badge,u.title);else if(u.hit){let p=o.createElementNS(mt,"title");p.textContent=u.title;let h=o.createElementNS(mt,"rect");h.setAttribute("class","live-hit"),h.setAttribute("x",String(d.x)),h.setAttribute("y",String(d.y)),h.setAttribute("width",String(d.w)),h.setAttribute("height",String(d.h)),h.append(p),i(h)}if((u.beside??[]).forEach((p,h)=>c(d.x+18*(h+1)/l,d.y,p.glyph,p.title)),u.dot&&c(d.x,d.y+d.h,u.dot.glyph,u.dot.title),u.tag){let p=o.createElementNS(mt,"text");p.setAttribute("class",`live-life ${u.tag.cls}`),p.setAttribute("x",String(d.x+d.w)),p.setAttribute("y",String(d.y+d.h)),p.style.fontSize=`${(9/l).toFixed(2)}px`,p.textContent=u.tag.text,i(p)}}}}function s(o,i,a){for(let l of a){let c=o.createElementNS(mt,"g");c.setAttribute("class",`live-extra${l.cls}`);for(let[M,$]of l.data)c.setAttribute(M,$);let{x:f,y:u,w:d,hgt:p,k:h}=l.rect,m=o.createElementNS(mt,"rect");m.setAttribute("x",String(f)),m.setAttribute("y",String(u)),m.setAttribute("width",String(d)),m.setAttribute("height",String(p)),m.setAttribute("rx",String(6/h));let y=o.createElementNS(mt,"text");y.setAttribute("x",String(f+8/h)),y.setAttribute("y",String(u+13/h)),y.style.fontSize=`${(11/h).toFixed(2)}px`,y.textContent=l.line1;let I=o.createElementNS(mt,"text");I.setAttribute("class","sub"),I.setAttribute("x",String(f+8/h)),I.setAttribute("y",String(u+27/h)),I.style.fontSize=`${(9/h).toFixed(2)}px`,I.textContent=l.line2;let N=o.createElementNS(mt,"title");N.textContent=l.title,c.append(m,y,I,N),i(c)}}function r(o,i,a){let l=[];for(let c of a){let f=c.over,u=(f.x0+f.x1)/2,d=(f.y0+f.y1)/2,p=0,h={x0:0,y0:0,x1:0,y1:0};for(let B=0;B<6;B++){let V=f.z1+dt.above+p,q=V+dt.h,Z=[ze(u-dt.half,d+dt.t,V),ze(u+dt.half,d+dt.t,V),ze(u+dt.half,d-dt.t,q),ze(u-dt.half,d+dt.t,q)];if(h={x0:Math.min(...Z.map(A=>A[0])),y0:Math.min(...Z.map(A=>A[1])),x1:Math.max(...Z.map(A=>A[0])),y1:Math.max(...Z.map(A=>A[1]))},!Yo(h,l))break;p+=dt.lift}l.push(h);let m=f.z1+dt.above+p,y=m+dt.h,I=u-dt.half,N=u+dt.half,M=d+dt.t,$=d-dt.t,O=o.createElementNS(mt,"g");O.setAttribute("class",`${e}-card${c.cls}`);for(let[B,V]of c.data)O.setAttribute(B,V);let[E,x]=ze(u,d,f.z1+.15),T=`${E.toFixed(1)}px ${x.toFixed(1)}px`;O.style.transformOrigin=T;let L=o.createElementNS(mt,"g");L.setAttribute("class",`${e}-float`),L.style.transformOrigin=T;let w=[];for(let B=Math.min(c.count-1,3);B>=1;B--){let V=B*dt.fan,q=$-(B-1)*(2*dt.t+dt.gap)-dt.gap,Z=q-2*dt.t,A=I+V,D=N+V,K=m+V,W=y+V,ie=(de,X)=>{let te=o.createElementNS(mt,"polygon");te.setAttribute("class",`${e}-face stacked ${de}`),te.setAttribute("points",br(X)),L.append(te)};ie("s-top",[ze(A,Z,W),ze(D,Z,W),ze(D,q,W),ze(A,q,W)]),ie("s-side",[ze(D,Z,K),ze(D,q,K),ze(D,q,W),ze(D,Z,W)]),ie("s-front",[ze(A,q,K),ze(D,q,K),ze(D,q,W),ze(A,q,W)]),w.push({x0:A,x1:D,y0:Z,y1:q,z0:K,z1:W})}let P=o.createElementNS(mt,"polygon");P.setAttribute("class",`${e}-tail`),P.setAttribute("points",br([ze(u-.5,M,m+.05),ze(u+.5,M,m+.05),ze(u,d,f.z1+.15)]));let b=(B,V)=>{let q=o.createElementNS(mt,"polygon");return q.setAttribute("class",B),q.setAttribute("points",br(V)),q},v=b(`${e}-face front`,[ze(I,M,m),ze(N,M,m),ze(N,M,y),ze(I,M,y)]);L.append(P,b(`${e}-face top`,[ze(I,$,y),ze(N,$,y),ze(N,M,y),ze(I,M,y)]),b(`${e}-face side`,[ze(N,$,m),ze(N,M,m),ze(N,M,y),ze(N,$,y)]),v);let[g,R]=ze(I,M,y),F=40,j=o.createElementNS(mt,"g");j.setAttribute("transform",`matrix(${(yt*Xe/F).toFixed(4)} ${(.5*Xe/F).toFixed(4)} 0 ${(Xe/F).toFixed(4)} ${g.toFixed(1)} ${R.toFixed(1)})`);let U=(B,V,q,Z)=>{let A=o.createElementNS(mt,"text");return A.setAttribute("class",B),A.setAttribute("x",String(V)),A.setAttribute("y",String(q)),A.textContent=Z,A};if(j.append(U(`${e}-mark`,34,98,c.mark),U(`${e}-who`,70,52,c.who),U(`${e}-age`,70,82,c.age)),c.line!==void 0&&j.append(U(`${e}-q`,12,118,c.line)),c.count>1){let B=o.createElementNS(mt,"circle");B.setAttribute("class",`${e}-count-bg`),B.setAttribute("cx","178"),B.setAttribute("cy","14"),B.setAttribute("r","15"),j.append(B,U(`${e}-count`,178,14,String(c.count)))}L.append(j);let ne=o.createElementNS(mt,"title");ne.textContent=c.title,O.append(L,ne),t.onCard?.(O,{cx:u,cy:d,tipZ:f.z1+.15,card:{x0:I,x1:N,y0:$,y1:M,z0:m,z1:y},panes:w.reverse()}),i(O)}}return{paintMarks:n,paintGhosts:s,paintCards:r}}var Oc=[["scale","Scale"],["spin","Spin"],["dissolve","Dissolve"],["inflate","Inflate"]],Rc=[["none","None"],["jiggle","Jiggle"],["pirouette","Pirouette"],["glow","Glow"],["breathe","Breathe"]];function Pu(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0)%1e3/1e3}var Ma=t=>t<0?0:t>1?1:1-Math.pow(1-t,3),Pc=t=>t<0?0:t>1?1:t*t*t,$a=Math.PI*2,Ea={appear:{scale:420,spin:760,dissolve:520,inflate:640},disappear:{scale:320,spin:600,dissolve:420,inflate:420},period:{jiggle:4200,pirouette:6400,glow:3200,breathe:4400}},en={windup:220,turn:980,land:260};function Cc(t,e,{prefix:n,key:s,alt:r}){let o={...e},i=1,a=new Map,l=new WeakSet,c=0,f=0,u=new WeakMap,d=new WeakMap;function p(P){c=0;for(let[b,v]of a){if(!b.isConnected){a.delete(b);continue}let g;if(v.repeat){if(g=(P+(v.offset??0))%v.repeat/v.dur,g>1){l.has(b)&&(t.restore(b),l.delete(b),b.style.removeProperty("transform"));continue}}else if(g=(P-v.start)/v.dur,g>=1){h(b,v);continue}let R=v.frame(Math.max(0,g));t.spin(b,R.theta,R.lift),l.add(b),d.set(b,R),R.scale!==1?b.style.transform=`scale(${R.scale.toFixed(4)})`:b.style.removeProperty("transform"),f++}a.size&&(c=requestAnimationFrame(p))}function h(P,b){a.delete(P),l.has(P)&&(t.restore(P),l.delete(P)),P.style.removeProperty("transform"),b.done?.()}function m(P){let b=a.get(P.card);b&&h(P.card,b),a.set(P.card,P),c||(c=requestAnimationFrame(p))}let y=8,I=0,N=P=>(I++,P.finally(()=>{I--}));function M(P){return!o.enabled||I>=y?Promise.resolve():N(O(P))}function $(P){return!o.enabled||I>=y?Promise.resolve():N(E(P))}function O(P){let b=Ea.appear[o.appear]/i;if(o.appear==="spin")return new Promise(R=>m({card:P,start:performance.now(),dur:b,frame:F=>({theta:(1-Ma(F))*$a,lift:0,scale:Math.max(.001,Ma(F))}),done:R}));let v=o.appear==="scale"?[{transform:"scale(0)"},{transform:"scale(1)"}]:o.appear==="dissolve"?[{opacity:0,filter:"blur(4px)"},{opacity:1,filter:"blur(0px)"}]:[{transform:"scale(0)",easing:"cubic-bezier(.3,0,.4,1)"},{transform:"scale(1.16)",offset:.55,easing:"ease-in-out"},{transform:"scale(.95)",offset:.78,easing:"ease-in-out"},{transform:"scale(1)"}];return P.animate(v,{duration:b,easing:o.appear==="inflate"?"linear":"ease-out"}).finished.then(()=>{},()=>{})}function E(P){let b=Ea.disappear[o.appear]/i;if(o.appear==="spin")return new Promise(R=>m({card:P,start:performance.now(),dur:b,frame:F=>({theta:Pc(F)*$a,lift:0,scale:Math.max(.001,1-Pc(F))}),done:()=>{P.style.transform="scale(0)",R()}}));let v=o.appear==="scale"?[{transform:"scale(1)"},{transform:"scale(0)"}]:o.appear==="dissolve"?[{opacity:1,filter:"blur(0px)"},{opacity:0,filter:"blur(4px)"}]:[{transform:"scale(1)"},{transform:"scale(1.08)",offset:.3},{transform:"scale(0)"}];return P.animate(v,{duration:b,easing:"ease-in",fill:"forwards"}).finished.then(()=>{},()=>{})}function x(P){u.get(P)?.cancel(),u.delete(P);let b=a.get(P);b?.repeat&&h(P,b)}function T(P,b){if(x(P),!o.enabled||o.idle==="none"||P.classList.contains("still"))return;let v=P.getAttribute(s)??P.getAttribute(r)??"",g=(b??Ea.period[o.idle])/i,R=Pu(v)*g;if(o.idle==="pirouette"){let B=(en.windup+en.turn+en.land)/i,V=en.windup/(en.windup+en.turn+en.land),q=(en.windup+en.turn)/(en.windup+en.turn+en.land);m({card:P,start:0,dur:B,repeat:g,offset:R,frame:Z=>{if(Z<V)return{theta:-.35*Math.sin(Z/V*Math.PI/2),lift:0,scale:1};if(Z<q){let D=(Z-V)/(q-V);return{theta:-.35*(1-D)+Ma(D)*$a,lift:.9*Math.sin(D*Math.PI),scale:1}}let A=(Z-q)/(1-q);return{theta:0,lift:0,scale:1-.04*Math.sin(A*Math.PI)}}});return}let F=P.querySelector(`.${n}-float`)??P,j=t.amber(),U=o.idle==="jiggle"?[{transform:"scale(1)",offset:0},{transform:"scale(1.07)",offset:.04},{transform:"scale(.97)",offset:.08},{transform:"scale(1.02)",offset:.11},{transform:"scale(1)",offset:.14},{transform:"scale(1)",offset:1}]:o.idle==="glow"?[{filter:`drop-shadow(0 0 0px ${j})`},{filter:`drop-shadow(0 0 7px ${j})`},{filter:`drop-shadow(0 0 0px ${j})`}]:[{transform:"scale(1)"},{transform:"scale(1.035)"},{transform:"scale(1)"}],ne=F.animate(U,{duration:g,iterations:1/0,easing:o.idle==="jiggle"?"linear":"ease-in-out"});ne.startTime=(document.timeline.currentTime??0)-((document.timeline.currentTime??0)+R)%g,u.set(P,ne)}function L(P,b,v,g,R=!1){R&&(g=!1);for(let[j,U]of b)!P.has(j)&&!R&&M(U),!u.has(U)&&!a.get(U)?.repeat&&T(U);if(!o.enabled||!g)return;let F=t.leavingLayer();if(F)for(let[j,U]of v){let ne=P.get(j);!ne||b.has(j)||(x(ne),ne.setAttribute("class",`${n}-leaving${U?" expired":""}`),ne.removeAttribute(r),F.append(ne),$(ne).then(()=>ne.remove()))}}function w(P){for(let[b,v]of[...a])h(b,v);c&&cancelAnimationFrame(c),c=0;for(let b of document.getAnimations())b.effect?.target?.closest?.(`.live-layer, .${n}-leaving-layer`)&&b.cancel();t.leavingLayer()?.replaceChildren()}return{get settings(){return{...o}},set(P,b){let v=o;if(o={...o,...P},(!o.enabled||v.idle!==o.idle||v.enabled!==o.enabled)&&(w(void 0),o.enabled))for(let g of b)T(g)},update:L,appear:M,disappear:$,startIdle:T,stopIdle:x,stopAll:w,async preview(P){o.enabled&&await Promise.all(P.map(async b=>{if(x(b),await M(b),o.idle!=="none"&&!b.classList.contains("still")){let v=o.idle==="pirouette"?1800:1400;T(b,v),await new Promise(g=>setTimeout(g,v*2.2/i)),x(b)}else await new Promise(v=>setTimeout(v,700/i));await $(b);for(let v of b.getAnimations())v.cancel();b.style.removeProperty("transform"),T(b)}))},get stats(){return{jobs:a.size,raf:!!c,frames:f,effects:I}},setSpeed(P){i=P},lastFrame:P=>d.get(P)}}var Ta=t=>String(Math.round(t*100)/100),Lc=(t,e={},...n)=>({name:t,attrs:Object.entries(e).map(([s,r])=>[s,typeof r=="number"?Ta(r):r]),children:n});function Aa(t,e){if(typeof t=="string")return t;let n=t.attrs.map(([s,r])=>{if(s==="id")return[s,e+r];let o=r.replace(/var\(--([a-zA-Z][\w-]*)/g,"var(--iso-$1").replace(/url\(\s*(['"]?)#/g,(i,a)=>`url(${a}#${e}`);return(s==="href"||s==="xlink:href")&&o.startsWith("#")&&!o.startsWith(`#${e}`)&&(o=`#${e}${o.slice(1)}`),[s,o]});return{name:t.name,attrs:n,children:t.children.map(s=>Aa(s,e))}}function Na(t,e){if(typeof t=="string")return t;if(!e(t))return{...t,children:t.children.map(n=>Na(n,e)).filter(n=>n!==void 0)}}var Ic=t=>(t.attrs.find(e=>e[0]==="class")?.[1]??"").split(/\s+/),mn=(t,e)=>t.attrs.find(n=>n[0]===e)?.[1];function Jo(t){let e=[],n=[],s=i=>{if(typeof i=="string")return;let a=mn(i,"transform");if(a&&/matrix/.test(a))return;let l=mn(i,"points");if(l)for(let c of l.trim().split(/\s+/)){let[f,u]=c.split(",").map(Number);Number.isFinite(f)&&Number.isFinite(u)&&(e.push(f),n.push(u))}if(i.name==="rect"){let c=Number(mn(i,"x")),f=Number(mn(i,"y")),u=Number(mn(i,"width")),d=Number(mn(i,"height"));[c,f,u,d].every(Number.isFinite)&&(e.push(c,c+u),n.push(f,f+d))}if(i.name==="circle"){let c=Number(mn(i,"cx")),f=Number(mn(i,"cy")),u=Number(mn(i,"r"));[c,f,u].every(Number.isFinite)&&(e.push(c-u,c+u),n.push(f-u,f+u))}i.children.forEach(s)};if(t.forEach(s),!e.length)return;let r=Math.min(...e),o=Math.min(...n);return{x:r,y:o,w:Math.max(...e)-r,h:Math.max(...n)-o}}var Xo=(t,e)=>{if(!e)return t;let n=Math.min(t.x,e.x),s=Math.min(t.y,e.y);return{x:n,y:s,w:Math.max(t.x+t.w,e.x+e.w)-n,h:Math.max(t.y+t.h,e.y+e.h)-s}};function Fc(t,e,n){let s=a=>Math.min((e.width-e.pad*2)/a.w,(e.height-e.pad*2)/a.h),r=s(t),o=n(r),i=Xo(t,Jo(o));return r=s(i),o=n(r),i=Xo(t,Jo(o)),r=s(i),{k:r,box:i,live:o}}var Bc=t=>t.replace(/--([a-zA-Z][\w-]*)/g,"--iso-$1");function Ou(t){let e=[],n=0,s=t.replace(/\/\*[\s\S]*?\*\//g,"");for(;n<s.length;){let r=s.indexOf("{",n);if(r<0)break;let o=1,i=r+1;for(;i<s.length&&o;)s[i]==="{"?o++:s[i]==="}"&&o--,i++;e.push([s.slice(n,r).trim(),s.slice(r+1,i-1)]),n=i}return e}function Ru(t){let e=[],n=0,s=0;for(let r=0;r<t.length;r++){let o=t[r];o==="("||o==="["?n++:o===")"||o==="]"?n--:o===","&&!n&&(e.push(t.slice(s,r).trim()),s=r+1)}return e.push(t.slice(s).trim()),e.filter(Boolean)}function Pa(t,e,n){let s=/^:root((?:\[[^\]]*\]|:not\([^)]*\))*)(.*)$/.exec(t),r=n.replace(/^\./,"");if(s){let o=s[1],i=s[2].trim();return`${o?`.${r}${o} `:""}${e}${i?" "+i:""}`}if(/^(html|body|\*)\b/.test(t)||/^[a-z]+$/.test(t)&&!/^(svg|g|text|path|polygon|rect|circle|line)$/.test(t))throw new Error(`the canvas's CSS can't style the page: "${t}"`);return`${e} ${t}`}function Oa(t,e,n){let s="";for(let[r,o]of Ou(t)){if(r.startsWith("@keyframes")){s+=`@keyframes iso-${r.slice(10).trim()}{${o}}
283
- `;continue}if(r.startsWith("@media")||r.startsWith("@supports")){s+=`${r}{${Oa(o,e,n)}}
284
- `;continue}if(r.startsWith("@"))throw new Error(`the canvas's CSS has an at-rule it can't scope: ${r}`);s+=`${Ru(r).map(i=>Pa(i,e,n)).join(",")}{${o.replace(/\banimation:\s*([a-z][\w-]*)/g,"animation:iso-$1")}}
285
- `}return s}var Ra=["<","script"].join("");function Tn(t){return t?ut(t).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<b>$1</b>").replace(/(^|[^*])\*([^*\s][^*]*)\*/g,"$1<em>$2</em>").replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(e,n,s)=>/^(https?:|#|\.{0,2}\/)/.test(s.replace(/&amp;/g,"&"))?`<a href="${s}">${n}</a>`:n):""}var Ca=t=>(t??"").split(/\n\s*\n/).filter(Boolean).map(e=>`<p class="sec-sub">${Tn(e.trim())}</p>`).join("");function La(t){return JSON.stringify({scenes:t.scenes.map(e=>({id:e.id,loop:e.raw.loop??!0,dim:e.raw.dim??"flows",vis:e.steps.vis,steps:e.steps.steps.map(n=>({...n,caption:Tn(n.caption)})),assemble:e.assemble,grid:!!e.grid.show,assembly:e.rendered.assembly}))})}function Ia(t,e){let n=t.theme,s=e.raw.legend;if(s===!1)return"";let r=Array.isArray(s)?s:e.steps.kindsUsed.filter(a=>e.routes.some(l=>l.kind===a)||e.steps.steps.some(l=>l.phases.some(c=>c.some(f=>f.kind===a)))),o=a=>`<span><i${a.box?' class="box"':""} style="${a.swatch}"></i>${a.label}</span>`,i=r.map(a=>{let l=pt(t.catalog,a)?.legend;if(l)return o(l);let c=n.kinds[a];return c?`<span><i style="${`border-color:${Mn(n,c.color)}${c.dash==="dashed"?";border-top-style:dashed":c.dash==="dotted"?";border-top-style:dotted":""}`}"></i>${Tn(c.legend)}</span>`:""});if(!Array.isArray(s)){let a=new Set(e.layout.items.map(l=>l.region?.kind));for(let[l,c]of Object.entries(t.catalog.regions))c.legend?.auto&&a.has(l)&&i.push(o(c.legend))}return i.join("")}function Cu(t){let e=t.steps.steps,n=`<div class="tools">
282
+ `;function $a(t){return{name:"card",description:"A card: a slab with its name on its front face",size:[Wn.W,Wn.D,Wn.H],role:"grey",draw(e,n,s){let r=t(s.id),o=e.blockFaces(n);if(!r)return o;let i=n.z1-n.z0;return o+=e.faceText(n.x0+.2,n.y1,n.z0+(r.sub?i*.52:i*.34),r.label,"card-name",at.lbl,"left","start"),r.sub&&(o+=e.faceText(n.x0+.2,n.y1,n.z0+i*.14,r.sub,"card-sub",at.sub,"left","start")),o}}}function $c(t){let e=new Map(t.cards.map(n=>[n.id,{label:n.label,sub:n.sub}]));return{regions:{panel:{shape:"slab",pad:Wn.PAD,z:[Wn.PANEL_H,0],floor:!0,role:"grey",labelStyle:"floor"}},nodes:{card:$a(n=>e.get(n))},defaultNode:"card"}}function Ec(t,e={}){let n=Wn,{prect:s,parentIx:r,cardAt:o}=gr(t,{W:n.W,H:n.D,GX:n.GX,GY:n.GY,PAD:n.PAD,TITLE:0,CH:n.CH}),i=t.panels??[],a=h=>Math.round(h*1e3)/1e3,l=h=>(h.cells[2]-h.cells[0]+1)*(h.cells[3]-h.cells[1]+1),c=h=>{let m=-1;return i.forEach((y,I)=>{let N=y.cells;h.cell[0]>=N[0]&&h.cell[0]<=N[2]&&h.cell[1]>=N[1]&&h.cell[1]<=N[3]&&(m<0||l(y)<=l(i[m]))&&(m=I)}),m},f=i.map((h,m)=>{let y=s[m],I=r[m]>=0?s[r[m]]:{l:0,t:0};return{id:h.id,kind:"panel",label:h.label,role:h.role,at:[a(y.l-I.l),a(y.t-I.t)],size:[a(y.r-y.l),a(y.b-y.t)],regions:[],nodes:[]}}),u=[],d=[];f.forEach((h,m)=>r[m]>=0?f[r[m]].regions.push(h):u.push(h));for(let h of t.cards){let[m,y]=o(t.cards.indexOf(h)),I=c(h),N=I>=0?s[I]:{l:0,t:0},M={id:h.id,asset:"card",role:h.role,ghost:h.ghost||void 0,at:[a(m-N.l),a(y-N.t)],size:[n.W,n.D,n.H]};(I>=0?f[I].nodes:d).push(M)}for(let h of f)h.regions.length||delete h.regions,h.nodes.length||delete h.nodes;let p=(t.links??[]).map((h,m)=>({id:h.id??`link-${m}`,from:h.aOn??h.a,to:h.bOn??h.b,kind:h.kind,label:h.label}));return{isodiag:1,title:e.title,kinds:e.kinds,roles:e.roles,scenes:[{id:"board",title:e.title??"board",regions:u,nodes:d,routes:p}]}}var mf={};bi(mf,{APPEARS:()=>Rc,BASE_FIELDS:()=>_a,BINS:()=>zc,BIN_MS:()=>tn,CARD:()=>dt,DUAL_VIEW_CSS:()=>pf,IDLES:()=>Oc,MAX_ZOOM:()=>Xo,MIN_ZOOM:()=>Jo,P3:()=>ze,SEGMENT_NAME:()=>ei,SEVERITIES:()=>jt,TIMELINE_VERSION:()=>Dc,activityOf:()=>Ga,attr:()=>mn,binNext:()=>ii,binStart:()=>cs,buildLayer:()=>vr,cardMotion:()=>Cc,clamp:()=>_n,cls:()=>Ic,crumbs:()=>Is,dualView:()=>ff,ease:()=>kr,escapeName:()=>si,extent:()=>Qo,findGaps:()=>ai,fitWithOverlay:()=>Fc,flatCss:()=>rf,flatSvg:()=>pi,formatScope:()=>jc,gapKey:()=>us,gapLabel:()=>fs,h:()=>Q,hasSegment:()=>Gc,highlights:()=>xr,isZone:()=>Yc,isoVars:()=>Bc,join:()=>Vc,kindOf:()=>Cs,legend:()=>Ba,levelOf:()=>Nt,markConnectors:()=>gi,md:()=>Tn,measureIn:()=>mi,memorySource:()=>Qc,modeFor:()=>Ka,morphSvgs:()=>cf,mountTimeline:()=>nf,n:()=>Na,nameOf:()=>Ls,node:()=>Lc,offsetAt:()=>Ct,overlayPaint:()=>Nc,parentOf:()=>Kc,prefixAt:()=>Bn,prune:()=>Ra,pts:()=>br,rangeOf:()=>yr,readTime:()=>Da,rectOf:()=>of,renderPage:()=>_c,rewrite:()=>Pa,scope:()=>Ca,scopePattern:()=>ti,scopeRules:()=>ni,scopeSelector:()=>Oa,searchFor:()=>Fs,severities:()=>Uc,stepData:()=>Fa,storedMode:()=>uf,ticks:()=>li,timeScale:()=>Bs,toCSV:()=>fi,toJSON:()=>ci,unite:()=>Zo,viewToggle:()=>df,viewport:()=>Ac,within:()=>Vt});function Pu(t,e,n){let r=(a,l,c,f,u)=>Math.min((a-48)/(c-l),...f===void 0||u===void 0?[]:[[u-f,12],[u-l,30],[c-f,30]].map(([d,p])=>d>0?(a-p)/d:1/0)),o=Math.min(Xo,Math.max(Jo,Math.min(r(t.w,e.x,e.x+e.w,n?.x,n&&n.x+n.w),r(t.h,e.y,e.y+e.h,n?.y,n&&n.y+n.h)))),i=(a,l,c,f,u)=>{let d=(l+c)/2;if(f===void 0||u===void 0)return d;let p=u-(a/2-6)/o,h=f+(a/2-6)/o;return p>h?(p+h)/2:Math.max(p,Math.min(h,d))};return{k:o,cx:i(t.w,e.x,e.x+e.w,n?.x,n&&n.x+n.w),cy:i(t.h,e.y,e.y+e.h,n?.y,n&&n.y+n.h)}}var Jo=.1,Xo=8;function Ac(t,e){let n,s,r=!1,o=0,i=0,a=0,l=0,c=0,f=!1,u=()=>{let w=t.getBoundingClientRect();return{w:Math.max(1,w.width),h:Math.max(1,w.height)}},d=(w=n)=>{let T=u();return Math.min(T.w/w.w,T.h/w.h)},p=w=>{o++;try{w()}finally{o--}};function h(){let w=e.svg();if(!w||!n)return;o||(r=!0);let T=u(),L=d(),x=T.w/L,P=T.h/L;n={x:n.x+(n.w-x)/2,y:n.y+(n.h-P)/2,w:x,h:P},w.setAttribute("viewBox",`${n.x.toFixed(2)} ${n.y.toFixed(2)} ${n.w.toFixed(2)} ${n.h.toFixed(2)}`),i=L,e.onApply(L),a&&Math.abs(L/a-1)>.02&&(cancelAnimationFrame(l),l=requestAnimationFrame(()=>{l=0,e.onRezoom()}))}let m=(w,T)=>{let L=t.getBoundingClientRect(),x=d();return{x:n.x+(w-L.left)/x,y:n.y+(T-L.top)/x}};function y(w,T,L){if(!n)return;let x=d(),P=Math.min(Xo,Math.max(Jo,x*w)),b=t.getBoundingClientRect(),v=T??b.left+b.width/2,g=L??b.top+b.height/2,O=m(v,g),F=u();n={x:O.x-(v-b.left)/P,y:O.y-(g-b.top)/P,w:F.w/P,h:F.h/P},h()}function I(w=s,T){if(!w)return;let L=u(),{k:x,cx:P,cy:b}=Pu(L,w,T),v={x:P-L.w/x/2,y:b-L.h/x/2,w:L.w/x,h:L.h/x};if(n&&Math.abs(v.w/n.w-1)<.001&&Math.abs(v.h/n.h-1)<.001&&Math.abs(v.x-n.x)<v.w*.001&&Math.abs(v.y-n.y)<v.h*.001){h();return}n=v,h()}function N(){for(let w=0,T="";w<4;w++){let L=e.itemsBox()??s;if(!L)return;let x=[L.x,L.y,L.w,L.h].map(b=>Math.round(b)).join();if(x===T)break;T=x;let P=Math.max(24,Math.min(L.w,L.h)*.06);if(p(()=>I({x:L.x-P,y:L.y-P,w:L.w+P*2,h:L.h+P*2},e.alsoBox?.())),!e.marksShowing()||!a||Math.abs(d()/a-1)<=.02)break;cancelAnimationFrame(l),l=0,e.onRezoom()}r=!1}function M(){if(r||!e.svg()||!n)return;let w=t.getBoundingClientRect();w.width<2||w.height<2||N()}function $(){if(!n)return;let w=d();y(1/w)}function R(){return new Promise(w=>{let T=0,L=i,x=()=>{if(f){w();return}let P=!!(l||c)||i!==L;L=i,T=P?0:T+1,T>=2?w():requestAnimationFrame(x)};requestAnimationFrame(x)})}let E=new ResizeObserver(()=>{if(!(!n||f)){if(r&&i){let w=u(),T=n.x+n.w/2,L=n.y+n.h/2;n={x:T-w.w/i/2,y:L-w.h/i/2,w:w.w/i,h:w.h/i}}r||(cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=0,f||M()})),p(h)}});return E.observe(t),{get view(){return n},set view(w){n=w},get full(){return s},set full(w){s=w},get moved(){return r},get zoom(){return i},painted(w){a=w},size:u,scale:d,quietly:p,applyView:h,toSvg:m,zoomAt:y,fit:I,fitItems:N,autoFit:M,actual:$,settled:R,dispose(){cancelAnimationFrame(c),cancelAnimationFrame(l),E.disconnect(),f=!0}}}var mt="http://www.w3.org/2000/svg",dt={half:2.4,h:3.2,t:.25,above:1.4,lift:3.8,fan:.32,gap:.3},ze=(t,e,n)=>[(t-e)*yt*Xe,(t+e)*.5*Xe-n*Xe],br=t=>t.map(([e,n])=>`${e.toFixed(1)},${n.toFixed(1)}`).join(" ");function Nc(t,e){function n(o,i,a){let l=t.k(),c=(u,d,p,h,m="")=>{let y=o.createElementNS(mt,"g");y.setAttribute("class",`live-badge ${p.cls} ${m}`.trim());let I=8/l,N=o.createElementNS(mt,"circle");if(N.setAttribute("cx",String(u)),N.setAttribute("cy",String(d)),N.setAttribute("r",String(I)),y.append(N),"g"in p){let $=o.createElementNS(mt,"text");$.setAttribute("x",String(u)),$.setAttribute("y",String(d)),$.style.fontSize=`${(10/l).toFixed(2)}px`,$.textContent=p.g,y.append($)}else{let $=o.createElementNS(mt,"use");$.setAttribute("href",t.iconHref(p.icon));let R=11/l;$.setAttribute("x",String(u-R/2)),$.setAttribute("y",String(d-R/2)),$.setAttribute("width",String(R)),$.setAttribute("height",String(R)),y.append($)}let M=o.createElementNS(mt,"title");M.textContent=h,y.append(M),i(y)},f=(u,d)=>{for(let p of t.outlinesFor(u)){if(p.kind!=="poly")continue;let h=o.createElementNS(mt,"polygon");h.setAttribute("class",d),h.setAttribute("points",p.points.map(([m,y])=>`${m.toFixed(1)},${y.toFixed(1)}`).join(" ")),i(h)}};for(let u of a){let d=t.boxOf(u.at);if(d){if(u.outline&&f(u.at,u.outline),u.badge)c(d.x,d.y,u.badge,u.title);else if(u.hit){let p=o.createElementNS(mt,"title");p.textContent=u.title;let h=o.createElementNS(mt,"rect");h.setAttribute("class","live-hit"),h.setAttribute("x",String(d.x)),h.setAttribute("y",String(d.y)),h.setAttribute("width",String(d.w)),h.setAttribute("height",String(d.h)),h.append(p),i(h)}if((u.beside??[]).forEach((p,h)=>c(d.x+18*(h+1)/l,d.y,p.glyph,p.title)),u.dot&&c(d.x,d.y+d.h,u.dot.glyph,u.dot.title),u.tag){let p=o.createElementNS(mt,"text");p.setAttribute("class",`live-life ${u.tag.cls}`),p.setAttribute("x",String(d.x+d.w)),p.setAttribute("y",String(d.y+d.h)),p.style.fontSize=`${(9/l).toFixed(2)}px`,p.textContent=u.tag.text,i(p)}}}}function s(o,i,a){for(let l of a){let c=o.createElementNS(mt,"g");c.setAttribute("class",`live-extra${l.cls}`);for(let[M,$]of l.data)c.setAttribute(M,$);let{x:f,y:u,w:d,hgt:p,k:h}=l.rect,m=o.createElementNS(mt,"rect");m.setAttribute("x",String(f)),m.setAttribute("y",String(u)),m.setAttribute("width",String(d)),m.setAttribute("height",String(p)),m.setAttribute("rx",String(6/h));let y=o.createElementNS(mt,"text");y.setAttribute("x",String(f+8/h)),y.setAttribute("y",String(u+13/h)),y.style.fontSize=`${(11/h).toFixed(2)}px`,y.textContent=l.line1;let I=o.createElementNS(mt,"text");I.setAttribute("class","sub"),I.setAttribute("x",String(f+8/h)),I.setAttribute("y",String(u+27/h)),I.style.fontSize=`${(9/h).toFixed(2)}px`,I.textContent=l.line2;let N=o.createElementNS(mt,"title");N.textContent=l.title,c.append(m,y,I,N),i(c)}}function r(o,i,a){let l=[];for(let c of a){let f=c.over,u=(f.x0+f.x1)/2,d=(f.y0+f.y1)/2,p=0,h={x0:0,y0:0,x1:0,y1:0};for(let B=0;B<6;B++){let K=f.z1+dt.above+p,q=K+dt.h,Z=[ze(u-dt.half,d+dt.t,K),ze(u+dt.half,d+dt.t,K),ze(u+dt.half,d-dt.t,q),ze(u-dt.half,d+dt.t,q)];if(h={x0:Math.min(...Z.map(A=>A[0])),y0:Math.min(...Z.map(A=>A[1])),x1:Math.max(...Z.map(A=>A[0])),y1:Math.max(...Z.map(A=>A[1]))},!Yo(h,l))break;p+=dt.lift}l.push(h);let m=f.z1+dt.above+p,y=m+dt.h,I=u-dt.half,N=u+dt.half,M=d+dt.t,$=d-dt.t,R=o.createElementNS(mt,"g");R.setAttribute("class",`${e}-card${c.cls}`);for(let[B,K]of c.data)R.setAttribute(B,K);let[E,w]=ze(u,d,f.z1+.15),T=`${E.toFixed(1)}px ${w.toFixed(1)}px`;R.style.transformOrigin=T;let L=o.createElementNS(mt,"g");L.setAttribute("class",`${e}-float`),L.style.transformOrigin=T;let x=[];for(let B=Math.min(c.count-1,3);B>=1;B--){let K=B*dt.fan,q=$-(B-1)*(2*dt.t+dt.gap)-dt.gap,Z=q-2*dt.t,A=I+K,D=N+K,V=m+K,W=y+K,ie=(de,X)=>{let te=o.createElementNS(mt,"polygon");te.setAttribute("class",`${e}-face stacked ${de}`),te.setAttribute("points",br(X)),L.append(te)};ie("s-top",[ze(A,Z,W),ze(D,Z,W),ze(D,q,W),ze(A,q,W)]),ie("s-side",[ze(D,Z,V),ze(D,q,V),ze(D,q,W),ze(D,Z,W)]),ie("s-front",[ze(A,q,V),ze(D,q,V),ze(D,q,W),ze(A,q,W)]),x.push({x0:A,x1:D,y0:Z,y1:q,z0:V,z1:W})}let P=o.createElementNS(mt,"polygon");P.setAttribute("class",`${e}-tail`),P.setAttribute("points",br([ze(u-.5,M,m+.05),ze(u+.5,M,m+.05),ze(u,d,f.z1+.15)]));let b=(B,K)=>{let q=o.createElementNS(mt,"polygon");return q.setAttribute("class",B),q.setAttribute("points",br(K)),q},v=b(`${e}-face front`,[ze(I,M,m),ze(N,M,m),ze(N,M,y),ze(I,M,y)]);L.append(P,b(`${e}-face top`,[ze(I,$,y),ze(N,$,y),ze(N,M,y),ze(I,M,y)]),b(`${e}-face side`,[ze(N,$,m),ze(N,M,m),ze(N,M,y),ze(N,$,y)]),v);let[g,O]=ze(I,M,y),F=40,j=o.createElementNS(mt,"g");j.setAttribute("transform",`matrix(${(yt*Xe/F).toFixed(4)} ${(.5*Xe/F).toFixed(4)} 0 ${(Xe/F).toFixed(4)} ${g.toFixed(1)} ${O.toFixed(1)})`);let U=(B,K,q,Z)=>{let A=o.createElementNS(mt,"text");return A.setAttribute("class",B),A.setAttribute("x",String(K)),A.setAttribute("y",String(q)),A.textContent=Z,A};if(j.append(U(`${e}-mark`,34,98,c.mark),U(`${e}-who`,70,52,c.who),U(`${e}-age`,70,82,c.age)),c.line!==void 0&&j.append(U(`${e}-q`,12,118,c.line)),c.count>1){let B=o.createElementNS(mt,"circle");B.setAttribute("class",`${e}-count-bg`),B.setAttribute("cx","178"),B.setAttribute("cy","14"),B.setAttribute("r","15"),j.append(B,U(`${e}-count`,178,14,String(c.count)))}L.append(j);let ne=o.createElementNS(mt,"title");ne.textContent=c.title,R.append(L,ne),t.onCard?.(R,{cx:u,cy:d,tipZ:f.z1+.15,card:{x0:I,x1:N,y0:$,y1:M,z0:m,z1:y},panes:x.reverse()}),i(R)}}return{paintMarks:n,paintGhosts:s,paintCards:r}}var Rc=[["scale","Scale"],["spin","Spin"],["dissolve","Dissolve"],["inflate","Inflate"]],Oc=[["none","None"],["jiggle","Jiggle"],["pirouette","Pirouette"],["glow","Glow"],["breathe","Breathe"]];function Ru(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0)%1e3/1e3}var Ea=t=>t<0?0:t>1?1:1-Math.pow(1-t,3),Pc=t=>t<0?0:t>1?1:t*t*t,Ta=Math.PI*2,Aa={appear:{scale:420,spin:760,dissolve:520,inflate:640},disappear:{scale:320,spin:600,dissolve:420,inflate:420},period:{jiggle:4200,pirouette:6400,glow:3200,breathe:4400}},en={windup:220,turn:980,land:260};function Cc(t,e,{prefix:n,key:s,alt:r}){let o={...e},i=1,a=new Map,l=new WeakSet,c=0,f=0,u=new WeakMap,d=new WeakMap;function p(P){c=0;for(let[b,v]of a){if(!b.isConnected){a.delete(b);continue}let g;if(v.repeat){if(g=(P+(v.offset??0))%v.repeat/v.dur,g>1){l.has(b)&&(t.restore(b),l.delete(b),b.style.removeProperty("transform"));continue}}else if(g=(P-v.start)/v.dur,g>=1){h(b,v);continue}let O=v.frame(Math.max(0,g));t.spin(b,O.theta,O.lift),l.add(b),d.set(b,O),O.scale!==1?b.style.transform=`scale(${O.scale.toFixed(4)})`:b.style.removeProperty("transform"),f++}a.size&&(c=requestAnimationFrame(p))}function h(P,b){a.delete(P),l.has(P)&&(t.restore(P),l.delete(P)),P.style.removeProperty("transform"),b.done?.()}function m(P){let b=a.get(P.card);b&&h(P.card,b),a.set(P.card,P),c||(c=requestAnimationFrame(p))}let y=8,I=0,N=P=>(I++,P.finally(()=>{I--}));function M(P){return!o.enabled||I>=y?Promise.resolve():N(R(P))}function $(P){return!o.enabled||I>=y?Promise.resolve():N(E(P))}function R(P){let b=Aa.appear[o.appear]/i;if(o.appear==="spin")return new Promise(O=>m({card:P,start:performance.now(),dur:b,frame:F=>({theta:(1-Ea(F))*Ta,lift:0,scale:Math.max(.001,Ea(F))}),done:O}));let v=o.appear==="scale"?[{transform:"scale(0)"},{transform:"scale(1)"}]:o.appear==="dissolve"?[{opacity:0,filter:"blur(4px)"},{opacity:1,filter:"blur(0px)"}]:[{transform:"scale(0)",easing:"cubic-bezier(.3,0,.4,1)"},{transform:"scale(1.16)",offset:.55,easing:"ease-in-out"},{transform:"scale(.95)",offset:.78,easing:"ease-in-out"},{transform:"scale(1)"}];return P.animate(v,{duration:b,easing:o.appear==="inflate"?"linear":"ease-out"}).finished.then(()=>{},()=>{})}function E(P){let b=Aa.disappear[o.appear]/i;if(o.appear==="spin")return new Promise(O=>m({card:P,start:performance.now(),dur:b,frame:F=>({theta:Pc(F)*Ta,lift:0,scale:Math.max(.001,1-Pc(F))}),done:()=>{P.style.transform="scale(0)",O()}}));let v=o.appear==="scale"?[{transform:"scale(1)"},{transform:"scale(0)"}]:o.appear==="dissolve"?[{opacity:1,filter:"blur(0px)"},{opacity:0,filter:"blur(4px)"}]:[{transform:"scale(1)"},{transform:"scale(1.08)",offset:.3},{transform:"scale(0)"}];return P.animate(v,{duration:b,easing:"ease-in",fill:"forwards"}).finished.then(()=>{},()=>{})}function w(P){u.get(P)?.cancel(),u.delete(P);let b=a.get(P);b?.repeat&&h(P,b)}function T(P,b){if(w(P),!o.enabled||o.idle==="none"||P.classList.contains("still"))return;let v=P.getAttribute(s)??P.getAttribute(r)??"",g=(b??Aa.period[o.idle])/i,O=Ru(v)*g;if(o.idle==="pirouette"){let B=(en.windup+en.turn+en.land)/i,K=en.windup/(en.windup+en.turn+en.land),q=(en.windup+en.turn)/(en.windup+en.turn+en.land);m({card:P,start:0,dur:B,repeat:g,offset:O,frame:Z=>{if(Z<K)return{theta:-.35*Math.sin(Z/K*Math.PI/2),lift:0,scale:1};if(Z<q){let D=(Z-K)/(q-K);return{theta:-.35*(1-D)+Ea(D)*Ta,lift:.9*Math.sin(D*Math.PI),scale:1}}let A=(Z-q)/(1-q);return{theta:0,lift:0,scale:1-.04*Math.sin(A*Math.PI)}}});return}let F=P.querySelector(`.${n}-float`)??P,j=t.amber(),U=o.idle==="jiggle"?[{transform:"scale(1)",offset:0},{transform:"scale(1.07)",offset:.04},{transform:"scale(.97)",offset:.08},{transform:"scale(1.02)",offset:.11},{transform:"scale(1)",offset:.14},{transform:"scale(1)",offset:1}]:o.idle==="glow"?[{filter:`drop-shadow(0 0 0px ${j})`},{filter:`drop-shadow(0 0 7px ${j})`},{filter:`drop-shadow(0 0 0px ${j})`}]:[{transform:"scale(1)"},{transform:"scale(1.035)"},{transform:"scale(1)"}],ne=F.animate(U,{duration:g,iterations:1/0,easing:o.idle==="jiggle"?"linear":"ease-in-out"});ne.startTime=(document.timeline.currentTime??0)-((document.timeline.currentTime??0)+O)%g,u.set(P,ne)}function L(P,b,v,g,O=!1){O&&(g=!1);for(let[j,U]of b)!P.has(j)&&!O&&M(U),!u.has(U)&&!a.get(U)?.repeat&&T(U);if(!o.enabled||!g)return;let F=t.leavingLayer();if(F)for(let[j,U]of v){let ne=P.get(j);!ne||b.has(j)||(w(ne),ne.setAttribute("class",`${n}-leaving${U?" expired":""}`),ne.removeAttribute(r),F.append(ne),$(ne).then(()=>ne.remove()))}}function x(P){for(let[b,v]of[...a])h(b,v);c&&cancelAnimationFrame(c),c=0;for(let b of document.getAnimations())b.effect?.target?.closest?.(`.live-layer, .${n}-leaving-layer`)&&b.cancel();t.leavingLayer()?.replaceChildren()}return{get settings(){return{...o}},set(P,b){let v=o;if(o={...o,...P},(!o.enabled||v.idle!==o.idle||v.enabled!==o.enabled)&&(x(void 0),o.enabled))for(let g of b)T(g)},update:L,appear:M,disappear:$,startIdle:T,stopIdle:w,stopAll:x,async preview(P){o.enabled&&await Promise.all(P.map(async b=>{if(w(b),await M(b),o.idle!=="none"&&!b.classList.contains("still")){let v=o.idle==="pirouette"?1800:1400;T(b,v),await new Promise(g=>setTimeout(g,v*2.2/i)),w(b)}else await new Promise(v=>setTimeout(v,700/i));await $(b);for(let v of b.getAnimations())v.cancel();b.style.removeProperty("transform"),T(b)}))},get stats(){return{jobs:a.size,raf:!!c,frames:f,effects:I}},setSpeed(P){i=P},lastFrame:P=>d.get(P)}}var Na=t=>String(Math.round(t*100)/100),Lc=(t,e={},...n)=>({name:t,attrs:Object.entries(e).map(([s,r])=>[s,typeof r=="number"?Na(r):r]),children:n});function Pa(t,e){if(typeof t=="string")return t;let n=t.attrs.map(([s,r])=>{if(s==="id")return[s,e+r];let o=r.replace(/var\(--([a-zA-Z][\w-]*)/g,"var(--iso-$1").replace(/url\(\s*(['"]?)#/g,(i,a)=>`url(${a}#${e}`);return(s==="href"||s==="xlink:href")&&o.startsWith("#")&&!o.startsWith(`#${e}`)&&(o=`#${e}${o.slice(1)}`),[s,o]});return{name:t.name,attrs:n,children:t.children.map(s=>Pa(s,e))}}function Ra(t,e){if(typeof t=="string")return t;if(!e(t))return{...t,children:t.children.map(n=>Ra(n,e)).filter(n=>n!==void 0)}}var Ic=t=>(t.attrs.find(e=>e[0]==="class")?.[1]??"").split(/\s+/),mn=(t,e)=>t.attrs.find(n=>n[0]===e)?.[1];function Qo(t){let e=[],n=[],s=i=>{if(typeof i=="string")return;let a=mn(i,"transform");if(a&&/matrix/.test(a))return;let l=mn(i,"points");if(l)for(let c of l.trim().split(/\s+/)){let[f,u]=c.split(",").map(Number);Number.isFinite(f)&&Number.isFinite(u)&&(e.push(f),n.push(u))}if(i.name==="rect"){let c=Number(mn(i,"x")),f=Number(mn(i,"y")),u=Number(mn(i,"width")),d=Number(mn(i,"height"));[c,f,u,d].every(Number.isFinite)&&(e.push(c,c+u),n.push(f,f+d))}if(i.name==="circle"){let c=Number(mn(i,"cx")),f=Number(mn(i,"cy")),u=Number(mn(i,"r"));[c,f,u].every(Number.isFinite)&&(e.push(c-u,c+u),n.push(f-u,f+u))}i.children.forEach(s)};if(t.forEach(s),!e.length)return;let r=Math.min(...e),o=Math.min(...n);return{x:r,y:o,w:Math.max(...e)-r,h:Math.max(...n)-o}}var Zo=(t,e)=>{if(!e)return t;let n=Math.min(t.x,e.x),s=Math.min(t.y,e.y);return{x:n,y:s,w:Math.max(t.x+t.w,e.x+e.w)-n,h:Math.max(t.y+t.h,e.y+e.h)-s}};function Fc(t,e,n){let s=a=>Math.min((e.width-e.pad*2)/a.w,(e.height-e.pad*2)/a.h),r=s(t),o=n(r),i=Zo(t,Qo(o));return r=s(i),o=n(r),i=Zo(t,Qo(o)),r=s(i),{k:r,box:i,live:o}}var Bc=t=>t.replace(/--([a-zA-Z][\w-]*)/g,"--iso-$1");function Ou(t){let e=[],n=0,s=t.replace(/\/\*[\s\S]*?\*\//g,"");for(;n<s.length;){let r=s.indexOf("{",n);if(r<0)break;let o=1,i=r+1;for(;i<s.length&&o;)s[i]==="{"?o++:s[i]==="}"&&o--,i++;e.push([s.slice(n,r).trim(),s.slice(r+1,i-1)]),n=i}return e}function Cu(t){let e=[],n=0,s=0;for(let r=0;r<t.length;r++){let o=t[r];o==="("||o==="["?n++:o===")"||o==="]"?n--:o===","&&!n&&(e.push(t.slice(s,r).trim()),s=r+1)}return e.push(t.slice(s).trim()),e.filter(Boolean)}function Oa(t,e,n){let s=/^:root((?:\[[^\]]*\]|:not\([^)]*\))*)(.*)$/.exec(t),r=n.replace(/^\./,"");if(s){let o=s[1],i=s[2].trim();return`${o?`.${r}${o} `:""}${e}${i?" "+i:""}`}if(/^(html|body|\*)\b/.test(t)||/^[a-z]+$/.test(t)&&!/^(svg|g|text|path|polygon|rect|circle|line)$/.test(t))throw new Error(`the canvas's CSS can't style the page: "${t}"`);return`${e} ${t}`}function Ca(t,e,n){let s="";for(let[r,o]of Ou(t)){if(r.startsWith("@keyframes")){s+=`@keyframes iso-${r.slice(10).trim()}{${o}}
283
+ `;continue}if(r.startsWith("@media")||r.startsWith("@supports")){s+=`${r}{${Ca(o,e,n)}}
284
+ `;continue}if(r.startsWith("@"))throw new Error(`the canvas's CSS has an at-rule it can't scope: ${r}`);s+=`${Cu(r).map(i=>Oa(i,e,n)).join(",")}{${o.replace(/\banimation:\s*([a-z][\w-]*)/g,"animation:iso-$1")}}
285
+ `}return s}var La=["<","script"].join("");function Tn(t){return t?ut(t).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<b>$1</b>").replace(/(^|[^*])\*([^*\s][^*]*)\*/g,"$1<em>$2</em>").replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(e,n,s)=>/^(https?:|#|\.{0,2}\/)/.test(s.replace(/&amp;/g,"&"))?`<a href="${s}">${n}</a>`:n):""}var Ia=t=>(t??"").split(/\n\s*\n/).filter(Boolean).map(e=>`<p class="sec-sub">${Tn(e.trim())}</p>`).join("");function Fa(t){return JSON.stringify({scenes:t.scenes.map(e=>({id:e.id,loop:e.raw.loop??!0,dim:e.raw.dim??"flows",vis:e.steps.vis,steps:e.steps.steps.map(n=>({...n,caption:Tn(n.caption)})),assemble:e.assemble,grid:!!e.grid.show,assembly:e.rendered.assembly}))})}function Ba(t,e){let n=t.theme,s=e.raw.legend;if(s===!1)return"";let r=Array.isArray(s)?s:e.steps.kindsUsed.filter(a=>e.routes.some(l=>l.kind===a)||e.steps.steps.some(l=>l.phases.some(c=>c.some(f=>f.kind===a)))),o=a=>`<span><i${a.box?' class="box"':""} style="${a.swatch}"></i>${a.label}</span>`,i=r.map(a=>{let l=pt(t.catalog,a)?.legend;if(l)return o(l);let c=n.kinds[a];return c?`<span><i style="${`border-color:${Mn(n,c.color)}${c.dash==="dashed"?";border-top-style:dashed":c.dash==="dotted"?";border-top-style:dotted":""}`}"></i>${Tn(c.legend)}</span>`:""});if(!Array.isArray(s)){let a=new Set(e.layout.items.map(l=>l.region?.kind));for(let[l,c]of Object.entries(t.catalog.regions))c.legend?.auto&&a.has(l)&&i.push(o(c.legend))}return i.join("")}function Lu(t){let e=t.steps.steps,n=`<div class="tools">
286
286
  <button class="pbtn small" type="button" data-a="grid" aria-pressed="${t.grid.show?"true":"false"}" title="Show the floor grid">Grid</button>
287
287
  <button class="pbtn small" type="button" data-a="assemble" title="Draw the diagram again, piece by piece">Assemble</button>
288
288
  </div>`;if(!e.length)return`<div class="player">${n}</div>`;let s=e[0];return`<div class="player">
@@ -299,17 +299,17 @@ svg.pre-assemble > g:not(.g-anim){opacity:0}
299
299
  <div class="prog"><i></i></div>
300
300
  </div>
301
301
  <div class="dots"></div>
302
- </div>`}function Lu(t){let e=t.steps.steps;return e.length?`<details class="steps"><summary>All ${e.length} steps as text</summary><ol>${e.map(n=>`<li value="${n.num}"><b>${ut(n.heading)}.</b> ${Tn(n.caption)}${n.command?`<br><code>${ut(n.command)}</code>`:""}</li>`).join("")}</ol></details>`:""}function _c(t,e={}){let n=t.doc,s=n.title??n.scenes[0]?.title??"Diagram",r=(n.pills??[]).map(i=>`<span class="pill">${Tn(i)}</span>`).join(""),o=t.scenes.map(i=>`
302
+ </div>`}function Iu(t){let e=t.steps.steps;return e.length?`<details class="steps"><summary>All ${e.length} steps as text</summary><ol>${e.map(n=>`<li value="${n.num}"><b>${ut(n.heading)}.</b> ${Tn(n.caption)}${n.command?`<br><code>${ut(n.command)}</code>`:""}</li>`).join("")}</ol></details>`:""}function _c(t,e={}){let n=t.doc,s=n.title??n.scenes[0]?.title??"Diagram",r=(n.pills??[]).map(i=>`<span class="pill">${Tn(i)}</span>`).join(""),o=t.scenes.map(i=>`
303
303
  <section class="scene" id="scene-${ut(i.id)}">
304
304
  <h2>${ut(i.raw.title)}</h2>
305
- ${Ca(i.raw.caption)}
305
+ ${Ia(i.raw.caption)}
306
306
  <div class="figure" tabindex="-1">
307
307
  <div class="scroller">${i.grid.show?i.rendered.svg.replace("<svg ",'<svg class="show-grid" '):i.rendered.svg}</div>
308
- ${Cu(i)}
309
- <div class="legend">${Ia(t,i)}</div>
308
+ ${Lu(i)}
309
+ <div class="legend">${Ba(t,i)}</div>
310
310
  </div>
311
- ${Lu(i)}
312
- ${i.raw.after?`<div class="after">${Ca(i.raw.after)}</div>`:""}
311
+ ${Iu(i)}
312
+ ${i.raw.after?`<div class="after">${Ia(i.raw.after)}</div>`:""}
313
313
  </section>`).join(`
314
314
  `);return`<!doctype html>
315
315
  <html lang="en">
@@ -333,11 +333,11 @@ ${e.extraHead??""}
333
333
  <div class="pills">${r}<button class="theme" id="themeBtn" type="button">Theme</button></div>
334
334
  </header>
335
335
  ${o}
336
- ${n.after?Ca(n.after):""}
336
+ ${n.after?Ia(n.after):""}
337
337
  ${n.footer?`<footer>${Tn(n.footer)}</footer>`:""}
338
338
  </div>
339
- ${Ra} type="application/json" id="diagram-steps">${La(t).replace(/</g,"\\u003c")}<\/script>
340
- ${Ra}>
339
+ ${La} type="application/json" id="diagram-steps">${Fa(t).replace(/</g,"\\u003c")}<\/script>
340
+ ${La}>
341
341
  (function(){
342
342
  var root=document.documentElement, m=/theme=(light|dark)/.exec(location.hash);
343
343
  try{var t=localStorage.getItem('diagram-theme'); if(t) root.dataset.theme=t;}catch(e){}
@@ -349,14 +349,14 @@ ${Ra}>
349
349
  });
350
350
  })();
351
351
  <\/script>
352
- ${e.runtime?`${Ra}>${e.runtime}<\/script>`:""}
352
+ ${e.runtime?`${La}>${e.runtime}<\/script>`:""}
353
353
  ${e.extraBody??""}
354
354
  </body>
355
355
  </html>
356
- `}function Q(t,e=null,...n){let s=document.createElement(t);for(let[r,o]of Object.entries(e??{}))if(!(o==null||o===!1))if(r==="class")s.className=String(o);else if(r==="on")for(let[i,a]of Object.entries(o))s.addEventListener(i,a);else s.setAttribute(r,o===!0?"":String(o));for(let r of n)r!=null&&r!==!1&&s.append(r instanceof Node?r:document.createTextNode(String(r)));return s}var Dc=1,Qo="(?:[^/:%\\s]|%[0-9A-F]{2})+",jt=["debug","info","notice","warning","error"],zc=["1m","1h","1d"],tn={"1m":6e4,"1h":36e5,"1d":864e5},Zo=t=>`^(?:(?:${t.kinds.join("|")}):(?:${Qo})(?:/(?:${t.kinds.join("|")}):(?:${Qo}))*)?$`;function ei(t){let e=new RegExp(Zo(t)),n=o=>e.test(o);function s(o){if(!e.test(o))throw new Error(`not a scope path: ${JSON.stringify(o)}`);return o===""?[]:o.split("/").map(i=>{let a=i.indexOf(":");return{kind:i.slice(0,a),name:decodeURIComponent(i.slice(a+1))}})}function r(o){let i="";for(let a of s(o)){if(!t.parents[a.kind].includes(i))return!1;i=a.kind}return!0}return{isScope:n,parseScope:s,wellNested:r}}var ti=t=>t.replace(/[%/:\s]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`),jc=t=>t.map(e=>`${e.kind}:${ti(e.name)}`).join("/"),Kc=(t,e,n)=>(t?`${t}/`:"")+`${e}:${ti(n)}`,Nt=t=>t===""?0:t.split("/").length;function Bn(t,e){return e<=0?"":(t===""?[]:t.split("/")).slice(0,e).join("/")}var Vc=t=>Bn(t,Nt(t)-1),Kt=(t,e)=>e===""||t===e||t.startsWith(`${e}/`),Gc=(t,e)=>t!==""&&t.split("/").includes(e),Cs=t=>t===""?"fleet":t.slice(t.lastIndexOf("/")+1).split(":")[0],Ls=t=>t===""?"all hosts":decodeURIComponent(t.slice(t.lastIndexOf("/")+1).split(":").slice(1).join(":"));function Is(t){let e=[{scope:"",label:"all hosts",kind:"fleet"}];for(let n=1;n<=Nt(t);n++){let s=Bn(t,n);e.push({scope:s,label:Ls(s),kind:Cs(s)})}return e}var Fa=["kind","source","severity","scope","since","before"];function Iu(t){let e=[],n=0;for(;n<t.length;){for(;n<t.length&&/\s/.test(t[n]);)n++;if(n>=t.length)break;let s=!1;t[n]==="-"&&n+1<t.length&&!/\s/.test(t[n+1])&&(s=!0,n++);let r=/^(attr\.[a-z][a-z0-9_]*|[a-z]+):/.exec(t.slice(n)),o;r&&(o=r[1],n+=r[0].length);let i="",a=!1;if(t[n]==='"'){let l=t.indexOf('"',n+1);i=t.slice(n+1,l<0?t.length:l),a=!0,n=l<0?t.length:l+1}else{let l=n;for(;n<t.length&&!/\s/.test(t[n]);)n++;i=t.slice(l,n)}e.push({neg:s,raw:i,quoted:a,field:o})}return e}var Fu=/^(\d+)(s|m|h|d|w)$/,Bu={s:1e3,m:6e4,h:36e5,d:864e5,w:7*864e5};function Ba(t,e){let n=Fu.exec(t);if(n)return e-Number(n[1])*Bu[n[2]];let s=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?)?(Z|[+-]\d{2}:?\d{2})?$/.exec(t);if(!s)return;let[,r,o,i,a="0",l="0",c="0",f="0",u]=s;if(u){let p=Date.parse(t.replace(" ","T"));return Number.isNaN(p)?void 0:p}let d=new Date(+r,+o-1,+i,+a,+l,+c,+f.padEnd(3,"0")).getTime();return Number.isNaN(d)?void 0:d}function _u(t,e,n=Date.now()){let s=[],r=[];for(let o of Iu(e??"")){let i=c=>{let f=o.field?`${o.field}:${o.raw}`:o.raw;c&&r.push(`${JSON.stringify(f)}: ${c}; searched as text`),f&&s.push({neg:o.neg,value:f})};if(!o.field){i();continue}if(!(t.includes(o.field)||o.field.startsWith("attr."))){i(`no field ${o.field}`);continue}if(!o.raw){i(`${o.field}: needs a value`);continue}let l=o.field;if(l==="severity"){let c=/^(>=|<=|>|<|=)?(.*)$/.exec(o.raw);if(!jt.includes(c[2])){i(`no severity ${c[2]} (${jt.join(", ")})`);continue}s.push({neg:o.neg,field:l,op:c[1]??"=",value:c[2]})}else if(l==="since"||l==="before"){let c=Ba(o.raw,n);if(c===void 0){i(`can't read the time ${o.raw} (15m, 2h, 3d, 1w, or a date like 2026-11-20 or 2026-11-20T09:30)`);continue}if(o.neg){i(`-${l} isn't allowed (use ${l==="since"?"before":"since"})`);continue}s.push({neg:!1,field:l,value:o.raw,time:c})}else s.push({neg:o.neg,field:l,value:o.raw})}return{terms:s,warnings:r}}var ni=t=>jt.indexOf(t),Du={"=":"eq",">=":"ge",">":"gt","<=":"le","<":"lt"};function zu(t,e){switch(t.field){case void 0:return{field:"text",value:t.value};case"kind":case"source":return t.value.endsWith("*")?{field:t.field,value:t.value.slice(0,-1),prefix:!0}:{field:t.field,value:t.value};case"severity":return{field:"severity",op:Du[t.op??"="],value:t.value};case"scope":return{field:"scope",value:t.value,from:e.topKinds.some(n=>t.value.startsWith(`${n}:`))?"top":"segments"};case"since":case"before":return;default:return e.links.includes(t.field)?{field:"link",link:t.field,value:t.value}:{field:"attr",key:t.field.slice(5),value:t.value}}}function ju(t,e){let n=[],s=new Map;for(let r of e.terms){let o=zu(r,t);if(!o)continue;if(r.neg){n.push({not:!0,any:[o]});continue}if(o.field==="text"||o.field==="severity"){n.push({any:[o]});continue}let i=o.field==="link"?`link.${o.link}`:o.field==="attr"?`attr.${o.key}`:o.field,a=s.get(i);if(a)a.any.push(o);else{let l={any:[o]};s.set(i,l),n.push(l)}}return{all:n}}function Ku(t,e,n,s){switch(e.field){case"text":{let r=e.value.toLowerCase();if(n.summary.toLowerCase().includes(r)||n.kind.toLowerCase().includes(r)||n.source.toLowerCase().includes(r)||n.scope.toLowerCase().includes(r))return!0;for(let[o,i]of Object.entries(n.attrs))if(typeof i=="string"&&!s.has(`${n.source}.${o}`)&&i.toLowerCase().includes(r))return!0;return!1}case"kind":case"source":{let r=n[e.field];return e.prefix?r.startsWith(e.value):r===e.value}case"severity":{let r=ni(n.severity),o=ni(e.value);return e.op==="ge"?r>=o:e.op==="gt"?r>o:e.op==="le"?r<=o:e.op==="lt"?r<o:r===o}case"scope":return e.from==="top"?Kt(n.scope,e.value):`/${n.scope}/`.includes(`/${e.value}/`);case"link":return t.linkMatch?.(String(e.link),e.value,n)??n.links[e.link]===e.value;case"attr":{let r=n.attrs[e.key];return r!=null&&String(r).toLowerCase()===e.value.toLowerCase()}}}function Fs(t){let e=[...Fa,...t.links],n=(a,l=Date.now())=>_u(e,a,l),s=a=>ju(t,a);function r(a,l,c,f){let u=n(a,l);return{where:s(u),...yr(u,c,f),warnings:u.warnings}}function o(a,l=[]){let c=new Set(l),f=a?.all??[];return f.length?u=>f.every(d=>d.any.some(p=>Ku(t,p,u,c))!==!!d.not):()=>!0}return{FIELDS:e,parseSearch:n,toAst:s,compileSearch:r,matchAst:o,matcher:(a,l=[])=>o(s(a),l)}}function yr(t,e,n){for(let s of t.terms)s.field==="since"&&(e=Math.max(e,s.time)),s.field==="before"&&(n=Math.min(n,s.time));return{from:e,to:Math.max(e,n)}}function xr(t,e){let n=e.toLowerCase(),s=[];for(let o of t.terms){if(o.neg||o.field||!o.value)continue;let i=o.value.toLowerCase();for(let a=n.indexOf(i);a>=0;a=n.indexOf(i,a+i.length))s.push([a,a+i.length])}s.sort((o,i)=>o[0]-i[0]);let r=[];for(let o of s){let i=r[r.length-1];i&&o[0]<=i[1]?i[1]=Math.max(i[1],o[1]):r.push([...o])}return r}var Uc=t=>jt.filter(e=>ni(e)>=ni(t));var qc=new Map,si=new Map;function Ct(t,e){if(!t||t==="UTC")return 0;let n=`${t}|${Math.floor(e/(15*6e4))}`,s=si.get(n);if(s!==void 0)return s;let r=qc.get(t);if(!r){try{r=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}catch{return 0}qc.set(t,r)}let o={};for(let l of r.formatToParts(new Date(e)))l.type!=="literal"&&(o[l.type]=Number(l.value));let i=Date.UTC(o.year,o.month-1,o.day,o.hour%24,o.minute,o.second),a=Math.round((i-Math.floor(e/1e3)*1e3)/6e4)*6e4;return si.size>5e4&&si.clear(),si.set(n,a),a}var Yc=t=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:t}),!0}catch{return!1}};function cs(t,e,n){if(e==="1m")return Math.floor(t/6e4)*6e4;let s=Ct(n,t);if(e==="1h")return s%36e5===0?Math.floor(t/36e5)*36e5:Math.floor((t+s)/36e5)*36e5-s;let r=Math.floor((t+s)/864e5)*864e5,o=r-Ct(n,r-s);return o>t?o=r-864e5-Ct(n,r-864e5-s):ri(o,n)<=t&&(o=ri(o,n)),o}function ri(t,e,n="1d"){if(n==="1m")return t+6e4;if(n==="1h")return t+36e5;let s=Ct(e,t),r=Math.floor((t+s)/864e5)*864e5+864e5;return r-Ct(e,r-s)}var Jn=6e4,Xn=36e5,nn=864e5;function oi(t,e,n,s={}){let r=Math.max((s.minFrac??.15)*(n-e),s.minMs??10*Jn),o=t.filter(([l,c])=>c>=e&&l<n).map(([l,c])=>[Math.max(e,l),Math.min(n,Math.max(l,c))]).sort((l,c)=>l[0]-c[0]),i=[];if(!o.length)return i;let a=e;for(let[l,c]of o)l-a>r&&i.push({from:a,to:l}),a=Math.max(a,c);return n-a>r&&i.push({from:a,to:n}),i}function fs(t){if(t>=nn){let e=Math.floor(t/nn),n=Math.round((t-e*nn)/Xn);return n?`${e} d ${n} h`:`${e} d`}if(t>=Xn){let e=Math.floor(t/Xn),n=Math.round((t-e*Xn)/Jn);return n&&e<10?`${e} h ${n} min`:`${e} h`}return`${Math.max(1,Math.round(t/Jn))} min`}var us=t=>`${t.from}-${t.to}`;function Bs(t,e,n,s=[],r={}){let o=r.cut??24,i=Math.max(1,n),a=Math.max(1,e-t),l=s.filter(M=>M.to>t&&M.from<e).map(M=>({from:Math.max(t,M.from),to:Math.min(e,M.to),w:r.weights?.get(us(M))??0})).sort((M,$)=>M.from-$.from),c=l.reduce((M,$)=>M+($.to-$.from)*(1-$.w),0),f=l.reduce((M,$)=>M+(1-$.w)*o,0),u=(i-f)/Math.max(1,a-c);if(!(u>0)||f>i*.6)return Bs(t,e,n,[],r);let d=[[t,0]],p=0,h=t,m=[];for(let M of l){p+=(M.from-h)*u,d.push([M.from,p]);let $=(1-M.w)*o+M.w*u*(M.to-M.from);m.push({from:M.from,to:M.to,x0:p,x1:p+$,weight:M.w}),p+=$,d.push([M.to,p]),h=M.to}d.push([e,p+(e-h)*u]);let y=M=>{if(M<=t)return(M-t)*u;if(M>=e)return d[d.length-1][1]+(M-e)*u;let $=0,O=d.length-1;for(;O-$>1;){let w=$+O>>1;d[w][0]<=M?$=w:O=w}let[E,x]=d[$],[T,L]=d[O];return T===E?x:x+(M-E)/(T-E)*(L-x)},I=M=>m.find($=>$.weight<1&&M>$.x0&&M<$.x1);return{t0:t,t1:e,width:i,cuts:m,x:y,t:M=>{let $=I(M);if($)return M-$.x0<$.x1-M?$.from:$.to;if(M<=0)return t+M/u;let O=0,E=d.length-1;if(M>=d[E][1])return e+(M-d[E][1])/u;for(;E-O>1;){let P=O+E>>1;d[P][1]<=M?O=P:E=P}let[x,T]=d[O],[L,w]=d[E];return w===T?x:x+(M-T)/(w-T)*(L-x)},cutAt:I,msPerPx:1/u}}var _a=[1e3,5e3,15e3,3e4,Jn,5*Jn,15*Jn,30*Jn,Xn,3*Xn,6*Xn,12*Xn,nn,2*nn,7*nn,14*nn,28*nn];function ii(t,e,n=80){let s=_a.find(l=>l/t.msPerPx>=n)??_a[_a.length-1],r=[],o=l=>{let c=new Date(l+Ct(e,l)),f=String(c.getUTCHours()).padStart(2,"0"),u=String(c.getUTCMinutes()).padStart(2,"0"),d=String(c.getUTCSeconds()).padStart(2,"0"),p=`${c.getUTCDate()} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][c.getUTCMonth()]}`,h=f==="00"&&u==="00"&&d==="00";return s>=nn||h?{label:p,major:!0}:{label:s<Jn?`${f}:${u}:${d}`:`${f}:${u}`,major:!1}},i=[],a=t.t0;for(let l of t.cuts)l.weight<1&&(i.push([a,l.from]),a=l.to);i.push([a,t.t1]);for(let[l,c]of i){let f=d=>d-Ct(e,d-Ct(e,d)),u=Math.ceil((l+Ct(e,l))/s)*s;s>=7*nn&&(u=Math.ceil((l+Ct(e,l))/nn)*nn);for(let d=0,p=f(u);p<c&&d<2e3;d++,u+=s,p=f(u)){if(p<l)continue;let h=t.x(p),m=r[r.length-1];(!m||h-m.x>=n*.6)&&r.push({t:p,x:h,...o(p)})}}return r}var Vu=["id","time","t","dur","scope","source","kind","severity","summary"],Gu=t=>{if(t==null)return"";let e=typeof t=="string"&&/^[=+\-@\t\r]/.test(t)?`'${t}`:String(t);return/[",\n\r]/.test(e)?`"${e.replace(/"/g,'""')}"`:e},Hc=(t,e)=>e.size?{...t,attrs:Object.fromEntries(Object.entries(t.attrs).filter(([n])=>!e.has(`${t.source}.${n}`)))}:t;function ai(t,e=[]){let n=new Set(e);return JSON.stringify(t.map(s=>Hc(s,n)),null,2)+`
357
- `}function li(t,e=[]){let n=new Set(e),s=t.map(l=>Hc(l,n)),r=[...new Set(s.flatMap(l=>Object.keys(l.attrs)))].sort(),o=[...new Set(s.flatMap(l=>Object.keys(l.links)))].sort(),i=[...Vu,...r.map(l=>`attr.${l}`),...o.map(l=>`link.${l}`)],a=s.map(l=>[l.id,new Date(l.t).toISOString(),l.t,l.dur,l.scope,l.source,l.kind,l.severity,l.summary,...r.map(c=>l.attrs[c]),...o.map(c=>l.links[c])].map(Gu).join(","));return[i.join(","),...a].join(`\r
356
+ `}function Q(t,e=null,...n){let s=document.createElement(t);for(let[r,o]of Object.entries(e??{}))if(!(o==null||o===!1))if(r==="class")s.className=String(o);else if(r==="on")for(let[i,a]of Object.entries(o))s.addEventListener(i,a);else s.setAttribute(r,o===!0?"":String(o));for(let r of n)r!=null&&r!==!1&&s.append(r instanceof Node?r:document.createTextNode(String(r)));return s}var Dc=1,ei="(?:[^/:%\\s]|%[0-9A-F]{2})+",jt=["debug","info","notice","warning","error"],zc=["1m","1h","1d"],tn={"1m":6e4,"1h":36e5,"1d":864e5},ti=t=>`^(?:(?:${t.kinds.join("|")}):(?:${ei})(?:/(?:${t.kinds.join("|")}):(?:${ei}))*)?$`;function ni(t){let e=new RegExp(ti(t)),n=o=>e.test(o);function s(o){if(!e.test(o))throw new Error(`not a scope path: ${JSON.stringify(o)}`);return o===""?[]:o.split("/").map(i=>{let a=i.indexOf(":");return{kind:i.slice(0,a),name:decodeURIComponent(i.slice(a+1))}})}function r(o){let i="";for(let a of s(o)){if(!t.parents[a.kind].includes(i))return!1;i=a.kind}return!0}return{isScope:n,parseScope:s,wellNested:r}}var si=t=>t.replace(/[%/:\s]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`),jc=t=>t.map(e=>`${e.kind}:${si(e.name)}`).join("/"),Vc=(t,e,n)=>(t?`${t}/`:"")+`${e}:${si(n)}`,Nt=t=>t===""?0:t.split("/").length;function Bn(t,e){return e<=0?"":(t===""?[]:t.split("/")).slice(0,e).join("/")}var Kc=t=>Bn(t,Nt(t)-1),Vt=(t,e)=>e===""||t===e||t.startsWith(`${e}/`),Gc=(t,e)=>t!==""&&t.split("/").includes(e),Cs=t=>t===""?"fleet":t.slice(t.lastIndexOf("/")+1).split(":")[0],Ls=t=>t===""?"all hosts":decodeURIComponent(t.slice(t.lastIndexOf("/")+1).split(":").slice(1).join(":"));function Is(t){let e=[{scope:"",label:"all hosts",kind:"fleet"}];for(let n=1;n<=Nt(t);n++){let s=Bn(t,n);e.push({scope:s,label:Ls(s),kind:Cs(s)})}return e}var _a=["kind","source","severity","scope","since","before"];function Fu(t){let e=[],n=0;for(;n<t.length;){for(;n<t.length&&/\s/.test(t[n]);)n++;if(n>=t.length)break;let s=!1;t[n]==="-"&&n+1<t.length&&!/\s/.test(t[n+1])&&(s=!0,n++);let r=/^(attr\.[a-z][a-z0-9_]*|[a-z]+):/.exec(t.slice(n)),o;r&&(o=r[1],n+=r[0].length);let i="",a=!1;if(t[n]==='"'){let l=t.indexOf('"',n+1);i=t.slice(n+1,l<0?t.length:l),a=!0,n=l<0?t.length:l+1}else{let l=n;for(;n<t.length&&!/\s/.test(t[n]);)n++;i=t.slice(l,n)}e.push({neg:s,raw:i,quoted:a,field:o})}return e}var Bu=/^(\d+)(s|m|h|d|w)$/,_u={s:1e3,m:6e4,h:36e5,d:864e5,w:7*864e5};function Da(t,e){let n=Bu.exec(t);if(n)return e-Number(n[1])*_u[n[2]];let s=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?)?(Z|[+-]\d{2}:?\d{2})?$/.exec(t);if(!s)return;let[,r,o,i,a="0",l="0",c="0",f="0",u]=s;if(u){let p=Date.parse(t.replace(" ","T"));return Number.isNaN(p)?void 0:p}let d=new Date(+r,+o-1,+i,+a,+l,+c,+f.padEnd(3,"0")).getTime();return Number.isNaN(d)?void 0:d}function Du(t,e,n=Date.now()){let s=[],r=[];for(let o of Fu(e??"")){let i=c=>{let f=o.field?`${o.field}:${o.raw}`:o.raw;c&&r.push(`${JSON.stringify(f)}: ${c}; searched as text`),f&&s.push({neg:o.neg,value:f})};if(!o.field){i();continue}if(!(t.includes(o.field)||o.field.startsWith("attr."))){i(`no field ${o.field}`);continue}if(!o.raw){i(`${o.field}: needs a value`);continue}let l=o.field;if(l==="severity"){let c=/^(>=|<=|>|<|=)?(.*)$/.exec(o.raw);if(!jt.includes(c[2])){i(`no severity ${c[2]} (${jt.join(", ")})`);continue}s.push({neg:o.neg,field:l,op:c[1]??"=",value:c[2]})}else if(l==="since"||l==="before"){let c=Da(o.raw,n);if(c===void 0){i(`can't read the time ${o.raw} (15m, 2h, 3d, 1w, or a date like 2026-11-20 or 2026-11-20T09:30)`);continue}if(o.neg){i(`-${l} isn't allowed (use ${l==="since"?"before":"since"})`);continue}s.push({neg:!1,field:l,value:o.raw,time:c})}else s.push({neg:o.neg,field:l,value:o.raw})}return{terms:s,warnings:r}}var ri=t=>jt.indexOf(t),zu={"=":"eq",">=":"ge",">":"gt","<=":"le","<":"lt"};function ju(t,e){switch(t.field){case void 0:return{field:"text",value:t.value};case"kind":case"source":return t.value.endsWith("*")?{field:t.field,value:t.value.slice(0,-1),prefix:!0}:{field:t.field,value:t.value};case"severity":return{field:"severity",op:zu[t.op??"="],value:t.value};case"scope":return{field:"scope",value:t.value,from:e.topKinds.some(n=>t.value.startsWith(`${n}:`))?"top":"segments"};case"since":case"before":return;default:return e.links.includes(t.field)?{field:"link",link:t.field,value:t.value}:{field:"attr",key:t.field.slice(5),value:t.value}}}function Vu(t,e){let n=[],s=new Map;for(let r of e.terms){let o=ju(r,t);if(!o)continue;if(r.neg){n.push({not:!0,any:[o]});continue}if(o.field==="text"||o.field==="severity"){n.push({any:[o]});continue}let i=o.field==="link"?`link.${o.link}`:o.field==="attr"?`attr.${o.key}`:o.field,a=s.get(i);if(a)a.any.push(o);else{let l={any:[o]};s.set(i,l),n.push(l)}}return{all:n}}function Ku(t,e,n,s){switch(e.field){case"text":{let r=e.value.toLowerCase();if(n.summary.toLowerCase().includes(r)||n.kind.toLowerCase().includes(r)||n.source.toLowerCase().includes(r)||n.scope.toLowerCase().includes(r))return!0;for(let[o,i]of Object.entries(n.attrs))if(typeof i=="string"&&!s.has(`${n.source}.${o}`)&&i.toLowerCase().includes(r))return!0;return!1}case"kind":case"source":{let r=n[e.field];return e.prefix?r.startsWith(e.value):r===e.value}case"severity":{let r=ri(n.severity),o=ri(e.value);return e.op==="ge"?r>=o:e.op==="gt"?r>o:e.op==="le"?r<=o:e.op==="lt"?r<o:r===o}case"scope":return e.from==="top"?Vt(n.scope,e.value):`/${n.scope}/`.includes(`/${e.value}/`);case"link":return t.linkMatch?.(String(e.link),e.value,n)??n.links[e.link]===e.value;case"attr":{let r=n.attrs[e.key];return r!=null&&String(r).toLowerCase()===e.value.toLowerCase()}}}function Fs(t){let e=[..._a,...t.links],n=(a,l=Date.now())=>Du(e,a,l),s=a=>Vu(t,a);function r(a,l,c,f){let u=n(a,l);return{where:s(u),...yr(u,c,f),warnings:u.warnings}}function o(a,l=[]){let c=new Set(l),f=a?.all??[];return f.length?u=>f.every(d=>d.any.some(p=>Ku(t,p,u,c))!==!!d.not):()=>!0}return{FIELDS:e,parseSearch:n,toAst:s,compileSearch:r,matchAst:o,matcher:(a,l=[])=>o(s(a),l)}}function yr(t,e,n){for(let s of t.terms)s.field==="since"&&(e=Math.max(e,s.time)),s.field==="before"&&(n=Math.min(n,s.time));return{from:e,to:Math.max(e,n)}}function xr(t,e){let n=e.toLowerCase(),s=[];for(let o of t.terms){if(o.neg||o.field||!o.value)continue;let i=o.value.toLowerCase();for(let a=n.indexOf(i);a>=0;a=n.indexOf(i,a+i.length))s.push([a,a+i.length])}s.sort((o,i)=>o[0]-i[0]);let r=[];for(let o of s){let i=r[r.length-1];i&&o[0]<=i[1]?i[1]=Math.max(i[1],o[1]):r.push([...o])}return r}var Uc=t=>jt.filter(e=>ri(e)>=ri(t));var qc=new Map,oi=new Map;function Ct(t,e){if(!t||t==="UTC")return 0;let n=`${t}|${Math.floor(e/(15*6e4))}`,s=oi.get(n);if(s!==void 0)return s;let r=qc.get(t);if(!r){try{r=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}catch{return 0}qc.set(t,r)}let o={};for(let l of r.formatToParts(new Date(e)))l.type!=="literal"&&(o[l.type]=Number(l.value));let i=Date.UTC(o.year,o.month-1,o.day,o.hour%24,o.minute,o.second),a=Math.round((i-Math.floor(e/1e3)*1e3)/6e4)*6e4;return oi.size>5e4&&oi.clear(),oi.set(n,a),a}var Yc=t=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:t}),!0}catch{return!1}};function cs(t,e,n){if(e==="1m")return Math.floor(t/6e4)*6e4;let s=Ct(n,t);if(e==="1h")return s%36e5===0?Math.floor(t/36e5)*36e5:Math.floor((t+s)/36e5)*36e5-s;let r=Math.floor((t+s)/864e5)*864e5,o=r-Ct(n,r-s);return o>t?o=r-864e5-Ct(n,r-864e5-s):ii(o,n)<=t&&(o=ii(o,n)),o}function ii(t,e,n="1d"){if(n==="1m")return t+6e4;if(n==="1h")return t+36e5;let s=Ct(e,t),r=Math.floor((t+s)/864e5)*864e5+864e5;return r-Ct(e,r-s)}var Jn=6e4,Xn=36e5,nn=864e5;function ai(t,e,n,s={}){let r=Math.max((s.minFrac??.15)*(n-e),s.minMs??10*Jn),o=t.filter(([l,c])=>c>=e&&l<n).map(([l,c])=>[Math.max(e,l),Math.min(n,Math.max(l,c))]).sort((l,c)=>l[0]-c[0]),i=[];if(!o.length)return i;let a=e;for(let[l,c]of o)l-a>r&&i.push({from:a,to:l}),a=Math.max(a,c);return n-a>r&&i.push({from:a,to:n}),i}function fs(t){if(t>=nn){let e=Math.floor(t/nn),n=Math.round((t-e*nn)/Xn);return n?`${e} d ${n} h`:`${e} d`}if(t>=Xn){let e=Math.floor(t/Xn),n=Math.round((t-e*Xn)/Jn);return n&&e<10?`${e} h ${n} min`:`${e} h`}return`${Math.max(1,Math.round(t/Jn))} min`}var us=t=>`${t.from}-${t.to}`;function Bs(t,e,n,s=[],r={}){let o=r.cut??24,i=Math.max(1,n),a=Math.max(1,e-t),l=s.filter(M=>M.to>t&&M.from<e).map(M=>({from:Math.max(t,M.from),to:Math.min(e,M.to),w:r.weights?.get(us(M))??0})).sort((M,$)=>M.from-$.from),c=l.reduce((M,$)=>M+($.to-$.from)*(1-$.w),0),f=l.reduce((M,$)=>M+(1-$.w)*o,0),u=(i-f)/Math.max(1,a-c);if(!(u>0)||f>i*.6)return Bs(t,e,n,[],r);let d=[[t,0]],p=0,h=t,m=[];for(let M of l){p+=(M.from-h)*u,d.push([M.from,p]);let $=(1-M.w)*o+M.w*u*(M.to-M.from);m.push({from:M.from,to:M.to,x0:p,x1:p+$,weight:M.w}),p+=$,d.push([M.to,p]),h=M.to}d.push([e,p+(e-h)*u]);let y=M=>{if(M<=t)return(M-t)*u;if(M>=e)return d[d.length-1][1]+(M-e)*u;let $=0,R=d.length-1;for(;R-$>1;){let x=$+R>>1;d[x][0]<=M?$=x:R=x}let[E,w]=d[$],[T,L]=d[R];return T===E?w:w+(M-E)/(T-E)*(L-w)},I=M=>m.find($=>$.weight<1&&M>$.x0&&M<$.x1);return{t0:t,t1:e,width:i,cuts:m,x:y,t:M=>{let $=I(M);if($)return M-$.x0<$.x1-M?$.from:$.to;if(M<=0)return t+M/u;let R=0,E=d.length-1;if(M>=d[E][1])return e+(M-d[E][1])/u;for(;E-R>1;){let P=R+E>>1;d[P][1]<=M?R=P:E=P}let[w,T]=d[R],[L,x]=d[E];return x===T?w:w+(M-T)/(x-T)*(L-w)},cutAt:I,msPerPx:1/u}}var za=[1e3,5e3,15e3,3e4,Jn,5*Jn,15*Jn,30*Jn,Xn,3*Xn,6*Xn,12*Xn,nn,2*nn,7*nn,14*nn,28*nn];function li(t,e,n=80){let s=za.find(l=>l/t.msPerPx>=n)??za[za.length-1],r=[],o=l=>{let c=new Date(l+Ct(e,l)),f=String(c.getUTCHours()).padStart(2,"0"),u=String(c.getUTCMinutes()).padStart(2,"0"),d=String(c.getUTCSeconds()).padStart(2,"0"),p=`${c.getUTCDate()} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][c.getUTCMonth()]}`,h=f==="00"&&u==="00"&&d==="00";return s>=nn||h?{label:p,major:!0}:{label:s<Jn?`${f}:${u}:${d}`:`${f}:${u}`,major:!1}},i=[],a=t.t0;for(let l of t.cuts)l.weight<1&&(i.push([a,l.from]),a=l.to);i.push([a,t.t1]);for(let[l,c]of i){let f=d=>d-Ct(e,d-Ct(e,d)),u=Math.ceil((l+Ct(e,l))/s)*s;s>=7*nn&&(u=Math.ceil((l+Ct(e,l))/nn)*nn);for(let d=0,p=f(u);p<c&&d<2e3;d++,u+=s,p=f(u)){if(p<l)continue;let h=t.x(p),m=r[r.length-1];(!m||h-m.x>=n*.6)&&r.push({t:p,x:h,...o(p)})}}return r}var Gu=["id","time","t","dur","scope","source","kind","severity","summary"],Uu=t=>{if(t==null)return"";let e=typeof t=="string"&&/^[=+\-@\t\r]/.test(t)?`'${t}`:String(t);return/[",\n\r]/.test(e)?`"${e.replace(/"/g,'""')}"`:e},Hc=(t,e)=>e.size?{...t,attrs:Object.fromEntries(Object.entries(t.attrs).filter(([n])=>!e.has(`${t.source}.${n}`)))}:t;function ci(t,e=[]){let n=new Set(e);return JSON.stringify(t.map(s=>Hc(s,n)),null,2)+`
357
+ `}function fi(t,e=[]){let n=new Set(e),s=t.map(l=>Hc(l,n)),r=[...new Set(s.flatMap(l=>Object.keys(l.attrs)))].sort(),o=[...new Set(s.flatMap(l=>Object.keys(l.links)))].sort(),i=[...Gu,...r.map(l=>`attr.${l}`),...o.map(l=>`link.${l}`)],a=s.map(l=>[l.id,new Date(l.t).toISOString(),l.t,l.dur,l.scope,l.source,l.kind,l.severity,l.summary,...r.map(c=>l.attrs[c]),...o.map(c=>l.links[c])].map(Uu).join(","));return[i.join(","),...a].join(`\r
358
358
  `)+`\r
359
- `}var Uu=864e5,hn=36e5,ci=(t,e)=>t.t-e.t||(t.id<e.id?-1:t.id>e.id?1:0);function An(t,e){let n=0,s=t.length;for(;n<s;){let r=n+s>>1;t[r].t<e?n=r+1:s=r}return n}var Xc=(t,e)=>{t.min=Math.min(t.min,e.min),t.max=Math.max(t.max,e.max),t.sum+=e.sum,t.count+=e.count};function Wc(t,e,n){let s=[];for(let r of t){let o=cs(r.t,e,n),i=s[s.length-1];i&&i.t===o?Xc(i,r):s.push({t:o,min:r.min,max:r.max,sum:r.sum,count:r.count})}return s}function Da(t,e,n,s){for(let i=An(t,e.t);i<t.length&&t[i].t===e.t;i++)if(n(t[i])){t[i]=e;return}let r=t[t.length-1];if(!r||s(r,e)<=0){t.push(e);return}let o=An(t,e.t);for(;o<t.length&&s(t[o],e)<0;)o++;t.splice(o,0,e)}function Jc(t,e,n){for(let s=An(t,e);s<t.length&&t[s].t===e;s++)if(n(t[s])){t.splice(s,1);return}}function Qc(t,e,n={}){let s=t.catalog,{isScope:r}=ei(e),{parseSearch:o,matchAst:i,toAst:a}=Fs(e),l=S=>Object.fromEntries(e.flags.filter(Y=>S?.[Y]).map(Y=>[Y,!0])),c=n.now??s.now,f=(s.names??[]).flatMap(S=>(S.aliases??[]).map(Y=>[Y,S.scope])).sort((S,Y)=>Y[0].length-S[0].length),u=new Map,d=S=>{if(!f.length)return S;let Y=u.get(S);if(Y===void 0){let se=f.find(([le])=>Kt(S,le));Y=se?se[1]+S.slice(se[0].length):S,u.set(S,Y)}return Y},p=new Map((s.names??[]).map(S=>[S.scope,S])),h=S=>f.length?{...S,scope:d(S.scope)}:S,m=S=>`${S.source}\0${S.id}`,y=t.events.map(h).sort(ci),I=new Map;for(let S of y)I.set(m(S),S);let N=y.filter(S=>S.dur!==void 0&&!S.open),M=N.reduce((S,Y)=>Math.max(S,Y.dur),0),$=new Map;for(let S of y)S.open&&$.set(m(S),S);let O=new Map,E=new Set,x=S=>{for(let Y=Nt(S);Y>=1;Y--){let se=Bn(S,Y);if(E.has(se))break;E.add(se)}},T=new Map;for(let S of s.sources)for(let Y of S.series)T.set(Y.name,Y.type);let L=s.sources.flatMap(S=>(S.sensitive??[]).map(Y=>`${S.name}.${Y}`)),w=new Map;for(let S of s.sources)w.set(S.name,{events:S.defaultRetention.events,rollups:{...S.defaultRetention.rollups},setBy:"default"});for(let S of s.retention)w.set(S.source,{events:S.events,rollups:{...S.rollups},setBy:S.setBy});let P=new Map;for(let S of s.sources)for(let Y of S.series)P.set(Y.name,S.name);function b(S){let Y=d(S.scope),se=`${S.series}\0${Y}`,le=O.get(se);le||(le={series:S.series,scope:Y,fine:[],cache:new Map},O.set(se,le),x(Y));let Pe="value"in S?{t:S.t,min:S.value,max:S.value,sum:S.value,count:1}:{t:S.t,min:S.min,max:S.max,sum:S.sum,count:S.count};Da(le.fine,Pe,ae=>ae.t===Pe.t,(ae,Be)=>ae.t-Be.t),le.cache.clear()}for(let S of y)x(S.scope);for(let S of t.metrics)b(S);let v=new Map,g=new Set,R=(S,Y)=>{g.add(S.source);let se=v.get(S.scope);se||v.set(S.scope,se=new Map);let le=se.get(S.source);le||se.set(S.source,le=new Map);let Pe=Math.floor(S.t/hn)*hn,ae=le.get(Pe);if(ae||le.set(Pe,ae={t:Pe,count:0,severity:{},kinds:{},first:1/0,last:-1/0}),ae.count+=Y,Y>0)ae.first=Math.min(ae.first,S.t),ae.last=Math.max(ae.last,S.t);else if(S.t===ae.first||S.t===ae.last){ae.first=1/0,ae.last=-1/0;for(let Be=An(y,Pe);Be<y.length&&y[Be].t<Pe+hn;Be++){let xe=y[Be];xe.scope===S.scope&&xe.source===S.source&&(ae.first=Math.min(ae.first,xe.t),ae.last=Math.max(ae.last,xe.t))}}ae.severity[S.severity]=(ae.severity[S.severity]??0)+Y,ae.kinds[S.kind]=(ae.kinds[S.kind]??0)+Y,ae.severity[S.severity]===0&&delete ae.severity[S.severity],ae.kinds[S.kind]===0&&delete ae.kinds[S.kind],ae.count||le.delete(Pe)};for(let S of y)R(S,1);let F=(S,Y,se)=>{let le=`${Y}|${se??""}`,Pe=S.cache.get(le);return Pe||(Pe=Y==="1d"?Wc(F(S,"1h",se),"1d",se):Wc(S.fine,Y,se),S.cache.set(le,Pe)),Pe},j=S=>S===null?-1/0:c-S*Uu,U=S=>j(w.get(S)?.events??null),ne=(S,Y)=>{let se=w.get(S);return j(se?Y?se.rollups[Y]:se.events:null)};function B(S){let Y=[];for(let se of new Set(S)){let le=w.get(se);if(!le)continue;let Pe=y.find(fe=>fe.source===se&&fe.t>=U(se))?.t,ae=fe=>{let Se=1/0;for(let Ve of O.values())if(P.get(Ve.series)===se){let Te=(fe?F(Ve,fe):Ve.fine).find(Qe=>Qe.t>=ne(se,fe));Te&&Te.t<Se&&(Se=Te.t)}return Se===1/0?void 0:Se},Be=[Pe,ae()].filter(fe=>fe!==void 0),xe={};for(let fe of["1m","1h","1d"]){let Se=ae(fe)??(Pe!==void 0&&Pe>=ne(se,fe)?Pe:void 0);Se!==void 0&&(xe[fe]=Math.max(Se,ne(se,fe)))}Y.push({source:se,events:le.events,rollups:{...le.rollups},setBy:le.setBy,keptFrom:{...Be.length?{events:Math.min(...Be)}:{},rollups:xe}})}return Y}function V(S){let Y=S.where,se={from:S.from,to:S.to},le=[];if(!Y&&S.q){let Te=o(S.q,c);Y=a(Te),se=yr(Te,S.from,S.to),le=Te.warnings}let Pe=i(Y,L),ae=S.filters??{},Be=ae.source?.length?new Set(ae.source):void 0,xe=ae.kind?.length?new Set(ae.kind):void 0,fe=ae.severity?.length?new Set(ae.severity):void 0,Se=ae.scope?.length?ae.scope:void 0;return{test:Te=>Kt(Te.scope,S.scope)&&(!Be||Be.has(Te.source))&&(!xe||xe.has(Te.kind))&&(!fe||fe.has(Te.severity))&&(!Se||Se.some(Qe=>Kt(Te.scope,Qe)))&&Te.t>=U(Te.source)&&Pe(Te),range:se,warnings:le}}function q(S){let Y=Nt(S.scope),se=Y+S.depth,le=new Map,Pe=fe=>{let Se=le.get(fe);return Se===void 0&&!le.has(fe)&&(Se=Kt(fe,S.scope)?Nt(fe)>=se?Bn(fe,se):fe:void 0,le.set(fe,Se)),Se},ae=fe=>{let Se=0,Ve=Nt(fe)+1;for(let Te of E)Nt(Te)===Ve&&Kt(Te,fe)&&Se++;return Se},Be=new Map,xe=fe=>{let Se=Be.get(fe);if(!Se){let Ve=Nt(fe)-Y,Te=p.get(fe);Se={scope:fe,label:Te?.label??Ls(fe),kind:Cs(fe),...l(Te),depth:Ve,...Ve<S.depth?{own:!0}:{},children:ae(fe),count:0},Be.set(fe,Se)}return Se};for(let fe of E)Nt(fe)===se&&Kt(fe,S.scope)&&xe(fe);return se===0&&xe(""),{at:Pe,add:xe,rows:Be}}let Z=S=>[...S.values()].sort((Y,se)=>Y.scope===se.scope?0:Y.scope<se.scope?-1:1);function A(S,Y){let se=[];for(let le=An(N,S-M);le<N.length&&N[le].t<S;le++)N[le].t+N[le].dur>S&&se.push(N[le]);for(let le of $.values())le.t<S&&c>S&&se.push(le);for(let le=An(y,S);le<y.length&&y[le].t<Y;le++)se.push(y[le]);return se}function D(S,Y,se,le){let Pe=S.series?new Set(S.series):void 0,ae=new Map;for(let xe of O.values()){if(Pe&&!Pe.has(xe.series))continue;let fe=Y(xe.scope);if(fe===void 0)continue;let Se=P.get(xe.series)??"",Ve=ne(Se,S.bin),Te=S.bin?F(xe,S.bin,S.tz):xe.fine;for(let Qe=An(Te,S.bin?cs(se,S.bin,S.tz):se);Qe<Te.length&&Te[Qe].t<le;Qe++){let lt=Te[Qe];if(lt.t<Ve)continue;let je=`${xe.series}\0${fe}\0${lt.t}`,st=ae.get(je);st?Xc(st,lt):ae.set(je,{series:xe.series,scope:fe,t:lt.t,bin:S.bin??"1m",min:lt.min,max:lt.max,sum:lt.sum,count:lt.count})}}let Be=[...ae.values()].sort((xe,fe)=>xe.t-fe.t||(xe.series<fe.series?-1:1)||(xe.scope<fe.scope?-1:1));return S.bin?Be:Be.map(xe=>({series:xe.series,scope:xe.scope,t:xe.t,value:xe.count===1||T.get(xe.series)!=="gauge"?xe.sum:xe.sum/xe.count}))}let K=S=>`${S.t}:${S.id}`,W=(S,Y)=>{let se=Y.indexOf(":"),le=Number(Y.slice(0,se)),Pe=Y.slice(se+1);return S.t>le||S.t===le&&S.id>Pe};function ie(S){if(S.bin!=="1h"&&S.bin!=="1d"||(S.where?.all.length??0)||S.q||S.filters?.kind?.length||S.filters?.severity?.length||S.filters?.scope?.length||Ct(S.tz,S.from)%hn||Ct(S.tz,S.to)%hn)return;let Y=S.filters?.source?.length?new Set(S.filters.source):void 0,se=ce=>Math.max(S.from,U(ce)),{at:le,add:Pe,rows:ae}=q(S),Be=new Set,xe=new Map,fe=0,Se=(ce,Re)=>{let Ee=cs(Re,S.bin,S.tz),tt=`${ce}\0${Ee}`,k=xe.get(tt);return k||(k={scope:ce,t:Ee,bin:S.bin,count:0,severity:{},kinds:{}},xe.set(tt,k)),k},Ve=(ce,Re,Ee)=>{let tt=Pe(ce);tt.count+=Ee,fe+=Ee,(tt.first===void 0||Re<tt.first)&&(tt.first=Re),(tt.last===void 0||Re>tt.last)&&(tt.last=Re)},Te=Math.floor(S.to/hn)*hn;for(let[ce,Re]of v){let Ee=le(ce);if(Ee!==void 0)for(let[tt,k]of Re){if(Y&&!Y.has(tt))continue;let _=Math.ceil(se(tt)/hn)*hn;for(let[z,oe]of k){if(z<_||z>=Te)continue;Ve(Ee,oe.first,oe.count),oe.last>(ae.get(Ee).last??-1/0)&&(ae.get(Ee).last=oe.last),Be.add(tt);let re=Se(Ee,z);re.count+=oe.count;for(let[ke,he]of Object.entries(oe.severity))re.severity[ke]=(re.severity[ke]??0)+he;for(let[ke,he]of Object.entries(oe.kinds))re.kinds[ke]=(re.kinds[ke]??0)+he}}}let Qe=ce=>Kt(ce.scope,S.scope)&&(!Y||Y.has(ce.source))&&ce.t>=U(ce.source)&&le(ce.scope)!==void 0,lt=ce=>{let Re=le(ce.scope);Ve(Re,ce.t,1),Be.add(ce.source);let Ee=Se(Re,ce.t);Ee.count++,Ee.severity[ce.severity]=(Ee.severity[ce.severity]??0)+1,Ee.kinds[ce.kind]=(Ee.kinds[ce.kind]??0)+1};for(let ce of g){if(Y&&!Y.has(ce))continue;let Re=se(ce),Ee=Math.ceil(Re/hn)*hn,tt=Ee>=Te?[[Re,S.to]]:[[Re,Ee],[Te,S.to]];for(let[k,_]of tt)for(let z=An(y,k);z<y.length&&y[z].t<_;z++){let oe=y[z];oe.source===ce&&Qe(oe)&&lt(oe)}}let je=tn[S.bin],st=[];for(let ce=An(N,S.from-M);ce<N.length&&N[ce].t<S.from;ce++){let Re=N[ce];Re.t+Re.dur>S.from&&Qe(Re)&&(Ve(le(Re.scope),Re.t,1),Be.add(Re.source),Re.dur>=je&&st.length<5e3&&st.push(Re))}for(let ce of $.values())ce.t<S.from&&c>S.from&&Qe(ce)&&(Ve(le(ce.scope),ce.t,1),Be.add(ce.source),st.length<5e3&&st.push(ce));for(let ce=An(N,S.from);ce<N.length&&N[ce].t<S.to&&st.length<5e3;ce++)N[ce].dur>=je&&Qe(N[ce])&&st.push(N[ce]);for(let ce of $.values())ce.t>=S.from&&ce.t<S.to&&st.length<5e3&&Qe(ce)&&st.push(ce);let Ye=D(S,le,S.from,S.to);for(let ce of Ye){let Re=P.get(ce.series);Re&&Be.add(Re)}let rt=[...xe.values()].sort((ce,Re)=>ce.t-Re.t||(ce.scope<Re.scope?-1:1));return{timeline:1,type:"result",rows:Z(ae),bins:rt,spans:st,metrics:Ye,total:fe,retention:B(Be)}}async function de(S){if(!r(S.scope))throw new Error(`not a scope path: ${JSON.stringify(S.scope)}`);let Y=ie(S);if(Y)return Y;let{test:se,range:le,warnings:Pe}=V(S),{at:ae,add:Be,rows:xe}=q(S),fe=new Set,Se=[];for(let Ye of A(le.from,le.to)){if(!se(Ye))continue;let rt=ae(Ye.scope);if(rt===void 0)continue;let ce=Be(rt);ce.count++,(ce.first===void 0||Ye.t<ce.first)&&(ce.first=Ye.t),(ce.last===void 0||Ye.t>ce.last)&&(ce.last=Ye.t),fe.add(Ye.source),Se.push(Ye)}Se.sort(ci);let Ve=D(S,ae,le.from,le.to);for(let Ye of Ve){let rt=P.get(Ye.series);rt&&fe.add(rt)}let Te={timeline:1,type:"result",total:Se.length,...Pe.length?{warnings:Pe}:{}};if(S.bin){let Ye=tn[S.bin],rt=new Map,ce=[];for(let Ee of Se){if((Ee.open||Ee.dur!==void 0&&Ee.dur>=Ye)&&ce.length<5e3&&ce.push(Ee),Ee.t<le.from)continue;let tt=ae(Ee.scope),k=cs(Ee.t,S.bin,S.tz),_=`${tt}\0${k}`,z=rt.get(_);z||(z={scope:tt,t:k,bin:S.bin,count:0,severity:{},kinds:{}},rt.set(_,z)),z.count++,z.severity[Ee.severity]=(z.severity[Ee.severity]??0)+1,z.kinds[Ee.kind]=(z.kinds[Ee.kind]??0)+1}let Re=[...rt.values()].sort((Ee,tt)=>Ee.t-tt.t||(Ee.scope<tt.scope?-1:1));return{...Te,rows:Z(xe),bins:Re,spans:ce,metrics:Ve,retention:B(fe)}}let Qe=Math.min(1e4,Math.max(1,S.limit??2e3)),lt=S.cursor?Se.findIndex(Ye=>W(Ye,S.cursor)):0,je=lt<0?[]:Se.slice(lt,lt+Qe),st=lt>=0&&lt+Qe<Se.length;return{...Te,rows:Z(xe),events:je,metrics:Ve,retention:B(fe),...st?{next:K(je[je.length-1])}:{}}}let X=new Set,te=S=>jt.includes(S),ye=0;function Fe(S){let Y=m(S),se=I.get(Y);se&&(Jc(y,se.t,le=>le===se),R(se,-1),se.dur!==void 0&&!se.open&&Jc(N,se.t,le=>le===se),$.delete(Y)),I.set(Y,S),R(S,1),Da(y,S,()=>!1,ci),S.open?$.set(Y,S):S.dur!==void 0&&(Da(N,S,()=>!1,ci),M=Math.max(M,S.dur)),x(S.scope)}return{async catalog(){return{...s,now:c,retention:B(s.sources.map(S=>S.name))}},query:de,subscribe(S,Y){let se={q:S,on:Y};return X.add(se),()=>{X.delete(se)}},...n.stateAt?{stateAt:(S,Y)=>n.stateAt(S,Y)}:{},append(S,Y=[],se){se!==void 0&&(c=Math.max(c,se));let le=new Set(E),Pe=S.map(h);for(let ae of Pe){if(!te(ae.severity))throw new Error(`not a severity: ${ae.severity}`);Fe(ae)}for(let ae of Y)b(ae);ye++;for(let ae of X){let{test:Be}=V(ae.q),{at:xe}=q(ae.q),fe=Pe.filter(je=>Be(je)&&xe(je.scope)!==void 0),Se=ae.q.series?new Set(ae.q.series):void 0,Ve=Y.filter(je=>Kt(d(je.scope),ae.q.scope)&&(!Se||Se.has(je.series))).map(je=>({...je,scope:xe(d(je.scope))})),Te=[...E].filter(je=>!le.has(je)),Qe=Nt(ae.q.scope)+ae.q.depth,lt=Te.filter(je=>Nt(je)===Qe&&Kt(je,ae.q.scope)).map(je=>({scope:je,label:p.get(je)?.label??Ls(je),kind:Cs(je),depth:ae.q.depth,children:0,count:0}));ae.on({timeline:1,type:"batch",events:fe,metrics:Ve,...lt.length?{rows:lt}:{},now:c,resume:String(ye)})}},setRetention(S,Y){w.set(S,{events:Y.events,rollups:{...Y.rollups},setBy:"user"})},get now(){return c},get size(){let S=0;for(let Y of O.values())S+=Y.fine.length;return{events:y.length,samples:S}}}}var Zc="http://www.w3.org/2000/svg",ds=22,fi=38,Nn=26,qu=210,Yu=24,wr=6e4,ps=36e5,Yt=864e5,ef={"15m":15*wr,"1h":ps,"1d":Yt,"1w":7*Yt},tf=t=>jt.indexOf(t),Hu={debug:"dot",info:"circle",notice:"square",warning:"triangle",error:"diamond"},nt=(t,e,n)=>{let s=document.createElementNS(Zc,t);for(let[r,o]of Object.entries(e))o!==void 0&&s.setAttribute(r,String(o));if(n){let r=document.createElementNS(Zc,"title");r.textContent=n,s.append(r)}return s},Lt=(t,e)=>{try{return new Intl.DateTimeFormat(void 0,{timeZone:e,dateStyle:"medium",timeStyle:"medium"}).format(t)}catch{return new Date(t).toISOString()}},za=t=>t<1e3?`${Math.round(t)} ms`:t<wr?`${(t/1e3).toFixed(1)} s`:fs(t),Wu=(t,e)=>e==="bytes"?t>=1e9?`${(t/1e9).toFixed(1)} GB`:t>=1e6?`${(t/1e6).toFixed(1)} MB`:t>=1e3?`${(t/1e3).toFixed(1)} kB`:`${Math.round(t)} B`:`${Math.round(t*10)/10}${e==="count"?"":` ${e}`}`;function ja(t,e){if(t<=3*ps)return{kind:"single"};for(let n of["1m","1h","1d"])if(t/tn[n]<=e/2)return{kind:"binned",bin:n};return{kind:"binned",bin:"1d"}}function Ka(t,e,n){let s=[];for(let i of t.events??[])s.push([i.t,i.t]),i.dur!==void 0&&!i.open&&s.push([i.t+i.dur,i.t+i.dur]);for(let i of t.spans??[])s.push([i.t,i.t]),i.dur!==void 0&&!i.open&&s.push([i.t+i.dur,i.t+i.dur]);let r=e.kind==="binned"?tn[e.bin]:wr;for(let i of t.bins??[])i.count&&s.push([i.t,i.t+tn[i.bin]]);let o=new Map;for(let i of t.metrics){let a="value"in i?i.value:i.sum,l=`${i.series}|${i.scope}`,c=(n?.get(i.series)??"counter")==="counter"?a!==0:o.get(l)!==a;o.set(l,a),c&&s.push([i.t,i.t+r])}return s}function nf(t,e){let n=e.tz??Intl.DateTimeFormat().resolvedOptions().timeZone,s=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,r=e.motion??!s;t.classList.add(...e.rootClass??[],"tlx");let{parseSearch:o,compileSearch:i}=Fs(e.catalog),a=(C="system")=>{t.style.colorScheme=C==="system"?"light dark":C,C==="system"?delete t.dataset.theme:t.dataset.theme=C};a(e.theme),t.setAttribute("role","region"),t.setAttribute("aria-label","Timeline");let l,c="",f=1,u="",d={},p=!1,h=e.collapseGaps??!0,m={t0:0,t1:Yt},y,I="",N={from:0,to:0,mode:{kind:"single"},key:""},M,$,O,E,x=!0,T=0,L=0,w=!1,P,b=[],v=[],g=-1,R=new Set,F=new Map,j=[],U=Bs(0,Yt,800),ne=new Map,B=[],V=Q("nav",{class:"tlx-crumbs","aria-label":"Scope"}),q=Q("div",{class:"segmented tlx-quick",role:"group","aria-label":"Range"});for(let C of["15m","1h","1d","1w","run"]){let G=Q("button",{type:"button",class:"seg","data-v":C,title:C==="run"?"The latest run":`The last ${C}`},C==="run"?"this run":C);G.addEventListener("click",()=>Zn(C)),q.append(G)}let Z=Q("button",{type:"button",class:"btn sm tlx-live","aria-pressed":"false",title:"Follow what happens now"},"Live"),A=Q("button",{type:"button",class:"btn sm quiet tlx-now",hidden:!0,title:"Back to the live edge"},"Back to now"),D=Q("button",{type:"button",class:"btn sm quiet tlx-fit",title:"Everything in this scope"},"Fit"),K=Q("input",{type:"checkbox",class:"tlx-gaps"});K.checked=h;let W=!0,ie=Q("input",{type:"checkbox",class:"tlx-quiet"});ie.checked=W;let de=Q("input",{type:"search",class:"input tlx-q",placeholder:"Search: words, kind:\u2026, source:\u2026, severity:>=warning, -kind:\u2026","aria-label":"Search the timeline",spellcheck:"false"}),X=Q("span",{class:"tlx-hits",role:"status","aria-live":"polite"}),te=Q("button",{type:"button",class:"btn sm quiet tlx-prev",title:"Previous hit (\u21E7N)","aria-label":"Previous hit"},"\u2039"),ye=Q("button",{type:"button",class:"btn sm quiet tlx-next",title:"Next hit (N)","aria-label":"Next hit"},"\u203A"),Fe=Q("div",{class:"tlx-facets",role:"group","aria-label":"Sources"}),S=Q("select",{class:"input tlx-sev","aria-label":"Severity"},Q("option",{value:""},"every severity"),...jt.slice(1).map(C=>Q("option",{value:C},`${C} and above`))),Y=Q("select",{class:"input tlx-views","aria-label":"Saved views",hidden:!e.views},Q("option",{value:""},"Saved views\u2026")),se=Q("button",{type:"button",class:"btn sm quiet tlx-save",hidden:!e.saveView,title:"Save this view"},"Save view"),le=Q("div",{class:"tlx-warn",role:"status",hidden:!0}),Pe=Q("div",{class:"tlx-status",role:"status"}),ae=Q("span",{class:"tlx-canvas-note"}),Be=Q("div",{class:"tlx-labels"}),xe=Q("div",{class:"tlx-lanes",tabindex:"0",role:"application","aria-label":"Timeline lanes: drag to pan, wheel to zoom, drag the axis to choose a range, click it to move the playhead. Keys: \u2190 \u2192 pan, + \u2212 zoom, N next hit"}),fe=nt("svg",{class:"tlx-svg"});xe.append(fe);let Se=Q("div",{class:"tlx-scroll"},Q("div",{class:"tlx-grid"},Be,xe)),Ve=Q("section",{class:"tlx-table",hidden:!0,"aria-label":"The events in the chosen range"}),Te=Q("aside",{class:"tlx-detail",hidden:!0,"aria-label":"The event"});t.replaceChildren(Q("div",{class:"tlx-bar"},V,Q("span",{class:"spacer"}),q,Z,A,D,Q("label",{class:"tlx-gaps-label",title:"Draw long empty stretches as narrow breaks"},K,"Collapse gaps"),Q("label",{class:"tlx-gaps-label",title:"Hide the rows with nothing in this range"},ie,"Hide quiet rows")),Q("div",{class:"tlx-bar"},de,X,te,ye,S,Y,se),Fe,le,Q("div",{class:"tlx-body"},Se,Te),Q("div",{class:"tlx-foot"},Pe,Q("span",{class:"spacer"}),ae),Ve);let Qe=()=>Math.max(200,xe.clientWidth||800),lt=()=>{let C=(ue,Oe)=>(ue.own?-1:0)-(Oe.own?-1:0)||ue.scope.localeCompare(Oe.scope,void 0,{numeric:!0}),J=(y?.rows??[]).filter(ue=>!W||ue.count>0||ue.own||(y?.rows.length??0)<=1).sort(C).map(ue=>({kind:"row",row:ue})),ee=new Set(y?.metrics.map(ue=>ue.series)??[]);for(let ue of[...ee].sort()){let Oe=ne.get(ue);J.push({kind:"metric",series:ue,unit:Oe?.unit??"count",type:Oe?.type??"counter",title:Oe?.title??ue})}return J},je=(C,G)=>l?.names?.find(J=>J.scope===C)?.label??G,st=C=>C.kind==="metric"?fi:ds,Ye=()=>ja(m.t1-m.t0,Qe()),rt=()=>l?.now??Date.now();function ce(){return{timeline:1,type:"view",name:"",scope:c,depth:f,range:{from:Math.round(m.t0),to:Math.round(m.t1)},...u?{q:u}:{},...Object.keys(d).length?{filters:d}:{},...p?{live:p}:{},...h?{}:{collapseGaps:!1},...W?{}:{quietRows:!0}}}function Re(C){C.scope!==void 0&&(c=C.scope),C.depth!==void 0&&(f=C.depth),u=C.q??"",de.value=u,d=C.filters??{},S.value=d.severity?.length?d.severity[0]:"",h=C.collapseGaps??e.collapseGaps??!0,K.checked=h,W=!C.quietRows,ie.checked=W,R.clear(),F.clear();let G=C.range;G&&"last"in G?Zn(G.last,!1):G&&(m={t0:G.from,t1:G.to}),ht(!!C.live,!1)}let Ee=()=>{let C=ce();if(e.onViewChange?.(C),!!e.urlState)try{history.replaceState(null,"",`#timeline=${encodeURIComponent(JSON.stringify(C))}`)}catch{}},tt=()=>{if(!e.urlState)return;let C=/#timeline=(.+)$/.exec(location.hash);if(C)try{return JSON.parse(decodeURIComponent(C[1]))}catch{return}};function k(C,G,J,ee={}){let ue=i(u,rt(),C,G);b=ue.warnings;let Oe=u?[]:d.source?[...ne].filter(([,Ue])=>d.source.includes(Ue.source)).map(([Ue])=>Ue):void 0;return{timeline:1,type:"query",scope:c,depth:f,from:ue.from,to:ue.to,tz:n,...J.kind==="binned"?{bin:J.bin}:{},...u?{q:u,where:ue.where}:{},...Object.keys(d).length?{filters:d}:{},...Oe?{series:Oe}:{},...ee}}let _=()=>JSON.stringify([c,f,u,d,Ye()]);async function z(C=!1){let G=Ye(),J=_(),ee=m.t1-m.t0;if(!C&&y&&J===N.key&&m.t0>=N.from&&m.t1<=N.to){re();return}if(L){w=!0;return}L++;let ue=m.t0-ee/2,Oe=Math.min(m.t1+ee/2,Math.max(m.t1,rt()+ee*.1));try{let Ue=await e.source.query(k(ue,Oe,G,G.kind==="single"?{limit:1e4}:{}));G.kind==="single"&&Ue.next&&(Ue=await e.source.query(k(ue,Oe,{kind:"binned",bin:"1m"}))),y=Ue,I=J,N={from:ue,to:Oe,mode:G,key:J}}catch(Ue){Pe.textContent=`The history couldn't be read: ${String(Ue?.message??Ue)}`}finally{L--}re(),Ee(),w&&(w=!1,z())}function oe(){let C=Qe(),G=Ye();if(j=[],h&&y){let J=new Map([...ne].map(([ee,ue])=>[ee,ue.type]));j=oi(Ka(y,G,J),m.t0,Math.min(m.t1,Math.max(m.t0,rt())),{minFrac:.15,minMs:10*wr}),G.kind==="binned"&&(j=j.filter(ee=>ee.to-ee.from>=2*tn[G.bin])),j=j.filter(ee=>!(R.has(us(ee))&&(F.get(us(ee))??1)>=1))}U=Bs(m.t0,m.t1,C,j,{cut:Yu,weights:F})}let re=()=>{T||(T=requestAnimationFrame(ke))};function ke(){T=0,oe();let C=Qe(),G=lt(),J=N.mode,ee=[],ue=Nn;for(let H of G)ee.push(ue),ue+=st(H);let Oe=Math.max(ue,Nn+ds);fe.setAttribute("width",String(C)),fe.setAttribute("height",String(Oe)),fe.setAttribute("viewBox",`0 0 ${C} ${Oe}`);let Ue=Se.scrollTop-200,gn=Se.scrollTop+(Se.clientHeight||600)+200,Me=[],ve=U.x;Me.push(nt("rect",{class:"tlx-axis",x:0,y:0,width:C,height:Nn}));let Pt=(y?.retention??[]).map(H=>({r:H,from:J.kind==="binned"?H.keptFrom.rollups[J.bin]??H.keptFrom.events:H.keptFrom.events,days:J.kind==="binned"?H.rollups[J.bin]:H.events})).filter(H=>H.from!==void 0);if(Pt.length){let H=Math.min(...Pt.map(pe=>pe.from));H>m.t0&&Me.push(nt("rect",{class:"tlx-notkept",x:Math.max(0,ve(m.t0)),y:Nn,width:Math.max(0,ve(H)-Math.max(0,ve(m.t0))),height:Oe-Nn},`Nothing kept before ${Lt(H,n)}: ${Pt.map(pe=>`${pe.r.source} ${pe.days===null?"kept until deleted":`kept ${pe.days} days`}`).join(", ")}`))}let Vt=rt();Vt<m.t1&&Me.push(nt("rect",{class:"tlx-future",x:ve(Vt),y:Nn,width:C-ve(Vt),height:Oe-Nn}));for(let H of ii(U,n,90)){Me.push(nt("line",{class:`tlx-tick${H.major?" major":""}`,x1:H.x,x2:H.x,y1:Nn-6,y2:Oe}));let pe=nt("text",{class:"tlx-ticklabel",x:H.x+3,y:16});pe.textContent=H.label,Me.push(pe)}E&&Me.push(nt("rect",{class:"tlx-brush",x:ve(E.from),y:0,width:Math.max(1,ve(E.to)-ve(E.from)),height:Oe}));let Sr=J.kind==="single"?(y?.events??[]).filter(H=>H.dur!==void 0||H.open):y?.spans??[],hf=J.kind==="single"?(y?.events??[]).filter(H=>H.dur===void 0&&!H.open):[],Ga=new Map;G.forEach((H,pe)=>{H.kind==="row"&&Ga.set(H.row.scope,pe)});let Mr=H=>{let pe=Nt(c)+f,_e=Nt(H)>=pe?Bn(H,pe):H;return Ga.get(_e)},_s=H=>ee[H]+st(G[H])>=Ue&&ee[H]<=gn;if(G.forEach((H,pe)=>{_s(pe)&&Me.push(nt("rect",{class:`tlx-lane${pe%2?" odd":""}${H.kind==="metric"?" metric":""}`,x:0,y:ee[pe],width:C,height:st(H)}))}),J.kind==="binned"){let H=new Map;for(let pe of y?.bins??[]){let _e=Mr(pe.scope);_e!==void 0&&H.set(_e,Math.max(H.get(_e)??0,pe.count))}for(let pe of y?.bins??[]){let _e=Mr(pe.scope);if(_e===void 0||!_s(_e))continue;let qe=ve(pe.t),Ke=ve(pe.t+tn[pe.bin]);if(Ke<0||qe>C)continue;let ft=[...jt].reverse().find(Ht=>(pe.severity[Ht]??0)>0)??"info",Tt=Math.max(2,(ds-8)*Math.sqrt(pe.count)/Math.sqrt(H.get(_e)||1));Me.push(nt("rect",{class:"tlx-countbar",x:qe,y:ee[_e]+ds-3-Tt,width:Math.max(1,Ke-qe-.5),height:Tt,"data-t":pe.t},`${Lt(pe.t,n)}: ${pe.count} event${pe.count===1?"":"s"}${ft!=="info"&&ft!=="debug"?`, the worst ${ft}`:""}`)),(ft==="warning"||ft==="error")&&Me.push(nt("rect",{class:`tlx-heat sev-${ft}`,x:qe,y:ee[_e]+ds-(ft==="error"?4:3),width:Math.max(1,Ke-qe-.5),height:ft==="error"?3:2}))}}for(let H of Sr){let pe=Mr(H.scope);if(pe===void 0||!_s(pe))continue;let _e=H.open?Vt:H.t+(H.dur??0),qe=ve(H.t),Ke=ve(_e);if(Ke<-2||qe>C+2)continue;let ft=`tlx-span sev-${H.severity}${H.open?" open":""}${O?.id===H.id?" selected":""}`,Tt=`${H.summary} \xB7 ${Lt(H.t,n)}${H.open?", still going":`, ${za(_e-H.t)}`}`,Ht=ee[pe]+5,Dn=J.kind==="binned"?4:8,Wt=qe;for(let on of U.cuts)on.weight>=1||on.x1<=qe||on.x0>=Ke||(on.x0>Wt&&Me.push(nt("rect",{class:ft,x:Wt,y:Ht,width:Math.max(1,on.x0-Wt),height:Dn,rx:2,"data-id":H.id},Tt)),Me.push(nt("path",{class:`${ft} through`,d:`M${on.x0} ${Ht+Dn/2} H${on.x1}`,"data-id":H.id},`${Tt} (lasted through the break)`)),Wt=on.x1);Ke>Wt&&Me.push(nt("rect",{class:ft,x:Math.max(-2,Wt),y:Ht,width:Math.max(2,Math.min(C+2,Ke)-Math.max(-2,Wt)),height:Dn,rx:2,"data-id":H.id},Tt))}let Ua=new Map;for(let H of hf){let pe=Mr(H.scope);if(pe===void 0||!_s(pe))continue;let _e=ve(H.t);if(_e<-6||_e>C+6||_e-(Ua.get(pe)??-1/0)<3)continue;Ua.set(pe,_e);let qe=ee[pe]+ds/2+2,Ke=4,ft=Hu[H.severity],Tt=ft==="diamond"?`M${_e} ${qe-Ke-1} l${Ke+1} ${Ke+1} l${-Ke-1} ${Ke+1} l${-Ke-1} ${-Ke-1} z`:ft==="triangle"?`M${_e} ${qe-Ke-1} l${Ke+1} ${2*Ke+1} h${-2*Ke-2} z`:ft==="square"?`M${_e-Ke+.5} ${qe-Ke+.5} h${2*Ke-1} v${2*Ke-1} h${-2*Ke+1} z`:"",Ht=`${Lt(H.t,n)} \xB7 ${H.summary}`,Dn=`tlx-mark sev-${H.severity}${O?.id===H.id?" selected":""}${g>=0&&v[g]?.id===H.id?" hit":""}`;Me.push(Tt?nt("path",{class:Dn,d:Tt,"data-id":H.id},Ht):nt("circle",{class:Dn,cx:_e,cy:qe,r:ft==="dot"?2.5:Ke,"data-id":H.id},Ht))}G.forEach((H,pe)=>{if(H.kind!=="metric"||!_s(pe))return;let _e=new Map;for(let Je of y?.metrics??[]){if(Je.series!==H.series)continue;let At="value"in Je?{min:Je.value,max:Je.value,sum:Je.value,count:1}:{min:Je.min,max:Je.max,sum:Je.sum,count:Je.count},vt=_e.get(Je.t);vt?(vt.min=Math.min(vt.min,At.min),vt.max=Math.max(vt.max,At.max),vt.sum+=At.sum,vt.count+=At.count):_e.set(Je.t,{...At})}let qe=[..._e].sort((Je,At)=>Je[0]-At[0]);if(!qe.length)return;let Ke=J.kind==="binned"?tn[J.bin]:wr,ft=Je=>H.type==="gauge"?Je.sum/Math.max(1,Je.count):Je.sum,Tt=Math.max(1e-9,...qe.map(([,Je])=>H.type==="gauge"?Je.max:ft(Je))),Ht=ee[pe]+fi-4,Dn=fi-10,Wt=Je=>Ht-Je/Tt*Dn;if(H.type==="gauge"){let Je=qe.map(([At,vt])=>`${ve(At)},${Wt(vt.max)}`).join(" ")+" "+[...qe].reverse().map(([At,vt])=>`${ve(At)},${Wt(vt.min)}`).join(" ");Me.push(nt("polygon",{class:"tlx-band",points:Je})),Me.push(nt("polyline",{class:"tlx-line",points:qe.map(([At,vt])=>`${ve(At+Ke/2)},${Wt(ft(vt))}`).join(" ")}))}else{let Je="",At=-1/0;for(let[vt,gf]of qe){let bf=ve(vt),qa=ve(vt+Ke),Ya=Wt(ft(gf));Je+=vt>At?`M${bf} ${Ht} V${Ya} H${qa}`:` V${Ya} H${qa}`,At=vt+Ke;let Ha=qe.find(([yf])=>yf>vt);(!Ha||Ha[0]>At)&&(Je+=` V${Ht} Z`)}Me.push(nt("path",{class:"tlx-area",d:Je}))}let on=nt("text",{class:"tlx-peak",x:4,y:ee[pe]+11});on.textContent=`peak ${Wu(Tt,H.unit)}${H.type==="counter"?` per ${J.kind==="binned"?J.bin:"1m"}`:""}`,Me.push(on)});for(let H of U.cuts){if(H.weight>=1)continue;let pe=Ke=>{let ft=`M${Ke} 0`;for(let Tt=0;Tt<Oe;Tt+=8)ft+=` L${Ke+(Tt/8%2?-3:3)} ${Tt+8}`;return ft},_e=nt("g",{class:"tlx-cut",tabindex:0,role:"button","data-from":H.from,"data-to":H.to,"aria-label":`A break of ${fs(H.to-H.from)} with nothing shown, from ${Lt(H.from,n)} to ${Lt(H.to,n)}: press to open it`},`${fs(H.to-H.from)} with nothing here: ${Lt(H.from,n)} to ${Lt(H.to,n)} (click to open)`);_e.append(nt("rect",{class:"tlx-cut-bg",x:H.x0,y:0,width:H.x1-H.x0,height:Oe})),_e.append(nt("path",{class:"tlx-cut-edge",d:pe(H.x0+3)}),nt("path",{class:"tlx-cut-edge",d:pe(H.x1-3)}));let qe=nt("text",{class:"tlx-cut-label",x:(H.x0+H.x1)/2,y:15,"text-anchor":"middle"});qe.textContent=fs(H.to-H.from),_e.append(qe),Me.push(_e)}if(M!==void 0){let H=ve(M);Me.push(nt("line",{class:"tlx-playhead",x1:H,x2:H,y1:0,y2:Oe})),Me.push(nt("path",{class:"tlx-handle",d:`M${H-6} 0 h12 v8 l-6 7 l-6 -7 z`},`the playhead: ${Lt(M,n)}`))}fe.replaceChildren(...Me),Be.replaceChildren(Q("div",{class:"tlx-labelhead",style:`height:${Nn}px`},Ye().kind==="single"?"single events":`per ${Ye().kind==="binned"?Ye().bin:""}`),...G.map(H=>{if(H.kind==="metric")return Q("div",{class:"tlx-rowlabel metric",style:`height:${fi}px`,title:`${H.title} (${H.type==="counter"?"sums":"min, max and mean"})`},H.title);let pe=H.row,_e=Q("div",{class:`tlx-rowlabel${pe.own?" own":""}`,style:`height:${ds}px`,"data-scope":pe.scope,title:`${pe.scope||"all hosts"} \xB7 ${pe.count} event${pe.count===1?"":"s"}`},Q("span",{class:"tlx-kind"},e.catalog.flags.find(qe=>pe[qe])??pe.kind),Q("span",{class:"tlx-name"},pe.own?`${pe.label} (itself)`:pe.label),Q("span",{class:"tlx-count"},String(pe.count)));if(!pe.own&&pe.scope!==c){let qe=Q("button",{type:"button",class:"tlx-drill",title:pe.children?`Into ${pe.label}: its ${pe.children} part${pe.children===1?"":"s"}`:`Into ${pe.label}`,"aria-label":`Into ${pe.label}`},"\u203A");qe.addEventListener("click",()=>We(pe.scope)),_e.append(qe)}return _e})),Be.style.width=`${qu}px`,he()}function he(){V.replaceChildren(...Is(c).flatMap((ee,ue,Oe)=>{let Ue=Q("button",{type:"button",class:`tlx-crumb${ue===Oe.length-1?" current":""}`,"aria-current":ue===Oe.length-1?"location":void 0},je(ee.scope,ee.label));return Ue.addEventListener("click",()=>{ee.scope!==c&&(c=ee.scope,f=1,z(!0))}),ue?[Q("span",{class:"tlx-sep","aria-hidden":"true"},"/"),Ue]:[Ue]})),Z.setAttribute("aria-pressed",String(p)),Z.classList.toggle("on",p),A.hidden=!p||x;let C=Ye(),G=y?.total??0,J=(y?.retention??[]).filter(ee=>ee.events!==null).map(ee=>`${ee.source} kept ${ee.events} d`);Pe.textContent=`${Lt(m.t0,n)} \u2013 ${Lt(m.t1,n)} \xB7 ${C.kind==="single"?"single events":`bins of ${C.bin}`} \xB7 ${G} event${G===1?"":"s"}${j.length?` \xB7 ${j.length} break${j.length===1?"":"s"}`:""}${J.length?` \xB7 ${J.slice(0,3).join(", ")}`:""}`,le.hidden=!b.length,le.textContent=b.join(" \xB7 "),X.textContent=u?v.length?`${g+1>0?`${g+1} of `:""}${v.length}${v.length>=2e3?"+":""} hit${v.length===1?"":"s"}`:`${G?`${G} hit${G===1?"":"s"}`:"no hits"}`:"";for(let ee of q.querySelectorAll(".seg"))ee.classList.remove("on");ae.textContent=M===void 0?"":$?(()=>{let ee=e.stamp?.($)??{};return`Canvas: the state recorded at ${Lt(Date.parse(ee.at??"")||M,n)}${ee.tag?` (${ee.tag})`:""}`})():"No state recorded here",ae.classList.toggle("none",M!==void 0&&!$)}function He(){Fe.replaceChildren();for(let C of l?.sources??[]){let G=!d.source?.length||d.source.includes(C.name),J=Q("button",{type:"button",class:`tlx-chip${G?" on":""}${C.status==="not-yet"?" notyet":""}`,"aria-pressed":String(G&&C.status!=="not-yet"),disabled:C.status==="not-yet",title:C.status==="not-yet"?`${C.title}: not kept yet`:`${C.title}${$e(C)}`},C.name);C.status!=="not-yet"&&J.addEventListener("click",()=>be(C.name)),Fe.append(J)}}let $e=C=>{let G=l?.retention.find(J=>J.source===C.name);return G?` (kept ${G.events===null?"until deleted":`${G.events} days`})`:""};function be(C){let G=(l?.sources??[]).filter(ee=>ee.status==="kept").map(ee=>ee.name),J=d.source?.length?[...d.source]:[...G];J=J.includes(C)?J.filter(ee=>ee!==C):[...J,C],d={...d,...J.length===G.length?{source:void 0}:{source:J}},d.source||delete d.source,He(),z(!0),Ie()}let Ae=0;de.addEventListener("input",()=>{clearTimeout(Ae),Ae=setTimeout(()=>{u=de.value.trim(),g=-1,z(!0),Ie()},250)}),de.addEventListener("keydown",C=>{C.key==="Enter"&&(C.preventDefault(),clearTimeout(Ae),u=de.value.trim(),z(!0).then(()=>Ie()).then(()=>ot(C.shiftKey?-1:1)))});async function Ie(){if(!u){v=[],g=-1,he();return}let C=m.t1-m.t0;v=(await e.source.query(k(m.t0-C*4,Math.max(m.t1+C*4,rt()),{kind:"single"},{limit:2e3}))).events??[],g=Math.min(g,v.length-1),he()}function ot(C){if(!v.length)return;let G=(m.t0+m.t1)/2;g<0?g=C>0?Math.max(0,v.findIndex(ue=>ue.t>=G)):Math.max(0,v.length-1-[...v].reverse().findIndex(ue=>ue.t<=G)):g=(g+C+v.length)%v.length;let J=v[g],ee=Math.min(m.t1-m.t0,2*ps);m={t0:J.t-ee/2,t1:J.t+ee/2},x=!1,ct(J),z()}te.addEventListener("click",()=>ot(-1)),ye.addEventListener("click",()=>ot(1)),S.addEventListener("change",()=>{let C=S.value;d={...d,...C?{severity:jt.filter(G=>tf(G)>=tf(C))}:{}},C||delete d.severity,z(!0),Ie()});async function Zn(C,G=!0){let J=rt();if(C==="run"){let ee=await e.source.query({timeline:1,type:"query",scope:c,depth:0,from:J-30*Yt,to:J+1,filters:{kind:["run"]},limit:1e4}).catch(()=>{}),ue=ee?.events?.[ee.events.length-1];m=ue?{t0:ue.t-(ue.dur??ps)*.02,t1:(ue.open?J:ue.t+(ue.dur??ps))+(ue.dur??ps)*.04}:{t0:J-Yt,t1:J+Yt*.02}}else m={t0:J-ef[C],t1:J+ef[C]*.02};x=!0,R.clear(),F.clear(),G&&z()}function ht(C,G=!0){if(p=C,P?.(),P=void 0,C&&e.source.subscribe){let J=0,ee=0;P=e.source.subscribe(k(rt()-ps,rt()+365*Yt,{kind:"single"}),ue=>{if(l&&(l.now=Math.max(l.now,ue.now)),x){let Ue=m.t1-m.t0;m={t0:ue.now-Ue*.98,t1:ue.now+Ue*.02}}let Oe=Date.now();Oe-J>500?(J=Oe,z(!0)):ee||(ee=setTimeout(()=>{ee=0,J=Date.now(),z(!0)},500))}),x=!0}G&&(he(),Ee())}Z.addEventListener("click",()=>ht(!p)),A.addEventListener("click",()=>{x=!0;let C=m.t1-m.t0,G=rt();m={t0:G-C*.98,t1:G+C*.02},z()}),D.addEventListener("click",()=>{Ze()}),K.addEventListener("change",()=>{h=K.checked,R.clear(),F.clear(),re(),Ee()}),ie.addEventListener("change",()=>{W=ie.checked,re(),Ee()});function We(C){let G=y?.rows.find(J=>J.scope===C);c=C,f=G&&G.children===0?0:1,E=void 0,Ve.hidden=!0,z(!0)}async function Ze(){let C=rt(),J=((await e.source.query({timeline:1,type:"query",scope:c,depth:0,from:C-400*Yt,to:C+1,bin:"1d",tz:n}).catch(()=>{}))?.bins??[]).map(ue=>ue.t),ee=J.length?Math.min(...J):C-7*Yt;m={t0:ee,t1:C+(C-ee)*.02},x=!0,z()}let sn=0;async function Mt(C){if(M=C,re(),C===void 0){$=void 0;return}let G=++sn,J=e.source.stateAt?await e.source.stateAt(c,C).catch(()=>{}):void 0;G===sn&&($=J,e.onPlayhead?.(C,J),he())}async function wt(C,G){E={from:Math.min(C,G),to:Math.max(C,G)},re();let J=await e.source.query(k(E.from,E.to,{kind:"single"},{limit:500})),ee=o(u),ue=Me=>{let ve=[],bt=0;for(let[Pt,Vt]of xr(ee,Me))ve.push(Me.slice(bt,Pt),Q("mark",null,Me.slice(Pt,Vt))),bt=Vt;return ve.push(Me.slice(bt)),ve},Oe=(J.events??[]).map(Me=>{let ve=Q("tr",{"data-id":Me.id,tabindex:"0"},Q("td",null,Lt(Me.t,n)),Q("td",null,Me.dur!==void 0?za(Me.dur):Me.open?"still going":""),Q("td",null,Me.source),Q("td",null,Me.kind),Q("td",{class:`sev-${Me.severity}`},Me.severity),Q("td",{class:"tlx-sum"},...ue(Me.summary)),Q("td",{class:"tlx-scope"},Me.scope));return ve.addEventListener("click",()=>ct(Me)),ve.addEventListener("keydown",bt=>{bt.key==="Enter"&&ct(Me)}),ve}),Ue=Q("button",{type:"button",class:"btn sm quiet","aria-label":"Close the table"},"Close");Ue.addEventListener("click",()=>{E=void 0,Ve.hidden=!0,re()});let gn=Me=>{let ve=Q("button",{type:"button",class:"btn sm","data-export":Me},Me.toUpperCase());return ve.addEventListener("click",()=>{$t(Me)}),ve};Ve.replaceChildren(Q("div",{class:"tlx-table-head"},Q("strong",null,`${J.total} event${J.total===1?"":"s"}`),Q("span",null,` ${Lt(E.from,n)} \u2013 ${Lt(E.to,n)}${J.total>500?" (the first 500 shown; the export has them all)":""}`),Q("span",{class:"spacer"}),Q("span",null,"Export: "),gn("json"),gn("csv"),Ue),Q("div",{class:"tlx-table-wrap"},Q("table",null,Q("thead",null,Q("tr",null,...["When","Long","Source","Kind","Severity","What","Scope"].map(Me=>Q("th",{scope:"col"},Me)))),Q("tbody",null,...Oe)))),Ve.hidden=!1}async function kt(){if(!E)return[];let C=[],G;do{let J=await e.source.query(k(E.from,E.to,{kind:"single"},{limit:1e4,...G?{cursor:G}:{}}));C.push(...J.events??[]),G=J.next}while(G&&C.length<2e5);return C}async function $t(C){let G=await kt(),J=C==="json"?ai(G,B):li(G,B),ee=`timeline-${new Date(E.from).toISOString().slice(0,16).replace(/:/g,"")}.${C}`,ue=C==="json"?"application/json":"text/csv";if(e.onExport){e.onExport(ee,J,ue);return}let Oe=Q("a",{href:`data:${ue};charset=utf-8,${encodeURIComponent(J)}`,download:ee});document.body.append(Oe),Oe.click(),Oe.remove()}function ct(C){if(O=C,re(),!C){Te.hidden=!0;return}let G=l?.sources.find(ve=>ve.name===C.source),J=new Set(G?.sensitive??[]),ee=o(u),ue=ve=>{let bt=[],Pt=0;for(let[Vt,Sr]of xr(ee,ve))bt.push(ve.slice(Pt,Vt),Q("mark",null,ve.slice(Vt,Sr))),Pt=Sr;return bt.push(ve.slice(Pt)),bt},Oe=(ve,bt)=>{if(!bt)return null;let Pt=Q("button",{type:"button",class:"btn sm"},ve);return Pt.addEventListener("click",bt),Pt},Ue=Object.entries(C.attrs).map(([ve,bt])=>{if(!J.has(ve))return Q("tr",null,Q("th",{scope:"row"},ve),Q("td",null,...ue(String(bt))));let Pt=Q("button",{type:"button",class:"btn sm quiet",title:"This can name a remote host, a folder or free text"},"Show"),Vt=Q("td",{class:"tlx-sensitive"},"hidden ",Pt);return Pt.addEventListener("click",()=>Vt.replaceChildren(String(bt))),Q("tr",null,Q("th",{scope:"row"},ve),Vt)}),gn=Q("button",{type:"button",class:"btn sm quiet tlx-close","aria-label":"Close"},"\xD7");gn.addEventListener("click",()=>ct(void 0));let Me=Is(C.scope).slice(1).map(ve=>{let bt=Q("button",{type:"button",class:"tlx-crumb"},je(ve.scope,ve.label));return bt.addEventListener("click",()=>We(ve.scope)),bt});Te.replaceChildren(Q("div",{class:"tlx-detail-head"},Q("strong",null,C.kind),gn),Q("p",{class:`tlx-sev sev-${C.severity}`},`${C.severity} \xB7 ${G?.title??C.source}`),Q("p",{class:"tlx-sum"},...ue(C.summary)),Q("p",null,Lt(C.t,n),C.dur!==void 0?` \xB7 ${za(C.dur)}${C.open?" so far":""}`:C.open?" \xB7 still going":""),Q("p",{class:"tlx-crumbs small"},...Me),...Ue.length?[Q("table",{class:"tlx-attrs"},Q("tbody",null,...Ue))]:[],Q("div",{class:"tlx-links"},...(e.actions?.(C)??[]).map(([ve,bt])=>Oe(ve,bt)))),Te.hidden=!1}function ms(C,G){let J=us({from:C,to:G});if(!j.find(Ue=>Ue.from===C&&Ue.to===G))return;if(R.add(J),!r){F.set(J,1),re();return}let ue=performance.now(),Oe=Ue=>{let gn=Math.min(1,(Ue-ue)/260);F.set(J,1-(1-gn)**3),ke(),gn<1&&requestAnimationFrame(Oe)};requestAnimationFrame(Oe)}let Et,es=C=>C.clientX-fe.getBoundingClientRect().left;fe.addEventListener("pointerdown",C=>{let G=es(C),J=C.clientY-fe.getBoundingClientRect().top,ee=C.target.closest?.(".tlx-cut");if(ee){C.preventDefault(),ms(Number(ee.getAttribute("data-from")),Number(ee.getAttribute("data-to")));return}fe.setPointerCapture(C.pointerId),Et={kind:J<Nn||C.shiftKey?"brush":C.target.classList.contains("tlx-handle")?"scrub":"pan",x0:G,t0:U.t(G),v0:m,moved:!1},C.preventDefault(),xe.focus({preventScroll:!0})}),fe.addEventListener("pointermove",C=>{if(!Et)return;let G=es(C);if(Math.abs(G-Et.x0)>3&&(Et.moved=!0),!!Et.moved)if(Et.kind==="pan"){let J=(Et.x0-G)*U.msPerPx;m={t0:Et.v0.t0+J,t1:Et.v0.t1+J},x=!1,z()}else Et.kind==="scrub"?Mt(U.t(G)):(E={from:Math.min(Et.t0,U.t(G)),to:Math.max(Et.t0,U.t(G))},re())}),fe.addEventListener("pointerup",C=>{let G=Et;if(Et=void 0,!G)return;let J=es(C);if(G.kind==="brush"&&G.moved){wt(G.t0,U.t(J));return}if(G.kind==="brush"&&!G.moved){Mt(U.t(J));return}if(G.kind==="pan"&&!G.moved){let ee=C.target.closest?.("[data-id]")?.getAttribute("data-id"),ue=ee?[...y?.events??[],...y?.spans??[]].find(Oe=>Oe.id===ee):void 0;ue?(ct(ue),Mt(ue.t)):Mt(U.t(J))}}),fe.addEventListener("keydown",C=>{let G=C.target.closest?.(".tlx-cut");G&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),ms(Number(G.getAttribute("data-from")),Number(G.getAttribute("data-to"))))}),fe.addEventListener("wheel",C=>{C.preventDefault();let G=es(C);if(C.shiftKey||Math.abs(C.deltaX)>Math.abs(C.deltaY)){let J=(C.shiftKey?C.deltaY:C.deltaX)*U.msPerPx;m={t0:m.t0+J,t1:m.t1+J},x=!1}else hs(U.t(G),Math.exp(C.deltaY*.0015),G/Qe());z()},{passive:!1});function hs(C,G,J=.5){let ee=Math.min(400*Yt,Math.max(1e4,(m.t1-m.t0)*G));m={t0:C-J*ee,t1:C+(1-J)*ee},R.clear(),F.clear(),G<1&&(x=p&&m.t1>=rt())}xe.addEventListener("keydown",C=>{let G=m.t1-m.t0;if(C.key==="ArrowLeft"||C.key==="ArrowRight"){let J=G*.15*(C.key==="ArrowLeft"?-1:1);m={t0:m.t0+J,t1:m.t1+J},x=!1}else if(C.key==="+"||C.key==="=")hs((m.t0+m.t1)/2,.6);else if(C.key==="-"||C.key==="_")hs((m.t0+m.t1)/2,1/.6);else if(C.key==="n"||C.key==="N"){ot(C.shiftKey?-1:1),C.preventDefault();return}else if(C.key==="Escape")ct(void 0),E=void 0,Ve.hidden=!0;else return;C.preventDefault(),z()}),t.addEventListener("keydown",C=>{C.key==="/"&&document.activeElement!==de&&!C.target.closest("input, select, textarea")&&(C.preventDefault(),de.focus())}),Se.addEventListener("scroll",()=>re(),{passive:!0}),se.addEventListener("click",async()=>{let C=`${Is(c).slice(-1)[0].label}${u?`: ${u}`:""}`.slice(0,80);await e.saveView?.({...ce(),name:C}),await rn()});let Ce=[];async function rn(){e.views&&(Ce=await e.views(),Y.replaceChildren(Q("option",{value:""},"Saved views\u2026"),...Ce.map((C,G)=>Q("option",{value:String(G)},C.name))))}Y.addEventListener("change",()=>{let C=Ce[Number(Y.value)];C&&(Re(C),He(),z(!0)),Y.value=""});let et=typeof ResizeObserver=="function"?new ResizeObserver(()=>re()):void 0;et?.observe(xe);let Bt=(async()=>{l=await e.source.catalog(),B=l.sources.flatMap(ee=>(ee.sensitive??[]).map(ue=>`${ee.name}.${ue}`));for(let ee of l.sources)for(let ue of ee.series)ne.set(ue.name,{unit:ue.unit,type:ue.type,title:ue.title,source:ee.name});c=l.hosts.length===1?`host:${l.hosts[0].replace(/[%/:\s]/g,ee=>`%${ee.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`)}`:"";let G=l.now;m={t0:G-Yt,t1:G+Yt*.02};let J=tt()??e.view;J&&Re(J),He(),await rn(),await z(!0),u&&await Ie()})();return{el:t,ready:Bt,get view(){return ce()},setView(C){return Re(C),He(),z(!0)},setRange(C,G){return m={t0:C,t1:G},x=!1,z()},setPlayhead:Mt,setLive:ht,setTheme:a,refresh:()=>z(!0),internal:{get result(){return y},get mode(){return Ye()},get scale(){return U},get gaps(){return j},get playState(){return $},get hits(){return v},get selected(){return O},get follow(){return x},openCut:ms,showTable:wt,rangeEvents:kt,exportRange:$t,select:ct,stepHit:ot,drill:We,findHits:Ie,paint:ke,lines:lt},dispose(){P?.(),et?.disconnect(),T&&cancelAnimationFrame(T),t.replaceChildren()}}}var Ju={arrow:{d:"M0,0 L10,5 L0,10 z",refX:9},open:{d:"M0,0 L10,5 L0,10 L3,5 z",refX:9},diamond:{d:"M0,5 L5,1.5 L10,5 L5,8.5 z",refX:1}},It=t=>(Math.round(t*10)/10).toString(),sf=t=>(t??"link").replace(/[^\w-]/g,"_");function ui(t,e){let{id:n}=e,s=e.styles??{},r=t.options,o=t.bounds,i=new Map,a=(p,h)=>{let m=s[p]??{},y=h==="start"?m.start??"none":m.end??"arrow";if(y!=="none")return(i.get(p)??i.set(p,new Set).get(p)).add(y),`url(#${n}-mk-${p}-${y})`},l="",c="",f="",u="";for(let p of[...t.panels].sort((h,m)=>h.depth-m.depth)){let h=p.rect,m=p.label?me("text",{class:"pl",x:p.titleAt[0],y:p.titleAt[1]},ut(p.label)+(p.sub?me("tspan",{class:"pls",dx:10},ut(p.sub)):"")):"";l+=me("g",{class:`panel k-${p.role??"grey"}`,"data-id":p.id},me("rect",{class:"face",x:It(h.l),y:It(h.t),width:It(h.r-h.l),height:It(h.b-h.t),rx:r.panelRx})+m)}for(let p of t.links){if(!p.points.length)continue;let h=sf(p.kind);c+=me("path",{class:`conn k-${h}`,d:"M"+p.points.map(m=>`${It(m[0])},${It(m[1])}`).join(" L"),"data-id":p.id,"data-a":p.a,"data-b":p.b,"marker-start":a(h,"start"),"marker-end":a(h,"end")}),p.at&&(u+=me("text",{class:`cl k-${h}`,x:p.at.x,y:p.at.y,"text-anchor":p.at.anchor==="start"?void 0:p.at.anchor,"data-for":p.id},ut(p.at.text)))}for(let p of t.cards){let h=p.rect;f+=me("g",{class:`card k-${p.role??"grey"}${p.ghost?" ghost":""}`,"data-id":p.id,tabindex:0,role:"button","aria-label":p.sub?`${p.label}: ${p.sub}`:p.label},me("rect",{class:"face",x:It(h.l),y:It(h.t),width:r.W,height:r.H,rx:r.cardRx})+me("text",{class:"lt",x:It(h.l+14),y:It(h.t+24)},ut(p.label))+(p.sub?me("text",{class:"st",x:It(h.l+14),y:It(h.t+42)},ut(p.sub)):""))}let d="";for(let[p,h]of i)for(let m of h){let y=Ju[m];d+=me("marker",{id:`${n}-mk-${p}-${m}`,viewBox:"0 0 10 10",refX:y.refX,refY:5,markerWidth:5.4,markerHeight:5.4,orient:"auto-start-reverse"},me("path",{d:y.d,class:`mk k-${p}`}))}return me("svg",{xmlns:"http://www.w3.org/2000/svg",class:"flat",viewBox:`${It(o.l)} ${It(o.t)} ${It(o.r-o.l)} ${It(o.b-o.t)}`,role:"img","aria-label":e.title??"drawing, flat view","data-view":"2d"},(d?me("defs",{},d):"")+me("g",{class:"panels"},l)+me("g",{class:"conns"},c)+me("g",{class:"cards"},f)+me("g",{class:"labels"},u))}function rf(t={}){let e=s=>s?s.startsWith("#")||s.includes("(")?s:`var(--${s})`:"var(--ink)",n=`
359
+ `}var qu=864e5,hn=36e5,ui=(t,e)=>t.t-e.t||(t.id<e.id?-1:t.id>e.id?1:0);function An(t,e){let n=0,s=t.length;for(;n<s;){let r=n+s>>1;t[r].t<e?n=r+1:s=r}return n}var Xc=(t,e)=>{t.min=Math.min(t.min,e.min),t.max=Math.max(t.max,e.max),t.sum+=e.sum,t.count+=e.count};function Wc(t,e,n){let s=[];for(let r of t){let o=cs(r.t,e,n),i=s[s.length-1];i&&i.t===o?Xc(i,r):s.push({t:o,min:r.min,max:r.max,sum:r.sum,count:r.count})}return s}function ja(t,e,n,s){for(let i=An(t,e.t);i<t.length&&t[i].t===e.t;i++)if(n(t[i])){t[i]=e;return}let r=t[t.length-1];if(!r||s(r,e)<=0){t.push(e);return}let o=An(t,e.t);for(;o<t.length&&s(t[o],e)<0;)o++;t.splice(o,0,e)}function Jc(t,e,n){for(let s=An(t,e);s<t.length&&t[s].t===e;s++)if(n(t[s])){t.splice(s,1);return}}function Qc(t,e,n={}){let s=t.catalog,{isScope:r}=ni(e),{parseSearch:o,matchAst:i,toAst:a}=Fs(e),l=S=>Object.fromEntries(e.flags.filter(Y=>S?.[Y]).map(Y=>[Y,!0])),c=n.now??s.now,f=(s.names??[]).flatMap(S=>(S.aliases??[]).map(Y=>[Y,S.scope])).sort((S,Y)=>Y[0].length-S[0].length),u=new Map,d=S=>{if(!f.length)return S;let Y=u.get(S);if(Y===void 0){let se=f.find(([le])=>Vt(S,le));Y=se?se[1]+S.slice(se[0].length):S,u.set(S,Y)}return Y},p=new Map((s.names??[]).map(S=>[S.scope,S])),h=S=>f.length?{...S,scope:d(S.scope)}:S,m=S=>`${S.source}\0${S.id}`,y=t.events.map(h).sort(ui),I=new Map;for(let S of y)I.set(m(S),S);let N=y.filter(S=>S.dur!==void 0&&!S.open),M=N.reduce((S,Y)=>Math.max(S,Y.dur),0),$=new Map;for(let S of y)S.open&&$.set(m(S),S);let R=new Map,E=new Set,w=S=>{for(let Y=Nt(S);Y>=1;Y--){let se=Bn(S,Y);if(E.has(se))break;E.add(se)}},T=new Map;for(let S of s.sources)for(let Y of S.series)T.set(Y.name,Y.type);let L=s.sources.flatMap(S=>(S.sensitive??[]).map(Y=>`${S.name}.${Y}`)),x=new Map;for(let S of s.sources)x.set(S.name,{events:S.defaultRetention.events,rollups:{...S.defaultRetention.rollups},setBy:"default"});for(let S of s.retention)x.set(S.source,{events:S.events,rollups:{...S.rollups},setBy:S.setBy});let P=new Map;for(let S of s.sources)for(let Y of S.series)P.set(Y.name,S.name);function b(S){let Y=d(S.scope),se=`${S.series}\0${Y}`,le=R.get(se);le||(le={series:S.series,scope:Y,fine:[],cache:new Map},R.set(se,le),w(Y));let Pe="value"in S?{t:S.t,min:S.value,max:S.value,sum:S.value,count:1}:{t:S.t,min:S.min,max:S.max,sum:S.sum,count:S.count};ja(le.fine,Pe,ae=>ae.t===Pe.t,(ae,Be)=>ae.t-Be.t),le.cache.clear()}for(let S of y)w(S.scope);for(let S of t.metrics)b(S);let v=new Map,g=new Set,O=(S,Y)=>{g.add(S.source);let se=v.get(S.scope);se||v.set(S.scope,se=new Map);let le=se.get(S.source);le||se.set(S.source,le=new Map);let Pe=Math.floor(S.t/hn)*hn,ae=le.get(Pe);if(ae||le.set(Pe,ae={t:Pe,count:0,severity:{},kinds:{},first:1/0,last:-1/0}),ae.count+=Y,Y>0)ae.first=Math.min(ae.first,S.t),ae.last=Math.max(ae.last,S.t);else if(S.t===ae.first||S.t===ae.last){ae.first=1/0,ae.last=-1/0;for(let Be=An(y,Pe);Be<y.length&&y[Be].t<Pe+hn;Be++){let xe=y[Be];xe.scope===S.scope&&xe.source===S.source&&(ae.first=Math.min(ae.first,xe.t),ae.last=Math.max(ae.last,xe.t))}}ae.severity[S.severity]=(ae.severity[S.severity]??0)+Y,ae.kinds[S.kind]=(ae.kinds[S.kind]??0)+Y,ae.severity[S.severity]===0&&delete ae.severity[S.severity],ae.kinds[S.kind]===0&&delete ae.kinds[S.kind],ae.count||le.delete(Pe)};for(let S of y)O(S,1);let F=(S,Y,se)=>{let le=`${Y}|${se??""}`,Pe=S.cache.get(le);return Pe||(Pe=Y==="1d"?Wc(F(S,"1h",se),"1d",se):Wc(S.fine,Y,se),S.cache.set(le,Pe)),Pe},j=S=>S===null?-1/0:c-S*qu,U=S=>j(x.get(S)?.events??null),ne=(S,Y)=>{let se=x.get(S);return j(se?Y?se.rollups[Y]:se.events:null)};function B(S){let Y=[];for(let se of new Set(S)){let le=x.get(se);if(!le)continue;let Pe=y.find(fe=>fe.source===se&&fe.t>=U(se))?.t,ae=fe=>{let Se=1/0;for(let Ke of R.values())if(P.get(Ke.series)===se){let Te=(fe?F(Ke,fe):Ke.fine).find(Qe=>Qe.t>=ne(se,fe));Te&&Te.t<Se&&(Se=Te.t)}return Se===1/0?void 0:Se},Be=[Pe,ae()].filter(fe=>fe!==void 0),xe={};for(let fe of["1m","1h","1d"]){let Se=ae(fe)??(Pe!==void 0&&Pe>=ne(se,fe)?Pe:void 0);Se!==void 0&&(xe[fe]=Math.max(Se,ne(se,fe)))}Y.push({source:se,events:le.events,rollups:{...le.rollups},setBy:le.setBy,keptFrom:{...Be.length?{events:Math.min(...Be)}:{},rollups:xe}})}return Y}function K(S){let Y=S.where,se={from:S.from,to:S.to},le=[];if(!Y&&S.q){let Te=o(S.q,c);Y=a(Te),se=yr(Te,S.from,S.to),le=Te.warnings}let Pe=i(Y,L),ae=S.filters??{},Be=ae.source?.length?new Set(ae.source):void 0,xe=ae.kind?.length?new Set(ae.kind):void 0,fe=ae.severity?.length?new Set(ae.severity):void 0,Se=ae.scope?.length?ae.scope:void 0;return{test:Te=>Vt(Te.scope,S.scope)&&(!Be||Be.has(Te.source))&&(!xe||xe.has(Te.kind))&&(!fe||fe.has(Te.severity))&&(!Se||Se.some(Qe=>Vt(Te.scope,Qe)))&&Te.t>=U(Te.source)&&Pe(Te),range:se,warnings:le}}function q(S){let Y=Nt(S.scope),se=Y+S.depth,le=new Map,Pe=fe=>{let Se=le.get(fe);return Se===void 0&&!le.has(fe)&&(Se=Vt(fe,S.scope)?Nt(fe)>=se?Bn(fe,se):fe:void 0,le.set(fe,Se)),Se},ae=fe=>{let Se=0,Ke=Nt(fe)+1;for(let Te of E)Nt(Te)===Ke&&Vt(Te,fe)&&Se++;return Se},Be=new Map,xe=fe=>{let Se=Be.get(fe);if(!Se){let Ke=Nt(fe)-Y,Te=p.get(fe);Se={scope:fe,label:Te?.label??Ls(fe),kind:Cs(fe),...l(Te),depth:Ke,...Ke<S.depth?{own:!0}:{},children:ae(fe),count:0},Be.set(fe,Se)}return Se};for(let fe of E)Nt(fe)===se&&Vt(fe,S.scope)&&xe(fe);return se===0&&xe(""),{at:Pe,add:xe,rows:Be}}let Z=S=>[...S.values()].sort((Y,se)=>Y.scope===se.scope?0:Y.scope<se.scope?-1:1);function A(S,Y){let se=[];for(let le=An(N,S-M);le<N.length&&N[le].t<S;le++)N[le].t+N[le].dur>S&&se.push(N[le]);for(let le of $.values())le.t<S&&c>S&&se.push(le);for(let le=An(y,S);le<y.length&&y[le].t<Y;le++)se.push(y[le]);return se}function D(S,Y,se,le){let Pe=S.series?new Set(S.series):void 0,ae=new Map;for(let xe of R.values()){if(Pe&&!Pe.has(xe.series))continue;let fe=Y(xe.scope);if(fe===void 0)continue;let Se=P.get(xe.series)??"",Ke=ne(Se,S.bin),Te=S.bin?F(xe,S.bin,S.tz):xe.fine;for(let Qe=An(Te,S.bin?cs(se,S.bin,S.tz):se);Qe<Te.length&&Te[Qe].t<le;Qe++){let lt=Te[Qe];if(lt.t<Ke)continue;let je=`${xe.series}\0${fe}\0${lt.t}`,st=ae.get(je);st?Xc(st,lt):ae.set(je,{series:xe.series,scope:fe,t:lt.t,bin:S.bin??"1m",min:lt.min,max:lt.max,sum:lt.sum,count:lt.count})}}let Be=[...ae.values()].sort((xe,fe)=>xe.t-fe.t||(xe.series<fe.series?-1:1)||(xe.scope<fe.scope?-1:1));return S.bin?Be:Be.map(xe=>({series:xe.series,scope:xe.scope,t:xe.t,value:xe.count===1||T.get(xe.series)!=="gauge"?xe.sum:xe.sum/xe.count}))}let V=S=>`${S.t}:${S.id}`,W=(S,Y)=>{let se=Y.indexOf(":"),le=Number(Y.slice(0,se)),Pe=Y.slice(se+1);return S.t>le||S.t===le&&S.id>Pe};function ie(S){if(S.bin!=="1h"&&S.bin!=="1d"||(S.where?.all.length??0)||S.q||S.filters?.kind?.length||S.filters?.severity?.length||S.filters?.scope?.length||Ct(S.tz,S.from)%hn||Ct(S.tz,S.to)%hn)return;let Y=S.filters?.source?.length?new Set(S.filters.source):void 0,se=ce=>Math.max(S.from,U(ce)),{at:le,add:Pe,rows:ae}=q(S),Be=new Set,xe=new Map,fe=0,Se=(ce,Oe)=>{let Ee=cs(Oe,S.bin,S.tz),tt=`${ce}\0${Ee}`,k=xe.get(tt);return k||(k={scope:ce,t:Ee,bin:S.bin,count:0,severity:{},kinds:{}},xe.set(tt,k)),k},Ke=(ce,Oe,Ee)=>{let tt=Pe(ce);tt.count+=Ee,fe+=Ee,(tt.first===void 0||Oe<tt.first)&&(tt.first=Oe),(tt.last===void 0||Oe>tt.last)&&(tt.last=Oe)},Te=Math.floor(S.to/hn)*hn;for(let[ce,Oe]of v){let Ee=le(ce);if(Ee!==void 0)for(let[tt,k]of Oe){if(Y&&!Y.has(tt))continue;let _=Math.ceil(se(tt)/hn)*hn;for(let[z,oe]of k){if(z<_||z>=Te)continue;Ke(Ee,oe.first,oe.count),oe.last>(ae.get(Ee).last??-1/0)&&(ae.get(Ee).last=oe.last),Be.add(tt);let re=Se(Ee,z);re.count+=oe.count;for(let[ke,he]of Object.entries(oe.severity))re.severity[ke]=(re.severity[ke]??0)+he;for(let[ke,he]of Object.entries(oe.kinds))re.kinds[ke]=(re.kinds[ke]??0)+he}}}let Qe=ce=>Vt(ce.scope,S.scope)&&(!Y||Y.has(ce.source))&&ce.t>=U(ce.source)&&le(ce.scope)!==void 0,lt=ce=>{let Oe=le(ce.scope);Ke(Oe,ce.t,1),Be.add(ce.source);let Ee=Se(Oe,ce.t);Ee.count++,Ee.severity[ce.severity]=(Ee.severity[ce.severity]??0)+1,Ee.kinds[ce.kind]=(Ee.kinds[ce.kind]??0)+1};for(let ce of g){if(Y&&!Y.has(ce))continue;let Oe=se(ce),Ee=Math.ceil(Oe/hn)*hn,tt=Ee>=Te?[[Oe,S.to]]:[[Oe,Ee],[Te,S.to]];for(let[k,_]of tt)for(let z=An(y,k);z<y.length&&y[z].t<_;z++){let oe=y[z];oe.source===ce&&Qe(oe)&&lt(oe)}}let je=tn[S.bin],st=[];for(let ce=An(N,S.from-M);ce<N.length&&N[ce].t<S.from;ce++){let Oe=N[ce];Oe.t+Oe.dur>S.from&&Qe(Oe)&&(Ke(le(Oe.scope),Oe.t,1),Be.add(Oe.source),Oe.dur>=je&&st.length<5e3&&st.push(Oe))}for(let ce of $.values())ce.t<S.from&&c>S.from&&Qe(ce)&&(Ke(le(ce.scope),ce.t,1),Be.add(ce.source),st.length<5e3&&st.push(ce));for(let ce=An(N,S.from);ce<N.length&&N[ce].t<S.to&&st.length<5e3;ce++)N[ce].dur>=je&&Qe(N[ce])&&st.push(N[ce]);for(let ce of $.values())ce.t>=S.from&&ce.t<S.to&&st.length<5e3&&Qe(ce)&&st.push(ce);let Ye=D(S,le,S.from,S.to);for(let ce of Ye){let Oe=P.get(ce.series);Oe&&Be.add(Oe)}let rt=[...xe.values()].sort((ce,Oe)=>ce.t-Oe.t||(ce.scope<Oe.scope?-1:1));return{timeline:1,type:"result",rows:Z(ae),bins:rt,spans:st,metrics:Ye,total:fe,retention:B(Be)}}async function de(S){if(!r(S.scope))throw new Error(`not a scope path: ${JSON.stringify(S.scope)}`);let Y=ie(S);if(Y)return Y;let{test:se,range:le,warnings:Pe}=K(S),{at:ae,add:Be,rows:xe}=q(S),fe=new Set,Se=[];for(let Ye of A(le.from,le.to)){if(!se(Ye))continue;let rt=ae(Ye.scope);if(rt===void 0)continue;let ce=Be(rt);ce.count++,(ce.first===void 0||Ye.t<ce.first)&&(ce.first=Ye.t),(ce.last===void 0||Ye.t>ce.last)&&(ce.last=Ye.t),fe.add(Ye.source),Se.push(Ye)}Se.sort(ui);let Ke=D(S,ae,le.from,le.to);for(let Ye of Ke){let rt=P.get(Ye.series);rt&&fe.add(rt)}let Te={timeline:1,type:"result",total:Se.length,...Pe.length?{warnings:Pe}:{}};if(S.bin){let Ye=tn[S.bin],rt=new Map,ce=[];for(let Ee of Se){if((Ee.open||Ee.dur!==void 0&&Ee.dur>=Ye)&&ce.length<5e3&&ce.push(Ee),Ee.t<le.from)continue;let tt=ae(Ee.scope),k=cs(Ee.t,S.bin,S.tz),_=`${tt}\0${k}`,z=rt.get(_);z||(z={scope:tt,t:k,bin:S.bin,count:0,severity:{},kinds:{}},rt.set(_,z)),z.count++,z.severity[Ee.severity]=(z.severity[Ee.severity]??0)+1,z.kinds[Ee.kind]=(z.kinds[Ee.kind]??0)+1}let Oe=[...rt.values()].sort((Ee,tt)=>Ee.t-tt.t||(Ee.scope<tt.scope?-1:1));return{...Te,rows:Z(xe),bins:Oe,spans:ce,metrics:Ke,retention:B(fe)}}let Qe=Math.min(1e4,Math.max(1,S.limit??2e3)),lt=S.cursor?Se.findIndex(Ye=>W(Ye,S.cursor)):0,je=lt<0?[]:Se.slice(lt,lt+Qe),st=lt>=0&&lt+Qe<Se.length;return{...Te,rows:Z(xe),events:je,metrics:Ke,retention:B(fe),...st?{next:V(je[je.length-1])}:{}}}let X=new Set,te=S=>jt.includes(S),ye=0;function Fe(S){let Y=m(S),se=I.get(Y);se&&(Jc(y,se.t,le=>le===se),O(se,-1),se.dur!==void 0&&!se.open&&Jc(N,se.t,le=>le===se),$.delete(Y)),I.set(Y,S),O(S,1),ja(y,S,()=>!1,ui),S.open?$.set(Y,S):S.dur!==void 0&&(ja(N,S,()=>!1,ui),M=Math.max(M,S.dur)),w(S.scope)}return{async catalog(){return{...s,now:c,retention:B(s.sources.map(S=>S.name))}},query:de,subscribe(S,Y){let se={q:S,on:Y};return X.add(se),()=>{X.delete(se)}},...n.stateAt?{stateAt:(S,Y)=>n.stateAt(S,Y)}:{},append(S,Y=[],se){se!==void 0&&(c=Math.max(c,se));let le=new Set(E),Pe=S.map(h);for(let ae of Pe){if(!te(ae.severity))throw new Error(`not a severity: ${ae.severity}`);Fe(ae)}for(let ae of Y)b(ae);ye++;for(let ae of X){let{test:Be}=K(ae.q),{at:xe}=q(ae.q),fe=Pe.filter(je=>Be(je)&&xe(je.scope)!==void 0),Se=ae.q.series?new Set(ae.q.series):void 0,Ke=Y.filter(je=>Vt(d(je.scope),ae.q.scope)&&(!Se||Se.has(je.series))).map(je=>({...je,scope:xe(d(je.scope))})),Te=[...E].filter(je=>!le.has(je)),Qe=Nt(ae.q.scope)+ae.q.depth,lt=Te.filter(je=>Nt(je)===Qe&&Vt(je,ae.q.scope)).map(je=>({scope:je,label:p.get(je)?.label??Ls(je),kind:Cs(je),depth:ae.q.depth,children:0,count:0}));ae.on({timeline:1,type:"batch",events:fe,metrics:Ke,...lt.length?{rows:lt}:{},now:c,resume:String(ye)})}},setRetention(S,Y){x.set(S,{events:Y.events,rollups:{...Y.rollups},setBy:"user"})},get now(){return c},get size(){let S=0;for(let Y of R.values())S+=Y.fine.length;return{events:y.length,samples:S}}}}var Zc="http://www.w3.org/2000/svg",ds=22,di=38,Nn=26,Yu=210,Hu=24,wr=6e4,ps=36e5,Yt=864e5,ef={"15m":15*wr,"1h":ps,"1d":Yt,"1w":7*Yt},tf=t=>jt.indexOf(t),Wu={debug:"dot",info:"circle",notice:"square",warning:"triangle",error:"diamond"},nt=(t,e,n)=>{let s=document.createElementNS(Zc,t);for(let[r,o]of Object.entries(e))o!==void 0&&s.setAttribute(r,String(o));if(n){let r=document.createElementNS(Zc,"title");r.textContent=n,s.append(r)}return s},Lt=(t,e)=>{try{return new Intl.DateTimeFormat(void 0,{timeZone:e,dateStyle:"medium",timeStyle:"medium"}).format(t)}catch{return new Date(t).toISOString()}},Va=t=>t<1e3?`${Math.round(t)} ms`:t<wr?`${(t/1e3).toFixed(1)} s`:fs(t),Ju=(t,e)=>e==="bytes"?t>=1e9?`${(t/1e9).toFixed(1)} GB`:t>=1e6?`${(t/1e6).toFixed(1)} MB`:t>=1e3?`${(t/1e3).toFixed(1)} kB`:`${Math.round(t)} B`:`${Math.round(t*10)/10}${e==="count"?"":` ${e}`}`;function Ka(t,e){if(t<=3*ps)return{kind:"single"};for(let n of["1m","1h","1d"])if(t/tn[n]<=e/2)return{kind:"binned",bin:n};return{kind:"binned",bin:"1d"}}function Ga(t,e,n){let s=[];for(let i of t.events??[])s.push([i.t,i.t]),i.dur!==void 0&&!i.open&&s.push([i.t+i.dur,i.t+i.dur]);for(let i of t.spans??[])s.push([i.t,i.t]),i.dur!==void 0&&!i.open&&s.push([i.t+i.dur,i.t+i.dur]);let r=e.kind==="binned"?tn[e.bin]:wr;for(let i of t.bins??[])i.count&&s.push([i.t,i.t+tn[i.bin]]);let o=new Map;for(let i of t.metrics){let a="value"in i?i.value:i.sum,l=`${i.series}|${i.scope}`,c=(n?.get(i.series)??"counter")==="counter"?a!==0:o.get(l)!==a;o.set(l,a),c&&s.push([i.t,i.t+r])}return s}function nf(t,e){let n=e.tz??Intl.DateTimeFormat().resolvedOptions().timeZone,s=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,r=e.motion??!s;t.classList.add(...e.rootClass??[],"tlx");let{parseSearch:o,compileSearch:i}=Fs(e.catalog),a=(C="system")=>{t.style.colorScheme=C==="system"?"light dark":C,C==="system"?delete t.dataset.theme:t.dataset.theme=C};a(e.theme),t.setAttribute("role","region"),t.setAttribute("aria-label","Timeline");let l,c="",f=1,u="",d={},p=!1,h=e.collapseGaps??!0,m={t0:0,t1:Yt},y,I="",N={from:0,to:0,mode:{kind:"single"},key:""},M,$,R,E,w=!0,T=0,L=0,x=!1,P,b=[],v=[],g=-1,O=new Set,F=new Map,j=[],U=Bs(0,Yt,800),ne=new Map,B=[],K=Q("nav",{class:"tlx-crumbs","aria-label":"Scope"}),q=Q("div",{class:"segmented tlx-quick",role:"group","aria-label":"Range"});for(let C of["15m","1h","1d","1w","run"]){let G=Q("button",{type:"button",class:"seg","data-v":C,title:C==="run"?"The latest run":`The last ${C}`},C==="run"?"this run":C);G.addEventListener("click",()=>Zn(C)),q.append(G)}let Z=Q("button",{type:"button",class:"btn sm tlx-live","aria-pressed":"false",title:"Follow what happens now"},"Live"),A=Q("button",{type:"button",class:"btn sm quiet tlx-now",hidden:!0,title:"Back to the live edge"},"Back to now"),D=Q("button",{type:"button",class:"btn sm quiet tlx-fit",title:"Everything in this scope"},"Fit"),V=Q("input",{type:"checkbox",class:"tlx-gaps"});V.checked=h;let W=!0,ie=Q("input",{type:"checkbox",class:"tlx-quiet"});ie.checked=W;let de=Q("input",{type:"search",class:"input tlx-q",placeholder:"Search: words, kind:\u2026, source:\u2026, severity:>=warning, -kind:\u2026","aria-label":"Search the timeline",spellcheck:"false"}),X=Q("span",{class:"tlx-hits",role:"status","aria-live":"polite"}),te=Q("button",{type:"button",class:"btn sm quiet tlx-prev",title:"Previous hit (\u21E7N)","aria-label":"Previous hit"},"\u2039"),ye=Q("button",{type:"button",class:"btn sm quiet tlx-next",title:"Next hit (N)","aria-label":"Next hit"},"\u203A"),Fe=Q("div",{class:"tlx-facets",role:"group","aria-label":"Sources"}),S=Q("select",{class:"input tlx-sev","aria-label":"Severity"},Q("option",{value:""},"every severity"),...jt.slice(1).map(C=>Q("option",{value:C},`${C} and above`))),Y=Q("select",{class:"input tlx-views","aria-label":"Saved views",hidden:!e.views},Q("option",{value:""},"Saved views\u2026")),se=Q("button",{type:"button",class:"btn sm quiet tlx-save",hidden:!e.saveView,title:"Save this view"},"Save view"),le=Q("div",{class:"tlx-warn",role:"status",hidden:!0}),Pe=Q("div",{class:"tlx-status",role:"status"}),ae=Q("span",{class:"tlx-canvas-note"}),Be=Q("div",{class:"tlx-labels"}),xe=Q("div",{class:"tlx-lanes",tabindex:"0",role:"application","aria-label":"Timeline lanes: drag to pan, wheel to zoom, drag the axis to choose a range, click it to move the playhead. Keys: \u2190 \u2192 pan, + \u2212 zoom, N next hit"}),fe=nt("svg",{class:"tlx-svg"});xe.append(fe);let Se=Q("div",{class:"tlx-scroll"},Q("div",{class:"tlx-grid"},Be,xe)),Ke=Q("section",{class:"tlx-table",hidden:!0,"aria-label":"The events in the chosen range"}),Te=Q("aside",{class:"tlx-detail",hidden:!0,"aria-label":"The event"});t.replaceChildren(Q("div",{class:"tlx-bar"},K,Q("span",{class:"spacer"}),q,Z,A,D,Q("label",{class:"tlx-gaps-label",title:"Draw long empty stretches as narrow breaks"},V,"Collapse gaps"),Q("label",{class:"tlx-gaps-label",title:"Hide the rows with nothing in this range"},ie,"Hide quiet rows")),Q("div",{class:"tlx-bar"},de,X,te,ye,S,Y,se),Fe,le,Q("div",{class:"tlx-body"},Se,Te),Q("div",{class:"tlx-foot"},Pe,Q("span",{class:"spacer"}),ae),Ke);let Qe=()=>Math.max(200,xe.clientWidth||800),lt=()=>{let C=(ue,Re)=>(ue.own?-1:0)-(Re.own?-1:0)||ue.scope.localeCompare(Re.scope,void 0,{numeric:!0}),J=(y?.rows??[]).filter(ue=>!W||ue.count>0||ue.own||(y?.rows.length??0)<=1).sort(C).map(ue=>({kind:"row",row:ue})),ee=new Set(y?.metrics.map(ue=>ue.series)??[]);for(let ue of[...ee].sort()){let Re=ne.get(ue);J.push({kind:"metric",series:ue,unit:Re?.unit??"count",type:Re?.type??"counter",title:Re?.title??ue})}return J},je=(C,G)=>l?.names?.find(J=>J.scope===C)?.label??G,st=C=>C.kind==="metric"?di:ds,Ye=()=>Ka(m.t1-m.t0,Qe()),rt=()=>l?.now??Date.now();function ce(){return{timeline:1,type:"view",name:"",scope:c,depth:f,range:{from:Math.round(m.t0),to:Math.round(m.t1)},...u?{q:u}:{},...Object.keys(d).length?{filters:d}:{},...p?{live:p}:{},...h?{}:{collapseGaps:!1},...W?{}:{quietRows:!0}}}function Oe(C){C.scope!==void 0&&(c=C.scope),C.depth!==void 0&&(f=C.depth),u=C.q??"",de.value=u,d=C.filters??{},S.value=d.severity?.length?d.severity[0]:"",h=C.collapseGaps??e.collapseGaps??!0,V.checked=h,W=!C.quietRows,ie.checked=W,O.clear(),F.clear();let G=C.range;G&&"last"in G?Zn(G.last,!1):G&&(m={t0:G.from,t1:G.to}),ht(!!C.live,!1)}let Ee=()=>{let C=ce();if(e.onViewChange?.(C),!!e.urlState)try{history.replaceState(null,"",`#timeline=${encodeURIComponent(JSON.stringify(C))}`)}catch{}},tt=()=>{if(!e.urlState)return;let C=/#timeline=(.+)$/.exec(location.hash);if(C)try{return JSON.parse(decodeURIComponent(C[1]))}catch{return}};function k(C,G,J,ee={}){let ue=i(u,rt(),C,G);b=ue.warnings;let Re=u?[]:d.source?[...ne].filter(([,Ue])=>d.source.includes(Ue.source)).map(([Ue])=>Ue):void 0;return{timeline:1,type:"query",scope:c,depth:f,from:ue.from,to:ue.to,tz:n,...J.kind==="binned"?{bin:J.bin}:{},...u?{q:u,where:ue.where}:{},...Object.keys(d).length?{filters:d}:{},...Re?{series:Re}:{},...ee}}let _=()=>JSON.stringify([c,f,u,d,Ye()]);async function z(C=!1){let G=Ye(),J=_(),ee=m.t1-m.t0;if(!C&&y&&J===N.key&&m.t0>=N.from&&m.t1<=N.to){re();return}if(L){x=!0;return}L++;let ue=m.t0-ee/2,Re=Math.min(m.t1+ee/2,Math.max(m.t1,rt()+ee*.1));try{let Ue=await e.source.query(k(ue,Re,G,G.kind==="single"?{limit:1e4}:{}));G.kind==="single"&&Ue.next&&(Ue=await e.source.query(k(ue,Re,{kind:"binned",bin:"1m"}))),y=Ue,I=J,N={from:ue,to:Re,mode:G,key:J}}catch(Ue){Pe.textContent=`The history couldn't be read: ${String(Ue?.message??Ue)}`}finally{L--}re(),Ee(),x&&(x=!1,z())}function oe(){let C=Qe(),G=Ye();if(j=[],h&&y){let J=new Map([...ne].map(([ee,ue])=>[ee,ue.type]));j=ai(Ga(y,G,J),m.t0,Math.min(m.t1,Math.max(m.t0,rt())),{minFrac:.15,minMs:10*wr}),G.kind==="binned"&&(j=j.filter(ee=>ee.to-ee.from>=2*tn[G.bin])),j=j.filter(ee=>!(O.has(us(ee))&&(F.get(us(ee))??1)>=1))}U=Bs(m.t0,m.t1,C,j,{cut:Hu,weights:F})}let re=()=>{T||(T=requestAnimationFrame(ke))};function ke(){T=0,oe();let C=Qe(),G=lt(),J=N.mode,ee=[],ue=Nn;for(let H of G)ee.push(ue),ue+=st(H);let Re=Math.max(ue,Nn+ds);fe.setAttribute("width",String(C)),fe.setAttribute("height",String(Re)),fe.setAttribute("viewBox",`0 0 ${C} ${Re}`);let Ue=Se.scrollTop-200,gn=Se.scrollTop+(Se.clientHeight||600)+200,Me=[],ve=U.x;Me.push(nt("rect",{class:"tlx-axis",x:0,y:0,width:C,height:Nn}));let Pt=(y?.retention??[]).map(H=>({r:H,from:J.kind==="binned"?H.keptFrom.rollups[J.bin]??H.keptFrom.events:H.keptFrom.events,days:J.kind==="binned"?H.rollups[J.bin]:H.events})).filter(H=>H.from!==void 0);if(Pt.length){let H=Math.min(...Pt.map(pe=>pe.from));H>m.t0&&Me.push(nt("rect",{class:"tlx-notkept",x:Math.max(0,ve(m.t0)),y:Nn,width:Math.max(0,ve(H)-Math.max(0,ve(m.t0))),height:Re-Nn},`Nothing kept before ${Lt(H,n)}: ${Pt.map(pe=>`${pe.r.source} ${pe.days===null?"kept until deleted":`kept ${pe.days} days`}`).join(", ")}`))}let Kt=rt();Kt<m.t1&&Me.push(nt("rect",{class:"tlx-future",x:ve(Kt),y:Nn,width:C-ve(Kt),height:Re-Nn}));for(let H of li(U,n,90)){Me.push(nt("line",{class:`tlx-tick${H.major?" major":""}`,x1:H.x,x2:H.x,y1:Nn-6,y2:Re}));let pe=nt("text",{class:"tlx-ticklabel",x:H.x+3,y:16});pe.textContent=H.label,Me.push(pe)}E&&Me.push(nt("rect",{class:"tlx-brush",x:ve(E.from),y:0,width:Math.max(1,ve(E.to)-ve(E.from)),height:Re}));let Sr=J.kind==="single"?(y?.events??[]).filter(H=>H.dur!==void 0||H.open):y?.spans??[],hf=J.kind==="single"?(y?.events??[]).filter(H=>H.dur===void 0&&!H.open):[],qa=new Map;G.forEach((H,pe)=>{H.kind==="row"&&qa.set(H.row.scope,pe)});let Mr=H=>{let pe=Nt(c)+f,_e=Nt(H)>=pe?Bn(H,pe):H;return qa.get(_e)},_s=H=>ee[H]+st(G[H])>=Ue&&ee[H]<=gn;if(G.forEach((H,pe)=>{_s(pe)&&Me.push(nt("rect",{class:`tlx-lane${pe%2?" odd":""}${H.kind==="metric"?" metric":""}`,x:0,y:ee[pe],width:C,height:st(H)}))}),J.kind==="binned"){let H=new Map;for(let pe of y?.bins??[]){let _e=Mr(pe.scope);_e!==void 0&&H.set(_e,Math.max(H.get(_e)??0,pe.count))}for(let pe of y?.bins??[]){let _e=Mr(pe.scope);if(_e===void 0||!_s(_e))continue;let qe=ve(pe.t),Ve=ve(pe.t+tn[pe.bin]);if(Ve<0||qe>C)continue;let ft=[...jt].reverse().find(Ht=>(pe.severity[Ht]??0)>0)??"info",Tt=Math.max(2,(ds-8)*Math.sqrt(pe.count)/Math.sqrt(H.get(_e)||1));Me.push(nt("rect",{class:"tlx-countbar",x:qe,y:ee[_e]+ds-3-Tt,width:Math.max(1,Ve-qe-.5),height:Tt,"data-t":pe.t},`${Lt(pe.t,n)}: ${pe.count} event${pe.count===1?"":"s"}${ft!=="info"&&ft!=="debug"?`, the worst ${ft}`:""}`)),(ft==="warning"||ft==="error")&&Me.push(nt("rect",{class:`tlx-heat sev-${ft}`,x:qe,y:ee[_e]+ds-(ft==="error"?4:3),width:Math.max(1,Ve-qe-.5),height:ft==="error"?3:2}))}}for(let H of Sr){let pe=Mr(H.scope);if(pe===void 0||!_s(pe))continue;let _e=H.open?Kt:H.t+(H.dur??0),qe=ve(H.t),Ve=ve(_e);if(Ve<-2||qe>C+2)continue;let ft=`tlx-span sev-${H.severity}${H.open?" open":""}${R?.id===H.id?" selected":""}`,Tt=`${H.summary} \xB7 ${Lt(H.t,n)}${H.open?", still going":`, ${Va(_e-H.t)}`}`,Ht=ee[pe]+5,Dn=J.kind==="binned"?4:8,Wt=qe;for(let on of U.cuts)on.weight>=1||on.x1<=qe||on.x0>=Ve||(on.x0>Wt&&Me.push(nt("rect",{class:ft,x:Wt,y:Ht,width:Math.max(1,on.x0-Wt),height:Dn,rx:2,"data-id":H.id},Tt)),Me.push(nt("path",{class:`${ft} through`,d:`M${on.x0} ${Ht+Dn/2} H${on.x1}`,"data-id":H.id},`${Tt} (lasted through the break)`)),Wt=on.x1);Ve>Wt&&Me.push(nt("rect",{class:ft,x:Math.max(-2,Wt),y:Ht,width:Math.max(2,Math.min(C+2,Ve)-Math.max(-2,Wt)),height:Dn,rx:2,"data-id":H.id},Tt))}let Ya=new Map;for(let H of hf){let pe=Mr(H.scope);if(pe===void 0||!_s(pe))continue;let _e=ve(H.t);if(_e<-6||_e>C+6||_e-(Ya.get(pe)??-1/0)<3)continue;Ya.set(pe,_e);let qe=ee[pe]+ds/2+2,Ve=4,ft=Wu[H.severity],Tt=ft==="diamond"?`M${_e} ${qe-Ve-1} l${Ve+1} ${Ve+1} l${-Ve-1} ${Ve+1} l${-Ve-1} ${-Ve-1} z`:ft==="triangle"?`M${_e} ${qe-Ve-1} l${Ve+1} ${2*Ve+1} h${-2*Ve-2} z`:ft==="square"?`M${_e-Ve+.5} ${qe-Ve+.5} h${2*Ve-1} v${2*Ve-1} h${-2*Ve+1} z`:"",Ht=`${Lt(H.t,n)} \xB7 ${H.summary}`,Dn=`tlx-mark sev-${H.severity}${R?.id===H.id?" selected":""}${g>=0&&v[g]?.id===H.id?" hit":""}`;Me.push(Tt?nt("path",{class:Dn,d:Tt,"data-id":H.id},Ht):nt("circle",{class:Dn,cx:_e,cy:qe,r:ft==="dot"?2.5:Ve,"data-id":H.id},Ht))}G.forEach((H,pe)=>{if(H.kind!=="metric"||!_s(pe))return;let _e=new Map;for(let Je of y?.metrics??[]){if(Je.series!==H.series)continue;let At="value"in Je?{min:Je.value,max:Je.value,sum:Je.value,count:1}:{min:Je.min,max:Je.max,sum:Je.sum,count:Je.count},vt=_e.get(Je.t);vt?(vt.min=Math.min(vt.min,At.min),vt.max=Math.max(vt.max,At.max),vt.sum+=At.sum,vt.count+=At.count):_e.set(Je.t,{...At})}let qe=[..._e].sort((Je,At)=>Je[0]-At[0]);if(!qe.length)return;let Ve=J.kind==="binned"?tn[J.bin]:wr,ft=Je=>H.type==="gauge"?Je.sum/Math.max(1,Je.count):Je.sum,Tt=Math.max(1e-9,...qe.map(([,Je])=>H.type==="gauge"?Je.max:ft(Je))),Ht=ee[pe]+di-4,Dn=di-10,Wt=Je=>Ht-Je/Tt*Dn;if(H.type==="gauge"){let Je=qe.map(([At,vt])=>`${ve(At)},${Wt(vt.max)}`).join(" ")+" "+[...qe].reverse().map(([At,vt])=>`${ve(At)},${Wt(vt.min)}`).join(" ");Me.push(nt("polygon",{class:"tlx-band",points:Je})),Me.push(nt("polyline",{class:"tlx-line",points:qe.map(([At,vt])=>`${ve(At+Ve/2)},${Wt(ft(vt))}`).join(" ")}))}else{let Je="",At=-1/0;for(let[vt,gf]of qe){let bf=ve(vt),Ha=ve(vt+Ve),Wa=Wt(ft(gf));Je+=vt>At?`M${bf} ${Ht} V${Wa} H${Ha}`:` V${Wa} H${Ha}`,At=vt+Ve;let Ja=qe.find(([yf])=>yf>vt);(!Ja||Ja[0]>At)&&(Je+=` V${Ht} Z`)}Me.push(nt("path",{class:"tlx-area",d:Je}))}let on=nt("text",{class:"tlx-peak",x:4,y:ee[pe]+11});on.textContent=`peak ${Ju(Tt,H.unit)}${H.type==="counter"?` per ${J.kind==="binned"?J.bin:"1m"}`:""}`,Me.push(on)});for(let H of U.cuts){if(H.weight>=1)continue;let pe=Ve=>{let ft=`M${Ve} 0`;for(let Tt=0;Tt<Re;Tt+=8)ft+=` L${Ve+(Tt/8%2?-3:3)} ${Tt+8}`;return ft},_e=nt("g",{class:"tlx-cut",tabindex:0,role:"button","data-from":H.from,"data-to":H.to,"aria-label":`A break of ${fs(H.to-H.from)} with nothing shown, from ${Lt(H.from,n)} to ${Lt(H.to,n)}: press to open it`},`${fs(H.to-H.from)} with nothing here: ${Lt(H.from,n)} to ${Lt(H.to,n)} (click to open)`);_e.append(nt("rect",{class:"tlx-cut-bg",x:H.x0,y:0,width:H.x1-H.x0,height:Re})),_e.append(nt("path",{class:"tlx-cut-edge",d:pe(H.x0+3)}),nt("path",{class:"tlx-cut-edge",d:pe(H.x1-3)}));let qe=nt("text",{class:"tlx-cut-label",x:(H.x0+H.x1)/2,y:15,"text-anchor":"middle"});qe.textContent=fs(H.to-H.from),_e.append(qe),Me.push(_e)}if(M!==void 0){let H=ve(M);Me.push(nt("line",{class:"tlx-playhead",x1:H,x2:H,y1:0,y2:Re})),Me.push(nt("path",{class:"tlx-handle",d:`M${H-6} 0 h12 v8 l-6 7 l-6 -7 z`},`the playhead: ${Lt(M,n)}`))}fe.replaceChildren(...Me),Be.replaceChildren(Q("div",{class:"tlx-labelhead",style:`height:${Nn}px`},Ye().kind==="single"?"single events":`per ${Ye().kind==="binned"?Ye().bin:""}`),...G.map(H=>{if(H.kind==="metric")return Q("div",{class:"tlx-rowlabel metric",style:`height:${di}px`,title:`${H.title} (${H.type==="counter"?"sums":"min, max and mean"})`},H.title);let pe=H.row,_e=Q("div",{class:`tlx-rowlabel${pe.own?" own":""}`,style:`height:${ds}px`,"data-scope":pe.scope,title:`${pe.scope||"all hosts"} \xB7 ${pe.count} event${pe.count===1?"":"s"}`},Q("span",{class:"tlx-kind"},e.catalog.flags.find(qe=>pe[qe])??pe.kind),Q("span",{class:"tlx-name"},pe.own?`${pe.label} (itself)`:pe.label),Q("span",{class:"tlx-count"},String(pe.count)));if(!pe.own&&pe.scope!==c){let qe=Q("button",{type:"button",class:"tlx-drill",title:pe.children?`Into ${pe.label}: its ${pe.children} part${pe.children===1?"":"s"}`:`Into ${pe.label}`,"aria-label":`Into ${pe.label}`},"\u203A");qe.addEventListener("click",()=>We(pe.scope)),_e.append(qe)}return _e})),Be.style.width=`${Yu}px`,he()}function he(){K.replaceChildren(...Is(c).flatMap((ee,ue,Re)=>{let Ue=Q("button",{type:"button",class:`tlx-crumb${ue===Re.length-1?" current":""}`,"aria-current":ue===Re.length-1?"location":void 0},je(ee.scope,ee.label));return Ue.addEventListener("click",()=>{ee.scope!==c&&(c=ee.scope,f=1,z(!0))}),ue?[Q("span",{class:"tlx-sep","aria-hidden":"true"},"/"),Ue]:[Ue]})),Z.setAttribute("aria-pressed",String(p)),Z.classList.toggle("on",p),A.hidden=!p||w;let C=Ye(),G=y?.total??0,J=(y?.retention??[]).filter(ee=>ee.events!==null).map(ee=>`${ee.source} kept ${ee.events} d`);Pe.textContent=`${Lt(m.t0,n)} \u2013 ${Lt(m.t1,n)} \xB7 ${C.kind==="single"?"single events":`bins of ${C.bin}`} \xB7 ${G} event${G===1?"":"s"}${j.length?` \xB7 ${j.length} break${j.length===1?"":"s"}`:""}${J.length?` \xB7 ${J.slice(0,3).join(", ")}`:""}`,le.hidden=!b.length,le.textContent=b.join(" \xB7 "),X.textContent=u?v.length?`${g+1>0?`${g+1} of `:""}${v.length}${v.length>=2e3?"+":""} hit${v.length===1?"":"s"}`:`${G?`${G} hit${G===1?"":"s"}`:"no hits"}`:"";for(let ee of q.querySelectorAll(".seg"))ee.classList.remove("on");ae.textContent=M===void 0?"":$?(()=>{let ee=e.stamp?.($)??{};return`Canvas: the state recorded at ${Lt(Date.parse(ee.at??"")||M,n)}${ee.tag?` (${ee.tag})`:""}`})():"No state recorded here",ae.classList.toggle("none",M!==void 0&&!$)}function He(){Fe.replaceChildren();for(let C of l?.sources??[]){let G=!d.source?.length||d.source.includes(C.name),J=Q("button",{type:"button",class:`tlx-chip${G?" on":""}${C.status==="not-yet"?" notyet":""}`,"aria-pressed":String(G&&C.status!=="not-yet"),disabled:C.status==="not-yet",title:C.status==="not-yet"?`${C.title}: not kept yet`:`${C.title}${$e(C)}`},C.name);C.status!=="not-yet"&&J.addEventListener("click",()=>be(C.name)),Fe.append(J)}}let $e=C=>{let G=l?.retention.find(J=>J.source===C.name);return G?` (kept ${G.events===null?"until deleted":`${G.events} days`})`:""};function be(C){let G=(l?.sources??[]).filter(ee=>ee.status==="kept").map(ee=>ee.name),J=d.source?.length?[...d.source]:[...G];J=J.includes(C)?J.filter(ee=>ee!==C):[...J,C],d={...d,...J.length===G.length?{source:void 0}:{source:J}},d.source||delete d.source,He(),z(!0),Ie()}let Ae=0;de.addEventListener("input",()=>{clearTimeout(Ae),Ae=setTimeout(()=>{u=de.value.trim(),g=-1,z(!0),Ie()},250)}),de.addEventListener("keydown",C=>{C.key==="Enter"&&(C.preventDefault(),clearTimeout(Ae),u=de.value.trim(),z(!0).then(()=>Ie()).then(()=>ot(C.shiftKey?-1:1)))});async function Ie(){if(!u){v=[],g=-1,he();return}let C=m.t1-m.t0;v=(await e.source.query(k(m.t0-C*4,Math.max(m.t1+C*4,rt()),{kind:"single"},{limit:2e3}))).events??[],g=Math.min(g,v.length-1),he()}function ot(C){if(!v.length)return;let G=(m.t0+m.t1)/2;g<0?g=C>0?Math.max(0,v.findIndex(ue=>ue.t>=G)):Math.max(0,v.length-1-[...v].reverse().findIndex(ue=>ue.t<=G)):g=(g+C+v.length)%v.length;let J=v[g],ee=Math.min(m.t1-m.t0,2*ps);m={t0:J.t-ee/2,t1:J.t+ee/2},w=!1,ct(J),z()}te.addEventListener("click",()=>ot(-1)),ye.addEventListener("click",()=>ot(1)),S.addEventListener("change",()=>{let C=S.value;d={...d,...C?{severity:jt.filter(G=>tf(G)>=tf(C))}:{}},C||delete d.severity,z(!0),Ie()});async function Zn(C,G=!0){let J=rt();if(C==="run"){let ee=await e.source.query({timeline:1,type:"query",scope:c,depth:0,from:J-30*Yt,to:J+1,filters:{kind:["run"]},limit:1e4}).catch(()=>{}),ue=ee?.events?.[ee.events.length-1];m=ue?{t0:ue.t-(ue.dur??ps)*.02,t1:(ue.open?J:ue.t+(ue.dur??ps))+(ue.dur??ps)*.04}:{t0:J-Yt,t1:J+Yt*.02}}else m={t0:J-ef[C],t1:J+ef[C]*.02};w=!0,O.clear(),F.clear(),G&&z()}function ht(C,G=!0){if(p=C,P?.(),P=void 0,C&&e.source.subscribe){let J=0,ee=0;P=e.source.subscribe(k(rt()-ps,rt()+365*Yt,{kind:"single"}),ue=>{if(l&&(l.now=Math.max(l.now,ue.now)),w){let Ue=m.t1-m.t0;m={t0:ue.now-Ue*.98,t1:ue.now+Ue*.02}}let Re=Date.now();Re-J>500?(J=Re,z(!0)):ee||(ee=setTimeout(()=>{ee=0,J=Date.now(),z(!0)},500))}),w=!0}G&&(he(),Ee())}Z.addEventListener("click",()=>ht(!p)),A.addEventListener("click",()=>{w=!0;let C=m.t1-m.t0,G=rt();m={t0:G-C*.98,t1:G+C*.02},z()}),D.addEventListener("click",()=>{Ze()}),V.addEventListener("change",()=>{h=V.checked,O.clear(),F.clear(),re(),Ee()}),ie.addEventListener("change",()=>{W=ie.checked,re(),Ee()});function We(C){let G=y?.rows.find(J=>J.scope===C);c=C,f=G&&G.children===0?0:1,E=void 0,Ke.hidden=!0,z(!0)}async function Ze(){let C=rt(),J=((await e.source.query({timeline:1,type:"query",scope:c,depth:0,from:C-400*Yt,to:C+1,bin:"1d",tz:n}).catch(()=>{}))?.bins??[]).map(ue=>ue.t),ee=J.length?Math.min(...J):C-7*Yt;m={t0:ee,t1:C+(C-ee)*.02},w=!0,z()}let sn=0;async function Mt(C){if(M=C,re(),C===void 0){$=void 0;return}let G=++sn,J=e.source.stateAt?await e.source.stateAt(c,C).catch(()=>{}):void 0;G===sn&&($=J,e.onPlayhead?.(C,J),he())}async function wt(C,G){E={from:Math.min(C,G),to:Math.max(C,G)},re();let J=await e.source.query(k(E.from,E.to,{kind:"single"},{limit:500})),ee=o(u),ue=Me=>{let ve=[],bt=0;for(let[Pt,Kt]of xr(ee,Me))ve.push(Me.slice(bt,Pt),Q("mark",null,Me.slice(Pt,Kt))),bt=Kt;return ve.push(Me.slice(bt)),ve},Re=(J.events??[]).map(Me=>{let ve=Q("tr",{"data-id":Me.id,tabindex:"0"},Q("td",null,Lt(Me.t,n)),Q("td",null,Me.dur!==void 0?Va(Me.dur):Me.open?"still going":""),Q("td",null,Me.source),Q("td",null,Me.kind),Q("td",{class:`sev-${Me.severity}`},Me.severity),Q("td",{class:"tlx-sum"},...ue(Me.summary)),Q("td",{class:"tlx-scope"},Me.scope));return ve.addEventListener("click",()=>ct(Me)),ve.addEventListener("keydown",bt=>{bt.key==="Enter"&&ct(Me)}),ve}),Ue=Q("button",{type:"button",class:"btn sm quiet","aria-label":"Close the table"},"Close");Ue.addEventListener("click",()=>{E=void 0,Ke.hidden=!0,re()});let gn=Me=>{let ve=Q("button",{type:"button",class:"btn sm","data-export":Me},Me.toUpperCase());return ve.addEventListener("click",()=>{$t(Me)}),ve};Ke.replaceChildren(Q("div",{class:"tlx-table-head"},Q("strong",null,`${J.total} event${J.total===1?"":"s"}`),Q("span",null,` ${Lt(E.from,n)} \u2013 ${Lt(E.to,n)}${J.total>500?" (the first 500 shown; the export has them all)":""}`),Q("span",{class:"spacer"}),Q("span",null,"Export: "),gn("json"),gn("csv"),Ue),Q("div",{class:"tlx-table-wrap"},Q("table",null,Q("thead",null,Q("tr",null,...["When","Long","Source","Kind","Severity","What","Scope"].map(Me=>Q("th",{scope:"col"},Me)))),Q("tbody",null,...Re)))),Ke.hidden=!1}async function kt(){if(!E)return[];let C=[],G;do{let J=await e.source.query(k(E.from,E.to,{kind:"single"},{limit:1e4,...G?{cursor:G}:{}}));C.push(...J.events??[]),G=J.next}while(G&&C.length<2e5);return C}async function $t(C){let G=await kt(),J=C==="json"?ci(G,B):fi(G,B),ee=`timeline-${new Date(E.from).toISOString().slice(0,16).replace(/:/g,"")}.${C}`,ue=C==="json"?"application/json":"text/csv";if(e.onExport){e.onExport(ee,J,ue);return}let Re=Q("a",{href:`data:${ue};charset=utf-8,${encodeURIComponent(J)}`,download:ee});document.body.append(Re),Re.click(),Re.remove()}function ct(C){if(R=C,re(),!C){Te.hidden=!0;return}let G=l?.sources.find(ve=>ve.name===C.source),J=new Set(G?.sensitive??[]),ee=o(u),ue=ve=>{let bt=[],Pt=0;for(let[Kt,Sr]of xr(ee,ve))bt.push(ve.slice(Pt,Kt),Q("mark",null,ve.slice(Kt,Sr))),Pt=Sr;return bt.push(ve.slice(Pt)),bt},Re=(ve,bt)=>{if(!bt)return null;let Pt=Q("button",{type:"button",class:"btn sm"},ve);return Pt.addEventListener("click",bt),Pt},Ue=Object.entries(C.attrs).map(([ve,bt])=>{if(!J.has(ve))return Q("tr",null,Q("th",{scope:"row"},ve),Q("td",null,...ue(String(bt))));let Pt=Q("button",{type:"button",class:"btn sm quiet",title:"This can name a remote host, a folder or free text"},"Show"),Kt=Q("td",{class:"tlx-sensitive"},"hidden ",Pt);return Pt.addEventListener("click",()=>Kt.replaceChildren(String(bt))),Q("tr",null,Q("th",{scope:"row"},ve),Kt)}),gn=Q("button",{type:"button",class:"btn sm quiet tlx-close","aria-label":"Close"},"\xD7");gn.addEventListener("click",()=>ct(void 0));let Me=Is(C.scope).slice(1).map(ve=>{let bt=Q("button",{type:"button",class:"tlx-crumb"},je(ve.scope,ve.label));return bt.addEventListener("click",()=>We(ve.scope)),bt});Te.replaceChildren(Q("div",{class:"tlx-detail-head"},Q("strong",null,C.kind),gn),Q("p",{class:`tlx-sev sev-${C.severity}`},`${C.severity} \xB7 ${G?.title??C.source}`),Q("p",{class:"tlx-sum"},...ue(C.summary)),Q("p",null,Lt(C.t,n),C.dur!==void 0?` \xB7 ${Va(C.dur)}${C.open?" so far":""}`:C.open?" \xB7 still going":""),Q("p",{class:"tlx-crumbs small"},...Me),...Ue.length?[Q("table",{class:"tlx-attrs"},Q("tbody",null,...Ue))]:[],Q("div",{class:"tlx-links"},...(e.actions?.(C)??[]).map(([ve,bt])=>Re(ve,bt)))),Te.hidden=!1}function ms(C,G){let J=us({from:C,to:G});if(!j.find(Ue=>Ue.from===C&&Ue.to===G))return;if(O.add(J),!r){F.set(J,1),re();return}let ue=performance.now(),Re=Ue=>{let gn=Math.min(1,(Ue-ue)/260);F.set(J,1-(1-gn)**3),ke(),gn<1&&requestAnimationFrame(Re)};requestAnimationFrame(Re)}let Et,es=C=>C.clientX-fe.getBoundingClientRect().left;fe.addEventListener("pointerdown",C=>{let G=es(C),J=C.clientY-fe.getBoundingClientRect().top,ee=C.target.closest?.(".tlx-cut");if(ee){C.preventDefault(),ms(Number(ee.getAttribute("data-from")),Number(ee.getAttribute("data-to")));return}fe.setPointerCapture(C.pointerId),Et={kind:J<Nn||C.shiftKey?"brush":C.target.classList.contains("tlx-handle")?"scrub":"pan",x0:G,t0:U.t(G),v0:m,moved:!1},C.preventDefault(),xe.focus({preventScroll:!0})}),fe.addEventListener("pointermove",C=>{if(!Et)return;let G=es(C);if(Math.abs(G-Et.x0)>3&&(Et.moved=!0),!!Et.moved)if(Et.kind==="pan"){let J=(Et.x0-G)*U.msPerPx;m={t0:Et.v0.t0+J,t1:Et.v0.t1+J},w=!1,z()}else Et.kind==="scrub"?Mt(U.t(G)):(E={from:Math.min(Et.t0,U.t(G)),to:Math.max(Et.t0,U.t(G))},re())}),fe.addEventListener("pointerup",C=>{let G=Et;if(Et=void 0,!G)return;let J=es(C);if(G.kind==="brush"&&G.moved){wt(G.t0,U.t(J));return}if(G.kind==="brush"&&!G.moved){Mt(U.t(J));return}if(G.kind==="pan"&&!G.moved){let ee=C.target.closest?.("[data-id]")?.getAttribute("data-id"),ue=ee?[...y?.events??[],...y?.spans??[]].find(Re=>Re.id===ee):void 0;ue?(ct(ue),Mt(ue.t)):Mt(U.t(J))}}),fe.addEventListener("keydown",C=>{let G=C.target.closest?.(".tlx-cut");G&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),ms(Number(G.getAttribute("data-from")),Number(G.getAttribute("data-to"))))}),fe.addEventListener("wheel",C=>{C.preventDefault();let G=es(C);if(C.shiftKey||Math.abs(C.deltaX)>Math.abs(C.deltaY)){let J=(C.shiftKey?C.deltaY:C.deltaX)*U.msPerPx;m={t0:m.t0+J,t1:m.t1+J},w=!1}else hs(U.t(G),Math.exp(C.deltaY*.0015),G/Qe());z()},{passive:!1});function hs(C,G,J=.5){let ee=Math.min(400*Yt,Math.max(1e4,(m.t1-m.t0)*G));m={t0:C-J*ee,t1:C+(1-J)*ee},O.clear(),F.clear(),G<1&&(w=p&&m.t1>=rt())}xe.addEventListener("keydown",C=>{let G=m.t1-m.t0;if(C.key==="ArrowLeft"||C.key==="ArrowRight"){let J=G*.15*(C.key==="ArrowLeft"?-1:1);m={t0:m.t0+J,t1:m.t1+J},w=!1}else if(C.key==="+"||C.key==="=")hs((m.t0+m.t1)/2,.6);else if(C.key==="-"||C.key==="_")hs((m.t0+m.t1)/2,1/.6);else if(C.key==="n"||C.key==="N"){ot(C.shiftKey?-1:1),C.preventDefault();return}else if(C.key==="Escape")ct(void 0),E=void 0,Ke.hidden=!0;else return;C.preventDefault(),z()}),t.addEventListener("keydown",C=>{C.key==="/"&&document.activeElement!==de&&!C.target.closest("input, select, textarea")&&(C.preventDefault(),de.focus())}),Se.addEventListener("scroll",()=>re(),{passive:!0}),se.addEventListener("click",async()=>{let C=`${Is(c).slice(-1)[0].label}${u?`: ${u}`:""}`.slice(0,80);await e.saveView?.({...ce(),name:C}),await rn()});let Ce=[];async function rn(){e.views&&(Ce=await e.views(),Y.replaceChildren(Q("option",{value:""},"Saved views\u2026"),...Ce.map((C,G)=>Q("option",{value:String(G)},C.name))))}Y.addEventListener("change",()=>{let C=Ce[Number(Y.value)];C&&(Oe(C),He(),z(!0)),Y.value=""});let et=typeof ResizeObserver=="function"?new ResizeObserver(()=>re()):void 0;et?.observe(xe);let Bt=(async()=>{l=await e.source.catalog(),B=l.sources.flatMap(ee=>(ee.sensitive??[]).map(ue=>`${ee.name}.${ue}`));for(let ee of l.sources)for(let ue of ee.series)ne.set(ue.name,{unit:ue.unit,type:ue.type,title:ue.title,source:ee.name});c=l.hosts.length===1?`host:${l.hosts[0].replace(/[%/:\s]/g,ee=>`%${ee.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`)}`:"";let G=l.now;m={t0:G-Yt,t1:G+Yt*.02};let J=tt()??e.view;J&&Oe(J),He(),await rn(),await z(!0),u&&await Ie()})();return{el:t,ready:Bt,get view(){return ce()},setView(C){return Oe(C),He(),z(!0)},setRange(C,G){return m={t0:C,t1:G},w=!1,z()},setPlayhead:Mt,setLive:ht,setTheme:a,refresh:()=>z(!0),internal:{get result(){return y},get mode(){return Ye()},get scale(){return U},get gaps(){return j},get playState(){return $},get hits(){return v},get selected(){return R},get follow(){return w},openCut:ms,showTable:wt,rangeEvents:kt,exportRange:$t,select:ct,stepHit:ot,drill:We,findHits:Ie,paint:ke,lines:lt},dispose(){P?.(),et?.disconnect(),T&&cancelAnimationFrame(T),t.replaceChildren()}}}var Xu={arrow:{d:"M0,0 L10,5 L0,10 z",refX:9},open:{d:"M0,0 L10,5 L0,10 L3,5 z",refX:9},diamond:{d:"M0,5 L5,1.5 L10,5 L5,8.5 z",refX:1}},It=t=>(Math.round(t*10)/10).toString(),sf=t=>(t??"link").replace(/[^\w-]/g,"_");function pi(t,e){let{id:n}=e,s=e.styles??{},r=t.options,o=t.bounds,i=new Map,a=(p,h)=>{let m=s[p]??{},y=h==="start"?m.start??"none":m.end??"arrow";if(y!=="none")return(i.get(p)??i.set(p,new Set).get(p)).add(y),`url(#${n}-mk-${p}-${y})`},l="",c="",f="",u="";for(let p of[...t.panels].sort((h,m)=>h.depth-m.depth)){let h=p.rect,m=p.label?me("text",{class:"pl",x:p.titleAt[0],y:p.titleAt[1]},ut(p.label)+(p.sub?me("tspan",{class:"pls",dx:10},ut(p.sub)):"")):"";l+=me("g",{class:`panel k-${p.role??"grey"}`,"data-id":p.id},me("rect",{class:"face",x:It(h.l),y:It(h.t),width:It(h.r-h.l),height:It(h.b-h.t),rx:r.panelRx})+m)}for(let p of t.links){if(!p.points.length)continue;let h=sf(p.kind);c+=me("path",{class:`conn k-${h}`,d:"M"+p.points.map(m=>`${It(m[0])},${It(m[1])}`).join(" L"),"data-id":p.id,"data-a":p.a,"data-b":p.b,"marker-start":a(h,"start"),"marker-end":a(h,"end")}),p.at&&(u+=me("text",{class:`cl k-${h}`,x:p.at.x,y:p.at.y,"text-anchor":p.at.anchor==="start"?void 0:p.at.anchor,"data-for":p.id},ut(p.at.text)))}for(let p of t.cards){let h=p.rect;f+=me("g",{class:`card k-${p.role??"grey"}${p.ghost?" ghost":""}`,"data-id":p.id,tabindex:0,role:"button","aria-label":p.sub?`${p.label}: ${p.sub}`:p.label},me("rect",{class:"face",x:It(h.l),y:It(h.t),width:r.W,height:r.H,rx:r.cardRx})+me("text",{class:"lt",x:It(h.l+14),y:It(h.t+24)},ut(p.label))+(p.sub?me("text",{class:"st",x:It(h.l+14),y:It(h.t+42)},ut(p.sub)):""))}let d="";for(let[p,h]of i)for(let m of h){let y=Xu[m];d+=me("marker",{id:`${n}-mk-${p}-${m}`,viewBox:"0 0 10 10",refX:y.refX,refY:5,markerWidth:5.4,markerHeight:5.4,orient:"auto-start-reverse"},me("path",{d:y.d,class:`mk k-${p}`}))}return me("svg",{xmlns:"http://www.w3.org/2000/svg",class:"flat",viewBox:`${It(o.l)} ${It(o.t)} ${It(o.r-o.l)} ${It(o.b-o.t)}`,role:"img","aria-label":e.title??"drawing, flat view","data-view":"2d"},(d?me("defs",{},d):"")+me("g",{class:"panels"},l)+me("g",{class:"conns"},c)+me("g",{class:"cards"},f)+me("g",{class:"labels"},u))}function rf(t={}){let e=s=>s?s.startsWith("#")||s.includes("(")?s:`var(--${s})`:"var(--ink)",n=`
360
360
  .flat{font-family:inherit}
361
361
  .flat .card{cursor:pointer;outline:none}
362
362
  .flat .card .face{fill:hsl(var(--h) var(--s) var(--l-top));stroke:hsl(var(--h) var(--s) var(--l-edge) / .55);stroke-width:1}
@@ -375,7 +375,7 @@ ${e.extraBody??""}
375
375
  .flat .conn.hot{stroke-width:3}
376
376
  .flat .conn.dim,.flat .cl.dim{opacity:.3}
377
377
  `;for(let[s,r]of Object.entries(t)){let o=sf(s),i=e(r.color);n+=`.flat .conn.k-${o}{stroke:${i}${r.dash?`;stroke-dasharray:${r.dash}`:""}${r.width?`;stroke-width:${r.width}`:""}} .flat .mk.k-${o}{fill:${i}} .flat .cl.k-${o}{fill:${i}}
378
- `}return n}var Xu={name:["card","lt"],sub:["card","st"],title:["panel","pl"],titleSub:["panel","pls"],label:["","cl"]};function di(t){let e="http://www.w3.org/2000/svg",n=document.createElementNS(e,"svg");n.setAttribute("class","flat"),n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;left:-10000px;top:0;width:10px;height:10px;visibility:hidden",t.appendChild(n);let s={};for(let[i,[a,l]]of Object.entries(Xu)){let c=document.createElementNS(e,"g");a&&c.setAttribute("class",a);let f=document.createElementNS(e,"text");f.setAttribute("class",l),c.appendChild(f),n.appendChild(c),s[i]=f}let r=new Map,o=((i,a)=>{let l=a+"\0"+i,c=r.get(l);return c===void 0&&(s[a].textContent=i,c=s[a].getComputedTextLength(),r.set(l,c)),c});return o.dispose=()=>n.remove(),o}var of=(t,e)=>t.cards.find(n=>n.id===e)?.rect??t.panels.find(n=>n.id===e)?.rect;var Qn="http://www.w3.org/2000/svg";function mi(t,e,n){let s=new Map((n?.links??[]).map((r,o)=>[r.id??`link-${o}`,r]));for(let r of e.routes){let o=s.get(r.id),i=o?.a??Ut(r.raw.from).id,a=o?.b??Ut(r.raw.to).id;for(let l of t.querySelectorAll(`[data-id="${CSS.escape(r.id)}"]`))l.setAttribute("data-a",i),l.setAttribute("data-b",a)}}var Qu=(t="auto")=>t==="always"||t==="auto"&&!(typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches);function cf(t,e,n,s,r={}){let o=r.duration??600;if(!o||!Qu(r.motion))return;let i=vr(t,e,n,s);t.appendChild(i.svg),i.at(0);let a=0,l=!1,c,f=new Promise(h=>c=h),u=()=>{l||(l=!0,cancelAnimationFrame(a),i.svg.remove(),c())},d=performance.now(),p=h=>{if(l)return;let m=Math.min(1,(h-d)/o);i.at(m),m<1?a=requestAnimationFrame(p):u()};return a=requestAnimationFrame(p),{done:f,finish:u}}var _n=t=>Math.max(0,Math.min(1,t)),kr=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;function pi(t){let e=t.cloneNode(!0),n=[t,...t.querySelectorAll("*")],s=[e,...e.querySelectorAll("*")];return n.forEach((r,o)=>{let i=getComputedStyle(r),a=s[o];a.removeAttribute("class"),a.removeAttribute("tabindex");for(let l of["fill","fill-opacity","stroke","stroke-width","stroke-dasharray","stroke-opacity","opacity","font-size","font-weight","font-family","letter-spacing","paint-order","stroke-linejoin","text-anchor"])a.style.setProperty(l,i.getPropertyValue(l))}),e}var Va=(t,e)=>{let n=t.getBoundingClientRect();return{x:n.left-e.left,y:n.top-e.top,w:n.width,h:n.height}},af=t=>{let e=Math.min(...t.map(o=>o.x)),n=Math.min(...t.map(o=>o.y)),s=Math.max(...t.map(o=>o.x+o.w)),r=Math.max(...t.map(o=>o.y+o.h));return{x:e,y:n,w:s-e,h:r-n}},Zu=(t,e)=>{let n=t.getScreenCTM();return`matrix(${n.a} ${n.b} ${n.c} ${n.d} ${n.e-e.left} ${n.f-e.top})`},lf=(t,e,n)=>{let s=1+(e.w/Math.max(t.w,1e-6)-1)*n,r=1+(e.h/Math.max(t.h,1e-6)-1)*n,o=(e.x-t.x*(e.w/Math.max(t.w,1e-6)))*n,i=(e.y-t.y*(e.h/Math.max(t.h,1e-6)))*n;return`matrix(${s} 0 0 ${r} ${o} ${i})`};function ed(t,e){let n=t.querySelector("polygon.top");if(!n)return;let s=n.getScreenCTM(),r=[];for(let o=0;o<n.points.numberOfItems;o++){let i=n.points.getItem(o);r.push([s.a*i.x+s.c*i.y+s.e-e.left,s.b*i.x+s.d*i.y+s.f-e.top])}return r.length===4?{pts:r,fill:getComputedStyle(n).fill}:void 0}function vr(t,e,n,s){let r=t.getBoundingClientRect(),o=document.createElementNS(Qn,"svg");o.setAttribute("class","dual-morph"),o.setAttribute("aria-hidden","true"),o.style.cssText=`position:absolute;left:0;top:0;width:${r.width}px;height:${Math.max(r.height,e.getBoundingClientRect().height,n.getBoundingClientRect().height)}px;overflow:visible;pointer-events:none`;let i=O=>{let E=document.createElementNS(Qn,"g");return E.setAttribute("transform",Zu(O,r)),E},a=O=>O.hasAttribute("data-a")||O.hasAttribute("data-for"),l=O=>{let E=new Map;for(let x of O.querySelectorAll("[data-id]")){if(a(x)||x.parentElement?.closest("[data-id]")||x.closest(".overlay"))continue;let T=x.getAttribute("data-id");(E.get(T)??E.set(T,[]).get(T)).push(x)}return E},c=l(e),f=l(n),u=document.createElementNS(Qn,"g"),d=document.createElementNS(Qn,"g"),p=i(e),h=i(n);for(let O of e.querySelectorAll("[data-a],[data-for]"))O.closest(".overlay")||p.appendChild(pi(O));for(let O of n.querySelectorAll("[data-a],[data-for]"))O.closest(".overlay")||h.appendChild(pi(O));u.appendChild(p),d.appendChild(h);let m=[...h.querySelectorAll("path")].map(O=>{let E=O.getTotalLength?.()??0;return{p:O,len:E}}),y=[...h.children].filter(O=>O.tagName.toLowerCase()==="text"),I=[...(s==="2d"?c:f).keys()],N=[],M=document.createElementNS(Qn,"g");for(let O of new Set([...I,...c.keys(),...f.keys()])){let E=c.get(O),x=f.get(O),T={};if(E){T.a=af(E.map(R=>Va(R,r)));let v=document.createElementNS(Qn,"g"),g=i(e);for(let R of E)g.appendChild(pi(R));v.appendChild(g),T.src=v}if(x){T.b=af(x.map(R=>Va(R,r)));let v=document.createElementNS(Qn,"g"),g=i(n);for(let R of x)g.appendChild(pi(R));v.appendChild(g),T.dst=v}let L=s==="3d"?E?.[0]:x?.[0],w=s==="3d"?x?.[0]:E?.[0],P=L?ed(L,r):void 0,b=w?.querySelector("rect.face");if(P&&b){let v=Va(b,r),g=[[v.x,v.y],[v.x+v.w,v.y],[v.x+v.w,v.y+v.h],[v.x,v.y+v.h]],R=P.pts.reduce((B,V,q)=>V[0]<P.pts[B][0]?q:B,0),F=[...P.pts.slice(R),...P.pts.slice(0,R)],j=[F[0],F[1],F[2],F[3]],U=getComputedStyle(b).fill,ne=document.createElementNS(Qn,"polygon");T.face=ne,T.faceFrom=s==="3d"?j:g,T.faceTo=s==="3d"?g:j,T.faceFill=s==="3d"?[P.fill,U]:[U,P.fill]}T.src&&M.appendChild(T.src),T.face&&M.appendChild(T.face),T.dst&&M.appendChild(T.dst),N.push(T)}o.append(u,M,d);let $=(O,E,x)=>`color-mix(in srgb, ${O} ${Math.round((1-x)*100)}%, ${E})`;return{svg:o,at(O){let E=_n(O/.2),x=kr(_n((O-.2)/.6)),T=_n((O-.8)/.2);u.setAttribute("opacity",String(1-E));for(let{p:L,len:w}of m)L.style.strokeDasharray=`${w} ${w}`,L.style.strokeDashoffset=String(w*(1-T));d.setAttribute("opacity",String(T>0?1:0));for(let L of y)L.style.opacity=String(T);for(let L of N)if(L.src&&(L.src.setAttribute("transform",L.a&&L.b?lf(L.a,L.b,x):""),L.src.setAttribute("opacity",String(L.b?1-_n(x/(L.face?.35:.6)):1-x))),L.dst&&(L.dst.setAttribute("transform",L.a&&L.b?lf(L.b,L.a,1-x):""),L.dst.setAttribute("opacity",String(L.a?_n((x-(L.face?.65:.4))/(L.face?.35:.6)):x))),L.face){let w=L.faceFrom.map((P,b)=>[P[0]+(L.faceTo[b][0]-P[0])*x,P[1]+(L.faceTo[b][1]-P[1])*x]);L.face.setAttribute("points",w.map(P=>P.join(",")).join(" ")),L.face.style.fill=$(L.faceFill[0],L.faceFill[1],x),L.face.setAttribute("opacity",String(x<.08?x/.08:x>.92?(1-x)/.08:1))}}}}var td=0;function ff(t,e,n={}){let s=`dv${++td}`,r=document.createElement("div");r.className="dual-view",r.style.position="relative",t.appendChild(r);let o=document.createElement("div"),i=document.createElement("div");o.className="dual-3d",i.className="dual-2d",r.append(o,i),o.innerHTML=e.rendered.svg;let a=o.querySelector("svg");a.setAttribute("data-view","3d");let l=n.board??Wo(e);mi(a,e,l);let c=new Set(e.routes.map(w=>w.id));for(let w of a.querySelectorAll("g[data-id]")){let P=w.getAttribute("data-id");c.has(P)||w.hasAttribute("tabindex")||!w.querySelector("polygon")||(w.setAttribute("tabindex","0"),w.setAttribute("role","button"),w.setAttribute("aria-label",P))}let f=di(i),u=Rs(l,f,n.flat);f.dispose(),i.innerHTML=ui(u,{id:s,title:n.title,styles:n.styles});let d=i.querySelector("svg");for(let w of[a,d])w.style.display="block",w.style.width="100%",w.style.height="auto";n.title&&a.setAttribute("aria-label",n.title);let p=n.mode??"3d",h,m=w=>w==="3d"?o:i,y=w=>w==="3d"?a:d,I=w=>{o.hidden=w!=="3d",i.hidden=w!=="2d";for(let P of[o,i])P.style.cssText="";r.style.height="",r.dataset.mode=w};I(p);let N=()=>{for(let w of[a,d]){for(let P of w.querySelectorAll("[data-id]"))P.classList.toggle("sel",!!h&&P.getAttribute("data-id")===h);for(let P of w.querySelectorAll("[data-a]")){let b=!!h&&(P.getAttribute("data-a")===h||P.getAttribute("data-b")===h);P.classList.toggle("hot",b),P.classList.toggle("dim",!!h&&!b),w.querySelector(`[data-for="${CSS.escape(P.getAttribute("data-id")??"")}"]`)?.classList.toggle("dim",!!h&&!b)}}},M=w=>{h=w,N()},$=w=>{let P=w.target.closest?.("[data-id]");if(!P||!r.contains(P)||P.hasAttribute("data-a"))return;let b=P.getAttribute("data-id");M(b),n.onSelect?.(b)},O=w=>{(w.key==="Enter"||w.key===" ")&&w.target.matches?.("[data-id][tabindex]")&&(w.preventDefault(),$(w))};r.addEventListener("click",$),r.addEventListener("keydown",O);let E,x=()=>{if(!E)return;cancelAnimationFrame(E.frame),E.layer.remove();let w=E;E=void 0,p=w.to,I(p),N(),w.done()},T=w=>{!w||!h||y(p).querySelector(`[data-id="${CSS.escape(h)}"][tabindex]`)?.focus({preventScroll:!0})};return{get mode(){return E?E.to:p},layout:u,root:r,morph:w=>{let P=r.contains(document.activeElement);if(E&&x(),w===p)return T(P),Promise.resolve();let b=n.motion??"auto";return b==="never"||b==="auto"&&typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches||!(n.duration??600)?(p=w,I(p),N(),T(P),Promise.resolve()):new Promise(g=>{let R=p,F=r.getBoundingClientRect().height;o.hidden=!1,i.hidden=!1;for(let Z of[o,i])Z.style.cssText="position:absolute;left:0;top:0;right:0;visibility:hidden";let j=m(w).getBoundingClientRect().height;r.style.height=`${F}px`;let U=vr(r,y(R),y(w),R);r.appendChild(U.svg);let ne=n.duration??600,B=performance.now(),V={frame:0,layer:U.svg,to:w,done:()=>{T(P),g()}},q=Z=>{if(E!==V)return;let A=Math.min(1,(Z-B)/ne);U.at(A),r.style.height=`${F+(j-F)*kr(_n((A-.2)/.6))}px`,A<1?V.frame=requestAnimationFrame(q):x()};E=V,V.frame=requestAnimationFrame(q)})},select:M,get selected(){return h},svgOf:y,destroy(){E&&x(),r.removeEventListener("click",$),r.removeEventListener("keydown",O),r.remove()}}}function uf(t="iso-view"){try{let e=localStorage.getItem(t);return e==="2d"||e==="3d"?e:void 0}catch{return}}function df(t,e,n={}){let s=n.storageKey??"iso-view",r=Array.isArray(e)?e:[e],o=document.createElement("div");o.className="view-switch",o.setAttribute("role","group"),o.setAttribute("aria-label","Drawing view");let i=["3d","2d"].map((l,c)=>{let f=document.createElement("button");return f.type="button",f.dataset.mode=l,f.textContent=(n.labels??["3D","2D"])[c],f.addEventListener("click",()=>{try{localStorage.setItem(s,l)}catch{}a(l);for(let u of r)u.morph(l)}),o.appendChild(f),f}),a=l=>i.forEach(c=>c.setAttribute("aria-pressed",String(c.dataset.mode===l)));return a(r[0]?.mode??"3d"),t.appendChild(o),o}var pf=`
378
+ `}return n}var Qu={name:["card","lt"],sub:["card","st"],title:["panel","pl"],titleSub:["panel","pls"],label:["","cl"]};function mi(t){let e="http://www.w3.org/2000/svg",n=document.createElementNS(e,"svg");n.setAttribute("class","flat"),n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;left:-10000px;top:0;width:10px;height:10px;visibility:hidden",t.appendChild(n);let s={};for(let[i,[a,l]]of Object.entries(Qu)){let c=document.createElementNS(e,"g");a&&c.setAttribute("class",a);let f=document.createElementNS(e,"text");f.setAttribute("class",l),c.appendChild(f),n.appendChild(c),s[i]=f}let r=new Map,o=((i,a)=>{let l=a+"\0"+i,c=r.get(l);return c===void 0&&(s[a].textContent=i,c=s[a].getComputedTextLength(),r.set(l,c)),c});return o.dispose=()=>n.remove(),o}var of=(t,e)=>t.cards.find(n=>n.id===e)?.rect??t.panels.find(n=>n.id===e)?.rect;var Qn="http://www.w3.org/2000/svg";function gi(t,e,n){let s=new Map((n?.links??[]).map((r,o)=>[r.id??`link-${o}`,r]));for(let r of e.routes){let o=s.get(r.id),i=o?.a??Ut(r.raw.from).id,a=o?.b??Ut(r.raw.to).id;for(let l of t.querySelectorAll(`[data-id="${CSS.escape(r.id)}"]`))l.setAttribute("data-a",i),l.setAttribute("data-b",a)}}var Zu=(t="auto")=>t==="always"||t==="auto"&&!(typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches);function cf(t,e,n,s,r={}){let o=r.duration??600;if(!o||!Zu(r.motion))return;let i=vr(t,e,n,s);t.appendChild(i.svg),i.at(0);let a=0,l=!1,c,f=new Promise(h=>c=h),u=()=>{l||(l=!0,cancelAnimationFrame(a),i.svg.remove(),c())},d=performance.now(),p=h=>{if(l)return;let m=Math.min(1,(h-d)/o);i.at(m),m<1?a=requestAnimationFrame(p):u()};return a=requestAnimationFrame(p),{done:f,finish:u}}var _n=t=>Math.max(0,Math.min(1,t)),kr=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;function hi(t){let e=t.cloneNode(!0),n=[t,...t.querySelectorAll("*")],s=[e,...e.querySelectorAll("*")];return n.forEach((r,o)=>{let i=getComputedStyle(r),a=s[o];a.removeAttribute("class"),a.removeAttribute("tabindex");for(let l of["fill","fill-opacity","stroke","stroke-width","stroke-dasharray","stroke-opacity","opacity","font-size","font-weight","font-family","letter-spacing","paint-order","stroke-linejoin","text-anchor"])a.style.setProperty(l,i.getPropertyValue(l))}),e}var Ua=(t,e)=>{let n=t.getBoundingClientRect();return{x:n.left-e.left,y:n.top-e.top,w:n.width,h:n.height}},af=t=>{let e=Math.min(...t.map(o=>o.x)),n=Math.min(...t.map(o=>o.y)),s=Math.max(...t.map(o=>o.x+o.w)),r=Math.max(...t.map(o=>o.y+o.h));return{x:e,y:n,w:s-e,h:r-n}},ed=(t,e)=>{let n=t.getScreenCTM();return`matrix(${n.a} ${n.b} ${n.c} ${n.d} ${n.e-e.left} ${n.f-e.top})`},lf=(t,e,n)=>{let s=1+(e.w/Math.max(t.w,1e-6)-1)*n,r=1+(e.h/Math.max(t.h,1e-6)-1)*n,o=(e.x-t.x*(e.w/Math.max(t.w,1e-6)))*n,i=(e.y-t.y*(e.h/Math.max(t.h,1e-6)))*n;return`matrix(${s} 0 0 ${r} ${o} ${i})`};function td(t,e){let n=t.querySelector("polygon.top");if(!n)return;let s=n.getScreenCTM(),r=[];for(let o=0;o<n.points.numberOfItems;o++){let i=n.points.getItem(o);r.push([s.a*i.x+s.c*i.y+s.e-e.left,s.b*i.x+s.d*i.y+s.f-e.top])}return r.length===4?{pts:r,fill:getComputedStyle(n).fill}:void 0}function vr(t,e,n,s){let r=t.getBoundingClientRect(),o=document.createElementNS(Qn,"svg");o.setAttribute("class","dual-morph"),o.setAttribute("aria-hidden","true"),o.style.cssText=`position:absolute;left:0;top:0;width:${r.width}px;height:${Math.max(r.height,e.getBoundingClientRect().height,n.getBoundingClientRect().height)}px;overflow:visible;pointer-events:none`;let i=R=>{let E=document.createElementNS(Qn,"g");return E.setAttribute("transform",ed(R,r)),E},a=R=>R.hasAttribute("data-a")||R.hasAttribute("data-for"),l=R=>{let E=new Map;for(let w of R.querySelectorAll("[data-id]")){if(a(w)||w.parentElement?.closest("[data-id]")||w.closest(".overlay"))continue;let T=w.getAttribute("data-id");(E.get(T)??E.set(T,[]).get(T)).push(w)}return E},c=l(e),f=l(n),u=document.createElementNS(Qn,"g"),d=document.createElementNS(Qn,"g"),p=i(e),h=i(n);for(let R of e.querySelectorAll("[data-a],[data-for]"))R.closest(".overlay")||p.appendChild(hi(R));for(let R of n.querySelectorAll("[data-a],[data-for]"))R.closest(".overlay")||h.appendChild(hi(R));u.appendChild(p),d.appendChild(h);let m=[...h.querySelectorAll("path")].map(R=>{let E=R.getTotalLength?.()??0;return{p:R,len:E}}),y=[...h.children].filter(R=>R.tagName.toLowerCase()==="text"),I=[...(s==="2d"?c:f).keys()],N=[],M=document.createElementNS(Qn,"g");for(let R of new Set([...I,...c.keys(),...f.keys()])){let E=c.get(R),w=f.get(R),T={};if(E){T.a=af(E.map(O=>Ua(O,r)));let v=document.createElementNS(Qn,"g"),g=i(e);for(let O of E)g.appendChild(hi(O));v.appendChild(g),T.src=v}if(w){T.b=af(w.map(O=>Ua(O,r)));let v=document.createElementNS(Qn,"g"),g=i(n);for(let O of w)g.appendChild(hi(O));v.appendChild(g),T.dst=v}let L=s==="3d"?E?.[0]:w?.[0],x=s==="3d"?w?.[0]:E?.[0],P=L?td(L,r):void 0,b=x?.querySelector("rect.face");if(P&&b){let v=Ua(b,r),g=[[v.x,v.y],[v.x+v.w,v.y],[v.x+v.w,v.y+v.h],[v.x,v.y+v.h]],O=P.pts.reduce((B,K,q)=>K[0]<P.pts[B][0]?q:B,0),F=[...P.pts.slice(O),...P.pts.slice(0,O)],j=[F[0],F[1],F[2],F[3]],U=getComputedStyle(b).fill,ne=document.createElementNS(Qn,"polygon");T.face=ne,T.faceFrom=s==="3d"?j:g,T.faceTo=s==="3d"?g:j,T.faceFill=s==="3d"?[P.fill,U]:[U,P.fill]}T.src&&M.appendChild(T.src),T.face&&M.appendChild(T.face),T.dst&&M.appendChild(T.dst),N.push(T)}o.append(u,M,d);let $=(R,E,w)=>`color-mix(in srgb, ${R} ${Math.round((1-w)*100)}%, ${E})`;return{svg:o,at(R){let E=_n(R/.2),w=kr(_n((R-.2)/.6)),T=_n((R-.8)/.2);u.setAttribute("opacity",String(1-E));for(let{p:L,len:x}of m)L.style.strokeDasharray=`${x} ${x}`,L.style.strokeDashoffset=String(x*(1-T));d.setAttribute("opacity",String(T>0?1:0));for(let L of y)L.style.opacity=String(T);for(let L of N)if(L.src&&(L.src.setAttribute("transform",L.a&&L.b?lf(L.a,L.b,w):""),L.src.setAttribute("opacity",String(L.b?1-_n(w/(L.face?.35:.6)):1-w))),L.dst&&(L.dst.setAttribute("transform",L.a&&L.b?lf(L.b,L.a,1-w):""),L.dst.setAttribute("opacity",String(L.a?_n((w-(L.face?.65:.4))/(L.face?.35:.6)):w))),L.face){let x=L.faceFrom.map((P,b)=>[P[0]+(L.faceTo[b][0]-P[0])*w,P[1]+(L.faceTo[b][1]-P[1])*w]);L.face.setAttribute("points",x.map(P=>P.join(",")).join(" ")),L.face.style.fill=$(L.faceFill[0],L.faceFill[1],w),L.face.setAttribute("opacity",String(w<.08?w/.08:w>.92?(1-w)/.08:1))}}}}var nd=0;function ff(t,e,n={}){let s=`dv${++nd}`,r=document.createElement("div");r.className="dual-view",r.style.position="relative",t.appendChild(r);let o=document.createElement("div"),i=document.createElement("div");o.className="dual-3d",i.className="dual-2d",r.append(o,i),o.innerHTML=e.rendered.svg;let a=o.querySelector("svg");a.setAttribute("data-view","3d");let l=n.board??Wo(e);gi(a,e,l);let c=new Set(e.routes.map(x=>x.id));for(let x of a.querySelectorAll("g[data-id]")){let P=x.getAttribute("data-id");c.has(P)||x.hasAttribute("tabindex")||!x.querySelector("polygon")||(x.setAttribute("tabindex","0"),x.setAttribute("role","button"),x.setAttribute("aria-label",P))}let f=mi(i),u=Os(l,f,n.flat);f.dispose(),i.innerHTML=pi(u,{id:s,title:n.title,styles:n.styles});let d=i.querySelector("svg");for(let x of[a,d])x.style.display="block",x.style.width="100%",x.style.height="auto";n.title&&a.setAttribute("aria-label",n.title);let p=n.mode??"3d",h,m=x=>x==="3d"?o:i,y=x=>x==="3d"?a:d,I=x=>{o.hidden=x!=="3d",i.hidden=x!=="2d";for(let P of[o,i])P.style.cssText="";r.style.height="",r.dataset.mode=x};I(p);let N=()=>{for(let x of[a,d]){for(let P of x.querySelectorAll("[data-id]"))P.classList.toggle("sel",!!h&&P.getAttribute("data-id")===h);for(let P of x.querySelectorAll("[data-a]")){let b=!!h&&(P.getAttribute("data-a")===h||P.getAttribute("data-b")===h);P.classList.toggle("hot",b),P.classList.toggle("dim",!!h&&!b),x.querySelector(`[data-for="${CSS.escape(P.getAttribute("data-id")??"")}"]`)?.classList.toggle("dim",!!h&&!b)}}},M=x=>{h=x,N()},$=x=>{let P=x.target.closest?.("[data-id]");if(!P||!r.contains(P)||P.hasAttribute("data-a"))return;let b=P.getAttribute("data-id");M(b),n.onSelect?.(b)},R=x=>{(x.key==="Enter"||x.key===" ")&&x.target.matches?.("[data-id][tabindex]")&&(x.preventDefault(),$(x))};r.addEventListener("click",$),r.addEventListener("keydown",R);let E,w=()=>{if(!E)return;cancelAnimationFrame(E.frame),E.layer.remove();let x=E;E=void 0,p=x.to,I(p),N(),x.done()},T=x=>{!x||!h||y(p).querySelector(`[data-id="${CSS.escape(h)}"][tabindex]`)?.focus({preventScroll:!0})};return{get mode(){return E?E.to:p},layout:u,root:r,morph:x=>{let P=r.contains(document.activeElement);if(E&&w(),x===p)return T(P),Promise.resolve();let b=n.motion??"auto";return b==="never"||b==="auto"&&typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches||!(n.duration??600)?(p=x,I(p),N(),T(P),Promise.resolve()):new Promise(g=>{let O=p,F=r.getBoundingClientRect().height;o.hidden=!1,i.hidden=!1;for(let Z of[o,i])Z.style.cssText="position:absolute;left:0;top:0;right:0;visibility:hidden";let j=m(x).getBoundingClientRect().height;r.style.height=`${F}px`;let U=vr(r,y(O),y(x),O);r.appendChild(U.svg);let ne=n.duration??600,B=performance.now(),K={frame:0,layer:U.svg,to:x,done:()=>{T(P),g()}},q=Z=>{if(E!==K)return;let A=Math.min(1,(Z-B)/ne);U.at(A),r.style.height=`${F+(j-F)*kr(_n((A-.2)/.6))}px`,A<1?K.frame=requestAnimationFrame(q):w()};E=K,K.frame=requestAnimationFrame(q)})},select:M,get selected(){return h},svgOf:y,destroy(){E&&w(),r.removeEventListener("click",$),r.removeEventListener("keydown",R),r.remove()}}}function uf(t="iso-view"){try{let e=localStorage.getItem(t);return e==="2d"||e==="3d"?e:void 0}catch{return}}function df(t,e,n={}){let s=n.storageKey??"iso-view",r=Array.isArray(e)?e:[e],o=document.createElement("div");o.className="view-switch",o.setAttribute("role","group"),o.setAttribute("aria-label","Drawing view");let i=["3d","2d"].map((l,c)=>{let f=document.createElement("button");return f.type="button",f.dataset.mode=l,f.textContent=(n.labels??["3D","2D"])[c],f.addEventListener("click",()=>{try{localStorage.setItem(s,l)}catch{}a(l);for(let u of r)u.morph(l)}),o.appendChild(f),f}),a=l=>i.forEach(c=>c.setAttribute("aria-pressed",String(c.dataset.mode===l)));return a(r[0]?.mode??"3d"),t.appendChild(o),o}var pf=`
379
379
  .view-switch{display:inline-flex;border:1px solid var(--line);border-radius:8px;overflow:hidden;background:var(--surface);font:600 12px/1 system-ui,sans-serif;box-shadow:0 1px 4px rgba(0,0,0,.12)}
380
380
  .view-switch button{font:inherit;border:0;background:none;color:var(--ink);padding:6px 10px;cursor:pointer}
381
381
  .view-switch button+button{border-left:1px solid var(--line)}
@@ -385,4 +385,4 @@ ${e.extraBody??""}
385
385
  .dual-view .blk.sel polygon{stroke:var(--accent,#2f6fd6);stroke-width:2.4}
386
386
  .dual-view [data-a].dim{opacity:.3}
387
387
  .dual-view [data-a].hot path{stroke-width:3.4}
388
- `;export{Zl as core,$c as objects,mf as viewer};
388
+ `;export{tc as core,Tc as objects,mf as viewer};