@johnoscott/isometric-engine 0.14.1 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/iso-editor.js +249 -203
- package/iso-render.js +200 -154
- package/iso-systems.js +210 -162
- package/isometric-diagram.js +389 -0
- package/js/iso-core/index.js +5 -0
- package/js/iso-core/mono.js +242 -0
- package/js/iso-editor/ui/canvas.js +23 -1
- package/js/iso-objects/ants.js +36 -0
- package/js/iso-objects/index.js +55 -1
- package/js/iso-objects/looks.js +25 -0
- package/js/iso-objects/mono-paint.js +96 -0
- package/js/iso-objects/motion-builder.js +130 -0
- package/js/iso-objects/motion-doc.js +421 -0
- package/js/iso-objects/motion-entry.js +34 -0
- package/js/iso-objects/motion-schema.js +83 -0
- package/js/iso-objects/motion.js +640 -0
- package/js/iso-objects/resolve.js +238 -0
- package/js/iso-objects/scene.js +15 -13
- package/js/iso-objects/timeline.js +593 -0
- package/js/iso-systems/compile.js +83 -1
- package/js/iso-systems/index.js +4 -1
- package/js/iso-systems/render.js +20 -0
- package/js/iso-systems/schema.json +40 -0
- package/js/iso-viewer/index.js +6 -0
- package/js/iso-viewer/page.js +40 -16
- package/js/iso-viewer/play.js +340 -0
- package/js/iso-viewer/player.js +149 -175
- package/js/iso-viewer/transport.js +289 -0
- package/package.json +84 -2
- package/src/iso-core/index.ts +1 -0
- package/src/iso-core/mono.ts +306 -0
- package/src/iso-core/theme.ts +2 -1
- package/src/iso-editor/ui/canvas.ts +14 -1
- package/src/iso-objects/ants.ts +53 -0
- package/src/iso-objects/compile.ts +4 -1
- package/src/iso-objects/index.ts +16 -1
- package/src/iso-objects/looks.ts +21 -0
- package/src/iso-objects/mono-paint.ts +97 -0
- package/src/iso-objects/motion-builder.ts +79 -0
- package/src/iso-objects/motion-doc.ts +309 -0
- package/src/iso-objects/motion-entry.ts +13 -0
- package/src/iso-objects/motion-schema.ts +55 -0
- package/src/iso-objects/motion.ts +617 -0
- package/src/iso-objects/resolve.ts +196 -0
- package/src/iso-objects/scene.ts +32 -13
- package/src/iso-objects/timeline.ts +493 -0
- package/src/iso-objects/types.ts +22 -2
- package/src/iso-systems/compile.ts +86 -4
- package/src/iso-systems/index.ts +4 -1
- package/src/iso-systems/render.ts +45 -0
- package/src/iso-systems/schema.json +40 -0
- package/src/iso-viewer/index.ts +4 -0
- package/src/iso-viewer/page.ts +28 -11
- package/src/iso-viewer/play.ts +280 -0
- package/src/iso-viewer/player.ts +132 -150
- package/src/iso-viewer/transport.ts +272 -0
- package/types/iso-core/index.d.ts +1 -0
- package/types/iso-core/mono.d.ts +61 -0
- package/types/iso-core/theme.d.ts +2 -0
- package/types/iso-objects/ants.d.ts +34 -0
- package/types/iso-objects/compile.d.ts +3 -0
- package/types/iso-objects/index.d.ts +16 -1
- package/types/iso-objects/looks.d.ts +4 -0
- package/types/iso-objects/mono-paint.d.ts +20 -0
- package/types/iso-objects/motion-builder.d.ts +105 -0
- package/types/iso-objects/motion-doc.d.ts +193 -0
- package/types/iso-objects/motion-entry.d.ts +11 -0
- package/types/iso-objects/motion-schema.d.ts +594 -0
- package/types/iso-objects/motion.d.ts +202 -0
- package/types/iso-objects/resolve.d.ts +20 -0
- package/types/iso-objects/scene.d.ts +14 -0
- package/types/iso-objects/timeline.d.ts +66 -0
- package/types/iso-objects/types.d.ts +34 -0
- package/types/iso-systems/compile.d.ts +25 -3
- package/types/iso-systems/index.d.ts +4 -1
- package/types/iso-systems/render.d.ts +25 -0
- package/types/iso-viewer/index.d.ts +4 -0
- package/types/iso-viewer/play.d.ts +37 -0
- package/types/iso-viewer/transport.d.ts +73 -0
- package/types/player/isometric-diagram.d.ts +24 -0
package/iso-render.js
CHANGED
|
@@ -1,145 +1,156 @@
|
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");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
|
-
`)}};
|
|
3
|
-
`)?
|
|
1
|
+
var Nd=Object.defineProperty;var va=(n,e)=>{for(var t in e)Nd(n,t,{get:e[t],enumerable:!0})};var Pf={};va(Pf,{Bounds:()=>kr,C:()=>wt,DiagError:()=>ai,FONTS:()=>lt,Kernel:()=>js,MONO:()=>jt,S:()=>st,VEl:()=>Vr,allowed:()=>nl,apply:()=>xr,bubble:()=>wo,buildSvg:()=>Ef,center:()=>yo,colorRef:()=>Tn,contrast:()=>qr,createHash:()=>Of,depthSort:()=>Sr,didYouMean:()=>Bt,distance:()=>el,envelope:()=>xo,esc:()=>mt,extendTheme:()=>Xs,faceFrame:()=>Sa,fileLines:()=>ko,formatDiag:()=>tl,formatDiags:()=>kf,greyOf:()=>Gr,iso:()=>Ce,keyGlyph:()=>Ec,loadTheme:()=>oi,matStr:()=>wr,monoOf:()=>fi,n1:()=>at,parse:()=>Sf,parseSvg:()=>sl,placeholderFace:()=>Ac,pt:()=>xs,screenFaces:()=>Ds,screenGlass:()=>Oc,serialize:()=>li,sha256Hex:()=>rl,socketGlyph:()=>Tc,tag:()=>Ee,termLines:()=>vr,textWidth:()=>an,themeCss:()=>ii,themeParts:()=>Kr,vdoc:()=>Tf});var Mc={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 st=34,wt=Math.cos(Math.PI/6),Ce=(n,e,t=0)=>[(n-e)*wt*st,(n+e)*.5*st-t*st],at=n=>{let e=Math.round(n*10)/10;return Object.is(e,-0)?"0":String(e)},xs=n=>`${at(n[0])},${at(n[1])}`,mt=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function Ee(n,e={},t){let s="";for(let r in e){let o=e[r];o==null||o===!1||o===""||(s+=` ${r}="${mt(typeof o=="number"?at(o):o)}"`)}return t===void 0?`<${n}${s}/>`:`<${n}${s}>${t}</${n}>`}var lt={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 an(n,e){let t=Mc[e.key],s=e.key.startsWith("mono")?.6:.58,r=0;for(let o of n)r+=t[o]??s;return(r+(e.spacing??0)*[...n].length)*e.size}var xr=(n,e,t)=>[n[0]*e+n[2]*t+n[4],n[1]*e+n[3]*t+n[5]],wr=n=>`matrix(${n.map(e=>Math.round(e*1e4)/1e4).join(" ")})`;function Sa(n,e){if(e==="left"){let[r,o]=Ce(n.x0,n.y1,n.z1);return{m:[wt,.5,0,1,r,o],w:(n.x1-n.x0)*st,h:(n.z1-n.z0)*st}}if(e==="right"){let[r,o]=Ce(n.x1,n.y1,n.z1);return{m:[wt,-.5,0,1,r,o],w:(n.y1-n.y0)*st,h:(n.z1-n.z0)*st}}let[t,s]=Ce(n.x0,n.y0,n.z1);return{m:[wt,.5,-wt,.5,t,s],w:(n.x1-n.x0)*st,h:(n.y1-n.y0)*st}}var kr=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,t,s,r){this.add([e,t]),this.add([e+s,t+r])}get empty(){return this.x0===1/0}},js=class{bounds=new kr;texts=[];planes=[];planePolys=[];defs=new Map;poly(e,t,s={}){let r=e.map(o=>Ce(o[0],o[1],o[2]));return r.forEach(o=>this.bounds.add(o)),Ee("polygon",{points:r.map(xs).join(" "),class:t,...s})}line3(e,t,s,r={}){let o=Ce(...e),i=Ce(...t);return this.bounds.add(o),this.bounds.add(i),Ee("line",{x1:o[0],y1:o[1],x2:i[0],y2:i[1],class:s,...r})}blockFaces(e){let{x0:t,y0:s,x1:r,y1:o,z0:i,z1:l}=e;return this.poly([[t,o,i],[r,o,i],[r,o,l],[t,o,l]],"lft")+this.poly([[r,s,i],[r,o,i],[r,o,l],[r,s,l]],"rgt")+this.poly([[t,s,l],[r,s,l],[r,o,l],[t,o,l]],"top")}onFace(e,t,s,r){let o=Sa(e,t);for(let[i,l]of[[0,0],[o.w,0],[0,o.h],[o.w,o.h]])this.bounds.add(xr(o.m,i,l));return Ee("g",{class:r,transform:wr(o.m)},s(o.w,o.h))}onMatrix(e,t,s,r,o){for(let[i,l]of[[0,0],[t,0],[0,s],[t,s]])this.bounds.add(xr(e,i,l));return Ee("g",{class:o,transform:wr(e)},r(t,s))}text(e,t,s,r,o,i="middle",l={},a){let c=an(s,o),u={x:i==="start"?e:i==="end"?e-c:e-c/2,y:t-o.size*.8,w:c,h:o.size*1.05,text:s,owner:a};return this.bounds.addRect(u.x-2,u.y-2,u.w+4,u.h+4),this.texts.push(u),Ee("text",{x:e,y:t,class:r,"text-anchor":i==="start"?void 0:i,...l},mt(s))}planeText(e,t,s,r,o="start",i={}){let l=an(t,r),a=o==="start"?0:o==="end"?-l:-l/2,c=[[a,-r.size*.8],[a+l,-r.size*.8],[a,r.size*.25],[a+l,r.size*.25]].map(([d,h])=>xr(e,d,h));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)}),Ee("text",{transform:wr(e),class:s,"text-anchor":o==="start"?void 0:o,...i},mt(t))}floorText(e,t,s,r,o,i="x",l="start",a={}){let[c,f]=Ce(e,t,s),u=i==="x"?[wt,.5,-wt,.5,c,f]:[wt,-.5,wt,.5,c,f];return this.planeText(u,r,o,lt.floor,l,a)}faceText(e,t,s,r,o,i,l="left",a="start",c={}){let[f,u]=Ce(e,t,s),d=l==="left"?[wt,.5,0,1,f,u]:[wt,-.5,0,1,f,u];return this.planeText(d,r,o,i,a,c)}def(e,t){this.defs.set(e,t)}},yo=n=>[(n.x0+n.x1)/2,(n.y0+n.y1)/2,n.z1];function vr(n,e,t){let s="";for(let r=0;r<t;r++){let o=e.z1-(e.z1-e.z0)*(.28+r*.2),i=(e.x1-e.x0)*(r===t-1?.35:.62-r*.1);s+=n.line3([e.x0+.35,e.y1,o],[e.x0+.35+i,e.y1,o],"det")}return s}function xo(n,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],l=[e.x0+.55,e.y1-.55,s],a=[(e.x0+e.x1)/2,(e.y0+e.y1)/2,s];return n.poly([r,o,i,l],"det")+n.line3(r,a,"det")+n.line3(a,o,"det")}function wo(n,e){let s=e.z1,r=n.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+=n.line3([e.x0+.55+.3,i,s],[e.x1-.55-.3-(o===2?.5:0),i,s],"det")}return r}function ko(n,e){let s=e.z1,r=(e.y0+e.y1)/2;return n.line3([e.x0+.3,r-.2,s],[e.x1-.3,r-.2,s],"det")+n.line3([e.x0+.3,r+.2,s],[e.x1-.3-.3,r+.2,s],"det")}function Ec(n,e){let t=(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 l=0;l<20;l++){let a=l/20*Math.PI*2;i.push([t-o*1.4+Math.cos(a)*o,s+Math.sin(a)*o,r])}return n.poly(i,"det")+n.line3([t-o*.4,s,r],[t+o*2.2,s,r],"det")+n.line3([t+o*1.7,s,r],[t+o*1.7,s+o*.8,r],"det")}function Tc(n,e){let t=(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 l=0;l<24;l++){let a=l/24*Math.PI*2;i.push([t+Math.cos(a)*o,s+Math.sin(a)*o,r])}return n.poly(i,"det sock-hole")}var ws=(n,e,t,s,r,o=0)=>Ee("rect",{class:n,x:e,y:t,width:s,height:r,rx:o||void 0}),Ds={terminal(n,e){let t="",s=Math.max(2,Math.floor((e-12)/9));for(let r=0;r<s;r++){let o=10+r*9,i=(n-18)*[.7,.45,.6,.3,.55][r%5];t+=Ee("line",{class:"ln",x1:8,y1:o,x2:8+i,y2:o})}return t},chat(n,e){return[[6,.62,"w"],[.3,.58,"m"],[6,.46,"w"],[.42,.5,"m"]].map((s,r)=>{let o=(n-14)*s[1],i=s[0]===6?7:n-7-o;return ws(s[2],i,8+r*(e-18)/4,o,(e-18)/4-4,3)}).join("")},desktop(n,e){return ws("wall",5,5,n-10,e-10,2)+ws("bar",5,5,n-10,6)+ws("win",n*.5,13,n*.38,e*.42,2)},tiles(n,e){let i=(n-12-5)/3,l=(e-12-2.5*1)/2,a="";for(let c=0;c<2;c++)for(let f=0;f<3;f++){let u=6+f*(i+2.5),d=6+c*(l+2.5);a+=ws("t",u,d,i,l,1.5),[.3,.52,.74].forEach((h,b)=>{a+=Ee("line",{class:"ln",x1:u+2.5,y1:d+l*h,x2:u+2.5+(i-5)*[.8,.5,.65][(b+c+f)%3],y2:d+l*h})})}return a}};function Ac(n,e){let t=n/2,s=e/2,r=Math.min(n,e)*.22;return ws("unk",n*.2,e*.2,n*.6,e*.6,2)+Ee("path",{class:"unk-q",d:`M${at(t-r*.5)},${at(s-r*.45)}a${at(r*.5)},${at(r*.5)} 0 1 1 ${at(r*.5)},${at(r*.55)}v${at(r*.3)}`})+Ee("circle",{class:"unk-dot",cx:at(t),cy:at(s+r*.75),r:at(Math.max(.8,r*.1))})}function Oc(n,e){return ws("glass",3,3,n-6,e-6,3)}function Cd(n){let e=[Ce(n.x0,n.y0,n.z1),Ce(n.x1,n.y0,n.z0),Ce(n.x0,n.y1,n.z0),Ce(n.x1,n.y1,n.z0),Ce(n.x1,n.y1,n.z1),Ce(n.x0,n.y0,n.z0)],t=e.map(r=>r[0]),s=e.map(r=>r[1]);return[Math.min(...t),Math.min(...s),Math.max(...t),Math.max(...s)]}function Id(n,e){let s=n.x1<=e.x0+1e-6,r=e.x1<=n.x0+1e-6,o=n.y1<=e.y0+1e-6,i=e.y1<=n.y0+1e-6,l=n.z1<=e.z0+1e-6,a=e.z1<=n.z0+1e-6,c=s||o||l,f=r||i||a;return c&&!f?-1:f&&!c?1:0}function Sr(n){let e=n.length,t=n.map(c=>Cd(c.box)),s=c=>c.box.x0+c.box.y0+c.box.z0*.01,r=n.map(()=>[]),o=new Array(e).fill(0);for(let c=0;c<e;c++)for(let f=c+1;f<e;f++){let u=t[c],d=t[f];if(u[2]<=d[0]||d[2]<=u[0]||u[3]<=d[1]||d[3]<=u[1])continue;let h=Id(n[c].box,n[f].box);h<0?(r[c].push(f),o[f]++):h>0&&(r[f].push(c),o[c]++)}let i=[],l=n.map((c,f)=>f).filter(c=>!o[c]),a=new Array(e).fill(!1);for(;i.length<e;){if(!l.length){let f=n.map((u,d)=>d).filter(u=>!a[u]).sort((u,d)=>s(n[u])-s(n[d]));l.push(f[0]),o[f[0]]=0}l.sort((f,u)=>s(n[f])-s(n[u])||f-u);let c=l.shift();if(!a[c]){a[c]=!0,i.push(n[c]);for(let f of r[c])!a[f]&&--o[f]===0&&l.push(f)}}return i}var vo=Symbol.for("yaml.alias"),So=Symbol.for("yaml.document"),wn=Symbol.for("yaml.map"),$a=Symbol.for("yaml.pair"),Qt=Symbol.for("yaml.scalar"),Wn=Symbol.for("yaml.seq"),Kt=Symbol.for("yaml.node.type"),kn=n=>!!n&&typeof n=="object"&&n[Kt]===vo,Fn=n=>!!n&&typeof n=="object"&&n[Kt]===So,qt=n=>!!n&&typeof n=="object"&&n[Kt]===wn,Ge=n=>!!n&&typeof n=="object"&&n[Kt]===$a,_e=n=>!!n&&typeof n=="object"&&n[Kt]===Qt,Ut=n=>!!n&&typeof n=="object"&&n[Kt]===Wn;function Xe(n){if(n&&typeof n=="object")switch(n[Kt]){case wn:case Wn:return!0}return!1}function He(n){if(n&&typeof n=="object")switch(n[Kt]){case vo:case wn:case Qt:case Wn:return!0}return!1}var $o=n=>(_e(n)||Xe(n))&&!!n.anchor;var Ht=Symbol("break visit"),Nc=Symbol("skip children"),Bn=Symbol("remove node");function jn(n,e){let t=Rc(e);Fn(n)?_s(null,n.contents,t,Object.freeze([n]))===Bn&&(n.contents=null):_s(null,n,t,Object.freeze([]))}jn.BREAK=Ht;jn.SKIP=Nc;jn.REMOVE=Bn;function _s(n,e,t,s){let r=Pc(n,e,t,s);if(He(r)||Ge(r))return Cc(n,s,r),_s(n,r,t,s);if(typeof r!="symbol"){if(Xe(e)){s=Object.freeze(s.concat(e));for(let o=0;o<e.items.length;++o){let i=_s(o,e.items[o],t,s);if(typeof i=="number")o=i-1;else{if(i===Ht)return Ht;i===Bn&&(e.items.splice(o,1),o-=1)}}}else if(Ge(e)){s=Object.freeze(s.concat(e));let o=_s("key",e.key,t,s);if(o===Ht)return Ht;o===Bn&&(e.key=null);let i=_s("value",e.value,t,s);if(i===Ht)return Ht;i===Bn&&(e.value=null)}}return r}async function Mo(n,e){let t=Rc(e);Fn(n)?await zs(null,n.contents,t,Object.freeze([n]))===Bn&&(n.contents=null):await zs(null,n,t,Object.freeze([]))}Mo.BREAK=Ht;Mo.SKIP=Nc;Mo.REMOVE=Bn;async function zs(n,e,t,s){let r=await Pc(n,e,t,s);if(He(r)||Ge(r))return Cc(n,s,r),zs(n,r,t,s);if(typeof r!="symbol"){if(Xe(e)){s=Object.freeze(s.concat(e));for(let o=0;o<e.items.length;++o){let i=await zs(o,e.items[o],t,s);if(typeof i=="number")o=i-1;else{if(i===Ht)return Ht;i===Bn&&(e.items.splice(o,1),o-=1)}}}else if(Ge(e)){s=Object.freeze(s.concat(e));let o=await zs("key",e.key,t,s);if(o===Ht)return Ht;o===Bn&&(e.key=null);let i=await zs("value",e.value,t,s);if(i===Ht)return Ht;i===Bn&&(e.value=null)}}return r}function Rc(n){return typeof n=="object"&&(n.Collection||n.Node||n.Value)?Object.assign({Alias:n.Node,Map:n.Node,Scalar:n.Node,Seq:n.Node},n.Value&&{Map:n.Value,Scalar:n.Value,Seq:n.Value},n.Collection&&{Map:n.Collection,Seq:n.Collection},n):n}function Pc(n,e,t,s){if(typeof t=="function")return t(n,e,s);if(qt(e))return t.Map?.(n,e,s);if(Ut(e))return t.Seq?.(n,e,s);if(Ge(e))return t.Pair?.(n,e,s);if(_e(e))return t.Scalar?.(n,e,s);if(kn(e))return t.Alias?.(n,e,s)}function Cc(n,e,t){let s=e[e.length-1];if(Xe(s))s.items[n]=t;else if(Ge(s))n==="key"?s.key=t:s.value=t;else if(Fn(s))s.contents=t;else{let r=kn(s)?"alias":"scalar";throw new Error(`Cannot replace node with ${r} parent`)}}var Ld={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Fd=n=>n.replace(/[!,[\]{}]/g,e=>Ld[e]),Dn=class n{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},n.defaultYaml,e),this.tags=Object.assign({},n.defaultTags,t)}clone(){let e=new n(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new n(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:n.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},n.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:n.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},n.defaultTags),this.atNextDocument=!1);let s=e.trim().split(/[ \t]+/),r=s.shift();switch(r){case"%TAG":{if(s.length!==2&&(t(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 t(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 t(6,`Unsupported YAML version ${o}`,i),!1}}default:return t(0,`Unknown directive ${r}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let i=e.slice(2,-1);return i==="!"||i==="!!"?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),i)}let[,s,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let o=this.tags[s];if(o)try{return o+decodeURIComponent(r)}catch(i){return t(String(i)),null}return s==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,s]of Object.entries(this.tags))if(e.startsWith(s))return t+Fd(e.substring(s.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags),r;if(e&&s.length>0&&He(e.contents)){let o={};jn(e.contents,(i,l)=>{He(l)&&l.tag&&(o[l.tag]=!0)}),r=Object.keys(o)}else r=[];for(let[o,i]of s)o==="!!"&&i==="tag:yaml.org,2002:"||(!e||r.some(l=>l.startsWith(i)))&&t.push(`%TAG ${o} ${i}`);return t.join(`
|
|
2
|
+
`)}};Dn.defaultYaml={explicit:!1,version:"1.2"};Dn.defaultTags={"!!":"tag:yaml.org,2002:"};function Eo(n){if(/[\x00-\x19\s,[\]{}]/.test(n)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(n)}`;throw new Error(t)}return!0}function Ma(n){let e=new Set;return jn(n,{Value(t,s){s.anchor&&e.add(s.anchor)}}),e}function Ea(n,e){for(let t=1;;++t){let s=`${n}${t}`;if(!e.has(s))return s}}function Ic(n,e){let t=[],s=new Map,r=null;return{onAnchor:o=>{t.push(o),r??(r=Ma(n));let i=Ea(e,r);return r.add(i),i},setAnchors:()=>{for(let o of t){let i=s.get(o);if(typeof i=="object"&&i.anchor&&(_e(i.node)||Xe(i.node)))i.node.anchor=i.anchor;else{let l=new Error("Failed to resolve repeated object (this should not happen)");throw l.source=o,l}}},sourceObjects:s}}function rs(n,e,t,s){if(s&&typeof s=="object")if(Array.isArray(s))for(let r=0,o=s.length;r<o;++r){let i=s[r],l=rs(n,s,String(r),i);l===void 0?delete s[r]:l!==i&&(s[r]=l)}else if(s instanceof Map)for(let r of Array.from(s.keys())){let o=s.get(r),i=rs(n,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=rs(n,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=rs(n,s,r,o);i===void 0?delete s[r]:i!==o&&(s[r]=i)}return n.call(e,t,s)}function Mt(n,e,t){if(Array.isArray(n))return n.map((s,r)=>Mt(s,String(r),t));if(n&&typeof n.toJSON=="function"){if(!t||!$o(n))return n.toJSON(e,t);let s={aliasCount:0,count:1,res:void 0};t.anchors.set(n,s),t.onCreate=o=>{s.res=o,delete t.onCreate};let r=n.toJSON(e,t);return t.onCreate&&t.onCreate(r),r}return typeof n=="bigint"&&!t?.keep?Number(n):n}var os=class{constructor(e){Object.defineProperty(this,Kt,{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:t,maxAliasCount:s,onAnchor:r,reviver:o}={}){if(!Fn(e))throw new TypeError("A document argument is required");let i={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},l=Mt(this,"",i);if(typeof r=="function")for(let{count:a,res:c}of i.anchors.values())r(c,a);return typeof o=="function"?rs(o,{"":l},"",l):l}};var Jn=class extends os{constructor(e){super(vo),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let s;t?.aliasResolveCache?s=t.aliasResolveCache:(s=[],jn(e,{Node:(o,i)=>{(kn(i)||$o(i))&&s.push(i)}}),t&&(t.aliasResolveCache=s));let r;for(let o of s){if(o===this)break;o.anchor===this.source&&(r=o)}if(r&&t){let{anchors:o,doc:i,maxAliasCount:l}=t,a=o.get(r);if(a||(Mt(r,null,t),a=o.get(r)),a?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(l>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=To(i,r,o)),a.count*a.aliasCount>l)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}}return r}toJSON(e,t){if(!t)return{source:this.source};let s=this.resolve(t.doc,t);if(!s){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(r)}return t.anchors.get(s).res}toString(e,t,s){let r=`*${this.source}`;if(e){if(Eo(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 To(n,e,t){if(kn(e)){let s=e.resolve(n),r=t&&s&&t.get(s);return r?r.count*r.aliasCount:0}else if(Xe(e)){let s=0;for(let r of e.items){let o=To(n,r,t);o>s&&(s=o)}return s}else if(Ge(e)){let s=To(n,e.key,t),r=To(n,e.value,t);return Math.max(s,r)}return 1}var Ao=n=>!n||typeof n!="function"&&typeof n!="object",Ae=class extends os{constructor(e){super(Qt),this.value=e}toJSON(e,t){return t?.keep?this.value:Mt(this.value,e,t)}toString(){return String(this.value)}};Ae.BLOCK_FOLDED="BLOCK_FOLDED";Ae.BLOCK_LITERAL="BLOCK_LITERAL";Ae.PLAIN="PLAIN";Ae.QUOTE_DOUBLE="QUOTE_DOUBLE";Ae.QUOTE_SINGLE="QUOTE_SINGLE";var Bd="tag:yaml.org,2002:";function jd(n,e,t){if(e){let s=t.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 t.find(s=>s.identify?.(n)&&!s.format)}function Xn(n,e,t){if(Fn(n)&&(n=n.contents),He(n))return n;if(Ge(n)){let u=t.schema[wn].createNode?.(t.schema,null,t);return u.items.push(n),u}(n instanceof String||n instanceof Number||n instanceof Boolean||typeof BigInt<"u"&&n instanceof BigInt)&&(n=n.valueOf());let{aliasDuplicateObjects:s,onAnchor:r,onTagObj:o,schema:i,sourceObjects:l}=t,a;if(s&&n&&typeof n=="object"){if(a=l.get(n),a)return a.anchor??(a.anchor=r(n)),new Jn(a.anchor);a={anchor:null,node:null},l.set(n,a)}e?.startsWith("!!")&&(e=Bd+e.slice(2));let c=jd(n,e,i.tags);if(!c){if(n&&typeof n.toJSON=="function"&&(n=n.toJSON()),!n||typeof n!="object"){let u=new Ae(n);return a&&(a.node=u),u}c=n instanceof Map?i[wn]:Symbol.iterator in Object(n)?i[Wn]:i[wn]}o&&(o(c),delete t.onTagObj);let f=c?.createNode?c.createNode(t.schema,n,t):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(t.schema,n,t):new Ae(n);return e?f.tag=e:c.default||(f.tag=c.tag),a&&(a.node=f),f}function $r(n,e,t){let s=t;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 Xn(s,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:n,sourceObjects:new Map})}var Vs=n=>n==null||typeof n=="object"&&!!n[Symbol.iterator]().next().done,Ks=class extends os{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(s=>He(s)||Ge(s)?s.clone(e):s),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Vs(e))this.add(t);else{let[s,...r]=e,o=this.get(s,!0);if(Xe(o))o.addIn(r,t);else if(o===void 0&&this.schema)this.set(s,$r(this.schema,r,t));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${r}`)}}deleteIn(e){let[t,...s]=e;if(s.length===0)return this.delete(t);let r=this.get(t,!0);if(Xe(r))return r.deleteIn(s);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${s}`)}getIn(e,t){let[s,...r]=e,o=this.get(s,!0);return r.length===0?!t&&_e(o)?o.value:o:Xe(o)?o.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!Ge(t))return!1;let s=t.value;return s==null||e&&_e(s)&&s.value==null&&!s.commentBefore&&!s.comment&&!s.tag})}hasIn(e){let[t,...s]=e;if(s.length===0)return this.has(t);let r=this.get(t,!0);return Xe(r)?r.hasIn(s):!1}setIn(e,t){let[s,...r]=e;if(r.length===0)this.set(s,t);else{let o=this.get(s,!0);if(Xe(o))o.setIn(r,t);else if(o===void 0&&this.schema)this.set(s,$r(this.schema,r,t));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${r}`)}}};var Lc=n=>n.replace(/^(?!$)(?: $)?/gm,"#");function ln(n,e){return/^\n+$/.test(n)?n.substring(1):e?n.replace(/^(?! *$)/gm,e):n}var _n=(n,e,t)=>n.endsWith(`
|
|
3
|
+
`)?ln(t,e):t.includes(`
|
|
4
4
|
`)?`
|
|
5
|
-
`+
|
|
6
|
-
`)
|
|
7
|
-
`&&
|
|
8
|
-
|
|
9
|
-
${e}${
|
|
10
|
-
${e}${
|
|
11
|
-
`);s=e,r=e+1,o=
|
|
12
|
-
`){if(o-i>s)return!0;if(i=o+1,r-i<=s)return!1}return!0}function
|
|
5
|
+
`+ln(t,e):(n.endsWith(" ")?"":" ")+t;var Ta="flow",Oo="block",Mr="quoted";function Er(n,e,t="flow",{indentAtStart:s,lineWidth:r=80,minContentWidth:o=20,onFold:i,onOverflow:l}={}){if(!r||r<0)return n;r<o&&(o=0);let a=Math.max(1+o,1+r-e.length);if(n.length<=a)return n;let c=[],f={},u=r-e.length;typeof s=="number"&&(s>r-Math.max(2,o)?c.push(0):u=r-s);let d,h,b=!1,m=-1,y=-1,N=-1;t===Oo&&(m=Fc(n,m,e.length),m!==-1&&(u=m+a));for(let g;g=n[m+=1];){if(t===Mr&&g==="\\"){switch(y=m,n[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}N=m}if(g===`
|
|
6
|
+
`)t===Oo&&(m=Fc(n,m,e.length)),u=m+e.length+a,d=void 0;else{if(g===" "&&h&&h!==" "&&h!==`
|
|
7
|
+
`&&h!==" "){let x=n[m+1];x&&x!==" "&&x!==`
|
|
8
|
+
`&&x!==" "&&(d=m)}if(m>=u)if(d)c.push(d),u=d+a,d=void 0;else if(t===Mr){for(;h===" "||h===" ";)h=g,g=n[m+=1],b=!0;let x=m>N+1?m-2:y-1;if(f[x])return n;c.push(x),f[x]=!0,u=x+a,d=void 0}else b=!0}h=g}if(b&&l&&l(),c.length===0)return n;i&&i();let p=n.slice(0,c[0]);for(let g=0;g<c.length;++g){let x=c[g],$=c[g+1]||n.length;x===0?p=`
|
|
9
|
+
${e}${n.slice(0,$)}`:(t===Mr&&f[x]&&(p+=`${n[x]}\\`),p+=`
|
|
10
|
+
${e}${n.slice(x+1,$)}`)}return p}function Fc(n,e,t){let s=e,r=e+1,o=n[r];for(;o===" "||o===" ";)if(e<r+t)o=n[++e];else{do o=n[++e];while(o&&o!==`
|
|
11
|
+
`);s=e,r=e+1,o=n[r]}return s}var Ro=(n,e)=>({indentAtStart:e?n.indent.length:n.indentAtStart,lineWidth:n.options.lineWidth,minContentWidth:n.options.minContentWidth}),Po=n=>/^(%|---|\.\.\.)/m.test(n);function Dd(n,e,t){if(!e||e<0)return!1;let s=e-t,r=n.length;if(r<=s)return!1;for(let o=0,i=0;o<r;++o)if(n[o]===`
|
|
12
|
+
`){if(o-i>s)return!0;if(i=o+1,r-i<=s)return!1}return!0}function Tr(n,e){let t=JSON.stringify(n);if(e.options.doubleQuotedAsJSON)return t;let{implicitKey:s}=e,r=e.options.doubleQuotedMinMultiLineLength,o=e.indent||(Po(n)?" ":""),i="",l=0;for(let a=0,c=t[a];c;c=t[++a])if(c===" "&&t[a+1]==="\\"&&t[a+2]==="n"&&(i+=t.slice(l,a)+"\\ ",a+=1,l=a,c="\\"),c==="\\")switch(t[a+1]){case"u":{i+=t.slice(l,a);let f=t.substr(a+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+=t.substr(a,6)}a+=5,l=a+1}break;case"n":if(s||t[a+2]==='"'||t.length<r)a+=1;else{for(i+=t.slice(l,a)+`
|
|
13
13
|
|
|
14
|
-
`;
|
|
15
|
-
`,
|
|
16
|
-
`)||/[ \t]\n|\n[ \t]/.test(
|
|
17
|
-
${
|
|
14
|
+
`;t[a+2]==="\\"&&t[a+3]==="n"&&t[a+4]!=='"';)i+=`
|
|
15
|
+
`,a+=2;i+=o,t[a+2]===" "&&(i+="\\"),a+=1,l=a+1}break;default:a+=1}return i=l?i+t.slice(l):t,s?i:Er(i,o,Mr,Ro(e,!1))}function Aa(n,e){if(e.options.singleQuote===!1||e.implicitKey&&n.includes(`
|
|
16
|
+
`)||/[ \t]\n|\n[ \t]/.test(n))return Tr(n,e);let t=e.indent||(Po(n)?" ":""),s="'"+n.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
17
|
+
${t}`)+"'";return e.implicitKey?s:Er(s,t,Ta,Ro(e,!1))}function Gs(n,e){let{singleQuote:t}=e.options,s;if(t===!1)s=Tr;else{let r=n.includes('"'),o=n.includes("'");r&&!o?s=Aa:o&&!r?s=Tr:s=t?Aa:Tr}return s(n,e)}var Oa;try{Oa=new RegExp(`(^|(?<!
|
|
18
18
|
))
|
|
19
19
|
+(?!
|
|
20
|
-
|$)`,"g")}catch{
|
|
20
|
+
|$)`,"g")}catch{Oa=/\n+(?!\n|$)/g}function No({comment:n,type:e,value:t},s,r,o){let{blockQuote:i,commentString:l,lineWidth:a}=s.options;if(!i||/\n[\t ]+$/.test(t))return Gs(t,s);let c=s.indent||(s.forceBlockIndent||Po(t)?" ":""),f=i==="literal"?!0:i==="folded"||e===Ae.BLOCK_FOLDED?!1:e===Ae.BLOCK_LITERAL?!0:!Dd(t,a,c.length);if(!t)return f?`|
|
|
21
21
|
`:`>
|
|
22
|
-
`;let u,d;for(d=
|
|
23
|
-
|
|
24
|
-
`);
|
|
25
|
-
`&&(
|
|
26
|
-
`)
|
|
27
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),
|
|
28
|
-
${c}${
|
|
29
|
-
${c}${
|
|
30
|
-
`)||f&&/[[\]{},]/.test(o))return
|
|
31
|
-
`)?
|
|
32
|
-
`))return
|
|
33
|
-
${
|
|
34
|
-
${e.indent}${
|
|
35
|
-
${
|
|
36
|
-
`:"",
|
|
37
|
-
${
|
|
38
|
-
`&&
|
|
22
|
+
`;let u,d;for(d=t.length;d>0;--d){let $=t[d-1];if($!==`
|
|
23
|
+
`&&$!==" "&&$!==" ")break}let h=t.substring(d),b=h.indexOf(`
|
|
24
|
+
`);b===-1?u="-":t===h||b!==h.length-1?(u="+",o&&o()):u="",h&&(t=t.slice(0,-h.length),h[h.length-1]===`
|
|
25
|
+
`&&(h=h.slice(0,-1)),h=h.replace(Oa,`$&${c}`));let m=!1,y,N=-1;for(y=0;y<t.length;++y){let $=t[y];if($===" ")m=!0;else if($===`
|
|
26
|
+
`)N=y;else break}let p=t.substring(0,N<y?N+1:y);p&&(t=t.substring(p.length),p=p.replace(/\n+/g,`$&${c}`));let x=(m?c?"2":"1":"")+u;if(n&&(x+=" "+l(n.replace(/ ?[\r\n]+/g," ")),r&&r()),!f){let $=t.replace(/\n+/g,`
|
|
27
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),T=!1,v=Ro(s,!0);i!=="folded"&&e!==Ae.BLOCK_FOLDED&&(v.onOverflow=()=>{T=!0});let A=Er(`${p}${$}${h}`,c,Oo,v);if(!T)return`>${x}
|
|
28
|
+
${c}${A}`}return t=t.replace(/\n+/g,`$&${c}`),`|${x}
|
|
29
|
+
${c}${p}${t}${h}`}function _d(n,e,t,s){let{type:r,value:o}=n,{actualString:i,implicitKey:l,indent:a,indentStep:c,inFlow:f}=e;if(l&&o.includes(`
|
|
30
|
+
`)||f&&/[[\]{},]/.test(o))return Gs(o,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return l||f||!o.includes(`
|
|
31
|
+
`)?Gs(o,e):No(n,e,t,s);if(!l&&!f&&r!==Ae.PLAIN&&o.includes(`
|
|
32
|
+
`))return No(n,e,t,s);if(Po(o)){if(a==="")return e.forceBlockIndent=!0,No(n,e,t,s);if(l&&a===c)return Gs(o,e)}let u=o.replace(/\n+/g,`$&
|
|
33
|
+
${a}`);if(i){let d=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(u),{compat:h,tags:b}=e.doc.schema;if(b.some(d)||h?.some(d))return Gs(o,e)}return l?u:Er(u,a,Ta,Ro(e,!1))}function ks(n,e,t,s){let{implicitKey:r,inFlow:o}=e,i=typeof n.value=="string"?n:Object.assign({},n,{value:String(n.value)}),{type:l}=n;l!==Ae.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(i.value)&&(l=Ae.QUOTE_DOUBLE);let a=f=>{switch(f){case Ae.BLOCK_FOLDED:case Ae.BLOCK_LITERAL:return r||o?Gs(i.value,e):No(i,e,t,s);case Ae.QUOTE_DOUBLE:return Tr(i.value,e);case Ae.QUOTE_SINGLE:return Aa(i.value,e);case Ae.PLAIN:return _d(i,e,t,s);default:return null}},c=a(l);if(c===null){let{defaultKeyType:f,defaultStringType:u}=e.options,d=r&&f||u;if(c=a(d),c===null)throw new Error(`Unsupported default string type ${d}`)}return c}function Co(n,e){let t=Object.assign({blockQuote:!0,commentString:Lc,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},n.schema.toStringOptions,e),s;switch(t.collectionStyle){case"block":s=!1;break;case"flow":s=!0;break;default:s=null}return{anchors:new Set,doc:n,flowCollectionPadding:t.flowCollectionPadding?" ":"",indent:"",indentStep:typeof t.indent=="number"?" ".repeat(t.indent):" ",inFlow:s,options:t}}function zd(n,e){if(e.tag){let r=n.filter(o=>o.tag===e.tag);if(r.length>0)return r.find(o=>o.format===e.format)??r[0]}let t,s;if(_e(e)){s=e.value;let r=n.filter(o=>o.identify?.(s));if(r.length>1){let o=r.filter(i=>i.test);o.length>0&&(r=o)}t=r.find(o=>o.format===e.format)??r.find(o=>!o.format)}else s=e,t=n.find(r=>r.nodeClass&&s instanceof r.nodeClass);if(!t){let r=s?.constructor?.name??(s===null?"null":typeof s);throw new Error(`Tag not resolved for ${r} value`)}return t}function Kd(n,e,{anchors:t,doc:s}){if(!s.directives)return"";let r=[],o=(_e(n)||Xe(n))&&n.anchor;o&&Eo(o)&&(t.add(o),r.push(`&${o}`));let i=n.tag??(e.default?null:e.tag);return i&&r.push(s.directives.tagString(i)),r.join(" ")}function Qn(n,e,t,s){if(Ge(n))return n.toString(e,t,s);if(kn(n)){if(e.doc.directives)return n.toString(e);if(e.resolvedAliases?.has(n))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(n):e.resolvedAliases=new Set([n]),n=n.resolve(e.doc)}let r,o=He(n)?n:e.doc.createNode(n,{onTagObj:a=>r=a});r??(r=zd(e.doc.schema.tags,o));let i=Kd(o,r,e);i.length>0&&(e.indentAtStart=(e.indentAtStart??0)+i.length+1);let l=typeof r.stringify=="function"?r.stringify(o,e,t,s):_e(o)?ks(o,e,t,s):o.toString(e,t,s);return i?_e(o)||l[0]==="{"||l[0]==="["?`${i} ${l}`:`${i}
|
|
34
|
+
${e.indent}${l}`:l}function Bc({key:n,value:e},t,s,r){let{allNullValues:o,doc:i,indent:l,indentStep:a,options:{commentString:c,indentSeq:f,simpleKeys:u}}=t,d=He(n)&&n.comment||null;if(u){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(Xe(n)||!He(n)&&typeof n=="object"){let v="With simple keys, collection cannot be used as a key value";throw new Error(v)}}let h=!u&&(!n||d&&e==null&&!t.inFlow||Xe(n)||(_e(n)?n.type===Ae.BLOCK_FOLDED||n.type===Ae.BLOCK_LITERAL:typeof n=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!h&&(u||!o),indent:l+a});let b=!1,m=!1,y=Qn(n,t,()=>b=!0,()=>m=!0);if(!h&&!t.inFlow&&y.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(t.inFlow){if(o||e==null)return b&&s&&s(),y===""?"?":h?`? ${y}`:y}else if(o&&!u||e==null&&h)return y=`? ${y}`,d&&!b?y+=_n(y,t.indent,c(d)):m&&r&&r(),y;b&&(d=null),h?(d&&(y+=_n(y,t.indent,c(d))),y=`? ${y}
|
|
35
|
+
${l}:`):(y=`${y}:`,d&&(y+=_n(y,t.indent,c(d))));let N,p,g;He(e)?(N=!!e.spaceBefore,p=e.commentBefore,g=e.comment):(N=!1,p=null,g=null,e&&typeof e=="object"&&(e=i.createNode(e))),t.implicitKey=!1,!h&&!d&&_e(e)&&(t.indentAtStart=y.length+1),m=!1,!f&&a.length>=2&&!t.inFlow&&!h&&Ut(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let x=!1,$=Qn(e,t,()=>x=!0,()=>m=!0),T=" ";if(d||N||p){if(T=N?`
|
|
36
|
+
`:"",p){let v=c(p);T+=`
|
|
37
|
+
${ln(v,t.indent)}`}$===""&&!t.inFlow?T===`
|
|
38
|
+
`&&g&&(T=`
|
|
39
39
|
|
|
40
|
-
`):
|
|
41
|
-
${
|
|
42
|
-
`),L=
|
|
43
|
-
${
|
|
44
|
-
`)&&(
|
|
45
|
-
${
|
|
46
|
-
`}}return
|
|
47
|
-
`+
|
|
48
|
-
`)),
|
|
40
|
+
`):T+=`
|
|
41
|
+
${t.indent}`}else if(!h&&Xe(e)){let v=$[0],A=$.indexOf(`
|
|
42
|
+
`),L=A!==-1,M=t.inFlow??e.flow??e.items.length===0;if(L||!M){let P=!1;if(L&&(v==="&"||v==="!")){let k=$.indexOf(" ");v==="&"&&k!==-1&&k<A&&$[k+1]==="!"&&(k=$.indexOf(" ",k+1)),(k===-1||A<k)&&(P=!0)}P||(T=`
|
|
43
|
+
${t.indent}`)}}else($===""||$[0]===`
|
|
44
|
+
`)&&(T="");return y+=T+$,t.inFlow?x&&s&&s():g&&!x?y+=_n(y,t.indent,c(g)):m&&r&&r(),y}function Io(n,e){(n==="debug"||n==="warn")&&console.warn(e)}var Lo="<<",vn={identify:n=>n===Lo||typeof n=="symbol"&&n.description===Lo,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Ae(Symbol(Lo)),{addToJSMap:Ra}),stringify:()=>Lo},jc=(n,e)=>(vn.identify(e)||_e(e)&&(!e.type||e.type===Ae.PLAIN)&&vn.identify(e.value))&&n?.doc.schema.tags.some(t=>t.tag===vn.tag&&t.default);function Ra(n,e,t){let s=Dc(n,t);if(Ut(s))for(let r of s.items)Na(n,e,r);else if(Array.isArray(s))for(let r of s)Na(n,e,r);else Na(n,e,s)}function Na(n,e,t){let s=Dc(n,t);if(!qt(s))throw new Error("Merge sources must be maps or map aliases");let r=s.toJSON(null,n,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 Dc(n,e){return n&&kn(e)?e.resolve(n.doc,n):e}function Fo(n,e,{key:t,value:s}){if(He(t)&&t.addToJSMap)t.addToJSMap(n,e,s);else if(jc(n,t))Ra(n,e,s);else{let r=Mt(t,"",n);if(e instanceof Map)e.set(r,Mt(s,r,n));else if(e instanceof Set)e.add(r);else{let o=Vd(t,r,n),i=Mt(s,o,n);o in e?Object.defineProperty(e,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):e[o]=i}}return e}function Vd(n,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(He(n)&&t?.doc){let s=Co(t.doc,{});s.anchors=new Set;for(let o of t.anchors.keys())s.anchors.add(o.anchor);s.inFlow=!0,s.inStringifyKey=!0;let r=n.toString(s);if(!t.mapKeyWarned){let o=JSON.stringify(r);o.length>40&&(o=o.substring(0,36)+'..."'),Io(t.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),t.mapKeyWarned=!0}return r}return JSON.stringify(e)}function qs(n,e,t){let s=Xn(n,void 0,t),r=Xn(e,void 0,t);return new yt(s,r)}var yt=class n{constructor(e,t=null){Object.defineProperty(this,Kt,{value:$a}),this.key=e,this.value=t}clone(e){let{key:t,value:s}=this;return He(t)&&(t=t.clone(e)),He(s)&&(s=s.clone(e)),new n(t,s)}toJSON(e,t){let s=t?.mapAsMap?new Map:{};return Fo(t,s,this)}toString(e,t,s){return e?.doc?Bc(this,e,t,s):JSON.stringify(this)}};function jo(n,e,t){return(e.inFlow??n.flow?qd:Gd)(n,e,t)}function Gd({comment:n,items:e},t,{blockItemPrefix:s,flowChars:r,itemIndent:o,onChompKeep:i,onComment:l}){let{indent:a,options:{commentString:c}}=t,f=Object.assign({},t,{indent:o,type:null}),u=!1,d=[];for(let b=0;b<e.length;++b){let m=e[b],y=null;if(He(m))!u&&m.spaceBefore&&d.push(""),Bo(t,d,m.commentBefore,u),m.comment&&(y=m.comment);else if(Ge(m)){let p=He(m.key)?m.key:null;p&&(!u&&p.spaceBefore&&d.push(""),Bo(t,d,p.commentBefore,u))}u=!1;let N=Qn(m,f,()=>y=null,()=>u=!0);y&&(N+=_n(N,o,c(y))),u&&y&&(u=!1),d.push(s+N)}let h;if(d.length===0)h=r.start+r.end;else{h=d[0];for(let b=1;b<d.length;++b){let m=d[b];h+=m?`
|
|
45
|
+
${a}${m}`:`
|
|
46
|
+
`}}return n?(h+=`
|
|
47
|
+
`+ln(c(n),a),l&&l()):u&&i&&i(),h}function qd({items:n},e,{flowChars:t,itemIndent:s}){let{indent:r,indentStep:o,flowCollectionPadding:i,options:{commentString:l}}=e;s+=o;let a=Object.assign({},e,{indent:s,inFlow:!0,type:null}),c=!1,f=0,u=[];for(let b=0;b<n.length;++b){let m=n[b],y=null;if(He(m))m.spaceBefore&&u.push(""),Bo(e,u,m.commentBefore,!1),m.comment&&(y=m.comment);else if(Ge(m)){let p=He(m.key)?m.key:null;p&&(p.spaceBefore&&u.push(""),Bo(e,u,p.commentBefore,!1),p.comment&&(c=!0));let g=He(m.value)?m.value:null;g?(g.comment&&(y=g.comment),g.commentBefore&&(c=!0)):m.value==null&&p?.comment&&(y=p.comment)}y&&(c=!0);let N=Qn(m,a,()=>y=null);c||(c=u.length>f||N.includes(`
|
|
48
|
+
`)),b<n.length-1?N+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(c||(c=u.reduce((p,g)=>p+g.length+2,2)+(N.length+2)>e.options.lineWidth)),c&&(N+=",")),y&&(N+=_n(N,s,l(y))),u.push(N),f=u.length}let{start:d,end:h}=t;if(u.length===0)return d+h;if(!c){let b=u.reduce((m,y)=>m+y.length+2,2);c=e.options.lineWidth>0&&b>e.options.lineWidth}if(c){let b=d;for(let m of u)b+=m?`
|
|
49
49
|
${o}${r}${m}`:`
|
|
50
|
-
`;return`${
|
|
51
|
-
${r}${
|
|
52
|
-
`:" ")}return
|
|
50
|
+
`;return`${b}
|
|
51
|
+
${r}${h}`}else return`${d}${i}${u.join(" ")}${i}${h}`}function Bo({indent:n,options:{commentString:e}},t,s,r){if(s&&r&&(s=s.replace(/^\n+/,"")),s){let o=ln(e(s),n);t.push(o.trimStart())}}function is(n,e){let t=_e(e)?e.value:e;for(let s of n)if(Ge(s)&&(s.key===e||s.key===t||_e(s.key)&&s.key.value===t))return s}var kt=class extends Ks{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(wn,e),this.items=[]}static from(e,t,s){let{keepUndefined:r,replacer:o}=s,i=new this(e),l=(a,c)=>{if(typeof o=="function")c=o.call(t,a,c);else if(Array.isArray(o)&&!o.includes(a))return;(c!==void 0||r)&&i.items.push(qs(a,c,s))};if(t instanceof Map)for(let[a,c]of t)l(a,c);else if(t&&typeof t=="object")for(let a of Object.keys(t))l(a,t[a]);return typeof e.sortMapEntries=="function"&&i.items.sort(e.sortMapEntries),i}add(e,t){let s;Ge(e)?s=e:!e||typeof e!="object"||!("key"in e)?s=new yt(e,e?.value):s=new yt(e.key,e.value);let r=is(this.items,s.key),o=this.schema?.sortMapEntries;if(r){if(!t)throw new Error(`Key ${s.key} already set`);_e(r.value)&&Ao(s.value)?r.value.value=s.value:r.value=s.value}else if(o){let i=this.items.findIndex(l=>o(s,l)<0);i===-1?this.items.push(s):this.items.splice(i,0,s)}else this.items.push(s)}delete(e){let t=is(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let r=is(this.items,e)?.value;return(!t&&_e(r)?r.value:r)??void 0}has(e){return!!is(this.items,e)}set(e,t){this.add(new yt(e,t),!0)}toJSON(e,t,s){let r=s?new s:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let o of this.items)Fo(t,r,o);return r}toString(e,t,s){if(!e)return JSON.stringify(this);for(let r of this.items)if(!Ge(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})),jo(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:s,onComment:t})}};var Sn={collection:"map",default:!0,nodeClass:kt,tag:"tag:yaml.org,2002:map",resolve(n,e){return qt(n)||e("Expected a mapping for this tag"),n},createNode:(n,e,t)=>kt.from(n,e,t)};var Lt=class extends Ks{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Wn,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=Do(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){let s=Do(e);if(typeof s!="number")return;let r=this.items[s];return!t&&_e(r)?r.value:r}has(e){let t=Do(e);return typeof t=="number"&&t<this.items.length}set(e,t){let s=Do(e);if(typeof s!="number")throw new Error(`Expected a valid index, not ${e}.`);let r=this.items[s];_e(r)&&Ao(t)?r.value=t:this.items[s]=t}toJSON(e,t){let s=[];t?.onCreate&&t.onCreate(s);let r=0;for(let o of this.items)s.push(Mt(o,String(r++),t));return s}toString(e,t,s){return e?jo(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:s,onComment:t}):JSON.stringify(this)}static from(e,t,s){let{replacer:r}=s,o=new this(e);if(t&&Symbol.iterator in Object(t)){let i=0;for(let l of t){if(typeof r=="function"){let a=t instanceof Set?l:String(i++);l=r.call(t,a,l)}o.items.push(Xn(l,void 0,s))}}return o}};function Do(n){let e=_e(n)?n.value:n;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}var $n={collection:"seq",default:!0,nodeClass:Lt,tag:"tag:yaml.org,2002:seq",resolve(n,e){return Ut(n)||e("Expected a sequence for this tag"),n},createNode:(n,e,t)=>Lt.from(n,e,t)};var as={identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify(n,e,t,s){return e=Object.assign({actualString:!0},e),ks(n,e,t,s)}};var vs={identify:n=>n==null,createNode:()=>new Ae(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Ae(null),stringify:({source:n},e)=>typeof n=="string"&&vs.test.test(n)?n:e.options.nullStr};var Ar={identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:n=>new Ae(n[0]==="t"||n[0]==="T"),stringify({source:n,value:e},t){if(n&&Ar.test.test(n)){let s=n[0]==="t"||n[0]==="T";if(e===s)return n}return e?t.options.trueStr:t.options.falseStr}};function Ft({format:n,minFractionDigits:e,tag:t,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(!n&&e&&(!t||t==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let i=o.indexOf(".");i<0&&(i=o.length,o+=".");let l=e-(o.length-i-1);for(;l-- >0;)o+="0"}return o}var _o={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:n=>n.slice(-3).toLowerCase()==="nan"?NaN:n[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Ft},zo={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:n=>parseFloat(n),stringify(n){let e=Number(n.value);return isFinite(e)?e.toExponential():Ft(n)}},Ko={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(n){let e=new Ae(parseFloat(n)),t=n.indexOf(".");return t!==-1&&n[n.length-1]==="0"&&(e.minFractionDigits=n.length-t-1),e},stringify:Ft};var Vo=n=>typeof n=="bigint"||Number.isInteger(n),Pa=(n,e,t,{intAsBigInt:s})=>s?BigInt(n):parseInt(n.substring(e),t);function _c(n,e,t){let{value:s}=n;return Vo(s)&&s>=0?t+s.toString(e):Ft(n)}var Go={identify:n=>Vo(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(n,e,t)=>Pa(n,2,8,t),stringify:n=>_c(n,8,"0o")},qo={identify:Vo,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(n,e,t)=>Pa(n,0,10,t),stringify:Ft},Uo={identify:n=>Vo(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(n,e,t)=>Pa(n,2,16,t),stringify:n=>_c(n,16,"0x")};var zc=[Sn,$n,as,vs,Ar,Go,qo,Uo,_o,zo,Ko];function Kc(n){return typeof n=="bigint"||Number.isInteger(n)}var Ho=({value:n})=>JSON.stringify(n),Ud=[{identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify:Ho},{identify:n=>n==null,createNode:()=>new Ae(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Ho},{identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:n=>n==="true",stringify:Ho},{identify:Kc,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(n,e,{intAsBigInt:t})=>t?BigInt(n):parseInt(n,10),stringify:({value:n})=>Kc(n)?n.toString():JSON.stringify(n)},{identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:n=>parseFloat(n),stringify:Ho}],Hd={default:!0,tag:"",test:/^/,resolve(n,e){return e(`Unresolved plain scalar ${JSON.stringify(n)}`),n}},Vc=[Sn,$n].concat(Ud,Hd);var Or={identify:n=>n instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(n,e){if(typeof atob=="function"){let t=atob(n.replace(/[\n\r]/g,"")),s=new Uint8Array(t.length);for(let r=0;r<t.length;++r)s[r]=t.charCodeAt(r);return s}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),n},stringify({comment:n,type:e,value:t},s,r,o){if(!t)return"";let i=t,l;if(typeof btoa=="function"){let a="";for(let c=0;c<i.length;++c)a+=String.fromCharCode(i[c]);l=btoa(a)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=Ae.BLOCK_LITERAL),e!==Ae.QUOTE_DOUBLE){let a=Math.max(s.options.lineWidth-s.indent.length,s.options.minContentWidth),c=Math.ceil(l.length/a),f=new Array(c);for(let u=0,d=0;u<c;++u,d+=a)f[u]=l.substr(d,a);l=f.join(e===Ae.BLOCK_LITERAL?`
|
|
52
|
+
`:" ")}return ks({comment:n,type:e,value:l},s,r,o)}};function Ca(n,e){if(Ut(n))for(let t=0;t<n.items.length;++t){let s=n.items[t];if(!Ge(s)){if(qt(s)){s.items.length>1&&e("Each pair must have its own sequence indicator");let r=s.items[0]||new yt(new Ae(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}
|
|
55
|
-
`)?(
|
|
54
|
+
${o.comment}`:s.comment}s=r}n.items[t]=Ge(s)?s:new yt(s)}}else e("Expected a sequence for this tag");return n}function Ia(n,e,t){let{replacer:s}=t,r=new Lt(n);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 l,a;if(Array.isArray(i))if(i.length===2)l=i[0],a=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)l=c[0],a=i[l];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else l=i;r.items.push(qs(l,a,t))}return r}var Nr={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ca,createNode:Ia};var Us=class n extends Lt{constructor(){super(),this.add=kt.prototype.add.bind(this),this.delete=kt.prototype.delete.bind(this),this.get=kt.prototype.get.bind(this),this.has=kt.prototype.has.bind(this),this.set=kt.prototype.set.bind(this),this.tag=n.tag}toJSON(e,t){if(!t)return super.toJSON(e);let s=new Map;t?.onCreate&&t.onCreate(s);for(let r of this.items){let o,i;if(Ge(r)?(o=Mt(r.key,"",t),i=Mt(r.value,o,t)):o=Mt(r,"",t),s.has(o))throw new Error("Ordered maps must not include duplicate keys");s.set(o,i)}return s}static from(e,t,s){let r=Ia(e,t,s),o=new this;return o.items=r.items,o}};Us.tag="tag:yaml.org,2002:omap";var Rr={collection:"seq",identify:n=>n instanceof Map,nodeClass:Us,default:!1,tag:"tag:yaml.org,2002:omap",resolve(n,e){let t=Ca(n,e),s=[];for(let{key:r}of t.items)_e(r)&&(s.includes(r.value)?e(`Ordered maps must not include duplicate keys: ${r.value}`):s.push(r.value));return Object.assign(new Us,t)},createNode:(n,e,t)=>Us.from(n,e,t)};function Gc({value:n,source:e},t){return e&&(n?La:Fa).test.test(e)?e:n?t.options.trueStr:t.options.falseStr}var La={identify:n=>n===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Ae(!0),stringify:Gc},Fa={identify:n=>n===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Ae(!1),stringify:Gc};var qc={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:n=>n.slice(-3).toLowerCase()==="nan"?NaN:n[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Ft},Uc={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:n=>parseFloat(n.replace(/_/g,"")),stringify(n){let e=Number(n.value);return isFinite(e)?e.toExponential():Ft(n)}},Hc={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(n){let e=new Ae(parseFloat(n.replace(/_/g,""))),t=n.indexOf(".");if(t!==-1){let s=n.substring(t+1).replace(/_/g,"");s[s.length-1]==="0"&&(e.minFractionDigits=s.length)}return e},stringify:Ft};var Pr=n=>typeof n=="bigint"||Number.isInteger(n);function Yo(n,e,t,{intAsBigInt:s}){let r=n[0];if((r==="-"||r==="+")&&(e+=1),n=n.substring(e).replace(/_/g,""),s){switch(t){case 2:n=`0b${n}`;break;case 8:n=`0o${n}`;break;case 16:n=`0x${n}`;break}let i=BigInt(n);return r==="-"?BigInt(-1)*i:i}let o=parseInt(n,t);return r==="-"?-1*o:o}function Ba(n,e,t){let{value:s}=n;if(Pr(s)){let r=s.toString(e);return s<0?"-"+t+r.substr(1):t+r}return Ft(n)}var Yc={identify:Pr,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(n,e,t)=>Yo(n,2,2,t),stringify:n=>Ba(n,2,"0b")},Wc={identify:Pr,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(n,e,t)=>Yo(n,1,8,t),stringify:n=>Ba(n,8,"0")},Jc={identify:Pr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(n,e,t)=>Yo(n,0,10,t),stringify:Ft},Xc={identify:Pr,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(n,e,t)=>Yo(n,2,16,t),stringify:n=>Ba(n,16,"0x")};var Hs=class n extends kt{constructor(e){super(e),this.tag=n.tag}add(e){let t;Ge(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new yt(e.key,null):t=new yt(e,null),is(this.items,t.key)||this.items.push(t)}get(e,t){let s=is(this.items,e);return!t&&Ge(s)?_e(s.key)?s.key.value:s.key:s}set(e,t){if(typeof t!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let s=is(this.items,e);s&&!t?this.items.splice(this.items.indexOf(s),1):!s&&t&&this.items.push(new yt(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,s){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,s);throw new Error("Set items must all have null values")}static from(e,t,s){let{replacer:r}=s,o=new this(e);if(t&&Symbol.iterator in Object(t))for(let i of t)typeof r=="function"&&(i=r.call(t,i,i)),o.items.push(qs(i,null,s));return o}};Hs.tag="tag:yaml.org,2002:set";var Cr={collection:"map",identify:n=>n instanceof Set,nodeClass:Hs,default:!1,tag:"tag:yaml.org,2002:set",createNode:(n,e,t)=>Hs.from(n,e,t),resolve(n,e){if(qt(n)){if(n.hasAllNullValues(!0))return Object.assign(new Hs,n);e("Set items must all have null values")}else e("Expected a mapping for this tag");return n}};function ja(n,e){let t=n[0],s=t==="-"||t==="+"?n.substring(1):n,r=i=>e?BigInt(i):Number(i),o=s.replace(/_/g,"").split(":").reduce((i,l)=>i*r(60)+r(l),r(0));return t==="-"?r(-1)*o:o}function Qc(n){let{value:e}=n,t=i=>i;if(typeof e=="bigint")t=i=>BigInt(i);else if(isNaN(e)||!isFinite(e))return Ft(n);let s="";e<0&&(s="-",e*=t(-1));let r=t(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 Wo={identify:n=>typeof n=="bigint"||Number.isInteger(n),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(n,e,{intAsBigInt:t})=>ja(n,t),stringify:Qc},Jo={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:n=>ja(n,!1),stringify:Qc},Ys={identify:n=>n 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(n){let e=n.match(Ys.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,t,s,r,o,i,l]=e.map(Number),a=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(t,s-1,r,o||0,i||0,l||0,a),f=e[8];if(f&&f!=="Z"){let u=ja(f,!1);Math.abs(u)<30&&(u*=60),c-=6e4*u}return new Date(c)},stringify:({value:n})=>n?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};var Da=[Sn,$n,as,vs,La,Fa,Yc,Wc,Jc,Xc,qc,Uc,Hc,Or,vn,Rr,Nr,Cr,Wo,Jo,Ys];var Zc=new Map([["core",zc],["failsafe",[Sn,$n,as]],["json",Vc],["yaml11",Da],["yaml-1.1",Da]]),ef={binary:Or,bool:Ar,float:Ko,floatExp:zo,floatNaN:_o,floatTime:Jo,int:qo,intHex:Uo,intOct:Go,intTime:Wo,map:Sn,merge:vn,null:vs,omap:Rr,pairs:Nr,seq:$n,set:Cr,timestamp:Ys},tf={"tag:yaml.org,2002:binary":Or,"tag:yaml.org,2002:merge":vn,"tag:yaml.org,2002:omap":Rr,"tag:yaml.org,2002:pairs":Nr,"tag:yaml.org,2002:set":Cr,"tag:yaml.org,2002:timestamp":Ys};function Xo(n,e,t){let s=Zc.get(e);if(s&&!n)return t&&!s.includes(vn)?s.concat(vn):s.slice();let r=s;if(!r)if(Array.isArray(n))r=[];else{let o=Array.from(Zc.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(n))for(let o of n)r=r.concat(o);else typeof n=="function"&&(r=n(r.slice()));return t&&(r=r.concat(vn)),r.reduce((o,i)=>{let l=typeof i=="string"?ef[i]:i;if(!l){let a=JSON.stringify(i),c=Object.keys(ef).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${a}; use one of ${c}`)}return o.includes(l)||o.push(l),o},[])}var Yd=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0,Ir=class n{constructor({compat:e,customTags:t,merge:s,resolveKnownTags:r,schema:o,sortMapEntries:i,toStringDefaults:l}){this.compat=Array.isArray(e)?Xo(e,"compat"):e?Xo(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=r?tf:{},this.tags=Xo(t,this.name,s),this.toStringOptions=l??null,Object.defineProperty(this,wn,{value:Sn}),Object.defineProperty(this,Qt,{value:as}),Object.defineProperty(this,Wn,{value:$n}),this.sortMapEntries=typeof i=="function"?i:i===!0?Yd:null}clone(){let e=Object.create(n.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};function nf(n,e){let t=[],s=e.directives===!0;if(e.directives!==!1&&n.directives){let a=n.directives.toString(n);a?(t.push(a),s=!0):n.directives.docStart&&(s=!0)}s&&t.push("---");let r=Co(n,e),{commentString:o}=r.options;if(n.commentBefore){t.length!==1&&t.unshift("");let a=o(n.commentBefore);t.unshift(ln(a,""))}let i=!1,l=null;if(n.contents){if(He(n.contents)){if(n.contents.spaceBefore&&s&&t.push(""),n.contents.commentBefore){let f=o(n.contents.commentBefore);t.push(ln(f,""))}r.forceBlockIndent=!!n.comment,l=n.contents.comment}let a=l?void 0:()=>i=!0,c=Qn(n.contents,r,()=>l=null,a);l&&(c+=_n(c,"",o(l))),(c[0]==="|"||c[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${c}`:t.push(c)}else t.push(Qn(n.contents,r));if(n.directives?.docEnd)if(n.comment){let a=o(n.comment);a.includes(`
|
|
55
|
+
`)?(t.push("..."),t.push(ln(a,""))):t.push(`... ${a}`)}else t.push("...");else{let a=n.comment;a&&i&&(a=a.replace(/^\n+/,"")),a&&((!i||l)&&t[t.length-1]!==""&&t.push(""),t.push(ln(o(a),"")))}return t.join(`
|
|
56
56
|
`)+`
|
|
57
|
-
`}var
|
|
58
|
-
`),i=
|
|
57
|
+
`}var ls=class n{constructor(e,t,s){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Kt,{value:So});let r=null;typeof t=="function"||Array.isArray(t)?r=t:s===void 0&&t&&(s=t,t=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 Dn({version:i}),this.setSchema(i,s),this.contents=e===void 0?null:this.createNode(e,r,s)}clone(){let e=Object.create(n.prototype,{[Kt]:{value:So}});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=He(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Ws(this.contents)&&this.contents.add(e)}addIn(e,t){Ws(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let s=Ma(this);e.anchor=!t||s.has(t)?Ea(t||"a",s):t}return new Jn(e.anchor)}createNode(e,t,s){let r;if(typeof t=="function")e=t.call({"":e},"",e),r=t;else if(Array.isArray(t)){let y=p=>typeof p=="number"||p instanceof String||p instanceof Number,N=t.filter(y).map(String);N.length>0&&(t=t.concat(N)),r=t}else s===void 0&&t&&(s=t,t=void 0);let{aliasDuplicateObjects:o,anchorPrefix:i,flow:l,keepUndefined:a,onTagObj:c,tag:f}=s??{},{onAnchor:u,setAnchors:d,sourceObjects:h}=Ic(this,i||"a"),b={aliasDuplicateObjects:o??!0,keepUndefined:a??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:h},m=Xn(e,f,b);return l&&Xe(m)&&(m.flow=!0),d(),m}createPair(e,t,s={}){let r=this.createNode(e,null,s),o=this.createNode(t,null,s);return new yt(r,o)}delete(e){return Ws(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Vs(e)?this.contents==null?!1:(this.contents=null,!0):Ws(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Xe(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Vs(e)?!t&&_e(this.contents)?this.contents.value:this.contents:Xe(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Xe(this.contents)?this.contents.has(e):!1}hasIn(e){return Vs(e)?this.contents!==void 0:Xe(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=$r(this.schema,[e],t):Ws(this.contents)&&this.contents.set(e,t)}setIn(e,t){Vs(e)?this.contents=t:this.contents==null?this.contents=$r(this.schema,Array.from(e),t):Ws(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e=="number"&&(e=String(e));let s;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Dn({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 Dn({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(t.schema instanceof Object)this.schema=t.schema;else if(s)this.schema=new Ir(Object.assign(s,t));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:s,maxAliasCount:r,onAnchor:o,reviver:i}={}){let l={anchors:new Map,doc:this,keep:!e,mapAsMap:s===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},a=Mt(this.contents,t??"",l);if(typeof o=="function")for(let{count:c,res:f}of l.anchors.values())o(f,c);return typeof i=="function"?rs(i,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}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 t=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${t}`)}return nf(this,e)}};function Ws(n){if(Xe(n))return!0;throw new Error("Expected a YAML collection as document contents")}var Lr=class extends Error{constructor(e,t,s,r){super(),this.name=e,this.code=s,this.message=r,this.pos=t}},Mn=class extends Lr{constructor(e,t,s){super("YAMLParseError",e,t,s)}},Fr=class extends Lr{constructor(e,t,s){super("YAMLWarning",e,t,s)}},_a=(n,e)=>t=>{if(t.pos[0]===-1)return;t.linePos=t.pos.map(l=>e.linePos(l));let{line:s,col:r}=t.linePos[0];t.message+=` at line ${s}, column ${r}`;let o=r-1,i=n.substring(e.lineStarts[s-1],e.lineStarts[s]).replace(/[\n\r]+$/,"");if(o>=60&&i.length>80){let l=Math.min(o-39,i.length-79);i="\u2026"+i.substring(l),o-=l-1}if(i.length>80&&(i=i.substring(0,79)+"\u2026"),s>1&&/^ *$/.test(i.substring(0,o))){let l=n.substring(e.lineStarts[s-2],e.lineStarts[s-1]);l.length>80&&(l=l.substring(0,79)+`\u2026
|
|
58
|
+
`),i=l+i}if(/[^ ]/.test(i)){let l=1,a=t.linePos[1];a?.line===s&&a.col>r&&(l=Math.max(1,Math.min(a.col-r,80-o)));let c=" ".repeat(o)+"^".repeat(l);t.message+=`:
|
|
59
59
|
|
|
60
60
|
${i}
|
|
61
61
|
${c}
|
|
62
|
-
`}};function
|
|
63
|
-
`))return!0;if(
|
|
64
|
-
`+m.comment:
|
|
65
|
-
`+
|
|
66
|
-
`+
|
|
67
|
-
`+
|
|
68
|
-
`+L.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
|
|
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
|
|
71
|
-
`;for(let m=f;m<
|
|
72
|
-
`):y.length>
|
|
73
|
-
`:!
|
|
62
|
+
`}};function zn(n,{flow:e,indicator:t,next:s,offset:r,onError:o,parentIndent:i,startOnNewline:l}){let a=!1,c=l,f=l,u="",d="",h=!1,b=!1,m=null,y=null,N=null,p=null,g=null,x=null,$=null;for(let A of n)switch(b&&(A.type!=="space"&&A.type!=="newline"&&A.type!=="comma"&&o(A.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),b=!1),m&&(c&&A.type!=="comment"&&A.type!=="newline"&&o(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),A.type){case"space":!e&&(t!=="doc-start"||s?.type!=="flow-collection")&&A.source.includes(" ")&&(m=A),f=!0;break;case"comment":{f||o(A,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let L=A.source.substring(1)||" ";u?u+=d+L:u=L,d="",c=!1;break}case"newline":c?u?u+=A.source:(!x||t!=="seq-item-ind")&&(a=!0):d+=A.source,c=!0,h=!0,(y||N)&&(p=A),f=!0;break;case"anchor":y&&o(A,"MULTIPLE_ANCHORS","A node can have at most one anchor"),A.source.endsWith(":")&&o(A.offset+A.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),y=A,$??($=A.offset),c=!1,f=!1,b=!0;break;case"tag":{N&&o(A,"MULTIPLE_TAGS","A node can have at most one tag"),N=A,$??($=A.offset),c=!1,f=!1,b=!0;break}case t:(y||N)&&o(A,"BAD_PROP_ORDER",`Anchors and tags must be after the ${A.source} indicator`),x&&o(A,"UNEXPECTED_TOKEN",`Unexpected ${A.source} in ${e??"collection"}`),x=A,c=t==="seq-item-ind"||t==="explicit-key-ind",f=!1;break;case"comma":if(e){g&&o(A,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),g=A,c=!1,f=!1;break}default:o(A,"UNEXPECTED_TOKEN",`Unexpected ${A.type} token`),c=!1,f=!1}let T=n[n.length-1],v=T?T.offset+T.source.length:r;return b&&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:g,found:x,spaceBefore:a,comment:u,hasNewline:h,anchor:y,tag:N,newlineAfterProp:p,end:v,start:$??v}}function cs(n){if(!n)return null;switch(n.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(n.source.includes(`
|
|
63
|
+
`))return!0;if(n.end){for(let e of n.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of n.items){for(let t of e.start)if(t.type==="newline")return!0;if(e.sep){for(let t of e.sep)if(t.type==="newline")return!0}if(cs(e.key)||cs(e.value))return!0}return!1;default:return!0}}function Br(n,e,t){if(e?.type==="flow-collection"){let s=e.end[0];s.indent===n&&(s.source==="]"||s.source==="}")&&cs(e)&&t(s,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function Qo(n,e,t){let{uniqueKeys:s}=n.options;if(s===!1)return!1;let r=typeof s=="function"?s:(o,i)=>o===i||_e(o)&&_e(i)&&o.value===i.value;return e.some(o=>r(o.key,t))}var sf="All mapping items must start at the same column";function rf({composeNode:n,composeEmptyNode:e},t,s,r,o){let i=o?.nodeClass??kt,l=new i(t.schema);t.atRoot&&(t.atRoot=!1);let a=s.offset,c=null;for(let f of s.items){let{start:u,key:d,sep:h,value:b}=f,m=zn(u,{indicator:"explicit-key-ind",next:d??h?.[0],offset:a,onError:r,parentIndent:s.indent,startOnNewline:!0}),y=!m.found;if(y){if(d&&(d.type==="block-seq"?r(a,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==s.indent&&r(a,"BAD_INDENT",sf)),!m.anchor&&!m.tag&&!h){c=m.end,m.comment&&(l.comment?l.comment+=`
|
|
64
|
+
`+m.comment:l.comment=m.comment);continue}(m.newlineAfterProp||cs(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(a,"BAD_INDENT",sf);t.atKey=!0;let N=m.end,p=d?n(t,d,m,r):e(t,N,u,null,m,r);t.schema.compat&&Br(s.indent,d,r),t.atKey=!1,Qo(t,l.items,p)&&r(N,"DUPLICATE_KEY","Map keys must be unique");let g=zn(h??[],{indicator:"map-value-ind",next:b,offset:p.range[2],onError:r,parentIndent:s.indent,startOnNewline:!d||d.type==="block-scalar"});if(a=g.end,g.found){y&&(b?.type==="block-map"&&!g.hasNewline&&r(a,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&m.start<g.found.offset-1024&&r(p.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let x=b?n(t,b,g,r):e(t,a,h,null,g,r);t.schema.compat&&Br(s.indent,b,r),a=x.range[2];let $=new yt(p,x);t.options.keepSourceTokens&&($.srcToken=f),l.items.push($)}else{y&&r(p.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),g.comment&&(p.comment?p.comment+=`
|
|
65
|
+
`+g.comment:p.comment=g.comment);let x=new yt(p);t.options.keepSourceTokens&&(x.srcToken=f),l.items.push(x)}}return c&&c<a&&r(c,"IMPOSSIBLE","Map comment with trailing content"),l.range=[s.offset,a,c??a],l}function of({composeNode:n,composeEmptyNode:e},t,s,r,o){let i=o?.nodeClass??Lt,l=new i(t.schema);t.atRoot&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let a=s.offset,c=null;for(let{start:f,value:u}of s.items){let d=zn(f,{indicator:"seq-item-ind",next:u,offset:a,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(a,"MISSING_CHAR","Sequence item without - indicator");else{c=d.end,d.comment&&(l.comment=d.comment);continue}let h=u?n(t,u,d,r):e(t,d.end,f,null,d,r);t.schema.compat&&Br(s.indent,u,r),a=h.range[2],l.items.push(h)}return l.range=[s.offset,a,c??a],l}function Kn(n,e,t,s){let r="";if(n){let o=!1,i="";for(let l of n){let{source:a,type:c}=l;switch(c){case"space":o=!0;break;case"comment":{t&&!o&&s(l,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=a.substring(1)||" ";r?r+=i+f:r=f,i="";break}case"newline":r&&(i+=a),o=!0;break;default:s(l,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=a.length}}return{comment:r,offset:e}}var za="Block collections are not allowed within flow collections",Ka=n=>n&&(n.type==="block-map"||n.type==="block-seq");function af({composeNode:n,composeEmptyNode:e},t,s,r,o){let i=s.start.source==="{",l=i?"flow map":"flow sequence",a=o?.nodeClass??(i?kt:Lt),c=new a(t.schema);c.flow=!0;let f=t.atRoot;f&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let u=s.offset+s.start.source.length;for(let y=0;y<s.items.length;++y){let N=s.items[y],{start:p,key:g,sep:x,value:$}=N,T=zn(p,{flow:l,indicator:"explicit-key-ind",next:g??x?.[0],offset:u,onError:r,parentIndent:s.indent,startOnNewline:!1});if(!T.found){if(!T.anchor&&!T.tag&&!x&&!$){y===0&&T.comma?r(T.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${l}`):y<s.items.length-1&&r(T.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${l}`),T.comment&&(c.comment?c.comment+=`
|
|
66
|
+
`+T.comment:c.comment=T.comment),u=T.end;continue}!i&&t.options.strict&&cs(g)&&r(g,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(y===0)T.comma&&r(T.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${l}`);else if(T.comma||r(T.start,"MISSING_CHAR",`Missing , between ${l} items`),T.comment){let v="";e:for(let A of p)switch(A.type){case"comma":case"space":break;case"comment":v=A.source.substring(1);break e;default:break e}if(v){let A=c.items[c.items.length-1];Ge(A)&&(A=A.value??A.key),A.comment?A.comment+=`
|
|
67
|
+
`+v:A.comment=v,T.comment=T.comment.substring(v.length+1)}}if(!i&&!x&&!T.found){let v=$?n(t,$,T,r):e(t,T.end,x,null,T,r);c.items.push(v),u=v.range[2],Ka($)&&r(v.range,"BLOCK_IN_FLOW",za)}else{t.atKey=!0;let v=T.end,A=g?n(t,g,T,r):e(t,v,p,null,T,r);Ka(g)&&r(A.range,"BLOCK_IN_FLOW",za),t.atKey=!1;let L=zn(x??[],{flow:l,indicator:"map-value-ind",next:$,offset:A.range[2],onError:r,parentIndent:s.indent,startOnNewline:!1});if(L.found){if(!i&&!T.found&&t.options.strict){if(x)for(let k of x){if(k===L.found)break;if(k.type==="newline"){r(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}T.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 $&&("source"in $&&$.source?.[0]===":"?r($,"MISSING_CHAR",`Missing space after : in ${l}`):r(L.start,"MISSING_CHAR",`Missing , or : between ${l} items`));let M=$?n(t,$,L,r):L.found?e(t,L.end,x,null,L,r):null;M?Ka($)&&r(M.range,"BLOCK_IN_FLOW",za):L.comment&&(A.comment?A.comment+=`
|
|
68
|
+
`+L.comment:A.comment=L.comment);let P=new yt(A,M);if(t.options.keepSourceTokens&&(P.srcToken=N),i){let k=c;Qo(t,k.items,A)&&r(v,"DUPLICATE_KEY","Map keys must be unique"),k.items.push(P)}else{let k=new kt(t.schema);k.flow=!0,k.items.push(P);let O=(M??A).range;k.range=[A.range[0],O[1],O[2]],c.items.push(k)}u=M?M.range[2]:L.end}}let d=i?"}":"]",[h,...b]=s.end,m=u;if(h?.source===d)m=h.offset+h.source.length;else{let y=l[0].toUpperCase()+l.substring(1),N=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",N),h&&h.source.length!==1&&b.unshift(h)}if(b.length>0){let y=Kn(b,m,t.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 Va(n,e,t,s,r,o){let i=t.type==="block-map"?rf(n,e,t,s,o):t.type==="block-seq"?of(n,e,t,s,o):af(n,e,t,s,o),l=i.constructor;return r==="!"||r===l.tagName?(i.tag=l.tagName,i):(r&&(i.tag=r),i)}function lf(n,e,t,s,r){let o=s.tag,i=o?e.directives.tagName(o.source,d=>r(o,"TAG_RESOLVE_FAILED",d)):null;if(t.type==="block-seq"){let{anchor:d,newlineAfterProp:h}=s,b=d&&o?d.offset>o.offset?d:o:d??o;b&&(!h||h.offset<b.offset)&&r(b,"MISSING_CHAR","Missing newline after block sequence props")}let l=t.type==="block-map"?"map":t.type==="block-seq"?"seq":t.start.source==="{"?"map":"seq";if(!o||!i||i==="!"||i===kt.tagName&&l==="map"||i===Lt.tagName&&l==="seq")return Va(n,e,t,r,i);let a=e.schema.tags.find(d=>d.tag===i&&d.collection===l);if(!a){let d=e.schema.knownTags[i];if(d?.collection===l)e.schema.tags.push(Object.assign({},d,{default:!1})),a=d;else return d?r(o,"BAD_COLLECTION_TYPE",`${d.tag} used for ${l} collection, but expects ${d.collection??"scalar"}`,!0):r(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,!0),Va(n,e,t,r,i)}let c=Va(n,e,t,r,i,a),f=a.resolve?.(c,d=>r(o,"TAG_RESOLVE_FAILED",d),e.options)??c,u=He(f)?f:new Ae(f);return u.range=c.range,u.tag=i,a?.format&&(u.format=a.format),u}function Ga(n,e,t){let s=e.offset,r=Wd(e,n.options.strict,t);if(!r)return{value:"",type:null,comment:"",range:[s,s,s]};let o=r.mode===">"?Ae.BLOCK_FOLDED:Ae.BLOCK_LITERAL,i=e.source?Jd(e.source):[],l=i.length;for(let m=i.length-1;m>=0;--m){let y=i[m][1];if(y===""||y==="\r")l=m;else break}if(l===0){let m=r.chomp==="+"&&i.length>0?`
|
|
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 a=e.indent+r.indent,c=e.offset+r.length,f=0;for(let m=0;m<l;++m){let[y,N]=i[m];if(N===""||N==="\r")r.indent===0&&y.length>a&&(a=y.length);else{y.length<a&&t(c+y.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),r.indent===0&&(a=y.length),f=m,a===0&&!n.atRoot&&t(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=y.length+N.length+1}for(let m=i.length-1;m>=l;--m)i[m][0].length>a&&(l=m+1);let u="",d="",h=!1;for(let m=0;m<f;++m)u+=i[m][0].slice(a)+`
|
|
71
|
+
`;for(let m=f;m<l;++m){let[y,N]=i[m];c+=y.length+N.length+1;let p=N[N.length-1]==="\r";if(p&&(N=N.slice(0,-1)),N&&y.length<a){let x=`Block scalar lines must not be less indented than their ${r.indent?"explicit indentation indicator":"first line"}`;t(c-N.length-(p?2:1),"BAD_INDENT",x),y=""}o===Ae.BLOCK_LITERAL?(u+=d+y.slice(a)+N,d=`
|
|
72
|
+
`):y.length>a||N[0]===" "?(d===" "?d=`
|
|
73
|
+
`:!h&&d===`
|
|
74
74
|
`&&(d=`
|
|
75
75
|
|
|
76
|
-
`),u+=d+y.slice(
|
|
77
|
-
`,
|
|
76
|
+
`),u+=d+y.slice(a)+N,d=`
|
|
77
|
+
`,h=!0):N===""?d===`
|
|
78
78
|
`?u+=`
|
|
79
79
|
`:d=`
|
|
80
|
-
`:(u+=d+
|
|
81
|
-
`+i[m][0].slice(
|
|
80
|
+
`:(u+=d+N,d=" ",h=!1)}switch(r.chomp){case"-":break;case"+":for(let m=l;m<i.length;++m)u+=`
|
|
81
|
+
`+i[m][0].slice(a);u[u.length-1]!==`
|
|
82
82
|
`&&(u+=`
|
|
83
83
|
`);break;default:u+=`
|
|
84
|
-
`}let
|
|
84
|
+
`}let b=s+r.length+e.source.length;return{value:u,type:o,comment:r.comment,range:[s,b,b]}}function Wd({offset:n,props:e},t,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,l="",a=-1;for(let d=1;d<r.length;++d){let h=r[d];if(!l&&(h==="-"||h==="+"))l=h;else{let b=Number(h);!i&&b?i=b:a===-1&&(a=n+d)}}a!==-1&&s(a,"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 h=e[d];switch(h.type){case"space":c=!0;case"newline":u+=h.source.length;break;case"comment":t&&!c&&s(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=h.source.length,f=h.source.substring(1);break;case"error":s(h,"UNEXPECTED_TOKEN",h.message),u+=h.source.length;break;default:{let b=`Unexpected token in block scalar header: ${h.type}`;s(h,"UNEXPECTED_TOKEN",b);let m=h.source;m&&typeof m=="string"&&(u+=m.length)}}}return{mode:o,indent:i,chomp:l,comment:f,length:u}}function Jd(n){let e=n.split(/\n( *)/),t=e[0],s=t.match(/^( *)/),o=[s?.[1]?[s[1],t.slice(s[1].length)]:["",t]];for(let i=1;i<e.length;i+=2)o.push([e[i],e[i+1]]);return o}function qa(n,e,t){let{offset:s,type:r,source:o,end:i}=n,l,a,c=(d,h,b)=>t(s+d,h,b);switch(r){case"scalar":l=Ae.PLAIN,a=Xd(o,c);break;case"single-quoted-scalar":l=Ae.QUOTE_SINGLE,a=Qd(o,c);break;case"double-quoted-scalar":l=Ae.QUOTE_DOUBLE,a=Zd(o,c);break;default:return t(n,"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=Kn(i,f,e,t);return{value:a,type:l,comment:u.comment,range:[s,f,u.offset]}}function Xd(n,e){let t="";switch(n[0]){case" ":t="a tab character";break;case",":t="flow indicator character ,";break;case"%":t="directive indicator character %";break;case"|":case">":{t=`block scalar indicator ${n[0]}`;break}case"@":case"`":{t=`reserved character ${n[0]}`;break}}return t&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${t}`),cf(n)}function Qd(n,e){return(n[n.length-1]!=="'"||n.length===1)&&e(n.length,"MISSING_CHAR","Missing closing 'quote"),cf(n.slice(1,-1)).replace(/''/g,"'")}function cf(n){let e=/(.*?)\r?\n/sy,t=e.exec(n);if(!t)return n;let s,r;try{s=new RegExp("(?<![ ])[ ]+$"),r=new RegExp("^[ ]+|(?<![ ])[ ]+$","g")}catch{s=/[ \t]+$/,r=/^[ \t]+|[ \t]+$/g}let o=t[1].replace(s,""),i=" ",l=e.lastIndex;for(;t=e.exec(n);){let c=t[1].replace(r,"");c===""?i===`
|
|
85
85
|
`?o+=i:i=`
|
|
86
|
-
`:(o+=i+c,i=" "),
|
|
86
|
+
`:(o+=i+c,i=" "),l=e.lastIndex}let a=/[ \t]*(.*)/sy;return a.lastIndex=l,t=a.exec(n),o+i+(t?.[1]??"")}function Zd(n,e){let t="";for(let s=1;s<n.length-1;++s){let r=n[s];if(!(r==="\r"&&n[s+1]===`
|
|
87
87
|
`))if(r===`
|
|
88
|
-
`){let{fold:o,offset:i}=
|
|
89
|
-
`)for(o=
|
|
90
|
-
`)for(o=
|
|
91
|
-
`&&!(i==="\r"&&
|
|
92
|
-
`)&&(
|
|
93
|
-
`||s==="\r")&&!(s==="\r"&&
|
|
88
|
+
`){let{fold:o,offset:i}=em(n,s);t+=o,s=i}else if(r==="\\"){let o=n[++s],i=tm[o];if(i)t+=i;else if(o===`
|
|
89
|
+
`)for(o=n[s+1];o===" "||o===" ";)o=n[++s+1];else if(o==="\r"&&n[s+1]===`
|
|
90
|
+
`)for(o=n[++s+1];o===" "||o===" ";)o=n[++s+1];else if(o==="x"||o==="u"||o==="U"){let l=o==="x"?2:o==="u"?4:8;t+=nm(n,s+1,l,e),s+=l}else{let l=n.substr(s-1,2);e(s-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${l}`),t+=l}}else if(r===" "||r===" "){let o=s,i=n[s+1];for(;i===" "||i===" ";)i=n[++s+1];i!==`
|
|
91
|
+
`&&!(i==="\r"&&n[s+2]===`
|
|
92
|
+
`)&&(t+=s>o?n.slice(o,s+1):r)}else t+=r}return(n[n.length-1]!=='"'||n.length===1)&&e(n.length,"MISSING_CHAR",'Missing closing "quote'),t}function em(n,e){let t="",s=n[e+1];for(;(s===" "||s===" "||s===`
|
|
93
|
+
`||s==="\r")&&!(s==="\r"&&n[e+2]!==`
|
|
94
94
|
`);)s===`
|
|
95
|
-
`&&(
|
|
96
|
-
`),e+=1,s=
|
|
97
|
-
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function
|
|
95
|
+
`&&(t+=`
|
|
96
|
+
`),e+=1,s=n[e+1];return t||(t=" "),{fold:t,offset:e}}var tm={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 nm(n,e,t,s){let r=n.substr(e,t),i=r.length===t&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;try{return String.fromCodePoint(i)}catch{let l=n.substr(e-2,t+2);return s(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${l}`),l}}function Ua(n,e,t,s){let{value:r,type:o,comment:i,range:l}=e.type==="block-scalar"?Ga(n,e,s):qa(e,n.options.strict,s),a=t?n.directives.tagName(t.source,u=>s(t,"TAG_RESOLVE_FAILED",u)):null,c;n.options.stringKeys&&n.atKey?c=n.schema[Qt]:a?c=sm(n.schema,r,a,t,s):e.type==="scalar"?c=rm(n,r,e,s):c=n.schema[Qt];let f;try{let u=c.resolve(r,d=>s(t??e,"TAG_RESOLVE_FAILED",d),n.options);f=_e(u)?u:new Ae(u)}catch(u){let d=u instanceof Error?u.message:String(u);s(t??e,"TAG_RESOLVE_FAILED",d),f=new Ae(r)}return f.range=l,f.source=r,o&&(f.type=o),a&&(f.tag=a),c.format&&(f.format=c.format),i&&(f.comment=i),f}function sm(n,e,t,s,r){if(t==="!")return n[Qt];let o=[];for(let l of n.tags)if(!l.collection&&l.tag===t)if(l.default&&l.test)o.push(l);else return l;for(let l of o)if(l.test?.test(e))return l;let i=n.knownTags[t];return i&&!i.collection?(n.tags.push(Object.assign({},i,{default:!1,test:void 0})),i):(r(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${t}`,t!=="tag:yaml.org,2002:str"),n[Qt])}function rm({atKey:n,directives:e,schema:t},s,r,o){let i=t.tags.find(l=>(l.default===!0||n&&l.default==="key")&&l.test?.test(s))||t[Qt];if(t.compat){let l=t.compat.find(a=>a.default&&a.test?.test(s))??t[Qt];if(i.tag!==l.tag){let a=e.tagString(i.tag),c=e.tagString(l.tag),f=`Value may be parsed as either ${a} or ${c}`;o(r,"TAG_RESOLVE_FAILED",f,!0)}}return i}function ff(n,e,t){if(e){t??(t=e.length);for(let s=t-1;s>=0;--s){let r=e[s];switch(r.type){case"space":case"comment":case"newline":n-=r.source.length;continue}for(r=e[++s];r?.type==="space";)n+=r.source.length,r=e[++s];break}}return n}var om={composeNode:Ha,composeEmptyNode:Zo};function Ha(n,e,t,s){let r=n.atKey,{spaceBefore:o,comment:i,anchor:l,tag:a}=t,c,f=!0;switch(e.type){case"alias":c=im(n,e,s),(l||a)&&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=Ua(n,e,a,s),l&&(c.anchor=l.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=lf(om,n,e,t,s),l&&(c.anchor=l.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=Zo(n,e.offset,void 0,null,t,s)),l&&c.anchor===""&&s(l,"BAD_ALIAS","Anchor cannot be an empty string"),r&&n.options.stringKeys&&(!_e(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&s(a??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),n.options.keepSourceTokens&&f&&(c.srcToken=e),c}function Zo(n,e,t,s,{spaceBefore:r,comment:o,anchor:i,tag:l,end:a},c){let f={type:"scalar",offset:ff(e,t,s),indent:-1,source:""},u=Ua(n,f,l,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]=a),u}function im({options:n},{offset:e,source:t,end:s},r){let o=new Jn(t.substring(1));o.source===""&&r(e,"BAD_ALIAS","Alias cannot be an empty string"),o.source.endsWith(":")&&r(e+t.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let i=e+t.length,l=Kn(s,i,n.strict,r);return o.range=[e,i,l.offset],l.comment&&(o.comment=l.comment),o}function uf(n,e,{offset:t,start:s,value:r,end:o},i){let l=Object.assign({_directives:e},n),a=new ls(void 0,l),c={atKey:!1,atRoot:!0,directives:a.directives,options:a.options,schema:a.schema},f=zn(s,{indicator:"doc-start",next:r??o?.[0],offset:t,onError:i,parentIndent:0,startOnNewline:!0});f.found&&(a.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")),a.contents=r?Ha(c,r,f,i):Zo(c,f.end,s,null,f,i);let u=a.contents.range[2],d=Kn(o,u,!1,i);return d.comment&&(a.comment=d.comment),a.range=[t,u,d.offset],a}function jr(n){if(typeof n=="number")return[n,n+1];if(Array.isArray(n))return n.length===2?n:[n[0],n[1]];let{offset:e,source:t}=n;return[e,e+(typeof t=="string"?t.length:1)]}function df(n){let e="",t=!1,s=!1;for(let r=0;r<n.length;++r){let o=n[r];switch(o[0]){case"#":e+=(e===""?"":s?`
|
|
98
98
|
|
|
99
99
|
`:`
|
|
100
|
-
`)+(o.substring(1)||" "),
|
|
101
|
-
${s}`:s;else if(r||e.directives.docStart||!o)e.commentBefore=s;else if(
|
|
102
|
-
${
|
|
103
|
-
${i}`:s}}if(
|
|
104
|
-
${
|
|
100
|
+
`)+(o.substring(1)||" "),t=!0,s=!1;break;case"%":n[r+1]?.[0]!=="#"&&(r+=1),t=!1;break;default:t||(s=!0),t=!1}}return{comment:e,afterEmptyLine:s}}var Dr=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,s,r,o)=>{let i=jr(t);o?this.warnings.push(new Fr(i,s,r)):this.errors.push(new Mn(i,s,r))},this.directives=new Dn({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:s,afterEmptyLine:r}=df(this.prelude);if(s){let o=e.contents;if(t)e.comment=e.comment?`${e.comment}
|
|
101
|
+
${s}`:s;else if(r||e.directives.docStart||!o)e.commentBefore=s;else if(Xe(o)&&!o.flow&&o.items.length>0){let i=o.items[0];Ge(i)&&(i=i.key);let l=i.commentBefore;i.commentBefore=l?`${s}
|
|
102
|
+
${l}`:s}else{let i=o.commentBefore;o.commentBefore=i?`${s}
|
|
103
|
+
${i}`:s}}if(t){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:df(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,s=-1){for(let r of e)yield*this.next(r);yield*this.end(t,s)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(t,s,r)=>{let o=jr(e);o[0]+=t,this.onError(o,"BAD_DIRECTIVE",s,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=uf(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,s=new Mn(jr(e),"UNEXPECTED_TOKEN",t);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 Mn(jr(e),"UNEXPECTED_TOKEN",s));break}this.doc.directives.docEnd=!0;let t=Kn(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let s=this.doc.comment;this.doc.comment=s?`${s}
|
|
104
|
+
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Mn(jr(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-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 ls(void 0,s);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),r.range=[0,t,t],this.decorate(r,!1),yield r}}};var Ya=Symbol("break visit"),am=Symbol("skip children"),mf=Symbol("remove item");function Ss(n,e){"type"in n&&n.type==="document"&&(n={start:n.start,value:n.value}),pf(Object.freeze([]),n,e)}Ss.BREAK=Ya;Ss.SKIP=am;Ss.REMOVE=mf;Ss.itemAtPath=(n,e)=>{let t=n;for(let[s,r]of e){let o=t?.[s];if(o&&"items"in o)t=o.items[r];else return}return t};Ss.parentCollection=(n,e)=>{let t=Ss.itemAtPath(n,e.slice(0,-1)),s=e[e.length-1][0],r=t?.[s];if(r&&"items"in r)return r;throw new Error("Parent collection not found")};function pf(n,e,t){let s=t(e,n);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 l=pf(Object.freeze(n.concat([[r,i]])),o.items[i],t);if(typeof l=="number")i=l-1;else{if(l===Ya)return Ya;l===mf&&(o.items.splice(i,1),i-=1)}}typeof s=="function"&&r==="key"&&(s=s(e,n))}}return typeof s=="function"?s(e,n):s}var Wa="\uFEFF",Ja="",Xa="",ei="";function hf(n){switch(n){case Wa:return"byte-order-mark";case Ja:return"doc-mode";case Xa:return"flow-error-end";case ei:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
105
105
|
`:case`\r
|
|
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(
|
|
107
|
-
`:case"\r":case" ":return!0;default:return!1}}var
|
|
108
|
-
\r `),
|
|
109
|
-
`?!0:
|
|
110
|
-
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let
|
|
111
|
-
`||!r&&!this.atEnd)return e+s+1}return
|
|
112
|
-
`||s>=this.indentNext||!
|
|
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]===
|
|
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(n[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 En(n){switch(n){case void 0:case" ":case`
|
|
107
|
+
`:case"\r":case" ":return!0;default:return!1}}var gf=new Set("0123456789ABCDEFabcdef"),cm=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),ti=new Set(",[]{}"),fm=new Set(` ,[]{}
|
|
108
|
+
\r `),Qa=n=>!n||fm.has(n),_r=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,t=!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=!t;let s=this.next??"stream";for(;s&&(t||this.hasChars(1));)s=yield*this.parseNext(s)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===" "||t===" ";)t=this.buffer[++e];return!t||t==="#"||t===`
|
|
109
|
+
`?!0:t==="\r"?this.buffer[e+1]===`
|
|
110
|
+
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let s=0;for(;t===" ";)t=this.buffer[++s+e];if(t==="\r"){let r=this.buffer[s+e+1];if(r===`
|
|
111
|
+
`||!r&&!this.atEnd)return e+s+1}return t===`
|
|
112
|
+
`||s>=this.indentNext||!t&&!this.atEnd?e+s:-1}if(t==="-"||t==="."){let s=this.buffer.substr(e,3);if((s==="---"||s==="...")&&En(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]===Wa&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let t=e.length,s=e.indexOf("#");for(;s!==-1;){let o=e[s-1];if(o===" "||o===" "){t=s-1;break}else s=e.indexOf("#",s+1)}for(;;){let o=e[t-1];if(o===" "||o===" ")t-=1;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),"stream"}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield Ja,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 t=this.peek(3);if((t==="---"||t==="...")&&En(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!En(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&En(t)){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 t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);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(Qa),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,s=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=s=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>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("..."))&&En(r[3]))&&!(s===this.indentNext-1&&this.flowLevel===1&&(r[0]==="]"||r[0]==="}")))return this.flowLevel=0,yield Xa,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(Qa),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let i=this.charAt(1);if(this.flowKey||En(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),t=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;t!==-1&&this.buffer[t+1]==="'";)t=this.buffer.indexOf("'",t+2);else for(;t!==-1;){let o=0;for(;this.buffer[t-1-o]==="\\";)o+=1;if(o%2===0)break;t=this.buffer.indexOf('"',t+1)}let s=this.buffer.substring(0,t),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
|
-
`,o)}r!==-1&&(
|
|
116
|
-
`:e=o,
|
|
117
|
-
`)break}default:break e}if(!s&&!this.atEnd)return this.setNext("block-scalar");if(
|
|
115
|
+
`,o)}r!==-1&&(t=r-(s[r-1]==="\r"?2:1))}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil(t=>En(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,s;e:for(let o=this.pos;s=this.buffer[o];++o)switch(s){case" ":t+=1;break;case`
|
|
116
|
+
`:e=o,t=0;break;case"\r":{let i=this.buffer[o+1];if(!i&&!this.atEnd)return this.setNext("block-scalar");if(i===`
|
|
117
|
+
`)break}default:break e}if(!s&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=t:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let o=this.continueScalar(e+1);if(o===-1)break;e=this.buffer.indexOf(`
|
|
118
118
|
`,o)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let r=e+1;for(s=this.buffer[r];s===" ";)s=this.buffer[++r];if(s===" "){for(;s===" "||s===" "||s==="\r"||s===`
|
|
119
|
-
`;)s=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let o=e-1,i=this.buffer[o];i==="\r"&&(i=this.buffer[--o]);let
|
|
120
|
-
`&&o>=this.pos&&o+1+
|
|
119
|
+
`;)s=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let o=e-1,i=this.buffer[o];i==="\r"&&(i=this.buffer[--o]);let l=o;for(;i===" ";)i=this.buffer[--o];if(i===`
|
|
120
|
+
`&&o>=this.pos&&o+1+t>l)e=o;else break}while(!0);return yield ei,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,s=this.pos-1,r;for(;r=this.buffer[++s];)if(r===":"){let o=this.buffer[s+1];if(En(o)||e&&ti.has(o))break;t=s}else if(En(r)){let o=this.buffer[s+1];if(r==="\r"&&(o===`
|
|
121
121
|
`?(s+=1,r=`
|
|
122
|
-
`,o=this.buffer[s+1]):
|
|
123
|
-
`){let i=this.continueScalar(s+1);if(i===-1)break;s=Math.max(s,i-2)}}else{if(e&&
|
|
122
|
+
`,o=this.buffer[s+1]):t=s),o==="#"||e&&ti.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&&ti.has(r))break;t=s}return!r&&!this.atEnd?this.setNext("plain-scalar"):(yield ei,yield*this.pushToIndex(t+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let s=this.buffer.slice(this.pos,e);return s?(yield s,this.pos+=s.length,s.length):(t&&(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(Qa),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,s=this.charAt(1);if(En(s)||t&&ti.has(s)){t?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,t=this.buffer[e];for(;!En(t)&&t!==">";)t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(cm.has(t))t=this.buffer[++e];else if(t==="%"&&gf.has(this.buffer[e+1])&&gf.has(this.buffer[e+2]))t=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
|
|
126
|
-
`)+1;for(;
|
|
127
|
-
`,
|
|
128
|
-
`)+1;for(;
|
|
129
|
-
`,
|
|
130
|
-
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){${
|
|
131
|
-
:root[data-theme="dark"]{${
|
|
132
|
-
${s}`}function
|
|
133
|
-
`;for(let[
|
|
134
|
-
`}return{light:
|
|
135
|
-
`)),this.diags=e}};function
|
|
136
|
-
${
|
|
137
|
-
${
|
|
138
|
-
${" ".repeat(
|
|
125
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,s;do s=this.buffer[++t];while(s===" "||e&&s===" ");let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,s=this.buffer[t];for(;!e(s);)s=this.buffer[++t];return yield*this.pushToIndex(t,!1)}};var $s=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,s=this.lineStarts.length;for(;t<s;){let o=t+s>>1;this.lineStarts[o]<e?t=o+1:s=o}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function fs(n,e){for(let t=0;t<n.length;++t)if(n[t].type===e)return!0;return!1}function bf(n){for(let e=0;e<n.length;++e)switch(n[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function xf(n){switch(n?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function ni(n){switch(n.type){case"document":return n.start;case"block-map":{let e=n.items[n.items.length-1];return e.sep??e.start}case"block-seq":return n.items[n.items.length-1].start;default:return[]}}function Js(n){if(n.length===0)return[];let e=n.length;e:for(;--e>=0;)switch(n[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;n[++e]?.type==="space";);return n.splice(e,n.length)}function si(n,e){if(e.length<1e5)Array.prototype.push.apply(n,e);else for(let t=0;t<e.length;++t)n.push(e[t])}function yf(n){if(n.start.type==="flow-seq-start")for(let e of n.items)e.sep&&!e.value&&!fs(e.start,"explicit-key-ind")&&!fs(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,xf(e.value)?e.value.end?si(e.value.end,e.sep):e.value.end=e.sep:si(e.start,e.sep),delete e.sep)}var zr=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 _r,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let s of this.lexer.lex(e,t))yield*this.next(s);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=hf(e);if(t)if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){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 t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{let s=this.peek(1);switch(t.type==="block-scalar"?t.indent="indent"in s?s.indent:0:t.type==="flow-collection"&&s.type==="document"&&(t.indent=0),t.type==="flow-collection"&&yf(t),s.type){case"document":s.value=t;break;case"block-scalar":s.props.push(t);break;case"block-map":{let r=s.items[s.items.length-1];if(r.value){s.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(r.sep)r.value=t;else{Object.assign(r,{key:t,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:t}):r.value=t;break}case"flow-collection":{let r=s.items[s.items.length-1];!r||r.value?s.items.push({start:[],key:t,sep:[]}):r.sep?r.value=t:Object.assign(r,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((s.type==="document"||s.type==="block-map"||s.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let r=t.items[t.items.length-1];r&&!r.sep&&!r.value&&r.start.length>0&&bf(r.start)===-1&&(t.indent===0||r.start.every(o=>o.type!=="comment"||o.indent<t.indent))&&(s.type==="document"?s.end=r.start:s.items.push({start:r.start}),t.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":{bf(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 t=this.startBlockValue(e);t?this.stack.push(t):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 t=ni(this.peek(2)),s=Js(t),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 t=this.source.indexOf(`
|
|
126
|
+
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
127
|
+
`,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let s="end"in t.value?t.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 t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){si(r,t.start),r.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let s=!this.onKeyLine&&this.indent===e.indent,r=s&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",o=[];if(r&&t.sep&&!t.value){let i=[];for(let l=0;l<t.sep.length;++l){let a=t.sep[l];switch(a.type){case"newline":i.push(l);break;case"space":break;case"comment":a.indent>e.indent&&(i.length=0);break;default:i.length=0}}i.length>=2&&(o=t.sep.splice(i[1]))}switch(this.type){case"anchor":case"tag":r||t.value?(o.push(this.sourceToken),e.items.push({start:o}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.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(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(fs(t.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(xf(t.key)&&!fs(t.sep,"newline")){let i=Js(t.start),l=t.key,a=t.sep;a.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:l,sep:a}]})}else o.length>0?t.sep=t.sep.concat(o,this.sourceToken):t.sep.push(this.sourceToken);else if(fs(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let i=Js(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||r?e.items.push({start:o,key:null,sep:[this.sourceToken]}):fs(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{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||t.value?(e.items.push({start:o,key:i,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(i):(Object.assign(t,{key:i,sep:[]}),this.onKeyLine=!0);return}default:{let i=this.startBlockValue(e);if(i){if(i.type==="block-seq"){if(!t.explicitKey&&t.sep&&!fs(t.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 t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let s="end"in t.value?t.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 t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){si(r,t.start),r.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||fs(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.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 t=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":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let r=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:r,sep:[]}):t.sep?this.stack.push(r):Object.assign(t,{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=ni(s),o=Js(r);yf(e);let i=e.end.splice(1,e.end.length);i.push(this.sourceToken);let l={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]=l}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
|
|
128
|
+
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
129
|
+
`,t)+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 t=ni(e),s=Js(t);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 t=ni(e),s=Js(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!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 um(n){let e=n.prettyErrors!==!1;return{lineCounter:n.lineCounter||e&&new $s||null,prettyErrors:e}}function ri(n,e={}){let{lineCounter:t,prettyErrors:s}=um(e),r=new zr(t?.addNewLine),o=new Dr(e),i=null;for(let l of o.compose(r.parse(n),!0,n.length))if(!i)i=l;else if(i.options.logLevel!=="silent"){i.errors.push(new Mn(l.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return s&&t&&(i.errors.forEach(_a(n,t)),i.warnings.forEach(_a(n,t))),i}function Za(n,e,t){let s;typeof e=="function"?s=e:t===void 0&&e&&typeof e=="object"&&(t=e);let r=ri(n,t);if(!r)return null;if(r.warnings.forEach(o=>Io(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},t))}function oi(n){let e=Za(n);for(let t of["light","dark","kinds","roles"])if(!e||typeof e[t]!="object")throw new Error(`theme: missing "${t}"`);return e}function Xs(n,e={},t={}){let s={...n.kinds};for(let[r,o]of Object.entries(t)){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{...n,roles:{...n.roles,...e},kinds:s}}var wf=n=>Object.entries(n).map(([e,t])=>`--${e}:${t}`).join(";");function Tn(n,e){return e in n.light?`var(--${e})`:e}function ii(n){let{light:e,dark:t,rest:s}=Kr(n);return`:root{${e}}
|
|
130
|
+
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){${t}}}
|
|
131
|
+
:root[data-theme="dark"]{${t}}
|
|
132
|
+
${s}`}function Kr(n){let e="";for(let[t,s]of Object.entries(n.roles))e+=`.k-${t}{--h:${s.h};--s:${s.s}%}`,s.top?e+=`.k-${t} .top{fill:${s.top}}`:s.tint&&(e+=`.k-${t} .top{fill:color-mix(in srgb,hsl(${s.h} ${Math.min(100,s.s+15)}% 50%) ${s.tint}%,var(--pad-top))}`),e+=`
|
|
133
|
+
`;for(let[t,s]of Object.entries(n.kinds)){let r=Tn(n,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-${t}{stroke:${r}${o}} .t-${t}{fill:${r}} .c-${t}{--c:${r}}
|
|
134
|
+
`}return{light:wf(n.light),dark:wf(n.dark),rest:e}}var ai=class extends Error{diags;constructor(e){super(e.map(t=>`${t.line}:${t.col} ${t.message}`).join(`
|
|
135
|
+
`)),this.diags=e}};function el(n,e){let t=n.length,s=e.length;if(!t)return s;if(!s)return t;let r=Array.from({length:t+1},(o,i)=>[i,...Array(s).fill(0)]);for(let o=0;o<=s;o++)r[0][o]=o;for(let o=1;o<=t;o++)for(let i=1;i<=s;i++){let l=n[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]+l),o>1&&i>1&&n[o-1]===e[i-2]&&n[o-2]===e[i-1]&&(r[o][i]=Math.min(r[o][i],r[o-2][i-2]+1))}return r[t][s]}function Bt(n,e){let t,s=1/0,r=n.toLowerCase();for(let i of e){let l=el(r,i.toLowerCase());l<s&&(s=l,t=i)}if(t===void 0)return;let o=Math.max(1,Math.min(3,Math.floor(Math.max(n.length,t.length)/3)));return s<=o?t:void 0}function tl(n,e,t){n.file&&(e=n.file,t=n.source);let r=`${n.line?`${e}:${n.line}:${n.col}`:e} ${n.severity}: ${n.message}`;if(n.hint&&(r+=`
|
|
136
|
+
${n.hint}`),t&&n.line){let i=t.split(/\r?\n/)[n.line-1]??"",l=String(n.line).padStart(4);r+=`
|
|
137
|
+
${l} | ${i}
|
|
138
|
+
${" ".repeat(l.length)} | ${" ".repeat(Math.max(0,n.col-1))}^`}return r}function kf(n,e,t){return n.map(s=>tl(s,e,t)).join(`
|
|
139
139
|
|
|
140
|
-
`)}function
|
|
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
|
|
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,"&").replace(/</g,"<").replace(/>/g,">"),lu=t=>Zl(t).replace(/"/g,""");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=`
|
|
140
|
+
`)}function vf(n){return n.split("/").slice(1).map(e=>{let t=e.replace(/~1/g,"/").replace(/~0/g,"~");return/^\d+$/.test(t)?Number(t):t})}function Sf(n){let e=new $s,t=ri(n,{lineCounter:e,prettyErrors:!1,uniqueKeys:!0}),s=[],r=a=>{let c=e.linePos(a);return{line:c.line,col:c.col}};for(let a of t.errors){let c=r(a.pos[0]),f=a.message.split(`
|
|
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 a of t.warnings){let c=r(a.pos[0]);s.push({severity:"warning",message:`YAML: ${a.message.split(`
|
|
142
|
+
`)[0]}`,line:c.line,col:c.col,path:""})}function o(a,c={}){let f=vf(a),u=t.contents,d={line:1,col:1},h=b=>{let m=b?.range;m&&(d=r(m[0]))};h(u);for(let b=0;b<f.length;b++){let m=f[b];if(qt(u)){let y=u.items.find(N=>Ge(N)&&_e(N.key)&&String(N.key.value)===String(m));if(!y)break;if(c.key&&b===f.length-1)return h(y.key),d;h(y.key),u=y.value,u&&h(u)}else if(Ut(u)&&typeof m=="number"){if(u=u.items[m],!u)break;h(u)}else break}return d}function i(a){let c=t.contents;for(let h of vf(a)){if(qt(c)){let b=c.items.find(m=>Ge(m)&&_e(m.key)&&String(m.key.value)===String(h));if(!b)return;c=b.value}else if(Ut(c)&&typeof h=="number")c=c.items[h];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=n.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 l=null;return t.errors.length||(l=t.toJS({maxAliasCount:100})),{data:l,locate:o,span:i,diags:s}}var mm=new Set(["svg","g","defs","marker","symbol","title","desc","path","polygon","polyline","line","rect","circle","ellipse","text","tspan","linearGradient","radialGradient","stop","clipPath"]),pm=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"]),hm=new Set(["fill","stroke","marker-start","marker-mid","marker-end","clip-path","style"]),gm={amp:"&",lt:"<",gt:">",quot:'"',apos:"'","#39":"'"},$f=n=>n.replace(/&(amp|lt|gt|quot|apos|#39);/g,(e,t)=>gm[t]);function nl(n,e){return n.startsWith("data-")||n.startsWith("aria-")?/^[a-z][\w-]*$/.test(n):!(!pm.has(n)||hm.has(n)&&/url\(\s*(?!['"]?#)|javascript:|expression\(|@import/i.test(e))}function sl(n){let e={name:"#root",attrs:[],children:[]},t=[{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(n);){if(r.index!==o)throw new Error(`not the renderer's SVG at ${o}: ${JSON.stringify(n.slice(o,o+40))}`);o=s.lastIndex;let i=t[t.length-1];if(r[0].charAt(1)!=="!"){if(r[1]){if(t.length<2||i.node.name!==r[1])throw new Error(`a stray </${r[1]}>`);t.pop();continue}if(r[2]){let l=r[2],a=[];for(let u of r[3].matchAll(/([\w:-]+)="([^"]*)"/g)){let d=u[1],h=$f(u[2]);d==="xmlns"||d.startsWith("xmlns:")||nl(d,h)&&a.push([d,h])}let c={name:l,attrs:a,children:[]},f=i.dropped||!mm.has(l);f||i.node.children.push(c),r[4]||t.push({node:c,dropped:f});continue}!i.dropped&&r[5].trim()&&i.node.children.push($f(r[5]))}}if(o!==n.length)throw new Error(`not the renderer's SVG at ${o}`);if(t.length!==1)throw new Error(`<${t[t.length-1].node.name}> is never closed`);return e}var bm="http://www.w3.org/2000/svg",Mf=n=>n.replace(/var\(--([a-zA-Z][\w-]*)/g,"var(--iso-$1");function Ef(n,e=document){let t=r=>{let o=e.createElementNS(bm,r.name);for(let[i,l]of r.attrs)i==="style"?o.style.cssText=Mf(l):o.setAttribute(i,/var\(--/.test(l)?Mf(l):l);for(let i of r.children)o.append(typeof i=="string"?e.createTextNode(i):t(i));return o},s=sl(n).children.find(r=>typeof r!="string"&&r.name==="svg");if(!s)throw new Error("the drawing has no <svg>");return t(s)}var ym=n=>n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),Vr=class n{name;attrs=[];children=[];style={};constructor(e){this.name=e}setAttribute(e,t){let s=this.attrs.findIndex(r=>r[0]===e);s>=0?this.attrs[s][1]=String(t):this.attrs.push([e,String(t)])}getAttribute(e){return this.attrs.find(t=>t[0]===e)?.[1]??null}append(...e){for(let t of e)t!=null&&this.children.push(t)}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(([,t])=>t!==""&&t!==void 0).map(([t,s])=>`${ym(t)}:${s}`).join(";");return{name:this.name,attrs:e?[...this.attrs,["style",e]]:[...this.attrs],children:this.children.map(t=>t instanceof n?t.toNode():t)}}},Tf={createElementNS:(n,e)=>new Vr(e)},Af=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),xm=n=>Af(n).replace(/"/g,""");function li(n,e=new Set(["style"])){if(typeof n=="string")return Af(n);let t=n.attrs.map(([r,o])=>` ${r}="${xm(o)}"`).join("");if(!n.children.length)return`<${n.name}${t}/>`;let s=e.has(n.name)?n.children.map(r=>typeof r=="string"?r.replace(/<\//g,"<\\/"):li(r,e)).join(""):n.children.map(r=>li(r,e)).join("");return`<${n.name}${t}>${s}</${n.name}>`}var wm=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 rl(n){let e=new TextEncoder().encode(n),t=e.length,s=Math.ceil((t+9)/64),r=new Uint8Array(s*64);r.set(e),r[t]=128;let o=new DataView(r.buffer);o.setUint32(r.length-4,t*8>>>0),o.setUint32(r.length-8,Math.floor(t/536870912));let i=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),l=new Uint32Array(64),a=(c,f)=>c>>>f|c<<32-f;for(let c=0;c<s;c++){for(let p=0;p<16;p++)l[p]=o.getUint32(c*64+p*4);for(let p=16;p<64;p++){let g=a(l[p-15],7)^a(l[p-15],18)^l[p-15]>>>3,x=a(l[p-2],17)^a(l[p-2],19)^l[p-2]>>>10;l[p]=l[p-16]+g+l[p-7]+x>>>0}let[f,u,d,h,b,m,y,N]=i;for(let p=0;p<64;p++){let g=N+(a(b,6)^a(b,11)^a(b,25))+(b&m^~b&y)+wm[p]+l[p]>>>0,x=(a(f,2)^a(f,13)^a(f,22))+(f&u^f&d^u&d)>>>0;N=y,y=m,m=b,b=h+g>>>0,h=d,d=u,u=f,f=g+x>>>0}i[0]+=f,i[1]+=u,i[2]+=d,i[3]+=h,i[4]+=b,i[5]+=m,i[6]+=y,i[7]+=N}return[...i].map(c=>c.toString(16).padStart(8,"0")).join("")}function Of(n){if(n!=="sha256")throw new Error(`only sha256 here, not ${n}`);let e="",t={update(s){return e+=s,t},digest(s){return rl(e)}};return t}var Rf=n=>{if(n&&typeof n=="object"){Object.freeze(n);for(let e of Object.values(n))Rf(e)}return n},ci=[86,81,76],km=["send","reply","token","blocked","user","event","control","planned"],jt=Rf({light:{paper:"#ffffff",ink:"#141414",steps:[{top:"#f4f4f4",left:"#dcdcdc",right:"#c4c4c4",edge:"#3a3a3a"},{top:"#dedede",left:"#bfbfbf",right:"#a2a2a2",edge:"#2e2e2e"},{top:"#bcbcbc",left:"#9a9a9a",right:"#7e7e7e",edge:"#222222"},{top:"#8f8f8f",left:"#707070",right:"#565656",edge:"#141414"}]},dark:{paper:"#161616",ink:"#f2f2f2",steps:[{top:"#2a2a2a",left:"#222222",right:"#1b1b1b",edge:"#b8b8b8"},{top:"#454545",left:"#383838",right:"#2c2c2c",edge:"#c8c8c8"},{top:"#6a6a6a",left:"#565656",right:"#444444",edge:"#dadada"},{top:"#9c9c9c",left:"#808080",right:"#686868",edge:"#141414"}]},patterns:["none","hatch","hatch-wide","dots"],rhythms:[{dash:[],width:2.6},{dash:[9,4],width:2.4},{dash:[7,6],width:2.4},{dash:[3,6],width:2.4},{dash:[1.5,3.5],width:2.6},{dash:[10,3,2,3],width:2.4},{dash:[],width:1.4},{dash:[7,6],width:1.4},{dash:[3,3],width:1.6},{dash:[14,4],width:1.8}],kindOrder:km,thresholds:ci,darkWidthAdd:.4}),vm=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i,Sm=/^hsl\(\s*([+-]?(?:\d+\.?\d*|\.\d+))\s+([+-]?(?:\d+\.?\d*|\.\d+))%\s+([+-]?(?:\d+\.?\d*|\.\d+))%\s*\)$/i;function $m(n){if(typeof n!="string")throw new Error(`mono: invalid colour "${String(n)}"`);let e=n.trim(),t=vm.exec(e);if(t){let r=t[1];return r.length===3?[parseInt(r[0]+r[0],16)/255,parseInt(r[1]+r[1],16)/255,parseInt(r[2]+r[2],16)/255]:[parseInt(r.slice(0,2),16)/255,parseInt(r.slice(2,4),16)/255,parseInt(r.slice(4,6),16)/255]}let s=Sm.exec(e);if(s){let r=Number(s[1]),o=Number(s[2]),i=Number(s[3]);if(!Number.isFinite(r)||o<0||o>100||i<0||i>100)throw new Error(`mono: invalid colour "${n}"`);let l=(r%360+360)%360,a=o/100,c=i/100,f=a*Math.min(c,1-c),u=d=>{let h=(d+l/30)%12;return c-f*Math.max(-1,Math.min(h-3,9-h,1))};return[u(0),u(8),u(4)]}throw new Error(`mono: invalid colour "${n}"`)}function ol(n){let[e,t,s]=$m(n),r=o=>o<=.04045?o/12.92:((o+.055)/1.055)**2.4;return .2126*r(e)+.7152*r(t)+.0722*r(s)}function Gr(n){let e=ol(n);return e>216/24389?116*Math.cbrt(e)-16:24389/27*e}function qr(n,e){let t=ol(n),s=ol(e);return(Math.max(t,s)+.05)/(Math.min(t,s)+.05)}var Mm=new Set(jt.patterns),Em=new Map(jt.kindOrder.map((n,e)=>[n,e])),Tm=(n,e)=>n<e?-1:n>e?1:0,Nf=n=>[...new Set(n)].sort(Tm),Am=n=>Math.round(n*100)/100;function Om(n){return n>=ci[0]?0:n>=ci[1]?1:n>=ci[2]?2:3}function Nm(n){if(n.roles)for(let[e,t]of Object.entries(n.roles)){if(t.step!==void 0&&(typeof t.step!="number"||!Number.isInteger(t.step)||t.step<0||t.step>3))throw new Error(`mono: invalid step "${String(t.step)}" for role "${e}"`);if(t.pattern!==void 0&&(typeof t.pattern!="string"||!Mm.has(t.pattern)))throw new Error(`mono: invalid pattern "${String(t.pattern)}" for role "${e}"`)}if(n.kinds)for(let[e,t]of Object.entries(n.kinds)){if(t.dash!==void 0&&(!Array.isArray(t.dash)||!t.dash.every(s=>typeof s=="number"&&Number.isFinite(s)&&s>=0)))throw new Error(`mono: invalid dash "${String(t.dash)}" for kind "${e}"`);if(t.width!==void 0&&(typeof t.width!="number"||!Number.isFinite(t.width)||t.width<=0))throw new Error(`mono: invalid width "${String(t.width)}" for kind "${e}"`)}}function fi(n,e,t,s){if(e!=="light"&&e!=="dark")throw new Error(`mono: invalid mode "${String(e)}"`);s&&Nm(s);let r=jt[e],o=[],i=n.light["l-top"],l=Nf(t?.roles??Object.keys(n.roles)),a=new Map,c=[[],[],[],[]];for(let y of l){let N=s?.roles?.[y]?.step,p;if(N!==void 0)p=N;else{let g=n.roles[y];if(!g)throw new Error(`mono: unknown role "${y}"`);if(typeof i!="string")throw new Error('mono: theme.light is missing "l-top"');p=Om(Gr(`hsl(${g.h} ${g.s}% ${i})`))}a.set(y,p),c[p].push(y)}let f=new Map;for(let y=0;y<c.length;y++){let N=c[y];for(let p=0;p<N.length;p++){let g=N[p],x=s?.roles?.[g]?.pattern;if(x!==void 0)f.set(g,x);else{let $=p%jt.patterns.length,T=jt.patterns[$];if(f.set(g,T),p>=jt.patterns.length){let v=N.slice(0,p).find(A=>f.get(A)===T);v!==void 0&&o.push(`role "${g}" wraps on step ${y} to pattern "${T}", matching "${v}"`)}}}}let u={};for(let y of l){let N=a.get(y),p=f.get(y),g=r.steps[N];u[y]={step:N,pattern:p,top:g.top,left:g.left,right:g.right,edge:g.edge}}let d=Nf(t?.kinds??Object.keys(n.kinds)),h=e==="dark"?jt.darkWidthAdd:0,b={},m=0;for(let y of d){let N=s?.kinds?.[y],p=Em.get(y),g;if(p!==void 0)g=p;else if(g=jt.kindOrder.length+m,m++,g>=jt.rhythms.length){let v=g%jt.rhythms.length;(!N||N.dash===void 0||N.width===void 0)&&o.push(`kind "${y}" exceeds the ${jt.rhythms.length} line rhythms; reusing rhythm ${v}`),g=v}let x=jt.rhythms[g],$=N?.dash!==void 0?[...N.dash]:[...x.dash],T=N?.width!==void 0?N.width:Am(x.width+h);b[y]={dash:$,width:T}}return{mode:e,paper:r.paper,ink:r.ink,roles:u,kinds:b,warnings:o}}var Cu={};va(Cu,{ANTS_CSS:()=>iu,ANT_DASH:()=>Ol,ANT_SPEED:()=>Zr,ANT_STILL:()=>Nl,ASSEMBLE_STYLES:()=>nr,BOARD_3D:()=>ps,BOARD_CSS:()=>Nu,DISASSEMBLE_STYLES:()=>sr,EASING_NAMES:()=>so,EXTRAPOLATE:()=>Ns,FLAT_DEFAULTS:()=>Wl,FLAT_FONTS:()=>Jl,FONT_STACKS:()=>Ll,GRID_CSS:()=>Ul,LABEL_BUDGET:()=>Bi,MARKS_CSS:()=>Gl,MOTION_EASINGS:()=>Wf,MOTION_ORDERS:()=>Ts,MOTION_SCHEMA:()=>du,MotionBuilder:()=>to,NodesBuilder:()=>ir,Obstacles:()=>Es,PAGE_CSS:()=>Kl,PLAYER_CSS:()=>Yi,PLAYER_UI_CSS:()=>ql,ROUTE_BUDGET:()=>Si,SeriesBuilder:()=>ar,WALL_T:()=>Vn,alongPath:()=>Ci,antDash:()=>eo,antsOf:()=>Di,assemble:()=>Al,assembly:()=>Ni,baseCss:()=>Hi,bezier:()=>ds,bindMotion:()=>io,boardCatalog:()=>Ru,boardDiagram:()=>Pu,boardErrors:()=>Ji,boardOf:()=>Xi,boxAsset:()=>If,boxSilhouette:()=>$u,calloutRect:()=>bl,cardAsset:()=>Xl,checkMotion:()=>Ki,cloudPath:()=>fl,compileRaw:()=>ku,convexOverlap:()=>Jr,curveAt:()=>cr,defaultLabel:()=>Ff,disassemble:()=>su,drawCloud:()=>hi,drawDecos:()=>cl,drawLooks:()=>ou,drawingCss:()=>Vl,durationFor:()=>_l,easeOf:()=>Pn,facePainter:()=>pi,flatHit:()=>Ou,floorAt:()=>Qs,floorOf:()=>Mu,focusView:()=>zi,gateBox:()=>Yr,iconPainter:()=>Ur,inConvex:()=>yl,introSvg:()=>ru,kindsCss:()=>di,labelRect:()=>Xr,layoutFlat:()=>dr,lineRectArea:()=>Kf,localAt:()=>Su,markCss:()=>mi,metricsMeasure:()=>Au,midpoint:()=>zl,monoCss:()=>Dl,monoOfDrawing:()=>wu,monoTheme:()=>jl,motion:()=>cu,motionModel:()=>As,motionOfSteps:()=>Vi,motionOrder:()=>$l,motionSource:()=>oo,msOf:()=>Rn,noSource:()=>Hl,nodeKind:()=>Ms,nodeKindOr:()=>cn,offscreen:()=>tr,openList:()=>ml,overlap2:()=>bi,overlaps:()=>Wi,paddingOf:()=>Eu,paint:()=>Ii,paintMono:()=>xu,parseEnd:()=>Zt,place:()=>yi,placeBoard:()=>lo,placeCallout:()=>Ai,placeNodeLabel:()=>Qr,placeholderIcon:()=>ll,planOf:()=>rr,plate:()=>Lf,polyBounds:()=>An,polyRectArea:()=>er,readMs:()=>ro,rectArea:()=>gl,regionKind:()=>ht,regionRole:()=>ji,registerMarks:()=>Cf,renderScene:()=>or,resolveSteps:()=>Ui,resolveSvg:()=>yu,routeAll:()=>$i,screenToGrid:()=>vu,silhouette:()=>Rt,simplify:()=>Wr,snapMove:()=>Tu,springAt:()=>lr,svgAt:()=>Tl,usedIn:()=>Bl,wallHeight:()=>ui,wallsOf:()=>Fi,withAnts:()=>au});var ht=(n,e)=>e!==void 0&&Object.hasOwn(n.regions,e)?n.regions[e]:void 0,Ms=(n,e)=>n.nodes[e??n.defaultNode],cn=(n,e)=>Ms(n,e)??n.nodes[n.defaultNode],ui=n=>Object.values(n.regions).find(e=>e.shape==="walled")?.z[1]??.8,di=n=>Object.values(n.regions).map(e=>e.css??"").join("");var il=Object.create(null),al=[];function Cf(n){Object.assign(il,n.icons??{}),Object.assign(Ds,n.faces??{}),n.css&&!al.includes(n.css)&&al.push(n.css)}var mi=()=>al.join(""),Ur=n=>Object.hasOwn(il,n)?il[n]:void 0,pi=n=>Object.hasOwn(Ds,n)?Ds[n]:void 0;function ll(n,e){let t=(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=[[t-o,s-o,r],[t+o,s-o,r],[t+o,s+o,r],[t-o,s+o,r]];return n.poly(i,"ico-unknown")+n.line3([t-o*.3,s-o*.35,r],[t+o*.3,s-o*.35,r],"ico-unknown-q")+n.line3([t+o*.3,s-o*.35,r],[t,s+o*.1,r],"ico-unknown-q")+n.line3([t,s+o*.45,r],[t,s+o*.5,r],"ico-unknown-q")}function cl(n,e,t){let s="";for(let r of t??[])r==="terminal"?s+=vr(n,e,3):r==="envelope"?s+=xo(n,e):r==="bubble"?s+=wo(n,e):r==="file-lines"?s+=ko(n,e):typeof r=="object"&&(r.terminal&&(s+=vr(n,e,r.terminal)),r.icon&&(s+=(Ur(r.icon)??ll)(n,e)));return s}var Rm=(n,e)=>(n.deco??e.deco??[]).filter(t=>t!=="ghost");function If(n,e,t,s,r,o){let i={name:n,description:e,size:t,role:s,deco:r,draw:(l,a,c)=>l.blockFaces(a)+cl(l,a,Rm(c,i))+(o?o(l,a):"")};return i}function Lf(n){let[e,t]=yo(n);return{x0:e-.75,y0:t-.75,x1:e+.75,y1:t+.75,z0:n.z0,z1:n.z0+.18}}function fl(n,e){let t=Math.max(8,Math.min(n,e)*.18),s=t*.55,r=s,o=s,i=n-s,l=e-s,a=(c,f,u,d)=>{let h=Math.hypot(u-c,d-f),b=Math.max(1,Math.round(h/(t*1.7))),m="";for(let y=1;y<=b;y++){let N=c+(u-c)*y/b,p=f+(d-f)*y/b,g=h/b/2*1.08;m+=` A${g.toFixed(1)},${g.toFixed(1)} 0 0 1 ${N.toFixed(1)},${p.toFixed(1)}`}return m};return`M${r.toFixed(1)},${o.toFixed(1)}`+a(r,o,i,o)+a(i,o,i,l)+a(i,l,r,l)+a(r,l,r,o)+"Z"}function hi(n,e){let t={...e,z0:e.z1},s=l=>{let[a,c]=Ce(e.x0,e.y0,l);return[wt,.5,-wt,.5,a,c]},r=(e.x1-e.x0)*st,o=(e.y1-e.y0)*st,i=fl(r,o);return n.onMatrix(s(e.z0),r,o,()=>Ee("path",{d:i,class:"lft cloud-side"}))+n.onMatrix(s(e.z1),r,o,()=>Ee("path",{d:i,class:"top cloud-top"}))}function Ff(n,e){let[t,s]=Ce((n.x0+n.x1)/2,(n.y0+n.y1)/2,n.z1+.75);return{x:t,y:s-18+(e?0:6),anchor:"middle"}}var Vn=.16,ul=["right-of","left-of","below","behind"];function yi(n,e,t,s,r,o={},i){let l=[],a=(k,O,w,R=!1,I="error")=>{let G=t.locate(k,{key:R});l.push({severity:I,message:O,line:G.line,col:G.col,path:k,hint:w})},c=[],f=new Map,u=[],d=new Map,h=new Set([...Object.keys(s.roles),...Object.keys(o)]);function b(k,O){let w=f.get(k.id);if(w){let R=t.locate(w.path+"/id");return a(k.path+"/id",`duplicate id "${k.id}" (first used on line ${R.line})`),!1}return f.set(k.id,k),c.push(k),k.parent=O,O?O.children.push(k):u.push(k),!0}let m=()=>({x0:0,y0:0,z0:0,x1:0,y1:0,z1:0});function y(k,O,w){let R={id:k.id,type:"node",path:O,children:[],box:m(),floor:0,node:k,appears:k.appears,disappears:k.disappears};b(R,w)&&(k.nodes??[]).forEach((I,G)=>y(I,`${O}/nodes/${G}`,R))}function N(k,O,w){let R={id:k.id,type:"region",path:O,children:[],box:m(),floor:0,region:k,appears:k.appears,disappears:k.disappears};b(R,w)&&((k.nodes??[]).forEach((I,G)=>y(I,`${O}/nodes/${G}`,R)),(k.regions??[]).forEach((I,G)=>N(I,`${O}/regions/${G}`,R)))}(n.regions??[]).forEach((k,O)=>N(k,`${e}/regions/${O}`,void 0)),(n.nodes??[]).forEach((k,O)=>y(k,`${e}/nodes/${O}`,void 0));let p=()=>f.keys(),g=()=>c.filter(k=>k.type==="region").map(k=>k.id);for(let k of[...c]){let O=k.node??k.region;if(O.in!==void 0){let R=f.get(O.in);if(!R){a(k.path+"/in",`unknown region "${O.in}"`+Hr(O.in,g()));continue}if(R.type!=="region"){a(k.path+"/in",`"${O.in}" is a node, not a region; put nodes on a node with its own "nodes:" list`);continue}if(k.parent&&k.parent!==R){a(k.path+"/in",`"${k.id}" is written inside "${k.parent.id}" but says in: ${O.in}; use one or the other`);continue}for(let I=R;I;I=I.parent)if(I===k){a(k.path+"/in",`"${k.id}" cannot be inside itself`);continue}k.parent||(u.splice(u.indexOf(k),1),k.parent=R,R.children.push(k))}if(k.node){let R=k.node.asset;R!==void 0&&!Ms(r,R)&&a(k.path+"/asset",`unknown asset "${R}"`+Hr(R,Object.keys(r.nodes)),`assets: ${Object.keys(r.nodes).join(", ")}`)}let w=(k.node??k.region).role;w!==void 0&&!h.has(w)&&a(k.path+"/role",`unknown colour role "${w}"`+Hr(w,h),`add it under "roles:" at the top of the file, or use one of: ${[...h].join(", ")}`)}for(let k of c){let O=k.region?.gate;if(!O?.node)continue;let w=f.get(O.node);if(!w){a(k.path+"/gate/node",`unknown node "${O.node}"`+Hr(O.node,p()));continue}if(w.type!=="node"){a(k.path+"/gate/node",`"${O.node}" is a region; a gate is a node`);continue}w.placedBy=k.id;let R=w.node;(R.at||ul.some(I=>R[I]))&&a(w.path,`"${w.id}" is the gate of "${k.id}", which places it; its own placement is ignored`,void 0,!1,"warning")}let x=k=>k.gap??n.gap??2;function $(k){let O=k.node,w=cn(r,O.asset),R=O.size,I=w.size[0],G=w.size[1],X=w.size[2];if(R&&(I=R[0],G=R[1],R.length>2&&(X=R[2])),k.placedBy){let U=f.get(k.placedBy).region,B=U.gate,H=B.width??2,Y=R?Math.min(I,G):.3;X=R&&R.length>2?X:B.height??(U.height??ui(r))+.3,B.side==="e"||B.side==="w"?(I=Y,G=H):(I=H,G=Y)}return[I,G,X]}function T(k,O,w,R,I){for(let W of O)A(W);let G=O.filter(W=>!W.placedBy),X=new Set(G),U=new Set,B=[],H=new Set,Y=W=>{let oe=W.node??W.region,Me=[];for(let Le of ul){let C=oe[Le];if(C===void 0)continue;let V=f.get(C);if(!V){a(`${W.path}/${Le}`,`unknown id "${C}"`+Hr(C,p()));continue}if(V===W){a(`${W.path}/${Le}`,`"${W.id}" cannot be placed ${Le} itself`);continue}if(!X.has(V)){let te=ae=>ae.parent?`"${ae.parent.id}"`:"the scene";a(`${W.path}/${Le}`,`"${C}" is in ${te(V)} but "${W.id}" is in ${te(W)}; relative placement works between items in the same region`,V.placedBy?`"${C}" is a gate, placed by its ${f.get(V.placedBy)?.region?.kind??"region"}`:`place "${W.id}" relative to something in ${te(W)}, or use "at:"`);continue}Me.push(V)}if(!Me.length&&!oe.at){let Le=G.indexOf(W);Le>0&&Me.push(G[Le-1])}return Me},ee=W=>{if(!U.has(W)){if(H.has(W)){a(W.path,`placement loop: "${W.id}" is placed relative to something placed relative to it`);return}H.add(W),Y(W).forEach(ee),H.delete(W),U.add(W),B.push(W)}};G.forEach(ee);for(let W of B){let oe=W.node??W.region,Me=d.get(W),Le=ul.find(C=>oe[C]!==void 0&&f.get(oe[C])&&X.has(f.get(oe[C])));if(oe.at&&Le&&a(`${W.path}/at`,`"${W.id}" has both "at" and "${Le}"; "at" wins`,void 0,!0,"warning"),oe.at)Me.x=oe.at[0],Me.y=oe.at[1];else if(Le)v(Me,d.get(f.get(oe[Le])),Le,x(oe),oe.align??"center");else{let C=G.indexOf(W);C>0?v(Me,d.get(G[C-1]),R==="row"?"right-of":"below",x(oe),"center"):(Me.x=w,Me.y=w)}oe.shift&&(Me.x+=oe.shift[0],Me.y+=oe.shift[1])}if(I||!G.length)return{w:0,d:0};let F=1/0,K=1/0,q=-1/0,Z=-1/0;for(let W of G){let oe=d.get(W);F=Math.min(F,oe.x),K=Math.min(K,oe.y),q=Math.max(q,oe.x+oe.w),Z=Math.max(Z,oe.y+oe.d)}let ce=Math.min(0,F-w),fe=Math.min(0,K-w);if(ce||fe)for(let W of G){let oe=d.get(W);oe.x-=ce,oe.y-=fe}return{w:q-ce+w,d:Z-fe+w}}function v(k,O,w,R,I){let G=()=>{k.y=I==="start"?O.y:I==="end"?O.y+O.d-k.d:O.y+(O.d-k.d)/2},X=()=>{k.x=I==="start"?O.x:I==="end"?O.x+O.w-k.w:O.x+(O.w-k.w)/2};w==="right-of"?(k.x=O.x+O.w+R,G()):w==="left-of"?(k.x=O.x-R-k.w,G()):w==="below"?(k.y=O.y+O.d+R,X()):(k.y=O.y-R-k.d,X())}function A(k){if(k.type==="node"){let[B,H,Y]=$(k);d.set(k,{x:0,y:0,w:B,d:H,h:Y,z:k.node.z??0}),k.children.length&&T(k,k.children,0,"row",!0);return}let O=k.region,w=O.padding??ht(r,O.kind)?.pad,R=!!O.size,I=T(k,k.children,w,O.flow??"row",R),G=O.size?O.size[0]:Math.max(I.w,w*2+.5),X=O.size?O.size[1]:Math.max(I.d,w*2+.5);if(!O.size&&O.gate){let B=(O.gate.width??2)+1;O.gate.side==="e"||O.gate.side==="w"?X=Math.max(X,B):G=Math.max(G,B)}let U=O.size&&O.size.length>2?O.size[2]:O.height??ht(r,O.kind).z[1];d.set(k,{x:0,y:0,w:G,d:X,h:U,z:0})}T(void 0,u,0,n.flow??"row",!0);function L(k,O,w,R){let I=d.get(k),G=O+I.x,X=w+I.y;if(k.type==="region"){let U=ht(r,k.region.kind),[B]=U.z,H=U.floor,Y=U.shape==="slab"&&ht(r,k.parent?.region?.kind)?.shape==="slab"?0:B,ee=k.region.z??0,F=R+Y+ee,K=R+I.h+ee;k.box={x0:G,y0:X,z0:F,x1:G+I.w,y1:X+I.d,z1:K},k.floor=H?K:R}else{let U=R+I.z;k.box={x0:G,y0:X,z0:U,x1:G+I.w,y1:X+I.d,z1:U+I.h},k.floor=k.box.z1}for(let U of k.children)U.placedBy||L(U,G,X,k.floor)}for(let k of u)k.placedBy||L(k,0,0,0);if(i){let k=w=>Math.round(w/i)*i,O=w=>Math.round(w*1e9)/1e9;for(let w of c){if(w.placedBy)continue;let R=w.box,I=k(R.x0),G=k(R.x1),X=k(R.y0),U=k(R.y1);G-I<i&&(G=I+i),U-X<i&&(U=X+i),w.box={...R,x0:O(I),x1:O(G),y0:O(X),y1:O(U)};let B=w.node??w.region;B.at&&B.at.forEach((H,Y)=>{let ee=H/i;Math.abs(ee-Math.round(ee))>1e-6&&a(`${w.path}/at/${Y}`,`${H} is not on the ${i} grid; it is drawn at ${O(k(H))}`,void 0,!1,"warning")})}}for(let k of c){let O=k.region?.gate;if(!O?.node)continue;let w=f.get(O.node);!w||w.placedBy!==k.id||(w.box=Yr(k,d.get(w).h,d.get(w).w,d.get(w).d),w.floor=w.box.z1)}for(let k of c){let O=k.children.filter(w=>!w.placedBy);for(let w=0;w<O.length;w++)for(let R=w+1;R<O.length;R++){let I=O[w],G=O[R];gi(I,r)||gi(G,r)||bi(I.box,G.box)&&a(G.path,`"${G.id}" overlaps "${I.id}"`,'move one with "at", a relative placement, "gap" or "shift"',!1,"warning")}if(k.parent&&k.parent.type==="region"&&!k.placedBy){let w=k.parent.box,R=k.box,I=1e-6;(R.x0<w.x0-I||R.y0<w.y0-I||R.x1>w.x1+I||R.y1>w.y1+I)&&a(k.path,`"${k.id}" sticks out of region "${k.parent.id}"`,`make "${k.parent.id}" bigger, or leave out its "size" so it fits its contents`,!1,"warning")}}{let k=u.filter(O=>!O.placedBy);for(let O=0;O<k.length;O++)for(let w=O+1;w<k.length;w++){let R=k[O],I=k[w];bi(R.box,I.box)&&!gi(R,r)&&!gi(I,r)&&a(I.path,`"${I.id}" overlaps "${R.id}"`,'move one with "at", a relative placement, "gap" or "shift"',!1,"warning")}}let M=new Set,P=l.filter(k=>{let O=k.path+k.message;return M.has(O)?!1:(M.add(O),!0)});return{items:c,byId:f,roots:u,diags:P,catalog:r}}var gi=(n,e)=>n.type==="region"&&["zone","tunnel"].includes(ht(e,n.region.kind)?.shape??"");function Yr(n,e,t,s){let r=n.region.gate,o=n.box,i=n.box.z0,l=r.at??.5,a=r.width??2;if(r.side==="w"||r.side==="e"){let u=r.side==="w"?o.x0+Vn/2:o.x1-Vn/2,d=o.y0+(o.y1-o.y0)*l;return{x0:u-t/2,x1:u+t/2,y0:d-a/2,y1:d+a/2,z0:i,z1:i+e}}let c=r.side==="n"?o.y0+Vn/2:o.y1-Vn/2,f=o.x0+(o.x1-o.x0)*l;return{x0:f-a/2,x1:f+a/2,y0:c-s/2,y1:c+s/2,z0:i,z1:i+e}}function bi(n,e,t=1e-6){return n.x0<e.x1-t&&e.x0<n.x1-t&&n.y0<e.y1-t&&e.y0<n.y1-t}function Hr(n,e){let t=Bt(n,e);return t?` (did you mean "${t}"?)`:""}var Zn=.2,xi=.05,Pm=.6,wi=.25,ki={n:[0,-1],s:[0,1],e:[1,0],w:[-1,0]};function Zt(n){let e=/^(.*?)(?:\.(n|e|s|w|top))?$/.exec(n);return{id:e[1],side:e[2]}}var Bf=new WeakMap;function Qs(n,e,t){let s=Bf.get(n);if(!s){s=[];for(let i of n.items){if(i.type!=="region"||!ht(n.catalog,i.region.kind)?.floor)continue;let l=0;for(let a=i.parent;a;a=a.parent)l++;s.push({r:i,d:l})}Bf.set(n,s)}let r=0,o=-1;for(let{r:i,d:l}of s){let a=i.box,c=1e-6;e>=a.x0-c&&e<=a.x1+c&&t>=a.y0-c&&t<=a.y1+c&&l>o&&(o=l,r=i.floor)}return r}function Cm(n,e){let t=[(n.x0+n.x1)/2,(n.y0+n.y1)/2],s=[(e.x0+e.x1)/2,(e.y0+e.y1)/2],r=s[0]-t[0],o=s[1]-t[1],i=Math.max(e.x0-n.x1,n.x0-e.x1),l=Math.max(e.y0-n.y1,n.y0-e.y1);return i>0&&(l<=0||i>=l)?r>0?"e":"w":l>0?o>0?"s":"n":Math.abs(r)>=Math.abs(o)?r>0?"e":"w":o>0?"s":"n"}var Si=5e5;function $i(n,e,t,s,r,o){let i=[],l=(g,x,$,T="error")=>{let v=s.locate(g);i.push({severity:T,message:x,line:v.line,col:v.col,path:g,hint:$})},a=n.routes??[],c={left:Si},f=0,u=()=>t.items.map(g=>g.id),d=new Map,h=[],b=[];a.forEach((g,x)=>{let $=`${e}/routes/${x}`;(d.has(g.id)||t.byId.has(g.id))&&l($+"/id",`duplicate id "${g.id}"`),d.set(g.id,x);let T=g.kind??"send";r.has(T)||l($+"/kind",`unknown flow kind "${T}"`+dl(T,r),`kinds: ${[...r].join(", ")}; add one under "kinds:"`);let v={id:g.id,raw:g,path:$,kind:T,points:[]},A=(L,M)=>{let{id:P}=Zt(L),k=t.byId.get(P);if(!k){l(`${$}/${M}`,`unknown node "${P}"`+dl(P,u()));return}return k};v.from=A(g.from,"from"),v.to=A(g.to,"to"),h.push(v),b.push({r:v})});let m=new Map;for(let g of b){let{r:x}=g;if(!x.from||!x.to||x.raw.points)continue;let $=Zt(x.raw.from).side,T=Zt(x.raw.to).side,v=x.raw.via?.[0],A=x.raw.via?.[x.raw.via.length-1],L=(O,w)=>{if(Array.isArray(O))return{x0:O[0],x1:O[0],y0:O[1],y1:O[1],z0:0,z1:0};if(typeof O=="string"){let R=t.byId.get(Zt(O).id);if(R)return R.box}return w.box},M=(O,w,R)=>{let I=w??Cm(O.box,R);return{node:O,side:I,explicit:!!w,p:[0,0],z:0}};g.a=M(x.from,$,L(v,x.to)),g.b=M(x.to,T,L(A,x.from));let P=L(v,x.to),k=L(A,x.from);for(let[O,w]of[[g.a,P],[g.b,k]]){let R=`${O.node.id}.${O.side}`;m.has(R)||m.set(R,[]),m.get(R).push({e:O,other:[(w.x0+w.x1)/2,(w.y0+w.y1)/2]})}}for(let[,g]of m){let x=g[0].e,$=x.node.box,T=x.side,v=T==="e"||T==="w"?1:0;g.sort((O,w)=>O.other[v]-w.other[v]);let A=v?$.y0:$.x0,L=v?$.y1:$.x1,M=(A+L)/2,P=Math.max(0,L-A-.3),k=g.length>1?Math.min(Pm,P/(g.length-1)):0;g.forEach((O,w)=>{let R=(w-(g.length-1)/2)*k,I=M+R,G=O.e.node.box.z0;if(T==="top"){O.e.p=[($.x0+$.x1)/2,($.y0+$.y1)/2],O.e.z=$.z1;return}let[X,U]=ki[T];O.e.p=v?[X>0?$.x1+xi:$.x0-xi,I]:[I,U>0?$.y1+xi:$.y0-xi],O.e.z=G})}let y=[];for(let g of t.items)g.type==="node"&&y.push(g.box);let N=[];for(let g of t.items.filter(x=>ht(t.catalog,x.region?.kind)?.shape==="walled")){let{x0:x,y0:$,x1:T,y1:v}=g.box,A=Vn,L=g.region.gate,M=[[{x0:x,y0:$,x1:T,y1:$+A,z0:0,z1:0},"n"],[{x0:x,y0:v-A,x1:T,y1:v,z0:0,z1:0},"s"],[{x0:x,y0:$,x1:x+A,y1:v,z0:0,z1:0},"w"],[{x0:T-A,y0:$,x1:T,y1:v,z0:0,z1:0},"e"]];for(let[P,k]of M)if(L&&L.side===k){if(L.node)continue;let O=L.at??.5,w=L.width??2;if(k==="e"||k==="w"){let R=$+(v-$)*O;N.push({...P,y1:R-w/2},{...P,y0:R+w/2})}else{let R=x+(T-x)*O;N.push({...P,x1:R-w/2},{...P,x0:R+w/2})}}else N.push(P)}let p=new Map;for(let g of b){let{r:x,a:$,b:T}=g;if(x.raw.points){x.points=x.raw.points.map(I=>[I[0],I[1],I.length>2?I[2]:Qs(t,I[0],I[1])+.01]);continue}if(!$||!T)continue;let v=[];(x.raw.via??[]).forEach((I,G)=>{if(Array.isArray(I))if(o){let X=U=>Math.round(Math.round(U/o)*o*1e9)/1e9;I.forEach((U,B)=>{Math.abs(U/o-Math.round(U/o))>1e-6&&l(`${x.path}/via/${G}/${B}`,`${U} is not on the ${o} grid; it is drawn at ${X(U)}`,void 0,"warning")}),v.push({p:[X(I[0]),X(I[1])]})}else v.push({p:[I[0],I[1]]});else{let{id:X,side:U}=Zt(I),B=t.byId.get(X);if(!B){l(`${x.path}/via/${G}`,`unknown node "${X}"`+dl(X,u()));return}let H=U&&U!=="top"?U:"n",[Y,ee]=ki[H],F=B.box;v.push({p:[Y?Y>0?F.x1+.4:F.x0-.4:(F.x0+F.x1)/2,ee?ee>0?F.y1+.4:F.y0-.4:(F.y0+F.y1)/2]})}});let L=y.filter(I=>I!==$.node.box&&I!==T.node.box).concat(x.raw.cross?[]:N).filter(I=>!vi($.node.box,I)&&!vi(T.node.box,I)&&!vi(I,$.node.box)&&!vi(I,T.node.box)),M=$.side==="top"?void 0:ki[$.side],P=T.side==="top"?void 0:ki[T.side],k=[$.p,...v.map(I=>I.p),T.p],O=[$.p],w=M,R=!0;for(let I=0;I+1<k.length;I++){let G=I+2===k.length,X=Lm(k[I],k[I+1],L,p,w,G&&P?[-P[0],-P[1]]:void 0,c);if(!X){R=!1;break}O.push(...X.slice(1));let U=O.length;if(U>=2){let B=Math.sign(O[U-1][0]-O[U-2][0]),H=Math.sign(O[U-1][1]-O[U-2][1]);w=[B,H]}}!R&&c.left<=0?(f++,O=[$.p,[T.p[0],$.p[1]],T.p]):R||(l(x.path,`no path found for route "${x.id}" from "${$.node.id}" to "${T.node.id}"`,'add "via" points, or use "points" to draw it by hand',"warning"),O=[$.p,[T.p[0],$.p[1]],T.p]),O=Wr(O);for(let I=0;I+1<O.length;I++)Im(p,O[I],O[I+1]);x.points=jm(t,O,$,T)}return f&&l(e,`${f} of ${h.length} routes were drawn as plain elbows: the scene is too large to route them all around what stands in the way (${Si.toLocaleString("en")} search steps)`,'split it into scenes, or give the busiest routes "via" points or "points"',"warning"),{routes:h,diags:i}}function vi(n,e){return e.x0>=n.x0-1e-6&&e.x1<=n.x1+1e-6&&e.y0>=n.y0-1e-6&&e.y1<=n.y1+1e-6&&e.z0>=n.z1-1e-6}var jf=(n,e)=>`${Math.round(n/Zn)},${Math.round(e/Zn)}`;function Im(n,e,t){let s=Math.max(1,Math.round(Math.hypot(t[0]-e[0],t[1]-e[1])/Zn));for(let r=0;r<=s;r++){let o=jf(e[0]+(t[0]-e[0])*r/s,e[1]+(t[1]-e[1])*r/s);n.set(o,(n.get(o)??0)+1)}}function Df(n,e,t){for(let s of t)if(n>s.x0-wi&&n<s.x1+wi&&e>s.y0-wi&&e<s.y1+wi)return!0;return!1}function Lm(n,e,t,s,r,o,i={left:1/0}){if((Math.abs(n[0]-e[0])<1e-6||Math.abs(n[1]-e[1])<1e-6)&&Bm(n,e,t)){let B=[Math.sign(e[0]-n[0]),Math.sign(e[1]-n[1])],H=!r||r[0]===B[0]&&r[1]===B[1],Y=!o||o[0]===B[0]&&o[1]===B[1];if(H&&Y)return[n,e]}if(i.left<=0)return null;let l=B=>Math.round((B-n[0])/Zn),a=B=>Math.round((B-n[1])/Zn),c=B=>n[0]+B*Zn,f=B=>n[1]+B*Zn,u=l(e[0]),d=a(e[1]),h=30,b=Math.min(0,u)-h,m=Math.max(0,u)+h,y=Math.min(0,d)-h,N=Math.max(0,d)+h,p=1.2,g=Zn,x=.06,$=[[1,0],[-1,0],[0,1],[0,-1]],T=m-b+1,v=N-y+1,A=(B,H)=>(B-b)*v+(H-y),L=new Int8Array(T*v).fill(-1),M=new Float64Array(T*v).fill(-1),P=new Float64Array(T*v*4).fill(1/0),k=(B,H)=>{let Y=A(B,H);return L[Y]<0&&(L[Y]=Df(c(B),f(H),t)?1:0),L[Y]===1},O=(B,H)=>{let Y=A(B,H);return M[Y]<0&&(M[Y]=s.get(jf(c(B),f(H)))??0),M[Y]},w=ml(),R=(B,H)=>(Math.abs(B-u)+Math.abs(H-d))*g,I=r?$.findIndex(B=>B[0]===r[0]&&B[1]===r[1]):-1;w.push({i:0,j:0,d:I,g:0,f:R(0,0),idx:0,hp:0});let G=(B,H)=>Math.abs(B)+Math.abs(H)<=2,X=(B,H)=>Math.abs(B-u)+Math.abs(H-d)<=2,U=0;for(;w.length()&&U++<2e5;){if(i.left--<=0)return null;let B=w.take();if(B.i===u&&B.j===d&&!(o&&B.d>=0&&($[B.d][0]!==o[0]||$[B.d][1]!==o[1]))){let H=[];for(let Y=B;Y;Y=Y.prev)H.push([c(Y.i),f(Y.j)]);return H.reverse(),H[0]=n,Fm(Wr(H),e)}for(let H=0;H<4;H++){let Y=$[H];if(B.d>=0&&Y[0]===-$[B.d][0]&&Y[1]===-$[B.d][1])continue;let ee=B.i+Y[0],F=B.j+Y[1];if(ee<b||ee>m||F<y||F>N||!G(ee,F)&&!X(ee,F)&&k(ee,F))continue;if((G(ee,F)||X(ee,F))&&k(ee,F)&&!(ee===u&&F===d)){let ce=G(ee,F)?r:o&&[-o[0],-o[1]];if(!ce||(G(ee,F)?Y[0]!==ce[0]||Y[1]!==ce[1]:Y[0]!==o[0]||Y[1]!==o[1]))continue}let K=B.d>=0&&B.d!==H?p:0,q=B.g+g+K+O(ee,F)*x,Z=A(ee,F)*4+H;P[Z]<=q||(P[Z]=q,w.push({i:ee,j:F,d:H,g:q,f:q+R(ee,F),prev:B,idx:0,hp:0}))}}return null}function ml(){let n=[],e=[],t=(i,l)=>i.f<l.f||i.f===l.f&&i.idx<l.idx,s=(i,l)=>{let a=e[i];e[i]=e[l],e[l]=a,e[i].hp=i,e[l].hp=l},r=i=>{for(;i>0;){let l=i-1>>1;if(!t(e[i],e[l]))break;s(i,l),i=l}},o=i=>{for(;;){let l=2*i+1,a=l+1,c=i;if(l<e.length&&t(e[l],e[c])&&(c=l),a<e.length&&t(e[a],e[c])&&(c=a),c===i)return;s(i,c),i=c}};return{length:()=>n.length,push(i){i.idx=n.length,n.push(i),i.hp=e.length,e.push(i),r(i.hp)},take(){let i=e[0],l=e.pop();e.length&&(e[0]=l,l.hp=0,o(0));let a=n.pop();return a!==i&&(n[i.idx]=a,a.idx=i.idx,r(a.hp)),i}}}function Fm(n,e){let t=n.map(o=>[o[0],o[1]]),s=t.length,r=t[s-1];if(s>=2){let o=t[s-2];Math.abs(o[1]-r[1])<1e-9?(o[1]=e[1],s>=3&&Math.abs(t[s-3][1]-r[1])<1e-9&&(t[s-3][1]=e[1])):Math.abs(o[0]-r[0])<1e-9&&(o[0]=e[0],s>=3&&Math.abs(t[s-3][0]-r[0])<1e-9&&(t[s-3][0]=e[0]))}return t[s-1]=e,Wr(t)}function Bm(n,e,t){let s=Math.max(1,Math.round(Math.hypot(e[0]-n[0],e[1]-n[1])/(Zn/2)));for(let r=2;r<s-1;r++)if(Df(n[0]+(e[0]-n[0])*r/s,n[1]+(e[1]-n[1])*r/s,t))return!1;return!0}function Wr(n){let e=[];for(let t of n){let s=e.length;if(!(s&&Math.abs(e[s-1][0]-t[0])<1e-6&&Math.abs(e[s-1][1]-t[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]-t[0])<1e-6||Math.abs(r[1]-o[1])<1e-6&&Math.abs(o[1]-t[1])<1e-6){e[s-1]=t;continue}}e.push(t)}}return e}function jm(n,e,t,s){let r=new Set,o=new Set;for(let c of n.items)c.type!=="region"||!ht(n.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=[],l=(c,f)=>Qs(n,c,f)+.01;for(let c=0;c+1<e.length;c++){let[f,u]=e[c],[d,h]=e[c+1],b=[0,1];if(Math.abs(u-h)<1e-6)for(let m of r){let y=(m-f)/(d-f);y>1e-6&&y<1-1e-6&&b.push(y)}else for(let m of o){let y=(m-u)/(h-u);y>1e-6&&y<1-1e-6&&b.push(y)}b.sort((m,y)=>m-y);for(let m=0;m+1<b.length;m++){let y=b[m],N=b[m+1],p=(y+N)/2,g=l(f+(d-f)*p,u+(h-u)*p),x=[f+(d-f)*y,u+(h-u)*y,g],$=[f+(d-f)*N,u+(h-u)*N,g],T=i[i.length-1];T&&(Math.abs(T[0]-x[0])>1e-6||Math.abs(T[1]-x[1])>1e-6||Math.abs(T[2]-x[2])>1e-6)?i.push(x):T||i.push(x),i.push($)}}i.length&&(i[0][2]=t.side==="top"?t.z:t.node.box.z0+.01,i[i.length-1][2]=s.side==="top"?s.z:s.node.box.z0+.01);let a=[];for(let c of i){let f=a.length;if(f>=2){let u=a[f-2],d=a[f-1],h=Math.abs(u[2]-d[2])<1e-9&&Math.abs(d[2]-c[2])<1e-9,b=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(h&&b){a[f-1]=c;continue}}a.push(c)}return a}function dl(n,e){let t=Bt(n,e);return t?` (did you mean "${t}"?)`:""}function Rt(n){return[Ce(n.x0,n.y0,n.z1),Ce(n.x1,n.y0,n.z1),Ce(n.x1,n.y0,n.z0),Ce(n.x1,n.y1,n.z0),Ce(n.x0,n.y1,n.z0),Ce(n.x0,n.y1,n.z1)]}function An(n){let e=n.map(o=>o[0]),t=n.map(o=>o[1]),s=Math.min(...e),r=Math.min(...t);return{x:s,y:r,w:Math.max(...e)-s,h:Math.max(...t)-r}}function er(n,e){let t=n,s=(l,a)=>{let c=[];for(let f=0;f<t.length;f++){let u=t[f],d=t[(f+1)%t.length],h=l(u),b=l(d);h&&c.push(u),h!==b&&c.push(a(u,d))}t=c},r=l=>(a,c)=>[l,a[1]+(c[1]-a[1])*(l-a[0])/(c[0]-a[0])],o=l=>(a,c)=>[a[0]+(c[0]-a[0])*(l-a[1])/(c[1]-a[1]),l];if(s(l=>l[0]>=e.x,r(e.x)),!t.length||(s(l=>l[0]<=e.x+e.w,r(e.x+e.w)),!t.length)||(s(l=>l[1]>=e.y,o(e.y)),!t.length)||(s(l=>l[1]<=e.y+e.h,o(e.y+e.h)),!t.length))return 0;let i=0;for(let l=0;l<t.length;l++){let a=t[l],c=t[(l+1)%t.length];i+=a[0]*c[1]-c[0]*a[1]}return Math.abs(i)/2}function gl(n,e){let t=Math.min(n.x+n.w,e.x+e.w)-Math.max(n.x,e.x),s=Math.min(n.y+n.h,e.y+e.h)-Math.max(n.y,e.y);return t>0&&s>0?t*s:0}function Kf(n,e){let t=0;for(let s=0;s+1<n.length;s++){let r=n[s],o=n[s+1],i=Math.hypot(o[0]-r[0],o[1]-r[1]),l=Math.max(1,Math.ceil(i/4));for(let a=0;a<l;a++){let c=r[0]+(o[0]-r[0])*(a+.5)/l,f=r[1]+(o[1]-r[1])*(a+.5)/l;c>=e.x&&c<=e.x+e.w&&f>=e.y&&f<=e.y+e.h&&(t+=i/l*4)}}return t}var es=64,Ei=class{cells=new Map;n=0;add(e,t,s,r,o){for(let i=Math.floor(t/es);i<=Math.floor(r/es);i++)for(let l=Math.floor(s/es);l<=Math.floor(o/es);l++){let a=i*1048576+l,c=this.cells.get(a);c||this.cells.set(a,c=[]),c[c.length-1]!==e&&c.push(e)}}query(e,t,s,r){let o=new Set;for(let i=Math.floor(e/es);i<=Math.floor(s/es);i++)for(let l=Math.floor(t/es);l<=Math.floor(r/es);l++){let a=this.cells.get(i*1048576+l);if(a)for(let c of a)o.add(c)}return[...o].sort((i,l)=>i-l)}},pl=n=>{let e=1/0,t=1/0,s=-1/0,r=-1/0;for(let[o,i]of n)o<e&&(e=o),o>s&&(s=o),i<t&&(t=i),i>r&&(r=i);return[e,t,s,r]},Ti=new WeakMap;function us(n,e){let t=Ti.get(n);for((!t||t.n>n.length)&&Ti.set(n,t=new Ei);t.n<n.length;t.n++){let[s,r,o,i]=e(n[t.n]);t.add(t.n,s,r,o,i)}return t}function _f(n){let e=Ti.get(n);for((!e||e.n>n.length)&&Ti.set(n,e=new Ei);e.n<n.length;e.n++){let t=n[e.n].pts;for(let s=0;s+1<t.length;s++){let r=t[s],o=t[s+1],i=e.n*65536+s,l=Math.max(1,Math.ceil(Math.hypot(o[0]-r[0],o[1]-r[1])/(es/2)));for(let a=0;a<l;a++){let c=a/l,f=(a+1)/l,u=r[0]+(o[0]-r[0])*c,d=r[1]+(o[1]-r[1])*c,h=r[0]+(o[0]-r[0])*f,b=r[1]+(o[1]-r[1])*f;e.add(i,Math.min(u,h)-1,Math.min(d,b)-1,Math.max(u,h)+1,Math.max(d,b)+1)}}}return e}var Gn=(n,e,t,s,r)=>n.query(e,t,s,r),Zs=n=>pl(n),Mi=n=>[n.x,n.y,n.x+n.w,n.y+n.h];function zf(n,e,t,[s,r,o,i]){let l=0,a=t-1;for(let c of[0,1]){let f=e[c]-n[c],u=c?r:s,d=c?i:o;if(Math.abs(f)<1e-12){if(n[c]<u||n[c]>d)return[1,0];continue}let h=(u-n[c])/f*t-.5,b=(d-n[c])/f*t-.5;h>b&&([h,b]=[b,h]),l=Math.max(l,Math.floor(h)-1),a=Math.min(a,Math.ceil(b)+1)}return[l,a]}var Es=class n{polys=[];rects=[];lines=[];solids=[];slants=[];budget={spots:1/0,over:!1,told:!1};hidden(e){let t=0;for(let s of Gn(us(this.solids,Zs),...Mi(e)))t+=er(this.solids[s],e);return t}hiddenPoly(e){let t=0;for(let s of Gn(us(this.solids,Zs),...pl(e)))t+=Jr(e,this.solids[s]);return t}costPoly(e,t=1/0){let s=pl(e),r=0;for(let o of Gn(us(this.polys,i=>Zs(i.poly)),...s))r+=Jr(e,this.polys[o].poly);for(let o of Gn(us(this.rects,i=>Mi(i.r)),...s))r+=er(e,this.rects[o].r)*2;for(let o of Gn(us(this.slants,Zs),...s))r+=Jr(e,this.slants[o])*2;if(r>=t)return r;for(let o of Gn(_f(this.lines),...s)){if(r>=t)return r;let i=this.lines[Math.floor(o/65536)].pts,l=o%65536,a=i[l],c=i[l+1],f=Math.hypot(c[0]-a[0],c[1]-a[1]),u=Math.max(1,Math.ceil(f/4)),[d,h]=zf(a,c,u,s);for(let b=d;b<=h;b++)yl(e,[a[0]+(c[0]-a[0])*(b+.5)/u,a[1]+(c[1]-a[1])*(b+.5)/u])&&(r+=f/u*4*.6)}return r}cost(e,t,s=.6){let r=Mi(e),o=0;for(let i of Gn(us(this.polys,l=>Zs(l.poly)),...r)){let l=this.polys[i];o+=er(l.poly,e)*(l.owner===t?1.5:1)}for(let i of Gn(us(this.rects,l=>Mi(l.r)),...r)){let l=this.rects[i];(l.owner!==t||!t)&&(o+=gl(l.r,e)*2)}for(let i of Gn(us(this.slants,Zs),...r))o+=er(this.slants[i],e)*2;if(s){let i=-1,l=0;for(let a of Gn(_f(this.lines),...r)){let c=Math.floor(a/65536);c!==i&&(i>=0&&(o+=l*s),i=c,l=0);let f=this.lines[c].pts,u=a%65536,d=f[u],h=f[u+1],b=Math.hypot(h[0]-d[0],h[1]-d[1]),m=Math.max(1,Math.ceil(b/4)),[y,N]=zf(d,h,m,r);for(let p=y;p<=N;p++){let g=d[0]+(h[0]-d[0])*(p+.5)/m,x=d[1]+(h[1]-d[1])*(p+.5)/m;g>=e.x&&g<=e.x+e.w&&x>=e.y&&x<=e.y+e.h&&(l+=b/m*4)}}i>=0&&(o+=l*s)}return o}fork(){let e=new n;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}},Vf=14;function Xr(n,e,t,s){let r=Math.max(n.name?an(n.name,lt.lbl):0,n.sub?an(n.sub,lt.sub):0)+4,o=(n.name?1:0)+(n.sub?1:0),i=t-(n.name?11:9)-1,l=(o-1)*Vf+(n.name?11:9)+4;return{x:s==="start"?e-2:s==="end"?e-r+2:e-r/2,y:i,w:r,h:l}}function Qr(n,e,t,s,r,o){let i=An(t),l=Ce((e.x0+e.x1)/2,(e.y0+e.y1)/2,e.z1)[0],c=((n.name?1:0)+(n.sub?1:0)-1)*Vf+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:l,y:f,anchor:"middle",pen:o?20:0});for(let m of[12,24,40])d.push({x:l,y:f-m,anchor:"middle",pen:20+m});for(let m of[-30,30,-60,60])d.push({x:l+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:l,y:i.y+i.h+14,anchor:"middle",pen:300});let h,b=1/0;for(let m of d){let y=Xr(n,m.x,m.y,m.anchor),N=s.cost(y,r,.15)*2+m.pen;N<b&&(b=N,h={x:m.x,y:m.y,anchor:m.anchor,rect:y})}return h}function bl(n,e,t,s){return{x:(s==="start"?e:s==="end"?e-n:e-n/2)-2,y:t-14,w:n+4,h:28}}function Ai(n,e,t,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:t+f,anchor:"middle",pen:10+(-f-46)*.5+Math.abs(u)*.4});for(let f of[34,60,86])o.push({x:e,y:t+f,anchor:"middle",pen:60+f*.3});let i=s.x-e,l=s.y-t;for(let f of[-1,1])for(let u of[16,32,48])o.push({...s,y:t+l+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:t+l+d,pen:8+u*.6+Math.abs(d)});let a,c=1/0;for(let f of o){let u=bl(n,f.x,f.y,f.anchor),d=r.cost(u,void 0,.05)*3+f.pen;d<c&&(c=d,a={x:f.x,y:f.y,anchor:f.anchor,rect:u})}return a}var Gf=n=>{let e=0;for(let t=0;t<n.length;t++){let s=n[t],r=n[(t+1)%n.length];e+=s[0]*r[1]-r[0]*s[1]}return e/2},hl=n=>Gf(n)<0?[...n].reverse():n;function yl(n,e){let t=hl(n);for(let s=0;s<t.length;s++){let r=t[s],o=t[(s+1)%t.length];if((o[0]-r[0])*(e[1]-r[1])-(o[1]-r[1])*(e[0]-r[0])<0)return!1}return!0}function Jr(n,e){let t=hl(n),s=hl(e);for(let r=0;r<s.length&&t.length;r++){let o=s[r],i=s[(r+1)%s.length],l=c=>(i[0]-o[0])*(c[1]-o[1])-(i[1]-o[1])*(c[0]-o[0]),a=t;t=[];for(let c=0;c<a.length;c++){let f=a[c],u=a[(c+1)%a.length],d=l(f),h=l(u);if(d>=0&&t.push(f),d>=0!=h>=0){let b=d/(d-h);t.push([f[0]+(u[0]-f[0])*b,f[1]+(u[1]-f[1])*b])}}}return t.length>=3?Math.abs(Gf(t)):0}var Oi=24;function tr(n,e){let[t,s,r,o]=e,i=n.x+n.w/2,l=n.y+n.h/2,a=[["left",i-t],["right",t+r-i],["top",l-s],["bottom",s+o-l]];a.sort((f,u)=>f[1]-u[1]);let c=a[0][0];return c==="left"?{edge:c,dx:-(n.x+n.w-t)-Oi,dy:0}:c==="right"?{edge:c,dx:t+r-n.x+Oi,dy:0}:c==="top"?{edge:c,dx:0,dy:-(n.y+n.h-s)-Oi}:{edge:c,dx:0,dy:s+o-n.y+Oi}}function Ni(n,e,t){let s=x=>{let $=0;for(let T=x.parent;T;T=T.parent)$++;return $},r=x=>x.box.x0+x.box.y0+x.box.z0*.01,o=n.items.filter(x=>x.type==="region").sort((x,$)=>s(x)-s($)||r(x)-r($)),i=n.items.filter(x=>x.type==="node").sort((x,$)=>r(x)-r($)||x.box.z0-$.box.z0),l=[],a=Math.min(90,400/Math.max(1,o.length)),c=650;o.forEach((x,$)=>{let T=An(Rt(x.box));l.push({id:x.id,kind:"region",...tr(T,t),delay:Math.round($*a),dur:c,bbox:T})});let f=250+Math.round(a*o.length),u=Math.min(70,700/Math.max(1,i.length)),d=600;i.forEach((x,$)=>{let T=An(Rt(x.box));l.push({id:x.id,kind:"node",...tr(T,t),delay:Math.round(f+$*u),dur:d,bbox:T})});let h=i.length?f+(i.length-1)*u:f,b=Math.round(h+300),m=Math.min(30,300/Math.max(1,e.length)),y=400,N=e.filter(x=>x.points.length>=2).map((x,$)=>({id:x.id,delay:Math.round(b+$*m),dur:y})),p={delay:b+200,dur:400},g=Math.max(...l.map(x=>x.delay+x.dur),...N.map(x=>x.delay+x.dur),p.delay+p.dur);return{pieces:l,routes:N,labels:p,total:g}}var nr=["edge","drop","rise","fly","pop","scatter","build","fade"],sr=["explode","lift-off","sink","scatter","fly-out","collapse","fade","reverse"],Ts=["by-depth","by-layer","by-region","by-flow","as-listed","random"],Wf=["linear","ease","ease-in","ease-out","settle","spring","bounce"],fn=n=>Math.round(n*100)/100||0,Vt=n=>Math.round(n*1e4)/1e4||0;function As(n){let e=r=>{let o=0;for(let i=r.parent;i;i=i.parent)o++;return o},t=r=>{let o=[];for(let i=r;i;i=i.parent){let l=(i.region??i.node)?.motion;l&&o.unshift(l)}return o.length?Object.assign({},...o):void 0},s=new Set(n.layout.items.filter(r=>r.region&&n.layout.catalog&&n.rendered.svg.includes(`class="tunnel" data-id="${r.id}"`)).map(r=>r.id));return{viewBox:n.rendered.viewBox,pieces:n.layout.items.map(r=>{let o=r.box,i=Ce((o.x0+o.x1)/2,(o.y0+o.y1)/2,o.z0),l=t(r);return{id:r.id,kind:r.type,...r.parent?{parent:r.parent.id}:{},depth:e(r),layer:s.has(r.id)?2:r.type==="region"?0:1,key:fn(o.x0+o.y0+o.z0*.01),bbox:An(Rt(o)),foot:[fn(i[0]),fn(i[1])],base:[Ce(o.x0,o.y1,o.z0),Ce(o.x1,o.y1,o.z0),Ce(o.x1,o.y0,o.z0)].map(a=>[fn(a[0]),fn(a[1])]),...l?{motion:l}:{}}}),routes:n.routes.filter(r=>n.rendered.paths[r.id]).map(r=>({id:r.id,path:n.rendered.paths[r.id],...Dm(r.raw)})),notes:Object.fromEntries((n.raw.notes??[]).map((r,o)=>[`${n.id}-note-${o}`,r.on])),intro:n.rendered.assembly}}var qf=n=>typeof n=="string"?n.split(".")[0]:void 0,Dm=n=>{let e=qf(n.from),t=qf(n.to);return{...e?{from:e}:{},...t?{to:t}:{}}},Ri=(n,e,t,s)=>r=>{if(r<=0)return 0;if(r>=1)return 1;let o=(a,c,f)=>3*a*f*(1-f)**2+3*c*f*f*(1-f)+f**3,i=0,l=1;for(let a=0;a<40;a++){let c=(i+l)/2;o(n,t,c)<r?i=c:l=c}return o(e,s,(i+l)/2)},xl={linear:n=>n,ease:Ri(.42,0,.58,1),"ease-in":Ri(.42,0,1,1),"ease-out":Ri(0,0,.58,1),settle:Ri(.16,.84,.3,1),spring:n=>n<=0?0:n>=1?1:1-Math.exp(-6*n)*Math.cos(9.5*n)*(1-n),bounce:n=>{if(n<=0)return 0;if(n>=1)return 1;let e=7.5625,t=2.75;return n<1/t?e*n*n:n<2/t?e*(n-1.5/t)**2+.75:n<2.5/t?e*(n-2.25/t)**2+.9375:e*(n-2.625/t)**2+.984375}};function vl(n){let e=n>>>0;return()=>{e=e+1831565813>>>0;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}var Uf=n=>{let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0},On=n=>Math.max(0,Math.min(1,n)),Pi=24;function wl(n,e,t){let[s,r,o,i]=e;return t==="left"?[-(n.x+n.w-s)-Pi,0]:t==="right"?[s+o-n.x+Pi,0]:t==="top"?[0,-(n.y+n.h-r)-Pi]:[0,r+i-n.y+Pi]}function $l(n,e,t={}){let s=n.pieces,r=new Map(s.map(m=>[m.id,m])),o=(m,y)=>m.depth-y.depth||m.key-y.key;if(e==="as-listed")return[...s];if(e==="random"){let m=vl(t.seed??1);return s.map(y=>[m(),y]).sort((y,N)=>y[0]-N[0]).map(y=>y[1])}if(e==="by-layer")return[...s].sort((m,y)=>m.layer-y.layer||o(m,y));if(e==="by-depth")return[...s].sort((m,y)=>m.key-y.key||m.depth-y.depth);let i=new Map;for(let m of[...s].sort(o)){let y=i.get(m.parent)??[];y.push(m),i.set(m.parent,y)}let l=[],a=new Set,c=m=>{if(a.has(m.id))return;let y=m.parent?r.get(m.parent):void 0;y&&c(y),a.add(m.id),l.push(m)};if(e==="by-region"){let m=y=>{for(let N of i.get(y)??[])c(N),m(N.id)};return m(),l}let f=new Map,u=new Set;for(let m of n.routes)m.from&&m.to&&(f.set(m.from,[...f.get(m.from)??[],m.to]),u.add(m.to));let d=t.source??n.routes.find(m=>m.from&&!u.has(m.from))?.from??n.routes[0]?.from,h=d?[d]:[],b=new Set(h);for(;h.length;){let m=h.shift(),y=r.get(m);y&&c(y);for(let N of f.get(m)??[])b.has(N)||(b.add(N),h.push(N))}for(let m of[...s].sort(o))c(m);return l}var _m={edge:"settle",drop:"settle",rise:"ease-out",fly:"settle",pop:"spring",scatter:"settle",build:"ease-out",fade:"linear",explode:"ease-in","lift-off":"ease-in",sink:"ease-in","fly-out":"ease-in",collapse:"ease-in"},zm={"lift-off":"lift",sink:"rise",scatter:"scatter","fly-out":"edge",fade:"fade",explode:"explode",collapse:"collapse"};function rr(n,e,t={}){let s=t.seed??1,r=e==="disassemble",o=r&&t.style==="reverse",i=U=>{if(!r)return U.motion?.style??t.style??"edge";let B=U.motion?.out??t.style??"fly-out";return B==="reverse"?U.motion?.style??t.of??"edge":zm[B]},l=U=>r?U.motion?.out??t.style??"fly-out":i(U),a=!r&&!t.order&&t.stagger===void 0&&t.piece===void 0&&t.overlap===void 0&&(t.style??"edge")==="edge",c=t.order??(t.style==="build"?"by-layer":"by-depth"),f=[],u,d,h=(U,B,H)=>{let Y=i(U),ee=U.motion?.easing??t.easing??_m[r&&l(U)!=="reverse"?l(U):Y]??"ease";return{p:U,delay:B+(U.motion?.delay??0),dur:Math.max(1,U.motion?.duration??H),style:Y,curve:xl[ee],from:U.motion?.from??t.from??"left"}};if(a){let U=new Map(n.pieces.map(B=>[B.id,B]));for(let B of n.intro.pieces){let H=U.get(B.id);H&&f.push(h(H,B.delay,B.dur))}u=n.intro.routes.map(B=>({...B})),d={...n.intro.labels}}else{let U=$l(n,c,{seed:s,source:t.source}),B=t.piece??600,H=t.stagger??Math.min(70,900/Math.max(1,U.length)),Y=On(t.overlap??.5),ee=o||r?[...U].reverse():U,F=Math.min(30,300/Math.max(1,n.routes.length)),K=400,q=400;if(r){d={delay:0,dur:q};let Z=q*(1-Y);u=[...n.routes].reverse().map((W,oe)=>({id:W.id,delay:Z+oe*F,dur:K}));let ce=Math.max(Z,...u.map(W=>W.delay+W.dur)),fe=Math.max(0,ce-Y*K);ee.forEach((W,oe)=>f.push(h(W,fe+oe*H,B)))}else{ee.forEach((W,oe)=>f.push(h(W,oe*H,B)));let Z=Math.max(0,...f.map(W=>W.delay+W.dur)),ce=Math.max(0,Z-Y*B);u=n.routes.map((W,oe)=>({id:W.id,delay:ce+oe*F,dur:K}));let fe=Math.max(ce,...u.map(W=>W.delay+W.dur));d={delay:Math.max(0,fe-Y*q),dur:q}}}let b=t.pulses&&n.routes.length?700:0;if(b&&r)for(let U of[...f,...u,d])U.delay+=b;let m=Math.max(1,...f.map(U=>U.delay+U.dur),...u.map(U=>U.delay+U.dur),d.delay+d.dur),y=r?0:m;b&&!r&&(m+=b);let N=t.duration!==void 0?Math.max(1,t.duration)/m:1;for(let U of[...f,...u,d])U.delay=fn(U.delay*N),U.dur=Math.max(.01,fn(U.dur*N));let p=t.duration!==void 0?Math.max(1,t.duration):Math.max(1,fn(m)),g=new Map(f.map(U=>[U.p.id,U])),x=new Map(u.map(U=>[U.id,U])),[$,T,v,A]=n.viewBox,L=[$+v/2,T+A/2],M=U=>[U.x+U.w/2,U.y+U.h/2],P=(U,B)=>{let H=t.point;if(Array.isArray(H))return H;if(H==="region"||B==="collapse"&&H===void 0&&U.parent){let Y=n.pieces.find(ee=>ee.id===U.parent);return Y?Y.foot:L}if(typeof H=="string"){let Y=n.pieces.find(ee=>ee.id===H);if(Y)return Y.foot}return L};function k(U,B,H){let{p:Y}=U,ee=Y.bbox,F=1-B,K=(q,Z)=>({dx:fn(q*F),dy:fn(Z*F)});switch(U.style){case"drop":return K(...wl(ee,n.viewBox,"top"));case"lift":return K(...wl(ee,n.viewBox,"top"));case"fly":return K(...wl(ee,n.viewBox,U.from));case"rise":{let q=ee.h*F,[Z,ce,fe]=Y.base,W=ee.y-ee.h-4;return{...K(0,ee.h),clip:[[Z[0],Z[1]-q],[ce[0],ce[1]-q],[fe[0],fe[1]-q],[fe[0]+2,W-q],[Z[0]-2,W-q]].map(oe=>[fn(oe[0]),fn(oe[1])])}}case"pop":return{scale:Vt(Math.max(0,B)),about:Y.foot,opacity:Vt(On(H*4))};case"scatter":{let q=vl((s^Uf(Y.id))>>>0),Z=q()*Math.PI*2,ce=.35+q()*.65;return{...K(Math.cos(Z)*v*ce*.6,Math.sin(Z)*A*ce*.6),opacity:Vt(On(B*1.6))}}case"build":return{...K(0,-18),opacity:Vt(On(B))};case"fade":return{opacity:Vt(On(B))};case"explode":{let q=P(Y,"explode"),Z=M(ee),ce=Z[0]-q[0],fe=Z[1]-q[1],W=Math.hypot(ce,fe),oe=vl((s^Uf(Y.id))>>>0),Me=oe()*Math.PI*2,Le=W>1?[ce/W,fe/W]:[Math.cos(Me),Math.sin(Me)],C=Math.hypot(v,A)+Math.max(ee.w,ee.h);return K(Le[0]*C,Le[1]*C)}case"collapse":{let q=P(Y,"collapse");return{...K(q[0]-Y.foot[0],q[1]-Y.foot[1]),scale:Vt(Math.max(0,B)),about:Y.foot,opacity:Vt(On(B*3))}}default:{let q=tr(ee,n.viewBox);return K(q.dx,q.dy)}}}let O=(U,B,H)=>{let Y=On((U-B)/H);return r?1-Y:Y},w={opacity:0},R=t.connectors??"draw",I=t.labels??"fade",G=[...n.pieces.map(U=>U.id),...n.routes.map(U=>U.id),...Object.keys(n.notes)];function X(U){let B=Math.max(0,Math.min(p,Number.isFinite(U)?U:0));if(r?B<=0:B>=p)return{};let H=r?B>=p:B<=0,Y={},ee={},F={};for(let fe of f){let W=H?0:O(B,fe.delay,fe.dur);W<=0?Y[fe.p.id]=w:W<1&&(Y[fe.p.id]=k(fe,r?1-fe.curve(1-W):fe.curve(W),W))}for(let fe of n.routes){let W=x.get(fe.id),oe=H||!W?0:O(B,W.delay,W.dur);oe<=0?ee[fe.id]={opacity:0,drawn:0}:oe<1&&(ee[fe.id]=R==="fade"?{opacity:Vt(oe)}:R==="grow"?{drawn:Vt(oe),by:"grow"}:{drawn:Vt(xl["ease-out"](oe))})}let K=H?0:O(B,d.delay,d.dur),q=K<=0?w:K>=1?void 0:I==="type"?{typed:Vt(K)}:{opacity:Vt(K)};for(let fe of G){let W=q;if(I==="with-piece"){let oe=Object.hasOwn(n.notes,fe)?n.notes[fe]:fe,Me=oe===void 0?void 0:g.get(oe)??x.get(oe);if(Me){let Le=H?0:O(B,Me.delay,Me.dur);W=Le<=0?w:Le>=1?void 0:{opacity:Vt(Le)}}}W&&(F[fe]=W)}let Z=[];if(b&&!H){let fe=(B-y*N)/(b*N);if(fe>0&&fe<1)for(let W of n.routes)Z.push({route:W.id,at:Vt(xl.ease(fe))})}let ce=fe=>Object.keys(fe).length>0;return{...ce(Y)?{items:Y}:{},...ce(F)?{labels:F}:{},...ce(ee)?{routes:ee}:{},...K<1?{marks:{opacity:Vt(Math.max(0,K))}}:{},...Z.length?{tokens:Z}:{}}}return{kind:e,duration:p,pieces:f.map(U=>({id:U.p.id,delay:U.delay,dur:U.dur,style:l(U.p)})),routes:u,labels:d,at:X}}var ct=n=>{let e=n.toFixed(2);return e==="-0.00"?"0":String(Number(e))},Km=(n,e)=>`translate(${ct(n[0])} ${ct(n[1])}) scale(${Number(e.toFixed(4))}) translate(${ct(-n[0])} ${ct(-n[1])})`,Ml=n=>[...n.matchAll(/(-?[\d.]+),(-?[\d.]+)/g)].map(e=>[Number(e[1]),Number(e[2])]),El=n=>n.slice(1).reduce((e,t,s)=>e+Math.hypot(t[0]-n[s][0],t[1]-n[s][1]),0);function Ci(n,e){let t=Ml(n),s=El(t)*e;for(let r=0;r+1<t.length;r++){let o=Math.hypot(t[r+1][0]-t[r][0],t[r+1][1]-t[r][1]);if(s<=o&&o>0){let i=s/o;return[t[r][0]+(t[r+1][0]-t[r][0])*i,t[r][1]+(t[r+1][1]-t[r][1])*i]}s-=o}return t[t.length-1]??[0,0]}function Vm(n,e){let t=Ml(n),s=Ci(n,e),r=[],o=El(t)*e;for(let i=0;i<t.length;i++){r.push(t[i]);let l=i+1<t.length?Math.hypot(t[i+1][0]-t[i][0],t[i+1][1]-t[i][1]):1/0;if(o<=l)break;o-=l}return"M"+[...r,s].map(i=>`${ct(i[0])},${ct(i[1])}`).join(" L")}var qn=n=>String(Number(n.toFixed(4)));function Gm(n,e){let t=n.match(/&[^;\s]+;|[\s\S]/gu)??[];return t.slice(0,Math.round(t.length*e)).join("")}function qm(n){let e=[];return(n.dx||n.dy)&&e.push(`translate(${ct(n.dx??0)} ${ct(n.dy??0)})`),n.scale!==void 0&&n.scale!==1&&e.push(Km(n.about??[0,0],n.scale)),{attrs:{...n.opacity===void 0||n.opacity===1?{}:{opacity:qn(n.opacity)},...e.length?{transform:e.join(" ")}:{}},clip:n.clip}}function Um(n,e){let t={attrs:n.opacity===void 0||n.opacity===1?{}:{opacity:qn(n.opacity)}};if(n.drawn!==void 0&&n.drawn<1&&e!==void 0){let s=On(n.drawn),r=El(Ml(e));t.path=n.by==="grow"?{d:Vm(e,s),head:!1}:{style:`stroke-dasharray:${ct(r)} ${ct(r)};stroke-dashoffset:${ct(r*(1-s))}`,head:!1}}else n.ants&&(t.path={style:`stroke-dasharray:${ct(n.ants.dash[0])} ${ct(n.ants.dash[1])};stroke-dashoffset:${ct(-n.ants.offset)}`,head:!0});return t}function Jf(n,e,t,s,r){if(s==="label"||s==="note"){let i=n.labels&&Object.hasOwn(n.labels,t)?n.labels[t]:void 0;return i&&{attrs:{...i.opacity===void 0||i.opacity===1?{}:{opacity:qn(i.opacity)},...i.dx||i.dy?{transform:`translate(${ct(i.dx??0)} ${ct(i.dy??0)})`}:{}},...i.typed===void 0||i.typed>=1?{}:{typed:i.typed}}}if(e==="route"){let i=n.routes&&Object.hasOwn(n.routes,t)?n.routes[t]:void 0;return i&&Um(i,r(t))}let o=n.items&&Object.hasOwn(n.items,t)?n.items[t]:void 0;return o&&qm(o)}function Xf(n,e,t){let s=[];for(let r of n.outlines??[])s.push(["polygon",{points:r.points.map(o=>o.map(ct).join(",")).join(" "),class:"ring",fill:"none","stroke-width":"2.5","stroke-linejoin":"round",...r.opacity===void 0?{}:{opacity:qn(r.opacity)},...t?{stroke:r.color??t.control}:{style:`stroke:${r.color??"var(--ring,var(--control,currentColor))"}`}}]);for(let r of n.pulses??[])s.push(["ellipse",{cx:ct(r.x),cy:ct(r.y),rx:ct(r.rx),ry:ct(r.ry),class:"ring",fill:"none","stroke-width":"2.5",...r.opacity===void 0?{}:{opacity:qn(r.opacity)},...t?{stroke:r.color??t.control}:{style:`stroke:${r.color??"currentColor"}`}}]);for(let r of n.tokens??[]){let o=e(r.route);if(o===void 0)continue;let[i,l]=Ci(o,On(r.at));s.push(["circle",{cx:ct(i),cy:ct(l),r:"7",class:"tok",...t?{fill:r.color??(r.kind!==void 0?t.kinds?.[r.kind]:void 0)??t.control,stroke:t.surface,"stroke-width":"2.5"}:{style:`fill:${r.color??(r.kind!==void 0?`var(--${r.kind},var(--control,currentColor))`:"var(--control,currentColor)")}`}}])}return s}var Qf=n=>Object.keys(n).every(e=>e==="morph"||n[e]===void 0),Zf=new Set(["marks","badges"]),Hf=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,""");function Sl(n){let e=new Map,t=[];for(let s of n.matchAll(/<(\/?)([a-zA-Z]+)((?:\s+[\w:-]+="[^"]*")*)\s*(\/?)>/g)){if(s[1]){let i=t.pop();i?.key!==void 0&&e.set(i.key,[i.from,s.index]);continue}if(s[4])continue;let r=/\sdata-item="([^"]*)"/.exec(s[3])?.[1],o=/\sdata-part="([^"]*)"/.exec(s[3])?.[1];t.push({...t.length===2&&r!==void 0&&o!==void 0?{key:`${tu(r)}
|
|
143
|
+
${o}`}:{},from:s.index+s[0].length})}return e}var Yf=new WeakMap;function Hm(n,e){let t=Yf.get(n)??new Map;Yf.set(n,t);let s=t.get(e);if(!s){t.set(e,s=new Map);let r=n.variants?.[e],o=Sl(n.svg);if(r!==void 0)for(let[i,[l,a]]of Sl(r)){let c=o.get(i);c&&n.looks?.[i.split(`
|
|
144
|
+
`)[0]]?.includes(e)&&n.svg.slice(...c)!==r.slice(l,a)&&s.set(i,r.slice(l,a))}}return s}function eu(n,e,t,s){let r=[];for(let o of n.looks?.[e]??[]){let i=On(s[o]??0),l=i>0?Hm(n,o).get(`${e}
|
|
145
|
+
${t}`):void 0;l!==void 0&&r.push([l,i])}return r.length?{own:On(1-r.reduce((o,[,i])=>o+i,0)),looks:r}:void 0}var Ym=(n,e)=>(e.own>0?`<g opacity="${qn(e.own)}">${n}</g>`:"")+e.looks.map(([t,s])=>`<g opacity="${qn(s)}">${t}</g>`).join("");function Wm(n,e){let t="",s=0;for(let[r,[o,i]]of[...Sl(n.svg)].sort((l,a)=>l[1][0]-a[1][0])){let[l,a]=r.split(`
|
|
146
|
+
`),c=Object.hasOwn(e,l)?eu(n,l,a,e[l]):void 0;c&&(t+=n.svg.slice(s,o)+Ym(n.svg.slice(o,i),c),s=i)}return t+n.svg.slice(s)}function Tl(n,e){if(Qf(e))return n.rendered.svg;let t=e.variants?Wm(n.rendered,e.variants):n.rendered.svg,s=u=>Object.hasOwn(n.rendered.paths,u)?n.rendered.paths[u]:void 0,r=0,o="",i="",l=0,a,c=t.replace(/<(\/?)([a-zA-Z]+)((?:\s+[\w:-]+="[^"]*")*)\s*(\/?)>|([^<]+)/g,(u,d,h,b,m,y)=>{if(y!==void 0)return a?.w.typed===void 0?u:Gm(y,a.w.typed);if(d)return r--,a&&r===a.at&&(a=void 0),r===1&&(o=""),u;let N=r;m||r++;let p={};for(let[,g,x]of b.matchAll(/([\w:-]+)="([^"]*)"/g))p[g]=x;if(N===0){if(!e.camera)return u;p.viewBox=e.camera.map(ct).join(" ")}else if(N===1)if(o=h==="g"&&p.class?.startsWith("g-")?p.class.slice(2):"",Zf.has(o)&&e.marks&&e.marks.opacity!==1)p.opacity=qn(e.marks.opacity);else return u;else if(N===2&&p["data-part"]!==void 0){let g=p["data-route"]===void 0?"item":"route",x=tu(p["data-route"]??p["data-item"]??""),$=Jf(e,g,x,p["data-part"],s);if(!$)return u;for(let[T,v]of Object.entries($.attrs))p[T]=Hf(v);if($.clip){let T=`${n.id}-mc${l++}`;i+=`<clipPath id="${T}"><polygon points="${$.clip.map(v=>v.join(",")).join(" ")}"/></clipPath>`,p["clip-path"]=`url(#${T})`}if(!m&&($.path||$.typed!==void 0)&&(a={at:N,w:$}),!Object.keys($.attrs).length&&!$.clip)return u}else if(a?.w.path&&h==="path"&&p.class?.split(" ")[0]==="flow"){let g=a.w.path;g.d!==void 0&&(p.d=g.d),g.style!==void 0&&(p.style=g.style),g.head||delete p["marker-end"]}else return u;return`<${h}${Object.entries(p).map(([g,x])=>` ${g}="${x}"`).join("")}${m?"/":""}>`});i&&(c=c.replace(/<defs>|<defs\/>/,u=>u==="<defs/>"?`<defs>${i}</defs>`:u+i));let f=Xf(e,s,n.rendered.inks);return f.length&&(c=c.replace('<g class="g-anim">',u=>u+f.map(([d,h])=>`<${d}${Object.entries(h).map(([b,m])=>` ${b}="${Hf(m)}"`).join("")}/>`).join(""))),c}var tu=n=>n.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/&/g,"&"),kl=new WeakMap;function Ii(n,e,t,s={}){let r=kl.get(n);if(r){for(let[p,g]of r.mixed)p.replaceChildren(...g);for(let[p,g]of r.attrs)for(let[x,$]of g)$===null?p.removeAttribute(x):p.setAttribute(x,$);for(let[p,g,x]of r.gone.reverse())g.insertBefore(p,x);for(let[p,g]of r.texts)p.data=g;for(let p of r.made)p.remove();kl.delete(n)}if(Qf(e))return;let o={attrs:new Map,texts:new Map,gone:[],made:[],mixed:[]};kl.set(n,o);let i=(p,g,x)=>{let $=o.attrs.get(p)??new Map;$.has(g)||$.set(g,g==="style"?p.getAttribute(g)||null:p.getAttribute(g)),o.attrs.set(p,$),x===null?p.removeAttribute(g):p.setAttribute(g,x)},l=n.ownerDocument,a=(p,g,x)=>{let $=l.createElementNS("http://www.w3.org/2000/svg",p);for(let[T,v]of Object.entries(g))$.setAttribute(T,v);return x.append($),o.made.push($),$},c=Array.from(n.children),f=p=>c.find(g=>g.getAttribute("class")===`g-${p}`),u=new Map;for(let p of Array.from(f("flows")?.children??[])){let g=p.getAttribute("data-route"),x=p.querySelector("path.flow")?.getAttribute("d");g!==null&&x&&u.set(g,x)}let d=p=>u.get(p);e.camera&&i(n,"viewBox",e.camera.map(ct).join(" "));for(let p of Zf){let g=f(p);g&&e.marks&&e.marks.opacity!==1&&i(g,"opacity",qn(e.marks.opacity))}let h=0,b=c.find(p=>p.localName==="defs"),m=b?.firstChild??null,y=n.getAttribute("data-scene")??"scene";for(let p of c)for(let g of Array.from(p.children)){let x=g.getAttribute("data-part");if(x===null)continue;let $=g.getAttribute("data-route"),T=$===null?g.getAttribute("data-item")??"":"",v=t&&e.variants&&Object.hasOwn(e.variants,T)?eu(t,T,x,e.variants[T]):void 0;if(v){let M=Array.from(g.childNodes),P=(O,w)=>{let R=l.createElementNS("http://www.w3.org/2000/svg","g");return R.setAttribute("opacity",qn(O)),R.append(...w),R},k=O=>Array.from(l.importNode(new DOMParser().parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">${O}</svg>`,"image/svg+xml").documentElement,!0).childNodes);o.mixed.push([g,M]),g.replaceChildren(...v.own>0?[P(v.own,M)]:[],...v.looks.map(([O,w])=>P(w,k(O))))}let A=Jf(e,$===null?"item":"route",$??g.getAttribute("data-item")??"",x,d);if(!A)continue;for(let[M,P]of Object.entries(A.attrs))i(g,M,P);if(A.clip&&b){let M=a("clipPath",{id:`${y}-mc${h++}`},b);b.insertBefore(M,m);let P=l.createElementNS("http://www.w3.org/2000/svg","polygon");P.setAttribute("points",A.clip.map(k=>k.join(",")).join(" ")),M.append(P),i(g,"clip-path",`url(#${M.id})`)}if(A.typed!==void 0){let M=[];for(let P=l.createTreeWalker(g,4);P.nextNode();)M.push(P.currentNode);for(let P of M)o.texts.set(P,P.data),P.data=Array.from(P.data).slice(0,Math.round(Array.from(P.data).length*A.typed)).join(""),P.data||(o.gone.push([P,P.parentNode,P.nextSibling]),P.remove())}let L=A.path&&g.querySelector("path.flow");L&&A.path&&(A.path.d!==void 0&&i(L,"d",A.path.d),A.path.style!==void 0&&(s.styles==="cssom"?(i(L,"style",null),L.style.cssText=A.path.style):i(L,"style",A.path.style)),A.path.head||i(L,"marker-end",null))}let N=f("anim");if(N)for(let[p,g]of Xf(e,d,t?.inks))a(p,g,N)}var nu=(n,e)=>({...e,frame:t=>Tl(n,e.at(t))}),Al=(n,e={})=>nu(n,rr(As(n),"assemble",e)),su=(n,e={})=>nu(n,rr(As(n),"disassemble",e)),ru=(n,e)=>Al(n).frame(e);var ji=(n,e)=>e.role??ht(n,e.kind)?.role,Li=(n,e)=>ht(n,e.region.kind)?.shape,en=(n,e,t,s="item")=>t?Ee("g",{[`data-${s}`]:n,"data-part":e},t):"";function or({scene:n,layout:e,routes:t,steps:s,theme:r,id:o,gridStep:i=1}){let l=new js,a={base:"",floor:"",flows:"",blocks:[],air:"",labels:"",marks:"",badges:""},c=new Es;c.budget.spots=Bi;let f=w=>s.vis[w]?{"data-vis":"1"}:{},u=e.items.filter(w=>w.type==="region"),d=w=>{let R=0;for(let I=w.parent;I;I=I.parent)R++;return R},h=e.catalog,b=u.filter(w=>Li(h,w)!=="walled"&&Li(h,w)!=="tunnel"),m=Sr(b.map(w=>({box:w.box,r:w}))).map(w=>w.r).sort((w,R)=>d(w)-d(R));for(let w of m)a.base+=Xm(l,h,w,f(w.id),i);for(let w of u.filter(R=>Li(h,R)==="walled")){for(let I of Fi(w))c.solids.push(Rt(I));for(let[I,G]of Fi(w).entries())a.blocks.push({box:G,svg:en(w.id,`wall-${I+1}`,Ee("g",{class:`blk k-${ji(h,w.region)} wall${w.region.ghost?" ghost":""}`,"data-id":w.id,"data-dim":"1",...f(w.id)},l.blockFaces(G)))});let R=w.region.gate;if(R&&!R.node){let I=Yr(w,R.height??(w.region.height??.8)+.3,.3,.3);c.solids.push(Rt(I)),a.blocks.push({box:I,svg:en(w.id,"gate",Ee("g",{class:"blk k-gate","data-id":w.id,...f(w.id)},l.blockFaces(I)))})}w.region.label&&(w.region["label-style"]??"face")!=="none"&&(a.labels+=en(w.id,"name",l.faceText(w.box.x0+.3,w.box.y1,w.box.z0+.13,w.region.label,"slabname sm fz",lt.sm,"left","start",{"data-id":w.id,...f(w.id)})))}for(let w of u.filter(R=>Li(h,R)==="tunnel"))a.air+=en(w.id,"block",Zm(l,w,f(w.id)));let y=e.items.filter(w=>w.type==="node");for(let w of y){let R=w.node,I=cn(h,R.asset),G=R.ghost||(R.deco??[]).includes("ghost"),X=["blk",`k-${R.role??I.role}`,I.cls,G?"ghost":""].filter(Boolean).join(" ");a.blocks.push({box:w.box,svg:en(w.id,"block",Ee("g",{class:X,"data-id":w.id,"data-dim":"1",...f(w.id)},I.draw(l,w.box,R)))}),c.polys.push({poly:Rt(w.box),owner:w.id}),c.solids.push(Rt(w.box))}let N=Sr(a.blocks).map(w=>w.svg).join(""),p=new Set,g={};for(let w of t){if(w.points.length<2)continue;let R=w.points.map(X=>Ce(X[0],X[1],X[2]));R.forEach(X=>l.bounds.add(X));let I="M"+R.map(xs).join(" L");g[w.id]=I;let G=w.raw.arrow!==!1;G&&p.add(w.kind),a.flows+=en(w.id,"line",Ee("g",{"data-hl":w.id,"data-id":w.id,...f(w.id)},Ee("path",{d:I,class:`flow f-${w.kind}`,"marker-end":G?`url(#ah-${o}-${w.kind})`:void 0})),"route"),c.lines.push({pts:R,owner:w.id})}for(let w of p)l.def(`ah-${o}-${w}`,Ee("marker",{id:`ah-${o}-${w}`,viewBox:"0 0 10 10",refX:"7",refY:"5",markerWidth:"4.2",markerHeight:"4.2",orient:"auto-start-reverse"},Ee("path",{d:"M0,0 L10,5 L0,10 z",style:`fill:${Tn(r,r.kinds[w]?.color??"control")}`})));for(let w of l.planePolys)c.slants.push(w);let x=y.filter(w=>w.node.label||w.node.sub).sort((w,R)=>(R.box.x1-R.box.x0)*(R.box.y1-R.box.y0)-(w.box.x1-w.box.x0)*(w.box.y1-w.box.y0));for(let w of x)a.labels+=en(w.id,"label",Qm(l,h,w,c,f(w.id)));let $=[];for(let w of t)if(w.raw.label&&w.points.length>=2){let R=ep(l,w,c,f(w.id),e);a.floor+=en(w.id,"label",R.svg,"route"),R.warning&&$.push({path:`${w.path}/label`,message:R.warning}),c.budget.over&&!c.budget.told&&(c.budget.told=!0,$.push({path:w.path,message:`from route "${w.id}" on, route labels were placed without weighing what other labels and lines cover: the scene is too large to search every spot (${Bi.toLocaleString("en")} spots); split it into scenes, or give the labels "along", "side" or "at"`}))}(n.notes??[]).forEach((w,R)=>{let I=en(`${o}-note-${R}`,"note",tp(l,w,e,t,`${o}-note-${R}`));w.floor?a.floor+=I:a.labels+=I});let T=[],v=new Map;for(let w of s.says){let R=v.get(w.step)??c.fork();v.set(w.step,R);let I=an(w.text,lt.say)+18,G=Ai(I,w.ax,w.ay,{x:w.x,y:w.y,anchor:w.anchor},R);R.rects.push({r:G.rect,owner:""}),T.push({step:w.step,...G.rect,text:w.text});let X=G.rect.x+2;l.bounds.addRect(G.rect.x,G.rect.y,G.rect.w,G.rect.h);let U=Tn(r,r.kinds[w.kind]?.color??"control");a.marks+=Ee("g",{class:"say","data-step":w.step},Ee("rect",{x:X,y:G.y-12,width:I,height:24,rx:12,style:`stroke:${U}`})+Ee("text",{x:X+I/2,y:G.y+4,"text-anchor":"middle",style:`fill:${U}`},mt(w.text)))}for(let w of s.marks){let[R,I]=Ce(...w.p);l.bounds.addRect(R-12,I-12,24,24),a.marks+=Ee("g",{class:"xm","data-step":w.step,"data-hl":w.on},Ee("circle",{cx:R,cy:I,r:10})+Ee("path",{d:`M${at(R-4.5)},${at(I-4.5)} L${at(R+4.5)},${at(I+4.5)} M${at(R+4.5)},${at(I-4.5)} L${at(R-4.5)},${at(I+4.5)}`}))}for(let w of s.badges){let[R,I]=Ce(...w.p);l.bounds.addRect(R-13,I-13,26,26),a.badges+=Ee("g",{class:`badge c-${w.kind}`,"data-go":w.step,"data-badge":w.step,tabindex:"0",role:"button","aria-label":`Step ${w.num}`},Ee("circle",{cx:R,cy:I,r:11.5})+Ee("text",{x:R,y:I+.5},String(w.num)))}let A=l.bounds,L=22,M=A.empty?[0,0,100,100]:[Math.floor(A.x0-L),Math.floor(A.y0-L),Math.ceil(A.x1-A.x0+L*2),Math.ceil(A.y1-A.y0+L*2)],P=[...l.defs.values()].join(""),k=(w,R)=>Ee("g",{class:"g-"+w},R);return{svg:Ee("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:M.join(" "),role:"img","aria-label":n.aria??n.title,"data-scene":o},Ee("defs",{},P)+k("base",a.base)+k("floor",a.floor)+k("flows",a.flows)+k("blocks",N)+k("air",a.air)+k("labels",a.labels)+k("marks",a.marks)+k("badges",a.badges)+k("anim","")),viewBox:M,texts:l.texts,paths:g,warnings:$,callouts:T,assembly:Ni(e,t,M)}}function Jm(n,e){let t=n.z1+.002,s=1e-6,r=[],o=(i,l)=>{let a=Ce(i[0],i[1],t),c=Ce(l[0],l[1],t);r.push(`M${xs(a)}L${xs(c)}`)};for(let i=Math.ceil((n.x0+s)/e)*e;i<n.x1-s;i+=e)o([i,n.y0],[i,n.y1]);for(let i=Math.ceil((n.y0+s)/e)*e;i<n.y1-s;i+=e)o([n.x0,i],[n.x1,i]);return r.length?Ee("path",{class:"grid",d:r.join("")}):""}function Xm(n,e,t,s,r=1){let o=t.region,i=t.box,l=ji(e,o),a=ht(e,o.kind),c=a?.shape,f={"data-id":t.id,"data-dim":"1",...s},u="";c==="cloud"?u=Ee("g",{class:`blk k-${l} cloud`,...f},hi(n,i)):c==="zone"?u=Ee("g",{class:`zone k-${l}`,...f},n.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=Ee("g",{class:`blk k-${l}${o.ghost?" ghost":""}`,...f},n.blockFaces(i)+Jm(i,r)),u=en(t.id,"block",u);let d=o["label-style"]??a?.labelStyle;if(o.label&&d!=="none")if(d==="face"){let h=i.z1-i.z0,b=p=>p.size*.73/st,m=c==="slab"&&.28+b(lt.slabname)+.08>h,y=c==="slab"&&!m,N=y?i.z0+.28:m?i.z0+Math.max(.02,(h-b(lt.sm))/2):i.z0+Math.min(.1,h*.25);u+=en(t.id,"name",Ee("g",f,n.faceText(i.x0+(y?.6:.3),i.y1,N,o.label,y?"slabname":"slabname sm",y?lt.slabname:lt.sm,"left","start")))}else if(d==="face-right")u+=en(t.id,"name",Ee("g",f,n.faceText(i.x1,i.y0+.6,i.z0+Math.max(.14,(i.z1-i.z0)*.2),o.label,"slabname",lt.slabname,"right","end")));else{let h=c==="cloud"?"middle":"start",b=c==="cloud"?(i.x0+i.x1)/2:i.x0+.35,m=c==="cloud"?(i.y0+i.y1)/2:i.y1-.35;u+=en(t.id,"name",Ee("g",f,n.floorText(b,m,i.z1+.01,o.label,"slabname sm","x",h)))}return u}function Fi(n){let{x0:e,y0:t,x1:s,y1:r,z0:o,z1:i}=n.box,l=Vn,a=n.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,h,b)=>{if(!a||a.side!==b)return[[d,h]];let m=a.at??.5,y=a.width??2,N=b==="e"||b==="w"?t+(r-t)*m:e+(s-e)*m;return[[d,N-y/2],[N+y/2,h]]};for(let[d,h]of u(e,s,"n"))f({x0:d,y0:t,x1:h,y1:t+l});for(let[d,h]of u(t+l,r-l,"w"))f({x0:e,y0:d,x1:e+l,y1:h});for(let[d,h]of u(t+l,r-l,"e"))f({x0:s-l,y0:d,x1:s,y1:h});for(let[d,h]of u(e,s,"s"))f({x0:d,y0:r-l,x1:h,y1:r});return c}function Qm(n,e,t,s,r){let o=t.node,i=cn(e,o.asset),l=t.box,a={name:o.label,sub:o.sub},c=o["label-at"],f;if(c){let d=An(Rt(l)),h=c.side??"above",b=d.y+Math.min(d.h,60)*.45;h==="right"?f={x:d.x+d.w+8,y:b,anchor:"start"}:h==="left"?f={x:d.x-8,y:b,anchor:"end"}:h==="below"?f={x:d.x+d.w/2,y:d.y+d.h+14,anchor:"middle"}:f=Qr(a,l,Rt(l),new Es,t.id),f={...f,x:f.x+(c.dx??0),y:f.y+(c.dy??0)}}else{let d=i.label?i.label(l,o,!!o.sub):void 0;f=Qr(a,l,Rt(l),s,t.id,d)}s.rects.push({r:Xr(a,f.x,f.y,f.anchor),owner:""});let u="";return o.label&&(u+=n.text(f.x,f.y,o.label,"lbl",lt.lbl,f.anchor,{},t.id)),o.sub&&(u+=n.text(f.x,o.label?f.y+14:f.y,o.sub,"sub mono",lt.sub,f.anchor,{},t.id)),Ee("g",{"data-id":t.id,"data-dim":"1",...r},u)}function Zm(n,e,t){let{x0:s,y0:r,x1:o,y1:i,z0:l,z1:a}=e.box,c=n.blockFaces(e.box),f=o-s>=i-r,u=Math.max(1,Math.round((f?o-s:i-r)/1.6));for(let h=1;h<u;h++){let b=f?s+(o-s)*h/u:r+(i-r)*h/u;c+=n.poly(f?[[b,r,a],[b,i,a],[b,i,l]]:[[s,b,a],[o,b,a],[o,b,l]],"rib")}let d=e.region.label;return d&&e.region["label-style"]!=="none"&&(c+=f?n.faceText(s+.35,i,l+.14,d,"tunname",lt.tunname,"left","start"):n.faceText(o,i-.35,l+.18,d,"tunname",lt.tunname,"right","start")),Ee("g",{class:"tunnel","data-id":e.id,"data-dim":"1",...t},c)}var Bi=2e4;function ep(n,e,t,s,r){let o=typeof e.raw.label=="string"?{text:e.raw.label}:e.raw.label,i=`floor mono t-${e.kind}`,l={"data-hl":e.id,...s},a=lt.floor;if(o.at){let p=o.at.length>2?o.at[2]:e.points[0][2];return{svg:n.floorText(o.at[0],o.at[1],p,o.text,i,o.dir??"x",o.anchor??"start",l)}}let c=e.points,f=[];for(let p=0;p+1<c.length;p++){let g=c[p],x=c[p+1];Math.abs(g[2]-x[2])>1e-6||f.push({i:p,len:Math.hypot(x[0]-g[0],x[1]-g[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(p=>p.i===Math.min(o.along-1,c.length-2)):[...f].sort((p,g)=>g.len-p.len),d=.22,h=11/st,b=p=>{let g=an(p,a)/st,x,$=1/0,T=0;e:for(let v of u.length?u:f){let A=c[v.i],L=c[v.i+1],M=A[2],P=Math.abs(A[1]-L[1])<1e-6,k=P?Math.min(A[0],L[0]):Math.min(A[1],L[1]),O=P?Math.max(A[0],L[0]):Math.max(A[1],L[1]),w=P?A[1]:A[0],R=o.side==="left"?[-1]:o.side==="right"?[1]:[-1,1],I=[];for(let G=k+.3;G<=Math.max(k+.3,O-g-.2)+1e-9;G+=.4)I.push(G);for(let G=O-g-.2+.4;G<O+.5&&O-k<g+.5;G+=.6)I.push(G);for(let G of R)for(let X of I){if($<=T*.5)break e;let U=G<0?w-d:w+d+h,B,H,Y;if(P?(B=X,H=U,Y=[Ce(B,H-h,M),Ce(B+g,H-h,M),Ce(B+g,H,M),Ce(B,H,M)]):(B=U,H=X+g,Y=[Ce(B-h,H,M),Ce(B-h,H-g,M),Ce(B,H-g,M),Ce(B,H,M)]),(P?[[B,H-h],[B+g,H-h],[B+g,H],[B,H]]:[[B-h,H],[B-h,H-g],[B,H-g],[B,H]]).some(([ce,fe])=>Math.abs(Qs(r,ce,fe)+.01-M)>.001)){T++;continue}let F=t.hiddenPoly(Y),K=F*50+T*.5,q=t.budget.spots-- >0;q||(t.budget.over=!0);let Z=K>=$?1/0:q?K+t.costPoly(Y,$-K):K;T++,Z<$&&($=Z,x={x:B,y:H,z:M,dir:P?"x":"y",rect:An(Y),poly:Y,hidden:F})}}return x&&x.hidden<6?x:void 0},m=o.text,y=b(m),N;if(!y){let p=o.text.split(/(\s+)/);for(let g=p.length-1;g>0&&!y;g--){let x=p.slice(0,g).join("").trimEnd().replace(/[\s,;:·–-]+$/,"")+"\u2026";if(x.length<6)break;let $=b(x);$&&(y=$,m=x)}N=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?N+='; give it "along", "side" or "at", or move the nodes apart':N+='; give it "at: [x, y]", or move the nodes apart'}return y?(t.slants.push(y.poly),{svg:n.floorText(y.x,y.y,y.z+.01,m,i,y.dir,"start",l),warning:N}):{svg:"",warning:N}}function tp(n,e,t,s,r){let o=e.on?s.find(f=>f.id===e.on):void 0,i=e.on&&!o?t.byId.get(e.on):void 0,l=e.at,a={"data-id":r,"data-hl":o?.id,"data-dim":o?void 0:"1"},c=e.kind??o?.kind??"control";if(e.floor){let f=l&&l.length>2?l[2]:o?o.points[0][2]:i?i.floor:.36,[u,d]=l?[l[0],l[1]]:o?[o.points[0][0]+.35,o.points[0][1]-.25]:i?[i.box.x0+.3,i.box.y1-.3]:[0,0];return n.floorText(u,d,f+.01,e.floor,`floor mono t-${c}`,e.dir??"x",e.anchor??"start",a)}if(e.face){let f=i?.box,[u,d,h]=l?[l[0],l[1],l[2]??.45]:f?[f.x0+.3,f.y1,f.z0+.13]:[0,0,0];return n.faceText(u,d,h,e.face,"slabname sm",lt.sm,"left",e.anchor??"start",a)}if(e.label||e.sub){let f=i?.box,u=l?[l[0],l[1],l[2]??.36]:f?[(f.x0+f.x1)/2,(f.y0+f.y1)/2,f.z1+.75]:[0,0,0],[d,h]=Ce(u[0],u[1],u[2]),b=d+(e.dx??0),m=h-18+(e.dy??0),y=e.anchor??"middle",N="";return e.label&&(N+=n.text(b,m,e.label,"lbl",lt.lbl,y)),e.sub&&(N+=n.text(b,e.label?m+14:m,e.sub,"sub mono",lt.sub,y)),Ee("g",a,N)}return""}function ou(n,e){let t={};for(let s of n.layout.items){let r=(s.region??s.node)?.variants;r&&(t[s.id]=Object.keys(r))}Object.keys(t).length&&(n.rendered.looks=t,n.rendered.variants=Object.fromEntries([...new Set(Object.values(t).flat())].map(s=>[s,or({scene:n.raw,routes:n.routes,steps:n.steps,theme:e,id:n.raw.id,gridStep:n.grid.step??n.grid.snap??1,layout:{...n.layout,items:n.layout.items.map(r=>{let o=(r.region??r.node)?.variants?.[s];return o?r.region?{...r,region:{...r.region,...o,deco:void 0}}:{...r,node:{...r.node,...o}}:r})}}).svg])))}var Zr=29.09090909090909,Ol={solid:[9,7],dashed:[7,6],dotted:[3,6]},Nl=["blocked","planned"],iu=`
|
|
147
|
+
.flow.iso-ants{stroke-dasharray:var(--ant-on) var(--ant-off);animation:iso-ants var(--ant-turn) linear infinite;animation-play-state:var(--ants,running)}
|
|
148
|
+
@keyframes iso-ants{to{stroke-dashoffset:var(--ant-to)}}
|
|
149
|
+
`;function eo(n,e={}){return(e.still??Nl).includes(n)?void 0:e.dash??e.kinds?.[n]?.ants??Ol[e.kinds?.[n]?.dash??"solid"]}function Di(n){let e=n?.ants;return e?e===!0?{}:Array.isArray(e)?{ids:e}:e:void 0}function au(n,e={}){let t=new Map(n.routes.map(i=>[i.id,i.kind])),s=e.ids&&new Set(e.ids),r=e.speed??Zr,o=i=>String(Number(i.toFixed(3)));return n.rendered.svg.replace(/(<g data-route="([^"]*)" data-part="line">(?:<g[^>]*>)*)<path ([^>]*?)\s*\/>/g,(i,l,a,c)=>{let f=a.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"),u=s&&!s.has(f)?void 0:eo(t.get(f)??"",e);if(!u||!/class="flow\b/.test(c))return i;let d=u[0]+u[1],h=o(d/Math.max(1e-6,Math.abs(r))),b=o(r<0?d:-d);return e.by==="css"?`${l}<path ${c.replace(/class="flow\b/,'class="flow iso-ants')} style="--ant-on:${o(u[0])};--ant-off:${o(u[1])};--ant-to:${b};--ant-turn:${h}s"/>`:e.by==="none"?`${l}<path ${c.replace(/ ?stroke-dasharray="[^"]*"/,"")} style="stroke-dasharray:${o(u[0])} ${o(u[1])}"/>`:`${l}<path ${c.replace(/ ?stroke-dasharray="[^"]*"/,"")} style="stroke-dasharray:${o(u[0])} ${o(u[1])}"><animate attributeName="stroke-dashoffset" from="0" to="${b}" dur="${h}s" repeatCount="indefinite"/></path>`})}var Os=n=>typeof n=="string"?[n]:[...n],_i=n=>JSON.parse(JSON.stringify(n)),un=(n={})=>({...n.from===void 0?{}:{from:n.from},...n.over===void 0?{}:{duration:n.over},...n.easing===void 0?{}:{easing:n.easing}}),ir=class n{nodes=[];add(e){return this.nodes.push(_i(e)),this}assemble(e={},t={}){return this.add({assemble:e,...un(t)})}disassemble(e={},t={}){return this.add({disassemble:e,...un(t)})}travel(e,t={}){let{each:s,hold:r,loop:o}=t;return this.add({travel:e,...un(t),each:s,hold:r,loop:o})}pulse(e,t={}){return this.add({pulse:Os(e),...un(t),loop:t.loop})}ants(e=!0,t={}){return this.add({ants:e===!0?!0:Os(e),...un(t),speed:t.speed,dash:t.dash})}draw(e,t={}){return this.add({draw:Os(e),...un(t),by:t.by,stagger:t.stagger})}type(e,t={}){return this.add({type:Os(e),...un(t)})}move(e,t){return this.add({move:e,...t})}lift(e,t,s={}){return this.add({lift:Os(e),by:t,...un(s),stagger:s.stagger,to:s.to,opacity:s.opacity})}focus(e,t={}){let{scope:s,level:r,always:o}=t;return this.add({focus:{lit:Os(e),scope:s,level:r,always:o},...un(t),fade:t.fade})}highlight(e,t={}){return this.add({highlight:Os(e),...un(t),fade:t.fade})}get camera(){return{focus:(e,t={})=>this.add({camera:{focus:e,zoom:t.zoom,margin:t.margin},...un(t)}),fit:(e={})=>this.add({camera:"fit",...un(e)})}}sequence(e,t={},s){return this.add({sequence:lu(e,t,s)})}series(e){let t=new ar;return e(t),this.add({series:t.items})}layers(e){let t=new n;return e(t),this.add({layers:t.nodes})}};function lu(n,e,t){let{read:s,duration:r,...o}=e,i=new ir;return t?.(i),_i({...n===void 0?{}:{name:n},...o,...s!==void 0?{duration:{read:s}}:r!==void 0?{duration:r}:{},...i.nodes.length?{children:i.nodes}:{}})}var ar=class{items=[];sequence(e,t={},s){return this.items.push({sequence:lu(e,t,s)}),this}transition(e){return this.items.push({transition:_i(e)}),this}},to=class extends ar{over=[];marks={};head;constructor(e={}){super(),this.head=e}beat(e,t,s={},r){return this.sequence(e,{...s,say:t},r)}assemble(e={},t={}){return this.sequence(void 0,{},s=>s.assemble(e,t))}disassemble(e={},t={}){return this.sequence(void 0,{},s=>s.disassemble(e,t))}mark(e,t){return this.marks[e]=t,this}layers(e){let t=new ir;return e(t),this.over.push(...t.nodes),this}toJSON(){return _i({isomotion:1,...this.head,...this.items.length?{series:this.items}:{},...this.over.length?{layers:this.over}:{},...Object.keys(this.marks).length?{markers:this.marks}:{}})}},cu=(n={})=>new to(n);function zi(n,e){if(!e)return n;let[t,s,r,o]=e,i=n[2]/n[3],l=r-t,a=o-s;l/a<i?l=a*i:a=l/i,l=Math.min(l,n[2]),a=Math.min(a,n[3]);let c=(t+r)/2,f=(s+o)/2,u=Math.max(n[0],Math.min(n[0]+n[2]-l,c-l/2)),d=Math.max(n[1],Math.min(n[1]+n[3]-a,f-a/2));return[u,d,l,a]}var so=["linear","ease","ease-in","ease-out","ease-in-out","settle","bounce"],Ns=["extend","clamp","wrap","identity"];function Rn(n,e){if(typeof n=="number")return Number.isFinite(n)?n:void 0;if(typeof n!="string")return;let t=/^(-?\d+(?:\.\d+)?)(ms|s|f)?$/.exec(n.trim());if(!t)return;let s=Number(t[1]);return t[2]==="s"?s*1e3:t[2]==="f"?e?s/e*1e3:void 0:s}function ro(n,e){let t=e===!0?{}:e,s=t.base??2600,r=t.perChar??40,o=t.min??5600,i=t.max??12500;return Math.max(o,Math.min(i,s+(n?.text??"").length*r))}var ds=(n,e,t,s)=>r=>{if(r<=0)return 0;if(r>=1)return 1;let o=(a,c,f)=>3*a*f*(1-f)**2+3*c*f*f*(1-f)+f**3,i=0,l=1;for(let a=0;a<50;a++){let c=(i+l)/2;o(n,t,c)<r?i=c:l=c}return o(e,s,(i+l)/2)},np=n=>{if(n<=0)return 0;if(n>=1)return 1;let e=7.5625,t=2.75;return n<1/t?e*n*n:n<2/t?e*(n-1.5/t)**2+.75:n<2.5/t?e*(n-2.25/t)**2+.9375:e*(n-2.625/t)**2+.984375},sp={linear:n=>n,ease:ds(.25,.1,.25,1),"ease-in":ds(.42,0,1,1),"ease-out":ds(0,0,.58,1),"ease-in-out":ds(.42,0,.58,1),settle:ds(.16,.84,.3,1),bounce:np};function lr(n,e={}){let t=e.mass??1,s=e.stiffness??100,r=e.damping??10,o=Math.max(0,n)/1e3,i=Math.sqrt(s/t),l=r/(2*Math.sqrt(s*t)),a;if(l<1){let c=i*Math.sqrt(1-l*l);a=1-Math.exp(-l*i*o)*(Math.cos(c*o)+l*i/c*Math.sin(c*o))}else a=1-Math.exp(-i*o)*(1+i*o);return e.overshootClamping?Math.min(1,a):a}function Pn(n,e,t="ease-in-out"){let s=n??t;return typeof s=="string"?sp[s]:"bezier"in s?ds(...s.bezier):r=>r<=0?0:r>=1?1:lr(r*e,s.spring)}function cr(n,e,t){let s=n.times.map(u=>Rn(u,t)),r=n.values,o=s.length;if(o===1)return r[0];let i=(u,d)=>{if(u==="clamp")return d?r[0]:r[o-1];if(u==="identity")return e;if(u==="wrap"){let h=s[o-1]-s[0];return cr({...n,extrapolateLeft:"clamp",extrapolateRight:"clamp"},s[0]+((e-s[0])%h+h)%h,t)}};if(e<s[0]){let u=i(n.extrapolateLeft??"extend",!0);if(u!==void 0)return u}if(e>s[o-1]){let u=i(n.extrapolateRight??"extend",!1);if(u!==void 0)return u}let l=0;for(;l<o-2&&e>=s[l+1];)l++;let a=s[l+1]-s[l],c=(e-s[l])/a,f=c<0||c>1?c:Pn(n.easing,a,"linear")(c);return r[l]+(r[l+1]-r[l])*f}var Rl=["sequence","series","layers","assemble","disassemble","travel","pulse","ants","draw","type","move","lift","focus","highlight","camera"],fu={morph:"the 2D morph is a later version's",diff:"diffs are a later version's",switch:"a look is a beat's: its variants"},Nn=["from","duration","easing"],no={sequence:[],series:[],layers:[],assemble:Nn,disassemble:Nn,travel:[...Nn,"each","hold","loop"],pulse:[...Nn,"loop"],ants:[...Nn,"speed","dash"],draw:[...Nn,"by","stagger"],type:Nn,move:["from","x","y","scale","opacity"],lift:[...Nn,"by","stagger","to","opacity"],focus:[...Nn,"fade"],highlight:[...Nn,"fade"],camera:Nn},rp=["name","from","offset","duration","loop","playbackRate","trimBefore","say","show","hide","focus","highlight","levels","variants","enter","ants","children","layers","series"],gt=n=>!!n&&typeof n=="object"&&!Array.isArray(n);function Ki(n){let e=[],t=(p,g,x)=>{e.push({severity:"error",path:p,message:g,...x?{hint:x}:{}})},s=(p,g,x)=>{for(let $ of Object.keys(p))if(!g.includes($)){let T=Bt($,g);t(`${x}/${$}`,`unknown key "${$}"`,T?`did you mean "${T}"?`:void 0)}};if(!gt(n))return t("","a motion document is a map"),e;s(n,["isomotion","fps","seed","ambient","series","layers","markers"],""),n.isomotion!==1&&t("/isomotion","isomotion is 1");let r=typeof n.fps=="number"&&n.fps>0?n.fps:void 0;n.fps!==void 0&&r===void 0&&t("/fps","fps is a number over 0"),n.seed!==void 0&&!Number.isInteger(n.seed)&&t("/seed","seed is a whole number"),n.ambient!==void 0&&n.ambient!=="on"&&n.ambient!=="off"&&t("/ambient",'ambient is "on" or "off"');let o=(p,g,x={})=>{if(p===void 0)return;if(typeof p=="string"&&/f$/.test(p)&&r===void 0){t(g,`"${p}" is in frames: the document needs its fps`);return}let $=Rn(p,r);$===void 0?t(g,`${JSON.stringify(p)} isn't a time (ms, "1.2s", "450ms", "30f")`):$<0&&!x.negative&&t(g,"a time can't be negative")},i=(p,g,x)=>{if(p!==void 0&&!g.includes(p)){let $=typeof p=="string"?Bt(p,g):void 0;t(x,`${JSON.stringify(p)} isn't one of ${g.join(", ")}`,$?`did you mean "${$}"?`:void 0)}},l=(p,g,x={})=>{p!==void 0&&(typeof p!="number"||!Number.isFinite(p)||x.min!==void 0&&p<x.min||x.max!==void 0&&p>x.max||x.over!==void 0&&p<=x.over)&&t(g,`${JSON.stringify(p)} isn't a number${x.over!==void 0?` over ${x.over}`:x.min!==void 0?` from ${x.min}${x.max!==void 0?` to ${x.max}`:""}`:""}`)},a=(p,g)=>{if(p!==void 0){if(!Array.isArray(p)){t(g,"a list of ids");return}p.forEach((x,$)=>{typeof x!="string"&&t(`${g}/${$}`,"an id")})}},c=(p,g,x=[])=>{if(!gt(p)){t(g,"a spring is a map");return}s(p,["mass","damping","stiffness","overshootClamping",...x],g);for(let $ of["mass","damping","stiffness"])l(p[$],`${g}/${$}`,{over:0});p.overshootClamping!==void 0&&typeof p.overshootClamping!="boolean"&&t(`${g}/overshootClamping`,"true or false")},f=(p,g)=>{if(p!==void 0){if(typeof p=="string"){i(p,so,g);return}if(gt(p)&&"bezier"in p){s(p,["bezier"],g),(!Array.isArray(p.bezier)||p.bezier.length!==4||p.bezier.some(x=>typeof x!="number"))&&t(`${g}/bezier`,"four numbers");return}if(gt(p)&&"spring"in p){s(p,["spring"],g),c(p.spring,`${g}/spring`);return}t(g,"an easing is a name, { bezier: [a, b, c, d] } or { spring: { \u2026 } }")}},u=(p,g)=>{if(p===void 0)return;if(!gt(p)){t(g,"a curve is { times, values }");return}s(p,["times","values","easing","extrapolateLeft","extrapolateRight"],g);let x=p.times,$=p.values;if(!Array.isArray(x)||!x.length)t(`${g}/times`,"a list of times");else{x.forEach((v,A)=>o(v,`${g}/times/${A}`,{negative:!0}));let T=x.map(v=>Rn(v,r));for(let v=1;v<T.length;v++)T[v]!==void 0&&T[v-1]!==void 0&&T[v]<=T[v-1]&&t(`${g}/times/${v}`,"times go up")}!Array.isArray($)||$.some(T=>typeof T!="number")?t(`${g}/values`,"a list of numbers"):Array.isArray(x)&&$.length!==x.length&&t(`${g}/values`,`${$.length} values for ${x.length} times`),f(p.easing,`${g}/easing`),i(p.extrapolateLeft,Ns,`${g}/extrapolateLeft`),i(p.extrapolateRight,Ns,`${g}/extrapolateRight`)},d=(p,g)=>{if(p!==void 0){if(!gt(p)){t(g,"focus is { lit: [ids] }");return}s(p,["lit","scope","level","always"],g),p.lit===void 0&&t(`${g}/lit`,"what is lit"),a(p.lit,`${g}/lit`),a(p.always,`${g}/always`),i(p.scope,["all","links"],`${g}/scope`),l(p.level,`${g}/level`,{min:0,max:1})}},h=(p,g)=>{p!==void 0&&typeof p!="string"&&t(g,"text")},b=new Map;function m(p,g,x){if(!gt(p)){t(g,"a sequence is a map");return}if(s(p,rp,g),p.name!==void 0&&(typeof p.name!="string"||!/^[A-Za-z][\w-]*$/.test(p.name)?t(`${g}/name`,"a name is letters, digits, - and _, from a letter"):b.has(p.name)?t(`${g}/name`,`"${p.name}" is already a name (${b.get(p.name)})`):b.set(p.name,g)),x&&p.from!==void 0&&t(`${g}/from`,"in a series a sequence follows the one before","offset moves it"),!x&&p.offset!==void 0&&t(`${g}/offset`,"offset is for a series","use from"),o(p.from,`${g}/from`),o(p.offset,`${g}/offset`,{negative:!0}),o(p.trimBefore,`${g}/trimBefore`),gt(p.duration)){s(p.duration,["read"],`${g}/duration`);let $=p.duration.read;if($!==!0&&!gt($))t(`${g}/duration/read`,"true, or { base, perChar, min, max }");else if(gt($)){s($,["base","perChar","min","max"],`${g}/duration/read`);for(let T of["base","perChar","min","max"])l($[T],`${g}/duration/read/${T}`,{min:0})}}else o(p.duration,`${g}/duration`);if(p.loop!==void 0&&typeof p.loop!="boolean"&&!(Number.isInteger(p.loop)&&p.loop>=1)&&t(`${g}/loop`,"true, false, or how many times"),l(p.playbackRate,`${g}/playbackRate`,{over:0}),p.say!==void 0)if(!gt(p.say))t(`${g}/say`,"say is a map");else{let $=p.say;s($,["chapter","title","text","code","facts","color"],`${g}/say`);for(let T of["chapter","title","text","code","color"])h($[T],`${g}/say/${T}`);$.facts!==void 0&&(!Array.isArray($.facts)||$.facts.some(T=>!Array.isArray(T)||T.length!==2||T.some(v=>typeof v!="string")))&&t(`${g}/say/facts`,"a list of [name, value]")}for(let $ of["show","hide","highlight"])a(p[$],`${g}/${$}`);if(d(p.focus,`${g}/focus`),p.levels!==void 0)if(!gt(p.levels))t(`${g}/levels`,"levels is a map: an id, and how much of it");else for(let[$,T]of Object.entries(p.levels))l(T,`${g}/levels/${$}`,{min:0,max:1});if(p.variants!==void 0)if(!gt(p.variants))t(`${g}/variants`,"variants is a map: an id, and the name of its look");else for(let[$,T]of Object.entries(p.variants))typeof T!="string"&&t(`${g}/variants/${$}`,`a look's name, or "" for its own`);p.enter!==void 0&&(gt(p.enter)?(s(p.enter,["fade","easing"],`${g}/enter`),p.enter.fade===void 0&&t(`${g}/enter/fade`,"how long the fade is"),o(p.enter.fade,`${g}/enter/fade`),f(p.enter.easing,`${g}/enter/easing`)):t(`${g}/enter`,"enter is { fade }")),p.ants!==void 0&&typeof p.ants!="boolean"&&a(p.ants,`${g}/ants`);for(let $ of["children","layers"])p[$]!==void 0&&N(p[$],`${g}/${$}`);p.series!==void 0&&y(p.series,`${g}/series`)}function y(p,g){if(!Array.isArray(p)){t(g,"a series is a list");return}p.forEach((x,$)=>{let T=`${g}/${$}`;if(!gt(x)||Object.keys(x).length!==1||!("sequence"in x||"transition"in x)){t(T,"a series holds sequences and transitions");return}if("sequence"in x){m(x.sequence,`${T}/sequence`,!0);return}let v=x.transition,A=`${T}/transition`,L=M=>gt(p[M])&&"sequence"in p[M];if((!L($-1)||!L($+1))&&t(A,"a transition is between two sequences"),!gt(v)){t(A,"a transition is { presentation, timing }");return}s(v,["presentation","timing"],A),v.presentation===void 0?t(`${A}/presentation`,"a presentation"):i(v.presentation,["fade","none"],`${A}/presentation`),gt(v.timing)?"linear"in v.timing?(s(v.timing,["linear"],`${A}/timing`),o(v.timing.linear,`${A}/timing/linear`)):"spring"in v.timing?(s(v.timing,["spring"],`${A}/timing`),c(v.timing.spring,`${A}/timing/spring`,["duration"]),gt(v.timing.spring)&&o(v.timing.spring.duration,`${A}/timing/spring/duration`)):t(`${A}/timing`,"a timing is { linear } or { spring }"):t(`${A}/timing`,"a timing is { linear } or { spring }")})}function N(p,g){if(!Array.isArray(p)){t(g,"a list");return}p.forEach((x,$)=>{let T=`${g}/${$}`;if(!gt(x)){t(T,"a map");return}let v=Rl.filter(P=>P in x);if(v.length!==1){let P=Object.keys(x).find(w=>w in fu),k=Object.keys(x)[0],O=k?Bt(k,Rl):void 0;t(T,P?`${P}: ${fu[P]}`:v.length?`one of ${v.join(", ")}, not several`:`one of ${Rl.join(", ")}`,!P&&!v.length&&O?`did you mean "${O}"?`:void 0);return}let A=v[0],L=x[A],M=`${T}/${A}`;s(x,[A,...no[A]],T),no[A].includes("from")&&o(x.from,`${T}/from`),no[A].includes("duration")&&(o(x.duration,`${T}/duration`),f(x.easing,`${T}/easing`));for(let P of["each","hold","stagger","fade"])no[A].includes(P)&&o(x[P],`${T}/${P}`);if(no[A].includes("loop")&&x.loop!==void 0&&typeof x.loop!="boolean"&&t(`${T}/loop`,"true or false"),A==="sequence")m(L,M,!1);else if(A==="series")y(L,M);else if(A==="layers")N(L,M);else if(A==="assemble"||A==="disassemble")gt(L)?(i(L.style,A==="assemble"?nr:sr,`${M}/style`),i(L.order,Ts,`${M}/order`),L.duration!==void 0&&t(`${M}/duration`,"its length is beside it","duration is the node's")):t(M,`${A} is a map (its options)`);else if(A==="travel")!Array.isArray(L)||!L.length?t(M,"a list of connectors"):L.forEach((P,k)=>{Array.isArray(P)?a(P,`${M}/${k}`):typeof P!="string"&&t(`${M}/${k}`,"a connector, or a list of them at once")});else if(A==="ants")L!==!0&&a(L,M),l(x.speed,`${T}/speed`),x.dash!==void 0&&(!Array.isArray(x.dash)||x.dash.length!==2||x.dash.some(P=>typeof P!="number"||P<=0))&&t(`${T}/dash`,"two numbers over 0: on, off");else if(A==="move"){typeof L!="string"&&t(M,"an id");for(let P of["x","y","scale","opacity"])u(x[P],`${T}/${P}`)}else if(A==="focus")d(L,M);else if(A==="camera"){if(L!=="fit")if(!gt(L))t(M,'"fit", or { focus, zoom, margin }');else{s(L,["focus","zoom","margin"],M),l(L.zoom,`${M}/zoom`,{over:0}),l(L.margin,`${M}/margin`);let P=L.focus;typeof P=="string"||Array.isArray(P)&&(P.every(k=>typeof k=="string")||P.length===4&&P.every(k=>typeof k=="number"))||t(`${M}/focus`,"an id, some ids, or a box [x, y, w, h]")}}else a(L,M);A==="draw"&&i(x.by,["stroke","grow"],`${T}/by`),A==="lift"&&(x.by===void 0&&t(`${T}/by`,"how far apart"),l(x.by,`${T}/by`),i(x.to,["up","down"],`${T}/to`),u(x.opacity,`${T}/opacity`))})}if(n.series!==void 0&&y(n.series,"/series"),n.layers!==void 0&&N(n.layers,"/layers"),n.markers!==void 0)if(!gt(n.markers))t("/markers","markers is a map");else for(let[p,g]of Object.entries(n.markers))if(typeof g=="string"&&/^[A-Za-z][\w-]*([+-].+)?$/.test(g)){let x=/^([A-Za-z][\w-]*?)(?:([+-])(\d.*))?$/.exec(g);if(x&&(b.has(x[1])?x[1]:void 0))x[3]!==void 0&&o(x[3],`/markers/${p}`);else if(!b.has(g)){let v=Bt(x?.[1]??g,b.keys());t(`/markers/${p}`,`no sequence is named "${x?.[1]??g}"`,v?`did you mean "${v}"?`:void 0)}}else o(g,`/markers/${p}`);return e}var tn=n=>Math.round(n*100)/100||0,Pt=n=>Math.round(n*1e4)/1e4||0,dn=n=>Math.max(0,Math.min(1,n)),fr=(n,e,t)=>n+(e-n)*t,op=250,Pl=class{items=new Map;labels=new Map;routes=new Map;tokens=[];pulses=[];outlines=[];variants={};marks=1;at(e,t){let s=e.get(t);return s||e.set(t,s={}),s}item(e,t){let s=this.at(this.items,e);t.opacity!==void 0&&(s.opacity=(s.opacity??1)*t.opacity),t.dx&&(s.dx=(s.dx??0)+t.dx),t.dy&&(s.dy=(s.dy??0)+t.dy),t.scale!==void 0&&(s.scale=(s.scale??1)*t.scale,s.about=t.about??s.about),t.clip&&(s.clip=t.clip)}label(e,t){let s=this.at(this.labels,e);t.opacity!==void 0&&(s.opacity=(s.opacity??1)*t.opacity),t.dx&&(s.dx=(s.dx??0)+t.dx),t.dy&&(s.dy=(s.dy??0)+t.dy),t.typed!==void 0&&(s.typed=Math.min(s.typed??1,t.typed))}route(e,t){let s=this.at(this.routes,e);t.opacity!==void 0&&(s.opacity=(s.opacity??1)*t.opacity),t.drawn!==void 0&&t.drawn<(s.drawn??1)&&(s.drawn=t.drawn,s.by=t.by),t.ants&&(s.ants=t.ants)}add(e){for(let[t,s]of Object.entries(e.items??{}))this.item(t,s);for(let[t,s]of Object.entries(e.labels??{}))this.label(t,s);for(let[t,s]of Object.entries(e.routes??{}))this.route(t,s);e.marks&&(this.marks*=e.marks.opacity),this.tokens.push(...e.tokens??[]),this.pulses.push(...e.pulses??[])}state(e){let t={},s=(f,u)=>{let d={};for(let[h,b]of f){let m=u(b);Object.keys(m).length&&(d[h]=m)}return d},r=f=>Object.keys(f).length>0,o=f=>f===void 0||Pt(f)>=1?{}:{opacity:Pt(Math.max(0,f))},i=f=>({...tn(f.dx??0)?{dx:tn(f.dx)}:{},...tn(f.dy??0)?{dy:tn(f.dy)}:{}}),l=s(this.items,f=>({...o(f.opacity),...i(f),...f.scale!==void 0&&Pt(f.scale)!==1?{scale:Pt(f.scale),...f.about?{about:f.about}:{}}:{},...f.clip?{clip:f.clip}:{}})),a=s(this.labels,f=>({...o(f.opacity),...f.typed!==void 0&&f.typed<1?{typed:Pt(f.typed)}:{},...i(f)})),c=s(this.routes,f=>{let u=f.opacity!==void 0&&Pt(f.opacity)<=0,d=f.drawn!==void 0&&f.drawn<1;return{...o(f.opacity),...d?{drawn:Pt(f.drawn),...f.by?{by:f.by}:{}}:{},...f.ants&&!u&&!d?{ants:f.ants}:{}}});return r(l)&&(t.items=l),r(a)&&(t.labels=a),r(c)&&(t.routes=c),Pt(this.marks)<1&&(t.marks={opacity:Pt(this.marks)}),this.tokens.length&&(t.tokens=this.tokens),this.pulses.length&&(t.pulses=this.pulses),this.outlines.length&&(t.outlines=this.outlines),r(this.variants)&&(t.variants=this.variants),e&&(t.camera=e),t}};function oo(n){let e=Di(n.raw),t=n.rendered.looks,s=As(n),r=Object.keys(s.notes).filter(o=>s.notes[o]===void 0);return{model:s,kinds:Object.fromEntries(n.routes.map(o=>[o.id,o.kind])),outlines:Object.fromEntries(n.layout.items.map(o=>[o.id,Rt(o.box).map(i=>[tn(i[0]),tn(i[1])])])),...t&&Object.keys(t).length?{looks:t}:{},...e?{ants:e}:{},...r.length?{free:r}:{}}}function io(n,e,t={}){let s="model"in n?n:oo(n),r=s.free?{...s.model,notes:{...s.model.notes,...Object.fromEntries(s.free.map(S=>[S,void 0]))}}:s.model,o=Ki(e),i=e.fps,l=s.ants,a=()=>({ok:!1,diags:o,duration:0,beats:[],markers:{},ambient:"on",loops:!1,at:()=>({}),cues:()=>{},beatAt:()=>{},startOf:()=>{}});if(o.length)return a();let c=(S,z,J)=>{o.push({severity:"error",path:S,message:z,...J?{hint:J}:{}})},f=(S,z)=>S===void 0?z:Rn(S,i),u=new Map(r.pieces.map(S=>[S.id,S])),d=new Set(r.routes.map(S=>S.id)),h=new Set(Object.keys(r.notes)),b=new Map(Object.entries(s.kinds)),m=[...u.keys(),...d,...h],y=new Set(m),N=new Map;for(let[S,z]of Object.entries(r.notes))z!==void 0&&N.set(z,[...N.get(z)??[],S]);let p={any:y,thing:new Set(u.keys()),route:d},g={any:"thing, connector or note",thing:"thing",route:"connector"},x=(S,z,J="any")=>{if(!p[J].has(S)){let de=Bt(S,p[J]);c(z,`no ${g[J]} "${S}" in this drawing`,de?`did you mean "${de}"?`:void 0)}},$=(S,z,J="any")=>S?.forEach((de,me)=>x(de,`${z}/${me}`,J)),T=new Map(Object.entries(s.outlines)),v=new Map;function A(S,z){let J="from"in S?f(S.from,0):0,de="duration"in S?f(S.duration,NaN):NaN,me=Number.isFinite(de);if("sequence"in S){let Q=S.sequence;return f(Q.from,0)+k(Q,`${z}/sequence`)}if("series"in S)return O(S.series,`${z}/series`).end;if("layers"in S)return Math.max(0,...S.layers.map((Q,ne)=>A(Q,`${z}/layers/${ne}`)));if("assemble"in S||"disassemble"in S){let Q="assemble"in S?"assemble":"disassemble",ne="assemble"in S?S.assemble:S.disassemble,ge=v.get(S);return ge||v.set(S,ge=rr(r,Q,{seed:e.seed??1,...ne,...me?{duration:de}:{}})),J+ge.duration}return"draw"in S?J+(me?de:400)+Math.max(0,S.draw.length-1)*f(S.stagger,0):"lift"in S?J+Math.max(me?de:750,...S.opacity?.times.map(Q=>Rn(Q,i))??[])+Math.max(0,S.lift.length-1)*f(S.stagger,0):me?J+de:"travel"in S?S.loop?J:J+S.travel.length*f(S.each,1150):"pulse"in S?S.loop?J:J+1500:"type"in S?J+400:"camera"in S?J+900:"move"in S?J+Math.max(0,...[S.x,S.y,S.scale,S.opacity].flatMap(Q=>Q?.times.map(ne=>Rn(ne,i))??[])):J}let L=(S,z)=>Math.max(0,...(S.children??[]).map((J,de)=>A(J,`${z}/children/${de}`)),...(S.layers??[]).map((J,de)=>A(J,`${z}/layers/${de}`)),S.series?O(S.series,`${z}/series`).end:0),M=new Map;function P(S,z){let J=M.get(S);if(J!==void 0)return J;let de;return S.duration!==void 0&&typeof S.duration=="object"?de=ro(S.say,S.duration.read):de=S.duration!==void 0?f(S.duration,0):L(S,z),S.duration===void 0&&de<=0&&S.say&&(de=ro(S.say,!0)),de<=0&&c(`${z}/duration`,"how long is it? (nothing in it says)"),M.set(S,de),de}let k=(S,z)=>{let J=P(S,z),de=S.playbackRate??1;return S.loop===!0?J/de:(typeof S.loop=="number"?J*S.loop:J)/de};function O(S,z){let J=[],de=0,me;return S.forEach((Q,ne)=>{if("transition"in Q){let _=Q.transition,le=_.timing,pe=_.presentation==="none"?0:"linear"in le?f(le.linear,0):f(le.spring.duration,ip(le.spring));me={t:_,length:pe};return}let ge=Q.sequence,ke=`${z}/${ne}/sequence`,E=k(ge,ke),j=Math.max(0,de+f(ge.offset,0)-(me?.length??0));me&&J.length&&me.length>Math.min(J[J.length-1].end-J[J.length-1].start,E)&&c(`${z}/${ne-1}/transition/timing`,"a transition is no longer than either side of it"),J.push({s:ge,path:ke,start:j,end:j+E,...me?{into:me}:{}}),de=j+E,me=void 0}),{list:J,end:Math.max(0,...J.map(Q=>Q.end))}}let w=O(e.series??[],"/series"),R=Math.max(0,...(e.layers??[]).map((S,z)=>A(S,`/layers/${z}`))),I=Math.max(w.end,R);I<=0&&!o.length&&c("","a motion document has a series, or layers, that last");let G=new Map,X=[],U=r.viewBox,B=(S,z,J)=>{let de=J!==void 0?1/J:Math.max((S.w+z*2)/U[2],(S.h+z*2)/U[3]);return[S.x+S.w/2-U[2]*de/2,S.y+S.h/2-U[3]*de/2,U[2]*de,U[3]*de]};function H(S,z,J){let de=me=>J?{at:J.at+me/J.rate,rate:J.rate}:void 0;if("sequence"in S){ee(S.sequence,`${z}/sequence`,de(f(S.sequence.from,0)),!1);return}if("series"in S){for(let me of O(S.series,`${z}/series`).list)ee(me.s,me.path,de(me.start),!1);return}if("layers"in S){S.layers.forEach((me,Q)=>H(me,`${z}/layers/${Q}`,J));return}if("travel"in S)S.travel.forEach((me,Q)=>(Array.isArray(me)?me:[me]).forEach((ne,ge)=>x(ne.split(":")[0],`${z}/travel/${Q}${Array.isArray(me)?`/${ge}`:""}`,"route")));else if("pulse"in S)$(S.pulse,`${z}/pulse`,"thing");else if("ants"in S)S.ants!==!0&&$(S.ants,`${z}/ants`,"route");else if("draw"in S)$(S.draw,`${z}/draw`,"route");else if("type"in S)$(S.type,`${z}/type`);else if("move"in S)x(S.move,`${z}/move`,"thing");else if("lift"in S)$(S.lift,`${z}/lift`,"thing");else if("focus"in S)Y(S.focus,`${z}/focus`);else if("highlight"in S)$(S.highlight,`${z}/highlight`,"thing");else if("camera"in S){let me=S.camera,Q=f(S.duration,900);if(!J){c(`${z}/camera`,"a camera can't be in a loop");return}let ne=U;if(me!=="fit"){let ge=me.focus;if(Array.isArray(ge)&&typeof ge[0]=="number")ne=B({x:ge[0],y:ge[1],w:ge[2],h:ge[3]},me.margin??0,me.zoom);else{let ke=typeof ge=="string"?[ge]:ge;ke.forEach((j,_)=>x(j,`${z}/camera/focus${typeof ge=="string"?"":`/${_}`}`,"thing"));let E=ke.map(j=>u.get(j)?.bbox).filter(j=>!!j);if(E.length){let j=Math.min(...E.map(le=>le.x)),_=Math.min(...E.map(le=>le.y));ne=B({x:j,y:_,w:Math.max(...E.map(le=>le.x+le.w))-j,h:Math.max(...E.map(le=>le.y+le.h))-_},me.margin??40,me.zoom)}}}X.push({at:J.at+f(S.from,0)/J.rate,over:Q/J.rate,ease:Pn(S.easing,Q,"settle"),to:ne})}}let Y=(S,z)=>{S&&($(S.lit,`${z}/lit`),$(S.always,`${z}/always`))};function ee(S,z,J,de){if(S.name!==void 0&&J&&G.set(S.name,J.at),!de)for(let ne of["show","hide","say","enter","focus","highlight","levels","variants","ants"])S[ne]!==void 0&&c(`${z}/${ne}`,`${ne} is for a sequence of the document's own series`,ne==="focus"||ne==="highlight"||ne==="ants"?`here, a child: { ${ne}: \u2026 }`:void 0);$(S.show,`${z}/show`),$(S.hide,`${z}/hide`),$(S.highlight,`${z}/highlight`,"thing"),Y(S.focus,`${z}/focus`);for(let ne of Object.keys(S.levels??{}))ne!=="*"&&x(ne,`${z}/levels/${ne}`);for(let[ne,ge]of Object.entries(S.variants??{})){x(ne,`${z}/variants/${ne}`,"thing");let ke=s.looks?.[ne]??[];if(u.has(ne)&&ge!==""&&!ke.includes(ge)){let E=Bt(ge,ke);c(`${z}/variants/${ne}`,ke.length?`${ne} has no look "${ge}" (it has ${ke.join(", ")})`:`${ne} declares no looks (variants: in the diagram)`,E?`did you mean "${E}"?`:void 0)}}Array.isArray(S.ants)&&$(S.ants,`${z}/ants`,"route");let me=S.playbackRate??1,Q=J&&!S.loop?{at:J.at-f(S.trimBefore,0)/(J.rate*me),rate:J.rate*me}:void 0;if((S.children??[]).forEach((ne,ge)=>H(ne,`${z}/children/${ge}`,Q)),(S.layers??[]).forEach((ne,ge)=>H(ne,`${z}/layers/${ge}`,Q)),S.series)for(let ne of O(S.series,`${z}/series`).list)ee(ne.s,ne.path,Q&&{at:Q.at+ne.start/Q.rate,rate:Q.rate},!1)}for(let S of w.list)ee(S.s,S.path,{at:S.start,rate:1},!0);(e.layers??[]).forEach((S,z)=>H(S,`/layers/${z}`,{at:0,rate:1})),X.sort((S,z)=>S.at-z.at);let F={};for(let[S,z]of Object.entries(e.markers??{})){let J=Rn(z,i);if(J!==void 0){F[S]=J;continue}let de=String(z),me=[...G.keys()].filter(ge=>de===ge||de.startsWith(ge+"+")||de.startsWith(ge+"-")).sort((ge,ke)=>ke.length-ge.length)[0];if(me===void 0){c(`/markers/${S}`,`"${de}" isn't a moment of this document`);continue}let Q=de.slice(me.length),ne=Q?Rn(Q.slice(1),i):0;if(ne===void 0){c(`/markers/${S}`,`"${Q}" isn't a time`);continue}F[S]=G.get(me)+(Q[0]==="-"?-ne:ne)}if(o.length)return a();let K=w.list.map((S,z)=>({name:S.s.name??`beat-${z+1}`,index:z,start:S.start,end:S.end,...S.s.say?{say:S.s.say}:{}})),q=new Map;for(let S of w.list){for(let z of S.s.show??[])q.has(z)||q.set(z,!1);for(let z of S.s.hide??[])q.has(z)||q.set(z,!0)}let Z=[new Map(q)];for(let S of w.list){let z=new Map(Z[Z.length-1]);for(let J of S.s.show??[])z.set(J,!0);for(let J of S.s.hide??[])z.set(J,!1);Z.push(z)}let ce=[new Map];for(let S of w.list){let z=new Map(ce[ce.length-1]);for(let[J,de]of Object.entries(S.s.variants??{}))z.set(J,de);ce.push(z)}let fe=(S,z)=>!S||S.lit.includes(z)||S.always?.includes(z)||S.scope==="links"&&u.has(z)?1:S.level??.12,W=(S,z)=>{let J=S<0?void 0:w.list[S].s.levels;return J?J[z]??J["*"]??1:1},oe=(S,z)=>(Z[S+1].get(z)===!1?0:1)*(S<0?1:fe(w.list[S].s.focus,z))*W(S,z),Me=(S,z)=>{let J=r.notes[z];if(J===void 0)return oe(S,z);let de=S<0?void 0:w.list[S].s.levels?.[z];return oe(S,J)*(Z[S+1].get(z)===!1?0:1)*(de??1)},Le=S=>{let z=-1;for(let J=0;J<w.list.length;J++)w.list[J].start<=S&&(z=J);return z},C=(S,z)=>{let J=w.list[S],de=z-J.start;if(J.into&&J.into.length>0){let ne=J.into.t.timing;return"spring"in ne?de>=J.into.length?1:dn(lr(de,{...ne.spring,overshootClamping:!0})/lr(J.into.length,{...ne.spring,overshootClamping:!0})):dn(de/J.into.length)}let me=J.s.enter;if(!me)return 1;let Q=f(me.fade,0);return Q<=0?1:Pn(me.easing,Q,"ease")(dn(de/Q))};function V(S,z,J,de,me){if("sequence"in S){let ke=S.sequence,E=f(ke.from,0);we(ke,z-E,J-E,Oe(ke,de-E),me);return}if("series"in S){for(let ke of O(S.series,"").list)we(ke.s,z-ke.start,J-ke.start,ke.end-ke.start,me);return}if("layers"in S){for(let ke of S.layers)V(ke,z,J,de,me);return}let Q=f("from"in S?S.from:void 0,0),ne=z-Q;if("assemble"in S||"disassemble"in S){me.sum.add(v.get(S).at(ne));return}if("draw"in S){let ke=Math.max(1,f(S.duration,400)),E=f(S.stagger,0),j=Pn(S.easing,ke,"ease-out");S.draw.forEach((_,le)=>{let pe=j(dn((ne-le*E)/ke));pe<=0?(me.sum.route(_,{opacity:0,drawn:0}),me.sum.label(_,{opacity:0})):pe<1&&(me.sum.route(_,{drawn:pe,...S.by?{by:S.by}:{}}),me.sum.label(_,{opacity:pe}))});return}if("type"in S){let ke=f(S.duration,400),E=Pn(S.easing,ke,"linear")(dn(ne/Math.max(1,ke)));if(E<1)for(let j of S.type)me.sum.label(j,E<=0?{opacity:0}:{typed:E});return}if("move"in S){let ke=pe=>pe?cr(pe,ne,i):void 0,E=ke(S.x)??0,j=ke(S.y)??0,_=ke(S.scale),le=ke(S.opacity);me.sum.item(S.move,{dx:E,dy:j,..._===void 0?{}:{scale:_,about:u.get(S.move).foot},...le===void 0?{}:{opacity:dn(le)}});for(let pe of[S.move,...N.get(S.move)??[]])me.sum.label(pe,{dx:E,dy:j,...le===void 0?{}:{opacity:dn(le)}});return}if("lift"in S){let ke=f(S.stagger,0),E=Math.max(1,f(S.duration,750)),j=Pn(S.easing,E,"ease-out"),_=S.to==="down",le=S.lift.length;S.lift.forEach((pe,Re)=>{let ie=ne-(_?le-1-Re:Re)*ke,Pe=j(dn(ie/E)),Se=(Re+1)*S.by*(_?Pe:-Pe),xe=S.opacity?dn(cr(S.opacity,ie,i)):1;if(!(!Se&&xe>=1)){me.sum.item(pe,{dy:Se,opacity:xe});for(let Ie of[pe,...N.get(pe)??[]])me.sum.label(Ie,{dy:Se,opacity:xe})}});return}if("camera"in S)return;let ge=S.duration===void 0?Math.max(0,de-Q):f(S.duration,0);if(!(ne<0||ne>ge)){if("focus"in S||"highlight"in S){let ke=Math.max(1,f(S.fade,op)),E=dn(Math.min(ne/ke,S.duration===void 0?1:(ge-ne)/ke)),j=Pn(S.easing,ke,"linear")(E);if("focus"in S)ye(S.focus,j,me.sum);else for(let _ of S.highlight)me.shown(_)&&Te(_,j,me.sum);return}if("ants"in S){Ne(S.ants===!0?[...d]:S.ants,me,S.speed,S.dash);return}if("pulse"in S){let E=S.loop?ae(J-Q,1500,me)/1500:ne/Math.max(1,S.duration===void 0?1500:ge);if(E<0||E>=1)return;for(let j of S.pulse)if(me.shown(j)){let _=u.get(j),le=_.bbox.w*.5*(.7+E*.6);me.sum.pulses.push({x:tn(_.foot[0]),y:tn(_.foot[1]),rx:tn(le),ry:tn(le*.58),opacity:Pt(1-E)})}return}if("travel"in S){let ke=f(S.each,1150),E=f(S.hold,S.loop?700:0),j=S.travel.length*ke+E,_=S.loop?ae(J-Q,j,me):ne,le=Math.floor(_/ke);if(le>=S.travel.length)return;let pe=(_-le*ke)/ke,Re=Pn(S.easing,ke,"ease-in-out")(pe),ie=S.travel[le];for(let Pe of Array.isArray(ie)?ie:[ie]){let[Se,xe]=Pe.split(":");me.shown(Se)&&me.sum.tokens.push({route:Se,at:Pt((xe??b.get(Se))==="blocked"?te(pe):Re),...xe?{kind:xe}:{}})}}}}let te=S=>S<.7?S/.7:1-(S-.7)/.3*.25,ae=(S,z,J)=>J.off?0:(S%z+z)%z,Te=(S,z,J)=>{Pt(z)>0&&T.has(S)&&J.outlines.push({id:S,points:T.get(S),...Pt(z)<1?{opacity:Pt(z)}:{}})},ye=(S,z,J)=>{for(let de of m){let me=h.has(de)&&!S.lit.includes(de)&&!S.always?.includes(de)?r.notes[de]:void 0,Q=fr(1,fe(S,me??de),z);Q>=1||(u.has(de)?(J.item(de,{opacity:Q}),J.label(de,{opacity:Q})):d.has(de)?(J.route(de,{opacity:Q}),J.label(de,{opacity:Q})):J.label(de,{opacity:Q}))}},Ne=(S,z,J=Zr,de)=>{for(let me of S){let Q=eo(b.get(me)??"",{dash:de,kinds:t.kinds,still:t.still});if(!Q)continue;let ne=Q[0]+Q[1],ge=ae(J*z.A/1e3,ne,z);z.sum.route(me,{ants:{dash:Q,offset:tn(ge)}})}},Oe=(S,z)=>S.loop===!0?Math.max(0,z):k(S,"");function we(S,z,J,de,me){if(z<0||z>de||z===de&&de<I&&de>0&&S.loop)return;let Q=S.playbackRate??1,ne=P(S,""),ge=f(S.trimBefore,0),ke=S.loop&&ne>0?z*Q%ne:z*Q,E=ke+ge,j=J*Q+ge;for(let _ of S.children??[])V(_,E,j,ne+ge,me);for(let _ of S.layers??[])V(_,E,j,ne+ge,me);if(S.series)for(let _ of O(S.series,"").list)we(_.s,E-_.start,j-_.start,_.end-_.start,me)}function Fe(S,z={}){let J=Math.max(0,Math.min(I,Number.isFinite(S)?S:0)),de=z.ambient==="off"||e.ambient==="off"&&z.ambient===void 0,me=typeof z.ambient=="number"?z.ambient:J,Q=new Pl,ne=Le(J),ge=ne<0?1:C(ne,J),ke=(ie,Pe)=>ne<0?Pe(-1,ie):ge>=1?Pe(ne,ie):fr(Pe(ne-1,ie),Pe(ne,ie),ge),E=ie=>(ne<0?Z[0]:Z[ne+1]).get(ie)!==!1;if(q.size||w.list.some(ie=>ie.s.focus||ie.s.levels))for(let ie of m){let Pe=ke(ie,h.has(ie)?Me:oe);Pe>=1||(u.has(ie)&&Q.item(ie,{opacity:Pe}),d.has(ie)&&Q.route(ie,{opacity:Pe}),Q.label(ie,{opacity:Pe}))}if(ne>=0)for(let ie of ce[ce.length-1].keys()){let Pe=ce[ne].get(ie)??"",Se=ce[ne+1].get(ie)??"",xe={};Pe&&ge<1&&(xe[Pe]=Pt(1-ge)),Se&&(xe[Se]=Pt((xe[Se]??0)+ge));for(let Ie of Object.keys(xe))xe[Ie]<=0&&delete xe[Ie];Object.keys(xe).length&&(Q.variants[ie]=xe)}if(ne>=0){let ie=new Set(w.list[ne].s.highlight??[]),Pe=new Set(ne>0&&ge<1?w.list[ne-1].s.highlight??[]:[]);for(let Se of new Set([...Pe,...ie]))Te(Se,fr(Pe.has(Se)?1:0,ie.has(Se)?1:0,ge),Q)}let j={sum:Q,shown:E,off:de,A:me},_=ne>=0?w.list[ne].s.ants:void 0,le=_===void 0?l:void 0;_?Ne(_===!0?[...d]:_,j):le&&Ne(le.ids??[...d],j,le.speed,le.dash),w.list.forEach((ie,Pe)=>{J>=ie.start&&(J<ie.end||Pe===ne&&J<=ie.end)&&we(ie.s,J-ie.start,me-ie.start,ie.end-ie.start,j)});for(let ie of e.layers??[])V(ie,J,me,I,j);let pe;for(let ie of X){if(ie.at>J)break;let Pe=ie.over<=0?1:ie.ease(dn((J-ie.at)/ie.over)),Se=pe??U;if(Pe>=1){pe=ie.to;continue}let xe=Se[2],Ie=ie.to[2],ze=Math.exp(fr(Math.log(xe),Math.log(Ie),Pe)),tt=Math.abs(Ie-xe)<1e-6?Pe:(ze-xe)/(Ie-xe),Yn=fr(Se[0]+Se[2]/2,ie.to[0]+ie.to[2]/2,tt),ft=fr(Se[1]+Se[3]/2,ie.to[1]+ie.to[3]/2,tt),Je=ze*U[3]/U[2];pe=[Yn-ze/2,ft-Je/2,ze,Je]}let Re=pe?.map(tn);return Q.state(Re&&Re.some((ie,Pe)=>Math.abs(ie-U[Pe])>.005)?Re:void 0)}let qe=S=>{if(!S||typeof S!="object")return!1;if(Array.isArray(S))return S.some(qe);let z=S;return z.ants!==void 0&&z.ants!==!1||z.loop===!0&&("travel"in z||"pulse"in z)?!0:Object.values(z).some(qe)},De=l!==void 0||qe(e.series)||qe(e.layers),Qe=S=>{let z=Le(Math.max(0,Math.min(I,S)));return z<0?void 0:K[z]};return{ok:!0,diags:o,duration:I,beats:K,markers:F,ambient:e.ambient??"on",loops:De,at:Fe,beatAt:Qe,startOf:S=>G.get(S)??K.find(z=>z.name===S)?.start,cues(S){let z=Qe(S);if(!z)return;let J=Math.max(0,Math.min(I,S));return{beat:z.name,index:z.index,of:K.length,progress:Pt(dn((J-z.start)/Math.max(1,z.end-z.start))),...z.say?{say:z.say,...z.say.chapter!==void 0?{chapter:z.say.chapter}:{},...z.say.color!==void 0?{color:z.say.color}:{}}:{}}}}}function ip(n){let e=n.mass??1,t=n.stiffness??100,s=n.damping??10,r=Math.sqrt(t/e),o=Math.min(1,s/(2*Math.sqrt(t*e)));return Math.ceil(Math.log(200)/(o*r)*1e3*(o>=1?1.6:1))}function Vi(n){let{steps:e,vis:t}=n.steps,s=n.rendered.viewBox,r=!1,o=As(n),i=new Set([...o.pieces.map(f=>f.id),...o.routes.map(f=>f.id),...Object.keys(o.notes)]),l=f=>i.has(f),a=Object.keys(o.notes).filter(f=>o.notes[f]===void 0),c=e.map((f,u)=>{let d=[],h=[];for(let[p,g]of Object.entries(t))(u===0?!g.includes(!0):g[u-1]&&!g[u])?h.push(p):u>0&&g[u]&&!g[u-1]&&d.push(p);let b=[],m=p=>`${p.route}:${p.kind}`;f.phases.length&&b.push({travel:f.phases.map(p=>p.length===1?m(p[0]):p.map(m)),each:1150,hold:700,loop:!0});let y=(n.raw.steps??[])[u]?.pulse?.filter(p=>n.layout.byId.has(p))??[];if(y.length&&b.push({pulse:y,loop:!0}),f.focus){let[p,g,x,$]=zi(s,f.focus).map(tn);b.push({camera:{focus:[p,g,x,$]},duration:900,easing:"ease-in-out"}),r=!0}else r&&(b.push({camera:"fit",duration:900,easing:"ease-in-out"}),r=!1);let N={name:`step-${f.n}`,duration:f.duration,say:{title:f.heading,...f.caption?{text:f.caption}:{},...f.command?{code:f.command}:{}}};return d.length&&(N.show=d),h.length&&(N.hide=h),N.focus=n.raw.dim==="all"?{lit:f.lit.filter(l),scope:"all",level:.14}:{lit:f.lit.filter(l),scope:"links",level:.12,...a.length?{always:a}:{}},b.length&&(N.children=b),{sequence:N}});return{isomotion:1,...c.length?{series:c}:{}}}var ap={anyOf:[{type:"number"},{type:"string",pattern:"^-?\\d+(\\.\\d+)?(ms|s|f)?$"}]},lp={type:"array",items:{type:"string"}},cp={anyOf:[{enum:so},{type:"object",required:["bezier"],additionalProperties:!1,properties:{bezier:{type:"array",items:{type:"number"},minItems:4,maxItems:4}}},{type:"object",required:["spring"],additionalProperties:!1,properties:{spring:{$ref:"#/$defs/spring"}}}]},uu={from:{$ref:"#/$defs/time"},duration:{$ref:"#/$defs/time"},easing:{$ref:"#/$defs/ease"}},Yt=(n,e,t={},s=!0)=>({type:"object",required:[n],additionalProperties:!1,properties:{[n]:e,...s?uu:{},...t}}),du={$schema:"https://json-schema.org/draft/2020-12/schema",title:"isomotion/1",type:"object",required:["isomotion"],additionalProperties:!1,properties:{isomotion:{const:1},fps:{type:"number",exclusiveMinimum:0,description:'Frames a second, for lengths written "30f".'},seed:{type:"integer"},ambient:{enum:["on","off"],description:"Off: the ants and the looping tokens and pulses stand still, each at its start."},series:{$ref:"#/$defs/series"},layers:{$ref:"#/$defs/nodes"},markers:{type:"object",additionalProperties:{anyOf:[{type:"number"},{type:"string"}]}}},$defs:{time:ap,ids:lp,ease:cp,spring:{type:"object",additionalProperties:!1,properties:{mass:{type:"number",exclusiveMinimum:0},damping:{type:"number",exclusiveMinimum:0},stiffness:{type:"number",exclusiveMinimum:0},overshootClamping:{type:"boolean"}}},curve:{type:"object",required:["times","values"],additionalProperties:!1,properties:{times:{type:"array",items:{$ref:"#/$defs/time"},minItems:1},values:{type:"array",items:{type:"number"},minItems:1},easing:{$ref:"#/$defs/ease"},extrapolateLeft:{enum:Ns},extrapolateRight:{enum:Ns}}},say:{type:"object",additionalProperties:!1,properties:{chapter:{type:"string"},title:{type:"string"},text:{type:"string"},code:{type:"string"},color:{type:"string"},facts:{type:"array",items:{type:"array",items:{type:"string"},minItems:2,maxItems:2}}}},focus:{type:"object",required:["lit"],additionalProperties:!1,properties:{lit:{$ref:"#/$defs/ids"},scope:{enum:["all","links"]},level:{type:"number",minimum:0,maximum:1},always:{$ref:"#/$defs/ids"}}},sequence:{type:"object",additionalProperties:!1,properties:{name:{type:"string",pattern:"^[A-Za-z][\\w-]*$"},from:{$ref:"#/$defs/time"},offset:{$ref:"#/$defs/time"},trimBefore:{$ref:"#/$defs/time"},duration:{anyOf:[{$ref:"#/$defs/time"},{type:"object",required:["read"],additionalProperties:!1,properties:{read:{anyOf:[{const:!0},{type:"object",additionalProperties:!1,properties:{base:{type:"number"},perChar:{type:"number"},min:{type:"number"},max:{type:"number"}}}]}}}]},loop:{anyOf:[{type:"boolean"},{type:"integer",minimum:1}]},playbackRate:{type:"number",exclusiveMinimum:0},say:{$ref:"#/$defs/say"},show:{$ref:"#/$defs/ids"},hide:{$ref:"#/$defs/ids"},focus:{$ref:"#/$defs/focus"},highlight:{$ref:"#/$defs/ids"},levels:{type:"object",additionalProperties:{type:"number",minimum:0,maximum:1}},variants:{type:"object",additionalProperties:{type:"string"}},enter:{type:"object",required:["fade"],additionalProperties:!1,properties:{fade:{$ref:"#/$defs/time"},easing:{$ref:"#/$defs/ease"}}},ants:{anyOf:[{type:"boolean"},{$ref:"#/$defs/ids"}]},children:{$ref:"#/$defs/nodes"},layers:{$ref:"#/$defs/nodes"},series:{$ref:"#/$defs/series"}}},series:{type:"array",items:{anyOf:[{$ref:"#/$defs/seq"},Yt("transition",{type:"object",required:["presentation","timing"],additionalProperties:!1,properties:{presentation:{enum:["fade","none"]},timing:{anyOf:[{type:"object",required:["linear"],additionalProperties:!1,properties:{linear:{$ref:"#/$defs/time"}}},{type:"object",required:["spring"],additionalProperties:!1,properties:{spring:{type:"object",additionalProperties:!1,properties:{mass:{type:"number",exclusiveMinimum:0},damping:{type:"number",exclusiveMinimum:0},stiffness:{type:"number",exclusiveMinimum:0},overshootClamping:{type:"boolean"},duration:{$ref:"#/$defs/time"}}}}}]}}},{},!1)]}},seq:Yt("sequence",{$ref:"#/$defs/sequence"},{},!1),plan:{type:"object"},nodes:{type:"array",items:{anyOf:[{$ref:"#/$defs/seq"},Yt("series",{$ref:"#/$defs/series"},{},!1),Yt("layers",{$ref:"#/$defs/nodes"},{},!1),Yt("assemble",{type:"object",properties:{style:{enum:nr},order:{enum:Ts}}}),Yt("disassemble",{type:"object",properties:{style:{enum:sr},order:{enum:Ts}}}),Yt("travel",{type:"array",items:{anyOf:[{type:"string"},{$ref:"#/$defs/ids"}]},minItems:1},{each:{$ref:"#/$defs/time"},hold:{$ref:"#/$defs/time"},loop:{type:"boolean"}}),Yt("pulse",{$ref:"#/$defs/ids"},{loop:{type:"boolean"}}),Yt("ants",{anyOf:[{const:!0},{$ref:"#/$defs/ids"}]},{speed:{type:"number"},dash:{type:"array",items:{type:"number",exclusiveMinimum:0},minItems:2,maxItems:2}}),Yt("draw",{$ref:"#/$defs/ids"},{by:{enum:["stroke","grow"]},stagger:{$ref:"#/$defs/time"}}),Yt("type",{$ref:"#/$defs/ids"}),{type:"object",required:["move"],additionalProperties:!1,properties:{move:{type:"string"},from:{$ref:"#/$defs/time"},x:{$ref:"#/$defs/curve"},y:{$ref:"#/$defs/curve"},scale:{$ref:"#/$defs/curve"},opacity:{$ref:"#/$defs/curve"}}},{type:"object",required:["lift","by"],additionalProperties:!1,properties:{lift:{$ref:"#/$defs/ids"},by:{type:"number"},stagger:{$ref:"#/$defs/time"},to:{enum:["up","down"]},opacity:{$ref:"#/$defs/curve"},...uu}},Yt("focus",{$ref:"#/$defs/focus"},{fade:{$ref:"#/$defs/time"}}),Yt("highlight",{$ref:"#/$defs/ids"},{fade:{$ref:"#/$defs/time"}}),Yt("camera",{anyOf:[{const:"fit"},{type:"object",required:["focus"],additionalProperties:!1,properties:{focus:{anyOf:[{type:"string"},{$ref:"#/$defs/ids"},{type:"array",items:{type:"number"},minItems:4,maxItems:4}]},zoom:{type:"number",exclusiveMinimum:0},margin:{type:"number"}}}]})]}}}};var hu=new Set(["fill","stroke","stroke-width","stroke-dasharray","stroke-linecap","stroke-linejoin","opacity","fill-opacity","stroke-opacity","font-size","font-weight","font-family","letter-spacing","text-anchor","dominant-baseline","paint-order","display","stop-color","stop-opacity"]),fp=new Set("cursor pointer-events transition animation transform-box transform-origin user-select".split(" "));function up(n,e){let t={classes:[],not:[],attrs:[],child:e},s=n,r=i=>{let l=i.exec(s);return l&&(s=s.slice(l[0].length)),l},o=r(/^[a-zA-Z][\w-]*/);for(o?t.tag=o[0]:r(/^\*/);s;){let i;if(i=r(/^\.([\w-]+)/))t.classes.push(i[1]);else if(i=r(/^:not\(\.([\w-]+)\)/))t.not.push(i[1]);else if(i=r(/^\[([\w-]+)(?:="([^"]*)")?\]/))t.attrs.push([i[1],i[2]]);else throw new Error(`resolve: a selector it doesn't know: ${n}`)}return t}function dp(n){let e=n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/@keyframes[^{]*\{(?:[^{}]*\{[^}]*\})*[^{}]*\}/g,"").replace(/@media[^{]*\{(?:[^{}]*\{[^}]*\})*[^{}]*\}/g,"");if(/@/.test(e.replace(/"[^"]*"/g,"")))throw new Error("resolve: an at-rule it doesn't know");let t=[];for(let s of e.matchAll(/([^{}]+)\{([^{}]*)\}/g)){let r=s[2].split(";").map(o=>o.trim()).filter(Boolean).map(o=>{let i=o.indexOf(":"),l=o.slice(0,i).trim(),a=o.slice(i+1).trim();return[l,a.replace(/\s*!important$/,""),/!important$/.test(a)]});for(let o of r)if(!o[0].startsWith("--")&&!hu.has(o[0])&&!fp.has(o[0]))throw new Error(`resolve: a property it doesn't know: ${o[0]}`);for(let o of s[1].split(",").map(i=>i.trim()).filter(Boolean)){if(o.includes(":root")||o.includes("::")||/^(html|body)\b/.test(o))continue;let l=o.replace(/\s*>\s*/g," >").split(/\s+/).map(c=>up(c.replace(/^>/,""),c.startsWith(">"))),a=l.reduce((c,f)=>c+10*(f.classes.length+f.not.length+f.attrs.length)+(f.tag?1:0),0);t.push({parts:l,spec:a,order:t.length,decls:r})}}return t}function mp(n){let e={name:"#root",attrs:[],children:[]},t=e;for(let s of n.matchAll(/<\/[a-zA-Z][\w:-]*>|<([a-zA-Z][\w:-]*)((?:\s+[\w:-]+="[^"]*")*)\s*(\/?)>|([^<]+)/g)){if(s[4]!==void 0){t.children.push(s[4]);continue}if(s[1]===void 0){t=t.parent;continue}let r={name:s[1],attrs:[...s[2].matchAll(/([\w:-]+)="([^"]*)"/g)].map(o=>[o[1],o[2]]),children:[],parent:t};t.children.push(r),s[3]||(t=r)}return e.children[0]}var gu=n=>typeof n=="string"?n:`<${n.name}${n.attrs.map(([e,t])=>` ${e}="${t}"`).join("")}${n.children.length||n.name==="g"?`>${n.children.map(gu).join("")}</${n.name}>`:"/>"}`,ao=(n,e)=>n.attrs.find(t=>t[0]===e)?.[1],ur=(n,e,t)=>{let s=n.attrs.find(r=>r[0]===e);s?s[1]=t:n.attrs.push([e,t])},pp=n=>(ao(n,"class")??"").split(/\s+/).filter(Boolean);function hp(n,e){if(e.tag&&e.tag!==n.name)return!1;let t=pp(n);return e.classes.every(s=>t.includes(s))&&!e.not.some(s=>t.includes(s))&&e.attrs.every(([s,r])=>{let o=ao(n,s);return o!==void 0&&(r===void 0||o===r)})}function Cl(n,e,t=e.length-1){if(!hp(n,e[t]))return!1;if(t===0)return!0;let s=n.parent;if(e[t].child)return!!s&&s.name!=="#root"&&Cl(s,e,t-1);for(;s&&s.name!=="#root";s=s.parent)if(Cl(s,e,t-1))return!0;return!1}var ms=n=>n.endsWith("%")?parseFloat(n)/100:parseFloat(n);function gp(n,e,t,s){let r=(1-Math.abs(2*t-1))*e,o=(n%360+360)%360/60,i=r*(1-Math.abs(o%2-1)),l=t-r/2,[a,c,f]=o<1?[r,i,0]:o<2?[i,r,0]:o<3?[0,r,i]:o<4?[0,i,r]:o<5?[i,0,r]:[r,0,i];return[(a+l)*255,(c+l)*255,(f+l)*255,s]}function bu(n,e){let t=[],s=0,r="";for(let o of n)o==="("&&s++,o===")"&&s--,o===e&&s===0?(t.push(r.trim()),r=""):r+=o;return[...t,r.trim()].filter(Boolean)}var mu={transparent:[0,0,0,0],black:[0,0,0,1],white:[255,255,255,1]};function Gi(n){let e=n.trim();if(Object.hasOwn(mu,e))return mu[e];let t=/^#([0-9a-f]{3,8})$/i.exec(e);if(t){let s=t[1].length<6?[...t[1]].map(r=>r+r).join(""):t[1];return[parseInt(s.slice(0,2),16),parseInt(s.slice(2,4),16),parseInt(s.slice(4,6),16),s.length===8?parseInt(s.slice(6),16)/255:1]}if(t=/^hsla?\((.*)\)$/.exec(e),t){let[s,r]=t[1].split("/").map(c=>c.trim()),[o,i,l,a]=s.split(/[\s,]+/);return gp(parseFloat(o),ms(i),ms(l),r!==void 0?ms(r):a!==void 0?ms(a):1)}if(t=/^rgba?\((.*)\)$/.exec(e),t){let[s,r,o,i]=t[1].split(/[\s,/]+/).filter(Boolean);return[ms(s),ms(r),ms(o),i===void 0?1:ms(i)]}if(t=/^color-mix\(in srgb\s*,(.*)\)$/.exec(e),t){let[s,r]=bu(t[1],",").map(f=>{let u=/^(.*?)\s+([\d.]+)%$/.exec(f);return u?{c:Gi(u[1]),p:Number(u[2])/100}:{c:Gi(f),p:void 0}});if(!s?.c||!r?.c)return;let o=s.p??(r.p===void 0?.5:1-r.p),i=r.p??1-o,l=o+i,a=(s.c[3]*o+r.c[3]*i)/l,c=f=>a===0?0:(s.c[f]*s.c[3]*o+r.c[f]*r.c[3]*i)/l/a;return[c(0),c(1),c(2),a*Math.min(1,l)]}}var pu=n=>"#"+[n[0],n[1],n[2]].map(e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0")).join(""),bp=n=>String(Math.round(n*1e4)/1e4);function Il(n,e,t=0){if(t>20)throw new Error(`resolve: a custom property in a loop: ${n}`);let s=n.indexOf("var(");if(s<0)return n;let r=0,o=s+3;do n[o]==="("&&r++,n[o]===")"&&r--,o++;while(r>0&&o<n.length);let[i,...l]=bu(n.slice(s+4,o-1),","),a=e.get(i)??(l.length?l.join(","):void 0);if(a===void 0)throw new Error(`resolve: no value for ${i}`);return Il(n.slice(0,s)+a+n.slice(o),e,t+1)}var yp=n=>new Map(n.split(";").filter(Boolean).map(e=>{let t=e.indexOf(":");return[e.slice(0,t).trim(),e.slice(t+1).trim()]})),Ll={sans:"system-ui, -apple-system, Segoe UI, Roboto, sans-serif",mono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"};function yu(n,e){let t=Kr(e.theme),s=e.fonts??Ll,r=dp(`.mono{font-family:${s.mono.replace(/"/g,"")}}
|
|
150
|
+
${t.rest}
|
|
151
|
+
${e.css}`),o=mp(n);ur(o,"font-family",s.sans.replace(/"/g,""));let i=(l,a)=>{let c=a,f=new Map,u=(b,m,y)=>{let N=f.get(b);(!N||y[0]>N.rank[0]||y[0]===N.rank[0]&&(y[1]>N.rank[1]||y[1]===N.rank[1]&&y[2]>=N.rank[2]))&&f.set(b,{v:m,rank:y})};for(let b of r)if(Cl(l,b.parts))for(let[m,y,N]of b.decls)u(m,y,[N?1:0,b.spec,b.order]);let d=ao(l,"style");if(d){for(let b of d.split(";").map(m=>m.trim()).filter(Boolean)){let m=b.indexOf(":");u(b.slice(0,m).trim(),b.slice(m+1).trim(),[0,1e6,0])}l.attrs=l.attrs.filter(b=>b[0]!=="style")}for(let[b,m]of f)b.startsWith("--")&&(c===a&&(c=new Map(a)),c.set(b,m.v));let h={};for(let[b,m]of f){if(!hu.has(b))continue;let y=Il(m.v,c).trim();if(b==="fill"||b==="stroke"||b==="stop-color"){if(y==="none"||y==="currentColor"||y==="inherit"||y.startsWith("url(")){ur(l,b,y);continue}let N=Gi(y);if(!N)throw new Error(`resolve: a colour it doesn't know: ${y}`);ur(l,b,pu(N)),N[3]!==1&&(h[b==="stop-color"?"stop":b]=N[3])}else ur(l,b,b==="letter-spacing"||b==="font-size"||b==="stroke-width"?y:y.replace(/"/g,""))}for(let[b,m]of Object.entries(h))ur(l,`${b}-opacity`,bp(m*Number(ao(l,`${b}-opacity`)??1)));ao(l,"opacity")==="0"&&(ur(l,"display","none"),l.attrs=l.attrs.filter(b=>b[0]!=="opacity"));for(let b of l.attrs)if(/var\(|hsl\(|color-mix/.test(b[1])){let m=Il(b[1],c),y=Gi(m);b[1]=y?pu(y):m}for(let b of l.children)typeof b!="string"&&i(b,c)};return i(o,yp(e.mode==="dark"?`${t.light};${t.dark}`:t.light)),gu(o)}var qi=n=>`${Math.round(parseInt(n.slice(1,3),16)/255*1e4)/100}%`,Fl=(n,e,t)=>{let[s,r]=[n,e].map(i=>parseInt(i.slice(1,3),16)),o=Math.round(s+(r-s)*t).toString(16).padStart(2,"0");return`#${o}${o}${o}`};function Bl(n,e,t){let s=new Set([...n.matchAll(/\sclass="([^"]*)"/g)].flatMap(r=>r[1].split(/\s+/)).filter(r=>r.startsWith("k-")).map(r=>r.slice(2)));return{roles:Object.keys(e.roles).filter(r=>s.has(r)),kinds:[...new Set(t)].filter(r=>r in e.kinds)}}function jl(n,e){let t=jt[e.mode].steps,s=(c,f)=>e.roles[c]??t[f],r={};for(let[c,f]of Object.entries(n.light))r[c]=/%$/.test(f)?f:e.ink;let o=s("slab",0),i=s("pad",0);Object.assign(r,{bg:e.paper,surface:e.paper,on:e.paper,ink:e.ink,muted:Fl(e.paper,e.ink,.72),line:Fl(e.paper,e.ink,.3),"code-bg":Fl(e.paper,e.ink,.06),"slab-top":o.top,"slab-l":o.left,"slab-r":o.right,"pad-top":i.top});let l=Object.fromEntries(Object.entries(n.roles).map(([c])=>[c,{h:0,s:0}])),a=Object.fromEntries(Object.entries(n.kinds).map(([c,f])=>[c,{...f,color:e.ink}]));return Xs({...n,light:r,dark:r,roles:l,kinds:a})}function Dl(n){let e="";for(let[t,s]of Object.entries(n.roles))e+=`.k-${t}{--s:0%;--l-top:${qi(s.top)};--l-left:${qi(s.left)};--l-right:${qi(s.right)};--l-edge:${qi(s.edge)}}
|
|
152
|
+
`;for(let[t,s]of Object.entries(n.kinds))e+=`.flow.f-${t}{stroke-width:${s.width}${s.dash.length?`;stroke-dasharray:${s.dash.join(" ")}`:";stroke-dasharray:none"}}
|
|
153
|
+
`;return e}var xp={hatch:{size:6,draw:(n,e)=>`<path d="M0,6L6,0M-1.5,1.5L1.5,-1.5M4.5,7.5L7.5,4.5" stroke="${n}" stroke-width="${e}" fill="none"/>`},"hatch-wide":{size:12,draw:(n,e)=>`<path d="M0,0L12,12M-3,9L3,15M9,-3L15,3" stroke="${n}" stroke-width="${e}" fill="none"/>`},dots:{size:8,draw:(n,e)=>`<circle cx="2" cy="2" r="${e+.2}" fill="${n}"/><circle cx="6" cy="6" r="${e+.2}" fill="${n}"/>`}},wp=n=>Math.round(n*100)/100,kp=(n,e)=>qr(n,e.ink)>=qr(n,e.paper)?e.ink:e.paper;function xu(n,e,t){let s=new Map,r=(a,c)=>{let f=`${t}-mono-${a}-${c.slice(1)}`,u=xp[a],d=e.mode==="dark"?1.2:.9;return s.has(f)||s.set(f,`<pattern id="${f}" width="${u.size}" height="${u.size}" patternUnits="userSpaceOnUse">${u.draw(c,wp(d))}</pattern>`),f},o=[],i="",l="";for(let a of n.matchAll(/<\/[a-zA-Z][\w:-]*>|<([a-zA-Z][\w:-]*)((?:\s+[\w:-]+="[^"]*")*)\s*(\/?)>|[^<]+/g)){if(i+=a[0],a[0].startsWith("</")){o.pop();continue}if(a[1]===void 0)continue;let c=(/\sclass="([^"]*)"/.exec(a[2])?.[1]??"").split(/\s+/);o.length===1&&(l=c.find(m=>m.startsWith("g-"))??"");let f=c.find(m=>m.startsWith("k-"))?.slice(2)??o.at(-1);if(a[3]||o.push(c.includes("ghost")?"":f),!a[3]||a[1]!=="polygon"&&a[1]!=="path"||!f||!c.some(m=>m==="top"||m==="lft"||m==="rgt")||l==="g-base"&&!c.includes("rgt"))continue;let u=Object.hasOwn(e.roles,f)?e.roles[f].pattern:"none",d=/\sfill="(#[0-9a-f]{6})"/.exec(a[2])?.[1],h=/\s(points|d)="[^"]*"/.exec(a[2])?.[0];if(u==="none"||!d||!h)continue;let b=/\sfill-opacity="[^"]*"/.exec(a[2])?.[0]??"";i+=`<${a[1]}${h} class="mono-pattern" fill="url(#${r(u,kp(d,e))})" stroke="none"${b}/>`}return i=i.replace(/#([0-9a-f]{6})\b/g,(a,c)=>c.slice(0,2)===c.slice(2,4)&&c.slice(2,4)===c.slice(4,6)?a:vp(a)),s.size&&(i=i.replace(/<defs\/>|<defs>/,a=>a==="<defs/>"?`<defs>${[...s.values()].join("")}</defs>`:a+[...s.values()].join(""))),i}function vp(n){let e=Gr(n),t=e>8?((e+16)/116)**3:e/(24389/27),s=t<=.0031308?t*12.92:1.055*t**(1/2.4)-.055,r=Math.max(0,Math.min(255,Math.round(s*255))).toString(16).padStart(2,"0");return`#${r}${r}${r}`}function wu(n,e,t,s,r){let o=fi(e,t,Bl(n,e,s),r);return{look:o,theme:jl(e,o),css:Dl(o)}}function _l(n){return Math.max(5600,Math.min(12500,2600+n.length*40))}function Ui(n,e,t,s,r,o){let i=[],l=(M,P,k,O="error")=>{let w=r.locate(M);i.push({severity:O,message:P,line:w.line,col:w.col,path:M,hint:k})},a=n.steps??[],c=new Set(Object.keys(o.kinds)),f=new Map(s.map(M=>[M.id,M])),u=()=>[...t.byId.keys(),...f.keys()],d=new Map;a.forEach((M,P)=>{M.id&&(d.has(M.id)&&l(`${e}/steps/${P}/id`,`duplicate step id "${M.id}"`),d.set(M.id,P+1))});let h=a.length,b=(M,P)=>{if(typeof M=="number"){if(M<1||M>h){l(P,`there is no step ${M}; this scene has ${h} step(s)`);return}return M}let k=d.get(M);return k===void 0&&l(P,`unknown step "${M}"`+mn(M,d.keys())),k},m=M=>Tn(o,o.kinds[M]?.color??"control"),y=[],N=M=>{y.includes(M)||y.push(M)};for(let M of s)N(M.kind);let p={},g=(M,P,k,O)=>{if(P===void 0&&k===void 0)return;let w=P!==void 0?b(P,O+"/appears"):1,R=k!==void 0?b(k,O+"/disappears"):h+1;p[M]=Array.from({length:h},(I,G)=>G+1>=(w??1)&&G+1<(R??h+1))};for(let M of t.items)g(M.id,M.appears,M.disappears,M.path);for(let M of s)g(M.id,M.raw.appears,M.raw.disappears,M.path);let x=[],$=[],T=[],v=[],A=()=>{for(let M of s){if(M.raw.appears!==void 0||M.raw.disappears!==void 0)continue;let P=[M.from,M.to].map(k=>k&&(p[k.id]??L(k)));P.some(Boolean)&&(p[M.id]=Array.from({length:h},(k,O)=>P.every(w=>!w||w[O])))}},L=M=>{for(let P=M.parent;P;P=P.parent)if(p[P.id])return p[P.id]};return a.forEach((M,P)=>{let k=P+1,O=`${e}/steps/${P}`,w=M.kind??"control";c.has(w)||l(O+"/kind",`unknown flow kind "${w}"`+mn(w,c)),N(w);let R=new Set,I=[];(M.animate??[]).forEach((B,H)=>{let Y=Array.isArray(B)?B:[B],ee=[];Y.forEach((F,K)=>{let q=Array.isArray(B)?`${O}/animate/${H}/${K}`:`${O}/animate/${H}`,Z,ce;if(typeof F=="string"){let oe=/^([^:\s]+)\s*(?::\s*(\S+))?$/.exec(F.trim());Z=oe?oe[1]:F,ce=oe?.[2]}else{let oe=Object.entries(F)[0];Z=oe[0],ce=oe[1]}let fe=f.get(Z);if(!fe){l(q,`unknown route "${Z}"`+mn(Z,f.keys()));return}if(ce&&!c.has(ce)){l(q,`unknown flow kind "${ce}"`+mn(ce,c));return}let W=ce??fe.kind;N(W),ee.push({route:Z,kind:W,color:m(W)}),R.add(Z),fe.from&&R.add(fe.from.id),fe.to&&R.add(fe.to.id)}),ee.length&&I.push(ee)});let G=[];(M.pulse??[]).forEach((B,H)=>{let Y=t.byId.get(B);if(!Y){l(`${O}/pulse/${H}`,`unknown node "${B}"`+mn(B,t.byId.keys()));return}let ee,F,K,q,Z=Y.node?Ms(t.catalog,Y.node.asset):void 0;if(Z?.pulse)[ee,F,K,q]=Z.pulse(Y.box);else{let W=Y.box;ee=(W.x0+W.x1)/2,F=(W.y0+W.y1)/2,K=W.z1,q=Math.max(22,Math.min(60,(W.x1-W.x0+W.y1-W.y0)*8.5))}let[ce,fe]=Ce(ee,F,K);G.push([ce,fe,q*1.7,q*.98]),R.add(B)}),(M.highlight??[]).forEach((B,H)=>{!t.byId.has(B)&&!f.has(B)&&l(`${O}/highlight/${H}`,`unknown id "${B}"`+mn(B,u())),R.add(B)});for(let[B,H]of[["show",!0],["hide",!1]])(M[B]??[]).forEach((Y,ee)=>{if(!t.byId.has(Y)&&!f.has(Y)){l(`${O}/${B}/${ee}`,`unknown id "${Y}"`+mn(Y,u()));return}let F=p[Y]??(p[Y]=Array(h).fill(!H));for(let K=P;K<h;K++)F[K]=H});if((M.say??[]).forEach((B,H)=>{let Y,ee;if(Array.isArray(B.at))[Y,ee]=Ce(B.at[0],B.at[1],B.at[2]??.36);else{let K=t.byId.get(B.at);if(!K){l(`${O}/say/${H}/at`,`unknown node "${B.at}"`+mn(B.at,t.byId.keys()));return}let q=K.box;[Y,ee]=Ce((q.x0+q.x1)/2,(q.y0+q.y1)/2,q.z1+.75)}let F=B.kind??w;c.has(F)||l(`${O}/say/${H}/kind`,`unknown flow kind "${F}"`+mn(F,c)),$.push({step:k,x:Y+(B.dx??0),y:ee+(B.dy??(Array.isArray(B.at)?0:-46)),ax:Y,ay:ee,text:B.text,kind:F,anchor:B.anchor??"middle"})}),(M.mark??[]).forEach((B,H)=>{if(B.at){T.push({step:k,p:[B.at[0],B.at[1],B.at[2]??.36]});return}let Y=B.on?f.get(B.on):void 0;if(!Y){l(`${O}/mark/${H}`,B.on?`unknown route "${B.on}"`+mn(B.on,f.keys()):'a mark needs "on: ROUTE" or "at: [x, y]"');return}let ee=Y.points[Y.points.length-1];T.push({step:k,p:[ee[0],ee[1],ee[2]+.6],on:Y.id}),R.add(Y.id)}),n.badges&&M.badge!==!1){let B=Array.isArray(M.badge)?[M.badge[0],M.badge[1],M.badge[2]??.36]:void 0,H=typeof M.badge=="string"?M.badge:I[0]?.[0]?.route,Y=H?f.get(H):void 0;if(!B)if(Y)B=zl(Y.points);else if(H&&t.byId.get(H)){let ee=t.byId.get(H).box;B=[(ee.x0+ee.x1)/2,(ee.y0+ee.y1)/2,ee.z1+.3]}else typeof M.badge=="string"&&l(`${O}/badge`,`unknown id "${M.badge}"`+mn(M.badge,u()));B&&v.push({step:k,num:M.number??k,kind:w,p:B})}for(let B of[...R])for(let H=t.byId.get(B)?.parent;H;H=H.parent)R.add(H.id);for(let B of t.items)B.region?.kind==="tunnel"&&(B.region.around??[]).some(H=>R.has(H))&&R.add(B.id);let X;if(M.focus?.length){let B=1/0,H=1/0,Y=-1/0,ee=-1/0;M.focus.forEach((F,K)=>{let q=t.byId.get(F);if(!q){l(`${O}/focus/${K}`,`unknown node or region "${F}"`+mn(F,t.byId.keys()));return}let Z=q.box;for(let[ce,fe,W]of[[Z.x0,Z.y0,Z.z1],[Z.x1,Z.y0,Z.z0],[Z.x0,Z.y1,Z.z0],[Z.x1,Z.y1,Z.z0],[Z.x1,Z.y0,Z.z1],[Z.x0,Z.y1,Z.z1]]){let[oe,Me]=Ce(ce,fe,W);B=Math.min(B,oe),H=Math.min(H,Me),Y=Math.max(Y,oe),ee=Math.max(ee,Me)}R.add(F)}),B<1/0&&(X=[Math.round(B-60),Math.round(H-70),Math.round(Y+60),Math.round(ee+40)])}let U=M.caption??"";x.push({n:k,num:M.number??k,kind:w,color:m(w),heading:M.heading,caption:U,command:M.command??"",phases:I,pulses:G,lit:[...R],duration:M.duration===void 0||M.duration==="auto"?_l(U):M.duration,...X?{focus:X}:{}})}),A(),{steps:x,says:$,marks:T,badges:v,vis:p,diags:i,kindsUsed:y}}function zl(n){let e=n.slice(1).map((s,r)=>Math.hypot(s[0]-n[r][0],s[1]-n[r][1],s[2]-n[r][2])),t=e.reduce((s,r)=>s+r,0)/2;for(let s=0;s<e.length;s++){if(t<=e[s]&&e[s]>0){let r=t/e[s],o=n[s],i=n[s+1];return[o[0]+(i[0]-o[0])*r,o[1]+(i[1]-o[1])*r,o[2]+(i[2]-o[2])*r]}t-=e[s]}return n[0]}function mn(n,e){let t=Bt(n,e);return t?` (did you mean "${t}"?)`:""}var Kl=`
|
|
143
154
|
*{box-sizing:border-box}
|
|
144
155
|
html,body{margin:0}
|
|
145
156
|
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 +174,7 @@ h2{font-size:20px;margin:44px 0 4px;letter-spacing:-.005em;text-wrap:balance}
|
|
|
163
174
|
.legend i{display:inline-block;width:26px;height:0;border-top:3px solid}
|
|
164
175
|
.legend i.box{height:10px;border-width:1.5px;border-style:solid;border-radius:2px}
|
|
165
176
|
footer{margin-top:40px;font-size:12.5px;color:var(--muted)}
|
|
166
|
-
`,
|
|
177
|
+
`,Vl=n=>Sp+di(n)+$p+mi(),Sp=`
|
|
167
178
|
/* blocks: hue per role, lightness per face and theme */
|
|
168
179
|
.blk .top{fill:hsl(var(--h) var(--s) var(--l-top))}
|
|
169
180
|
.blk .lft{fill:hsl(var(--h) var(--s) var(--l-left))}
|
|
@@ -204,14 +215,14 @@ footer{margin-top:40px;font-size:12.5px;color:var(--muted)}
|
|
|
204
215
|
.floor.t-control{fill:var(--muted)}
|
|
205
216
|
.slabname{font-size:15px;font-weight:800;fill:var(--muted);letter-spacing:.12em;opacity:.8}
|
|
206
217
|
.slabname.sm{font-size:10.5px;letter-spacing:.1em;opacity:1}
|
|
207
|
-
`,$
|
|
218
|
+
`,$p=`.tunnel polygon{fill:hsl(205 85% 55% / .17);stroke:hsl(205 75% 45% / .8);stroke-width:1.3;stroke-linejoin:round}
|
|
208
219
|
.tunnel .top{fill:hsl(205 85% 65% / .22)}
|
|
209
220
|
.tunnel .rib{fill:none;stroke:hsl(205 75% 45% / .5);stroke-width:1}
|
|
210
221
|
.tunname{font-size:12px;font-weight:800;letter-spacing:.14em;fill:var(--tunnel-text);paint-order:stroke;stroke:var(--surface);stroke-width:3px;stroke-linejoin:round}
|
|
211
222
|
|
|
212
223
|
/* flows */
|
|
213
224
|
.flow{fill:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round}
|
|
214
|
-
`,
|
|
225
|
+
`,Hi=n=>Kl+Vl(n),Gl=`
|
|
215
226
|
/* step marks */
|
|
216
227
|
.xm circle{fill:var(--surface);stroke:var(--blocked);stroke-width:2.5}
|
|
217
228
|
.xm path{stroke:var(--blocked);stroke-width:3;stroke-linecap:round}
|
|
@@ -234,7 +245,7 @@ svg.all .badge{opacity:1}
|
|
|
234
245
|
svg.focus.all [data-hl]:not(.hl),svg.focus.all.dim-all [data-dim]:not(.hl){opacity:.9}
|
|
235
246
|
svg [data-step]:not(.on),svg.all [data-step]{opacity:0!important;pointer-events:none}
|
|
236
247
|
.pre{opacity:0!important;pointer-events:none}
|
|
237
|
-
`,
|
|
248
|
+
`,ql=`
|
|
238
249
|
/* player */
|
|
239
250
|
.player{display:flex;align-items:flex-start;gap:10px 14px;padding:12px 16px;border-top:1px solid var(--line);flex-wrap:wrap}
|
|
240
251
|
.ctrls{display:flex;gap:6px;flex:none}
|
|
@@ -269,57 +280,57 @@ details.steps li code{font-size:11.5px}
|
|
|
269
280
|
.still .ctrls,.still .tools{display:none}
|
|
270
281
|
.tools{display:flex;gap:6px;flex:none;order:3;margin-left:auto}
|
|
271
282
|
.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)}`,
|
|
283
|
+
.pbtn.small[aria-pressed="true"]{color:var(--ink);border-color:var(--muted);background:var(--surface)}`,Ul=`
|
|
273
284
|
.grid{display:none;fill:none;stroke:var(--ink);stroke-width:.6;opacity:.16;pointer-events:none}
|
|
274
285
|
svg.show-grid .grid{display:inline}
|
|
275
286
|
svg.pre-assemble > g:not(.g-anim){opacity:0}
|
|
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":""}:
|
|
287
|
+
`,Yi=Gl+ql+Ul;var Hl=n=>({data:n,locate:()=>({line:0,col:0}),span:()=>{},diags:[]});function ku(n,e,t,s=Hl(n),r,o={},i=[]){let l=Xs(oi(e),n.roles,n.kinds),a=[],c=new Map;return n.scenes.forEach((f,u)=>{let d=`/scenes/${u}`;if(c.has(f.id)){let p=s.locate(d+"/id");i.push({severity:"error",message:`duplicate scene id "${f.id}"`,line:p.line,col:p.col,path:d+"/id"})}c.set(f.id,u);let h={...n.grid,...f.grid,...o.snap?{snap:o.snap}:{}},b=yi(f,d,s,l,t,n.roles,h.snap);i.push(...b.diags);let m=$i(f,d,b,s,new Set(Object.keys(l.kinds)),h.snap);i.push(...m.diags);let y=Ui(f,d,b,m.routes,s,l);i.push(...y.diags),i.push(...Mp(f,d,t,s));let N=or({scene:f,layout:b,routes:m.routes,steps:y,theme:l,id:f.id,gridStep:h.step??h.snap??1});for(let p of N.warnings){let g=s.locate(p.path);i.push({severity:"warning",message:p.message,line:g.line,col:g.col,path:p.path})}a.push({id:f.id,raw:f,layout:b,routes:m.routes,steps:y,rendered:N,grid:h,assemble:f.assemble??n.assemble??!1})}),i.sort((f,u)=>f.line-u.line||f.col-u.col),{ok:!i.some(f=>f.severity==="error"),diags:i,doc:n,theme:l,catalog:t,scenes:a,parsed:s,source:r}}function Mp(n,e,t,s){let r=[],o=(l,a)=>{let c=s.locate(l);r.push({severity:"warning",message:a,line:c.line,col:c.col,path:l})},i=(l,a)=>{l.nodes?.forEach((c,f)=>{let u=`${a}/nodes/${f}`;(c.deco??cn(t,c.asset).deco??[]).forEach((d,h)=>{typeof d=="object"&&d.icon&&!Ur(d.icon)&&o(c.deco?`${u}/deco/${h}/icon`:u,`node "${c.id}": no icon "${d.icon}" is registered here, so it is drawn as a placeholder`)}),c.face!==void 0&&!pi(c.face)&&o(`${u}/face`,`node "${c.id}": no screen face "${c.face}" is registered here, so it is drawn as a placeholder`)}),l.regions?.forEach((c,f)=>i(c,`${a}/regions/${f}`))};return i(n,e),r}function vu(n,e){let t=n/(wt*st),s=2*e/st;return[(t+s)/2,(s-t)/2]}function Su(n,e){let t=n.layout.byId.get(e);if(!t)return;let s=t.parent?[t.parent.box.x0,t.parent.box.y0]:[0,0];return[t.box.x0-s[0],t.box.y0-s[1]]}function $u(n){let e=[];for(let t of[n.x0,n.x1])for(let s of[n.y0,n.y1])for(let r of[n.z0,n.z1])e.push(Ce(t,s,r));return Ep(e)}function Mu(n){return[[n.x0,n.y0],[n.x1,n.y0],[n.x1,n.y1],[n.x0,n.y1]].map(([e,t])=>Ce(e,t,n.z0))}function Ep(n){let e=[...new Map(n.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 t=(o,i,l)=>(i[0]-o[0])*(l[1]-o[1])-(i[1]-o[1])*(l[0]-o[0]),s=[],r=[];for(let o of e){for(;s.length>=2&&t(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&&t(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 Eu=(n,e)=>e?.padding??ht(n,e?.kind)?.pad??0;function Tu(n,e,t,s,r){let o=f=>Math.round(f/t)*t,i=o(n[0]+e[0]),l=o(n[1]+e[1]),a={left:!1,right:!1,top:!1,bottom:!1};if(r){let f=Math.ceil(r.pad/t-1e-9)*t,u=Math.floor((r.w-r.pad-s[0])/t+1e-9)*t,d=Math.floor((r.d-r.pad-s[1])/t+1e-9)*t;i<f&&(i=f,a.left=!0),u>=f&&i>u&&(i=u,a.right=!0),l<f&&(l=f,a.top=!0),d>=f&&l>d&&(l=d,a.bottom=!0)}let c=f=>Math.round(f*1e3)/1e3;return{at:[c(i),c(l)],delta:[c(i-n[0]),c(l-n[1])],clamped:a}}function Wi(n,e){return e.some(s=>n.x0<s.x1-1e-6&&n.x1>s.x0+1e-6&&n.y0<s.y1-1e-6&&n.y1>s.y0+1e-6)}var Wl=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}),Jl={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}},Au=(n,e)=>an(n,Jl[e]);function Ji(n){let e=[],t=new Map,s=(a,c)=>{if(typeof c!="string"||!c){e.push(`${a} has no id`);return}let f=t.get(c);f?e.push(`duplicate id "${c}": a ${f} and a ${a} (cards and panels share one set of ids)`):t.set(c,a)};for(let a of n.cards)s("card",a.id),(!Array.isArray(a.cell)||a.cell.length!==2||!a.cell.every(c=>Number.isInteger(c)&&c>=0))&&e.push(`card "${a.id}": cell must be [column, row], whole numbers from 0`);for(let a of n.panels??[]){s("panel",a.id);let c=a.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 "${a.id}": cells must be [c0, r0, c1, r1] with c0 \u2264 c1 and r0 \u2264 r1`)}let r=new Map;for(let a of n.cards){let c=String(a.cell);r.has(c)?e.push(`cards "${r.get(c)}" and "${a.id}" are both at cell [${c}]`):r.set(c,a.id)}let o=(n.panels??[]).filter(a=>Array.isArray(a.cells)&&a.cells.length===4);for(let a=0;a<o.length;a++)for(let c=a+1;c<o.length;c++){let f=o[a].cells,u=o[c].cells;f[0]<=u[2]&&u[0]<=f[2]&&f[1]<=u[3]&&u[1]<=f[3]&&!Yl(f,u)&&!Yl(u,f)&&e.push(`panels "${o[a].id}" and "${o[c].id}" overlap without one holding the other`)}let i=new Set([...n.cards.map(a=>a.id),...o.map(a=>a.id)]),l=new Set(o.map(a=>a.id));return(n.links??[]).forEach((a,c)=>{let f=`link ${a.id?`"${a.id}"`:c}`;for(let u of["a","b"])i.has(a[u])||e.push(`${f}: ${u} "${a[u]}" is no card or panel`);for(let u of["aOn","bOn"])a[u]!==void 0&&!l.has(a[u])&&e.push(`${f}: ${u} "${a[u]}" is no panel`);a.id!==void 0&&s("link",a.id)}),e}var Yl=(n,e)=>n[0]>=e[0]&&n[2]<=e[2]&&n[1]>=e[1]&&n[3]<=e[3];function lo(n,e){let{W:t,H:s,GX:r,GY:o,PAD:i,TITLE:l,CH:a}=e,c=n.panels??[],f=F=>(F[2]-F[0]+1)*(F[3]-F[1]+1),u=(F,K)=>{let q=c[F].cells,Z=c[K].cells;return Yl(Z,q)?f(q)>f(Z)||F<K:!1},d=c.map((F,K)=>{let q=-1;return c.forEach((Z,ce)=>{ce!==K&&u(ce,K)&&(q<0||u(q,ce))&&(q=ce)}),q}),h=F=>d[F]<0?0:1+h(d[F]),b=(F,K)=>{let q=-1;c.forEach((ce,fe)=>{let W=ce.cells;F>=W[0]&&F<=W[2]&&K>=W[1]&&K<=W[3]&&(q<0||u(q,fe))&&(q=fe)});let Z=[];for(let ce=q;ce>=0;ce=d[ce])Z.unshift(ce);return Z},m=Math.max(1,...n.cards.map(F=>F.cell[0]+1),...c.map(F=>F.cells[2]+1)),y=Math.max(1,...n.cards.map(F=>F.cell[1]+1),...c.map(F=>F.cells[3]+1)),N=[];for(let F=0;F<m;F++){N.push([]);for(let K=0;K<y;K++)N[F].push(b(F,K))}let p=(F,K,q)=>{let Z=F.filter(fe=>!K.includes(fe)),ce=K.filter(fe=>!F.includes(fe));return!Z.length&&!ce.length?0:Z.length*(i+(q?l:0))+ce.length*i+a},g=new Array(m+1).fill(0),x=new Array(y+1).fill(0);for(let F=0;F<y;F++)for(let K=1;K<m;K++){let q=p(N[K-1][F],N[K][F],!1);q&&(g[K]=Math.max(g[K],q-r))}for(let F=0;F<m;F++)for(let K=1;K<y;K++){let q=p(N[F][K-1],N[F][K],!0);q&&(x[K]=Math.max(x[K],q-o))}let $=F=>{let K=F*(t+r);for(let q=1;q<=F;q++)K+=g[q];return K},T=F=>{let K=F*(s+o);for(let q=1;q<=F;q++)K+=x[q];return K},v=(F,K,q,Z)=>q===K?F(K):F(K)+(Z-K)*(F(q)-F(K))/(q-K),A=c.map(()=>new Set),L=(F,K)=>{for(let q=F;q>=0;q=d[q])A[q].add(K)};c.forEach((F,K)=>{L(K,F.cells[1]),L(K,F.cells[3])});for(let F of n.cards){let K=N[F.cell[0]][F.cell[1]];K.length&&L(K[K.length-1],F.cell[1])}let M=c.map(()=>new Map),P=(F,K)=>F.slice(F.indexOf(K)+1);for(let F of c.map((K,q)=>q).sort((K,q)=>h(K)-h(q)||K-q)){let K=c[F].cells,q=[...A[F]].sort((ce,fe)=>ce-fe),Z=d[F]>=0?M[d[F]].get(q[0]):T(q[0]);M[F].set(q[0],Z);for(let ce=1;ce<q.length;ce++){let fe=0;for(let W=K[0];W<=K[2];W++)fe=Math.max(fe,p(P(N[W][q[ce-1]],F),P(N[W][q[ce]],F),!0));Z+=s+Math.max(o,fe),M[F].set(q[ce],Z)}}let k=c.map(()=>new Set),O=(F,K)=>{for(let q=F;q>=0;q=d[q])k[q].add(K)};c.forEach((F,K)=>{O(K,F.cells[0]),O(K,F.cells[2])});for(let F of n.cards){let K=N[F.cell[0]][F.cell[1]];K.length&&O(K[K.length-1],F.cell[0])}let w=c.map(()=>new Map);for(let F of c.map((K,q)=>q).sort((K,q)=>h(K)-h(q)||K-q)){let K=c[F].cells,q=[...k[F]].sort((ce,fe)=>ce-fe);if(d[F]<0&&!d.includes(F)&&q.length===K[2]-K[0]+1){for(let ce of q)w[F].set(ce,v($,K[0],K[2],ce));continue}let Z=d[F]>=0?w[d[F]].get(q[0]):$(q[0]);w[F].set(q[0],Z);for(let ce=1;ce<q.length;ce++){let fe=0;for(let W=K[1];W<=K[3];W++)fe=Math.max(fe,p(P(N[q[ce-1]][W],F),P(N[q[ce]][W],F),!1));Z+=t+Math.max(r,fe),w[F].set(q[ce],Z)}}let R=(F,K)=>{let q=N[F][K],Z=q.length?q[q.length-1]:-1;return Z>=0?[w[Z].get(F),M[Z].get(K)]:[$(F),T(K)]},I=c.map((F,K)=>K).sort((F,K)=>h(K)-h(F)||F-K),G=new Array(c.length);for(let F of I){let K=c[F].cells,q=[],Z=[];for(let W of n.cards){let oe=N[W.cell[0]][W.cell[1]];oe[oe.length-1]===F&&(q.push(w[F].get(W.cell[0])),Z.push(M[F].get(W.cell[1])))}let ce=W=>W.cell[0]>=K[0]&&W.cell[0]<=K[2]&&W.cell[1]>=K[1]&&W.cell[1]<=K[3];for(let W of[K[1],K[3]])n.cards.some(oe=>oe.cell[1]===W&&ce(oe))||Z.push(M[F].get(W));for(let W of[K[0],K[2]])n.cards.some(oe=>oe.cell[0]===W&&ce(oe))||q.push(w[F].get(W));let fe={l:q.length?Math.min(...q):1/0,t:Z.length?Math.min(...Z):1/0,r:q.length?Math.max(...q)+t:-1/0,b:Z.length?Math.max(...Z)+s:-1/0};c.forEach((W,oe)=>{if(d[oe]!==F)return;let Me=G[oe];fe.l=Math.min(fe.l,Me.l),fe.t=Math.min(fe.t,Me.t),fe.r=Math.max(fe.r,Me.r),fe.b=Math.max(fe.b,Me.b)}),G[F]={l:fe.l-i,t:fe.t-i,r:fe.r+i,b:fe.b+i+l}}let X=n.cards.map(F=>R(F.cell[0],F.cell[1])),U=n.cards.map(F=>{let K=N[F.cell[0]][F.cell[1]];return K.length?K[K.length-1]:-1}),B=(F,K)=>{for(let q=F;q>=0;q=d[q])if(q===K)return!0;return!1},H=(F,K)=>{n.cards.forEach((q,Z)=>{U[Z]>=0&&B(U[Z],F)&&(X[Z]=[X[Z][0]+K,X[Z][1]])}),c.forEach((q,Z)=>{B(Z,F)&&(G[Z]={...G[Z],l:G[Z].l+K,r:G[Z].r+K})})},Y=F=>{let K=[],q=[],Z=[],ce=[];n.cards.forEach((C,V)=>{U[V]===F&&(K.push(X[V][0]),Z.push(X[V][0]+t),q.push(X[V][1]),ce.push(X[V][1]+s))}),c.forEach((C,V)=>{d[V]===F&&(K.push(G[V].l),Z.push(G[V].r),q.push(G[V].t),ce.push(G[V].b))});let fe=G[F],W=Math.min(...K,fe.l+i),oe=Math.max(...Z,fe.r-i),Me=Math.min(...q,fe.t+i),Le=Math.max(...ce,fe.b-i-l);G[F]={l:W-i,t:Me-i,r:oe+i,b:Le+i+l}};for(let F of I)if(d[F]<0&&!d.includes(F))Y(F);else{let q=[];n.cards.forEach((oe,Me)=>{U[Me]===F&&q.push({l:X[Me][0],r:X[Me][0]+t,t:X[Me][1],b:X[Me][1]+s,card:Me})}),c.forEach((oe,Me)=>{d[Me]===F&&q.push({...G[Me],panel:Me})}),q.sort((oe,Me)=>oe.l-Me.l||oe.t-Me.t);let Z=Math.min(...q.map(oe=>oe.l)),ce=[];for(let oe of q){let Me=Z;for(let C of ce)C.t<oe.b&&oe.t<C.b&&C.r<=oe.l+1e-6&&(Me=Math.max(Me,C.r+(C.card!==void 0&&oe.card!==void 0?r:a)));let Le=Me-oe.l;Le<-1e-6&&(oe.card!==void 0?X[oe.card]=[X[oe.card][0]+Le,X[oe.card][1]]:H(oe.panel,Le),oe.l+=Le,oe.r+=Le),ce.push(oe)}let fe=q.map(oe=>oe.l),W=q.map(oe=>oe.r);G[F]={...G[F],l:Math.min(...fe)-i,r:Math.max(...W)+i}}return{prect:G,parentIx:d,depthOf:h,pos:R,cardAt:F=>X[F]}}function dr(n,e,t={}){if(t.wrap){let{wrap:E,...j}=t;return dr(Tp(n,e,E.aspect,j),e,j)}let s=Ji(n);if(s.length)throw new Error(`the board has ${s.length} error${s.length>1?"s":""}:
|
|
277
288
|
${s.join(`
|
|
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=`
|
|
289
|
+
`)}`);let r={...Wl,...t},{W:o,H:i}=r,l=E=>Math.round(E*10)/10,a=[],c=n.panels??[],{prect:f,parentIx:u,depthOf:d,cardAt:h}=lo(n,r),b=c.map((E,j)=>{let _=f[j],le=e(E.label??"","title")+(E.sub?e(E.sub,"titleSub"):0);return{...E,rect:_,titleAt:[l(_.l+16),l(_.b-15)],depth:d(j),parent:u[j]>=0?c[u[j]].id:void 0,title:{l:_.l+10,r:_.l+22+le,t:_.b-30,b:_.b-6}}}),m=n.cards.map(E=>{let[j,_]=h(n.cards.indexOf(E));return{...E,rect:{l:j,t:_,r:j+o,b:_+i}}}),y=new Map;b.forEach(E=>y.set(E.id,E.rect)),m.forEach(E=>y.set(E.id,E.rect));let N=m.map(E=>E.rect),p=b.map(E=>E.rect),g=b.filter(E=>E.label).map(E=>E.title),x=(E,j)=>E.l>=j.l&&E.r<=j.r&&E.t>=j.t&&E.b<=j.b,$=(E,j,_,le)=>Math.min(E[0],j[0])<_.r+le&&Math.max(E[0],j[0])>_.l-le&&Math.min(E[1],j[1])<_.b+le&&Math.max(E[1],j[1])>_.t-le,T=(E,j)=>p.reduce((_,le)=>{if(E[0]===j[0]){let pe=Math.min(E[1],j[1]),Re=Math.max(E[1],j[1]);E[0]>le.l&&E[0]<le.r&&(_+=[le.t,le.b].filter(ie=>ie>pe+1&&ie<Re-1).length)}else{let pe=Math.min(E[0],j[0]),Re=Math.max(E[0],j[0]);E[1]>le.t&&E[1]<le.b&&(_+=[le.l,le.r].filter(ie=>ie>pe+1&&ie<Re-1).length)}return _},0),v=(E,j)=>p.some(_=>E[1]===j[1]?[_.t,_.b].some(le=>Math.abs(E[1]-le)<16&&Math.max(E[0],j[0])>_.l&&Math.min(E[0],j[0])<_.r):[_.l,_.r].some(le=>Math.abs(E[0]-le)<16&&Math.max(E[1],j[1])>_.t&&Math.min(E[1],j[1])<_.b)),A=(E,j,_,le)=>p.filter(pe=>pe!==_&&pe!==le&&!x(_,pe)&&!x(le,pe)&&$(E,j,{l:pe.l+3,r:pe.r-3,t:pe.t+3,b:pe.b-3},0)).length,L=[],M=new Map,P=new Map,k=(E,j)=>{L.push([E,j]);let[_,le]=E[1]===j[1]?[M,E[1]]:E[0]===j[0]?[P,E[0]]:[void 0,0];if(!_)return;let pe=Math.floor(le/6);(_.get(pe)??_.set(pe,[]).get(pe)).push([E,j])},O=(E,j)=>{let _=E[1]===j[1];if(!_&&E[0]!==j[0])return 0;let le=_?1:0,pe=_?0:1,Re=_?M:P,ie=Math.floor(E[le]/6),Pe=Math.min(E[pe],j[pe]),Se=Math.max(E[pe],j[pe]),xe=0;for(let Ie=ie-1;Ie<=ie+1;Ie++)for(let[ze,tt]of Re.get(Ie)??[])Math.abs(E[le]-ze[le])<6&&Math.min(Se,Math.max(ze[pe],tt[pe]))-Math.max(Pe,Math.min(ze[pe],tt[pe]))>0&&xe++;return xe},w=[...y.values()],R=Math.min(...w.map(E=>E.l)),I=Math.max(...w.map(E=>E.r)),G=Math.min(...w.map(E=>E.t)),X=Math.max(...w.map(E=>E.b)),U=(E,j)=>{let _=(E+j)/2;return[_,_-12,_+12,_-24,_+24]},B=(()=>{let E=[];return N.forEach(j=>N.forEach(_=>{_.t>j.b&&_.l<j.r+400&&_.r>j.l-400&&E.push(...U(j.b,_.t))})),E.push(G-22,G-34,X+22,X+34),[...new Set(E.map(Math.round))]})(),H=(()=>{let E=[];return N.forEach(j=>N.forEach(_=>{_.l>j.r&&E.push(...U(j.r,_.l))})),E.push(R-22,R-34,I+22,I+34),[...new Set(E.map(Math.round))]})(),Y=new Map,ee=new Map,F=E=>{let j=Y.get(E);return j||Y.set(E,j=N.filter(_=>E<_.b+6&&E>_.t-6)),j},K=E=>{let j=ee.get(E);return j||ee.set(E,j=N.filter(_=>E<_.r+6&&E>_.l-6)),j},q=r.crossPanel/r.overlap,Z=r.border/r.overlap,ce=r.nearEdge/r.overlap;function fe(E,j,_,le,pe=!0){let Re=0;for(let xe=1;xe<E.length;xe++)Re+=Math.abs(E[xe-1][0]-E[xe][0])+Math.abs(E[xe-1][1]-E[xe][1]);let ie=Re+r.bend*(E.length-2);if(ie>=le)return ie;let Pe=0,Se=0;for(let xe=1;xe<E.length;xe++){let Ie=E[xe-1],ze=E[xe];if(pe){if(ae(Ie,ze,j,_)||v(Ie,ze))return 1/0;continue}for(let tt of Ie[1]===ze[1]?F(Ie[1]):K(Ie[0]))tt!==j&&tt!==_&&$(Ie,ze,tt,6)&&Pe++;for(let tt of g)$(Ie,ze,tt,2)&&Pe++}for(let xe=1;xe<E.length;xe++){let Ie=E[xe-1],ze=E[xe];if(Se+=O(Ie,ze)+q*A(Ie,ze,j,_)+Z*T(Ie,ze),v(Ie,ze)&&(Se+=ce),ie+r.overlap*Se>=le)return ie+r.overlap*Se}return ie+r.overlap*Se+Pe*1e5}let W=E=>(E.l+E.r)/2,oe=E=>(E.t+E.b)/2,Me=[0,-22,22,-44,44],Le={bc:1/0},C=(E,j,_,le)=>Math.abs(E-_)+Math.abs(j-le),V=(E,j,_,le,pe,Re,ie,Pe)=>{let Se=0;return Se+=C(E,j,_,le),Se+=C(_,le,pe,Re),Se+=C(pe,Re,ie,Pe),Se+r.bend*2},te=(E,j,_,le,pe,Re,ie,Pe,Se,xe)=>{let Ie=0;return Ie+=C(E,j,_,le),Ie+=C(_,le,pe,Re),Ie+=C(pe,Re,ie,Pe),Ie+=C(ie,Pe,Se,xe),Ie+r.bend*3},ae=(E,j,_,le)=>{for(let pe of E[1]===j[1]?F(E[1]):K(E[0]))if(pe!==_&&pe!==le&&$(E,j,pe,6))return!0;for(let pe of g)if($(E,j,pe,2))return!0;return v(E,j)};function Te(E,j,_,le){let pe=Math.max(E.l,j.l),Re=Math.min(E.r,j.r);if(Re-pe>24)for(let Je of Me){let rt=(pe+Re)/2+Je;rt>pe+8&&rt<Re-8&&_(j.t>=E.b?[[rt,E.b],[rt,j.t]]:[[rt,E.t],[rt,j.b]])}let ie=Math.max(E.t,j.t),Pe=Math.min(E.b,j.b);if(Pe-ie>16)for(let Je of[0,-10,10]){let rt=(ie+Pe)/2+Je;_(j.l>=E.r?[[E.r,rt],[j.l,rt]]:[[E.l,rt],[j.r,rt]])}let Se=H.length,xe=B.length,Ie=new Uint8Array(Me.length*xe),ze=new Uint8Array(Me.length*xe),tt=new Uint8Array(Me.length*Se),Yn=new Uint8Array(Me.length*Se),ft=(Je,rt,bn,Et)=>le?(Je[rt]||(Je[rt]=ae(bn,Et,E,j)?2:1),Je[rt]===1):!0;Me.forEach((Je,rt)=>Me.forEach((bn,Et)=>{let vt=W(E)+Je,St=W(j)+bn,Tt=oe(E)+Je/3,ut=oe(j)+bn/3;B.forEach((Ve,yn)=>{let ot=Ve>E.b?E.b:Ve<E.t?E.t:null,Gt=Ve>j.b?j.b:Ve<j.t?j.t:null;ot!==null&&Gt!==null&&V(vt,ot,vt,Ve,St,Ve,St,Gt)<Le.bc&&ft(Ie,rt*xe+yn,[vt,ot],[vt,Ve])&&ft(ze,Et*xe+yn,[St,Ve],[St,Gt])&&_([[vt,ot],[vt,Ve],[St,Ve],[St,Gt]])}),H.forEach((Ve,yn)=>{let ot=Ve>E.r?E.r:Ve<E.l?E.l:null,Gt=Ve>j.r?j.r:Ve<j.l?j.l:null;ot!==null&&Gt!==null&&V(ot,Tt,Ve,Tt,Ve,ut,Gt,ut)<Le.bc&&ft(tt,rt*Se+yn,[ot,Tt],[Ve,Tt])&&ft(Yn,Et*Se+yn,[Ve,ut],[Gt,ut])&&_([[ot,Tt],[Ve,Tt],[Ve,ut],[Gt,ut]])}),Je===0&&bn===0&&H.forEach((Ve,yn)=>B.forEach((ot,Gt)=>{let D=Ve>E.r?E.r:Ve<E.l?E.l:null,se=ot>j.b?j.b:ot<j.t?j.t:null;D!==null&&se!==null&&te(D,Tt,Ve,Tt,Ve,ot,St,ot,St,se)<Le.bc&&ft(tt,rt*Se+yn,[D,Tt],[Ve,Tt])&&ft(ze,Et*xe+Gt,[St,ot],[St,se])&&_([[D,Tt],[Ve,Tt],[Ve,ot],[St,ot],[St,se]]);let he=ot>E.b?E.b:ot<E.t?E.t:null,be=Ve>j.r?j.r:Ve<j.l?j.l:null;he!==null&&be!==null&&te(vt,he,vt,ot,Ve,ot,Ve,ut,be,ut)<Le.bc&&ft(Ie,rt*xe+Gt,[vt,he],[vt,ot])&&ft(Yn,Et*Se+yn,[Ve,ut],[be,ut])&&_([[vt,he],[vt,ot],[Ve,ot],[Ve,ut],[be,ut]])}));let Fs=W(E)<j.l?j.l:W(E)>j.r?j.r:null,At=ut<E.t?E.t:ut>E.b?E.b:null;Fs!==null&&At!==null&&_([[vt,At],[vt,ut],[Fs,ut]]);let ys=oe(E)<j.t?j.t:oe(E)>j.b?j.b:null,Bs=St<E.l?E.l:St>E.r?E.r:null;ys!==null&&Bs!==null&&_([[Bs,Tt],[St,Tt],[St,ys]])}))}function ye(E,j,_,le){for(let pe of Me){let Re=W(E)+pe,ie=oe(E)+pe/3,Pe=[[[Re,E.t],[Re,j.t]],[[E.r,ie],[j.r,ie]],[[Re,E.b],[Re,j.b]],[[E.l,ie],[j.l,ie]]];for(let Se of Pe)le(_?[Se[1],Se[0]]:Se)}}let Ne=(E,j,_,le)=>{let pe=null;return Le.bc=1/0,E(Re=>{let ie=fe(Re,j,_,Le.bc,le);ie<Le.bc&&(Le.bc=ie,pe=Re)},le),pe},Oe=[],we=E=>p.some(j=>[j.l,j.r].some(_=>E.l<_+3&&E.r>_-3&&E.b>j.t&&E.t<j.b)||[j.t,j.b].some(_=>E.t<_+3&&E.b>_-3&&E.r>j.l&&E.l<j.r)),Fe=E=>L.filter(([j,_])=>$(j,_,E,1)).length,qe=E=>g.some(j=>E.l<j.r&&E.r>j.l&&E.t<j.b&&E.b>j.t),De=E=>N.filter(j=>E.l<j.r+3&&E.r>j.l-3&&E.t<j.b+3&&E.b>j.t-3).length,Qe=E=>Oe.filter(j=>E.l<j.r+4&&E.r>j.l-4&&E.t<j.b+2&&E.b>j.t-2).length,S=E=>50*me(E)+3*Fe(E)+(we(E)?1:0)+(qe(E)?5:0)+5*De(E)+5*Qe(E),z=E=>Fe(E)>0||we(E)||qe(E)||De(E)>0||Qe(E)>0,J=[];(n.links??[]).forEach((E,j)=>{let _=E.id??`link-${j}`,le=y.get(E.aOn??E.a),pe=y.get(E.bOn??E.b);if(le===pe){a.push(`link "${_}" joins "${E.aOn??E.a}" to itself: not drawn`),J.push({...E,id:_,points:[],routed:!1});return}let Re=x(le,pe)?Se=>ye(le,pe,!1,Se):x(pe,le)?Se=>ye(pe,le,!0,Se):(Se,xe)=>Te(le,pe,Se,xe),ie=Ne(Re,le,pe,!0),Pe=!0;if(ie||(ie=Ne(Re,le,pe,!1),Pe=!1,a.push(`link "${_}": no clear route; drawn the least bad way`)),!ie){J.push({...E,id:_,points:[],routed:!1});return}for(let Se=1;Se<ie.length;Se++)k(ie[Se-1],ie[Se]);J.push({...E,id:_,points:ie,routed:Pe})});let de=[];for(let E=0;E<L.length;E++)for(let j=E+1;j<L.length;j++){let[_,le]=L[E],[pe,Re]=L[j],ie=_[1]===le[1],Pe=pe[1]===Re[1];if(ie===Pe)continue;let[Se,xe]=ie?[[_,le],[pe,Re]]:[[pe,Re],[_,le]],Ie=xe[0][0],ze=Se[0][1];Ie>Math.min(Se[0][0],Se[1][0])&&Ie<Math.max(Se[0][0],Se[1][0])&&ze>Math.min(xe[0][1],xe[1][1])&&ze<Math.max(xe[0][1],xe[1][1])&&de.push([Ie,ze])}let me=E=>de.filter(([j,_])=>j>E.l-2&&j<E.r+2&&_>E.t-2&&_<E.b+2).length;for(let E of J){let j=E,_=E.points;if(!j.label||!_.length)continue;let le=[];for(let xe=1;xe<_.length;xe++)le.push([_[xe-1],_[xe]]);let pe=xe=>Math.abs(xe[0][0]-xe[1][0])+Math.abs(xe[0][1]-xe[1][1]);le.sort((xe,Ie)=>pe(Ie)-pe(xe));let Re=e(j.label,"label")+6,ie=null,Pe=null,Se=1/0;for(let[xe,Ie]of le){let ze=(xe[0]+Ie[0])/2,tt=(xe[1]+Ie[1])/2,Yn=xe[1]===Ie[1]?[0,-.3,.3,-.15,.15].flatMap(ft=>{let Je=ze+ft*Math.abs(xe[0]-Ie[0]);return[[Je,tt-6,"middle"],[Je,tt+15,"middle"]]}):[0,-.3,.3].flatMap(ft=>{let Je=tt+4+ft*Math.abs(xe[1]-Ie[1]);return[[ze+7,Je,"start"],[ze-7,Je,"end"],[ze+24,Je,"start"],[ze-24,Je,"end"]]});for(let[ft,Je,rt]of Yn){let bn=rt==="middle"?ft-Re/2:rt==="end"?ft-Re:ft,Et={l:bn,r:bn+Re,t:Je-11,b:Je+3};if(!z(Et)){ie=[ft,Je,rt,Et];break}let vt=S(Et);vt<Se&&(Se=vt,Pe=[ft,Je,rt,Et])}if(ie)break}if(!ie&&Pe&&(ie=Pe),!ie){let[xe,Ie]=le[0],ze=(xe[0]+Ie[0])/2,tt=(xe[1]+Ie[1])/2-6;ie=[ze,tt,"middle",{l:ze-Re/2,r:ze+Re/2,t:tt-11,b:tt+3}]}Oe.push(ie[3]),E.at={x:l(ie[0]),y:l(ie[1]),anchor:ie[2],box:ie[3],text:j.label}}let Q=[],ne=[];for(let E of[...w,...Oe,...b.map(j=>j.title)])Q.push(E.l,E.r),ne.push(E.t,E.b);for(let E of J)for(let j of E.points)Q.push(j[0]),ne.push(j[1]);let ge=r.margin,ke={l:Math.min(...Q)-ge,t:Math.min(...ne)-ge,r:Math.max(...Q)+ge,b:Math.max(...ne)+ge};return{cards:m,panels:b,links:J,bounds:ke,options:r,warnings:a}}function Ou(n,e,t){let s=o=>e>=o.l&&e<=o.r&&t>=o.t&&t<=o.b,r=n.cards.find(o=>s(o.rect));return r?r.id:[...n.panels].sort((o,i)=>i.depth-o.depth).find(o=>s(o.rect))?.id}function Tp(n,e,t,s={}){let r=l=>{let a=dr(l,e,s);return Math.max(a.bounds.r-a.bounds.l,(a.bounds.b-a.bounds.t)*t)},o=n,i=r(n);for(let l=0;l<12;l++){let a,c=i;for(let f of Ap(o)){if(Ji(f).length)continue;let u=r(f);u<c-.5&&(c=u,a=f)}if(!a)break;o=a,i=c}return o}function*Ap(n){let e=n.panels??[],t=(i,l)=>i[0]>=l[0]&&i[2]<=l[2]&&i[1]>=l[1]&&i[3]<=l[3],s=(i,l)=>i.every((a,c)=>a===l[c]),r=(i,l=-1)=>{let a=-1;return e.forEach((c,f)=>{f===l||!t(i,c.cells)||l>=0&&f>l&&s(c.cells,e[l].cells)||(a<0||t(c.cells,e[a].cells)&&(!s(c.cells,e[a].cells)||f>a))&&(a=f)}),a},o=i=>{let l=[];return e.forEach((a,c)=>{r(a.cells,c)===i&&l.push({range:[...a.cells],panel:c})}),n.cards.forEach((a,c)=>{let f=[a.cell[0],a.cell[1],a.cell[0],a.cell[1]];r(f)===i&&l.push({range:f,card:c})}),l};for(let i of[-1,...e.map((l,a)=>a)]){let l=o(i);if(i>=0&&!l.some(u=>u.panel!==void 0))continue;let a=u=>[u.range[1],u.range[3]],c=[];for(let u of[...l].sort((d,h)=>d.range[1]-h.range[1]||d.range[0]-h.range[0])){let d=c.find(h=>h.some(b=>a(b)[0]<=a(u)[1]&&a(u)[0]<=a(b)[1]));d?d.push(u):c.push([u])}let f=Math.max(...l.map(u=>u.range[3]));for(let u of c){u.sort((d,h)=>d.range[0]-h.range[0]);for(let d=1;d<u.length;d++){let h=u.slice(d),b=u[0].range[0],m=f+1,y=Math.min(...h.map(T=>T.range[1])),N=Math.max(...h.map(T=>T.range[3]))-y+1,p=n.cards.map(T=>({...T,cell:[...T.cell]})),g=e.map(T=>({...T,cells:[...T.cells]}));for(let T of p)T.cell[1]>f&&(T.cell[1]+=N);let x=new Set;for(let T=i;T>=0&&!x.has(T);T=r(e[T].cells,T))x.add(T);g.forEach((T,v)=>{T.cells[1]>f?(T.cells[1]+=N,T.cells[3]+=N):(x.has(v)||T.cells[1]<=f&&T.cells[3]>f)&&(T.cells[3]+=N)});let $=b;for(let T of h){let v=$-T.range[0],A=m+(T.range[1]-y)-T.range[1],L=M=>M[0]>=T.range[0]&&M[0]<=T.range[2]&&M[1]>=T.range[1]&&M[1]<=T.range[3];n.cards.forEach((M,P)=>{L([M.cell[0],M.cell[1]])&&(p[P].cell=[M.cell[0]+v,M.cell[1]+A])}),e.forEach((M,P)=>{t(M.cells,T.range)&&(g[P].cells=[M.cells[0]+v,M.cells[1]+A,M.cells[2]+v,M.cells[3]+A])}),$+=T.range[2]-T.range[0]+1}e.forEach((T,v)=>{let A=n.cards.map((L,M)=>t([L.cell[0],L.cell[1],L.cell[0],L.cell[1]],T.cells)?p[M].cell:void 0).filter(L=>!!L);A.length&&(g[v].cells=[Math.min(...A.map(L=>L[0])),Math.min(...A.map(L=>L[1])),Math.max(...A.map(L=>L[0])),Math.max(...A.map(L=>L[1]))])}),yield{cards:p,panels:g,links:n.links}}}}}function Xi(n,e=()=>!0){let t=n.layout.items.filter(v=>e(v.id)),s=n.layout.catalog,r=!n.layout.items.some(v=>v.type==="node"),o=v=>r?!v.children.some(A=>e(A.id)):v.type==="node"&&!v.children.some(A=>A.type==="node"&&e(A.id)),i=t.filter(o),l=v=>{let A=[];for(let L=v;L;L=L.parent)A.unshift(L);return A},a=new Map(i.map(v=>[v.id,l(v)])),c=(v,A)=>{let L=a.get(v.id),M=a.get(A.id),P=0;for(;P<L.length&&P<M.length&&L[P]===M[P];)P++;return[L[P].box,M[P].box]},f=1e-6,u=(v,A)=>{let[L,M]=c(v,A);return L.y1<=M.y0+f&&L.x0<M.x1-f&&M.x0<L.x1-f},d=(v,A)=>{let[L,M]=c(v,A);return L.x1<=M.x0+f&&L.y0<M.y1-f&&M.y0<L.y1-f},h=(v,A)=>{let L=new Map,M=[];for(let P of[...i].sort((k,O)=>A(k)-A(O))){let k=0;for(let O of M)L.get(O.id)+1>k&&v(O,P)&&(k=L.get(O.id)+1);L.set(P.id,k),M.push(P)}return L},b=h(u,v=>v.box.y0),m=h(d,v=>v.box.x0),y=Math.min(...i.map(v=>v.box.x1-v.box.x0))/2;for(let v of i)if(!v.parent)for(let A of i)A.parent&&A.box.x0<=v.box.x0+y&&m.set(v.id,Math.max(m.get(v.id),m.get(A.id)));let N=new Map;for(let v of i)N.set(v.id,[m.get(v.id),b.get(v.id)]);let p=new Map;for(let v of i){let A=N.get(v.id),L=p.get(String(A));if(L!==void 0&&L!==v.id){for(let[,M]of N)M[0]>A[0]&&M!==A&&M[0]++;A[0]++,p.clear();for(let M of i)p.set(String(N.get(M.id)),M.id)}else p.set(String(A),v.id)}let g=i.map(v=>{if(v.region){let M=v.region;return{id:v.id,label:M.label??v.id,sub:void 0,role:M.role??ht(s,M.kind)?.role??"grey",ghost:M.ghost||void 0,cell:N.get(v.id)}}let A=v.node,L=cn(s,A.asset);return{id:v.id,label:A.label??v.id,sub:A.sub,role:A.role??L.role,ghost:A.ghost||void 0,cell:N.get(v.id)}}),x=[];for(let v of t){if(o(v))continue;let A=[],L=w=>{for(let R of w.children){let I=N.get(R.id);I&&A.push(I),L(R)}};if(L(v),!A.length)continue;let M=A.map(w=>w[0]),P=A.map(w=>w[1]),k=v.type==="region"?v.region.label:v.node.label??v.id,O=v.type==="region"?v.region.role??ht(s,v.region.kind)?.role:v.node.role??cn(s,v.node.asset).role;x.push({id:v.id,label:k,sub:v.type==="node"?v.node.sub:void 0,role:O,cells:[Math.min(...M),Math.min(...P),Math.max(...M),Math.max(...P)]})}let $=new Set([...g.map(v=>v.id),...x.map(v=>v.id)]),T=[];for(let v of n.routes){if(!e(v.id))continue;let A=Zt(v.raw.from).id,L=Zt(v.raw.to).id;if(!$.has(A)||!$.has(L))continue;let M=typeof v.raw.label=="string"?v.raw.label:v.raw.label?.text;T.push({id:v.id,a:A,b:L,kind:v.kind,label:M})}return{cards:g,panels:x,links:T}}var ps={W:4,D:2,H:.9,GX:2,GY:2.4,PAD:.6,CH:2.2,PANEL_H:.3},Nu=`
|
|
279
290
|
.blk .card-name{font-size:13px;font-weight:600;fill:var(--ink)}
|
|
280
291
|
.blk .card-sub{font-size:10px;fill:var(--ink);opacity:.75}
|
|
281
292
|
.blk.ghost .card-name,.blk.ghost .card-sub{fill:var(--muted)}
|
|
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}{${
|
|
284
|
-
`;continue}if(r.startsWith("@"))throw new Error(`the canvas's CSS has an at-rule it can't scope: ${r}`);s+=`${
|
|
285
|
-
`}return s}var
|
|
286
|
-
<button class="pbtn small" type="button" data-a="grid" aria-pressed="${
|
|
293
|
+
`;function Xl(n){return{name:"card",description:"A card: a slab with its name on its front face",size:[ps.W,ps.D,ps.H],role:"grey",draw(e,t,s){let r=n(s.id),o=e.blockFaces(t);if(!r)return o;let i=t.z1-t.z0;return o+=e.faceText(t.x0+.2,t.y1,t.z0+(r.sub?i*.52:i*.34),r.label,"card-name",lt.lbl,"left","start"),r.sub&&(o+=e.faceText(t.x0+.2,t.y1,t.z0+i*.14,r.sub,"card-sub",lt.sub,"left","start")),o}}}function Ru(n){let e=new Map(n.cards.map(t=>[t.id,{label:t.label,sub:t.sub}]));return{regions:{panel:{shape:"slab",pad:ps.PAD,z:[ps.PANEL_H,0],floor:!0,role:"grey",labelStyle:"floor"}},nodes:{card:Xl(t=>e.get(t))},defaultNode:"card"}}function Pu(n,e={}){let t=ps,{prect:s,parentIx:r,cardAt:o}=lo(n,{W:t.W,H:t.D,GX:t.GX,GY:t.GY,PAD:t.PAD,TITLE:0,CH:t.CH}),i=n.panels??[],l=b=>Math.round(b*1e3)/1e3,a=b=>(b.cells[2]-b.cells[0]+1)*(b.cells[3]-b.cells[1]+1),c=b=>{let m=-1;return i.forEach((y,N)=>{let p=y.cells;b.cell[0]>=p[0]&&b.cell[0]<=p[2]&&b.cell[1]>=p[1]&&b.cell[1]<=p[3]&&(m<0||a(y)<=a(i[m]))&&(m=N)}),m},f=i.map((b,m)=>{let y=s[m],N=r[m]>=0?s[r[m]]:{l:0,t:0};return{id:b.id,kind:"panel",label:b.label,role:b.role,at:[l(y.l-N.l),l(y.t-N.t)],size:[l(y.r-y.l),l(y.b-y.t)],regions:[],nodes:[]}}),u=[],d=[];f.forEach((b,m)=>r[m]>=0?f[r[m]].regions.push(b):u.push(b));for(let b of n.cards){let[m,y]=o(n.cards.indexOf(b)),N=c(b),p=N>=0?s[N]:{l:0,t:0},g={id:b.id,asset:"card",role:b.role,ghost:b.ghost||void 0,at:[l(m-p.l),l(y-p.t)],size:[t.W,t.D,t.H]};(N>=0?f[N].nodes:d).push(g)}for(let b of f)b.regions.length||delete b.regions,b.nodes.length||delete b.nodes;let h=(n.links??[]).map((b,m)=>({id:b.id??`link-${m}`,from:b.aOn??b.a,to:b.bOn??b.b,kind:b.kind,label:b.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:h}]}}var Md={};va(Md,{APPEARS:()=>Bu,BASE_FIELDS:()=>dc,BINS:()=>Qu,BIN_MS:()=>hn,CARD:()=>pt,DUAL_VIEW_CSS:()=>$d,IDLES:()=>ju,MAX_ZOOM:()=>Zi,MIN_ZOOM:()=>Qi,P3:()=>Ye,PLAY_CSS:()=>Ju,SEGMENT_NAME:()=>oa,SEVERITIES:()=>Wt,TIMELINE_VERSION:()=>Xu,activityOf:()=>yc,attr:()=>Cn,binNext:()=>ua,binStart:()=>Rs,buildLayer:()=>ho,cardMotion:()=>Du,clamp:()=>ns,cls:()=>zu,crumbs:()=>hr,dualView:()=>kd,ease:()=>po,escapeName:()=>la,extent:()=>ea,findGaps:()=>da,fitWithOverlay:()=>Ku,flatCss:()=>gd,flatSvg:()=>ya,formatScope:()=>Zu,gapKey:()=>Cs,gapLabel:()=>Ps,h:()=>re,hasSegment:()=>nd,highlights:()=>uo,isZone:()=>od,isoVars:()=>Vu,join:()=>ed,kindOf:()=>mr,legend:()=>fc,levelOf:()=>Ct,markConnectors:()=>ka,md:()=>nn,measureIn:()=>xa,memorySource:()=>fd,modeFor:()=>bc,morphSvgs:()=>wd,mountPlayer:()=>Wu,mountTimeline:()=>pd,n:()=>tc,nameOf:()=>pr,node:()=>_u,offsetAt:()=>Dt,overlayPaint:()=>Lu,pageClock:()=>uc,parentOf:()=>td,prefixAt:()=>ts,prune:()=>sc,pts:()=>co,rangeOf:()=>fo,readTime:()=>mc,rectOf:()=>bd,renderPage:()=>qu,rewrite:()=>nc,scope:()=>oc,scopePattern:()=>ia,scopeRules:()=>aa,scopeSelector:()=>rc,searchFor:()=>gr,severities:()=>sd,stepData:()=>cc,storedMode:()=>vd,ticks:()=>ma,timeScale:()=>br,toCSV:()=>ha,toJSON:()=>pa,transport:()=>na,unite:()=>ta,viewToggle:()=>Sd,viewport:()=>Iu,within:()=>Jt});function Op(n,e,t){let r=(l,a,c,f,u)=>Math.min((l-48)/(c-a),...f===void 0||u===void 0?[]:[[u-f,12],[u-a,30],[c-f,30]].map(([d,h])=>d>0?(l-h)/d:1/0)),o=Math.min(Zi,Math.max(Qi,Math.min(r(n.w,e.x,e.x+e.w,t?.x,t&&t.x+t.w),r(n.h,e.y,e.y+e.h,t?.y,t&&t.y+t.h)))),i=(l,a,c,f,u)=>{let d=(a+c)/2;if(f===void 0||u===void 0)return d;let h=u-(l/2-6)/o,b=f+(l/2-6)/o;return h>b?(h+b)/2:Math.max(h,Math.min(b,d))};return{k:o,cx:i(n.w,e.x,e.x+e.w,t?.x,t&&t.x+t.w),cy:i(n.h,e.y,e.y+e.h,t?.y,t&&t.y+t.h)}}var Qi=.1,Zi=8;function Iu(n,e){let t,s,r=!1,o=0,i=0,l=0,a=0,c=0,f=!1,u=()=>{let v=n.getBoundingClientRect();return{w:Math.max(1,v.width),h:Math.max(1,v.height)}},d=(v=t)=>{let A=u();return Math.min(A.w/v.w,A.h/v.h)},h=v=>{o++;try{v()}finally{o--}};function b(){let v=e.svg();if(!v||!t)return;o||(r=!0);let A=u(),L=d(),M=A.w/L,P=A.h/L;t={x:t.x+(t.w-M)/2,y:t.y+(t.h-P)/2,w:M,h:P},v.setAttribute("viewBox",`${t.x.toFixed(2)} ${t.y.toFixed(2)} ${t.w.toFixed(2)} ${t.h.toFixed(2)}`),i=L,e.onApply(L),l&&Math.abs(L/l-1)>.02&&(cancelAnimationFrame(a),a=requestAnimationFrame(()=>{a=0,e.onRezoom()}))}let m=(v,A)=>{let L=n.getBoundingClientRect(),M=d();return{x:t.x+(v-L.left)/M,y:t.y+(A-L.top)/M}};function y(v,A,L){if(!t)return;let M=d(),P=Math.min(Zi,Math.max(Qi,M*v)),k=n.getBoundingClientRect(),O=A??k.left+k.width/2,w=L??k.top+k.height/2,R=m(O,w),I=u();t={x:R.x-(O-k.left)/P,y:R.y-(w-k.top)/P,w:I.w/P,h:I.h/P},b()}function N(v=s,A){if(!v)return;let L=u(),{k:M,cx:P,cy:k}=Op(L,v,A),O={x:P-L.w/M/2,y:k-L.h/M/2,w:L.w/M,h:L.h/M};if(t&&Math.abs(O.w/t.w-1)<.001&&Math.abs(O.h/t.h-1)<.001&&Math.abs(O.x-t.x)<O.w*.001&&Math.abs(O.y-t.y)<O.h*.001){b();return}t=O,b()}function p(){for(let v=0,A="";v<4;v++){let L=e.itemsBox()??s;if(!L)return;let M=[L.x,L.y,L.w,L.h].map(k=>Math.round(k)).join();if(M===A)break;A=M;let P=Math.max(24,Math.min(L.w,L.h)*.06);if(h(()=>N({x:L.x-P,y:L.y-P,w:L.w+P*2,h:L.h+P*2},e.alsoBox?.())),!e.marksShowing()||!l||Math.abs(d()/l-1)<=.02)break;cancelAnimationFrame(a),a=0,e.onRezoom()}r=!1}function g(){if(r||!e.svg()||!t)return;let v=n.getBoundingClientRect();v.width<2||v.height<2||p()}function x(){if(!t)return;let v=d();y(1/v)}function $(){return new Promise(v=>{let A=0,L=i,M=()=>{if(f){v();return}let P=!!(a||c)||i!==L;L=i,A=P?0:A+1,A>=2?v():requestAnimationFrame(M)};requestAnimationFrame(M)})}let T=new ResizeObserver(()=>{if(!(!t||f)){if(r&&i){let v=u(),A=t.x+t.w/2,L=t.y+t.h/2;t={x:A-v.w/i/2,y:L-v.h/i/2,w:v.w/i,h:v.h/i}}r||(cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=0,f||g()})),h(b)}});return T.observe(n),{get view(){return t},set view(v){t=v},get full(){return s},set full(v){s=v},get moved(){return r},get zoom(){return i},painted(v){l=v},size:u,scale:d,quietly:h,applyView:b,toSvg:m,zoomAt:y,fit:N,fitItems:p,autoFit:g,actual:x,settled:$,dispose(){cancelAnimationFrame(c),cancelAnimationFrame(a),T.disconnect(),f=!0}}}var bt="http://www.w3.org/2000/svg",pt={half:2.4,h:3.2,t:.25,above:1.4,lift:3.8,fan:.32,gap:.3},Ye=(n,e,t)=>[(n-e)*wt*st,(n+e)*.5*st-t*st],co=n=>n.map(([e,t])=>`${e.toFixed(1)},${t.toFixed(1)}`).join(" ");function Lu(n,e){function t(o,i,l){let a=n.k(),c=(u,d,h,b,m="")=>{let y=o.createElementNS(bt,"g");y.setAttribute("class",`live-badge ${h.cls} ${m}`.trim());let N=8/a,p=o.createElementNS(bt,"circle");if(p.setAttribute("cx",String(u)),p.setAttribute("cy",String(d)),p.setAttribute("r",String(N)),y.append(p),"g"in h){let x=o.createElementNS(bt,"text");x.setAttribute("x",String(u)),x.setAttribute("y",String(d)),x.style.fontSize=`${(10/a).toFixed(2)}px`,x.textContent=h.g,y.append(x)}else{let x=o.createElementNS(bt,"use");x.setAttribute("href",n.iconHref(h.icon));let $=11/a;x.setAttribute("x",String(u-$/2)),x.setAttribute("y",String(d-$/2)),x.setAttribute("width",String($)),x.setAttribute("height",String($)),y.append(x)}let g=o.createElementNS(bt,"title");g.textContent=b,y.append(g),i(y)},f=(u,d)=>{for(let h of n.outlinesFor(u)){if(h.kind!=="poly")continue;let b=o.createElementNS(bt,"polygon");b.setAttribute("class",d),b.setAttribute("points",h.points.map(([m,y])=>`${m.toFixed(1)},${y.toFixed(1)}`).join(" ")),i(b)}};for(let u of l){let d=n.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 h=o.createElementNS(bt,"title");h.textContent=u.title;let b=o.createElementNS(bt,"rect");b.setAttribute("class","live-hit"),b.setAttribute("x",String(d.x)),b.setAttribute("y",String(d.y)),b.setAttribute("width",String(d.w)),b.setAttribute("height",String(d.h)),b.append(h),i(b)}if((u.beside??[]).forEach((h,b)=>c(d.x+18*(b+1)/a,d.y,h.glyph,h.title)),u.dot&&c(d.x,d.y+d.h,u.dot.glyph,u.dot.title),u.tag){let h=o.createElementNS(bt,"text");h.setAttribute("class",`live-life ${u.tag.cls}`),h.setAttribute("x",String(d.x+d.w)),h.setAttribute("y",String(d.y+d.h)),h.style.fontSize=`${(9/a).toFixed(2)}px`,h.textContent=u.tag.text,i(h)}}}}function s(o,i,l){for(let a of l){let c=o.createElementNS(bt,"g");c.setAttribute("class",`live-extra${a.cls}`);for(let[g,x]of a.data)c.setAttribute(g,x);let{x:f,y:u,w:d,hgt:h,k:b}=a.rect,m=o.createElementNS(bt,"rect");m.setAttribute("x",String(f)),m.setAttribute("y",String(u)),m.setAttribute("width",String(d)),m.setAttribute("height",String(h)),m.setAttribute("rx",String(6/b));let y=o.createElementNS(bt,"text");y.setAttribute("x",String(f+8/b)),y.setAttribute("y",String(u+13/b)),y.style.fontSize=`${(11/b).toFixed(2)}px`,y.textContent=a.line1;let N=o.createElementNS(bt,"text");N.setAttribute("class","sub"),N.setAttribute("x",String(f+8/b)),N.setAttribute("y",String(u+27/b)),N.style.fontSize=`${(9/b).toFixed(2)}px`,N.textContent=a.line2;let p=o.createElementNS(bt,"title");p.textContent=a.title,c.append(m,y,N,p),i(c)}}function r(o,i,l){let a=[];for(let c of l){let f=c.over,u=(f.x0+f.x1)/2,d=(f.y0+f.y1)/2,h=0,b={x0:0,y0:0,x1:0,y1:0};for(let B=0;B<6;B++){let H=f.z1+pt.above+h,Y=H+pt.h,ee=[Ye(u-pt.half,d+pt.t,H),Ye(u+pt.half,d+pt.t,H),Ye(u+pt.half,d-pt.t,Y),Ye(u-pt.half,d+pt.t,Y)];if(b={x0:Math.min(...ee.map(F=>F[0])),y0:Math.min(...ee.map(F=>F[1])),x1:Math.max(...ee.map(F=>F[0])),y1:Math.max(...ee.map(F=>F[1]))},!Wi(b,a))break;h+=pt.lift}a.push(b);let m=f.z1+pt.above+h,y=m+pt.h,N=u-pt.half,p=u+pt.half,g=d+pt.t,x=d-pt.t,$=o.createElementNS(bt,"g");$.setAttribute("class",`${e}-card${c.cls}`);for(let[B,H]of c.data)$.setAttribute(B,H);let[T,v]=Ye(u,d,f.z1+.15),A=`${T.toFixed(1)}px ${v.toFixed(1)}px`;$.style.transformOrigin=A;let L=o.createElementNS(bt,"g");L.setAttribute("class",`${e}-float`),L.style.transformOrigin=A;let M=[];for(let B=Math.min(c.count-1,3);B>=1;B--){let H=B*pt.fan,Y=x-(B-1)*(2*pt.t+pt.gap)-pt.gap,ee=Y-2*pt.t,F=N+H,K=p+H,q=m+H,Z=y+H,ce=(fe,W)=>{let oe=o.createElementNS(bt,"polygon");oe.setAttribute("class",`${e}-face stacked ${fe}`),oe.setAttribute("points",co(W)),L.append(oe)};ce("s-top",[Ye(F,ee,Z),Ye(K,ee,Z),Ye(K,Y,Z),Ye(F,Y,Z)]),ce("s-side",[Ye(K,ee,q),Ye(K,Y,q),Ye(K,Y,Z),Ye(K,ee,Z)]),ce("s-front",[Ye(F,Y,q),Ye(K,Y,q),Ye(K,Y,Z),Ye(F,Y,Z)]),M.push({x0:F,x1:K,y0:ee,y1:Y,z0:q,z1:Z})}let P=o.createElementNS(bt,"polygon");P.setAttribute("class",`${e}-tail`),P.setAttribute("points",co([Ye(u-.5,g,m+.05),Ye(u+.5,g,m+.05),Ye(u,d,f.z1+.15)]));let k=(B,H)=>{let Y=o.createElementNS(bt,"polygon");return Y.setAttribute("class",B),Y.setAttribute("points",co(H)),Y},O=k(`${e}-face front`,[Ye(N,g,m),Ye(p,g,m),Ye(p,g,y),Ye(N,g,y)]);L.append(P,k(`${e}-face top`,[Ye(N,x,y),Ye(p,x,y),Ye(p,g,y),Ye(N,g,y)]),k(`${e}-face side`,[Ye(p,x,m),Ye(p,g,m),Ye(p,g,y),Ye(p,x,y)]),O);let[w,R]=Ye(N,g,y),I=40,G=o.createElementNS(bt,"g");G.setAttribute("transform",`matrix(${(wt*st/I).toFixed(4)} ${(.5*st/I).toFixed(4)} 0 ${(st/I).toFixed(4)} ${w.toFixed(1)} ${R.toFixed(1)})`);let X=(B,H,Y,ee)=>{let F=o.createElementNS(bt,"text");return F.setAttribute("class",B),F.setAttribute("x",String(H)),F.setAttribute("y",String(Y)),F.textContent=ee,F};if(G.append(X(`${e}-mark`,34,98,c.mark),X(`${e}-who`,70,52,c.who),X(`${e}-age`,70,82,c.age)),c.line!==void 0&&G.append(X(`${e}-q`,12,118,c.line)),c.count>1){let B=o.createElementNS(bt,"circle");B.setAttribute("class",`${e}-count-bg`),B.setAttribute("cx","178"),B.setAttribute("cy","14"),B.setAttribute("r","15"),G.append(B,X(`${e}-count`,178,14,String(c.count)))}L.append(G);let U=o.createElementNS(bt,"title");U.textContent=c.title,$.append(L,U),n.onCard?.($,{cx:u,cy:d,tipZ:f.z1+.15,card:{x0:N,x1:p,y0:x,y1:g,z0:m,z1:y},panes:M.reverse()}),i($)}}return{paintMarks:t,paintGhosts:s,paintCards:r}}var Bu=[["scale","Scale"],["spin","Spin"],["dissolve","Dissolve"],["inflate","Inflate"]],ju=[["none","None"],["jiggle","Jiggle"],["pirouette","Pirouette"],["glow","Glow"],["breathe","Breathe"]];function Np(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return(e>>>0)%1e3/1e3}var Ql=n=>n<0?0:n>1?1:1-Math.pow(1-n,3),Fu=n=>n<0?0:n>1?1:n*n*n,Zl=Math.PI*2,ec={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}},pn={windup:220,turn:980,land:260};function Du(n,e,{prefix:t,key:s,alt:r}){let o={...e},i=1,l=new Map,a=new WeakSet,c=0,f=0,u=new WeakMap,d=new WeakMap;function h(P){c=0;for(let[k,O]of l){if(!k.isConnected){l.delete(k);continue}let w;if(O.repeat){if(w=(P+(O.offset??0))%O.repeat/O.dur,w>1){a.has(k)&&(n.restore(k),a.delete(k),k.style.removeProperty("transform"));continue}}else if(w=(P-O.start)/O.dur,w>=1){b(k,O);continue}let R=O.frame(Math.max(0,w));n.spin(k,R.theta,R.lift),a.add(k),d.set(k,R),R.scale!==1?k.style.transform=`scale(${R.scale.toFixed(4)})`:k.style.removeProperty("transform"),f++}l.size&&(c=requestAnimationFrame(h))}function b(P,k){l.delete(P),a.has(P)&&(n.restore(P),a.delete(P)),P.style.removeProperty("transform"),k.done?.()}function m(P){let k=l.get(P.card);k&&b(P.card,k),l.set(P.card,P),c||(c=requestAnimationFrame(h))}let y=8,N=0,p=P=>(N++,P.finally(()=>{N--}));function g(P){return!o.enabled||N>=y?Promise.resolve():p($(P))}function x(P){return!o.enabled||N>=y?Promise.resolve():p(T(P))}function $(P){let k=ec.appear[o.appear]/i;if(o.appear==="spin")return new Promise(R=>m({card:P,start:performance.now(),dur:k,frame:I=>({theta:(1-Ql(I))*Zl,lift:0,scale:Math.max(.001,Ql(I))}),done:R}));let O=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(O,{duration:k,easing:o.appear==="inflate"?"linear":"ease-out"}).finished.then(()=>{},()=>{})}function T(P){let k=ec.disappear[o.appear]/i;if(o.appear==="spin")return new Promise(R=>m({card:P,start:performance.now(),dur:k,frame:I=>({theta:Fu(I)*Zl,lift:0,scale:Math.max(.001,1-Fu(I))}),done:()=>{P.style.transform="scale(0)",R()}}));let O=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(O,{duration:k,easing:"ease-in",fill:"forwards"}).finished.then(()=>{},()=>{})}function v(P){u.get(P)?.cancel(),u.delete(P);let k=l.get(P);k?.repeat&&b(P,k)}function A(P,k){if(v(P),!o.enabled||o.idle==="none"||P.classList.contains("still"))return;let O=P.getAttribute(s)??P.getAttribute(r)??"",w=(k??ec.period[o.idle])/i,R=Np(O)*w;if(o.idle==="pirouette"){let B=(pn.windup+pn.turn+pn.land)/i,H=pn.windup/(pn.windup+pn.turn+pn.land),Y=(pn.windup+pn.turn)/(pn.windup+pn.turn+pn.land);m({card:P,start:0,dur:B,repeat:w,offset:R,frame:ee=>{if(ee<H)return{theta:-.35*Math.sin(ee/H*Math.PI/2),lift:0,scale:1};if(ee<Y){let K=(ee-H)/(Y-H);return{theta:-.35*(1-K)+Ql(K)*Zl,lift:.9*Math.sin(K*Math.PI),scale:1}}let F=(ee-Y)/(1-Y);return{theta:0,lift:0,scale:1-.04*Math.sin(F*Math.PI)}}});return}let I=P.querySelector(`.${t}-float`)??P,G=n.amber(),X=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 ${G})`},{filter:`drop-shadow(0 0 7px ${G})`},{filter:`drop-shadow(0 0 0px ${G})`}]:[{transform:"scale(1)"},{transform:"scale(1.035)"},{transform:"scale(1)"}],U=I.animate(X,{duration:w,iterations:1/0,easing:o.idle==="jiggle"?"linear":"ease-in-out"});U.startTime=(document.timeline.currentTime??0)-((document.timeline.currentTime??0)+R)%w,u.set(P,U)}function L(P,k,O,w,R=!1){R&&(w=!1);for(let[G,X]of k)!P.has(G)&&!R&&g(X),!u.has(X)&&!l.get(X)?.repeat&&A(X);if(!o.enabled||!w)return;let I=n.leavingLayer();if(I)for(let[G,X]of O){let U=P.get(G);!U||k.has(G)||(v(U),U.setAttribute("class",`${t}-leaving${X?" expired":""}`),U.removeAttribute(r),I.append(U),x(U).then(()=>U.remove()))}}function M(P){for(let[k,O]of[...l])b(k,O);c&&cancelAnimationFrame(c),c=0;for(let k of document.getAnimations())k.effect?.target?.closest?.(`.live-layer, .${t}-leaving-layer`)&&k.cancel();n.leavingLayer()?.replaceChildren()}return{get settings(){return{...o}},set(P,k){let O=o;if(o={...o,...P},(!o.enabled||O.idle!==o.idle||O.enabled!==o.enabled)&&(M(void 0),o.enabled))for(let w of k)A(w)},update:L,appear:g,disappear:x,startIdle:A,stopIdle:v,stopAll:M,async preview(P){o.enabled&&await Promise.all(P.map(async k=>{if(v(k),await g(k),o.idle!=="none"&&!k.classList.contains("still")){let O=o.idle==="pirouette"?1800:1400;A(k,O),await new Promise(w=>setTimeout(w,O*2.2/i)),v(k)}else await new Promise(O=>setTimeout(O,700/i));await x(k);for(let O of k.getAnimations())O.cancel();k.style.removeProperty("transform"),A(k)}))},get stats(){return{jobs:l.size,raf:!!c,frames:f,effects:N}},setSpeed(P){i=P},lastFrame:P=>d.get(P)}}var tc=n=>String(Math.round(n*100)/100),_u=(n,e={},...t)=>({name:n,attrs:Object.entries(e).map(([s,r])=>[s,typeof r=="number"?tc(r):r]),children:t});function nc(n,e){if(typeof n=="string")return n;let t=n.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,l)=>`url(${l}#${e}`);return(s==="href"||s==="xlink:href")&&o.startsWith("#")&&!o.startsWith(`#${e}`)&&(o=`#${e}${o.slice(1)}`),[s,o]});return{name:n.name,attrs:t,children:n.children.map(s=>nc(s,e))}}function sc(n,e){if(typeof n=="string")return n;if(!e(n))return{...n,children:n.children.map(t=>sc(t,e)).filter(t=>t!==void 0)}}var zu=n=>(n.attrs.find(e=>e[0]==="class")?.[1]??"").split(/\s+/),Cn=(n,e)=>n.attrs.find(t=>t[0]===e)?.[1];function ea(n){let e=[],t=[],s=i=>{if(typeof i=="string")return;let l=Cn(i,"transform");if(l&&/matrix/.test(l))return;let a=Cn(i,"points");if(a)for(let c of a.trim().split(/\s+/)){let[f,u]=c.split(",").map(Number);Number.isFinite(f)&&Number.isFinite(u)&&(e.push(f),t.push(u))}if(i.name==="rect"){let c=Number(Cn(i,"x")),f=Number(Cn(i,"y")),u=Number(Cn(i,"width")),d=Number(Cn(i,"height"));[c,f,u,d].every(Number.isFinite)&&(e.push(c,c+u),t.push(f,f+d))}if(i.name==="circle"){let c=Number(Cn(i,"cx")),f=Number(Cn(i,"cy")),u=Number(Cn(i,"r"));[c,f,u].every(Number.isFinite)&&(e.push(c-u,c+u),t.push(f-u,f+u))}i.children.forEach(s)};if(n.forEach(s),!e.length)return;let r=Math.min(...e),o=Math.min(...t);return{x:r,y:o,w:Math.max(...e)-r,h:Math.max(...t)-o}}var ta=(n,e)=>{if(!e)return n;let t=Math.min(n.x,e.x),s=Math.min(n.y,e.y);return{x:t,y:s,w:Math.max(n.x+n.w,e.x+e.w)-t,h:Math.max(n.y+n.h,e.y+e.h)-s}};function Ku(n,e,t){let s=l=>Math.min((e.width-e.pad*2)/l.w,(e.height-e.pad*2)/l.h),r=s(n),o=t(r),i=ta(n,ea(o));return r=s(i),o=t(r),i=ta(n,ea(o)),r=s(i),{k:r,box:i,live:o}}var Vu=n=>n.replace(/--([a-zA-Z][\w-]*)/g,"--iso-$1");function Rp(n){let e=[],t=0,s=n.replace(/\/\*[\s\S]*?\*\//g,"");for(;t<s.length;){let r=s.indexOf("{",t);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(t,r).trim(),s.slice(r+1,i-1)]),t=i}return e}function Pp(n){let e=[],t=0,s=0;for(let r=0;r<n.length;r++){let o=n[r];o==="("||o==="["?t++:o===")"||o==="]"?t--:o===","&&!t&&(e.push(n.slice(s,r).trim()),s=r+1)}return e.push(n.slice(s).trim()),e.filter(Boolean)}function rc(n,e,t){let s=/^:root((?:\[[^\]]*\]|:not\([^)]*\))*)(.*)$/.exec(n),r=t.replace(/^\./,"");if(s){let o=s[1],i=s[2].trim();return`${o?`.${r}${o} `:""}${e}${i?" "+i:""}`}if(/^(html|body|\*)\b/.test(n)||/^[a-z]+$/.test(n)&&!/^(svg|g|text|path|polygon|rect|circle|line)$/.test(n))throw new Error(`the canvas's CSS can't style the page: "${n}"`);return`${e} ${n}`}function oc(n,e,t){let s="";for(let[r,o]of Rp(n)){if(r.startsWith("@keyframes")){s+=`@keyframes iso-${r.slice(10).trim()}{${o}}
|
|
294
|
+
`;continue}if(r.startsWith("@media")||r.startsWith("@supports")){s+=`${r}{${oc(o,e,t)}}
|
|
295
|
+
`;continue}if(r.startsWith("@"))throw new Error(`the canvas's CSS has an at-rule it can't scope: ${r}`);s+=`${Pp(r).map(i=>rc(i,e,t)).join(",")}{${o.replace(/\banimation:\s*([a-z][\w-]*)/g,"animation:iso-$1")}}
|
|
296
|
+
`}return s}var ic=["<","script"].join("");function nn(n){return n?mt(n).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<b>$1</b>").replace(/(^|[^*])\*([^*\s][^*]*)\*/g,"$1<em>$2</em>").replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(e,t,s)=>/^(https?:|#|\.{0,2}\/)/.test(s.replace(/&/g,"&"))?`<a href="${s}">${t}</a>`:t):""}var ac=n=>(n??"").split(/\n\s*\n/).filter(Boolean).map(e=>`<p class="sec-sub">${nn(e.trim())}</p>`).join(""),Gu=(n,e)=>!!e.motion&&io(e,e.motion,{kinds:n.theme.kinds}).ok;function lc(n,e){return Gu(n,e)?io(e,e.motion,{kinds:n.theme.kinds}).beats.map(t=>({n:t.index+1,num:t.index+1,kind:"control",color:t.say?.color??Tn(n.theme,n.theme.kinds.control?.color??"control"),heading:t.say?.title??t.name,caption:t.say?.text??"",command:t.say?.code??"",phases:[],pulses:[],lit:[],duration:t.end-t.start})):e.steps.steps}function cc(n){return JSON.stringify({scenes:n.scenes.map(e=>{let t=Gu(n,e),s=lc(n,e),r=t?e.motion:e.steps.steps.length?Vi(e):void 0;return{id:e.id,loop:e.raw.loop??!0,dim:e.raw.dim??"flows",vis:e.steps.vis,steps:s.map(({focus:o,...i})=>({...i,caption:nn(i.caption)})),assemble:e.assemble,grid:!!e.grid.show,source:oo(e),...r?{doc:r}:{},...t?{own:t}:{}}})})}function fc(n,e){let t=n.theme,s=e.raw.legend;if(s===!1)return"";let r=Array.isArray(s)?s:e.steps.kindsUsed.filter(l=>e.routes.some(a=>a.kind===l)||e.steps.steps.some(a=>a.phases.some(c=>c.some(f=>f.kind===l)))),o=l=>`<span><i${l.box?' class="box"':""} style="${l.swatch}"></i>${l.label}</span>`,i=r.map(l=>{let a=ht(n.catalog,l)?.legend;if(a)return o(a);let c=t.kinds[l];return c?`<span><i style="${`border-color:${Tn(t,c.color)}${c.dash==="dashed"?";border-top-style:dashed":c.dash==="dotted"?";border-top-style:dotted":""}`}"></i>${nn(c.legend)}</span>`:""});if(!Array.isArray(s)){let l=new Set(e.layout.items.map(a=>a.region?.kind));for(let[a,c]of Object.entries(n.catalog.regions))c.legend?.auto&&l.has(a)&&i.push(o(c.legend))}return i.join("")}function Cp(n,e){let t=lc(n,e),s=`<div class="tools">
|
|
297
|
+
<button class="pbtn small" type="button" data-a="grid" aria-pressed="${e.grid.show?"true":"false"}" title="Show the floor grid">Grid</button>
|
|
287
298
|
<button class="pbtn small" type="button" data-a="assemble" title="Draw the diagram again, piece by piece">Assemble</button>
|
|
288
|
-
</div>`;if(!
|
|
299
|
+
</div>`;if(!t.length)return`<div class="player">${s}</div>`;let r=t[0];return`<div class="player">
|
|
289
300
|
<div class="ctrls">
|
|
290
301
|
<button class="pbtn icon" type="button" data-a="prev" aria-label="Previous step">\u2039</button>
|
|
291
302
|
<button class="pbtn primary" type="button" data-a="play" aria-label="Play">\u25B6 Play</button>
|
|
292
303
|
<button class="pbtn icon" type="button" data-a="next" aria-label="Next step">\u203A</button>
|
|
293
304
|
</div>
|
|
294
|
-
${
|
|
305
|
+
${s}
|
|
295
306
|
<div class="cap" aria-live="polite">
|
|
296
|
-
<div class="cap-h"><span class="num" style="background:${
|
|
297
|
-
<p class="cap-t">${
|
|
298
|
-
<pre class="cap-c">${
|
|
307
|
+
<div class="cap-h"><span class="num" style="background:${r.color}">${r.num}</span><span class="h">${mt(r.heading)}</span><span class="cnt">1 / ${t.length}</span></div>
|
|
308
|
+
<p class="cap-t">${nn(r.caption)}</p>
|
|
309
|
+
<pre class="cap-c">${mt(r.command)}</pre>
|
|
299
310
|
<div class="prog"><i></i></div>
|
|
300
311
|
</div>
|
|
301
312
|
<div class="dots"></div>
|
|
302
|
-
</div>`}function
|
|
303
|
-
<section class="scene" id="scene-${
|
|
304
|
-
<h2>${
|
|
305
|
-
${
|
|
313
|
+
</div>`}function Ip(n,e){let t=lc(n,e);return t.length?`<details class="steps"><summary>All ${t.length} steps as text</summary><ol>${t.map(s=>`<li value="${s.num}"><b>${mt(s.heading)}.</b> ${nn(s.caption)}${s.command?`<br><code>${mt(s.command)}</code>`:""}</li>`).join("")}</ol></details>`:""}function qu(n,e={}){let t=n.doc,s=t.title??t.scenes[0]?.title??"Diagram",r=(t.pills??[]).map(i=>`<span class="pill">${nn(i)}</span>`).join(""),o=n.scenes.map(i=>`
|
|
314
|
+
<section class="scene" id="scene-${mt(i.id)}">
|
|
315
|
+
<h2>${mt(i.raw.title)}</h2>
|
|
316
|
+
${ac(i.raw.caption)}
|
|
306
317
|
<div class="figure" tabindex="-1">
|
|
307
318
|
<div class="scroller">${i.grid.show?i.rendered.svg.replace("<svg ",'<svg class="show-grid" '):i.rendered.svg}</div>
|
|
308
|
-
${
|
|
309
|
-
<div class="legend">${
|
|
319
|
+
${Cp(n,i)}
|
|
320
|
+
<div class="legend">${fc(n,i)}</div>
|
|
310
321
|
</div>
|
|
311
|
-
${
|
|
312
|
-
${i.raw.after?`<div class="after">${
|
|
322
|
+
${Ip(n,i)}
|
|
323
|
+
${i.raw.after?`<div class="after">${ac(i.raw.after)}</div>`:""}
|
|
313
324
|
</section>`).join(`
|
|
314
325
|
`);return`<!doctype html>
|
|
315
326
|
<html lang="en">
|
|
316
327
|
<head>
|
|
317
328
|
<meta charset="utf-8">
|
|
318
329
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
319
|
-
<title>${
|
|
320
|
-
${
|
|
330
|
+
<title>${mt(s)}</title>
|
|
331
|
+
${t.lede?`<meta name="description" content="${mt(t.lede)}">`:""}
|
|
321
332
|
<style>
|
|
322
|
-
${
|
|
333
|
+
${ii(n.theme)}${Hi(n.catalog)}${Yi}
|
|
323
334
|
</style>
|
|
324
335
|
${e.extraHead??""}
|
|
325
336
|
</head>
|
|
@@ -327,17 +338,17 @@ ${e.extraHead??""}
|
|
|
327
338
|
<div class="wrap">
|
|
328
339
|
<header class="page">
|
|
329
340
|
<div>
|
|
330
|
-
<h1>${
|
|
331
|
-
${
|
|
341
|
+
<h1>${mt(s)}</h1>
|
|
342
|
+
${t.lede?`<p class="lede">${nn(t.lede)}</p>`:""}
|
|
332
343
|
</div>
|
|
333
344
|
<div class="pills">${r}<button class="theme" id="themeBtn" type="button">Theme</button></div>
|
|
334
345
|
</header>
|
|
335
346
|
${o}
|
|
336
|
-
${
|
|
337
|
-
${
|
|
347
|
+
${t.after?ac(t.after):""}
|
|
348
|
+
${t.footer?`<footer>${nn(t.footer)}</footer>`:""}
|
|
338
349
|
</div>
|
|
339
|
-
${
|
|
340
|
-
${
|
|
350
|
+
${ic} type="application/json" id="diagram-steps">${cc(n).replace(/</g,"\\u003c")}<\/script>
|
|
351
|
+
${ic}>
|
|
341
352
|
(function(){
|
|
342
353
|
var root=document.documentElement, m=/theme=(light|dark)/.exec(location.hash);
|
|
343
354
|
try{var t=localStorage.getItem('diagram-theme'); if(t) root.dataset.theme=t;}catch(e){}
|
|
@@ -349,14 +360,49 @@ ${La}>
|
|
|
349
360
|
});
|
|
350
361
|
})();
|
|
351
362
|
<\/script>
|
|
352
|
-
${e.runtime?`${
|
|
363
|
+
${e.runtime?`${ic}>${e.runtime}<\/script>`:""}
|
|
353
364
|
${e.extraBody??""}
|
|
354
365
|
</body>
|
|
355
366
|
</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,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
|
-
|
|
367
|
+
`}function uc(){let n=globalThis;return{now:()=>performance.now(),next(e){let t={},s=()=>{t.raf!==void 0&&n.cancelAnimationFrame?.(t.raf),clearTimeout(t.timer),e()};return t.raf=n.requestAnimationFrame?.(s),t.timer=setTimeout(s,t.raf===void 0?16:100),t},cancel(e){let t=e;t.raf!==void 0&&n.cancelAnimationFrame?.(t.raf),clearTimeout(t.timer)}}}var Lp=400;function na(n,e={}){let t=e.clock??uc(),s=n,r=0,o=g(e.rate??1),i=e.loop??!1,l=!1,a=!0,c=!1,f=(e.ambient??s.ambient)==="on",u=f?0:"off",d,h=0,b=s.beatAt(0),m=!1,y=0,N,p={};function g(R){if(!(Number.isFinite(R)&&R>0))throw new Error("rate is a number over 0");return R}let x=R=>Math.max(0,Math.min(s.duration,R));function $(R,...I){for(let G of[...p[R]??[]])G(...I)}let T=()=>a&&!c&&(l||f&&s.loops);function v(){T()?d===void 0&&(h=t.now(),d=t.next(M)):d!==void 0&&(t.cancel(d),d=void 0)}function A(R,I){let G=y;for(let X of s.beats)if(!(X.start<=R||X.start>I||X.index===b?.index)&&(b=X,m=!0,$("beat",X,"play"),y!==G))return!1;return!0}function L(R){if(!l){$("time",r,"ambient");return}let I=r,G=r+R,X=y;if(N!==void 0&&G>=N){if(r=N,!A(I,r))return;N=void 0,l=!1,$("time",r,"play"),y===X&&$("pause");return}if(G<s.duration){r=G,A(I,r)&&$("time",r,"play");return}if(i){if(!A(I,s.duration)||(r=G%s.duration,f&&(u=r),b=void 0,$("loop"),y!==X))return;let U=s.beatAt(0);if(U&&(b=U,$("beat",U,"play"),y!==X||!A(U.start,r)))return;$("time",r,"play");return}r=s.duration,A(I,r)&&(l=!1,$("time",r,"play"),y===X&&($("pause"),y===X&&$("end")))}function M(){d=void 0;let R=t.now(),I=Math.max(0,R-h)*o;h=R,f&&u!=="off"&&(u+=I),L(I),d===void 0&&T()&&(d=t.next(M))}function P(R,I=!1){let G=s.beatAt(r);y++;let X=y,U=G?.name!==b?.name||G?.index!==b?.index;b=G,!(G&&(U||I)&&(m=!0,$("beat",G,R),y!==X))&&$("time",r,R)}function k(R,I={}){if(c||!Number.isFinite(R))return;let G=x(R);f&&u!=="off"&&(u=I.join?G:u+G-r),r=G,h=t.now(),N!==void 0&&r>=N&&(N=void 0),P("seek"),v()}function O(){c||(r=0,f&&(u=0),N=void 0,h=t.now(),P("seek",!0),v())}let w={get timeline(){return s},get duration(){return s.duration},get time(){return r},get ambientTime(){return u},get playing(){return l},get beat(){return b},get cue(){return s.cues(r)},get rate(){return o},set rate(R){let I=g(R);I!==o&&(o=I,$("rate",I))},get loop(){return i},set loop(R){i=R},get ambient(){return f},set ambient(R){c||R===f||(f=R,f&&u==="off"&&(u=b?.start??0),v(),$("ambient",f),$("time",r,"ambient"))},get active(){return a},set active(R){R!==a&&(a=R,v())},state:()=>s.at(r,{ambient:u}),play(R={}){c||l||s.duration<=0||(r>=s.duration&&R.until===void 0&&O(),N=R.until!==void 0&&R.until>r&&R.until<=s.duration?R.until:void 0,!(R.until!==void 0&&N===void 0)&&(l=!0,h=t.now(),v(),$("play"),l&&!m&&b&&(m=!0,$("beat",b,"play"))))},pause(){l&&(l=!1,N=void 0,y++,v(),$("pause"))},toggle(){l?w.pause():w.play()},seek:k,seekBeat(R){let I=typeof R=="number"?s.beats[R]?.start:s.beats.find(G=>G.name===R)?.start;return I===void 0?!1:(k(I),!0)},next(){let R=s.beats.find(I=>I.start>r);k(R?R.start:s.duration)},prev(){let R=[...s.beats].reverse().find(I=>I.start<r-Lp);k(R?R.start:0)},restart:O,rebind(R){if(c||!R.ok)return!1;N=void 0;let I=s.beatAt(r),G=I?(r-I.start)/Math.max(1,I.end-I.start):0,X=u==="off"?0:u-r,U=s;if(s=R,I){let B=R.beats.find(H=>H.name===I.name);if(B)r=B.start+G*(B.end-B.start);else{let H=U.beats.filter(Y=>Y.index<I.index).reverse().map(Y=>R.beats.find(ee=>ee.name===Y.name)).find(Boolean);r=H?H.start:0}}return r=x(r),f&&u!=="off"&&(u=r+X),h=t.now(),P("rebind"),v(),!0},on(R,I){let G=p[R]??=new Set;return G.add(I),()=>{G.delete(I)}},dispose(){c=!0,y++,l=!1,d!==void 0&&t.cancel(d),d=void 0;for(let R of Object.keys(p))p[R].clear()}};return v(),w}function re(n,e=null,...t){let s=document.createElement(n);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,l]of Object.entries(o))s.addEventListener(i,l);else s.setAttribute(r,o===!0?"":String(o));for(let r of t)r!=null&&r!==!1&&s.append(r instanceof Node?r:document.createTextNode(String(r)));return s}var ra=new Map;function Uu(){let n,e=.35;for(let[t,s]of ra)s.wants&&s.seen>=e&&(s.seen>e||!n)&&(n=t,e=s.seen);for(let[t,s]of ra)s.wants&&s.auto(t===n)}var Hu=n=>{let e=new DOMParser().parseFromString(n,"image/svg+xml");if(e.documentElement.localName!=="svg")throw new Error("the drawing is not SVG");return document.importNode(e.documentElement,!0)},sa=n=>{let e=Math.round(n/1e3);return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`},Yu={ok:!0,diags:[],duration:0,beats:[],markers:{},ambient:"on",loops:!1,at:()=>({}),cues:()=>{},beatAt:()=>{},startOf:()=>{}};function Fp(n){let e={...n.camera?{camera:n.camera}:{},...n.variants?{variants:n.variants}:{}};for(let t of["items","labels","routes"]){let s=Object.entries(n[t]??{}).filter(([,r])=>r.opacity===0).map(([r])=>[r,{opacity:0}]);s.length&&(e[t]=Object.fromEntries(s))}return e}function Wu(n,e){if(e.timeline&&!e.timeline.ok)throw new Error(`the motion has faults: ${e.timeline.diags.map(V=>`${V.path}: ${V.message}`).join("; ")}`);let t=e.scene,s=Hu(t.rendered.svg),r,o,i=!1,l=!1,a=na(e.timeline??Yu,{loop:e.loop,rate:e.rate,ambient:e.ambient,clock:e.clock}),c=e.controls??!0,f=e.reducedMotion==="respect"&&typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,u=f,d=(V,te,ae,Te)=>re("button",{type:"button",class:`iso-play-btn ${V}`,"aria-label":te,title:te,on:{click:Te}},ae),h=re("div",{class:"iso-play-stage"},s),b=d("back","Back","\u2039",()=>ce(()=>W(Math.max(0,q()-1)))),m=d("play","Play","\u25B6",()=>oe()),y=d("next","Next","\u203A",()=>ce(()=>W(Math.min(a.timeline.beats.length-1,q()+1)))),N=d("again","Reset","\u21BA",()=>ce(()=>{fe(),a.restart()})),p=d("ambient","Ambient motion","\u223F",()=>{Z(),a.ambient=!a.ambient,ee()}),g=re("input",{type:"range",class:"iso-play-bar",min:0,step:1,"aria-label":"Time",on:{input:(()=>ce(()=>{fe(),a.seek(Number(g.value))}))}}),x=re("span",{class:"iso-play-time"}),$=re("div",{class:"iso-play-dots"}),T=re("span",{class:"iso-play-num"}),v=re("span",{class:"iso-play-title"}),A=re("span",{class:"iso-play-chapter"}),L=re("span",{class:"iso-play-count"}),M=re("div",{class:"iso-play-text"}),P=re("pre",{class:"iso-play-code"}),k=re("dl",{class:"iso-play-facts"}),O=re("div",{class:"iso-play-say","aria-live":"polite"},re("div",{class:"iso-play-head"},T,v,A,L),M,P,k),w=re("details",{class:"iso-play-list"}),R=re("div",{class:"iso-play-row"},b,m,y,N,p,g,x),I=re("div",{class:"iso-play",role:"group","aria-roledescription":"animated diagram","aria-label":e.label??"Diagram",tabindex:c?0:void 0,"data-mode":e.mode??"light"},h,c&&R,c&&$,c&&O,c&&w);n.append(I);let G=[];function X(){let V=a.timeline.beats,te=V.length>0,ae=V.some(Ne=>Ne.say);G=[],$.replaceChildren();let Te,ye;for(let Ne of V){(!Te||Ne.say?.chapter!==ye)&&(Te=re("span",{class:"iso-play-group",role:"group","aria-label":Ne.say?.chapter,title:Ne.say?.chapter}),$.append(Te),ye=Ne.say?.chapter);let Oe=re("button",{type:"button",class:"iso-play-dot","aria-label":`Step ${Ne.index+1}: ${Ne.say?.title??Ne.name}`,title:Ne.say?.title??Ne.name,on:{click:(()=>ce(()=>W(Ne.index)))}});Te.append(Oe),G.push(Oe)}w.replaceChildren(re("summary",null,`All ${V.length} steps as text`),re("ol",null,...V.map(Ne=>re("li",null,...U(Ne)))));for(let Ne of[b,y,$])Ne.hidden=!te;O.hidden=!ae,w.hidden=!ae,p.hidden=!a.timeline.loops,g.max=String(Math.round(a.duration));for(let Ne of[m,N,g,x])Ne.hidden=a.duration<=0;B=void 0}function U(V){let te=V.say,ae=[re("b",null,te?.title??V.name)];if(te?.text){let Te=re("div",null);Te.innerHTML=nn(te.text),ae.push(Te)}return te?.code&&ae.push(re("code",null,te.code)),te?.facts?.length&&ae.push(re("span",null,te.facts.map(([Te,ye])=>`${Te}: ${ye}`).join(" \xB7 "))),ae}let B;function H(V){let te=String((V?.index??-1)+1);for(let ae of s.querySelectorAll("[data-badge]"))ae.classList.toggle("on",ae.getAttribute("data-badge")===te),e.steps&&(ae.getAttribute("data-badge")===te||u?ae.removeAttribute("opacity"):ae.setAttribute("opacity","0.14"));if(e.steps)for(let ae of s.querySelectorAll("[data-step]"))ae.setAttribute("visibility",ae.getAttribute("data-step")===te&&!u?"visible":"hidden")}function Y(){let V=a.beat;if(V===B||(B=V,H(V),!c))return;let te=V?.say;T.textContent=V?String(V.index+1):"",T.style.backgroundColor=te?.color??"",v.textContent=te?.title??V?.name??"",A.textContent=te?.chapter??"",L.textContent=V?`${V.index+1} / ${a.timeline.beats.length}`:"",M.innerHTML=nn(te?.text),P.textContent=te?.code??"",k.replaceChildren(...(te?.facts??[]).flatMap(([ae,Te])=>[re("dt",null,ae),re("dd",null,Te)])),P.hidden=!te?.code,k.hidden=!te?.facts?.length,G.forEach((ae,Te)=>{ae.classList.toggle("on",Te===V?.index),ae.classList.toggle("done",V!==void 0&&Te<V.index),Te===V?.index?ae.setAttribute("aria-current","step"):ae.removeAttribute("aria-current")})}function ee(){let V=r!==void 0?a.timeline.at(r,{ambient:r}):u?Fp(a.timeline.at(a.duration,{ambient:"off"})):a.state();Ii(s,V,t.rendered,{styles:"cssom"}),I.dataset.time=String(Math.round(r??a.time)),r!==void 0?H(a.timeline.beatAt(r)):Y(),c&&(g.value=String(Math.round(a.time)),g.setAttribute("aria-valuetext",`${sa(a.time)} of ${sa(a.duration)}${a.beat?`, ${a.beat.say?.title??a.beat.name}`:""}`),x.textContent=`${sa(a.time)} / ${sa(a.duration)}`)}function F(){let V=K();m.textContent=V?"\u275A\u275A":"\u25B6",m.setAttribute("aria-label",V?"Pause":"Play"),m.title=V?"Pause":"Play",p.setAttribute("aria-pressed",String(a.ambient)),O.setAttribute("aria-live",V?"off":"polite"),I.dataset.playing=String(V)}let K=()=>a.playing&&o===void 0,q=()=>a.beat?.index??0;function Z(){u&&(u=!1,B=void 0)}function ce(V){Z(),i=!0,V(),F(),ee()}function fe(){o=void 0,a.pause()}function W(V){let te=a.timeline.beats[V];if(!te||l)return;a.pause(),a.seek(te.start,{join:!0});let ae=a.timeline.beats[V+1]?.start??1/0;o=Math.max(te.start,Math.min(te.end,ae,a.duration)-1),a.play({until:o})}function oe(){Z(),K()?(i=!0,fe()):(i=!1,o=void 0,a.pause(),a.play()),F(),ee()}a.on("time",ee),a.on("play",F),a.on("ambient",F),a.on("pause",()=>{o=void 0,F()}),I.addEventListener("keydown",V=>{let te=V.key,ae=V.target;V.altKey||V.ctrlKey||V.metaKey||ae===g||(te==="ArrowRight"||te==="ArrowLeft"?(V.preventDefault(),(te==="ArrowRight"?y:b).click()):te==="Home"?(V.preventDefault(),N.click()):(te===" "||te==="k")&&ae===I&&(V.preventDefault(),oe()))});let Me=V=>{let te=V.target.closest?.("[data-go]"),ae=V.key;!te||V.type==="keydown"&&ae!=="Enter"&&ae!==" "||(V.preventDefault(),V.stopPropagation(),ce(()=>W(Number(te.getAttribute("data-go"))-1)))};h.addEventListener("click",Me),h.addEventListener("keydown",Me);let Le={seen:0,wants:e.autoplay==="visible"&&!f,auto(V){V?!i&&!K()&&(o=void 0,a.play()):K()&&(o=void 0,a.pause())}};ra.set(I,Le);let C=typeof IntersectionObserver=="function"?new IntersectionObserver(V=>{for(let te of V)Le.seen=te.isIntersecting?te.intersectionRatio:0,r===void 0&&(a.active=te.isIntersecting);Uu()},{threshold:[0,.2,.35,.5,.7,.9,1]}):void 0;return C?.observe(I),X(),F(),ee(),e.autoplay===!0&&!f&&a.play(),{root:I,transport:a,step:V=>ce(()=>W(V)),set(V,te=Yu,ae){if(l||!te.ok)return!1;let Te=Hu(V.rendered.svg);return t=V,s.replaceWith(Te),s=Te,ae&&(I.dataset.mode=ae),o!==void 0&&fe(),a.rebind(te),X(),F(),ee(),!0},freeze(V){r=V,a.pause(),a.active=!1,I.classList.add("frozen"),ee()},dispose(){l=!0,C?.disconnect(),ra.delete(I),a.dispose(),I.remove(),Uu()}}}var Ju=`
|
|
368
|
+
.iso-play{--ip-ink:#1c2026;--ip-muted:#68707c;--ip-line:#dfe3e8;--ip-bg:#fff;--ip-code:#f2f4f7;--ip-focus:#2a64d6;container:iso-play/inline-size;display:block;color:var(--ip-ink);background:var(--ip-bg);font:14px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif;border-radius:10px}
|
|
369
|
+
.iso-play[data-mode="dark"]{--ip-ink:#e6e9ee;--ip-muted:#98a1ae;--ip-line:#333a44;--ip-bg:#15181d;--ip-code:#1f242b;--ip-focus:#7aa7ff;color-scheme:dark}
|
|
370
|
+
.iso-play:focus-visible,.iso-play button:focus-visible,.iso-play input:focus-visible,.iso-play summary:focus-visible{outline:2px solid var(--ip-focus);outline-offset:2px}
|
|
371
|
+
.iso-play [hidden]{display:none}
|
|
372
|
+
.iso-play-stage svg{display:block;width:100%;height:auto}
|
|
373
|
+
.iso-play-stage [data-go]{cursor:pointer}
|
|
374
|
+
.iso-play-row{display:flex;align-items:center;gap:6px;padding:8px 12px 4px}
|
|
375
|
+
.iso-play-btn{font:inherit;min-width:32px;height:32px;padding:0 8px;border:1px solid var(--ip-line);border-radius:8px;background:none;color:inherit;cursor:pointer}
|
|
376
|
+
.iso-play-btn:hover{border-color:var(--ip-muted)}
|
|
377
|
+
.iso-play-btn.play{background:var(--ip-ink);color:var(--ip-bg);border-color:var(--ip-ink);min-width:44px}
|
|
378
|
+
.iso-play-btn.ambient[aria-pressed="false"]{color:var(--ip-muted);text-decoration:line-through}
|
|
379
|
+
.iso-play-bar{flex:1 1 60px;min-width:0;accent-color:var(--ip-ink)}
|
|
380
|
+
.iso-play-time{color:var(--ip-muted);font-size:12px;font-variant-numeric:tabular-nums;white-space:nowrap}
|
|
381
|
+
.iso-play-dots{display:flex;flex-wrap:wrap;gap:4px 12px;padding:2px 12px}
|
|
382
|
+
.iso-play-group{display:inline-flex;gap:0}
|
|
383
|
+
.iso-play-dot{width:24px;height:24px;padding:0;border:0;background:none;cursor:pointer;display:grid;place-items:center}
|
|
384
|
+
.iso-play-dot::before{content:"";width:9px;height:9px;border-radius:50%;background:var(--ip-line)}
|
|
385
|
+
.iso-play-dot.done::before{background:var(--ip-muted)}
|
|
386
|
+
.iso-play-dot.on::before{background:var(--ip-ink);width:11px;height:11px}
|
|
387
|
+
.iso-play-say{padding:4px 12px 10px;min-height:5.2em}
|
|
388
|
+
.iso-play-head{display:flex;align-items:baseline;gap:8px;font-weight:700}
|
|
389
|
+
.iso-play-num{flex:none;display:inline-grid;place-items:center;min-width:22px;height:22px;border-radius:11px;background:var(--ip-ink);color:var(--ip-bg);font-size:11px;align-self:center}
|
|
390
|
+
.iso-play-chapter,.iso-play-count{color:var(--ip-muted);font-size:12px;font-weight:500}
|
|
391
|
+
.iso-play-count{margin-left:auto;white-space:nowrap}
|
|
392
|
+
.iso-play-text{max-width:80ch}
|
|
393
|
+
.iso-play-text a{color:inherit}
|
|
394
|
+
.iso-play-code{margin:6px 0 0;padding:6px 10px;border-radius:8px;background:var(--ip-code);font:12px/1.5 ui-monospace,Menlo,monospace;white-space:pre-wrap;overflow-wrap:anywhere}
|
|
395
|
+
.iso-play-facts{display:flex;flex-wrap:wrap;gap:2px 16px;margin:6px 0 0;font-size:12px}
|
|
396
|
+
.iso-play-facts dt{color:var(--ip-muted)}
|
|
397
|
+
.iso-play-facts dd{margin:0 8px 0 -10px;font-weight:600}
|
|
398
|
+
.iso-play-list{padding:0 12px 10px;font-size:13px}
|
|
399
|
+
.iso-play-list summary{color:var(--ip-muted);cursor:pointer}
|
|
400
|
+
.iso-play.frozen>:not(.iso-play-stage){display:none}
|
|
401
|
+
@container iso-play (max-width:420px){.iso-play-time{display:none}.iso-play-row{flex-wrap:wrap}.iso-play-bar{flex-basis:100%;order:9}}
|
|
402
|
+
`;var Xu=1,oa="(?:[^/:%\\s]|%[0-9A-F]{2})+",Wt=["debug","info","notice","warning","error"],Qu=["1m","1h","1d"],hn={"1m":6e4,"1h":36e5,"1d":864e5},ia=n=>`^(?:(?:${n.kinds.join("|")}):(?:${oa})(?:/(?:${n.kinds.join("|")}):(?:${oa}))*)?$`;function aa(n){let e=new RegExp(ia(n)),t=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 l=i.indexOf(":");return{kind:i.slice(0,l),name:decodeURIComponent(i.slice(l+1))}})}function r(o){let i="";for(let l of s(o)){if(!n.parents[l.kind].includes(i))return!1;i=l.kind}return!0}return{isScope:t,parseScope:s,wellNested:r}}var la=n=>n.replace(/[%/:\s]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`),Zu=n=>n.map(e=>`${e.kind}:${la(e.name)}`).join("/"),ed=(n,e,t)=>(n?`${n}/`:"")+`${e}:${la(t)}`,Ct=n=>n===""?0:n.split("/").length;function ts(n,e){return e<=0?"":(n===""?[]:n.split("/")).slice(0,e).join("/")}var td=n=>ts(n,Ct(n)-1),Jt=(n,e)=>e===""||n===e||n.startsWith(`${e}/`),nd=(n,e)=>n!==""&&n.split("/").includes(e),mr=n=>n===""?"fleet":n.slice(n.lastIndexOf("/")+1).split(":")[0],pr=n=>n===""?"all hosts":decodeURIComponent(n.slice(n.lastIndexOf("/")+1).split(":").slice(1).join(":"));function hr(n){let e=[{scope:"",label:"all hosts",kind:"fleet"}];for(let t=1;t<=Ct(n);t++){let s=ts(n,t);e.push({scope:s,label:pr(s),kind:mr(s)})}return e}var dc=["kind","source","severity","scope","since","before"];function Bp(n){let e=[],t=0;for(;t<n.length;){for(;t<n.length&&/\s/.test(n[t]);)t++;if(t>=n.length)break;let s=!1;n[t]==="-"&&t+1<n.length&&!/\s/.test(n[t+1])&&(s=!0,t++);let r=/^(attr\.[a-z][a-z0-9_]*|[a-z]+):/.exec(n.slice(t)),o;r&&(o=r[1],t+=r[0].length);let i="",l=!1;if(n[t]==='"'){let a=n.indexOf('"',t+1);i=n.slice(t+1,a<0?n.length:a),l=!0,t=a<0?n.length:a+1}else{let a=t;for(;t<n.length&&!/\s/.test(n[t]);)t++;i=n.slice(a,t)}e.push({neg:s,raw:i,quoted:l,field:o})}return e}var jp=/^(\d+)(s|m|h|d|w)$/,Dp={s:1e3,m:6e4,h:36e5,d:864e5,w:7*864e5};function mc(n,e){let t=jp.exec(n);if(t)return e-Number(t[1])*Dp[t[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(n);if(!s)return;let[,r,o,i,l="0",a="0",c="0",f="0",u]=s;if(u){let h=Date.parse(n.replace(" ","T"));return Number.isNaN(h)?void 0:h}let d=new Date(+r,+o-1,+i,+l,+a,+c,+f.padEnd(3,"0")).getTime();return Number.isNaN(d)?void 0:d}function _p(n,e,t=Date.now()){let s=[],r=[];for(let o of Bp(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(!(n.includes(o.field)||o.field.startsWith("attr."))){i(`no field ${o.field}`);continue}if(!o.raw){i(`${o.field}: needs a value`);continue}let a=o.field;if(a==="severity"){let c=/^(>=|<=|>|<|=)?(.*)$/.exec(o.raw);if(!Wt.includes(c[2])){i(`no severity ${c[2]} (${Wt.join(", ")})`);continue}s.push({neg:o.neg,field:a,op:c[1]??"=",value:c[2]})}else if(a==="since"||a==="before"){let c=mc(o.raw,t);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(`-${a} isn't allowed (use ${a==="since"?"before":"since"})`);continue}s.push({neg:!1,field:a,value:o.raw,time:c})}else s.push({neg:o.neg,field:a,value:o.raw})}return{terms:s,warnings:r}}var ca=n=>Wt.indexOf(n),zp={"=":"eq",">=":"ge",">":"gt","<=":"le","<":"lt"};function Kp(n,e){switch(n.field){case void 0:return{field:"text",value:n.value};case"kind":case"source":return n.value.endsWith("*")?{field:n.field,value:n.value.slice(0,-1),prefix:!0}:{field:n.field,value:n.value};case"severity":return{field:"severity",op:zp[n.op??"="],value:n.value};case"scope":return{field:"scope",value:n.value,from:e.topKinds.some(t=>n.value.startsWith(`${t}:`))?"top":"segments"};case"since":case"before":return;default:return e.links.includes(n.field)?{field:"link",link:n.field,value:n.value}:{field:"attr",key:n.field.slice(5),value:n.value}}}function Vp(n,e){let t=[],s=new Map;for(let r of e.terms){let o=Kp(r,n);if(!o)continue;if(r.neg){t.push({not:!0,any:[o]});continue}if(o.field==="text"||o.field==="severity"){t.push({any:[o]});continue}let i=o.field==="link"?`link.${o.link}`:o.field==="attr"?`attr.${o.key}`:o.field,l=s.get(i);if(l)l.any.push(o);else{let a={any:[o]};s.set(i,a),t.push(a)}}return{all:t}}function Gp(n,e,t,s){switch(e.field){case"text":{let r=e.value.toLowerCase();if(t.summary.toLowerCase().includes(r)||t.kind.toLowerCase().includes(r)||t.source.toLowerCase().includes(r)||t.scope.toLowerCase().includes(r))return!0;for(let[o,i]of Object.entries(t.attrs))if(typeof i=="string"&&!s.has(`${t.source}.${o}`)&&i.toLowerCase().includes(r))return!0;return!1}case"kind":case"source":{let r=t[e.field];return e.prefix?r.startsWith(e.value):r===e.value}case"severity":{let r=ca(t.severity),o=ca(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"?Jt(t.scope,e.value):`/${t.scope}/`.includes(`/${e.value}/`);case"link":return n.linkMatch?.(String(e.link),e.value,t)??t.links[e.link]===e.value;case"attr":{let r=t.attrs[e.key];return r!=null&&String(r).toLowerCase()===e.value.toLowerCase()}}}function gr(n){let e=[...dc,...n.links],t=(l,a=Date.now())=>_p(e,l,a),s=l=>Vp(n,l);function r(l,a,c,f){let u=t(l,a);return{where:s(u),...fo(u,c,f),warnings:u.warnings}}function o(l,a=[]){let c=new Set(a),f=l?.all??[];return f.length?u=>f.every(d=>d.any.some(h=>Gp(n,h,u,c))!==!!d.not):()=>!0}return{FIELDS:e,parseSearch:t,toAst:s,compileSearch:r,matchAst:o,matcher:(l,a=[])=>o(s(l),a)}}function fo(n,e,t){for(let s of n.terms)s.field==="since"&&(e=Math.max(e,s.time)),s.field==="before"&&(t=Math.min(t,s.time));return{from:e,to:Math.max(e,t)}}function uo(n,e){let t=e.toLowerCase(),s=[];for(let o of n.terms){if(o.neg||o.field||!o.value)continue;let i=o.value.toLowerCase();for(let l=t.indexOf(i);l>=0;l=t.indexOf(i,l+i.length))s.push([l,l+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 sd=n=>Wt.filter(e=>ca(e)>=ca(n));var rd=new Map,fa=new Map;function Dt(n,e){if(!n||n==="UTC")return 0;let t=`${n}|${Math.floor(e/(15*6e4))}`,s=fa.get(t);if(s!==void 0)return s;let r=rd.get(n);if(!r){try{r=new Intl.DateTimeFormat("en-US",{timeZone:n,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}catch{return 0}rd.set(n,r)}let o={};for(let a of r.formatToParts(new Date(e)))a.type!=="literal"&&(o[a.type]=Number(a.value));let i=Date.UTC(o.year,o.month-1,o.day,o.hour%24,o.minute,o.second),l=Math.round((i-Math.floor(e/1e3)*1e3)/6e4)*6e4;return fa.size>5e4&&fa.clear(),fa.set(t,l),l}var od=n=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:n}),!0}catch{return!1}};function Rs(n,e,t){if(e==="1m")return Math.floor(n/6e4)*6e4;let s=Dt(t,n);if(e==="1h")return s%36e5===0?Math.floor(n/36e5)*36e5:Math.floor((n+s)/36e5)*36e5-s;let r=Math.floor((n+s)/864e5)*864e5,o=r-Dt(t,r-s);return o>n?o=r-864e5-Dt(t,r-864e5-s):ua(o,t)<=n&&(o=ua(o,t)),o}function ua(n,e,t="1d"){if(t==="1m")return n+6e4;if(t==="1h")return n+36e5;let s=Dt(e,n),r=Math.floor((n+s)/864e5)*864e5+864e5;return r-Dt(e,r-s)}var hs=6e4,gs=36e5,gn=864e5;function da(n,e,t,s={}){let r=Math.max((s.minFrac??.15)*(t-e),s.minMs??10*hs),o=n.filter(([a,c])=>c>=e&&a<t).map(([a,c])=>[Math.max(e,a),Math.min(t,Math.max(a,c))]).sort((a,c)=>a[0]-c[0]),i=[];if(!o.length)return i;let l=e;for(let[a,c]of o)a-l>r&&i.push({from:l,to:a}),l=Math.max(l,c);return t-l>r&&i.push({from:l,to:t}),i}function Ps(n){if(n>=gn){let e=Math.floor(n/gn),t=Math.round((n-e*gn)/gs);return t?`${e} d ${t} h`:`${e} d`}if(n>=gs){let e=Math.floor(n/gs),t=Math.round((n-e*gs)/hs);return t&&e<10?`${e} h ${t} min`:`${e} h`}return`${Math.max(1,Math.round(n/hs))} min`}var Cs=n=>`${n.from}-${n.to}`;function br(n,e,t,s=[],r={}){let o=r.cut??24,i=Math.max(1,t),l=Math.max(1,e-n),a=s.filter(g=>g.to>n&&g.from<e).map(g=>({from:Math.max(n,g.from),to:Math.min(e,g.to),w:r.weights?.get(Cs(g))??0})).sort((g,x)=>g.from-x.from),c=a.reduce((g,x)=>g+(x.to-x.from)*(1-x.w),0),f=a.reduce((g,x)=>g+(1-x.w)*o,0),u=(i-f)/Math.max(1,l-c);if(!(u>0)||f>i*.6)return br(n,e,t,[],r);let d=[[n,0]],h=0,b=n,m=[];for(let g of a){h+=(g.from-b)*u,d.push([g.from,h]);let x=(1-g.w)*o+g.w*u*(g.to-g.from);m.push({from:g.from,to:g.to,x0:h,x1:h+x,weight:g.w}),h+=x,d.push([g.to,h]),b=g.to}d.push([e,h+(e-b)*u]);let y=g=>{if(g<=n)return(g-n)*u;if(g>=e)return d[d.length-1][1]+(g-e)*u;let x=0,$=d.length-1;for(;$-x>1;){let M=x+$>>1;d[M][0]<=g?x=M:$=M}let[T,v]=d[x],[A,L]=d[$];return A===T?v:v+(g-T)/(A-T)*(L-v)},N=g=>m.find(x=>x.weight<1&&g>x.x0&&g<x.x1);return{t0:n,t1:e,width:i,cuts:m,x:y,t:g=>{let x=N(g);if(x)return g-x.x0<x.x1-g?x.from:x.to;if(g<=0)return n+g/u;let $=0,T=d.length-1;if(g>=d[T][1])return e+(g-d[T][1])/u;for(;T-$>1;){let P=$+T>>1;d[P][1]<=g?$=P:T=P}let[v,A]=d[$],[L,M]=d[T];return M===A?v:v+(g-A)/(M-A)*(L-v)},cutAt:N,msPerPx:1/u}}var pc=[1e3,5e3,15e3,3e4,hs,5*hs,15*hs,30*hs,gs,3*gs,6*gs,12*gs,gn,2*gn,7*gn,14*gn,28*gn];function ma(n,e,t=80){let s=pc.find(a=>a/n.msPerPx>=t)??pc[pc.length-1],r=[],o=a=>{let c=new Date(a+Dt(e,a)),f=String(c.getUTCHours()).padStart(2,"0"),u=String(c.getUTCMinutes()).padStart(2,"0"),d=String(c.getUTCSeconds()).padStart(2,"0"),h=`${c.getUTCDate()} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][c.getUTCMonth()]}`,b=f==="00"&&u==="00"&&d==="00";return s>=gn||b?{label:h,major:!0}:{label:s<hs?`${f}:${u}:${d}`:`${f}:${u}`,major:!1}},i=[],l=n.t0;for(let a of n.cuts)a.weight<1&&(i.push([l,a.from]),l=a.to);i.push([l,n.t1]);for(let[a,c]of i){let f=d=>d-Dt(e,d-Dt(e,d)),u=Math.ceil((a+Dt(e,a))/s)*s;s>=7*gn&&(u=Math.ceil((a+Dt(e,a))/gn)*gn);for(let d=0,h=f(u);h<c&&d<2e3;d++,u+=s,h=f(u)){if(h<a)continue;let b=n.x(h),m=r[r.length-1];(!m||b-m.x>=t*.6)&&r.push({t:h,x:b,...o(h)})}}return r}var qp=["id","time","t","dur","scope","source","kind","severity","summary"],Up=n=>{if(n==null)return"";let e=typeof n=="string"&&/^[=+\-@\t\r]/.test(n)?`'${n}`:String(n);return/[",\n\r]/.test(e)?`"${e.replace(/"/g,'""')}"`:e},id=(n,e)=>e.size?{...n,attrs:Object.fromEntries(Object.entries(n.attrs).filter(([t])=>!e.has(`${n.source}.${t}`)))}:n;function pa(n,e=[]){let t=new Set(e);return JSON.stringify(n.map(s=>id(s,t)),null,2)+`
|
|
403
|
+
`}function ha(n,e=[]){let t=new Set(e),s=n.map(a=>id(a,t)),r=[...new Set(s.flatMap(a=>Object.keys(a.attrs)))].sort(),o=[...new Set(s.flatMap(a=>Object.keys(a.links)))].sort(),i=[...qp,...r.map(a=>`attr.${a}`),...o.map(a=>`link.${a}`)],l=s.map(a=>[a.id,new Date(a.t).toISOString(),a.t,a.dur,a.scope,a.source,a.kind,a.severity,a.summary,...r.map(c=>a.attrs[c]),...o.map(c=>a.links[c])].map(Up).join(","));return[i.join(","),...l].join(`\r
|
|
358
404
|
`)+`\r
|
|
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)&<(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&<+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=`
|
|
405
|
+
`}var Hp=864e5,In=36e5,ga=(n,e)=>n.t-e.t||(n.id<e.id?-1:n.id>e.id?1:0);function Un(n,e){let t=0,s=n.length;for(;t<s;){let r=t+s>>1;n[r].t<e?t=r+1:s=r}return t}var cd=(n,e)=>{n.min=Math.min(n.min,e.min),n.max=Math.max(n.max,e.max),n.sum+=e.sum,n.count+=e.count};function ad(n,e,t){let s=[];for(let r of n){let o=Rs(r.t,e,t),i=s[s.length-1];i&&i.t===o?cd(i,r):s.push({t:o,min:r.min,max:r.max,sum:r.sum,count:r.count})}return s}function hc(n,e,t,s){for(let i=Un(n,e.t);i<n.length&&n[i].t===e.t;i++)if(t(n[i])){n[i]=e;return}let r=n[n.length-1];if(!r||s(r,e)<=0){n.push(e);return}let o=Un(n,e.t);for(;o<n.length&&s(n[o],e)<0;)o++;n.splice(o,0,e)}function ld(n,e,t){for(let s=Un(n,e);s<n.length&&n[s].t===e;s++)if(t(n[s])){n.splice(s,1);return}}function fd(n,e,t={}){let s=n.catalog,{isScope:r}=aa(e),{parseSearch:o,matchAst:i,toAst:l}=gr(e),a=C=>Object.fromEntries(e.flags.filter(V=>C?.[V]).map(V=>[V,!0])),c=t.now??s.now,f=(s.names??[]).flatMap(C=>(C.aliases??[]).map(V=>[V,C.scope])).sort((C,V)=>V[0].length-C[0].length),u=new Map,d=C=>{if(!f.length)return C;let V=u.get(C);if(V===void 0){let te=f.find(([ae])=>Jt(C,ae));V=te?te[1]+C.slice(te[0].length):C,u.set(C,V)}return V},h=new Map((s.names??[]).map(C=>[C.scope,C])),b=C=>f.length?{...C,scope:d(C.scope)}:C,m=C=>`${C.source}\0${C.id}`,y=n.events.map(b).sort(ga),N=new Map;for(let C of y)N.set(m(C),C);let p=y.filter(C=>C.dur!==void 0&&!C.open),g=p.reduce((C,V)=>Math.max(C,V.dur),0),x=new Map;for(let C of y)C.open&&x.set(m(C),C);let $=new Map,T=new Set,v=C=>{for(let V=Ct(C);V>=1;V--){let te=ts(C,V);if(T.has(te))break;T.add(te)}},A=new Map;for(let C of s.sources)for(let V of C.series)A.set(V.name,V.type);let L=s.sources.flatMap(C=>(C.sensitive??[]).map(V=>`${C.name}.${V}`)),M=new Map;for(let C of s.sources)M.set(C.name,{events:C.defaultRetention.events,rollups:{...C.defaultRetention.rollups},setBy:"default"});for(let C of s.retention)M.set(C.source,{events:C.events,rollups:{...C.rollups},setBy:C.setBy});let P=new Map;for(let C of s.sources)for(let V of C.series)P.set(V.name,C.name);function k(C){let V=d(C.scope),te=`${C.series}\0${V}`,ae=$.get(te);ae||(ae={series:C.series,scope:V,fine:[],cache:new Map},$.set(te,ae),v(V));let Te="value"in C?{t:C.t,min:C.value,max:C.value,sum:C.value,count:1}:{t:C.t,min:C.min,max:C.max,sum:C.sum,count:C.count};hc(ae.fine,Te,ye=>ye.t===Te.t,(ye,Ne)=>ye.t-Ne.t),ae.cache.clear()}for(let C of y)v(C.scope);for(let C of n.metrics)k(C);let O=new Map,w=new Set,R=(C,V)=>{w.add(C.source);let te=O.get(C.scope);te||O.set(C.scope,te=new Map);let ae=te.get(C.source);ae||te.set(C.source,ae=new Map);let Te=Math.floor(C.t/In)*In,ye=ae.get(Te);if(ye||ae.set(Te,ye={t:Te,count:0,severity:{},kinds:{},first:1/0,last:-1/0}),ye.count+=V,V>0)ye.first=Math.min(ye.first,C.t),ye.last=Math.max(ye.last,C.t);else if(C.t===ye.first||C.t===ye.last){ye.first=1/0,ye.last=-1/0;for(let Ne=Un(y,Te);Ne<y.length&&y[Ne].t<Te+In;Ne++){let Oe=y[Ne];Oe.scope===C.scope&&Oe.source===C.source&&(ye.first=Math.min(ye.first,Oe.t),ye.last=Math.max(ye.last,Oe.t))}}ye.severity[C.severity]=(ye.severity[C.severity]??0)+V,ye.kinds[C.kind]=(ye.kinds[C.kind]??0)+V,ye.severity[C.severity]===0&&delete ye.severity[C.severity],ye.kinds[C.kind]===0&&delete ye.kinds[C.kind],ye.count||ae.delete(Te)};for(let C of y)R(C,1);let I=(C,V,te)=>{let ae=`${V}|${te??""}`,Te=C.cache.get(ae);return Te||(Te=V==="1d"?ad(I(C,"1h",te),"1d",te):ad(C.fine,V,te),C.cache.set(ae,Te)),Te},G=C=>C===null?-1/0:c-C*Hp,X=C=>G(M.get(C)?.events??null),U=(C,V)=>{let te=M.get(C);return G(te?V?te.rollups[V]:te.events:null)};function B(C){let V=[];for(let te of new Set(C)){let ae=M.get(te);if(!ae)continue;let Te=y.find(we=>we.source===te&&we.t>=X(te))?.t,ye=we=>{let Fe=1/0;for(let qe of $.values())if(P.get(qe.series)===te){let De=(we?I(qe,we):qe.fine).find(Qe=>Qe.t>=U(te,we));De&&De.t<Fe&&(Fe=De.t)}return Fe===1/0?void 0:Fe},Ne=[Te,ye()].filter(we=>we!==void 0),Oe={};for(let we of["1m","1h","1d"]){let Fe=ye(we)??(Te!==void 0&&Te>=U(te,we)?Te:void 0);Fe!==void 0&&(Oe[we]=Math.max(Fe,U(te,we)))}V.push({source:te,events:ae.events,rollups:{...ae.rollups},setBy:ae.setBy,keptFrom:{...Ne.length?{events:Math.min(...Ne)}:{},rollups:Oe}})}return V}function H(C){let V=C.where,te={from:C.from,to:C.to},ae=[];if(!V&&C.q){let De=o(C.q,c);V=l(De),te=fo(De,C.from,C.to),ae=De.warnings}let Te=i(V,L),ye=C.filters??{},Ne=ye.source?.length?new Set(ye.source):void 0,Oe=ye.kind?.length?new Set(ye.kind):void 0,we=ye.severity?.length?new Set(ye.severity):void 0,Fe=ye.scope?.length?ye.scope:void 0;return{test:De=>Jt(De.scope,C.scope)&&(!Ne||Ne.has(De.source))&&(!Oe||Oe.has(De.kind))&&(!we||we.has(De.severity))&&(!Fe||Fe.some(Qe=>Jt(De.scope,Qe)))&&De.t>=X(De.source)&&Te(De),range:te,warnings:ae}}function Y(C){let V=Ct(C.scope),te=V+C.depth,ae=new Map,Te=we=>{let Fe=ae.get(we);return Fe===void 0&&!ae.has(we)&&(Fe=Jt(we,C.scope)?Ct(we)>=te?ts(we,te):we:void 0,ae.set(we,Fe)),Fe},ye=we=>{let Fe=0,qe=Ct(we)+1;for(let De of T)Ct(De)===qe&&Jt(De,we)&&Fe++;return Fe},Ne=new Map,Oe=we=>{let Fe=Ne.get(we);if(!Fe){let qe=Ct(we)-V,De=h.get(we);Fe={scope:we,label:De?.label??pr(we),kind:mr(we),...a(De),depth:qe,...qe<C.depth?{own:!0}:{},children:ye(we),count:0},Ne.set(we,Fe)}return Fe};for(let we of T)Ct(we)===te&&Jt(we,C.scope)&&Oe(we);return te===0&&Oe(""),{at:Te,add:Oe,rows:Ne}}let ee=C=>[...C.values()].sort((V,te)=>V.scope===te.scope?0:V.scope<te.scope?-1:1);function F(C,V){let te=[];for(let ae=Un(p,C-g);ae<p.length&&p[ae].t<C;ae++)p[ae].t+p[ae].dur>C&&te.push(p[ae]);for(let ae of x.values())ae.t<C&&c>C&&te.push(ae);for(let ae=Un(y,C);ae<y.length&&y[ae].t<V;ae++)te.push(y[ae]);return te}function K(C,V,te,ae){let Te=C.series?new Set(C.series):void 0,ye=new Map;for(let Oe of $.values()){if(Te&&!Te.has(Oe.series))continue;let we=V(Oe.scope);if(we===void 0)continue;let Fe=P.get(Oe.series)??"",qe=U(Fe,C.bin),De=C.bin?I(Oe,C.bin,C.tz):Oe.fine;for(let Qe=Un(De,C.bin?Rs(te,C.bin,C.tz):te);Qe<De.length&&De[Qe].t<ae;Qe++){let S=De[Qe];if(S.t<qe)continue;let z=`${Oe.series}\0${we}\0${S.t}`,J=ye.get(z);J?cd(J,S):ye.set(z,{series:Oe.series,scope:we,t:S.t,bin:C.bin??"1m",min:S.min,max:S.max,sum:S.sum,count:S.count})}}let Ne=[...ye.values()].sort((Oe,we)=>Oe.t-we.t||(Oe.series<we.series?-1:1)||(Oe.scope<we.scope?-1:1));return C.bin?Ne:Ne.map(Oe=>({series:Oe.series,scope:Oe.scope,t:Oe.t,value:Oe.count===1||A.get(Oe.series)!=="gauge"?Oe.sum:Oe.sum/Oe.count}))}let q=C=>`${C.t}:${C.id}`,Z=(C,V)=>{let te=V.indexOf(":"),ae=Number(V.slice(0,te)),Te=V.slice(te+1);return C.t>ae||C.t===ae&&C.id>Te};function ce(C){if(C.bin!=="1h"&&C.bin!=="1d"||(C.where?.all.length??0)||C.q||C.filters?.kind?.length||C.filters?.severity?.length||C.filters?.scope?.length||Dt(C.tz,C.from)%In||Dt(C.tz,C.to)%In)return;let V=C.filters?.source?.length?new Set(C.filters.source):void 0,te=Q=>Math.max(C.from,X(Q)),{at:ae,add:Te,rows:ye}=Y(C),Ne=new Set,Oe=new Map,we=0,Fe=(Q,ne)=>{let ge=Rs(ne,C.bin,C.tz),ke=`${Q}\0${ge}`,E=Oe.get(ke);return E||(E={scope:Q,t:ge,bin:C.bin,count:0,severity:{},kinds:{}},Oe.set(ke,E)),E},qe=(Q,ne,ge)=>{let ke=Te(Q);ke.count+=ge,we+=ge,(ke.first===void 0||ne<ke.first)&&(ke.first=ne),(ke.last===void 0||ne>ke.last)&&(ke.last=ne)},De=Math.floor(C.to/In)*In;for(let[Q,ne]of O){let ge=ae(Q);if(ge!==void 0)for(let[ke,E]of ne){if(V&&!V.has(ke))continue;let j=Math.ceil(te(ke)/In)*In;for(let[_,le]of E){if(_<j||_>=De)continue;qe(ge,le.first,le.count),le.last>(ye.get(ge).last??-1/0)&&(ye.get(ge).last=le.last),Ne.add(ke);let pe=Fe(ge,_);pe.count+=le.count;for(let[Re,ie]of Object.entries(le.severity))pe.severity[Re]=(pe.severity[Re]??0)+ie;for(let[Re,ie]of Object.entries(le.kinds))pe.kinds[Re]=(pe.kinds[Re]??0)+ie}}}let Qe=Q=>Jt(Q.scope,C.scope)&&(!V||V.has(Q.source))&&Q.t>=X(Q.source)&&ae(Q.scope)!==void 0,S=Q=>{let ne=ae(Q.scope);qe(ne,Q.t,1),Ne.add(Q.source);let ge=Fe(ne,Q.t);ge.count++,ge.severity[Q.severity]=(ge.severity[Q.severity]??0)+1,ge.kinds[Q.kind]=(ge.kinds[Q.kind]??0)+1};for(let Q of w){if(V&&!V.has(Q))continue;let ne=te(Q),ge=Math.ceil(ne/In)*In,ke=ge>=De?[[ne,C.to]]:[[ne,ge],[De,C.to]];for(let[E,j]of ke)for(let _=Un(y,E);_<y.length&&y[_].t<j;_++){let le=y[_];le.source===Q&&Qe(le)&&S(le)}}let z=hn[C.bin],J=[];for(let Q=Un(p,C.from-g);Q<p.length&&p[Q].t<C.from;Q++){let ne=p[Q];ne.t+ne.dur>C.from&&Qe(ne)&&(qe(ae(ne.scope),ne.t,1),Ne.add(ne.source),ne.dur>=z&&J.length<5e3&&J.push(ne))}for(let Q of x.values())Q.t<C.from&&c>C.from&&Qe(Q)&&(qe(ae(Q.scope),Q.t,1),Ne.add(Q.source),J.length<5e3&&J.push(Q));for(let Q=Un(p,C.from);Q<p.length&&p[Q].t<C.to&&J.length<5e3;Q++)p[Q].dur>=z&&Qe(p[Q])&&J.push(p[Q]);for(let Q of x.values())Q.t>=C.from&&Q.t<C.to&&J.length<5e3&&Qe(Q)&&J.push(Q);let de=K(C,ae,C.from,C.to);for(let Q of de){let ne=P.get(Q.series);ne&&Ne.add(ne)}let me=[...Oe.values()].sort((Q,ne)=>Q.t-ne.t||(Q.scope<ne.scope?-1:1));return{timeline:1,type:"result",rows:ee(ye),bins:me,spans:J,metrics:de,total:we,retention:B(Ne)}}async function fe(C){if(!r(C.scope))throw new Error(`not a scope path: ${JSON.stringify(C.scope)}`);let V=ce(C);if(V)return V;let{test:te,range:ae,warnings:Te}=H(C),{at:ye,add:Ne,rows:Oe}=Y(C),we=new Set,Fe=[];for(let de of F(ae.from,ae.to)){if(!te(de))continue;let me=ye(de.scope);if(me===void 0)continue;let Q=Ne(me);Q.count++,(Q.first===void 0||de.t<Q.first)&&(Q.first=de.t),(Q.last===void 0||de.t>Q.last)&&(Q.last=de.t),we.add(de.source),Fe.push(de)}Fe.sort(ga);let qe=K(C,ye,ae.from,ae.to);for(let de of qe){let me=P.get(de.series);me&&we.add(me)}let De={timeline:1,type:"result",total:Fe.length,...Te.length?{warnings:Te}:{}};if(C.bin){let de=hn[C.bin],me=new Map,Q=[];for(let ge of Fe){if((ge.open||ge.dur!==void 0&&ge.dur>=de)&&Q.length<5e3&&Q.push(ge),ge.t<ae.from)continue;let ke=ye(ge.scope),E=Rs(ge.t,C.bin,C.tz),j=`${ke}\0${E}`,_=me.get(j);_||(_={scope:ke,t:E,bin:C.bin,count:0,severity:{},kinds:{}},me.set(j,_)),_.count++,_.severity[ge.severity]=(_.severity[ge.severity]??0)+1,_.kinds[ge.kind]=(_.kinds[ge.kind]??0)+1}let ne=[...me.values()].sort((ge,ke)=>ge.t-ke.t||(ge.scope<ke.scope?-1:1));return{...De,rows:ee(Oe),bins:ne,spans:Q,metrics:qe,retention:B(we)}}let Qe=Math.min(1e4,Math.max(1,C.limit??2e3)),S=C.cursor?Fe.findIndex(de=>Z(de,C.cursor)):0,z=S<0?[]:Fe.slice(S,S+Qe),J=S>=0&&S+Qe<Fe.length;return{...De,rows:ee(Oe),events:z,metrics:qe,retention:B(we),...J?{next:q(z[z.length-1])}:{}}}let W=new Set,oe=C=>Wt.includes(C),Me=0;function Le(C){let V=m(C),te=N.get(V);te&&(ld(y,te.t,ae=>ae===te),R(te,-1),te.dur!==void 0&&!te.open&&ld(p,te.t,ae=>ae===te),x.delete(V)),N.set(V,C),R(C,1),hc(y,C,()=>!1,ga),C.open?x.set(V,C):C.dur!==void 0&&(hc(p,C,()=>!1,ga),g=Math.max(g,C.dur)),v(C.scope)}return{async catalog(){return{...s,now:c,retention:B(s.sources.map(C=>C.name))}},query:fe,subscribe(C,V){let te={q:C,on:V};return W.add(te),()=>{W.delete(te)}},...t.stateAt?{stateAt:(C,V)=>t.stateAt(C,V)}:{},append(C,V=[],te){te!==void 0&&(c=Math.max(c,te));let ae=new Set(T),Te=C.map(b);for(let ye of Te){if(!oe(ye.severity))throw new Error(`not a severity: ${ye.severity}`);Le(ye)}for(let ye of V)k(ye);Me++;for(let ye of W){let{test:Ne}=H(ye.q),{at:Oe}=Y(ye.q),we=Te.filter(z=>Ne(z)&&Oe(z.scope)!==void 0),Fe=ye.q.series?new Set(ye.q.series):void 0,qe=V.filter(z=>Jt(d(z.scope),ye.q.scope)&&(!Fe||Fe.has(z.series))).map(z=>({...z,scope:Oe(d(z.scope))})),De=[...T].filter(z=>!ae.has(z)),Qe=Ct(ye.q.scope)+ye.q.depth,S=De.filter(z=>Ct(z)===Qe&&Jt(z,ye.q.scope)).map(z=>({scope:z,label:h.get(z)?.label??pr(z),kind:mr(z),depth:ye.q.depth,children:0,count:0}));ye.on({timeline:1,type:"batch",events:we,metrics:qe,...S.length?{rows:S}:{},now:c,resume:String(Me)})}},setRetention(C,V){M.set(C,{events:V.events,rollups:{...V.rollups},setBy:"user"})},get now(){return c},get size(){let C=0;for(let V of $.values())C+=V.fine.length;return{events:y.length,samples:C}}}}var ud="http://www.w3.org/2000/svg",Is=22,ba=38,Hn=26,Yp=210,Wp=24,mo=6e4,Ls=36e5,sn=864e5,dd={"15m":15*mo,"1h":Ls,"1d":sn,"1w":7*sn},md=n=>Wt.indexOf(n),Jp={debug:"dot",info:"circle",notice:"square",warning:"triangle",error:"diamond"},it=(n,e,t)=>{let s=document.createElementNS(ud,n);for(let[r,o]of Object.entries(e))o!==void 0&&s.setAttribute(r,String(o));if(t){let r=document.createElementNS(ud,"title");r.textContent=t,s.append(r)}return s},_t=(n,e)=>{try{return new Intl.DateTimeFormat(void 0,{timeZone:e,dateStyle:"medium",timeStyle:"medium"}).format(n)}catch{return new Date(n).toISOString()}},gc=n=>n<1e3?`${Math.round(n)} ms`:n<mo?`${(n/1e3).toFixed(1)} s`:Ps(n),Xp=(n,e)=>e==="bytes"?n>=1e9?`${(n/1e9).toFixed(1)} GB`:n>=1e6?`${(n/1e6).toFixed(1)} MB`:n>=1e3?`${(n/1e3).toFixed(1)} kB`:`${Math.round(n)} B`:`${Math.round(n*10)/10}${e==="count"?"":` ${e}`}`;function bc(n,e){if(n<=3*Ls)return{kind:"single"};for(let t of["1m","1h","1d"])if(n/hn[t]<=e/2)return{kind:"binned",bin:t};return{kind:"binned",bin:"1d"}}function yc(n,e,t){let s=[];for(let i of n.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 n.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"?hn[e.bin]:mo;for(let i of n.bins??[])i.count&&s.push([i.t,i.t+hn[i.bin]]);let o=new Map;for(let i of n.metrics){let l="value"in i?i.value:i.sum,a=`${i.series}|${i.scope}`,c=(t?.get(i.series)??"counter")==="counter"?l!==0:o.get(a)!==l;o.set(a,l),c&&s.push([i.t,i.t+r])}return s}function pd(n,e){let t=e.tz??Intl.DateTimeFormat().resolvedOptions().timeZone,s=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,r=e.motion??!s;n.classList.add(...e.rootClass??[],"tlx");let{parseSearch:o,compileSearch:i}=gr(e.catalog),l=(D="system")=>{n.style.colorScheme=D==="system"?"light dark":D,D==="system"?delete n.dataset.theme:n.dataset.theme=D};l(e.theme),n.setAttribute("role","region"),n.setAttribute("aria-label","Timeline");let a,c="",f=1,u="",d={},h=!1,b=e.collapseGaps??!0,m={t0:0,t1:sn},y,N="",p={from:0,to:0,mode:{kind:"single"},key:""},g,x,$,T,v=!0,A=0,L=0,M=!1,P,k=[],O=[],w=-1,R=new Set,I=new Map,G=[],X=br(0,sn,800),U=new Map,B=[],H=re("nav",{class:"tlx-crumbs","aria-label":"Scope"}),Y=re("div",{class:"segmented tlx-quick",role:"group","aria-label":"Range"});for(let D of["15m","1h","1d","1w","run"]){let se=re("button",{type:"button",class:"seg","data-v":D,title:D==="run"?"The latest run":`The last ${D}`},D==="run"?"this run":D);se.addEventListener("click",()=>Yn(D)),Y.append(se)}let ee=re("button",{type:"button",class:"btn sm tlx-live","aria-pressed":"false",title:"Follow what happens now"},"Live"),F=re("button",{type:"button",class:"btn sm quiet tlx-now",hidden:!0,title:"Back to the live edge"},"Back to now"),K=re("button",{type:"button",class:"btn sm quiet tlx-fit",title:"Everything in this scope"},"Fit"),q=re("input",{type:"checkbox",class:"tlx-gaps"});q.checked=b;let Z=!0,ce=re("input",{type:"checkbox",class:"tlx-quiet"});ce.checked=Z;let fe=re("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"}),W=re("span",{class:"tlx-hits",role:"status","aria-live":"polite"}),oe=re("button",{type:"button",class:"btn sm quiet tlx-prev",title:"Previous hit (\u21E7N)","aria-label":"Previous hit"},"\u2039"),Me=re("button",{type:"button",class:"btn sm quiet tlx-next",title:"Next hit (N)","aria-label":"Next hit"},"\u203A"),Le=re("div",{class:"tlx-facets",role:"group","aria-label":"Sources"}),C=re("select",{class:"input tlx-sev","aria-label":"Severity"},re("option",{value:""},"every severity"),...Wt.slice(1).map(D=>re("option",{value:D},`${D} and above`))),V=re("select",{class:"input tlx-views","aria-label":"Saved views",hidden:!e.views},re("option",{value:""},"Saved views\u2026")),te=re("button",{type:"button",class:"btn sm quiet tlx-save",hidden:!e.saveView,title:"Save this view"},"Save view"),ae=re("div",{class:"tlx-warn",role:"status",hidden:!0}),Te=re("div",{class:"tlx-status",role:"status"}),ye=re("span",{class:"tlx-canvas-note"}),Ne=re("div",{class:"tlx-labels"}),Oe=re("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"}),we=it("svg",{class:"tlx-svg"});Oe.append(we);let Fe=re("div",{class:"tlx-scroll"},re("div",{class:"tlx-grid"},Ne,Oe)),qe=re("section",{class:"tlx-table",hidden:!0,"aria-label":"The events in the chosen range"}),De=re("aside",{class:"tlx-detail",hidden:!0,"aria-label":"The event"});n.replaceChildren(re("div",{class:"tlx-bar"},H,re("span",{class:"spacer"}),Y,ee,F,K,re("label",{class:"tlx-gaps-label",title:"Draw long empty stretches as narrow breaks"},q,"Collapse gaps"),re("label",{class:"tlx-gaps-label",title:"Hide the rows with nothing in this range"},ce,"Hide quiet rows")),re("div",{class:"tlx-bar"},fe,W,oe,Me,C,V,te),Le,ae,re("div",{class:"tlx-body"},Fe,De),re("div",{class:"tlx-foot"},Te,re("span",{class:"spacer"}),ye),qe);let Qe=()=>Math.max(200,Oe.clientWidth||800),S=()=>{let D=(ve,Ke)=>(ve.own?-1:0)-(Ke.own?-1:0)||ve.scope.localeCompare(Ke.scope,void 0,{numeric:!0}),he=(y?.rows??[]).filter(ve=>!Z||ve.count>0||ve.own||(y?.rows.length??0)<=1).sort(D).map(ve=>({kind:"row",row:ve})),be=new Set(y?.metrics.map(ve=>ve.series)??[]);for(let ve of[...be].sort()){let Ke=U.get(ve);he.push({kind:"metric",series:ve,unit:Ke?.unit??"count",type:Ke?.type??"counter",title:Ke?.title??ve})}return he},z=(D,se)=>a?.names?.find(he=>he.scope===D)?.label??se,J=D=>D.kind==="metric"?ba:Is,de=()=>bc(m.t1-m.t0,Qe()),me=()=>a?.now??Date.now();function Q(){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}:{},...h?{live:h}:{},...b?{}:{collapseGaps:!1},...Z?{}:{quietRows:!0}}}function ne(D){D.scope!==void 0&&(c=D.scope),D.depth!==void 0&&(f=D.depth),u=D.q??"",fe.value=u,d=D.filters??{},C.value=d.severity?.length?d.severity[0]:"",b=D.collapseGaps??e.collapseGaps??!0,q.checked=b,Z=!D.quietRows,ce.checked=Z,R.clear(),I.clear();let se=D.range;se&&"last"in se?Yn(se.last,!1):se&&(m={t0:se.from,t1:se.to}),ft(!!D.live,!1)}let ge=()=>{let D=Q();if(e.onViewChange?.(D),!!e.urlState)try{history.replaceState(null,"",`#timeline=${encodeURIComponent(JSON.stringify(D))}`)}catch{}},ke=()=>{if(!e.urlState)return;let D=/#timeline=(.+)$/.exec(location.hash);if(D)try{return JSON.parse(decodeURIComponent(D[1]))}catch{return}};function E(D,se,he,be={}){let ve=i(u,me(),D,se);k=ve.warnings;let Ke=u?[]:d.source?[...U].filter(([,Ze])=>d.source.includes(Ze.source)).map(([Ze])=>Ze):void 0;return{timeline:1,type:"query",scope:c,depth:f,from:ve.from,to:ve.to,tz:t,...he.kind==="binned"?{bin:he.bin}:{},...u?{q:u,where:ve.where}:{},...Object.keys(d).length?{filters:d}:{},...Ke?{series:Ke}:{},...be}}let j=()=>JSON.stringify([c,f,u,d,de()]);async function _(D=!1){let se=de(),he=j(),be=m.t1-m.t0;if(!D&&y&&he===p.key&&m.t0>=p.from&&m.t1<=p.to){pe();return}if(L){M=!0;return}L++;let ve=m.t0-be/2,Ke=Math.min(m.t1+be/2,Math.max(m.t1,me()+be*.1));try{let Ze=await e.source.query(E(ve,Ke,se,se.kind==="single"?{limit:1e4}:{}));se.kind==="single"&&Ze.next&&(Ze=await e.source.query(E(ve,Ke,{kind:"binned",bin:"1m"}))),y=Ze,N=he,p={from:ve,to:Ke,mode:se,key:he}}catch(Ze){Te.textContent=`The history couldn't be read: ${String(Ze?.message??Ze)}`}finally{L--}pe(),ge(),M&&(M=!1,_())}function le(){let D=Qe(),se=de();if(G=[],b&&y){let he=new Map([...U].map(([be,ve])=>[be,ve.type]));G=da(yc(y,se,he),m.t0,Math.min(m.t1,Math.max(m.t0,me())),{minFrac:.15,minMs:10*mo}),se.kind==="binned"&&(G=G.filter(be=>be.to-be.from>=2*hn[se.bin])),G=G.filter(be=>!(R.has(Cs(be))&&(I.get(Cs(be))??1)>=1))}X=br(m.t0,m.t1,D,G,{cut:Wp,weights:I})}let pe=()=>{A||(A=requestAnimationFrame(Re))};function Re(){A=0,le();let D=Qe(),se=S(),he=p.mode,be=[],ve=Hn;for(let ue of se)be.push(ve),ve+=J(ue);let Ke=Math.max(ve,Hn+Is);we.setAttribute("width",String(D)),we.setAttribute("height",String(Ke)),we.setAttribute("viewBox",`0 0 ${D} ${Ke}`);let Ze=Fe.scrollTop-200,Ln=Fe.scrollTop+(Fe.clientHeight||600)+200,je=[],Be=X.x;je.push(it("rect",{class:"tlx-axis",x:0,y:0,width:D,height:Hn}));let It=(y?.retention??[]).map(ue=>({r:ue,from:he.kind==="binned"?ue.keptFrom.rollups[he.bin]??ue.keptFrom.events:ue.keptFrom.events,days:he.kind==="binned"?ue.rollups[he.bin]:ue.events})).filter(ue=>ue.from!==void 0);if(It.length){let ue=Math.min(...It.map($e=>$e.from));ue>m.t0&&je.push(it("rect",{class:"tlx-notkept",x:Math.max(0,Be(m.t0)),y:Hn,width:Math.max(0,Be(ue)-Math.max(0,Be(m.t0))),height:Ke-Hn},`Nothing kept before ${_t(ue,t)}: ${It.map($e=>`${$e.r.source} ${$e.days===null?"kept until deleted":`kept ${$e.days} days`}`).join(", ")}`))}let Xt=me();Xt<m.t1&&je.push(it("rect",{class:"tlx-future",x:Be(Xt),y:Hn,width:D-Be(Xt),height:Ke-Hn}));for(let ue of ma(X,t,90)){je.push(it("line",{class:`tlx-tick${ue.major?" major":""}`,x1:ue.x,x2:ue.x,y1:Hn-6,y2:Ke}));let $e=it("text",{class:"tlx-ticklabel",x:ue.x+3,y:16});$e.textContent=ue.label,je.push($e)}T&&je.push(it("rect",{class:"tlx-brush",x:Be(T.from),y:0,width:Math.max(1,Be(T.to)-Be(T.from)),height:Ke}));let go=he.kind==="single"?(y?.events??[]).filter(ue=>ue.dur!==void 0||ue.open):y?.spans??[],Ed=he.kind==="single"?(y?.events??[]).filter(ue=>ue.dur===void 0&&!ue.open):[],wc=new Map;se.forEach((ue,$e)=>{ue.kind==="row"&&wc.set(ue.row.scope,$e)});let bo=ue=>{let $e=Ct(c)+f,Ue=Ct(ue)>=$e?ts(ue,$e):ue;return wc.get(Ue)},yr=ue=>be[ue]+J(se[ue])>=Ze&&be[ue]<=Ln;if(se.forEach((ue,$e)=>{yr($e)&&je.push(it("rect",{class:`tlx-lane${$e%2?" odd":""}${ue.kind==="metric"?" metric":""}`,x:0,y:be[$e],width:D,height:J(ue)}))}),he.kind==="binned"){let ue=new Map;for(let $e of y?.bins??[]){let Ue=bo($e.scope);Ue!==void 0&&ue.set(Ue,Math.max(ue.get(Ue)??0,$e.count))}for(let $e of y?.bins??[]){let Ue=bo($e.scope);if(Ue===void 0||!yr(Ue))continue;let et=Be($e.t),We=Be($e.t+hn[$e.bin]);if(We<0||et>D)continue;let dt=[...Wt].reverse().find(rn=>($e.severity[rn]??0)>0)??"info",Ot=Math.max(2,(Is-8)*Math.sqrt($e.count)/Math.sqrt(ue.get(Ue)||1));je.push(it("rect",{class:"tlx-countbar",x:et,y:be[Ue]+Is-3-Ot,width:Math.max(1,We-et-.5),height:Ot,"data-t":$e.t},`${_t($e.t,t)}: ${$e.count} event${$e.count===1?"":"s"}${dt!=="info"&&dt!=="debug"?`, the worst ${dt}`:""}`)),(dt==="warning"||dt==="error")&&je.push(it("rect",{class:`tlx-heat sev-${dt}`,x:et,y:be[Ue]+Is-(dt==="error"?4:3),width:Math.max(1,We-et-.5),height:dt==="error"?3:2}))}}for(let ue of go){let $e=bo(ue.scope);if($e===void 0||!yr($e))continue;let Ue=ue.open?Xt:ue.t+(ue.dur??0),et=Be(ue.t),We=Be(Ue);if(We<-2||et>D+2)continue;let dt=`tlx-span sev-${ue.severity}${ue.open?" open":""}${$?.id===ue.id?" selected":""}`,Ot=`${ue.summary} \xB7 ${_t(ue.t,t)}${ue.open?", still going":`, ${gc(Ue-ue.t)}`}`,rn=be[$e]+5,ss=he.kind==="binned"?4:8,on=et;for(let xn of X.cuts)xn.weight>=1||xn.x1<=et||xn.x0>=We||(xn.x0>on&&je.push(it("rect",{class:dt,x:on,y:rn,width:Math.max(1,xn.x0-on),height:ss,rx:2,"data-id":ue.id},Ot)),je.push(it("path",{class:`${dt} through`,d:`M${xn.x0} ${rn+ss/2} H${xn.x1}`,"data-id":ue.id},`${Ot} (lasted through the break)`)),on=xn.x1);We>on&&je.push(it("rect",{class:dt,x:Math.max(-2,on),y:rn,width:Math.max(2,Math.min(D+2,We)-Math.max(-2,on)),height:ss,rx:2,"data-id":ue.id},Ot))}let kc=new Map;for(let ue of Ed){let $e=bo(ue.scope);if($e===void 0||!yr($e))continue;let Ue=Be(ue.t);if(Ue<-6||Ue>D+6||Ue-(kc.get($e)??-1/0)<3)continue;kc.set($e,Ue);let et=be[$e]+Is/2+2,We=4,dt=Jp[ue.severity],Ot=dt==="diamond"?`M${Ue} ${et-We-1} l${We+1} ${We+1} l${-We-1} ${We+1} l${-We-1} ${-We-1} z`:dt==="triangle"?`M${Ue} ${et-We-1} l${We+1} ${2*We+1} h${-2*We-2} z`:dt==="square"?`M${Ue-We+.5} ${et-We+.5} h${2*We-1} v${2*We-1} h${-2*We+1} z`:"",rn=`${_t(ue.t,t)} \xB7 ${ue.summary}`,ss=`tlx-mark sev-${ue.severity}${$?.id===ue.id?" selected":""}${w>=0&&O[w]?.id===ue.id?" hit":""}`;je.push(Ot?it("path",{class:ss,d:Ot,"data-id":ue.id},rn):it("circle",{class:ss,cx:Ue,cy:et,r:dt==="dot"?2.5:We,"data-id":ue.id},rn))}se.forEach((ue,$e)=>{if(ue.kind!=="metric"||!yr($e))return;let Ue=new Map;for(let nt of y?.metrics??[]){if(nt.series!==ue.series)continue;let Nt="value"in nt?{min:nt.value,max:nt.value,sum:nt.value,count:1}:{min:nt.min,max:nt.max,sum:nt.sum,count:nt.count},$t=Ue.get(nt.t);$t?($t.min=Math.min($t.min,Nt.min),$t.max=Math.max($t.max,Nt.max),$t.sum+=Nt.sum,$t.count+=Nt.count):Ue.set(nt.t,{...Nt})}let et=[...Ue].sort((nt,Nt)=>nt[0]-Nt[0]);if(!et.length)return;let We=he.kind==="binned"?hn[he.bin]:mo,dt=nt=>ue.type==="gauge"?nt.sum/Math.max(1,nt.count):nt.sum,Ot=Math.max(1e-9,...et.map(([,nt])=>ue.type==="gauge"?nt.max:dt(nt))),rn=be[$e]+ba-4,ss=ba-10,on=nt=>rn-nt/Ot*ss;if(ue.type==="gauge"){let nt=et.map(([Nt,$t])=>`${Be(Nt)},${on($t.max)}`).join(" ")+" "+[...et].reverse().map(([Nt,$t])=>`${Be(Nt)},${on($t.min)}`).join(" ");je.push(it("polygon",{class:"tlx-band",points:nt})),je.push(it("polyline",{class:"tlx-line",points:et.map(([Nt,$t])=>`${Be(Nt+We/2)},${on(dt($t))}`).join(" ")}))}else{let nt="",Nt=-1/0;for(let[$t,Td]of et){let Ad=Be($t),vc=Be($t+We),Sc=on(dt(Td));nt+=$t>Nt?`M${Ad} ${rn} V${Sc} H${vc}`:` V${Sc} H${vc}`,Nt=$t+We;let $c=et.find(([Od])=>Od>$t);(!$c||$c[0]>Nt)&&(nt+=` V${rn} Z`)}je.push(it("path",{class:"tlx-area",d:nt}))}let xn=it("text",{class:"tlx-peak",x:4,y:be[$e]+11});xn.textContent=`peak ${Xp(Ot,ue.unit)}${ue.type==="counter"?` per ${he.kind==="binned"?he.bin:"1m"}`:""}`,je.push(xn)});for(let ue of X.cuts){if(ue.weight>=1)continue;let $e=We=>{let dt=`M${We} 0`;for(let Ot=0;Ot<Ke;Ot+=8)dt+=` L${We+(Ot/8%2?-3:3)} ${Ot+8}`;return dt},Ue=it("g",{class:"tlx-cut",tabindex:0,role:"button","data-from":ue.from,"data-to":ue.to,"aria-label":`A break of ${Ps(ue.to-ue.from)} with nothing shown, from ${_t(ue.from,t)} to ${_t(ue.to,t)}: press to open it`},`${Ps(ue.to-ue.from)} with nothing here: ${_t(ue.from,t)} to ${_t(ue.to,t)} (click to open)`);Ue.append(it("rect",{class:"tlx-cut-bg",x:ue.x0,y:0,width:ue.x1-ue.x0,height:Ke})),Ue.append(it("path",{class:"tlx-cut-edge",d:$e(ue.x0+3)}),it("path",{class:"tlx-cut-edge",d:$e(ue.x1-3)}));let et=it("text",{class:"tlx-cut-label",x:(ue.x0+ue.x1)/2,y:15,"text-anchor":"middle"});et.textContent=Ps(ue.to-ue.from),Ue.append(et),je.push(Ue)}if(g!==void 0){let ue=Be(g);je.push(it("line",{class:"tlx-playhead",x1:ue,x2:ue,y1:0,y2:Ke})),je.push(it("path",{class:"tlx-handle",d:`M${ue-6} 0 h12 v8 l-6 7 l-6 -7 z`},`the playhead: ${_t(g,t)}`))}we.replaceChildren(...je),Ne.replaceChildren(re("div",{class:"tlx-labelhead",style:`height:${Hn}px`},de().kind==="single"?"single events":`per ${de().kind==="binned"?de().bin:""}`),...se.map(ue=>{if(ue.kind==="metric")return re("div",{class:"tlx-rowlabel metric",style:`height:${ba}px`,title:`${ue.title} (${ue.type==="counter"?"sums":"min, max and mean"})`},ue.title);let $e=ue.row,Ue=re("div",{class:`tlx-rowlabel${$e.own?" own":""}`,style:`height:${Is}px`,"data-scope":$e.scope,title:`${$e.scope||"all hosts"} \xB7 ${$e.count} event${$e.count===1?"":"s"}`},re("span",{class:"tlx-kind"},e.catalog.flags.find(et=>$e[et])??$e.kind),re("span",{class:"tlx-name"},$e.own?`${$e.label} (itself)`:$e.label),re("span",{class:"tlx-count"},String($e.count)));if(!$e.own&&$e.scope!==c){let et=re("button",{type:"button",class:"tlx-drill",title:$e.children?`Into ${$e.label}: its ${$e.children} part${$e.children===1?"":"s"}`:`Into ${$e.label}`,"aria-label":`Into ${$e.label}`},"\u203A");et.addEventListener("click",()=>Je($e.scope)),Ue.append(et)}return Ue})),Ne.style.width=`${Yp}px`,ie()}function ie(){H.replaceChildren(...hr(c).flatMap((be,ve,Ke)=>{let Ze=re("button",{type:"button",class:`tlx-crumb${ve===Ke.length-1?" current":""}`,"aria-current":ve===Ke.length-1?"location":void 0},z(be.scope,be.label));return Ze.addEventListener("click",()=>{be.scope!==c&&(c=be.scope,f=1,_(!0))}),ve?[re("span",{class:"tlx-sep","aria-hidden":"true"},"/"),Ze]:[Ze]})),ee.setAttribute("aria-pressed",String(h)),ee.classList.toggle("on",h),F.hidden=!h||v;let D=de(),se=y?.total??0,he=(y?.retention??[]).filter(be=>be.events!==null).map(be=>`${be.source} kept ${be.events} d`);Te.textContent=`${_t(m.t0,t)} \u2013 ${_t(m.t1,t)} \xB7 ${D.kind==="single"?"single events":`bins of ${D.bin}`} \xB7 ${se} event${se===1?"":"s"}${G.length?` \xB7 ${G.length} break${G.length===1?"":"s"}`:""}${he.length?` \xB7 ${he.slice(0,3).join(", ")}`:""}`,ae.hidden=!k.length,ae.textContent=k.join(" \xB7 "),W.textContent=u?O.length?`${w+1>0?`${w+1} of `:""}${O.length}${O.length>=2e3?"+":""} hit${O.length===1?"":"s"}`:`${se?`${se} hit${se===1?"":"s"}`:"no hits"}`:"";for(let be of Y.querySelectorAll(".seg"))be.classList.remove("on");ye.textContent=g===void 0?"":x?(()=>{let be=e.stamp?.(x)??{};return`Canvas: the state recorded at ${_t(Date.parse(be.at??"")||g,t)}${be.tag?` (${be.tag})`:""}`})():"No state recorded here",ye.classList.toggle("none",g!==void 0&&!x)}function Pe(){Le.replaceChildren();for(let D of a?.sources??[]){let se=!d.source?.length||d.source.includes(D.name),he=re("button",{type:"button",class:`tlx-chip${se?" on":""}${D.status==="not-yet"?" notyet":""}`,"aria-pressed":String(se&&D.status!=="not-yet"),disabled:D.status==="not-yet",title:D.status==="not-yet"?`${D.title}: not kept yet`:`${D.title}${Se(D)}`},D.name);D.status!=="not-yet"&&he.addEventListener("click",()=>xe(D.name)),Le.append(he)}}let Se=D=>{let se=a?.retention.find(he=>he.source===D.name);return se?` (kept ${se.events===null?"until deleted":`${se.events} days`})`:""};function xe(D){let se=(a?.sources??[]).filter(be=>be.status==="kept").map(be=>be.name),he=d.source?.length?[...d.source]:[...se];he=he.includes(D)?he.filter(be=>be!==D):[...he,D],d={...d,...he.length===se.length?{source:void 0}:{source:he}},d.source||delete d.source,Pe(),_(!0),ze()}let Ie=0;fe.addEventListener("input",()=>{clearTimeout(Ie),Ie=setTimeout(()=>{u=fe.value.trim(),w=-1,_(!0),ze()},250)}),fe.addEventListener("keydown",D=>{D.key==="Enter"&&(D.preventDefault(),clearTimeout(Ie),u=fe.value.trim(),_(!0).then(()=>ze()).then(()=>tt(D.shiftKey?-1:1)))});async function ze(){if(!u){O=[],w=-1,ie();return}let D=m.t1-m.t0;O=(await e.source.query(E(m.t0-D*4,Math.max(m.t1+D*4,me()),{kind:"single"},{limit:2e3}))).events??[],w=Math.min(w,O.length-1),ie()}function tt(D){if(!O.length)return;let se=(m.t0+m.t1)/2;w<0?w=D>0?Math.max(0,O.findIndex(ve=>ve.t>=se)):Math.max(0,O.length-1-[...O].reverse().findIndex(ve=>ve.t<=se)):w=(w+D+O.length)%O.length;let he=O[w],be=Math.min(m.t1-m.t0,2*Ls);m={t0:he.t-be/2,t1:he.t+be/2},v=!1,ut(he),_()}oe.addEventListener("click",()=>tt(-1)),Me.addEventListener("click",()=>tt(1)),C.addEventListener("change",()=>{let D=C.value;d={...d,...D?{severity:Wt.filter(se=>md(se)>=md(D))}:{}},D||delete d.severity,_(!0),ze()});async function Yn(D,se=!0){let he=me();if(D==="run"){let be=await e.source.query({timeline:1,type:"query",scope:c,depth:0,from:he-30*sn,to:he+1,filters:{kind:["run"]},limit:1e4}).catch(()=>{}),ve=be?.events?.[be.events.length-1];m=ve?{t0:ve.t-(ve.dur??Ls)*.02,t1:(ve.open?he:ve.t+(ve.dur??Ls))+(ve.dur??Ls)*.04}:{t0:he-sn,t1:he+sn*.02}}else m={t0:he-dd[D],t1:he+dd[D]*.02};v=!0,R.clear(),I.clear(),se&&_()}function ft(D,se=!0){if(h=D,P?.(),P=void 0,D&&e.source.subscribe){let he=0,be=0;P=e.source.subscribe(E(me()-Ls,me()+365*sn,{kind:"single"}),ve=>{if(a&&(a.now=Math.max(a.now,ve.now)),v){let Ze=m.t1-m.t0;m={t0:ve.now-Ze*.98,t1:ve.now+Ze*.02}}let Ke=Date.now();Ke-he>500?(he=Ke,_(!0)):be||(be=setTimeout(()=>{be=0,he=Date.now(),_(!0)},500))}),v=!0}se&&(ie(),ge())}ee.addEventListener("click",()=>ft(!h)),F.addEventListener("click",()=>{v=!0;let D=m.t1-m.t0,se=me();m={t0:se-D*.98,t1:se+D*.02},_()}),K.addEventListener("click",()=>{rt()}),q.addEventListener("change",()=>{b=q.checked,R.clear(),I.clear(),pe(),ge()}),ce.addEventListener("change",()=>{Z=ce.checked,pe(),ge()});function Je(D){let se=y?.rows.find(he=>he.scope===D);c=D,f=se&&se.children===0?0:1,T=void 0,qe.hidden=!0,_(!0)}async function rt(){let D=me(),he=((await e.source.query({timeline:1,type:"query",scope:c,depth:0,from:D-400*sn,to:D+1,bin:"1d",tz:t}).catch(()=>{}))?.bins??[]).map(ve=>ve.t),be=he.length?Math.min(...he):D-7*sn;m={t0:be,t1:D+(D-be)*.02},v=!0,_()}let bn=0;async function Et(D){if(g=D,pe(),D===void 0){x=void 0;return}let se=++bn,he=e.source.stateAt?await e.source.stateAt(c,D).catch(()=>{}):void 0;se===bn&&(x=he,e.onPlayhead?.(D,he),ie())}async function vt(D,se){T={from:Math.min(D,se),to:Math.max(D,se)},pe();let he=await e.source.query(E(T.from,T.to,{kind:"single"},{limit:500})),be=o(u),ve=je=>{let Be=[],xt=0;for(let[It,Xt]of uo(be,je))Be.push(je.slice(xt,It),re("mark",null,je.slice(It,Xt))),xt=Xt;return Be.push(je.slice(xt)),Be},Ke=(he.events??[]).map(je=>{let Be=re("tr",{"data-id":je.id,tabindex:"0"},re("td",null,_t(je.t,t)),re("td",null,je.dur!==void 0?gc(je.dur):je.open?"still going":""),re("td",null,je.source),re("td",null,je.kind),re("td",{class:`sev-${je.severity}`},je.severity),re("td",{class:"tlx-sum"},...ve(je.summary)),re("td",{class:"tlx-scope"},je.scope));return Be.addEventListener("click",()=>ut(je)),Be.addEventListener("keydown",xt=>{xt.key==="Enter"&&ut(je)}),Be}),Ze=re("button",{type:"button",class:"btn sm quiet","aria-label":"Close the table"},"Close");Ze.addEventListener("click",()=>{T=void 0,qe.hidden=!0,pe()});let Ln=je=>{let Be=re("button",{type:"button",class:"btn sm","data-export":je},je.toUpperCase());return Be.addEventListener("click",()=>{Tt(je)}),Be};qe.replaceChildren(re("div",{class:"tlx-table-head"},re("strong",null,`${he.total} event${he.total===1?"":"s"}`),re("span",null,` ${_t(T.from,t)} \u2013 ${_t(T.to,t)}${he.total>500?" (the first 500 shown; the export has them all)":""}`),re("span",{class:"spacer"}),re("span",null,"Export: "),Ln("json"),Ln("csv"),Ze),re("div",{class:"tlx-table-wrap"},re("table",null,re("thead",null,re("tr",null,...["When","Long","Source","Kind","Severity","What","Scope"].map(je=>re("th",{scope:"col"},je)))),re("tbody",null,...Ke)))),qe.hidden=!1}async function St(){if(!T)return[];let D=[],se;do{let he=await e.source.query(E(T.from,T.to,{kind:"single"},{limit:1e4,...se?{cursor:se}:{}}));D.push(...he.events??[]),se=he.next}while(se&&D.length<2e5);return D}async function Tt(D){let se=await St(),he=D==="json"?pa(se,B):ha(se,B),be=`timeline-${new Date(T.from).toISOString().slice(0,16).replace(/:/g,"")}.${D}`,ve=D==="json"?"application/json":"text/csv";if(e.onExport){e.onExport(be,he,ve);return}let Ke=re("a",{href:`data:${ve};charset=utf-8,${encodeURIComponent(he)}`,download:be});document.body.append(Ke),Ke.click(),Ke.remove()}function ut(D){if($=D,pe(),!D){De.hidden=!0;return}let se=a?.sources.find(Be=>Be.name===D.source),he=new Set(se?.sensitive??[]),be=o(u),ve=Be=>{let xt=[],It=0;for(let[Xt,go]of uo(be,Be))xt.push(Be.slice(It,Xt),re("mark",null,Be.slice(Xt,go))),It=go;return xt.push(Be.slice(It)),xt},Ke=(Be,xt)=>{if(!xt)return null;let It=re("button",{type:"button",class:"btn sm"},Be);return It.addEventListener("click",xt),It},Ze=Object.entries(D.attrs).map(([Be,xt])=>{if(!he.has(Be))return re("tr",null,re("th",{scope:"row"},Be),re("td",null,...ve(String(xt))));let It=re("button",{type:"button",class:"btn sm quiet",title:"This can name a remote host, a folder or free text"},"Show"),Xt=re("td",{class:"tlx-sensitive"},"hidden ",It);return It.addEventListener("click",()=>Xt.replaceChildren(String(xt))),re("tr",null,re("th",{scope:"row"},Be),Xt)}),Ln=re("button",{type:"button",class:"btn sm quiet tlx-close","aria-label":"Close"},"\xD7");Ln.addEventListener("click",()=>ut(void 0));let je=hr(D.scope).slice(1).map(Be=>{let xt=re("button",{type:"button",class:"tlx-crumb"},z(Be.scope,Be.label));return xt.addEventListener("click",()=>Je(Be.scope)),xt});De.replaceChildren(re("div",{class:"tlx-detail-head"},re("strong",null,D.kind),Ln),re("p",{class:`tlx-sev sev-${D.severity}`},`${D.severity} \xB7 ${se?.title??D.source}`),re("p",{class:"tlx-sum"},...ve(D.summary)),re("p",null,_t(D.t,t),D.dur!==void 0?` \xB7 ${gc(D.dur)}${D.open?" so far":""}`:D.open?" \xB7 still going":""),re("p",{class:"tlx-crumbs small"},...je),...Ze.length?[re("table",{class:"tlx-attrs"},re("tbody",null,...Ze))]:[],re("div",{class:"tlx-links"},...(e.actions?.(D)??[]).map(([Be,xt])=>Ke(Be,xt)))),De.hidden=!1}function Fs(D,se){let he=Cs({from:D,to:se});if(!G.find(Ze=>Ze.from===D&&Ze.to===se))return;if(R.add(he),!r){I.set(he,1),pe();return}let ve=performance.now(),Ke=Ze=>{let Ln=Math.min(1,(Ze-ve)/260);I.set(he,1-(1-Ln)**3),Re(),Ln<1&&requestAnimationFrame(Ke)};requestAnimationFrame(Ke)}let At,ys=D=>D.clientX-we.getBoundingClientRect().left;we.addEventListener("pointerdown",D=>{let se=ys(D),he=D.clientY-we.getBoundingClientRect().top,be=D.target.closest?.(".tlx-cut");if(be){D.preventDefault(),Fs(Number(be.getAttribute("data-from")),Number(be.getAttribute("data-to")));return}we.setPointerCapture(D.pointerId),At={kind:he<Hn||D.shiftKey?"brush":D.target.classList.contains("tlx-handle")?"scrub":"pan",x0:se,t0:X.t(se),v0:m,moved:!1},D.preventDefault(),Oe.focus({preventScroll:!0})}),we.addEventListener("pointermove",D=>{if(!At)return;let se=ys(D);if(Math.abs(se-At.x0)>3&&(At.moved=!0),!!At.moved)if(At.kind==="pan"){let he=(At.x0-se)*X.msPerPx;m={t0:At.v0.t0+he,t1:At.v0.t1+he},v=!1,_()}else At.kind==="scrub"?Et(X.t(se)):(T={from:Math.min(At.t0,X.t(se)),to:Math.max(At.t0,X.t(se))},pe())}),we.addEventListener("pointerup",D=>{let se=At;if(At=void 0,!se)return;let he=ys(D);if(se.kind==="brush"&&se.moved){vt(se.t0,X.t(he));return}if(se.kind==="brush"&&!se.moved){Et(X.t(he));return}if(se.kind==="pan"&&!se.moved){let be=D.target.closest?.("[data-id]")?.getAttribute("data-id"),ve=be?[...y?.events??[],...y?.spans??[]].find(Ke=>Ke.id===be):void 0;ve?(ut(ve),Et(ve.t)):Et(X.t(he))}}),we.addEventListener("keydown",D=>{let se=D.target.closest?.(".tlx-cut");se&&(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),Fs(Number(se.getAttribute("data-from")),Number(se.getAttribute("data-to"))))}),we.addEventListener("wheel",D=>{D.preventDefault();let se=ys(D);if(D.shiftKey||Math.abs(D.deltaX)>Math.abs(D.deltaY)){let he=(D.shiftKey?D.deltaY:D.deltaX)*X.msPerPx;m={t0:m.t0+he,t1:m.t1+he},v=!1}else Bs(X.t(se),Math.exp(D.deltaY*.0015),se/Qe());_()},{passive:!1});function Bs(D,se,he=.5){let be=Math.min(400*sn,Math.max(1e4,(m.t1-m.t0)*se));m={t0:D-he*be,t1:D+(1-he)*be},R.clear(),I.clear(),se<1&&(v=h&&m.t1>=me())}Oe.addEventListener("keydown",D=>{let se=m.t1-m.t0;if(D.key==="ArrowLeft"||D.key==="ArrowRight"){let he=se*.15*(D.key==="ArrowLeft"?-1:1);m={t0:m.t0+he,t1:m.t1+he},v=!1}else if(D.key==="+"||D.key==="=")Bs((m.t0+m.t1)/2,.6);else if(D.key==="-"||D.key==="_")Bs((m.t0+m.t1)/2,1/.6);else if(D.key==="n"||D.key==="N"){tt(D.shiftKey?-1:1),D.preventDefault();return}else if(D.key==="Escape")ut(void 0),T=void 0,qe.hidden=!0;else return;D.preventDefault(),_()}),n.addEventListener("keydown",D=>{D.key==="/"&&document.activeElement!==fe&&!D.target.closest("input, select, textarea")&&(D.preventDefault(),fe.focus())}),Fe.addEventListener("scroll",()=>pe(),{passive:!0}),te.addEventListener("click",async()=>{let D=`${hr(c).slice(-1)[0].label}${u?`: ${u}`:""}`.slice(0,80);await e.saveView?.({...Q(),name:D}),await yn()});let Ve=[];async function yn(){e.views&&(Ve=await e.views(),V.replaceChildren(re("option",{value:""},"Saved views\u2026"),...Ve.map((D,se)=>re("option",{value:String(se)},D.name))))}V.addEventListener("change",()=>{let D=Ve[Number(V.value)];D&&(ne(D),Pe(),_(!0)),V.value=""});let ot=typeof ResizeObserver=="function"?new ResizeObserver(()=>pe()):void 0;ot?.observe(Oe);let Gt=(async()=>{a=await e.source.catalog(),B=a.sources.flatMap(be=>(be.sensitive??[]).map(ve=>`${be.name}.${ve}`));for(let be of a.sources)for(let ve of be.series)U.set(ve.name,{unit:ve.unit,type:ve.type,title:ve.title,source:be.name});c=a.hosts.length===1?`host:${a.hosts[0].replace(/[%/:\s]/g,be=>`%${be.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`)}`:"";let se=a.now;m={t0:se-sn,t1:se+sn*.02};let he=ke()??e.view;he&&ne(he),Pe(),await yn(),await _(!0),u&&await ze()})();return{el:n,ready:Gt,get view(){return Q()},setView(D){return ne(D),Pe(),_(!0)},setRange(D,se){return m={t0:D,t1:se},v=!1,_()},setPlayhead:Et,setLive:ft,setTheme:l,refresh:()=>_(!0),internal:{get result(){return y},get mode(){return de()},get scale(){return X},get gaps(){return G},get playState(){return x},get hits(){return O},get selected(){return $},get follow(){return v},openCut:Fs,showTable:vt,rangeEvents:St,exportRange:Tt,select:ut,stepHit:tt,drill:Je,findHits:ze,paint:Re,lines:S},dispose(){P?.(),ot?.disconnect(),A&&cancelAnimationFrame(A),n.replaceChildren()}}}var Qp={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}},zt=n=>(Math.round(n*10)/10).toString(),hd=n=>(n??"link").replace(/[^\w-]/g,"_");function ya(n,e){let{id:t}=e,s=e.styles??{},r=n.options,o=n.bounds,i=new Map,l=(h,b)=>{let m=s[h]??{},y=b==="start"?m.start??"none":m.end??"arrow";if(y!=="none")return(i.get(h)??i.set(h,new Set).get(h)).add(y),`url(#${t}-mk-${h}-${y})`},a="",c="",f="",u="";for(let h of[...n.panels].sort((b,m)=>b.depth-m.depth)){let b=h.rect,m=h.label?Ee("text",{class:"pl",x:h.titleAt[0],y:h.titleAt[1]},mt(h.label)+(h.sub?Ee("tspan",{class:"pls",dx:10},mt(h.sub)):"")):"";a+=Ee("g",{class:`panel k-${h.role??"grey"}`,"data-id":h.id},Ee("rect",{class:"face",x:zt(b.l),y:zt(b.t),width:zt(b.r-b.l),height:zt(b.b-b.t),rx:r.panelRx})+m)}for(let h of n.links){if(!h.points.length)continue;let b=hd(h.kind);c+=Ee("path",{class:`conn k-${b}`,d:"M"+h.points.map(m=>`${zt(m[0])},${zt(m[1])}`).join(" L"),"data-id":h.id,"data-a":h.a,"data-b":h.b,"marker-start":l(b,"start"),"marker-end":l(b,"end")}),h.at&&(u+=Ee("text",{class:`cl k-${b}`,x:h.at.x,y:h.at.y,"text-anchor":h.at.anchor==="start"?void 0:h.at.anchor,"data-for":h.id},mt(h.at.text)))}for(let h of n.cards){let b=h.rect;f+=Ee("g",{class:`card k-${h.role??"grey"}${h.ghost?" ghost":""}`,"data-id":h.id,tabindex:0,role:"button","aria-label":h.sub?`${h.label}: ${h.sub}`:h.label},Ee("rect",{class:"face",x:zt(b.l),y:zt(b.t),width:r.W,height:r.H,rx:r.cardRx})+Ee("text",{class:"lt",x:zt(b.l+14),y:zt(b.t+24)},mt(h.label))+(h.sub?Ee("text",{class:"st",x:zt(b.l+14),y:zt(b.t+42)},mt(h.sub)):""))}let d="";for(let[h,b]of i)for(let m of b){let y=Qp[m];d+=Ee("marker",{id:`${t}-mk-${h}-${m}`,viewBox:"0 0 10 10",refX:y.refX,refY:5,markerWidth:5.4,markerHeight:5.4,orient:"auto-start-reverse"},Ee("path",{d:y.d,class:`mk k-${h}`}))}return Ee("svg",{xmlns:"http://www.w3.org/2000/svg",class:"flat",viewBox:`${zt(o.l)} ${zt(o.t)} ${zt(o.r-o.l)} ${zt(o.b-o.t)}`,role:"img","aria-label":e.title??"drawing, flat view","data-view":"2d"},(d?Ee("defs",{},d):"")+Ee("g",{class:"panels"},a)+Ee("g",{class:"conns"},c)+Ee("g",{class:"cards"},f)+Ee("g",{class:"labels"},u))}function gd(n={}){let e=s=>s?s.startsWith("#")||s.includes("(")?s:`var(--${s})`:"var(--ink)",t=`
|
|
360
406
|
.flat{font-family:inherit}
|
|
361
407
|
.flat .card{cursor:pointer;outline:none}
|
|
362
408
|
.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}
|
|
@@ -374,8 +420,8 @@ ${e.extraBody??""}
|
|
|
374
420
|
.flat .panel.sel .face{stroke:var(--accent,#2f6fd6);stroke-width:2}
|
|
375
421
|
.flat .conn.hot{stroke-width:3}
|
|
376
422
|
.flat .conn.dim,.flat .cl.dim{opacity:.3}
|
|
377
|
-
`;for(let[s,r]of Object.entries(
|
|
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=`
|
|
423
|
+
`;for(let[s,r]of Object.entries(n)){let o=hd(s),i=e(r.color);t+=`.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}}
|
|
424
|
+
`}return t}var Zp={name:["card","lt"],sub:["card","st"],title:["panel","pl"],titleSub:["panel","pls"],label:["","cl"]};function xa(n){let e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"svg");t.setAttribute("class","flat"),t.setAttribute("aria-hidden","true"),t.style.cssText="position:absolute;left:-10000px;top:0;width:10px;height:10px;visibility:hidden",n.appendChild(t);let s={};for(let[i,[l,a]]of Object.entries(Zp)){let c=document.createElementNS(e,"g");l&&c.setAttribute("class",l);let f=document.createElementNS(e,"text");f.setAttribute("class",a),c.appendChild(f),t.appendChild(c),s[i]=f}let r=new Map,o=((i,l)=>{let a=l+"\0"+i,c=r.get(a);return c===void 0&&(s[l].textContent=i,c=s[l].getComputedTextLength(),r.set(a,c)),c});return o.dispose=()=>t.remove(),o}var bd=(n,e)=>n.cards.find(t=>t.id===e)?.rect??n.panels.find(t=>t.id===e)?.rect;var bs="http://www.w3.org/2000/svg";function ka(n,e,t){let s=new Map((t?.links??[]).map((r,o)=>[r.id??`link-${o}`,r]));for(let r of e.routes){let o=s.get(r.id),i=o?.a??Zt(r.raw.from).id,l=o?.b??Zt(r.raw.to).id;for(let a of n.querySelectorAll(`[data-id="${CSS.escape(r.id)}"]`))a.setAttribute("data-a",i),a.setAttribute("data-b",l)}}var eh=(n="auto")=>n==="always"||n==="auto"&&!(typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches);function wd(n,e,t,s,r={}){let o=r.duration??600;if(!o||!eh(r.motion))return;let i=ho(n,e,t,s);n.appendChild(i.svg),i.at(0);let l=0,a=!1,c,f=new Promise(b=>c=b),u=()=>{a||(a=!0,cancelAnimationFrame(l),i.svg.remove(),c())},d=performance.now(),h=b=>{if(a)return;let m=Math.min(1,(b-d)/o);i.at(m),m<1?l=requestAnimationFrame(h):u()};return l=requestAnimationFrame(h),{done:f,finish:u}}var ns=n=>Math.max(0,Math.min(1,n)),po=n=>n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2;function wa(n){let e=n.cloneNode(!0),t=[n,...n.querySelectorAll("*")],s=[e,...e.querySelectorAll("*")];return t.forEach((r,o)=>{let i=getComputedStyle(r),l=s[o];l.removeAttribute("class"),l.removeAttribute("tabindex");for(let a 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"])l.style.setProperty(a,i.getPropertyValue(a))}),e}var xc=(n,e)=>{let t=n.getBoundingClientRect();return{x:t.left-e.left,y:t.top-e.top,w:t.width,h:t.height}},yd=n=>{let e=Math.min(...n.map(o=>o.x)),t=Math.min(...n.map(o=>o.y)),s=Math.max(...n.map(o=>o.x+o.w)),r=Math.max(...n.map(o=>o.y+o.h));return{x:e,y:t,w:s-e,h:r-t}},th=(n,e)=>{let t=n.getScreenCTM();return`matrix(${t.a} ${t.b} ${t.c} ${t.d} ${t.e-e.left} ${t.f-e.top})`},xd=(n,e,t)=>{let s=1+(e.w/Math.max(n.w,1e-6)-1)*t,r=1+(e.h/Math.max(n.h,1e-6)-1)*t,o=(e.x-n.x*(e.w/Math.max(n.w,1e-6)))*t,i=(e.y-n.y*(e.h/Math.max(n.h,1e-6)))*t;return`matrix(${s} 0 0 ${r} ${o} ${i})`};function nh(n,e){let t=n.querySelector("polygon.top");if(!t)return;let s=t.getScreenCTM(),r=[];for(let o=0;o<t.points.numberOfItems;o++){let i=t.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(t).fill}:void 0}function ho(n,e,t,s){let r=n.getBoundingClientRect(),o=document.createElementNS(bs,"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,t.getBoundingClientRect().height)}px;overflow:visible;pointer-events:none`;let i=$=>{let T=document.createElementNS(bs,"g");return T.setAttribute("transform",th($,r)),T},l=$=>$.hasAttribute("data-a")||$.hasAttribute("data-for"),a=$=>{let T=new Map;for(let v of $.querySelectorAll("[data-id]")){if(l(v)||v.parentElement?.closest("[data-id]")||v.closest(".overlay"))continue;let A=v.getAttribute("data-id");(T.get(A)??T.set(A,[]).get(A)).push(v)}return T},c=a(e),f=a(t),u=document.createElementNS(bs,"g"),d=document.createElementNS(bs,"g"),h=i(e),b=i(t);for(let $ of e.querySelectorAll("[data-a],[data-for]"))$.closest(".overlay")||h.appendChild(wa($));for(let $ of t.querySelectorAll("[data-a],[data-for]"))$.closest(".overlay")||b.appendChild(wa($));u.appendChild(h),d.appendChild(b);let m=[...b.querySelectorAll("path")].map($=>{let T=$.getTotalLength?.()??0;return{p:$,len:T}}),y=[...b.children].filter($=>$.tagName.toLowerCase()==="text"),N=[...(s==="2d"?c:f).keys()],p=[],g=document.createElementNS(bs,"g");for(let $ of new Set([...N,...c.keys(),...f.keys()])){let T=c.get($),v=f.get($),A={};if(T){A.a=yd(T.map(R=>xc(R,r)));let O=document.createElementNS(bs,"g"),w=i(e);for(let R of T)w.appendChild(wa(R));O.appendChild(w),A.src=O}if(v){A.b=yd(v.map(R=>xc(R,r)));let O=document.createElementNS(bs,"g"),w=i(t);for(let R of v)w.appendChild(wa(R));O.appendChild(w),A.dst=O}let L=s==="3d"?T?.[0]:v?.[0],M=s==="3d"?v?.[0]:T?.[0],P=L?nh(L,r):void 0,k=M?.querySelector("rect.face");if(P&&k){let O=xc(k,r),w=[[O.x,O.y],[O.x+O.w,O.y],[O.x+O.w,O.y+O.h],[O.x,O.y+O.h]],R=P.pts.reduce((B,H,Y)=>H[0]<P.pts[B][0]?Y:B,0),I=[...P.pts.slice(R),...P.pts.slice(0,R)],G=[I[0],I[1],I[2],I[3]],X=getComputedStyle(k).fill,U=document.createElementNS(bs,"polygon");A.face=U,A.faceFrom=s==="3d"?G:w,A.faceTo=s==="3d"?w:G,A.faceFill=s==="3d"?[P.fill,X]:[X,P.fill]}A.src&&g.appendChild(A.src),A.face&&g.appendChild(A.face),A.dst&&g.appendChild(A.dst),p.push(A)}o.append(u,g,d);let x=($,T,v)=>`color-mix(in srgb, ${$} ${Math.round((1-v)*100)}%, ${T})`;return{svg:o,at($){let T=ns($/.2),v=po(ns(($-.2)/.6)),A=ns(($-.8)/.2);u.setAttribute("opacity",String(1-T));for(let{p:L,len:M}of m)L.style.strokeDasharray=`${M} ${M}`,L.style.strokeDashoffset=String(M*(1-A));d.setAttribute("opacity",String(A>0?1:0));for(let L of y)L.style.opacity=String(A);for(let L of p)if(L.src&&(L.src.setAttribute("transform",L.a&&L.b?xd(L.a,L.b,v):""),L.src.setAttribute("opacity",String(L.b?1-ns(v/(L.face?.35:.6)):1-v))),L.dst&&(L.dst.setAttribute("transform",L.a&&L.b?xd(L.b,L.a,1-v):""),L.dst.setAttribute("opacity",String(L.a?ns((v-(L.face?.65:.4))/(L.face?.35:.6)):v))),L.face){let M=L.faceFrom.map((P,k)=>[P[0]+(L.faceTo[k][0]-P[0])*v,P[1]+(L.faceTo[k][1]-P[1])*v]);L.face.setAttribute("points",M.map(P=>P.join(",")).join(" ")),L.face.style.fill=x(L.faceFill[0],L.faceFill[1],v),L.face.setAttribute("opacity",String(v<.08?v/.08:v>.92?(1-v)/.08:1))}}}}var sh=0;function kd(n,e,t={}){let s=`dv${++sh}`,r=document.createElement("div");r.className="dual-view",r.style.position="relative",n.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 l=o.querySelector("svg");l.setAttribute("data-view","3d");let a=t.board??Xi(e);ka(l,e,a);let c=new Set(e.routes.map(M=>M.id));for(let M of l.querySelectorAll("g[data-id]")){let P=M.getAttribute("data-id");c.has(P)||M.hasAttribute("tabindex")||!M.querySelector("polygon")||(M.setAttribute("tabindex","0"),M.setAttribute("role","button"),M.setAttribute("aria-label",P))}let f=xa(i),u=dr(a,f,t.flat);f.dispose(),i.innerHTML=ya(u,{id:s,title:t.title,styles:t.styles});let d=i.querySelector("svg");for(let M of[l,d])M.style.display="block",M.style.width="100%",M.style.height="auto";t.title&&l.setAttribute("aria-label",t.title);let h=t.mode??"3d",b,m=M=>M==="3d"?o:i,y=M=>M==="3d"?l:d,N=M=>{o.hidden=M!=="3d",i.hidden=M!=="2d";for(let P of[o,i])P.style.cssText="";r.style.height="",r.dataset.mode=M};N(h);let p=()=>{for(let M of[l,d]){for(let P of M.querySelectorAll("[data-id]"))P.classList.toggle("sel",!!b&&P.getAttribute("data-id")===b);for(let P of M.querySelectorAll("[data-a]")){let k=!!b&&(P.getAttribute("data-a")===b||P.getAttribute("data-b")===b);P.classList.toggle("hot",k),P.classList.toggle("dim",!!b&&!k),M.querySelector(`[data-for="${CSS.escape(P.getAttribute("data-id")??"")}"]`)?.classList.toggle("dim",!!b&&!k)}}},g=M=>{b=M,p()},x=M=>{let P=M.target.closest?.("[data-id]");if(!P||!r.contains(P)||P.hasAttribute("data-a"))return;let k=P.getAttribute("data-id");g(k),t.onSelect?.(k)},$=M=>{(M.key==="Enter"||M.key===" ")&&M.target.matches?.("[data-id][tabindex]")&&(M.preventDefault(),x(M))};r.addEventListener("click",x),r.addEventListener("keydown",$);let T,v=()=>{if(!T)return;cancelAnimationFrame(T.frame),T.layer.remove();let M=T;T=void 0,h=M.to,N(h),p(),M.done()},A=M=>{!M||!b||y(h).querySelector(`[data-id="${CSS.escape(b)}"][tabindex]`)?.focus({preventScroll:!0})};return{get mode(){return T?T.to:h},layout:u,root:r,morph:M=>{let P=r.contains(document.activeElement);if(T&&v(),M===h)return A(P),Promise.resolve();let k=t.motion??"auto";return k==="never"||k==="auto"&&typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches||!(t.duration??600)?(h=M,N(h),p(),A(P),Promise.resolve()):new Promise(w=>{let R=h,I=r.getBoundingClientRect().height;o.hidden=!1,i.hidden=!1;for(let ee of[o,i])ee.style.cssText="position:absolute;left:0;top:0;right:0;visibility:hidden";let G=m(M).getBoundingClientRect().height;r.style.height=`${I}px`;let X=ho(r,y(R),y(M),R);r.appendChild(X.svg);let U=t.duration??600,B=performance.now(),H={frame:0,layer:X.svg,to:M,done:()=>{A(P),w()}},Y=ee=>{if(T!==H)return;let F=Math.min(1,(ee-B)/U);X.at(F),r.style.height=`${I+(G-I)*po(ns((F-.2)/.6))}px`,F<1?H.frame=requestAnimationFrame(Y):v()};T=H,H.frame=requestAnimationFrame(Y)})},select:g,get selected(){return b},svgOf:y,destroy(){T&&v(),r.removeEventListener("click",x),r.removeEventListener("keydown",$),r.remove()}}}function vd(n="iso-view"){try{let e=localStorage.getItem(n);return e==="2d"||e==="3d"?e:void 0}catch{return}}function Sd(n,e,t={}){let s=t.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((a,c)=>{let f=document.createElement("button");return f.type="button",f.dataset.mode=a,f.textContent=(t.labels??["3D","2D"])[c],f.addEventListener("click",()=>{try{localStorage.setItem(s,a)}catch{}l(a);for(let u of r)u.morph(a)}),o.appendChild(f),f}),l=a=>i.forEach(c=>c.setAttribute("aria-pressed",String(c.dataset.mode===a)));return l(r[0]?.mode??"3d"),n.appendChild(o),o}var $d=`
|
|
379
425
|
.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
426
|
.view-switch button{font:inherit;border:0;background:none;color:var(--ink);padding:6px 10px;cursor:pointer}
|
|
381
427
|
.view-switch button+button{border-left:1px solid var(--line)}
|
|
@@ -385,4 +431,4 @@ ${e.extraBody??""}
|
|
|
385
431
|
.dual-view .blk.sel polygon{stroke:var(--accent,#2f6fd6);stroke-width:2.4}
|
|
386
432
|
.dual-view [data-a].dim{opacity:.3}
|
|
387
433
|
.dual-view [data-a].hot path{stroke-width:3.4}
|
|
388
|
-
`;export{
|
|
434
|
+
`;export{Pf as core,Cu as objects,Md as viewer};
|